@nextclaw/ui 0.11.3 → 0.11.4

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/assets/{ChannelsList-CKl1Zg8f.js → ChannelsList-ClgglSCM.js} +1 -1
  3. package/dist/assets/ChatPage-_RQ-15hd.js +37 -0
  4. package/dist/assets/{DocBrowser-DYRBs4-z.js → DocBrowser-CEN7WszT.js} +1 -1
  5. package/dist/assets/{LogoBadge-33Qlv3Hg.js → LogoBadge-CVhsEo0l.js} +1 -1
  6. package/dist/assets/{MarketplacePage-B8BZVtjV.js → MarketplacePage-DsC673tU.js} +1 -1
  7. package/dist/assets/{McpMarketplacePage-BRuE5fJJ.js → McpMarketplacePage-CBaj_rSP.js} +1 -1
  8. package/dist/assets/{ModelConfig-BiFblwO-.js → ModelConfig-BLchzPTQ.js} +1 -1
  9. package/dist/assets/{ProvidersList-9goRgHE4.js → ProvidersList-Djbu1TO0.js} +1 -1
  10. package/dist/assets/{RemoteAccessPage-5vCxZPS6.js → RemoteAccessPage-oQwNGaf6.js} +1 -1
  11. package/dist/assets/{RuntimeConfig-BmDFHBdW.js → RuntimeConfig-DQMcGY1J.js} +1 -1
  12. package/dist/assets/{SearchConfig-CJx5CKwG.js → SearchConfig-COiDtpe8.js} +1 -1
  13. package/dist/assets/{SecretsConfig-B91efXoK.js → SecretsConfig-Ct-H-00g.js} +1 -1
  14. package/dist/assets/{SessionsConfig-CbFPVmx3.js → SessionsConfig-9iDn5nNW.js} +1 -1
  15. package/dist/assets/index-ClK2uqZ_.css +1 -0
  16. package/dist/assets/index-DOioYtlD.js +8 -0
  17. package/dist/assets/{label-BnSDpjhL.js → label-CGGD8iAm.js} +1 -1
  18. package/dist/assets/{ncp-session-adapter-w8ZHprab.js → ncp-session-adapter-qs80LdAm.js} +1 -1
  19. package/dist/assets/{page-layout-B1RIu5-r.js → page-layout-D-XTwxQY.js} +1 -1
  20. package/dist/assets/{popover-ChzbCIfO.js → popover-D1o13wqM.js} +1 -1
  21. package/dist/assets/{security-config-eYa6Ovfa.js → security-config-DEUjv2rj.js} +1 -1
  22. package/dist/assets/{skeleton-D4Eyop0R.js → skeleton-BAHz3XuH.js} +1 -1
  23. package/dist/assets/{status-dot-CrCw5tkJ.js → status-dot-DRhDa82q.js} +1 -1
  24. package/dist/assets/{switch-C3vVTpfU.js → switch-DXjAXRVB.js} +1 -1
  25. package/dist/assets/{tabs-custom-Ilrgt6n1.js → tabs-custom-yMLD4FfD.js} +1 -1
  26. package/dist/assets/{useConfirmDialog-BeaFLDO8.js → useConfirmDialog-Da7xoSDD.js} +1 -1
  27. package/dist/index.html +2 -2
  28. package/package.json +4 -4
  29. package/src/components/chat/adapters/chat-message.adapter.test.ts +0 -7
  30. package/src/components/chat/adapters/chat-message.adapter.ts +0 -5
  31. package/src/components/chat/containers/chat-message-list.container.tsx +0 -2
  32. package/src/lib/i18n.chat.ts +0 -2
  33. package/dist/assets/ChatPage-BJgO27mk.js +0 -37
  34. package/dist/assets/index-BtAuUyww.css +0 -1
  35. package/dist/assets/index-COJomMe9.js +0 -8
