nextclaw 0.16.21 → 0.16.23
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 +84 -8
- package/package.json +11 -11
- package/templates/USAGE.md +12 -4
- package/ui-dist/assets/{ChannelsList-C63gOoYI.js → ChannelsList-BlQD1VuM.js} +4 -4
- package/ui-dist/assets/ChatPage-DBvm558n.js +37 -0
- package/ui-dist/assets/{DocBrowser-CI4jOzJY.js → DocBrowser-DTww3NZc.js} +1 -1
- package/ui-dist/assets/{LogoBadge-DImV63-L.js → LogoBadge-D0ogG1ut.js} +1 -1
- package/ui-dist/assets/{MarketplacePage-B360oSAV.js → MarketplacePage-DTHw6n0X.js} +1 -1
- package/ui-dist/assets/{McpMarketplacePage-KIQgx_7h.js → McpMarketplacePage-BikE0mBl.js} +2 -2
- package/ui-dist/assets/{ModelConfig-Ben3tQoX.js → ModelConfig-CvM__Pz1.js} +1 -1
- package/ui-dist/assets/{ProvidersList-DE-S9mq0.js → ProvidersList-DtZWZlL0.js} +1 -1
- package/ui-dist/assets/RemoteAccessPage-E5fT1pem.js +1 -0
- package/ui-dist/assets/RuntimeConfig-DyZNiqYT.js +1 -0
- package/ui-dist/assets/{SearchConfig-DeOa-M6j.js → SearchConfig-C1bhOCNX.js} +1 -1
- package/ui-dist/assets/{SecretsConfig-Ci8pJmzd.js → SecretsConfig-CYmy1Sqy.js} +2 -2
- package/ui-dist/assets/{SessionsConfig-B6zq55yu.js → SessionsConfig-DSlhPpIE.js} +2 -2
- package/ui-dist/assets/{chat-session-display--oo5yuIw.js → chat-session-display-D9YuDGe3.js} +1 -1
- package/ui-dist/assets/index-BBz4mi7g.js +8 -0
- package/ui-dist/assets/{index-Bro-iRcb.css → index-CfVmBgkf.css} +1 -1
- package/ui-dist/assets/{label-3TKt0PoZ.js → label-C7Xd_hqz.js} +1 -1
- package/ui-dist/assets/{page-layout-CopkIM3Q.js → page-layout-VxCaUcrD.js} +1 -1
- package/ui-dist/assets/{popover-CUx8uRJw.js → popover-CC4znqAM.js} +1 -1
- package/ui-dist/assets/security-config-7eVxJq8b.js +1 -0
- package/ui-dist/assets/skeleton-DhZRDdHm.js +1 -0
- package/ui-dist/assets/{status-dot-D6vJMwD7.js → status-dot-Bi7Ze-LS.js} +1 -1
- package/ui-dist/assets/{switch-A3-ClT1P.js → switch-COBEivEX.js} +1 -1
- package/ui-dist/assets/{tabs-custom-BVSd5urq.js → tabs-custom-B9j40wuu.js} +1 -1
- package/ui-dist/assets/{useConfirmDialog-ChPriea6.js → useConfirmDialog-N8nuxOq-.js} +1 -1
- package/ui-dist/assets/{vendor-BEQcLDx6.js → vendor-MCpnpiKt.js} +35 -35
- package/ui-dist/index.html +3 -3
- package/ui-dist/assets/ChatPage-Ci3Gz0qh.js +0 -37
- package/ui-dist/assets/RemoteAccessPage-DxUia6R-.js +0 -1
- package/ui-dist/assets/RuntimeConfig-CQcGfNZT.js +0 -1
- package/ui-dist/assets/index-LhlkB00c.js +0 -8
- package/ui-dist/assets/security-config-BL29kTzz.js +0 -1
- package/ui-dist/assets/skeleton-Bs4zvcql.js +0 -1
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
var $a=Object.defineProperty;var qa=(e,t,n)=>t in e?$a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var te=(e,t,n)=>qa(e,typeof t!="symbol"?t+"":t,n);import{r as k,j as d,ae as Hi,v as mt,X as Ka,af as Wa,f as Qa,e as at,d as Fn,t as Ga,c as Xa,y as Ya,z as Ja,h as Vi,I as Za,i as Dt,n as el,o as Ui,V as tl,q as $i,s as nl,w as rl,k as qi,l as il,m as Ki,a as sl,ag as al,B as On,G as _n,ah as ll,ai as ol,aj as ul,F as cl,ak as hl,al as dl,_ as fl,am as Wi,an as Qi,ao as pl,ap as ml,aq as gl,ar as xl,as as yl,at as bl,au as Sl,av as kl,aw as wl,A as zn,ax as Cl,a0 as vl,a3 as Tl,a1 as Il,a2 as Ml,M as Nl,ay as Gi,az as El,aA as Ll,aB as Al,u as jl,a4 as Rl,aC as Pl,aD as Dl}from"./vendor-BEQcLDx6.js";import{t as v,c as ve,I as Bn,B as Re,i as Ft,j as Xi,k as Fl,l as Yi,m as Ol,n as _l,o as Hn,p as zl,T as gr,L as xr,q as Bl,r as yr,s as Hl,v as br,h as lt,A as Ji,w as Vl,x as Ul,y as $l,z as ql,S as Kl,e as Wl,f as Ql,g as Gl,C as Xl,E as Yl,F as Jl,u as Zl,a as eo,G as to,H as no,J as Sr,K as ro}from"./index-LhlkB00c.js";import{T as io,a as so,b as ao,c as lo,P as oo,R as uo,d as co,e as ho,C as Zi,M as fo,u as po}from"./MarketplacePage-B360oSAV.js";import{R as mo,A as go,P as xo,C as es,T as yo,a as bo,b as So,c as ko}from"./popover-CUx8uRJw.js";import{S as wo,a as ts,b as Co,c as kr,s as vo}from"./chat-session-display--oo5yuIw.js";import{u as ns}from"./useConfirmDialog-ChPriea6.js";import{P as To,a as Io}from"./page-layout-CopkIM3Q.js";import{b as Mo,c as No,r as Eo}from"./provider-models-BOeNnjk9.js";import"./tabs-custom-BVSd5urq.js";import"./skeleton-Bs4zvcql.js";import"./marketplace-localization-Dk31LJJJ.js";var ee=(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))(ee||{}),wr=/\[\[\s*reply_to_current\s*\]\]/gi,Cr=/\[\[\s*reply_to\s*:\s*([^\]]+?)\s*\]\]/i;function Sn(e){if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}function Lo(e,t){var s;let n=e,r;wr.test(n)&&(r=Sn(t),n=n.replace(wr,"").trim());const i=(s=n.match(Cr))==null?void 0:s[1];return i&&(r=Sn(i),n=n.replace(Cr,"").trim()),r?{content:n,replyTo:r}:{content:n}}function Ao(e,t=e.id){if(e.role!=="assistant")return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0};const n=e.parts.findIndex(h=>h.type==="text"),r=e.metadata?{...e.metadata}:void 0,i=Sn(r==null?void 0:r.reply_to);if(n<0)return{...e,parts:[...e.parts],metadata:r};const s=e.parts[n];if(!s||s.type!=="text")return{...e,parts:[...e.parts],metadata:r};const{content:a,replyTo:l}=Lo(s.text,t),o=l??i,u=e.parts.flatMap((h,c)=>c!==n||h.type!=="text"?[h]:a.length===0?[]:[{...h,text:a}]);return o?{...e,parts:u,metadata:{...r,reply_to:o}}:{...e,parts:u,metadata:r}}function vr(e){const t=e.split(/\r?\n/);let n="message";const r=[];for(const i of t){const s=i.trimEnd();if(!(!s||s.startsWith(":"))){if(s.startsWith("event:")){n=s.slice(6).trim()||"message";continue}s.startsWith("data:")&&r.push(s.slice(5).trimStart())}}return r.length===0?null:{event:n,data:r.join(`
|
|
2
|
-
`)}}async function*jo(e){const t=e.getReader(),n=new TextDecoder;let r="";try{for(;;){const{value:s,done:a}=await t.read();if(a)break;r+=n.decode(s,{stream:!0});const{frames:l,rest:o}=Tr(r);r=o;for(const u of l)yield u}r+=n.decode();const{frames:i}=Tr(r,!0);for(const s of i)yield s}finally{t.releaseLock()}}function Tr(e,t=!1){const n=e.split(/\r?\n\r?\n/),r=n.pop()??"",i=[];for(const s of n){const a=vr(s);a&&i.push(a)}if(t&&r.trim()){const s=vr(r);return s&&i.push(s),{frames:i,rest:""}}return{frames:i,rest:r}}var Ir="/ncp/agent",Ro="ncp-http-agent-client",rs=class extends Error{constructor(t,n=!1){super(t.message);te(this,"ncpError");te(this,"alreadyPublished");this.name=`NcpHttpAgentClientError(${t.code})`,this.ncpError=t,this.alreadyPublished=n}};function Po(e){const t=e.trim();if(!t)throw new Error("NcpHttpAgentClient requires a non-empty baseUrl.");return new URL(t)}function Do(e){if(e)return e;if(typeof globalThis.fetch=="function")return globalThis.fetch.bind(globalThis);throw new Error("No fetch implementation found. Pass options.fetchImpl explicitly.")}function Fo(e){const t=(e??Ir).trim();if(!t)return Ir;const n=t.startsWith("/")?t:`/${t}`;return n.endsWith("/")?n.slice(0,-1):n}async function Mr(e){try{return(await e.text()).trim()}catch{return""}}function Nr(e){if(is(e))return e.ncpError;if(Oo(e))return e;const t=e instanceof Error?e.message:String(e??"Unknown error");return{code:ss(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function Wt(e,t={}){return new rs(e,t.alreadyPublished??!1)}function Oo(e){return Vn(e)&&typeof e.code=="string"&&typeof e.message=="string"}function Vn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function is(e){return e instanceof rs}var _o={"config-error":"config-error","auth-error":"auth-error","runtime-error":"runtime-error","timeout-error":"timeout-error","abort-error":"abort-error"};function ss(e){if(!e)return"runtime-error";const t=_o[e];if(t)return t;const 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 zo(e){const t=as(e);return!t||typeof t.type!="string"||!t.type.trim()?null:t}function Bo(e){const t=as(e);if(!t)return{code:"runtime-error",message:e||"Unknown stream error."};const n=typeof t.code=="string"?t.code:void 0,r=ss(n),i=Vn(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 as(e){try{const t=JSON.parse(e);return Vn(t)?t:null}catch{return null}}var Ho=["text","file","source","step-start","reasoning","tool-invocation","card","rich-text","action","extension"],Vo=class{constructor(e){te(this,"manifest");te(this,"baseUrl");te(this,"basePath");te(this,"fetchImpl");te(this,"defaultHeaders");te(this,"subscribers",new Set);te(this,"activeControllers",new Set);te(this,"started",!1);var t;this.baseUrl=Po(e.baseUrl),this.basePath=Fo(e.basePath),this.fetchImpl=Do(e.fetchImpl),this.defaultHeaders=e.headers??{},this.manifest={endpointKind:"custom",endpointId:((t=e.endpointId)==null?void 0:t.trim())||Ro,version:"0.1.0",supportsStreaming:!0,supportsAbort:!0,supportsProactiveMessages:!1,supportsLiveSessionStream:!0,supportedPartTypes:Ho,expectedLatency:"seconds",metadata:{transport:"http+sse",scope:"agent"}}}async start(){this.started||(this.started=!0,this.publish({type:ee.EndpointReady}))}async stop(){if(this.started){this.started=!1;for(const 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();const t=new URLSearchParams({sessionId:e.sessionId});await this.streamRequest({path:`/stream?${t.toString()}`,method:"GET"})}async abort(e){await this.ensureStarted();const t=new AbortController;this.activeControllers.add(t);try{const 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 new Error(`Abort request failed with HTTP ${n.status}: ${await Mr(n)}`)}catch(n){if(t.signal.aborted)return;const r=Nr(n);throw this.publish({type:ee.EndpointError,payload:r}),Wt(r)}finally{this.activeControllers.delete(t)}}async ensureStarted(){this.started||await this.start()}publish(e){for(const t of this.subscribers)t(e)}resolveUrl(e){return new URL(`${this.basePath}${e}`,this.baseUrl)}async streamRequest(e){const t=new AbortController;this.activeControllers.add(t);try{const 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 new Error(`NCP stream request failed with HTTP ${n.status}: ${await Mr(n)}`);if(!n.body)throw new Error("NCP stream response has no body.");for await(const r of jo(n.body)){if(t.signal.aborted)return;this.handleSseFrame(r)}}catch(n){if(t.signal.aborted)return;if(is(n))throw n;const r=Nr(n);throw this.publish({type:ee.EndpointError,payload:r}),Wt(r)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event==="ncp-event"){const t=zo(e.data);if(!t){this.publish({type:ee.EndpointError,payload:{code:"runtime-error",message:"Received malformed ncp-event frame."}});return}this.publish(t);return}if(e.event==="error"){const t=Bo(e.data);throw this.publish({type:ee.EndpointError,payload:t}),Wt(t,{alreadyPublished:!0})}}};function ls(e){return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0}}function Qt(e){return ls(Ao(e))}function Uo(e){var n;const t=(n=e.error)==null?void 0:n.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 $o(e,t){return t.trim()?e.id.startsWith("tool-")?!0:e.parts.some(n=>n.type==="tool-invocation"):!1}function qo(e,t,n){for(const[r,i]of e)i===t&&e.set(r,n)}function Gt(e,t,n){for(const[r,i]of e)i===n&&(e.delete(r),t.delete(r))}function kn(e,t){for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(r.type==="tool-invocation"&&r.toolCallId===t)return r}return null}function Er(e,t){const n=kn(e,t);return(n==null?void 0:n.toolName)??null}function et(e,t){const n=[...e];for(let r=n.length-1;r>=0;r-=1){const i=n[r];if(i.type==="tool-invocation"&&i.toolCallId===t.toolCallId)return n[r]={...i,...t},n}return n.push(t),n}var Ko="assistant",Wo=class{constructor(){te(this,"messages",[]);te(this,"streamingMessage",null);te(this,"error",null);te(this,"activeRun",null);te(this,"listeners",new Set);te(this,"toolCallMessageIdByCallId",new Map);te(this,"toolCallArgsRawByCallId",new Map);te(this,"snapshotCache",null);te(this,"snapshotVersion",-1);te(this,"stateVersion",0)}getSnapshot(){if(this.snapshotCache&&this.snapshotVersion===this.stateVersion)return this.snapshotCache;const 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){return 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.stateVersion+=1,this.notifyListeners())}hydrate(e){this.messages=e.messages.map(t=>Qt(t)),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.stateVersion+=1,this.notifyListeners()}async dispatch(e){const t=this.stateVersion;switch(e.type){case ee.MessageSent:this.handleMessageSent(e.payload);break;case ee.MessageAbort:this.handleMessageAbort(e.payload);break;case ee.MessageTextStart:this.handleMessageTextStart(e.payload);break;case ee.MessageTextDelta:this.handleMessageTextDelta(e.payload);break;case ee.MessageTextEnd:this.handleMessageTextEnd(e.payload);break;case ee.MessageReasoningStart:this.handleMessageReasoningStart(e.payload);break;case ee.MessageReasoningDelta:this.handleMessageReasoningDelta(e.payload);break;case ee.MessageReasoningEnd:this.handleMessageReasoningEnd(e.payload);break;case ee.MessageToolCallStart:this.handleMessageToolCallStart(e.payload);break;case ee.MessageToolCallArgs:this.handleMessageToolCallArgs(e.payload);break;case ee.MessageToolCallArgsDelta:this.handleMessageToolCallArgsDelta(e.payload);break;case ee.MessageToolCallEnd:this.handleMessageToolCallEnd(e.payload);break;case ee.MessageToolCallResult:this.handleMessageToolCallResult(e.payload);break;case ee.RunStarted:this.handleRunStarted(e.payload);break;case ee.RunFinished:this.handleRunFinished(e.payload);break;case ee.RunError:this.handleRunError(e.payload);break;case ee.RunMetadata:this.handleRunMetadata(e.payload);break;case ee.EndpointError:this.handleEndpointError(e.payload);break}this.stateVersion!==t&&this.notifyListeners()}handleMessageSent(e){this.upsertMessage(e.message),this.setError(null)}handleMessageAbort(e){var n;const t=(n=e.messageId)==null?void 0:n.trim();if(this.clearActiveRun(),this.setError(null),this.streamingMessage&&(!t||this.streamingMessage.id===t)){const r=this.streamingMessage.id;this.upsertMessage({...this.streamingMessage,status:"final"}),this.replaceStreamingMessage(null),t?Gt(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t):Gt(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,r)}}handleMessageTextStart(e){this.ensureStreamingMessage(e.sessionId,e.messageId,"streaming"),this.setError(null)}handleMessageTextDelta(e){if(!e.delta)return;const t=this.ensureStreamingMessage(e.sessionId,e.messageId,"streaming"),n=[...t.parts],r=n[n.length-1];(r==null?void 0: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){var t;((t=this.streamingMessage)==null?void 0:t.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;const t=this.ensureStreamingMessage(e.sessionId,e.messageId,"streaming"),n=[...t.parts],r=n[n.length-1];(r==null?void 0: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){var t;(t=this.streamingMessage)==null||t.id,e.messageId}handleMessageToolCallStart(e){const t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId,e.messageId);this.toolCallArgsRawByCallId.set(e.toolCallId,"");const n=et(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){const n=`${this.toolCallArgsRawByCallId.get(e.toolCallId)??""}${e.delta}`;this.toolCallArgsRawByCallId.set(e.toolCallId,n),this.applyToolCallArgs(e.sessionId,e.toolCallId,n,e.messageId)}handleMessageToolCallEnd(e){const t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId),n=this.toolCallArgsRawByCallId.get(e.toolCallId)??"",r=et(t.parts,{type:"tool-invocation",toolCallId:e.toolCallId,toolName:Er(t.parts,e.toolCallId)??"unknown",state:"call",args:n});this.replaceStreamingMessage({...t,parts:r,status:"streaming"})}handleMessageToolCallResult(e){if(!this.updateMessageContainingToolCall(e.toolCallId,(n,r)=>{const i={type:"tool-invocation",toolCallId:e.toolCallId,toolName:r.toolName,state:"result",args:r.args,result:e.content};return et(n.parts,i)})){const n=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId),r=et(n.parts,{type:"tool-invocation",toolCallId:e.toolCallId,toolName:"unknown",state:"result",result:e.content});this.replaceStreamingMessage({...n,parts:r,status:"streaming"})}}handleRunStarted(e){this.setError(null),this.activeRun={runId:e.runId??null,sessionId:e.sessionId},this.stateVersion+=1}handleRunFinished(e){this.settleStreamingMessage("final"),this.setError(null),this.clearActiveRun()}handleRunError(e){this.settleStreamingMessage("error"),this.setError(Uo(e)),this.clearActiveRun()}handleRunMetadata(e){var n,r;const t=e.metadata;if((t==null?void 0:t.kind)==="ready"){const i=t;this.activeRun={runId:i.runId??((n=this.activeRun)==null?void 0:n.runId)??null,sessionId:i.sessionId??((r=this.activeRun)==null?void 0:r.sessionId),abortDisabledReason:i.supportsAbort===!1?i.abortDisabledReason??"Unsupported":null},this.stateVersion+=1}else(t==null?void 0:t.kind)==="final"&&this.clearActiveRun()}handleEndpointError(e){var t,n,r;if(e.code==="abort-error"){this.handleMessageAbort({sessionId:((t=this.activeRun)==null?void 0:t.sessionId)??((n=this.streamingMessage)==null?void 0:n.sessionId)??"",...(r=this.streamingMessage)!=null&&r.id?{messageId:this.streamingMessage.id}:{}});return}this.settleStreamingMessage("error"),this.clearActiveRun(),this.setError(e)}applyToolCallArgs(e,t,n,r){const i=this.resolveToolCallTargetMessage(e,t,r),s=Er(i.parts,t)??"unknown",a=et(i.parts,{type:"tool-invocation",toolCallId:t,toolName:s,state:"partial-call",args:n});this.replaceStreamingMessage({...i,parts:a,status:"streaming"})}ensureStreamingMessage(e,t,n){var a;if(((a=this.streamingMessage)==null?void 0:a.id)===t){if(this.streamingMessage.status===n)return this.streamingMessage;const l={...this.streamingMessage,status:n};return this.replaceStreamingMessage(l),l}const r=this.messages.findIndex(l=>l.id===t);if(r>=0){const l=ls(this.messages[r]),o=[...this.messages];o.splice(r,1),this.messages=o,this.stateVersion+=1;const u={...l,sessionId:e,status:n};return this.replaceStreamingMessage(u),u}const i=this.streamingMessage;if(i&&i.id!==t&&i.sessionId===e&&$o(i,t)){const l={...i,id:t,sessionId:e,status:n};return qo(this.toolCallMessageIdByCallId,i.id,t),this.replaceStreamingMessage(l),l}const s={id:t,sessionId:e,role:Ko,status:n,parts:[],timestamp:new Date().toISOString()};return this.replaceStreamingMessage(s),s}resolveToolCallTargetMessage(e,t,n){var i;const r=(n==null?void 0:n.trim())||this.toolCallMessageIdByCallId.get(t)||((i=this.streamingMessage)==null?void 0:i.id)||`tool-${t}`;return this.toolCallMessageIdByCallId.set(t,r),this.ensureStreamingMessage(e,r,"streaming")}updateMessageContainingToolCall(e,t){if(this.streamingMessage){const n=kn(this.streamingMessage.parts,e);if(n){const r=t(this.streamingMessage,n);return this.replaceStreamingMessage({...this.streamingMessage,parts:r}),!0}}for(let n=this.messages.length-1;n>=0;n-=1){const r=this.messages[n],i=kn(r.parts,e);if(!i)continue;const s=[...this.messages];return s[n]={...r,parts:t(r,i)},this.messages=s,this.stateVersion+=1,!0}return!1}upsertMessage(e){const t=Qt(e),n=this.messages.findIndex(i=>i.id===t.id);if(n<0){this.messages=[...this.messages,t],this.stateVersion+=1;return}const r=[...this.messages];r[n]=t,this.messages=r,this.stateVersion+=1}replaceStreamingMessage(e){!e&&!this.streamingMessage||(this.streamingMessage=e?Qt(e):null,this.stateVersion+=1)}setError(e){var n,r,i,s;((n=this.error)==null?void 0:n.code)===(e==null?void 0:e.code)&&((r=this.error)==null?void 0:r.message)===(e==null?void 0:e.message)&&((i=this.error)==null?void 0:i.details)===(e==null?void 0:e.details)&&((s=this.error)==null?void 0:s.cause)===(e==null?void 0: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)}settleStreamingMessage(e){if(!this.streamingMessage)return;const t={...this.streamingMessage,status:e};this.upsertMessage(t),this.replaceStreamingMessage(null),Gt(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t.id)}notifyListeners(){const e=this.getSnapshot();for(const t of this.listeners)t(e)}};function Qo(e,t){const n="payload"in e?e.payload:null;return!n||typeof n!="object"||!("sessionId"in n)||typeof n.sessionId!="string"?!0:n.sessionId===t}function Go(e){return e.parts.some(t=>t.type==="text"||t.type==="rich-text"||t.type==="reasoning"?t.text.trim().length>0:!0)}function Xo(e,t){if(typeof e=="string"){const 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 Go(e.message)?{...e,sessionId:e.sessionId,message:{...e.message,sessionId:e.message.sessionId||e.sessionId}}:null}function Yo(e){const t=k.useRef();return(!t.current||t.current.sessionId!==e)&&(t.current={sessionId:e,manager:new Wo}),t.current.manager}function Jo({sessionId:e,client:t,manager:n}){var p;const r=k.useSyncExternalStore(f=>n.subscribe(()=>f()),()=>n.getSnapshot(),()=>n.getSnapshot()),[i,s]=k.useState(!1);k.useEffect(()=>{s(!1)},[e]),k.useEffect(()=>{const f=t.subscribe(m=>{Qo(m,e)&&n.dispatch(m)});return()=>{f(),t.stop()}},[t,n,e]);const a=r.streamingMessage?[...r.messages,r.streamingMessage]:r.messages,l=((p=r.activeRun)==null?void 0:p.runId)??null,o=!!r.activeRun;return{snapshot:r,visibleMessages:a,activeRunId:l,isRunning:o,isSending:i,send:async f=>{if(i||o)return;const m=Xo(f,e);if(m){s(!0),await n.dispatch({type:ee.MessageSent,payload:{sessionId:e,message:m.message,metadata:m.metadata}});try{await t.send(m)}finally{s(!1)}}},abort:async()=>{r.activeRun&&await t.abort({sessionId:e})},streamRun:async()=>{r.activeRun&&await t.stream({sessionId:e})}}}function Lr(e){return e instanceof Error?e:new Error(String(e))}function Zo(e){return e.isHydrating||e.hydratedSessionId!==e.sessionId}function eu({sessionId:e,client:t,loadSeed:n,autoResumeRunningSession:r=!0}){const i=Yo(e),s=Jo({sessionId:e,client:t,manager:i}),[a,l]=k.useState(!0),[o,u]=k.useState(null),[h,c]=k.useState(null),p=k.useRef({requestId:0,controller:null}),f=k.useCallback(async()=>{var S;(S=p.current.controller)==null||S.abort();const m=new AbortController,x=p.current.requestId+1;p.current={requestId:x,controller:m},await t.stop(),i.reset(),u(null),l(!0);try{const g=await n(e,m.signal);if(m.signal.aborted||p.current.requestId!==x)return;i.hydrate({sessionId:e,messages:g.messages,activeRun:g.status==="running"?{runId:null,sessionId:e,abortDisabledReason:null}:null}),u(null),c(e),l(!1),g.status==="running"&&r&&t.stream({sessionId:e}).catch(I=>{p.current.requestId===x&&u(Lr(I))})}catch(g){if(m.signal.aborted||p.current.requestId!==x)return;u(Lr(g)),c(e),l(!1)}finally{p.current.controller===m&&(p.current.controller=null)}},[r,t,n,i,e]);return k.useEffect(()=>(f(),()=>{var m;(m=p.current.controller)==null||m.abort(),p.current.controller=null}),[f]),{...s,isHydrating:Zo({sessionId:e,hydratedSessionId:h,isHydrating:a}),hydrateError:o,reloadSeed:f}}var os=200*1024*1024,tu="application/octet-stream";function us(e){const t=e.type.trim().toLowerCase();return t.length>0?t:tu}function nu(e,t){const n=t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0?new Set(t.acceptedMimeTypes.map(s=>s.trim().toLowerCase())):null,r=t.maxBytes??os,i=us(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 ru(e){var i;const t=e.parts&&e.parts.length>0?e.parts.map(s=>structuredClone(s)):[...((i=e.text)==null?void 0:i.trim())??""?[{type:"text",text:e.text.trim()}]:[],...(e.attachments??[]).map(s=>{var a,l,o;return{type:"file",name:s.name,mimeType:s.mimeType,...(a=s.assetUri)!=null&&a.trim()?{assetUri:s.assetUri.trim()}:{},...(l=s.url)!=null&&l.trim()?{url:s.url.trim()}:{},...(o=s.contentBase64)!=null&&o.trim()?{contentBase64:s.contentBase64.trim()}:{},sizeBytes:s.sizeBytes}})];if(t.length===0)return null;const 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 iu(e,t){const n=[],r=[];for(const i of e){const s=nu(i,t);if(!s.ok){r.push(s.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(i=>({fileName:i.name,mimeType:us(i),sizeBytes:i.size,reason:"read-failed"}))),{attachments:[],rejected:r}}}const su={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 au({status:e,className:t}){const n=su[e],r=e==="connected"?v("connected"):e==="disconnected"?v("disconnected"):v("connecting");return d.jsx(io,{delayDuration:250,children:d.jsxs(so,{children:[d.jsx(ao,{asChild:!0,children:d.jsx("span",{role:"status","aria-label":r,className:ve("inline-flex h-5 w-5 items-center justify-center",t),children:e==="connecting"?d.jsx(Hi,{className:ve("h-3 w-3 animate-spin",n.dotClass)}):d.jsx("span",{className:ve(e==="connected"?"h-2 w-2 rounded-full":"",n.dotClass)})})}),d.jsx(lo,{side:"bottom",className:"text-xs",children:r})]})})}function lu(e){const{session:t,active:n,runStatus:r,sessionTypeLabel:i,title:s,isEditing:a,draftLabel:l,isSaving:o,onSelect:u,onStartEditing:h,onDraftLabelChange:c,onSave:p,onCancel:f}=e;return d.jsx("div",{className:ve("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:a?d.jsxs("div",{className:"space-y-2",children:[d.jsx(Bn,{value:l,onChange:m=>c(m.target.value),onKeyDown:m=>{m.key==="Enter"?(m.preventDefault(),p()):m.key==="Escape"&&(m.preventDefault(),f())},placeholder:v("sessionsLabelPlaceholder"),className:"h-8 rounded-lg border-gray-300 bg-white text-xs",autoFocus:!0,disabled:o}),d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("div",{className:"min-w-0 text-[11px] text-gray-400 truncate",children:t.key}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Re,{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 p(),disabled:o,"aria-label":v("save"),children:d.jsx(mt,{className:"h-3.5 w-3.5"})}),d.jsx(Re,{type:"button",size:"icon",variant:"ghost",className:"h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900",onClick:f,disabled:o,"aria-label":v("cancel"),children:d.jsx(Ka,{className:"h-3.5 w-3.5"})})]})]})]}):d.jsxs("div",{className:"group/session relative",children:[d.jsxs("button",{type:"button",onClick:u,className:"w-full text-left",children:[d.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_0.875rem] items-center gap-1.5 pr-8",children:[d.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[d.jsx("span",{className:"truncate font-medium",children:s}),i?d.jsx("span",{className:ve("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}):null]}),d.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:r?d.jsx(wo,{status:r}):null})]}),d.jsxs("div",{className:"mt-0.5 text-[11px] text-gray-400 truncate",children:[t.messageCount," · ",Ft(t.updatedAt)]})]}),d.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),h()},className:ve("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":v("edit"),children:d.jsx(Wa,{className:"h-3.5 w-3.5"})})]})})}function ou(){const e=Qa();return async t=>{try{const n=await Xi(t.sessionKey,{label:t.label});Fl(e,n),at.success(v("configSavedApplied"))}catch(n){throw at.error(v("configSaveFailed")+": "+(n instanceof Error?n.message:String(n))),n}}}const uu={selectedSessionKey:null,selectedAgentId:"main",query:""},fe=Fn(e=>({snapshot:uu,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))}));function cu(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.key.toLowerCase().includes(n)):[...e]}function hu(e={}){var i;const t=fe(s=>s.snapshot.query),n=Yi({limit:e.limit??200}),r=k.useMemo(()=>{var u;const s=((u=n.data)==null?void 0:u.sessions)??[],a=ts(s),l=cu(a,t),o=new Map(s.map(h=>[h.sessionId,h]));return l.map(h=>{var c;return{session:h,runStatus:((c=o.get(h.key))==null?void 0:c.status)==="running"?"running":void 0}})},[t,(i=n.data)==null?void 0:i.sessions]);return{isLoading:n.isLoading,items:r}}const cs=k.createContext(null);function du({presenter:e,children:t}){return d.jsx(cs.Provider,{value:e,children:t})}function Un(){const e=k.useContext(cs);if(!e)throw new Error("usePresenter must be used inside ChatPresenterProvider");return e}const fu=e=>`[data-item-index="${e}"]`;function hs(e){const t=e.getItemSelector??fu;k.useEffect(()=>{if(!e.isEnabled||e.itemCount===0)return;const n=e.containerRef.current;if(!n)return;const r=n.querySelector(t(e.activeIndex));r==null||r.scrollIntoView({block:"nearest",inline:"nearest"})},[t,e.activeIndex,e.containerRef,e.isEnabled,e.itemCount])}function pu(){const e=k.useRef(null),[t,n]=k.useState(null);return k.useEffect(()=>{const r=e.current;if(!r||typeof ResizeObserver>"u")return;const i=()=>{n(r.getBoundingClientRect().width)};i();const s=new ResizeObserver(()=>i());return s.observe(r),()=>s.disconnect()},[]),{elementRef:e,width:t}}function Q(...e){return Ga(Xa(e))}const ds=k.forwardRef(({className:e,type:t,...n},r)=>d.jsx("input",{type:t,className:Q("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}));ds.displayName="ChatInput";const mu=mo,gu=yo,xu=go,fs=k.forwardRef(({className:e,sideOffset:t=8,align:n="start",...r},i)=>d.jsx(xo,{children:d.jsx(es,{ref:i,sideOffset:t,align:n,className:Q("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})}));fs.displayName=es.displayName;const yu=Ya,bu=Ja,ps=k.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(Vi,{ref:r,className:Q("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,d.jsx(Za,{asChild:!0,children:d.jsx(Dt,{className:"h-4 w-4 opacity-50"})})]}));ps.displayName=Vi.displayName;const ms=k.forwardRef(({className:e,...t},n)=>d.jsx(qi,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(il,{className:"h-4 w-4"})}));ms.displayName=qi.displayName;const gs=k.forwardRef(({className:e,...t},n)=>d.jsx(Ki,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(Dt,{className:"h-4 w-4"})}));gs.displayName=Ki.displayName;const xs=k.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>d.jsx(el,{children:d.jsxs(Ui,{ref:i,className:Q("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:[d.jsx(ms,{}),d.jsx(tl,{className:Q("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),d.jsx(gs,{})]})}));xs.displayName=Ui.displayName;const ys=k.forwardRef(({className:e,children:t,...n},r)=>d.jsxs($i,{ref:r,className:Q("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:[d.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(nl,{children:d.jsx(mt,{className:"h-4 w-4"})})}),d.jsx(rl,{children:t})]}));ys.displayName=$i.displayName;const Su=oo,ku=uo,wu=co,bs=k.forwardRef(({className:e,sideOffset:t=4,...n},r)=>d.jsx(ho,{children:d.jsx(Zi,{ref:r,sideOffset:t,className:Q("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})}));bs.displayName=Zi.displayName;const gt={Popover:mu,PopoverAnchor:xu,PopoverContent:fs,PopoverTrigger:gu,Input:ds,Select:yu,SelectContent:xs,SelectItem:ys,SelectTrigger:ps,SelectValue:bu,Tooltip:ku,TooltipContent:bs,TooltipProvider:Su,TooltipTrigger:wu},Cu=680,vu=.82,Tu=560;function Iu(e){const{Popover:t,PopoverAnchor:n,PopoverContent:r}=gt,{elementRef:i,width:s}=pu(),a=k.useRef(null),{isOpen:l,isLoading:o,items:u,activeIndex:h,activeItem:c,texts:p,onSelectItem:f,onOpenChange:m,onSetActiveIndex:x}=e,S=k.useMemo(()=>{if(s)return Math.min(s>Tu?s*vu:s,Cu)},[s]);return hs({containerRef:a,activeIndex:h,itemCount:u.length,isEnabled:l&&!o,getItemSelector:g=>`[data-slash-index="${g}"]`}),d.jsxs(t,{open:l,onOpenChange:m,children:[d.jsx(n,{asChild:!0,children:d.jsx("div",{ref:i,className:"pointer-events-none absolute bottom-full left-3 right-3 h-0"})}),d.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:g=>g.preventDefault(),style:S?{width:`${S}px`}:void 0,children:d.jsxs("div",{className:"grid min-h-[240px] grid-cols-[minmax(220px,300px)_minmax(0,1fr)]",children:[d.jsx("div",{ref:a,role:"listbox","aria-label":p.slashSectionLabel,className:"custom-scrollbar max-h-[320px] overflow-y-auto border-r border-gray-200 p-2.5",children:o?d.jsx("div",{className:"p-2 text-xs text-gray-500",children:p.slashLoadingLabel}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"mb-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500",children:p.slashSectionLabel}),u.length===0?d.jsx("div",{className:"px-2 text-xs text-gray-400",children:p.slashEmptyLabel}):d.jsx("div",{className:"space-y-1",children:u.map((g,I)=>{const M=I===h;return d.jsxs("button",{type:"button",role:"option","aria-selected":M,"data-slash-index":I,onMouseEnter:()=>x(I),onClick:()=>f(g),className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition ${M?"bg-gray-100 text-gray-900":"text-gray-700 hover:bg-gray-50"}`,children:[d.jsx("span",{className:"truncate text-xs font-semibold",children:g.title}),d.jsx("span",{className:"truncate text-xs text-gray-500",children:g.subtitle})]},g.key)})})]})}),d.jsx("div",{className:"max-w-[320px] p-3.5",children:c?d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary",children:c.subtitle}),d.jsx("span",{className:"text-sm font-semibold text-gray-900",children:c.title})]}),d.jsx("p",{className:"text-xs leading-5 text-gray-600",children:c.description}),d.jsx("div",{className:"space-y-1",children:c.detailLines.map(g=>d.jsx("div",{className:"rounded-md bg-gray-50 px-2 py-1 text-[11px] text-gray-600",children:g},g))}),d.jsx("div",{className:"pt-1 text-[11px] text-gray-500",children:p.slashSkillHintLabel})]}):d.jsx("div",{className:"text-xs text-gray-500",children:p.slashHintLabel})})]})})]})}const Mu=sl("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"}}),Mt=k.forwardRef(({className:e,variant:t,size:n,...r},i)=>d.jsx("button",{className:Q(Mu({variant:t,size:n,className:e})),ref:i,...r}));Mt.displayName="ChatButton";function Ar(){return d.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 Nu(e){var s;const{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=gt;return d.jsxs("div",{className:"flex flex-col items-end gap-1",children:[(s=e.sendError)!=null&&s.trim()?d.jsx("div",{className:"max-w-[420px] text-right text-[11px] text-red-600",children:e.sendError}):null,d.jsx("div",{className:"flex items-center gap-2",children:e.isSending?e.canStopGeneration?d.jsx(Mt,{size:"icon",variant:"outline",className:"h-8 w-8 rounded-full","aria-label":e.stopButtonLabel,onClick:()=>void e.onStop(),disabled:e.stopDisabled,children:d.jsx(Ar,{})}):d.jsx(r,{children:d.jsxs(t,{children:[d.jsx(i,{asChild:!0,children:d.jsx("span",{children:d.jsx(Mt,{size:"icon",variant:"outline",className:"h-8 w-8 rounded-full","aria-label":e.stopButtonLabel,disabled:!0,children:d.jsx(Ar,{})})})}),d.jsx(n,{side:"top",children:d.jsx("p",{className:"text-xs",children:e.stopHint})})]})}):d.jsx(Mt,{size:"icon",className:"h-8 w-8 rounded-full","aria-label":e.sendButtonLabel,onClick:()=>void e.onSend(),disabled:e.sendDisabled,children:d.jsx(al,{className:"h-5 w-5"})})})]})}function Eu(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>[r.label,r.key,r.description].filter(s=>typeof s=="string"&&s.trim().length>0).join(" ").toLowerCase().includes(n)):e}function Lu(e){const{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=gt,{picker:s}=e,a=k.useRef(null),l=k.useId(),[o,u]=k.useState(""),[h,c]=k.useState(0),p=k.useMemo(()=>new Set(s.selectedKeys),[s.selectedKeys]),f=s.selectedKeys.length,m=k.useMemo(()=>Eu(s.options,o),[s.options,o]);k.useEffect(()=>{c(0)},[o]),k.useEffect(()=>{c(g=>m.length===0?0:Math.min(g,m.length-1))},[m.length]),hs({containerRef:a,activeIndex:h,itemCount:m.length,isEnabled:m.length>0,getItemSelector:g=>`[data-skill-index="${g}"]`});const x=g=>{if(p.has(g)){s.onSelectedKeysChange(s.selectedKeys.filter(I=>I!==g));return}s.onSelectedKeysChange([...s.selectedKeys,g])},S=g=>{if(m.length!==0){if(g.key==="ArrowDown"){g.preventDefault(),c(I=>Math.min(I+1,m.length-1));return}if(g.key==="ArrowUp"){g.preventDefault(),c(I=>Math.max(I-1,0));return}if(g.key==="Enter"){g.preventDefault();const I=m[h];I&&x(I.key)}}};return d.jsxs(n,{children:[d.jsx(i,{asChild:!0,children:d.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:[d.jsx(On,{className:"h-4 w-4"}),d.jsx("span",{children:s.title}),f>0?d.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:f}):null]})}),d.jsxs(r,{side:"top",align:"start",className:"w-[360px] p-0",children:[d.jsxs("div",{className:"space-y-2 border-b border-gray-100 px-4 py-3",children:[d.jsx("div",{className:"text-sm font-semibold text-gray-900",children:s.title}),d.jsxs("div",{className:"relative",children:[d.jsx(_n,{className:"pointer-events-none absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400"}),d.jsx(t,{value:o,onChange:g=>u(g.target.value),onKeyDown:S,placeholder:s.searchPlaceholder,role:"combobox","aria-controls":l,"aria-expanded":"true","aria-autocomplete":"list","aria-activedescendant":m[h]?`${l}-option-${h}`:void 0,className:"h-8 rounded-lg pl-8 text-xs"})]})]}),d.jsx("div",{ref:a,id:l,role:"listbox","aria-multiselectable":"true",className:"custom-scrollbar max-h-[320px] overflow-y-auto",children:s.isLoading?d.jsx("div",{className:"p-4 text-xs text-gray-500",children:s.loadingLabel}):m.length===0?d.jsx("div",{className:"p-4 text-center text-xs text-gray-500",children:s.emptyLabel}):d.jsx("div",{className:"py-1",children:m.map((g,I)=>{const M=p.has(g.key),D=I===h;return d.jsxs("button",{type:"button",id:`${l}-option-${I}`,role:"option","aria-selected":M,"data-skill-index":I,onClick:()=>x(g.key),onMouseEnter:()=>c(I),className:`flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${D?"bg-gray-50":"hover:bg-gray-50"}`,children:[d.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-500",children:d.jsx(ll,{className:"h-4 w-4"})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:"truncate text-sm text-gray-900",children:g.label}),g.badgeLabel?d.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary",children:g.badgeLabel}):null]}),d.jsx("div",{className:"mt-0.5 truncate text-xs text-gray-500",children:g.description||g.key})]}),d.jsx("div",{className:"ml-3 shrink-0",children:d.jsx("span",{className:M?"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:M?d.jsx(mt,{className:"h-3 w-3"}):null})})]},g.key)})})}),s.manageHref&&s.manageLabel?d.jsx("div",{className:"border-t border-gray-100 px-4 py-2.5",children:d.jsxs("a",{href:s.manageHref,className:"inline-flex items-center gap-1.5 text-xs font-medium text-primary transition-colors hover:text-primary/80",children:[s.manageLabel,d.jsx(ol,{className:"h-3 w-3"})]})}):null]})]})}function Ss({icon:e}){return e==="sparkles"?d.jsx(cl,{className:"h-3.5 w-3.5 shrink-0 text-primary"}):e==="brain"?d.jsx(hl,{className:"h-3.5 w-3.5 shrink-0 text-gray-500"}):null}function Au({icon:e}){return e==="paperclip"?d.jsx(ul,{className:"h-4 w-4"}):d.jsx(Ss,{icon:e})}function ju(e){return e==="model"?"min-w-[220px]":e==="session-type"?"min-w-[140px]":e==="thinking"?"min-w-[150px]":""}function Ru(e){return e==="model"?"w-[320px]":e==="session-type"?"w-[220px]":e==="thinking"?"w-[180px]":""}function Pu({item:e}){const{Select:t,SelectContent:n,SelectItem:r,SelectTrigger:i,SelectValue:s}=gt;return d.jsxs(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[d.jsx(i,{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 ${ju(e.key)}`,children:e.selectedLabel?d.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-left",children:[d.jsx(Ss,{icon:e.icon}),d.jsx("span",{className:"truncate text-xs font-semibold text-gray-700",children:e.selectedLabel})]}):e.loading?d.jsx("div",{className:"h-3 w-24 animate-pulse rounded bg-gray-200"}):d.jsx(s,{placeholder:e.placeholder})}),d.jsxs(n,{className:Ru(e.key),children:[e.options.length===0?e.loading?d.jsxs("div",{className:"space-y-2 px-3 py-2",children:[d.jsx("div",{className:"h-3 w-36 animate-pulse rounded bg-gray-200"}),d.jsx("div",{className:"h-3 w-28 animate-pulse rounded bg-gray-200"}),d.jsx("div",{className:"h-3 w-32 animate-pulse rounded bg-gray-200"})]}):e.emptyLabel?d.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:e.emptyLabel}):null:null,e.options.map(a=>d.jsx(r,{value:a.value,className:"py-2",children:a.description?d.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[d.jsx("span",{className:"truncate text-xs font-semibold text-gray-800",children:a.label}),d.jsx("span",{className:"truncate text-[11px] text-gray-500",children:a.description})]}):d.jsx("span",{className:"truncate text-xs font-semibold text-gray-800",children:a.label})},a.value))]})]})}function Du(e){var s;const{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=gt;return d.jsxs("div",{className:"flex items-center justify-between px-3 pb-3",children:[d.jsxs("div",{className:"flex items-center gap-1",children:[e.skillPicker?d.jsx(Lu,{picker:e.skillPicker}):null,e.selects.map(a=>d.jsx(Pu,{item:a},a.key)),(s=e.accessories)==null?void 0:s.map(a=>{const l=d.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 ${a.iconOnly?"h-8 w-8 justify-center px-0":"gap-1.5 px-3"}`,onClick:a.onClick,disabled:a.disabled,"aria-label":a.label,children:[d.jsx(Au,{icon:a.icon}),a.iconOnly?null:d.jsx("span",{children:a.label})]});if(!a.tooltip)return d.jsx("div",{children:l},a.key);const o=a.disabled?d.jsx("span",{className:"inline-flex",children:l}):l;return d.jsx(r,{children:d.jsxs(t,{children:[d.jsx(i,{asChild:!0,children:o}),d.jsx(n,{side:"top",children:d.jsx("p",{className:"text-xs",children:a.tooltip})})]})},a.key)})]}),d.jsx(Nu,{...e.actions})]})}const Fu="";function ks(){return`composer-${Math.random().toString(36).slice(2,10)}`}function ht(e=""){return{id:ks(),type:"text",text:e}}function $n(e){return{id:ks(),type:"token",tokenKind:e.tokenKind,tokenKey:e.tokenKey,label:e.label}}function xt(e){return e.type==="text"?e.text.length:1}function qn(){return[ht("")]}function Ou(e){return[ht(e)]}function Qe(e){const t=[];for(const n of e){if(n.type==="text"){if(n.text.length===0)continue;const r=t[t.length-1];if((r==null?void 0:r.type)==="text"){t[t.length-1]={...r,text:r.text+n.text};continue}}t.push(n)}return t.length===0?qn():t}function _u(e){return e.map(t=>t.type==="text"?t.text:Fu).join("")}function zu(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Ot(e,t){const n=[],r=new Set;for(const i of e)i.type!=="token"||i.tokenKind!==t||r.has(i.tokenKey)||(r.add(i.tokenKey),n.push(i.tokenKey));return n}function Bu(e,t,n,r){const i=Math.max(0,n-t),s=Math.max(0,t+e.text.length-r),a=[];return i>0&&a.push({...e,text:e.text.slice(0,i)}),s>0&&a.push({...e,text:e.text.slice(e.text.length-s)}),a}function Hu(e,t,n,r){return t<=n||e>=r}function Vu(e,t,n,r,i){return!n&&r>=i?(e.push(...t),!0):n}function Uu(e,t,n,r,i,s,a){const l=Bu(t,n,r,i);l[0]&&e.push(l[0]);let o=a;return o||(e.push(...s),o=!0),l[1]&&e.push(l[1]),o}function $u(e,t,n,r,i,s){return!r&&i<=s?(e.push(...n),!0):(e.push(t),r)}function Xt(e,t,n,r){const i=Math.max(0,t),s=Math.max(i,n),a=[];let l=0,o=!1;for(const u of e){const h=xt(u),c=l,p=l+h;if(Hu(c,p,i,s)){o=Vu(a,r,o,c,s),a.push(u),l=p;continue}u.type==="text"?o=Uu(a,u,c,i,s,r,o):o=$u(a,u,r,o,i,c),l=p}return o||a.push(...r),Qe(a)}function Kn(e,t){return Qe(e.filter(n=>n.type!=="token"||!t(n)))}function qu(e,t){if(!t||t.start!==t.end)return null;const n=_u(e),r=t.end,i=n.slice(0,r),s=/(?:^|\s)\/([^\s\uFFFC]*)$/.exec(i);if(!s)return null;const a=r-s[0].length+(s[0].startsWith("/")?0:1);return{query:(s[1]??"").trim().toLowerCase(),start:a,end:r}}function Ku(e,t,n){return e?e.start<n&&e.end>t:!1}function ws(e){const t=new Map;let n=0;for(const r of e)t.set(r.id,n),n+=xt(r);return t}function Cs(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 Wu(e,t,n){if(e instanceof HTMLElement){const r=e.dataset.composerNodeId;if(r)return n.find(i=>i.id===r)}return n[t]}function vs(e,t,n){let r=0;for(let i=0;i<n;i+=1){const s=Wu(e.childNodes[i],i,t);s&&(r+=xt(s))}return r}function Qu(e,t,n,r){var l;const i=Cs(e,t),s=vs(e,r,i),a=r[i];return(a==null?void 0:a.type)==="text"?s+Math.min(n,a.text.length):s+Math.min(n,((l=t.textContent)==null?void 0:l.length)??0)}function Gu(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 wn(e,t,n,r,i){var u;if(t===e)return vs(e,r,n);if(t.nodeType===Node.TEXT_NODE&&t.parentNode===e)return Qu(e,t,n,r);const s=t instanceof HTMLElement?t.closest("[data-composer-node-id]"):((u=t.parentElement)==null?void 0:u.closest("[data-composer-node-id]"))??null;if(!(s instanceof HTMLElement)){const h=Cs(e,t);return wn(e,e,h,r,i)}const a=s.dataset.composerNodeId;if(!a)return 0;const l=r.find(h=>h.id===a),o=i.get(a)??0;return l?Gu(t,n,l,o,s):o}function Ts(e,t){const n=window.getSelection();if(!n||n.rangeCount===0)return null;const r=n.getRangeAt(0);if(!e.contains(r.startContainer)||!e.contains(r.endContainer))return null;const i=ws(t),s=wn(e,r.startContainer,r.startOffset,t,i),a=wn(e,r.endContainer,r.endOffset,t,i);return{start:Math.min(s,a),end:Math.max(s,a)}}function Xu(e,t,n){if(!n)return;const r=window.getSelection();if(!r)return;const i=o=>{let u=0;for(let h=0;h<t.length;h+=1){const c=t[h],p=xt(c),f=u,m=u+p,x=e.childNodes[h];if(!x){u=m;continue}if(c.type==="text"){if(o<=m)return{container:x.firstChild??x,offset:Math.max(0,Math.min(o-f,c.text.length))}}else{if(o<=f)return{container:e,offset:h};if(o<=m)return{container:e,offset:h+1}}u=m}return{container:e,offset:e.childNodes.length}},s=i(n.start),a=i(n.end),l=document.createRange();l.setStart(s.container,s.offset),l.setEnd(a.container,a.offset),r.removeAllRanges(),r.addRange(l)}function Yu(e){const t=[];for(const n of Array.from(e.childNodes)){if(n.nodeType===Node.TEXT_NODE){t.push(ht(n.textContent??""));continue}if(!(n instanceof HTMLElement))continue;if(n.dataset.composerNodeType==="token"){const s=n.dataset.composerTokenKind,a=n.dataset.composerTokenKey,l=n.dataset.composerLabel;s&&a&&l&&t.push({id:n.dataset.composerNodeId??$n({tokenKind:s,tokenKey:a,label:l}).id,type:"token",tokenKind:s,tokenKey:a,label:l});continue}const i=n.textContent??"";t.push({id:n.dataset.composerNodeId??ht(i).id,type:"text",text:i})}return Qe(t)}function jr(e){const t=Yu(e);return{nodes:t,selection:Ts(e,t)}}class Ju{constructor(){this.nodes=qn(),this.selection=null,this.sync=(t,n)=>(this.nodes=Qe(t),this.selection=n,this.getSnapshot()),this.setSelection=t=>(this.selection=t,this.getSnapshot()),this.replaceDocument=(t,n)=>(this.nodes=Qe(t),this.selection=n,this.getSnapshot()),this.insertText=t=>{const n=this.selection??{start:0,end:0};this.nodes=Xt(this.nodes,n.start,n.end,[ht(t)]);const r=n.start+t.length;return this.selection={start:r,end:r},this.getSnapshot()},this.insertFileToken=(t,n)=>this.insertToken("file",t,n),this.insertSkillToken=(t,n)=>this.getSelectedSkillKeys().includes(t)?this.getSnapshot():this.insertToken("skill",t,n,this.getSlashTrigger()),this.syncSelectedSkills=(t,n)=>{const r=this.getSelectedSkillKeys(),i=new Map(n.map(l=>[l.key,l])),s=t.find(l=>!r.includes(l));if(s){const l=i.get(s);return this.insertSkillToken(s,(l==null?void 0:l.label)??s)}const a=r.find(l=>!t.includes(l));return a&&(this.nodes=Kn(this.nodes,l=>l.tokenKind==="skill"&&l.tokenKey===a)),this.getSnapshot()},this.deleteContent=t=>{const n=this.getDocumentLength(),r=this.selection??{start:n,end:n};let i=r.start,s=r.end;if(r.start===r.end)if(t==="backward"&&r.start>0)i=r.start-1;else if(t==="forward")s=r.end+1;else return this.getSnapshot();return this.nodes=Xt(this.nodes,i,s,[]),this.selection={start:i,end:i},this.getSnapshot()},this.getSnapshot=()=>({nodes:this.nodes,selection:this.selection,nodeStartMap:ws(this.nodes),documentLength:this.getDocumentLength(),selectedSkillKeys:this.getSelectedSkillKeys(),slashTrigger:this.getSlashTrigger()}),this.getDocumentLength=()=>this.nodes.reduce((t,n)=>t+xt(n),0),this.getSelectedSkillKeys=()=>Ot(this.nodes,"skill"),this.insertToken=(t,n,r,i=null)=>{var o,u;const s=this.getDocumentLength(),a=(i==null?void 0:i.start)??((o=this.selection)==null?void 0:o.start)??s,l=(i==null?void 0:i.end)??((u=this.selection)==null?void 0:u.end)??a;return this.nodes=Xt(this.nodes,a,l,[$n({tokenKind:t,tokenKey:n,label:r})]),this.selection={start:a+1,end:a+1},this.getSnapshot()},this.getSlashTrigger=()=>qu(this.nodes,this.selection)}}function Zu(e){const{key:t,shiftKey:n,isComposing:r,isSlashMenuOpen:i,slashItemCount:s,activeSlashIndex:a,isSending:l,canStopGeneration:o}=e;if(i&&s>0){if(t==="ArrowDown")return{type:"move-slash-index",index:(a+1)%s};if(t==="ArrowUp")return{type:"move-slash-index",index:(a-1+s)%s};if(t==="Enter"&&!n||t==="Tab")return{type:"insert-active-slash-item"}}return t==="Escape"?i?{type:"close-slash"}:l&&o?{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"}}const Rr="http://www.w3.org/2000/svg";class ec{constructor(){this.render=(t,n)=>{if(!t)return;const r=document.createDocumentFragment();for(const i of n.nodes){const s=i.type==="text"?this.createTextNodeElement(i):this.createTokenNodeElement(i,n.selectedRange,n.nodeStartMap);s&&r.appendChild(s)}t.replaceChildren(r)},this.createTextNodeElement=t=>{if(t.text.length===0)return null;const n=document.createElement("span");return n.dataset.composerNodeId=t.id,n.dataset.composerNodeType="text",n.textContent=t.text,n},this.createTokenNodeElement=(t,n,r)=>{const i=r.get(t.id)??0,s=Ku(n,i,i+1),a=document.createElement("span");a.contentEditable="false",a.dataset.composerNodeId=t.id,a.dataset.composerNodeType="token",a.dataset.composerTokenKind=t.tokenKind,a.dataset.composerTokenKey=t.tokenKey,a.dataset.composerLabel=t.label,a.title=t.label,a.className=this.buildTokenClassName(t.tokenKind,s),a.append(this.createTokenIcon(t.tokenKind));const l=document.createElement("span");return l.className=t.tokenKind==="file"?"min-w-0 flex-1 truncate text-[12px] font-medium text-slate-700":"truncate",l.textContent=t.label,a.append(l),a},this.buildTokenClassName=(t,n)=>t==="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",n?"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",n?"border-primary/30 bg-primary/18 text-primary":"border-primary/12 bg-primary/8 text-primary"].join(" "),this.createTokenIcon=t=>{const n=document.createElement("span");return n.className=t==="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",n.append(t==="file"?this.createFileIcon():this.createSkillIcon()),n},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=t=>{const n=document.createElementNS(Rr,"svg");n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.25"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true"),n.setAttribute("class","h-3 w-3");for(const r of t){const i=document.createElementNS(Rr,r.tag);for(const[s,a]of Object.entries(r.attrs))i.setAttribute(s,a);n.append(i)}return n}}}const Pr=188;class tc{constructor(t){this.controller=t,this.surfaceRenderer=new ec,this.sync=(n,r)=>this.controller.sync(n,r),this.syncSelectionFromRoot=n=>this.controller.setSelection(Ts(n,this.controller.getSnapshot().nodes)),this.restoreSelectionIfFocused=(n,r)=>{!n||document.activeElement!==n||Xu(n,this.controller.getSnapshot().nodes,r)},this.syncViewport=n=>{n&&(n.style.maxHeight=`${Pr}px`,n.style.overflowY=n.scrollHeight>Pr?"auto":"hidden")},this.renderSurface=n=>{this.surfaceRenderer.render(n.root,{nodes:n.snapshot.nodes,selectedRange:n.selectedRange,nodeStartMap:n.snapshot.nodeStartMap})},this.insertSlashItem=(n,r)=>{n.value&&r(this.controller.insertSkillToken(n.value,n.title))},this.syncSelectedSkills=(n,r,i)=>{i(this.controller.syncSelectedSkills(n,r))},this.handleBeforeInput=n=>{const{event:r,disabled:i,isComposing:s,commitSnapshot:a}=n,l=r.nativeEvent;i||s||l.isComposing||!(l.inputType==="insertText"||l.inputType==="insertReplacementText")||!l.data||(r.preventDefault(),a(this.controller.insertText(l.data)))},this.handleInput=n=>{const{event:r,isComposing:i,commitSnapshot:s}=n,a=r.nativeEvent;if(i||a.isComposing)return;const l=r.currentTarget,o=jr(l);s(this.controller.replaceDocument(o.nodes,o.selection))},this.handleCompositionEnd=n=>{const{event:r,commitSnapshot:i}=n,s=r.currentTarget,a=jr(s);i(this.controller.replaceDocument(a.nodes,a.selection))},this.handleKeyDown=n=>{const{event:r,slashItems:i,activeSlashIndex:s,activeSlashItem:a,actions:l,commitSnapshot:o,insertSkillToken:u,onSlashActiveIndexChange:h,onSlashQueryChange:c,onSlashOpenChange:p}=n,f=this.controller.getSnapshot(),m=Zu({key:r.key,shiftKey:r.shiftKey,isComposing:r.nativeEvent.isComposing,isSlashMenuOpen:f.slashTrigger!==null,slashItemCount:i.length,activeSlashIndex:s,isSending:l.isSending,canStopGeneration:l.canStopGeneration});if(m.type!=="noop"){if(r.preventDefault(),m.type==="move-slash-index"){h(m.index);return}if(m.type==="insert-active-slash-item"){a&&u(a.value??a.key,a.title);return}if(m.type==="close-slash"){c==null||c(null),p(!1);return}if(m.type==="stop-generation"){l.onStop();return}if(m.type==="insert-line-break"){o(this.controller.insertText(`
|
|
3
|
-
`));return}if(m.type==="send-message"){l.onSend();return}m.type==="delete-content"&&o(this.controller.deleteContent(m.direction))}},this.handlePaste=n=>{const{event:r,onFilesAdd:i,commitSnapshot:s}=n,a=Array.from(r.clipboardData.files??[]);if(a.length>0&&i){r.preventDefault(),i(a);return}const l=r.clipboardData.getData("text/plain");l&&(r.preventDefault(),s(this.controller.insertText(l)))},this.handleBlur=n=>{const{clearSelectedRange:r,onSlashQueryChange:i,onSlashOpenChange:s}=n;r(),i==null||i(null),s(!1)}}}class nc{constructor(){this.controller=new Ju,this.viewController=new tc(this.controller),this.rootElement=null,this.selection=null,this.selectedRange=null,this.snapshot=this.controller.getSnapshot(),this.config=null,this.isComposing=!1,this.bindRootElement=t=>{this.rootElement=t},this.update=t=>(this.config=t,this.snapshot=this.viewController.sync(t.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:t=>{this.viewController.insertSlashItem(t,this.commitSnapshot)},insertFileToken:(t,n)=>{this.commitSnapshot(this.controller.insertFileToken(t,n)),this.focusComposerSoon()},insertFileTokens:t=>{let n=null;for(const r of t)n=this.controller.insertFileToken(r.tokenKey,r.label);n&&(this.commitSnapshot(n),this.focusComposerSoon())},focusComposer:()=>{this.focusComposer()},syncSelectedSkills:(t,n)=>{this.viewController.syncSelectedSkills(t,n,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;const t=this.viewController.syncSelectionFromRoot(this.rootElement);this.selection=t.selection,this.selectedRange=t.selection,this.syncSlashState(t),this.requestRender()},this.handleBeforeInput=t=>{this.viewController.handleBeforeInput({event:t,disabled:this.requireConfig().disabled,isComposing:this.isComposing,commitSnapshot:this.commitSnapshot})},this.handleInput=t=>{this.viewController.handleInput({event:t,isComposing:this.isComposing,commitSnapshot:this.commitSnapshot})},this.handleCompositionStart=()=>{this.isComposing=!0},this.handleCompositionEnd=t=>{this.isComposing=!1,this.viewController.handleCompositionEnd({event:t,commitSnapshot:this.commitSnapshot})},this.handleKeyDown=t=>{const n=this.requireConfig();if(this.rootElement&&!this.isComposing){const i=this.viewController.syncSelectionFromRoot(this.rootElement);this.selection=i.selection,this.selectedRange=i.selection,this.snapshot=i}const r=n.slashItems[n.activeSlashIndex]??null;this.viewController.handleKeyDown({event:t,slashItems:n.slashItems,activeSlashIndex:n.activeSlashIndex,activeSlashItem:r,actions:n.actions,commitSnapshot:this.commitSnapshot,insertSkillToken:this.insertSkillToken,onSlashActiveIndexChange:n.onSlashActiveIndexChange,onSlashQueryChange:n.onSlashQueryChange,onSlashOpenChange:n.onSlashOpenChange})},this.handlePaste=t=>{this.viewController.handlePaste({event:t,onFilesAdd:this.requireConfig().onFilesAdd,commitSnapshot:this.commitSnapshot})},this.handleBlur=()=>{const t=this.requireConfig();this.isComposing=!1,this.viewController.handleBlur({clearSelectedRange:this.clearSelectedRange,onSlashQueryChange:t.onSlashQueryChange,onSlashOpenChange:t.onSlashOpenChange})},this.setSelectedRange=t=>{this.selectedRange=t,this.selection=t,this.requestRender()},this.clearSelectedRange=()=>{this.selectedRange=null,this.requestRender()},this.commitSnapshot=t=>{const n=this.requireConfig();this.selection=t.selection,this.selectedRange=t.selection,this.snapshot=t,n.onNodesChange(t.nodes),this.syncSlashState(t)},this.insertSkillToken=(t,n)=>{this.commitSnapshot(this.controller.insertSkillToken(t,n))},this.syncSlashState=t=>{var r,i,s;const n=this.requireConfig();(r=n.onSlashTriggerChange)==null||r.call(n,t.slashTrigger),(s=n.onSlashQueryChange)==null||s.call(n,((i=t.slashTrigger)==null?void 0:i.query)??null),n.onSlashOpenChange(t.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;const t=this.selection;this.rootElement.focus();const n=()=>{this.rootElement&&(this.selection=t,this.selectedRange=t,this.viewController.restoreSelectionIfFocused(this.rootElement,t))};if(typeof requestAnimationFrame=="function"){requestAnimationFrame(n);return}n()},this.requireConfig=()=>{if(!this.config)throw new Error("ChatComposerRuntime is not configured.");return this.config}}}const rc=k.forwardRef(function(t,n){const{nodes:r,placeholder:i,disabled:s,slashItems:a,actions:l,onNodesChange:o,onFilesAdd:u,onSlashQueryChange:h,onSlashTriggerChange:c,onSlashOpenChange:p,onSlashActiveIndexChange:f,activeSlashIndex:m}=t,[x,S]=k.useState(0),[g]=k.useState(()=>new nc),{snapshot:I,bindRootElement:M,handleBeforeInput:D,handleInput:F,handleCompositionStart:T,handleCompositionEnd:O,handleKeyDown:H,handlePaste:B,handleBlur:w,syncSelectionState:E,imperativeHandle:L}=g.update({nodes:r,disabled:s,slashItems:a,actions:l,onNodesChange:o,onFilesAdd:u,onSlashQueryChange:h,onSlashTriggerChange:c,onSlashOpenChange:p,onSlashActiveIndexChange:f,activeSlashIndex:m,requestRender:()=>S(V=>V+1)});return k.useImperativeHandle(n,()=>L,[L]),k.useLayoutEffect(()=>{g.renderSurface(),g.restoreDomAfterCommit(),g.syncViewport()},[g,I.nodes,I.nodeStartMap,x]),d.jsx("div",{className:"px-4 py-2.5",children:d.jsx("div",{className:"min-h-[60px]",children:d.jsx("div",{ref:M,contentEditable:!s,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":"true","data-placeholder":i,onBeforeInput:D,onInput:F,onCompositionStart:T,onCompositionEnd:O,onKeyDown:H,onKeyUp:E,onMouseUp:E,onFocus:E,onBlur:w,onPaste:B,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 ic({hint:e}){if(!e)return null;if(e.loading)return d.jsx("div",{className:"px-4 pb-2",children:d.jsxs("div",{className:"inline-flex items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2",children:[d.jsx("span",{className:"h-3 w-28 animate-pulse rounded bg-gray-200"}),d.jsx("span",{className:"h-3 w-16 animate-pulse rounded bg-gray-200"})]})});const t=e.tone==="warning"?"border-amber-200 bg-amber-50 text-amber-800":"border-gray-200 bg-gray-50 text-gray-700";return d.jsx("div",{className:"px-4 pb-2",children:d.jsxs("div",{className:`inline-flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs ${t}`,children:[e.text?d.jsx("span",{children:e.text}):null,e.actionLabel&&e.onAction?d.jsx("button",{type:"button",onClick:e.onAction,className:"font-semibold underline-offset-2 hover:underline",children:e.actionLabel}):null]})})}const Is=k.forwardRef(function(t,n){const r=k.useRef(null),[i,s]=k.useState(null),[a,l]=k.useState(0),[o,u]=k.useState(null),[h,c]=k.useState(null),p=o!==null&&h!==o,f=t.slashMenu.items[a]??null;k.useEffect(()=>{l(x=>t.slashMenu.items.length===0?0:Math.min(x,t.slashMenu.items.length-1))},[t.slashMenu.items.length]),k.useEffect(()=>{i!==null&&l(0)},[i]),k.useEffect(()=>{o===null&&h!==null&&c(null)},[o,h]);const m=k.useMemo(()=>t.toolbar.skillPicker?{...t.toolbar,skillPicker:{...t.toolbar.skillPicker,onSelectedKeysChange:x=>{var S,g;(g=r.current)==null||g.syncSelectedSkills(x,((S=t.toolbar.skillPicker)==null?void 0:S.options)??[])}}}:t.toolbar,[t.toolbar]);return k.useImperativeHandle(n,()=>({insertFileToken:(x,S)=>{var g;return(g=r.current)==null?void 0:g.insertFileToken(x,S)},insertFileTokens:x=>{var S;return(S=r.current)==null?void 0:S.insertFileTokens(x)},focusComposer:()=>{var x;return(x=r.current)==null?void 0:x.focusComposer()}}),[]),d.jsx("div",{className:"border-t border-gray-200/80 bg-white p-4",children:d.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)]",children:d.jsxs("div",{className:"overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-card",children:[d.jsxs("div",{className:"relative",children:[d.jsx(rc,{ref:r,nodes:t.composer.nodes,placeholder:t.composer.placeholder,disabled:t.composer.disabled,slashItems:t.slashMenu.items,actions:t.toolbar.actions,activeSlashIndex:a,onNodesChange:t.composer.onNodesChange,onFilesAdd:t.composer.onFilesAdd,onSlashQueryChange:x=>{var S,g;s(x),(g=(S=t.composer).onSlashQueryChange)==null||g.call(S,x)},onSlashTriggerChange:x=>{u((x==null?void 0:x.start)??null)},onSlashOpenChange:x=>{!x&&o!==null&&c(o)},onSlashActiveIndexChange:l}),d.jsx(Iu,{isOpen:p,isLoading:t.slashMenu.isLoading,items:t.slashMenu.items,activeIndex:a,activeItem:f,texts:t.slashMenu.texts,onSelectItem:x=>{var S;c(null),(S=r.current)==null||S.insertSlashItem(x)},onOpenChange:x=>{!x&&o!==null&&c(o)},onSetActiveIndex:l})]}),d.jsx(ic,{hint:t.hint}),d.jsx(Du,{...m})]})})})});Is.displayName="ChatInputBar";function Yt({role:e}){return e==="user"?d.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:d.jsx(dl,{className:"h-4 w-4"})}):e==="tool"?d.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:d.jsx(fl,{className:"h-4 w-4"})}):d.jsx("div",{"data-testid":"chat-message-avatar-assistant",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-gray-200/80 bg-gray-900 text-white shadow-sm",children:d.jsx(Wi,{className:"h-4 w-4"})})}function sc(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const ac=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lc=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,oc={};function Dr(e,t){return(oc.jsx?lc:ac).test(e)}const uc=/[ \t\n\f\r]/g;function cc(e){return typeof e=="object"?e.type==="text"?Fr(e.value):!1:Fr(e)}function Fr(e){return e.replace(uc,"")===""}class yt{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}yt.prototype.normal={};yt.prototype.property={};yt.prototype.space=void 0;function Ms(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new yt(n,r,t)}function Cn(e){return e.toLowerCase()}class pe{constructor(t,n){this.attribute=n,this.property=t}}pe.prototype.attribute="";pe.prototype.booleanish=!1;pe.prototype.boolean=!1;pe.prototype.commaOrSpaceSeparated=!1;pe.prototype.commaSeparated=!1;pe.prototype.defined=!1;pe.prototype.mustUseProperty=!1;pe.prototype.number=!1;pe.prototype.overloadedBoolean=!1;pe.prototype.property="";pe.prototype.spaceSeparated=!1;pe.prototype.space=void 0;let hc=0;const q=Ve(),ie=Ve(),vn=Ve(),A=Ve(),Z=Ve(),We=Ve(),ge=Ve();function Ve(){return 2**++hc}const Tn=Object.freeze(Object.defineProperty({__proto__:null,boolean:q,booleanish:ie,commaOrSpaceSeparated:ge,commaSeparated:We,number:A,overloadedBoolean:vn,spaceSeparated:Z},Symbol.toStringTag,{value:"Module"})),Jt=Object.keys(Tn);class Wn extends pe{constructor(t,n,r,i){let s=-1;if(super(t,n),Or(this,"space",i),typeof r=="number")for(;++s<Jt.length;){const a=Jt[s];Or(this,Jt[s],(r&Tn[a])===Tn[a])}}}Wn.prototype.defined=!0;function Or(e,t,n){n&&(e[t]=n)}function Xe(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Wn(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Cn(r)]=r,n[Cn(s.attribute)]=r}return new yt(t,n,e.space)}const Ns=Xe({properties:{ariaActiveDescendant:null,ariaAtomic:ie,ariaAutoComplete:null,ariaBusy:ie,ariaChecked:ie,ariaColCount:A,ariaColIndex:A,ariaColSpan:A,ariaControls:Z,ariaCurrent:null,ariaDescribedBy:Z,ariaDetails:null,ariaDisabled:ie,ariaDropEffect:Z,ariaErrorMessage:null,ariaExpanded:ie,ariaFlowTo:Z,ariaGrabbed:ie,ariaHasPopup:null,ariaHidden:ie,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Z,ariaLevel:A,ariaLive:null,ariaModal:ie,ariaMultiLine:ie,ariaMultiSelectable:ie,ariaOrientation:null,ariaOwns:Z,ariaPlaceholder:null,ariaPosInSet:A,ariaPressed:ie,ariaReadOnly:ie,ariaRelevant:null,ariaRequired:ie,ariaRoleDescription:Z,ariaRowCount:A,ariaRowIndex:A,ariaRowSpan:A,ariaSelected:ie,ariaSetSize:A,ariaSort:null,ariaValueMax:A,ariaValueMin:A,ariaValueNow:A,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Es(e,t){return t in e?e[t]:t}function Ls(e,t){return Es(e,t.toLowerCase())}const dc=Xe({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:We,acceptCharset:Z,accessKey:Z,action:null,allow:null,allowFullScreen:q,allowPaymentRequest:q,allowUserMedia:q,alt:null,as:null,async:q,autoCapitalize:null,autoComplete:Z,autoFocus:q,autoPlay:q,blocking:Z,capture:null,charSet:null,checked:q,cite:null,className:Z,cols:A,colSpan:null,content:null,contentEditable:ie,controls:q,controlsList:Z,coords:A|We,crossOrigin:null,data:null,dateTime:null,decoding:null,default:q,defer:q,dir:null,dirName:null,disabled:q,download:vn,draggable:ie,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:q,formTarget:null,headers:Z,height:A,hidden:vn,high:A,href:null,hrefLang:null,htmlFor:Z,httpEquiv:Z,id:null,imageSizes:null,imageSrcSet:null,inert:q,inputMode:null,integrity:null,is:null,isMap:q,itemId:null,itemProp:Z,itemRef:Z,itemScope:q,itemType:Z,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:q,low:A,manifest:null,max:null,maxLength:A,media:null,method:null,min:null,minLength:A,multiple:q,muted:q,name:null,nonce:null,noModule:q,noValidate:q,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:q,optimum:A,pattern:null,ping:Z,placeholder:null,playsInline:q,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:q,referrerPolicy:null,rel:Z,required:q,reversed:q,rows:A,rowSpan:A,sandbox:Z,scope:null,scoped:q,seamless:q,selected:q,shadowRootClonable:q,shadowRootDelegatesFocus:q,shadowRootMode:null,shape:null,size:A,sizes:null,slot:null,span:A,spellCheck:ie,src:null,srcDoc:null,srcLang:null,srcSet:null,start:A,step:null,style:null,tabIndex:A,target:null,title:null,translate:null,type:null,typeMustMatch:q,useMap:null,value:ie,width:A,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Z,axis:null,background:null,bgColor:null,border:A,borderColor:null,bottomMargin:A,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:q,declare:q,event:null,face:null,frame:null,frameBorder:null,hSpace:A,leftMargin:A,link:null,longDesc:null,lowSrc:null,marginHeight:A,marginWidth:A,noResize:q,noHref:q,noShade:q,noWrap:q,object:null,profile:null,prompt:null,rev:null,rightMargin:A,rules:null,scheme:null,scrolling:ie,standby:null,summary:null,text:null,topMargin:A,valueType:null,version:null,vAlign:null,vLink:null,vSpace:A,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:q,disableRemotePlayback:q,prefix:null,property:null,results:A,security:null,unselectable:null},space:"html",transform:Ls}),fc=Xe({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ge,accentHeight:A,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:A,amplitude:A,arabicForm:null,ascent:A,attributeName:null,attributeType:null,azimuth:A,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:A,by:null,calcMode:null,capHeight:A,className:Z,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:A,diffuseConstant:A,direction:null,display:null,dur:null,divisor:A,dominantBaseline:null,download:q,dx:null,dy:null,edgeMode:null,editable:null,elevation:A,enableBackground:null,end:null,event:null,exponent:A,externalResourcesRequired:null,fill:null,fillOpacity:A,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:We,g2:We,glyphName:We,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:A,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:A,horizOriginX:A,horizOriginY:A,id:null,ideographic:A,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:A,k:A,k1:A,k2:A,k3:A,k4:A,kernelMatrix:ge,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:A,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:A,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:A,overlineThickness:A,paintOrder:null,panose1:null,path:null,pathLength:A,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Z,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:A,pointsAtY:A,pointsAtZ:A,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ge,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ge,rev:ge,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ge,requiredFeatures:ge,requiredFonts:ge,requiredFormats:ge,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:A,specularExponent:A,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:A,strikethroughThickness:A,string:null,stroke:null,strokeDashArray:ge,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:A,strokeOpacity:A,strokeWidth:null,style:null,surfaceScale:A,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ge,tabIndex:A,tableValues:null,target:null,targetX:A,targetY:A,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ge,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:A,underlineThickness:A,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:A,values:null,vAlphabetic:A,vMathematical:A,vectorEffect:null,vHanging:A,vIdeographic:A,version:null,vertAdvY:A,vertOriginX:A,vertOriginY:A,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:A,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Es}),As=Xe({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()}}),js=Xe({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ls}),Rs=Xe({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),pc={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"},mc=/[A-Z]/g,_r=/-[a-z]/g,gc=/^data[-\w.:]+$/i;function xc(e,t){const n=Cn(t);let r=t,i=pe;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&gc.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(_r,bc);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!_r.test(s)){let a=s.replace(mc,yc);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=Wn}return new i(r,t)}function yc(e){return"-"+e.toLowerCase()}function bc(e){return e.charAt(1).toUpperCase()}const Sc=Ms([Ns,dc,As,js,Rs],"html"),Qn=Ms([Ns,fc,As,js,Rs],"svg");function kc(e){return e.join(" ").trim()}var $e={},Zt,zr;function wc(){if(zr)return Zt;zr=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,l=/^\s+|\s+$/g,o=`
|
|
4
|
-
`,u="/",h="*",c="",p="comment",f="declaration";function m(S,g){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];g=g||{};var I=1,M=1;function D(R){var C=R.match(t);C&&(I+=C.length);var P=R.lastIndexOf(o);M=~P?R.length-P:M+R.length}function F(){var R={line:I,column:M};return function(C){return C.position=new T(R),B(),C}}function T(R){this.start=R,this.end={line:I,column:M},this.source=g.source}T.prototype.content=S;function O(R){var C=new Error(g.source+":"+I+":"+M+": "+R);if(C.reason=R,C.filename=g.source,C.line=I,C.column=M,C.source=S,!g.silent)throw C}function H(R){var C=R.exec(S);if(C){var P=C[0];return D(P),S=S.slice(P.length),C}}function B(){H(n)}function w(R){var C;for(R=R||[];C=E();)C!==!1&&R.push(C);return R}function E(){var R=F();if(!(u!=S.charAt(0)||h!=S.charAt(1))){for(var C=2;c!=S.charAt(C)&&(h!=S.charAt(C)||u!=S.charAt(C+1));)++C;if(C+=2,c===S.charAt(C-1))return O("End of comment missing");var P=S.slice(2,C-2);return M+=2,D(P),S=S.slice(C),M+=2,R({type:p,comment:P})}}function L(){var R=F(),C=H(r);if(C){if(E(),!H(i))return O("property missing ':'");var P=H(s),z=R({type:f,property:x(C[0].replace(e,c)),value:P?x(P[0].replace(e,c)):c});return H(a),z}}function V(){var R=[];w(R);for(var C;C=L();)C!==!1&&(R.push(C),w(R));return R}return B(),V()}function x(S){return S?S.replace(l,c):c}return Zt=m,Zt}var Br;function Cc(){if(Br)return $e;Br=1;var e=$e&&$e.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty($e,"__esModule",{value:!0}),$e.default=n;const t=e(wc());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const a=(0,t.default)(r),l=typeof i=="function";return a.forEach(o=>{if(o.type!=="declaration")return;const{property:u,value:h}=o;l?i(u,h,o):h&&(s=s||{},s[u]=h)}),s}return $e}var tt={},Hr;function vc(){if(Hr)return tt;Hr=1,Object.defineProperty(tt,"__esModule",{value:!0}),tt.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(u){return!u||n.test(u)||e.test(u)},a=function(u,h){return h.toUpperCase()},l=function(u,h){return"".concat(h,"-")},o=function(u,h){return h===void 0&&(h={}),s(u)?u:(u=u.toLowerCase(),h.reactCompat?u=u.replace(i,l):u=u.replace(r,l),u.replace(t,a))};return tt.camelCase=o,tt}var nt,Vr;function Tc(){if(Vr)return nt;Vr=1;var e=nt&&nt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Cc()),n=vc();function r(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(l,o){l&&o&&(a[(0,n.camelCase)(l,s)]=o)}),a}return r.default=r,nt=r,nt}var Ic=Tc();const Mc=Qi(Ic),Ps=Ds("end"),Gn=Ds("start");function Ds(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Nc(e){const t=Gn(e),n=Ps(e);if(t&&n)return{start:t,end:n}}function ot(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Ur(e.position):"start"in e||"end"in e?Ur(e):"line"in e||"column"in e?In(e):""}function In(e){return $r(e&&e.line)+":"+$r(e&&e.column)}function Ur(e){return In(e&&e.start)+"-"+In(e&&e.end)}function $r(e){return e&&typeof e=="number"?e:1}class le extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},a=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(a=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const o=r.indexOf(":");o===-1?s.ruleId=r:(s.source=r.slice(0,o),s.ruleId=r.slice(o+1))}if(!s.place&&s.ancestors&&s.ancestors){const o=s.ancestors[s.ancestors.length-1];o&&(s.place=o.position)}const l=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=ot(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}le.prototype.file="";le.prototype.name="";le.prototype.reason="";le.prototype.message="";le.prototype.stack="";le.prototype.column=void 0;le.prototype.line=void 0;le.prototype.ancestors=void 0;le.prototype.cause=void 0;le.prototype.fatal=void 0;le.prototype.place=void 0;le.prototype.ruleId=void 0;le.prototype.source=void 0;const Xn={}.hasOwnProperty,Ec=new Map,Lc=/[A-Z]/g,Ac=new Set(["table","tbody","thead","tfoot","tr"]),jc=new Set(["td","th"]),Fs="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Rc(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Hc(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Bc(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Qn:Sc,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=Os(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function Os(e,t,n){if(t.type==="element")return Pc(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Dc(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Oc(e,t,n);if(t.type==="mdxjsEsm")return Fc(e,t);if(t.type==="root")return _c(e,t,n);if(t.type==="text")return zc(e,t)}function Pc(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Qn,e.schema=i),e.ancestors.push(t);const s=zs(e,t.tagName,!1),a=Vc(e,t);let l=Jn(e,t);return Ac.has(t.tagName)&&(l=l.filter(function(o){return typeof o=="string"?!cc(o):!0})),_s(e,a,s,t),Yn(a,l),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function Dc(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}dt(e,t.position)}function Fc(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);dt(e,t.position)}function Oc(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Qn,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:zs(e,t.name,!0),a=Uc(e,t),l=Jn(e,t);return _s(e,a,s,t),Yn(a,l),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function _c(e,t,n){const r={};return Yn(r,Jn(e,t)),e.create(t,e.Fragment,r,n)}function zc(e,t){return t.value}function _s(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Yn(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Bc(e,t,n){return r;function r(i,s,a,l){const u=Array.isArray(a.children)?n:t;return l?u(s,a,l):u(s,a)}}function Hc(e,t){return n;function n(r,i,s,a){const l=Array.isArray(s.children),o=Gn(r);return t(i,s,a,l,{columnNumber:o?o.column-1:void 0,fileName:e,lineNumber:o?o.line:void 0},void 0)}}function Vc(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Xn.call(t.properties,i)){const s=$c(e,i,t.properties[i]);if(s){const[a,l]=s;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&jc.has(t.tagName)?r=l:n[a]=l}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Uc(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const a=s.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else dt(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,s=e.evaluater.evaluateExpression(l.expression)}else dt(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Jn(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Ec;for(;++r<t.children.length;){const s=t.children[r];let a;if(e.passKeys){const o=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(o){const u=i.get(o)||0;a=o+"-"+u,i.set(o,u+1)}}const l=Os(e,s,a);l!==void 0&&n.push(l)}return n}function $c(e,t,n){const r=xc(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?sc(n):kc(n)),r.property==="style"){let i=typeof n=="object"?n:qc(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Kc(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?pc[r.property]||r.property:r.attribute,n]}}function qc(e,t){try{return Mc(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new le("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=Fs+"#cannot-parse-style-attribute",i}}function zs(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,a;for(;++s<i.length;){const l=Dr(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(s&&l.type==="Literal"),optional:!1}:l}r=a}else r=Dr(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Xn.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);dt(e)}function dt(e,t){const n=new le("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Fs+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Kc(e){const t={};let n;for(n in e)Xn.call(e,n)&&(t[Wc(n)]=e[n]);return t}function Wc(e){let t=e.replace(Lc,Qc);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Qc(e){return"-"+e.toLowerCase()}const en={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"]},Gc={};function Zn(e,t){const n=Gc,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Bs(e,r,i)}function Bs(e,t,n){if(Xc(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 qr(e.children,t,n)}return Array.isArray(e)?qr(e,t,n):""}function qr(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Bs(e[i],t,n);return r.join("")}function Xc(e){return!!(e&&typeof e=="object")}const Kr=document.createElement("i");function er(e){const t="&"+e+";";Kr.innerHTML=t;const n=Kr.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function xe(e,t,n,r){const i=e.length;let s=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);s<r.length;)a=r.slice(s,s+1e4),a.unshift(t,0),e.splice(...a),s+=1e4,t+=1e4}function be(e,t){return e.length>0?(xe(e,e.length,0,t),e):t}const Wr={}.hasOwnProperty;function Hs(e){const t={};let n=-1;for(;++n<e.length;)Yc(t,e[n]);return t}function Yc(e,t){let n;for(n in t){const i=(Wr.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let a;if(s)for(a in s){Wr.call(i,a)||(i[a]=[]);const l=s[a];Jc(i[a],Array.isArray(l)?l:l?[l]:[])}}}function Jc(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);xe(e,0,0,r)}function Vs(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Te(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const oe=_e(/[A-Za-z]/),ae=_e(/[\dA-Za-z]/),Zc=_e(/[#-'*+\--9=?A-Z^-~]/);function Lt(e){return e!==null&&(e<32||e===127)}const Mn=_e(/\d/),eh=_e(/[\dA-Fa-f]/),th=_e(/[!-/:-@[-`{-~]/);function _(e){return e!==null&&e<-2}function J(e){return e!==null&&(e<0||e===32)}function K(e){return e===-2||e===-1||e===32}const _t=_e(new RegExp("\\p{P}|\\p{S}","u")),He=_e(/\s/);function _e(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Ye(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let a="";if(s===37&&ae(e.charCodeAt(n+1))&&ae(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){const l=e.charCodeAt(n+1);s<56320&&l>56319&&l<57344?(a=String.fromCharCode(s,l),i=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function G(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(o){return K(o)?(e.enter(n),l(o)):t(o)}function l(o){return K(o)&&s++<i?(e.consume(o),l):(e.exit(n),t(o))}}const nh={tokenize:rh};function rh(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),G(e,t,"linePrefix")}function i(l){return e.enter("paragraph"),s(l)}function s(l){const o=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=o),n=o,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return _(l)?(e.consume(l),e.exit("chunkText"),s):(e.consume(l),a)}}const ih={tokenize:sh},Qr={tokenize:ah};function sh(e){const t=this,n=[];let r=0,i,s,a;return l;function l(M){if(r<n.length){const D=n[r];return t.containerState=D[1],e.attempt(D[0].continuation,o,u)(M)}return u(M)}function o(M){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&I();const D=t.events.length;let F=D,T;for(;F--;)if(t.events[F][0]==="exit"&&t.events[F][1].type==="chunkFlow"){T=t.events[F][1].end;break}g(r);let O=D;for(;O<t.events.length;)t.events[O][1].end={...T},O++;return xe(t.events,F+1,0,t.events.slice(D)),t.events.length=O,u(M)}return l(M)}function u(M){if(r===n.length){if(!i)return p(M);if(i.currentConstruct&&i.currentConstruct.concrete)return m(M);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Qr,h,c)(M)}function h(M){return i&&I(),g(r),p(M)}function c(M){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,m(M)}function p(M){return t.containerState={},e.attempt(Qr,f,m)(M)}function f(M){return r++,n.push([t.currentConstruct,t.containerState]),p(M)}function m(M){if(M===null){i&&I(),g(0),e.consume(M);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),x(M)}function x(M){if(M===null){S(e.exit("chunkFlow"),!0),g(0),e.consume(M);return}return _(M)?(e.consume(M),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(M),x)}function S(M,D){const F=t.sliceStream(M);if(D&&F.push(null),M.previous=s,s&&(s.next=M),s=M,i.defineSkip(M.start),i.write(F),t.parser.lazy[M.start.line]){let T=i.events.length;for(;T--;)if(i.events[T][1].start.offset<a&&(!i.events[T][1].end||i.events[T][1].end.offset>a))return;const O=t.events.length;let H=O,B,w;for(;H--;)if(t.events[H][0]==="exit"&&t.events[H][1].type==="chunkFlow"){if(B){w=t.events[H][1].end;break}B=!0}for(g(r),T=O;T<t.events.length;)t.events[T][1].end={...w},T++;xe(t.events,H+1,0,t.events.slice(O)),t.events.length=T}}function g(M){let D=n.length;for(;D-- >M;){const F=n[D];t.containerState=F[1],F[0].exit.call(t,e)}n.length=M}function I(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function ah(e,t,n){return G(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ge(e){if(e===null||J(e)||He(e))return 1;if(_t(e))return 2}function zt(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const Nn={name:"attention",resolveAll:lh,tokenize:oh};function lh(e,t){let n=-1,r,i,s,a,l,o,u,h;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;o=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},p={...e[n][1].start};Gr(c,-o),Gr(p,o),a={type:o>1?"strongSequence":"emphasisSequence",start:c,end:{...e[r][1].end}},l={type:o>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},s={type:o>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:o>1?"strong":"emphasis",start:{...a.start},end:{...l.end}},e[r][1].end={...a.start},e[n][1].start={...l.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=be(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=be(u,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),u=be(u,zt(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=be(u,[["exit",s,t],["enter",l,t],["exit",l,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,u=be(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,xe(e,r-1,n-r+3,u),n=r+u.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function oh(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Ge(r);let s;return a;function a(o){return s=o,e.enter("attentionSequence"),l(o)}function l(o){if(o===s)return e.consume(o),l;const u=e.exit("attentionSequence"),h=Ge(o),c=!h||h===2&&i||n.includes(o),p=!i||i===2&&h||n.includes(r);return u._open=!!(s===42?c:c&&(i||!p)),u._close=!!(s===42?p:p&&(h||!c)),t(o)}}function Gr(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const uh={name:"autolink",tokenize:ch};function ch(e,t,n){let r=0;return i;function i(f){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(f){return oe(f)?(e.consume(f),a):f===64?n(f):u(f)}function a(f){return f===43||f===45||f===46||ae(f)?(r=1,l(f)):u(f)}function l(f){return f===58?(e.consume(f),r=0,o):(f===43||f===45||f===46||ae(f))&&r++<32?(e.consume(f),l):(r=0,u(f))}function o(f){return f===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):f===null||f===32||f===60||Lt(f)?n(f):(e.consume(f),o)}function u(f){return f===64?(e.consume(f),h):Zc(f)?(e.consume(f),u):n(f)}function h(f){return ae(f)?c(f):n(f)}function c(f){return f===46?(e.consume(f),r=0,h):f===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):p(f)}function p(f){if((f===45||ae(f))&&r++<63){const m=f===45?p:c;return e.consume(f),m}return n(f)}}const bt={partial:!0,tokenize:hh};function hh(e,t,n){return r;function r(s){return K(s)?G(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||_(s)?t(s):n(s)}}const Us={continuation:{tokenize:fh},exit:ph,name:"blockQuote",tokenize:dh};function dh(e,t,n){const r=this;return i;function i(a){if(a===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),s}return n(a)}function s(a){return K(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function fh(e,t,n){const r=this;return i;function i(a){return K(a)?G(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(Us,t,n)(a)}}function ph(e){e.exit("blockQuote")}const $s={name:"characterEscape",tokenize:mh};function mh(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return th(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const qs={name:"characterReference",tokenize:gh};function gh(e,t,n){const r=this;let i=0,s,a;return l;function l(c){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),o}function o(c){return c===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(c),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,a=ae,h(c))}function u(c){return c===88||c===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(c),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,a=eh,h):(e.enter("characterReferenceValue"),s=7,a=Mn,h(c))}function h(c){if(c===59&&i){const p=e.exit("characterReferenceValue");return a===ae&&!er(r.sliceSerialize(p))?n(c):(e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(c)&&i++<s?(e.consume(c),h):n(c)}}const Xr={partial:!0,tokenize:yh},Yr={concrete:!0,name:"codeFenced",tokenize:xh};function xh(e,t,n){const r=this,i={partial:!0,tokenize:F};let s=0,a=0,l;return o;function o(T){return u(T)}function u(T){const O=r.events[r.events.length-1];return s=O&&O[1].type==="linePrefix"?O[2].sliceSerialize(O[1],!0).length:0,l=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(T)}function h(T){return T===l?(a++,e.consume(T),h):a<3?n(T):(e.exit("codeFencedFenceSequence"),K(T)?G(e,c,"whitespace")(T):c(T))}function c(T){return T===null||_(T)?(e.exit("codeFencedFence"),r.interrupt?t(T):e.check(Xr,x,D)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(T))}function p(T){return T===null||_(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(T)):K(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),G(e,f,"whitespace")(T)):T===96&&T===l?n(T):(e.consume(T),p)}function f(T){return T===null||_(T)?c(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(T))}function m(T){return T===null||_(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(T)):T===96&&T===l?n(T):(e.consume(T),m)}function x(T){return e.attempt(i,D,S)(T)}function S(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),g}function g(T){return s>0&&K(T)?G(e,I,"linePrefix",s+1)(T):I(T)}function I(T){return T===null||_(T)?e.check(Xr,x,D)(T):(e.enter("codeFlowValue"),M(T))}function M(T){return T===null||_(T)?(e.exit("codeFlowValue"),I(T)):(e.consume(T),M)}function D(T){return e.exit("codeFenced"),t(T)}function F(T,O,H){let B=0;return w;function w(C){return T.enter("lineEnding"),T.consume(C),T.exit("lineEnding"),E}function E(C){return T.enter("codeFencedFence"),K(C)?G(T,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):L(C)}function L(C){return C===l?(T.enter("codeFencedFenceSequence"),V(C)):H(C)}function V(C){return C===l?(B++,T.consume(C),V):B>=a?(T.exit("codeFencedFenceSequence"),K(C)?G(T,R,"whitespace")(C):R(C)):H(C)}function R(C){return C===null||_(C)?(T.exit("codeFencedFence"),O(C)):H(C)}}}function yh(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const tn={name:"codeIndented",tokenize:Sh},bh={partial:!0,tokenize:kh};function Sh(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),G(e,s,"linePrefix",5)(u)}function s(u){const h=r.events[r.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?o(u):_(u)?e.attempt(bh,a,o)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||_(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),l)}function o(u){return e.exit("codeIndented"),t(u)}}function kh(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):_(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):G(e,s,"linePrefix",5)(a)}function s(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):_(a)?i(a):n(a)}}const wh={name:"codeText",previous:vh,resolve:Ch,tokenize:Th};function Ch(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 vh(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Th(e,t,n){let r=0,i,s;return a;function a(c){return e.enter("codeText"),e.enter("codeTextSequence"),l(c)}function l(c){return c===96?(e.consume(c),r++,l):(e.exit("codeTextSequence"),o(c))}function o(c){return c===null?n(c):c===32?(e.enter("space"),e.consume(c),e.exit("space"),o):c===96?(s=e.enter("codeTextSequence"),i=0,h(c)):_(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):(e.enter("codeTextData"),u(c))}function u(c){return c===null||c===32||c===96||_(c)?(e.exit("codeTextData"),o(c)):(e.consume(c),u)}function h(c){return c===96?(e.consume(c),i++,h):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(c)):(s.type="codeTextData",u(c))}}class Ih{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&rt(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),rt(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),rt(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);rt(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);rt(this.left,n.reverse())}}}function rt(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 Ks(e){const t={};let n=-1,r,i,s,a,l,o,u;const h=new Ih(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(r=h.get(n),n&&r[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(o=r[1]._tokenizer.events,s=0,s<o.length&&o[s][1].type==="lineEndingBlank"&&(s+=2),s<o.length&&o[s][1].type==="content"))for(;++s<o.length&&o[s][1].type!=="content";)o[s][1].type==="chunkText"&&(o[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Mh(h,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(a=h.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(h.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=s);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...h.get(i)[1].start},l=h.slice(i,n),l.unshift(r),h.splice(i,n-i+1,l))}}return xe(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!u}function Mh(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,o=[],u={};let h,c,p=-1,f=n,m=0,x=0;const S=[x];for(;f;){for(;e.get(++i)[1]!==f;);s.push(i),f._tokenizer||(h=r.sliceStream(f),f.next||h.push(null),c&&a.defineSkip(f.start),f._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(h),f._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),c=f,f=f.next}for(f=n;++p<l.length;)l[p][0]==="exit"&&l[p-1][0]==="enter"&&l[p][1].type===l[p-1][1].type&&l[p][1].start.line!==l[p][1].end.line&&(x=p+1,S.push(x),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(a.events=[],f?(f._tokenizer=void 0,f.previous=void 0):S.pop(),p=S.length;p--;){const g=l.slice(S[p],S[p+1]),I=s.pop();o.push([I,I+g.length-1]),e.splice(I,2,g)}for(o.reverse(),p=-1;++p<o.length;)u[m+o[p][0]]=m+o[p][1],m+=o[p][1]-o[p][0]-1;return u}const Nh={resolve:Lh,tokenize:Ah},Eh={partial:!0,tokenize:jh};function Lh(e){return Ks(e),e}function Ah(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(l)}function i(l){return l===null?s(l):_(l)?e.check(Eh,a,s)(l):(e.consume(l),i)}function s(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function a(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function jh(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),G(e,s,"linePrefix")}function s(a){if(a===null||_(a))return n(a);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function Ws(e,t,n,r,i,s,a,l,o){const u=o||Number.POSITIVE_INFINITY;let h=0;return c;function c(g){return g===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(g),e.exit(s),p):g===null||g===32||g===41||Lt(g)?n(g):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),x(g))}function p(g){return g===62?(e.enter(s),e.consume(g),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),f(g))}function f(g){return g===62?(e.exit("chunkString"),e.exit(l),p(g)):g===null||g===60||_(g)?n(g):(e.consume(g),g===92?m:f)}function m(g){return g===60||g===62||g===92?(e.consume(g),f):f(g)}function x(g){return!h&&(g===null||g===41||J(g))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(g)):h<u&&g===40?(e.consume(g),h++,x):g===41?(e.consume(g),h--,x):g===null||g===32||g===40||Lt(g)?n(g):(e.consume(g),g===92?S:x)}function S(g){return g===40||g===41||g===92?(e.consume(g),x):x(g)}}function Qs(e,t,n,r,i,s){const a=this;let l=0,o;return u;function u(f){return e.enter(r),e.enter(i),e.consume(f),e.exit(i),e.enter(s),h}function h(f){return l>999||f===null||f===91||f===93&&!o||f===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(f):f===93?(e.exit(s),e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):_(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),c(f))}function c(f){return f===null||f===91||f===93||_(f)||l++>999?(e.exit("chunkString"),h(f)):(e.consume(f),o||(o=!K(f)),f===92?p:c)}function p(f){return f===91||f===92||f===93?(e.consume(f),l++,c):c(f)}}function Gs(e,t,n,r,i,s){let a;return l;function l(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),a=p===40?41:p,o):n(p)}function o(p){return p===a?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),u(p))}function u(p){return p===a?(e.exit(s),o(a)):p===null?n(p):_(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),G(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(p))}function h(p){return p===a||p===null||_(p)?(e.exit("chunkString"),u(p)):(e.consume(p),p===92?c:h)}function c(p){return p===a||p===92?(e.consume(p),h):h(p)}}function ut(e,t){let n;return r;function r(i){return _(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):K(i)?G(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Rh={name:"definition",tokenize:Dh},Ph={partial:!0,tokenize:Fh};function Dh(e,t,n){const r=this;let i;return s;function s(f){return e.enter("definition"),a(f)}function a(f){return Qs.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function l(f){return i=Te(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(e.enter("definitionMarker"),e.consume(f),e.exit("definitionMarker"),o):n(f)}function o(f){return J(f)?ut(e,u)(f):u(f)}function u(f){return Ws(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function h(f){return e.attempt(Ph,c,c)(f)}function c(f){return K(f)?G(e,p,"whitespace")(f):p(f)}function p(f){return f===null||_(f)?(e.exit("definition"),r.parser.defined.push(i),t(f)):n(f)}}function Fh(e,t,n){return r;function r(l){return J(l)?ut(e,i)(l):n(l)}function i(l){return Gs(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function s(l){return K(l)?G(e,a,"whitespace")(l):a(l)}function a(l){return l===null||_(l)?t(l):n(l)}}const Oh={name:"hardBreakEscape",tokenize:_h};function _h(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return _(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const zh={name:"headingAtx",resolve:Bh,tokenize:Hh};function Bh(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},xe(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function Hh(e,t,n){let r=0;return i;function i(h){return e.enter("atxHeading"),s(h)}function s(h){return e.enter("atxHeadingSequence"),a(h)}function a(h){return h===35&&r++<6?(e.consume(h),a):h===null||J(h)?(e.exit("atxHeadingSequence"),l(h)):n(h)}function l(h){return h===35?(e.enter("atxHeadingSequence"),o(h)):h===null||_(h)?(e.exit("atxHeading"),t(h)):K(h)?G(e,l,"whitespace")(h):(e.enter("atxHeadingText"),u(h))}function o(h){return h===35?(e.consume(h),o):(e.exit("atxHeadingSequence"),l(h))}function u(h){return h===null||h===35||J(h)?(e.exit("atxHeadingText"),l(h)):(e.consume(h),u)}}const Vh=["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"],Jr=["pre","script","style","textarea"],Uh={concrete:!0,name:"htmlFlow",resolveTo:Kh,tokenize:Wh},$h={partial:!0,tokenize:Gh},qh={partial:!0,tokenize:Qh};function Kh(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 Wh(e,t,n){const r=this;let i,s,a,l,o;return u;function u(b){return h(b)}function h(b){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(b),c}function c(b){return b===33?(e.consume(b),p):b===47?(e.consume(b),s=!0,x):b===63?(e.consume(b),i=3,r.interrupt?t:y):oe(b)?(e.consume(b),a=String.fromCharCode(b),S):n(b)}function p(b){return b===45?(e.consume(b),i=2,f):b===91?(e.consume(b),i=5,l=0,m):oe(b)?(e.consume(b),i=4,r.interrupt?t:y):n(b)}function f(b){return b===45?(e.consume(b),r.interrupt?t:y):n(b)}function m(b){const ce="CDATA[";return b===ce.charCodeAt(l++)?(e.consume(b),l===ce.length?r.interrupt?t:L:m):n(b)}function x(b){return oe(b)?(e.consume(b),a=String.fromCharCode(b),S):n(b)}function S(b){if(b===null||b===47||b===62||J(b)){const ce=b===47,Ie=a.toLowerCase();return!ce&&!s&&Jr.includes(Ie)?(i=1,r.interrupt?t(b):L(b)):Vh.includes(a.toLowerCase())?(i=6,ce?(e.consume(b),g):r.interrupt?t(b):L(b)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(b):s?I(b):M(b))}return b===45||ae(b)?(e.consume(b),a+=String.fromCharCode(b),S):n(b)}function g(b){return b===62?(e.consume(b),r.interrupt?t:L):n(b)}function I(b){return K(b)?(e.consume(b),I):w(b)}function M(b){return b===47?(e.consume(b),w):b===58||b===95||oe(b)?(e.consume(b),D):K(b)?(e.consume(b),M):w(b)}function D(b){return b===45||b===46||b===58||b===95||ae(b)?(e.consume(b),D):F(b)}function F(b){return b===61?(e.consume(b),T):K(b)?(e.consume(b),F):M(b)}function T(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),o=b,O):K(b)?(e.consume(b),T):H(b)}function O(b){return b===o?(e.consume(b),o=null,B):b===null||_(b)?n(b):(e.consume(b),O)}function H(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||J(b)?F(b):(e.consume(b),H)}function B(b){return b===47||b===62||K(b)?M(b):n(b)}function w(b){return b===62?(e.consume(b),E):n(b)}function E(b){return b===null||_(b)?L(b):K(b)?(e.consume(b),E):n(b)}function L(b){return b===45&&i===2?(e.consume(b),P):b===60&&i===1?(e.consume(b),z):b===62&&i===4?(e.consume(b),se):b===63&&i===3?(e.consume(b),y):b===93&&i===5?(e.consume(b),ue):_(b)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check($h,ye,V)(b)):b===null||_(b)?(e.exit("htmlFlowData"),V(b)):(e.consume(b),L)}function V(b){return e.check(qh,R,ye)(b)}function R(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),C}function C(b){return b===null||_(b)?V(b):(e.enter("htmlFlowData"),L(b))}function P(b){return b===45?(e.consume(b),y):L(b)}function z(b){return b===47?(e.consume(b),a="",ne):L(b)}function ne(b){if(b===62){const ce=a.toLowerCase();return Jr.includes(ce)?(e.consume(b),se):L(b)}return oe(b)&&a.length<8?(e.consume(b),a+=String.fromCharCode(b),ne):L(b)}function ue(b){return b===93?(e.consume(b),y):L(b)}function y(b){return b===62?(e.consume(b),se):b===45&&i===2?(e.consume(b),y):L(b)}function se(b){return b===null||_(b)?(e.exit("htmlFlowData"),ye(b)):(e.consume(b),se)}function ye(b){return e.exit("htmlFlow"),t(b)}}function Qh(e,t,n){const r=this;return i;function i(a){return _(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):n(a)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function Gh(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(bt,t,n)}}const Xh={name:"htmlText",tokenize:Yh};function Yh(e,t,n){const r=this;let i,s,a;return l;function l(y){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(y),o}function o(y){return y===33?(e.consume(y),u):y===47?(e.consume(y),F):y===63?(e.consume(y),M):oe(y)?(e.consume(y),H):n(y)}function u(y){return y===45?(e.consume(y),h):y===91?(e.consume(y),s=0,m):oe(y)?(e.consume(y),I):n(y)}function h(y){return y===45?(e.consume(y),f):n(y)}function c(y){return y===null?n(y):y===45?(e.consume(y),p):_(y)?(a=c,z(y)):(e.consume(y),c)}function p(y){return y===45?(e.consume(y),f):c(y)}function f(y){return y===62?P(y):y===45?p(y):c(y)}function m(y){const se="CDATA[";return y===se.charCodeAt(s++)?(e.consume(y),s===se.length?x:m):n(y)}function x(y){return y===null?n(y):y===93?(e.consume(y),S):_(y)?(a=x,z(y)):(e.consume(y),x)}function S(y){return y===93?(e.consume(y),g):x(y)}function g(y){return y===62?P(y):y===93?(e.consume(y),g):x(y)}function I(y){return y===null||y===62?P(y):_(y)?(a=I,z(y)):(e.consume(y),I)}function M(y){return y===null?n(y):y===63?(e.consume(y),D):_(y)?(a=M,z(y)):(e.consume(y),M)}function D(y){return y===62?P(y):M(y)}function F(y){return oe(y)?(e.consume(y),T):n(y)}function T(y){return y===45||ae(y)?(e.consume(y),T):O(y)}function O(y){return _(y)?(a=O,z(y)):K(y)?(e.consume(y),O):P(y)}function H(y){return y===45||ae(y)?(e.consume(y),H):y===47||y===62||J(y)?B(y):n(y)}function B(y){return y===47?(e.consume(y),P):y===58||y===95||oe(y)?(e.consume(y),w):_(y)?(a=B,z(y)):K(y)?(e.consume(y),B):P(y)}function w(y){return y===45||y===46||y===58||y===95||ae(y)?(e.consume(y),w):E(y)}function E(y){return y===61?(e.consume(y),L):_(y)?(a=E,z(y)):K(y)?(e.consume(y),E):B(y)}function L(y){return y===null||y===60||y===61||y===62||y===96?n(y):y===34||y===39?(e.consume(y),i=y,V):_(y)?(a=L,z(y)):K(y)?(e.consume(y),L):(e.consume(y),R)}function V(y){return y===i?(e.consume(y),i=void 0,C):y===null?n(y):_(y)?(a=V,z(y)):(e.consume(y),V)}function R(y){return y===null||y===34||y===39||y===60||y===61||y===96?n(y):y===47||y===62||J(y)?B(y):(e.consume(y),R)}function C(y){return y===47||y===62||J(y)?B(y):n(y)}function P(y){return y===62?(e.consume(y),e.exit("htmlTextData"),e.exit("htmlText"),t):n(y)}function z(y){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),ne}function ne(y){return K(y)?G(e,ue,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(y):ue(y)}function ue(y){return e.enter("htmlTextData"),a(y)}}const tr={name:"labelEnd",resolveAll:td,resolveTo:nd,tokenize:rd},Jh={tokenize:id},Zh={tokenize:sd},ed={tokenize:ad};function td(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&xe(e,0,e.length,n),e}function nd(e,t){let n=e.length,r=0,i,s,a,l;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const o={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[s][1].start},end:{...e[a][1].end}},h={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",o,t],["enter",u,t]],l=be(l,e.slice(s+1,s+r+3)),l=be(l,[["enter",h,t]]),l=be(l,zt(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),l=be(l,[["exit",h,t],e[a-2],e[a-1],["exit",u,t]]),l=be(l,e.slice(a+1)),l=be(l,[["exit",o,t]]),xe(e,s,e.length,l),e}function rd(e,t,n){const r=this;let i=r.events.length,s,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return l;function l(p){return s?s._inactive?c(p):(a=r.parser.defined.includes(Te(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),o):n(p)}function o(p){return p===40?e.attempt(Jh,h,a?h:c)(p):p===91?e.attempt(Zh,h,a?u:c)(p):a?h(p):c(p)}function u(p){return e.attempt(ed,h,c)(p)}function h(p){return t(p)}function c(p){return s._balanced=!0,n(p)}}function id(e,t,n){return r;function r(c){return e.enter("resource"),e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),i}function i(c){return J(c)?ut(e,s)(c):s(c)}function s(c){return c===41?h(c):Ws(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(c)}function a(c){return J(c)?ut(e,o)(c):h(c)}function l(c){return n(c)}function o(c){return c===34||c===39||c===40?Gs(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(c):h(c)}function u(c){return J(c)?ut(e,h)(c):h(c)}function h(c){return c===41?(e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),e.exit("resource"),t):n(c)}}function sd(e,t,n){const r=this;return i;function i(l){return Qs.call(r,e,s,a,"reference","referenceMarker","referenceString")(l)}function s(l){return r.parser.defined.includes(Te(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function ad(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const ld={name:"labelStartImage",resolveAll:tr.resolveAll,tokenize:od};function od(e,t,n){const r=this;return i;function i(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),s}function s(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),a):n(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const ud={name:"labelStartLink",resolveAll:tr.resolveAll,tokenize:cd};function cd(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),s}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const nn={name:"lineEnding",tokenize:hd};function hd(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),G(e,t,"linePrefix")}}const Nt={name:"thematicBreak",tokenize:dd};function dd(e,t,n){let r=0,i;return s;function s(u){return e.enter("thematicBreak"),a(u)}function a(u){return i=u,l(u)}function l(u){return u===i?(e.enter("thematicBreakSequence"),o(u)):r>=3&&(u===null||_(u))?(e.exit("thematicBreak"),t(u)):n(u)}function o(u){return u===i?(e.consume(u),r++,o):(e.exit("thematicBreakSequence"),K(u)?G(e,l,"whitespace")(u):l(u))}}const de={continuation:{tokenize:gd},exit:yd,name:"list",tokenize:md},fd={partial:!0,tokenize:bd},pd={partial:!0,tokenize:xd};function md(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return l;function l(f){const m=r.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||f===r.containerState.marker:Mn(f)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),f===42||f===45?e.check(Nt,n,u)(f):u(f);if(!r.interrupt||f===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),o(f)}return n(f)}function o(f){return Mn(f)&&++a<10?(e.consume(f),o):(!r.interrupt||a<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(e.exit("listItemValue"),u(f)):n(f)}function u(f){return e.enter("listItemMarker"),e.consume(f),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||f,e.check(bt,r.interrupt?n:h,e.attempt(fd,p,c))}function h(f){return r.containerState.initialBlankLine=!0,s++,p(f)}function c(f){return K(f)?(e.enter("listItemPrefixWhitespace"),e.consume(f),e.exit("listItemPrefixWhitespace"),p):n(f)}function p(f){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(f)}}function gd(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(bt,i,s);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,G(e,t,"listItemIndent",r.containerState.size+1)(l)}function s(l){return r.containerState.furtherBlankLines||!K(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(pd,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,G(e,e.attempt(de,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function xd(e,t,n){const r=this;return G(e,i,"listItemIndent",r.containerState.size+1);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(s):n(s)}}function yd(e){e.exit(this.containerState.type)}function bd(e,t,n){const r=this;return G(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=r.events[r.events.length-1];return!K(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const Zr={name:"setextUnderline",resolveTo:Sd,tokenize:kd};function Sd(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",a,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function kd(e,t,n){const r=this;let i;return s;function s(u){let h=r.events.length,c;for(;h--;)if(r.events[h][1].type!=="lineEnding"&&r.events[h][1].type!=="linePrefix"&&r.events[h][1].type!=="content"){c=r.events[h][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter("setextHeadingLine"),i=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===i?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),K(u)?G(e,o,"lineSuffix")(u):o(u))}function o(u){return u===null||_(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const wd={tokenize:Cd};function Cd(e){const t=this,n=e.attempt(bt,r,e.attempt(this.parser.constructs.flowInitial,i,G(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Nh,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const vd={resolveAll:Ys()},Td=Xs("string"),Id=Xs("text");function Xs(e){return{resolveAll:Ys(e==="text"?Md:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,a,l);return a;function a(h){return u(h)?s(h):l(h)}function l(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),o}function o(h){return u(h)?(n.exit("data"),s(h)):(n.consume(h),o)}function u(h){if(h===null)return!0;const c=i[h];let p=-1;if(c)for(;++p<c.length;){const f=c[p];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function Ys(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function Md(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,a=-1,l=0,o;for(;s--;){const u=i[s];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(u===-2)o=!0,l++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const u={type:n===e.length||o||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?a:r.start._bufferIndex+a,_index:r.start._index+s,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const Nd={42:de,43:de,45:de,48:de,49:de,50:de,51:de,52:de,53:de,54:de,55:de,56:de,57:de,62:Us},Ed={91:Rh},Ld={[-2]:tn,[-1]:tn,32:tn},Ad={35:zh,42:Nt,45:[Zr,Nt],60:Uh,61:Zr,95:Nt,96:Yr,126:Yr},jd={38:qs,92:$s},Rd={[-5]:nn,[-4]:nn,[-3]:nn,33:ld,38:qs,42:Nn,60:[uh,Xh],91:ud,92:[Oh,$s],93:tr,95:Nn,96:wh},Pd={null:[Nn,vd]},Dd={null:[42,95]},Fd={null:[]},Od=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Dd,contentInitial:Ed,disable:Fd,document:Nd,flow:Ad,flowInitial:Ld,insideSpan:Pd,string:jd,text:Rd},Symbol.toStringTag,{value:"Module"}));function _d(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let a=[],l=[];const o={attempt:O(F),check:O(T),consume:I,enter:M,exit:D,interrupt:O(T,{interrupt:!0})},u={code:null,containerState:{},defineSkip:x,events:[],now:m,parser:e,previous:null,sliceSerialize:p,sliceStream:f,write:c};let h=t.tokenize.call(u,o);return t.resolveAll&&s.push(t),u;function c(E){return a=be(a,E),S(),a[a.length-1]!==null?[]:(H(t,0),u.events=zt(s,u.events,u),u.events)}function p(E,L){return Bd(f(E),L)}function f(E){return zd(a,E)}function m(){const{_bufferIndex:E,_index:L,line:V,column:R,offset:C}=r;return{_bufferIndex:E,_index:L,line:V,column:R,offset:C}}function x(E){i[E.line]=E.column,w()}function S(){let E;for(;r._index<a.length;){const L=a[r._index];if(typeof L=="string")for(E=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===E&&r._bufferIndex<L.length;)g(L.charCodeAt(r._bufferIndex));else g(L)}}function g(E){h=h(E)}function I(E){_(E)?(r.line++,r.column=1,r.offset+=E===-3?2:1,w()):E!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=E}function M(E,L){const V=L||{};return V.type=E,V.start=m(),u.events.push(["enter",V,u]),l.push(V),V}function D(E){const L=l.pop();return L.end=m(),u.events.push(["exit",L,u]),L}function F(E,L){H(E,L.from)}function T(E,L){L.restore()}function O(E,L){return V;function V(R,C,P){let z,ne,ue,y;return Array.isArray(R)?ye(R):"tokenize"in R?ye([R]):se(R);function se(re){return De;function De(U){const ke=U!==null&&re[U],he=U!==null&&re.null,we=[...Array.isArray(ke)?ke:ke?[ke]:[],...Array.isArray(he)?he:he?[he]:[]];return ye(we)(U)}}function ye(re){return z=re,ne=0,re.length===0?P:b(re[ne])}function b(re){return De;function De(U){return y=B(),ue=re,re.partial||(u.currentConstruct=re),re.name&&u.parser.constructs.disable.null.includes(re.name)?Ie():re.tokenize.call(L?Object.assign(Object.create(u),L):u,o,ce,Ie)(U)}}function ce(re){return E(ue,y),C}function Ie(re){return y.restore(),++ne<z.length?b(z[ne]):P}}}function H(E,L){E.resolveAll&&!s.includes(E)&&s.push(E),E.resolve&&xe(u.events,L,u.events.length-L,E.resolve(u.events.slice(L),u)),E.resolveTo&&(u.events=E.resolveTo(u.events,u))}function B(){const E=m(),L=u.previous,V=u.currentConstruct,R=u.events.length,C=Array.from(l);return{from:R,restore:P};function P(){r=E,u.previous=L,u.currentConstruct=V,u.events.length=R,l=C,w()}}function w(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function zd(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,s)];else{if(a=e.slice(n,i),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}s>0&&a.push(e[i].slice(0,s))}return a}function Bd(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let a;if(typeof s=="string")a=s;else switch(s){case-5:{a="\r";break}case-4:{a=`
|
|
5
|
-
`;break}case-3:{a=`\r
|
|
6
|
-
`;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(s)}i=s===-2,r.push(a)}return r.join("")}function Hd(e){const r={constructs:Hs([Od,...(e||{}).extensions||[]]),content:i(nh),defined:[],document:i(ih),flow:i(wd),lazy:{},string:i(Td),text:i(Id)};return r;function i(s){return a;function a(l){return _d(r,s,l)}}}function Vd(e){for(;!Ks(e););return e}const ei=/[\0\t\n\r]/g;function Ud(){let e=1,t="",n=!0,r;return i;function i(s,a,l){const o=[];let u,h,c,p,f;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(a||void 0).decode(s)),c=0,t="",n&&(s.charCodeAt(0)===65279&&c++,n=void 0);c<s.length;){if(ei.lastIndex=c,u=ei.exec(s),p=u&&u.index!==void 0?u.index:s.length,f=s.charCodeAt(p),!u){t=s.slice(c);break}if(f===10&&c===p&&r)o.push(-3),r=void 0;else switch(r&&(o.push(-5),r=void 0),c<p&&(o.push(s.slice(c,p)),e+=p-c),f){case 0:{o.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,o.push(-2);e++<h;)o.push(-1);break}case 10:{o.push(-4),e=1;break}default:r=!0,e=1}c=p+1}return l&&(r&&o.push(-5),t&&o.push(t),o.push(null)),o}}const $d=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function qd(e){return e.replace($d,Kd)}function Kd(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return Vs(n.slice(s?2:1),s?16:10)}return er(n)||e}const Js={}.hasOwnProperty;function Wd(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),Qd(n)(Vd(Hd(n).document().write(Ud()(e,t,!0))))}function Qd(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(pr),autolinkProtocol:B,autolinkEmail:B,atxHeading:s(hr),blockQuote:s(he),characterEscape:B,characterReference:B,codeFenced:s(we),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(we,a),codeText:s(Le,a),codeTextData:B,data:B,codeFlowValue:B,definition:s(Kt),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(kt),hardBreakEscape:s(dr),hardBreakTrailing:s(dr),htmlFlow:s(fr,a),htmlFlowData:B,htmlText:s(fr,a),htmlTextData:B,image:s(_a),label:a,link:s(pr),listItem:s(za),listItemValue:p,listOrdered:s(mr,c),listUnordered:s(mr),paragraph:s(Ba),reference:b,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(hr),strong:s(Ha),thematicBreak:s(Ua)},exit:{atxHeading:o(),atxHeadingSequence:F,autolink:o(),autolinkEmail:ke,autolinkProtocol:U,blockQuote:o(),characterEscapeValue:w,characterReferenceMarkerHexadecimal:Ie,characterReferenceMarkerNumeric:Ie,characterReferenceValue:re,characterReference:De,codeFenced:o(S),codeFencedFence:x,codeFencedFenceInfo:f,codeFencedFenceMeta:m,codeFlowValue:w,codeIndented:o(g),codeText:o(C),codeTextData:w,data:w,definition:o(),definitionDestinationString:D,definitionLabelString:I,definitionTitleString:M,emphasis:o(),hardBreakEscape:o(L),hardBreakTrailing:o(L),htmlFlow:o(V),htmlFlowData:w,htmlText:o(R),htmlTextData:w,image:o(z),label:ue,labelText:ne,lineEnding:E,link:o(P),listItem:o(),listOrdered:o(),listUnordered:o(),paragraph:o(),referenceString:ce,resourceDestinationString:y,resourceTitleString:se,resource:ye,setextHeading:o(H),setextHeadingLineSequence:O,setextHeadingText:T,strong:o(),thematicBreak:o()}};Zs(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(N){let j={type:"root",children:[]};const $={stack:[j],tokenStack:[],config:t,enter:l,exit:u,buffer:a,resume:h,data:n},W=[];let X=-1;for(;++X<N.length;)if(N[X][1].type==="listOrdered"||N[X][1].type==="listUnordered")if(N[X][0]==="enter")W.push(X);else{const Ce=W.pop();X=i(N,Ce,X)}for(X=-1;++X<N.length;){const Ce=t[N[X][0]];Js.call(Ce,N[X][1].type)&&Ce[N[X][1].type].call(Object.assign({sliceSerialize:N[X][2].sliceSerialize},$),N[X][1])}if($.tokenStack.length>0){const Ce=$.tokenStack[$.tokenStack.length-1];(Ce[1]||ti).call($,void 0,Ce[0])}for(j.position={start:Fe(N.length>0?N[0][1].start:{line:1,column:1,offset:0}),end:Fe(N.length>0?N[N.length-2][1].end:{line:1,column:1,offset:0})},X=-1;++X<t.transforms.length;)j=t.transforms[X](j)||j;return j}function i(N,j,$){let W=j-1,X=-1,Ce=!1,ze,Ae,Je,Ze;for(;++W<=$;){const me=N[W];switch(me[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{me[0]==="enter"?X++:X--,Ze=void 0;break}case"lineEndingBlank":{me[0]==="enter"&&(ze&&!Ze&&!X&&!Je&&(Je=W),Ze=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ze=void 0}if(!X&&me[0]==="enter"&&me[1].type==="listItemPrefix"||X===-1&&me[0]==="exit"&&(me[1].type==="listUnordered"||me[1].type==="listOrdered")){if(ze){let Ue=W;for(Ae=void 0;Ue--;){const je=N[Ue];if(je[1].type==="lineEnding"||je[1].type==="lineEndingBlank"){if(je[0]==="exit")continue;Ae&&(N[Ae][1].type="lineEndingBlank",Ce=!0),je[1].type="lineEnding",Ae=Ue}else if(!(je[1].type==="linePrefix"||je[1].type==="blockQuotePrefix"||je[1].type==="blockQuotePrefixWhitespace"||je[1].type==="blockQuoteMarker"||je[1].type==="listItemIndent"))break}Je&&(!Ae||Je<Ae)&&(ze._spread=!0),ze.end=Object.assign({},Ae?N[Ae][1].start:me[1].end),N.splice(Ae||W,0,["exit",ze,me[2]]),W++,$++}if(me[1].type==="listItemPrefix"){const Ue={type:"listItem",_spread:!1,start:Object.assign({},me[1].start),end:void 0};ze=Ue,N.splice(W,0,["enter",Ue,me[2]]),W++,$++,Je=void 0,Ze=!0}}}return N[j][1]._spread=Ce,$}function s(N,j){return $;function $(W){l.call(this,N(W),W),j&&j.call(this,W)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(N,j,$){this.stack[this.stack.length-1].children.push(N),this.stack.push(N),this.tokenStack.push([j,$||void 0]),N.position={start:Fe(j.start),end:void 0}}function o(N){return j;function j($){N&&N.call(this,$),u.call(this,$)}}function u(N,j){const $=this.stack.pop(),W=this.tokenStack.pop();if(W)W[0].type!==N.type&&(j?j.call(this,N,W[0]):(W[1]||ti).call(this,N,W[0]));else throw new Error("Cannot close `"+N.type+"` ("+ot({start:N.start,end:N.end})+"): it’s not open");$.position.end=Fe(N.end)}function h(){return Zn(this.stack.pop())}function c(){this.data.expectingFirstListItemValue=!0}function p(N){if(this.data.expectingFirstListItemValue){const j=this.stack[this.stack.length-2];j.start=Number.parseInt(this.sliceSerialize(N),10),this.data.expectingFirstListItemValue=void 0}}function f(){const N=this.resume(),j=this.stack[this.stack.length-1];j.lang=N}function m(){const N=this.resume(),j=this.stack[this.stack.length-1];j.meta=N}function x(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const N=this.resume(),j=this.stack[this.stack.length-1];j.value=N.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const N=this.resume(),j=this.stack[this.stack.length-1];j.value=N.replace(/(\r?\n|\r)$/g,"")}function I(N){const j=this.resume(),$=this.stack[this.stack.length-1];$.label=j,$.identifier=Te(this.sliceSerialize(N)).toLowerCase()}function M(){const N=this.resume(),j=this.stack[this.stack.length-1];j.title=N}function D(){const N=this.resume(),j=this.stack[this.stack.length-1];j.url=N}function F(N){const j=this.stack[this.stack.length-1];if(!j.depth){const $=this.sliceSerialize(N).length;j.depth=$}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function O(N){const j=this.stack[this.stack.length-1];j.depth=this.sliceSerialize(N).codePointAt(0)===61?1:2}function H(){this.data.setextHeadingSlurpLineEnding=void 0}function B(N){const $=this.stack[this.stack.length-1].children;let W=$[$.length-1];(!W||W.type!=="text")&&(W=Va(),W.position={start:Fe(N.start),end:void 0},$.push(W)),this.stack.push(W)}function w(N){const j=this.stack.pop();j.value+=this.sliceSerialize(N),j.position.end=Fe(N.end)}function E(N){const j=this.stack[this.stack.length-1];if(this.data.atHardBreak){const $=j.children[j.children.length-1];$.position.end=Fe(N.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(j.type)&&(B.call(this,N),w.call(this,N))}function L(){this.data.atHardBreak=!0}function V(){const N=this.resume(),j=this.stack[this.stack.length-1];j.value=N}function R(){const N=this.resume(),j=this.stack[this.stack.length-1];j.value=N}function C(){const N=this.resume(),j=this.stack[this.stack.length-1];j.value=N}function P(){const N=this.stack[this.stack.length-1];if(this.data.inReference){const j=this.data.referenceType||"shortcut";N.type+="Reference",N.referenceType=j,delete N.url,delete N.title}else delete N.identifier,delete N.label;this.data.referenceType=void 0}function z(){const N=this.stack[this.stack.length-1];if(this.data.inReference){const j=this.data.referenceType||"shortcut";N.type+="Reference",N.referenceType=j,delete N.url,delete N.title}else delete N.identifier,delete N.label;this.data.referenceType=void 0}function ne(N){const j=this.sliceSerialize(N),$=this.stack[this.stack.length-2];$.label=qd(j),$.identifier=Te(j).toLowerCase()}function ue(){const N=this.stack[this.stack.length-1],j=this.resume(),$=this.stack[this.stack.length-1];if(this.data.inReference=!0,$.type==="link"){const W=N.children;$.children=W}else $.alt=j}function y(){const N=this.resume(),j=this.stack[this.stack.length-1];j.url=N}function se(){const N=this.resume(),j=this.stack[this.stack.length-1];j.title=N}function ye(){this.data.inReference=void 0}function b(){this.data.referenceType="collapsed"}function ce(N){const j=this.resume(),$=this.stack[this.stack.length-1];$.label=j,$.identifier=Te(this.sliceSerialize(N)).toLowerCase(),this.data.referenceType="full"}function Ie(N){this.data.characterReferenceType=N.type}function re(N){const j=this.sliceSerialize(N),$=this.data.characterReferenceType;let W;$?(W=Vs(j,$==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):W=er(j);const X=this.stack[this.stack.length-1];X.value+=W}function De(N){const j=this.stack.pop();j.position.end=Fe(N.end)}function U(N){w.call(this,N);const j=this.stack[this.stack.length-1];j.url=this.sliceSerialize(N)}function ke(N){w.call(this,N);const j=this.stack[this.stack.length-1];j.url="mailto:"+this.sliceSerialize(N)}function he(){return{type:"blockquote",children:[]}}function we(){return{type:"code",lang:null,meta:null,value:""}}function Le(){return{type:"inlineCode",value:""}}function Kt(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function kt(){return{type:"emphasis",children:[]}}function hr(){return{type:"heading",depth:0,children:[]}}function dr(){return{type:"break"}}function fr(){return{type:"html",value:""}}function _a(){return{type:"image",title:null,url:"",alt:null}}function pr(){return{type:"link",title:null,url:"",children:[]}}function mr(N){return{type:"list",ordered:N.type==="listOrdered",start:null,spread:N._spread,children:[]}}function za(N){return{type:"listItem",spread:N._spread,checked:null,children:[]}}function Ba(){return{type:"paragraph",children:[]}}function Ha(){return{type:"strong",children:[]}}function Va(){return{type:"text",value:""}}function Ua(){return{type:"thematicBreak"}}}function Fe(e){return{line:e.line,column:e.column,offset:e.offset}}function Zs(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Zs(e,r):Gd(e,r)}}function Gd(e,t){let n;for(n in t)if(Js.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function ti(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ot({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ot({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ot({start:t.start,end:t.end})+") is still open")}function Xd(e){const t=this;t.parser=n;function n(r){return Wd(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Yd(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Jd(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
7
|
-
`}]}function Zd(e,t){const n=t.value?t.value+`
|
|
8
|
-
`:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function ef(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function tf(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nf(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=Ye(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let a,l=e.footnoteCounts.get(r);l===void 0?(l=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=s+1,l+=1,e.footnoteCounts.set(r,l);const o={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,o);const u={type:"element",tagName:"sup",properties:{},children:[o]};return e.patch(t,u),e.applyData(t,u)}function rf(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function sf(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function ea(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function af(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ea(e,t);const i={src:Ye(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function lf(e,t){const n={src:Ye(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function of(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function uf(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ea(e,t);const i={href:Ye(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function cf(e,t){const n={href:Ye(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function hf(e,t,n){const r=e.all(t),i=n?df(n):ta(t),s={},a=[];if(typeof t.checked=="boolean"){const h=r[0];let c;h&&h.type==="element"&&h.tagName==="p"?c=h:(c={type:"element",tagName:"p",properties:{},children:[]},r.unshift(c)),c.children.length>0&&c.children.unshift({type:"text",value:" "}),c.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const h=r[l];(i||l!==0||h.type!=="element"||h.tagName!=="p")&&a.push({type:"text",value:`
|
|
9
|
-
`}),h.type==="element"&&h.tagName==="p"&&!i?a.push(...h.children):a.push(h)}const o=r[r.length-1];o&&(i||o.type!=="element"||o.tagName!=="p")&&a.push({type:"text",value:`
|
|
10
|
-
`});const u={type:"element",tagName:"li",properties:s,children:a};return e.patch(t,u),e.applyData(t,u)}function df(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=ta(n[r])}return t}function ta(e){const t=e.spread;return t??e.children.length>1}function ff(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function pf(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function mf(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function gf(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function xf(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=Gn(t.children[1]),o=Ps(t.children[t.children.length-1]);l&&o&&(a.position={start:l,end:o}),i.push(a)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function yf(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,l=a?a.length:t.children.length;let o=-1;const u=[];for(;++o<l;){const c=t.children[o],p={},f=a?a[o]:void 0;f&&(p.align=f);let m={type:"element",tagName:s,properties:p,children:[]};c&&(m.children=e.all(c),e.patch(c,m),m=e.applyData(c,m)),u.push(m)}const h={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,h),e.applyData(t,h)}function bf(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const ni=9,ri=32;function Sf(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(ii(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(ii(t.slice(i),i>0,!1)),s.join("")}function ii(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===ni||s===ri;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===ni||s===ri;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function kf(e,t){const n={type:"text",value:Sf(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function wf(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Cf={blockquote:Yd,break:Jd,code:Zd,delete:ef,emphasis:tf,footnoteReference:nf,heading:rf,html:sf,imageReference:af,image:lf,inlineCode:of,linkReference:uf,link:cf,listItem:hf,list:ff,paragraph:pf,root:mf,strong:gf,table:xf,tableCell:bf,tableRow:yf,text:kf,thematicBreak:wf,toml:wt,yaml:wt,definition:wt,footnoteDefinition:wt};function wt(){}const na=-1,Bt=0,ct=1,At=2,nr=3,rr=4,ir=5,sr=6,ra=7,ia=8,si=typeof self=="object"?self:globalThis,vf=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,a]=t[i];switch(s){case Bt:case na:return n(a,i);case ct:{const l=n([],i);for(const o of a)l.push(r(o));return l}case At:{const l=n({},i);for(const[o,u]of a)l[r(o)]=r(u);return l}case nr:return n(new Date(a),i);case rr:{const{source:l,flags:o}=a;return n(new RegExp(l,o),i)}case ir:{const l=n(new Map,i);for(const[o,u]of a)l.set(r(o),r(u));return l}case sr:{const l=n(new Set,i);for(const o of a)l.add(r(o));return l}case ra:{const{name:l,message:o}=a;return n(new si[l](o),i)}case ia:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:l}=new Uint8Array(a);return n(new DataView(l),a)}}return n(new si[s](a),i)};return r},ai=e=>vf(new Map,e)(0),qe="",{toString:Tf}={},{keys:If}=Object,it=e=>{const t=typeof e;if(t!=="object"||!e)return[Bt,t];const n=Tf.call(e).slice(8,-1);switch(n){case"Array":return[ct,qe];case"Object":return[At,qe];case"Date":return[nr,qe];case"RegExp":return[rr,qe];case"Map":return[ir,qe];case"Set":return[sr,qe];case"DataView":return[ct,n]}return n.includes("Array")?[ct,n]:n.includes("Error")?[ra,n]:[At,n]},Ct=([e,t])=>e===Bt&&(t==="function"||t==="symbol"),Mf=(e,t,n,r)=>{const i=(a,l)=>{const o=r.push(a)-1;return n.set(l,o),o},s=a=>{if(n.has(a))return n.get(a);let[l,o]=it(a);switch(l){case Bt:{let h=a;switch(o){case"bigint":l=ia,h=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+o);h=null;break;case"undefined":return i([na],a)}return i([l,h],a)}case ct:{if(o){let p=a;return o==="DataView"?p=new Uint8Array(a.buffer):o==="ArrayBuffer"&&(p=new Uint8Array(a)),i([o,[...p]],a)}const h=[],c=i([l,h],a);for(const p of a)h.push(s(p));return c}case At:{if(o)switch(o){case"BigInt":return i([o,a.toString()],a);case"Boolean":case"Number":case"String":return i([o,a.valueOf()],a)}if(t&&"toJSON"in a)return s(a.toJSON());const h=[],c=i([l,h],a);for(const p of If(a))(e||!Ct(it(a[p])))&&h.push([s(p),s(a[p])]);return c}case nr:return i([l,a.toISOString()],a);case rr:{const{source:h,flags:c}=a;return i([l,{source:h,flags:c}],a)}case ir:{const h=[],c=i([l,h],a);for(const[p,f]of a)(e||!(Ct(it(p))||Ct(it(f))))&&h.push([s(p),s(f)]);return c}case sr:{const h=[],c=i([l,h],a);for(const p of a)(e||!Ct(it(p)))&&h.push(s(p));return c}}const{message:u}=a;return i([l,{name:o,message:u}],a)};return s},li=(e,{json:t,lossy:n}={})=>{const r=[];return Mf(!(t||n),!!t,new Map,r)(e),r},jt=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?ai(li(e,t)):structuredClone(e):(e,t)=>ai(li(e,t));function Nf(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function Ef(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function Lf(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Nf,r=e.options.footnoteBackLabel||Ef,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let o=-1;for(;++o<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[o]);if(!u)continue;const h=e.all(u),c=String(u.identifier).toUpperCase(),p=Ye(c.toLowerCase());let f=0;const m=[],x=e.footnoteCounts.get(c);for(;x!==void 0&&++f<=x;){m.length>0&&m.push({type:"text",value:" "});let I=typeof n=="string"?n:n(o,f);typeof I=="string"&&(I={type:"text",value:I}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(f>1?"-"+f:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(o,f),className:["data-footnote-backref"]},children:Array.isArray(I)?I:[I]})}const S=h[h.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const I=S.children[S.children.length-1];I&&I.type==="text"?I.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...m)}else h.push(...m);const g={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(h,!0)};e.patch(u,g),l.push(g)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...jt(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
11
|
-
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:`
|
|
12
|
-
`}]}}const Ht=(function(e){if(e==null)return Pf;if(typeof e=="function")return Vt(e);if(typeof e=="object")return Array.isArray(e)?Af(e):jf(e);if(typeof e=="string")return Rf(e);throw new Error("Expected function, string, or object as test")});function Af(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Ht(e[n]);return Vt(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function jf(e){const t=e;return Vt(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function Rf(e){return Vt(t);function t(n){return n&&n.type===e}}function Vt(e){return t;function t(n,r,i){return!!(Df(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function Pf(){return!0}function Df(e){return e!==null&&typeof e=="object"&&"type"in e}const sa=[],Ff=!0,En=!1,Of="skip";function aa(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=Ht(i),a=r?-1:1;l(e,void 0,[])();function l(o,u,h){const c=o&&typeof o=="object"?o:{};if(typeof c.type=="string"){const f=typeof c.tagName=="string"?c.tagName:typeof c.name=="string"?c.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(o.type+(f?"<"+f+">":""))+")"})}return p;function p(){let f=sa,m,x,S;if((!t||s(o,u,h[h.length-1]||void 0))&&(f=_f(n(o,h)),f[0]===En))return f;if("children"in o&&o.children){const g=o;if(g.children&&f[0]!==Of)for(x=(r?g.children.length:-1)+a,S=h.concat(g);x>-1&&x<g.children.length;){const I=g.children[x];if(m=l(I,x,S)(),m[0]===En)return m;x=typeof m[1]=="number"?m[1]:x+a}}return f}}}function _f(e){return Array.isArray(e)?e:typeof e=="number"?[Ff,e]:e==null?sa:[e]}function ar(e,t,n,r){let i,s,a;typeof t=="function"&&typeof n!="function"?(s=void 0,a=t,i=n):(s=t,a=n,i=r),aa(e,s,l,i);function l(o,u){const h=u[u.length-1],c=h?h.children.indexOf(o):void 0;return a(o,c,h)}}const Ln={}.hasOwnProperty,zf={};function Bf(e,t){const n=t||zf,r=new Map,i=new Map,s=new Map,a={...Cf,...n.handlers},l={all:u,applyData:Vf,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:a,one:o,options:n,patch:Hf,wrap:$f};return ar(e,function(h){if(h.type==="definition"||h.type==="footnoteDefinition"){const c=h.type==="definition"?r:i,p=String(h.identifier).toUpperCase();c.has(p)||c.set(p,h)}}),l;function o(h,c){const p=h.type,f=l.handlers[p];if(Ln.call(l.handlers,p)&&f)return f(l,h,c);if(l.options.passThrough&&l.options.passThrough.includes(p)){if("children"in h){const{children:x,...S}=h,g=jt(S);return g.children=l.all(h),g}return jt(h)}return(l.options.unknownHandler||Uf)(l,h,c)}function u(h){const c=[];if("children"in h){const p=h.children;let f=-1;for(;++f<p.length;){const m=l.one(p[f],h);if(m){if(f&&p[f-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=oi(m.value)),!Array.isArray(m)&&m.type==="element")){const x=m.children[0];x&&x.type==="text"&&(x.value=oi(x.value))}Array.isArray(m)?c.push(...m):c.push(m)}}}return c}}function Hf(e,t){e.position&&(t.position=Nc(e))}function Vf(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&s&&Object.assign(n.properties,jt(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function Uf(e,t){const n=t.data||{},r="value"in t&&!(Ln.call(n,"hProperties")||Ln.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 $f(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
13
|
-
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
14
|
-
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
15
|
-
`}),n}function oi(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function ui(e,t){const n=Bf(e,t),r=n.one(e,void 0),i=Lf(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
|
|
16
|
-
`},i),s}function qf(e,t){return e&&"run"in e?async function(n,r){const i=ui(n,{file:r,...t});await e.run(i,r)}:function(n,r){return ui(n,{file:r,...e||t})}}function ci(e){if(e)throw e}var rn,hi;function Kf(){if(hi)return rn;hi=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):t.call(u)==="[object Array]"},s=function(u){if(!u||t.call(u)!=="[object Object]")return!1;var h=e.call(u,"constructor"),c=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!h&&!c)return!1;var p;for(p in u);return typeof p>"u"||e.call(u,p)},a=function(u,h){n&&h.name==="__proto__"?n(u,h.name,{enumerable:!0,configurable:!0,value:h.newValue,writable:!0}):u[h.name]=h.newValue},l=function(u,h){if(h==="__proto__")if(e.call(u,h)){if(r)return r(u,h).value}else return;return u[h]};return rn=function o(){var u,h,c,p,f,m,x=arguments[0],S=1,g=arguments.length,I=!1;for(typeof x=="boolean"&&(I=x,x=arguments[1]||{},S=2),(x==null||typeof x!="object"&&typeof x!="function")&&(x={});S<g;++S)if(u=arguments[S],u!=null)for(h in u)c=l(x,h),p=l(u,h),x!==p&&(I&&p&&(s(p)||(f=i(p)))?(f?(f=!1,m=c&&i(c)?c:[]):m=c&&s(c)?c:{},a(x,{name:h,newValue:o(I,m,p)})):typeof p<"u"&&a(x,{name:h,newValue:p}));return x},rn}var Wf=Kf();const sn=Qi(Wf);function An(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Qf(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...i);function l(o,...u){const h=e[++s];let c=-1;if(o){a(o);return}for(;++c<i.length;)(u[c]===null||u[c]===void 0)&&(u[c]=i[c]);i=u,h?Gf(h,l)(...u):a(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function Gf(e,t){let n;return r;function r(...a){const l=e.length>a.length;let o;l&&a.push(i);try{o=e.apply(this,a)}catch(u){const h=u;if(l&&n)throw h;return i(h)}l||(o&&o.then&&typeof o.then=="function"?o.then(s,i):o instanceof Error?i(o):s(o))}function i(a,...l){n||(n=!0,t(a,...l))}function s(a){i(null,a)}}const Ne={basename:Xf,dirname:Yf,extname:Jf,join:Zf,sep:"/"};function Xf(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');St(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,l=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else a<0&&(s=!0,a=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(r=i):(l=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function Yf(e){if(St(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function Jf(e){St(e);let t=e.length,n=-1,r=0,i=-1,s=0,a;for(;t--;){const l=e.codePointAt(t);if(l===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),l===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function Zf(...e){let t=-1,n;for(;++t<e.length;)St(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":ep(n)}function ep(e){St(e);const t=e.codePointAt(0)===47;let n=tp(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function tp(e,t){let n="",r=0,i=-1,s=0,a=-1,l,o;for(;++a<=e.length;){if(a<e.length)l=e.codePointAt(a);else{if(l===47)break;l=47}if(l===47){if(!(i===a-1||s===1))if(i!==a-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(o=n.lastIndexOf("/"),o!==n.length-1){o<0?(n="",r=0):(n=n.slice(0,o),r=n.length-1-n.lastIndexOf("/")),i=a,s=0;continue}}else if(n.length>0){n="",r=0,i=a,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,s=0}else l===46&&s>-1?s++:s=-1}return n}function St(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const np={cwd:rp};function rp(){return"/"}function jn(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function ip(e){if(typeof e=="string")e=new URL(e);else if(!jn(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return sp(e)}function sp(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const an=["history","path","basename","stem","extname","dirname"];class la{constructor(t){let n;t?jn(t)?n={path:t}:typeof t=="string"||ap(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":np.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<an.length;){const s=an[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}let i;for(i in n)an.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Ne.basename(this.path):void 0}set basename(t){on(t,"basename"),ln(t,"basename"),this.path=Ne.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Ne.dirname(this.path):void 0}set dirname(t){di(this.basename,"dirname"),this.path=Ne.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Ne.extname(this.path):void 0}set extname(t){if(ln(t,"extname"),di(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Ne.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){jn(t)&&(t=ip(t)),on(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Ne.basename(this.path,this.extname):void 0}set stem(t){on(t,"stem"),ln(t,"stem"),this.path=Ne.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new le(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function ln(e,t){if(e&&e.includes(Ne.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Ne.sep+"`")}function on(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function di(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function ap(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const lp=(function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),op={}.hasOwnProperty;class lr extends lp{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=Qf()}copy(){const t=new lr;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(sn(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(hn("data",this.frozen),this.namespace[t]=n,this):op.call(this.namespace,t)&&this.namespace[t]||void 0:t?(hn("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=vt(t),r=this.parser||this.Parser;return un("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),un("process",this.parser||this.Parser),cn("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,a){const l=vt(t),o=r.parse(l);r.run(o,l,function(h,c,p){if(h||!c||!p)return u(h);const f=c,m=r.stringify(f,p);hp(m)?p.value=m:p.result=m,u(h,p)});function u(h,c){h||!c?a(h):s?s(c):n(void 0,c)}}}processSync(t){let n=!1,r;return this.freeze(),un("processSync",this.parser||this.Parser),cn("processSync",this.compiler||this.Compiler),this.process(t,i),pi("processSync","process",n),r;function i(s,a){n=!0,ci(s),r=a}}run(t,n,r){fi(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(a,l){const o=vt(n);i.run(t,o,u);function u(h,c,p){const f=c||t;h?l(h):a?a(f):r(void 0,f,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),pi("runSync","run",r),i;function s(a,l){ci(a),i=l,r=!0}}stringify(t,n){this.freeze();const r=vt(n),i=this.compiler||this.Compiler;return cn("stringify",i),fi(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(hn("use",this.frozen),t!=null)if(typeof t=="function")o(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(u){if(typeof u=="function")o(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[h,...c]=u;o(h,c)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(u.plugins),u.settings&&(i.settings=sn(!0,i.settings,u.settings))}function l(u){let h=-1;if(u!=null)if(Array.isArray(u))for(;++h<u.length;){const c=u[h];s(c)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function o(u,h){let c=-1,p=-1;for(;++c<r.length;)if(r[c][0]===u){p=c;break}if(p===-1)r.push([u,...h]);else if(h.length>0){let[f,...m]=h;const x=r[p][1];An(x)&&An(f)&&(f=sn(!0,x,f)),r[p]=[u,f,...m]}}}}const up=new lr().freeze();function un(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function cn(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function hn(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function fi(e){if(!An(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function pi(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function vt(e){return cp(e)?e:new la(e)}function cp(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function hp(e){return typeof e=="string"||dp(e)}function dp(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const fp="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",mi=[],gi={allowDangerousHtml:!0},pp=/^(https?|ircs?|mailto|xmpp)$/i,mp=[{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 gp(e){const t=xp(e),n=yp(e);return bp(t.runSync(t.parse(n),n),e)}function xp(e){const t=e.rehypePlugins||mi,n=e.remarkPlugins||mi,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...gi}:gi;return up().use(Xd).use(n).use(qf,r).use(t)}function yp(e){const t=e.children||"",n=new la;return typeof t=="string"&&(n.value=t),n}function bp(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,o=t.urlTransform||Sp;for(const h of mp)Object.hasOwn(t,h.from)&&(""+h.from+(h.to?"use `"+h.to+"` instead":"remove it")+fp+h.id,void 0);return ar(e,u),Rc(e,{Fragment:d.Fragment,components:i,ignoreInvalidStyle:!0,jsx:d.jsx,jsxs:d.jsxs,passKeys:!0,passNode:!0});function u(h,c,p){if(h.type==="raw"&&p&&typeof c=="number")return a?p.children.splice(c,1):p.children[c]={type:"text",value:h.value},c;if(h.type==="element"){let f;for(f in en)if(Object.hasOwn(en,f)&&Object.hasOwn(h.properties,f)){const m=h.properties[f],x=en[f];(x===null||x.includes(h.tagName))&&(h.properties[f]=o(String(m||""),f,h))}}if(h.type==="element"){let f=n?!n.includes(h.tagName):s?s.includes(h.tagName):!1;if(!f&&r&&typeof c=="number"&&(f=!r(h,c,p)),f&&p&&typeof c=="number")return l&&h.children?p.children.splice(c,1,...h.children):p.children.splice(c,1),c}}}function Sp(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||pp.test(e.slice(0,t))?e:""}function xi(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function kp(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function wp(e,t,n){const i=Ht((n||{}).ignore||[]),s=Cp(t);let a=-1;for(;++a<s.length;)aa(e,"text",l);function l(u,h){let c=-1,p;for(;++c<h.length;){const f=h[c],m=p?p.children:void 0;if(i(f,m?m.indexOf(f):void 0,p))return;p=f}if(p)return o(u,h)}function o(u,h){const c=h[h.length-1],p=s[a][0],f=s[a][1];let m=0;const S=c.children.indexOf(u);let g=!1,I=[];p.lastIndex=0;let M=p.exec(u.value);for(;M;){const D=M.index,F={index:M.index,input:M.input,stack:[...h,u]};let T=f(...M,F);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?p.lastIndex=D+1:(m!==D&&I.push({type:"text",value:u.value.slice(m,D)}),Array.isArray(T)?I.push(...T):T&&I.push(T),m=D+M[0].length,g=!0),!p.global)break;M=p.exec(u.value)}return g?(m<u.value.length&&I.push({type:"text",value:u.value.slice(m)}),c.children.splice(S,1,...I)):I=[u],S+I.length}}function Cp(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([vp(i[0]),Tp(i[1])])}return t}function vp(e){return typeof e=="string"?new RegExp(kp(e),"g"):e}function Tp(e){return typeof e=="function"?e:function(){return e}}const dn="phrasing",fn=["autolink","link","image","label"];function Ip(){return{transforms:[Rp],enter:{literalAutolink:Np,literalAutolinkEmail:pn,literalAutolinkHttp:pn,literalAutolinkWww:pn},exit:{literalAutolink:jp,literalAutolinkEmail:Ap,literalAutolinkHttp:Ep,literalAutolinkWww:Lp}}}function Mp(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:dn,notInConstruct:fn},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:dn,notInConstruct:fn},{character:":",before:"[ps]",after:"\\/",inConstruct:dn,notInConstruct:fn}]}}function Np(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function pn(e){this.config.enter.autolinkProtocol.call(this,e)}function Ep(e){this.config.exit.autolinkProtocol.call(this,e)}function Lp(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function Ap(e){this.config.exit.autolinkEmail.call(this,e)}function jp(e){this.exit(e)}function Rp(e){wp(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Pp],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Dp]],{ignore:["link","linkReference"]})}function Pp(e,t,n,r,i){let s="";if(!oa(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!Fp(n)))return!1;const a=Op(n+r);if(!a[0])return!1;const l={type:"link",title:null,url:s+t+a[0],children:[{type:"text",value:t+a[0]}]};return a[1]?[l,{type:"text",value:a[1]}]:l}function Dp(e,t,n,r){return!oa(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Fp(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function Op(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=xi(e,"(");let s=xi(e,")");for(;r!==-1&&i>s;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[e,n]}function oa(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||He(n)||_t(n))&&(!t||n!==47)}ua.peek=Kp;function _p(){this.buffer()}function zp(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Bp(){this.buffer()}function Hp(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Vp(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Te(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Up(e){this.exit(e)}function $p(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Te(this.sliceSerialize(e)).toLowerCase(),n.label=t}function qp(e){this.exit(e)}function Kp(){return"["}function ua(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const a=n.enter("footnoteReference"),l=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),l(),a(),s+=i.move("]"),s}function Wp(){return{enter:{gfmFootnoteCallString:_p,gfmFootnoteCall:zp,gfmFootnoteDefinitionLabelString:Bp,gfmFootnoteDefinition:Hp},exit:{gfmFootnoteCallString:Vp,gfmFootnoteCall:Up,gfmFootnoteDefinitionLabelString:$p,gfmFootnoteDefinition:qp}}}function Qp(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:ua},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,a){const l=s.createTracker(a);let o=l.move("[^");const u=s.enter("footnoteDefinition"),h=s.enter("label");return o+=l.move(s.safe(s.associationId(r),{before:o,after:"]"})),h(),o+=l.move("]:"),r.children&&r.children.length>0&&(l.shift(4),o+=l.move((t?`
|
|
17
|
-
`:" ")+s.indentLines(s.containerFlow(r,l.current()),t?ca:Gp))),u(),o}}function Gp(e,t,n){return t===0?e:ca(e,t,n)}function ca(e,t,n){return(n?"":" ")+e}const Xp=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];ha.peek=tm;function Yp(){return{canContainEols:["delete"],enter:{strikethrough:Zp},exit:{strikethrough:em}}}function Jp(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Xp}],handlers:{delete:ha}}}function Zp(e){this.enter({type:"delete",children:[]},e)}function em(e){this.exit(e)}function ha(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let a=i.move("~~");return a+=n.containerPhrasing(e,{...i.current(),before:a,after:"~"}),a+=i.move("~~"),s(),a}function tm(){return"~"}function nm(e){return e.length}function rm(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||nm,s=[],a=[],l=[],o=[];let u=0,h=-1;for(;++h<e.length;){const x=[],S=[];let g=-1;for(e[h].length>u&&(u=e[h].length);++g<e[h].length;){const I=im(e[h][g]);if(n.alignDelimiters!==!1){const M=i(I);S[g]=M,(o[g]===void 0||M>o[g])&&(o[g]=M)}x.push(I)}a[h]=x,l[h]=S}let c=-1;if(typeof r=="object"&&"length"in r)for(;++c<u;)s[c]=yi(r[c]);else{const x=yi(r);for(;++c<u;)s[c]=x}c=-1;const p=[],f=[];for(;++c<u;){const x=s[c];let S="",g="";x===99?(S=":",g=":"):x===108?S=":":x===114&&(g=":");let I=n.alignDelimiters===!1?1:Math.max(1,o[c]-S.length-g.length);const M=S+"-".repeat(I)+g;n.alignDelimiters!==!1&&(I=S.length+I+g.length,I>o[c]&&(o[c]=I),f[c]=I),p[c]=M}a.splice(1,0,p),l.splice(1,0,f),h=-1;const m=[];for(;++h<a.length;){const x=a[h],S=l[h];c=-1;const g=[];for(;++c<u;){const I=x[c]||"";let M="",D="";if(n.alignDelimiters!==!1){const F=o[c]-(S[c]||0),T=s[c];T===114?M=" ".repeat(F):T===99?F%2?(M=" ".repeat(F/2+.5),D=" ".repeat(F/2-.5)):(M=" ".repeat(F/2),D=M):D=" ".repeat(F)}n.delimiterStart!==!1&&!c&&g.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&I==="")&&(n.delimiterStart!==!1||c)&&g.push(" "),n.alignDelimiters!==!1&&g.push(M),g.push(I),n.alignDelimiters!==!1&&g.push(D),n.padding!==!1&&g.push(" "),(n.delimiterEnd!==!1||c!==u-1)&&g.push("|")}m.push(n.delimiterEnd===!1?g.join("").replace(/ +$/,""):g.join(""))}return m.join(`
|
|
18
|
-
`)}function im(e){return e==null?"":String(e)}function yi(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function sm(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const a=n.indentLines(n.containerFlow(e,s.current()),am);return i(),a}function am(e,t,n){return">"+(n?"":" ")+e}function lm(e,t){return bi(e,t.inConstruct,!0)&&!bi(e,t.notInConstruct,!1)}function bi(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 Si(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
19
|
-
`&&lm(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
20
|
-
`}function om(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>a&&(a=s):s=1,i=r+t.length,r=n.indexOf(t,i);return a}function um(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 cm(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function hm(e,t,n,r){const i=cm(n),s=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(um(e,n)){const c=n.enter("codeIndented"),p=n.indentLines(s,dm);return c(),p}const l=n.createTracker(r),o=i.repeat(Math.max(om(s,i)+1,3)),u=n.enter("codeFenced");let h=l.move(o);if(e.lang){const c=n.enter(`codeFencedLang${a}`);h+=l.move(n.safe(e.lang,{before:h,after:" ",encode:["`"],...l.current()})),c()}if(e.lang&&e.meta){const c=n.enter(`codeFencedMeta${a}`);h+=l.move(" "),h+=l.move(n.safe(e.meta,{before:h,after:`
|
|
21
|
-
`,encode:["`"],...l.current()})),c()}return h+=l.move(`
|
|
22
|
-
`),s&&(h+=l.move(s+`
|
|
23
|
-
`)),h+=l.move(o),u(),h}function dm(e,t,n){return(n?"":" ")+e}function or(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function fm(e,t,n,r){const i=or(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("definition");let l=n.enter("label");const o=n.createTracker(r);let u=o.move("[");return u+=o.move(n.safe(n.associationId(e),{before:u,after:"]",...o.current()})),u+=o.move("]: "),l(),!e.url||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(e.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(l=n.enter("destinationRaw"),u+=o.move(n.safe(e.url,{before:u,after:e.title?" ":`
|
|
24
|
-
`,...o.current()}))),l(),e.title&&(l=n.enter(`title${s}`),u+=o.move(" "+i),u+=o.move(n.safe(e.title,{before:u,after:i,...o.current()})),u+=o.move(i),l()),a(),u}function pm(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function ft(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Rt(e,t,n){const r=Ge(e),i=Ge(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}}da.peek=mm;function da(e,t,n,r){const i=pm(n),s=n.enter("emphasis"),a=n.createTracker(r),l=a.move(i);let o=a.move(n.containerPhrasing(e,{after:i,before:l,...a.current()}));const u=o.charCodeAt(0),h=Rt(r.before.charCodeAt(r.before.length-1),u,i);h.inside&&(o=ft(u)+o.slice(1));const c=o.charCodeAt(o.length-1),p=Rt(r.after.charCodeAt(0),c,i);p.inside&&(o=o.slice(0,-1)+ft(c));const f=a.move(i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:h.outside},l+o+f}function mm(e,t,n){return n.options.emphasis||"*"}function gm(e,t){let n=!1;return ar(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,En}),!!((!e.depth||e.depth<3)&&Zn(e)&&(t.options.setext||n))}function xm(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(gm(e,n)){const h=n.enter("headingSetext"),c=n.enter("phrasing"),p=n.containerPhrasing(e,{...s.current(),before:`
|
|
25
|
-
`,after:`
|
|
26
|
-
`});return c(),h(),p+`
|
|
27
|
-
`+(i===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
|
|
28
|
-
`))+1))}const a="#".repeat(i),l=n.enter("headingAtx"),o=n.enter("phrasing");s.move(a+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
|
|
29
|
-
`,...s.current()});return/^[\t ]/.test(u)&&(u=ft(u.charCodeAt(0))+u.slice(1)),u=u?a+" "+u:a,n.options.closeAtx&&(u+=" "+a),o(),l(),u}fa.peek=ym;function fa(e){return e.value||""}function ym(){return"<"}pa.peek=bm;function pa(e,t,n,r){const i=or(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let l=n.enter("label");const o=n.createTracker(r);let u=o.move("![");return u+=o.move(n.safe(e.alt,{before:u,after:"]",...o.current()})),u+=o.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(e.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(l=n.enter("destinationRaw"),u+=o.move(n.safe(e.url,{before:u,after:e.title?" ":")",...o.current()}))),l(),e.title&&(l=n.enter(`title${s}`),u+=o.move(" "+i),u+=o.move(n.safe(e.title,{before:u,after:i,...o.current()})),u+=o.move(i),l()),u+=o.move(")"),a(),u}function bm(){return"!"}ma.peek=Sm;function ma(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let a=n.enter("label");const l=n.createTracker(r);let o=l.move("![");const u=n.safe(e.alt,{before:o,after:"]",...l.current()});o+=l.move(u+"]["),a();const h=n.stack;n.stack=[],a=n.enter("reference");const c=n.safe(n.associationId(e),{before:o,after:"]",...l.current()});return a(),n.stack=h,s(),i==="full"||!u||u!==c?o+=l.move(c+"]"):i==="shortcut"?o=o.slice(0,-1):o+=l.move("]"),o}function Sm(){return"!"}ga.peek=km;function ga(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const a=n.unsafe[s],l=n.compilePattern(a);let o;if(a.atBreak)for(;o=l.exec(r);){let u=o.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(o.index+1)}}return i+r+i}function km(){return"`"}function xa(e,t){const n=Zn(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))}ya.peek=wm;function ya(e,t,n,r){const i=or(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let l,o;if(xa(e,n)){const h=n.stack;n.stack=[],l=n.enter("autolink");let c=a.move("<");return c+=a.move(n.containerPhrasing(e,{before:c,after:">",...a.current()})),c+=a.move(">"),l(),n.stack=h,c}l=n.enter("link"),o=n.enter("label");let u=a.move("[");return u+=a.move(n.containerPhrasing(e,{before:u,after:"](",...a.current()})),u+=a.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(n.safe(e.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(o=n.enter("destinationRaw"),u+=a.move(n.safe(e.url,{before:u,after:e.title?" ":")",...a.current()}))),o(),e.title&&(o=n.enter(`title${s}`),u+=a.move(" "+i),u+=a.move(n.safe(e.title,{before:u,after:i,...a.current()})),u+=a.move(i),o()),u+=a.move(")"),l(),u}function wm(e,t,n){return xa(e,n)?"<":"["}ba.peek=Cm;function ba(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let a=n.enter("label");const l=n.createTracker(r);let o=l.move("[");const u=n.containerPhrasing(e,{before:o,after:"]",...l.current()});o+=l.move(u+"]["),a();const h=n.stack;n.stack=[],a=n.enter("reference");const c=n.safe(n.associationId(e),{before:o,after:"]",...l.current()});return a(),n.stack=h,s(),i==="full"||!u||u!==c?o+=l.move(c+"]"):i==="shortcut"?o=o.slice(0,-1):o+=l.move("]"),o}function Cm(){return"["}function ur(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function vm(e){const t=ur(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Tm(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Sa(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Im(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?Tm(n):ur(n);const l=e.ordered?a==="."?")":".":vm(n);let o=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const h=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&h&&(!h.children||!h.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&&(o=!0),Sa(n)===a&&h){let c=-1;for(;++c<e.children.length;){const p=e.children[c];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){o=!0;break}}}}o&&(a=l),n.bulletCurrent=a;const u=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=s,i(),u}function Mm(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Nm(e,t,n,r){const i=Mm(n);let s=n.bulletCurrent||ur(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let a=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const l=n.createTracker(r);l.move(s+" ".repeat(a-s.length)),l.shift(a);const o=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,l.current()),h);return o(),u;function h(c,p,f){return p?(f?"":" ".repeat(a))+c:(f?s:s+" ".repeat(a-s.length))+c}}function Em(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,r);return s(),i(),a}const Lm=Ht(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Am(e,t,n,r){return(e.children.some(function(a){return Lm(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function jm(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}ka.peek=Rm;function ka(e,t,n,r){const i=jm(n),s=n.enter("strong"),a=n.createTracker(r),l=a.move(i+i);let o=a.move(n.containerPhrasing(e,{after:i,before:l,...a.current()}));const u=o.charCodeAt(0),h=Rt(r.before.charCodeAt(r.before.length-1),u,i);h.inside&&(o=ft(u)+o.slice(1));const c=o.charCodeAt(o.length-1),p=Rt(r.after.charCodeAt(0),c,i);p.inside&&(o=o.slice(0,-1)+ft(c));const f=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:h.outside},l+o+f}function Rm(e,t,n){return n.options.strong||"*"}function Pm(e,t,n,r){return n.safe(e.value,r)}function Dm(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Fm(e,t,n){const r=(Sa(n)+(n.options.ruleSpaces?" ":"")).repeat(Dm(n));return n.options.ruleSpaces?r.slice(0,-1):r}const wa={blockquote:sm,break:Si,code:hm,definition:fm,emphasis:da,hardBreak:Si,heading:xm,html:fa,image:pa,imageReference:ma,inlineCode:ga,link:ya,linkReference:ba,list:Im,listItem:Nm,paragraph:Em,root:Am,strong:ka,text:Pm,thematicBreak:Fm};function Om(){return{enter:{table:_m,tableData:ki,tableHeader:ki,tableRow:Bm},exit:{codeText:Hm,table:zm,tableData:mn,tableHeader:mn,tableRow:mn}}}function _m(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function zm(e){this.exit(e),this.data.inTable=void 0}function Bm(e){this.enter({type:"tableRow",children:[]},e)}function mn(e){this.exit(e)}function ki(e){this.enter({type:"tableCell",children:[]},e)}function Hm(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Vm));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Vm(e,t){return t==="|"?t:e}function Um(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
30
|
-
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:a,tableCell:o,tableRow:l}};function a(f,m,x,S){return u(h(f,x,S),f.align)}function l(f,m,x,S){const g=c(f,x,S),I=u([g]);return I.slice(0,I.indexOf(`
|
|
31
|
-
`))}function o(f,m,x,S){const g=x.enter("tableCell"),I=x.enter("phrasing"),M=x.containerPhrasing(f,{...S,before:s,after:s});return I(),g(),M}function u(f,m){return rm(f,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function h(f,m,x){const S=f.children;let g=-1;const I=[],M=m.enter("table");for(;++g<S.length;)I[g]=c(S[g],m,x);return M(),I}function c(f,m,x){const S=f.children;let g=-1;const I=[],M=m.enter("tableRow");for(;++g<S.length;)I[g]=o(S[g],f,m,x);return M(),I}function p(f,m,x){let S=wa.inlineCode(f,m,x);return x.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function $m(){return{exit:{taskListCheckValueChecked:wi,taskListCheckValueUnchecked:wi,paragraph:Km}}}function qm(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Wm}}}function wi(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function Km(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,a;for(;++s<i.length;){const l=i[s];if(l.type==="paragraph"){a=l;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function Wm(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",l=n.createTracker(r);s&&l.move(a);let o=wa.listItem(e,t,n,{...r,...l.current()});return s&&(o=o.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),o;function u(h){return h+a}}function Qm(){return[Ip(),Wp(),Yp(),Om(),$m()]}function Gm(e){return{extensions:[Mp(),Qp(e),Jp(),Um(e),qm()]}}const Xm={tokenize:ng,partial:!0},Ca={tokenize:rg,partial:!0},va={tokenize:ig,partial:!0},Ta={tokenize:sg,partial:!0},Ym={tokenize:ag,partial:!0},Ia={name:"wwwAutolink",tokenize:eg,previous:Na},Ma={name:"protocolAutolink",tokenize:tg,previous:Ea},Pe={name:"emailAutolink",tokenize:Zm,previous:La},Ee={};function Jm(){return{text:Ee}}let Be=48;for(;Be<123;)Ee[Be]=Pe,Be++,Be===58?Be=65:Be===91&&(Be=97);Ee[43]=Pe;Ee[45]=Pe;Ee[46]=Pe;Ee[95]=Pe;Ee[72]=[Pe,Ma];Ee[104]=[Pe,Ma];Ee[87]=[Pe,Ia];Ee[119]=[Pe,Ia];function Zm(e,t,n){const r=this;let i,s;return a;function a(c){return!Rn(c)||!La.call(r,r.previous)||cr(r.events)?n(c):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),l(c))}function l(c){return Rn(c)?(e.consume(c),l):c===64?(e.consume(c),o):n(c)}function o(c){return c===46?e.check(Ym,h,u)(c):c===45||c===95||ae(c)?(s=!0,e.consume(c),o):h(c)}function u(c){return e.consume(c),i=!0,o}function h(c){return s&&i&&oe(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(c)):n(c)}}function eg(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!Na.call(r,r.previous)||cr(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Xm,e.attempt(Ca,e.attempt(va,s),n),n)(a))}function s(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function tg(e,t,n){const r=this;let i="",s=!1;return a;function a(c){return(c===72||c===104)&&Ea.call(r,r.previous)&&!cr(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(c),e.consume(c),l):n(c)}function l(c){if(oe(c)&&i.length<5)return i+=String.fromCodePoint(c),e.consume(c),l;if(c===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(c),o}return n(c)}function o(c){return c===47?(e.consume(c),s?u:(s=!0,o)):n(c)}function u(c){return c===null||Lt(c)||J(c)||He(c)||_t(c)?n(c):e.attempt(Ca,e.attempt(va,h),n)(c)}function h(c){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(c)}}function ng(e,t,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),i):a===46&&r===3?(e.consume(a),s):n(a)}function s(a){return a===null?n(a):t(a)}}function rg(e,t,n){let r,i,s;return a;function a(u){return u===46||u===95?e.check(Ta,o,l)(u):u===null||J(u)||He(u)||u!==45&&_t(u)?o(u):(s=!0,e.consume(u),a)}function l(u){return u===95?r=!0:(i=r,r=void 0),e.consume(u),a}function o(u){return i||r||!s?n(u):t(u)}}function ig(e,t){let n=0,r=0;return i;function i(a){return a===40?(n++,e.consume(a),i):a===41&&r<n?s(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(Ta,t,s)(a):a===null||J(a)||He(a)?t(a):(e.consume(a),i)}function s(a){return a===41&&r++,e.consume(a),i}}function sg(e,t,n){return r;function r(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(e.consume(l),r):l===38?(e.consume(l),s):l===93?(e.consume(l),i):l===60||l===null||J(l)||He(l)?t(l):n(l)}function i(l){return l===null||l===40||l===91||J(l)||He(l)?t(l):r(l)}function s(l){return oe(l)?a(l):n(l)}function a(l){return l===59?(e.consume(l),r):oe(l)?(e.consume(l),a):n(l)}}function ag(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return ae(s)?n(s):t(s)}}function Na(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||J(e)}function Ea(e){return!oe(e)}function La(e){return!(e===47||Rn(e))}function Rn(e){return e===43||e===45||e===46||e===95||ae(e)}function cr(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const lg={tokenize:mg,partial:!0};function og(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:dg,continuation:{tokenize:fg},exit:pg}},text:{91:{name:"gfmFootnoteCall",tokenize:hg},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:ug,resolveTo:cg}}}}function ug(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const o=r.events[i][1];if(o.type==="labelImage"){a=o;break}if(o.type==="gfmFootnoteCall"||o.type==="labelLink"||o.type==="label"||o.type==="image"||o.type==="link")break}return l;function l(o){if(!a||!a._balanced)return n(o);const u=Te(r.sliceSerialize({start:a.end,end:r.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?n(o):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),t(o))}}function cg(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},l=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",a,t],["exit",a,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...l),e}function hg(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,a;return l;function l(c){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),o}function o(c){return c!==94?n(c):(e.enter("gfmFootnoteCallMarker"),e.consume(c),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(c){if(s>999||c===93&&!a||c===null||c===91||J(c))return n(c);if(c===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(Te(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(c)}return J(c)||(a=!0),s++,e.consume(c),c===92?h:u}function h(c){return c===91||c===92||c===93?(e.consume(c),s++,u):u(c)}}function dg(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,a=0,l;return o;function o(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):n(m)}function h(m){if(a>999||m===93&&!l||m===null||m===91||J(m))return n(m);if(m===93){e.exit("chunkString");const x=e.exit("gfmFootnoteDefinitionLabelString");return s=Te(r.sliceSerialize(x)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return J(m)||(l=!0),a++,e.consume(m),m===92?c:h}function c(m){return m===91||m===92||m===93?(e.consume(m),a++,h):h(m)}function p(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),G(e,f,"gfmFootnoteDefinitionWhitespace")):n(m)}function f(m){return t(m)}}function fg(e,t,n){return e.check(bt,t,e.attempt(lg,t,n))}function pg(e){e.exit("gfmFootnoteDefinition")}function mg(e,t,n){const r=this;return G(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(s):n(s)}}function gg(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,l){let o=-1;for(;++o<a.length;)if(a[o][0]==="enter"&&a[o][1].type==="strikethroughSequenceTemporary"&&a[o][1]._close){let u=o;for(;u--;)if(a[u][0]==="exit"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._open&&a[o][1].end.offset-a[o][1].start.offset===a[u][1].end.offset-a[u][1].start.offset){a[o][1].type="strikethroughSequence",a[u][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},a[u][1].start),end:Object.assign({},a[o][1].end)},c={type:"strikethroughText",start:Object.assign({},a[u][1].end),end:Object.assign({},a[o][1].start)},p=[["enter",h,l],["enter",a[u][1],l],["exit",a[u][1],l],["enter",c,l]],f=l.parser.constructs.insideSpan.null;f&&xe(p,p.length,0,zt(f,a.slice(u+1,o),l)),xe(p,p.length,0,[["exit",c,l],["enter",a[o][1],l],["exit",a[o][1],l],["exit",h,l]]),xe(a,u-1,o-u+3,p),o=u+p.length-2;break}}for(o=-1;++o<a.length;)a[o][1].type==="strikethroughSequenceTemporary"&&(a[o][1].type="data");return a}function s(a,l,o){const u=this.previous,h=this.events;let c=0;return p;function p(m){return u===126&&h[h.length-1][1].type!=="characterEscape"?o(m):(a.enter("strikethroughSequenceTemporary"),f(m))}function f(m){const x=Ge(u);if(m===126)return c>1?o(m):(a.consume(m),c++,f);if(c<2&&!n)return o(m);const S=a.exit("strikethroughSequenceTemporary"),g=Ge(m);return S._open=!g||g===2&&!!x,S._close=!x||x===2&&!!g,l(m)}}}class xg{constructor(){this.map=[]}add(t,n,r){yg(this,t,n,r)}consume(t){if(this.map.sort(function(s,a){return s[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function yg(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 bg(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function Sg(){return{flow:{null:{name:"table",tokenize:kg,resolveAll:wg}}}}function kg(e,t,n){const r=this;let i=0,s=0,a;return l;function l(w){let E=r.events.length-1;for(;E>-1;){const R=r.events[E][1].type;if(R==="lineEnding"||R==="linePrefix")E--;else break}const L=E>-1?r.events[E][1].type:null,V=L==="tableHead"||L==="tableRow"?T:o;return V===T&&r.parser.lazy[r.now().line]?n(w):V(w)}function o(w){return e.enter("tableHead"),e.enter("tableRow"),u(w)}function u(w){return w===124||(a=!0,s+=1),h(w)}function h(w){return w===null?n(w):_(w)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),f):n(w):K(w)?G(e,h,"whitespace")(w):(s+=1,a&&(a=!1,i+=1),w===124?(e.enter("tableCellDivider"),e.consume(w),e.exit("tableCellDivider"),a=!0,h):(e.enter("data"),c(w)))}function c(w){return w===null||w===124||J(w)?(e.exit("data"),h(w)):(e.consume(w),w===92?p:c)}function p(w){return w===92||w===124?(e.consume(w),c):c(w)}function f(w){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(w):(e.enter("tableDelimiterRow"),a=!1,K(w)?G(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(w):m(w))}function m(w){return w===45||w===58?S(w):w===124?(a=!0,e.enter("tableCellDivider"),e.consume(w),e.exit("tableCellDivider"),x):F(w)}function x(w){return K(w)?G(e,S,"whitespace")(w):S(w)}function S(w){return w===58?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(w),e.exit("tableDelimiterMarker"),g):w===45?(s+=1,g(w)):w===null||_(w)?D(w):F(w)}function g(w){return w===45?(e.enter("tableDelimiterFiller"),I(w)):F(w)}function I(w){return w===45?(e.consume(w),I):w===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(w),e.exit("tableDelimiterMarker"),M):(e.exit("tableDelimiterFiller"),M(w))}function M(w){return K(w)?G(e,D,"whitespace")(w):D(w)}function D(w){return w===124?m(w):w===null||_(w)?!a||i!==s?F(w):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(w)):F(w)}function F(w){return n(w)}function T(w){return e.enter("tableRow"),O(w)}function O(w){return w===124?(e.enter("tableCellDivider"),e.consume(w),e.exit("tableCellDivider"),O):w===null||_(w)?(e.exit("tableRow"),t(w)):K(w)?G(e,O,"whitespace")(w):(e.enter("data"),H(w))}function H(w){return w===null||w===124||J(w)?(e.exit("data"),O(w)):(e.consume(w),w===92?B:H)}function B(w){return w===92||w===124?(e.consume(w),H):H(w)}}function wg(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],l=!1,o=0,u,h,c;const p=new xg;for(;++n<e.length;){const f=e[n],m=f[1];f[0]==="enter"?m.type==="tableHead"?(l=!1,o!==0&&(Ci(p,t,o,u,h),h=void 0,o=0),u={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",u,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,c=void 0,s=[0,0,0,0],a=[0,n+1,0,0],l&&(l=!1,h={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",h,t]])),i=m.type==="tableDelimiterRow"?2:h?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(s[1]!==0&&(a[0]=a[1],c=Tt(p,t,s,i,void 0,c),s=[0,0,0,0]),a[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(a[0]=a[1],c=Tt(p,t,s,i,void 0,c)),s=a,a=[s[1],n,0,0])):m.type==="tableHead"?(l=!0,o=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(o=n,s[1]!==0?(a[0]=a[1],c=Tt(p,t,s,i,n,c)):a[1]!==0&&(c=Tt(p,t,a,i,n,c)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=n)}for(o!==0&&Ci(p,t,o,u,h),p.consume(t.events),n=-1;++n<t.events.length;){const f=t.events[n];f[0]==="enter"&&f[1].type==="table"&&(f[1]._align=bg(t.events,n))}return e}function Tt(e,t,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(s.end=Object.assign({},Ke(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const o=Ke(t.events,n[1]);if(s={type:a,start:Object.assign({},o),end:Object.assign({},o)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const u=Ke(t.events,n[2]),h=Ke(t.events,n[3]),c={type:l,start:Object.assign({},u),end:Object.assign({},h)};if(e.add(n[2],0,[["enter",c,t]]),r!==2){const p=t.events[n[2]],f=t.events[n[3]];if(p[1].end=Object.assign({},f[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,x=n[3]-n[2]-1;e.add(m,x,[])}}e.add(n[3]+1,0,[["exit",c,t]])}return i!==void 0&&(s.end=Object.assign({},Ke(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Ci(e,t,n,r,i){const s=[],a=Ke(t.events,n);i&&(i.end=Object.assign({},a),s.push(["exit",i,t])),r.end=Object.assign({},a),s.push(["exit",r,t]),e.add(n+1,0,s)}function Ke(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const Cg={name:"tasklistCheck",tokenize:Tg};function vg(){return{text:{91:Cg}}}function Tg(e,t,n){const r=this;return i;function i(o){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(o):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(o),e.exit("taskListCheckMarker"),s)}function s(o){return J(o)?(e.enter("taskListCheckValueUnchecked"),e.consume(o),e.exit("taskListCheckValueUnchecked"),a):o===88||o===120?(e.enter("taskListCheckValueChecked"),e.consume(o),e.exit("taskListCheckValueChecked"),a):n(o)}function a(o){return o===93?(e.enter("taskListCheckMarker"),e.consume(o),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),l):n(o)}function l(o){return _(o)?t(o):K(o)?e.check({tokenize:Ig},t,n)(o):n(o)}}function Ig(e,t,n){return G(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function Mg(e){return Hs([Jm(),og(),gg(e),Sg(),vg()])}const Ng={};function Eg(e){const t=this,n=e||Ng,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Mg(n)),s.push(Qm()),a.push(Gm(n))}function Lg(){var e;return typeof navigator<"u"&&typeof((e=navigator.clipboard)==null?void 0:e.writeText)=="function"}function Ag(e){if(typeof document>"u")return;const t=document.getSelection();t&&(t.removeAllRanges(),e.forEach(n=>t.addRange(n)))}function vi(e){if(typeof document>"u"||!document.body)return!1;const 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(),s=i?Array.from({length:i.rangeCount},(o,u)=>i.getRangeAt(u).cloneRange()):[],a=document.createElement("textarea");a.value=e,a.setAttribute("readonly",""),a.setAttribute("aria-hidden","true"),a.style.position="fixed",a.style.top="0",a.style.left="-9999px",a.style.opacity="0",a.style.pointerEvents="none",a.style.fontSize="12pt",document.body.appendChild(a);try{a.focus({preventScroll:!0})}catch{a.focus()}a.select(),a.setSelectionRange(0,a.value.length);let l=!1;try{l=typeof document.execCommand=="function"&&document.execCommand("copy")}catch{l=!1}if(a.remove(),t)try{t.focus({preventScroll:!0})}catch{t.focus()}return n&&r?n.setSelectionRange(r.start,r.end):Ag(s),l}async function jg(e){if(!e)return!1;if(Lg())try{return await navigator.clipboard.writeText(e),!0}catch{return vi(e)}return vi(e)}const Rg=1300;function Pg(e){const[t,n]=k.useState(!1),r=k.useCallback(async()=>{if(!e.text)return;const i=await jg(e.text);n(!!i)},[e.text]);return k.useEffect(()=>{if(!t||typeof window>"u")return;const i=window.setTimeout(()=>n(!1),e.resetDelayMs??Rg);return()=>window.clearTimeout(i)},[t,e.resetDelayMs]),{copied:t,copy:r}}const Dg=/language-([a-z0-9-]+)/i;function Aa(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Aa).join(""):""}function Fg(e){const t=Aa(e);return t.endsWith(`
|
|
32
|
-
`)?t.slice(0,-1):t}function Og(e){var n;const t=e?Dg.exec(e):null;return((n=t==null?void 0:t[1])==null?void 0:n.toLowerCase())||"text"}function _g(e){const t=k.useMemo(()=>Og(e.className),[e.className]),n=k.useMemo(()=>Fg(e.children),[e.children]),{copied:r,copy:i}=Pg({text:n});return d.jsxs("div",{className:"chat-codeblock",children:[d.jsxs("div",{className:"chat-codeblock-toolbar",children:[d.jsx("span",{className:"chat-codeblock-language",children:t}),d.jsxs("button",{type:"button",className:"chat-codeblock-copy",onClick:()=>void i(),"aria-label":r?e.texts.copiedCodeLabel:e.texts.copyCodeLabel,children:[r?d.jsx(mt,{className:"h-3.5 w-3.5"}):d.jsx(pl,{className:"h-3.5 w-3.5"}),d.jsx("span",{children:r?e.texts.copiedCodeLabel:e.texts.copyCodeLabel})]})]}),d.jsx("pre",{children:d.jsx("code",{className:e.className,children:n})})]})}const Ti=14e4,zg=new Set(["http:","https:","mailto:","tel:"]);function Bg(e){return e.length<=Ti?e:`${e.slice(0,Ti)}
|
|
33
|
-
|
|
34
|
-
...`}function Ii(e){if(!e)return null;if(e.startsWith("#")||e.startsWith("/")||e.startsWith("./")||e.startsWith("../"))return e;try{const t=new URL(e);return zg.has(t.protocol)?e:null}catch{return null}}function Hg(e){return/^https?:\/\//i.test(e)}function Vg(e){const t=e.role==="user",n=k.useMemo(()=>({a:({href:r,children:i,...s})=>{const a=Ii(r);if(!a)return d.jsx("span",{className:"chat-link-invalid",children:i});const l=Hg(a);return d.jsx("a",{...s,href:a,target:l?"_blank":void 0,rel:l?"noreferrer noopener":void 0,children:i})},table:({children:r,...i})=>d.jsx("div",{className:"chat-table-wrap",children:d.jsx("table",{...i,children:r})}),input:({type:r,checked:i,...s})=>r!=="checkbox"?d.jsx("input",{...s,type:r}):d.jsx("input",{...s,type:"checkbox",checked:i,readOnly:!0,disabled:!0,className:"chat-task-checkbox"}),img:({src:r,alt:i,...s})=>{const a=Ii(r);return a?d.jsx("img",{...s,src:a,alt:i||"",loading:"lazy",decoding:"async"}):null},code:({className:r,children:i,...s})=>{const a=String(i??"");return!r&&!a.includes(`
|
|
35
|
-
`)?d.jsx("code",{...s,className:Q("chat-inline-code",r),children:i}):d.jsx(_g,{className:r,texts:e.texts,children:i})}}),[e.texts]);return d.jsx("div",{className:Q("chat-markdown",t?"chat-markdown-user":"chat-markdown-assistant"),children:d.jsx(gp,{skipHtml:!0,remarkPlugins:[Eg],components:n,children:Bg(e.text)})})}const ja={archive:"Archive",audio:"Audio",code:"Code",data:"Data",document:"Document",generic:"File",image:"Image",pdf:"PDF",sheet:"Sheet",video:"Video"},gn={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"},Ug=new Set(["c","cpp","css","go","html","java","js","jsx","md","php","py","rb","rs","sh","sql","svg","ts","tsx"]),$g=new Set(["graphql","json","toml","xml","yaml","yml"]),qg=new Set(["doc","docx","odt","pages","rtf","txt"]),Kg=new Set(["csv","numbers","ods","tsv","xls","xlsx"]),Wg=new Set(["7z","bz2","gz","rar","tar","tgz","zip"]);function Qg(e){if(!Number.isFinite(e)||e==null||e<0)return null;if(e===0)return"0 B";const t=["B","KB","MB","GB","TB"];let n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;const i=n>=10||r===0?0:1;return`${n.toFixed(i).replace(/\.0$/,"")} ${t[r]}`}function Gg(e,t){var s;const n=/\.([a-z0-9]{1,12})$/i.exec(e.trim());if(n!=null&&n[1])return n[1].toUpperCase();const i=(s=(t.split("/")[1]??"").split(/[+.;-]/)[0])==null?void 0:s.trim();return i?i.slice(0,6).toUpperCase():"FILE"}function Xg(e,t){var i,s;const n=((s=(i=/\.([a-z0-9]{1,12})$/i.exec(e.trim()))==null?void 0:i[1])==null?void 0:s.toLowerCase())??"",r=t.toLowerCase();return r.startsWith("image/")?"image":r.startsWith("audio/")?"audio":r.startsWith("video/")?"video":r.includes("pdf")||n==="pdf"?"pdf":Wg.has(n)||/(zip|tar|gzip|rar|compressed|archive)/.test(r)?"archive":Kg.has(n)||/(spreadsheet|sheet|excel|csv)/.test(r)?"sheet":$g.has(n)||/(json|xml|yaml|toml)/.test(r)?"data":Ug.has(n)||/(javascript|typescript|jsx|tsx|css|html)/.test(r)?"code":qg.has(n)||/(msword|document|opendocument|rtf|text\/)/.test(r)?"document":"generic"}function Yg(e){const t=Xg(e.label,e.mimeType),n=Qg(e.sizeBytes);return{category:t,extension:Gg(e.label,e.mimeType),sizeLabel:n,metaBadges:[ja[t],n].filter(r=>!!r)}}function xn(e,t){return d.jsx("span",{className:Q("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 Mi(e,t){return d.jsx("div",{className:Q("truncate text-[11px]",t?"text-white/58":"text-slate-500"),children:e})}function Ni(e,t,n){return d.jsx("span",{className:Q("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 Jg({file:e,isUser:t=!1}){const{category:n,extension:r,metaBadges:i,sizeLabel:s}=Yg(e),a=!!e.dataUrl,l=a?e.isImage?"Open preview":"Open file":"Attached",o=r.slice(0,4),u=Q("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)]",a&&(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 d.jsx("a",{href:e.dataUrl,target:"_blank",rel:"noreferrer","aria-label":`Open preview: ${e.label}`,className:Q(u,"group"),children:d.jsxs("figure",{children:[d.jsxs("div",{className:Q("relative overflow-hidden p-2",t?"bg-white/[0.04]":"bg-gradient-to-br from-slate-100 via-white to-slate-100"),children:[d.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]"}),d.jsxs("div",{className:"pointer-events-none absolute inset-x-4 top-4 flex items-center justify-between",children:[s?xn(s,t):d.jsx("span",{}),d.jsx("span",{className:Q("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":gn[n]),children:o})]})]}),d.jsxs("figcaption",{className:"flex items-start gap-3 p-4",children:[d.jsx("div",{className:Q("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":gn[n]),children:o}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("div",{className:"truncate text-sm font-semibold leading-5",children:e.label}),d.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:i.map(c=>xn(c,t))}),d.jsx("div",{className:"mt-2",children:Mi(e.mimeType,t)})]}),Ni(l,t,!0)]})]})});const h=d.jsxs("div",{className:"flex items-start gap-3 p-3.5",children:[d.jsx("div",{className:Q("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":gn[n]),children:o}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("div",{className:"truncate text-sm font-semibold leading-5",children:e.label}),d.jsxs("div",{className:Q("mt-1 text-xs",t?"text-white/68":"text-slate-500"),children:[ja[n]," attachment"]})]}),Ni(l,t,a)]}),d.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:i.map(c=>xn(c,t))}),d.jsx("div",{className:"mt-2",children:Mi(e.mimeType,t)})]})]});return a?d.jsx("a",{href:e.dataUrl,target:"_blank",rel:"noreferrer","aria-label":`Open file: ${e.label}`,className:Q(u,"group"),children:h}):d.jsx("div",{className:u,children:h})}function Zg(e){return d.jsxs("details",{className:"mt-3",open:!0,children:[d.jsx("summary",{className:Q("cursor-pointer text-xs",e.isUser?"text-primary-100":"text-gray-500"),children:e.label}),d.jsx("pre",{className:Q("mt-2 whitespace-pre-wrap break-words rounded-lg p-2 text-[11px]",e.isUser?"bg-primary-700/60":"bg-gray-100"),children:e.text})]})}function Ut({children:e,className:t}){return d.jsx("div",{className:Q("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 $t({children:e,className:t}){return d.jsx("div",{className:Q("border-t border-amber-200/15 bg-amber-50/50 px-3 pt-1 pb-2 w-full overflow-hidden",t),children:e})}const Ei={running:{text:"text-amber-500/80",icon:Hi,spin:!0},success:{text:"text-amber-500/80",icon:mt,spin:!1},error:{text:"text-amber-500/80",icon:gl,spin:!1},cancelled:{text:"text-amber-500/80",icon:ml,spin:!1}};function ex({card:e}){const t=Ei[e.statusTone]||Ei.cancelled,n=t.icon;return d.jsxs("span",{className:Q("inline-flex items-center gap-1.5 text-[11px] font-medium leading-none shrink-0",t.text),children:[d.jsx(n,{className:Q("h-3.5 w-3.5",t.spin&&"animate-spin"),strokeWidth:3}),e.statusTone==="running"?e.statusLabel:null]})}function qt({card:e,icon:t,expanded:n,canExpand:r,onToggle:i}){var a;const s=(a=e.summary)==null?void 0:a.replace(/^(command|path|args|query|input):\s*/i,"");return d.jsxs("div",{className:Q("flex items-center justify-between px-3 py-2.5 transition-colors bg-transparent",r?"cursor-pointer hover:bg-amber-100/30":""),onClick:i,children:[d.jsxs("div",{className:"flex items-center gap-2 font-mono min-w-0 max-w-[calc(100%-80px)] text-amber-950/80",children:[d.jsx(t,{className:"h-4 w-4 text-amber-600/80 shrink-0",strokeWidth:3}),d.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[d.jsx("span",{className:"font-bold shrink-0 tracking-tight",children:e.toolName}),s&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-amber-300 font-bold select-none shrink-0",children:"›"}),d.jsx("span",{className:"truncate flex-1 min-w-0 font-normal",title:s,children:s})]})]})]}),d.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[d.jsx(ex,{card:e}),r&&(n?d.jsx(Dt,{className:"h-4 w-4 text-amber-400/80",strokeWidth:3}):d.jsx(xl,{className:"h-4 w-4 text-amber-400/80",strokeWidth:3}))]})]})}function tx({card:e}){var p,f,m;const t=((p=e.output)==null?void 0:p.trim())??"",n=e.statusTone==="running",r=!!((f=e.summary)!=null&&f.trim()||t.length>0),i=k.useRef(!r),[s,a]=k.useState(r&&(n||e.statusTone==="error"||t.length<500)),[l,o]=k.useState(!1),u=k.useRef(n);k.useEffect(()=>{i.current&&r&&n&&(a(!0),i.current=!1)},[r,n]),k.useEffect(()=>{u.current&&!n&&!l&&a(!1),u.current=n},[n,l]);const h=()=>{!t&&!n||(a(!s),o(!0))},c=(m=e.summary)==null?void 0:m.replace(/^(command|path|args|query|input):\s*/i,"");return d.jsxs(Ut,{children:[d.jsx(qt,{card:e,icon:yl,expanded:s,canExpand:!!t||n,onToggle:h}),s&&d.jsxs(d.Fragment,{children:[d.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:d.jsxs("div",{className:"flex items-start gap-2 leading-relaxed",children:[d.jsx("span",{className:"text-amber-500/50 font-medium shrink-0 select-none mt-[1px]",children:"$"}),d.jsx("div",{className:"flex-1 min-w-0",children:c?d.jsxs("div",{className:"text-amber-950/80 break-words whitespace-pre-wrap tracking-tight font-medium inline-block",children:[c,n&&!t&&d.jsx("span",{className:"inline-block w-1.5 h-3 ml-1 bg-amber-500/60 animate-pulse align-middle"})]}):d.jsx("div",{className:"h-3 w-32 bg-amber-200/30 rounded animate-pulse mt-2"})})]})}),t&&d.jsx($t,{children:d.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&&d.jsx("span",{className:"inline-block w-1.5 h-3 ml-1 bg-amber-500/60 animate-pulse align-middle"})]})})]})]})}function nx({card:e}){var x;const t=((x=e.output)==null?void 0:x.trim())??"",n=e.statusTone==="running",[r,i]=k.useState(!1),[s,a]=k.useState(!1),l=k.useRef(n);k.useEffect(()=>{l.current&&!n&&!s&&i(!1),l.current=n},[n,s]);const o=()=>{!t&&!n||(i(!r),a(!0))},u=e.toolName==="edit_file"||e.toolName==="write_file",h=(S,g)=>{if(u){if(S.startsWith("+")&&!S.startsWith("+++"))return d.jsxs("div",{className:"bg-emerald-500/10 text-emerald-700 px-2 py-0.5 w-full break-all whitespace-pre-wrap",children:[d.jsx("span",{className:"select-none opacity-40 mr-2 w-3 inline-block shrink-0",children:"+"}),d.jsx("span",{children:S.slice(1)})]},g);if(S.startsWith("-")&&!S.startsWith("---"))return d.jsxs("div",{className:"bg-rose-500/10 text-rose-700 px-2 py-0.5 w-full break-all whitespace-pre-wrap",children:[d.jsx("span",{className:"select-none opacity-40 mr-2 w-3 inline-block shrink-0",children:"-"}),d.jsx("span",{className:"line-through decoration-rose-400/50",children:S.slice(1)})]},g)}return d.jsx("div",{className:"py-0.5 text-amber-950/80 w-full break-all whitespace-pre-wrap",children:d.jsx("span",{children:S})},g)},c=t.split(`
|
|
36
|
-
`),p=15,f=c.length>p,m=!r&&f?c.slice(0,p):c;return d.jsxs(Ut,{children:[d.jsx(qt,{card:e,icon:u?bl:Sl,expanded:r,canExpand:!!t||n,onToggle:o}),r&&t&&d.jsx($t,{children:d.jsx("div",{className:"font-mono text-[12px] leading-relaxed max-h-48 overflow-y-auto overflow-x-hidden min-w-0 custom-scrollbar-amber text-amber-950/80 w-full",children:m.map(h)})})]})}function rx({card:e}){var u;const t=e.statusTone==="running",[n,r]=k.useState(t),[i,s]=k.useState(!1),a=k.useRef(t),l=((u=e.output)==null?void 0:u.trim())??"";k.useEffect(()=>{a.current&&!t&&!i&&r(!1),a.current=t},[t,i]);const o=()=>{!l&&!t||(r(!n),s(!0))};return d.jsxs(Ut,{children:[d.jsx(qt,{card:e,icon:_n,expanded:n,canExpand:!!l||t,onToggle:o}),n&&l&&d.jsx($t,{children:d.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:l})})]})}function ix({card:e}){var h;const t=((h=e.output)==null?void 0:h.trim())??"",n=e.statusTone==="running",[r,i]=k.useState(n),[s,a]=k.useState(!1),l=k.useRef(n),o=e.kind==="result"||e.hasResult;k.useEffect(()=>{l.current&&!n&&!s&&i(!1),l.current=n},[n,s]);const u=()=>{o&&(i(!r),a(!0))};return d.jsxs(Ut,{children:[d.jsx(qt,{card:e,icon:kl,expanded:r,canExpand:o,onToggle:u}),r&&t&&d.jsx($t,{children:d.jsx("pre",{className:"text-amber-950/80 whitespace-pre-wrap break-all overflow-y-auto overflow-x-hidden max-h-64 custom-scrollbar-amber w-full min-w-0 max-w-full leading-relaxed",children:t})})]})}function sx(e){const t=e.toLowerCase();return t==="exec"||t==="execute_command"||t==="bash"||t==="shell"||t.includes("run_")}function ax(e){const t=e.toLowerCase();return t==="read_file"||t==="write_file"||t==="edit_file"||t==="apply_patch"}function lx(e){const t=e.toLowerCase();return t==="grep_search"||t==="find_files"||t.includes("search")}function ox({card:e}){return sx(e.toolName)?d.jsx(tx,{card:e}):ax(e.toolName)?d.jsx(nx,{card:e}):lx(e.toolName)?d.jsx(rx,{card:e}):d.jsx(ix,{card:e})}function ux(e){return d.jsxs("div",{className:"rounded-lg border border-gray-200 bg-gray-50 px-2.5 py-2 text-xs text-gray-600",children:[d.jsxs("div",{className:"font-semibold text-gray-700",children:[e.label,": ",e.rawType]}),e.text?d.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-[11px] text-gray-500",children:e.text}):null]})}const cx=k.memo(function(t){const{message:n,texts:r}=t,{role:i}=n,s=i==="user";return d.jsx("div",{className:Q("inline-block w-fit max-w-full rounded-2xl border px-4 py-3 shadow-sm",s?"border-primary bg-primary text-white":i==="assistant"?"border-gray-200 bg-white text-gray-900":"border-orange-200/80 bg-orange-50/70 text-gray-900"),children:d.jsx("div",{className:"space-y-2",children:n.parts.map((a,l)=>a.type==="markdown"?d.jsx(Vg,{text:a.text,role:i,texts:r},`markdown-${l}`):a.type==="reasoning"?d.jsx(Zg,{label:a.label,text:a.text,isUser:s},`reasoning-${l}`):a.type==="tool-card"?d.jsx("div",{className:"mt-0.5",children:d.jsx(ox,{card:a.card})},`tool-${l}`):a.type==="file"?d.jsx(Jg,{file:a.file,isUser:s},`file-${l}`):a.type==="unknown"?d.jsx(ux,{label:a.label,rawType:a.rawType,text:a.text},`unknown-${l}`):null)})})});function hx(e){return d.jsxs("div",{className:Q("px-1 text-[11px] leading-4 text-gray-400",e.isUser?"text-right":"text-left"),children:[e.roleLabel," · ",e.timestampLabel]})}const dx=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function fx(e){const t=e.trim();return t?t.replace(dx,"").trim().length>0:!1}function px(e){return e.parts.some(t=>t.type==="markdown"||t.type==="reasoning"?fx(t.text):!0)}function mx(e){const t=e.messages.filter(px),n=t.some(r=>r.role==="assistant"&&(r.status==="streaming"||r.status==="pending"));return d.jsxs("div",{className:Q("space-y-5",e.className),children:[t.map(r=>{const i=r.role==="user";return d.jsxs("div",{className:Q("flex gap-3",i?"justify-end":"justify-start"),children:[i?null:d.jsx(Yt,{role:r.role}),d.jsxs("div",{className:Q("w-fit max-w-[92%] space-y-2",i&&"flex flex-col items-end"),children:[d.jsx(cx,{message:r,texts:e.texts}),d.jsx(hx,{roleLabel:r.roleLabel,timestampLabel:r.timestampLabel,isUser:i})]}),i?d.jsx(Yt,{role:r.role}):null]},r.id)}),e.isSending&&!n?d.jsxs("div",{className:"flex justify-start gap-3",children:[d.jsx(Yt,{role:"assistant"}),d.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]})}const gx=10;function xx(e){e.scrollTop=e.scrollHeight}function Li(e){e.scrollRef.current&&(e.scheduledScrollFrameRef.current!==null&&cancelAnimationFrame(e.scheduledScrollFrameRef.current),e.scheduledScrollFrameRef.current=requestAnimationFrame(()=>{e.scheduledScrollFrameRef.current=null;const n=e.scrollRef.current;n&&(e.isProgrammaticScrollRef.current=!0,xx(n))}))}function yx(e){const t=k.useRef(!0),n=k.useRef(!1),r=k.useRef(null),i=k.useRef(!1),s=k.useRef(null),a=()=>{if(n.current){n.current=!1;return}const l=e.scrollRef.current;if(!l)return;const o=l.scrollHeight-l.scrollTop-l.clientHeight;t.current=o<=(e.stickyThresholdPx??gx)};return k.useEffect(()=>{r.current!==e.resetKey&&(r.current=e.resetKey,t.current=!0,i.current=!0)},[e.resetKey]),k.useEffect(()=>{const l=s.current;return()=>{l!==null&&cancelAnimationFrame(l)}},[]),k.useLayoutEffect(()=>{!i.current||e.isLoading||!e.hasContent||!e.scrollRef.current||(i.current=!1,Li({scrollRef:e.scrollRef,scheduledScrollFrameRef:s,isProgrammaticScrollRef:n}))},[e.hasContent,e.isLoading,e.scrollRef]),k.useLayoutEffect(()=>{!t.current||!e.hasContent||!e.scrollRef.current||Li({scrollRef:e.scrollRef,scheduledScrollFrameRef:s,isProgrammaticScrollRef:n})},[e.contentVersion,e.hasContent,e.scrollRef]),{onScroll:a}}function Ra(){return qn()}function bx(e){return Ou(e)}function Ai(e){return zu(e)}function ji(e){return Ot(e,"skill")}function Sx(e){return Ot(e,"file")}function kx(e,t,n){const r=new Set(t),i=Kn(e,o=>o.tokenKind==="skill"&&!r.has(o.tokenKey)),s=Ot(i,"skill"),a=new Map(n.map(o=>[o.spec,o])),l=t.filter(o=>!s.includes(o)).map(o=>{var u;return $n({tokenKind:"skill",tokenKey:o,label:((u=a.get(o))==null?void 0:u.label)||o})});return l.length===0?i:Qe([...i,...l])}function Ri(e,t){const n=new Set(t.map(r=>r.id));return Kn(e,r=>r.tokenKind==="file"&&!n.has(r.tokenKey))}function wx(e,t){const n=new Set(Sx(e));return t.filter(r=>n.has(r.id))}function Cx(e,t){const n=new Map(t.map(i=>[i.id,i])),r=[];for(const i of e){if(i.type==="text"){i.text.length>0&&r.push({type:"text",text:i.text});continue}if(i.tokenKind!=="file")continue;const s=n.get(i.tokenKey);s&&r.push({type:"file",name:s.name,mimeType:s.mimeType,...s.assetUri?{assetUri:s.assetUri}:{},...s.url?{url:s.url}:{},...s.contentBase64?{contentBase64:s.contentBase64}:{},sizeBytes:s.sizeBytes})}return r}const vx={isProviderStateResolved:!1,composerNodes:Ra(),attachments:[],draft:"",pendingSessionType:"native",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:[]},Y=Fn(e=>({snapshot:vx,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))}));function Tx(e){const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,s=[],a=[],l=[],o=[];for(const h of e){const{session:c}=h,p=new Date(c.updatedAt).getTime();p>=n?s.push(h):p>=r?a.push(h):p>=i?l.push(h):o.push(h)}const u=[];return s.length>0&&u.push({label:v("chatSidebarToday"),items:s}),a.length>0&&u.push({label:v("chatSidebarYesterday"),items:a}),l.length>0&&u.push({label:v("chatSidebarPrevious7Days"),items:l}),o.length>0&&u.push({label:v("chatSidebarOlder"),items:o}),u}function Ix(e){if(e.label&&e.label.trim())return e.label.trim();const t=e.key.split(":");return t[t.length-1]||e.key}function Mx(e,t){const n=e.trim().toLowerCase();if(!n||n==="native")return null;const r=t.find(i=>i.value.trim().toLowerCase()===n);return r!=null&&r.label.trim()?r.label.trim():n.split(/[-_]+/g).filter(Boolean).map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" ")}function Nx(e){var t;return e.ready===!1?((t=e.reasonMessage)==null?void 0:t.trim())||v("statusSetup"):v("statusReady")}const Ex=[{target:"/cron",label:()=>v("chatSidebarScheduledTasks"),icon:zn},{target:"/skills",label:()=>v("chatSidebarSkills"),icon:On}];function Lx(){var V,R;const e=Un(),t=Ol(),[n,r]=k.useState(!1),[i,s]=k.useState(null),[a,l]=k.useState(""),[o,u]=k.useState(null),h=Y(C=>C.snapshot),c=fe(C=>C.snapshot),p=_l(C=>C.connectionStatus),{isLoading:f,items:m}=hu(),{language:x,setLanguage:S}=Hn(),{theme:g,setTheme:I}=zl(),M=ou(),D=v(((V=gr.find(C=>C.value===g))==null?void 0:V.labelKey)??"themeWarm"),F=((R=xr.find(C=>C.value===x))==null?void 0:R.label)??x,T=k.useMemo(()=>Tx(m),[m]),O=h.defaultSessionType||"native",H=k.useMemo(()=>h.sessionTypeOptions.filter(C=>C.value!==O),[O,h.sessionTypeOptions]),B=C=>{x!==C&&(S(C),window.location.reload())},w=C=>{var P;s(C.key),l(((P=C.label)==null?void 0:P.trim())??"")},E=()=>{s(null),l(""),u(null)},L=async C=>{var ne;const P=a.trim(),z=((ne=C.label)==null?void 0:ne.trim())??"";if(P===z){E();return}u(C.key);try{await M({sessionKey:C.key,label:P||null}),E()}catch{u(null)}};return d.jsxs("aside",{className:"w-[280px] shrink-0 flex flex-col h-full bg-secondary border-r border-gray-200/60",children:[d.jsx("div",{className:"px-5 pt-5 pb-3",children:d.jsx(Bl,{className:"flex items-center gap-2.5 min-w-0",suffix:d.jsx(au,{status:p})})}),d.jsx("div",{className:"px-4 pb-3",children:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(Re,{variant:"primary",className:ve("min-w-0 rounded-xl",H.length>0?"flex-1 rounded-r-md":"w-full"),onClick:()=>{r(!1),e.chatSessionListManager.createSession(O)},children:[d.jsx(wl,{className:"h-4 w-4 mr-2"}),v("chatSidebarNewTask")]}),H.length>0?d.jsxs(bo,{open:n,onOpenChange:r,children:[d.jsx(So,{asChild:!0,children:d.jsx(Re,{variant:"primary",size:"icon",className:"h-9 w-10 shrink-0 rounded-xl rounded-l-md","aria-label":v("chatSessionTypeLabel"),children:d.jsx(Dt,{className:"h-4 w-4"})})}),d.jsxs(ko,{align:"end",className:"w-64 p-2",children:[d.jsx("div",{className:"px-2 py-1 text-[11px] font-medium uppercase tracking-wider text-gray-400",children:v("chatSessionTypeLabel")}),d.jsx("div",{className:"mt-1 space-y-1",children:H.map(C=>d.jsxs("button",{type:"button",onClick:()=>{e.chatSessionListManager.createSession(C.value),r(!1)},className:"w-full rounded-xl px-3 py-2 text-left transition-colors hover:bg-gray-100",children:[d.jsxs("div",{className:"flex items-center justify-between gap-3",children:[d.jsx("div",{className:"text-[13px] font-medium text-gray-900",children:C.label}),d.jsx("span",{className:ve("shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold",C.ready===!1?"bg-amber-100 text-amber-800":"bg-emerald-100 text-emerald-700"),children:C.ready===!1?v("statusSetup"):v("statusReady")})]}),d.jsx("div",{className:"mt-0.5 text-[11px] text-gray-500",children:Nx(C)})]},C.value))})]})]}):null]})}),d.jsx("div",{className:"px-4 pb-3",children:d.jsxs("div",{className:"relative",children:[d.jsx(_n,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),d.jsx(Bn,{value:c.query,onChange:C=>e.chatSessionListManager.setQuery(C.target.value),placeholder:v("chatSidebarSearchPlaceholder"),className:"pl-8 h-9 rounded-lg text-xs"})]})}),d.jsx("div",{className:"px-3 pb-2",children:d.jsx("ul",{className:"space-y-0.5",children:Ex.map(C=>d.jsx("li",{children:d.jsx(yr,{to:C.target,label:C.label(),icon:C.icon,density:"compact"})},C.target))})}),d.jsx("div",{className:"mx-4 border-t border-gray-200/60"}),d.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2",children:f?d.jsx("div",{className:"text-xs text-gray-500 p-3",children:v("sessionsLoading")}):T.length===0?d.jsxs("div",{className:"p-4 text-center",children:[d.jsx(Cl,{className:"h-6 w-6 mx-auto mb-2 text-gray-300"}),d.jsx("div",{className:"text-xs text-gray-500",children:v("sessionsEmpty")})]}):d.jsx("div",{className:"space-y-3",children:T.map(C=>d.jsxs("div",{children:[d.jsx("div",{className:"px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider",children:C.label}),d.jsx("div",{className:"space-y-0.5",children:C.items.map(({session:P,runStatus:z})=>{const ne=c.selectedSessionKey===P.key,ue=Mx(P.sessionType,h.sessionTypeOptions),y=i===P.key,se=o===P.key;return d.jsx(lu,{session:P,active:ne,runStatus:z,sessionTypeLabel:ue,title:Ix(P),isEditing:y,draftLabel:a,isSaving:se,onSelect:()=>e.chatSessionListManager.selectSession(P.key),onStartEditing:()=>w(P),onDraftLabelChange:l,onSave:()=>L(P),onCancel:E},P.key)})})]},C.label))})}),d.jsxs("div",{className:"px-3 py-3 border-t border-gray-200/60 space-y-0.5",children:[d.jsx(yr,{to:"/settings",label:v("settings"),icon:vl,density:"compact"}),d.jsx(Hl,{onClick:()=>t.open(void 0,{kind:"docs",newTab:!0,title:"Docs"}),icon:Tl,label:v("docBrowserHelp"),density:"compact"}),d.jsx(br,{value:g,onValueChange:C=>I(C),icon:Il,label:v("theme"),valueLabel:D,density:"compact",children:gr.map(C=>d.jsx(lt,{value:C.value,className:"text-xs",children:v(C.labelKey)},C.value))}),d.jsx(br,{value:x,onValueChange:C=>B(C),icon:Ml,label:v("language"),valueLabel:F,density:"compact",children:xr.map(C=>d.jsx(lt,{value:C.value,className:"text-xs",children:C.label},C.value))})]})]})}function Ax(e,t){if(!e||typeof e!="object"||Array.isArray(e))return t;const n=e.error;if(!n||typeof n!="object"||Array.isArray(n))return t;const r=n.message;return typeof r=="string"&&r.trim().length>0?r:t}async function jx(e){const t=new FormData;for(const i of e)t.append("files",i);const n=await fetch(`${Ji}/api/ncp/assets`,{method:"POST",body:t,credentials:"include"}),r=await n.json();if(!n.ok||!r.ok)throw new Error(Ax(r,"Failed to put assets."));return r.data.assets.map(i=>({id:i.id,name:i.name,mimeType:i.mimeType,sizeBytes:i.sizeBytes,assetUri:i.assetUri,url:i.url}))}const Me={exactSpec:1200,exactLabel:1150,prefixSpec:1e3,prefixLabel:950,prefixToken:900,containsSpec:800,containsLabel:760,containsDescription:500,subsequence:300,fallback:1};function It(e){return(e??"").trim().toLowerCase()}function Pi(e,t){if(!e||!t)return!1;let n=0;for(const r of t)if(r===e[n]&&(n+=1,n>=e.length))return!0;return!1}function Rx(e,t){const n=It(t);if(!n)return Me.fallback;const r=It(e.key),i=It(e.label||e.key),s=It(`${e.descriptionZh??""} ${e.description??""}`),a=i.split(/[\s/_-]+/).filter(Boolean);return r===n?Me.exactSpec:i===n?Me.exactLabel:r.startsWith(n)?Me.prefixSpec:i.startsWith(n)?Me.prefixLabel:a.some(l=>l.startsWith(n))?Me.prefixToken:r.includes(n)?Me.containsSpec:i.includes(n)?Me.containsLabel:s.includes(n)?Me.containsDescription:Pi(n,i)||Pi(n,r)?Me.subsequence:0}function Px(e,t,n){const r=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0});return e.map((i,s)=>({record:i,order:s,score:Rx(i,t)})).filter(i=>i.score>0).sort((i,s)=>{if(s.score!==i.score)return s.score-i.score;const a=(i.record.label||i.record.key).trim(),l=(s.record.label||s.record.key).trim(),o=r.compare(a,l);return o!==0?o:i.order-s.order}).map(({record:i})=>({key:`skill:${i.key}`,title:i.label||i.key,subtitle:n.slashSkillSubtitle,description:(i.descriptionZh??i.description??"").trim()||n.noSkillDescription,detailLines:[`${n.slashSkillSpecLabel}: ${i.key}`],value:i.key}))}function Dx(e){return e.map(t=>({key:t.key,label:t.label,description:t.descriptionZh||t.description||"",badgeLabel:t.badgeLabel}))}function Fx(e){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:Dx(e.skillRecords),selectedKeys:e.selectedSkills,onSelectedKeysChange:e.onSelectedKeysChange}}function Ox(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 _x(e){const t=e.modelOptions.find(s=>s.value===e.selectedModel),n=e.modelOptions[0],r=t??n;return{key:"model",value:e.hasModelOptions?r==null?void 0:r.value:void 0,placeholder:e.texts.modelSelectPlaceholder,selectedLabel:r?`${r.providerLabel}/${r.modelLabel}`:void 0,icon:"sparkles",options:e.modelOptions.map(s=>({value:s.value,label:s.modelLabel,description:s.providerLabel})),disabled:!e.hasModelOptions,loading:e.isModelOptionsLoading,emptyLabel:e.texts.modelNoOptionsLabel,onValueChange:e.onValueChange}}function zx(e){const t=[];for(const n of["off",...e])t.includes(n)||t.push(n);return t}function Bx(e){if(e.supportedLevels.length===0)return null;const t=zx(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(i=>({value:i,label:e.texts.thinkingLabels[i]})),onValueChange:i=>e.onValueChange(i)}}function Hx(){return{off:v("chatThinkingLevelOff"),minimal:v("chatThinkingLevelMinimal"),low:v("chatThinkingLevelLow"),medium:v("chatThinkingLevelMedium"),high:v("chatThinkingLevelHigh"),adaptive:v("chatThinkingLevelAdaptive"),xhigh:v("chatThinkingLevelXhigh")}}function Vx(e,t){return e.map(n=>({key:n.spec,label:n.label||n.spec,description:n.description,descriptionZh:n.descriptionZh,badgeLabel:n.origin==="builtin"?t:void 0}))}function Ux(e){return e.map(t=>({value:t.value,modelLabel:t.modelLabel,providerLabel:t.providerLabel,thinkingCapability:t.thinkingCapability?{supported:t.thinkingCapability.supported,default:t.thinkingCapability.default??null}:null}))}function $x(){var w;const e=Un(),{language:t}=Hn(),n=Y(E=>E.snapshot),[r,i]=k.useState(null),s=k.useRef(null),a=k.useRef(null),l=k.useMemo(()=>v("chatSkillsPickerOfficial"),[t]),o=k.useMemo(()=>({slashSkillSubtitle:v("chatSlashTypeSkill"),slashSkillSpecLabel:v("chatSlashSkillSpec"),noSkillDescription:v("chatSkillsPickerNoDescription")}),[t]),u=k.useMemo(()=>Vx(n.skillRecords,l),[n.skillRecords,l]),h=k.useMemo(()=>Ux(n.modelOptions),[n.modelOptions]),c=h.length>0,p=!n.isProviderStateResolved&&!c,f=n.isProviderStateResolved&&!c,m=(p||f)&&!n.isSending||n.sessionTypeUnavailable,x=typeof e.chatInputManager.addAttachments=="function",S=p?"":c?v("chatInputPlaceholder"):v("chatModelNoOptions"),g=k.useMemo(()=>Px(u,r??"",o),[r,u,o]),I=h.find(E=>E.value===n.selectedModel),M=I==null?void 0:I.thinkingCapability,D=(M==null?void 0:M.supported)??[],F=n.stopDisabledReason==="__preparing__"?v("chatStopPreparing"):((w=n.stopDisabledReason)==null?void 0:w.trim())||v("chatStopUnavailable"),T=k.useCallback(E=>{if(E==="unsupported-type"){at.error(v("chatInputAttachmentUnsupported"));return}if(E==="too-large"){at.error(v("chatInputAttachmentTooLarge").replace("{maxMb}",String(os/(1024*1024))));return}at.error(v("chatInputAttachmentReadFailed"))},[]),O=k.useCallback(async E=>{var V,R,C;if(!x||E.length===0)return;const L=await iu(E,{uploadBatch:jx});if(L.attachments.length>0){const P=((R=(V=e.chatInputManager).addAttachments)==null?void 0:R.call(V,L.attachments))??[];P.length>0&&((C=s.current)==null||C.insertFileTokens(P.map(z=>({tokenKey:z.id,label:z.name}))))}L.rejected.length>0&&T(L.rejected[0].reason)},[x,e.chatInputManager,T]),H=[_x({modelOptions:h,selectedModel:n.selectedModel,isModelOptionsLoading:p,hasModelOptions:c,onValueChange:e.chatInputManager.selectModel,texts:{modelSelectPlaceholder:v("chatSelectModel"),modelNoOptionsLabel:v("chatModelNoOptions")}}),Bx({supportedLevels:D,selectedThinkingLevel:n.selectedThinkingLevel,defaultThinkingLevel:(M==null?void 0:M.default)??null,onValueChange:E=>e.chatInputManager.selectThinkingLevel(E),texts:{thinkingLabels:Hx()}})].filter(E=>E!==null),B=Fx({skillRecords:u,selectedSkills:n.selectedSkills,isLoading:n.isSkillsLoading,onSelectedKeysChange:e.chatInputManager.selectSkills,texts:{title:v("chatSkillsPickerTitle"),searchPlaceholder:v("chatSkillsPickerSearchPlaceholder"),emptyLabel:v("chatSkillsPickerEmpty"),loadingLabel:v("sessionsLoading"),manageLabel:v("chatSkillsPickerManage")}});return d.jsxs(d.Fragment,{children:[d.jsx(Is,{ref:s,composer:{nodes:n.composerNodes,placeholder:S,disabled:m,onNodesChange:e.chatInputManager.setComposerNodes,...x?{onFilesAdd:O}:{},onSlashQueryChange:i},slashMenu:{isLoading:n.isSkillsLoading,items:g,texts:{slashLoadingLabel:v("chatSlashLoading"),slashSectionLabel:v("chatSlashSectionSkills"),slashEmptyLabel:v("chatSlashNoResult"),slashHintLabel:v("chatSlashHint"),slashSkillHintLabel:v("chatSlashSkillHint")}},hint:Ox({isModelOptionsLoading:p,isModelOptionsEmpty:f,onGoToProviders:e.chatInputManager.goToProviders,texts:{noModelOptionsLabel:v("chatModelNoOptions"),configureProviderLabel:v("chatGoConfigureProvider")}}),toolbar:{selects:H,accessories:[{key:"attach",label:v("chatInputAttach"),icon:"paperclip",iconOnly:!0,disabled:!x||m||n.isSending,...x?{onClick:()=>{var E;return(E=a.current)==null?void 0:E.click()}}:{tooltip:v("chatInputAttachComingSoon")}}],skillPicker:B,actions:{sendError:n.sendError,isSending:n.isSending,canStopGeneration:n.canStopGeneration,sendDisabled:n.draft.trim().length===0&&n.attachments.length===0||!c||n.sessionTypeUnavailable,stopDisabled:!n.canStopGeneration,stopHint:F,sendButtonLabel:v("chatSend"),stopButtonLabel:v("chatStop"),onSend:e.chatInputManager.send,onStop:e.chatInputManager.stop}}}),x?d.jsx("input",{ref:a,type:"file",multiple:!0,className:"hidden",onChange:async E=>{const L=Array.from(E.target.files??[]);E.currentTarget.value="",await O(L)}}):null]})}const qx=["cmd","command","query","q","path","url","to","channel","agentId","sessionKey"];function Di(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Pn(e,t=2400){return e.length<=t?e:`${e.slice(0,t)}
|
|
37
|
-
…`}function Pt(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(e==null)return"";try{return Pn(JSON.stringify(e,null,2))}catch{return String(e)}}function Kx(e){if(Di(e))return e;if(typeof e!="string")return null;const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return null;try{const n=JSON.parse(t);return Di(n)?n:null}catch{return null}}function Wx(e){const t=Kx(e);if(!t){const r=Pt(e).trim();return r?Pn(r,120):void 0}const n=[];for(const r of qx){const i=t[r];if(typeof i=="string"&&i.trim()?n.push(`${r}: ${i.trim()}`):(typeof i=="number"||typeof i=="boolean")&&n.push(`${r}: ${String(i)}`),n.length>=2)break}return n.length>0?n.join(" · "):Pn(Pt(t),140)}const Qx=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function Et(e){return typeof e=="object"&&e!==null}function yn(e){if(typeof e!="string")return null;const t=e.trim();return t.length>0?t:null}function Pa(e){if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e;if(typeof e!="string")return null;const t=e.trim();if(!t)return null;const n=Number(t);return Number.isFinite(n)&&n>=0?n:null}function Gx(e,t){if(!Et(e))return null;const n=Et(e.asset)?e.asset:Array.isArray(e.assets)&&e.assets.length>0&&Et(e.assets[0])?e.assets[0]:null;if(!n)return null;const r=yn(n.url),i=yn(n.mimeType)??"application/octet-stream",s=Pa(n.sizeBytes);return r?{type:"file",file:{label:yn(n.name)??(i.startsWith("image/")?t.imageAttachmentLabel:t.fileAttachmentLabel),mimeType:i,dataUrl:r,...s!=null?{sizeBytes:s}:{},isImage:i.startsWith("image/")}}:null}function Xx(e){return e.type==="text"&&typeof e.text=="string"}function Yx(e){return e.type==="reasoning"&&typeof e.reasoning=="string"}function Jx(e){return e.type==="file"&&typeof e.mimeType=="string"&&typeof e.data=="string"}function Zx(e){return e.type!=="tool-invocation"||!Et(e.toolInvocation)?!1:typeof e.toolInvocation.toolName=="string"}function ey(e){var n;const t=(n=e.meta)==null?void 0:n.timestamp;return t&&Number.isFinite(Date.parse(t))?t:new Date().toISOString()}function 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{kind:e.kind,toolName:e.name,summary:e.detail,output:e.text,hasResult:!!e.hasResult,statusTone:e.statusTone,statusLabel:e.statusLabel,titleLabel:e.kind==="call"?t.toolCallLabel:t.toolResultLabel,outputLabel:t.toolOutputLabel,emptyLabel:t.toolNoOutputLabel}}function iy(e){const 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}:t==="partial-call"?{kind:"call",hasResult:!1,statusTone:"running",statusLabel:e.texts.toolStatusPreparingLabel}:{kind:"call",hasResult:!1,statusTone:"running",statusLabel:e.texts.toolStatusRunningLabel}}function Fi(e){const t=e.trim();return t&&t.replace(Qx,"").trim()?t:null}function sy(e,t){var n;return{id:e.id,role:ny(e.role),roleLabel:ty(e.role,t.texts.roleLabels),timestampLabel:t.formatTimestamp(ey(e)),status:(n=e.meta)==null?void 0:n.status,parts:e.parts.map(r=>{if(Xx(r)){const i=Fi(r.text);return i?{type:"markdown",text:i}:null}if(Yx(r)){const i=Fi(r.reasoning);return i?{type:"reasoning",text:i,label:t.texts.reasoningLabel}:null}if(Jx(r)){const i=r.mimeType.startsWith("image/"),s=Pa(r.sizeBytes);return{type:"file",file:{label:typeof r.name=="string"&&r.name.trim()?r.name.trim():i?t.texts.imageAttachmentLabel:t.texts.fileAttachmentLabel,mimeType:r.mimeType,dataUrl:typeof r.url=="string"&&r.url.trim().length>0?r.url.trim():`data:${r.mimeType};base64,${r.data}`,...s!=null?{sizeBytes:s}:{},isImage:i}}}if(Zx(r)){const i=r.toolInvocation,s=Gx(i.result,t.texts);if(s)return s;const a=iy({status:i.status,error:i.error,cancelled:i.cancelled,result:i.result,texts:t.texts}),l=Wx(i.parsedArgs??i.args),o=typeof i.error=="string"&&i.error.trim()?i.error.trim():i.result!=null?Pt(i.result).trim():"",u={kind:a.kind,name:i.toolName,detail:l,text:o||void 0,callId:i.toolCallId||void 0,hasResult:a.hasResult,statusTone:a.statusTone,statusLabel:a.statusLabel};return{type:"tool-card",card:ry(u,t.texts)}}return{type:"unknown",label:t.texts.unknownPartLabel,rawType:typeof r.type=="string"?r.type:"unknown",text:Pt(r)}}).filter(r=>r!==null)}}const Oi=new WeakMap;function ay(e){return{roleLabels:{user:v("chatRoleUser"),assistant:v("chatRoleAssistant"),tool:v("chatRoleTool"),system:v("chatRoleSystem"),fallback:v("chatRoleMessage")},reasoningLabel:v("chatReasoning"),toolCallLabel:v("chatToolCall"),toolResultLabel:v("chatToolResult"),toolNoOutputLabel:v("chatToolNoOutput"),toolOutputLabel:v("chatToolOutput"),toolStatusPreparingLabel:v("chatToolStatusPreparing"),toolStatusRunningLabel:v("chatToolStatusRunning"),toolStatusCompletedLabel:v("chatToolStatusCompleted"),toolStatusFailedLabel:v("chatToolStatusFailed"),toolStatusCancelledLabel:v("chatToolStatusCancelled"),imageAttachmentLabel:v("chatImageAttachment"),fileAttachmentLabel:v("chatFileAttachment"),unknownPartLabel:v("chatUnknownPart")}}function ly(e){return{copyCodeLabel:v("chatCodeCopy"),copiedCodeLabel:v("chatCodeCopied"),typingLabel:v("chatTyping")}}function oy(e){const{language:t}=Hn(),n=k.useMemo(()=>ay(),[t]),r=k.useMemo(()=>e.messages.map(a=>{var c,p;const l=Oi.get(a);if(l&&l.language===t)return l.viewModel;const o=Co(a),u={id:o.id,role:o.role,meta:{timestamp:(c=o.meta)==null?void 0:c.timestamp,status:(p=o.meta)==null?void 0:p.status},parts:o.parts},h=sy(u,{formatTimestamp:f=>Ft(f,t),texts:n});return Oi.set(a,{language:t,viewModel:h}),h}),[t,e.messages,n]),i=k.useMemo(()=>r.some(a=>a.role==="assistant"&&(a.status==="streaming"||a.status==="pending")),[r]),s=k.useMemo(()=>ly(),[t]);return d.jsx(mx,{messages:r,isSending:e.isSending,hasAssistantDraft:i,className:e.className,texts:s})}const uy=[{icon:Nl,titleKey:"chatWelcomeCapability1Title",descKey:"chatWelcomeCapability1Desc"},{icon:On,titleKey:"chatWelcomeCapability2Title",descKey:"chatWelcomeCapability2Desc"},{icon:zn,titleKey:"chatWelcomeCapability3Title",descKey:"chatWelcomeCapability3Desc"}];function cy({onCreateSession:e}){return d.jsx("div",{className:"h-full flex items-center justify-center p-8",children:d.jsxs("div",{className:"max-w-lg w-full text-center",children:[d.jsx("div",{className:"mx-auto mb-6 h-16 w-16 rounded-2xl bg-primary/10 flex items-center justify-center",children:d.jsx(Wi,{className:"h-8 w-8 text-primary"})}),d.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-2",children:v("chatWelcomeTitle")}),d.jsx("p",{className:"text-sm text-gray-500 mb-8",children:v("chatWelcomeSubtitle")}),d.jsx("div",{className:"grid grid-cols-3 gap-3",children:uy.map(t=>{const n=t.icon;return d.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:[d.jsx("div",{className:"h-9 w-9 rounded-xl bg-primary/8 flex items-center justify-center mb-3",children:d.jsx(n,{className:"h-4.5 w-4.5 text-primary"})}),d.jsx("div",{className:"text-sm font-semibold text-gray-900 mb-1",children:v(t.titleKey)}),d.jsx("div",{className:"text-[11px] text-gray-500 leading-relaxed",children:v(t.descKey)})]},t.titleKey)})})]})})}const hy={isProviderStateResolved:!1,modelOptions:[],sessionTypeUnavailable:!1,sessionTypeUnavailableMessage:null,sessionTypeLabel:null,selectedSessionKey:null,sessionDisplayName:void 0,canDeleteSession:!1,isDeletePending:!1,threadRef:null,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1},st=Fn(e=>({snapshot:hy,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))}));function dy(){return d.jsxs("section",{className:"flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white",children:[d.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:d.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5",children:d.jsxs("div",{className:"space-y-4",children:[d.jsx("div",{className:"h-6 w-48 animate-pulse rounded bg-gray-200"}),d.jsx("div",{className:"h-24 w-[78%] animate-pulse rounded-2xl bg-gray-200/80"}),d.jsx("div",{className:"h-20 w-[62%] animate-pulse rounded-2xl bg-gray-200/80"}),d.jsx("div",{className:"h-28 w-[84%] animate-pulse rounded-2xl bg-gray-200/80"})]})})}),d.jsx("div",{className:"border-t border-gray-200/80 bg-white p-4",children:d.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)]",children:d.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white shadow-card p-4",children:[d.jsx("div",{className:"h-16 w-full animate-pulse rounded-xl bg-gray-200/80"}),d.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[d.jsx("div",{className:"h-8 w-36 animate-pulse rounded-lg bg-gray-200/80"}),d.jsx("div",{className:"h-8 w-20 animate-pulse rounded-lg bg-gray-200/80"})]})]})})})]})}function fy(){var c;const e=Un(),t=st(p=>p.snapshot),n=k.useRef(null),r=t.threadRef??n,i=!!(t.selectedSessionKey||t.sessionTypeLabel),s=t.sessionDisplayName||t.selectedSessionKey||v("chatSidebarNewTask"),a=!t.selectedSessionKey&&t.messages.length===0&&!t.isSending,l=t.modelOptions.length>0,o=t.isProviderStateResolved&&!l,u=t.isHistoryLoading&&t.messages.length===0&&!t.isSending&&!t.isAwaitingAssistantOutput,{onScroll:h}=yx({scrollRef:r,resetKey:t.selectedSessionKey,isLoading:t.isHistoryLoading,hasContent:t.messages.length>0,contentVersion:t.messages[t.messages.length-1]??null});return t.isProviderStateResolved?d.jsxs("section",{className:"flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white",children:[d.jsxs("div",{className:ve("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:[d.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[d.jsx("span",{className:"text-sm font-medium text-gray-700 truncate",children:s}),t.sessionTypeLabel?d.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.selectedSessionKey?d.jsx(Re,{variant:"ghost",size:"icon",className:"rounded-lg shrink-0 text-gray-400 hover:text-destructive",onClick:e.chatThreadManager.deleteSession,disabled:!t.canDeleteSession||t.isDeletePending,children:d.jsx(Gi,{className:"h-4 w-4"})}):null]}),o&&d.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:[d.jsx("span",{className:"text-xs text-amber-800",children:v("chatModelNoOptions")}),d.jsx("button",{type:"button",onClick:e.chatThreadManager.goToProviders,className:"text-xs font-semibold text-amber-900 underline-offset-2 hover:underline",children:v("chatGoConfigureProvider")})]}),t.sessionTypeUnavailable&&((c=t.sessionTypeUnavailableMessage)==null?void 0:c.trim())&&d.jsx("div",{className:"px-5 py-2.5 border-b border-amber-200/70 bg-amber-50/70 shrink-0",children:d.jsx("span",{className:"text-xs text-amber-800",children:t.sessionTypeUnavailableMessage})}),d.jsx("div",{ref:r,onScroll:h,className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:a?d.jsx(cy,{onCreateSession:e.chatThreadManager.createSession}):u?d.jsx("div",{className:"h-full"}):t.messages.length===0?d.jsx("div",{className:"px-5 py-5 text-sm text-gray-500",children:v("chatNoMessages")}):d.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5",children:d.jsx(oy,{messages:t.messages,isSending:t.isSending&&t.isAwaitingAssistantOutput})})}),d.jsx($x,{})]}):d.jsx(dy,{})}function _i(e){return Ft(e??void 0)}function py(e){return typeof e!="number"||!Number.isFinite(e)?"-":Ft(new Date(e))}function my(e){if(typeof e!="number"||!Number.isFinite(e))return"-";const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const r=Math.round(n/60);return r<24?`${r}h`:`${Math.round(r/24)}d`}function gy(e){const t=e.schedule;return t.kind==="cron"?t.expr?`cron ${t.expr}`:"cron":t.kind==="every"?`every ${my(t.everyMs)}`:t.kind==="at"?`at ${py(t.atMs)}`:"-"}function xy(e){if(!e.payload.deliver)return"-";const t=e.payload.channel??"-",n=e.payload.to??"-";return`${t}:${n}`}function yy(e,t){const n=t.trim().toLowerCase();return n?[e.id,e.name,e.payload.message,e.payload.channel??"",e.payload.to??""].join(" ").toLowerCase().includes(n):!0}function by(e,t){return t==="all"?!0:t==="enabled"?e.enabled:!e.enabled}function Sy(){var m;const[e,t]=k.useState(""),[n,r]=k.useState("all"),i=Vl({all:!0}),s=Ul(),a=$l(),l=ql(),{confirm:o,ConfirmDialog:u}=ns(),h=k.useMemo(()=>{var S;return(((S=i.data)==null?void 0:S.jobs)??[]).filter(g=>yy(g,e)).filter(g=>by(g,n))},[i.data,e,n]),c=async x=>{await o({title:`${v("cronDeleteConfirm")}?`,description:x.name?`${x.name} (${x.id})`:x.id,variant:"destructive",confirmLabel:v("delete")})&&s.mutate({id:x.id})},p=async x=>{const S=!x.enabled;await o({title:S?`${v("cronEnableConfirm")}?`:`${v("cronDisableConfirm")}?`,description:x.name?`${x.name} (${x.id})`:x.id,variant:S?"default":"destructive",confirmLabel:S?v("cronEnable"):v("cronDisable")})&&a.mutate({id:x.id,enabled:S})},f=async x=>{const S=!x.enabled;await o({title:S?`${v("cronRunForceConfirm")}?`:`${v("cronRunConfirm")}?`,description:x.name?`${x.name} (${x.id})`:x.id,confirmLabel:v("cronRunNow")})&&l.mutate({id:x.id,force:S})};return d.jsxs(To,{fullHeight:!0,children:[d.jsx(Io,{title:v("cronPageTitle"),description:v("cronPageDescription"),actions:d.jsx(Re,{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:d.jsx(El,{className:ve("h-4 w-4",i.isFetching&&"animate-spin")})})}),d.jsx("div",{className:"mb-6",children:d.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[d.jsxs("div",{className:"relative flex-1 min-w-[240px]",children:[d.jsx(Bn,{value:e,onChange:x=>t(x.target.value),placeholder:v("cronSearchPlaceholder"),className:"pl-9"}),d.jsx(zn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"})]}),d.jsx("div",{className:"min-w-[180px]",children:d.jsxs(Kl,{value:n,onValueChange:x=>r(x),children:[d.jsx(Wl,{className:"w-full",children:d.jsx(Ql,{placeholder:v("cronStatusLabel")})}),d.jsxs(Gl,{children:[d.jsx(lt,{value:"all",children:v("cronStatusAll")}),d.jsx(lt,{value:"enabled",children:v("cronStatusEnabled")}),d.jsx(lt,{value:"disabled",children:v("cronStatusDisabled")})]})]})}),d.jsxs("div",{className:"text-xs text-gray-500 ml-auto",children:[v("cronTotalLabel"),": ",((m=i.data)==null?void 0:m.total)??0," / ",h.length]})]})}),d.jsx("div",{className:"flex-1 overflow-auto custom-scrollbar",children:i.isLoading?d.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:v("cronLoading")}):h.length===0?d.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:v("cronEmpty")}):d.jsx("div",{className:"space-y-4",children:h.map(x=>d.jsx(Xl,{className:"border border-gray-200",children:d.jsx(Yl,{className:"pt-5 pb-5",children:d.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[d.jsxs("div",{className:"min-w-[220px] flex-1",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx("span",{className:"text-sm font-semibold text-gray-900",children:x.name||x.id}),d.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500",children:x.id}),d.jsx("span",{className:ve("text-[10px] font-semibold px-2 py-0.5 rounded-full",x.enabled?"bg-emerald-50 text-emerald-700":"bg-gray-100 text-gray-500"),children:x.enabled?v("enabled"):v("disabled")}),x.deleteAfterRun&&d.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-amber-50 text-amber-700",children:v("cronOneShot")})]}),d.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[v("cronScheduleLabel"),": ",gy(x)]}),d.jsx("div",{className:"mt-2 text-sm text-gray-700 whitespace-pre-wrap break-words",children:x.payload.message}),d.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[v("cronDeliverTo"),": ",xy(x)]})]}),d.jsxs("div",{className:"min-w-[220px] text-xs text-gray-500 space-y-2",children:[d.jsxs("div",{children:[d.jsxs("span",{className:"font-medium text-gray-700",children:[v("cronNextRun"),":"]})," ",_i(x.state.nextRunAt)]}),d.jsxs("div",{children:[d.jsxs("span",{className:"font-medium text-gray-700",children:[v("cronLastRun"),":"]})," ",_i(x.state.lastRunAt)]}),d.jsxs("div",{children:[d.jsxs("span",{className:"font-medium text-gray-700",children:[v("cronLastStatus"),":"]})," ",x.state.lastStatus??"-"]}),x.state.lastError&&d.jsx("div",{className:"text-[11px] text-red-500 break-words",children:x.state.lastError})]}),d.jsxs("div",{className:"flex items-start gap-2 flex-wrap justify-end",children:[d.jsxs(Re,{variant:"subtle",size:"sm",onClick:()=>f(x),className:"gap-1",children:[d.jsx(Ll,{className:"h-3.5 w-3.5"}),v("cronRunNow")]}),d.jsxs(Re,{variant:x.enabled?"outline":"primary",size:"sm",onClick:()=>p(x),className:"gap-1",children:[d.jsx(Al,{className:"h-3.5 w-3.5"}),x.enabled?v("cronDisable"):v("cronEnable")]}),d.jsxs(Re,{variant:"destructive",size:"sm",onClick:()=>c(x),className:"gap-1",children:[d.jsx(Gi,{className:"h-3.5 w-3.5"}),v("delete")]})]})]})})},x.id))})}),d.jsx(u,{})]})}function ky(e){const{view:t,routeSessionKey:n,selectedSessionKey:r,selectedAgentId:i,setSelectedSessionKey:s,setSelectedAgentId:a,selectedSessionKeyRef:l,resetStreamState:o,resolveAgentIdFromSessionKey:u}=e;k.useEffect(()=>{if(t==="chat"){if(n){r!==n&&s(n);return}r!==null&&(s(null),o())}},[o,n,r,s,t]),k.useEffect(()=>{const h=r?u(r):null;h&&i!==h&&a(h)},[u,i,r,a]),k.useEffect(()=>{l.current=r},[r,l])}function wy({view:e,confirmDialog:t}){return d.jsxs("div",{className:"h-full flex",children:[d.jsx(Lx,{}),e==="chat"?d.jsx(fy,{}):d.jsx("section",{className:"flex-1 min-h-0 overflow-hidden bg-gradient-to-b from-gray-50/60 to-white",children:e==="cron"?d.jsx("div",{className:"h-full overflow-auto custom-scrollbar",children:d.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5",children:d.jsx(Sy,{})})}):d.jsx("div",{className:"h-full overflow-hidden",children:d.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:d.jsx(fo,{forcedType:"skills"})})})}),t]})}function Cy(){return(e,t)=>fetch(e,{credentials:"include",...t})}const Dn="sid_";function vy(e){var r;const t=/^agent:([^:]+):/i.exec(e.trim());if(!t)return null;const n=(r=t[1])==null?void 0:r.trim();return n||null}function Ty(e){const t=new TextEncoder().encode(e);let n="";for(const i of t)n+=String.fromCharCode(i);const r=btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"");return`${Dn}${r}`}function Iy(e){if(!e.startsWith(Dn))return null;const t=e.slice(Dn.length).replace(/-/g,"+").replace(/_/g,"/"),n=t.length%4===0?"":"=".repeat(4-t.length%4);try{const r=atob(t+n),i=Uint8Array.from(r,s=>s.charCodeAt(0));return new TextDecoder().decode(i)}catch{return null}}function My(e){if(!e)return null;const t=Iy(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function Ny(e){return`/chat/${Ty(e)}`}const Se="native";function Oe(e){return typeof e!="string"?Se:e.trim().toLowerCase()||Se}function pt(e,t){return e==="native"?v("chatSessionTypeNative"):e.trim().split(/[-_]+/g).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")||e}function Ey(e){var n;const t=new Map;for(const r of e){const i=Oe(r.value);t.set(i,{value:i,label:((n=r.label)==null?void 0:n.trim())||pt(i),ready:r.ready??!0,reason:r.reason??null,reasonMessage:r.reasonMessage??null,supportedModels:r.supportedModels,recommendedModel:r.recommendedModel??null,cta:r.cta??null})}return t.has(Se)||t.set(Se,{value:Se,label:pt(Se),ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),Array.from(t.values()).sort((r,i)=>r.value===Se?-1:i.value===Se?1:r.value.localeCompare(i.value))}function Ly(e){const{selectedSession:t,selectedSessionKey:n,pendingSessionType:r,setPendingSessionType:i,sessionTypesData:s}=e,a=k.useMemo(()=>Ey((s==null?void 0:s.options)??[]),[s==null?void 0:s.options]),l=k.useMemo(()=>{const S=[...a],g=Oe(t==null?void 0:t.sessionType);return S.some(I=>I.value===g)||S.push({value:g,label:pt(g),ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),S.sort((I,M)=>I.value===Se?-1:M.value===Se?1:I.value.localeCompare(M.value))},[a,t==null?void 0:t.sessionType]),o=k.useMemo(()=>Oe((s==null?void 0:s.defaultType)??Se),[s==null?void 0:s.defaultType]),u=k.useRef(null),h=k.useMemo(()=>Oe((t==null?void 0:t.sessionType)??r??o),[o,r,t==null?void 0:t.sessionType]),c=k.useMemo(()=>l.find(S=>S.value===h)??null,[h,l]);k.useEffect(()=>{if(n)return;const S=typeof r=="string"?r.trim():"",g=Oe(r);(S.length===0||u.current===g||u.current===null&&g===Se)&&(u.current=o,g!==o&&i(o))},[o,r,n,i]);const p=!n||!!(t!=null&&t.sessionTypeMutable),f=k.useMemo(()=>new Set(a.map(S=>S.value)),[a]),m=k.useMemo(()=>t&&!f.has(Oe(t.sessionType))?!0:(c==null?void 0:c.ready)===!1,[f,t,c==null?void 0:c.ready]),x=k.useMemo(()=>{var S;return t&&!f.has(Oe(t.sessionType))?`${pt(h)} ${v("chatSessionTypeUnavailableSuffix")}`:(c==null?void 0:c.ready)===!1?((S=c.reasonMessage)==null?void 0:S.trim())||`${c.label} setup required`:null},[f,t,h,c]);return{sessionTypeOptions:l,selectedSessionTypeOption:c,defaultSessionType:o,selectedSessionType:h,canEditSessionType:p,sessionTypeUnavailable:m,sessionTypeUnavailableMessage:x}}function zi(e){return(e==null?void 0:e.trim().toLowerCase())||"native"}function Ay(e,t){if(typeof t!="string")return!1;const n=t.trim();return n?e.some(r=>r.value===n):!1}function jy(e,t){return typeof t=="string"&&e.includes(t)}function Ry(e){return e.length===0?null:e.includes("off")?"off":e[0]??null}function Da(e){const{currentValue:t,selectedSessionPreferredValue:n,fallbackPreferredValue:r,defaultValue:i,isValueSupported:s,firstAvailableValue:a,preferSessionPreferredValue:l=!1,preserveCurrentValueOnSessionChange:o=!1}=e;return s(t)&&(!l||o)?t:s(n)?n:s(r)?r:s(i)?i:a}function Py(e){var n;const{modelOptions:t}=e;return t.length===0?"":Da({currentValue:e.currentSelectedModel,selectedSessionPreferredValue:e.selectedSessionPreferredModel,fallbackPreferredValue:e.fallbackPreferredModel,defaultValue:e.defaultModel,isValueSupported:r=>Ay(t,r),firstAvailableValue:((n=t[0])==null?void 0:n.value)??"",preferSessionPreferredValue:e.preferSessionPreferredModel,preserveCurrentValueOnSessionChange:e.preserveCurrentSelectedModelOnSessionChange})}function Dy(e){const{supportedThinkingLevels:t}=e;return t.length===0?null:Da({currentValue:e.currentSelectedThinkingLevel,selectedSessionPreferredValue:e.selectedSessionPreferredThinking,fallbackPreferredValue:e.fallbackPreferredThinking,defaultValue:e.defaultThinkingLevel,isValueSupported:n=>jy(t,n),firstAvailableValue:Ry(t)??"off",preferSessionPreferredValue:e.preferSessionPreferredThinking,preserveCurrentValueOnSessionChange:e.preserveCurrentSelectedThinkingOnSessionChange})}function Fa(e){const t=zi(e.sessionType);let n,r=Number.NEGATIVE_INFINITY;for(const i of e.sessions){if(i.key===e.selectedSessionKey||zi(i.sessionType)!==t)continue;const s=e.readPreference(i);if(s==null)continue;const a=Date.parse(i.updatedAt),l=Number.isFinite(a)?a:Number.NEGATIVE_INFINITY;(n===void 0||l>r)&&(n=s,r=l)}return n}function Fy(e){return Fa({sessions:e.sessions,selectedSessionKey:e.selectedSessionKey,sessionType:e.sessionType,readPreference:t=>{var r;return((r=t.preferredModel)==null?void 0:r.trim())||void 0}})}function Oy(e){return Fa({sessions:e.sessions,selectedSessionKey:e.selectedSessionKey,sessionType:e.sessionType,readPreference:t=>t.preferredThinking??void 0})}function Oa(e){const{isPreferenceAvailable:t,emptyValue:n,selectedSessionKey:r,selectedSessionExists:i=!1,setValue:s,resolveValue:a}=e,l=k.useRef(void 0),o=k.useRef(a);k.useEffect(()=>{o.current=a},[a]),k.useEffect(()=>{const u=l.current!==r;if(!t){s(n),l.current=r;return}s(h=>o.current({currentValue:h,sessionChanged:u,preserveCurrentValueOnSessionChange:u&&!!r&&!i})),l.current=r},[n,t,i,r,s])}function _y(e){const{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:s,defaultModel:a,setSelectedModel:l}=e;Oa({isPreferenceAvailable:t.length>0,emptyValue:"",selectedSessionKey:n,selectedSessionExists:r,setValue:l,resolveValue:({currentValue:o,sessionChanged:u,preserveCurrentValueOnSessionChange:h})=>Py({currentSelectedModel:o,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:s,defaultModel:a,preferSessionPreferredModel:u,preserveCurrentSelectedModelOnSessionChange:h})})}function zy(e){const{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:s,defaultThinkingLevel:a,setSelectedThinkingLevel:l}=e;Oa({isPreferenceAvailable:t.length>0,emptyValue:null,selectedSessionKey:n,selectedSessionExists:r,setValue:l,resolveValue:({currentValue:o,sessionChanged:u,preserveCurrentValueOnSessionChange:h})=>Dy({currentSelectedThinkingLevel:o,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:s,defaultThinkingLevel:a,preferSessionPreferredThinking:u,preserveCurrentSelectedThinkingOnSessionChange:h})})}function By(){return jl({queryKey:["ncp-session-types"],queryFn:Jl,staleTime:1e4,retry:!1})}function Hy(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.key.toLowerCase().includes(n)):e}function Vy(e){if(!e.supportedModels||e.supportedModels.length===0)return e.modelOptions;const t=new Set(e.supportedModels),n=e.modelOptions.filter(r=>t.has(r.value));return n.length>0?n:e.modelOptions}function Uy(e){var D,F,T,O,H,B,w,E;const t=Zl(),n=eo(),r=Yi({limit:200}),i=By(),s=po("skill"),a=(t.isFetched||t.isSuccess)&&(n.isFetched||n.isSuccess),l=k.useMemo(()=>{const L=Mo({meta:n.data,config:t.data,onlyConfigured:!0}),V=new Set,R=[];for(const C of L)for(const P of C.models){const z=No(C.prefix,P);!z||V.has(z)||(V.add(z),R.push({value:z,modelLabel:P,providerLabel:C.displayName,thinkingCapability:Eo(C.modelThinking,P,C.aliases)}))}return R.sort((C,P)=>{const z=C.providerLabel.localeCompare(P.providerLabel);return z!==0?z:C.modelLabel.localeCompare(P.modelLabel)})},[n.data,t.data]),o=k.useMemo(()=>{var L;return((L=r.data)==null?void 0:L.sessions)??[]},[(D=r.data)==null?void 0:D.sessions]),u=k.useMemo(()=>ts(o),[o]),h=k.useMemo(()=>Hy(u,e.query),[u,e.query]),c=k.useMemo(()=>u.find(L=>L.key===e.selectedSessionKey)??null,[u,e.selectedSessionKey]),p=k.useMemo(()=>{var L;return((L=s.data)==null?void 0:L.records)??[]},[(F=s.data)==null?void 0:F.records]),f=Ly({selectedSession:c,selectedSessionKey:e.selectedSessionKey,pendingSessionType:e.pendingSessionType,setPendingSessionType:e.setPendingSessionType,sessionTypesData:i.data}),m=k.useMemo(()=>{var L;return Vy({modelOptions:l,supportedModels:(L=f.selectedSessionTypeOption)==null?void 0:L.supportedModels})},[l,(T=f.selectedSessionTypeOption)==null?void 0:T.supportedModels]),x=k.useMemo(()=>Fy({sessions:u,selectedSessionKey:e.selectedSessionKey,sessionType:f.selectedSessionType}),[u,e.selectedSessionKey,f.selectedSessionType]),S=k.useMemo(()=>m.find(L=>L.value===e.currentSelectedModel),[m,e.currentSelectedModel]),g=k.useMemo(()=>{var L;return((L=S==null?void 0:S.thinkingCapability)==null?void 0:L.supported)??[]},[(O=S==null?void 0:S.thinkingCapability)==null?void 0:O.supported]),I=k.useMemo(()=>{var L;return((L=S==null?void 0:S.thinkingCapability)==null?void 0:L.default)??null},[(H=S==null?void 0:S.thinkingCapability)==null?void 0:H.default]),M=k.useMemo(()=>Oy({sessions:u,selectedSessionKey:e.selectedSessionKey,sessionType:f.selectedSessionType}),[u,e.selectedSessionKey,f.selectedSessionType]);return _y({modelOptions:m,selectedSessionKey:e.selectedSessionKey,selectedSessionExists:!!c,selectedSessionPreferredModel:c==null?void 0:c.preferredModel,fallbackPreferredModel:((B=f.selectedSessionTypeOption)==null?void 0:B.recommendedModel)??x,defaultModel:((w=f.selectedSessionTypeOption)==null?void 0:w.recommendedModel)??((E=t.data)==null?void 0:E.agents.defaults.model),setSelectedModel:e.setSelectedModel}),zy({supportedThinkingLevels:g,selectedSessionKey:e.selectedSessionKey,selectedSessionExists:!!c,selectedSessionPreferredThinking:(c==null?void 0:c.preferredThinking)??null,fallbackPreferredThinking:M??null,defaultThinkingLevel:I,setSelectedThinkingLevel:e.setSelectedThinkingLevel}),{configQuery:t,configMetaQuery:n,sessionsQuery:r,sessionTypesQuery:i,installedSkillsQuery:s,isProviderStateResolved:a,modelOptions:m,sessionSummaries:o,sessions:h,skillRecords:p,selectedSession:c,...f}}class $y{constructor(t,n){this.uiManager=t,this.streamActionsManager=n,this.resolveUpdateValue=(r,i)=>typeof i=="function"?i(r):i,this.setSelectedAgentId=r=>{const i=fe.getState().snapshot.selectedAgentId,s=this.resolveUpdateValue(i,r);s!==i&&fe.getState().setSnapshot({selectedAgentId:s})},this.setSelectedSessionKey=r=>{const i=fe.getState().snapshot.selectedSessionKey,s=this.resolveUpdateValue(i,r);s!==i&&fe.getState().setSnapshot({selectedSessionKey:s})},this.createSession=r=>{const{snapshot:i}=Y.getState(),{defaultSessionType:s}=i,a=s||"native",l=typeof r=="string"&&r.trim().length>0?r.trim():a;this.streamActionsManager.resetStreamState(),Y.getState().setSnapshot({pendingSessionType:l}),this.uiManager.goToChatRoot()},this.selectSession=r=>{this.uiManager.goToSession(r)},this.setQuery=r=>{const i=fe.getState().snapshot.query,s=this.resolveUpdateValue(i,r);s!==i&&fe.getState().setSnapshot({query:s})}}}const bn=async()=>{},Bi=()=>{};class qy{constructor(){this.actions={sendMessage:bn,stopCurrentRun:bn,resumeRun:bn,resetStreamState:Bi,applyHistoryMessages:Bi},this.bind=t=>{this.actions={...this.actions,...t}},this.sendMessage=t=>this.actions.sendMessage(t),this.stopCurrentRun=()=>this.actions.stopCurrentRun(),this.resumeRun=t=>this.actions.resumeRun(t),this.resetStreamState=()=>this.actions.resetStreamState(),this.applyHistoryMessages=(t,n)=>this.actions.applyHistoryMessages(t,n)}}const Ky=async e=>!1;class Wy{constructor(){this.state={pathname:""},this.actions={navigate:null,confirm:Ky},this.syncState=t=>{this.state={...this.state,...t}},this.bindActions=t=>{this.actions={...this.actions,...t}},this.confirm=async t=>this.actions.confirm(t),this.navigateTo=(t,n)=>{this.actions.navigate&&(this.state.pathname===t&&!(n!=null&&n.replace)||(this.actions.navigate(t,n),this.state.pathname=t))},this.goToProviders=()=>{this.navigateTo("/providers")},this.goToChatRoot=t=>{this.navigateTo("/chat",t)},this.goToSession=(t,n)=>{this.navigateTo(Ny(t),n)}}}function Qy(e){const t=e.trim();return t.length>0?t:null}function Gy(e){return e??null}class Xy{constructor(t){this.updateSession=t,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{const n=Y.getState().snapshot,i=fe.getState().snapshot.selectedSessionKey;i&&this.enqueue({sessionKey:i,patch:{preferredModel:Qy(n.selectedModel),preferredThinking:Gy(n.selectedThinkingLevel)}})}}enqueue(t){this.queued=t,!this.inFlight&&this.startFlush()}startFlush(){this.inFlight=this.flush().catch(t=>{console.error(`Failed to sync chat session preferences: ${String(t)}`)}).finally(()=>{this.inFlight=null,this.queued&&this.startFlush()})}async flush(){for(;this.queued;){const t=this.queued;this.queued=null,await this.updateSession(t.sessionKey,t.patch)}}}class Yy{constructor(t,n,r){this.uiManager=t,this.streamActionsManager=n,this.getDraftSessionId=r,this.sessionPreferenceSync=new Xy(Xi),this.buildAttachmentSignature=i=>[i.assetUri??"",i.url??"",i.name,i.mimeType,String(i.sizeBytes),i.contentBase64??""].join(":"),this.hasSnapshotChanges=i=>{const s=Y.getState().snapshot;for(const[a,l]of Object.entries(i))if(!Object.is(s[a],l))return!0;return!1},this.resolveUpdateValue=(i,s)=>typeof s=="function"?s(i):s,this.isSameStringArray=(i,s)=>i.length===s.length&&i.every((a,l)=>a===s[l]),this.syncComposerSnapshot=i=>{const s=Y.getState().snapshot.attachments,a=wx(i,s);Y.getState().setSnapshot({composerNodes:i,attachments:a,draft:Ai(i),selectedSkills:ji(i)})},this.syncComposerSnapshotWithAttachments=(i,s)=>{Y.getState().setSnapshot({composerNodes:i,attachments:s,draft:Ai(i),selectedSkills:ji(i)})},this.dedupeAttachments=i=>{const s=new Set,a=[];for(const l of i){const o=this.buildAttachmentSignature(l);s.has(o)||(s.add(o),a.push(l))}return a},this.syncSnapshot=i=>{if(this.hasSnapshotChanges(i)&&(Y.getState().setSnapshot(i),Object.prototype.hasOwnProperty.call(i,"modelOptions")||Object.prototype.hasOwnProperty.call(i,"selectedModel")||Object.prototype.hasOwnProperty.call(i,"selectedThinkingLevel"))){const{selectedModel:s}=Y.getState().snapshot;this.reconcileThinkingForModel(s)}},this.setDraft=i=>{const s=Y.getState().snapshot.draft,a=this.resolveUpdateValue(s,i);a!==s&&this.syncComposerSnapshot(bx(a))},this.setComposerNodes=i=>{const s=Y.getState().snapshot.composerNodes,a=this.resolveUpdateValue(s,i);Object.is(a,s)||this.syncComposerSnapshot(a)},this.addAttachments=i=>{if(i.length===0)return[];const s=Y.getState().snapshot,a=new Set(s.attachments.map(this.buildAttachmentSignature)),l=this.dedupeAttachments([...s.attachments,...i]),o=l.filter(h=>!a.has(this.buildAttachmentSignature(h)));if(o.length===0)return[];const u=Ri(s.composerNodes,l);return this.syncComposerSnapshotWithAttachments(u,l),o},this.restoreComposerState=(i,s)=>{const a=this.dedupeAttachments(s),l=Ri(i,a);this.syncComposerSnapshotWithAttachments(l,a)},this.setPendingSessionType=i=>{const s=Y.getState().snapshot.pendingSessionType,a=this.resolveUpdateValue(s,i);a!==s&&Y.getState().setSnapshot({pendingSessionType:a})},this.send=async()=>{const i=Y.getState().snapshot,s=fe.getState().snapshot,a=i.draft.trim(),l=i.attachments,o=Cx(i.composerNodes,l);if(!o.some(f=>f.type!=="text"||f.text.trim().length>0))return;const{selectedSkills:h,composerNodes:c}=i,p=s.selectedSessionKey??this.getDraftSessionId();s.selectedSessionKey||this.uiManager.goToSession(p,{replace:!0}),this.setComposerNodes(Ra()),await this.streamActionsManager.sendMessage({message:a,sessionKey:p,agentId:s.selectedAgentId,sessionType:i.selectedSessionType,model:i.selectedModel||void 0,thinkingLevel:i.selectedThinkingLevel??void 0,stopSupported:!0,requestedSkills:h,attachments:l,parts:o,restoreDraftOnError:!0,composerNodes:c})},this.stop=async()=>{await this.streamActionsManager.stopCurrentRun()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.setSelectedModel=i=>{const s=Y.getState().snapshot.selectedModel,a=this.resolveUpdateValue(s,i);a!==s&&(Y.getState().setSnapshot({selectedModel:a}),this.reconcileThinkingForModel(a))},this.setSelectedThinkingLevel=i=>{const s=Y.getState().snapshot.selectedThinkingLevel,a=this.resolveUpdateValue(s,i);a!==s&&Y.getState().setSnapshot({selectedThinkingLevel:a})},this.selectSessionType=i=>{const s=Oe(i);Y.getState().setSnapshot({selectedSessionType:s,pendingSessionType:s})},this.setSelectedSkills=i=>{const s=Y.getState().snapshot,{selectedSkills:a}=s,l=this.resolveUpdateValue(a,i);this.isSameStringArray(l,a)||this.syncComposerSnapshot(kx(s.composerNodes,l,s.skillRecords))},this.selectModel=i=>{this.setSelectedModel(i),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectThinkingLevel=i=>{this.setSelectedThinkingLevel(i),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectSkills=i=>{this.setSelectedSkills(i)}}resolveThinkingForModel(t,n){const r=t==null?void 0:t.thinkingCapability;return!r||r.supported.length===0?null:n==="off"?"off":n&&r.supported.includes(n)?n:r.default&&r.supported.includes(r.default)?r.default:"off"}reconcileThinkingForModel(t){const n=Y.getState().snapshot,r=n.modelOptions.find(a=>a.value===t),{selectedThinkingLevel:i}=n,s=this.resolveThinkingForModel(r,i);s!==i&&Y.getState().setSnapshot({selectedThinkingLevel:s})}}class Jy{constructor(t,n,r){this.uiManager=t,this.sessionListManager=n,this.streamActionsManager=r,this.hasSnapshotChanges=i=>{const s=st.getState().snapshot;for(const[a,l]of Object.entries(i))if(!Object.is(s[a],l))return!0;return!1},this.syncSnapshot=i=>{this.hasSnapshotChanges(i)&&st.getState().setSnapshot(i)},this.deleteSession=()=>{this.deleteCurrentSession()},this.createSession=()=>{this.sessionListManager.createSession()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.deleteCurrentSession=async()=>{const{snapshot:{selectedSessionKey:i}}=fe.getState();if(!(!i||!await this.uiManager.confirm({title:v("chatDeleteSessionConfirm"),variant:"destructive",confirmLabel:v("delete")}))){st.getState().setSnapshot({isDeletePending:!0});try{await to(i),no(Sr,i),Sr.removeQueries({queryKey:["ncp-session-messages",i]}),this.streamActionsManager.resetStreamState(),this.uiManager.goToChatRoot({replace:!0})}finally{st.getState().setSnapshot({isDeletePending:!1})}}}}}class Zy{constructor(){this.chatUiManager=new Wy,this.chatStreamActionsManager=new qy,this.chatSessionListManager=new $y(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new Yy(this.chatUiManager,this.chatStreamActionsManager,()=>this.getDraftSessionId()),this.chatThreadManager=new Jy(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.draftSessionId="",this.setDraftSessionId=t=>{this.draftSessionId=t}}getDraftSessionId(){return this.draftSessionId}}function eb(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const r=n.trim();r&&t.add(r)}return[...t]}function tb(e){var r,i,s;const t={};(r=e.model)!=null&&r.trim()&&(t.model=e.model.trim(),t.preferred_model=e.model.trim()),(i=e.thinkingLevel)!=null&&i.trim()&&(t.thinking=e.thinkingLevel.trim(),t.preferred_thinking=e.thinkingLevel.trim()),(s=e.sessionType)!=null&&s.trim()&&(t.session_type=e.sessionType.trim());const n=eb(e.requestedSkills);return n.length>0&&(t.requested_skills=n),t}function nb(e){return e instanceof Error?e.message.includes("ncp session not found:"):!1}function rb({view:e}){var Ie,re,De;const[t]=k.useState(()=>new Zy),[n,r]=k.useState(()=>kr()),i=fe(U=>U.snapshot.query),s=fe(U=>U.snapshot.selectedSessionKey),a=fe(U=>U.snapshot.selectedAgentId),l=Y(U=>U.snapshot.pendingSessionType),o=Y(U=>U.snapshot.selectedModel),{confirm:u,ConfirmDialog:h}=ns(),c=Rl(),p=Pl(),{sessionId:f}=Dl(),m=k.useRef(null),x=k.useRef(s),S=k.useMemo(()=>My(f),[f]),{installedSkillsQuery:g,isProviderStateResolved:I,modelOptions:M,sessionSummaries:D,skillRecords:F,selectedSession:T,sessionTypeOptions:O,defaultSessionType:H,selectedSessionType:B,canEditSessionType:w,sessionTypeUnavailable:E,sessionTypeUnavailableMessage:L}=Uy({query:i,selectedSessionKey:s,currentSelectedModel:o,pendingSessionType:l,setPendingSessionType:t.chatInputManager.setPendingSessionType,setSelectedModel:t.chatInputManager.setSelectedModel,setSelectedThinkingLevel:t.chatInputManager.setSelectedThinkingLevel}),V=s??n,R=k.useRef(D);k.useEffect(()=>{R.current=D},[D]);const[C]=k.useState(()=>new Vo({baseUrl:Ji,basePath:"/api/ncp/agent",fetchImpl:Cy()})),P=k.useCallback(async(U,ke)=>{ke.throwIfAborted();let he=null;try{he=await ro(U,300)}catch(Le){if(!nb(Le))throw Le}ke.throwIfAborted();const we=R.current.find(Le=>Le.sessionId===U)??null;return{messages:(he==null?void 0:he.messages)??[],status:(we==null?void 0:we.status)==="running"?"running":"idle"}},[]),z=eu({sessionId:V,client:C,loadSeed:P});k.useEffect(()=>{t.setDraftSessionId(n)},[n,t]),k.useEffect(()=>{if(s===null){const U=kr();r(U),t.setDraftSessionId(U)}},[t,s]);const ne=z.isSending||z.isRunning,ue=z.isRunning,y=z.isRunning,se=z.isRunning?null:"__preparing__",ye=((Ie=z.hydrateError)==null?void 0:Ie.message)??((re=z.snapshot.error)==null?void 0:re.message)??null;k.useEffect(()=>{t.chatStreamActionsManager.bind({sendMessage:async U=>{var we,Le;if(U.sessionKey!==V)return;const ke=tb({model:U.model,thinkingLevel:U.thinkingLevel,sessionType:U.sessionType,requestedSkills:U.requestedSkills}),he=ru({sessionId:U.sessionKey,text:U.message,attachments:U.attachments,parts:U.parts,metadata:ke});if(he)try{await z.send(he)}catch(Kt){throw U.restoreDraftOnError&&(U.composerNodes&&U.composerNodes.length>0?(Le=(we=t.chatInputManager).restoreComposerState)==null||Le.call(we,U.composerNodes,U.attachments??[]):t.chatInputManager.setDraft(kt=>kt.trim().length===0?U.message:kt)),Kt}},stopCurrentRun:async()=>{await z.abort()},resumeRun:async U=>{U.sessionKey===V&&await z.streamRun()},resetStreamState:()=>{x.current=null},applyHistoryMessages:()=>{}})},[V,z,t]),ky({view:e,routeSessionKey:S,selectedSessionKey:s,selectedAgentId:a,setSelectedSessionKey:t.chatSessionListManager.setSelectedSessionKey,setSelectedAgentId:t.chatSessionListManager.setSelectedAgentId,selectedSessionKeyRef:x,resetStreamState:t.chatStreamActionsManager.resetStreamState,resolveAgentIdFromSessionKey:vy}),k.useEffect(()=>{t.chatUiManager.syncState({pathname:c.pathname}),t.chatUiManager.bindActions({navigate:p,confirm:u})},[u,c.pathname,p,t]);const b=T?vo(T):void 0,ce=((De=O.find(U=>U.value===B))==null?void 0:De.label)??pt(B);return k.useEffect(()=>{t.chatInputManager.syncSnapshot({isProviderStateResolved:I,defaultSessionType:H,canStopGeneration:y,stopDisabledReason:se,stopSupported:!0,stopReason:void 0,sendError:ye,isSending:ne,modelOptions:M,sessionTypeOptions:O,selectedSessionType:B,canEditSessionType:w,sessionTypeUnavailable:E,skillRecords:F,isSkillsLoading:g.isLoading}),t.chatThreadManager.syncSnapshot({isProviderStateResolved:I,modelOptions:M,sessionTypeUnavailable:E,sessionTypeUnavailableMessage:L,sessionTypeLabel:ce,selectedSessionKey:s,sessionDisplayName:b,canDeleteSession:!!T,threadRef:m,isHistoryLoading:z.isHydrating,messages:z.visibleMessages,isSending:ne,isAwaitingAssistantOutput:ue})},[z.isHydrating,w,y,b,ce,H,g.isLoading,ue,I,ne,ye,M.length,M,t,T,s,B,O,E,L,F,se,m,z.visibleMessages]),d.jsx(du,{presenter:t,children:d.jsx(wy,{view:e,confirmDialog:d.jsx(h,{})})})}function gb({view:e}){return d.jsx(rb,{view:e})}export{gb as ChatPage};
|