nextclaw 0.16.23 → 0.16.25
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 +88 -25
- package/package.json +12 -12
- package/ui-dist/assets/{ChannelsList-BlQD1VuM.js → ChannelsList-WmCqjuMG.js} +1 -1
- package/ui-dist/assets/ChatPage-vfnUvEdN.js +37 -0
- package/ui-dist/assets/{DocBrowser-DTww3NZc.js → DocBrowser-Cuds8S4N.js} +1 -1
- package/ui-dist/assets/{LogoBadge-D0ogG1ut.js → LogoBadge-CiukNh5R.js} +1 -1
- package/ui-dist/assets/{MarketplacePage-DTHw6n0X.js → MarketplacePage--cCya2vU.js} +1 -1
- package/ui-dist/assets/{McpMarketplacePage-BikE0mBl.js → McpMarketplacePage-SYy23E4x.js} +1 -1
- package/ui-dist/assets/{ModelConfig-CvM__Pz1.js → ModelConfig-D4Nd4HWX.js} +1 -1
- package/ui-dist/assets/{ProvidersList-DtZWZlL0.js → ProvidersList-k95kUPqD.js} +1 -1
- package/ui-dist/assets/{RemoteAccessPage-E5fT1pem.js → RemoteAccessPage-XjDtIQV4.js} +1 -1
- package/ui-dist/assets/{RuntimeConfig-DyZNiqYT.js → RuntimeConfig-BR4oBxQ-.js} +1 -1
- package/ui-dist/assets/{SearchConfig-C1bhOCNX.js → SearchConfig-fJjFykmH.js} +1 -1
- package/ui-dist/assets/{SecretsConfig-CYmy1Sqy.js → SecretsConfig-D7CxxH1q.js} +1 -1
- package/ui-dist/assets/{SessionsConfig-DSlhPpIE.js → SessionsConfig-2hYobMkj.js} +1 -1
- package/ui-dist/assets/{chat-session-display-D9YuDGe3.js → chat-session-display-BeoRHq9x.js} +1 -1
- package/ui-dist/assets/index-DWrpxFk0.js +8 -0
- package/ui-dist/assets/{label-C7Xd_hqz.js → label-C2uGecRa.js} +1 -1
- package/ui-dist/assets/{page-layout-VxCaUcrD.js → page-layout-DICppNFk.js} +1 -1
- package/ui-dist/assets/{popover-CC4znqAM.js → popover-DoacXI3f.js} +1 -1
- package/ui-dist/assets/{security-config-7eVxJq8b.js → security-config-54LcQtst.js} +1 -1
- package/ui-dist/assets/{skeleton-DhZRDdHm.js → skeleton-DjjQR4NY.js} +1 -1
- package/ui-dist/assets/{status-dot-Bi7Ze-LS.js → status-dot-OjV8JCSV.js} +1 -1
- package/ui-dist/assets/{switch-COBEivEX.js → switch-Dvd2FqUB.js} +1 -1
- package/ui-dist/assets/{tabs-custom-B9j40wuu.js → tabs-custom-DlwuO0Gw.js} +1 -1
- package/ui-dist/assets/{useConfirmDialog-N8nuxOq-.js → useConfirmDialog-BuB9l_2r.js} +1 -1
- package/ui-dist/index.html +1 -1
- package/ui-dist/assets/ChatPage-DBvm558n.js +0 -37
- package/ui-dist/assets/index-BBz4mi7g.js +0 -8
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var Zl=Object.defineProperty;var ea=(e,t,n)=>t in e?Zl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ne=(e,t,n)=>ea(e,typeof t!="symbol"?t+"":t,n);import{r as k,j as h,ae as Ki,v as yt,X as ta,af as na,f as ra,e as ot,d as Bn,t as ia,c as sa,y as la,z as aa,ag as oa,h as qi,I as ua,i as _t,n as ca,o as Wi,V as da,x as Qi,p as Gi,q as Xi,s as ha,w as fa,k as Yi,l as pa,m as Ji,a as ma,ah as ga,B as Vn,G as Hn,ai as xa,aj as ya,ak as ba,F as Sa,al as ka,am as wa,_ as Ca,an as Zi,ao as es,ap as va,aq as Ta,ar as Ia,as as Ma,at as Na,au as Ea,av as La,aw as Aa,ax as Ra,A as Un,ay as ja,a0 as Pa,a3 as Da,a1 as Fa,a2 as Oa,M as za,az as ts,aA as _a,aB as Ba,aC as Va,u as Ha,a4 as Ua,aD as $a,aE as Ka}from"./vendor-MCpnpiKt.js";import{t as T,c as ve,I as $n,B as je,i as Bt,j as ns,k as qa,l as rs,m as Wa,n as Qa,o as Kn,p as Ga,T as br,L as Sr,q as Xa,r as kr,s as Ya,v as wr,h as ut,A as is,w as Ja,x as Za,y as eo,z as to,S as no,e as ro,f as io,g as so,C as lo,E as ao,F as oo,u as uo,a as co,G as ho,H as fo,J as Cr,K as po,M as mo}from"./index-DWrpxFk0.js";import{T as go,a as xo,b as yo,c as bo,P as So,R as ko,d as wo,e as Co,C as ss,M as vo,u as To}from"./MarketplacePage--cCya2vU.js";import{R as Io,A as Mo,P as No,C as ls,T as Eo,a as Lo,b as Ao,c as Ro}from"./popover-DoacXI3f.js";import{S as jo,a as as,b as Po,c as vr,s as Do}from"./chat-session-display-BeoRHq9x.js";import{u as os}from"./useConfirmDialog-BuB9l_2r.js";import{P as Fo,a as Oo}from"./page-layout-DICppNFk.js";import{b as zo,c as _o,r as Bo}from"./provider-models-BOeNnjk9.js";import"./tabs-custom-DlwuO0Gw.js";import"./skeleton-DjjQR4NY.js";import"./marketplace-localization-Dk31LJJJ.js";var te=(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))(te||{}),Tr=/\[\[\s*reply_to_current\s*\]\]/gi,Ir=/\[\[\s*reply_to\s*:\s*([^\]]+?)\s*\]\]/i;function vn(e){if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}function Vo(e,t){var s;let n=e,r;Tr.test(n)&&(r=vn(t),n=n.replace(Tr,"").trim());const i=(s=n.match(Ir))==null?void 0:s[1];return i&&(r=vn(i),n=n.replace(Ir,"").trim()),r?{content:n,replyTo:r}:{content:n}}function Ho(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(c=>c.type==="text"),r=e.metadata?{...e.metadata}:void 0,i=vn(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:l,replyTo:a}=Vo(s.text,t),o=a??i,u=e.parts.flatMap((c,d)=>d!==n||c.type!=="text"?[c]:l.length===0?[]:[{...c,text:l}]);return o?{...e,parts:u,metadata:{...r,reply_to:o}}:{...e,parts:u,metadata:r}}function Mr(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*Uo(e){const t=e.getReader(),n=new TextDecoder;let r="";try{for(;;){const{value:s,done:l}=await t.read();if(l)break;r+=n.decode(s,{stream:!0});const{frames:a,rest:o}=Nr(r);r=o;for(const u of a)yield u}r+=n.decode();const{frames:i}=Nr(r,!0);for(const s of i)yield s}finally{t.releaseLock()}}function Nr(e,t=!1){const n=e.split(/\r?\n\r?\n/),r=n.pop()??"",i=[];for(const s of n){const l=Mr(s);l&&i.push(l)}if(t&&r.trim()){const s=Mr(r);return s&&i.push(s),{frames:i,rest:""}}return{frames:i,rest:r}}var Er="/ncp/agent",$o="ncp-http-agent-client",us=class extends Error{constructor(t,n=!1){super(t.message);ne(this,"ncpError");ne(this,"alreadyPublished");this.name=`NcpHttpAgentClientError(${t.code})`,this.ncpError=t,this.alreadyPublished=n}};function Ko(e){const t=e.trim();if(!t)throw new Error("NcpHttpAgentClient requires a non-empty baseUrl.");return new URL(t)}function qo(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 Wo(e){const t=(e??Er).trim();if(!t)return Er;const n=t.startsWith("/")?t:`/${t}`;return n.endsWith("/")?n.slice(0,-1):n}async function Lr(e){try{return(await e.text()).trim()}catch{return""}}function Ar(e){if(cs(e))return e.ncpError;if(Qo(e))return e;const t=e instanceof Error?e.message:String(e??"Unknown error");return{code:ds(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function Yt(e,t={}){return new us(e,t.alreadyPublished??!1)}function Qo(e){return qn(e)&&typeof e.code=="string"&&typeof e.message=="string"}function qn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function cs(e){return e instanceof us}var Go={"config-error":"config-error","auth-error":"auth-error","runtime-error":"runtime-error","timeout-error":"timeout-error","abort-error":"abort-error"};function ds(e){if(!e)return"runtime-error";const t=Go[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 Xo(e){const t=hs(e);return!t||typeof t.type!="string"||!t.type.trim()?null:t}function Yo(e){const t=hs(e);if(!t)return{code:"runtime-error",message:e||"Unknown stream error."};const n=typeof t.code=="string"?t.code:void 0,r=ds(n),i=qn(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 hs(e){try{const t=JSON.parse(e);return qn(t)?t:null}catch{return null}}var Jo=["text","file","source","step-start","reasoning","tool-invocation","card","rich-text","action","extension"],Zo=class{constructor(e){ne(this,"manifest");ne(this,"baseUrl");ne(this,"basePath");ne(this,"fetchImpl");ne(this,"defaultHeaders");ne(this,"subscribers",new Set);ne(this,"activeControllers",new Set);ne(this,"started",!1);var t;this.baseUrl=Ko(e.baseUrl),this.basePath=Wo(e.basePath),this.fetchImpl=qo(e.fetchImpl),this.defaultHeaders=e.headers??{},this.manifest={endpointKind:"custom",endpointId:((t=e.endpointId)==null?void 0:t.trim())||$o,version:"0.1.0",supportsStreaming:!0,supportsAbort:!0,supportsProactiveMessages:!1,supportsLiveSessionStream:!0,supportedPartTypes:Jo,expectedLatency:"seconds",metadata:{transport:"http+sse",scope:"agent"}}}async start(){this.started||(this.started=!0,this.publish({type:te.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 Lr(n)}`)}catch(n){if(t.signal.aborted)return;const r=Ar(n);throw this.publish({type:te.EndpointError,payload:r}),Yt(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 Lr(n)}`);if(!n.body)throw new Error("NCP stream response has no body.");for await(const r of Uo(n.body)){if(t.signal.aborted)return;this.handleSseFrame(r)}}catch(n){if(t.signal.aborted)return;if(cs(n))throw n;const r=Ar(n);throw this.publish({type:te.EndpointError,payload:r}),Yt(r)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event==="ncp-event"){const t=Xo(e.data);if(!t){this.publish({type:te.EndpointError,payload:{code:"runtime-error",message:"Received malformed ncp-event frame."}});return}this.publish(t);return}if(e.event==="error"){const t=Yo(e.data);throw this.publish({type:te.EndpointError,payload:t}),Yt(t,{alreadyPublished:!0})}}};function fs(e){return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0}}function Jt(e){return fs(Ho(e))}function eu(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 tu(e,t){return t.trim()?e.id.startsWith("tool-")?!0:e.parts.some(n=>n.type==="tool-invocation"):!1}function nu(e,t,n){for(const[r,i]of e)i===t&&e.set(r,n)}function Zt(e,t,n){for(const[r,i]of e)i===n&&(e.delete(r),t.delete(r))}function Tn(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 Rr(e,t){const n=Tn(e,t);return(n==null?void 0:n.toolName)??null}function nt(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 ru="assistant",iu=class{constructor(){ne(this,"messages",[]);ne(this,"streamingMessage",null);ne(this,"error",null);ne(this,"activeRun",null);ne(this,"listeners",new Set);ne(this,"toolCallMessageIdByCallId",new Map);ne(this,"toolCallArgsRawByCallId",new Map);ne(this,"snapshotCache",null);ne(this,"snapshotVersion",-1);ne(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=>Jt(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 te.MessageSent:this.handleMessageSent(e.payload);break;case te.MessageAbort:this.handleMessageAbort(e.payload);break;case te.MessageTextStart:this.handleMessageTextStart(e.payload);break;case te.MessageTextDelta:this.handleMessageTextDelta(e.payload);break;case te.MessageTextEnd:this.handleMessageTextEnd(e.payload);break;case te.MessageReasoningStart:this.handleMessageReasoningStart(e.payload);break;case te.MessageReasoningDelta:this.handleMessageReasoningDelta(e.payload);break;case te.MessageReasoningEnd:this.handleMessageReasoningEnd(e.payload);break;case te.MessageToolCallStart:this.handleMessageToolCallStart(e.payload);break;case te.MessageToolCallArgs:this.handleMessageToolCallArgs(e.payload);break;case te.MessageToolCallArgsDelta:this.handleMessageToolCallArgsDelta(e.payload);break;case te.MessageToolCallEnd:this.handleMessageToolCallEnd(e.payload);break;case te.MessageToolCallResult:this.handleMessageToolCallResult(e.payload);break;case te.RunStarted:this.handleRunStarted(e.payload);break;case te.RunFinished:this.handleRunFinished(e.payload);break;case te.RunError:this.handleRunError(e.payload);break;case te.RunMetadata:this.handleRunMetadata(e.payload);break;case te.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?Zt(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t):Zt(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=nt(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=nt(t.parts,{type:"tool-invocation",toolCallId:e.toolCallId,toolName:Rr(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 nt(n.parts,i)})){const n=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId),r=nt(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(eu(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=Rr(i.parts,t)??"unknown",l=nt(i.parts,{type:"tool-invocation",toolCallId:t,toolName:s,state:"partial-call",args:n});this.replaceStreamingMessage({...i,parts:l,status:"streaming"})}ensureStreamingMessage(e,t,n){var l;if(((l=this.streamingMessage)==null?void 0:l.id)===t){if(this.streamingMessage.status===n)return this.streamingMessage;const a={...this.streamingMessage,status:n};return this.replaceStreamingMessage(a),a}const r=this.messages.findIndex(a=>a.id===t);if(r>=0){const a=fs(this.messages[r]),o=[...this.messages];o.splice(r,1),this.messages=o,this.stateVersion+=1;const u={...a,sessionId:e,status:n};return this.replaceStreamingMessage(u),u}const i=this.streamingMessage;if(i&&i.id!==t&&i.sessionId===e&&tu(i,t)){const a={...i,id:t,sessionId:e,status:n};return nu(this.toolCallMessageIdByCallId,i.id,t),this.replaceStreamingMessage(a),a}const s={id:t,sessionId:e,role:ru,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=Tn(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=Tn(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=Jt(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?Jt(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),Zt(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t.id)}notifyListeners(){const e=this.getSnapshot();for(const t of this.listeners)t(e)}};function su(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 lu(e){return e.parts.some(t=>t.type==="text"||t.type==="rich-text"||t.type==="reasoning"?t.text.trim().length>0:!0)}function au(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 lu(e.message)?{...e,sessionId:e.sessionId,message:{...e.message,sessionId:e.message.sessionId||e.sessionId}}:null}function ou(e){const t=k.useRef();return(!t.current||t.current.sessionId!==e)&&(t.current={sessionId:e,manager:new iu}),t.current.manager}function uu({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=>{su(m,e)&&n.dispatch(m)});return()=>{f(),t.stop()}},[t,n,e]);const l=r.streamingMessage?[...r.messages,r.streamingMessage]:r.messages,a=((p=r.activeRun)==null?void 0:p.runId)??null,o=!!r.activeRun;return{snapshot:r,visibleMessages:l,activeRunId:a,isRunning:o,isSending:i,send:async f=>{if(i||o)return;const m=au(f,e);if(m){s(!0),await n.dispatch({type:te.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 jr(e){return e instanceof Error?e:new Error(String(e))}function cu(e){return e.isHydrating||e.hydratedSessionId!==e.sessionId}function du({sessionId:e,client:t,loadSeed:n,autoResumeRunningSession:r=!0}){const i=ou(e),s=uu({sessionId:e,client:t,manager:i}),[l,a]=k.useState(!0),[o,u]=k.useState(null),[c,d]=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,y=p.current.requestId+1;p.current={requestId:y,controller:m},await t.stop(),i.reset(),u(null),a(!0);try{const g=await n(e,m.signal);if(m.signal.aborted||p.current.requestId!==y)return;i.hydrate({sessionId:e,messages:g.messages,activeRun:g.status==="running"?{runId:null,sessionId:e,abortDisabledReason:null}:null}),u(null),d(e),a(!1),g.status==="running"&&r&&t.stream({sessionId:e}).catch(I=>{p.current.requestId===y&&u(jr(I))})}catch(g){if(m.signal.aborted||p.current.requestId!==y)return;u(jr(g)),d(e),a(!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:cu({sessionId:e,hydratedSessionId:c,isHydrating:l}),hydrateError:o}}var ps=200*1024*1024,hu="application/octet-stream";function ms(e){const t=e.type.trim().toLowerCase();return t.length>0?t:hu}function fu(e,t){const n=t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0?new Set(t.acceptedMimeTypes.map(s=>s.trim().toLowerCase())):null,r=t.maxBytes??ps,i=ms(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 pu(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 l,a,o;return{type:"file",name:s.name,mimeType:s.mimeType,...(l=s.assetUri)!=null&&l.trim()?{assetUri:s.assetUri.trim()}:{},...(a=s.url)!=null&&a.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 mu(e,t){const n=[],r=[];for(const i of e){const s=fu(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:ms(i),sizeBytes:i.size,reason:"read-failed"}))),{attachments:[],rejected:r}}}const gu={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 xu({status:e,className:t}){const n=gu[e],r=e==="connected"?T("connected"):e==="disconnected"?T("disconnected"):T("connecting");return h.jsx(go,{delayDuration:250,children:h.jsxs(xo,{children:[h.jsx(yo,{asChild:!0,children:h.jsx("span",{role:"status","aria-label":r,className:ve("inline-flex h-5 w-5 items-center justify-center",t),children:e==="connecting"?h.jsx(Ki,{className:ve("h-3 w-3 animate-spin",n.dotClass)}):h.jsx("span",{className:ve(e==="connected"?"h-2 w-2 rounded-full":"",n.dotClass)})})}),h.jsx(bo,{side:"bottom",className:"text-xs",children:r})]})})}function yu(e){const{session:t,active:n,runStatus:r,sessionTypeLabel:i,title:s,isEditing:l,draftLabel:a,isSaving:o,onSelect:u,onStartEditing:c,onDraftLabelChange:d,onSave:p,onCancel:f}=e;return h.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:l?h.jsxs("div",{className:"space-y-2",children:[h.jsx($n,{value:a,onChange:m=>d(m.target.value),onKeyDown:m=>{m.key==="Enter"?(m.preventDefault(),p()):m.key==="Escape"&&(m.preventDefault(),f())},placeholder:T("sessionsLabelPlaceholder"),className:"h-8 rounded-lg border-gray-300 bg-white text-xs",autoFocus:!0,disabled:o}),h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsx("div",{className:"min-w-0 text-[11px] text-gray-400 truncate",children:t.key}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(je,{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":T("save"),children:h.jsx(yt,{className:"h-3.5 w-3.5"})}),h.jsx(je,{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":T("cancel"),children:h.jsx(ta,{className:"h-3.5 w-3.5"})})]})]})]}):h.jsxs("div",{className:"group/session relative",children:[h.jsxs("button",{type:"button",onClick:u,className:"w-full text-left",children:[h.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_0.875rem] items-center gap-1.5 pr-8",children:[h.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[h.jsx("span",{className:"truncate font-medium",children:s}),i?h.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]}),h.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:r?h.jsx(jo,{status:r}):null})]}),h.jsxs("div",{className:"mt-0.5 text-[11px] text-gray-400 truncate",children:[t.messageCount," · ",Bt(t.updatedAt)]})]}),h.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),c()},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":T("edit"),children:h.jsx(na,{className:"h-3.5 w-3.5"})})]})})}function bu(){const e=ra();return async t=>{try{const n=await ns(t.sessionKey,{label:t.label});qa(e,n),ot.success(T("configSavedApplied"))}catch(n){throw ot.error(T("configSaveFailed")+": "+(n instanceof Error?n.message:String(n))),n}}}const Su={selectedSessionKey:null,selectedAgentId:"main",query:""},fe=Bn(e=>({snapshot:Su,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))}));function ku(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.key.toLowerCase().includes(n)):[...e]}function wu(e={}){var i;const t=fe(s=>s.snapshot.query),n=rs({limit:e.limit??200}),r=k.useMemo(()=>{var u;const s=((u=n.data)==null?void 0:u.sessions)??[],l=as(s),a=ku(l,t),o=new Map(s.map(c=>[c.sessionId,c]));return a.map(c=>{var d;return{session:c,runStatus:((d=o.get(c.key))==null?void 0:d.status)==="running"?"running":void 0}})},[t,(i=n.data)==null?void 0:i.sessions]);return{isLoading:n.isLoading,items:r}}const gs=k.createContext(null);function Cu({presenter:e,children:t}){return h.jsx(gs.Provider,{value:e,children:t})}function Wn(){const e=k.useContext(gs);if(!e)throw new Error("usePresenter must be used inside ChatPresenterProvider");return e}const vu=e=>`[data-item-index="${e}"]`;function xs(e){const t=e.getItemSelector??vu;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 Tu(){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 ia(sa(e))}const ys=k.forwardRef(({className:e,type:t,...n},r)=>h.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}));ys.displayName="ChatInput";const Iu=Io,Mu=Eo,Nu=Mo,bs=k.forwardRef(({className:e,sideOffset:t=8,align:n="start",...r},i)=>h.jsx(No,{children:h.jsx(ls,{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})}));bs.displayName=ls.displayName;const Eu=la,Lu=oa,Au=aa,Ss=k.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(qi,{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,h.jsx(ua,{asChild:!0,children:h.jsx(_t,{className:"h-4 w-4 opacity-50"})})]}));Ss.displayName=qi.displayName;const ks=k.forwardRef(({className:e,...t},n)=>h.jsx(Yi,{ref:n,className:q("flex cursor-default items-center justify-center py-1",e),...t,children:h.jsx(pa,{className:"h-4 w-4"})}));ks.displayName=Yi.displayName;const ws=k.forwardRef(({className:e,...t},n)=>h.jsx(Ji,{ref:n,className:q("flex cursor-default items-center justify-center py-1",e),...t,children:h.jsx(_t,{className:"h-4 w-4"})}));ws.displayName=Ji.displayName;const Cs=k.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>h.jsx(ca,{children:h.jsxs(Wi,{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:[h.jsx(ks,{}),h.jsx(da,{className:q("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),h.jsx(ws,{})]})}));Cs.displayName=Wi.displayName;const vs=k.forwardRef(({className:e,...t},n)=>h.jsx(Gi,{ref:n,className:q("px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500",e),...t}));vs.displayName=Gi.displayName;const Ts=k.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(Xi,{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:[h.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(ha,{children:h.jsx(yt,{className:"h-4 w-4"})})}),h.jsx(fa,{children:t})]}));Ts.displayName=Xi.displayName;const Is=k.forwardRef(({className:e,...t},n)=>h.jsx(Qi,{ref:n,className:q("-mx-1 my-1 h-px bg-gray-100",e),...t}));Is.displayName=Qi.displayName;const Ru=So,ju=ko,Pu=wo,Ms=k.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(Co,{children:h.jsx(ss,{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})}));Ms.displayName=ss.displayName;const bt={Popover:Iu,PopoverAnchor:Nu,PopoverContent:bs,PopoverTrigger:Mu,Input:ys,Select:Eu,SelectContent:Cs,SelectGroup:Lu,SelectItem:Ts,SelectLabel:vs,SelectSeparator:Is,SelectTrigger:Ss,SelectValue:Au,Tooltip:ju,TooltipContent:Ms,TooltipProvider:Ru,TooltipTrigger:Pu},Du=680,Fu=.82,Ou=560;function zu(e){const{Popover:t,PopoverAnchor:n,PopoverContent:r}=bt,{elementRef:i,width:s}=Tu(),l=k.useRef(null),{isOpen:a,isLoading:o,items:u,activeIndex:c,activeItem:d,texts:p,onSelectItem:f,onOpenChange:m,onSetActiveIndex:y}=e,S=k.useMemo(()=>{if(s)return Math.min(s>Ou?s*Fu:s,Du)},[s]);return xs({containerRef:l,activeIndex:c,itemCount:u.length,isEnabled:a&&!o,getItemSelector:g=>`[data-slash-index="${g}"]`}),h.jsxs(t,{open:a,onOpenChange:m,children:[h.jsx(n,{asChild:!0,children:h.jsx("div",{ref:i,className:"pointer-events-none absolute bottom-full left-3 right-3 h-0"})}),h.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:h.jsxs("div",{className:"grid min-h-[240px] grid-cols-[minmax(220px,300px)_minmax(0,1fr)]",children:[h.jsx("div",{ref:l,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?h.jsx("div",{className:"p-2 text-xs text-gray-500",children:p.slashLoadingLabel}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"mb-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500",children:p.slashSectionLabel}),u.length===0?h.jsx("div",{className:"px-2 text-xs text-gray-400",children:p.slashEmptyLabel}):h.jsx("div",{className:"space-y-1",children:u.map((g,I)=>{const N=I===c;return h.jsxs("button",{type:"button",role:"option","aria-selected":N,"data-slash-index":I,onMouseEnter:()=>y(I),onClick:()=>f(g),className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition ${N?"bg-gray-100 text-gray-900":"text-gray-700 hover:bg-gray-50"}`,children:[h.jsx("span",{className:"truncate text-xs font-semibold",children:g.title}),h.jsx("span",{className:"truncate text-xs text-gray-500",children:g.subtitle})]},g.key)})})]})}),h.jsx("div",{className:"max-w-[320px] p-3.5",children:d?h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary",children:d.subtitle}),h.jsx("span",{className:"text-sm font-semibold text-gray-900",children:d.title})]}),h.jsx("p",{className:"text-xs leading-5 text-gray-600",children:d.description}),h.jsx("div",{className:"space-y-1",children:d.detailLines.map(g=>h.jsx("div",{className:"rounded-md bg-gray-50 px-2 py-1 text-[11px] text-gray-600",children:g},g))}),h.jsx("div",{className:"pt-1 text-[11px] text-gray-500",children:p.slashSkillHintLabel})]}):h.jsx("div",{className:"text-xs text-gray-500",children:p.slashHintLabel})})]})})]})}const _u=ma("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"}}),At=k.forwardRef(({className:e,variant:t,size:n,...r},i)=>h.jsx("button",{className:q(_u({variant:t,size:n,className:e})),ref:i,...r}));At.displayName="ChatButton";function Pr(){return h.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 Bu(e){var s;const{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=bt;return h.jsxs("div",{className:"flex flex-col items-end gap-1",children:[(s=e.sendError)!=null&&s.trim()?h.jsx("div",{className:"max-w-[420px] text-right text-[11px] text-red-600",children:e.sendError}):null,h.jsx("div",{className:"flex items-center gap-2",children:e.isSending?e.canStopGeneration?h.jsx(At,{size:"icon",variant:"outline",className:"h-8 w-8 rounded-full","aria-label":e.stopButtonLabel,onClick:()=>void e.onStop(),disabled:e.stopDisabled,children:h.jsx(Pr,{})}):h.jsx(r,{children:h.jsxs(t,{children:[h.jsx(i,{asChild:!0,children:h.jsx("span",{children:h.jsx(At,{size:"icon",variant:"outline",className:"h-8 w-8 rounded-full","aria-label":e.stopButtonLabel,disabled:!0,children:h.jsx(Pr,{})})})}),h.jsx(n,{side:"top",children:h.jsx("p",{className:"text-xs",children:e.stopHint})})]})}):h.jsx(At,{size:"icon",className:"h-8 w-8 rounded-full","aria-label":e.sendButtonLabel,onClick:()=>void e.onSend(),disabled:e.sendDisabled,children:h.jsx(ga,{className:"h-5 w-5"})})})]})}function Vu(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 Hu(e){const{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=bt,{picker:s}=e,l=k.useRef(null),a=k.useId(),[o,u]=k.useState(""),[c,d]=k.useState(0),p=k.useMemo(()=>new Set(s.selectedKeys),[s.selectedKeys]),f=s.selectedKeys.length,m=k.useMemo(()=>Vu(s.options,o),[s.options,o]);k.useEffect(()=>{d(0)},[o]),k.useEffect(()=>{d(g=>m.length===0?0:Math.min(g,m.length-1))},[m.length]),xs({containerRef:l,activeIndex:c,itemCount:m.length,isEnabled:m.length>0,getItemSelector:g=>`[data-skill-index="${g}"]`});const y=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(),d(I=>Math.min(I+1,m.length-1));return}if(g.key==="ArrowUp"){g.preventDefault(),d(I=>Math.max(I-1,0));return}if(g.key==="Enter"){g.preventDefault();const I=m[c];I&&y(I.key)}}};return h.jsxs(n,{children:[h.jsx(i,{asChild:!0,children:h.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:[h.jsx(Vn,{className:"h-4 w-4"}),h.jsx("span",{children:s.title}),f>0?h.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]})}),h.jsxs(r,{side:"top",align:"start",className:"w-[360px] p-0",children:[h.jsxs("div",{className:"space-y-2 border-b border-gray-100 px-4 py-3",children:[h.jsx("div",{className:"text-sm font-semibold text-gray-900",children:s.title}),h.jsxs("div",{className:"relative",children:[h.jsx(Hn,{className:"pointer-events-none absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400"}),h.jsx(t,{value:o,onChange:g=>u(g.target.value),onKeyDown:S,placeholder:s.searchPlaceholder,role:"combobox","aria-controls":a,"aria-expanded":"true","aria-autocomplete":"list","aria-activedescendant":m[c]?`${a}-option-${c}`:void 0,className:"h-8 rounded-lg pl-8 text-xs"})]})]}),h.jsx("div",{ref:l,id:a,role:"listbox","aria-multiselectable":"true",className:"custom-scrollbar max-h-[320px] overflow-y-auto",children:s.isLoading?h.jsx("div",{className:"p-4 text-xs text-gray-500",children:s.loadingLabel}):m.length===0?h.jsx("div",{className:"p-4 text-center text-xs text-gray-500",children:s.emptyLabel}):h.jsx("div",{className:"py-1",children:m.map((g,I)=>{const N=p.has(g.key),D=I===c;return h.jsxs("button",{type:"button",id:`${a}-option-${I}`,role:"option","aria-selected":N,"data-skill-index":I,onClick:()=>y(g.key),onMouseEnter:()=>d(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:[h.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-500",children:h.jsx(xa,{className:"h-4 w-4"})}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"truncate text-sm text-gray-900",children:g.label}),g.badgeLabel?h.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]}),h.jsx("div",{className:"mt-0.5 truncate text-xs text-gray-500",children:g.description||g.key})]}),h.jsx("div",{className:"ml-3 shrink-0",children:h.jsx("span",{className:N?"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:N?h.jsx(yt,{className:"h-3 w-3"}):null})})]},g.key)})})}),s.manageHref&&s.manageLabel?h.jsx("div",{className:"border-t border-gray-100 px-4 py-2.5",children:h.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,h.jsx(ya,{className:"h-3 w-3"})]})}):null]})]})}function Ns({icon:e}){return e==="sparkles"?h.jsx(Sa,{className:"h-3.5 w-3.5 shrink-0 text-primary"}):e==="brain"?h.jsx(ka,{className:"h-3.5 w-3.5 shrink-0 text-gray-500"}):null}function Uu({icon:e}){return e==="paperclip"?h.jsx(ba,{className:"h-4 w-4"}):h.jsx(Ns,{icon:e})}function $u(e){return e==="model"?"min-w-[220px]":e==="session-type"?"min-w-[140px]":e==="thinking"?"min-w-[150px]":""}function Ku(e){return e==="model"?"w-[320px]":e==="session-type"?"w-[220px]":e==="thinking"?"w-[180px]":""}function qu({item:e}){var d;const{Select:t,SelectContent:n,SelectGroup:r,SelectItem:i,SelectLabel:s,SelectSeparator:l,SelectTrigger:a,SelectValue:o}=bt,u=((d=e.groups)==null?void 0:d.filter(p=>p.options.length>0))??(e.options.length>0?[{key:`${e.key}-default`,options:e.options}]:[]),c=u.some(p=>p.options.length>0);return h.jsxs(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[h.jsx(a,{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 ${$u(e.key)}`,children:e.selectedLabel?h.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-left",children:[h.jsx(Ns,{icon:e.icon}),h.jsx("span",{className:"truncate text-xs font-semibold text-gray-700",children:e.selectedLabel})]}):e.loading?h.jsx("div",{className:"h-3 w-24 animate-pulse rounded bg-gray-200"}):h.jsx(o,{placeholder:e.placeholder})}),h.jsxs(n,{className:Ku(e.key),children:[c?null:e.loading?h.jsxs("div",{className:"space-y-2 px-3 py-2",children:[h.jsx("div",{className:"h-3 w-36 animate-pulse rounded bg-gray-200"}),h.jsx("div",{className:"h-3 w-28 animate-pulse rounded bg-gray-200"}),h.jsx("div",{className:"h-3 w-32 animate-pulse rounded bg-gray-200"})]}):e.emptyLabel?h.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:e.emptyLabel}):null,u.map((p,f)=>h.jsxs("div",{children:[f>0?h.jsx(l,{}):null,h.jsxs(r,{children:[p.label?h.jsx(s,{children:p.label}):null,p.options.map(m=>h.jsx(i,{value:m.value,className:"py-2",children:m.description?h.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[h.jsx("span",{className:"truncate text-xs font-semibold text-gray-800",children:m.label}),h.jsx("span",{className:"truncate text-[11px] text-gray-500",children:m.description})]}):h.jsx("span",{className:"truncate text-xs font-semibold text-gray-800",children:m.label})},m.value))]})]},p.key))]})]})}function Wu(e){var s;const{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=bt;return h.jsxs("div",{className:"flex items-center justify-between px-3 pb-3",children:[h.jsxs("div",{className:"flex items-center gap-1",children:[e.skillPicker?h.jsx(Hu,{picker:e.skillPicker}):null,e.selects.map(l=>h.jsx(qu,{item:l},l.key)),(s=e.accessories)==null?void 0:s.map(l=>{const a=h.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 ${l.iconOnly?"h-8 w-8 justify-center px-0":"gap-1.5 px-3"}`,onClick:l.onClick,disabled:l.disabled,"aria-label":l.label,children:[h.jsx(Uu,{icon:l.icon}),l.iconOnly?null:h.jsx("span",{children:l.label})]});if(!l.tooltip)return h.jsx("div",{children:a},l.key);const o=l.disabled?h.jsx("span",{className:"inline-flex",children:a}):a;return h.jsx(r,{children:h.jsxs(t,{children:[h.jsx(i,{asChild:!0,children:o}),h.jsx(n,{side:"top",children:h.jsx("p",{className:"text-xs",children:l.tooltip})})]})},l.key)})]}),h.jsx(Bu,{...e.actions})]})}const Qu="";function Es(){return`composer-${Math.random().toString(36).slice(2,10)}`}function ft(e=""){return{id:Es(),type:"text",text:e}}function Qn(e){return{id:Es(),type:"token",tokenKind:e.tokenKind,tokenKey:e.tokenKey,label:e.label}}function St(e){return e.type==="text"?e.text.length:1}function Gn(){return[ft("")]}function Gu(e){return[ft(e)]}function Ge(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?Gn():t}function Xu(e){return e.map(t=>t.type==="text"?t.text:Qu).join("")}function Yu(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Vt(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 Ju(e,t,n,r){const i=Math.max(0,n-t),s=Math.max(0,t+e.text.length-r),l=[];return i>0&&l.push({...e,text:e.text.slice(0,i)}),s>0&&l.push({...e,text:e.text.slice(e.text.length-s)}),l}function Zu(e,t,n,r){return t<=n||e>=r}function ec(e,t,n,r,i){return!n&&r>=i?(e.push(...t),!0):n}function tc(e,t,n,r,i,s,l){const a=Ju(t,n,r,i);a[0]&&e.push(a[0]);let o=l;return o||(e.push(...s),o=!0),a[1]&&e.push(a[1]),o}function nc(e,t,n,r,i,s){return!r&&i<=s?(e.push(...n),!0):(e.push(t),r)}function en(e,t,n,r){const i=Math.max(0,t),s=Math.max(i,n),l=[];let a=0,o=!1;for(const u of e){const c=St(u),d=a,p=a+c;if(Zu(d,p,i,s)){o=ec(l,r,o,d,s),l.push(u),a=p;continue}u.type==="text"?o=tc(l,u,d,i,s,r,o):o=nc(l,u,r,o,i,d),a=p}return o||l.push(...r),Ge(l)}function Xn(e,t){return Ge(e.filter(n=>n.type!=="token"||!t(n)))}function rc(e,t){if(!t||t.start!==t.end)return null;const n=Xu(e),r=t.end,i=n.slice(0,r),s=/(?:^|\s)\/([^\s\uFFFC]*)$/.exec(i);if(!s)return null;const l=r-s[0].length+(s[0].startsWith("/")?0:1);return{query:(s[1]??"").trim().toLowerCase(),start:l,end:r}}function ic(e,t,n){return e?e.start<n&&e.end>t:!1}function Ls(e){const t=new Map;let n=0;for(const r of e)t.set(r.id,n),n+=St(r);return t}function As(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 sc(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 Rs(e,t,n){let r=0;for(let i=0;i<n;i+=1){const s=sc(e.childNodes[i],i,t);s&&(r+=St(s))}return r}function lc(e,t,n,r){var a;const i=As(e,t),s=Rs(e,r,i),l=r[i];return(l==null?void 0:l.type)==="text"?s+Math.min(n,l.text.length):s+Math.min(n,((a=t.textContent)==null?void 0:a.length)??0)}function ac(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 In(e,t,n,r,i){var u;if(t===e)return Rs(e,r,n);if(t.nodeType===Node.TEXT_NODE&&t.parentNode===e)return lc(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 c=As(e,t);return In(e,e,c,r,i)}const l=s.dataset.composerNodeId;if(!l)return 0;const a=r.find(c=>c.id===l),o=i.get(l)??0;return a?ac(t,n,a,o,s):o}function js(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=Ls(t),s=In(e,r.startContainer,r.startOffset,t,i),l=In(e,r.endContainer,r.endOffset,t,i);return{start:Math.min(s,l),end:Math.max(s,l)}}function oc(e,t,n){if(!n)return;const r=window.getSelection();if(!r)return;const i=o=>{let u=0;for(let c=0;c<t.length;c+=1){const d=t[c],p=St(d),f=u,m=u+p,y=e.childNodes[c];if(!y){u=m;continue}if(d.type==="text"){if(o<=m)return{container:y.firstChild??y,offset:Math.max(0,Math.min(o-f,d.text.length))}}else{if(o<=f)return{container:e,offset:c};if(o<=m)return{container:e,offset:c+1}}u=m}return{container:e,offset:e.childNodes.length}},s=i(n.start),l=i(n.end),a=document.createRange();a.setStart(s.container,s.offset),a.setEnd(l.container,l.offset),r.removeAllRanges(),r.addRange(a)}function uc(e){const t=[];for(const n of Array.from(e.childNodes)){if(n.nodeType===Node.TEXT_NODE){t.push(ft(n.textContent??""));continue}if(!(n instanceof HTMLElement))continue;if(n.dataset.composerNodeType==="token"){const s=n.dataset.composerTokenKind,l=n.dataset.composerTokenKey,a=n.dataset.composerLabel;s&&l&&a&&t.push({id:n.dataset.composerNodeId??Qn({tokenKind:s,tokenKey:l,label:a}).id,type:"token",tokenKind:s,tokenKey:l,label:a});continue}const i=n.textContent??"";t.push({id:n.dataset.composerNodeId??ft(i).id,type:"text",text:i})}return Ge(t)}function Dr(e){const t=uc(e);return{nodes:t,selection:js(e,t)}}class cc{constructor(){this.nodes=Gn(),this.selection=null,this.sync=(t,n)=>(this.nodes=Ge(t),this.selection=n,this.getSnapshot()),this.setSelection=t=>(this.selection=t,this.getSnapshot()),this.replaceDocument=(t,n)=>(this.nodes=Ge(t),this.selection=n,this.getSnapshot()),this.insertText=t=>{const n=this.selection??{start:0,end:0};this.nodes=en(this.nodes,n.start,n.end,[ft(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(a=>[a.key,a])),s=t.find(a=>!r.includes(a));if(s){const a=i.get(s);return this.insertSkillToken(s,(a==null?void 0:a.label)??s)}const l=r.find(a=>!t.includes(a));return l&&(this.nodes=Xn(this.nodes,a=>a.tokenKind==="skill"&&a.tokenKey===l)),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=en(this.nodes,i,s,[]),this.selection={start:i,end:i},this.getSnapshot()},this.getSnapshot=()=>({nodes:this.nodes,selection:this.selection,nodeStartMap:Ls(this.nodes),documentLength:this.getDocumentLength(),selectedSkillKeys:this.getSelectedSkillKeys(),slashTrigger:this.getSlashTrigger()}),this.getDocumentLength=()=>this.nodes.reduce((t,n)=>t+St(n),0),this.getSelectedSkillKeys=()=>Vt(this.nodes,"skill"),this.insertToken=(t,n,r,i=null)=>{var o,u;const s=this.getDocumentLength(),l=(i==null?void 0:i.start)??((o=this.selection)==null?void 0:o.start)??s,a=(i==null?void 0:i.end)??((u=this.selection)==null?void 0:u.end)??l;return this.nodes=en(this.nodes,l,a,[Qn({tokenKind:t,tokenKey:n,label:r})]),this.selection={start:l+1,end:l+1},this.getSnapshot()},this.getSlashTrigger=()=>rc(this.nodes,this.selection)}}function dc(e){const{key:t,shiftKey:n,isComposing:r,isSlashMenuOpen:i,slashItemCount:s,activeSlashIndex:l,isSending:a,canStopGeneration:o}=e;if(i&&s>0){if(t==="ArrowDown")return{type:"move-slash-index",index:(l+1)%s};if(t==="ArrowUp")return{type:"move-slash-index",index:(l-1+s)%s};if(t==="Enter"&&!n||t==="Tab")return{type:"insert-active-slash-item"}}return t==="Escape"?i?{type:"close-slash"}:a&&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 Fr="http://www.w3.org/2000/svg";class hc{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=ic(n,i,i+1),l=document.createElement("span");l.contentEditable="false",l.dataset.composerNodeId=t.id,l.dataset.composerNodeType="token",l.dataset.composerTokenKind=t.tokenKind,l.dataset.composerTokenKey=t.tokenKey,l.dataset.composerLabel=t.label,l.title=t.label,l.className=this.buildTokenClassName(t.tokenKind,s),l.append(this.createTokenIcon(t.tokenKind));const a=document.createElement("span");return a.className=t.tokenKind==="file"?"min-w-0 flex-1 truncate text-[12px] font-medium text-slate-700":"truncate",a.textContent=t.label,l.append(a),l},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(Fr,"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(Fr,r.tag);for(const[s,l]of Object.entries(r.attrs))i.setAttribute(s,l);n.append(i)}return n}}}const Or=188;class fc{constructor(t){this.controller=t,this.surfaceRenderer=new hc,this.sync=(n,r)=>this.controller.sync(n,r),this.syncSelectionFromRoot=n=>this.controller.setSelection(js(n,this.controller.getSnapshot().nodes)),this.restoreSelectionIfFocused=(n,r)=>{!n||document.activeElement!==n||oc(n,this.controller.getSnapshot().nodes,r)},this.syncViewport=n=>{n&&(n.style.maxHeight=`${Or}px`,n.style.overflowY=n.scrollHeight>Or?"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:l}=n,a=r.nativeEvent;i||s||a.isComposing||!(a.inputType==="insertText"||a.inputType==="insertReplacementText")||!a.data||(r.preventDefault(),l(this.controller.insertText(a.data)))},this.handleInput=n=>{const{event:r,isComposing:i,commitSnapshot:s}=n,l=r.nativeEvent;if(i||l.isComposing)return;const a=r.currentTarget,o=Dr(a);s(this.controller.replaceDocument(o.nodes,o.selection))},this.handleCompositionEnd=n=>{const{event:r,commitSnapshot:i}=n,s=r.currentTarget,l=Dr(s);i(this.controller.replaceDocument(l.nodes,l.selection))},this.handleKeyDown=n=>{const{event:r,slashItems:i,activeSlashIndex:s,activeSlashItem:l,actions:a,commitSnapshot:o,insertSkillToken:u,onSlashActiveIndexChange:c,onSlashQueryChange:d,onSlashOpenChange:p}=n,f=this.controller.getSnapshot(),m=dc({key:r.key,shiftKey:r.shiftKey,isComposing:r.nativeEvent.isComposing,isSlashMenuOpen:f.slashTrigger!==null,slashItemCount:i.length,activeSlashIndex:s,isSending:a.isSending,canStopGeneration:a.canStopGeneration});if(m.type!=="noop"){if(r.preventDefault(),m.type==="move-slash-index"){c(m.index);return}if(m.type==="insert-active-slash-item"){l&&u(l.value??l.key,l.title);return}if(m.type==="close-slash"){d==null||d(null),p(!1);return}if(m.type==="stop-generation"){a.onStop();return}if(m.type==="insert-line-break"){o(this.controller.insertText(`
|
|
3
|
+
`));return}if(m.type==="send-message"){a.onSend();return}m.type==="delete-content"&&o(this.controller.deleteContent(m.direction))}},this.handlePaste=n=>{const{event:r,onFilesAdd:i,commitSnapshot:s}=n,l=Array.from(r.clipboardData.files??[]);if(l.length>0&&i){r.preventDefault(),i(l);return}const a=r.clipboardData.getData("text/plain");a&&(r.preventDefault(),s(this.controller.insertText(a)))},this.handleBlur=n=>{const{clearSelectedRange:r,onSlashQueryChange:i,onSlashOpenChange:s}=n;r(),i==null||i(null),s(!1)}}}class pc{constructor(){this.controller=new cc,this.viewController=new fc(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 mc=k.forwardRef(function(t,n){const{nodes:r,placeholder:i,disabled:s,slashItems:l,actions:a,onNodesChange:o,onFilesAdd:u,onSlashQueryChange:c,onSlashTriggerChange:d,onSlashOpenChange:p,onSlashActiveIndexChange:f,activeSlashIndex:m}=t,[y,S]=k.useState(0),[g]=k.useState(()=>new pc),{snapshot:I,bindRootElement:N,handleBeforeInput:D,handleInput:F,handleCompositionStart:v,handleCompositionEnd:O,handleKeyDown:_,handlePaste:B,handleBlur:w,syncSelectionState:j,imperativeHandle:L}=g.update({nodes:r,disabled:s,slashItems:l,actions:a,onNodesChange:o,onFilesAdd:u,onSlashQueryChange:c,onSlashTriggerChange:d,onSlashOpenChange:p,onSlashActiveIndexChange:f,activeSlashIndex:m,requestRender:()=>S(H=>H+1)});return k.useImperativeHandle(n,()=>L,[L]),k.useLayoutEffect(()=>{g.renderSurface(),g.restoreDomAfterCommit(),g.syncViewport()},[g,I.nodes,I.nodeStartMap,y]),h.jsx("div",{className:"px-4 py-2.5",children:h.jsx("div",{className:"min-h-[60px]",children:h.jsx("div",{ref:N,contentEditable:!s,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":"true","data-placeholder":i,onBeforeInput:D,onInput:F,onCompositionStart:v,onCompositionEnd:O,onKeyDown:_,onKeyUp:j,onMouseUp:j,onFocus:j,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 gc({hint:e}){if(!e)return null;if(e.loading)return h.jsx("div",{className:"px-4 pb-2",children:h.jsxs("div",{className:"inline-flex items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2",children:[h.jsx("span",{className:"h-3 w-28 animate-pulse rounded bg-gray-200"}),h.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 h.jsx("div",{className:"px-4 pb-2",children:h.jsxs("div",{className:`inline-flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs ${t}`,children:[e.text?h.jsx("span",{children:e.text}):null,e.actionLabel&&e.onAction?h.jsx("button",{type:"button",onClick:e.onAction,className:"font-semibold underline-offset-2 hover:underline",children:e.actionLabel}):null]})})}const Ps=k.forwardRef(function(t,n){const r=k.useRef(null),[i,s]=k.useState(null),[l,a]=k.useState(0),[o,u]=k.useState(null),[c,d]=k.useState(null),p=o!==null&&c!==o,f=t.slashMenu.items[l]??null;k.useEffect(()=>{a(y=>t.slashMenu.items.length===0?0:Math.min(y,t.slashMenu.items.length-1))},[t.slashMenu.items.length]),k.useEffect(()=>{i!==null&&a(0)},[i]),k.useEffect(()=>{o===null&&c!==null&&d(null)},[o,c]);const m=k.useMemo(()=>t.toolbar.skillPicker?{...t.toolbar,skillPicker:{...t.toolbar.skillPicker,onSelectedKeysChange:y=>{var S,g;(g=r.current)==null||g.syncSelectedSkills(y,((S=t.toolbar.skillPicker)==null?void 0:S.options)??[])}}}:t.toolbar,[t.toolbar]);return k.useImperativeHandle(n,()=>({insertFileToken:(y,S)=>{var g;return(g=r.current)==null?void 0:g.insertFileToken(y,S)},insertFileTokens:y=>{var S;return(S=r.current)==null?void 0:S.insertFileTokens(y)},focusComposer:()=>{var y;return(y=r.current)==null?void 0:y.focusComposer()}}),[]),h.jsx("div",{className:"border-t border-gray-200/80 bg-white p-4",children:h.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)]",children:h.jsxs("div",{className:"overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-card",children:[h.jsxs("div",{className:"relative",children:[h.jsx(mc,{ref:r,nodes:t.composer.nodes,placeholder:t.composer.placeholder,disabled:t.composer.disabled,slashItems:t.slashMenu.items,actions:t.toolbar.actions,activeSlashIndex:l,onNodesChange:t.composer.onNodesChange,onFilesAdd:t.composer.onFilesAdd,onSlashQueryChange:y=>{var S,g;s(y),(g=(S=t.composer).onSlashQueryChange)==null||g.call(S,y)},onSlashTriggerChange:y=>{u((y==null?void 0:y.start)??null)},onSlashOpenChange:y=>{!y&&o!==null&&d(o)},onSlashActiveIndexChange:a}),h.jsx(zu,{isOpen:p,isLoading:t.slashMenu.isLoading,items:t.slashMenu.items,activeIndex:l,activeItem:f,texts:t.slashMenu.texts,onSelectItem:y=>{var S;d(null),(S=r.current)==null||S.insertSlashItem(y)},onOpenChange:y=>{!y&&o!==null&&d(o)},onSetActiveIndex:a})]}),h.jsx(gc,{hint:t.hint}),h.jsx(Wu,{...m})]})})})});Ps.displayName="ChatInputBar";function tn({role:e}){return e==="user"?h.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:h.jsx(wa,{className:"h-4 w-4"})}):e==="tool"?h.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:h.jsx(Ca,{className:"h-4 w-4"})}):h.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:h.jsx(Zi,{className:"h-4 w-4"})})}function xc(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const yc=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,bc=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Sc={};function zr(e,t){return(Sc.jsx?bc:yc).test(e)}const kc=/[ \t\n\f\r]/g;function wc(e){return typeof e=="object"?e.type==="text"?_r(e.value):!1:_r(e)}function _r(e){return e.replace(kc,"")===""}class kt{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}kt.prototype.normal={};kt.prototype.property={};kt.prototype.space=void 0;function Ds(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new kt(n,r,t)}function Mn(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 Cc=0;const K=Ue(),ie=Ue(),Nn=Ue(),E=Ue(),ee=Ue(),Qe=Ue(),ge=Ue();function Ue(){return 2**++Cc}const En=Object.freeze(Object.defineProperty({__proto__:null,boolean:K,booleanish:ie,commaOrSpaceSeparated:ge,commaSeparated:Qe,number:E,overloadedBoolean:Nn,spaceSeparated:ee},Symbol.toStringTag,{value:"Module"})),nn=Object.keys(En);class Yn extends pe{constructor(t,n,r,i){let s=-1;if(super(t,n),Br(this,"space",i),typeof r=="number")for(;++s<nn.length;){const l=nn[s];Br(this,nn[s],(r&En[l])===En[l])}}}Yn.prototype.defined=!0;function Br(e,t,n){n&&(e[t]=n)}function Ye(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Yn(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Mn(r)]=r,n[Mn(s.attribute)]=r}return new kt(t,n,e.space)}const Fs=Ye({properties:{ariaActiveDescendant:null,ariaAtomic:ie,ariaAutoComplete:null,ariaBusy:ie,ariaChecked:ie,ariaColCount:E,ariaColIndex:E,ariaColSpan:E,ariaControls:ee,ariaCurrent:null,ariaDescribedBy:ee,ariaDetails:null,ariaDisabled:ie,ariaDropEffect:ee,ariaErrorMessage:null,ariaExpanded:ie,ariaFlowTo:ee,ariaGrabbed:ie,ariaHasPopup:null,ariaHidden:ie,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ee,ariaLevel:E,ariaLive:null,ariaModal:ie,ariaMultiLine:ie,ariaMultiSelectable:ie,ariaOrientation:null,ariaOwns:ee,ariaPlaceholder:null,ariaPosInSet:E,ariaPressed:ie,ariaReadOnly:ie,ariaRelevant:null,ariaRequired:ie,ariaRoleDescription:ee,ariaRowCount:E,ariaRowIndex:E,ariaRowSpan:E,ariaSelected:ie,ariaSetSize:E,ariaSort:null,ariaValueMax:E,ariaValueMin:E,ariaValueNow:E,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Os(e,t){return t in e?e[t]:t}function zs(e,t){return Os(e,t.toLowerCase())}const vc=Ye({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Qe,acceptCharset:ee,accessKey:ee,action:null,allow:null,allowFullScreen:K,allowPaymentRequest:K,allowUserMedia:K,alt:null,as:null,async:K,autoCapitalize:null,autoComplete:ee,autoFocus:K,autoPlay:K,blocking:ee,capture:null,charSet:null,checked:K,cite:null,className:ee,cols:E,colSpan:null,content:null,contentEditable:ie,controls:K,controlsList:ee,coords:E|Qe,crossOrigin:null,data:null,dateTime:null,decoding:null,default:K,defer:K,dir:null,dirName:null,disabled:K,download:Nn,draggable:ie,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:K,formTarget:null,headers:ee,height:E,hidden:Nn,high:E,href:null,hrefLang:null,htmlFor:ee,httpEquiv:ee,id:null,imageSizes:null,imageSrcSet:null,inert:K,inputMode:null,integrity:null,is:null,isMap:K,itemId:null,itemProp:ee,itemRef:ee,itemScope:K,itemType:ee,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:K,low:E,manifest:null,max:null,maxLength:E,media:null,method:null,min:null,minLength:E,multiple:K,muted:K,name:null,nonce:null,noModule:K,noValidate:K,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:K,optimum:E,pattern:null,ping:ee,placeholder:null,playsInline:K,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:K,referrerPolicy:null,rel:ee,required:K,reversed:K,rows:E,rowSpan:E,sandbox:ee,scope:null,scoped:K,seamless:K,selected:K,shadowRootClonable:K,shadowRootDelegatesFocus:K,shadowRootMode:null,shape:null,size:E,sizes:null,slot:null,span:E,spellCheck:ie,src:null,srcDoc:null,srcLang:null,srcSet:null,start:E,step:null,style:null,tabIndex:E,target:null,title:null,translate:null,type:null,typeMustMatch:K,useMap:null,value:ie,width:E,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ee,axis:null,background:null,bgColor:null,border:E,borderColor:null,bottomMargin:E,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:K,declare:K,event:null,face:null,frame:null,frameBorder:null,hSpace:E,leftMargin:E,link:null,longDesc:null,lowSrc:null,marginHeight:E,marginWidth:E,noResize:K,noHref:K,noShade:K,noWrap:K,object:null,profile:null,prompt:null,rev:null,rightMargin:E,rules:null,scheme:null,scrolling:ie,standby:null,summary:null,text:null,topMargin:E,valueType:null,version:null,vAlign:null,vLink:null,vSpace:E,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:K,disableRemotePlayback:K,prefix:null,property:null,results:E,security:null,unselectable:null},space:"html",transform:zs}),Tc=Ye({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ge,accentHeight:E,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:E,amplitude:E,arabicForm:null,ascent:E,attributeName:null,attributeType:null,azimuth:E,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:E,by:null,calcMode:null,capHeight:E,className:ee,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:E,diffuseConstant:E,direction:null,display:null,dur:null,divisor:E,dominantBaseline:null,download:K,dx:null,dy:null,edgeMode:null,editable:null,elevation:E,enableBackground:null,end:null,event:null,exponent:E,externalResourcesRequired:null,fill:null,fillOpacity:E,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Qe,g2:Qe,glyphName:Qe,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:E,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:E,horizOriginX:E,horizOriginY:E,id:null,ideographic:E,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:E,k:E,k1:E,k2:E,k3:E,k4:E,kernelMatrix:ge,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:E,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:E,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:E,overlineThickness:E,paintOrder:null,panose1:null,path:null,pathLength:E,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ee,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:E,pointsAtY:E,pointsAtZ:E,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ge,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ge,rev:ge,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ge,requiredFeatures:ge,requiredFonts:ge,requiredFormats:ge,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:E,specularExponent:E,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:E,strikethroughThickness:E,string:null,stroke:null,strokeDashArray:ge,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:E,strokeOpacity:E,strokeWidth:null,style:null,surfaceScale:E,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ge,tabIndex:E,tableValues:null,target:null,targetX:E,targetY:E,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ge,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:E,underlineThickness:E,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:E,values:null,vAlphabetic:E,vMathematical:E,vectorEffect:null,vHanging:E,vIdeographic:E,version:null,vertAdvY:E,vertOriginX:E,vertOriginY:E,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:E,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Os}),_s=Ye({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()}}),Bs=Ye({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:zs}),Vs=Ye({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Ic={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,Vr=/-[a-z]/g,Nc=/^data[-\w.:]+$/i;function Ec(e,t){const n=Mn(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"&&Nc.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Vr,Ac);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Vr.test(s)){let l=s.replace(Mc,Lc);l.charAt(0)!=="-"&&(l="-"+l),t="data"+l}}i=Yn}return new i(r,t)}function Lc(e){return"-"+e.toLowerCase()}function Ac(e){return e.charAt(1).toUpperCase()}const Rc=Ds([Fs,vc,_s,Bs,Vs],"html"),Jn=Ds([Fs,Tc,_s,Bs,Vs],"svg");function jc(e){return e.join(" ").trim()}var Ke={},rn,Hr;function Pc(){if(Hr)return rn;Hr=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,l=/^[;\s]*/,a=/^\s+|\s+$/g,o=`
|
|
4
|
+
`,u="/",c="*",d="",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,N=1;function D(A){var C=A.match(t);C&&(I+=C.length);var P=A.lastIndexOf(o);N=~P?A.length-P:N+A.length}function F(){var A={line:I,column:N};return function(C){return C.position=new v(A),B(),C}}function v(A){this.start=A,this.end={line:I,column:N},this.source=g.source}v.prototype.content=S;function O(A){var C=new Error(g.source+":"+I+":"+N+": "+A);if(C.reason=A,C.filename=g.source,C.line=I,C.column=N,C.source=S,!g.silent)throw C}function _(A){var C=A.exec(S);if(C){var P=C[0];return D(P),S=S.slice(P.length),C}}function B(){_(n)}function w(A){var C;for(A=A||[];C=j();)C!==!1&&A.push(C);return A}function j(){var A=F();if(!(u!=S.charAt(0)||c!=S.charAt(1))){for(var C=2;d!=S.charAt(C)&&(c!=S.charAt(C)||u!=S.charAt(C+1));)++C;if(C+=2,d===S.charAt(C-1))return O("End of comment missing");var P=S.slice(2,C-2);return N+=2,D(P),S=S.slice(C),N+=2,A({type:p,comment:P})}}function L(){var A=F(),C=_(r);if(C){if(j(),!_(i))return O("property missing ':'");var P=_(s),Q=A({type:f,property:y(C[0].replace(e,d)),value:P?y(P[0].replace(e,d)):d});return _(l),Q}}function H(){var A=[];w(A);for(var C;C=L();)C!==!1&&(A.push(C),w(A));return A}return B(),H()}function y(S){return S?S.replace(a,d):d}return rn=m,rn}var Ur;function Dc(){if(Ur)return Ke;Ur=1;var e=Ke&&Ke.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.default=n;const t=e(Pc());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const l=(0,t.default)(r),a=typeof i=="function";return l.forEach(o=>{if(o.type!=="declaration")return;const{property:u,value:c}=o;a?i(u,c,o):c&&(s=s||{},s[u]=c)}),s}return Ke}var rt={},$r;function Fc(){if($r)return rt;$r=1,Object.defineProperty(rt,"__esModule",{value:!0}),rt.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)},l=function(u,c){return c.toUpperCase()},a=function(u,c){return"".concat(c,"-")},o=function(u,c){return c===void 0&&(c={}),s(u)?u:(u=u.toLowerCase(),c.reactCompat?u=u.replace(i,a):u=u.replace(r,a),u.replace(t,l))};return rt.camelCase=o,rt}var it,Kr;function Oc(){if(Kr)return it;Kr=1;var e=it&&it.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Dc()),n=Fc();function r(i,s){var l={};return!i||typeof i!="string"||(0,t.default)(i,function(a,o){a&&o&&(l[(0,n.camelCase)(a,s)]=o)}),l}return r.default=r,it=r,it}var zc=Oc();const _c=es(zc),Hs=Us("end"),Zn=Us("start");function Us(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 Bc(e){const t=Zn(e),n=Hs(e);if(t&&n)return{start:t,end:n}}function ct(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?qr(e.position):"start"in e||"end"in e?qr(e):"line"in e||"column"in e?Ln(e):""}function Ln(e){return Wr(e&&e.line)+":"+Wr(e&&e.column)}function qr(e){return Ln(e&&e.start)+"-"+Ln(e&&e.end)}function Wr(e){return e&&typeof e=="number"?e:1}class ue extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},l=!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&&(l=!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 a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=ct(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=l&&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}}ue.prototype.file="";ue.prototype.name="";ue.prototype.reason="";ue.prototype.message="";ue.prototype.stack="";ue.prototype.column=void 0;ue.prototype.line=void 0;ue.prototype.ancestors=void 0;ue.prototype.cause=void 0;ue.prototype.fatal=void 0;ue.prototype.place=void 0;ue.prototype.ruleId=void 0;ue.prototype.source=void 0;const er={}.hasOwnProperty,Vc=new Map,Hc=/[A-Z]/g,Uc=new Set(["table","tbody","thead","tfoot","tr"]),$c=new Set(["td","th"]),$s="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Kc(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=Zc(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=Jc(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"?Jn:Rc,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=Ks(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function Ks(e,t,n){if(t.type==="element")return qc(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Wc(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Gc(e,t,n);if(t.type==="mdxjsEsm")return Qc(e,t);if(t.type==="root")return Xc(e,t,n);if(t.type==="text")return Yc(e,t)}function qc(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Jn,e.schema=i),e.ancestors.push(t);const s=Ws(e,t.tagName,!1),l=ed(e,t);let a=nr(e,t);return Uc.has(t.tagName)&&(a=a.filter(function(o){return typeof o=="string"?!wc(o):!0})),qs(e,l,s,t),tr(l,a),e.ancestors.pop(),e.schema=r,e.create(t,s,l,n)}function Wc(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)}pt(e,t.position)}function Qc(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);pt(e,t.position)}function Gc(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Jn,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:Ws(e,t.name,!0),l=td(e,t),a=nr(e,t);return qs(e,l,s,t),tr(l,a),e.ancestors.pop(),e.schema=r,e.create(t,s,l,n)}function Xc(e,t,n){const r={};return tr(r,nr(e,t)),e.create(t,e.Fragment,r,n)}function Yc(e,t){return t.value}function qs(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function tr(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Jc(e,t,n){return r;function r(i,s,l,a){const u=Array.isArray(l.children)?n:t;return a?u(s,l,a):u(s,l)}}function Zc(e,t){return n;function n(r,i,s,l){const a=Array.isArray(s.children),o=Zn(r);return t(i,s,l,a,{columnNumber:o?o.column-1:void 0,fileName:e,lineNumber:o?o.line:void 0},void 0)}}function ed(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&er.call(t.properties,i)){const s=nd(e,i,t.properties[i]);if(s){const[l,a]=s;e.tableCellAlignToStyle&&l==="align"&&typeof a=="string"&&$c.has(t.tagName)?r=a:n[l]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function td(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 l=s.expression;l.type;const a=l.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else pt(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else pt(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function nr(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Vc;for(;++r<t.children.length;){const s=t.children[r];let l;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;l=o+"-"+u,i.set(o,u+1)}}const a=Ks(e,s,l);a!==void 0&&n.push(a)}return n}function nd(e,t,n){const r=Ec(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?xc(n):jc(n)),r.property==="style"){let i=typeof n=="object"?n:rd(e,String(n));return e.stylePropertyNameCase==="css"&&(i=id(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Ic[r.property]||r.property:r.attribute,n]}}function rd(e,t){try{return _c(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new ue("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=$s+"#cannot-parse-style-attribute",i}}function Ws(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,l;for(;++s<i.length;){const a=zr(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};l=l?{type:"MemberExpression",object:l,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=l}else r=zr(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return er.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);pt(e)}function pt(e,t){const n=new ue("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=$s+"#cannot-handle-mdx-estrees-without-createevaluater",n}function id(e){const t={};let n;for(n in e)er.call(e,n)&&(t[sd(n)]=e[n]);return t}function sd(e){let t=e.replace(Hc,ld);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function ld(e){return"-"+e.toLowerCase()}const sn={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"]},ad={};function rr(e,t){const n=ad,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Qs(e,r,i)}function Qs(e,t,n){if(od(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]=Qs(e[i],t,n);return r.join("")}function od(e){return!!(e&&typeof e=="object")}const Gr=document.createElement("i");function ir(e){const t="&"+e+";";Gr.innerHTML=t;const n=Gr.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,l;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)l=Array.from(r),l.unshift(t,n),e.splice(...l);else for(n&&e.splice(t,n);s<r.length;)l=r.slice(s,s+1e4),l.unshift(t,0),e.splice(...l),s+=1e4,t+=1e4}function Se(e,t){return e.length>0?(xe(e,e.length,0,t),e):t}const Xr={}.hasOwnProperty;function Gs(e){const t={};let n=-1;for(;++n<e.length;)ud(t,e[n]);return t}function ud(e,t){let n;for(n in t){const i=(Xr.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let l;if(s)for(l in s){Xr.call(i,l)||(i[l]=[]);const a=s[l];cd(i[l],Array.isArray(a)?a:a?[a]:[])}}}function cd(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 Xs(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 ce=_e(/[A-Za-z]/),oe=_e(/[\dA-Za-z]/),dd=_e(/[#-'*+\--9=?A-Z^-~]/);function Dt(e){return e!==null&&(e<32||e===127)}const An=_e(/\d/),hd=_e(/[\dA-Fa-f]/),fd=_e(/[!-/:-@[-`{-~]/);function z(e){return e!==null&&e<-2}function Z(e){return e!==null&&(e<0||e===32)}function W(e){return e===-2||e===-1||e===32}const Ht=_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 Je(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let l="";if(s===37&&oe(e.charCodeAt(n+1))&&oe(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(l=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(l=String.fromCharCode(s,a),i=1):l="�"}else l=String.fromCharCode(s);l&&(t.push(e.slice(r,n),encodeURIComponent(l)),r=n+i+1,l=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function X(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return l;function l(o){return W(o)?(e.enter(n),a(o)):t(o)}function a(o){return W(o)&&s++<i?(e.consume(o),a):(e.exit(n),t(o))}}const pd={tokenize:md};function md(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),X(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const o=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=o),n=o,l(a)}function l(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return z(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),l)}}const gd={tokenize:xd},Yr={tokenize:yd};function xd(e){const t=this,n=[];let r=0,i,s,l;return a;function a(N){if(r<n.length){const D=n[r];return t.containerState=D[1],e.attempt(D[0].continuation,o,u)(N)}return u(N)}function o(N){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&I();const D=t.events.length;let F=D,v;for(;F--;)if(t.events[F][0]==="exit"&&t.events[F][1].type==="chunkFlow"){v=t.events[F][1].end;break}g(r);let O=D;for(;O<t.events.length;)t.events[O][1].end={...v},O++;return xe(t.events,F+1,0,t.events.slice(D)),t.events.length=O,u(N)}return a(N)}function u(N){if(r===n.length){if(!i)return p(N);if(i.currentConstruct&&i.currentConstruct.concrete)return m(N);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Yr,c,d)(N)}function c(N){return i&&I(),g(r),p(N)}function d(N){return t.parser.lazy[t.now().line]=r!==n.length,l=t.now().offset,m(N)}function p(N){return t.containerState={},e.attempt(Yr,f,m)(N)}function f(N){return r++,n.push([t.currentConstruct,t.containerState]),p(N)}function m(N){if(N===null){i&&I(),g(0),e.consume(N);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),y(N)}function y(N){if(N===null){S(e.exit("chunkFlow"),!0),g(0),e.consume(N);return}return z(N)?(e.consume(N),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(N),y)}function S(N,D){const F=t.sliceStream(N);if(D&&F.push(null),N.previous=s,s&&(s.next=N),s=N,i.defineSkip(N.start),i.write(F),t.parser.lazy[N.start.line]){let v=i.events.length;for(;v--;)if(i.events[v][1].start.offset<l&&(!i.events[v][1].end||i.events[v][1].end.offset>l))return;const O=t.events.length;let _=O,B,w;for(;_--;)if(t.events[_][0]==="exit"&&t.events[_][1].type==="chunkFlow"){if(B){w=t.events[_][1].end;break}B=!0}for(g(r),v=O;v<t.events.length;)t.events[v][1].end={...w},v++;xe(t.events,_+1,0,t.events.slice(O)),t.events.length=v}}function g(N){let D=n.length;for(;D-- >N;){const F=n[D];t.containerState=F[1],F[0].exit.call(t,e)}n.length=N}function I(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function yd(e,t,n){return X(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Xe(e){if(e===null||Z(e)||He(e))return 1;if(Ht(e))return 2}function Ut(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 Rn={name:"attention",resolveAll:bd,tokenize:Sd};function bd(e,t){let n=-1,r,i,s,l,a,o,u,c;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 d={...e[r][1].end},p={...e[n][1].start};Jr(d,-o),Jr(p,o),l={type:o>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},a={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:{...l.start},end:{...a.end}},e[r][1].end={...l.start},e[n][1].start={...a.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Se(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Se(u,[["enter",i,t],["enter",l,t],["exit",l,t],["enter",s,t]]),u=Se(u,Ut(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Se(u,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(c=2,u=Se(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):c=0,xe(e,r-1,n-r+3,u),n=r+u.length-c-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Sd(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Xe(r);let s;return l;function l(o){return s=o,e.enter("attentionSequence"),a(o)}function a(o){if(o===s)return e.consume(o),a;const u=e.exit("attentionSequence"),c=Xe(o),d=!c||c===2&&i||n.includes(o),p=!i||i===2&&c||n.includes(r);return u._open=!!(s===42?d:d&&(i||!p)),u._close=!!(s===42?p:p&&(c||!d)),t(o)}}function Jr(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const kd={name:"autolink",tokenize:wd};function wd(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 ce(f)?(e.consume(f),l):f===64?n(f):u(f)}function l(f){return f===43||f===45||f===46||oe(f)?(r=1,a(f)):u(f)}function a(f){return f===58?(e.consume(f),r=0,o):(f===43||f===45||f===46||oe(f))&&r++<32?(e.consume(f),a):(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||Dt(f)?n(f):(e.consume(f),o)}function u(f){return f===64?(e.consume(f),c):dd(f)?(e.consume(f),u):n(f)}function c(f){return oe(f)?d(f):n(f)}function d(f){return f===46?(e.consume(f),r=0,c):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||oe(f))&&r++<63){const m=f===45?p:d;return e.consume(f),m}return n(f)}}const wt={partial:!0,tokenize:Cd};function Cd(e,t,n){return r;function r(s){return W(s)?X(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||z(s)?t(s):n(s)}}const Ys={continuation:{tokenize:Td},exit:Id,name:"blockQuote",tokenize:vd};function vd(e,t,n){const r=this;return i;function i(l){if(l===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(l),e.exit("blockQuoteMarker"),s}return n(l)}function s(l){return W(l)?(e.enter("blockQuotePrefixWhitespace"),e.consume(l),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(l))}}function Td(e,t,n){const r=this;return i;function i(l){return W(l)?X(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l):s(l)}function s(l){return e.attempt(Ys,t,n)(l)}}function Id(e){e.exit("blockQuote")}const Js={name:"characterEscape",tokenize:Md};function Md(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 fd(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const Zs={name:"characterReference",tokenize:Nd};function Nd(e,t,n){const r=this;let i=0,s,l;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),o}function o(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,l=oe,c(d))}function u(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,l=hd,c):(e.enter("characterReferenceValue"),s=7,l=An,c(d))}function c(d){if(d===59&&i){const p=e.exit("characterReferenceValue");return l===oe&&!ir(r.sliceSerialize(p))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return l(d)&&i++<s?(e.consume(d),c):n(d)}}const Zr={partial:!0,tokenize:Ld},ei={concrete:!0,name:"codeFenced",tokenize:Ed};function Ed(e,t,n){const r=this,i={partial:!0,tokenize:F};let s=0,l=0,a;return o;function o(v){return u(v)}function u(v){const O=r.events[r.events.length-1];return s=O&&O[1].type==="linePrefix"?O[2].sliceSerialize(O[1],!0).length:0,a=v,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),c(v)}function c(v){return v===a?(l++,e.consume(v),c):l<3?n(v):(e.exit("codeFencedFenceSequence"),W(v)?X(e,d,"whitespace")(v):d(v))}function d(v){return v===null||z(v)?(e.exit("codeFencedFence"),r.interrupt?t(v):e.check(Zr,y,D)(v)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(v))}function p(v){return v===null||z(v)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(v)):W(v)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),X(e,f,"whitespace")(v)):v===96&&v===a?n(v):(e.consume(v),p)}function f(v){return v===null||z(v)?d(v):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(v))}function m(v){return v===null||z(v)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(v)):v===96&&v===a?n(v):(e.consume(v),m)}function y(v){return e.attempt(i,D,S)(v)}function S(v){return e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),g}function g(v){return s>0&&W(v)?X(e,I,"linePrefix",s+1)(v):I(v)}function I(v){return v===null||z(v)?e.check(Zr,y,D)(v):(e.enter("codeFlowValue"),N(v))}function N(v){return v===null||z(v)?(e.exit("codeFlowValue"),I(v)):(e.consume(v),N)}function D(v){return e.exit("codeFenced"),t(v)}function F(v,O,_){let B=0;return w;function w(C){return v.enter("lineEnding"),v.consume(C),v.exit("lineEnding"),j}function j(C){return v.enter("codeFencedFence"),W(C)?X(v,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):L(C)}function L(C){return C===a?(v.enter("codeFencedFenceSequence"),H(C)):_(C)}function H(C){return C===a?(B++,v.consume(C),H):B>=l?(v.exit("codeFencedFenceSequence"),W(C)?X(v,A,"whitespace")(C):A(C)):_(C)}function A(C){return C===null||z(C)?(v.exit("codeFencedFence"),O(C)):_(C)}}}function Ld(e,t,n){const r=this;return i;function i(l){return l===null?n(l):(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),s)}function s(l){return r.parser.lazy[r.now().line]?n(l):t(l)}}const ln={name:"codeIndented",tokenize:Rd},Ad={partial:!0,tokenize:jd};function Rd(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),X(e,s,"linePrefix",5)(u)}function s(u){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?l(u):n(u)}function l(u){return u===null?o(u):z(u)?e.attempt(Ad,l,o)(u):(e.enter("codeFlowValue"),a(u))}function a(u){return u===null||z(u)?(e.exit("codeFlowValue"),l(u)):(e.consume(u),a)}function o(u){return e.exit("codeIndented"),t(u)}}function jd(e,t,n){const r=this;return i;function i(l){return r.parser.lazy[r.now().line]?n(l):z(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),i):X(e,s,"linePrefix",5)(l)}function s(l){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(l):z(l)?i(l):n(l)}}const Pd={name:"codeText",previous:Fd,resolve:Dd,tokenize:Od};function Dd(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 Fd(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Od(e,t,n){let r=0,i,s;return l;function l(d){return e.enter("codeText"),e.enter("codeTextSequence"),a(d)}function a(d){return d===96?(e.consume(d),r++,a):(e.exit("codeTextSequence"),o(d))}function o(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),o):d===96?(s=e.enter("codeTextSequence"),i=0,c(d)):z(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),o):(e.enter("codeTextData"),u(d))}function u(d){return d===null||d===32||d===96||z(d)?(e.exit("codeTextData"),o(d)):(e.consume(d),u)}function c(d){return d===96?(e.consume(d),i++,c):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",u(d))}}class zd{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&&st(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),st(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),st(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);st(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);st(this.left,n.reverse())}}}function st(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 el(e){const t={};let n=-1,r,i,s,l,a,o,u;const c=new zd(e);for(;++n<c.length;){for(;n in t;)n=t[n];if(r=c.get(n),n&&r[1].type==="chunkFlow"&&c.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,_d(c,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(l=c.get(s),l[1].type==="lineEnding"||l[1].type==="lineEndingBlank")l[0]==="enter"&&(i&&(c.get(i)[1].type="lineEndingBlank"),l[1].type="lineEnding",i=s);else if(!(l[1].type==="linePrefix"||l[1].type==="listItemIndent"))break;i&&(r[1].end={...c.get(i)[1].start},a=c.slice(i,n),a.unshift(r),c.splice(i,n-i+1,a))}}return xe(e,0,Number.POSITIVE_INFINITY,c.slice(0)),!u}function _d(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let l=n._tokenizer;l||(l=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(l._contentTypeTextTrailing=!0));const a=l.events,o=[],u={};let c,d,p=-1,f=n,m=0,y=0;const S=[y];for(;f;){for(;e.get(++i)[1]!==f;);s.push(i),f._tokenizer||(c=r.sliceStream(f),f.next||c.push(null),d&&l.defineSkip(f.start),f._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=!0),l.write(c),f._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=void 0)),d=f,f=f.next}for(f=n;++p<a.length;)a[p][0]==="exit"&&a[p-1][0]==="enter"&&a[p][1].type===a[p-1][1].type&&a[p][1].start.line!==a[p][1].end.line&&(y=p+1,S.push(y),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(l.events=[],f?(f._tokenizer=void 0,f.previous=void 0):S.pop(),p=S.length;p--;){const g=a.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 Bd={resolve:Hd,tokenize:Ud},Vd={partial:!0,tokenize:$d};function Hd(e){return el(e),e}function Ud(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):z(a)?e.check(Vd,l,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function l(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function $d(e,t,n){const r=this;return i;function i(l){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),X(e,s,"linePrefix")}function s(l){if(l===null||z(l))return n(l);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(l):e.interrupt(r.parser.constructs.flow,n,t)(l)}}function tl(e,t,n,r,i,s,l,a,o){const u=o||Number.POSITIVE_INFINITY;let c=0;return d;function d(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||Dt(g)?n(g):(e.enter(r),e.enter(l),e.enter(a),e.enter("chunkString",{contentType:"string"}),y(g))}function p(g){return g===62?(e.enter(s),e.consume(g),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),f(g))}function f(g){return g===62?(e.exit("chunkString"),e.exit(a),p(g)):g===null||g===60||z(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 y(g){return!c&&(g===null||g===41||Z(g))?(e.exit("chunkString"),e.exit(a),e.exit(l),e.exit(r),t(g)):c<u&&g===40?(e.consume(g),c++,y):g===41?(e.consume(g),c--,y):g===null||g===32||g===40||Dt(g)?n(g):(e.consume(g),g===92?S:y)}function S(g){return g===40||g===41||g===92?(e.consume(g),y):y(g)}}function nl(e,t,n,r,i,s){const l=this;let a=0,o;return u;function u(f){return e.enter(r),e.enter(i),e.consume(f),e.exit(i),e.enter(s),c}function c(f){return a>999||f===null||f===91||f===93&&!o||f===94&&!a&&"_hiddenFootnoteSupport"in l.parser.constructs?n(f):f===93?(e.exit(s),e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):z(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(f))}function d(f){return f===null||f===91||f===93||z(f)||a++>999?(e.exit("chunkString"),c(f)):(e.consume(f),o||(o=!W(f)),f===92?p:d)}function p(f){return f===91||f===92||f===93?(e.consume(f),a++,d):d(f)}}function rl(e,t,n,r,i,s){let l;return a;function a(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),l=p===40?41:p,o):n(p)}function o(p){return p===l?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),u(p))}function u(p){return p===l?(e.exit(s),o(l)):p===null?n(p):z(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),X(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(p))}function c(p){return p===l||p===null||z(p)?(e.exit("chunkString"),u(p)):(e.consume(p),p===92?d:c)}function d(p){return p===l||p===92?(e.consume(p),c):c(p)}}function dt(e,t){let n;return r;function r(i){return z(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):W(i)?X(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Kd={name:"definition",tokenize:Wd},qd={partial:!0,tokenize:Qd};function Wd(e,t,n){const r=this;let i;return s;function s(f){return e.enter("definition"),l(f)}function l(f){return nl.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function a(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 Z(f)?dt(e,u)(f):u(f)}function u(f){return tl(e,c,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function c(f){return e.attempt(qd,d,d)(f)}function d(f){return W(f)?X(e,p,"whitespace")(f):p(f)}function p(f){return f===null||z(f)?(e.exit("definition"),r.parser.defined.push(i),t(f)):n(f)}}function Qd(e,t,n){return r;function r(a){return Z(a)?dt(e,i)(a):n(a)}function i(a){return rl(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return W(a)?X(e,l,"whitespace")(a):l(a)}function l(a){return a===null||z(a)?t(a):n(a)}}const Gd={name:"hardBreakEscape",tokenize:Xd};function Xd(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return z(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const Yd={name:"headingAtx",resolve:Jd,tokenize:Zd};function Jd(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 Zd(e,t,n){let r=0;return i;function i(c){return e.enter("atxHeading"),s(c)}function s(c){return e.enter("atxHeadingSequence"),l(c)}function l(c){return c===35&&r++<6?(e.consume(c),l):c===null||Z(c)?(e.exit("atxHeadingSequence"),a(c)):n(c)}function a(c){return c===35?(e.enter("atxHeadingSequence"),o(c)):c===null||z(c)?(e.exit("atxHeading"),t(c)):W(c)?X(e,a,"whitespace")(c):(e.enter("atxHeadingText"),u(c))}function o(c){return c===35?(e.consume(c),o):(e.exit("atxHeadingSequence"),a(c))}function u(c){return c===null||c===35||Z(c)?(e.exit("atxHeadingText"),a(c)):(e.consume(c),u)}}const eh=["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"],ti=["pre","script","style","textarea"],th={concrete:!0,name:"htmlFlow",resolveTo:ih,tokenize:sh},nh={partial:!0,tokenize:ah},rh={partial:!0,tokenize:lh};function ih(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 sh(e,t,n){const r=this;let i,s,l,a,o;return u;function u(b){return c(b)}function c(b){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(b),d}function d(b){return b===33?(e.consume(b),p):b===47?(e.consume(b),s=!0,y):b===63?(e.consume(b),i=3,r.interrupt?t:x):ce(b)?(e.consume(b),l=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,a=0,m):ce(b)?(e.consume(b),i=4,r.interrupt?t:x):n(b)}function f(b){return b===45?(e.consume(b),r.interrupt?t:x):n(b)}function m(b){const de="CDATA[";return b===de.charCodeAt(a++)?(e.consume(b),a===de.length?r.interrupt?t:L:m):n(b)}function y(b){return ce(b)?(e.consume(b),l=String.fromCharCode(b),S):n(b)}function S(b){if(b===null||b===47||b===62||Z(b)){const de=b===47,Ie=l.toLowerCase();return!de&&!s&&ti.includes(Ie)?(i=1,r.interrupt?t(b):L(b)):eh.includes(l.toLowerCase())?(i=6,de?(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):N(b))}return b===45||oe(b)?(e.consume(b),l+=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 W(b)?(e.consume(b),I):w(b)}function N(b){return b===47?(e.consume(b),w):b===58||b===95||ce(b)?(e.consume(b),D):W(b)?(e.consume(b),N):w(b)}function D(b){return b===45||b===46||b===58||b===95||oe(b)?(e.consume(b),D):F(b)}function F(b){return b===61?(e.consume(b),v):W(b)?(e.consume(b),F):N(b)}function v(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),o=b,O):W(b)?(e.consume(b),v):_(b)}function O(b){return b===o?(e.consume(b),o=null,B):b===null||z(b)?n(b):(e.consume(b),O)}function _(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||Z(b)?F(b):(e.consume(b),_)}function B(b){return b===47||b===62||W(b)?N(b):n(b)}function w(b){return b===62?(e.consume(b),j):n(b)}function j(b){return b===null||z(b)?L(b):W(b)?(e.consume(b),j):n(b)}function L(b){return b===45&&i===2?(e.consume(b),P):b===60&&i===1?(e.consume(b),Q):b===62&&i===4?(e.consume(b),le):b===63&&i===3?(e.consume(b),x):b===93&&i===5?(e.consume(b),se):z(b)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(nh,ye,H)(b)):b===null||z(b)?(e.exit("htmlFlowData"),H(b)):(e.consume(b),L)}function H(b){return e.check(rh,A,ye)(b)}function A(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),C}function C(b){return b===null||z(b)?H(b):(e.enter("htmlFlowData"),L(b))}function P(b){return b===45?(e.consume(b),x):L(b)}function Q(b){return b===47?(e.consume(b),l="",$):L(b)}function $(b){if(b===62){const de=l.toLowerCase();return ti.includes(de)?(e.consume(b),le):L(b)}return ce(b)&&l.length<8?(e.consume(b),l+=String.fromCharCode(b),$):L(b)}function se(b){return b===93?(e.consume(b),x):L(b)}function x(b){return b===62?(e.consume(b),le):b===45&&i===2?(e.consume(b),x):L(b)}function le(b){return b===null||z(b)?(e.exit("htmlFlowData"),ye(b)):(e.consume(b),le)}function ye(b){return e.exit("htmlFlow"),t(b)}}function lh(e,t,n){const r=this;return i;function i(l){return z(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),s):n(l)}function s(l){return r.parser.lazy[r.now().line]?n(l):t(l)}}function ah(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(wt,t,n)}}const oh={name:"htmlText",tokenize:uh};function uh(e,t,n){const r=this;let i,s,l;return a;function a(x){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(x),o}function o(x){return x===33?(e.consume(x),u):x===47?(e.consume(x),F):x===63?(e.consume(x),N):ce(x)?(e.consume(x),_):n(x)}function u(x){return x===45?(e.consume(x),c):x===91?(e.consume(x),s=0,m):ce(x)?(e.consume(x),I):n(x)}function c(x){return x===45?(e.consume(x),f):n(x)}function d(x){return x===null?n(x):x===45?(e.consume(x),p):z(x)?(l=d,Q(x)):(e.consume(x),d)}function p(x){return x===45?(e.consume(x),f):d(x)}function f(x){return x===62?P(x):x===45?p(x):d(x)}function m(x){const le="CDATA[";return x===le.charCodeAt(s++)?(e.consume(x),s===le.length?y:m):n(x)}function y(x){return x===null?n(x):x===93?(e.consume(x),S):z(x)?(l=y,Q(x)):(e.consume(x),y)}function S(x){return x===93?(e.consume(x),g):y(x)}function g(x){return x===62?P(x):x===93?(e.consume(x),g):y(x)}function I(x){return x===null||x===62?P(x):z(x)?(l=I,Q(x)):(e.consume(x),I)}function N(x){return x===null?n(x):x===63?(e.consume(x),D):z(x)?(l=N,Q(x)):(e.consume(x),N)}function D(x){return x===62?P(x):N(x)}function F(x){return ce(x)?(e.consume(x),v):n(x)}function v(x){return x===45||oe(x)?(e.consume(x),v):O(x)}function O(x){return z(x)?(l=O,Q(x)):W(x)?(e.consume(x),O):P(x)}function _(x){return x===45||oe(x)?(e.consume(x),_):x===47||x===62||Z(x)?B(x):n(x)}function B(x){return x===47?(e.consume(x),P):x===58||x===95||ce(x)?(e.consume(x),w):z(x)?(l=B,Q(x)):W(x)?(e.consume(x),B):P(x)}function w(x){return x===45||x===46||x===58||x===95||oe(x)?(e.consume(x),w):j(x)}function j(x){return x===61?(e.consume(x),L):z(x)?(l=j,Q(x)):W(x)?(e.consume(x),j):B(x)}function L(x){return x===null||x===60||x===61||x===62||x===96?n(x):x===34||x===39?(e.consume(x),i=x,H):z(x)?(l=L,Q(x)):W(x)?(e.consume(x),L):(e.consume(x),A)}function H(x){return x===i?(e.consume(x),i=void 0,C):x===null?n(x):z(x)?(l=H,Q(x)):(e.consume(x),H)}function A(x){return x===null||x===34||x===39||x===60||x===61||x===96?n(x):x===47||x===62||Z(x)?B(x):(e.consume(x),A)}function C(x){return x===47||x===62||Z(x)?B(x):n(x)}function P(x){return x===62?(e.consume(x),e.exit("htmlTextData"),e.exit("htmlText"),t):n(x)}function Q(x){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),$}function $(x){return W(x)?X(e,se,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):se(x)}function se(x){return e.enter("htmlTextData"),l(x)}}const sr={name:"labelEnd",resolveAll:fh,resolveTo:ph,tokenize:mh},ch={tokenize:gh},dh={tokenize:xh},hh={tokenize:yh};function fh(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 ph(e,t){let n=e.length,r=0,i,s,l,a;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(l){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"&&(l=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[l][1].end}},c={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[l-2][1].start}};return a=[["enter",o,t],["enter",u,t]],a=Se(a,e.slice(s+1,s+r+3)),a=Se(a,[["enter",c,t]]),a=Se(a,Ut(t.parser.constructs.insideSpan.null,e.slice(s+r+4,l-3),t)),a=Se(a,[["exit",c,t],e[l-2],e[l-1],["exit",u,t]]),a=Se(a,e.slice(l+1)),a=Se(a,[["exit",o,t]]),xe(e,s,e.length,a),e}function mh(e,t,n){const r=this;let i=r.events.length,s,l;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(p){return s?s._inactive?d(p):(l=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(ch,c,l?c:d)(p):p===91?e.attempt(dh,c,l?u:d)(p):l?c(p):d(p)}function u(p){return e.attempt(hh,c,d)(p)}function c(p){return t(p)}function d(p){return s._balanced=!0,n(p)}}function gh(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return Z(d)?dt(e,s)(d):s(d)}function s(d){return d===41?c(d):tl(e,l,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function l(d){return Z(d)?dt(e,o)(d):c(d)}function a(d){return n(d)}function o(d){return d===34||d===39||d===40?rl(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):c(d)}function u(d){return Z(d)?dt(e,c)(d):c(d)}function c(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function xh(e,t,n){const r=this;return i;function i(a){return nl.call(r,e,s,l,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Te(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function l(a){return n(a)}}function yh(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 bh={name:"labelStartImage",resolveAll:sr.resolveAll,tokenize:Sh};function Sh(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),l):n(a)}function l(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const kh={name:"labelStartLink",resolveAll:sr.resolveAll,tokenize:wh};function wh(e,t,n){const r=this;return i;function i(l){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelLink"),s}function s(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const an={name:"lineEnding",tokenize:Ch};function Ch(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),X(e,t,"linePrefix")}}const Rt={name:"thematicBreak",tokenize:vh};function vh(e,t,n){let r=0,i;return s;function s(u){return e.enter("thematicBreak"),l(u)}function l(u){return i=u,a(u)}function a(u){return u===i?(e.enter("thematicBreakSequence"),o(u)):r>=3&&(u===null||z(u))?(e.exit("thematicBreak"),t(u)):n(u)}function o(u){return u===i?(e.consume(u),r++,o):(e.exit("thematicBreakSequence"),W(u)?X(e,a,"whitespace")(u):a(u))}}const he={continuation:{tokenize:Nh},exit:Lh,name:"list",tokenize:Mh},Th={partial:!0,tokenize:Ah},Ih={partial:!0,tokenize:Eh};function Mh(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,l=0;return a;function a(f){const m=r.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||f===r.containerState.marker:An(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(Rt,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 An(f)&&++l<10?(e.consume(f),o):(!r.interrupt||l<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(wt,r.interrupt?n:c,e.attempt(Th,p,d))}function c(f){return r.containerState.initialBlankLine=!0,s++,p(f)}function d(f){return W(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 Nh(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(wt,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,X(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!W(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,l(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Ih,t,l)(a))}function l(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,X(e,e.attempt(he,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Eh(e,t,n){const r=this;return X(e,i,"listItemIndent",r.containerState.size+1);function i(s){const l=r.events[r.events.length-1];return l&&l[1].type==="listItemIndent"&&l[2].sliceSerialize(l[1],!0).length===r.containerState.size?t(s):n(s)}}function Lh(e){e.exit(this.containerState.type)}function Ah(e,t,n){const r=this;return X(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const l=r.events[r.events.length-1];return!W(s)&&l&&l[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const ni={name:"setextUnderline",resolveTo:Rh,tokenize:jh};function Rh(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 l={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",l,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=l,e.push(["exit",l,t]),e}function jh(e,t,n){const r=this;let i;return s;function s(u){let c=r.events.length,d;for(;c--;)if(r.events[c][1].type!=="lineEnding"&&r.events[c][1].type!=="linePrefix"&&r.events[c][1].type!=="content"){d=r.events[c][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=u,l(u)):n(u)}function l(u){return e.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===i?(e.consume(u),a):(e.exit("setextHeadingLineSequence"),W(u)?X(e,o,"lineSuffix")(u):o(u))}function o(u){return u===null||z(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Ph={tokenize:Dh};function Dh(e){const t=this,n=e.attempt(wt,r,e.attempt(this.parser.constructs.flowInitial,i,X(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Bd,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 Fh={resolveAll:sl()},Oh=il("string"),zh=il("text");function il(e){return{resolveAll:sl(e==="text"?_h:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,l,a);return l;function l(c){return u(c)?s(c):a(c)}function a(c){if(c===null){n.consume(c);return}return n.enter("data"),n.consume(c),o}function o(c){return u(c)?(n.exit("data"),s(c)):(n.consume(c),o)}function u(c){if(c===null)return!0;const d=i[c];let p=-1;if(d)for(;++p<d.length;){const f=d[p];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function sl(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 _h(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,l=-1,a=0,o;for(;s--;){const u=i[s];if(typeof u=="string"){for(l=u.length;u.charCodeAt(l-1)===32;)a++,l--;if(l)break;l=-1}else if(u===-2)o=!0,a++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const u={type:n===e.length||o||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?l:r.start._bufferIndex+l,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const Bh={42:he,43:he,45:he,48:he,49:he,50:he,51:he,52:he,53:he,54:he,55:he,56:he,57:he,62:Ys},Vh={91:Kd},Hh={[-2]:ln,[-1]:ln,32:ln},Uh={35:Yd,42:Rt,45:[ni,Rt],60:th,61:ni,95:Rt,96:ei,126:ei},$h={38:Zs,92:Js},Kh={[-5]:an,[-4]:an,[-3]:an,33:bh,38:Zs,42:Rn,60:[kd,oh],91:kh,92:[Gd,Js],93:sr,95:Rn,96:Pd},qh={null:[Rn,Fh]},Wh={null:[42,95]},Qh={null:[]},Gh=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Wh,contentInitial:Vh,disable:Qh,document:Bh,flow:Uh,flowInitial:Hh,insideSpan:qh,string:$h,text:Kh},Symbol.toStringTag,{value:"Module"}));function Xh(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 l=[],a=[];const o={attempt:O(F),check:O(v),consume:I,enter:N,exit:D,interrupt:O(v,{interrupt:!0})},u={code:null,containerState:{},defineSkip:y,events:[],now:m,parser:e,previous:null,sliceSerialize:p,sliceStream:f,write:d};let c=t.tokenize.call(u,o);return t.resolveAll&&s.push(t),u;function d(j){return l=Se(l,j),S(),l[l.length-1]!==null?[]:(_(t,0),u.events=Ut(s,u.events,u),u.events)}function p(j,L){return Jh(f(j),L)}function f(j){return Yh(l,j)}function m(){const{_bufferIndex:j,_index:L,line:H,column:A,offset:C}=r;return{_bufferIndex:j,_index:L,line:H,column:A,offset:C}}function y(j){i[j.line]=j.column,w()}function S(){let j;for(;r._index<l.length;){const L=l[r._index];if(typeof L=="string")for(j=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===j&&r._bufferIndex<L.length;)g(L.charCodeAt(r._bufferIndex));else g(L)}}function g(j){c=c(j)}function I(j){z(j)?(r.line++,r.column=1,r.offset+=j===-3?2:1,w()):j!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===l[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=j}function N(j,L){const H=L||{};return H.type=j,H.start=m(),u.events.push(["enter",H,u]),a.push(H),H}function D(j){const L=a.pop();return L.end=m(),u.events.push(["exit",L,u]),L}function F(j,L){_(j,L.from)}function v(j,L){L.restore()}function O(j,L){return H;function H(A,C,P){let Q,$,se,x;return Array.isArray(A)?ye(A):"tokenize"in A?ye([A]):le(A);function le(re){return De;function De(we){const V=we!==null&&re[we],ae=we!==null&&re.null,be=[...Array.isArray(V)?V:V?[V]:[],...Array.isArray(ae)?ae:ae?[ae]:[]];return ye(be)(we)}}function ye(re){return Q=re,$=0,re.length===0?P:b(re[$])}function b(re){return De;function De(we){return x=B(),se=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,de,Ie)(we)}}function de(re){return j(se,x),C}function Ie(re){return x.restore(),++$<Q.length?b(Q[$]):P}}}function _(j,L){j.resolveAll&&!s.includes(j)&&s.push(j),j.resolve&&xe(u.events,L,u.events.length-L,j.resolve(u.events.slice(L),u)),j.resolveTo&&(u.events=j.resolveTo(u.events,u))}function B(){const j=m(),L=u.previous,H=u.currentConstruct,A=u.events.length,C=Array.from(a);return{from:A,restore:P};function P(){r=j,u.previous=L,u.currentConstruct=H,u.events.length=A,a=C,w()}}function w(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Yh(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let l;if(n===i)l=[e[n].slice(r,s)];else{if(l=e.slice(n,i),r>-1){const a=l[0];typeof a=="string"?l[0]=a.slice(r):l.shift()}s>0&&l.push(e[i].slice(0,s))}return l}function Jh(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let l;if(typeof s=="string")l=s;else switch(s){case-5:{l="\r";break}case-4:{l=`
|
|
5
|
+
`;break}case-3:{l=`\r
|
|
6
|
+
`;break}case-2:{l=t?" ":" ";break}case-1:{if(!t&&i)continue;l=" ";break}default:l=String.fromCharCode(s)}i=s===-2,r.push(l)}return r.join("")}function Zh(e){const r={constructs:Gs([Gh,...(e||{}).extensions||[]]),content:i(pd),defined:[],document:i(gd),flow:i(Ph),lazy:{},string:i(Oh),text:i(zh)};return r;function i(s){return l;function l(a){return Xh(r,s,a)}}}function ef(e){for(;!el(e););return e}const ri=/[\0\t\n\r]/g;function tf(){let e=1,t="",n=!0,r;return i;function i(s,l,a){const o=[];let u,c,d,p,f;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(l||void 0).decode(s)),d=0,t="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d<s.length;){if(ri.lastIndex=d,u=ri.exec(s),p=u&&u.index!==void 0?u.index:s.length,f=s.charCodeAt(p),!u){t=s.slice(d);break}if(f===10&&d===p&&r)o.push(-3),r=void 0;else switch(r&&(o.push(-5),r=void 0),d<p&&(o.push(s.slice(d,p)),e+=p-d),f){case 0:{o.push(65533),e++;break}case 9:{for(c=Math.ceil(e/4)*4,o.push(-2);e++<c;)o.push(-1);break}case 10:{o.push(-4),e=1;break}default:r=!0,e=1}d=p+1}return a&&(r&&o.push(-5),t&&o.push(t),o.push(null)),o}}const nf=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function rf(e){return e.replace(nf,sf)}function sf(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return Xs(n.slice(s?2:1),s?16:10)}return ir(n)||e}const ll={}.hasOwnProperty;function lf(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),af(n)(ef(Zh(n).document().write(tf()(e,t,!0))))}function af(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(xr),autolinkProtocol:B,autolinkEmail:B,atxHeading:s(Ze),blockQuote:s(ae),characterEscape:B,characterReference:B,codeFenced:s(be),codeFencedFenceInfo:l,codeFencedFenceMeta:l,codeIndented:s(be,l),codeText:s(Fe,l),codeTextData:B,data:B,codeFlowValue:B,definition:s(Le),definitionDestinationString:l,definitionLabelString:l,definitionTitleString:l,emphasis:s(Xt),hardBreakEscape:s(mr),hardBreakTrailing:s(mr),htmlFlow:s(gr,l),htmlFlowData:B,htmlText:s(gr,l),htmlTextData:B,image:s(Wl),label:l,link:s(xr),listItem:s(Ql),listItemValue:p,listOrdered:s(yr,d),listUnordered:s(yr),paragraph:s(Gl),reference:b,referenceString:l,resourceDestinationString:l,resourceTitleString:l,setextHeading:s(Ze),strong:s(Xl),thematicBreak:s(Jl)},exit:{atxHeading:o(),atxHeadingSequence:F,autolink:o(),autolinkEmail:V,autolinkProtocol:we,blockQuote:o(),characterEscapeValue:w,characterReferenceMarkerHexadecimal:Ie,characterReferenceMarkerNumeric:Ie,characterReferenceValue:re,characterReference:De,codeFenced:o(S),codeFencedFence:y,codeFencedFenceInfo:f,codeFencedFenceMeta:m,codeFlowValue:w,codeIndented:o(g),codeText:o(C),codeTextData:w,data:w,definition:o(),definitionDestinationString:D,definitionLabelString:I,definitionTitleString:N,emphasis:o(),hardBreakEscape:o(L),hardBreakTrailing:o(L),htmlFlow:o(H),htmlFlowData:w,htmlText:o(A),htmlTextData:w,image:o(Q),label:se,labelText:$,lineEnding:j,link:o(P),listItem:o(),listOrdered:o(),listUnordered:o(),paragraph:o(),referenceString:de,resourceDestinationString:x,resourceTitleString:le,resource:ye,setextHeading:o(_),setextHeadingLineSequence:O,setextHeadingText:v,strong:o(),thematicBreak:o()}};al(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(M){let R={type:"root",children:[]};const U={stack:[R],tokenStack:[],config:t,enter:a,exit:u,buffer:l,resume:c,data:n},G=[];let Y=-1;for(;++Y<M.length;)if(M[Y][1].type==="listOrdered"||M[Y][1].type==="listUnordered")if(M[Y][0]==="enter")G.push(Y);else{const Ce=G.pop();Y=i(M,Ce,Y)}for(Y=-1;++Y<M.length;){const Ce=t[M[Y][0]];ll.call(Ce,M[Y][1].type)&&Ce[M[Y][1].type].call(Object.assign({sliceSerialize:M[Y][2].sliceSerialize},U),M[Y][1])}if(U.tokenStack.length>0){const Ce=U.tokenStack[U.tokenStack.length-1];(Ce[1]||ii).call(U,void 0,Ce[0])}for(R.position={start:Oe(M.length>0?M[0][1].start:{line:1,column:1,offset:0}),end:Oe(M.length>0?M[M.length-2][1].end:{line:1,column:1,offset:0})},Y=-1;++Y<t.transforms.length;)R=t.transforms[Y](R)||R;return R}function i(M,R,U){let G=R-1,Y=-1,Ce=!1,Be,Ae,et,tt;for(;++G<=U;){const me=M[G];switch(me[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{me[0]==="enter"?Y++:Y--,tt=void 0;break}case"lineEndingBlank":{me[0]==="enter"&&(Be&&!tt&&!Y&&!et&&(et=G),tt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:tt=void 0}if(!Y&&me[0]==="enter"&&me[1].type==="listItemPrefix"||Y===-1&&me[0]==="exit"&&(me[1].type==="listUnordered"||me[1].type==="listOrdered")){if(Be){let $e=G;for(Ae=void 0;$e--;){const Re=M[$e];if(Re[1].type==="lineEnding"||Re[1].type==="lineEndingBlank"){if(Re[0]==="exit")continue;Ae&&(M[Ae][1].type="lineEndingBlank",Ce=!0),Re[1].type="lineEnding",Ae=$e}else if(!(Re[1].type==="linePrefix"||Re[1].type==="blockQuotePrefix"||Re[1].type==="blockQuotePrefixWhitespace"||Re[1].type==="blockQuoteMarker"||Re[1].type==="listItemIndent"))break}et&&(!Ae||et<Ae)&&(Be._spread=!0),Be.end=Object.assign({},Ae?M[Ae][1].start:me[1].end),M.splice(Ae||G,0,["exit",Be,me[2]]),G++,U++}if(me[1].type==="listItemPrefix"){const $e={type:"listItem",_spread:!1,start:Object.assign({},me[1].start),end:void 0};Be=$e,M.splice(G,0,["enter",$e,me[2]]),G++,U++,et=void 0,tt=!0}}}return M[R][1]._spread=Ce,U}function s(M,R){return U;function U(G){a.call(this,M(G),G),R&&R.call(this,G)}}function l(){this.stack.push({type:"fragment",children:[]})}function a(M,R,U){this.stack[this.stack.length-1].children.push(M),this.stack.push(M),this.tokenStack.push([R,U||void 0]),M.position={start:Oe(R.start),end:void 0}}function o(M){return R;function R(U){M&&M.call(this,U),u.call(this,U)}}function u(M,R){const U=this.stack.pop(),G=this.tokenStack.pop();if(G)G[0].type!==M.type&&(R?R.call(this,M,G[0]):(G[1]||ii).call(this,M,G[0]));else throw new Error("Cannot close `"+M.type+"` ("+ct({start:M.start,end:M.end})+"): it’s not open");U.position.end=Oe(M.end)}function c(){return rr(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function p(M){if(this.data.expectingFirstListItemValue){const R=this.stack[this.stack.length-2];R.start=Number.parseInt(this.sliceSerialize(M),10),this.data.expectingFirstListItemValue=void 0}}function f(){const M=this.resume(),R=this.stack[this.stack.length-1];R.lang=M}function m(){const M=this.resume(),R=this.stack[this.stack.length-1];R.meta=M}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const M=this.resume(),R=this.stack[this.stack.length-1];R.value=M.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const M=this.resume(),R=this.stack[this.stack.length-1];R.value=M.replace(/(\r?\n|\r)$/g,"")}function I(M){const R=this.resume(),U=this.stack[this.stack.length-1];U.label=R,U.identifier=Te(this.sliceSerialize(M)).toLowerCase()}function N(){const M=this.resume(),R=this.stack[this.stack.length-1];R.title=M}function D(){const M=this.resume(),R=this.stack[this.stack.length-1];R.url=M}function F(M){const R=this.stack[this.stack.length-1];if(!R.depth){const U=this.sliceSerialize(M).length;R.depth=U}}function v(){this.data.setextHeadingSlurpLineEnding=!0}function O(M){const R=this.stack[this.stack.length-1];R.depth=this.sliceSerialize(M).codePointAt(0)===61?1:2}function _(){this.data.setextHeadingSlurpLineEnding=void 0}function B(M){const U=this.stack[this.stack.length-1].children;let G=U[U.length-1];(!G||G.type!=="text")&&(G=Yl(),G.position={start:Oe(M.start),end:void 0},U.push(G)),this.stack.push(G)}function w(M){const R=this.stack.pop();R.value+=this.sliceSerialize(M),R.position.end=Oe(M.end)}function j(M){const R=this.stack[this.stack.length-1];if(this.data.atHardBreak){const U=R.children[R.children.length-1];U.position.end=Oe(M.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(R.type)&&(B.call(this,M),w.call(this,M))}function L(){this.data.atHardBreak=!0}function H(){const M=this.resume(),R=this.stack[this.stack.length-1];R.value=M}function A(){const M=this.resume(),R=this.stack[this.stack.length-1];R.value=M}function C(){const M=this.resume(),R=this.stack[this.stack.length-1];R.value=M}function P(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const R=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=R,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function Q(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const R=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=R,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function $(M){const R=this.sliceSerialize(M),U=this.stack[this.stack.length-2];U.label=rf(R),U.identifier=Te(R).toLowerCase()}function se(){const M=this.stack[this.stack.length-1],R=this.resume(),U=this.stack[this.stack.length-1];if(this.data.inReference=!0,U.type==="link"){const G=M.children;U.children=G}else U.alt=R}function x(){const M=this.resume(),R=this.stack[this.stack.length-1];R.url=M}function le(){const M=this.resume(),R=this.stack[this.stack.length-1];R.title=M}function ye(){this.data.inReference=void 0}function b(){this.data.referenceType="collapsed"}function de(M){const R=this.resume(),U=this.stack[this.stack.length-1];U.label=R,U.identifier=Te(this.sliceSerialize(M)).toLowerCase(),this.data.referenceType="full"}function Ie(M){this.data.characterReferenceType=M.type}function re(M){const R=this.sliceSerialize(M),U=this.data.characterReferenceType;let G;U?(G=Xs(R,U==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):G=ir(R);const Y=this.stack[this.stack.length-1];Y.value+=G}function De(M){const R=this.stack.pop();R.position.end=Oe(M.end)}function we(M){w.call(this,M);const R=this.stack[this.stack.length-1];R.url=this.sliceSerialize(M)}function V(M){w.call(this,M);const R=this.stack[this.stack.length-1];R.url="mailto:"+this.sliceSerialize(M)}function ae(){return{type:"blockquote",children:[]}}function be(){return{type:"code",lang:null,meta:null,value:""}}function Fe(){return{type:"inlineCode",value:""}}function Le(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Xt(){return{type:"emphasis",children:[]}}function Ze(){return{type:"heading",depth:0,children:[]}}function mr(){return{type:"break"}}function gr(){return{type:"html",value:""}}function Wl(){return{type:"image",title:null,url:"",alt:null}}function xr(){return{type:"link",title:null,url:"",children:[]}}function yr(M){return{type:"list",ordered:M.type==="listOrdered",start:null,spread:M._spread,children:[]}}function Ql(M){return{type:"listItem",spread:M._spread,checked:null,children:[]}}function Gl(){return{type:"paragraph",children:[]}}function Xl(){return{type:"strong",children:[]}}function Yl(){return{type:"text",value:""}}function Jl(){return{type:"thematicBreak"}}}function Oe(e){return{line:e.line,column:e.column,offset:e.offset}}function al(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?al(e,r):of(e,r)}}function of(e,t){let n;for(n in t)if(ll.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 ii(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ct({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ct({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ct({start:t.start,end:t.end})+") is still open")}function uf(e){const t=this;t.parser=n;function n(r){return lf(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function cf(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 df(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
7
|
+
`}]}function hf(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 ff(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function pf(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function mf(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=Je(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let l,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),l=e.footnoteOrder.length):l=s+1,a+=1,e.footnoteCounts.set(r,a);const o={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(l)}]};e.patch(t,o);const u={type:"element",tagName:"sup",properties:{},children:[o]};return e.patch(t,u),e.applyData(t,u)}function gf(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 xf(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function ol(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 l=i[i.length-1];return l&&l.type==="text"?l.value+=r:i.push({type:"text",value:r}),i}function yf(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ol(e,t);const i={src:Je(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 bf(e,t){const n={src:Je(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 Sf(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 kf(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ol(e,t);const i={href:Je(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 wf(e,t){const n={href:Je(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 Cf(e,t,n){const r=e.all(t),i=n?vf(n):ul(t),s={},l=[];if(typeof t.checked=="boolean"){const c=r[0];let d;c&&c.type==="element"&&c.tagName==="p"?d=c:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const c=r[a];(i||a!==0||c.type!=="element"||c.tagName!=="p")&&l.push({type:"text",value:`
|
|
9
|
+
`}),c.type==="element"&&c.tagName==="p"&&!i?l.push(...c.children):l.push(c)}const o=r[r.length-1];o&&(i||o.type!=="element"||o.tagName!=="p")&&l.push({type:"text",value:`
|
|
10
|
+
`});const u={type:"element",tagName:"li",properties:s,children:l};return e.patch(t,u),e.applyData(t,u)}function vf(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=ul(n[r])}return t}function ul(e){const t=e.spread;return t??e.children.length>1}function Tf(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 l=r[i];if(l.type==="element"&&l.tagName==="li"&&l.properties&&Array.isArray(l.properties.className)&&l.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 If(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 Nf(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Ef(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const l={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],l),i.push(l)}if(n.length>0){const l={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=Zn(t.children[1]),o=Hs(t.children[t.children.length-1]);a&&o&&(l.position={start:a,end:o}),i.push(l)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function Lf(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",l=n&&n.type==="table"?n.align:void 0,a=l?l.length:t.children.length;let o=-1;const u=[];for(;++o<a;){const d=t.children[o],p={},f=l?l[o]:void 0;f&&(p.align=f);let m={type:"element",tagName:s,properties:p,children:[]};d&&(m.children=e.all(d),e.patch(d,m),m=e.applyData(d,m)),u.push(m)}const c={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,c),e.applyData(t,c)}function Af(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const si=9,li=32;function Rf(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(ai(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(ai(t.slice(i),i>0,!1)),s.join("")}function ai(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===si||s===li;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===si||s===li;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function jf(e,t){const n={type:"text",value:Rf(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Pf(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Df={blockquote:cf,break:df,code:hf,delete:ff,emphasis:pf,footnoteReference:mf,heading:gf,html:xf,imageReference:yf,image:bf,inlineCode:Sf,linkReference:kf,link:wf,listItem:Cf,list:Tf,paragraph:If,root:Mf,strong:Nf,table:Ef,tableCell:Af,tableRow:Lf,text:jf,thematicBreak:Pf,toml:vt,yaml:vt,definition:vt,footnoteDefinition:vt};function vt(){}const cl=-1,$t=0,ht=1,Ft=2,lr=3,ar=4,or=5,ur=6,dl=7,hl=8,oi=typeof self=="object"?self:globalThis,Ff=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,l]=t[i];switch(s){case $t:case cl:return n(l,i);case ht:{const a=n([],i);for(const o of l)a.push(r(o));return a}case Ft:{const a=n({},i);for(const[o,u]of l)a[r(o)]=r(u);return a}case lr:return n(new Date(l),i);case ar:{const{source:a,flags:o}=l;return n(new RegExp(a,o),i)}case or:{const a=n(new Map,i);for(const[o,u]of l)a.set(r(o),r(u));return a}case ur:{const a=n(new Set,i);for(const o of l)a.add(r(o));return a}case dl:{const{name:a,message:o}=l;return n(new oi[a](o),i)}case hl:return n(BigInt(l),i);case"BigInt":return n(Object(BigInt(l)),i);case"ArrayBuffer":return n(new Uint8Array(l).buffer,l);case"DataView":{const{buffer:a}=new Uint8Array(l);return n(new DataView(a),l)}}return n(new oi[s](l),i)};return r},ui=e=>Ff(new Map,e)(0),qe="",{toString:Of}={},{keys:zf}=Object,lt=e=>{const t=typeof e;if(t!=="object"||!e)return[$t,t];const n=Of.call(e).slice(8,-1);switch(n){case"Array":return[ht,qe];case"Object":return[Ft,qe];case"Date":return[lr,qe];case"RegExp":return[ar,qe];case"Map":return[or,qe];case"Set":return[ur,qe];case"DataView":return[ht,n]}return n.includes("Array")?[ht,n]:n.includes("Error")?[dl,n]:[Ft,n]},Tt=([e,t])=>e===$t&&(t==="function"||t==="symbol"),_f=(e,t,n,r)=>{const i=(l,a)=>{const o=r.push(l)-1;return n.set(a,o),o},s=l=>{if(n.has(l))return n.get(l);let[a,o]=lt(l);switch(a){case $t:{let c=l;switch(o){case"bigint":a=hl,c=l.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+o);c=null;break;case"undefined":return i([cl],l)}return i([a,c],l)}case ht:{if(o){let p=l;return o==="DataView"?p=new Uint8Array(l.buffer):o==="ArrayBuffer"&&(p=new Uint8Array(l)),i([o,[...p]],l)}const c=[],d=i([a,c],l);for(const p of l)c.push(s(p));return d}case Ft:{if(o)switch(o){case"BigInt":return i([o,l.toString()],l);case"Boolean":case"Number":case"String":return i([o,l.valueOf()],l)}if(t&&"toJSON"in l)return s(l.toJSON());const c=[],d=i([a,c],l);for(const p of zf(l))(e||!Tt(lt(l[p])))&&c.push([s(p),s(l[p])]);return d}case lr:return i([a,l.toISOString()],l);case ar:{const{source:c,flags:d}=l;return i([a,{source:c,flags:d}],l)}case or:{const c=[],d=i([a,c],l);for(const[p,f]of l)(e||!(Tt(lt(p))||Tt(lt(f))))&&c.push([s(p),s(f)]);return d}case ur:{const c=[],d=i([a,c],l);for(const p of l)(e||!Tt(lt(p)))&&c.push(s(p));return d}}const{message:u}=l;return i([a,{name:o,message:u}],l)};return s},ci=(e,{json:t,lossy:n}={})=>{const r=[];return _f(!(t||n),!!t,new Map,r)(e),r},Ot=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?ui(ci(e,t)):structuredClone(e):(e,t)=>ui(ci(e,t));function Bf(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 Vf(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function Hf(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Bf,r=e.options.footnoteBackLabel||Vf,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",l=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let o=-1;for(;++o<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[o]);if(!u)continue;const c=e.all(u),d=String(u.identifier).toUpperCase(),p=Je(d.toLowerCase());let f=0;const m=[],y=e.footnoteCounts.get(d);for(;y!==void 0&&++f<=y;){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=c[c.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 c.push(...m);const g={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(c,!0)};e.patch(u,g),a.push(g)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...Ot(l),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
11
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:`
|
|
12
|
+
`}]}}const Kt=(function(e){if(e==null)return qf;if(typeof e=="function")return qt(e);if(typeof e=="object")return Array.isArray(e)?Uf(e):$f(e);if(typeof e=="string")return Kf(e);throw new Error("Expected function, string, or object as test")});function Uf(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Kt(e[n]);return qt(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function $f(e){const t=e;return qt(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function Kf(e){return qt(t);function t(n){return n&&n.type===e}}function qt(e){return t;function t(n,r,i){return!!(Wf(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function qf(){return!0}function Wf(e){return e!==null&&typeof e=="object"&&"type"in e}const fl=[],Qf=!0,jn=!1,Gf="skip";function pl(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=Kt(i),l=r?-1:1;a(e,void 0,[])();function a(o,u,c){const d=o&&typeof o=="object"?o:{};if(typeof d.type=="string"){const f=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(o.type+(f?"<"+f+">":""))+")"})}return p;function p(){let f=fl,m,y,S;if((!t||s(o,u,c[c.length-1]||void 0))&&(f=Xf(n(o,c)),f[0]===jn))return f;if("children"in o&&o.children){const g=o;if(g.children&&f[0]!==Gf)for(y=(r?g.children.length:-1)+l,S=c.concat(g);y>-1&&y<g.children.length;){const I=g.children[y];if(m=a(I,y,S)(),m[0]===jn)return m;y=typeof m[1]=="number"?m[1]:y+l}}return f}}}function Xf(e){return Array.isArray(e)?e:typeof e=="number"?[Qf,e]:e==null?fl:[e]}function cr(e,t,n,r){let i,s,l;typeof t=="function"&&typeof n!="function"?(s=void 0,l=t,i=n):(s=t,l=n,i=r),pl(e,s,a,i);function a(o,u){const c=u[u.length-1],d=c?c.children.indexOf(o):void 0;return l(o,d,c)}}const Pn={}.hasOwnProperty,Yf={};function Jf(e,t){const n=t||Yf,r=new Map,i=new Map,s=new Map,l={...Df,...n.handlers},a={all:u,applyData:ep,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:l,one:o,options:n,patch:Zf,wrap:np};return cr(e,function(c){if(c.type==="definition"||c.type==="footnoteDefinition"){const d=c.type==="definition"?r:i,p=String(c.identifier).toUpperCase();d.has(p)||d.set(p,c)}}),a;function o(c,d){const p=c.type,f=a.handlers[p];if(Pn.call(a.handlers,p)&&f)return f(a,c,d);if(a.options.passThrough&&a.options.passThrough.includes(p)){if("children"in c){const{children:y,...S}=c,g=Ot(S);return g.children=a.all(c),g}return Ot(c)}return(a.options.unknownHandler||tp)(a,c,d)}function u(c){const d=[];if("children"in c){const p=c.children;let f=-1;for(;++f<p.length;){const m=a.one(p[f],c);if(m){if(f&&p[f-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=di(m.value)),!Array.isArray(m)&&m.type==="element")){const y=m.children[0];y&&y.type==="text"&&(y.value=di(y.value))}Array.isArray(m)?d.push(...m):d.push(m)}}}return d}}function Zf(e,t){e.position&&(t.position=Bc(e))}function ep(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 l="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:l}}n.type==="element"&&s&&Object.assign(n.properties,Ot(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function tp(e,t){const n=t.data||{},r="value"in t&&!(Pn.call(n,"hProperties")||Pn.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 np(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 di(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function hi(e,t){const n=Jf(e,t),r=n.one(e,void 0),i=Hf(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 rp(e,t){return e&&"run"in e?async function(n,r){const i=hi(n,{file:r,...t});await e.run(i,r)}:function(n,r){return hi(n,{file:r,...e||t})}}function fi(e){if(e)throw e}var on,pi;function ip(){if(pi)return on;pi=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 c=e.call(u,"constructor"),d=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!c&&!d)return!1;var p;for(p in u);return typeof p>"u"||e.call(u,p)},l=function(u,c){n&&c.name==="__proto__"?n(u,c.name,{enumerable:!0,configurable:!0,value:c.newValue,writable:!0}):u[c.name]=c.newValue},a=function(u,c){if(c==="__proto__")if(e.call(u,c)){if(r)return r(u,c).value}else return;return u[c]};return on=function o(){var u,c,d,p,f,m,y=arguments[0],S=1,g=arguments.length,I=!1;for(typeof y=="boolean"&&(I=y,y=arguments[1]||{},S=2),(y==null||typeof y!="object"&&typeof y!="function")&&(y={});S<g;++S)if(u=arguments[S],u!=null)for(c in u)d=a(y,c),p=a(u,c),y!==p&&(I&&p&&(s(p)||(f=i(p)))?(f?(f=!1,m=d&&i(d)?d:[]):m=d&&s(d)?d:{},l(y,{name:c,newValue:o(I,m,p)})):typeof p<"u"&&l(y,{name:c,newValue:p}));return y},on}var sp=ip();const un=es(sp);function Dn(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 lp(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const l=i.pop();if(typeof l!="function")throw new TypeError("Expected function as last argument, not "+l);a(null,...i);function a(o,...u){const c=e[++s];let d=-1;if(o){l(o);return}for(;++d<i.length;)(u[d]===null||u[d]===void 0)&&(u[d]=i[d]);i=u,c?ap(c,a)(...u):l(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 ap(e,t){let n;return r;function r(...l){const a=e.length>l.length;let o;a&&l.push(i);try{o=e.apply(this,l)}catch(u){const c=u;if(a&&n)throw c;return i(c)}a||(o&&o.then&&typeof o.then=="function"?o.then(s,i):o instanceof Error?i(o):s(o))}function i(l,...a){n||(n=!0,t(l,...a))}function s(l){i(null,l)}}const Ne={basename:op,dirname:up,extname:cp,join:dp,sep:"/"};function op(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ct(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 l=-1,a=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else l<0&&(s=!0,l=i+1),a>-1&&(e.codePointAt(i)===t.codePointAt(a--)?a<0&&(r=i):(a=-1,r=l));return n===r?r=l:r<0&&(r=e.length),e.slice(n,r)}function up(e){if(Ct(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 cp(e){Ct(e);let t=e.length,n=-1,r=0,i=-1,s=0,l;for(;t--;){const a=e.codePointAt(t);if(a===47){if(l){r=t+1;break}continue}n<0&&(l=!0,n=t+1),a===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function dp(...e){let t=-1,n;for(;++t<e.length;)Ct(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":hp(n)}function hp(e){Ct(e);const t=e.codePointAt(0)===47;let n=fp(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function fp(e,t){let n="",r=0,i=-1,s=0,l=-1,a,o;for(;++l<=e.length;){if(l<e.length)a=e.codePointAt(l);else{if(a===47)break;a=47}if(a===47){if(!(i===l-1||s===1))if(i!==l-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=l,s=0;continue}}else if(n.length>0){n="",r=0,i=l,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,l):n=e.slice(i+1,l),r=l-i-1;i=l,s=0}else a===46&&s>-1?s++:s=-1}return n}function Ct(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const pp={cwd:mp};function mp(){return"/"}function Fn(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function gp(e){if(typeof e=="string")e=new URL(e);else if(!Fn(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 xp(e)}function xp(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 cn=["history","path","basename","stem","extname","dirname"];class ml{constructor(t){let n;t?Fn(t)?n={path:t}:typeof t=="string"||yp(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":pp.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<cn.length;){const s=cn[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)cn.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Ne.basename(this.path):void 0}set basename(t){hn(t,"basename"),dn(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){mi(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(dn(t,"extname"),mi(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){Fn(t)&&(t=gp(t)),hn(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){hn(t,"stem"),dn(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 ue(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 dn(e,t){if(e&&e.includes(Ne.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Ne.sep+"`")}function hn(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function mi(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function yp(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const bp=(function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),Sp={}.hasOwnProperty;class dr extends bp{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=lp()}copy(){const t=new dr;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(un(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(mn("data",this.frozen),this.namespace[t]=n,this):Sp.call(this.namespace,t)&&this.namespace[t]||void 0:t?(mn("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=It(t),r=this.parser||this.Parser;return fn("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),fn("process",this.parser||this.Parser),pn("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,l){const a=It(t),o=r.parse(a);r.run(o,a,function(c,d,p){if(c||!d||!p)return u(c);const f=d,m=r.stringify(f,p);Cp(m)?p.value=m:p.result=m,u(c,p)});function u(c,d){c||!d?l(c):s?s(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),fn("processSync",this.parser||this.Parser),pn("processSync",this.compiler||this.Compiler),this.process(t,i),xi("processSync","process",n),r;function i(s,l){n=!0,fi(s),r=l}}run(t,n,r){gi(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(l,a){const o=It(n);i.run(t,o,u);function u(c,d,p){const f=d||t;c?a(c):l?l(f):r(void 0,f,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),xi("runSync","run",r),i;function s(l,a){fi(l),i=a,r=!0}}stringify(t,n){this.freeze();const r=It(n),i=this.compiler||this.Compiler;return pn("stringify",i),gi(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(mn("use",this.frozen),t!=null)if(typeof t=="function")o(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):l(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[c,...d]=u;o(c,d)}else l(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function l(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(u.plugins),u.settings&&(i.settings=un(!0,i.settings,u.settings))}function a(u){let c=-1;if(u!=null)if(Array.isArray(u))for(;++c<u.length;){const d=u[c];s(d)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function o(u,c){let d=-1,p=-1;for(;++d<r.length;)if(r[d][0]===u){p=d;break}if(p===-1)r.push([u,...c]);else if(c.length>0){let[f,...m]=c;const y=r[p][1];Dn(y)&&Dn(f)&&(f=un(!0,y,f)),r[p]=[u,f,...m]}}}}const kp=new dr().freeze();function fn(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function pn(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function mn(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 gi(e){if(!Dn(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function xi(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function It(e){return wp(e)?e:new ml(e)}function wp(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Cp(e){return typeof e=="string"||vp(e)}function vp(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Tp="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",yi=[],bi={allowDangerousHtml:!0},Ip=/^(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 Np(e){const t=Ep(e),n=Lp(e);return Ap(t.runSync(t.parse(n),n),e)}function Ep(e){const t=e.rehypePlugins||yi,n=e.remarkPlugins||yi,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...bi}:bi;return kp().use(uf).use(n).use(rp,r).use(t)}function Lp(e){const t=e.children||"",n=new ml;return typeof t=="string"&&(n.value=t),n}function Ap(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,l=t.skipHtml,a=t.unwrapDisallowed,o=t.urlTransform||Rp;for(const c of Mp)Object.hasOwn(t,c.from)&&(""+c.from+(c.to?"use `"+c.to+"` instead":"remove it")+Tp+c.id,void 0);return cr(e,u),Kc(e,{Fragment:h.Fragment,components:i,ignoreInvalidStyle:!0,jsx:h.jsx,jsxs:h.jsxs,passKeys:!0,passNode:!0});function u(c,d,p){if(c.type==="raw"&&p&&typeof d=="number")return l?p.children.splice(d,1):p.children[d]={type:"text",value:c.value},d;if(c.type==="element"){let f;for(f in sn)if(Object.hasOwn(sn,f)&&Object.hasOwn(c.properties,f)){const m=c.properties[f],y=sn[f];(y===null||y.includes(c.tagName))&&(c.properties[f]=o(String(m||""),f,c))}}if(c.type==="element"){let f=n?!n.includes(c.tagName):s?s.includes(c.tagName):!1;if(!f&&r&&typeof d=="number"&&(f=!r(c,d,p)),f&&p&&typeof d=="number")return a&&c.children?p.children.splice(d,1,...c.children):p.children.splice(d,1),d}}}function Rp(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||Ip.test(e.slice(0,t))?e:""}function Si(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 jp(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Pp(e,t,n){const i=Kt((n||{}).ignore||[]),s=Dp(t);let l=-1;for(;++l<s.length;)pl(e,"text",a);function a(u,c){let d=-1,p;for(;++d<c.length;){const f=c[d],m=p?p.children:void 0;if(i(f,m?m.indexOf(f):void 0,p))return;p=f}if(p)return o(u,c)}function o(u,c){const d=c[c.length-1],p=s[l][0],f=s[l][1];let m=0;const S=d.children.indexOf(u);let g=!1,I=[];p.lastIndex=0;let N=p.exec(u.value);for(;N;){const D=N.index,F={index:N.index,input:N.input,stack:[...c,u]};let v=f(...N,F);if(typeof v=="string"&&(v=v.length>0?{type:"text",value:v}:void 0),v===!1?p.lastIndex=D+1:(m!==D&&I.push({type:"text",value:u.value.slice(m,D)}),Array.isArray(v)?I.push(...v):v&&I.push(v),m=D+N[0].length,g=!0),!p.global)break;N=p.exec(u.value)}return g?(m<u.value.length&&I.push({type:"text",value:u.value.slice(m)}),d.children.splice(S,1,...I)):I=[u],S+I.length}}function Dp(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([Fp(i[0]),Op(i[1])])}return t}function Fp(e){return typeof e=="string"?new RegExp(jp(e),"g"):e}function Op(e){return typeof e=="function"?e:function(){return e}}const gn="phrasing",xn=["autolink","link","image","label"];function zp(){return{transforms:[Kp],enter:{literalAutolink:Bp,literalAutolinkEmail:yn,literalAutolinkHttp:yn,literalAutolinkWww:yn},exit:{literalAutolink:$p,literalAutolinkEmail:Up,literalAutolinkHttp:Vp,literalAutolinkWww:Hp}}}function _p(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:gn,notInConstruct:xn},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:gn,notInConstruct:xn},{character:":",before:"[ps]",after:"\\/",inConstruct:gn,notInConstruct:xn}]}}function Bp(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function yn(e){this.config.enter.autolinkProtocol.call(this,e)}function Vp(e){this.config.exit.autolinkProtocol.call(this,e)}function Hp(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 Up(e){this.config.exit.autolinkEmail.call(this,e)}function $p(e){this.exit(e)}function Kp(e){Pp(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,qp],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Wp]],{ignore:["link","linkReference"]})}function qp(e,t,n,r,i){let s="";if(!gl(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!Qp(n)))return!1;const l=Gp(n+r);if(!l[0])return!1;const a={type:"link",title:null,url:s+t+l[0],children:[{type:"text",value:t+l[0]}]};return l[1]?[a,{type:"text",value:l[1]}]:a}function Wp(e,t,n,r){return!gl(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Qp(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 Gp(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=Si(e,"(");let s=Si(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 gl(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||He(n)||Ht(n))&&(!t||n!==47)}xl.peek=im;function Xp(){this.buffer()}function Yp(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Jp(){this.buffer()}function Zp(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function em(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 tm(e){this.exit(e)}function nm(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 rm(e){this.exit(e)}function im(){return"["}function xl(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const l=n.enter("footnoteReference"),a=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),a(),l(),s+=i.move("]"),s}function sm(){return{enter:{gfmFootnoteCallString:Xp,gfmFootnoteCall:Yp,gfmFootnoteDefinitionLabelString:Jp,gfmFootnoteDefinition:Zp},exit:{gfmFootnoteCallString:em,gfmFootnoteCall:tm,gfmFootnoteDefinitionLabelString:nm,gfmFootnoteDefinition:rm}}}function lm(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:xl},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,l){const a=s.createTracker(l);let o=a.move("[^");const u=s.enter("footnoteDefinition"),c=s.enter("label");return o+=a.move(s.safe(s.associationId(r),{before:o,after:"]"})),c(),o+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
17
|
+
`:" ")+s.indentLines(s.containerFlow(r,a.current()),t?yl:am))),u(),o}}function am(e,t,n){return t===0?e:yl(e,t,n)}function yl(e,t,n){return(n?"":" ")+e}const om=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];bl.peek=fm;function um(){return{canContainEols:["delete"],enter:{strikethrough:dm},exit:{strikethrough:hm}}}function cm(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:om}],handlers:{delete:bl}}}function dm(e){this.enter({type:"delete",children:[]},e)}function hm(e){this.exit(e)}function bl(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let l=i.move("~~");return l+=n.containerPhrasing(e,{...i.current(),before:l,after:"~"}),l+=i.move("~~"),s(),l}function fm(){return"~"}function pm(e){return e.length}function mm(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||pm,s=[],l=[],a=[],o=[];let u=0,c=-1;for(;++c<e.length;){const y=[],S=[];let g=-1;for(e[c].length>u&&(u=e[c].length);++g<e[c].length;){const I=gm(e[c][g]);if(n.alignDelimiters!==!1){const N=i(I);S[g]=N,(o[g]===void 0||N>o[g])&&(o[g]=N)}y.push(I)}l[c]=y,a[c]=S}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<u;)s[d]=ki(r[d]);else{const y=ki(r);for(;++d<u;)s[d]=y}d=-1;const p=[],f=[];for(;++d<u;){const y=s[d];let S="",g="";y===99?(S=":",g=":"):y===108?S=":":y===114&&(g=":");let I=n.alignDelimiters===!1?1:Math.max(1,o[d]-S.length-g.length);const N=S+"-".repeat(I)+g;n.alignDelimiters!==!1&&(I=S.length+I+g.length,I>o[d]&&(o[d]=I),f[d]=I),p[d]=N}l.splice(1,0,p),a.splice(1,0,f),c=-1;const m=[];for(;++c<l.length;){const y=l[c],S=a[c];d=-1;const g=[];for(;++d<u;){const I=y[d]||"";let N="",D="";if(n.alignDelimiters!==!1){const F=o[d]-(S[d]||0),v=s[d];v===114?N=" ".repeat(F):v===99?F%2?(N=" ".repeat(F/2+.5),D=" ".repeat(F/2-.5)):(N=" ".repeat(F/2),D=N):D=" ".repeat(F)}n.delimiterStart!==!1&&!d&&g.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&I==="")&&(n.delimiterStart!==!1||d)&&g.push(" "),n.alignDelimiters!==!1&&g.push(N),g.push(I),n.alignDelimiters!==!1&&g.push(D),n.padding!==!1&&g.push(" "),(n.delimiterEnd!==!1||d!==u-1)&&g.push("|")}m.push(n.delimiterEnd===!1?g.join("").replace(/ +$/,""):g.join(""))}return m.join(`
|
|
18
|
+
`)}function gm(e){return e==null?"":String(e)}function ki(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 xm(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const l=n.indentLines(n.containerFlow(e,s.current()),ym);return i(),l}function ym(e,t,n){return">"+(n?"":" ")+e}function bm(e,t){return wi(e,t.inConstruct,!0)&&!wi(e,t.notInConstruct,!1)}function wi(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 Ci(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
19
|
+
`&&bm(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
20
|
+
`}function Sm(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,l=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>l&&(l=s):s=1,i=r+t.length,r=n.indexOf(t,i);return l}function km(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 wm(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 Cm(e,t,n,r){const i=wm(n),s=e.value||"",l=i==="`"?"GraveAccent":"Tilde";if(km(e,n)){const d=n.enter("codeIndented"),p=n.indentLines(s,vm);return d(),p}const a=n.createTracker(r),o=i.repeat(Math.max(Sm(s,i)+1,3)),u=n.enter("codeFenced");let c=a.move(o);if(e.lang){const d=n.enter(`codeFencedLang${l}`);c+=a.move(n.safe(e.lang,{before:c,after:" ",encode:["`"],...a.current()})),d()}if(e.lang&&e.meta){const d=n.enter(`codeFencedMeta${l}`);c+=a.move(" "),c+=a.move(n.safe(e.meta,{before:c,after:`
|
|
21
|
+
`,encode:["`"],...a.current()})),d()}return c+=a.move(`
|
|
22
|
+
`),s&&(c+=a.move(s+`
|
|
23
|
+
`)),c+=a.move(o),u(),c}function vm(e,t,n){return(n?"":" ")+e}function hr(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 Tm(e,t,n,r){const i=hr(n),s=i==='"'?"Quote":"Apostrophe",l=n.enter("definition");let a=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("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(e.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(a=n.enter("destinationRaw"),u+=o.move(n.safe(e.url,{before:u,after:e.title?" ":`
|
|
24
|
+
`,...o.current()}))),a(),e.title&&(a=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),a()),l(),u}function Im(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 mt(e){return"&#x"+e.toString(16).toUpperCase()+";"}function zt(e,t,n){const r=Xe(e),i=Xe(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}}Sl.peek=Mm;function Sl(e,t,n,r){const i=Im(n),s=n.enter("emphasis"),l=n.createTracker(r),a=l.move(i);let o=l.move(n.containerPhrasing(e,{after:i,before:a,...l.current()}));const u=o.charCodeAt(0),c=zt(r.before.charCodeAt(r.before.length-1),u,i);c.inside&&(o=mt(u)+o.slice(1));const d=o.charCodeAt(o.length-1),p=zt(r.after.charCodeAt(0),d,i);p.inside&&(o=o.slice(0,-1)+mt(d));const f=l.move(i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:c.outside},a+o+f}function Mm(e,t,n){return n.options.emphasis||"*"}function Nm(e,t){let n=!1;return cr(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,jn}),!!((!e.depth||e.depth<3)&&rr(e)&&(t.options.setext||n))}function Em(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(Nm(e,n)){const c=n.enter("headingSetext"),d=n.enter("phrasing"),p=n.containerPhrasing(e,{...s.current(),before:`
|
|
25
|
+
`,after:`
|
|
26
|
+
`});return d(),c(),p+`
|
|
27
|
+
`+(i===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
|
|
28
|
+
`))+1))}const l="#".repeat(i),a=n.enter("headingAtx"),o=n.enter("phrasing");s.move(l+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
|
|
29
|
+
`,...s.current()});return/^[\t ]/.test(u)&&(u=mt(u.charCodeAt(0))+u.slice(1)),u=u?l+" "+u:l,n.options.closeAtx&&(u+=" "+l),o(),a(),u}kl.peek=Lm;function kl(e){return e.value||""}function Lm(){return"<"}wl.peek=Am;function wl(e,t,n,r){const i=hr(n),s=i==='"'?"Quote":"Apostrophe",l=n.enter("image");let a=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("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(e.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(a=n.enter("destinationRaw"),u+=o.move(n.safe(e.url,{before:u,after:e.title?" ":")",...o.current()}))),a(),e.title&&(a=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),a()),u+=o.move(")"),l(),u}function Am(){return"!"}Cl.peek=Rm;function Cl(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let l=n.enter("label");const a=n.createTracker(r);let o=a.move("![");const u=n.safe(e.alt,{before:o,after:"]",...a.current()});o+=a.move(u+"]["),l();const c=n.stack;n.stack=[],l=n.enter("reference");const d=n.safe(n.associationId(e),{before:o,after:"]",...a.current()});return l(),n.stack=c,s(),i==="full"||!u||u!==d?o+=a.move(d+"]"):i==="shortcut"?o=o.slice(0,-1):o+=a.move("]"),o}function Rm(){return"!"}vl.peek=jm;function vl(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 l=n.unsafe[s],a=n.compilePattern(l);let o;if(l.atBreak)for(;o=a.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 jm(){return"`"}function Tl(e,t){const n=rr(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))}Il.peek=Pm;function Il(e,t,n,r){const i=hr(n),s=i==='"'?"Quote":"Apostrophe",l=n.createTracker(r);let a,o;if(Tl(e,n)){const c=n.stack;n.stack=[],a=n.enter("autolink");let d=l.move("<");return d+=l.move(n.containerPhrasing(e,{before:d,after:">",...l.current()})),d+=l.move(">"),a(),n.stack=c,d}a=n.enter("link"),o=n.enter("label");let u=l.move("[");return u+=l.move(n.containerPhrasing(e,{before:u,after:"](",...l.current()})),u+=l.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(e.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(o=n.enter("destinationRaw"),u+=l.move(n.safe(e.url,{before:u,after:e.title?" ":")",...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),u+=l.move(" "+i),u+=l.move(n.safe(e.title,{before:u,after:i,...l.current()})),u+=l.move(i),o()),u+=l.move(")"),a(),u}function Pm(e,t,n){return Tl(e,n)?"<":"["}Ml.peek=Dm;function Ml(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let l=n.enter("label");const a=n.createTracker(r);let o=a.move("[");const u=n.containerPhrasing(e,{before:o,after:"]",...a.current()});o+=a.move(u+"]["),l();const c=n.stack;n.stack=[],l=n.enter("reference");const d=n.safe(n.associationId(e),{before:o,after:"]",...a.current()});return l(),n.stack=c,s(),i==="full"||!u||u!==d?o+=a.move(d+"]"):i==="shortcut"?o=o.slice(0,-1):o+=a.move("]"),o}function Dm(){return"["}function fr(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 Fm(e){const t=fr(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 Om(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 Nl(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 zm(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let l=e.ordered?Om(n):fr(n);const a=e.ordered?l==="."?")":".":Fm(n);let o=t&&n.bulletLastUsed?l===n.bulletLastUsed:!1;if(!e.ordered){const c=e.children?e.children[0]:void 0;if((l==="*"||l==="-")&&c&&(!c.children||!c.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),Nl(n)===l&&c){let d=-1;for(;++d<e.children.length;){const p=e.children[d];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){o=!0;break}}}}o&&(l=a),n.bulletCurrent=l;const u=n.containerFlow(e,r);return n.bulletLastUsed=l,n.bulletCurrent=s,i(),u}function _m(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 Bm(e,t,n,r){const i=_m(n);let s=n.bulletCurrent||fr(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 l=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(l=Math.ceil(l/4)*4);const a=n.createTracker(r);a.move(s+" ".repeat(l-s.length)),a.shift(l);const o=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,a.current()),c);return o(),u;function c(d,p,f){return p?(f?"":" ".repeat(l))+d:(f?s:s+" ".repeat(l-s.length))+d}}function Vm(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),l=n.containerPhrasing(e,r);return s(),i(),l}const Hm=Kt(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Um(e,t,n,r){return(e.children.some(function(l){return Hm(l)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function $m(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}El.peek=Km;function El(e,t,n,r){const i=$m(n),s=n.enter("strong"),l=n.createTracker(r),a=l.move(i+i);let o=l.move(n.containerPhrasing(e,{after:i,before:a,...l.current()}));const u=o.charCodeAt(0),c=zt(r.before.charCodeAt(r.before.length-1),u,i);c.inside&&(o=mt(u)+o.slice(1));const d=o.charCodeAt(o.length-1),p=zt(r.after.charCodeAt(0),d,i);p.inside&&(o=o.slice(0,-1)+mt(d));const f=l.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:c.outside},a+o+f}function Km(e,t,n){return n.options.strong||"*"}function qm(e,t,n,r){return n.safe(e.value,r)}function Wm(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 Qm(e,t,n){const r=(Nl(n)+(n.options.ruleSpaces?" ":"")).repeat(Wm(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Ll={blockquote:xm,break:Ci,code:Cm,definition:Tm,emphasis:Sl,hardBreak:Ci,heading:Em,html:kl,image:wl,imageReference:Cl,inlineCode:vl,link:Il,linkReference:Ml,list:zm,listItem:Bm,paragraph:Vm,root:Um,strong:El,text:qm,thematicBreak:Qm};function Gm(){return{enter:{table:Xm,tableData:vi,tableHeader:vi,tableRow:Jm},exit:{codeText:Zm,table:Ym,tableData:bn,tableHeader:bn,tableRow:bn}}}function Xm(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 Ym(e){this.exit(e),this.data.inTable=void 0}function Jm(e){this.enter({type:"tableRow",children:[]},e)}function bn(e){this.exit(e)}function vi(e){this.enter({type:"tableCell",children:[]},e)}function Zm(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,eg));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function eg(e,t){return t==="|"?t:e}function tg(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:l,tableCell:o,tableRow:a}};function l(f,m,y,S){return u(c(f,y,S),f.align)}function a(f,m,y,S){const g=d(f,y,S),I=u([g]);return I.slice(0,I.indexOf(`
|
|
31
|
+
`))}function o(f,m,y,S){const g=y.enter("tableCell"),I=y.enter("phrasing"),N=y.containerPhrasing(f,{...S,before:s,after:s});return I(),g(),N}function u(f,m){return mm(f,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function c(f,m,y){const S=f.children;let g=-1;const I=[],N=m.enter("table");for(;++g<S.length;)I[g]=d(S[g],m,y);return N(),I}function d(f,m,y){const S=f.children;let g=-1;const I=[],N=m.enter("tableRow");for(;++g<S.length;)I[g]=o(S[g],f,m,y);return N(),I}function p(f,m,y){let S=Ll.inlineCode(f,m,y);return y.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function ng(){return{exit:{taskListCheckValueChecked:Ti,taskListCheckValueUnchecked:Ti,paragraph:ig}}}function rg(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:sg}}}function Ti(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function ig(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,l;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){l=a;break}}l===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 sg(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",l="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(l);let o=Ll.listItem(e,t,n,{...r,...a.current()});return s&&(o=o.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),o;function u(c){return c+l}}function lg(){return[zp(),sm(),um(),Gm(),ng()]}function ag(e){return{extensions:[_p(),lm(e),cm(),tg(e),rg()]}}const og={tokenize:pg,partial:!0},Al={tokenize:mg,partial:!0},Rl={tokenize:gg,partial:!0},jl={tokenize:xg,partial:!0},ug={tokenize:yg,partial:!0},Pl={name:"wwwAutolink",tokenize:hg,previous:Fl},Dl={name:"protocolAutolink",tokenize:fg,previous:Ol},Pe={name:"emailAutolink",tokenize:dg,previous:zl},Ee={};function cg(){return{text:Ee}}let Ve=48;for(;Ve<123;)Ee[Ve]=Pe,Ve++,Ve===58?Ve=65:Ve===91&&(Ve=97);Ee[43]=Pe;Ee[45]=Pe;Ee[46]=Pe;Ee[95]=Pe;Ee[72]=[Pe,Dl];Ee[104]=[Pe,Dl];Ee[87]=[Pe,Pl];Ee[119]=[Pe,Pl];function dg(e,t,n){const r=this;let i,s;return l;function l(d){return!On(d)||!zl.call(r,r.previous)||pr(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(d))}function a(d){return On(d)?(e.consume(d),a):d===64?(e.consume(d),o):n(d)}function o(d){return d===46?e.check(ug,c,u)(d):d===45||d===95||oe(d)?(s=!0,e.consume(d),o):c(d)}function u(d){return e.consume(d),i=!0,o}function c(d){return s&&i&&ce(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function hg(e,t,n){const r=this;return i;function i(l){return l!==87&&l!==119||!Fl.call(r,r.previous)||pr(r.events)?n(l):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(og,e.attempt(Al,e.attempt(Rl,s),n),n)(l))}function s(l){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(l)}}function fg(e,t,n){const r=this;let i="",s=!1;return l;function l(d){return(d===72||d===104)&&Ol.call(r,r.previous)&&!pr(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),a):n(d)}function a(d){if(ce(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),a;if(d===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(d),o}return n(d)}function o(d){return d===47?(e.consume(d),s?u:(s=!0,o)):n(d)}function u(d){return d===null||Dt(d)||Z(d)||He(d)||Ht(d)?n(d):e.attempt(Al,e.attempt(Rl,c),n)(d)}function c(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function pg(e,t,n){let r=0;return i;function i(l){return(l===87||l===119)&&r<3?(r++,e.consume(l),i):l===46&&r===3?(e.consume(l),s):n(l)}function s(l){return l===null?n(l):t(l)}}function mg(e,t,n){let r,i,s;return l;function l(u){return u===46||u===95?e.check(jl,o,a)(u):u===null||Z(u)||He(u)||u!==45&&Ht(u)?o(u):(s=!0,e.consume(u),l)}function a(u){return u===95?r=!0:(i=r,r=void 0),e.consume(u),l}function o(u){return i||r||!s?n(u):t(u)}}function gg(e,t){let n=0,r=0;return i;function i(l){return l===40?(n++,e.consume(l),i):l===41&&r<n?s(l):l===33||l===34||l===38||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===60||l===63||l===93||l===95||l===126?e.check(jl,t,s)(l):l===null||Z(l)||He(l)?t(l):(e.consume(l),i)}function s(l){return l===41&&r++,e.consume(l),i}}function xg(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||Z(a)||He(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||Z(a)||He(a)?t(a):r(a)}function s(a){return ce(a)?l(a):n(a)}function l(a){return a===59?(e.consume(a),r):ce(a)?(e.consume(a),l):n(a)}}function yg(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return oe(s)?n(s):t(s)}}function Fl(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Z(e)}function Ol(e){return!ce(e)}function zl(e){return!(e===47||On(e))}function On(e){return e===43||e===45||e===46||e===95||oe(e)}function pr(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 bg={tokenize:Mg,partial:!0};function Sg(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:vg,continuation:{tokenize:Tg},exit:Ig}},text:{91:{name:"gfmFootnoteCall",tokenize:Cg},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:kg,resolveTo:wg}}}}function kg(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l;for(;i--;){const o=r.events[i][1];if(o.type==="labelImage"){l=o;break}if(o.type==="gfmFootnoteCall"||o.type==="labelLink"||o.type==="label"||o.type==="image"||o.type==="link")break}return a;function a(o){if(!l||!l._balanced)return n(o);const u=Te(r.sliceSerialize({start:l.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 wg(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)},l={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",l,t],["exit",l,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function Cg(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,l;return a;function a(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),o}function o(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(d){if(s>999||d===93&&!l||d===null||d===91||Z(d))return n(d);if(d===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(Te(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return Z(d)||(l=!0),s++,e.consume(d),d===92?c:u}function c(d){return d===91||d===92||d===93?(e.consume(d),s++,u):u(d)}}function vg(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,l=0,a;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",c):n(m)}function c(m){if(l>999||m===93&&!a||m===null||m===91||Z(m))return n(m);if(m===93){e.exit("chunkString");const y=e.exit("gfmFootnoteDefinitionLabelString");return s=Te(r.sliceSerialize(y)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return Z(m)||(a=!0),l++,e.consume(m),m===92?d:c}function d(m){return m===91||m===92||m===93?(e.consume(m),l++,c):c(m)}function p(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),X(e,f,"gfmFootnoteDefinitionWhitespace")):n(m)}function f(m){return t(m)}}function Tg(e,t,n){return e.check(wt,t,e.attempt(bg,t,n))}function Ig(e){e.exit("gfmFootnoteDefinition")}function Mg(e,t,n){const r=this;return X(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const l=r.events[r.events.length-1];return l&&l[1].type==="gfmFootnoteDefinitionIndent"&&l[2].sliceSerialize(l[1],!0).length===4?t(s):n(s)}}function Ng(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(l,a){let o=-1;for(;++o<l.length;)if(l[o][0]==="enter"&&l[o][1].type==="strikethroughSequenceTemporary"&&l[o][1]._close){let u=o;for(;u--;)if(l[u][0]==="exit"&&l[u][1].type==="strikethroughSequenceTemporary"&&l[u][1]._open&&l[o][1].end.offset-l[o][1].start.offset===l[u][1].end.offset-l[u][1].start.offset){l[o][1].type="strikethroughSequence",l[u][1].type="strikethroughSequence";const c={type:"strikethrough",start:Object.assign({},l[u][1].start),end:Object.assign({},l[o][1].end)},d={type:"strikethroughText",start:Object.assign({},l[u][1].end),end:Object.assign({},l[o][1].start)},p=[["enter",c,a],["enter",l[u][1],a],["exit",l[u][1],a],["enter",d,a]],f=a.parser.constructs.insideSpan.null;f&&xe(p,p.length,0,Ut(f,l.slice(u+1,o),a)),xe(p,p.length,0,[["exit",d,a],["enter",l[o][1],a],["exit",l[o][1],a],["exit",c,a]]),xe(l,u-1,o-u+3,p),o=u+p.length-2;break}}for(o=-1;++o<l.length;)l[o][1].type==="strikethroughSequenceTemporary"&&(l[o][1].type="data");return l}function s(l,a,o){const u=this.previous,c=this.events;let d=0;return p;function p(m){return u===126&&c[c.length-1][1].type!=="characterEscape"?o(m):(l.enter("strikethroughSequenceTemporary"),f(m))}function f(m){const y=Xe(u);if(m===126)return d>1?o(m):(l.consume(m),d++,f);if(d<2&&!n)return o(m);const S=l.exit("strikethroughSequenceTemporary"),g=Xe(m);return S._open=!g||g===2&&!!y,S._close=!y||y===2&&!!g,a(m)}}}class Eg{constructor(){this.map=[]}add(t,n,r){Lg(this,t,n,r)}consume(t){if(this.map.sort(function(s,l){return s[0]-l[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 Lg(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 Ag(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 Rg(){return{flow:{null:{name:"table",tokenize:jg,resolveAll:Pg}}}}function jg(e,t,n){const r=this;let i=0,s=0,l;return a;function a(w){let j=r.events.length-1;for(;j>-1;){const A=r.events[j][1].type;if(A==="lineEnding"||A==="linePrefix")j--;else break}const L=j>-1?r.events[j][1].type:null,H=L==="tableHead"||L==="tableRow"?v:o;return H===v&&r.parser.lazy[r.now().line]?n(w):H(w)}function o(w){return e.enter("tableHead"),e.enter("tableRow"),u(w)}function u(w){return w===124||(l=!0,s+=1),c(w)}function c(w){return w===null?n(w):z(w)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),f):n(w):W(w)?X(e,c,"whitespace")(w):(s+=1,l&&(l=!1,i+=1),w===124?(e.enter("tableCellDivider"),e.consume(w),e.exit("tableCellDivider"),l=!0,c):(e.enter("data"),d(w)))}function d(w){return w===null||w===124||Z(w)?(e.exit("data"),c(w)):(e.consume(w),w===92?p:d)}function p(w){return w===92||w===124?(e.consume(w),d):d(w)}function f(w){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(w):(e.enter("tableDelimiterRow"),l=!1,W(w)?X(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?(l=!0,e.enter("tableCellDivider"),e.consume(w),e.exit("tableCellDivider"),y):F(w)}function y(w){return W(w)?X(e,S,"whitespace")(w):S(w)}function S(w){return w===58?(s+=1,l=!0,e.enter("tableDelimiterMarker"),e.consume(w),e.exit("tableDelimiterMarker"),g):w===45?(s+=1,g(w)):w===null||z(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?(l=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(w),e.exit("tableDelimiterMarker"),N):(e.exit("tableDelimiterFiller"),N(w))}function N(w){return W(w)?X(e,D,"whitespace")(w):D(w)}function D(w){return w===124?m(w):w===null||z(w)?!l||i!==s?F(w):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(w)):F(w)}function F(w){return n(w)}function v(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||z(w)?(e.exit("tableRow"),t(w)):W(w)?X(e,O,"whitespace")(w):(e.enter("data"),_(w))}function _(w){return w===null||w===124||Z(w)?(e.exit("data"),O(w)):(e.consume(w),w===92?B:_)}function B(w){return w===92||w===124?(e.consume(w),_):_(w)}}function Pg(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],l=[0,0,0,0],a=!1,o=0,u,c,d;const p=new Eg;for(;++n<e.length;){const f=e[n],m=f[1];f[0]==="enter"?m.type==="tableHead"?(a=!1,o!==0&&(Ii(p,t,o,u,c),c=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,d=void 0,s=[0,0,0,0],l=[0,n+1,0,0],a&&(a=!1,c={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",c,t]])),i=m.type==="tableDelimiterRow"?2:c?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,l[2]===0&&(s[1]!==0&&(l[0]=l[1],d=Mt(p,t,s,i,void 0,d),s=[0,0,0,0]),l[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(l[0]=l[1],d=Mt(p,t,s,i,void 0,d)),s=l,l=[s[1],n,0,0])):m.type==="tableHead"?(a=!0,o=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(o=n,s[1]!==0?(l[0]=l[1],d=Mt(p,t,s,i,n,d)):l[1]!==0&&(d=Mt(p,t,l,i,n,d)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(l[3]=n)}for(o!==0&&Ii(p,t,o,u,c),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=Ag(t.events,n))}return e}function Mt(e,t,n,r,i,s){const l=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},We(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const o=We(t.events,n[1]);if(s={type:l,start:Object.assign({},o),end:Object.assign({},o)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const u=We(t.events,n[2]),c=We(t.events,n[3]),d={type:a,start:Object.assign({},u),end:Object.assign({},c)};if(e.add(n[2],0,[["enter",d,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,y=n[3]-n[2]-1;e.add(m,y,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(s.end=Object.assign({},We(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Ii(e,t,n,r,i){const s=[],l=We(t.events,n);i&&(i.end=Object.assign({},l),s.push(["exit",i,t])),r.end=Object.assign({},l),s.push(["exit",r,t]),e.add(n+1,0,s)}function We(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const Dg={name:"tasklistCheck",tokenize:Og};function Fg(){return{text:{91:Dg}}}function Og(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 Z(o)?(e.enter("taskListCheckValueUnchecked"),e.consume(o),e.exit("taskListCheckValueUnchecked"),l):o===88||o===120?(e.enter("taskListCheckValueChecked"),e.consume(o),e.exit("taskListCheckValueChecked"),l):n(o)}function l(o){return o===93?(e.enter("taskListCheckMarker"),e.consume(o),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(o)}function a(o){return z(o)?t(o):W(o)?e.check({tokenize:zg},t,n)(o):n(o)}}function zg(e,t,n){return X(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function _g(e){return Gs([cg(),Sg(),Ng(e),Rg(),Fg()])}const Bg={};function Vg(e){const t=this,n=e||Bg,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),l=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(_g(n)),s.push(lg()),l.push(ag(n))}function Hg(){var e;return typeof navigator<"u"&&typeof((e=navigator.clipboard)==null?void 0:e.writeText)=="function"}function Ug(e){if(typeof document>"u")return;const t=document.getSelection();t&&(t.removeAllRanges(),e.forEach(n=>t.addRange(n)))}function Mi(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()):[],l=document.createElement("textarea");l.value=e,l.setAttribute("readonly",""),l.setAttribute("aria-hidden","true"),l.style.position="fixed",l.style.top="0",l.style.left="-9999px",l.style.opacity="0",l.style.pointerEvents="none",l.style.fontSize="12pt",document.body.appendChild(l);try{l.focus({preventScroll:!0})}catch{l.focus()}l.select(),l.setSelectionRange(0,l.value.length);let a=!1;try{a=typeof document.execCommand=="function"&&document.execCommand("copy")}catch{a=!1}if(l.remove(),t)try{t.focus({preventScroll:!0})}catch{t.focus()}return n&&r?n.setSelectionRange(r.start,r.end):Ug(s),a}async function $g(e){if(!e)return!1;if(Hg())try{return await navigator.clipboard.writeText(e),!0}catch{return Mi(e)}return Mi(e)}const Kg=1300;function qg(e){const[t,n]=k.useState(!1),r=k.useCallback(async()=>{if(!e.text)return;const i=await $g(e.text);n(!!i)},[e.text]);return k.useEffect(()=>{if(!t||typeof window>"u")return;const i=window.setTimeout(()=>n(!1),e.resetDelayMs??Kg);return()=>window.clearTimeout(i)},[t,e.resetDelayMs]),{copied:t,copy:r}}const Wg=/language-([a-z0-9-]+)/i;function _l(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(_l).join(""):""}function Qg(e){const t=_l(e);return t.endsWith(`
|
|
32
|
+
`)?t.slice(0,-1):t}function Gg(e){var n;const t=e?Wg.exec(e):null;return((n=t==null?void 0:t[1])==null?void 0:n.toLowerCase())||"text"}function Xg(e){const t=k.useMemo(()=>Gg(e.className),[e.className]),n=k.useMemo(()=>Qg(e.children),[e.children]),{copied:r,copy:i}=qg({text:n});return h.jsxs("div",{className:"chat-codeblock",children:[h.jsxs("div",{className:"chat-codeblock-toolbar",children:[h.jsx("span",{className:"chat-codeblock-language",children:t}),h.jsxs("button",{type:"button",className:"chat-codeblock-copy",onClick:()=>void i(),"aria-label":r?e.texts.copiedCodeLabel:e.texts.copyCodeLabel,children:[r?h.jsx(yt,{className:"h-3.5 w-3.5"}):h.jsx(va,{className:"h-3.5 w-3.5"}),h.jsx("span",{children:r?e.texts.copiedCodeLabel:e.texts.copyCodeLabel})]})]}),h.jsx("pre",{children:h.jsx("code",{className:e.className,children:n})})]})}const Ni=14e4,Yg=new Set(["http:","https:","mailto:","tel:"]);function Jg(e){return e.length<=Ni?e:`${e.slice(0,Ni)}
|
|
33
|
+
|
|
34
|
+
...`}function Ei(e){if(!e)return null;if(e.startsWith("#")||e.startsWith("/")||e.startsWith("./")||e.startsWith("../"))return e;try{const t=new URL(e);return Yg.has(t.protocol)?e:null}catch{return null}}function Zg(e){return/^https?:\/\//i.test(e)}function ex(e){const t=e.role==="user",n=k.useMemo(()=>({a:({href:r,children:i,...s})=>{const l=Ei(r);if(!l)return h.jsx("span",{className:"chat-link-invalid",children:i});const a=Zg(l);return h.jsx("a",{...s,href:l,target:a?"_blank":void 0,rel:a?"noreferrer noopener":void 0,children:i})},table:({children:r,...i})=>h.jsx("div",{className:"chat-table-wrap",children:h.jsx("table",{...i,children:r})}),input:({type:r,checked:i,...s})=>r!=="checkbox"?h.jsx("input",{...s,type:r}):h.jsx("input",{...s,type:"checkbox",checked:i,readOnly:!0,disabled:!0,className:"chat-task-checkbox"}),img:({src:r,alt:i,...s})=>{const l=Ei(r);return l?h.jsx("img",{...s,src:l,alt:i||"",loading:"lazy",decoding:"async"}):null},code:({className:r,children:i,...s})=>{const l=String(i??"");return!r&&!l.includes(`
|
|
35
|
+
`)?h.jsx("code",{...s,className:q("chat-inline-code",r),children:i}):h.jsx(Xg,{className:r,texts:e.texts,children:i})}}),[e.texts]);return h.jsx("div",{className:q("chat-markdown",t?"chat-markdown-user":"chat-markdown-assistant"),children:h.jsx(Np,{skipHtml:!0,remarkPlugins:[Vg],components:n,children:Jg(e.text)})})}const Bl={archive:"Archive",audio:"Audio",code:"Code",data:"Data",document:"Document",generic:"File",image:"Image",pdf:"PDF",sheet:"Sheet",video:"Video"},Sn={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"},tx=new Set(["c","cpp","css","go","html","java","js","jsx","md","php","py","rb","rs","sh","sql","svg","ts","tsx"]),nx=new Set(["graphql","json","toml","xml","yaml","yml"]),rx=new Set(["doc","docx","odt","pages","rtf","txt"]),ix=new Set(["csv","numbers","ods","tsv","xls","xlsx"]),sx=new Set(["7z","bz2","gz","rar","tar","tgz","zip"]);function lx(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 ax(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 ox(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":sx.has(n)||/(zip|tar|gzip|rar|compressed|archive)/.test(r)?"archive":ix.has(n)||/(spreadsheet|sheet|excel|csv)/.test(r)?"sheet":nx.has(n)||/(json|xml|yaml|toml)/.test(r)?"data":tx.has(n)||/(javascript|typescript|jsx|tsx|css|html)/.test(r)?"code":rx.has(n)||/(msword|document|opendocument|rtf|text\/)/.test(r)?"document":"generic"}function ux(e){const t=ox(e.label,e.mimeType),n=lx(e.sizeBytes);return{category:t,extension:ax(e.label,e.mimeType),sizeLabel:n,metaBadges:[Bl[t],n].filter(r=>!!r)}}function kn(e,t){return h.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 Li(e,t){return h.jsx("div",{className:q("truncate text-[11px]",t?"text-white/58":"text-slate-500"),children:e})}function Ai(e,t,n){return h.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 cx({file:e,isUser:t=!1}){const{category:n,extension:r,metaBadges:i,sizeLabel:s}=ux(e),l=!!e.dataUrl,a=l?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)]",l&&(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 h.jsx("a",{href:e.dataUrl,target:"_blank",rel:"noreferrer","aria-label":`Open preview: ${e.label}`,className:q(u,"group"),children:h.jsxs("figure",{children:[h.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:[h.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]"}),h.jsxs("div",{className:"pointer-events-none absolute inset-x-4 top-4 flex items-center justify-between",children:[s?kn(s,t):h.jsx("span",{}),h.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":Sn[n]),children:o})]})]}),h.jsxs("figcaption",{className:"flex items-start gap-3 p-4",children:[h.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":Sn[n]),children:o}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("div",{className:"truncate text-sm font-semibold leading-5",children:e.label}),h.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:i.map(d=>kn(d,t))}),h.jsx("div",{className:"mt-2",children:Li(e.mimeType,t)})]}),Ai(a,t,!0)]})]})});const c=h.jsxs("div",{className:"flex items-start gap-3 p-3.5",children:[h.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":Sn[n]),children:o}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("div",{className:"truncate text-sm font-semibold leading-5",children:e.label}),h.jsxs("div",{className:q("mt-1 text-xs",t?"text-white/68":"text-slate-500"),children:[Bl[n]," attachment"]})]}),Ai(a,t,l)]}),h.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:i.map(d=>kn(d,t))}),h.jsx("div",{className:"mt-2",children:Li(e.mimeType,t)})]})]});return l?h.jsx("a",{href:e.dataUrl,target:"_blank",rel:"noreferrer","aria-label":`Open file: ${e.label}`,className:q(u,"group"),children:c}):h.jsx("div",{className:u,children:c})}function dx(e){return h.jsxs("details",{className:"mt-3",open:!0,children:[h.jsx("summary",{className:q("cursor-pointer text-xs",e.isUser?"text-primary-100":"text-gray-500"),children:e.label}),h.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 Wt({children:e,className:t}){return h.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 Qt({children:e,className:t}){return h.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 Ri={running:{text:"text-amber-500/80",icon:Ki,spin:!0},success:{text:"text-amber-500/80",icon:yt,spin:!1},error:{text:"text-amber-500/80",icon:Ia,spin:!1},cancelled:{text:"text-amber-500/80",icon:Ta,spin:!1}};function hx({card:e}){const t=Ri[e.statusTone]||Ri.cancelled,n=t.icon;return h.jsxs("span",{className:q("inline-flex items-center gap-1.5 text-[11px] font-medium leading-none shrink-0",t.text),children:[h.jsx(n,{className:q("h-3.5 w-3.5",t.spin&&"animate-spin"),strokeWidth:3}),e.statusTone==="running"?e.statusLabel:null]})}function Gt({card:e,icon:t,expanded:n,canExpand:r,onToggle:i}){var l;const s=(l=e.summary)==null?void 0:l.replace(/^(command|path|args|query|input):\s*/i,"");return h.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:[h.jsxs("div",{className:"flex items-center gap-2 font-mono min-w-0 max-w-[calc(100%-80px)] text-amber-950/80",children:[h.jsx(t,{className:"h-4 w-4 text-amber-600/80 shrink-0",strokeWidth:3}),h.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[h.jsx("span",{className:"font-bold shrink-0 tracking-tight",children:e.toolName}),s&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-amber-300 font-bold select-none shrink-0",children:"›"}),h.jsx("span",{className:"truncate flex-1 min-w-0 font-normal",title:s,children:s})]})]})]}),h.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[h.jsx(hx,{card:e}),r&&(n?h.jsx(_t,{className:"h-4 w-4 text-amber-400/80",strokeWidth:3}):h.jsx(Ma,{className:"h-4 w-4 text-amber-400/80",strokeWidth:3}))]})]})}function fx({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,l]=k.useState(r&&(n||e.statusTone==="error"||t.length<500)),[a,o]=k.useState(!1),u=k.useRef(n);k.useEffect(()=>{i.current&&r&&n&&(l(!0),i.current=!1)},[r,n]),k.useEffect(()=>{u.current&&!n&&!a&&l(!1),u.current=n},[n,a]);const c=()=>{!t&&!n||(l(!s),o(!0))},d=(m=e.summary)==null?void 0:m.replace(/^(command|path|args|query|input):\s*/i,"");return h.jsxs(Wt,{children:[h.jsx(Gt,{card:e,icon:Na,expanded:s,canExpand:!!t||n,onToggle:c}),s&&h.jsxs(h.Fragment,{children:[h.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:h.jsxs("div",{className:"flex items-start gap-2 leading-relaxed",children:[h.jsx("span",{className:"text-amber-500/50 font-medium shrink-0 select-none mt-[1px]",children:"$"}),h.jsx("div",{className:"flex-1 min-w-0",children:d?h.jsxs("div",{className:"text-amber-950/80 break-words whitespace-pre-wrap tracking-tight font-medium inline-block",children:[d,n&&!t&&h.jsx("span",{className:"inline-block w-1.5 h-3 ml-1 bg-amber-500/60 animate-pulse align-middle"})]}):h.jsx("div",{className:"h-3 w-32 bg-amber-200/30 rounded animate-pulse mt-2"})})]})}),t&&h.jsx(Qt,{children:h.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&&h.jsx("span",{className:"inline-block w-1.5 h-3 ml-1 bg-amber-500/60 animate-pulse align-middle"})]})})]})]})}function px({card:e}){var y;const t=((y=e.output)==null?void 0:y.trim())??"",n=e.statusTone==="running",[r,i]=k.useState(!1),[s,l]=k.useState(!1),a=k.useRef(n);k.useEffect(()=>{a.current&&!n&&!s&&i(!1),a.current=n},[n,s]);const o=()=>{!t&&!n||(i(!r),l(!0))},u=e.toolName==="edit_file"||e.toolName==="write_file",c=(S,g)=>{if(u){if(S.startsWith("+")&&!S.startsWith("+++"))return h.jsxs("div",{className:"bg-emerald-500/10 text-emerald-700 px-2 py-0.5 w-full break-all whitespace-pre-wrap",children:[h.jsx("span",{className:"select-none opacity-40 mr-2 w-3 inline-block shrink-0",children:"+"}),h.jsx("span",{children:S.slice(1)})]},g);if(S.startsWith("-")&&!S.startsWith("---"))return h.jsxs("div",{className:"bg-rose-500/10 text-rose-700 px-2 py-0.5 w-full break-all whitespace-pre-wrap",children:[h.jsx("span",{className:"select-none opacity-40 mr-2 w-3 inline-block shrink-0",children:"-"}),h.jsx("span",{className:"line-through decoration-rose-400/50",children:S.slice(1)})]},g)}return h.jsx("div",{className:"py-0.5 text-amber-950/80 w-full break-all whitespace-pre-wrap",children:h.jsx("span",{children:S})},g)},d=t.split(`
|
|
36
|
+
`),p=15,f=d.length>p,m=!r&&f?d.slice(0,p):d;return h.jsxs(Wt,{children:[h.jsx(Gt,{card:e,icon:u?Ea:La,expanded:r,canExpand:!!t||n,onToggle:o}),r&&t&&h.jsx(Qt,{children:h.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(c)})})]})}function mx({card:e}){var u;const t=e.statusTone==="running",[n,r]=k.useState(t),[i,s]=k.useState(!1),l=k.useRef(t),a=((u=e.output)==null?void 0:u.trim())??"";k.useEffect(()=>{l.current&&!t&&!i&&r(!1),l.current=t},[t,i]);const o=()=>{!a&&!t||(r(!n),s(!0))};return h.jsxs(Wt,{children:[h.jsx(Gt,{card:e,icon:Hn,expanded:n,canExpand:!!a||t,onToggle:o}),n&&a&&h.jsx(Qt,{children:h.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:a})})]})}function gx({card:e}){var c;const t=((c=e.output)==null?void 0:c.trim())??"",n=e.statusTone==="running",[r,i]=k.useState(n),[s,l]=k.useState(!1),a=k.useRef(n),o=e.kind==="result"||e.hasResult;k.useEffect(()=>{a.current&&!n&&!s&&i(!1),a.current=n},[n,s]);const u=()=>{o&&(i(!r),l(!0))};return h.jsxs(Wt,{children:[h.jsx(Gt,{card:e,icon:Aa,expanded:r,canExpand:o,onToggle:u}),r&&t&&h.jsx(Qt,{children:h.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 xx(e){const t=e.toLowerCase();return t==="exec"||t==="execute_command"||t==="bash"||t==="shell"||t.includes("run_")}function yx(e){const t=e.toLowerCase();return t==="read_file"||t==="write_file"||t==="edit_file"||t==="apply_patch"}function bx(e){const t=e.toLowerCase();return t==="grep_search"||t==="find_files"||t.includes("search")}function Sx({card:e}){return xx(e.toolName)?h.jsx(fx,{card:e}):yx(e.toolName)?h.jsx(px,{card:e}):bx(e.toolName)?h.jsx(mx,{card:e}):h.jsx(gx,{card:e})}function kx(e){return h.jsxs("div",{className:"rounded-lg border border-gray-200 bg-gray-50 px-2.5 py-2 text-xs text-gray-600",children:[h.jsxs("div",{className:"font-semibold text-gray-700",children:[e.label,": ",e.rawType]}),e.text?h.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-[11px] text-gray-500",children:e.text}):null]})}const wx=k.memo(function(t){const{message:n,texts:r}=t,{role:i}=n,s=i==="user";return h.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:h.jsx("div",{className:"space-y-2",children:n.parts.map((l,a)=>l.type==="markdown"?h.jsx(ex,{text:l.text,role:i,texts:r},`markdown-${a}`):l.type==="reasoning"?h.jsx(dx,{label:l.label,text:l.text,isUser:s},`reasoning-${a}`):l.type==="tool-card"?h.jsx("div",{className:"mt-0.5",children:h.jsx(Sx,{card:l.card})},`tool-${a}`):l.type==="file"?h.jsx(cx,{file:l.file,isUser:s},`file-${a}`):l.type==="unknown"?h.jsx(kx,{label:l.label,rawType:l.rawType,text:l.text},`unknown-${a}`):null)})})});function Cx(e){return h.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 vx=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function Tx(e){const t=e.trim();return t?t.replace(vx,"").trim().length>0:!1}function Ix(e){return e.parts.some(t=>t.type==="markdown"||t.type==="reasoning"?Tx(t.text):!0)}function Mx(e){const t=e.messages.filter(Ix),n=t.some(r=>r.role==="assistant"&&(r.status==="streaming"||r.status==="pending"));return h.jsxs("div",{className:q("space-y-5",e.className),children:[t.map(r=>{const i=r.role==="user";return h.jsxs("div",{className:q("flex gap-3",i?"justify-end":"justify-start"),children:[i?null:h.jsx(tn,{role:r.role}),h.jsxs("div",{className:q("w-fit max-w-[92%] space-y-2",i&&"flex flex-col items-end"),children:[h.jsx(wx,{message:r,texts:e.texts}),h.jsx(Cx,{roleLabel:r.roleLabel,timestampLabel:r.timestampLabel,isUser:i})]}),i?h.jsx(tn,{role:r.role}):null]},r.id)}),e.isSending&&!n?h.jsxs("div",{className:"flex justify-start gap-3",children:[h.jsx(tn,{role:"assistant"}),h.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 Nx=10;function Ex(e){e.scrollTop=e.scrollHeight}function ji(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,Ex(n))}))}function Lx(e){const t=k.useRef(!0),n=k.useRef(!1),r=k.useRef(null),i=k.useRef(!1),s=k.useRef(null),l=()=>{if(n.current){n.current=!1;return}const a=e.scrollRef.current;if(!a)return;const o=a.scrollHeight-a.scrollTop-a.clientHeight;t.current=o<=(e.stickyThresholdPx??Nx)};return k.useEffect(()=>{r.current!==e.resetKey&&(r.current=e.resetKey,t.current=!0,i.current=!0)},[e.resetKey]),k.useEffect(()=>{const a=s.current;return()=>{a!==null&&cancelAnimationFrame(a)}},[]),k.useLayoutEffect(()=>{!i.current||e.isLoading||!e.hasContent||!e.scrollRef.current||(i.current=!1,ji({scrollRef:e.scrollRef,scheduledScrollFrameRef:s,isProgrammaticScrollRef:n}))},[e.hasContent,e.isLoading,e.scrollRef]),k.useLayoutEffect(()=>{!t.current||!e.hasContent||!e.scrollRef.current||ji({scrollRef:e.scrollRef,scheduledScrollFrameRef:s,isProgrammaticScrollRef:n})},[e.contentVersion,e.hasContent,e.scrollRef]),{onScroll:l}}function Vl(){return Gn()}function Ax(e){return Gu(e)}function Pi(e){return Yu(e)}function Di(e){return Vt(e,"skill")}function Rx(e){return Vt(e,"file")}function jx(e,t,n){const r=new Set(t),i=Xn(e,o=>o.tokenKind==="skill"&&!r.has(o.tokenKey)),s=Vt(i,"skill"),l=new Map(n.map(o=>[o.spec,o])),a=t.filter(o=>!s.includes(o)).map(o=>{var u;return Qn({tokenKind:"skill",tokenKey:o,label:((u=l.get(o))==null?void 0:u.label)||o})});return a.length===0?i:Ge([...i,...a])}function Fi(e,t){const n=new Set(t.map(r=>r.id));return Xn(e,r=>r.tokenKind==="file"&&!n.has(r.tokenKey))}function Px(e,t){const n=new Set(Rx(e));return t.filter(r=>n.has(r.id))}function Dx(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 Fx={isProviderStateResolved:!1,composerNodes:Vl(),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:[]},J=Bn(e=>({snapshot:Fx,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))}));function Ox(e){const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,s=[],l=[],a=[],o=[];for(const c of e){const{session:d}=c,p=new Date(d.updatedAt).getTime();p>=n?s.push(c):p>=r?l.push(c):p>=i?a.push(c):o.push(c)}const u=[];return s.length>0&&u.push({label:T("chatSidebarToday"),items:s}),l.length>0&&u.push({label:T("chatSidebarYesterday"),items:l}),a.length>0&&u.push({label:T("chatSidebarPrevious7Days"),items:a}),o.length>0&&u.push({label:T("chatSidebarOlder"),items:o}),u}function zx(e){if(e.label&&e.label.trim())return e.label.trim();const t=e.key.split(":");return t[t.length-1]||e.key}function _x(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 Bx(e){var t;return e.ready===!1?((t=e.reasonMessage)==null?void 0:t.trim())||T("statusSetup"):T("statusReady")}const Vx=[{target:"/cron",label:()=>T("chatSidebarScheduledTasks"),icon:Un},{target:"/skills",label:()=>T("chatSidebarSkills"),icon:Vn}];function Hx(){var H,A;const e=Wn(),t=Wa(),[n,r]=k.useState(!1),[i,s]=k.useState(null),[l,a]=k.useState(""),[o,u]=k.useState(null),c=J(C=>C.snapshot),d=fe(C=>C.snapshot),p=Qa(C=>C.connectionStatus),{isLoading:f,items:m}=wu(),{language:y,setLanguage:S}=Kn(),{theme:g,setTheme:I}=Ga(),N=bu(),D=T(((H=br.find(C=>C.value===g))==null?void 0:H.labelKey)??"themeWarm"),F=((A=Sr.find(C=>C.value===y))==null?void 0:A.label)??y,v=k.useMemo(()=>Ox(m),[m]),O=c.defaultSessionType||"native",_=k.useMemo(()=>c.sessionTypeOptions.filter(C=>C.value!==O),[O,c.sessionTypeOptions]),B=C=>{y!==C&&(S(C),window.location.reload())},w=C=>{var P;s(C.key),a(((P=C.label)==null?void 0:P.trim())??"")},j=()=>{s(null),a(""),u(null)},L=async C=>{var $;const P=l.trim(),Q=(($=C.label)==null?void 0:$.trim())??"";if(P===Q){j();return}u(C.key);try{await N({sessionKey:C.key,label:P||null}),j()}catch{u(null)}};return h.jsxs("aside",{className:"w-[280px] shrink-0 flex flex-col h-full bg-secondary border-r border-gray-200/60",children:[h.jsx("div",{className:"px-5 pt-5 pb-3",children:h.jsx(Xa,{className:"flex items-center gap-2.5 min-w-0",suffix:h.jsx(xu,{status:p})})}),h.jsx("div",{className:"px-4 pb-3",children:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(je,{variant:"primary",className:ve("min-w-0 rounded-xl",_.length>0?"flex-1 rounded-r-md":"w-full"),onClick:()=>{r(!1),e.chatSessionListManager.createSession(O)},children:[h.jsx(Ra,{className:"h-4 w-4 mr-2"}),T("chatSidebarNewTask")]}),_.length>0?h.jsxs(Lo,{open:n,onOpenChange:r,children:[h.jsx(Ao,{asChild:!0,children:h.jsx(je,{variant:"primary",size:"icon",className:"h-9 w-10 shrink-0 rounded-xl rounded-l-md","aria-label":T("chatSessionTypeLabel"),children:h.jsx(_t,{className:"h-4 w-4"})})}),h.jsxs(Ro,{align:"end",className:"w-64 p-2",children:[h.jsx("div",{className:"px-2 py-1 text-[11px] font-medium uppercase tracking-wider text-gray-400",children:T("chatSessionTypeLabel")}),h.jsx("div",{className:"mt-1 space-y-1",children:_.map(C=>h.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:[h.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h.jsx("div",{className:"text-[13px] font-medium text-gray-900",children:C.label}),h.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?T("statusSetup"):T("statusReady")})]}),h.jsx("div",{className:"mt-0.5 text-[11px] text-gray-500",children:Bx(C)})]},C.value))})]})]}):null]})}),h.jsx("div",{className:"px-4 pb-3",children:h.jsxs("div",{className:"relative",children:[h.jsx(Hn,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),h.jsx($n,{value:d.query,onChange:C=>e.chatSessionListManager.setQuery(C.target.value),placeholder:T("chatSidebarSearchPlaceholder"),className:"pl-8 h-9 rounded-lg text-xs"})]})}),h.jsx("div",{className:"px-3 pb-2",children:h.jsx("ul",{className:"space-y-0.5",children:Vx.map(C=>h.jsx("li",{children:h.jsx(kr,{to:C.target,label:C.label(),icon:C.icon,density:"compact"})},C.target))})}),h.jsx("div",{className:"mx-4 border-t border-gray-200/60"}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2",children:f?h.jsx("div",{className:"text-xs text-gray-500 p-3",children:T("sessionsLoading")}):v.length===0?h.jsxs("div",{className:"p-4 text-center",children:[h.jsx(ja,{className:"h-6 w-6 mx-auto mb-2 text-gray-300"}),h.jsx("div",{className:"text-xs text-gray-500",children:T("sessionsEmpty")})]}):h.jsx("div",{className:"space-y-3",children:v.map(C=>h.jsxs("div",{children:[h.jsx("div",{className:"px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider",children:C.label}),h.jsx("div",{className:"space-y-0.5",children:C.items.map(({session:P,runStatus:Q})=>{const $=d.selectedSessionKey===P.key,se=_x(P.sessionType,c.sessionTypeOptions),x=i===P.key,le=o===P.key;return h.jsx(yu,{session:P,active:$,runStatus:Q,sessionTypeLabel:se,title:zx(P),isEditing:x,draftLabel:l,isSaving:le,onSelect:()=>e.chatSessionListManager.selectSession(P.key),onStartEditing:()=>w(P),onDraftLabelChange:a,onSave:()=>L(P),onCancel:j},P.key)})})]},C.label))})}),h.jsxs("div",{className:"px-3 py-3 border-t border-gray-200/60 space-y-0.5",children:[h.jsx(kr,{to:"/settings",label:T("settings"),icon:Pa,density:"compact"}),h.jsx(Ya,{onClick:()=>t.open(void 0,{kind:"docs",newTab:!0,title:"Docs"}),icon:Da,label:T("docBrowserHelp"),density:"compact"}),h.jsx(wr,{value:g,onValueChange:C=>I(C),icon:Fa,label:T("theme"),valueLabel:D,density:"compact",children:br.map(C=>h.jsx(ut,{value:C.value,className:"text-xs",children:T(C.labelKey)},C.value))}),h.jsx(wr,{value:y,onValueChange:C=>B(C),icon:Oa,label:T("language"),valueLabel:F,density:"compact",children:Sr.map(C=>h.jsx(ut,{value:C.value,className:"text-xs",children:C.label},C.value))})]})]})}function Ux(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 $x(e){const t=new FormData;for(const i of e)t.append("files",i);const n=await fetch(`${is}/api/ncp/assets`,{method:"POST",body:t,credentials:"include"}),r=await n.json();if(!n.ok||!r.ok)throw new Error(Ux(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 Nt(e){const t=e.modelLabel.trim(),n=e.providerLabel.trim();return n?`${n}/${t}`:t}function Et(e){return(e??"").trim().toLowerCase()}function Oi(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 Kx(e,t){const n=Et(t);if(!n)return Me.fallback;const r=Et(e.key),i=Et(e.label||e.key),s=Et(`${e.descriptionZh??""} ${e.description??""}`),l=i.split(/[\s/_-]+/).filter(Boolean);return r===n?Me.exactSpec:i===n?Me.exactLabel:r.startsWith(n)?Me.prefixSpec:i.startsWith(n)?Me.prefixLabel:l.some(a=>a.startsWith(n))?Me.prefixToken:r.includes(n)?Me.containsSpec:i.includes(n)?Me.containsLabel:s.includes(n)?Me.containsDescription:Oi(n,i)||Oi(n,r)?Me.subsequence:0}function qx(e,t,n){const r=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0});return e.map((i,s)=>({record:i,order:s,score:Kx(i,t)})).filter(i=>i.score>0).sort((i,s)=>{if(s.score!==i.score)return s.score-i.score;const l=(i.record.label||i.record.key).trim(),a=(s.record.label||s.record.key).trim(),o=r.compare(l,a);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 Wx(e){return e.map(t=>({key:t.key,label:t.label,description:t.descriptionZh||t.description||"",badgeLabel:t.badgeLabel}))}function Qx(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:Wx(e.skillRecords),selectedKeys:e.selectedSkills,onSelectedKeysChange:e.onSelectedKeysChange}}function Gx(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 Xx(e){const t=e.modelOptions.find(c=>c.value===e.selectedModel),n=e.modelOptions[0],r=t??n,i=e.hasModelOptions?r==null?void 0:r.value:void 0,s=new Set(e.recentModelValues??[]),l=new Map(e.modelOptions.map(c=>[c.value,c])),a=(e.recentModelValues??[]).map(c=>l.get(c)).filter(c=>!!c),o=e.modelOptions.filter(c=>!s.has(c.value)),u=a.length>0?[{key:"recent-models",label:e.texts.recentModelsLabel,options:a.map(c=>({value:c.value,label:Nt(c)}))},{key:"all-models",label:e.texts.allModelsLabel,options:o.map(c=>({value:c.value,label:Nt(c)}))}].filter(c=>c.options.length>0):void 0;return{key:"model",value:i,placeholder:e.texts.modelSelectPlaceholder,selectedLabel:r?Nt(r):void 0,icon:"sparkles",options:e.modelOptions.map(c=>({value:c.value,label:Nt(c)})),groups:u,disabled:!e.hasModelOptions,loading:e.isModelOptionsLoading,emptyLabel:e.texts.modelNoOptionsLabel,onValueChange:e.onValueChange}}function Yx(e){const t=[];for(const n of["off",...e])t.includes(n)||t.push(n);return t}function Jx(e){if(e.supportedLevels.length===0)return null;const t=Yx(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)}}class Zx{constructor(t){this.options=t}read(){const t=this.getStorage();if(!t)return[];try{return this.normalizeList(JSON.parse(t.getItem(this.options.storageKey)??"[]"))}catch{return[]}}remember(t){const n=this.normalizeValue(t);if(!n)return this.read();const r=[n,...this.read().filter(i=>i!==n)].slice(0,this.options.limit);return this.write(r),r}resolveVisible(t){const n=this.normalizeList(t.availableValues,Number.POSITIVE_INFINITY);if(n.length<=t.minAvailableCount)return[];const r=new Set(n),i=[],s=Math.max(1,t.limit??this.options.limit);for(const l of this.read())if(!(!r.has(l)||i.includes(l))&&(i.push(l),i.length>=s))break;return i}write(t){const n=this.getStorage();if(n)try{n.setItem(this.options.storageKey,JSON.stringify(this.normalizeList(t)))}catch{}}getStorage(){return Object.prototype.hasOwnProperty.call(this.options,"storage")?this.options.storage??null:typeof window>"u"?null:window.localStorage}normalizeList(t,n=this.options.limit){if(!Array.isArray(t))return[];const r=[];for(const i of t){const s=this.normalizeValue(i);if(!(!s||r.includes(s))&&(r.push(s),r.length>=n))break}return r}normalizeValue(t){if(typeof t!="string")return null;const n=t.trim();return n.length>0?n:null}}const Hl=new Zx({storageKey:"nextclaw.chat.recent-models",limit:3}),ey=5;function ty(){return{off:T("chatThinkingLevelOff"),minimal:T("chatThinkingLevelMinimal"),low:T("chatThinkingLevelLow"),medium:T("chatThinkingLevelMedium"),high:T("chatThinkingLevelHigh"),adaptive:T("chatThinkingLevelAdaptive"),xhigh:T("chatThinkingLevelXhigh")}}function ny(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 ry(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 iy(){var H;const e=Wn(),{language:t}=Kn(),n=J(A=>A.snapshot),[r,i]=k.useState(null),s=k.useRef(null),l=k.useRef(null),a=k.useMemo(()=>T("chatSkillsPickerOfficial"),[t]),o=k.useMemo(()=>({slashSkillSubtitle:T("chatSlashTypeSkill"),slashSkillSpecLabel:T("chatSlashSkillSpec"),noSkillDescription:T("chatSkillsPickerNoDescription")}),[t]),u=k.useMemo(()=>ny(n.skillRecords,a),[n.skillRecords,a]),c=k.useMemo(()=>ry(n.modelOptions),[n.modelOptions]),d=Hl.resolveVisible({availableValues:c.map(A=>A.value),minAvailableCount:ey}),p=c.length>0,f=!n.isProviderStateResolved&&!p,m=n.isProviderStateResolved&&!p,y=(f||m)&&!n.isSending||n.sessionTypeUnavailable,S=typeof e.chatInputManager.addAttachments=="function",g=f?"":p?T("chatInputPlaceholder"):T("chatModelNoOptions"),I=t==="zh"?"最近选择":"Recent",N=t==="zh"?"全部模型":"All models",D=k.useMemo(()=>qx(u,r??"",o),[r,u,o]),F=c.find(A=>A.value===n.selectedModel),v=F==null?void 0:F.thinkingCapability,O=(v==null?void 0:v.supported)??[],_=n.stopDisabledReason==="__preparing__"?T("chatStopPreparing"):((H=n.stopDisabledReason)==null?void 0:H.trim())||T("chatStopUnavailable"),B=k.useCallback(A=>{if(A==="unsupported-type"){ot.error(T("chatInputAttachmentUnsupported"));return}if(A==="too-large"){ot.error(T("chatInputAttachmentTooLarge").replace("{maxMb}",String(ps/(1024*1024))));return}ot.error(T("chatInputAttachmentReadFailed"))},[]),w=k.useCallback(async A=>{var P,Q,$;if(!S||A.length===0)return;const C=await mu(A,{uploadBatch:$x});if(C.attachments.length>0){const se=((Q=(P=e.chatInputManager).addAttachments)==null?void 0:Q.call(P,C.attachments))??[];se.length>0&&(($=s.current)==null||$.insertFileTokens(se.map(x=>({tokenKey:x.id,label:x.name}))))}C.rejected.length>0&&B(C.rejected[0].reason)},[S,e.chatInputManager,B]),j=[Xx({modelOptions:c,recentModelValues:d,selectedModel:n.selectedModel,isModelOptionsLoading:f,hasModelOptions:p,onValueChange:e.chatInputManager.selectModel,texts:{modelSelectPlaceholder:T("chatSelectModel"),modelNoOptionsLabel:T("chatModelNoOptions"),recentModelsLabel:I,allModelsLabel:N}}),Jx({supportedLevels:O,selectedThinkingLevel:n.selectedThinkingLevel,defaultThinkingLevel:(v==null?void 0:v.default)??null,onValueChange:A=>e.chatInputManager.selectThinkingLevel(A),texts:{thinkingLabels:ty()}})].filter(A=>A!==null),L=Qx({skillRecords:u,selectedSkills:n.selectedSkills,isLoading:n.isSkillsLoading,onSelectedKeysChange:e.chatInputManager.selectSkills,texts:{title:T("chatSkillsPickerTitle"),searchPlaceholder:T("chatSkillsPickerSearchPlaceholder"),emptyLabel:T("chatSkillsPickerEmpty"),loadingLabel:T("sessionsLoading"),manageLabel:T("chatSkillsPickerManage")}});return h.jsxs(h.Fragment,{children:[h.jsx(Ps,{ref:s,composer:{nodes:n.composerNodes,placeholder:g,disabled:y,onNodesChange:e.chatInputManager.setComposerNodes,...S?{onFilesAdd:w}:{},onSlashQueryChange:i},slashMenu:{isLoading:n.isSkillsLoading,items:D,texts:{slashLoadingLabel:T("chatSlashLoading"),slashSectionLabel:T("chatSlashSectionSkills"),slashEmptyLabel:T("chatSlashNoResult"),slashHintLabel:T("chatSlashHint"),slashSkillHintLabel:T("chatSlashSkillHint")}},hint:Gx({isModelOptionsLoading:f,isModelOptionsEmpty:m,onGoToProviders:e.chatInputManager.goToProviders,texts:{noModelOptionsLabel:T("chatModelNoOptions"),configureProviderLabel:T("chatGoConfigureProvider")}}),toolbar:{selects:j,accessories:[{key:"attach",label:T("chatInputAttach"),icon:"paperclip",iconOnly:!0,disabled:!S||y||n.isSending,...S?{onClick:()=>{var A;return(A=l.current)==null?void 0:A.click()}}:{tooltip:T("chatInputAttachComingSoon")}}],skillPicker:L,actions:{sendError:n.sendError,isSending:n.isSending,canStopGeneration:n.canStopGeneration,sendDisabled:n.draft.trim().length===0&&n.attachments.length===0||!p||n.sessionTypeUnavailable,stopDisabled:!n.canStopGeneration,stopHint:_,sendButtonLabel:T("chatSend"),stopButtonLabel:T("chatStop"),onSend:e.chatInputManager.send,onStop:e.chatInputManager.stop}}}),S?h.jsx("input",{ref:l,type:"file",multiple:!0,className:"hidden",onChange:async A=>{const C=Array.from(A.target.files??[]);A.currentTarget.value="",await w(C)}}):null]})}const sy=["cmd","command","query","q","path","url","to","channel","agentId","sessionKey"];function zi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function zn(e,t=2400){return e.length<=t?e:`${e.slice(0,t)}
|
|
37
|
+
…`}function gt(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(e==null)return"";try{return zn(JSON.stringify(e,null,2))}catch{return String(e)}}function ly(e){if(zi(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 zi(n)?n:null}catch{return null}}function jt(e){const t=ly(e);if(!t){const r=gt(e).trim();return r?zn(r,120):void 0}const n=[];for(const r of sy){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(" · "):zn(gt(t),140)}function ay(e){return typeof e=="object"&&e!==null}function Lt(e){if(typeof e!="string")return null;const t=e.trim();return t.length>0?t:null}function oy(e){return ay(e)&&(e.kind==="nextclaw.subagent_run"||typeof e.runId=="string"&&typeof e.status=="string")?e:null}function uy(e){var s,l,a;if(e.invocation.toolName!=="spawn")return null;const t=oy(e.invocation.result);if(!t)return null;const n=[Lt(t.label)?`label: ${(s=t.label)==null?void 0:s.trim()}`:null,Lt(t.task)?`task: ${(l=t.task)==null?void 0:l.trim()}`:null].filter(o=>!!o),r=(a=Lt(t.status))==null?void 0:a.toLowerCase(),i=(typeof t.result<"u"?gt(t.result).trim():"")||Lt(t.message)||void 0;return r==="failed"?{kind:"result",name:e.invocation.toolName,detail:n.join(" · ")||jt(e.invocation.args),text:i,callId:e.invocation.toolCallId||void 0,hasResult:!!i,statusTone:"error",statusLabel:e.texts.toolStatusFailedLabel}:r==="completed"?{kind:"result",name:e.invocation.toolName,detail:n.join(" · ")||jt(e.invocation.args),text:i,callId:e.invocation.toolCallId||void 0,hasResult:!!i,statusTone:"success",statusLabel:e.texts.toolStatusCompletedLabel}:{kind:"result",name:e.invocation.toolName,detail:n.join(" · ")||jt(e.invocation.args),text:i,callId:e.invocation.toolCallId||void 0,hasResult:!!i,statusTone:"running",statusLabel:e.texts.toolStatusRunningLabel}}const cy=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function Pt(e){return typeof e=="object"&&e!==null}function wn(e){if(typeof e!="string")return null;const t=e.trim();return t.length>0?t:null}function Ul(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 dy(e,t){if(!Pt(e))return null;const n=Pt(e.asset)?e.asset:Array.isArray(e.assets)&&e.assets.length>0&&Pt(e.assets[0])?e.assets[0]:null;if(!n)return null;const r=wn(n.url),i=wn(n.mimeType)??"application/octet-stream",s=Ul(n.sizeBytes);return r?{type:"file",file:{label:wn(n.name)??(i.startsWith("image/")?t.imageAttachmentLabel:t.fileAttachmentLabel),mimeType:i,dataUrl:r,...s!=null?{sizeBytes:s}:{},isImage:i.startsWith("image/")}}:null}function hy(e){return e.type==="text"&&typeof e.text=="string"}function fy(e){return e.type==="reasoning"&&typeof e.reasoning=="string"}function py(e){return e.type==="file"&&typeof e.mimeType=="string"&&typeof e.data=="string"}function my(e){return e.type!=="tool-invocation"||!Pt(e.toolInvocation)?!1:typeof e.toolInvocation.toolName=="string"}function gy(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 xy(e,t){return e==="user"?t.user:e==="assistant"?t.assistant:e==="tool"?t.tool:e==="system"?t.system:t.fallback}function yy(e){return e==="user"||e==="assistant"||e==="tool"||e==="system"?e:"message"}function _i(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 by(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 Bi(e){const t=e.trim();return t&&t.replace(cy,"").trim()?t:null}function Sy(e,t){var n;return{id:e.id,role:yy(e.role),roleLabel:xy(e.role,t.texts.roleLabels),timestampLabel:t.formatTimestamp(gy(e)),status:(n=e.meta)==null?void 0:n.status,parts:e.parts.map(r=>{if(hy(r)){const i=Bi(r.text);return i?{type:"markdown",text:i}:null}if(fy(r)){const i=Bi(r.reasoning);return i?{type:"reasoning",text:i,label:t.texts.reasoningLabel}:null}if(py(r)){const i=r.mimeType.startsWith("image/"),s=Ul(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(my(r)){const i=r.toolInvocation,s=dy(i.result,t.texts);if(s)return s;const l=uy({invocation:i,texts:t.texts});if(l)return{type:"tool-card",card:_i(l,t.texts)};const a=by({status:i.status,error:i.error,cancelled:i.cancelled,result:i.result,texts:t.texts}),o=jt(i.parsedArgs??i.args),u=typeof i.error=="string"&&i.error.trim()?i.error.trim():i.result!=null?gt(i.result).trim():"",c={kind:a.kind,name:i.toolName,detail:o,text:u||void 0,callId:i.toolCallId||void 0,hasResult:a.hasResult,statusTone:a.statusTone,statusLabel:a.statusLabel};return{type:"tool-card",card:_i(c,t.texts)}}return{type:"unknown",label:t.texts.unknownPartLabel,rawType:typeof r.type=="string"?r.type:"unknown",text:gt(r)}}).filter(r=>r!==null)}}const Vi=new WeakMap;function ky(e){return{roleLabels:{user:T("chatRoleUser"),assistant:T("chatRoleAssistant"),tool:T("chatRoleTool"),system:T("chatRoleSystem"),fallback:T("chatRoleMessage")},reasoningLabel:T("chatReasoning"),toolCallLabel:T("chatToolCall"),toolResultLabel:T("chatToolResult"),toolNoOutputLabel:T("chatToolNoOutput"),toolOutputLabel:T("chatToolOutput"),toolStatusPreparingLabel:T("chatToolStatusPreparing"),toolStatusRunningLabel:T("chatToolStatusRunning"),toolStatusCompletedLabel:T("chatToolStatusCompleted"),toolStatusFailedLabel:T("chatToolStatusFailed"),toolStatusCancelledLabel:T("chatToolStatusCancelled"),imageAttachmentLabel:T("chatImageAttachment"),fileAttachmentLabel:T("chatFileAttachment"),unknownPartLabel:T("chatUnknownPart")}}function wy(e){return{copyCodeLabel:T("chatCodeCopy"),copiedCodeLabel:T("chatCodeCopied"),typingLabel:T("chatTyping")}}function Cy(e){const{language:t}=Kn(),n=k.useMemo(()=>ky(),[t]),r=k.useMemo(()=>e.messages.map(l=>{var d,p;const a=Vi.get(l);if(a&&a.language===t)return a.viewModel;const o=Po(l),u={id:o.id,role:o.role,meta:{timestamp:(d=o.meta)==null?void 0:d.timestamp,status:(p=o.meta)==null?void 0:p.status},parts:o.parts},c=Sy(u,{formatTimestamp:f=>Bt(f,t),texts:n});return Vi.set(l,{language:t,viewModel:c}),c}),[t,e.messages,n]),i=k.useMemo(()=>r.some(l=>l.role==="assistant"&&(l.status==="streaming"||l.status==="pending")),[r]),s=k.useMemo(()=>wy(),[t]);return h.jsx(Mx,{messages:r,isSending:e.isSending,hasAssistantDraft:i,className:e.className,texts:s})}const vy=[{icon:za,titleKey:"chatWelcomeCapability1Title",descKey:"chatWelcomeCapability1Desc"},{icon:Vn,titleKey:"chatWelcomeCapability2Title",descKey:"chatWelcomeCapability2Desc"},{icon:Un,titleKey:"chatWelcomeCapability3Title",descKey:"chatWelcomeCapability3Desc"}];function Ty({onCreateSession:e}){return h.jsx("div",{className:"h-full flex items-center justify-center p-8",children:h.jsxs("div",{className:"max-w-lg w-full text-center",children:[h.jsx("div",{className:"mx-auto mb-6 h-16 w-16 rounded-2xl bg-primary/10 flex items-center justify-center",children:h.jsx(Zi,{className:"h-8 w-8 text-primary"})}),h.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-2",children:T("chatWelcomeTitle")}),h.jsx("p",{className:"text-sm text-gray-500 mb-8",children:T("chatWelcomeSubtitle")}),h.jsx("div",{className:"grid grid-cols-3 gap-3",children:vy.map(t=>{const n=t.icon;return h.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:[h.jsx("div",{className:"h-9 w-9 rounded-xl bg-primary/8 flex items-center justify-center mb-3",children:h.jsx(n,{className:"h-4.5 w-4.5 text-primary"})}),h.jsx("div",{className:"text-sm font-semibold text-gray-900 mb-1",children:T(t.titleKey)}),h.jsx("div",{className:"text-[11px] text-gray-500 leading-relaxed",children:T(t.descKey)})]},t.titleKey)})})]})})}const Iy={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},at=Bn(e=>({snapshot:Iy,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))}));function My(){return h.jsxs("section",{className:"flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white",children:[h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:h.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5",children:h.jsxs("div",{className:"space-y-4",children:[h.jsx("div",{className:"h-6 w-48 animate-pulse rounded bg-gray-200"}),h.jsx("div",{className:"h-24 w-[78%] animate-pulse rounded-2xl bg-gray-200/80"}),h.jsx("div",{className:"h-20 w-[62%] animate-pulse rounded-2xl bg-gray-200/80"}),h.jsx("div",{className:"h-28 w-[84%] animate-pulse rounded-2xl bg-gray-200/80"})]})})}),h.jsx("div",{className:"border-t border-gray-200/80 bg-white p-4",children:h.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)]",children:h.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white shadow-card p-4",children:[h.jsx("div",{className:"h-16 w-full animate-pulse rounded-xl bg-gray-200/80"}),h.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[h.jsx("div",{className:"h-8 w-36 animate-pulse rounded-lg bg-gray-200/80"}),h.jsx("div",{className:"h-8 w-20 animate-pulse rounded-lg bg-gray-200/80"})]})]})})})]})}function Ny(){var d;const e=Wn(),t=at(p=>p.snapshot),n=k.useRef(null),r=t.threadRef??n,i=!!(t.selectedSessionKey||t.sessionTypeLabel),s=t.sessionDisplayName||t.selectedSessionKey||T("chatSidebarNewTask"),l=!t.selectedSessionKey&&t.messages.length===0&&!t.isSending,a=t.modelOptions.length>0,o=t.isProviderStateResolved&&!a,u=t.isHistoryLoading&&t.messages.length===0&&!t.isSending&&!t.isAwaitingAssistantOutput,{onScroll:c}=Lx({scrollRef:r,resetKey:t.selectedSessionKey,isLoading:t.isHistoryLoading,hasContent:t.messages.length>0,contentVersion:t.messages[t.messages.length-1]??null});return t.isProviderStateResolved?h.jsxs("section",{className:"flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white",children:[h.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:[h.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[h.jsx("span",{className:"text-sm font-medium text-gray-700 truncate",children:s}),t.sessionTypeLabel?h.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?h.jsx(je,{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:h.jsx(ts,{className:"h-4 w-4"})}):null]}),o&&h.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:[h.jsx("span",{className:"text-xs text-amber-800",children:T("chatModelNoOptions")}),h.jsx("button",{type:"button",onClick:e.chatThreadManager.goToProviders,className:"text-xs font-semibold text-amber-900 underline-offset-2 hover:underline",children:T("chatGoConfigureProvider")})]}),t.sessionTypeUnavailable&&((d=t.sessionTypeUnavailableMessage)==null?void 0:d.trim())&&h.jsx("div",{className:"px-5 py-2.5 border-b border-amber-200/70 bg-amber-50/70 shrink-0",children:h.jsx("span",{className:"text-xs text-amber-800",children:t.sessionTypeUnavailableMessage})}),h.jsx("div",{ref:r,onScroll:c,className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:l?h.jsx(Ty,{onCreateSession:e.chatThreadManager.createSession}):u?h.jsx("div",{className:"h-full"}):t.messages.length===0?h.jsx("div",{className:"px-5 py-5 text-sm text-gray-500",children:T("chatNoMessages")}):h.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5",children:h.jsx(Cy,{messages:t.messages,isSending:t.isSending&&t.isAwaitingAssistantOutput})})}),h.jsx(iy,{})]}):h.jsx(My,{})}function Hi(e){return Bt(e??void 0)}function Ey(e){return typeof e!="number"||!Number.isFinite(e)?"-":Bt(new Date(e))}function Ly(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 Ay(e){const t=e.schedule;return t.kind==="cron"?t.expr?`cron ${t.expr}`:"cron":t.kind==="every"?`every ${Ly(t.everyMs)}`:t.kind==="at"?`at ${Ey(t.atMs)}`:"-"}function Ry(e){if(!e.payload.deliver)return"-";const t=e.payload.channel??"-",n=e.payload.to??"-";return`${t}:${n}`}function jy(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 Py(e,t){return t==="all"?!0:t==="enabled"?e.enabled:!e.enabled}function Dy(){var m;const[e,t]=k.useState(""),[n,r]=k.useState("all"),i=Ja({all:!0}),s=Za(),l=eo(),a=to(),{confirm:o,ConfirmDialog:u}=os(),c=k.useMemo(()=>{var S;return(((S=i.data)==null?void 0:S.jobs)??[]).filter(g=>jy(g,e)).filter(g=>Py(g,n))},[i.data,e,n]),d=async y=>{await o({title:`${T("cronDeleteConfirm")}?`,description:y.name?`${y.name} (${y.id})`:y.id,variant:"destructive",confirmLabel:T("delete")})&&s.mutate({id:y.id})},p=async y=>{const S=!y.enabled;await o({title:S?`${T("cronEnableConfirm")}?`:`${T("cronDisableConfirm")}?`,description:y.name?`${y.name} (${y.id})`:y.id,variant:S?"default":"destructive",confirmLabel:S?T("cronEnable"):T("cronDisable")})&&l.mutate({id:y.id,enabled:S})},f=async y=>{const S=!y.enabled;await o({title:S?`${T("cronRunForceConfirm")}?`:`${T("cronRunConfirm")}?`,description:y.name?`${y.name} (${y.id})`:y.id,confirmLabel:T("cronRunNow")})&&a.mutate({id:y.id,force:S})};return h.jsxs(Fo,{fullHeight:!0,children:[h.jsx(Oo,{title:T("cronPageTitle"),description:T("cronPageDescription"),actions:h.jsx(je,{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:h.jsx(_a,{className:ve("h-4 w-4",i.isFetching&&"animate-spin")})})}),h.jsx("div",{className:"mb-6",children:h.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[h.jsxs("div",{className:"relative flex-1 min-w-[240px]",children:[h.jsx($n,{value:e,onChange:y=>t(y.target.value),placeholder:T("cronSearchPlaceholder"),className:"pl-9"}),h.jsx(Un,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"})]}),h.jsx("div",{className:"min-w-[180px]",children:h.jsxs(no,{value:n,onValueChange:y=>r(y),children:[h.jsx(ro,{className:"w-full",children:h.jsx(io,{placeholder:T("cronStatusLabel")})}),h.jsxs(so,{children:[h.jsx(ut,{value:"all",children:T("cronStatusAll")}),h.jsx(ut,{value:"enabled",children:T("cronStatusEnabled")}),h.jsx(ut,{value:"disabled",children:T("cronStatusDisabled")})]})]})}),h.jsxs("div",{className:"text-xs text-gray-500 ml-auto",children:[T("cronTotalLabel"),": ",((m=i.data)==null?void 0:m.total)??0," / ",c.length]})]})}),h.jsx("div",{className:"flex-1 overflow-auto custom-scrollbar",children:i.isLoading?h.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:T("cronLoading")}):c.length===0?h.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:T("cronEmpty")}):h.jsx("div",{className:"space-y-4",children:c.map(y=>h.jsx(lo,{className:"border border-gray-200",children:h.jsx(ao,{className:"pt-5 pb-5",children:h.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[h.jsxs("div",{className:"min-w-[220px] flex-1",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx("span",{className:"text-sm font-semibold text-gray-900",children:y.name||y.id}),h.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500",children:y.id}),h.jsx("span",{className:ve("text-[10px] font-semibold px-2 py-0.5 rounded-full",y.enabled?"bg-emerald-50 text-emerald-700":"bg-gray-100 text-gray-500"),children:y.enabled?T("enabled"):T("disabled")}),y.deleteAfterRun&&h.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-amber-50 text-amber-700",children:T("cronOneShot")})]}),h.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[T("cronScheduleLabel"),": ",Ay(y)]}),h.jsx("div",{className:"mt-2 text-sm text-gray-700 whitespace-pre-wrap break-words",children:y.payload.message}),h.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[T("cronDeliverTo"),": ",Ry(y)]})]}),h.jsxs("div",{className:"min-w-[220px] text-xs text-gray-500 space-y-2",children:[h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-gray-700",children:[T("cronNextRun"),":"]})," ",Hi(y.state.nextRunAt)]}),h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-gray-700",children:[T("cronLastRun"),":"]})," ",Hi(y.state.lastRunAt)]}),h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-gray-700",children:[T("cronLastStatus"),":"]})," ",y.state.lastStatus??"-"]}),y.state.lastError&&h.jsx("div",{className:"text-[11px] text-red-500 break-words",children:y.state.lastError})]}),h.jsxs("div",{className:"flex items-start gap-2 flex-wrap justify-end",children:[h.jsxs(je,{variant:"subtle",size:"sm",onClick:()=>f(y),className:"gap-1",children:[h.jsx(Ba,{className:"h-3.5 w-3.5"}),T("cronRunNow")]}),h.jsxs(je,{variant:y.enabled?"outline":"primary",size:"sm",onClick:()=>p(y),className:"gap-1",children:[h.jsx(Va,{className:"h-3.5 w-3.5"}),y.enabled?T("cronDisable"):T("cronEnable")]}),h.jsxs(je,{variant:"destructive",size:"sm",onClick:()=>d(y),className:"gap-1",children:[h.jsx(ts,{className:"h-3.5 w-3.5"}),T("delete")]})]})]})})},y.id))})}),h.jsx(u,{})]})}function Fy(e){const{view:t,routeSessionKey:n,selectedSessionKey:r,selectedAgentId:i,setSelectedSessionKey:s,setSelectedAgentId:l,selectedSessionKeyRef:a,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 c=r?u(r):null;c&&i!==c&&l(c)},[u,i,r,l]),k.useEffect(()=>{a.current=r},[r,a])}function Oy({view:e,confirmDialog:t}){return h.jsxs("div",{className:"h-full flex",children:[h.jsx(Hx,{}),e==="chat"?h.jsx(Ny,{}):h.jsx("section",{className:"flex-1 min-h-0 overflow-hidden bg-gradient-to-b from-gray-50/60 to-white",children:e==="cron"?h.jsx("div",{className:"h-full overflow-auto custom-scrollbar",children:h.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5",children:h.jsx(Dy,{})})}):h.jsx("div",{className:"h-full overflow-hidden",children:h.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:h.jsx(vo,{forcedType:"skills"})})})}),t]})}function zy(){return(e,t)=>fetch(e,{credentials:"include",...t})}const _n="sid_";function _y(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 By(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`${_n}${r}`}function Vy(e){if(!e.startsWith(_n))return null;const t=e.slice(_n.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 Hy(e){if(!e)return null;const t=Vy(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function Uy(e){return`/chat/${By(e)}`}const ke="native";function ze(e){return typeof e!="string"?ke:e.trim().toLowerCase()||ke}function xt(e,t){return e==="native"?T("chatSessionTypeNative"):e.trim().split(/[-_]+/g).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")||e}function $y(e){var n;const t=new Map;for(const r of e){const i=ze(r.value);t.set(i,{value:i,label:((n=r.label)==null?void 0:n.trim())||xt(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(ke)||t.set(ke,{value:ke,label:xt(ke),ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),Array.from(t.values()).sort((r,i)=>r.value===ke?-1:i.value===ke?1:r.value.localeCompare(i.value))}function Ky(e){const{selectedSession:t,selectedSessionKey:n,pendingSessionType:r,setPendingSessionType:i,sessionTypesData:s}=e,l=k.useMemo(()=>$y((s==null?void 0:s.options)??[]),[s==null?void 0:s.options]),a=k.useMemo(()=>{const S=[...l],g=ze(t==null?void 0:t.sessionType);return S.some(I=>I.value===g)||S.push({value:g,label:xt(g),ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),S.sort((I,N)=>I.value===ke?-1:N.value===ke?1:I.value.localeCompare(N.value))},[l,t==null?void 0:t.sessionType]),o=k.useMemo(()=>ze((s==null?void 0:s.defaultType)??ke),[s==null?void 0:s.defaultType]),u=k.useRef(null),c=k.useMemo(()=>ze((t==null?void 0:t.sessionType)??r??o),[o,r,t==null?void 0:t.sessionType]),d=k.useMemo(()=>a.find(S=>S.value===c)??null,[c,a]);k.useEffect(()=>{if(n)return;const S=typeof r=="string"?r.trim():"",g=ze(r);(S.length===0||u.current===g||u.current===null&&g===ke)&&(u.current=o,g!==o&&i(o))},[o,r,n,i]);const p=!n||!!(t!=null&&t.sessionTypeMutable),f=k.useMemo(()=>new Set(l.map(S=>S.value)),[l]),m=k.useMemo(()=>t&&!f.has(ze(t.sessionType))?!0:(d==null?void 0:d.ready)===!1,[f,t,d==null?void 0:d.ready]),y=k.useMemo(()=>{var S;return t&&!f.has(ze(t.sessionType))?`${xt(c)} ${T("chatSessionTypeUnavailableSuffix")}`:(d==null?void 0:d.ready)===!1?((S=d.reasonMessage)==null?void 0:S.trim())||`${d.label} setup required`:null},[f,t,c,d]);return{sessionTypeOptions:a,selectedSessionTypeOption:d,defaultSessionType:o,selectedSessionType:c,canEditSessionType:p,sessionTypeUnavailable:m,sessionTypeUnavailableMessage:y}}function Ui(e){return(e==null?void 0:e.trim().toLowerCase())||"native"}function qy(e,t){if(typeof t!="string")return!1;const n=t.trim();return n?e.some(r=>r.value===n):!1}function Wy(e,t){return typeof t=="string"&&e.includes(t)}function Qy(e){return e.length===0?null:e.includes("off")?"off":e[0]??null}function $l(e){const{currentValue:t,selectedSessionPreferredValue:n,fallbackPreferredValue:r,defaultValue:i,isValueSupported:s,firstAvailableValue:l,preferSessionPreferredValue:a=!1,preserveCurrentValueOnSessionChange:o=!1}=e;return s(t)&&(!a||o)?t:s(n)?n:s(r)?r:s(i)?i:l}function Gy(e){var n;const{modelOptions:t}=e;return t.length===0?"":$l({currentValue:e.currentSelectedModel,selectedSessionPreferredValue:e.selectedSessionPreferredModel,fallbackPreferredValue:e.fallbackPreferredModel,defaultValue:e.defaultModel,isValueSupported:r=>qy(t,r),firstAvailableValue:((n=t[0])==null?void 0:n.value)??"",preferSessionPreferredValue:e.preferSessionPreferredModel,preserveCurrentValueOnSessionChange:e.preserveCurrentSelectedModelOnSessionChange})}function Xy(e){const{supportedThinkingLevels:t}=e;return t.length===0?null:$l({currentValue:e.currentSelectedThinkingLevel,selectedSessionPreferredValue:e.selectedSessionPreferredThinking,fallbackPreferredValue:e.fallbackPreferredThinking,defaultValue:e.defaultThinkingLevel,isValueSupported:n=>Wy(t,n),firstAvailableValue:Qy(t)??"off",preferSessionPreferredValue:e.preferSessionPreferredThinking,preserveCurrentValueOnSessionChange:e.preserveCurrentSelectedThinkingOnSessionChange})}function Kl(e){const t=Ui(e.sessionType);let n,r=Number.NEGATIVE_INFINITY;for(const i of e.sessions){if(i.key===e.selectedSessionKey||Ui(i.sessionType)!==t)continue;const s=e.readPreference(i);if(s==null)continue;const l=Date.parse(i.updatedAt),a=Number.isFinite(l)?l:Number.NEGATIVE_INFINITY;(n===void 0||a>r)&&(n=s,r=a)}return n}function Yy(e){return Kl({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 Jy(e){return Kl({sessions:e.sessions,selectedSessionKey:e.selectedSessionKey,sessionType:e.sessionType,readPreference:t=>t.preferredThinking??void 0})}function ql(e){const{isPreferenceAvailable:t,emptyValue:n,selectedSessionKey:r,selectedSessionExists:i=!1,setValue:s,resolveValue:l}=e,a=k.useRef(void 0),o=k.useRef(l);k.useEffect(()=>{o.current=l},[l]),k.useEffect(()=>{const u=a.current!==r;if(!t){s(n),a.current=r;return}s(c=>o.current({currentValue:c,sessionChanged:u,preserveCurrentValueOnSessionChange:u&&!!r&&!i})),a.current=r},[n,t,i,r,s])}function Zy(e){const{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:s,defaultModel:l,setSelectedModel:a}=e;ql({isPreferenceAvailable:t.length>0,emptyValue:"",selectedSessionKey:n,selectedSessionExists:r,setValue:a,resolveValue:({currentValue:o,sessionChanged:u,preserveCurrentValueOnSessionChange:c})=>Gy({currentSelectedModel:o,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:s,defaultModel:l,preferSessionPreferredModel:u,preserveCurrentSelectedModelOnSessionChange:c})})}function eb(e){const{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:s,defaultThinkingLevel:l,setSelectedThinkingLevel:a}=e;ql({isPreferenceAvailable:t.length>0,emptyValue:null,selectedSessionKey:n,selectedSessionExists:r,setValue:a,resolveValue:({currentValue:o,sessionChanged:u,preserveCurrentValueOnSessionChange:c})=>Xy({currentSelectedThinkingLevel:o,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:s,defaultThinkingLevel:l,preferSessionPreferredThinking:u,preserveCurrentSelectedThinkingOnSessionChange:c})})}function tb(){return Ha({queryKey:["ncp-session-types"],queryFn:oo,staleTime:1e4,retry:!1})}function nb(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.key.toLowerCase().includes(n)):e}function rb(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 ib(e){var D,F,v,O,_,B,w,j;const t=uo(),n=co(),r=rs({limit:200}),i=tb(),s=To("skill"),l=(t.isFetched||t.isSuccess)&&(n.isFetched||n.isSuccess),a=k.useMemo(()=>{const L=zo({meta:n.data,config:t.data,onlyConfigured:!0}),H=new Set,A=[];for(const C of L)for(const P of C.models){const Q=_o(C.prefix,P);!Q||H.has(Q)||(H.add(Q),A.push({value:Q,modelLabel:P,providerLabel:C.displayName,thinkingCapability:Bo(C.modelThinking,P,C.aliases)}))}return A.sort((C,P)=>{const Q=C.providerLabel.localeCompare(P.providerLabel);return Q!==0?Q: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(()=>as(o),[o]),c=k.useMemo(()=>nb(u,e.query),[u,e.query]),d=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=Ky({selectedSession:d,selectedSessionKey:e.selectedSessionKey,pendingSessionType:e.pendingSessionType,setPendingSessionType:e.setPendingSessionType,sessionTypesData:i.data}),m=k.useMemo(()=>{var L;return rb({modelOptions:a,supportedModels:(L=f.selectedSessionTypeOption)==null?void 0:L.supportedModels})},[a,(v=f.selectedSessionTypeOption)==null?void 0:v.supportedModels]),y=k.useMemo(()=>Yy({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},[(_=S==null?void 0:S.thinkingCapability)==null?void 0:_.default]),N=k.useMemo(()=>Jy({sessions:u,selectedSessionKey:e.selectedSessionKey,sessionType:f.selectedSessionType}),[u,e.selectedSessionKey,f.selectedSessionType]);return Zy({modelOptions:m,selectedSessionKey:e.selectedSessionKey,selectedSessionExists:!!d,selectedSessionPreferredModel:d==null?void 0:d.preferredModel,fallbackPreferredModel:((B=f.selectedSessionTypeOption)==null?void 0:B.recommendedModel)??y,defaultModel:((w=f.selectedSessionTypeOption)==null?void 0:w.recommendedModel)??((j=t.data)==null?void 0:j.agents.defaults.model),setSelectedModel:e.setSelectedModel}),eb({supportedThinkingLevels:g,selectedSessionKey:e.selectedSessionKey,selectedSessionExists:!!d,selectedSessionPreferredThinking:(d==null?void 0:d.preferredThinking)??null,fallbackPreferredThinking:N??null,defaultThinkingLevel:I,setSelectedThinkingLevel:e.setSelectedThinkingLevel}),{configQuery:t,configMetaQuery:n,sessionsQuery:r,sessionTypesQuery:i,installedSkillsQuery:s,isProviderStateResolved:l,modelOptions:m,sessionSummaries:o,sessions:c,skillRecords:p,selectedSession:d,...f}}class sb{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}=J.getState(),{defaultSessionType:s}=i,l=s||"native",a=typeof r=="string"&&r.trim().length>0?r.trim():l;this.streamActionsManager.resetStreamState(),J.getState().setSnapshot({pendingSessionType:a}),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 Cn=async()=>{},$i=()=>{};class lb{constructor(){this.actions={sendMessage:Cn,stopCurrentRun:Cn,resumeRun:Cn,resetStreamState:$i,applyHistoryMessages:$i},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 ab=async e=>!1;class ob{constructor(){this.state={pathname:""},this.actions={navigate:null,confirm:ab},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(Uy(t),n)}}}function ub(e){const t=e.trim();return t.length>0?t:null}function cb(e){return e??null}class db{constructor(t){this.updateSession=t,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{const n=J.getState().snapshot,i=fe.getState().snapshot.selectedSessionKey;i&&this.enqueue({sessionKey:i,patch:{preferredModel:ub(n.selectedModel),preferredThinking:cb(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 hb{constructor(t,n,r){this.uiManager=t,this.streamActionsManager=n,this.getDraftSessionId=r,this.sessionPreferenceSync=new db(ns),this.buildAttachmentSignature=i=>[i.assetUri??"",i.url??"",i.name,i.mimeType,String(i.sizeBytes),i.contentBase64??""].join(":"),this.hasSnapshotChanges=i=>{const s=J.getState().snapshot;for(const[l,a]of Object.entries(i))if(!Object.is(s[l],a))return!0;return!1},this.resolveUpdateValue=(i,s)=>typeof s=="function"?s(i):s,this.isSameStringArray=(i,s)=>i.length===s.length&&i.every((l,a)=>l===s[a]),this.syncComposerSnapshot=i=>{const s=J.getState().snapshot.attachments,l=Px(i,s);J.getState().setSnapshot({composerNodes:i,attachments:l,draft:Pi(i),selectedSkills:Di(i)})},this.syncComposerSnapshotWithAttachments=(i,s)=>{J.getState().setSnapshot({composerNodes:i,attachments:s,draft:Pi(i),selectedSkills:Di(i)})},this.dedupeAttachments=i=>{const s=new Set,l=[];for(const a of i){const o=this.buildAttachmentSignature(a);s.has(o)||(s.add(o),l.push(a))}return l},this.syncSnapshot=i=>{if(this.hasSnapshotChanges(i)&&(J.getState().setSnapshot(i),Object.prototype.hasOwnProperty.call(i,"modelOptions")||Object.prototype.hasOwnProperty.call(i,"selectedModel")||Object.prototype.hasOwnProperty.call(i,"selectedThinkingLevel"))){const{selectedModel:s}=J.getState().snapshot;this.reconcileThinkingForModel(s)}},this.setDraft=i=>{const s=J.getState().snapshot.draft,l=this.resolveUpdateValue(s,i);l!==s&&this.syncComposerSnapshot(Ax(l))},this.setComposerNodes=i=>{const s=J.getState().snapshot.composerNodes,l=this.resolveUpdateValue(s,i);Object.is(l,s)||this.syncComposerSnapshot(l)},this.addAttachments=i=>{if(i.length===0)return[];const s=J.getState().snapshot,l=new Set(s.attachments.map(this.buildAttachmentSignature)),a=this.dedupeAttachments([...s.attachments,...i]),o=a.filter(c=>!l.has(this.buildAttachmentSignature(c)));if(o.length===0)return[];const u=Fi(s.composerNodes,a);return this.syncComposerSnapshotWithAttachments(u,a),o},this.restoreComposerState=(i,s)=>{const l=this.dedupeAttachments(s),a=Fi(i,l);this.syncComposerSnapshotWithAttachments(a,l)},this.setPendingSessionType=i=>{const s=J.getState().snapshot.pendingSessionType,l=this.resolveUpdateValue(s,i);l!==s&&J.getState().setSnapshot({pendingSessionType:l})},this.send=async()=>{const i=J.getState().snapshot,s=fe.getState().snapshot,l=i.draft.trim(),a=i.attachments,o=Dx(i.composerNodes,a);if(!o.some(f=>f.type!=="text"||f.text.trim().length>0))return;const{selectedSkills:c,composerNodes:d}=i,p=s.selectedSessionKey??this.getDraftSessionId();s.selectedSessionKey||this.uiManager.goToSession(p,{replace:!0}),this.setComposerNodes(Vl()),await this.streamActionsManager.sendMessage({message:l,sessionKey:p,agentId:s.selectedAgentId,sessionType:i.selectedSessionType,model:i.selectedModel||void 0,thinkingLevel:i.selectedThinkingLevel??void 0,stopSupported:!0,requestedSkills:c,attachments:a,parts:o,restoreDraftOnError:!0,composerNodes:d})},this.stop=async()=>{await this.streamActionsManager.stopCurrentRun()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.setSelectedModel=i=>{const s=J.getState().snapshot.selectedModel,l=this.resolveUpdateValue(s,i);l!==s&&(J.getState().setSnapshot({selectedModel:l}),this.reconcileThinkingForModel(l))},this.setSelectedThinkingLevel=i=>{const s=J.getState().snapshot.selectedThinkingLevel,l=this.resolveUpdateValue(s,i);l!==s&&J.getState().setSnapshot({selectedThinkingLevel:l})},this.selectSessionType=i=>{const s=ze(i);J.getState().setSnapshot({selectedSessionType:s,pendingSessionType:s})},this.setSelectedSkills=i=>{const s=J.getState().snapshot,{selectedSkills:l}=s,a=this.resolveUpdateValue(l,i);this.isSameStringArray(a,l)||this.syncComposerSnapshot(jx(s.composerNodes,a,s.skillRecords))},this.selectModel=i=>{this.setSelectedModel(i),Hl.remember(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=J.getState().snapshot,r=n.modelOptions.find(l=>l.value===t),{selectedThinkingLevel:i}=n,s=this.resolveThinkingForModel(r,i);s!==i&&J.getState().setSnapshot({selectedThinkingLevel:s})}}class fb{constructor(t,n,r){this.uiManager=t,this.sessionListManager=n,this.streamActionsManager=r,this.hasSnapshotChanges=i=>{const s=at.getState().snapshot;for(const[l,a]of Object.entries(i))if(!Object.is(s[l],a))return!0;return!1},this.syncSnapshot=i=>{this.hasSnapshotChanges(i)&&at.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:T("chatDeleteSessionConfirm"),variant:"destructive",confirmLabel:T("delete")}))){at.getState().setSnapshot({isDeletePending:!0});try{await ho(i),fo(Cr,i),Cr.removeQueries({queryKey:["ncp-session-messages",i]}),this.streamActionsManager.resetStreamState(),this.uiManager.goToChatRoot({replace:!0})}finally{at.getState().setSnapshot({isDeletePending:!1})}}}}}class pb{constructor(){this.chatUiManager=new ob,this.chatStreamActionsManager=new lb,this.chatSessionListManager=new sb(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new hb(this.chatUiManager,this.chatStreamActionsManager,()=>this.getDraftSessionId()),this.chatThreadManager=new fb(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.draftSessionId="",this.setDraftSessionId=t=>{this.draftSessionId=t}}getDraftSessionId(){return this.draftSessionId}}function mb(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 gb(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=mb(e.requestedSkills);return n.length>0&&(t.requested_skills=n),t}function xb(e){return e instanceof Error?e.message.includes("ncp session not found:"):!1}function yb({view:e}){var re,De,we;const[t]=k.useState(()=>new pb),[n,r]=k.useState(()=>vr()),i=fe(V=>V.snapshot.query),s=fe(V=>V.snapshot.selectedSessionKey),l=fe(V=>V.snapshot.selectedAgentId),a=J(V=>V.snapshot.pendingSessionType),o=J(V=>V.snapshot.selectedModel),{confirm:u,ConfirmDialog:c}=os(),d=Ua(),p=$a(),{sessionId:f}=Ka(),m=k.useRef(null),y=k.useRef(s),S=k.useRef(!1),g=k.useMemo(()=>Hy(f),[f]),{installedSkillsQuery:I,isProviderStateResolved:N,modelOptions:D,sessionSummaries:F,skillRecords:v,selectedSession:O,sessionTypeOptions:_,defaultSessionType:B,selectedSessionType:w,canEditSessionType:j,sessionTypeUnavailable:L,sessionTypeUnavailableMessage:H}=ib({query:i,selectedSessionKey:s,currentSelectedModel:o,pendingSessionType:a,setPendingSessionType:t.chatInputManager.setPendingSessionType,setSelectedModel:t.chatInputManager.setSelectedModel,setSelectedThinkingLevel:t.chatInputManager.setSelectedThinkingLevel}),A=s??n,C=k.useRef(F);k.useEffect(()=>{C.current=F},[F]);const[P]=k.useState(()=>new Zo({baseUrl:is,basePath:"/api/ncp/agent",fetchImpl:zy()})),Q=k.useCallback(async(V,ae)=>{ae.throwIfAborted();let be=null;try{be=await po(V,300)}catch(Le){if(!xb(Le))throw Le}ae.throwIfAborted();const Fe=C.current.find(Le=>Le.sessionId===V)??null;return{messages:(be==null?void 0:be.messages)??[],status:(Fe==null?void 0:Fe.status)==="running"?"running":"idle"}},[]),$=du({sessionId:A,client:P,loadSeed:Q});k.useEffect(()=>{t.setDraftSessionId(n)},[n,t]),k.useEffect(()=>{if(s===null){const V=vr();r(V),t.setDraftSessionId(V)}},[t,s]);const se=$.isSending||$.isRunning,x=$.isRunning,le=$.isRunning,ye=$.isRunning?null:"__preparing__",b=((re=$.hydrateError)==null?void 0:re.message)??((De=$.snapshot.error)==null?void 0:De.message)??null;k.useEffect(()=>{const V=()=>{S.current||$.isHydrating||$.isRunning||$.isSending||(S.current=!0,P.stream({sessionId:A}).catch(()=>{}).finally(()=>{S.current=!1}))};return mo.subscribe(ae=>{if(ae.type==="session.updated"&&ae.payload.sessionKey===A){V();return}ae.type==="session.summary.upsert"&&ae.payload.summary.sessionId===A&&V()})},[A,$.isHydrating,$.isRunning,$.isSending,P]),k.useEffect(()=>{t.chatStreamActionsManager.bind({sendMessage:async V=>{var Fe,Le;if(V.sessionKey!==A)return;const ae=gb({model:V.model,thinkingLevel:V.thinkingLevel,sessionType:V.sessionType,requestedSkills:V.requestedSkills}),be=pu({sessionId:V.sessionKey,text:V.message,attachments:V.attachments,parts:V.parts,metadata:ae});if(be)try{await $.send(be)}catch(Xt){throw V.restoreDraftOnError&&(V.composerNodes&&V.composerNodes.length>0?(Le=(Fe=t.chatInputManager).restoreComposerState)==null||Le.call(Fe,V.composerNodes,V.attachments??[]):t.chatInputManager.setDraft(Ze=>Ze.trim().length===0?V.message:Ze)),Xt}},stopCurrentRun:async()=>{await $.abort()},resumeRun:async V=>{V.sessionKey===A&&await $.streamRun()},resetStreamState:()=>{y.current=null},applyHistoryMessages:()=>{}})},[A,$,t]),Fy({view:e,routeSessionKey:g,selectedSessionKey:s,selectedAgentId:l,setSelectedSessionKey:t.chatSessionListManager.setSelectedSessionKey,setSelectedAgentId:t.chatSessionListManager.setSelectedAgentId,selectedSessionKeyRef:y,resetStreamState:t.chatStreamActionsManager.resetStreamState,resolveAgentIdFromSessionKey:_y}),k.useEffect(()=>{t.chatUiManager.syncState({pathname:d.pathname}),t.chatUiManager.bindActions({navigate:p,confirm:u})},[u,d.pathname,p,t]);const de=O?Do(O):void 0,Ie=((we=_.find(V=>V.value===w))==null?void 0:we.label)??xt(w);return k.useEffect(()=>{t.chatInputManager.syncSnapshot({isProviderStateResolved:N,defaultSessionType:B,canStopGeneration:le,stopDisabledReason:ye,stopSupported:!0,stopReason:void 0,sendError:b,isSending:se,modelOptions:D,sessionTypeOptions:_,selectedSessionType:w,canEditSessionType:j,sessionTypeUnavailable:L,skillRecords:v,isSkillsLoading:I.isLoading}),t.chatThreadManager.syncSnapshot({isProviderStateResolved:N,modelOptions:D,sessionTypeUnavailable:L,sessionTypeUnavailableMessage:H,sessionTypeLabel:Ie,selectedSessionKey:s,sessionDisplayName:de,canDeleteSession:!!O,threadRef:m,isHistoryLoading:$.isHydrating,messages:$.visibleMessages,isSending:se,isAwaitingAssistantOutput:x})},[$.isHydrating,j,le,de,Ie,B,I.isLoading,x,N,se,b,D.length,D,t,O,s,w,_,L,H,v,ye,m,$.visibleMessages]),h.jsx(Cu,{presenter:t,children:h.jsx(Oy,{view:e,confirmDialog:h.jsx(c,{})})})}function Ab({view:e}){return h.jsx(yb,{view:e})}export{Ab as ChatPage};
|