@@ -1,37 +0,0 @@
1
- var Da=Object.defineProperty;var Oa=(e,t,n)=>t in e?Da(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ne=(e,t,n)=>Oa(e,typeof t!="symbol"?t+"":t,n);import{r as C,j as d,ae as Di,v as Ht,X as Fa,af as za,f as _a,e as ht,t as Ba,c as Ua,y as Ha,z as Va,h as Oi,I as $a,i as _n,n as Ka,o as Fi,V as qa,q as zi,s as Wa,w as Qa,k as _i,l as Ga,m as Bi,a as Ya,ag as Xa,B as Bn,G as Un,ah as Ja,ai as Za,aj as el,F as tl,ak as nl,al as rl,_ as Ui,am as Hi,an as Vi,ao as il,ap as sl,aq as al,ar as ll,as as ol,at as ul,au as cl,av as hl,aw as dl,d as Vt,ax as fl,A as Hn,ay as pl,a0 as ml,a3 as gl,a1 as xl,a2 as yl,M as bl,az as $i,aA as Sl,aB as kl,aC as wl,u as Cl,a4 as vl,aD as Tl,aE as Il}from"./vendor-waGu-koL.js";import{t as v,c as Ce,I as Vn,B as Oe,i as $t,j as Ki,k as Ml,l as Nl,m as $n,n as Ll,T as pr,L as mr,o as El,p as gr,q as Al,r as xr,h as dt,A as qi,s as Rl,v as jl,w as Pl,x as Dl,S as Ol,e as Fl,f as zl,g as _l,C as Bl,y as Ul,z as Hl,u as Vl,a as $l,E as Kl,F as ql,G as Wl}from"./index-COJomMe9.js";import{T as Ql,a as Gl,b as Yl,c as Xl,P as Jl,R as Zl,d as eo,e as to,C as Wi,M as no,u as ro}from"./MarketplacePage-B8BZVtjV.js";import{R as io,A as so,P as ao,C as Qi,T as lo,a as oo,b as uo,c as co}from"./popover-ChzbCIfO.js";import{S as ho,a as fo,c as yr,b as po,d as mo,s as go}from"./ncp-session-adapter-w8ZHprab.js";import{u as Gi}from"./useConfirmDialog-BeaFLDO8.js";import{P as xo,a as yo}from"./page-layout-B1RIu5-r.js";import{b as bo,c as So,r as ko}from"./provider-models-BOeNnjk9.js";import"./tabs-custom-Ilrgt6n1.js";import"./skeleton-D4Eyop0R.js";import"./marketplace-localization-Dk31LJJJ.js";var Z=(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))(Z||{}),br=/\[\[\s*reply_to_current\s*\]\]/gi,Sr=/\[\[\s*reply_to\s*:\s*([^\]]+?)\s*\]\]/i;function wn(e){if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}function wo(e,t){var s;let n=e,r;br.test(n)&&(r=wn(t),n=n.replace(br,"").trim());const i=(s=n.match(Sr))==null?void 0:s[1];return i&&(r=wn(i),n=n.replace(Sr,"").trim()),r?{content:n,replyTo:r}:{content:n}}function Co(e,t=e.id){if(e.role!=="assistant")return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0};const n=e.parts.findIndex(h=>h.type==="text"),r=e.metadata?{...e.metadata}:void 0,i=wn(r==null?void 0:r.reply_to);if(n<0)return{...e,parts:[...e.parts],metadata:r};const s=e.parts[n];if(!s||s.type!=="text")return{...e,parts:[...e.parts],metadata:r};const{content:a,replyTo:l}=wo(s.text,t),o=l??i,u=e.parts.flatMap((h,c)=>c!==n||h.type!=="text"?[h]:a.length===0?[]:[{...h,text:a}]);return o?{...e,parts:u,metadata:{...r,reply_to:o}}:{...e,parts:u,metadata:r}}function kr(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*vo(e){const t=e.getReader(),n=new TextDecoder;let r="";try{for(;;){const{value:s,done:a}=await t.read();if(a)break;r+=n.decode(s,{stream:!0});const{frames:l,rest:o}=wr(r);r=o;for(const u of l)yield u}r+=n.decode();const{frames:i}=wr(r,!0);for(const s of i)yield s}finally{t.releaseLock()}}function wr(e,t=!1){const n=e.split(/\r?\n\r?\n/),r=n.pop()??"",i=[];for(const s of n){const a=kr(s);a&&i.push(a)}if(t&&r.trim()){const s=kr(r);return s&&i.push(s),{frames:i,rest:""}}return{frames:i,rest:r}}var Cr="/ncp/agent",To="ncp-http-agent-client",Yi=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 Io(e){const t=e.trim();if(!t)throw new Error("NcpHttpAgentClient requires a non-empty baseUrl.");return new URL(t)}function Mo(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 No(e){const t=(e??Cr).trim();if(!t)return Cr;const n=t.startsWith("/")?t:`/${t}`;return n.endsWith("/")?n.slice(0,-1):n}async function vr(e){try{return(await e.text()).trim()}catch{return""}}function Tr(e){if(Xi(e))return e.ncpError;if(Lo(e))return e;const t=e instanceof Error?e.message:String(e??"Unknown error");return{code:Ji(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function Xt(e,t={}){return new Yi(e,t.alreadyPublished??!1)}function Lo(e){return Kn(e)&&typeof e.code=="string"&&typeof e.message=="string"}function Kn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Xi(e){return e instanceof Yi}var Eo={"config-error":"config-error","auth-error":"auth-error","runtime-error":"runtime-error","timeout-error":"timeout-error","abort-error":"abort-error"};function Ji(e){if(!e)return"runtime-error";const t=Eo[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 Ao(e){const t=Zi(e);return!t||typeof t.type!="string"||!t.type.trim()?null:t}function Ro(e){const t=Zi(e);if(!t)return{code:"runtime-error",message:e||"Unknown stream error."};const n=typeof t.code=="string"?t.code:void 0,r=Ji(n),i=Kn(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 Zi(e){try{const t=JSON.parse(e);return Kn(t)?t:null}catch{return null}}var jo=["text","file","source","step-start","reasoning","tool-invocation","card","rich-text","action","extension"],Po=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=Io(e.baseUrl),this.basePath=No(e.basePath),this.fetchImpl=Mo(e.fetchImpl),this.defaultHeaders=e.headers??{},this.manifest={endpointKind:"custom",endpointId:((t=e.endpointId)==null?void 0:t.trim())||To,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:Z.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 vr(n)}`)}catch(n){if(t.signal.aborted)return;const r=Tr(n);throw this.publish({type:Z.EndpointError,payload:r}),Xt(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 vr(n)}`);if(!n.body)throw new Error("NCP stream response has no body.");for await(const r of vo(n.body)){if(t.signal.aborted)return;this.handleSseFrame(r)}}catch(n){if(t.signal.aborted)return;if(Xi(n))throw n;const r=Tr(n);throw this.publish({type:Z.EndpointError,payload:r}),Xt(r)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event==="ncp-event"){const t=Ao(e.data);if(!t){this.publish({type:Z.EndpointError,payload:{code:"runtime-error",message:"Received malformed ncp-event frame."}});return}this.publish(t);return}if(e.event==="error"){const t=Ro(e.data);throw this.publish({type:Z.EndpointError,payload:t}),Xt(t,{alreadyPublished:!0})}}};function jt(e){return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0}}function Jt(e){return jt(Co(e))}function Do(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 Oo(e,t){return t.trim()?e.id.startsWith("tool-")?!0:e.parts.some(n=>n.type==="tool-invocation"):!1}function Fo(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 Cn(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 Ir(e,t){const n=Cn(e,t);return(n==null?void 0:n.toolName)??null}function st(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 zo="assistant",_o=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.map(t=>jt(t)),streamingMessage:this.streamingMessage?jt(this.streamingMessage):null,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 Z.MessageSent:this.handleMessageSent(e.payload);break;case Z.MessageAbort:this.handleMessageAbort(e.payload);break;case Z.MessageTextStart:this.handleMessageTextStart(e.payload);break;case Z.MessageTextDelta:this.handleMessageTextDelta(e.payload);break;case Z.MessageTextEnd:this.handleMessageTextEnd(e.payload);break;case Z.MessageReasoningStart:this.handleMessageReasoningStart(e.payload);break;case Z.MessageReasoningDelta:this.handleMessageReasoningDelta(e.payload);break;case Z.MessageReasoningEnd:this.handleMessageReasoningEnd(e.payload);break;case Z.MessageToolCallStart:this.handleMessageToolCallStart(e.payload);break;case Z.MessageToolCallArgs:this.handleMessageToolCallArgs(e.payload);break;case Z.MessageToolCallArgsDelta:this.handleMessageToolCallArgsDelta(e.payload);break;case Z.MessageToolCallEnd:this.handleMessageToolCallEnd(e.payload);break;case Z.MessageToolCallResult:this.handleMessageToolCallResult(e.payload);break;case Z.RunStarted:this.handleRunStarted(e.payload);break;case Z.RunFinished:this.handleRunFinished(e.payload);break;case Z.RunError:this.handleRunError(e.payload);break;case Z.RunMetadata:this.handleRunMetadata(e.payload);break;case Z.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=st(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=st(t.parts,{type:"tool-invocation",toolCallId:e.toolCallId,toolName:Ir(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 st(n.parts,i)})){const n=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId),r=st(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(Do(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=Ir(i.parts,t)??"unknown",a=st(i.parts,{type:"tool-invocation",toolCallId:t,toolName:s,state:"partial-call",args:n});this.replaceStreamingMessage({...i,parts:a,status:"streaming"})}ensureStreamingMessage(e,t,n){var a;if(((a=this.streamingMessage)==null?void 0:a.id)===t){if(this.streamingMessage.status===n)return this.streamingMessage;const l={...this.streamingMessage,status:n};return this.replaceStreamingMessage(l),l}const r=this.messages.findIndex(l=>l.id===t);if(r>=0){const l=jt(this.messages[r]),o=[...this.messages];o.splice(r,1),this.messages=o,this.stateVersion+=1;const u={...l,sessionId:e,status:n};return this.replaceStreamingMessage(u),u}const i=this.streamingMessage;if(i&&i.id!==t&&i.sessionId===e&&Oo(i,t)){const l={...i,id:t,sessionId:e,status:n};return Fo(this.toolCallMessageIdByCallId,i.id,t),this.replaceStreamingMessage(l),l}const s={id:t,sessionId:e,role:zo,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=Cn(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=Cn(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 Bo(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 Uo(e){return e.parts.some(t=>t.type==="text"||t.type==="rich-text"||t.type==="reasoning"?t.text.trim().length>0:!0)}function Ho(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 Uo(e.message)?{...e,sessionId:e.sessionId,message:{...e.message,sessionId:e.message.sessionId||e.sessionId}}:null}function Vo(e){const t=C.useRef();return(!t.current||t.current.sessionId!==e)&&(t.current={sessionId:e,manager:new _o}),t.current.manager}function $o({sessionId:e,client:t,manager:n}){var p;const r=C.useSyncExternalStore(f=>n.subscribe(()=>f()),()=>n.getSnapshot(),()=>n.getSnapshot()),[i,s]=C.useState(!1);C.useEffect(()=>{s(!1)},[e]),C.useEffect(()=>{const f=t.subscribe(m=>{Bo(m,e)&&n.dispatch(m)});return()=>{f(),t.stop()}},[t,n,e]);const a=r.streamingMessage?[...r.messages,r.streamingMessage]:r.messages,l=((p=r.activeRun)==null?void 0:p.runId)??null,o=!!r.activeRun;return{snapshot:r,visibleMessages:a,activeRunId:l,isRunning:o,isSending:i,send:async f=>{if(i||o)return;const m=Ho(f,e);if(m){s(!0),await n.dispatch({type:Z.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 Mr(e){return e instanceof Error?e:new Error(String(e))}function Ko(e){return e.isHydrating||e.hydratedSessionId!==e.sessionId}function qo({sessionId:e,client:t,loadSeed:n,autoResumeRunningSession:r=!0}){const i=Vo(e),s=$o({sessionId:e,client:t,manager:i}),[a,l]=C.useState(!0),[o,u]=C.useState(null),[h,c]=C.useState(null),p=C.useRef({requestId:0,controller:null}),f=C.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),l(!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),c(e),l(!1),g.status==="running"&&r&&t.stream({sessionId:e}).catch(I=>{p.current.requestId===y&&u(Mr(I))})}catch(g){if(m.signal.aborted||p.current.requestId!==y)return;u(Mr(g)),c(e),l(!1)}finally{p.current.controller===m&&(p.current.controller=null)}},[r,t,n,i,e]);return C.useEffect(()=>(f(),()=>{var m;(m=p.current.controller)==null||m.abort(),p.current.controller=null}),[f]),{...s,isHydrating:Ko({sessionId:e,hydratedSessionId:h,isHydrating:a}),hydrateError:o,reloadSeed:f}}var es=200*1024*1024,Wo="application/octet-stream";function ts(e){const t=e.type.trim().toLowerCase();return t.length>0?t:Wo}function Qo(e,t){const n=t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0?new Set(t.acceptedMimeTypes.map(s=>s.trim().toLowerCase())):null,r=t.maxBytes??es,i=ts(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 Go(e){var i;const t=e.parts&&e.parts.length>0?e.parts.map(s=>structuredClone(s)):[...((i=e.text)==null?void 0:i.trim())??""?[{type:"text",text:e.text.trim()}]:[],...(e.attachments??[]).map(s=>{var a,l,o;return{type:"file",name:s.name,mimeType:s.mimeType,...(a=s.assetUri)!=null&&a.trim()?{assetUri:s.assetUri.trim()}:{},...(l=s.url)!=null&&l.trim()?{url:s.url.trim()}:{},...(o=s.contentBase64)!=null&&o.trim()?{contentBase64:s.contentBase64.trim()}:{},sizeBytes:s.sizeBytes}})];if(t.length===0)return null;const n=e.timestamp??new Date().toISOString(),r=e.messageId??`user-${Date.now().toString(36)}`;return{sessionId:e.sessionId,message:{id:r,sessionId:e.sessionId,role:"user",status:"final",parts:t,timestamp:n,...e.metadata?{metadata:e.metadata}:{}},...e.metadata?{metadata:e.metadata}:{}}}async function Yo(e,t){const n=[],r=[];for(const i of e){const s=Qo(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:ts(i),sizeBytes:i.size,reason:"read-failed"}))),{attachments:[],rejected:r}}}const Xo={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 Jo({status:e,className:t}){const n=Xo[e],r=e==="connected"?v("connected"):e==="disconnected"?v("disconnected"):v("connecting");return d.jsx(Ql,{delayDuration:250,children:d.jsxs(Gl,{children:[d.jsx(Yl,{asChild:!0,children:d.jsx("span",{role:"status","aria-label":r,className:Ce("inline-flex h-5 w-5 items-center justify-center",t),children:e==="connecting"?d.jsx(Di,{className:Ce("h-3 w-3 animate-spin",n.dotClass)}):d.jsx("span",{className:Ce(e==="connected"?"h-2 w-2 rounded-full":"",n.dotClass)})})}),d.jsx(Xl,{side:"bottom",className:"text-xs",children:r})]})})}function Zo(e){const{session:t,active:n,runStatus:r,sessionTypeLabel:i,title:s,isEditing:a,draftLabel:l,isSaving:o,onSelect:u,onStartEditing:h,onDraftLabelChange:c,onSave:p,onCancel:f}=e;return d.jsx("div",{className:Ce("w-full rounded-xl px-3 py-2 text-left transition-all text-[13px]",n?"bg-gray-200 text-gray-900 font-semibold shadow-sm":"text-gray-700 hover:bg-gray-200/60 hover:text-gray-900"),children:a?d.jsxs("div",{className:"space-y-2",children:[d.jsx(Vn,{value:l,onChange:m=>c(m.target.value),onKeyDown:m=>{m.key==="Enter"?(m.preventDefault(),p()):m.key==="Escape"&&(m.preventDefault(),f())},placeholder:v("sessionsLabelPlaceholder"),className:"h-8 rounded-lg border-gray-300 bg-white text-xs",autoFocus:!0,disabled:o}),d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("div",{className:"min-w-0 text-[11px] text-gray-400 truncate",children:t.key}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Oe,{type:"button",size:"icon",variant:"ghost",className:"h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900",onClick:()=>void p(),disabled:o,"aria-label":v("save"),children:d.jsx(Ht,{className:"h-3.5 w-3.5"})}),d.jsx(Oe,{type:"button",size:"icon",variant:"ghost",className:"h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900",onClick:f,disabled:o,"aria-label":v("cancel"),children:d.jsx(Fa,{className:"h-3.5 w-3.5"})})]})]})]}):d.jsxs("div",{className:"group/session relative",children:[d.jsxs("button",{type:"button",onClick:u,className:"w-full text-left",children:[d.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_0.875rem] items-center gap-1.5 pr-8",children:[d.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[d.jsx("span",{className:"truncate font-medium",children:s}),i?d.jsx("span",{className:Ce("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-semibold leading-none",n?"border-gray-300 bg-white/80 text-gray-700":"border-gray-200 bg-gray-100 text-gray-500"),children:i}):null]}),d.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:r?d.jsx(ho,{status:r}):null})]}),d.jsxs("div",{className:"mt-0.5 text-[11px] text-gray-400 truncate",children:[t.messageCount," · ",$t(t.updatedAt)]})]}),d.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),h()},className:Ce("absolute right-0 top-0 inline-flex h-7 w-7 items-center justify-center rounded-lg text-gray-400 transition-all hover:bg-white hover:text-gray-900",n?"opacity-100":"opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100"),"aria-label":v("edit"),children:d.jsx(za,{className:"h-3.5 w-3.5"})})]})})}function eu(){const e=_a();return async t=>{try{await Ki(t.sessionKey,{label:t.label}),e.invalidateQueries({queryKey:["ncp-sessions"]}),e.invalidateQueries({queryKey:["ncp-session-messages",t.sessionKey]}),ht.success(v("configSavedApplied"))}catch(n){throw ht.error(v("configSaveFailed")+": "+(n instanceof Error?n.message:String(n))),n}}}const ns=C.createContext(null);function tu({presenter:e,children:t}){return d.jsx(ns.Provider,{value:e,children:t})}function qn(){const e=C.useContext(ns);if(!e)throw new Error("usePresenter must be used inside ChatPresenterProvider");return e}const nu=e=>`[data-item-index="${e}"]`;function rs(e){const t=e.getItemSelector??nu;C.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 ru(){const e=C.useRef(null),[t,n]=C.useState(null);return C.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 te(...e){return Ba(Ua(e))}const is=C.forwardRef(({className:e,type:t,...n},r)=>d.jsx("input",{type:t,className:te("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}));is.displayName="ChatInput";const iu=io,su=lo,au=so,ss=C.forwardRef(({className:e,sideOffset:t=8,align:n="start",...r},i)=>d.jsx(ao,{children:d.jsx(Qi,{ref:i,sideOffset:t,align:n,className:te("z-[var(--z-popover,50)] w-72 overflow-hidden rounded-2xl border border-gray-200/50 bg-white p-4 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})}));ss.displayName=Qi.displayName;const lu=Ha,ou=Va,as=C.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(Oi,{ref:r,className:te("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-xl border border-gray-200/80 bg-white px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/40 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,d.jsx($a,{asChild:!0,children:d.jsx(_n,{className:"h-4 w-4 opacity-50"})})]}));as.displayName=Oi.displayName;const ls=C.forwardRef(({className:e,...t},n)=>d.jsx(_i,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(Ga,{className:"h-4 w-4"})}));ls.displayName=_i.displayName;const os=C.forwardRef(({className:e,...t},n)=>d.jsx(Bi,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(_n,{className:"h-4 w-4"})}));os.displayName=Bi.displayName;const us=C.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>d.jsx(Ka,{children:d.jsxs(Fi,{ref:i,className:te("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md bg-white text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[d.jsx(ls,{}),d.jsx(qa,{className:te("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),d.jsx(os,{})]})}));us.displayName=Fi.displayName;const cs=C.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(zi,{ref:r,className:te("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-gray-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-gray-100",e),...n,children:[d.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(Wa,{children:d.jsx(Ht,{className:"h-4 w-4"})})}),d.jsx(Qa,{children:t})]}));cs.displayName=zi.displayName;const uu=Jl,cu=Zl,hu=eo,hs=C.forwardRef(({className:e,sideOffset:t=4,...n},r)=>d.jsx(to,{children:d.jsx(Wi,{ref:r,sideOffset:t,className:te("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})}));hs.displayName=Wi.displayName;const St={Popover:iu,PopoverAnchor:au,PopoverContent:ss,PopoverTrigger:su,Input:is,Select:lu,SelectContent:us,SelectItem:cs,SelectTrigger:as,SelectValue:ou,Tooltip:cu,TooltipContent:hs,TooltipProvider:uu,TooltipTrigger:hu},du=680,fu=.82,pu=560;function mu(e){const{Popover:t,PopoverAnchor:n,PopoverContent:r}=St,{elementRef:i,width:s}=ru(),a=C.useRef(null),{isOpen:l,isLoading:o,items:u,activeIndex:h,activeItem:c,texts:p,onSelectItem:f,onOpenChange:m,onSetActiveIndex:y}=e,S=C.useMemo(()=>{if(s)return Math.min(s>pu?s*fu:s,du)},[s]);return rs({containerRef:a,activeIndex:h,itemCount:u.length,isEnabled:l&&!o,getItemSelector:g=>`[data-slash-index="${g}"]`}),d.jsxs(t,{open:l,onOpenChange:m,children:[d.jsx(n,{asChild:!0,children:d.jsx("div",{ref:i,className:"pointer-events-none absolute bottom-full left-3 right-3 h-0"})}),d.jsx(r,{side:"top",align:"start",sideOffset:10,className:"z-[70] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-2xl border border-gray-200 bg-white/95 p-0 shadow-2xl backdrop-blur-md",onOpenAutoFocus:g=>g.preventDefault(),style:S?{width:`${S}px`}:void 0,children:d.jsxs("div",{className:"grid min-h-[240px] grid-cols-[minmax(220px,300px)_minmax(0,1fr)]",children:[d.jsx("div",{ref:a,role:"listbox","aria-label":p.slashSectionLabel,className:"custom-scrollbar max-h-[320px] overflow-y-auto border-r border-gray-200 p-2.5",children:o?d.jsx("div",{className:"p-2 text-xs text-gray-500",children:p.slashLoadingLabel}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"mb-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500",children:p.slashSectionLabel}),u.length===0?d.jsx("div",{className:"px-2 text-xs text-gray-400",children:p.slashEmptyLabel}):d.jsx("div",{className:"space-y-1",children:u.map((g,I)=>{const M=I===h;return d.jsxs("button",{type:"button",role:"option","aria-selected":M,"data-slash-index":I,onMouseEnter:()=>y(I),onClick:()=>f(g),className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition ${M?"bg-gray-100 text-gray-900":"text-gray-700 hover:bg-gray-50"}`,children:[d.jsx("span",{className:"truncate text-xs font-semibold",children:g.title}),d.jsx("span",{className:"truncate text-xs text-gray-500",children:g.subtitle})]},g.key)})})]})}),d.jsx("div",{className:"max-w-[320px] p-3.5",children:c?d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary",children:c.subtitle}),d.jsx("span",{className:"text-sm font-semibold text-gray-900",children:c.title})]}),d.jsx("p",{className:"text-xs leading-5 text-gray-600",children:c.description}),d.jsx("div",{className:"space-y-1",children:c.detailLines.map(g=>d.jsx("div",{className:"rounded-md bg-gray-50 px-2 py-1 text-[11px] text-gray-600",children:g},g))}),d.jsx("div",{className:"pt-1 text-[11px] text-gray-500",children:p.slashSkillHintLabel})]}):d.jsx("div",{className:"text-xs text-gray-500",children:p.slashHintLabel})})]})})]})}const gu=Ya("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"}}),Pt=C.forwardRef(({className:e,variant:t,size:n,...r},i)=>d.jsx("button",{className:te(gu({variant:t,size:n,className:e})),ref:i,...r}));Pt.displayName="ChatButton";function Nr(){return d.jsx("span",{"aria-hidden":"true","data-testid":"chat-stop-icon",className:"block h-3 w-3 rounded-[2px] bg-gray-700 shadow-[inset_0_0_0_1px_rgba(17,24,39,0.06)]"})}function xu(e){var s;const{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=St;return d.jsxs("div",{className:"flex flex-col items-end gap-1",children:[(s=e.sendError)!=null&&s.trim()?d.jsx("div",{className:"max-w-[420px] text-right text-[11px] text-red-600",children:e.sendError}):null,d.jsx("div",{className:"flex items-center gap-2",children:e.isSending?e.canStopGeneration?d.jsx(Pt,{size:"icon",variant:"outline",className:"h-8 w-8 rounded-full","aria-label":e.stopButtonLabel,onClick:()=>void e.onStop(),disabled:e.stopDisabled,children:d.jsx(Nr,{})}):d.jsx(r,{children:d.jsxs(t,{children:[d.jsx(i,{asChild:!0,children:d.jsx("span",{children:d.jsx(Pt,{size:"icon",variant:"outline",className:"h-8 w-8 rounded-full","aria-label":e.stopButtonLabel,disabled:!0,children:d.jsx(Nr,{})})})}),d.jsx(n,{side:"top",children:d.jsx("p",{className:"text-xs",children:e.stopHint})})]})}):d.jsx(Pt,{size:"icon",className:"h-8 w-8 rounded-full","aria-label":e.sendButtonLabel,onClick:()=>void e.onSend(),disabled:e.sendDisabled,children:d.jsx(Xa,{className:"h-5 w-5"})})})]})}function yu(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 bu(e){const{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=St,{picker:s}=e,a=C.useRef(null),l=C.useId(),[o,u]=C.useState(""),[h,c]=C.useState(0),p=C.useMemo(()=>new Set(s.selectedKeys),[s.selectedKeys]),f=s.selectedKeys.length,m=C.useMemo(()=>yu(s.options,o),[s.options,o]);C.useEffect(()=>{c(0)},[o]),C.useEffect(()=>{c(g=>m.length===0?0:Math.min(g,m.length-1))},[m.length]),rs({containerRef:a,activeIndex:h,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(),c(I=>Math.min(I+1,m.length-1));return}if(g.key==="ArrowUp"){g.preventDefault(),c(I=>Math.max(I-1,0));return}if(g.key==="Enter"){g.preventDefault();const I=m[h];I&&y(I.key)}}};return d.jsxs(n,{children:[d.jsx(i,{asChild:!0,children:d.jsxs("button",{type:"button","aria-haspopup":"listbox",className:"inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900",children:[d.jsx(Bn,{className:"h-4 w-4"}),d.jsx("span",{children:s.title}),f>0?d.jsx("span",{className:"ml-0.5 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-primary/10 text-[10px] font-semibold text-primary",children:f}):null]})}),d.jsxs(r,{side:"top",align:"start",className:"w-[360px] p-0",children:[d.jsxs("div",{className:"space-y-2 border-b border-gray-100 px-4 py-3",children:[d.jsx("div",{className:"text-sm font-semibold text-gray-900",children:s.title}),d.jsxs("div",{className:"relative",children:[d.jsx(Un,{className:"pointer-events-none absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400"}),d.jsx(t,{value:o,onChange:g=>u(g.target.value),onKeyDown:S,placeholder:s.searchPlaceholder,role:"combobox","aria-controls":l,"aria-expanded":"true","aria-autocomplete":"list","aria-activedescendant":m[h]?`${l}-option-${h}`:void 0,className:"h-8 rounded-lg pl-8 text-xs"})]})]}),d.jsx("div",{ref:a,id:l,role:"listbox","aria-multiselectable":"true",className:"custom-scrollbar max-h-[320px] overflow-y-auto",children:s.isLoading?d.jsx("div",{className:"p-4 text-xs text-gray-500",children:s.loadingLabel}):m.length===0?d.jsx("div",{className:"p-4 text-center text-xs text-gray-500",children:s.emptyLabel}):d.jsx("div",{className:"py-1",children:m.map((g,I)=>{const M=p.has(g.key),D=I===h;return d.jsxs("button",{type:"button",id:`${l}-option-${I}`,role:"option","aria-selected":M,"data-skill-index":I,onClick:()=>y(g.key),onMouseEnter:()=>c(I),className:`flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${D?"bg-gray-50":"hover:bg-gray-50"}`,children:[d.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-500",children:d.jsx(Ja,{className:"h-4 w-4"})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:"truncate text-sm text-gray-900",children:g.label}),g.badgeLabel?d.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary",children:g.badgeLabel}):null]}),d.jsx("div",{className:"mt-0.5 truncate text-xs text-gray-500",children:g.description||g.key})]}),d.jsx("div",{className:"ml-3 shrink-0",children:d.jsx("span",{className:M?"inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary text-white":"inline-flex h-5 w-5 items-center justify-center rounded-full border border-gray-300 bg-white",children:M?d.jsx(Ht,{className:"h-3 w-3"}):null})})]},g.key)})})}),s.manageHref&&s.manageLabel?d.jsx("div",{className:"border-t border-gray-100 px-4 py-2.5",children:d.jsxs("a",{href:s.manageHref,className:"inline-flex items-center gap-1.5 text-xs font-medium text-primary transition-colors hover:text-primary/80",children:[s.manageLabel,d.jsx(Za,{className:"h-3 w-3"})]})}):null]})]})}function ds({icon:e}){return e==="sparkles"?d.jsx(tl,{className:"h-3.5 w-3.5 shrink-0 text-primary"}):e==="brain"?d.jsx(nl,{className:"h-3.5 w-3.5 shrink-0 text-gray-500"}):null}function Su({icon:e}){return e==="paperclip"?d.jsx(el,{className:"h-4 w-4"}):d.jsx(ds,{icon:e})}function ku(e){return e==="model"?"min-w-[220px]":e==="session-type"?"min-w-[140px]":e==="thinking"?"min-w-[150px]":""}function wu(e){return e==="model"?"w-[320px]":e==="session-type"?"w-[220px]":e==="thinking"?"w-[180px]":""}function Cu({item:e}){const{Select:t,SelectContent:n,SelectItem:r,SelectTrigger:i,SelectValue:s}=St;return d.jsxs(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[d.jsx(i,{className:`h-8 w-auto rounded-lg border-0 bg-transparent px-3 text-xs font-medium text-gray-600 shadow-none hover:bg-gray-100 focus:ring-0 ${ku(e.key)}`,children:e.selectedLabel?d.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-left",children:[d.jsx(ds,{icon:e.icon}),d.jsx("span",{className:"truncate text-xs font-semibold text-gray-700",children:e.selectedLabel})]}):e.loading?d.jsx("div",{className:"h-3 w-24 animate-pulse rounded bg-gray-200"}):d.jsx(s,{placeholder:e.placeholder})}),d.jsxs(n,{className:wu(e.key),children:[e.options.length===0?e.loading?d.jsxs("div",{className:"space-y-2 px-3 py-2",children:[d.jsx("div",{className:"h-3 w-36 animate-pulse rounded bg-gray-200"}),d.jsx("div",{className:"h-3 w-28 animate-pulse rounded bg-gray-200"}),d.jsx("div",{className:"h-3 w-32 animate-pulse rounded bg-gray-200"})]}):e.emptyLabel?d.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:e.emptyLabel}):null:null,e.options.map(a=>d.jsx(r,{value:a.value,className:"py-2",children:a.description?d.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[d.jsx("span",{className:"truncate text-xs font-semibold text-gray-800",children:a.label}),d.jsx("span",{className:"truncate text-[11px] text-gray-500",children:a.description})]}):d.jsx("span",{className:"truncate text-xs font-semibold text-gray-800",children:a.label})},a.value))]})]})}function vu(e){var s;const{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=St;return d.jsxs("div",{className:"flex items-center justify-between px-3 pb-3",children:[d.jsxs("div",{className:"flex items-center gap-1",children:[e.skillPicker?d.jsx(bu,{picker:e.skillPicker}):null,e.selects.map(a=>d.jsx(Cu,{item:a},a.key)),(s=e.accessories)==null?void 0:s.map(a=>{const l=d.jsxs("button",{type:"button",className:`inline-flex items-center rounded-lg py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 disabled:cursor-not-allowed disabled:text-gray-400 ${a.iconOnly?"h-8 w-8 justify-center px-0":"gap-1.5 px-3"}`,onClick:a.onClick,disabled:a.disabled,"aria-label":a.label,children:[d.jsx(Su,{icon:a.icon}),a.iconOnly?null:d.jsx("span",{children:a.label})]});if(!a.tooltip)return d.jsx("div",{children:l},a.key);const o=a.disabled?d.jsx("span",{className:"inline-flex",children:l}):l;return d.jsx(r,{children:d.jsxs(t,{children:[d.jsx(i,{asChild:!0,children:o}),d.jsx(n,{side:"top",children:d.jsx("p",{className:"text-xs",children:a.tooltip})})]})},a.key)})]}),d.jsx(xu,{...e.actions})]})}const Tu="";function fs(){return`composer-${Math.random().toString(36).slice(2,10)}`}function gt(e=""){return{id:fs(),type:"text",text:e}}function Wn(e){return{id:fs(),type:"token",tokenKind:e.tokenKind,tokenKey:e.tokenKey,label:e.label}}function kt(e){return e.type==="text"?e.text.length:1}function Qn(){return[gt("")]}function Iu(e){return[gt(e)]}function Je(e){const t=[];for(const n of e){if(n.type==="text"){if(n.text.length===0)continue;const r=t[t.length-1];if((r==null?void 0:r.type)==="text"){t[t.length-1]={...r,text:r.text+n.text};continue}}t.push(n)}return t.length===0?Qn():t}function Mu(e){return e.map(t=>t.type==="text"?t.text:Tu).join("")}function Nu(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Kt(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 Lu(e,t,n,r){const i=Math.max(0,n-t),s=Math.max(0,t+e.text.length-r),a=[];return i>0&&a.push({...e,text:e.text.slice(0,i)}),s>0&&a.push({...e,text:e.text.slice(e.text.length-s)}),a}function Eu(e,t,n,r){return t<=n||e>=r}function Au(e,t,n,r,i){return!n&&r>=i?(e.push(...t),!0):n}function Ru(e,t,n,r,i,s,a){const l=Lu(t,n,r,i);l[0]&&e.push(l[0]);let o=a;return o||(e.push(...s),o=!0),l[1]&&e.push(l[1]),o}function ju(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),a=[];let l=0,o=!1;for(const u of e){const h=kt(u),c=l,p=l+h;if(Eu(c,p,i,s)){o=Au(a,r,o,c,s),a.push(u),l=p;continue}u.type==="text"?o=Ru(a,u,c,i,s,r,o):o=ju(a,u,r,o,i,c),l=p}return o||a.push(...r),Je(a)}function Gn(e,t){return Je(e.filter(n=>n.type!=="token"||!t(n)))}function Pu(e,t){if(!t||t.start!==t.end)return null;const n=Mu(e),r=t.end,i=n.slice(0,r),s=/(?:^|\s)\/([^\s\uFFFC]*)$/.exec(i);if(!s)return null;const a=r-s[0].length+(s[0].startsWith("/")?0:1);return{query:(s[1]??"").trim().toLowerCase(),start:a,end:r}}function Du(e,t,n){return e?e.start<n&&e.end>t:!1}function ps(e){const t=new Map;let n=0;for(const r of e)t.set(r.id,n),n+=kt(r);return t}function ms(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 Ou(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 gs(e,t,n){let r=0;for(let i=0;i<n;i+=1){const s=Ou(e.childNodes[i],i,t);s&&(r+=kt(s))}return r}function Fu(e,t,n,r){var l;const i=ms(e,t),s=gs(e,r,i),a=r[i];return(a==null?void 0:a.type)==="text"?s+Math.min(n,a.text.length):s+Math.min(n,((l=t.textContent)==null?void 0:l.length)??0)}function zu(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 vn(e,t,n,r,i){var u;if(t===e)return gs(e,r,n);if(t.nodeType===Node.TEXT_NODE&&t.parentNode===e)return Fu(e,t,n,r);const s=t instanceof HTMLElement?t.closest("[data-composer-node-id]"):((u=t.parentElement)==null?void 0:u.closest("[data-composer-node-id]"))??null;if(!(s instanceof HTMLElement)){const h=ms(e,t);return vn(e,e,h,r,i)}const a=s.dataset.composerNodeId;if(!a)return 0;const l=r.find(h=>h.id===a),o=i.get(a)??0;return l?zu(t,n,l,o,s):o}function xs(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=ps(t),s=vn(e,r.startContainer,r.startOffset,t,i),a=vn(e,r.endContainer,r.endOffset,t,i);return{start:Math.min(s,a),end:Math.max(s,a)}}function _u(e,t,n){if(!n)return;const r=window.getSelection();if(!r)return;const i=o=>{let u=0;for(let h=0;h<t.length;h+=1){const c=t[h],p=kt(c),f=u,m=u+p,y=e.childNodes[h];if(!y){u=m;continue}if(c.type==="text"){if(o<=m)return{container:y.firstChild??y,offset:Math.max(0,Math.min(o-f,c.text.length))}}else{if(o<=f)return{container:e,offset:h};if(o<=m)return{container:e,offset:h+1}}u=m}return{container:e,offset:e.childNodes.length}},s=i(n.start),a=i(n.end),l=document.createRange();l.setStart(s.container,s.offset),l.setEnd(a.container,a.offset),r.removeAllRanges(),r.addRange(l)}function Bu(e){const t=[];for(const n of Array.from(e.childNodes)){if(n.nodeType===Node.TEXT_NODE){t.push(gt(n.textContent??""));continue}if(!(n instanceof HTMLElement))continue;if(n.dataset.composerNodeType==="token"){const s=n.dataset.composerTokenKind,a=n.dataset.composerTokenKey,l=n.dataset.composerLabel;s&&a&&l&&t.push({id:n.dataset.composerNodeId??Wn({tokenKind:s,tokenKey:a,label:l}).id,type:"token",tokenKind:s,tokenKey:a,label:l});continue}const i=n.textContent??"";t.push({id:n.dataset.composerNodeId??gt(i).id,type:"text",text:i})}return Je(t)}function Lr(e){const t=Bu(e);return{nodes:t,selection:xs(e,t)}}class Uu{constructor(){this.nodes=Qn(),this.selection=null,this.sync=(t,n)=>(this.nodes=Je(t),this.selection=n,this.getSnapshot()),this.setSelection=t=>(this.selection=t,this.getSnapshot()),this.replaceDocument=(t,n)=>(this.nodes=Je(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,[gt(t)]);const r=n.start+t.length;return this.selection={start:r,end:r},this.getSnapshot()},this.insertFileToken=(t,n)=>this.insertToken("file",t,n),this.insertSkillToken=(t,n)=>this.getSelectedSkillKeys().includes(t)?this.getSnapshot():this.insertToken("skill",t,n,this.getSlashTrigger()),this.syncSelectedSkills=(t,n)=>{const r=this.getSelectedSkillKeys(),i=new Map(n.map(l=>[l.key,l])),s=t.find(l=>!r.includes(l));if(s){const l=i.get(s);return this.insertSkillToken(s,(l==null?void 0:l.label)??s)}const a=r.find(l=>!t.includes(l));return a&&(this.nodes=Gn(this.nodes,l=>l.tokenKind==="skill"&&l.tokenKey===a)),this.getSnapshot()},this.deleteContent=t=>{const n=this.getDocumentLength(),r=this.selection??{start:n,end:n};let i=r.start,s=r.end;if(r.start===r.end)if(t==="backward"&&r.start>0)i=r.start-1;else if(t==="forward")s=r.end+1;else return this.getSnapshot();return this.nodes=en(this.nodes,i,s,[]),this.selection={start:i,end:i},this.getSnapshot()},this.getSnapshot=()=>({nodes:this.nodes,selection:this.selection,nodeStartMap:ps(this.nodes),documentLength:this.getDocumentLength(),selectedSkillKeys:this.getSelectedSkillKeys(),slashTrigger:this.getSlashTrigger()}),this.getDocumentLength=()=>this.nodes.reduce((t,n)=>t+kt(n),0),this.getSelectedSkillKeys=()=>Kt(this.nodes,"skill"),this.insertToken=(t,n,r,i=null)=>{var o,u;const s=this.getDocumentLength(),a=(i==null?void 0:i.start)??((o=this.selection)==null?void 0:o.start)??s,l=(i==null?void 0:i.end)??((u=this.selection)==null?void 0:u.end)??a;return this.nodes=en(this.nodes,a,l,[Wn({tokenKind:t,tokenKey:n,label:r})]),this.selection={start:a+1,end:a+1},this.getSnapshot()},this.getSlashTrigger=()=>Pu(this.nodes,this.selection)}}function Hu(e){const{key:t,shiftKey:n,isComposing:r,isSlashMenuOpen:i,slashItemCount:s,activeSlashIndex:a,isSending:l,canStopGeneration:o}=e;if(i&&s>0){if(t==="ArrowDown")return{type:"move-slash-index",index:(a+1)%s};if(t==="ArrowUp")return{type:"move-slash-index",index:(a-1+s)%s};if(t==="Enter"&&!n||t==="Tab")return{type:"insert-active-slash-item"}}return t==="Escape"?i?{type:"close-slash"}:l&&o?{type:"stop-generation"}:{type:"noop"}:t==="Enter"&&n?{type:"insert-line-break"}:t==="Enter"?{type:"send-message"}:!r&&(t==="Backspace"||t==="Delete")?{type:"delete-content",direction:t==="Backspace"?"backward":"forward"}:{type:"noop"}}const Er="http://www.w3.org/2000/svg";class Vu{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=Du(n,i,i+1),a=document.createElement("span");a.contentEditable="false",a.dataset.composerNodeId=t.id,a.dataset.composerNodeType="token",a.dataset.composerTokenKind=t.tokenKind,a.dataset.composerTokenKey=t.tokenKey,a.dataset.composerLabel=t.label,a.title=t.label,a.className=this.buildTokenClassName(t.tokenKind,s),a.append(this.createTokenIcon(t.tokenKind));const l=document.createElement("span");return l.className=t.tokenKind==="file"?"min-w-0 flex-1 truncate text-[12px] font-medium text-slate-700":"truncate",l.textContent=t.label,a.append(l),a},this.buildTokenClassName=(t,n)=>t==="file"?["mx-[2px]","inline-flex","h-7","max-w-[min(100%,17rem)]","items-center","gap-1.5","rounded-lg","border","px-2","align-baseline","transition-[border-color,background-color,box-shadow,color]","duration-150",n?"border-slate-300 bg-slate-100 text-slate-800 shadow-[0_0_0_2px_rgba(148,163,184,0.14)]":"border-slate-200/80 bg-slate-50 text-slate-700"].join(" "):["mx-[2px]","inline-flex","h-7","max-w-full","items-center","gap-1.5","rounded-lg","border","px-2","align-baseline","text-[11px]","font-medium","transition",n?"border-primary/30 bg-primary/18 text-primary":"border-primary/12 bg-primary/8 text-primary"].join(" "),this.createTokenIcon=t=>{const n=document.createElement("span");return n.className=t==="file"?"inline-flex h-4.5 w-4.5 shrink-0 items-center justify-center rounded-md bg-white text-slate-500 ring-1 ring-black/5":"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center text-primary/70",n.append(t==="file"?this.createFileIcon():this.createSkillIcon()),n},this.createSkillIcon=()=>this.createSvgIcon([{tag:"path",attrs:{d:"M8.5 2.75 2.75 6l5.75 3.25L14.25 6 8.5 2.75Z"}},{tag:"path",attrs:{d:"M2.75 10 8.5 13.25 14.25 10"}},{tag:"path",attrs:{d:"M2.75 6v4l5.75 3.25V9.25L2.75 6Z"}},{tag:"path",attrs:{d:"M14.25 6v4L8.5 13.25V9.25L14.25 6Z"}}]),this.createFileIcon=()=>this.createSvgIcon([{tag:"path",attrs:{d:"M3.25 4.25A1.5 1.5 0 0 1 4.75 2.75h6.5a1.5 1.5 0 0 1 1.5 1.5v7.5a1.5 1.5 0 0 1-1.5 1.5h-6.5a1.5 1.5 0 0 1-1.5-1.5v-7.5Z"}},{tag:"path",attrs:{d:"m4.75 10 2.25-2.5 1.75 1.75 1.25-1.25 2 2"}},{tag:"path",attrs:{d:"M9.75 6.25h.01"}}]),this.createSvgIcon=t=>{const n=document.createElementNS(Er,"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(Er,r.tag);for(const[s,a]of Object.entries(r.attrs))i.setAttribute(s,a);n.append(i)}return n}}}const Ar=188;class $u{constructor(t){this.controller=t,this.surfaceRenderer=new Vu,this.sync=(n,r)=>this.controller.sync(n,r),this.syncSelectionFromRoot=n=>this.controller.setSelection(xs(n,this.controller.getSnapshot().nodes)),this.restoreSelectionIfFocused=(n,r)=>{!n||document.activeElement!==n||_u(n,this.controller.getSnapshot().nodes,r)},this.syncViewport=n=>{n&&(n.style.maxHeight=`${Ar}px`,n.style.overflowY=n.scrollHeight>Ar?"auto":"hidden")},this.renderSurface=n=>{this.surfaceRenderer.render(n.root,{nodes:n.snapshot.nodes,selectedRange:n.selectedRange,nodeStartMap:n.snapshot.nodeStartMap})},this.insertSlashItem=(n,r)=>{n.value&&r(this.controller.insertSkillToken(n.value,n.title))},this.syncSelectedSkills=(n,r,i)=>{i(this.controller.syncSelectedSkills(n,r))},this.handleBeforeInput=n=>{const{event:r,disabled:i,isComposing:s,commitSnapshot:a}=n,l=r.nativeEvent;i||s||l.isComposing||!(l.inputType==="insertText"||l.inputType==="insertReplacementText")||!l.data||(r.preventDefault(),a(this.controller.insertText(l.data)))},this.handleInput=n=>{const{event:r,isComposing:i,commitSnapshot:s}=n,a=r.nativeEvent;if(i||a.isComposing)return;const l=r.currentTarget,o=Lr(l);s(this.controller.replaceDocument(o.nodes,o.selection))},this.handleCompositionEnd=n=>{const{event:r,commitSnapshot:i}=n,s=r.currentTarget,a=Lr(s);i(this.controller.replaceDocument(a.nodes,a.selection))},this.handleKeyDown=n=>{const{event:r,slashItems:i,activeSlashIndex:s,activeSlashItem:a,actions:l,commitSnapshot:o,insertSkillToken:u,onSlashActiveIndexChange:h,onSlashQueryChange:c,onSlashOpenChange:p}=n,f=this.controller.getSnapshot(),m=Hu({key:r.key,shiftKey:r.shiftKey,isComposing:r.nativeEvent.isComposing,isSlashMenuOpen:f.slashTrigger!==null,slashItemCount:i.length,activeSlashIndex:s,isSending:l.isSending,canStopGeneration:l.canStopGeneration});if(m.type!=="noop"){if(r.preventDefault(),m.type==="move-slash-index"){h(m.index);return}if(m.type==="insert-active-slash-item"){a&&u(a.value??a.key,a.title);return}if(m.type==="close-slash"){c==null||c(null),p(!1);return}if(m.type==="stop-generation"){l.onStop();return}if(m.type==="insert-line-break"){o(this.controller.insertText(`
3
- `));return}if(m.type==="send-message"){l.onSend();return}m.type==="delete-content"&&o(this.controller.deleteContent(m.direction))}},this.handlePaste=n=>{const{event:r,onFilesAdd:i,commitSnapshot:s}=n,a=Array.from(r.clipboardData.files??[]);if(a.length>0&&i){r.preventDefault(),i(a);return}const l=r.clipboardData.getData("text/plain");l&&(r.preventDefault(),s(this.controller.insertText(l)))},this.handleBlur=n=>{const{clearSelectedRange:r,onSlashQueryChange:i,onSlashOpenChange:s}=n;r(),i==null||i(null),s(!1)}}}class Ku{constructor(){this.controller=new Uu,this.viewController=new $u(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 qu=C.forwardRef(function(t,n){const{nodes:r,placeholder:i,disabled:s,slashItems:a,actions:l,onNodesChange:o,onFilesAdd:u,onSlashQueryChange:h,onSlashTriggerChange:c,onSlashOpenChange:p,onSlashActiveIndexChange:f,activeSlashIndex:m}=t,[y,S]=C.useState(0),[g]=C.useState(()=>new Ku),{snapshot:I,bindRootElement:M,handleBeforeInput:D,handleInput:O,handleCompositionStart:T,handleCompositionEnd:z,handleKeyDown:_,handlePaste:B,handleBlur:k,syncSelectionState:L,imperativeHandle:E}=g.update({nodes:r,disabled:s,slashItems:a,actions:l,onNodesChange:o,onFilesAdd:u,onSlashQueryChange:h,onSlashTriggerChange:c,onSlashOpenChange:p,onSlashActiveIndexChange:f,activeSlashIndex:m,requestRender:()=>S(U=>U+1)});return C.useImperativeHandle(n,()=>E,[E]),C.useLayoutEffect(()=>{g.renderSurface(),g.restoreDomAfterCommit(),g.syncViewport()},[g,I.nodes,I.nodeStartMap,y]),d.jsx("div",{className:"px-4 py-2.5",children:d.jsx("div",{className:"min-h-[60px]",children:d.jsx("div",{ref:M,contentEditable:!s,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":"true","data-placeholder":i,onBeforeInput:D,onInput:O,onCompositionStart:T,onCompositionEnd:z,onKeyDown:_,onKeyUp:L,onMouseUp:L,onFocus:L,onBlur:k,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 Wu({hint:e}){if(!e)return null;if(e.loading)return d.jsx("div",{className:"px-4 pb-2",children:d.jsxs("div",{className:"inline-flex items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2",children:[d.jsx("span",{className:"h-3 w-28 animate-pulse rounded bg-gray-200"}),d.jsx("span",{className:"h-3 w-16 animate-pulse rounded bg-gray-200"})]})});const t=e.tone==="warning"?"border-amber-200 bg-amber-50 text-amber-800":"border-gray-200 bg-gray-50 text-gray-700";return d.jsx("div",{className:"px-4 pb-2",children:d.jsxs("div",{className:`inline-flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs ${t}`,children:[e.text?d.jsx("span",{children:e.text}):null,e.actionLabel&&e.onAction?d.jsx("button",{type:"button",onClick:e.onAction,className:"font-semibold underline-offset-2 hover:underline",children:e.actionLabel}):null]})})}const ys=C.forwardRef(function(t,n){const r=C.useRef(null),[i,s]=C.useState(null),[a,l]=C.useState(0),[o,u]=C.useState(null),[h,c]=C.useState(null),p=o!==null&&h!==o,f=t.slashMenu.items[a]??null;C.useEffect(()=>{l(y=>t.slashMenu.items.length===0?0:Math.min(y,t.slashMenu.items.length-1))},[t.slashMenu.items.length]),C.useEffect(()=>{i!==null&&l(0)},[i]),C.useEffect(()=>{o===null&&h!==null&&c(null)},[o,h]);const m=C.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 C.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()}}),[]),d.jsx("div",{className:"border-t border-gray-200/80 bg-white p-4",children:d.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)]",children:d.jsxs("div",{className:"overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-card",children:[d.jsxs("div",{className:"relative",children:[d.jsx(qu,{ref:r,nodes:t.composer.nodes,placeholder:t.composer.placeholder,disabled:t.composer.disabled,slashItems:t.slashMenu.items,actions:t.toolbar.actions,activeSlashIndex:a,onNodesChange:t.composer.onNodesChange,onFilesAdd:t.composer.onFilesAdd,onSlashQueryChange: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&&c(o)},onSlashActiveIndexChange:l}),d.jsx(mu,{isOpen:p,isLoading:t.slashMenu.isLoading,items:t.slashMenu.items,activeIndex:a,activeItem:f,texts:t.slashMenu.texts,onSelectItem:y=>{var S;c(null),(S=r.current)==null||S.insertSlashItem(y)},onOpenChange:y=>{!y&&o!==null&&c(o)},onSetActiveIndex:l})]}),d.jsx(Wu,{hint:t.hint}),d.jsx(vu,{...m})]})})})});ys.displayName="ChatInputBar";function tn({role:e}){return e==="user"?d.jsx("div",{"data-testid":"chat-message-avatar-user",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-white shadow-sm",children:d.jsx(rl,{className:"h-4 w-4"})}):e==="tool"?d.jsx("div",{"data-testid":"chat-message-avatar-tool",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-amber-100 text-amber-700 shadow-sm",children:d.jsx(Ui,{className:"h-4 w-4"})}):d.jsx("div",{"data-testid":"chat-message-avatar-assistant",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-gray-200/80 bg-gray-900 text-white shadow-sm",children:d.jsx(Hi,{className:"h-4 w-4"})})}function Qu(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Gu=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Yu=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Xu={};function Rr(e,t){return(Xu.jsx?Yu:Gu).test(e)}const Ju=/[ \t\n\f\r]/g;function Zu(e){return typeof e=="object"?e.type==="text"?jr(e.value):!1:jr(e)}function jr(e){return e.replace(Ju,"")===""}class wt{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}wt.prototype.normal={};wt.prototype.property={};wt.prototype.space=void 0;function bs(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new wt(n,r,t)}function Tn(e){return e.toLowerCase()}class fe{constructor(t,n){this.attribute=n,this.property=t}}fe.prototype.attribute="";fe.prototype.booleanish=!1;fe.prototype.boolean=!1;fe.prototype.commaOrSpaceSeparated=!1;fe.prototype.commaSeparated=!1;fe.prototype.defined=!1;fe.prototype.mustUseProperty=!1;fe.prototype.number=!1;fe.prototype.overloadedBoolean=!1;fe.prototype.property="";fe.prototype.spaceSeparated=!1;fe.prototype.space=void 0;let ec=0;const V=qe(),ie=qe(),In=qe(),A=qe(),J=qe(),Xe=qe(),xe=qe();function qe(){return 2**++ec}const Mn=Object.freeze(Object.defineProperty({__proto__:null,boolean:V,booleanish:ie,commaOrSpaceSeparated:xe,commaSeparated:Xe,number:A,overloadedBoolean:In,spaceSeparated:J},Symbol.toStringTag,{value:"Module"})),nn=Object.keys(Mn);class Yn extends fe{constructor(t,n,r,i){let s=-1;if(super(t,n),Pr(this,"space",i),typeof r=="number")for(;++s<nn.length;){const a=nn[s];Pr(this,nn[s],(r&Mn[a])===Mn[a])}}}Yn.prototype.defined=!0;function Pr(e,t,n){n&&(e[t]=n)}function et(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Yn(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Tn(r)]=r,n[Tn(s.attribute)]=r}return new wt(t,n,e.space)}const Ss=et({properties:{ariaActiveDescendant:null,ariaAtomic:ie,ariaAutoComplete:null,ariaBusy:ie,ariaChecked:ie,ariaColCount:A,ariaColIndex:A,ariaColSpan:A,ariaControls:J,ariaCurrent:null,ariaDescribedBy:J,ariaDetails:null,ariaDisabled:ie,ariaDropEffect:J,ariaErrorMessage:null,ariaExpanded:ie,ariaFlowTo:J,ariaGrabbed:ie,ariaHasPopup:null,ariaHidden:ie,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:J,ariaLevel:A,ariaLive:null,ariaModal:ie,ariaMultiLine:ie,ariaMultiSelectable:ie,ariaOrientation:null,ariaOwns:J,ariaPlaceholder:null,ariaPosInSet:A,ariaPressed:ie,ariaReadOnly:ie,ariaRelevant:null,ariaRequired:ie,ariaRoleDescription:J,ariaRowCount:A,ariaRowIndex:A,ariaRowSpan:A,ariaSelected:ie,ariaSetSize:A,ariaSort:null,ariaValueMax:A,ariaValueMin:A,ariaValueNow:A,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function ks(e,t){return t in e?e[t]:t}function ws(e,t){return ks(e,t.toLowerCase())}const tc=et({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Xe,acceptCharset:J,accessKey:J,action:null,allow:null,allowFullScreen:V,allowPaymentRequest:V,allowUserMedia:V,alt:null,as:null,async:V,autoCapitalize:null,autoComplete:J,autoFocus:V,autoPlay:V,blocking:J,capture:null,charSet:null,checked:V,cite:null,className:J,cols:A,colSpan:null,content:null,contentEditable:ie,controls:V,controlsList:J,coords:A|Xe,crossOrigin:null,data:null,dateTime:null,decoding:null,default:V,defer:V,dir:null,dirName:null,disabled:V,download:In,draggable:ie,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:V,formTarget:null,headers:J,height:A,hidden:In,high:A,href:null,hrefLang:null,htmlFor:J,httpEquiv:J,id:null,imageSizes:null,imageSrcSet:null,inert:V,inputMode:null,integrity:null,is:null,isMap:V,itemId:null,itemProp:J,itemRef:J,itemScope:V,itemType:J,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:V,low:A,manifest:null,max:null,maxLength:A,media:null,method:null,min:null,minLength:A,multiple:V,muted:V,name:null,nonce:null,noModule:V,noValidate:V,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:V,optimum:A,pattern:null,ping:J,placeholder:null,playsInline:V,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:V,referrerPolicy:null,rel:J,required:V,reversed:V,rows:A,rowSpan:A,sandbox:J,scope:null,scoped:V,seamless:V,selected:V,shadowRootClonable:V,shadowRootDelegatesFocus:V,shadowRootMode:null,shape:null,size:A,sizes:null,slot:null,span:A,spellCheck:ie,src:null,srcDoc:null,srcLang:null,srcSet:null,start:A,step:null,style:null,tabIndex:A,target:null,title:null,translate:null,type:null,typeMustMatch:V,useMap:null,value:ie,width:A,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:J,axis:null,background:null,bgColor:null,border:A,borderColor:null,bottomMargin:A,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:V,declare:V,event:null,face:null,frame:null,frameBorder:null,hSpace:A,leftMargin:A,link:null,longDesc:null,lowSrc:null,marginHeight:A,marginWidth:A,noResize:V,noHref:V,noShade:V,noWrap:V,object:null,profile:null,prompt:null,rev:null,rightMargin:A,rules:null,scheme:null,scrolling:ie,standby:null,summary:null,text:null,topMargin:A,valueType:null,version:null,vAlign:null,vLink:null,vSpace:A,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:V,disableRemotePlayback:V,prefix:null,property:null,results:A,security:null,unselectable:null},space:"html",transform:ws}),nc=et({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:xe,accentHeight:A,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:A,amplitude:A,arabicForm:null,ascent:A,attributeName:null,attributeType:null,azimuth:A,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:A,by:null,calcMode:null,capHeight:A,className:J,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:A,diffuseConstant:A,direction:null,display:null,dur:null,divisor:A,dominantBaseline:null,download:V,dx:null,dy:null,edgeMode:null,editable:null,elevation:A,enableBackground:null,end:null,event:null,exponent:A,externalResourcesRequired:null,fill:null,fillOpacity:A,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Xe,g2:Xe,glyphName:Xe,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:A,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:A,horizOriginX:A,horizOriginY:A,id:null,ideographic:A,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:A,k:A,k1:A,k2:A,k3:A,k4:A,kernelMatrix:xe,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:A,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:A,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:A,overlineThickness:A,paintOrder:null,panose1:null,path:null,pathLength:A,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:J,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:A,pointsAtY:A,pointsAtZ:A,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:xe,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:xe,rev:xe,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:xe,requiredFeatures:xe,requiredFonts:xe,requiredFormats:xe,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:A,specularExponent:A,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:A,strikethroughThickness:A,string:null,stroke:null,strokeDashArray:xe,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:A,strokeOpacity:A,strokeWidth:null,style:null,surfaceScale:A,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:xe,tabIndex:A,tableValues:null,target:null,targetX:A,targetY:A,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:xe,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:A,underlineThickness:A,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:A,values:null,vAlphabetic:A,vMathematical:A,vectorEffect:null,vHanging:A,vIdeographic:A,version:null,vertAdvY:A,vertOriginX:A,vertOriginY:A,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:A,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:ks}),Cs=et({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),vs=et({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:ws}),Ts=et({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),rc={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"},ic=/[A-Z]/g,Dr=/-[a-z]/g,sc=/^data[-\w.:]+$/i;function ac(e,t){const n=Tn(t);let r=t,i=fe;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&sc.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Dr,oc);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Dr.test(s)){let a=s.replace(ic,lc);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=Yn}return new i(r,t)}function lc(e){return"-"+e.toLowerCase()}function oc(e){return e.charAt(1).toUpperCase()}const uc=bs([Ss,tc,Cs,vs,Ts],"html"),Xn=bs([Ss,nc,Cs,vs,Ts],"svg");function cc(e){return e.join(" ").trim()}var Qe={},rn,Or;function hc(){if(Or)return rn;Or=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,l=/^\s+|\s+$/g,o=`
4
- `,u="/",h="*",c="",p="comment",f="declaration";function m(S,g){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];g=g||{};var I=1,M=1;function D(P){var w=P.match(t);w&&(I+=w.length);var j=P.lastIndexOf(o);M=~j?P.length-j:M+P.length}function O(){var P={line:I,column:M};return function(w){return w.position=new T(P),B(),w}}function T(P){this.start=P,this.end={line:I,column:M},this.source=g.source}T.prototype.content=S;function z(P){var w=new Error(g.source+":"+I+":"+M+": "+P);if(w.reason=P,w.filename=g.source,w.line=I,w.column=M,w.source=S,!g.silent)throw w}function _(P){var w=P.exec(S);if(w){var j=w[0];return D(j),S=S.slice(j.length),w}}function B(){_(n)}function k(P){var w;for(P=P||[];w=L();)w!==!1&&P.push(w);return P}function L(){var P=O();if(!(u!=S.charAt(0)||h!=S.charAt(1))){for(var w=2;c!=S.charAt(w)&&(h!=S.charAt(w)||u!=S.charAt(w+1));)++w;if(w+=2,c===S.charAt(w-1))return z("End of comment missing");var j=S.slice(2,w-2);return M+=2,D(j),S=S.slice(w),M+=2,P({type:p,comment:j})}}function E(){var P=O(),w=_(r);if(w){if(L(),!_(i))return z("property missing ':'");var j=_(s),$=P({type:f,property:y(w[0].replace(e,c)),value:j?y(j[0].replace(e,c)):c});return _(a),$}}function U(){var P=[];k(P);for(var w;w=E();)w!==!1&&(P.push(w),k(P));return P}return B(),U()}function y(S){return S?S.replace(l,c):c}return rn=m,rn}var Fr;function dc(){if(Fr)return Qe;Fr=1;var e=Qe&&Qe.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.default=n;const t=e(hc());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const a=(0,t.default)(r),l=typeof i=="function";return a.forEach(o=>{if(o.type!=="declaration")return;const{property:u,value:h}=o;l?i(u,h,o):h&&(s=s||{},s[u]=h)}),s}return Qe}var at={},zr;function fc(){if(zr)return at;zr=1,Object.defineProperty(at,"__esModule",{value:!0}),at.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(u){return!u||n.test(u)||e.test(u)},a=function(u,h){return h.toUpperCase()},l=function(u,h){return"".concat(h,"-")},o=function(u,h){return h===void 0&&(h={}),s(u)?u:(u=u.toLowerCase(),h.reactCompat?u=u.replace(i,l):u=u.replace(r,l),u.replace(t,a))};return at.camelCase=o,at}var lt,_r;function pc(){if(_r)return lt;_r=1;var e=lt&&lt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(dc()),n=fc();function r(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(l,o){l&&o&&(a[(0,n.camelCase)(l,s)]=o)}),a}return r.default=r,lt=r,lt}var mc=pc();const gc=Vi(mc),Is=Ms("end"),Jn=Ms("start");function Ms(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 xc(e){const t=Jn(e),n=Is(e);if(t&&n)return{start:t,end:n}}function ft(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Br(e.position):"start"in e||"end"in e?Br(e):"line"in e||"column"in e?Nn(e):""}function Nn(e){return Ur(e&&e.line)+":"+Ur(e&&e.column)}function Br(e){return Nn(e&&e.start)+"-"+Nn(e&&e.end)}function Ur(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={},a=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(a=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const o=r.indexOf(":");o===-1?s.ruleId=r:(s.source=r.slice(0,o),s.ruleId=r.slice(o+1))}if(!s.place&&s.ancestors&&s.ancestors){const o=s.ancestors[s.ancestors.length-1];o&&(s.place=o.position)}const l=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=ft(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}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 Zn={}.hasOwnProperty,yc=new Map,bc=/[A-Z]/g,Sc=new Set(["table","tbody","thead","tfoot","tr"]),kc=new Set(["td","th"]),Ns="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function wc(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=Ec(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=Lc(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"?Xn:uc,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=Ls(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function Ls(e,t,n){if(t.type==="element")return Cc(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return vc(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Ic(e,t,n);if(t.type==="mdxjsEsm")return Tc(e,t);if(t.type==="root")return Mc(e,t,n);if(t.type==="text")return Nc(e,t)}function Cc(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Xn,e.schema=i),e.ancestors.push(t);const s=As(e,t.tagName,!1),a=Ac(e,t);let l=tr(e,t);return Sc.has(t.tagName)&&(l=l.filter(function(o){return typeof o=="string"?!Zu(o):!0})),Es(e,a,s,t),er(a,l),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function vc(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)}xt(e,t.position)}function Tc(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);xt(e,t.position)}function Ic(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Xn,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:As(e,t.name,!0),a=Rc(e,t),l=tr(e,t);return Es(e,a,s,t),er(a,l),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function Mc(e,t,n){const r={};return er(r,tr(e,t)),e.create(t,e.Fragment,r,n)}function Nc(e,t){return t.value}function Es(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function er(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Lc(e,t,n){return r;function r(i,s,a,l){const u=Array.isArray(a.children)?n:t;return l?u(s,a,l):u(s,a)}}function Ec(e,t){return n;function n(r,i,s,a){const l=Array.isArray(s.children),o=Jn(r);return t(i,s,a,l,{columnNumber:o?o.column-1:void 0,fileName:e,lineNumber:o?o.line:void 0},void 0)}}function Ac(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Zn.call(t.properties,i)){const s=jc(e,i,t.properties[i]);if(s){const[a,l]=s;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&kc.has(t.tagName)?r=l:n[a]=l}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Rc(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const a=s.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else xt(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,s=e.evaluater.evaluateExpression(l.expression)}else xt(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function tr(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:yc;for(;++r<t.children.length;){const s=t.children[r];let a;if(e.passKeys){const o=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(o){const u=i.get(o)||0;a=o+"-"+u,i.set(o,u+1)}}const l=Ls(e,s,a);l!==void 0&&n.push(l)}return n}function jc(e,t,n){const r=ac(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Qu(n):cc(n)),r.property==="style"){let i=typeof n=="object"?n:Pc(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Dc(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?rc[r.property]||r.property:r.attribute,n]}}function Pc(e,t){try{return gc(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=Ns+"#cannot-parse-style-attribute",i}}function As(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,a;for(;++s<i.length;){const l=Rr(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(s&&l.type==="Literal"),optional:!1}:l}r=a}else r=Rr(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Zn.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);xt(e)}function xt(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=Ns+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Dc(e){const t={};let n;for(n in e)Zn.call(e,n)&&(t[Oc(n)]=e[n]);return t}function Oc(e){let t=e.replace(bc,Fc);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Fc(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"]},zc={};function nr(e,t){const n=zc,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Rs(e,r,i)}function Rs(e,t,n){if(_c(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 Hr(e.children,t,n)}return Array.isArray(e)?Hr(e,t,n):""}function Hr(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Rs(e[i],t,n);return r.join("")}function _c(e){return!!(e&&typeof e=="object")}const Vr=document.createElement("i");function rr(e){const t="&"+e+";";Vr.innerHTML=t;const n=Vr.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function ye(e,t,n,r){const i=e.length;let s=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);s<r.length;)a=r.slice(s,s+1e4),a.unshift(t,0),e.splice(...a),s+=1e4,t+=1e4}function be(e,t){return e.length>0?(ye(e,e.length,0,t),e):t}const $r={}.hasOwnProperty;function js(e){const t={};let n=-1;for(;++n<e.length;)Bc(t,e[n]);return t}function Bc(e,t){let n;for(n in t){const i=($r.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let a;if(s)for(a in s){$r.call(i,a)||(i[a]=[]);const l=s[a];Uc(i[a],Array.isArray(l)?l:l?[l]:[])}}}function Uc(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);ye(e,0,0,r)}function Ps(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 ve(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ce=Be(/[A-Za-z]/),oe=Be(/[\dA-Za-z]/),Hc=Be(/[#-'*+\--9=?A-Z^-~]/);function Ft(e){return e!==null&&(e<32||e===127)}const Ln=Be(/\d/),Vc=Be(/[\dA-Fa-f]/),$c=Be(/[!-/:-@[-`{-~]/);function F(e){return e!==null&&e<-2}function X(e){return e!==null&&(e<0||e===32)}function q(e){return e===-2||e===-1||e===32}const qt=Be(new RegExp("\\p{P}|\\p{S}","u")),Ke=Be(/\s/);function Be(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function tt(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let a="";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))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){const l=e.charCodeAt(n+1);s<56320&&l>56319&&l<57344?(a=String.fromCharCode(s,l),i=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Q(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(o){return q(o)?(e.enter(n),l(o)):t(o)}function l(o){return q(o)&&s++<i?(e.consume(o),l):(e.exit(n),t(o))}}const Kc={tokenize:qc};function qc(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),Q(e,t,"linePrefix")}function i(l){return e.enter("paragraph"),s(l)}function s(l){const o=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=o),n=o,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return F(l)?(e.consume(l),e.exit("chunkText"),s):(e.consume(l),a)}}const Wc={tokenize:Qc},Kr={tokenize:Gc};function Qc(e){const t=this,n=[];let r=0,i,s,a;return l;function l(M){if(r<n.length){const D=n[r];return t.containerState=D[1],e.attempt(D[0].continuation,o,u)(M)}return u(M)}function o(M){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&I();const D=t.events.length;let O=D,T;for(;O--;)if(t.events[O][0]==="exit"&&t.events[O][1].type==="chunkFlow"){T=t.events[O][1].end;break}g(r);let z=D;for(;z<t.events.length;)t.events[z][1].end={...T},z++;return ye(t.events,O+1,0,t.events.slice(D)),t.events.length=z,u(M)}return l(M)}function u(M){if(r===n.length){if(!i)return p(M);if(i.currentConstruct&&i.currentConstruct.concrete)return m(M);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Kr,h,c)(M)}function h(M){return i&&I(),g(r),p(M)}function c(M){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,m(M)}function p(M){return t.containerState={},e.attempt(Kr,f,m)(M)}function f(M){return r++,n.push([t.currentConstruct,t.containerState]),p(M)}function m(M){if(M===null){i&&I(),g(0),e.consume(M);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),y(M)}function y(M){if(M===null){S(e.exit("chunkFlow"),!0),g(0),e.consume(M);return}return F(M)?(e.consume(M),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(M),y)}function S(M,D){const O=t.sliceStream(M);if(D&&O.push(null),M.previous=s,s&&(s.next=M),s=M,i.defineSkip(M.start),i.write(O),t.parser.lazy[M.start.line]){let T=i.events.length;for(;T--;)if(i.events[T][1].start.offset<a&&(!i.events[T][1].end||i.events[T][1].end.offset>a))return;const z=t.events.length;let _=z,B,k;for(;_--;)if(t.events[_][0]==="exit"&&t.events[_][1].type==="chunkFlow"){if(B){k=t.events[_][1].end;break}B=!0}for(g(r),T=z;T<t.events.length;)t.events[T][1].end={...k},T++;ye(t.events,_+1,0,t.events.slice(z)),t.events.length=T}}function g(M){let D=n.length;for(;D-- >M;){const O=n[D];t.containerState=O[1],O[0].exit.call(t,e)}n.length=M}function I(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Gc(e,t,n){return Q(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ze(e){if(e===null||X(e)||Ke(e))return 1;if(qt(e))return 2}function Wt(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 En={name:"attention",resolveAll:Yc,tokenize:Xc};function Yc(e,t){let n=-1,r,i,s,a,l,o,u,h;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;o=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},p={...e[n][1].start};qr(c,-o),qr(p,o),a={type:o>1?"strongSequence":"emphasisSequence",start:c,end:{...e[r][1].end}},l={type:o>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},s={type:o>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:o>1?"strong":"emphasis",start:{...a.start},end:{...l.end}},e[r][1].end={...a.start},e[n][1].start={...l.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=be(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=be(u,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),u=be(u,Wt(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=be(u,[["exit",s,t],["enter",l,t],["exit",l,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,u=be(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,ye(e,r-1,n-r+3,u),n=r+u.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Xc(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Ze(r);let s;return a;function a(o){return s=o,e.enter("attentionSequence"),l(o)}function l(o){if(o===s)return e.consume(o),l;const u=e.exit("attentionSequence"),h=Ze(o),c=!h||h===2&&i||n.includes(o),p=!i||i===2&&h||n.includes(r);return u._open=!!(s===42?c:c&&(i||!p)),u._close=!!(s===42?p:p&&(h||!c)),t(o)}}function qr(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Jc={name:"autolink",tokenize:Zc};function Zc(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),a):f===64?n(f):u(f)}function a(f){return f===43||f===45||f===46||oe(f)?(r=1,l(f)):u(f)}function l(f){return f===58?(e.consume(f),r=0,o):(f===43||f===45||f===46||oe(f))&&r++<32?(e.consume(f),l):(r=0,u(f))}function o(f){return f===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):f===null||f===32||f===60||Ft(f)?n(f):(e.consume(f),o)}function u(f){return f===64?(e.consume(f),h):Hc(f)?(e.consume(f),u):n(f)}function h(f){return oe(f)?c(f):n(f)}function c(f){return f===46?(e.consume(f),r=0,h):f===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):p(f)}function p(f){if((f===45||oe(f))&&r++<63){const m=f===45?p:c;return e.consume(f),m}return n(f)}}const Ct={partial:!0,tokenize:eh};function eh(e,t,n){return r;function r(s){return q(s)?Q(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||F(s)?t(s):n(s)}}const Ds={continuation:{tokenize:nh},exit:rh,name:"blockQuote",tokenize:th};function th(e,t,n){const r=this;return i;function i(a){if(a===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),s}return n(a)}function s(a){return q(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function nh(e,t,n){const r=this;return i;function i(a){return q(a)?Q(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(Ds,t,n)(a)}}function rh(e){e.exit("blockQuote")}const Os={name:"characterEscape",tokenize:ih};function ih(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 $c(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const Fs={name:"characterReference",tokenize:sh};function sh(e,t,n){const r=this;let i=0,s,a;return l;function l(c){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),o}function o(c){return c===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(c),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,a=oe,h(c))}function u(c){return c===88||c===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(c),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,a=Vc,h):(e.enter("characterReferenceValue"),s=7,a=Ln,h(c))}function h(c){if(c===59&&i){const p=e.exit("characterReferenceValue");return a===oe&&!rr(r.sliceSerialize(p))?n(c):(e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(c)&&i++<s?(e.consume(c),h):n(c)}}const Wr={partial:!0,tokenize:lh},Qr={concrete:!0,name:"codeFenced",tokenize:ah};function ah(e,t,n){const r=this,i={partial:!0,tokenize:O};let s=0,a=0,l;return o;function o(T){return u(T)}function u(T){const z=r.events[r.events.length-1];return s=z&&z[1].type==="linePrefix"?z[2].sliceSerialize(z[1],!0).length:0,l=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(T)}function h(T){return T===l?(a++,e.consume(T),h):a<3?n(T):(e.exit("codeFencedFenceSequence"),q(T)?Q(e,c,"whitespace")(T):c(T))}function c(T){return T===null||F(T)?(e.exit("codeFencedFence"),r.interrupt?t(T):e.check(Wr,y,D)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(T))}function p(T){return T===null||F(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(T)):q(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Q(e,f,"whitespace")(T)):T===96&&T===l?n(T):(e.consume(T),p)}function f(T){return T===null||F(T)?c(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(T))}function m(T){return T===null||F(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(T)):T===96&&T===l?n(T):(e.consume(T),m)}function y(T){return e.attempt(i,D,S)(T)}function S(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),g}function g(T){return s>0&&q(T)?Q(e,I,"linePrefix",s+1)(T):I(T)}function I(T){return T===null||F(T)?e.check(Wr,y,D)(T):(e.enter("codeFlowValue"),M(T))}function M(T){return T===null||F(T)?(e.exit("codeFlowValue"),I(T)):(e.consume(T),M)}function D(T){return e.exit("codeFenced"),t(T)}function O(T,z,_){let B=0;return k;function k(w){return T.enter("lineEnding"),T.consume(w),T.exit("lineEnding"),L}function L(w){return T.enter("codeFencedFence"),q(w)?Q(T,E,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(w):E(w)}function E(w){return w===l?(T.enter("codeFencedFenceSequence"),U(w)):_(w)}function U(w){return w===l?(B++,T.consume(w),U):B>=a?(T.exit("codeFencedFenceSequence"),q(w)?Q(T,P,"whitespace")(w):P(w)):_(w)}function P(w){return w===null||F(w)?(T.exit("codeFencedFence"),z(w)):_(w)}}}function lh(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const an={name:"codeIndented",tokenize:uh},oh={partial:!0,tokenize:ch};function uh(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),Q(e,s,"linePrefix",5)(u)}function s(u){const h=r.events[r.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?o(u):F(u)?e.attempt(oh,a,o)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||F(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),l)}function o(u){return e.exit("codeIndented"),t(u)}}function ch(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):F(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):Q(e,s,"linePrefix",5)(a)}function s(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):F(a)?i(a):n(a)}}const hh={name:"codeText",previous:fh,resolve:dh,tokenize:ph};function dh(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 fh(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function ph(e,t,n){let r=0,i,s;return a;function a(c){return e.enter("codeText"),e.enter("codeTextSequence"),l(c)}function l(c){return c===96?(e.consume(c),r++,l):(e.exit("codeTextSequence"),o(c))}function o(c){return c===null?n(c):c===32?(e.enter("space"),e.consume(c),e.exit("space"),o):c===96?(s=e.enter("codeTextSequence"),i=0,h(c)):F(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):(e.enter("codeTextData"),u(c))}function u(c){return c===null||c===32||c===96||F(c)?(e.exit("codeTextData"),o(c)):(e.consume(c),u)}function h(c){return c===96?(e.consume(c),i++,h):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(c)):(s.type="codeTextData",u(c))}}class mh{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&ot(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),ot(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ot(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);ot(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ot(this.left,n.reverse())}}}function ot(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function zs(e){const t={};let n=-1,r,i,s,a,l,o,u;const h=new mh(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(r=h.get(n),n&&r[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(o=r[1]._tokenizer.events,s=0,s<o.length&&o[s][1].type==="lineEndingBlank"&&(s+=2),s<o.length&&o[s][1].type==="content"))for(;++s<o.length&&o[s][1].type!=="content";)o[s][1].type==="chunkText"&&(o[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,gh(h,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(a=h.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(h.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=s);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...h.get(i)[1].start},l=h.slice(i,n),l.unshift(r),h.splice(i,n-i+1,l))}}return ye(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!u}function gh(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,o=[],u={};let h,c,p=-1,f=n,m=0,y=0;const S=[y];for(;f;){for(;e.get(++i)[1]!==f;);s.push(i),f._tokenizer||(h=r.sliceStream(f),f.next||h.push(null),c&&a.defineSkip(f.start),f._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(h),f._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),c=f,f=f.next}for(f=n;++p<l.length;)l[p][0]==="exit"&&l[p-1][0]==="enter"&&l[p][1].type===l[p-1][1].type&&l[p][1].start.line!==l[p][1].end.line&&(y=p+1,S.push(y),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(a.events=[],f?(f._tokenizer=void 0,f.previous=void 0):S.pop(),p=S.length;p--;){const g=l.slice(S[p],S[p+1]),I=s.pop();o.push([I,I+g.length-1]),e.splice(I,2,g)}for(o.reverse(),p=-1;++p<o.length;)u[m+o[p][0]]=m+o[p][1],m+=o[p][1]-o[p][0]-1;return u}const xh={resolve:bh,tokenize:Sh},yh={partial:!0,tokenize:kh};function bh(e){return zs(e),e}function Sh(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(l)}function i(l){return l===null?s(l):F(l)?e.check(yh,a,s)(l):(e.consume(l),i)}function s(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function a(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function kh(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Q(e,s,"linePrefix")}function s(a){if(a===null||F(a))return n(a);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function _s(e,t,n,r,i,s,a,l,o){const u=o||Number.POSITIVE_INFINITY;let h=0;return c;function c(g){return g===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(g),e.exit(s),p):g===null||g===32||g===41||Ft(g)?n(g):(e.enter(r),e.enter(a),e.enter(l),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(l),e.enter("chunkString",{contentType:"string"}),f(g))}function f(g){return g===62?(e.exit("chunkString"),e.exit(l),p(g)):g===null||g===60||F(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!h&&(g===null||g===41||X(g))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(g)):h<u&&g===40?(e.consume(g),h++,y):g===41?(e.consume(g),h--,y):g===null||g===32||g===40||Ft(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 Bs(e,t,n,r,i,s){const a=this;let l=0,o;return u;function u(f){return e.enter(r),e.enter(i),e.consume(f),e.exit(i),e.enter(s),h}function h(f){return l>999||f===null||f===91||f===93&&!o||f===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(f):f===93?(e.exit(s),e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):F(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),c(f))}function c(f){return f===null||f===91||f===93||F(f)||l++>999?(e.exit("chunkString"),h(f)):(e.consume(f),o||(o=!q(f)),f===92?p:c)}function p(f){return f===91||f===92||f===93?(e.consume(f),l++,c):c(f)}}function Us(e,t,n,r,i,s){let a;return l;function l(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),a=p===40?41:p,o):n(p)}function o(p){return p===a?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),u(p))}function u(p){return p===a?(e.exit(s),o(a)):p===null?n(p):F(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),Q(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(p))}function h(p){return p===a||p===null||F(p)?(e.exit("chunkString"),u(p)):(e.consume(p),p===92?c:h)}function c(p){return p===a||p===92?(e.consume(p),h):h(p)}}function pt(e,t){let n;return r;function r(i){return F(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):q(i)?Q(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const wh={name:"definition",tokenize:vh},Ch={partial:!0,tokenize:Th};function vh(e,t,n){const r=this;let i;return s;function s(f){return e.enter("definition"),a(f)}function a(f){return Bs.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function l(f){return i=ve(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 X(f)?pt(e,u)(f):u(f)}function u(f){return _s(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function h(f){return e.attempt(Ch,c,c)(f)}function c(f){return q(f)?Q(e,p,"whitespace")(f):p(f)}function p(f){return f===null||F(f)?(e.exit("definition"),r.parser.defined.push(i),t(f)):n(f)}}function Th(e,t,n){return r;function r(l){return X(l)?pt(e,i)(l):n(l)}function i(l){return Us(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function s(l){return q(l)?Q(e,a,"whitespace")(l):a(l)}function a(l){return l===null||F(l)?t(l):n(l)}}const Ih={name:"hardBreakEscape",tokenize:Mh};function Mh(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return F(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const Nh={name:"headingAtx",resolve:Lh,tokenize:Eh};function Lh(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"},ye(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function Eh(e,t,n){let r=0;return i;function i(h){return e.enter("atxHeading"),s(h)}function s(h){return e.enter("atxHeadingSequence"),a(h)}function a(h){return h===35&&r++<6?(e.consume(h),a):h===null||X(h)?(e.exit("atxHeadingSequence"),l(h)):n(h)}function l(h){return h===35?(e.enter("atxHeadingSequence"),o(h)):h===null||F(h)?(e.exit("atxHeading"),t(h)):q(h)?Q(e,l,"whitespace")(h):(e.enter("atxHeadingText"),u(h))}function o(h){return h===35?(e.consume(h),o):(e.exit("atxHeadingSequence"),l(h))}function u(h){return h===null||h===35||X(h)?(e.exit("atxHeadingText"),l(h)):(e.consume(h),u)}}const Ah=["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"],Gr=["pre","script","style","textarea"],Rh={concrete:!0,name:"htmlFlow",resolveTo:Dh,tokenize:Oh},jh={partial:!0,tokenize:zh},Ph={partial:!0,tokenize:Fh};function Dh(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 Oh(e,t,n){const r=this;let i,s,a,l,o;return u;function u(b){return h(b)}function h(b){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(b),c}function c(b){return b===33?(e.consume(b),p):b===47?(e.consume(b),s=!0,y):b===63?(e.consume(b),i=3,r.interrupt?t:x):ce(b)?(e.consume(b),a=String.fromCharCode(b),S):n(b)}function p(b){return b===45?(e.consume(b),i=2,f):b===91?(e.consume(b),i=5,l=0,m):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 he="CDATA[";return b===he.charCodeAt(l++)?(e.consume(b),l===he.length?r.interrupt?t:E:m):n(b)}function y(b){return ce(b)?(e.consume(b),a=String.fromCharCode(b),S):n(b)}function S(b){if(b===null||b===47||b===62||X(b)){const he=b===47,Te=a.toLowerCase();return!he&&!s&&Gr.includes(Te)?(i=1,r.interrupt?t(b):E(b)):Ah.includes(a.toLowerCase())?(i=6,he?(e.consume(b),g):r.interrupt?t(b):E(b)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(b):s?I(b):M(b))}return b===45||oe(b)?(e.consume(b),a+=String.fromCharCode(b),S):n(b)}function g(b){return b===62?(e.consume(b),r.interrupt?t:E):n(b)}function I(b){return q(b)?(e.consume(b),I):k(b)}function M(b){return b===47?(e.consume(b),k):b===58||b===95||ce(b)?(e.consume(b),D):q(b)?(e.consume(b),M):k(b)}function D(b){return b===45||b===46||b===58||b===95||oe(b)?(e.consume(b),D):O(b)}function O(b){return b===61?(e.consume(b),T):q(b)?(e.consume(b),O):M(b)}function T(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),o=b,z):q(b)?(e.consume(b),T):_(b)}function z(b){return b===o?(e.consume(b),o=null,B):b===null||F(b)?n(b):(e.consume(b),z)}function _(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||X(b)?O(b):(e.consume(b),_)}function B(b){return b===47||b===62||q(b)?M(b):n(b)}function k(b){return b===62?(e.consume(b),L):n(b)}function L(b){return b===null||F(b)?E(b):q(b)?(e.consume(b),L):n(b)}function E(b){return b===45&&i===2?(e.consume(b),j):b===60&&i===1?(e.consume(b),$):b===62&&i===4?(e.consume(b),le):b===63&&i===3?(e.consume(b),x):b===93&&i===5?(e.consume(b),pe):F(b)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(jh,se,U)(b)):b===null||F(b)?(e.exit("htmlFlowData"),U(b)):(e.consume(b),E)}function U(b){return e.check(Ph,P,se)(b)}function P(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),w}function w(b){return b===null||F(b)?U(b):(e.enter("htmlFlowData"),E(b))}function j(b){return b===45?(e.consume(b),x):E(b)}function $(b){return b===47?(e.consume(b),a="",ee):E(b)}function ee(b){if(b===62){const he=a.toLowerCase();return Gr.includes(he)?(e.consume(b),le):E(b)}return ce(b)&&a.length<8?(e.consume(b),a+=String.fromCharCode(b),ee):E(b)}function pe(b){return b===93?(e.consume(b),x):E(b)}function x(b){return b===62?(e.consume(b),le):b===45&&i===2?(e.consume(b),x):E(b)}function le(b){return b===null||F(b)?(e.exit("htmlFlowData"),se(b)):(e.consume(b),le)}function se(b){return e.exit("htmlFlow"),t(b)}}function Fh(e,t,n){const r=this;return i;function i(a){return F(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):n(a)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function zh(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Ct,t,n)}}const _h={name:"htmlText",tokenize:Bh};function Bh(e,t,n){const r=this;let i,s,a;return l;function l(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),O):x===63?(e.consume(x),M):ce(x)?(e.consume(x),_):n(x)}function u(x){return x===45?(e.consume(x),h):x===91?(e.consume(x),s=0,m):ce(x)?(e.consume(x),I):n(x)}function h(x){return x===45?(e.consume(x),f):n(x)}function c(x){return x===null?n(x):x===45?(e.consume(x),p):F(x)?(a=c,$(x)):(e.consume(x),c)}function p(x){return x===45?(e.consume(x),f):c(x)}function f(x){return x===62?j(x):x===45?p(x):c(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):F(x)?(a=y,$(x)):(e.consume(x),y)}function S(x){return x===93?(e.consume(x),g):y(x)}function g(x){return x===62?j(x):x===93?(e.consume(x),g):y(x)}function I(x){return x===null||x===62?j(x):F(x)?(a=I,$(x)):(e.consume(x),I)}function M(x){return x===null?n(x):x===63?(e.consume(x),D):F(x)?(a=M,$(x)):(e.consume(x),M)}function D(x){return x===62?j(x):M(x)}function O(x){return ce(x)?(e.consume(x),T):n(x)}function T(x){return x===45||oe(x)?(e.consume(x),T):z(x)}function z(x){return F(x)?(a=z,$(x)):q(x)?(e.consume(x),z):j(x)}function _(x){return x===45||oe(x)?(e.consume(x),_):x===47||x===62||X(x)?B(x):n(x)}function B(x){return x===47?(e.consume(x),j):x===58||x===95||ce(x)?(e.consume(x),k):F(x)?(a=B,$(x)):q(x)?(e.consume(x),B):j(x)}function k(x){return x===45||x===46||x===58||x===95||oe(x)?(e.consume(x),k):L(x)}function L(x){return x===61?(e.consume(x),E):F(x)?(a=L,$(x)):q(x)?(e.consume(x),L):B(x)}function E(x){return x===null||x===60||x===61||x===62||x===96?n(x):x===34||x===39?(e.consume(x),i=x,U):F(x)?(a=E,$(x)):q(x)?(e.consume(x),E):(e.consume(x),P)}function U(x){return x===i?(e.consume(x),i=void 0,w):x===null?n(x):F(x)?(a=U,$(x)):(e.consume(x),U)}function P(x){return x===null||x===34||x===39||x===60||x===61||x===96?n(x):x===47||x===62||X(x)?B(x):(e.consume(x),P)}function w(x){return x===47||x===62||X(x)?B(x):n(x)}function j(x){return x===62?(e.consume(x),e.exit("htmlTextData"),e.exit("htmlText"),t):n(x)}function $(x){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),ee}function ee(x){return q(x)?Q(e,pe,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):pe(x)}function pe(x){return e.enter("htmlTextData"),a(x)}}const ir={name:"labelEnd",resolveAll:$h,resolveTo:Kh,tokenize:qh},Uh={tokenize:Wh},Hh={tokenize:Qh},Vh={tokenize:Gh};function $h(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&&ye(e,0,e.length,n),e}function Kh(e,t){let n=e.length,r=0,i,s,a,l;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const o={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[s][1].start},end:{...e[a][1].end}},h={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",o,t],["enter",u,t]],l=be(l,e.slice(s+1,s+r+3)),l=be(l,[["enter",h,t]]),l=be(l,Wt(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),l=be(l,[["exit",h,t],e[a-2],e[a-1],["exit",u,t]]),l=be(l,e.slice(a+1)),l=be(l,[["exit",o,t]]),ye(e,s,e.length,l),e}function qh(e,t,n){const r=this;let i=r.events.length,s,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return l;function l(p){return s?s._inactive?c(p):(a=r.parser.defined.includes(ve(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(Uh,h,a?h:c)(p):p===91?e.attempt(Hh,h,a?u:c)(p):a?h(p):c(p)}function u(p){return e.attempt(Vh,h,c)(p)}function h(p){return t(p)}function c(p){return s._balanced=!0,n(p)}}function Wh(e,t,n){return r;function r(c){return e.enter("resource"),e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),i}function i(c){return X(c)?pt(e,s)(c):s(c)}function s(c){return c===41?h(c):_s(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(c)}function a(c){return X(c)?pt(e,o)(c):h(c)}function l(c){return n(c)}function o(c){return c===34||c===39||c===40?Us(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(c):h(c)}function u(c){return X(c)?pt(e,h)(c):h(c)}function h(c){return c===41?(e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),e.exit("resource"),t):n(c)}}function Qh(e,t,n){const r=this;return i;function i(l){return Bs.call(r,e,s,a,"reference","referenceMarker","referenceString")(l)}function s(l){return r.parser.defined.includes(ve(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function Gh(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 Yh={name:"labelStartImage",resolveAll:ir.resolveAll,tokenize:Xh};function Xh(e,t,n){const r=this;return i;function i(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),s}function s(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),a):n(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const Jh={name:"labelStartLink",resolveAll:ir.resolveAll,tokenize:Zh};function Zh(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),s}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const ln={name:"lineEnding",tokenize:ed};function ed(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Q(e,t,"linePrefix")}}const Dt={name:"thematicBreak",tokenize:td};function td(e,t,n){let r=0,i;return s;function s(u){return e.enter("thematicBreak"),a(u)}function a(u){return i=u,l(u)}function l(u){return u===i?(e.enter("thematicBreakSequence"),o(u)):r>=3&&(u===null||F(u))?(e.exit("thematicBreak"),t(u)):n(u)}function o(u){return u===i?(e.consume(u),r++,o):(e.exit("thematicBreakSequence"),q(u)?Q(e,l,"whitespace")(u):l(u))}}const de={continuation:{tokenize:sd},exit:ld,name:"list",tokenize:id},nd={partial:!0,tokenize:od},rd={partial:!0,tokenize:ad};function id(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return l;function l(f){const m=r.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||f===r.containerState.marker:Ln(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(Dt,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 Ln(f)&&++a<10?(e.consume(f),o):(!r.interrupt||a<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(e.exit("listItemValue"),u(f)):n(f)}function u(f){return e.enter("listItemMarker"),e.consume(f),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||f,e.check(Ct,r.interrupt?n:h,e.attempt(nd,p,c))}function h(f){return r.containerState.initialBlankLine=!0,s++,p(f)}function c(f){return q(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 sd(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Ct,i,s);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Q(e,t,"listItemIndent",r.containerState.size+1)(l)}function s(l){return r.containerState.furtherBlankLines||!q(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(rd,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,Q(e,e.attempt(de,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function ad(e,t,n){const r=this;return Q(e,i,"listItemIndent",r.containerState.size+1);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(s):n(s)}}function ld(e){e.exit(this.containerState.type)}function od(e,t,n){const r=this;return Q(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=r.events[r.events.length-1];return!q(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const Yr={name:"setextUnderline",resolveTo:ud,tokenize:cd};function ud(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",a,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function cd(e,t,n){const r=this;let i;return s;function s(u){let h=r.events.length,c;for(;h--;)if(r.events[h][1].type!=="lineEnding"&&r.events[h][1].type!=="linePrefix"&&r.events[h][1].type!=="content"){c=r.events[h][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter("setextHeadingLine"),i=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===i?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),q(u)?Q(e,o,"lineSuffix")(u):o(u))}function o(u){return u===null||F(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const hd={tokenize:dd};function dd(e){const t=this,n=e.attempt(Ct,r,e.attempt(this.parser.constructs.flowInitial,i,Q(e,e.attempt(this.parser.constructs.flow,i,e.attempt(xh,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 fd={resolveAll:Vs()},pd=Hs("string"),md=Hs("text");function Hs(e){return{resolveAll:Vs(e==="text"?gd:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,a,l);return a;function a(h){return u(h)?s(h):l(h)}function l(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),o}function o(h){return u(h)?(n.exit("data"),s(h)):(n.consume(h),o)}function u(h){if(h===null)return!0;const c=i[h];let p=-1;if(c)for(;++p<c.length;){const f=c[p];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function Vs(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 gd(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,a=-1,l=0,o;for(;s--;){const u=i[s];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(u===-2)o=!0,l++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const u={type:n===e.length||o||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?a:r.start._bufferIndex+a,_index:r.start._index+s,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const xd={42:de,43:de,45:de,48:de,49:de,50:de,51:de,52:de,53:de,54:de,55:de,56:de,57:de,62:Ds},yd={91:wh},bd={[-2]:an,[-1]:an,32:an},Sd={35:Nh,42:Dt,45:[Yr,Dt],60:Rh,61:Yr,95:Dt,96:Qr,126:Qr},kd={38:Fs,92:Os},wd={[-5]:ln,[-4]:ln,[-3]:ln,33:Yh,38:Fs,42:En,60:[Jc,_h],91:Jh,92:[Ih,Os],93:ir,95:En,96:hh},Cd={null:[En,fd]},vd={null:[42,95]},Td={null:[]},Id=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:vd,contentInitial:yd,disable:Td,document:xd,flow:Sd,flowInitial:bd,insideSpan:Cd,string:kd,text:wd},Symbol.toStringTag,{value:"Module"}));function Md(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let a=[],l=[];const o={attempt:z(O),check:z(T),consume:I,enter:M,exit:D,interrupt:z(T,{interrupt:!0})},u={code:null,containerState:{},defineSkip:y,events:[],now:m,parser:e,previous:null,sliceSerialize:p,sliceStream:f,write:c};let h=t.tokenize.call(u,o);return t.resolveAll&&s.push(t),u;function c(L){return a=be(a,L),S(),a[a.length-1]!==null?[]:(_(t,0),u.events=Wt(s,u.events,u),u.events)}function p(L,E){return Ld(f(L),E)}function f(L){return Nd(a,L)}function m(){const{_bufferIndex:L,_index:E,line:U,column:P,offset:w}=r;return{_bufferIndex:L,_index:E,line:U,column:P,offset:w}}function y(L){i[L.line]=L.column,k()}function S(){let L;for(;r._index<a.length;){const E=a[r._index];if(typeof E=="string")for(L=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===L&&r._bufferIndex<E.length;)g(E.charCodeAt(r._bufferIndex));else g(E)}}function g(L){h=h(L)}function I(L){F(L)?(r.line++,r.column=1,r.offset+=L===-3?2:1,k()):L!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=L}function M(L,E){const U=E||{};return U.type=L,U.start=m(),u.events.push(["enter",U,u]),l.push(U),U}function D(L){const E=l.pop();return E.end=m(),u.events.push(["exit",E,u]),E}function O(L,E){_(L,E.from)}function T(L,E){E.restore()}function z(L,E){return U;function U(P,w,j){let $,ee,pe,x;return Array.isArray(P)?se(P):"tokenize"in P?se([P]):le(P);function le(re){return me;function me(ke){const Ee=ke!==null&&re[ke],Ae=ke!==null&&re.null,Ue=[...Array.isArray(Ee)?Ee:Ee?[Ee]:[],...Array.isArray(Ae)?Ae:Ae?[Ae]:[]];return se(Ue)(ke)}}function se(re){return $=re,ee=0,re.length===0?j:b(re[ee])}function b(re){return me;function me(ke){return x=B(),pe=re,re.partial||(u.currentConstruct=re),re.name&&u.parser.constructs.disable.null.includes(re.name)?Te():re.tokenize.call(E?Object.assign(Object.create(u),E):u,o,he,Te)(ke)}}function he(re){return L(pe,x),w}function Te(re){return x.restore(),++ee<$.length?b($[ee]):j}}}function _(L,E){L.resolveAll&&!s.includes(L)&&s.push(L),L.resolve&&ye(u.events,E,u.events.length-E,L.resolve(u.events.slice(E),u)),L.resolveTo&&(u.events=L.resolveTo(u.events,u))}function B(){const L=m(),E=u.previous,U=u.currentConstruct,P=u.events.length,w=Array.from(l);return{from:P,restore:j};function j(){r=L,u.previous=E,u.currentConstruct=U,u.events.length=P,l=w,k()}}function k(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Nd(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,s)];else{if(a=e.slice(n,i),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}s>0&&a.push(e[i].slice(0,s))}return a}function Ld(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let a;if(typeof s=="string")a=s;else switch(s){case-5:{a="\r";break}case-4:{a=`
5
- `;break}case-3:{a=`\r
6
- `;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(s)}i=s===-2,r.push(a)}return r.join("")}function Ed(e){const r={constructs:js([Id,...(e||{}).extensions||[]]),content:i(Kc),defined:[],document:i(Wc),flow:i(hd),lazy:{},string:i(pd),text:i(md)};return r;function i(s){return a;function a(l){return Md(r,s,l)}}}function Ad(e){for(;!zs(e););return e}const Xr=/[\0\t\n\r]/g;function Rd(){let e=1,t="",n=!0,r;return i;function i(s,a,l){const o=[];let u,h,c,p,f;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(a||void 0).decode(s)),c=0,t="",n&&(s.charCodeAt(0)===65279&&c++,n=void 0);c<s.length;){if(Xr.lastIndex=c,u=Xr.exec(s),p=u&&u.index!==void 0?u.index:s.length,f=s.charCodeAt(p),!u){t=s.slice(c);break}if(f===10&&c===p&&r)o.push(-3),r=void 0;else switch(r&&(o.push(-5),r=void 0),c<p&&(o.push(s.slice(c,p)),e+=p-c),f){case 0:{o.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,o.push(-2);e++<h;)o.push(-1);break}case 10:{o.push(-4),e=1;break}default:r=!0,e=1}c=p+1}return l&&(r&&o.push(-5),t&&o.push(t),o.push(null)),o}}const jd=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Pd(e){return e.replace(jd,Dd)}function Dd(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return Ps(n.slice(s?2:1),s?16:10)}return rr(n)||e}const $s={}.hasOwnProperty;function Od(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),Fd(n)(Ad(Ed(n).document().write(Rd()(e,t,!0))))}function Fd(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Mt),autolinkProtocol:B,autolinkEmail:B,atxHeading:s(He),blockQuote:s(Ae),characterEscape:B,characterReference:B,codeFenced:s(Ue),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(Ue,a),codeText:s(Tt,a),codeTextData:B,data:B,codeFlowValue:B,definition:s(It),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(K),hardBreakEscape:s(Ie),hardBreakTrailing:s(Ie),htmlFlow:s(Re,a),htmlFlowData:B,htmlText:s(Re,a),htmlTextData:B,image:s(je),label:a,link:s(Mt),listItem:s(Ea),listItemValue:p,listOrdered:s(nt,c),listUnordered:s(nt),paragraph:s(Aa),reference:b,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(He),strong:s(Ra),thematicBreak:s(Pa)},exit:{atxHeading:o(),atxHeadingSequence:O,autolink:o(),autolinkEmail:Ee,autolinkProtocol:ke,blockQuote:o(),characterEscapeValue:k,characterReferenceMarkerHexadecimal:Te,characterReferenceMarkerNumeric:Te,characterReferenceValue:re,characterReference:me,codeFenced:o(S),codeFencedFence:y,codeFencedFenceInfo:f,codeFencedFenceMeta:m,codeFlowValue:k,codeIndented:o(g),codeText:o(w),codeTextData:k,data:k,definition:o(),definitionDestinationString:D,definitionLabelString:I,definitionTitleString:M,emphasis:o(),hardBreakEscape:o(E),hardBreakTrailing:o(E),htmlFlow:o(U),htmlFlowData:k,htmlText:o(P),htmlTextData:k,image:o($),label:pe,labelText:ee,lineEnding:L,link:o(j),listItem:o(),listOrdered:o(),listUnordered:o(),paragraph:o(),referenceString:he,resourceDestinationString:x,resourceTitleString:le,resource:se,setextHeading:o(_),setextHeadingLineSequence:z,setextHeadingText:T,strong:o(),thematicBreak:o()}};Ks(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(N){let R={type:"root",children:[]};const H={stack:[R],tokenStack:[],config:t,enter:l,exit:u,buffer:a,resume:h,data:n},W=[];let G=-1;for(;++G<N.length;)if(N[G][1].type==="listOrdered"||N[G][1].type==="listUnordered")if(N[G][0]==="enter")W.push(G);else{const we=W.pop();G=i(N,we,G)}for(G=-1;++G<N.length;){const we=t[N[G][0]];$s.call(we,N[G][1].type)&&we[N[G][1].type].call(Object.assign({sliceSerialize:N[G][2].sliceSerialize},H),N[G][1])}if(H.tokenStack.length>0){const we=H.tokenStack[H.tokenStack.length-1];(we[1]||Jr).call(H,void 0,we[0])}for(R.position={start:ze(N.length>0?N[0][1].start:{line:1,column:1,offset:0}),end:ze(N.length>0?N[N.length-2][1].end:{line:1,column:1,offset:0})},G=-1;++G<t.transforms.length;)R=t.transforms[G](R)||R;return R}function i(N,R,H){let W=R-1,G=-1,we=!1,Ve,Pe,rt,it;for(;++W<=H;){const ge=N[W];switch(ge[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ge[0]==="enter"?G++:G--,it=void 0;break}case"lineEndingBlank":{ge[0]==="enter"&&(Ve&&!it&&!G&&!rt&&(rt=W),it=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:it=void 0}if(!G&&ge[0]==="enter"&&ge[1].type==="listItemPrefix"||G===-1&&ge[0]==="exit"&&(ge[1].type==="listUnordered"||ge[1].type==="listOrdered")){if(Ve){let We=W;for(Pe=void 0;We--;){const De=N[We];if(De[1].type==="lineEnding"||De[1].type==="lineEndingBlank"){if(De[0]==="exit")continue;Pe&&(N[Pe][1].type="lineEndingBlank",we=!0),De[1].type="lineEnding",Pe=We}else if(!(De[1].type==="linePrefix"||De[1].type==="blockQuotePrefix"||De[1].type==="blockQuotePrefixWhitespace"||De[1].type==="blockQuoteMarker"||De[1].type==="listItemIndent"))break}rt&&(!Pe||rt<Pe)&&(Ve._spread=!0),Ve.end=Object.assign({},Pe?N[Pe][1].start:ge[1].end),N.splice(Pe||W,0,["exit",Ve,ge[2]]),W++,H++}if(ge[1].type==="listItemPrefix"){const We={type:"listItem",_spread:!1,start:Object.assign({},ge[1].start),end:void 0};Ve=We,N.splice(W,0,["enter",We,ge[2]]),W++,H++,rt=void 0,it=!0}}}return N[R][1]._spread=we,H}function s(N,R){return H;function H(W){l.call(this,N(W),W),R&&R.call(this,W)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(N,R,H){this.stack[this.stack.length-1].children.push(N),this.stack.push(N),this.tokenStack.push([R,H||void 0]),N.position={start:ze(R.start),end:void 0}}function o(N){return R;function R(H){N&&N.call(this,H),u.call(this,H)}}function u(N,R){const H=this.stack.pop(),W=this.tokenStack.pop();if(W)W[0].type!==N.type&&(R?R.call(this,N,W[0]):(W[1]||Jr).call(this,N,W[0]));else throw new Error("Cannot close `"+N.type+"` ("+ft({start:N.start,end:N.end})+"): it’s not open");H.position.end=ze(N.end)}function h(){return nr(this.stack.pop())}function c(){this.data.expectingFirstListItemValue=!0}function p(N){if(this.data.expectingFirstListItemValue){const R=this.stack[this.stack.length-2];R.start=Number.parseInt(this.sliceSerialize(N),10),this.data.expectingFirstListItemValue=void 0}}function f(){const N=this.resume(),R=this.stack[this.stack.length-1];R.lang=N}function m(){const N=this.resume(),R=this.stack[this.stack.length-1];R.meta=N}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const N=this.resume(),R=this.stack[this.stack.length-1];R.value=N.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const N=this.resume(),R=this.stack[this.stack.length-1];R.value=N.replace(/(\r?\n|\r)$/g,"")}function I(N){const R=this.resume(),H=this.stack[this.stack.length-1];H.label=R,H.identifier=ve(this.sliceSerialize(N)).toLowerCase()}function M(){const N=this.resume(),R=this.stack[this.stack.length-1];R.title=N}function D(){const N=this.resume(),R=this.stack[this.stack.length-1];R.url=N}function O(N){const R=this.stack[this.stack.length-1];if(!R.depth){const H=this.sliceSerialize(N).length;R.depth=H}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function z(N){const R=this.stack[this.stack.length-1];R.depth=this.sliceSerialize(N).codePointAt(0)===61?1:2}function _(){this.data.setextHeadingSlurpLineEnding=void 0}function B(N){const H=this.stack[this.stack.length-1].children;let W=H[H.length-1];(!W||W.type!=="text")&&(W=ja(),W.position={start:ze(N.start),end:void 0},H.push(W)),this.stack.push(W)}function k(N){const R=this.stack.pop();R.value+=this.sliceSerialize(N),R.position.end=ze(N.end)}function L(N){const R=this.stack[this.stack.length-1];if(this.data.atHardBreak){const H=R.children[R.children.length-1];H.position.end=ze(N.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(R.type)&&(B.call(this,N),k.call(this,N))}function E(){this.data.atHardBreak=!0}function U(){const N=this.resume(),R=this.stack[this.stack.length-1];R.value=N}function P(){const N=this.resume(),R=this.stack[this.stack.length-1];R.value=N}function w(){const N=this.resume(),R=this.stack[this.stack.length-1];R.value=N}function j(){const N=this.stack[this.stack.length-1];if(this.data.inReference){const R=this.data.referenceType||"shortcut";N.type+="Reference",N.referenceType=R,delete N.url,delete N.title}else delete N.identifier,delete N.label;this.data.referenceType=void 0}function $(){const N=this.stack[this.stack.length-1];if(this.data.inReference){const R=this.data.referenceType||"shortcut";N.type+="Reference",N.referenceType=R,delete N.url,delete N.title}else delete N.identifier,delete N.label;this.data.referenceType=void 0}function ee(N){const R=this.sliceSerialize(N),H=this.stack[this.stack.length-2];H.label=Pd(R),H.identifier=ve(R).toLowerCase()}function pe(){const N=this.stack[this.stack.length-1],R=this.resume(),H=this.stack[this.stack.length-1];if(this.data.inReference=!0,H.type==="link"){const W=N.children;H.children=W}else H.alt=R}function x(){const N=this.resume(),R=this.stack[this.stack.length-1];R.url=N}function le(){const N=this.resume(),R=this.stack[this.stack.length-1];R.title=N}function se(){this.data.inReference=void 0}function b(){this.data.referenceType="collapsed"}function he(N){const R=this.resume(),H=this.stack[this.stack.length-1];H.label=R,H.identifier=ve(this.sliceSerialize(N)).toLowerCase(),this.data.referenceType="full"}function Te(N){this.data.characterReferenceType=N.type}function re(N){const R=this.sliceSerialize(N),H=this.data.characterReferenceType;let W;H?(W=Ps(R,H==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):W=rr(R);const G=this.stack[this.stack.length-1];G.value+=W}function me(N){const R=this.stack.pop();R.position.end=ze(N.end)}function ke(N){k.call(this,N);const R=this.stack[this.stack.length-1];R.url=this.sliceSerialize(N)}function Ee(N){k.call(this,N);const R=this.stack[this.stack.length-1];R.url="mailto:"+this.sliceSerialize(N)}function Ae(){return{type:"blockquote",children:[]}}function Ue(){return{type:"code",lang:null,meta:null,value:""}}function Tt(){return{type:"inlineCode",value:""}}function It(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function K(){return{type:"emphasis",children:[]}}function He(){return{type:"heading",depth:0,children:[]}}function Ie(){return{type:"break"}}function Re(){return{type:"html",value:""}}function je(){return{type:"image",title:null,url:"",alt:null}}function Mt(){return{type:"link",title:null,url:"",children:[]}}function nt(N){return{type:"list",ordered:N.type==="listOrdered",start:null,spread:N._spread,children:[]}}function Ea(N){return{type:"listItem",spread:N._spread,checked:null,children:[]}}function Aa(){return{type:"paragraph",children:[]}}function Ra(){return{type:"strong",children:[]}}function ja(){return{type:"text",value:""}}function Pa(){return{type:"thematicBreak"}}}function ze(e){return{line:e.line,column:e.column,offset:e.offset}}function Ks(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Ks(e,r):zd(e,r)}}function zd(e,t){let n;for(n in t)if($s.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 Jr(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ft({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ft({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ft({start:t.start,end:t.end})+") is still open")}function _d(e){const t=this;t.parser=n;function n(r){return Od(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Bd(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 Ud(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
7
- `}]}function Hd(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 Vd(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function $d(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Kd(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=tt(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let a,l=e.footnoteCounts.get(r);l===void 0?(l=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=s+1,l+=1,e.footnoteCounts.set(r,l);const o={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,o);const u={type:"element",tagName:"sup",properties:{},children:[o]};return e.patch(t,u),e.applyData(t,u)}function qd(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 Wd(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function qs(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function Qd(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return qs(e,t);const i={src:tt(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function Gd(e,t){const n={src:tt(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function Yd(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 Xd(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return qs(e,t);const i={href:tt(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function Jd(e,t){const n={href:tt(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Zd(e,t,n){const r=e.all(t),i=n?ef(n):Ws(t),s={},a=[];if(typeof t.checked=="boolean"){const h=r[0];let c;h&&h.type==="element"&&h.tagName==="p"?c=h:(c={type:"element",tagName:"p",properties:{},children:[]},r.unshift(c)),c.children.length>0&&c.children.unshift({type:"text",value:" "}),c.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const h=r[l];(i||l!==0||h.type!=="element"||h.tagName!=="p")&&a.push({type:"text",value:`
9
- `}),h.type==="element"&&h.tagName==="p"&&!i?a.push(...h.children):a.push(h)}const o=r[r.length-1];o&&(i||o.type!=="element"||o.tagName!=="p")&&a.push({type:"text",value:`
10
- `});const u={type:"element",tagName:"li",properties:s,children:a};return e.patch(t,u),e.applyData(t,u)}function ef(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=Ws(n[r])}return t}function Ws(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 a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function nf(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function rf(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function sf(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function af(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=Jn(t.children[1]),o=Is(t.children[t.children.length-1]);l&&o&&(a.position={start:l,end:o}),i.push(a)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function lf(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,l=a?a.length:t.children.length;let o=-1;const u=[];for(;++o<l;){const c=t.children[o],p={},f=a?a[o]:void 0;f&&(p.align=f);let m={type:"element",tagName:s,properties:p,children:[]};c&&(m.children=e.all(c),e.patch(c,m),m=e.applyData(c,m)),u.push(m)}const h={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,h),e.applyData(t,h)}function of(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Zr=9,ei=32;function uf(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(ti(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(ti(t.slice(i),i>0,!1)),s.join("")}function ti(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===Zr||s===ei;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===Zr||s===ei;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function cf(e,t){const n={type:"text",value:uf(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function hf(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const df={blockquote:Bd,break:Ud,code:Hd,delete:Vd,emphasis:$d,footnoteReference:Kd,heading:qd,html:Wd,imageReference:Qd,image:Gd,inlineCode:Yd,linkReference:Xd,link:Jd,listItem:Zd,list:tf,paragraph:nf,root:rf,strong:sf,table:af,tableCell:of,tableRow:lf,text:cf,thematicBreak:hf,toml:Nt,yaml:Nt,definition:Nt,footnoteDefinition:Nt};function Nt(){}const Qs=-1,Qt=0,mt=1,zt=2,sr=3,ar=4,lr=5,or=6,Gs=7,Ys=8,ni=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,a]=t[i];switch(s){case Qt:case Qs:return n(a,i);case mt:{const l=n([],i);for(const o of a)l.push(r(o));return l}case zt:{const l=n({},i);for(const[o,u]of a)l[r(o)]=r(u);return l}case sr:return n(new Date(a),i);case ar:{const{source:l,flags:o}=a;return n(new RegExp(l,o),i)}case lr:{const l=n(new Map,i);for(const[o,u]of a)l.set(r(o),r(u));return l}case or:{const l=n(new Set,i);for(const o of a)l.add(r(o));return l}case Gs:{const{name:l,message:o}=a;return n(new ni[l](o),i)}case Ys:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:l}=new Uint8Array(a);return n(new DataView(l),a)}}return n(new ni[s](a),i)};return r},ri=e=>ff(new Map,e)(0),Ge="",{toString:pf}={},{keys:mf}=Object,ut=e=>{const t=typeof e;if(t!=="object"||!e)return[Qt,t];const n=pf.call(e).slice(8,-1);switch(n){case"Array":return[mt,Ge];case"Object":return[zt,Ge];case"Date":return[sr,Ge];case"RegExp":return[ar,Ge];case"Map":return[lr,Ge];case"Set":return[or,Ge];case"DataView":return[mt,n]}return n.includes("Array")?[mt,n]:n.includes("Error")?[Gs,n]:[zt,n]},Lt=([e,t])=>e===Qt&&(t==="function"||t==="symbol"),gf=(e,t,n,r)=>{const i=(a,l)=>{const o=r.push(a)-1;return n.set(l,o),o},s=a=>{if(n.has(a))return n.get(a);let[l,o]=ut(a);switch(l){case Qt:{let h=a;switch(o){case"bigint":l=Ys,h=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+o);h=null;break;case"undefined":return i([Qs],a)}return i([l,h],a)}case mt:{if(o){let p=a;return o==="DataView"?p=new Uint8Array(a.buffer):o==="ArrayBuffer"&&(p=new Uint8Array(a)),i([o,[...p]],a)}const h=[],c=i([l,h],a);for(const p of a)h.push(s(p));return c}case zt:{if(o)switch(o){case"BigInt":return i([o,a.toString()],a);case"Boolean":case"Number":case"String":return i([o,a.valueOf()],a)}if(t&&"toJSON"in a)return s(a.toJSON());const h=[],c=i([l,h],a);for(const p of mf(a))(e||!Lt(ut(a[p])))&&h.push([s(p),s(a[p])]);return c}case sr:return i([l,a.toISOString()],a);case ar:{const{source:h,flags:c}=a;return i([l,{source:h,flags:c}],a)}case lr:{const h=[],c=i([l,h],a);for(const[p,f]of a)(e||!(Lt(ut(p))||Lt(ut(f))))&&h.push([s(p),s(f)]);return c}case or:{const h=[],c=i([l,h],a);for(const p of a)(e||!Lt(ut(p)))&&h.push(s(p));return c}}const{message:u}=a;return i([l,{name:o,message:u}],a)};return s},ii=(e,{json:t,lossy:n}={})=>{const r=[];return gf(!(t||n),!!t,new Map,r)(e),r},_t=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?ri(ii(e,t)):structuredClone(e):(e,t)=>ri(ii(e,t));function xf(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 yf(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function bf(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||xf,r=e.options.footnoteBackLabel||yf,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let o=-1;for(;++o<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[o]);if(!u)continue;const h=e.all(u),c=String(u.identifier).toUpperCase(),p=tt(c.toLowerCase());let f=0;const m=[],y=e.footnoteCounts.get(c);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=h[h.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const I=S.children[S.children.length-1];I&&I.type==="text"?I.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...m)}else h.push(...m);const g={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(h,!0)};e.patch(u,g),l.push(g)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{..._t(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
11
- `},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:`
12
- `}]}}const Gt=(function(e){if(e==null)return Cf;if(typeof e=="function")return Yt(e);if(typeof e=="object")return Array.isArray(e)?Sf(e):kf(e);if(typeof e=="string")return wf(e);throw new Error("Expected function, string, or object as test")});function Sf(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Gt(e[n]);return Yt(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function kf(e){const t=e;return Yt(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function wf(e){return Yt(t);function t(n){return n&&n.type===e}}function Yt(e){return t;function t(n,r,i){return!!(vf(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function Cf(){return!0}function vf(e){return e!==null&&typeof e=="object"&&"type"in e}const Xs=[],Tf=!0,An=!1,If="skip";function Js(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=Gt(i),a=r?-1:1;l(e,void 0,[])();function l(o,u,h){const c=o&&typeof o=="object"?o:{};if(typeof c.type=="string"){const f=typeof c.tagName=="string"?c.tagName:typeof c.name=="string"?c.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(o.type+(f?"<"+f+">":""))+")"})}return p;function p(){let f=Xs,m,y,S;if((!t||s(o,u,h[h.length-1]||void 0))&&(f=Mf(n(o,h)),f[0]===An))return f;if("children"in o&&o.children){const g=o;if(g.children&&f[0]!==If)for(y=(r?g.children.length:-1)+a,S=h.concat(g);y>-1&&y<g.children.length;){const I=g.children[y];if(m=l(I,y,S)(),m[0]===An)return m;y=typeof m[1]=="number"?m[1]:y+a}}return f}}}function Mf(e){return Array.isArray(e)?e:typeof e=="number"?[Tf,e]:e==null?Xs:[e]}function ur(e,t,n,r){let i,s,a;typeof t=="function"&&typeof n!="function"?(s=void 0,a=t,i=n):(s=t,a=n,i=r),Js(e,s,l,i);function l(o,u){const h=u[u.length-1],c=h?h.children.indexOf(o):void 0;return a(o,c,h)}}const Rn={}.hasOwnProperty,Nf={};function Lf(e,t){const n=t||Nf,r=new Map,i=new Map,s=new Map,a={...df,...n.handlers},l={all:u,applyData:Af,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:a,one:o,options:n,patch:Ef,wrap:jf};return ur(e,function(h){if(h.type==="definition"||h.type==="footnoteDefinition"){const c=h.type==="definition"?r:i,p=String(h.identifier).toUpperCase();c.has(p)||c.set(p,h)}}),l;function o(h,c){const p=h.type,f=l.handlers[p];if(Rn.call(l.handlers,p)&&f)return f(l,h,c);if(l.options.passThrough&&l.options.passThrough.includes(p)){if("children"in h){const{children:y,...S}=h,g=_t(S);return g.children=l.all(h),g}return _t(h)}return(l.options.unknownHandler||Rf)(l,h,c)}function u(h){const c=[];if("children"in h){const p=h.children;let f=-1;for(;++f<p.length;){const m=l.one(p[f],h);if(m){if(f&&p[f-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=si(m.value)),!Array.isArray(m)&&m.type==="element")){const y=m.children[0];y&&y.type==="text"&&(y.value=si(y.value))}Array.isArray(m)?c.push(...m):c.push(m)}}}return c}}function Ef(e,t){e.position&&(t.position=xc(e))}function Af(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&s&&Object.assign(n.properties,_t(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function Rf(e,t){const n=t.data||{},r="value"in t&&!(Rn.call(n,"hProperties")||Rn.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 jf(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 si(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function ai(e,t){const n=Lf(e,t),r=n.one(e,void 0),i=bf(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 Pf(e,t){return e&&"run"in e?async function(n,r){const i=ai(n,{file:r,...t});await e.run(i,r)}:function(n,r){return ai(n,{file:r,...e||t})}}function li(e){if(e)throw e}var on,oi;function Df(){if(oi)return on;oi=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):t.call(u)==="[object Array]"},s=function(u){if(!u||t.call(u)!=="[object Object]")return!1;var h=e.call(u,"constructor"),c=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!h&&!c)return!1;var p;for(p in u);return typeof p>"u"||e.call(u,p)},a=function(u,h){n&&h.name==="__proto__"?n(u,h.name,{enumerable:!0,configurable:!0,value:h.newValue,writable:!0}):u[h.name]=h.newValue},l=function(u,h){if(h==="__proto__")if(e.call(u,h)){if(r)return r(u,h).value}else return;return u[h]};return on=function o(){var u,h,c,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(h in u)c=l(y,h),p=l(u,h),y!==p&&(I&&p&&(s(p)||(f=i(p)))?(f?(f=!1,m=c&&i(c)?c:[]):m=c&&s(c)?c:{},a(y,{name:h,newValue:o(I,m,p)})):typeof p<"u"&&a(y,{name:h,newValue:p}));return y},on}var Of=Df();const un=Vi(Of);function jn(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 Ff(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...i);function l(o,...u){const h=e[++s];let c=-1;if(o){a(o);return}for(;++c<i.length;)(u[c]===null||u[c]===void 0)&&(u[c]=i[c]);i=u,h?zf(h,l)(...u):a(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function zf(e,t){let n;return r;function r(...a){const l=e.length>a.length;let o;l&&a.push(i);try{o=e.apply(this,a)}catch(u){const h=u;if(l&&n)throw h;return i(h)}l||(o&&o.then&&typeof o.then=="function"?o.then(s,i):o instanceof Error?i(o):s(o))}function i(a,...l){n||(n=!0,t(a,...l))}function s(a){i(null,a)}}const Ne={basename:_f,dirname:Bf,extname:Uf,join:Hf,sep:"/"};function _f(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');vt(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,l=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else a<0&&(s=!0,a=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(r=i):(l=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function Bf(e){if(vt(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 Uf(e){vt(e);let t=e.length,n=-1,r=0,i=-1,s=0,a;for(;t--;){const l=e.codePointAt(t);if(l===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),l===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function Hf(...e){let t=-1,n;for(;++t<e.length;)vt(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":Vf(n)}function Vf(e){vt(e);const t=e.codePointAt(0)===47;let n=$f(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function $f(e,t){let n="",r=0,i=-1,s=0,a=-1,l,o;for(;++a<=e.length;){if(a<e.length)l=e.codePointAt(a);else{if(l===47)break;l=47}if(l===47){if(!(i===a-1||s===1))if(i!==a-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(o=n.lastIndexOf("/"),o!==n.length-1){o<0?(n="",r=0):(n=n.slice(0,o),r=n.length-1-n.lastIndexOf("/")),i=a,s=0;continue}}else if(n.length>0){n="",r=0,i=a,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,s=0}else l===46&&s>-1?s++:s=-1}return n}function vt(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Kf={cwd:qf};function qf(){return"/"}function Pn(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Wf(e){if(typeof e=="string")e=new URL(e);else if(!Pn(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 Qf(e)}function Qf(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 Zs{constructor(t){let n;t?Pn(t)?n={path:t}:typeof t=="string"||Gf(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":Kf.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){dn(t,"basename"),hn(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){ui(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(hn(t,"extname"),ui(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){Pn(t)&&(t=Wf(t)),dn(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){dn(t,"stem"),hn(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 hn(e,t){if(e&&e.includes(Ne.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Ne.sep+"`")}function dn(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function ui(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function Gf(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Yf=(function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),Xf={}.hasOwnProperty;class cr extends Yf{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=Ff()}copy(){const t=new cr;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):Xf.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=Et(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,a){const l=Et(t),o=r.parse(l);r.run(o,l,function(h,c,p){if(h||!c||!p)return u(h);const f=c,m=r.stringify(f,p);ep(m)?p.value=m:p.result=m,u(h,p)});function u(h,c){h||!c?a(h):s?s(c):n(void 0,c)}}}processSync(t){let n=!1,r;return this.freeze(),fn("processSync",this.parser||this.Parser),pn("processSync",this.compiler||this.Compiler),this.process(t,i),hi("processSync","process",n),r;function i(s,a){n=!0,li(s),r=a}}run(t,n,r){ci(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(a,l){const o=Et(n);i.run(t,o,u);function u(h,c,p){const f=c||t;h?l(h):a?a(f):r(void 0,f,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),hi("runSync","run",r),i;function s(a,l){li(a),i=l,r=!0}}stringify(t,n){this.freeze();const r=Et(n),i=this.compiler||this.Compiler;return pn("stringify",i),ci(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)?l(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(u){if(typeof u=="function")o(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[h,...c]=u;o(h,c)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(u.plugins),u.settings&&(i.settings=un(!0,i.settings,u.settings))}function l(u){let h=-1;if(u!=null)if(Array.isArray(u))for(;++h<u.length;){const c=u[h];s(c)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function o(u,h){let c=-1,p=-1;for(;++c<r.length;)if(r[c][0]===u){p=c;break}if(p===-1)r.push([u,...h]);else if(h.length>0){let[f,...m]=h;const y=r[p][1];jn(y)&&jn(f)&&(f=un(!0,y,f)),r[p]=[u,f,...m]}}}}const Jf=new cr().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 ci(e){if(!jn(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function hi(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Et(e){return Zf(e)?e:new Zs(e)}function Zf(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function ep(e){return typeof e=="string"||tp(e)}function tp(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const np="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",di=[],fi={allowDangerousHtml:!0},rp=/^(https?|ircs?|mailto|xmpp)$/i,ip=[{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 sp(e){const t=ap(e),n=lp(e);return op(t.runSync(t.parse(n),n),e)}function ap(e){const t=e.rehypePlugins||di,n=e.remarkPlugins||di,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...fi}:fi;return Jf().use(_d).use(n).use(Pf,r).use(t)}function lp(e){const t=e.children||"",n=new Zs;return typeof t=="string"&&(n.value=t),n}function op(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,o=t.urlTransform||up;for(const h of ip)Object.hasOwn(t,h.from)&&(""+h.from+(h.to?"use `"+h.to+"` instead":"remove it")+np+h.id,void 0);return ur(e,u),wc(e,{Fragment:d.Fragment,components:i,ignoreInvalidStyle:!0,jsx:d.jsx,jsxs:d.jsxs,passKeys:!0,passNode:!0});function u(h,c,p){if(h.type==="raw"&&p&&typeof c=="number")return a?p.children.splice(c,1):p.children[c]={type:"text",value:h.value},c;if(h.type==="element"){let f;for(f in sn)if(Object.hasOwn(sn,f)&&Object.hasOwn(h.properties,f)){const m=h.properties[f],y=sn[f];(y===null||y.includes(h.tagName))&&(h.properties[f]=o(String(m||""),f,h))}}if(h.type==="element"){let f=n?!n.includes(h.tagName):s?s.includes(h.tagName):!1;if(!f&&r&&typeof c=="number"&&(f=!r(h,c,p)),f&&p&&typeof c=="number")return l&&h.children?p.children.splice(c,1,...h.children):p.children.splice(c,1),c}}}function up(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||rp.test(e.slice(0,t))?e:""}function pi(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 cp(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function hp(e,t,n){const i=Gt((n||{}).ignore||[]),s=dp(t);let a=-1;for(;++a<s.length;)Js(e,"text",l);function l(u,h){let c=-1,p;for(;++c<h.length;){const f=h[c],m=p?p.children:void 0;if(i(f,m?m.indexOf(f):void 0,p))return;p=f}if(p)return o(u,h)}function o(u,h){const c=h[h.length-1],p=s[a][0],f=s[a][1];let m=0;const S=c.children.indexOf(u);let g=!1,I=[];p.lastIndex=0;let M=p.exec(u.value);for(;M;){const D=M.index,O={index:M.index,input:M.input,stack:[...h,u]};let T=f(...M,O);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?p.lastIndex=D+1:(m!==D&&I.push({type:"text",value:u.value.slice(m,D)}),Array.isArray(T)?I.push(...T):T&&I.push(T),m=D+M[0].length,g=!0),!p.global)break;M=p.exec(u.value)}return g?(m<u.value.length&&I.push({type:"text",value:u.value.slice(m)}),c.children.splice(S,1,...I)):I=[u],S+I.length}}function 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]),pp(i[1])])}return t}function fp(e){return typeof e=="string"?new RegExp(cp(e),"g"):e}function pp(e){return typeof e=="function"?e:function(){return e}}const gn="phrasing",xn=["autolink","link","image","label"];function mp(){return{transforms:[wp],enter:{literalAutolink:xp,literalAutolinkEmail:yn,literalAutolinkHttp:yn,literalAutolinkWww:yn},exit:{literalAutolink:kp,literalAutolinkEmail:Sp,literalAutolinkHttp:yp,literalAutolinkWww:bp}}}function gp(){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 xp(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function yn(e){this.config.enter.autolinkProtocol.call(this,e)}function yp(e){this.config.exit.autolinkProtocol.call(this,e)}function bp(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 Sp(e){this.config.exit.autolinkEmail.call(this,e)}function kp(e){this.exit(e)}function wp(e){hp(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Cp],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),vp]],{ignore:["link","linkReference"]})}function Cp(e,t,n,r,i){let s="";if(!ea(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!Tp(n)))return!1;const a=Ip(n+r);if(!a[0])return!1;const l={type:"link",title:null,url:s+t+a[0],children:[{type:"text",value:t+a[0]}]};return a[1]?[l,{type:"text",value:a[1]}]:l}function vp(e,t,n,r){return!ea(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Tp(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 Ip(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=pi(e,"(");let s=pi(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 ea(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Ke(n)||qt(n))&&(!t||n!==47)}ta.peek=Dp;function Mp(){this.buffer()}function Np(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Lp(){this.buffer()}function Ep(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Ap(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ve(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Rp(e){this.exit(e)}function jp(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ve(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Pp(e){this.exit(e)}function Dp(){return"["}function ta(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const a=n.enter("footnoteReference"),l=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),l(),a(),s+=i.move("]"),s}function Op(){return{enter:{gfmFootnoteCallString:Mp,gfmFootnoteCall:Np,gfmFootnoteDefinitionLabelString:Lp,gfmFootnoteDefinition:Ep},exit:{gfmFootnoteCallString:Ap,gfmFootnoteCall:Rp,gfmFootnoteDefinitionLabelString:jp,gfmFootnoteDefinition:Pp}}}function Fp(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:ta},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,a){const l=s.createTracker(a);let o=l.move("[^");const u=s.enter("footnoteDefinition"),h=s.enter("label");return o+=l.move(s.safe(s.associationId(r),{before:o,after:"]"})),h(),o+=l.move("]:"),r.children&&r.children.length>0&&(l.shift(4),o+=l.move((t?`
17
- `:" ")+s.indentLines(s.containerFlow(r,l.current()),t?na:zp))),u(),o}}function zp(e,t,n){return t===0?e:na(e,t,n)}function na(e,t,n){return(n?"":" ")+e}const _p=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];ra.peek=$p;function Bp(){return{canContainEols:["delete"],enter:{strikethrough:Hp},exit:{strikethrough:Vp}}}function Up(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:_p}],handlers:{delete:ra}}}function Hp(e){this.enter({type:"delete",children:[]},e)}function Vp(e){this.exit(e)}function ra(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let a=i.move("~~");return a+=n.containerPhrasing(e,{...i.current(),before:a,after:"~"}),a+=i.move("~~"),s(),a}function $p(){return"~"}function Kp(e){return e.length}function qp(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||Kp,s=[],a=[],l=[],o=[];let u=0,h=-1;for(;++h<e.length;){const y=[],S=[];let g=-1;for(e[h].length>u&&(u=e[h].length);++g<e[h].length;){const I=Wp(e[h][g]);if(n.alignDelimiters!==!1){const M=i(I);S[g]=M,(o[g]===void 0||M>o[g])&&(o[g]=M)}y.push(I)}a[h]=y,l[h]=S}let c=-1;if(typeof r=="object"&&"length"in r)for(;++c<u;)s[c]=mi(r[c]);else{const y=mi(r);for(;++c<u;)s[c]=y}c=-1;const p=[],f=[];for(;++c<u;){const y=s[c];let S="",g="";y===99?(S=":",g=":"):y===108?S=":":y===114&&(g=":");let I=n.alignDelimiters===!1?1:Math.max(1,o[c]-S.length-g.length);const M=S+"-".repeat(I)+g;n.alignDelimiters!==!1&&(I=S.length+I+g.length,I>o[c]&&(o[c]=I),f[c]=I),p[c]=M}a.splice(1,0,p),l.splice(1,0,f),h=-1;const m=[];for(;++h<a.length;){const y=a[h],S=l[h];c=-1;const g=[];for(;++c<u;){const I=y[c]||"";let M="",D="";if(n.alignDelimiters!==!1){const O=o[c]-(S[c]||0),T=s[c];T===114?M=" ".repeat(O):T===99?O%2?(M=" ".repeat(O/2+.5),D=" ".repeat(O/2-.5)):(M=" ".repeat(O/2),D=M):D=" ".repeat(O)}n.delimiterStart!==!1&&!c&&g.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&I==="")&&(n.delimiterStart!==!1||c)&&g.push(" "),n.alignDelimiters!==!1&&g.push(M),g.push(I),n.alignDelimiters!==!1&&g.push(D),n.padding!==!1&&g.push(" "),(n.delimiterEnd!==!1||c!==u-1)&&g.push("|")}m.push(n.delimiterEnd===!1?g.join("").replace(/ +$/,""):g.join(""))}return m.join(`
18
- `)}function Wp(e){return e==null?"":String(e)}function mi(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 Qp(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const a=n.indentLines(n.containerFlow(e,s.current()),Gp);return i(),a}function Gp(e,t,n){return">"+(n?"":" ")+e}function Yp(e,t){return gi(e,t.inConstruct,!0)&&!gi(e,t.notInConstruct,!1)}function gi(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 xi(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
19
- `&&Yp(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
20
- `}function Xp(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>a&&(a=s):s=1,i=r+t.length,r=n.indexOf(t,i);return a}function Jp(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 Zp(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 em(e,t,n,r){const i=Zp(n),s=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(Jp(e,n)){const c=n.enter("codeIndented"),p=n.indentLines(s,tm);return c(),p}const l=n.createTracker(r),o=i.repeat(Math.max(Xp(s,i)+1,3)),u=n.enter("codeFenced");let h=l.move(o);if(e.lang){const c=n.enter(`codeFencedLang${a}`);h+=l.move(n.safe(e.lang,{before:h,after:" ",encode:["`"],...l.current()})),c()}if(e.lang&&e.meta){const c=n.enter(`codeFencedMeta${a}`);h+=l.move(" "),h+=l.move(n.safe(e.meta,{before:h,after:`
21
- `,encode:["`"],...l.current()})),c()}return h+=l.move(`
22
- `),s&&(h+=l.move(s+`
23
- `)),h+=l.move(o),u(),h}function tm(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 nm(e,t,n,r){const i=hr(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("definition");let l=n.enter("label");const o=n.createTracker(r);let u=o.move("[");return u+=o.move(n.safe(n.associationId(e),{before:u,after:"]",...o.current()})),u+=o.move("]: "),l(),!e.url||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(e.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(l=n.enter("destinationRaw"),u+=o.move(n.safe(e.url,{before:u,after:e.title?" ":`
24
- `,...o.current()}))),l(),e.title&&(l=n.enter(`title${s}`),u+=o.move(" "+i),u+=o.move(n.safe(e.title,{before:u,after:i,...o.current()})),u+=o.move(i),l()),a(),u}function rm(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 yt(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Bt(e,t,n){const r=Ze(e),i=Ze(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}}ia.peek=im;function ia(e,t,n,r){const i=rm(n),s=n.enter("emphasis"),a=n.createTracker(r),l=a.move(i);let o=a.move(n.containerPhrasing(e,{after:i,before:l,...a.current()}));const u=o.charCodeAt(0),h=Bt(r.before.charCodeAt(r.before.length-1),u,i);h.inside&&(o=yt(u)+o.slice(1));const c=o.charCodeAt(o.length-1),p=Bt(r.after.charCodeAt(0),c,i);p.inside&&(o=o.slice(0,-1)+yt(c));const f=a.move(i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:h.outside},l+o+f}function im(e,t,n){return n.options.emphasis||"*"}function sm(e,t){let n=!1;return ur(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,An}),!!((!e.depth||e.depth<3)&&nr(e)&&(t.options.setext||n))}function am(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(sm(e,n)){const h=n.enter("headingSetext"),c=n.enter("phrasing"),p=n.containerPhrasing(e,{...s.current(),before:`
25
- `,after:`
26
- `});return c(),h(),p+`
27
- `+(i===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
28
- `))+1))}const a="#".repeat(i),l=n.enter("headingAtx"),o=n.enter("phrasing");s.move(a+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
29
- `,...s.current()});return/^[\t ]/.test(u)&&(u=yt(u.charCodeAt(0))+u.slice(1)),u=u?a+" "+u:a,n.options.closeAtx&&(u+=" "+a),o(),l(),u}sa.peek=lm;function sa(e){return e.value||""}function lm(){return"<"}aa.peek=om;function aa(e,t,n,r){const i=hr(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let l=n.enter("label");const o=n.createTracker(r);let u=o.move("![");return u+=o.move(n.safe(e.alt,{before:u,after:"]",...o.current()})),u+=o.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(e.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(l=n.enter("destinationRaw"),u+=o.move(n.safe(e.url,{before:u,after:e.title?" ":")",...o.current()}))),l(),e.title&&(l=n.enter(`title${s}`),u+=o.move(" "+i),u+=o.move(n.safe(e.title,{before:u,after:i,...o.current()})),u+=o.move(i),l()),u+=o.move(")"),a(),u}function om(){return"!"}la.peek=um;function la(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let a=n.enter("label");const l=n.createTracker(r);let o=l.move("![");const u=n.safe(e.alt,{before:o,after:"]",...l.current()});o+=l.move(u+"]["),a();const h=n.stack;n.stack=[],a=n.enter("reference");const c=n.safe(n.associationId(e),{before:o,after:"]",...l.current()});return a(),n.stack=h,s(),i==="full"||!u||u!==c?o+=l.move(c+"]"):i==="shortcut"?o=o.slice(0,-1):o+=l.move("]"),o}function um(){return"!"}oa.peek=cm;function oa(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const a=n.unsafe[s],l=n.compilePattern(a);let o;if(a.atBreak)for(;o=l.exec(r);){let u=o.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(o.index+1)}}return i+r+i}function cm(){return"`"}function ua(e,t){const n=nr(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))}ca.peek=hm;function ca(e,t,n,r){const i=hr(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let l,o;if(ua(e,n)){const h=n.stack;n.stack=[],l=n.enter("autolink");let c=a.move("<");return c+=a.move(n.containerPhrasing(e,{before:c,after:">",...a.current()})),c+=a.move(">"),l(),n.stack=h,c}l=n.enter("link"),o=n.enter("label");let u=a.move("[");return u+=a.move(n.containerPhrasing(e,{before:u,after:"](",...a.current()})),u+=a.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(n.safe(e.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(o=n.enter("destinationRaw"),u+=a.move(n.safe(e.url,{before:u,after:e.title?" ":")",...a.current()}))),o(),e.title&&(o=n.enter(`title${s}`),u+=a.move(" "+i),u+=a.move(n.safe(e.title,{before:u,after:i,...a.current()})),u+=a.move(i),o()),u+=a.move(")"),l(),u}function hm(e,t,n){return ua(e,n)?"<":"["}ha.peek=dm;function ha(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let a=n.enter("label");const l=n.createTracker(r);let o=l.move("[");const u=n.containerPhrasing(e,{before:o,after:"]",...l.current()});o+=l.move(u+"]["),a();const h=n.stack;n.stack=[],a=n.enter("reference");const c=n.safe(n.associationId(e),{before:o,after:"]",...l.current()});return a(),n.stack=h,s(),i==="full"||!u||u!==c?o+=l.move(c+"]"):i==="shortcut"?o=o.slice(0,-1):o+=l.move("]"),o}function dm(){return"["}function dr(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=dr(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 pm(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 da(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 mm(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?pm(n):dr(n);const l=e.ordered?a==="."?")":".":fm(n);let o=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const h=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&h&&(!h.children||!h.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(o=!0),da(n)===a&&h){let c=-1;for(;++c<e.children.length;){const p=e.children[c];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){o=!0;break}}}}o&&(a=l),n.bulletCurrent=a;const u=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=s,i(),u}function gm(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 xm(e,t,n,r){const i=gm(n);let s=n.bulletCurrent||dr(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let a=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const l=n.createTracker(r);l.move(s+" ".repeat(a-s.length)),l.shift(a);const o=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,l.current()),h);return o(),u;function h(c,p,f){return p?(f?"":" ".repeat(a))+c:(f?s:s+" ".repeat(a-s.length))+c}}function ym(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,r);return s(),i(),a}const bm=Gt(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Sm(e,t,n,r){return(e.children.some(function(a){return bm(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function km(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}fa.peek=wm;function fa(e,t,n,r){const i=km(n),s=n.enter("strong"),a=n.createTracker(r),l=a.move(i+i);let o=a.move(n.containerPhrasing(e,{after:i,before:l,...a.current()}));const u=o.charCodeAt(0),h=Bt(r.before.charCodeAt(r.before.length-1),u,i);h.inside&&(o=yt(u)+o.slice(1));const c=o.charCodeAt(o.length-1),p=Bt(r.after.charCodeAt(0),c,i);p.inside&&(o=o.slice(0,-1)+yt(c));const f=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:h.outside},l+o+f}function wm(e,t,n){return n.options.strong||"*"}function Cm(e,t,n,r){return n.safe(e.value,r)}function vm(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 Tm(e,t,n){const r=(da(n)+(n.options.ruleSpaces?" ":"")).repeat(vm(n));return n.options.ruleSpaces?r.slice(0,-1):r}const pa={blockquote:Qp,break:xi,code:em,definition:nm,emphasis:ia,hardBreak:xi,heading:am,html:sa,image:aa,imageReference:la,inlineCode:oa,link:ca,linkReference:ha,list:mm,listItem:xm,paragraph:ym,root:Sm,strong:fa,text:Cm,thematicBreak:Tm};function Im(){return{enter:{table:Mm,tableData:yi,tableHeader:yi,tableRow:Lm},exit:{codeText:Em,table:Nm,tableData:bn,tableHeader:bn,tableRow:bn}}}function Mm(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 Nm(e){this.exit(e),this.data.inTable=void 0}function Lm(e){this.enter({type:"tableRow",children:[]},e)}function bn(e){this.exit(e)}function yi(e){this.enter({type:"tableCell",children:[]},e)}function Em(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Am));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Am(e,t){return t==="|"?t:e}function Rm(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
30
- `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:a,tableCell:o,tableRow:l}};function a(f,m,y,S){return u(h(f,y,S),f.align)}function l(f,m,y,S){const g=c(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"),M=y.containerPhrasing(f,{...S,before:s,after:s});return I(),g(),M}function u(f,m){return qp(f,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function h(f,m,y){const S=f.children;let g=-1;const I=[],M=m.enter("table");for(;++g<S.length;)I[g]=c(S[g],m,y);return M(),I}function c(f,m,y){const S=f.children;let g=-1;const I=[],M=m.enter("tableRow");for(;++g<S.length;)I[g]=o(S[g],f,m,y);return M(),I}function p(f,m,y){let S=pa.inlineCode(f,m,y);return y.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function jm(){return{exit:{taskListCheckValueChecked:bi,taskListCheckValueUnchecked:bi,paragraph:Dm}}}function Pm(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Om}}}function bi(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function Dm(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,a;for(;++s<i.length;){const l=i[s];if(l.type==="paragraph"){a=l;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function Om(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",l=n.createTracker(r);s&&l.move(a);let o=pa.listItem(e,t,n,{...r,...l.current()});return s&&(o=o.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),o;function u(h){return h+a}}function Fm(){return[mp(),Op(),Bp(),Im(),jm()]}function zm(e){return{extensions:[gp(),Fp(e),Up(),Rm(e),Pm()]}}const _m={tokenize:Km,partial:!0},ma={tokenize:qm,partial:!0},ga={tokenize:Wm,partial:!0},xa={tokenize:Qm,partial:!0},Bm={tokenize:Gm,partial:!0},ya={name:"wwwAutolink",tokenize:Vm,previous:Sa},ba={name:"protocolAutolink",tokenize:$m,previous:ka},Fe={name:"emailAutolink",tokenize:Hm,previous:wa},Le={};function Um(){return{text:Le}}let $e=48;for(;$e<123;)Le[$e]=Fe,$e++,$e===58?$e=65:$e===91&&($e=97);Le[43]=Fe;Le[45]=Fe;Le[46]=Fe;Le[95]=Fe;Le[72]=[Fe,ba];Le[104]=[Fe,ba];Le[87]=[Fe,ya];Le[119]=[Fe,ya];function Hm(e,t,n){const r=this;let i,s;return a;function a(c){return!Dn(c)||!wa.call(r,r.previous)||fr(r.events)?n(c):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),l(c))}function l(c){return Dn(c)?(e.consume(c),l):c===64?(e.consume(c),o):n(c)}function o(c){return c===46?e.check(Bm,h,u)(c):c===45||c===95||oe(c)?(s=!0,e.consume(c),o):h(c)}function u(c){return e.consume(c),i=!0,o}function h(c){return s&&i&&ce(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(c)):n(c)}}function Vm(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!Sa.call(r,r.previous)||fr(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(_m,e.attempt(ma,e.attempt(ga,s),n),n)(a))}function s(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function $m(e,t,n){const r=this;let i="",s=!1;return a;function a(c){return(c===72||c===104)&&ka.call(r,r.previous)&&!fr(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(c),e.consume(c),l):n(c)}function l(c){if(ce(c)&&i.length<5)return i+=String.fromCodePoint(c),e.consume(c),l;if(c===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(c),o}return n(c)}function o(c){return c===47?(e.consume(c),s?u:(s=!0,o)):n(c)}function u(c){return c===null||Ft(c)||X(c)||Ke(c)||qt(c)?n(c):e.attempt(ma,e.attempt(ga,h),n)(c)}function h(c){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(c)}}function Km(e,t,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),i):a===46&&r===3?(e.consume(a),s):n(a)}function s(a){return a===null?n(a):t(a)}}function qm(e,t,n){let r,i,s;return a;function a(u){return u===46||u===95?e.check(xa,o,l)(u):u===null||X(u)||Ke(u)||u!==45&&qt(u)?o(u):(s=!0,e.consume(u),a)}function l(u){return u===95?r=!0:(i=r,r=void 0),e.consume(u),a}function o(u){return i||r||!s?n(u):t(u)}}function Wm(e,t){let n=0,r=0;return i;function i(a){return a===40?(n++,e.consume(a),i):a===41&&r<n?s(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(xa,t,s)(a):a===null||X(a)||Ke(a)?t(a):(e.consume(a),i)}function s(a){return a===41&&r++,e.consume(a),i}}function Qm(e,t,n){return r;function r(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(e.consume(l),r):l===38?(e.consume(l),s):l===93?(e.consume(l),i):l===60||l===null||X(l)||Ke(l)?t(l):n(l)}function i(l){return l===null||l===40||l===91||X(l)||Ke(l)?t(l):r(l)}function s(l){return ce(l)?a(l):n(l)}function a(l){return l===59?(e.consume(l),r):ce(l)?(e.consume(l),a):n(l)}}function Gm(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return oe(s)?n(s):t(s)}}function Sa(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||X(e)}function ka(e){return!ce(e)}function wa(e){return!(e===47||Dn(e))}function Dn(e){return e===43||e===45||e===46||e===95||oe(e)}function fr(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 Ym={tokenize:ig,partial:!0};function Xm(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:tg,continuation:{tokenize:ng},exit:rg}},text:{91:{name:"gfmFootnoteCall",tokenize:eg},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Jm,resolveTo:Zm}}}}function Jm(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const o=r.events[i][1];if(o.type==="labelImage"){a=o;break}if(o.type==="gfmFootnoteCall"||o.type==="labelLink"||o.type==="label"||o.type==="image"||o.type==="link")break}return l;function l(o){if(!a||!a._balanced)return n(o);const u=ve(r.sliceSerialize({start:a.end,end:r.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?n(o):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),t(o))}}function Zm(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},l=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",a,t],["exit",a,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...l),e}function eg(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,a;return l;function l(c){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),o}function o(c){return c!==94?n(c):(e.enter("gfmFootnoteCallMarker"),e.consume(c),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(c){if(s>999||c===93&&!a||c===null||c===91||X(c))return n(c);if(c===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(ve(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(c)}return X(c)||(a=!0),s++,e.consume(c),c===92?h:u}function h(c){return c===91||c===92||c===93?(e.consume(c),s++,u):u(c)}}function tg(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,a=0,l;return o;function o(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):n(m)}function h(m){if(a>999||m===93&&!l||m===null||m===91||X(m))return n(m);if(m===93){e.exit("chunkString");const y=e.exit("gfmFootnoteDefinitionLabelString");return s=ve(r.sliceSerialize(y)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return X(m)||(l=!0),a++,e.consume(m),m===92?c:h}function c(m){return m===91||m===92||m===93?(e.consume(m),a++,h):h(m)}function p(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),Q(e,f,"gfmFootnoteDefinitionWhitespace")):n(m)}function f(m){return t(m)}}function ng(e,t,n){return e.check(Ct,t,e.attempt(Ym,t,n))}function rg(e){e.exit("gfmFootnoteDefinition")}function ig(e,t,n){const r=this;return Q(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(s):n(s)}}function sg(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,l){let o=-1;for(;++o<a.length;)if(a[o][0]==="enter"&&a[o][1].type==="strikethroughSequenceTemporary"&&a[o][1]._close){let u=o;for(;u--;)if(a[u][0]==="exit"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._open&&a[o][1].end.offset-a[o][1].start.offset===a[u][1].end.offset-a[u][1].start.offset){a[o][1].type="strikethroughSequence",a[u][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},a[u][1].start),end:Object.assign({},a[o][1].end)},c={type:"strikethroughText",start:Object.assign({},a[u][1].end),end:Object.assign({},a[o][1].start)},p=[["enter",h,l],["enter",a[u][1],l],["exit",a[u][1],l],["enter",c,l]],f=l.parser.constructs.insideSpan.null;f&&ye(p,p.length,0,Wt(f,a.slice(u+1,o),l)),ye(p,p.length,0,[["exit",c,l],["enter",a[o][1],l],["exit",a[o][1],l],["exit",h,l]]),ye(a,u-1,o-u+3,p),o=u+p.length-2;break}}for(o=-1;++o<a.length;)a[o][1].type==="strikethroughSequenceTemporary"&&(a[o][1].type="data");return a}function s(a,l,o){const u=this.previous,h=this.events;let c=0;return p;function p(m){return u===126&&h[h.length-1][1].type!=="characterEscape"?o(m):(a.enter("strikethroughSequenceTemporary"),f(m))}function f(m){const y=Ze(u);if(m===126)return c>1?o(m):(a.consume(m),c++,f);if(c<2&&!n)return o(m);const S=a.exit("strikethroughSequenceTemporary"),g=Ze(m);return S._open=!g||g===2&&!!y,S._close=!y||y===2&&!!g,l(m)}}}class ag{constructor(){this.map=[]}add(t,n,r){lg(this,t,n,r)}consume(t){if(this.map.sort(function(s,a){return s[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function 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 og(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 ug(){return{flow:{null:{name:"table",tokenize:cg,resolveAll:hg}}}}function cg(e,t,n){const r=this;let i=0,s=0,a;return l;function l(k){let L=r.events.length-1;for(;L>-1;){const P=r.events[L][1].type;if(P==="lineEnding"||P==="linePrefix")L--;else break}const E=L>-1?r.events[L][1].type:null,U=E==="tableHead"||E==="tableRow"?T:o;return U===T&&r.parser.lazy[r.now().line]?n(k):U(k)}function o(k){return e.enter("tableHead"),e.enter("tableRow"),u(k)}function u(k){return k===124||(a=!0,s+=1),h(k)}function h(k){return k===null?n(k):F(k)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),f):n(k):q(k)?Q(e,h,"whitespace")(k):(s+=1,a&&(a=!1,i+=1),k===124?(e.enter("tableCellDivider"),e.consume(k),e.exit("tableCellDivider"),a=!0,h):(e.enter("data"),c(k)))}function c(k){return k===null||k===124||X(k)?(e.exit("data"),h(k)):(e.consume(k),k===92?p:c)}function p(k){return k===92||k===124?(e.consume(k),c):c(k)}function f(k){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(k):(e.enter("tableDelimiterRow"),a=!1,q(k)?Q(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):m(k))}function m(k){return k===45||k===58?S(k):k===124?(a=!0,e.enter("tableCellDivider"),e.consume(k),e.exit("tableCellDivider"),y):O(k)}function y(k){return q(k)?Q(e,S,"whitespace")(k):S(k)}function S(k){return k===58?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(k),e.exit("tableDelimiterMarker"),g):k===45?(s+=1,g(k)):k===null||F(k)?D(k):O(k)}function g(k){return k===45?(e.enter("tableDelimiterFiller"),I(k)):O(k)}function I(k){return k===45?(e.consume(k),I):k===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(k),e.exit("tableDelimiterMarker"),M):(e.exit("tableDelimiterFiller"),M(k))}function M(k){return q(k)?Q(e,D,"whitespace")(k):D(k)}function D(k){return k===124?m(k):k===null||F(k)?!a||i!==s?O(k):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(k)):O(k)}function O(k){return n(k)}function T(k){return e.enter("tableRow"),z(k)}function z(k){return k===124?(e.enter("tableCellDivider"),e.consume(k),e.exit("tableCellDivider"),z):k===null||F(k)?(e.exit("tableRow"),t(k)):q(k)?Q(e,z,"whitespace")(k):(e.enter("data"),_(k))}function _(k){return k===null||k===124||X(k)?(e.exit("data"),z(k)):(e.consume(k),k===92?B:_)}function B(k){return k===92||k===124?(e.consume(k),_):_(k)}}function hg(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],l=!1,o=0,u,h,c;const p=new ag;for(;++n<e.length;){const f=e[n],m=f[1];f[0]==="enter"?m.type==="tableHead"?(l=!1,o!==0&&(Si(p,t,o,u,h),h=void 0,o=0),u={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",u,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,c=void 0,s=[0,0,0,0],a=[0,n+1,0,0],l&&(l=!1,h={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",h,t]])),i=m.type==="tableDelimiterRow"?2:h?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(s[1]!==0&&(a[0]=a[1],c=At(p,t,s,i,void 0,c),s=[0,0,0,0]),a[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(a[0]=a[1],c=At(p,t,s,i,void 0,c)),s=a,a=[s[1],n,0,0])):m.type==="tableHead"?(l=!0,o=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(o=n,s[1]!==0?(a[0]=a[1],c=At(p,t,s,i,n,c)):a[1]!==0&&(c=At(p,t,a,i,n,c)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=n)}for(o!==0&&Si(p,t,o,u,h),p.consume(t.events),n=-1;++n<t.events.length;){const f=t.events[n];f[0]==="enter"&&f[1].type==="table"&&(f[1]._align=og(t.events,n))}return e}function At(e,t,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(s.end=Object.assign({},Ye(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const o=Ye(t.events,n[1]);if(s={type:a,start:Object.assign({},o),end:Object.assign({},o)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const u=Ye(t.events,n[2]),h=Ye(t.events,n[3]),c={type:l,start:Object.assign({},u),end:Object.assign({},h)};if(e.add(n[2],0,[["enter",c,t]]),r!==2){const p=t.events[n[2]],f=t.events[n[3]];if(p[1].end=Object.assign({},f[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,y=n[3]-n[2]-1;e.add(m,y,[])}}e.add(n[3]+1,0,[["exit",c,t]])}return i!==void 0&&(s.end=Object.assign({},Ye(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Si(e,t,n,r,i){const s=[],a=Ye(t.events,n);i&&(i.end=Object.assign({},a),s.push(["exit",i,t])),r.end=Object.assign({},a),s.push(["exit",r,t]),e.add(n+1,0,s)}function Ye(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const dg={name:"tasklistCheck",tokenize:pg};function fg(){return{text:{91:dg}}}function pg(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 X(o)?(e.enter("taskListCheckValueUnchecked"),e.consume(o),e.exit("taskListCheckValueUnchecked"),a):o===88||o===120?(e.enter("taskListCheckValueChecked"),e.consume(o),e.exit("taskListCheckValueChecked"),a):n(o)}function a(o){return o===93?(e.enter("taskListCheckMarker"),e.consume(o),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),l):n(o)}function l(o){return F(o)?t(o):q(o)?e.check({tokenize:mg},t,n)(o):n(o)}}function mg(e,t,n){return Q(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function gg(e){return js([Um(),Xm(),sg(e),ug(),fg()])}const xg={};function yg(e){const t=this,n=e||xg,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(gg(n)),s.push(Fm()),a.push(zm(n))}function bg(){var e;return typeof navigator<"u"&&typeof((e=navigator.clipboard)==null?void 0:e.writeText)=="function"}function Sg(e){if(typeof document>"u")return;const t=document.getSelection();t&&(t.removeAllRanges(),e.forEach(n=>t.addRange(n)))}function ki(e){if(typeof document>"u"||!document.body)return!1;const t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?t:null,r=n?{start:n.selectionStart,end:n.selectionEnd}:null,i=document.getSelection(),s=i?Array.from({length:i.rangeCount},(o,u)=>i.getRangeAt(u).cloneRange()):[],a=document.createElement("textarea");a.value=e,a.setAttribute("readonly",""),a.setAttribute("aria-hidden","true"),a.style.position="fixed",a.style.top="0",a.style.left="-9999px",a.style.opacity="0",a.style.pointerEvents="none",a.style.fontSize="12pt",document.body.appendChild(a);try{a.focus({preventScroll:!0})}catch{a.focus()}a.select(),a.setSelectionRange(0,a.value.length);let l=!1;try{l=typeof document.execCommand=="function"&&document.execCommand("copy")}catch{l=!1}if(a.remove(),t)try{t.focus({preventScroll:!0})}catch{t.focus()}return n&&r?n.setSelectionRange(r.start,r.end):Sg(s),l}async function kg(e){if(!e)return!1;if(bg())try{return await navigator.clipboard.writeText(e),!0}catch{return ki(e)}return ki(e)}const wg=1300;function Cg(e){const[t,n]=C.useState(!1),r=C.useCallback(async()=>{if(!e.text)return;const i=await kg(e.text);n(!!i)},[e.text]);return C.useEffect(()=>{if(!t||typeof window>"u")return;const i=window.setTimeout(()=>n(!1),e.resetDelayMs??wg);return()=>window.clearTimeout(i)},[t,e.resetDelayMs]),{copied:t,copy:r}}const vg=/language-([a-z0-9-]+)/i;function Ca(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Ca).join(""):""}function Tg(e){const t=Ca(e);return t.endsWith(`
32
- `)?t.slice(0,-1):t}function Ig(e){var n;const t=e?vg.exec(e):null;return((n=t==null?void 0:t[1])==null?void 0:n.toLowerCase())||"text"}function Mg(e){const t=C.useMemo(()=>Ig(e.className),[e.className]),n=C.useMemo(()=>Tg(e.children),[e.children]),{copied:r,copy:i}=Cg({text:n});return d.jsxs("div",{className:"chat-codeblock",children:[d.jsxs("div",{className:"chat-codeblock-toolbar",children:[d.jsx("span",{className:"chat-codeblock-language",children:t}),d.jsxs("button",{type:"button",className:"chat-codeblock-copy",onClick:()=>void i(),"aria-label":r?e.texts.copiedCodeLabel:e.texts.copyCodeLabel,children:[r?d.jsx(Ht,{className:"h-3.5 w-3.5"}):d.jsx(il,{className:"h-3.5 w-3.5"}),d.jsx("span",{children:r?e.texts.copiedCodeLabel:e.texts.copyCodeLabel})]})]}),d.jsx("pre",{children:d.jsx("code",{className:e.className,children:n})})]})}const wi=14e4,Ng=new Set(["http:","https:","mailto:","tel:"]);function Lg(e){return e.length<=wi?e:`${e.slice(0,wi)}
33
-
34
- ...`}function Ci(e){if(!e)return null;if(e.startsWith("#")||e.startsWith("/")||e.startsWith("./")||e.startsWith("../"))return e;try{const t=new URL(e);return Ng.has(t.protocol)?e:null}catch{return null}}function Eg(e){return/^https?:\/\//i.test(e)}function Ag(e){const t=e.role==="user",n=C.useMemo(()=>({a:({href:r,children:i,...s})=>{const a=Ci(r);if(!a)return d.jsx("span",{className:"chat-link-invalid",children:i});const l=Eg(a);return d.jsx("a",{...s,href:a,target:l?"_blank":void 0,rel:l?"noreferrer noopener":void 0,children:i})},table:({children:r,...i})=>d.jsx("div",{className:"chat-table-wrap",children:d.jsx("table",{...i,children:r})}),input:({type:r,checked:i,...s})=>r!=="checkbox"?d.jsx("input",{...s,type:r}):d.jsx("input",{...s,type:"checkbox",checked:i,readOnly:!0,disabled:!0,className:"chat-task-checkbox"}),img:({src:r,alt:i,...s})=>{const a=Ci(r);return a?d.jsx("img",{...s,src:a,alt:i||"",loading:"lazy",decoding:"async"}):null},code:({className:r,children:i,...s})=>{const a=String(i??"");return!r&&!a.includes(`
35
- `)?d.jsx("code",{...s,className:te("chat-inline-code",r),children:i}):d.jsx(Mg,{className:r,texts:e.texts,children:i})}}),[e.texts]);return d.jsx("div",{className:te("chat-markdown",t?"chat-markdown-user":"chat-markdown-assistant"),children:d.jsx(sp,{skipHtml:!0,remarkPlugins:[yg],components:n,children:Lg(e.text)})})}function Rg({file:e}){return e.isImage&&e.dataUrl?d.jsx("img",{src:e.dataUrl,alt:e.label,className:"block max-h-80 max-w-full rounded-2xl object-contain"}):e.dataUrl?d.jsxs("a",{href:e.dataUrl,download:e.label,target:"_blank",rel:"noreferrer",className:"block rounded-2xl border border-black/8 bg-black/6 px-3 py-2 text-sm transition hover:bg-black/8",children:[d.jsx("div",{className:"font-medium",children:e.label}),d.jsx("div",{className:"text-xs opacity-75",children:e.mimeType})]}):d.jsxs("div",{className:"rounded-2xl border border-black/8 bg-black/6 px-3 py-2 text-sm",children:[d.jsx("div",{className:"font-medium",children:e.label}),d.jsx("div",{className:"text-xs opacity-75",children:e.mimeType})]})}function jg(e){return d.jsxs("details",{className:"mt-3",open:!0,children:[d.jsx("summary",{className:te("cursor-pointer text-xs",e.isUser?"text-primary-100":"text-gray-500"),children:e.label}),d.jsx("pre",{className:te("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})]})}const vi=220,Pg=18,va={running:{text:"text-amber-700/80"},success:{text:"text-amber-700/80"},error:{text:"text-amber-700/80"},cancelled:{text:"text-amber-700/80"}};function Dg(e){const t=e.toLowerCase();return t.includes("exec")||t.includes("shell")||t.includes("command")?d.jsx(sl,{className:"h-3.5 w-3.5"}):t.includes("search")?d.jsx(Un,{className:"h-3.5 w-3.5"}):t.includes("fetch")||t.includes("http")||t.includes("web")?d.jsx(al,{className:"h-3.5 w-3.5"}):t.includes("read")||t.includes("file")?d.jsx(ll,{className:"h-3.5 w-3.5"}):t.includes("message")||t.includes("send")?d.jsx(ol,{className:"h-3.5 w-3.5"}):t.includes("cron")||t.includes("schedule")?d.jsx(ul,{className:"h-3.5 w-3.5"}):d.jsx(Ui,{className:"h-3.5 w-3.5"})}function Og(e,t=Pg){if(e.length<=t)return e;const n=Math.ceil((t-1)/2),r=Math.floor((t-1)/2);return`${e.slice(0,n)}…${e.slice(e.length-r)}`}function Fg(e){const t=va[e.statusTone];if(e.statusTone==="running")return d.jsxs("span",{className:te("inline-flex items-center gap-1 text-[11px] font-medium leading-none",t.text),children:[d.jsx(Di,{className:"h-3.5 w-3.5 animate-spin"}),e.statusLabel]});const n=e.statusTone==="success"?d.jsx(cl,{className:"h-3.5 w-3.5"}):e.statusTone==="error"?d.jsx(hl,{className:"h-3.5 w-3.5"}):d.jsx(dl,{className:"h-3.5 w-3.5"});return d.jsxs("span",{className:te("inline-flex items-center gap-1 text-[11px] font-medium leading-none",t.text),children:[n,e.statusTone==="success"?null:e.statusLabel]})}function zg({card:e}){var a;const t=((a=e.output)==null?void 0:a.trim())??"",n=t.length>vi||t.includes(`
36
- `),r=n?`${t.slice(0,vi)}...`:t,i=e.kind==="result"||e.hasResult,s=va[e.statusTone];return d.jsxs("div",{className:"rounded-xl border border-amber-200/80 bg-amber-50/60 px-3 py-2.5",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs font-semibold text-amber-800",children:[Dg(e.toolName),d.jsx("span",{children:e.titleLabel}),d.jsx("span",{className:"font-mono text-[11px] text-amber-900/80",children:e.toolName}),Fg(e)]}),e.summary?d.jsxs("div",{className:"mt-1",children:[d.jsx("div",{className:"text-[10px] text-amber-700/75",children:e.inputLabel}),d.jsx("div",{className:"break-words font-mono text-[11px] text-amber-800/90",children:e.summary})]}):null,e.callId?d.jsxs("div",{className:te("mt-1 text-[10px]",s.text),children:[d.jsx("span",{children:e.callIdLabel}),d.jsx("span",{children:": "}),d.jsx("span",{className:"font-mono",children:Og(e.callId)})]}):null,i?d.jsx("div",{className:"mt-2",children:t?n?d.jsxs("details",{className:"group",children:[d.jsx("summary",{className:"cursor-pointer text-[11px] text-amber-700",children:e.outputLabel}),d.jsx("pre",{className:"mt-2 whitespace-pre-wrap break-words rounded-lg border border-amber-200 bg-amber-100/40 p-2 text-[11px] text-amber-900",children:t})]}):d.jsx("pre",{className:"rounded-lg border border-amber-200 bg-amber-100/40 p-2 text-[11px] whitespace-pre-wrap break-words text-amber-900",children:r}):d.jsx("div",{className:"text-[11px] text-amber-700/80",children:e.emptyLabel})}):null]})}function _g(e){return d.jsxs("div",{className:"rounded-lg border border-gray-200 bg-gray-50 px-2.5 py-2 text-xs text-gray-600",children:[d.jsxs("div",{className:"font-semibold text-gray-700",children:[e.label,": ",e.rawType]}),e.text?d.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-[11px] text-gray-500",children:e.text}):null]})}function Bg(e){const{message:t,texts:n}=e,{role:r}=t,i=r==="user";return d.jsx("div",{className:te("inline-block w-fit max-w-full rounded-2xl border px-4 py-3 shadow-sm",i?"border-primary bg-primary text-white":r==="assistant"?"border-gray-200 bg-white text-gray-900":"border-orange-200/80 bg-orange-50/70 text-gray-900"),children:d.jsx("div",{className:"space-y-2",children:t.parts.map((s,a)=>s.type==="markdown"?d.jsx(Ag,{text:s.text,role:r,texts:n},`markdown-${a}`):s.type==="reasoning"?d.jsx(jg,{label:s.label,text:s.text,isUser:i},`reasoning-${a}`):s.type==="tool-card"?d.jsx("div",{className:"mt-0.5",children:d.jsx(zg,{card:s.card})},`tool-${a}`):s.type==="file"?d.jsx(Rg,{file:s.file},`file-${a}`):s.type==="unknown"?d.jsx(_g,{label:s.label,rawType:s.rawType,text:s.text},`unknown-${a}`):null)})})}function Ug(e){return d.jsxs("div",{className:te("px-1 text-[11px] leading-4 text-gray-400",e.isUser?"text-right":"text-left"),children:[e.roleLabel," · ",e.timestampLabel]})}const Hg=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function Vg(e){const t=e.trim();return t?t.replace(Hg,"").trim().length>0:!1}function $g(e){return e.parts.some(t=>t.type==="markdown"||t.type==="reasoning"?Vg(t.text):!0)}function Kg(e){const t=e.messages.filter($g),n=t.some(r=>r.role==="assistant"&&(r.status==="streaming"||r.status==="pending"));return d.jsxs("div",{className:te("space-y-5",e.className),children:[t.map(r=>{const i=r.role==="user";return d.jsxs("div",{className:te("flex gap-3",i?"justify-end":"justify-start"),children:[i?null:d.jsx(tn,{role:r.role}),d.jsxs("div",{className:te("w-fit max-w-[92%] space-y-2",i&&"flex flex-col items-end"),children:[d.jsx(Bg,{message:r,texts:e.texts}),d.jsx(Ug,{roleLabel:r.roleLabel,timestampLabel:r.timestampLabel,isUser:i})]}),i?d.jsx(tn,{role:r.role}):null]},r.id)}),e.isSending&&!n?d.jsxs("div",{className:"flex justify-start gap-3",children:[d.jsx(tn,{role:"assistant"}),d.jsx("div",{className:"rounded-2xl border border-gray-200 bg-white px-4 py-3 text-sm text-gray-500 shadow-sm",children:e.texts.typingLabel})]}):null]})}const qg=10;function Ti(e){e.scrollTop=e.scrollHeight}function Wg(e){const t=C.useRef(!0),n=C.useRef(!1),r=C.useRef(null),i=C.useRef(!1),s=C.useCallback(()=>{if(n.current){n.current=!1;return}const a=e.scrollRef.current;if(!a)return;const l=a.scrollHeight-a.scrollTop-a.clientHeight;t.current=l<=(e.stickyThresholdPx??qg)},[e.scrollRef,e.stickyThresholdPx]);return C.useEffect(()=>{r.current!==e.resetKey&&(r.current=e.resetKey,t.current=!0,i.current=!0)},[e.resetKey]),C.useLayoutEffect(()=>{if(!i.current||e.isLoading||!e.hasContent)return;const a=e.scrollRef.current;a&&(i.current=!1,n.current=!0,Ti(a))},[e.hasContent,e.isLoading,e.scrollRef]),C.useLayoutEffect(()=>{if(!t.current||!e.hasContent)return;const a=e.scrollRef.current;a&&(n.current=!0,Ti(a))},[e.contentVersion,e.hasContent,e.scrollRef]),{onScroll:s}}function Ta(){return Qn()}function Qg(e){return Iu(e)}function Ii(e){return Nu(e)}function Mi(e){return Kt(e,"skill")}function Gg(e){return Kt(e,"file")}function Yg(e,t,n){const r=new Set(t),i=Gn(e,o=>o.tokenKind==="skill"&&!r.has(o.tokenKey)),s=Kt(i,"skill"),a=new Map(n.map(o=>[o.spec,o])),l=t.filter(o=>!s.includes(o)).map(o=>{var u;return Wn({tokenKind:"skill",tokenKey:o,label:((u=a.get(o))==null?void 0:u.label)||o})});return l.length===0?i:Je([...i,...l])}function Ni(e,t){const n=new Set(t.map(r=>r.id));return Gn(e,r=>r.tokenKind==="file"&&!n.has(r.tokenKey))}function Xg(e,t){const n=new Set(Gg(e));return t.filter(r=>n.has(r.id))}function Jg(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 Zg={isProviderStateResolved:!1,composerNodes:Ta(),attachments:[],draft:"",pendingSessionType:"native",defaultSessionType:"native",canStopGeneration:!1,stopDisabledReason:null,sendError:null,isSending:!1,modelOptions:[],selectedModel:"",selectedThinkingLevel:null,sessionTypeOptions:[],selectedSessionType:void 0,stopSupported:!1,stopReason:void 0,canEditSessionType:!1,sessionTypeUnavailable:!1,skillRecords:[],isSkillsLoading:!1,selectedSkills:[]},Y=Vt(e=>({snapshot:Zg,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))})),ex={sessionRunStatusByKey:new Map,isLocallyRunning:!1,activeBackendRunId:null},On=Vt(e=>({snapshot:ex,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))})),tx={sessions:[],selectedSessionKey:null,selectedAgentId:"main",query:"",isLoading:!1},ae=Vt(e=>({snapshot:tx,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))}));function nx(e){const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,s=[],a=[],l=[],o=[];for(const h of e){const c=new Date(h.updatedAt).getTime();c>=n?s.push(h):c>=r?a.push(h):c>=i?l.push(h):o.push(h)}const u=[];return s.length>0&&u.push({label:v("chatSidebarToday"),sessions:s}),a.length>0&&u.push({label:v("chatSidebarYesterday"),sessions:a}),l.length>0&&u.push({label:v("chatSidebarPrevious7Days"),sessions:l}),o.length>0&&u.push({label:v("chatSidebarOlder"),sessions:o}),u}function rx(e){if(e.label&&e.label.trim())return e.label.trim();const t=e.key.split(":");return t[t.length-1]||e.key}function ix(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 sx(e){var t;return e.ready===!1?((t=e.reasonMessage)==null?void 0:t.trim())||v("statusSetup"):v("statusReady")}const ax=[{target:"/cron",label:()=>v("chatSidebarScheduledTasks"),icon:Hn},{target:"/skills",label:()=>v("chatSidebarSkills"),icon:Bn}];function lx(){var U,P;const e=qn(),t=Ml(),[n,r]=C.useState(!1),[i,s]=C.useState(null),[a,l]=C.useState(""),[o,u]=C.useState(null),h=Y(w=>w.snapshot),c=ae(w=>w.snapshot),p=On(w=>w.snapshot),f=Nl(w=>w.connectionStatus),{language:m,setLanguage:y}=$n(),{theme:S,setTheme:g}=Ll(),I=eu(),M=v(((U=pr.find(w=>w.value===S))==null?void 0:U.labelKey)??"themeWarm"),D=((P=mr.find(w=>w.value===m))==null?void 0:P.label)??m,O=C.useMemo(()=>nx(c.sessions),[c.sessions]),T=h.defaultSessionType||"native",z=C.useMemo(()=>h.sessionTypeOptions.filter(w=>w.value!==T),[T,h.sessionTypeOptions]),_=w=>{m!==w&&(y(w),window.location.reload())},B=(w,j)=>{const{sessions:$}=ae.getState().snapshot;ae.getState().setSnapshot({sessions:$.map(ee=>ee.key===w?{...ee,...j?{label:j}:{label:void 0}}:ee)})},k=w=>{var j;s(w.key),l(((j=w.label)==null?void 0:j.trim())??"")},L=()=>{s(null),l(""),u(null)},E=async w=>{var ee;const j=a.trim(),$=((ee=w.label)==null?void 0:ee.trim())??"";if(j===$){L();return}u(w.key);try{await I({sessionKey:w.key,label:j||null}),B(w.key,j||void 0),L()}catch{u(null)}};return d.jsxs("aside",{className:"w-[280px] shrink-0 flex flex-col h-full bg-secondary border-r border-gray-200/60",children:[d.jsx("div",{className:"px-5 pt-5 pb-3",children:d.jsx(El,{className:"flex items-center gap-2.5 min-w-0",suffix:d.jsx(Jo,{status:f})})}),d.jsx("div",{className:"px-4 pb-3",children:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(Oe,{variant:"primary",className:Ce("min-w-0 rounded-xl",z.length>0?"flex-1 rounded-r-md":"w-full"),onClick:()=>{r(!1),e.chatSessionListManager.createSession(T)},children:[d.jsx(fl,{className:"h-4 w-4 mr-2"}),v("chatSidebarNewTask")]}),z.length>0?d.jsxs(oo,{open:n,onOpenChange:r,children:[d.jsx(uo,{asChild:!0,children:d.jsx(Oe,{variant:"primary",size:"icon",className:"h-9 w-10 shrink-0 rounded-xl rounded-l-md","aria-label":v("chatSessionTypeLabel"),children:d.jsx(_n,{className:"h-4 w-4"})})}),d.jsxs(co,{align:"end",className:"w-64 p-2",children:[d.jsx("div",{className:"px-2 py-1 text-[11px] font-medium uppercase tracking-wider text-gray-400",children:v("chatSessionTypeLabel")}),d.jsx("div",{className:"mt-1 space-y-1",children:z.map(w=>d.jsxs("button",{type:"button",onClick:()=>{e.chatSessionListManager.createSession(w.value),r(!1)},className:"w-full rounded-xl px-3 py-2 text-left transition-colors hover:bg-gray-100",children:[d.jsxs("div",{className:"flex items-center justify-between gap-3",children:[d.jsx("div",{className:"text-[13px] font-medium text-gray-900",children:w.label}),d.jsx("span",{className:Ce("shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold",w.ready===!1?"bg-amber-100 text-amber-800":"bg-emerald-100 text-emerald-700"),children:w.ready===!1?v("statusSetup"):v("statusReady")})]}),d.jsx("div",{className:"mt-0.5 text-[11px] text-gray-500",children:sx(w)})]},w.value))})]})]}):null]})}),d.jsx("div",{className:"px-4 pb-3",children:d.jsxs("div",{className:"relative",children:[d.jsx(Un,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),d.jsx(Vn,{value:c.query,onChange:w=>e.chatSessionListManager.setQuery(w.target.value),placeholder:v("chatSidebarSearchPlaceholder"),className:"pl-8 h-9 rounded-lg text-xs"})]})}),d.jsx("div",{className:"px-3 pb-2",children:d.jsx("ul",{className:"space-y-0.5",children:ax.map(w=>d.jsx("li",{children:d.jsx(gr,{to:w.target,label:w.label(),icon:w.icon,density:"compact"})},w.target))})}),d.jsx("div",{className:"mx-4 border-t border-gray-200/60"}),d.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2",children:c.isLoading?d.jsx("div",{className:"text-xs text-gray-500 p-3",children:v("sessionsLoading")}):O.length===0?d.jsxs("div",{className:"p-4 text-center",children:[d.jsx(pl,{className:"h-6 w-6 mx-auto mb-2 text-gray-300"}),d.jsx("div",{className:"text-xs text-gray-500",children:v("sessionsEmpty")})]}):d.jsx("div",{className:"space-y-3",children:O.map(w=>d.jsxs("div",{children:[d.jsx("div",{className:"px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider",children:w.label}),d.jsx("div",{className:"space-y-0.5",children:w.sessions.map(j=>{const $=c.selectedSessionKey===j.key,ee=p.sessionRunStatusByKey.get(j.key),pe=ix(j.sessionType,h.sessionTypeOptions),x=i===j.key,le=o===j.key;return d.jsx(Zo,{session:j,active:$,runStatus:ee,sessionTypeLabel:pe,title:rx(j),isEditing:x,draftLabel:a,isSaving:le,onSelect:()=>e.chatSessionListManager.selectSession(j.key),onStartEditing:()=>k(j),onDraftLabelChange:l,onSave:()=>E(j),onCancel:L},j.key)})})]},w.label))})}),d.jsxs("div",{className:"px-3 py-3 border-t border-gray-200/60 space-y-0.5",children:[d.jsx(gr,{to:"/settings",label:v("settings"),icon:ml,density:"compact"}),d.jsx(Al,{onClick:()=>t.open(void 0,{kind:"docs",newTab:!0,title:"Docs"}),icon:gl,label:v("docBrowserHelp"),density:"compact"}),d.jsx(xr,{value:S,onValueChange:w=>g(w),icon:xl,label:v("theme"),valueLabel:M,density:"compact",children:pr.map(w=>d.jsx(dt,{value:w.value,className:"text-xs",children:v(w.labelKey)},w.value))}),d.jsx(xr,{value:m,onValueChange:w=>_(w),icon:yl,label:v("language"),valueLabel:D,density:"compact",children:mr.map(w=>d.jsx(dt,{value:w.value,className:"text-xs",children:w.label},w.value))})]})]})}function ox(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 ux(e){const t=new FormData;for(const i of e)t.append("files",i);const n=await fetch(`${qi}/api/ncp/assets`,{method:"POST",body:t,credentials:"include"}),r=await n.json();if(!n.ok||!r.ok)throw new Error(ox(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 Rt(e){return(e??"").trim().toLowerCase()}function Li(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 cx(e,t){const n=Rt(t);if(!n)return Me.fallback;const r=Rt(e.key),i=Rt(e.label||e.key),s=Rt(`${e.descriptionZh??""} ${e.description??""}`),a=i.split(/[\s/_-]+/).filter(Boolean);return r===n?Me.exactSpec:i===n?Me.exactLabel:r.startsWith(n)?Me.prefixSpec:i.startsWith(n)?Me.prefixLabel:a.some(l=>l.startsWith(n))?Me.prefixToken:r.includes(n)?Me.containsSpec:i.includes(n)?Me.containsLabel:s.includes(n)?Me.containsDescription:Li(n,i)||Li(n,r)?Me.subsequence:0}function hx(e,t,n){const r=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0});return e.map((i,s)=>({record:i,order:s,score:cx(i,t)})).filter(i=>i.score>0).sort((i,s)=>{if(s.score!==i.score)return s.score-i.score;const a=(i.record.label||i.record.key).trim(),l=(s.record.label||s.record.key).trim(),o=r.compare(a,l);return o!==0?o:i.order-s.order}).map(({record:i})=>({key:`skill:${i.key}`,title:i.label||i.key,subtitle:n.slashSkillSubtitle,description:(i.descriptionZh??i.description??"").trim()||n.noSkillDescription,detailLines:[`${n.slashSkillSpecLabel}: ${i.key}`],value:i.key}))}function dx(e){return e.map(t=>({key:t.key,label:t.label,description:t.descriptionZh||t.description||"",badgeLabel:t.badgeLabel}))}function fx(e){return{title:e.texts.title,searchPlaceholder:e.texts.searchPlaceholder,emptyLabel:e.texts.emptyLabel,loadingLabel:e.texts.loadingLabel,isLoading:e.isLoading,manageLabel:e.texts.manageLabel,manageHref:"/marketplace/skills",options:dx(e.skillRecords),selectedKeys:e.selectedSkills,onSelectedKeysChange:e.onSelectedKeysChange}}function px(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 mx(e){const t=e.modelOptions.find(s=>s.value===e.selectedModel),n=e.modelOptions[0],r=t??n;return{key:"model",value:e.hasModelOptions?r==null?void 0:r.value:void 0,placeholder:e.texts.modelSelectPlaceholder,selectedLabel:r?`${r.providerLabel}/${r.modelLabel}`:void 0,icon:"sparkles",options:e.modelOptions.map(s=>({value:s.value,label:s.modelLabel,description:s.providerLabel})),disabled:!e.hasModelOptions,loading:e.isModelOptionsLoading,emptyLabel:e.texts.modelNoOptionsLabel,onValueChange:e.onValueChange}}function gx(e){const t=[];for(const n of["off",...e])t.includes(n)||t.push(n);return t}function xx(e){if(e.supportedLevels.length===0)return null;const t=gx(e.supportedLevels),n=t.includes("off")?"off":t[0],r=e.selectedThinkingLevel&&t.includes(e.selectedThinkingLevel)&&e.selectedThinkingLevel||e.defaultThinkingLevel&&t.includes(e.defaultThinkingLevel)&&e.defaultThinkingLevel||n;return{key:"thinking",value:r,placeholder:e.texts.thinkingLabels[r],selectedLabel:e.texts.thinkingLabels[r],icon:"brain",options:t.map(i=>({value:i,label:e.texts.thinkingLabels[i]})),onValueChange:i=>e.onValueChange(i)}}function yx(){return{off:v("chatThinkingLevelOff"),minimal:v("chatThinkingLevelMinimal"),low:v("chatThinkingLevelLow"),medium:v("chatThinkingLevelMedium"),high:v("chatThinkingLevelHigh"),adaptive:v("chatThinkingLevelAdaptive"),xhigh:v("chatThinkingLevelXhigh")}}function bx(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 Sx(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 kx(){var k;const e=qn(),{language:t}=$n(),n=Y(L=>L.snapshot),[r,i]=C.useState(null),s=C.useRef(null),a=C.useRef(null),l=C.useMemo(()=>v("chatSkillsPickerOfficial"),[t]),o=C.useMemo(()=>({slashSkillSubtitle:v("chatSlashTypeSkill"),slashSkillSpecLabel:v("chatSlashSkillSpec"),noSkillDescription:v("chatSkillsPickerNoDescription")}),[t]),u=C.useMemo(()=>bx(n.skillRecords,l),[n.skillRecords,l]),h=C.useMemo(()=>Sx(n.modelOptions),[n.modelOptions]),c=h.length>0,p=!n.isProviderStateResolved&&!c,f=n.isProviderStateResolved&&!c,m=(p||f)&&!n.isSending||n.sessionTypeUnavailable,y=typeof e.chatInputManager.addAttachments=="function",S=p?"":c?v("chatInputPlaceholder"):v("chatModelNoOptions"),g=C.useMemo(()=>hx(u,r??"",o),[r,u,o]),I=h.find(L=>L.value===n.selectedModel),M=I==null?void 0:I.thinkingCapability,D=(M==null?void 0:M.supported)??[],O=n.stopDisabledReason==="__preparing__"?v("chatStopPreparing"):((k=n.stopDisabledReason)==null?void 0:k.trim())||v("chatStopUnavailable"),T=C.useCallback(L=>{if(L==="unsupported-type"){ht.error(v("chatInputAttachmentUnsupported"));return}if(L==="too-large"){ht.error(v("chatInputAttachmentTooLarge").replace("{maxMb}",String(es/(1024*1024))));return}ht.error(v("chatInputAttachmentReadFailed"))},[]),z=C.useCallback(async L=>{var U,P,w;if(!y||L.length===0)return;const E=await Yo(L,{uploadBatch:ux});if(E.attachments.length>0){const j=((P=(U=e.chatInputManager).addAttachments)==null?void 0:P.call(U,E.attachments))??[];j.length>0&&((w=s.current)==null||w.insertFileTokens(j.map($=>({tokenKey:$.id,label:$.name}))))}E.rejected.length>0&&T(E.rejected[0].reason)},[y,e.chatInputManager,T]),_=[mx({modelOptions:h,selectedModel:n.selectedModel,isModelOptionsLoading:p,hasModelOptions:c,onValueChange:e.chatInputManager.selectModel,texts:{modelSelectPlaceholder:v("chatSelectModel"),modelNoOptionsLabel:v("chatModelNoOptions")}}),xx({supportedLevels:D,selectedThinkingLevel:n.selectedThinkingLevel,defaultThinkingLevel:(M==null?void 0:M.default)??null,onValueChange:L=>e.chatInputManager.selectThinkingLevel(L),texts:{thinkingLabels:yx()}})].filter(L=>L!==null),B=fx({skillRecords:u,selectedSkills:n.selectedSkills,isLoading:n.isSkillsLoading,onSelectedKeysChange:e.chatInputManager.selectSkills,texts:{title:v("chatSkillsPickerTitle"),searchPlaceholder:v("chatSkillsPickerSearchPlaceholder"),emptyLabel:v("chatSkillsPickerEmpty"),loadingLabel:v("sessionsLoading"),manageLabel:v("chatSkillsPickerManage")}});return d.jsxs(d.Fragment,{children:[d.jsx(ys,{ref:s,composer:{nodes:n.composerNodes,placeholder:S,disabled:m,onNodesChange:e.chatInputManager.setComposerNodes,...y?{onFilesAdd:z}:{},onSlashQueryChange:i},slashMenu:{isLoading:n.isSkillsLoading,items:g,texts:{slashLoadingLabel:v("chatSlashLoading"),slashSectionLabel:v("chatSlashSectionSkills"),slashEmptyLabel:v("chatSlashNoResult"),slashHintLabel:v("chatSlashHint"),slashSkillHintLabel:v("chatSlashSkillHint")}},hint:px({isModelOptionsLoading:p,isModelOptionsEmpty:f,onGoToProviders:e.chatInputManager.goToProviders,texts:{noModelOptionsLabel:v("chatModelNoOptions"),configureProviderLabel:v("chatGoConfigureProvider")}}),toolbar:{selects:_,accessories:[{key:"attach",label:v("chatInputAttach"),icon:"paperclip",iconOnly:!0,disabled:!y||m||n.isSending,...y?{onClick:()=>{var L;return(L=a.current)==null?void 0:L.click()}}:{tooltip:v("chatInputAttachComingSoon")}}],skillPicker:B,actions:{sendError:n.sendError,isSending:n.isSending,canStopGeneration:n.canStopGeneration,sendDisabled:n.draft.trim().length===0&&n.attachments.length===0||!c||n.sessionTypeUnavailable,stopDisabled:!n.canStopGeneration,stopHint:O,sendButtonLabel:v("chatSend"),stopButtonLabel:v("chatStop"),onSend:e.chatInputManager.send,onStop:e.chatInputManager.stop}}}),y?d.jsx("input",{ref:a,type:"file",multiple:!0,className:"hidden",onChange:async L=>{const E=Array.from(L.target.files??[]);L.currentTarget.value="",await z(E)}}):null]})}const wx=["cmd","command","query","q","path","url","to","channel","agentId","sessionKey"];function Ei(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Fn(e,t=2400){return e.length<=t?e:`${e.slice(0,t)}
37
- …`}function Ut(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(e==null)return"";try{return Fn(JSON.stringify(e,null,2))}catch{return String(e)}}function Cx(e){if(Ei(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 Ei(n)?n:null}catch{return null}}function vx(e){const t=Cx(e);if(!t){const r=Ut(e).trim();return r?Fn(r,120):void 0}const n=[];for(const r of wx){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(" · "):Fn(Ut(t),140)}const Tx=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function Ot(e){return typeof e=="object"&&e!==null}function Sn(e){if(typeof e!="string")return null;const t=e.trim();return t.length>0?t:null}function Ia(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 Ix(e,t){if(!Ot(e))return null;const n=Ot(e.asset)?e.asset:Array.isArray(e.assets)&&e.assets.length>0&&Ot(e.assets[0])?e.assets[0]:null;if(!n)return null;const r=Sn(n.url),i=Sn(n.mimeType)??"application/octet-stream",s=Ia(n.sizeBytes);return r?{type:"file",file:{label:Sn(n.name)??(i.startsWith("image/")?t.imageAttachmentLabel:t.fileAttachmentLabel),mimeType:i,dataUrl:r,...s!=null?{sizeBytes:s}:{},isImage:i.startsWith("image/")}}:null}function Mx(e){return e.type==="text"&&typeof e.text=="string"}function Nx(e){return e.type==="reasoning"&&typeof e.reasoning=="string"}function Lx(e){return e.type==="file"&&typeof e.mimeType=="string"&&typeof e.data=="string"}function Ex(e){return e.type!=="tool-invocation"||!Ot(e.toolInvocation)?!1:typeof e.toolInvocation.toolName=="string"}function Ax(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 Rx(e,t){return e==="user"?t.user:e==="assistant"?t.assistant:e==="tool"?t.tool:e==="system"?t.system:t.fallback}function jx(e){return e==="user"||e==="assistant"||e==="tool"||e==="system"?e:"message"}function Px(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,inputLabel:t.toolInputLabel,outputLabel:t.toolOutputLabel,emptyLabel:t.toolNoOutputLabel,callIdLabel:t.toolCallIdLabel,callId:e.callId}}function Dx(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 Ai(e){const t=e.trim();return t&&t.replace(Tx,"").trim()?t:null}function Ox(e){return e.uiMessages.map(t=>{var n;return{id:t.id,role:jx(t.role),roleLabel:Rx(t.role,e.texts.roleLabels),timestampLabel:e.formatTimestamp(Ax(t)),status:(n=t.meta)==null?void 0:n.status,parts:t.parts.map(r=>{if(Mx(r)){const i=Ai(r.text);return i?{type:"markdown",text:i}:null}if(Nx(r)){const i=Ai(r.reasoning);return i?{type:"reasoning",text:i,label:e.texts.reasoningLabel}:null}if(Lx(r)){const i=r.mimeType.startsWith("image/"),s=Ia(r.sizeBytes);return{type:"file",file:{label:typeof r.name=="string"&&r.name.trim()?r.name.trim():i?e.texts.imageAttachmentLabel:e.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(Ex(r)){const i=r.toolInvocation,s=Ix(i.result,e.texts);if(s)return s;const a=Dx({status:i.status,error:i.error,cancelled:i.cancelled,result:i.result,texts:e.texts}),l=vx(i.parsedArgs??i.args),o=typeof i.error=="string"&&i.error.trim()?i.error.trim():i.result!=null?Ut(i.result).trim():"",u={kind:a.kind,name:i.toolName,detail:l,text:o||void 0,callId:i.toolCallId||void 0,hasResult:a.hasResult,statusTone:a.statusTone,statusLabel:a.statusLabel};return{type:"tool-card",card:Px(u,e.texts)}}return{type:"unknown",label:e.texts.unknownPartLabel,rawType:typeof r.type=="string"?r.type:"unknown",text:Ut(r)}}).filter(r=>r!==null)}})}function Fx(e){const{language:t}=$n(),n=C.useMemo(()=>e.uiMessages.map(i=>{var s,a;return{id:i.id,role:i.role,meta:{timestamp:(s=i.meta)==null?void 0:s.timestamp,status:(a=i.meta)==null?void 0:a.status},parts:i.parts}}),[e.uiMessages]),r=C.useMemo(()=>Ox({uiMessages:n,formatTimestamp:i=>$t(i,t),texts:{roleLabels:{user:v("chatRoleUser"),assistant:v("chatRoleAssistant"),tool:v("chatRoleTool"),system:v("chatRoleSystem"),fallback:v("chatRoleMessage")},reasoningLabel:v("chatReasoning"),toolCallLabel:v("chatToolCall"),toolResultLabel:v("chatToolResult"),toolInputLabel:v("chatToolInput"),toolCallIdLabel:v("chatToolCallId"),toolNoOutputLabel:v("chatToolNoOutput"),toolOutputLabel:v("chatToolOutput"),toolStatusPreparingLabel:v("chatToolStatusPreparing"),toolStatusRunningLabel:v("chatToolStatusRunning"),toolStatusCompletedLabel:v("chatToolStatusCompleted"),toolStatusFailedLabel:v("chatToolStatusFailed"),toolStatusCancelledLabel:v("chatToolStatusCancelled"),imageAttachmentLabel:v("chatImageAttachment"),fileAttachmentLabel:v("chatFileAttachment"),unknownPartLabel:v("chatUnknownPart")}}),[t,n]);return d.jsx(Kg,{messages:r,isSending:e.isSending,hasAssistantDraft:e.uiMessages.some(i=>{var s,a;return i.role==="assistant"&&(((s=i.meta)==null?void 0:s.status)==="streaming"||((a=i.meta)==null?void 0:a.status)==="pending")}),className:e.className,texts:{copyCodeLabel:v("chatCodeCopy"),copiedCodeLabel:v("chatCodeCopied"),typingLabel:v("chatTyping")}})}const zx=[{icon:bl,titleKey:"chatWelcomeCapability1Title",descKey:"chatWelcomeCapability1Desc"},{icon:Bn,titleKey:"chatWelcomeCapability2Title",descKey:"chatWelcomeCapability2Desc"},{icon:Hn,titleKey:"chatWelcomeCapability3Title",descKey:"chatWelcomeCapability3Desc"}];function _x({onCreateSession:e}){return d.jsx("div",{className:"h-full flex items-center justify-center p-8",children:d.jsxs("div",{className:"max-w-lg w-full text-center",children:[d.jsx("div",{className:"mx-auto mb-6 h-16 w-16 rounded-2xl bg-primary/10 flex items-center justify-center",children:d.jsx(Hi,{className:"h-8 w-8 text-primary"})}),d.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-2",children:v("chatWelcomeTitle")}),d.jsx("p",{className:"text-sm text-gray-500 mb-8",children:v("chatWelcomeSubtitle")}),d.jsx("div",{className:"grid grid-cols-3 gap-3",children:zx.map(t=>{const n=t.icon;return d.jsxs("button",{onClick:e,className:"rounded-2xl border border-gray-200 bg-white p-4 text-left shadow-card hover:shadow-card-hover transition-shadow cursor-pointer",children:[d.jsx("div",{className:"h-9 w-9 rounded-xl bg-primary/8 flex items-center justify-center mb-3",children:d.jsx(n,{className:"h-4.5 w-4.5 text-primary"})}),d.jsx("div",{className:"text-sm font-semibold text-gray-900 mb-1",children:v(t.titleKey)}),d.jsx("div",{className:"text-[11px] text-gray-500 leading-relaxed",children:v(t.descKey)})]},t.titleKey)})})]})})}const Bx={isProviderStateResolved:!1,modelOptions:[],sessionTypeUnavailable:!1,sessionTypeUnavailableMessage:null,sessionTypeLabel:null,selectedSessionKey:null,sessionDisplayName:void 0,canDeleteSession:!1,isDeletePending:!1,threadRef:null,isHistoryLoading:!1,uiMessages:[],isSending:!1,isAwaitingAssistantOutput:!1},ct=Vt(e=>({snapshot:Bx,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))}));function Ux(){return d.jsxs("section",{className:"flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white",children:[d.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:d.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5",children:d.jsxs("div",{className:"space-y-4",children:[d.jsx("div",{className:"h-6 w-48 animate-pulse rounded bg-gray-200"}),d.jsx("div",{className:"h-24 w-[78%] animate-pulse rounded-2xl bg-gray-200/80"}),d.jsx("div",{className:"h-20 w-[62%] animate-pulse rounded-2xl bg-gray-200/80"}),d.jsx("div",{className:"h-28 w-[84%] animate-pulse rounded-2xl bg-gray-200/80"})]})})}),d.jsx("div",{className:"border-t border-gray-200/80 bg-white p-4",children:d.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)]",children:d.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white shadow-card p-4",children:[d.jsx("div",{className:"h-16 w-full animate-pulse rounded-xl bg-gray-200/80"}),d.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[d.jsx("div",{className:"h-8 w-36 animate-pulse rounded-lg bg-gray-200/80"}),d.jsx("div",{className:"h-8 w-20 animate-pulse rounded-lg bg-gray-200/80"})]})]})})})]})}function Hx(){var c;const e=qn(),t=ct(p=>p.snapshot),n=C.useRef(null),r=t.threadRef??n,i=!!(t.selectedSessionKey||t.sessionTypeLabel),s=t.sessionDisplayName||t.selectedSessionKey||v("chatSidebarNewTask"),a=!t.selectedSessionKey&&t.uiMessages.length===0&&!t.isSending,l=t.modelOptions.length>0,o=t.isProviderStateResolved&&!l,u=t.isHistoryLoading&&t.uiMessages.length===0&&!t.isSending&&!t.isAwaitingAssistantOutput,{onScroll:h}=Wg({scrollRef:r,resetKey:t.selectedSessionKey,isLoading:t.isHistoryLoading,hasContent:t.uiMessages.length>0,contentVersion:t.uiMessages});return t.isProviderStateResolved?d.jsxs("section",{className:"flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white",children:[d.jsxs("div",{className:Ce("px-5 border-b border-gray-200/60 bg-white/80 backdrop-blur-sm flex items-center justify-between shrink-0 overflow-hidden transition-all duration-200",i?"py-3 opacity-100":"h-0 py-0 opacity-0 border-b-0"),children:[d.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[d.jsx("span",{className:"text-sm font-medium text-gray-700 truncate",children:s}),t.sessionTypeLabel?d.jsx("span",{className:"shrink-0 rounded-full border border-gray-200 bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600",children:t.sessionTypeLabel}):null]}),t.selectedSessionKey?d.jsx(Oe,{variant:"ghost",size:"icon",className:"rounded-lg shrink-0 text-gray-400 hover:text-destructive",onClick:e.chatThreadManager.deleteSession,disabled:!t.canDeleteSession||t.isDeletePending,children:d.jsx($i,{className:"h-4 w-4"})}):null]}),o&&d.jsxs("div",{className:"px-5 py-2.5 border-b border-amber-200/70 bg-amber-50/70 flex items-center justify-between gap-3 shrink-0",children:[d.jsx("span",{className:"text-xs text-amber-800",children:v("chatModelNoOptions")}),d.jsx("button",{type:"button",onClick:e.chatThreadManager.goToProviders,className:"text-xs font-semibold text-amber-900 underline-offset-2 hover:underline",children:v("chatGoConfigureProvider")})]}),t.sessionTypeUnavailable&&((c=t.sessionTypeUnavailableMessage)==null?void 0:c.trim())&&d.jsx("div",{className:"px-5 py-2.5 border-b border-amber-200/70 bg-amber-50/70 shrink-0",children:d.jsx("span",{className:"text-xs text-amber-800",children:t.sessionTypeUnavailableMessage})}),d.jsx("div",{ref:r,onScroll:h,className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:a?d.jsx(_x,{onCreateSession:e.chatThreadManager.createSession}):u?d.jsx("div",{className:"h-full"}):t.uiMessages.length===0?d.jsx("div",{className:"px-5 py-5 text-sm text-gray-500",children:v("chatNoMessages")}):d.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5",children:d.jsx(Fx,{uiMessages:t.uiMessages,isSending:t.isSending&&t.isAwaitingAssistantOutput})})}),d.jsx(kx,{})]}):d.jsx(Ux,{})}function Ri(e){return $t(e??void 0)}function Vx(e){return typeof e!="number"||!Number.isFinite(e)?"-":$t(new Date(e))}function $x(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 Kx(e){const t=e.schedule;return t.kind==="cron"?t.expr?`cron ${t.expr}`:"cron":t.kind==="every"?`every ${$x(t.everyMs)}`:t.kind==="at"?`at ${Vx(t.atMs)}`:"-"}function qx(e){if(!e.payload.deliver)return"-";const t=e.payload.channel??"-",n=e.payload.to??"-";return`${t}:${n}`}function Wx(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 Qx(e,t){return t==="all"?!0:t==="enabled"?e.enabled:!e.enabled}function Gx(){var m;const[e,t]=C.useState(""),[n,r]=C.useState("all"),i=Rl({all:!0}),s=jl(),a=Pl(),l=Dl(),{confirm:o,ConfirmDialog:u}=Gi(),h=C.useMemo(()=>{var S;return(((S=i.data)==null?void 0:S.jobs)??[]).filter(g=>Wx(g,e)).filter(g=>Qx(g,n))},[i.data,e,n]),c=async y=>{await o({title:`${v("cronDeleteConfirm")}?`,description:y.name?`${y.name} (${y.id})`:y.id,variant:"destructive",confirmLabel:v("delete")})&&s.mutate({id:y.id})},p=async y=>{const S=!y.enabled;await o({title:S?`${v("cronEnableConfirm")}?`:`${v("cronDisableConfirm")}?`,description:y.name?`${y.name} (${y.id})`:y.id,variant:S?"default":"destructive",confirmLabel:S?v("cronEnable"):v("cronDisable")})&&a.mutate({id:y.id,enabled:S})},f=async y=>{const S=!y.enabled;await o({title:S?`${v("cronRunForceConfirm")}?`:`${v("cronRunConfirm")}?`,description:y.name?`${y.name} (${y.id})`:y.id,confirmLabel:v("cronRunNow")})&&l.mutate({id:y.id,force:S})};return d.jsxs(xo,{fullHeight:!0,children:[d.jsx(yo,{title:v("cronPageTitle"),description:v("cronPageDescription"),actions:d.jsx(Oe,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100",onClick:()=>i.refetch(),children:d.jsx(Sl,{className:Ce("h-4 w-4",i.isFetching&&"animate-spin")})})}),d.jsx("div",{className:"mb-6",children:d.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[d.jsxs("div",{className:"relative flex-1 min-w-[240px]",children:[d.jsx(Vn,{value:e,onChange:y=>t(y.target.value),placeholder:v("cronSearchPlaceholder"),className:"pl-9"}),d.jsx(Hn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"})]}),d.jsx("div",{className:"min-w-[180px]",children:d.jsxs(Ol,{value:n,onValueChange:y=>r(y),children:[d.jsx(Fl,{className:"w-full",children:d.jsx(zl,{placeholder:v("cronStatusLabel")})}),d.jsxs(_l,{children:[d.jsx(dt,{value:"all",children:v("cronStatusAll")}),d.jsx(dt,{value:"enabled",children:v("cronStatusEnabled")}),d.jsx(dt,{value:"disabled",children:v("cronStatusDisabled")})]})]})}),d.jsxs("div",{className:"text-xs text-gray-500 ml-auto",children:[v("cronTotalLabel"),": ",((m=i.data)==null?void 0:m.total)??0," / ",h.length]})]})}),d.jsx("div",{className:"flex-1 overflow-auto custom-scrollbar",children:i.isLoading?d.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:v("cronLoading")}):h.length===0?d.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:v("cronEmpty")}):d.jsx("div",{className:"space-y-4",children:h.map(y=>d.jsx(Bl,{className:"border border-gray-200",children:d.jsx(Ul,{className:"pt-5 pb-5",children:d.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[d.jsxs("div",{className:"min-w-[220px] flex-1",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx("span",{className:"text-sm font-semibold text-gray-900",children:y.name||y.id}),d.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500",children:y.id}),d.jsx("span",{className:Ce("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?v("enabled"):v("disabled")}),y.deleteAfterRun&&d.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-amber-50 text-amber-700",children:v("cronOneShot")})]}),d.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[v("cronScheduleLabel"),": ",Kx(y)]}),d.jsx("div",{className:"mt-2 text-sm text-gray-700 whitespace-pre-wrap break-words",children:y.payload.message}),d.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[v("cronDeliverTo"),": ",qx(y)]})]}),d.jsxs("div",{className:"min-w-[220px] text-xs text-gray-500 space-y-2",children:[d.jsxs("div",{children:[d.jsxs("span",{className:"font-medium text-gray-700",children:[v("cronNextRun"),":"]})," ",Ri(y.state.nextRunAt)]}),d.jsxs("div",{children:[d.jsxs("span",{className:"font-medium text-gray-700",children:[v("cronLastRun"),":"]})," ",Ri(y.state.lastRunAt)]}),d.jsxs("div",{children:[d.jsxs("span",{className:"font-medium text-gray-700",children:[v("cronLastStatus"),":"]})," ",y.state.lastStatus??"-"]}),y.state.lastError&&d.jsx("div",{className:"text-[11px] text-red-500 break-words",children:y.state.lastError})]}),d.jsxs("div",{className:"flex items-start gap-2 flex-wrap justify-end",children:[d.jsxs(Oe,{variant:"subtle",size:"sm",onClick:()=>f(y),className:"gap-1",children:[d.jsx(kl,{className:"h-3.5 w-3.5"}),v("cronRunNow")]}),d.jsxs(Oe,{variant:y.enabled?"outline":"primary",size:"sm",onClick:()=>p(y),className:"gap-1",children:[d.jsx(wl,{className:"h-3.5 w-3.5"}),y.enabled?v("cronDisable"):v("cronEnable")]}),d.jsxs(Oe,{variant:"destructive",size:"sm",onClick:()=>c(y),className:"gap-1",children:[d.jsx($i,{className:"h-3.5 w-3.5"}),v("delete")]})]})]})})},y.id))})}),d.jsx(u,{})]})}function Yx(e){const{view:t,routeSessionKey:n,selectedSessionKey:r,selectedAgentId:i,setSelectedSessionKey:s,setSelectedAgentId:a,selectedSessionKeyRef:l,resetStreamState:o,resolveAgentIdFromSessionKey:u}=e;C.useEffect(()=>{if(t==="chat"){if(n){r!==n&&s(n);return}r!==null&&(s(null),o())}},[o,n,r,s,t]),C.useEffect(()=>{const h=r?u(r):null;h&&i!==h&&a(h)},[u,i,r,a]),C.useEffect(()=>{l.current=r},[r,l])}function Xx({view:e,confirmDialog:t}){return d.jsxs("div",{className:"h-full flex",children:[d.jsx(lx,{}),e==="chat"?d.jsx(Hx,{}):d.jsx("section",{className:"flex-1 min-h-0 overflow-hidden bg-gradient-to-b from-gray-50/60 to-white",children:e==="cron"?d.jsx("div",{className:"h-full overflow-auto custom-scrollbar",children:d.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5",children:d.jsx(Gx,{})})}):d.jsx("div",{className:"h-full overflow-hidden",children:d.jsx("div",{className:"mx-auto flex h-full min-h-0 w-full max-w-[min(1120px,100%)] flex-col px-6 py-5",children:d.jsx(no,{forcedType:"skills"})})})}),t]})}function Jx(){return(e,t)=>fetch(e,{credentials:"include",...t})}const zn="sid_";function Zx(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 ey(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`${zn}${r}`}function ty(e){if(!e.startsWith(zn))return null;const t=e.slice(zn.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 ny(e){if(!e)return null;const t=ty(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function ry(e){return`/chat/${ey(e)}`}const Se="native";function _e(e){return typeof e!="string"?Se:e.trim().toLowerCase()||Se}function bt(e,t){return e==="native"?v("chatSessionTypeNative"):e.trim().split(/[-_]+/g).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")||e}function iy(e){var n;const t=new Map;for(const r of e){const i=_e(r.value);t.set(i,{value:i,label:((n=r.label)==null?void 0:n.trim())||bt(i),ready:r.ready??!0,reason:r.reason??null,reasonMessage:r.reasonMessage??null,supportedModels:r.supportedModels,recommendedModel:r.recommendedModel??null,cta:r.cta??null})}return t.has(Se)||t.set(Se,{value:Se,label:bt(Se),ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),Array.from(t.values()).sort((r,i)=>r.value===Se?-1:i.value===Se?1:r.value.localeCompare(i.value))}function sy(e){const{selectedSession:t,selectedSessionKey:n,pendingSessionType:r,setPendingSessionType:i,sessionTypesData:s}=e,a=C.useMemo(()=>iy((s==null?void 0:s.options)??[]),[s==null?void 0:s.options]),l=C.useMemo(()=>{const S=[...a],g=_e(t==null?void 0:t.sessionType);return S.some(I=>I.value===g)||S.push({value:g,label:bt(g),ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),S.sort((I,M)=>I.value===Se?-1:M.value===Se?1:I.value.localeCompare(M.value))},[a,t==null?void 0:t.sessionType]),o=C.useMemo(()=>_e((s==null?void 0:s.defaultType)??Se),[s==null?void 0:s.defaultType]),u=C.useRef(null),h=C.useMemo(()=>_e((t==null?void 0:t.sessionType)??r??o),[o,r,t==null?void 0:t.sessionType]),c=C.useMemo(()=>l.find(S=>S.value===h)??null,[h,l]);C.useEffect(()=>{if(n)return;const S=typeof r=="string"?r.trim():"",g=_e(r);(S.length===0||u.current===g||u.current===null&&g===Se)&&(u.current=o,g!==o&&i(o))},[o,r,n,i]);const p=!n||!!(t!=null&&t.sessionTypeMutable),f=C.useMemo(()=>new Set(a.map(S=>S.value)),[a]),m=C.useMemo(()=>t&&!f.has(_e(t.sessionType))?!0:(c==null?void 0:c.ready)===!1,[f,t,c==null?void 0:c.ready]),y=C.useMemo(()=>{var S;return t&&!f.has(_e(t.sessionType))?`${bt(h)} ${v("chatSessionTypeUnavailableSuffix")}`:(c==null?void 0:c.ready)===!1?((S=c.reasonMessage)==null?void 0:S.trim())||`${c.label} setup required`:null},[f,t,h,c]);return{sessionTypeOptions:l,selectedSessionTypeOption:c,defaultSessionType:o,selectedSessionType:h,canEditSessionType:p,sessionTypeUnavailable:m,sessionTypeUnavailableMessage:y}}function ji(e){return(e==null?void 0:e.trim().toLowerCase())||"native"}function ay(e,t){if(typeof t!="string")return!1;const n=t.trim();return n?e.some(r=>r.value===n):!1}function ly(e,t){return typeof t=="string"&&e.includes(t)}function oy(e){return e.length===0?null:e.includes("off")?"off":e[0]??null}function Ma(e){const{currentValue:t,selectedSessionPreferredValue:n,fallbackPreferredValue:r,defaultValue:i,isValueSupported:s,firstAvailableValue:a,preferSessionPreferredValue:l=!1,preserveCurrentValueOnSessionChange:o=!1}=e;return s(t)&&(!l||o)?t:s(n)?n:s(r)?r:s(i)?i:a}function uy(e){var n;const{modelOptions:t}=e;return t.length===0?"":Ma({currentValue:e.currentSelectedModel,selectedSessionPreferredValue:e.selectedSessionPreferredModel,fallbackPreferredValue:e.fallbackPreferredModel,defaultValue:e.defaultModel,isValueSupported:r=>ay(t,r),firstAvailableValue:((n=t[0])==null?void 0:n.value)??"",preferSessionPreferredValue:e.preferSessionPreferredModel,preserveCurrentValueOnSessionChange:e.preserveCurrentSelectedModelOnSessionChange})}function cy(e){const{supportedThinkingLevels:t}=e;return t.length===0?null:Ma({currentValue:e.currentSelectedThinkingLevel,selectedSessionPreferredValue:e.selectedSessionPreferredThinking,fallbackPreferredValue:e.fallbackPreferredThinking,defaultValue:e.defaultThinkingLevel,isValueSupported:n=>ly(t,n),firstAvailableValue:oy(t)??"off",preferSessionPreferredValue:e.preferSessionPreferredThinking,preserveCurrentValueOnSessionChange:e.preserveCurrentSelectedThinkingOnSessionChange})}function Na(e){const t=ji(e.sessionType);let n,r=Number.NEGATIVE_INFINITY;for(const i of e.sessions){if(i.key===e.selectedSessionKey||ji(i.sessionType)!==t)continue;const s=e.readPreference(i);if(s==null)continue;const a=Date.parse(i.updatedAt),l=Number.isFinite(a)?a:Number.NEGATIVE_INFINITY;(n===void 0||l>r)&&(n=s,r=l)}return n}function hy(e){return Na({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 dy(e){return Na({sessions:e.sessions,selectedSessionKey:e.selectedSessionKey,sessionType:e.sessionType,readPreference:t=>t.preferredThinking??void 0})}function La(e){const{isPreferenceAvailable:t,emptyValue:n,selectedSessionKey:r,selectedSessionExists:i=!1,setValue:s,resolveValue:a}=e,l=C.useRef(void 0),o=C.useRef(a);C.useEffect(()=>{o.current=a},[a]),C.useEffect(()=>{const u=l.current!==r;if(!t){s(n),l.current=r;return}s(h=>o.current({currentValue:h,sessionChanged:u,preserveCurrentValueOnSessionChange:u&&!!r&&!i})),l.current=r},[n,t,i,r,s])}function fy(e){const{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:s,defaultModel:a,setSelectedModel:l}=e;La({isPreferenceAvailable:t.length>0,emptyValue:"",selectedSessionKey:n,selectedSessionExists:r,setValue:l,resolveValue:({currentValue:o,sessionChanged:u,preserveCurrentValueOnSessionChange:h})=>uy({currentSelectedModel:o,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:s,defaultModel:a,preferSessionPreferredModel:u,preserveCurrentSelectedModelOnSessionChange:h})})}function py(e){const{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:s,defaultThinkingLevel:a,setSelectedThinkingLevel:l}=e;La({isPreferenceAvailable:t.length>0,emptyValue:null,selectedSessionKey:n,selectedSessionExists:r,setValue:l,resolveValue:({currentValue:o,sessionChanged:u,preserveCurrentValueOnSessionChange:h})=>cy({currentSelectedThinkingLevel:o,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:s,defaultThinkingLevel:a,preferSessionPreferredThinking:u,preserveCurrentSelectedThinkingOnSessionChange:h})})}function my(){return Cl({queryKey:["ncp-session-types"],queryFn:Hl,staleTime:1e4,retry:!1})}function gy(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.key.toLowerCase().includes(n)):e}function xy(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 yy(e){var D,O,T,z,_,B,k,L;const t=Vl(),n=$l(),r=Kl({limit:200}),i=my(),s=ro("skill"),a=(t.isFetched||t.isSuccess)&&(n.isFetched||n.isSuccess),l=C.useMemo(()=>{const E=bo({meta:n.data,config:t.data,onlyConfigured:!0}),U=new Set,P=[];for(const w of E)for(const j of w.models){const $=So(w.prefix,j);!$||U.has($)||(U.add($),P.push({value:$,modelLabel:j,providerLabel:w.displayName,thinkingCapability:ko(w.modelThinking,j,w.aliases)}))}return P.sort((w,j)=>{const $=w.providerLabel.localeCompare(j.providerLabel);return $!==0?$:w.modelLabel.localeCompare(j.modelLabel)})},[n.data,t.data]),o=C.useMemo(()=>{var E;return((E=r.data)==null?void 0:E.sessions)??[]},[(D=r.data)==null?void 0:D.sessions]),u=C.useMemo(()=>fo(o),[o]),h=C.useMemo(()=>gy(u,e.query),[u,e.query]),c=C.useMemo(()=>u.find(E=>E.key===e.selectedSessionKey)??null,[u,e.selectedSessionKey]),p=C.useMemo(()=>{var E;return((E=s.data)==null?void 0:E.records)??[]},[(O=s.data)==null?void 0:O.records]),f=sy({selectedSession:c,selectedSessionKey:e.selectedSessionKey,pendingSessionType:e.pendingSessionType,setPendingSessionType:e.setPendingSessionType,sessionTypesData:i.data}),m=C.useMemo(()=>{var E;return xy({modelOptions:l,supportedModels:(E=f.selectedSessionTypeOption)==null?void 0:E.supportedModels})},[l,(T=f.selectedSessionTypeOption)==null?void 0:T.supportedModels]),y=C.useMemo(()=>hy({sessions:u,selectedSessionKey:e.selectedSessionKey,sessionType:f.selectedSessionType}),[u,e.selectedSessionKey,f.selectedSessionType]),S=C.useMemo(()=>m.find(E=>E.value===e.currentSelectedModel),[m,e.currentSelectedModel]),g=C.useMemo(()=>{var E;return((E=S==null?void 0:S.thinkingCapability)==null?void 0:E.supported)??[]},[(z=S==null?void 0:S.thinkingCapability)==null?void 0:z.supported]),I=C.useMemo(()=>{var E;return((E=S==null?void 0:S.thinkingCapability)==null?void 0:E.default)??null},[(_=S==null?void 0:S.thinkingCapability)==null?void 0:_.default]),M=C.useMemo(()=>dy({sessions:u,selectedSessionKey:e.selectedSessionKey,sessionType:f.selectedSessionType}),[u,e.selectedSessionKey,f.selectedSessionType]);return fy({modelOptions:m,selectedSessionKey:e.selectedSessionKey,selectedSessionExists:!!c,selectedSessionPreferredModel:c==null?void 0:c.preferredModel,fallbackPreferredModel:((B=f.selectedSessionTypeOption)==null?void 0:B.recommendedModel)??y,defaultModel:((k=f.selectedSessionTypeOption)==null?void 0:k.recommendedModel)??((L=t.data)==null?void 0:L.agents.defaults.model),setSelectedModel:e.setSelectedModel}),py({supportedThinkingLevels:g,selectedSessionKey:e.selectedSessionKey,selectedSessionExists:!!c,selectedSessionPreferredThinking:(c==null?void 0:c.preferredThinking)??null,fallbackPreferredThinking:M??null,defaultThinkingLevel:I,setSelectedThinkingLevel:e.setSelectedThinkingLevel}),{configQuery:t,configMetaQuery:n,sessionsQuery:r,sessionTypesQuery:i,installedSkillsQuery:s,isProviderStateResolved:a,modelOptions:m,sessionSummaries:o,sessions:h,skillRecords:p,selectedSession:c,...f}}function by(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const[n,r]of e.entries())if(!Object.is(r,t.get(n)))return!1;return!0}class Sy{constructor(){this.syncSnapshot=t=>{const n=On.getState().snapshot,r=t.sessionRunStatusByKey;(!r||by(n.sessionRunStatusByKey,r))&&(t.isLocallyRunning===void 0||Object.is(n.isLocallyRunning,t.isLocallyRunning))&&(t.activeBackendRunId===void 0||Object.is(n.activeBackendRunId,t.activeBackendRunId))||On.getState().setSnapshot(t)}}}class ky{constructor(t,n){this.uiManager=t,this.streamActionsManager=n,this.hasSnapshotChanges=r=>{const i=ae.getState().snapshot;for(const[s,a]of Object.entries(r))if(!Object.is(i[s],a))return!0;return!1},this.resolveUpdateValue=(r,i)=>typeof i=="function"?i(r):i,this.syncSnapshot=r=>{this.hasSnapshotChanges(r)&&ae.getState().setSnapshot(r)},this.setSelectedAgentId=r=>{const i=ae.getState().snapshot.selectedAgentId,s=this.resolveUpdateValue(i,r);s!==i&&ae.getState().setSnapshot({selectedAgentId:s})},this.setSelectedSessionKey=r=>{const i=ae.getState().snapshot.selectedSessionKey,s=this.resolveUpdateValue(i,r);s!==i&&ae.getState().setSnapshot({selectedSessionKey:s})},this.createSession=r=>{const{snapshot:i}=Y.getState(),{defaultSessionType:s}=i,a=s||"native",l=typeof r=="string"&&r.trim().length>0?r.trim():a;this.streamActionsManager.resetStreamState(),Y.getState().setSnapshot({pendingSessionType:l}),this.uiManager.goToChatRoot()},this.selectSession=r=>{this.uiManager.goToSession(r)},this.setQuery=r=>{const i=ae.getState().snapshot.query,s=this.resolveUpdateValue(i,r);s!==i&&ae.getState().setSnapshot({query:s})}}}const kn=async()=>{},Pi=()=>{};class wy{constructor(){this.actions={sendMessage:kn,stopCurrentRun:kn,resumeRun:kn,resetStreamState:Pi,applyHistoryMessages:Pi},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 Cy=async e=>!1;class vy{constructor(){this.state={pathname:""},this.actions={navigate:null,confirm:Cy},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(ry(t),n)}}}function Ty(e){const t=e.trim();return t.length>0?t:null}function Iy(e){return e??null}class My{constructor(t){this.updateSession=t,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{const n=Y.getState().snapshot,i=ae.getState().snapshot.selectedSessionKey;i&&this.enqueue({sessionKey:i,patch:{preferredModel:Ty(n.selectedModel),preferredThinking:Iy(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 Ny{constructor(t,n,r){this.uiManager=t,this.streamActionsManager=n,this.getDraftSessionId=r,this.sessionPreferenceSync=new My(Ki),this.buildAttachmentSignature=i=>[i.assetUri??"",i.url??"",i.name,i.mimeType,String(i.sizeBytes),i.contentBase64??""].join(":"),this.hasSnapshotChanges=i=>{const s=Y.getState().snapshot;for(const[a,l]of Object.entries(i))if(!Object.is(s[a],l))return!0;return!1},this.resolveUpdateValue=(i,s)=>typeof s=="function"?s(i):s,this.isSameStringArray=(i,s)=>i.length===s.length&&i.every((a,l)=>a===s[l]),this.syncComposerSnapshot=i=>{const s=Y.getState().snapshot.attachments,a=Xg(i,s);Y.getState().setSnapshot({composerNodes:i,attachments:a,draft:Ii(i),selectedSkills:Mi(i)})},this.syncComposerSnapshotWithAttachments=(i,s)=>{Y.getState().setSnapshot({composerNodes:i,attachments:s,draft:Ii(i),selectedSkills:Mi(i)})},this.dedupeAttachments=i=>{const s=new Set,a=[];for(const l of i){const o=this.buildAttachmentSignature(l);s.has(o)||(s.add(o),a.push(l))}return a},this.syncSnapshot=i=>{if(this.hasSnapshotChanges(i)&&(Y.getState().setSnapshot(i),Object.prototype.hasOwnProperty.call(i,"modelOptions")||Object.prototype.hasOwnProperty.call(i,"selectedModel")||Object.prototype.hasOwnProperty.call(i,"selectedThinkingLevel"))){const{selectedModel:s}=Y.getState().snapshot;this.reconcileThinkingForModel(s)}},this.setDraft=i=>{const s=Y.getState().snapshot.draft,a=this.resolveUpdateValue(s,i);a!==s&&this.syncComposerSnapshot(Qg(a))},this.setComposerNodes=i=>{const s=Y.getState().snapshot.composerNodes,a=this.resolveUpdateValue(s,i);Object.is(a,s)||this.syncComposerSnapshot(a)},this.addAttachments=i=>{if(i.length===0)return[];const s=Y.getState().snapshot,a=new Set(s.attachments.map(this.buildAttachmentSignature)),l=this.dedupeAttachments([...s.attachments,...i]),o=l.filter(h=>!a.has(this.buildAttachmentSignature(h)));if(o.length===0)return[];const u=Ni(s.composerNodes,l);return this.syncComposerSnapshotWithAttachments(u,l),o},this.restoreComposerState=(i,s)=>{const a=this.dedupeAttachments(s),l=Ni(i,a);this.syncComposerSnapshotWithAttachments(l,a)},this.setPendingSessionType=i=>{const s=Y.getState().snapshot.pendingSessionType,a=this.resolveUpdateValue(s,i);a!==s&&Y.getState().setSnapshot({pendingSessionType:a})},this.send=async()=>{const i=Y.getState().snapshot,s=ae.getState().snapshot,a=i.draft.trim(),l=i.attachments,o=Jg(i.composerNodes,l);if(!o.some(f=>f.type!=="text"||f.text.trim().length>0))return;const{selectedSkills:h,composerNodes:c}=i,p=s.selectedSessionKey??this.getDraftSessionId();s.selectedSessionKey||this.uiManager.goToSession(p,{replace:!0}),this.setComposerNodes(Ta()),await this.streamActionsManager.sendMessage({message:a,sessionKey:p,agentId:s.selectedAgentId,sessionType:i.selectedSessionType,model:i.selectedModel||void 0,thinkingLevel:i.selectedThinkingLevel??void 0,stopSupported:!0,requestedSkills:h,attachments:l,parts:o,restoreDraftOnError:!0,composerNodes:c})},this.stop=async()=>{await this.streamActionsManager.stopCurrentRun()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.setSelectedModel=i=>{const s=Y.getState().snapshot.selectedModel,a=this.resolveUpdateValue(s,i);a!==s&&(Y.getState().setSnapshot({selectedModel:a}),this.reconcileThinkingForModel(a))},this.setSelectedThinkingLevel=i=>{const s=Y.getState().snapshot.selectedThinkingLevel,a=this.resolveUpdateValue(s,i);a!==s&&Y.getState().setSnapshot({selectedThinkingLevel:a})},this.selectSessionType=i=>{const s=_e(i);Y.getState().setSnapshot({selectedSessionType:s,pendingSessionType:s})},this.setSelectedSkills=i=>{const s=Y.getState().snapshot,{selectedSkills:a}=s,l=this.resolveUpdateValue(a,i);this.isSameStringArray(l,a)||this.syncComposerSnapshot(Yg(s.composerNodes,l,s.skillRecords))},this.selectModel=i=>{this.setSelectedModel(i),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectThinkingLevel=i=>{this.setSelectedThinkingLevel(i),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectSkills=i=>{this.setSelectedSkills(i)}}resolveThinkingForModel(t,n){const r=t==null?void 0:t.thinkingCapability;return!r||r.supported.length===0?null:n==="off"?"off":n&&r.supported.includes(n)?n:r.default&&r.supported.includes(r.default)?r.default:"off"}reconcileThinkingForModel(t){const n=Y.getState().snapshot,r=n.modelOptions.find(a=>a.value===t),{selectedThinkingLevel:i}=n,s=this.resolveThinkingForModel(r,i);s!==i&&Y.getState().setSnapshot({selectedThinkingLevel:s})}}const Ly=async()=>{};class Ey{constructor(t,n,r){this.uiManager=t,this.sessionListManager=n,this.streamActionsManager=r,this.actions={refetchSessions:Ly},this.bindActions=i=>{this.actions={...this.actions,...i}},this.hasSnapshotChanges=i=>{const s=ct.getState().snapshot;for(const[a,l]of Object.entries(i))if(!Object.is(s[a],l))return!0;return!1},this.syncSnapshot=i=>{this.hasSnapshotChanges(i)&&ct.getState().setSnapshot(i)},this.deleteSession=()=>{this.deleteCurrentSession()},this.createSession=()=>{this.sessionListManager.createSession()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.deleteCurrentSession=async()=>{const{snapshot:{selectedSessionKey:i}}=ae.getState();if(!(!i||!await this.uiManager.confirm({title:v("chatDeleteSessionConfirm"),variant:"destructive",confirmLabel:v("delete")}))){ct.getState().setSnapshot({isDeletePending:!0});try{await ql(i),this.streamActionsManager.resetStreamState(),this.uiManager.goToChatRoot({replace:!0}),await this.actions.refetchSessions()}finally{ct.getState().setSnapshot({isDeletePending:!1})}}}}}class Ay{constructor(){this.chatUiManager=new vy,this.chatStreamActionsManager=new wy,this.chatSessionListManager=new ky(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new Ny(this.chatUiManager,this.chatStreamActionsManager,()=>this.getDraftSessionId()),this.chatRunStatusManager=new Sy,this.chatThreadManager=new Ey(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.draftSessionId="",this.setDraftSessionId=t=>{this.draftSessionId=t}}getDraftSessionId(){return this.draftSessionId}}function Ry(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 jy(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=Ry(e.requestedSkills);return n.length>0&&(t.requested_skills=n),t}function Py(e){return e instanceof Error?e.message.includes("ncp session not found:"):!1}function Dy({view:e}){var Ue,Tt,It;const[t]=C.useState(()=>new Ay),[n,r]=C.useState(()=>yr()),i=ae(K=>K.snapshot.query),s=ae(K=>K.snapshot.selectedSessionKey),a=ae(K=>K.snapshot.selectedAgentId),l=Y(K=>K.snapshot.pendingSessionType),o=Y(K=>K.snapshot.selectedModel),{confirm:u,ConfirmDialog:h}=Gi(),c=vl(),p=Tl(),{sessionId:f}=Il(),m=C.useRef(null),y=C.useRef(s),S=C.useMemo(()=>ny(f),[f]),{sessionsQuery:g,installedSkillsQuery:I,isProviderStateResolved:M,modelOptions:D,sessionSummaries:O,sessions:T,skillRecords:z,selectedSession:_,sessionTypeOptions:B,defaultSessionType:k,selectedSessionType:L,canEditSessionType:E,sessionTypeUnavailable:U,sessionTypeUnavailableMessage:P}=yy({query:i,selectedSessionKey:s,currentSelectedModel:o,pendingSessionType:l,setPendingSessionType:t.chatInputManager.setPendingSessionType,setSelectedModel:t.chatInputManager.setSelectedModel,setSelectedThinkingLevel:t.chatInputManager.setSelectedThinkingLevel}),w=g.refetch,j=s??n,$=C.useRef(O);C.useEffect(()=>{$.current=O},[O]);const[ee]=C.useState(()=>new Po({baseUrl:qi,basePath:"/api/ncp/agent",fetchImpl:Jx()})),pe=C.useCallback(async(K,He)=>{He.throwIfAborted();let Ie=null;try{Ie=await Wl(K,300)}catch(je){if(!Py(je))throw je}He.throwIfAborted();const Re=$.current.find(je=>je.sessionId===K)??null;return{messages:(Ie==null?void 0:Ie.messages)??[],status:(Re==null?void 0:Re.status)==="running"?"running":"idle"}},[]),x=qo({sessionId:j,client:ee,loadSeed:pe});C.useEffect(()=>{t.setDraftSessionId(n)},[n,t]),C.useEffect(()=>{if(s===null){const K=yr();r(K),t.setDraftSessionId(K)}},[t,s]);const le=C.useMemo(()=>po(x.visibleMessages),[x.visibleMessages]),se=x.isSending||x.isRunning,b=x.isRunning,he=x.isRunning,Te=x.isRunning?null:"__preparing__",re=((Ue=x.hydrateError)==null?void 0:Ue.message)??((Tt=x.snapshot.error)==null?void 0:Tt.message)??null,me=x.activeRunId,ke=C.useMemo(()=>mo({summaries:O,activeSessionId:j,isLocallyRunning:se||!!me}),[me,j,se,O]);C.useEffect(()=>{!se&&!me||w()},[me,se,w]),C.useEffect(()=>{t.chatStreamActionsManager.bind({sendMessage:async K=>{var Re,je;if(K.sessionKey!==j)return;const He=jy({model:K.model,thinkingLevel:K.thinkingLevel,sessionType:K.sessionType,requestedSkills:K.requestedSkills}),Ie=Go({sessionId:K.sessionKey,text:K.message,attachments:K.attachments,parts:K.parts,metadata:He});if(Ie)try{g.refetch(),await x.send(Ie),await g.refetch()}catch(Mt){throw K.restoreDraftOnError&&(K.composerNodes&&K.composerNodes.length>0?(je=(Re=t.chatInputManager).restoreComposerState)==null||je.call(Re,K.composerNodes,K.attachments??[]):t.chatInputManager.setDraft(nt=>nt.trim().length===0?K.message:nt)),Mt}},stopCurrentRun:async()=>{await x.abort(),await g.refetch()},resumeRun:async K=>{K.sessionKey===j&&await x.streamRun()},resetStreamState:()=>{y.current=null},applyHistoryMessages:()=>{}})},[j,x,t,g]),Yx({view:e,routeSessionKey:S,selectedSessionKey:s,selectedAgentId:a,setSelectedSessionKey:t.chatSessionListManager.setSelectedSessionKey,setSelectedAgentId:t.chatSessionListManager.setSelectedAgentId,selectedSessionKeyRef:y,resetStreamState:t.chatStreamActionsManager.resetStreamState,resolveAgentIdFromSessionKey:Zx}),C.useEffect(()=>{t.chatUiManager.syncState({pathname:c.pathname}),t.chatUiManager.bindActions({navigate:p,confirm:u})},[u,c.pathname,p,t]);const Ee=_?go(_):void 0,Ae=((It=B.find(K=>K.value===L))==null?void 0:It.label)??bt(L);return C.useEffect(()=>{t.chatThreadManager.bindActions({refetchSessions:g.refetch})},[t,g.refetch]),C.useEffect(()=>{t.chatInputManager.syncSnapshot({isProviderStateResolved:M,defaultSessionType:k,canStopGeneration:he,stopDisabledReason:Te,stopSupported:!0,stopReason:void 0,sendError:re,isSending:se,modelOptions:D,sessionTypeOptions:B,selectedSessionType:L,canEditSessionType:E,sessionTypeUnavailable:U,skillRecords:z,isSkillsLoading:I.isLoading}),t.chatSessionListManager.syncSnapshot({sessions:T,query:i,isLoading:g.isLoading}),t.chatRunStatusManager.syncSnapshot({sessionRunStatusByKey:ke,isLocallyRunning:se||!!me,activeBackendRunId:me}),t.chatThreadManager.syncSnapshot({isProviderStateResolved:M,modelOptions:D,sessionTypeUnavailable:U,sessionTypeUnavailableMessage:P,sessionTypeLabel:Ae,selectedSessionKey:s,sessionDisplayName:Ee,canDeleteSession:!!_,threadRef:m,isHistoryLoading:x.isHydrating,uiMessages:le,isSending:se,isAwaitingAssistantOutput:b})},[me,x.isHydrating,E,he,Ee,Ae,k,I.isLoading,b,M,se,re,D.length,D,t,i,_,s,L,ke,B,U,P,T,g.isLoading,z,Te,m,le]),d.jsx(tu,{presenter:t,children:d.jsx(Xx,{view:e,confirmDialog:d.jsx(h,{})})})}function Qy({view:e}){return d.jsx(Dy,{view:e})}export{Qy as ChatPage};