nextclaw 0.9.21 → 0.9.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +79 -10
- package/package.json +5 -5
- package/templates/USAGE.md +16 -5
- package/ui-dist/assets/ChannelsList-DBDjwf-X.js +1 -0
- package/ui-dist/assets/{ChatPage-DIx05c6s.js → ChatPage-C18sGGk1.js} +1 -1
- package/ui-dist/assets/DocBrowser-ZOplDEMS.js +1 -0
- package/ui-dist/assets/LogoBadge-2LMzEMwe.js +1 -0
- package/ui-dist/assets/{MarketplacePage-BOzko5s9.js → MarketplacePage-D4JHYcB5.js} +2 -2
- package/ui-dist/assets/ModelConfig-DZVvdLFq.js +1 -0
- package/ui-dist/assets/ProvidersList-Dum31480.js +1 -0
- package/ui-dist/assets/{RuntimeConfig-Dt9pLB9P.js → RuntimeConfig-4sb3mpkd.js} +1 -1
- package/ui-dist/assets/SearchConfig-B4u_MxRG.js +1 -0
- package/ui-dist/assets/{SecretsConfig-C1PU0Yy8.js → SecretsConfig-BQXblZvb.js} +2 -2
- package/ui-dist/assets/SessionsConfig-Jk29xjQU.js +2 -0
- package/ui-dist/assets/{card-C7Gtw2Vs.js → card-BekAnCgX.js} +1 -1
- package/ui-dist/assets/config-layout-BHnOoweL.js +1 -0
- package/ui-dist/assets/{index-nEYGCJTC.css → index-BXwjfCEO.css} +1 -1
- package/ui-dist/assets/index-Dl6t70wA.js +8 -0
- package/ui-dist/assets/{input-oBvxsnV9.js → input-MMn_Na9q.js} +1 -1
- package/ui-dist/assets/{label-C7F8lMpQ.js → label-Dg2ydpN0.js} +1 -1
- package/ui-dist/assets/{page-layout-DO8BlScF.js → page-layout-7K0rcz0I.js} +1 -1
- package/ui-dist/assets/{session-run-status-Kg0FwAPn.js → session-run-status-CAdjSqeb.js} +1 -1
- package/ui-dist/assets/{switch-C6a5GyZB.js → switch-DnDMlDVu.js} +1 -1
- package/ui-dist/assets/{tabs-custom-BatFap5k.js → tabs-custom-khLM8lWj.js} +1 -1
- package/ui-dist/assets/{useConfirmDialog-zJzVKMdu.js → useConfirmDialog-BYA1XnVU.js} +1 -1
- package/ui-dist/assets/{vendor-TlME1INH.js → vendor-d7E8OgNx.js} +1 -1
- package/ui-dist/index.html +3 -3
- package/ui-dist/assets/ChannelsList-C49JQ-Zt.js +0 -1
- package/ui-dist/assets/DocBrowser-CpOosDEI.js +0 -1
- package/ui-dist/assets/LogoBadge-CL_8ZPXU.js +0 -1
- package/ui-dist/assets/ModelConfig-BZ4ZfaQB.js +0 -1
- package/ui-dist/assets/ProvidersList-fPpJ5gl6.js +0 -1
- package/ui-dist/assets/SessionsConfig-EskBOofQ.js +0 -2
- package/ui-dist/assets/index-Cn6_2To7.js +0 -8
package/dist/cli/index.js
CHANGED
|
@@ -235,7 +235,8 @@ async function installMarketplaceSkill(options) {
|
|
|
235
235
|
throw new Error(`Invalid marketplace file path: ${file.path}`);
|
|
236
236
|
}
|
|
237
237
|
mkdirSync2(dirname(targetPath), { recursive: true });
|
|
238
|
-
|
|
238
|
+
const bytes = await fetchMarketplaceSkillFileBlob(apiBase, slug, file);
|
|
239
|
+
writeFileSync2(targetPath, bytes);
|
|
239
240
|
}
|
|
240
241
|
if (!existsSync2(join(destinationDir, "SKILL.md"))) {
|
|
241
242
|
throw new Error(`Marketplace skill ${slug} does not include SKILL.md`);
|
|
@@ -362,7 +363,59 @@ async function fetchMarketplaceSkillFiles(apiBase, slug) {
|
|
|
362
363
|
const message = payload.error?.message || `marketplace skill file fetch failed: ${response.status}`;
|
|
363
364
|
throw new Error(message);
|
|
364
365
|
}
|
|
365
|
-
|
|
366
|
+
if (!isRecord(payload.data) || !Array.isArray(payload.data.files)) {
|
|
367
|
+
throw new Error("Invalid marketplace skill file manifest response");
|
|
368
|
+
}
|
|
369
|
+
const files = payload.data.files.map((entry, index) => {
|
|
370
|
+
if (!isRecord(entry) || typeof entry.path !== "string" || entry.path.trim().length === 0) {
|
|
371
|
+
throw new Error(`Invalid marketplace skill file manifest at index ${index}`);
|
|
372
|
+
}
|
|
373
|
+
const normalized = {
|
|
374
|
+
path: entry.path.trim()
|
|
375
|
+
};
|
|
376
|
+
if (typeof entry.downloadPath === "string" && entry.downloadPath.trim().length > 0) {
|
|
377
|
+
normalized.downloadPath = entry.downloadPath.trim();
|
|
378
|
+
}
|
|
379
|
+
return normalized;
|
|
380
|
+
});
|
|
381
|
+
return { files };
|
|
382
|
+
}
|
|
383
|
+
async function fetchMarketplaceSkillFileBlob(apiBase, slug, file) {
|
|
384
|
+
const downloadUrl = resolveSkillFileDownloadUrl(apiBase, slug, file);
|
|
385
|
+
const response = await fetch(downloadUrl, {
|
|
386
|
+
headers: {
|
|
387
|
+
Accept: "application/octet-stream"
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
if (!response.ok) {
|
|
391
|
+
const message = await tryReadMarketplaceError(response);
|
|
392
|
+
throw new Error(message || `marketplace skill file download failed: ${response.status}`);
|
|
393
|
+
}
|
|
394
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
395
|
+
return Buffer.from(arrayBuffer);
|
|
396
|
+
}
|
|
397
|
+
function resolveSkillFileDownloadUrl(apiBase, slug, file) {
|
|
398
|
+
const fallback = `${apiBase}/api/v1/skills/items/${encodeURIComponent(slug)}/files/blob?path=${encodeURIComponent(file.path)}`;
|
|
399
|
+
if (!file.downloadPath) {
|
|
400
|
+
return fallback;
|
|
401
|
+
}
|
|
402
|
+
if (file.downloadPath.startsWith("http://") || file.downloadPath.startsWith("https://")) {
|
|
403
|
+
return file.downloadPath;
|
|
404
|
+
}
|
|
405
|
+
const normalizedPath = file.downloadPath.startsWith("/") ? file.downloadPath : `/${file.downloadPath}`;
|
|
406
|
+
return `${apiBase}${normalizedPath}`;
|
|
407
|
+
}
|
|
408
|
+
async function tryReadMarketplaceError(response) {
|
|
409
|
+
const raw = await response.text();
|
|
410
|
+
if (!raw.trim()) {
|
|
411
|
+
return void 0;
|
|
412
|
+
}
|
|
413
|
+
try {
|
|
414
|
+
const payload = JSON.parse(raw);
|
|
415
|
+
return payload.error?.message;
|
|
416
|
+
} catch {
|
|
417
|
+
return void 0;
|
|
418
|
+
}
|
|
366
419
|
}
|
|
367
420
|
async function readMarketplaceEnvelope(response) {
|
|
368
421
|
const raw = await response.text();
|
|
@@ -2984,7 +3037,7 @@ var GatewayAgentRuntimePool = class {
|
|
|
2984
3037
|
this.options.contextConfig = config2.agents.context;
|
|
2985
3038
|
this.options.execConfig = config2.tools.exec;
|
|
2986
3039
|
this.options.restrictToWorkspace = config2.tools.restrictToWorkspace;
|
|
2987
|
-
this.options.
|
|
3040
|
+
this.options.searchConfig = config2.search;
|
|
2988
3041
|
this.routeResolver.updateConfig(config2);
|
|
2989
3042
|
this.rebuild(config2);
|
|
2990
3043
|
}
|
|
@@ -3149,7 +3202,7 @@ var GatewayAgentRuntimePool = class {
|
|
|
3149
3202
|
await this.options.bus.publishOutbound({
|
|
3150
3203
|
channel: message.channel,
|
|
3151
3204
|
chatId: message.chatId,
|
|
3152
|
-
content: `Sorry, I encountered an error: ${
|
|
3205
|
+
content: `Sorry, I encountered an error: ${formatUserFacingError(error)}`,
|
|
3153
3206
|
media: [],
|
|
3154
3207
|
metadata: {}
|
|
3155
3208
|
});
|
|
@@ -3262,7 +3315,7 @@ var GatewayAgentRuntimePool = class {
|
|
|
3262
3315
|
model: context.model,
|
|
3263
3316
|
maxIterations: context.maxIterations,
|
|
3264
3317
|
contextTokens: context.contextTokens,
|
|
3265
|
-
|
|
3318
|
+
searchConfig: context.searchConfig,
|
|
3266
3319
|
execConfig: context.execConfig,
|
|
3267
3320
|
cronService: context.cronService,
|
|
3268
3321
|
restrictToWorkspace: context.restrictToWorkspace,
|
|
@@ -3302,7 +3355,7 @@ var GatewayAgentRuntimePool = class {
|
|
|
3302
3355
|
sessionManager: this.options.sessionManager,
|
|
3303
3356
|
cronService: this.options.cronService,
|
|
3304
3357
|
restrictToWorkspace: this.options.restrictToWorkspace,
|
|
3305
|
-
|
|
3358
|
+
searchConfig: this.options.searchConfig,
|
|
3306
3359
|
execConfig: this.options.execConfig,
|
|
3307
3360
|
contextConfig: this.options.contextConfig,
|
|
3308
3361
|
gatewayController: this.options.gatewayController,
|
|
@@ -3385,6 +3438,17 @@ function parseCommandOptionValue(type, rawValue) {
|
|
|
3385
3438
|
}
|
|
3386
3439
|
return value;
|
|
3387
3440
|
}
|
|
3441
|
+
function formatUserFacingError(error, maxChars = 320) {
|
|
3442
|
+
const raw = error instanceof Error ? error.message || error.name || "Unknown error" : String(error ?? "Unknown error");
|
|
3443
|
+
const normalized = raw.replace(/\s+/g, " ").trim();
|
|
3444
|
+
if (!normalized) {
|
|
3445
|
+
return "Unknown error";
|
|
3446
|
+
}
|
|
3447
|
+
if (normalized.length <= maxChars) {
|
|
3448
|
+
return normalized;
|
|
3449
|
+
}
|
|
3450
|
+
return `${normalized.slice(0, Math.max(0, maxChars - 3)).trimEnd()}...`;
|
|
3451
|
+
}
|
|
3388
3452
|
|
|
3389
3453
|
// src/cli/commands/ui-chat-run-coordinator.ts
|
|
3390
3454
|
import { existsSync as existsSync7, mkdirSync as mkdirSync4, readdirSync as readdirSync2, readFileSync as readFileSync7, writeFileSync as writeFileSync4 } from "fs";
|
|
@@ -4166,7 +4230,7 @@ var ServiceCommands = class {
|
|
|
4166
4230
|
config: config2,
|
|
4167
4231
|
cronService: cron2,
|
|
4168
4232
|
restrictToWorkspace: config2.tools.restrictToWorkspace,
|
|
4169
|
-
|
|
4233
|
+
searchConfig: config2.search,
|
|
4170
4234
|
execConfig: config2.tools.exec,
|
|
4171
4235
|
contextConfig: config2.agents.context,
|
|
4172
4236
|
gatewayController,
|
|
@@ -5206,8 +5270,13 @@ var WorkspaceManager = class {
|
|
|
5206
5270
|
if (!force && existsSync9(dest)) {
|
|
5207
5271
|
continue;
|
|
5208
5272
|
}
|
|
5209
|
-
|
|
5210
|
-
|
|
5273
|
+
try {
|
|
5274
|
+
cpSync3(src, dest, { recursive: true, force: true });
|
|
5275
|
+
seeded += 1;
|
|
5276
|
+
} catch (error) {
|
|
5277
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
5278
|
+
console.warn(`Warning: Failed to seed builtin skill '${entry.name}': ${message}`);
|
|
5279
|
+
}
|
|
5211
5280
|
}
|
|
5212
5281
|
return seeded;
|
|
5213
5282
|
}
|
|
@@ -5772,7 +5841,7 @@ ${this.logo} ${APP_NAME4} is ready! (${source})`);
|
|
|
5772
5841
|
model: config2.agents.defaults.model,
|
|
5773
5842
|
maxIterations: config2.agents.defaults.maxToolIterations,
|
|
5774
5843
|
contextTokens: config2.agents.defaults.contextTokens,
|
|
5775
|
-
|
|
5844
|
+
searchConfig: config2.search,
|
|
5776
5845
|
execConfig: config2.tools.exec,
|
|
5777
5846
|
restrictToWorkspace: config2.tools.restrictToWorkspace,
|
|
5778
5847
|
contextConfig: config2.agents.context,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextclaw",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.23",
|
|
4
4
|
"description": "Lightweight personal AI assistant with CLI, multi-provider routing, and channel integrations.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"chokidar": "^3.6.0",
|
|
40
40
|
"commander": "^12.1.0",
|
|
41
|
-
"@nextclaw/core": "0.7.
|
|
42
|
-
"@nextclaw/
|
|
43
|
-
"@nextclaw/
|
|
44
|
-
"@nextclaw/
|
|
41
|
+
"@nextclaw/core": "0.7.6",
|
|
42
|
+
"@nextclaw/runtime": "0.1.5",
|
|
43
|
+
"@nextclaw/openclaw-compat": "0.2.5",
|
|
44
|
+
"@nextclaw/server": "0.6.10"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^20.17.6",
|
package/templates/USAGE.md
CHANGED
|
@@ -791,15 +791,26 @@ After changing channel config, NextClaw hot-reloads channel runtime automaticall
|
|
|
791
791
|
|
|
792
792
|
## Tools
|
|
793
793
|
|
|
794
|
-
### Web search (Brave)
|
|
794
|
+
### Web search (Bocha default, Brave optional)
|
|
795
795
|
|
|
796
|
-
|
|
796
|
+
Configure the active search provider under `search`. Bocha is the default and is recommended for mainland China users:
|
|
797
797
|
|
|
798
798
|
```json
|
|
799
799
|
{
|
|
800
|
-
"
|
|
801
|
-
"
|
|
802
|
-
|
|
800
|
+
"search": {
|
|
801
|
+
"provider": "bocha",
|
|
802
|
+
"defaults": {
|
|
803
|
+
"maxResults": 10
|
|
804
|
+
},
|
|
805
|
+
"providers": {
|
|
806
|
+
"bocha": {
|
|
807
|
+
"apiKey": "YOUR_BOCHA_KEY",
|
|
808
|
+
"summary": true,
|
|
809
|
+
"freshness": "noLimit"
|
|
810
|
+
},
|
|
811
|
+
"brave": {
|
|
812
|
+
"apiKey": "YOUR_BRAVE_KEY"
|
|
813
|
+
}
|
|
803
814
|
}
|
|
804
815
|
}
|
|
805
816
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as v,j as a,aE as Z,D as ee,d as T,K as ae,ad as te,aP as se,aQ as ne,aR as le,x as re,q as oe,aA as ce,s as ie}from"./vendor-d7E8OgNx.js";import{t as e,c as I,M as me,u as q,a as $,b as H,O as pe,P as de,S as be,e as ue,f as xe,g as ye,h as ge}from"./index-Dl6t70wA.js";import{B as U,P as he,a as fe}from"./page-layout-7K0rcz0I.js";import{I as D}from"./input-MMn_Na9q.js";import{L as we}from"./label-Dg2ydpN0.js";import{S as ve}from"./switch-DnDMlDVu.js";import{L as K,S as J}from"./LogoBadge-2LMzEMwe.js";import{h as O}from"./config-hints-CApS3K_7.js";import{c as je,b as ke,a as Se,C as Ce}from"./config-layout-BHnOoweL.js";import{T as Ne}from"./tabs-custom-khLM8lWj.js";function Pe({value:t,onChange:m,className:i,placeholder:r=""}){const[o,u]=v.useState(""),d=x=>{x.key==="Enter"&&o.trim()?(x.preventDefault(),m([...t,o.trim()]),u("")):x.key==="Backspace"&&!o&&t.length>0&&m(t.slice(0,-1))},g=x=>{m(t.filter((j,h)=>h!==x))};return a.jsxs("div",{className:I("flex flex-wrap gap-2 p-2 border rounded-md min-h-[42px]",i),children:[t.map((x,j)=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-primary text-primary-foreground rounded text-sm",children:[x,a.jsx("button",{type:"button",onClick:()=>g(j),className:"hover:text-red-300 transition-colors",children:a.jsx(Z,{className:"h-3 w-3"})})]},j)),a.jsx("input",{type:"text",value:o,onChange:x=>u(x.target.value),onKeyDown:d,className:"flex-1 outline-none min-w-[100px] bg-transparent text-sm",placeholder:r||e("enterTag")})]})}function z(t){var r,o;const m=me();return((r=t.tutorialUrls)==null?void 0:r[m])||((o=t.tutorialUrls)==null?void 0:o.default)||t.tutorialUrl}const Ie={telegram:"telegram.svg",slack:"slack.svg",discord:"discord.svg",whatsapp:"whatsapp.svg",qq:"qq.svg",feishu:"feishu.svg",dingtalk:"dingtalk.svg",wecom:"wecom.svg",mochat:"mochat.svg",email:"email.svg"};function Fe(t,m){const i=m.toLowerCase(),r=t[i];return r?`/logos/${r}`:null}function Y(t){return Fe(Ie,t)}const R=[{value:"pairing",label:"pairing"},{value:"allowlist",label:"allowlist"},{value:"open",label:"open"},{value:"disabled",label:"disabled"}],B=[{value:"open",label:"open"},{value:"allowlist",label:"allowlist"},{value:"disabled",label:"disabled"}],Te=[{value:"off",label:"off"},{value:"partial",label:"partial"},{value:"block",label:"block"},{value:"progress",label:"progress"}],De=t=>t.includes("token")||t.includes("secret")||t.includes("password")?a.jsx(ae,{className:"h-3.5 w-3.5 text-gray-500"}):t.includes("url")||t.includes("host")?a.jsx(te,{className:"h-3.5 w-3.5 text-gray-500"}):t.includes("email")||t.includes("mail")?a.jsx(se,{className:"h-3.5 w-3.5 text-gray-500"}):t.includes("id")||t.includes("from")?a.jsx(ne,{className:"h-3.5 w-3.5 text-gray-500"}):t==="enabled"||t==="consentGranted"?a.jsx(le,{className:"h-3.5 w-3.5 text-gray-500"}):a.jsx(re,{className:"h-3.5 w-3.5 text-gray-500"});function G(){return{telegram:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"token",type:"password",label:e("botToken")},{name:"allowFrom",type:"tags",label:e("allowFrom")},{name:"proxy",type:"text",label:e("proxy")},{name:"accountId",type:"text",label:e("accountId")},{name:"dmPolicy",type:"select",label:e("dmPolicy"),options:R},{name:"groupPolicy",type:"select",label:e("groupPolicy"),options:B},{name:"groupAllowFrom",type:"tags",label:e("groupAllowFrom")},{name:"requireMention",type:"boolean",label:e("requireMention")},{name:"mentionPatterns",type:"tags",label:e("mentionPatterns")},{name:"groups",type:"json",label:e("groupRulesJson")}],discord:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"token",type:"password",label:e("botToken")},{name:"allowBots",type:"boolean",label:e("allowBotMessages")},{name:"allowFrom",type:"tags",label:e("allowFrom")},{name:"gatewayUrl",type:"text",label:e("gatewayUrl")},{name:"intents",type:"number",label:e("intents")},{name:"proxy",type:"text",label:e("proxy")},{name:"mediaMaxMb",type:"number",label:e("attachmentMaxSizeMb")},{name:"streaming",type:"select",label:e("streamingMode"),options:Te},{name:"draftChunk",type:"json",label:e("draftChunkingJson")},{name:"textChunkLimit",type:"number",label:e("textChunkLimit")},{name:"accountId",type:"text",label:e("accountId")},{name:"dmPolicy",type:"select",label:e("dmPolicy"),options:R},{name:"groupPolicy",type:"select",label:e("groupPolicy"),options:B},{name:"groupAllowFrom",type:"tags",label:e("groupAllowFrom")},{name:"requireMention",type:"boolean",label:e("requireMention")},{name:"mentionPatterns",type:"tags",label:e("mentionPatterns")},{name:"groups",type:"json",label:e("groupRulesJson")}],whatsapp:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"bridgeUrl",type:"text",label:e("bridgeUrl")},{name:"allowFrom",type:"tags",label:e("allowFrom")}],feishu:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"appId",type:"text",label:e("appId")},{name:"appSecret",type:"password",label:e("appSecret")},{name:"encryptKey",type:"password",label:e("encryptKey")},{name:"verificationToken",type:"password",label:e("verificationToken")},{name:"allowFrom",type:"tags",label:e("allowFrom")}],dingtalk:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"clientId",type:"text",label:e("clientId")},{name:"clientSecret",type:"password",label:e("clientSecret")},{name:"allowFrom",type:"tags",label:e("allowFrom")}],wecom:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"corpId",type:"text",label:e("corpId")},{name:"agentId",type:"text",label:e("agentId")},{name:"secret",type:"password",label:e("secret")},{name:"token",type:"password",label:e("token")},{name:"callbackPort",type:"number",label:e("callbackPort")},{name:"callbackPath",type:"text",label:e("callbackPath")},{name:"allowFrom",type:"tags",label:e("allowFrom")}],slack:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"mode",type:"text",label:e("mode")},{name:"webhookPath",type:"text",label:e("webhookPath")},{name:"allowBots",type:"boolean",label:e("allowBotMessages")},{name:"botToken",type:"password",label:e("botToken")},{name:"appToken",type:"password",label:e("appToken")}],email:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"consentGranted",type:"boolean",label:e("consentGranted")},{name:"imapHost",type:"text",label:e("imapHost")},{name:"imapPort",type:"number",label:e("imapPort")},{name:"imapUsername",type:"text",label:e("imapUsername")},{name:"imapPassword",type:"password",label:e("imapPassword")},{name:"fromAddress",type:"email",label:e("fromAddress")}],mochat:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"baseUrl",type:"text",label:e("baseUrl")},{name:"clawToken",type:"password",label:e("clawToken")},{name:"agentUserId",type:"text",label:e("agentUserId")},{name:"allowFrom",type:"tags",label:e("allowFrom")}],qq:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"appId",type:"text",label:e("appId")},{name:"secret",type:"password",label:e("appSecret")},{name:"markdownSupport",type:"boolean",label:e("markdownSupport")},{name:"allowFrom",type:"tags",label:e("allowFrom")}]}}function A(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Q(t,m){const i={...t};for(const[r,o]of Object.entries(m)){const u=i[r];if(A(u)&&A(o)){i[r]=Q(u,o);continue}i[r]=o}return i}function Ae(t,m){const i=t.split("."),r={};let o=r;for(let u=0;u<i.length-1;u+=1){const d=i[u];o[d]={},o=o[d]}return o[i[i.length-1]]=m,r}function Le({channelName:t}){var _,E;const{data:m}=q(),{data:i}=$(),{data:r}=H(),o=pe(),u=de(),[d,g]=v.useState({}),[x,j]=v.useState({}),[h,f]=v.useState(null),k=t?m==null?void 0:m.channels[t]:null,w=t?G()[t]??[]:[],c=r==null?void 0:r.uiHints,p=t?`channels.${t}`:null,S=((_=r==null?void 0:r.actions)==null?void 0:_.filter(s=>s.scope===p))??[],C=t&&(((E=O(`channels.${t}`,c))==null?void 0:E.label)??t),P=i==null?void 0:i.channels.find(s=>s.name===t),F=P?z(P):void 0;v.useEffect(()=>{if(k){g({...k});const s={};(t?G()[t]??[]:[]).filter(l=>l.type==="json").forEach(l=>{const y=k[l.name];s[l.name]=JSON.stringify(y??{},null,2)}),j(s)}else g({}),j({})},[k,t]);const N=(s,n)=>{g(l=>({...l,[s]:n}))},L=s=>{if(s.preventDefault(),!t)return;const n={...d};for(const l of w){if(l.type!=="password")continue;const y=n[l.name];(typeof y!="string"||y.length===0)&&delete n[l.name]}for(const l of w){if(l.type!=="json")continue;const y=x[l.name]??"";try{n[l.name]=y.trim()?JSON.parse(y):{}}catch{T.error(`${e("invalidJson")}: ${l.name}`);return}}o.mutate({channel:t,data:n})},V=s=>{if(!s||!t)return;const n=s.channels;if(!A(n))return;const l=n[t];A(l)&&g(y=>Q(y,l))},W=async s=>{if(!(!t||!p)){f(s.id);try{let n={...d};s.saveBeforeRun&&(n={...n,...s.savePatch??{}},g(n),await o.mutateAsync({channel:t,data:n}));const l=await u.mutateAsync({actionId:s.id,data:{scope:p,draftConfig:Ae(p,n)}});V(l.patch),l.ok?T.success(l.message||e("success")):T.error(l.message||e("error"))}catch(n){const l=n instanceof Error?n.message:String(n);T.error(`${e("error")}: ${l}`)}finally{f(null)}}};if(!t||!P||!k)return a.jsx("div",{className:je,children:a.jsxs("div",{children:[a.jsx("h3",{className:"text-base font-semibold text-gray-900",children:e("channelsSelectTitle")}),a.jsx("p",{className:"mt-2 text-sm text-gray-500",children:e("channelsSelectDescription")})]})});const M=!!k.enabled;return a.jsxs("div",{className:ke,children:[a.jsx("div",{className:"border-b border-gray-100 px-6 py-5",children:a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(K,{name:t,src:Y(t),className:I("h-9 w-9 rounded-lg border",M?"border-primary/30 bg-white":"border-gray-200/70 bg-white"),imgClassName:"h-5 w-5 object-contain",fallback:a.jsx("span",{className:"text-sm font-semibold uppercase text-gray-500",children:t[0]})}),a.jsx("h3",{className:"truncate text-lg font-semibold text-gray-900 capitalize",children:C})]}),a.jsx("p",{className:"mt-2 text-sm text-gray-500",children:e("channelsFormDescription")}),F&&a.jsxs("a",{href:F,className:"mt-2 inline-flex items-center gap-1.5 text-xs text-primary transition-colors hover:text-primary-hover",children:[a.jsx(ee,{className:"h-3.5 w-3.5"}),e("channelsGuideTitle")]})]}),a.jsx(J,{status:M?"active":"inactive",label:M?e("statusActive"):e("statusInactive")})]})}),a.jsxs("form",{onSubmit:L,className:"flex min-h-0 flex-1 flex-col",children:[a.jsx("div",{className:"min-h-0 flex-1 space-y-6 overflow-y-auto overscroll-contain px-6 py-5",children:w.map(s=>{const n=t?O(`channels.${t}.${s.name}`,c):void 0,l=(n==null?void 0:n.label)??s.label,y=n==null?void 0:n.placeholder;return a.jsxs("div",{className:"space-y-2.5",children:[a.jsxs(we,{htmlFor:s.name,className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[De(s.name),l]}),s.type==="boolean"&&a.jsxs("div",{className:"flex items-center justify-between rounded-xl bg-gray-50 p-3",children:[a.jsx("span",{className:"text-sm text-gray-500",children:d[s.name]?e("enabled"):e("disabled")}),a.jsx(ve,{id:s.name,checked:d[s.name]||!1,onCheckedChange:b=>N(s.name,b),className:"data-[state=checked]:bg-emerald-500"})]}),(s.type==="text"||s.type==="email")&&a.jsx(D,{id:s.name,type:s.type,value:d[s.name]||"",onChange:b=>N(s.name,b.target.value),placeholder:y,className:"rounded-xl"}),s.type==="password"&&a.jsx(D,{id:s.name,type:"password",value:d[s.name]||"",onChange:b=>N(s.name,b.target.value),placeholder:y??e("leaveBlankToKeepUnchanged"),className:"rounded-xl"}),s.type==="number"&&a.jsx(D,{id:s.name,type:"number",value:d[s.name]||0,onChange:b=>N(s.name,parseInt(b.target.value,10)||0),placeholder:y,className:"rounded-xl"}),s.type==="tags"&&a.jsx(Pe,{value:d[s.name]||[],onChange:b=>N(s.name,b)}),s.type==="select"&&a.jsxs(be,{value:d[s.name]||"",onValueChange:b=>N(s.name,b),children:[a.jsx(ue,{className:"rounded-xl",children:a.jsx(xe,{})}),a.jsx(ye,{children:(s.options??[]).map(b=>a.jsx(ge,{value:b.value,children:b.label},b.value))})]}),s.type==="json"&&a.jsx("textarea",{id:s.name,value:x[s.name]??"{}",onChange:b=>j(X=>({...X,[s.name]:b.target.value})),className:"min-h-[120px] w-full resize-none rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono"})]},s.name)})}),a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-gray-100 px-6 py-4",children:[a.jsx("div",{className:"flex flex-wrap items-center gap-2",children:S.filter(s=>s.trigger==="manual").map(s=>a.jsx(U,{type:"button",onClick:()=>W(s),disabled:o.isPending||!!h,variant:"secondary",children:h===s.id?e("connecting"):s.title},s.id))}),a.jsx(U,{type:"submit",disabled:o.isPending||!!h,children:o.isPending?e("saving"):e("save")})]})]})]})}const Me={telegram:"channelDescTelegram",slack:"channelDescSlack",email:"channelDescEmail",webhook:"channelDescWebhook",discord:"channelDescDiscord",feishu:"channelDescFeishu"};function Ke(){const{data:t}=q(),{data:m}=$(),{data:i}=H(),[r,o]=v.useState("enabled"),[u,d]=v.useState(),[g,x]=v.useState(""),j=i==null?void 0:i.uiHints,h=m==null?void 0:m.channels,f=t==null?void 0:t.channels,k=[{id:"enabled",label:e("channelsTabEnabled"),count:(h??[]).filter(c=>{var p;return(p=f==null?void 0:f[c.name])==null?void 0:p.enabled}).length},{id:"all",label:e("channelsTabAll"),count:(h??[]).length}],w=v.useMemo(()=>{const c=g.trim().toLowerCase();return(h??[]).filter(p=>{var C;const S=((C=f==null?void 0:f[p.name])==null?void 0:C.enabled)||!1;return r==="enabled"?S:!0}).filter(p=>c?(p.displayName||p.name).toLowerCase().includes(c)||p.name.toLowerCase().includes(c):!0)},[r,f,h,g]);return v.useEffect(()=>{if(w.length===0){d(void 0);return}w.some(p=>p.name===u)||d(w[0].name)},[w,u]),!t||!m?a.jsx("div",{className:"p-8 text-gray-400",children:e("channelsLoading")}):a.jsxs(he,{className:"xl:flex xl:h-full xl:min-h-0 xl:flex-col xl:pb-0",children:[a.jsx(fe,{title:e("channelsPageTitle"),description:e("channelsPageDescription")}),a.jsxs("div",{className:I(Ce,"xl:min-h-0 xl:flex-1"),children:[a.jsxs("section",{className:Se,children:[a.jsx("div",{className:"border-b border-gray-100 px-4 pt-4",children:a.jsx(Ne,{tabs:k,activeTab:r,onChange:o,className:"mb-0"})}),a.jsx("div",{className:"border-b border-gray-100 px-4 py-3",children:a.jsxs("div",{className:"relative",children:[a.jsx(oe,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),a.jsx(D,{value:g,onChange:c=>x(c.target.value),placeholder:e("channelsFilterPlaceholder"),className:"h-10 rounded-xl pl-9"})]})}),a.jsxs("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain p-3",children:[w.map(c=>{const p=t.channels[c.name],S=(p==null?void 0:p.enabled)||!1,C=O(`channels.${c.name}`,j),P=z(c),F=(C==null?void 0:C.help)||e(Me[c.name]||"channelDescriptionDefault"),N=u===c.name;return a.jsx("button",{type:"button",onClick:()=>d(c.name),className:I("w-full rounded-xl border p-2.5 text-left transition-all",N?"border-primary/30 bg-primary-50/40 shadow-sm":"border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70"),children:a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[a.jsx(K,{name:c.name,src:Y(c.name),className:I("h-10 w-10 rounded-lg border",S?"border-primary/30 bg-white":"border-gray-200/70 bg-white"),imgClassName:"h-5 w-5 object-contain",fallback:a.jsx("span",{className:"text-sm font-semibold uppercase text-gray-500",children:c.name[0]})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:c.displayName||c.name}),a.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:F})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[P&&a.jsx("a",{href:P,onClick:L=>L.stopPropagation(),className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-gray-300 transition-colors hover:bg-gray-100/70 hover:text-gray-500",title:e("channelsGuideTitle"),children:a.jsx(ce,{className:"h-3.5 w-3.5"})}),a.jsx(J,{status:S?"active":"inactive",label:S?e("statusActive"):e("statusInactive"),className:"min-w-[56px] justify-center"})]})]})},c.name)}),w.length===0&&a.jsxs("div",{className:"flex h-full min-h-[220px] flex-col items-center justify-center rounded-xl border border-dashed border-gray-200 bg-gray-50/70 py-10 text-center",children:[a.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white",children:a.jsx(ie,{className:"h-5 w-5 text-gray-300"})}),a.jsx("p",{className:"text-sm font-medium text-gray-700",children:e("channelsNoMatch")})]})]})]}),a.jsx(Le,{channelName:u})]})]})}export{Ke as ChannelsList};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var bo=Object.defineProperty;var So=(e,t,n)=>t in e?bo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var F=(e,t,n)=>So(e,typeof t!="symbol"?t+"":t,n);import{j as f,r as R,
|
|
1
|
+
var bo=Object.defineProperty;var So=(e,t,n)=>t in e?bo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var F=(e,t,n)=>So(e,typeof t!="symbol"?t+"":t,n);import{j as f,r as R,F as Ft,a1 as ko,q as Fn,A as zn,B as Bn,N as xn,a2 as wo,x as vo,y as Co,z as Io,a3 as yn,a4 as bn,a5 as Sn,a6 as yt,a7 as vi,a8 as Ro,a9 as Ci,aa as Ii,k as Ri,ab as To,ac as Ao,ad as Eo,ae as Mo,af as No,ag as Po,M as jo,ah as Lo,ai as _o,aj as Oo,ak as Ti,al as Ai,am as Do,an as Ei,ao as Mi,ap as ut,aq as Fo,ar as zo,as as Bo,at as $o,au as Uo,av as Ho,aw as Ko,ax as Vo,ay as qo,az as Wo,aA as Go,aB as Xo,p as Qo,aC as pr,aD as Yo,aE as Jo,aF as Ni,aG as Zo,aH as ea,aI as ta,E as na,aJ as ra,aK as ia}from"./vendor-d7E8OgNx.js";import{P as Pi,u as ji}from"./useConfirmDialog-BYA1XnVU.js";import{B as Pe,P as sa,a as oa}from"./page-layout-7K0rcz0I.js";import{i as Li,j as aa,t as A,T as mr,L as gr,B as la,c as te,k as zt,S as ft,e as pt,g as mt,h as He,f as $n,l as ua,m as ca,n as da,o as ha,p as fa,u as pa,a as ma,q as ga,r as xa,s as ya,v as ba,w as Sa,x as ka,y as wa,z as va,A as Ca,C as Ia}from"./index-Dl6t70wA.js";import{I as Un}from"./input-MMn_Na9q.js";import{S as Ra,s as Ta,a as Aa,b as Ea,c as Ma,e as xr}from"./session-run-status-CAdjSqeb.js";import{T as _i,a as Oi,b as Di,c as Fi,u as Na,M as Pa}from"./MarketplacePage-D4JHYcB5.js";import{C as ja,a as La}from"./card-BekAnCgX.js";import{b as _a,c as Oa}from"./provider-models-y4mUDcGF.js";import"./tabs-custom-khLM8lWj.js";const zi=R.createContext(null);function Da({presenter:e,children:t}){return f.jsx(zi.Provider,{value:e,children:t})}function Bt(){const e=R.useContext(zi);if(!e)throw new Error("usePresenter must be used inside ChatPresenterProvider");return e}const Fa={sessionRunStatusByKey:new Map,isLocallyRunning:!1,activeBackendRunId:null},kn=Ft(e=>({snapshot:Fa,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))})),za={sessions:[],selectedSessionKey:null,selectedAgentId:"main",query:"",isLoading:!1},oe=Ft(e=>({snapshot:za,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))}));function Ba(e){const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,s=[],o=[],a=[],l=[];for(const d of e){const c=new Date(d.updatedAt).getTime();c>=n?s.push(d):c>=r?o.push(d):c>=i?a.push(d):l.push(d)}const u=[];return s.length>0&&u.push({label:A("chatSidebarToday"),sessions:s}),o.length>0&&u.push({label:A("chatSidebarYesterday"),sessions:o}),a.length>0&&u.push({label:A("chatSidebarPrevious7Days"),sessions:a}),l.length>0&&u.push({label:A("chatSidebarOlder"),sessions:l}),u}function $a(e){if(e.label&&e.label.trim())return e.label.trim();const t=e.key.split(":");return t[t.length-1]||e.key}const Ua=[{target:"/cron",label:()=>A("chatSidebarScheduledTasks"),icon:zn},{target:"/skills",label:()=>A("chatSidebarSkills"),icon:Bn}];function Ha(){var c,p;const e=Bt(),t=oe(h=>h.snapshot),n=kn(h=>h.snapshot),{language:r,setLanguage:i}=Li(),{theme:s,setTheme:o}=aa(),a=A(((c=mr.find(h=>h.value===s))==null?void 0:c.labelKey)??"themeWarm"),l=((p=gr.find(h=>h.value===r))==null?void 0:p.label)??r,u=R.useMemo(()=>Ba(t.sessions),[t.sessions]),d=h=>{r!==h&&(i(h),window.location.reload())};return f.jsxs("aside",{className:"w-[280px] shrink-0 flex flex-col h-full bg-secondary border-r border-gray-200/60",children:[f.jsx("div",{className:"px-5 pt-5 pb-3",children:f.jsx(la,{})}),f.jsx("div",{className:"px-4 pb-3",children:f.jsxs(Pe,{variant:"primary",className:"w-full rounded-xl",onClick:e.chatSessionListManager.createSession,children:[f.jsx(ko,{className:"h-4 w-4 mr-2"}),A("chatSidebarNewTask")]})}),f.jsx("div",{className:"px-4 pb-3",children:f.jsxs("div",{className:"relative",children:[f.jsx(Fn,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),f.jsx(Un,{value:t.query,onChange:h=>e.chatSessionListManager.setQuery(h.target.value),placeholder:A("chatSidebarSearchPlaceholder"),className:"pl-8 h-9 rounded-lg text-xs"})]})}),f.jsx("div",{className:"px-3 pb-2",children:f.jsx("ul",{className:"space-y-0.5",children:Ua.map(h=>{const m=h.icon;return f.jsx("li",{children:f.jsx(xn,{to:h.target,className:({isActive:x})=>te("group w-full flex items-center gap-3 px-3 py-2 rounded-xl text-[13px] font-medium transition-all duration-150",x?"bg-gray-200 text-gray-900 font-semibold shadow-sm":"text-gray-600 hover:bg-gray-200/60 hover:text-gray-900"),children:({isActive:x})=>f.jsxs(f.Fragment,{children:[f.jsx(m,{className:te("h-4 w-4 transition-colors",x?"text-gray-900":"text-gray-500 group-hover:text-gray-800")}),f.jsx("span",{children:h.label()})]})})},h.target)})})}),f.jsx("div",{className:"mx-4 border-t border-gray-200/60"}),f.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2",children:t.isLoading?f.jsx("div",{className:"text-xs text-gray-500 p-3",children:A("sessionsLoading")}):u.length===0?f.jsxs("div",{className:"p-4 text-center",children:[f.jsx(wo,{className:"h-6 w-6 mx-auto mb-2 text-gray-300"}),f.jsx("div",{className:"text-xs text-gray-500",children:A("sessionsEmpty")})]}):f.jsx("div",{className:"space-y-3",children:u.map(h=>f.jsxs("div",{children:[f.jsx("div",{className:"px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider",children:h.label}),f.jsx("div",{className:"space-y-0.5",children:h.sessions.map(m=>{const x=t.selectedSessionKey===m.key,S=n.sessionRunStatusByKey.get(m.key);return f.jsxs("button",{onClick:()=>e.chatSessionListManager.selectSession(m.key),className:te("w-full rounded-xl px-3 py-2 text-left transition-all text-[13px]",x?"bg-gray-200 text-gray-900 font-semibold shadow-sm":"text-gray-700 hover:bg-gray-200/60 hover:text-gray-900"),children:[f.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_0.875rem] items-center gap-1.5",children:[f.jsx("span",{className:"truncate font-medium",children:$a(m)}),f.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:S?f.jsx(Ra,{status:S}):null})]}),f.jsxs("div",{className:"mt-0.5 text-[11px] text-gray-400 truncate",children:[m.messageCount," · ",zt(m.updatedAt)]})]},m.key)})})]},h.label))})}),f.jsxs("div",{className:"px-3 py-3 border-t border-gray-200/60 space-y-0.5",children:[f.jsx(xn,{to:"/settings",className:({isActive:h})=>te("group w-full flex items-center gap-2.5 px-3 py-2 rounded-xl text-[13px] font-medium transition-all duration-150",h?"bg-gray-200 text-gray-900 font-semibold shadow-sm":"text-gray-600 hover:bg-gray-200/60 hover:text-gray-900"),children:({isActive:h})=>f.jsxs(f.Fragment,{children:[f.jsx(vo,{className:te("h-4 w-4 transition-colors",h?"text-gray-900":"text-gray-500 group-hover:text-gray-800")}),f.jsx("span",{children:A("settings")})]})}),f.jsxs(ft,{value:s,onValueChange:h=>o(h),children:[f.jsxs(pt,{className:"w-full h-auto rounded-xl border-0 bg-transparent shadow-none px-3 py-2 text-[13px] font-medium text-gray-600 hover:bg-gray-200/60 focus:ring-0",children:[f.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[f.jsx(Co,{className:"h-4 w-4 text-gray-400"}),f.jsx("span",{children:A("theme")})]}),f.jsx("span",{className:"ml-auto text-[11px] text-gray-500",children:a})]}),f.jsx(mt,{children:mr.map(h=>f.jsx(He,{value:h.value,className:"text-xs",children:A(h.labelKey)},h.value))})]}),f.jsxs(ft,{value:r,onValueChange:h=>d(h),children:[f.jsxs(pt,{className:"w-full h-auto rounded-xl border-0 bg-transparent shadow-none px-3 py-2 text-[13px] font-medium text-gray-600 hover:bg-gray-200/60 focus:ring-0",children:[f.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[f.jsx(Io,{className:"h-4 w-4 text-gray-400"}),f.jsx("span",{children:A("language")})]}),f.jsx("span",{className:"ml-auto text-[11px] text-gray-500",children:l})]}),f.jsx(mt,{children:gr.map(h=>f.jsx(He,{value:h.value,className:"text-xs",children:h.label},h.value))})]})]})]})}function je(e){return typeof e=="function"}function Bi(e){var t=function(r){Error.call(r),r.stack=new Error().stack},n=e(t);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Gt=Bi(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
2
2
|
`+n.map(function(r,i){return i+1+") "+r.toString()}).join(`
|
|
3
3
|
`):"",this.name="UnsubscriptionError",this.errors=n}});function wn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var $t=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=yn(o),l=a.next();!l.done;l=a.next()){var u=l.value;u.remove(this)}}catch(x){t={error:x}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else o.remove(this);var d=this.initialTeardown;if(je(d))try{d()}catch(x){s=x instanceof Gt?x.errors:[x]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var p=yn(c),h=p.next();!h.done;h=p.next()){var m=h.value;try{yr(m)}catch(x){s=s??[],x instanceof Gt?s=bn(bn([],Sn(s)),Sn(x.errors)):s.push(x)}}}catch(x){r={error:x}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}}if(s)throw new Gt(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)yr(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(t)}},e.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},e.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},e.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&wn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&wn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),$i=$t.EMPTY;function Ui(e){return e instanceof $t||e&&"closed"in e&&je(e.remove)&&je(e.add)&&je(e.unsubscribe)}function yr(e){je(e)?e():e.unsubscribe()}var Ka={Promise:void 0},Va={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,bn([e,t],Sn(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function qa(e){Va.setTimeout(function(){throw e})}function br(){}function Mt(e){e()}var Hi=(function(e){yt(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Ui(n)&&n.add(r)):r.destination=Xa,r}return t.create=function(n,r,i){return new vn(n,r,i)},t.prototype.next=function(n){this.isStopped||this._next(n)},t.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})($t),Wa=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(r){vt(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){vt(r)}else vt(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){vt(n)}},e})(),vn=(function(e){yt(t,e);function t(n,r,i){var s=e.call(this)||this,o;return je(n)||!n?o={next:n??void 0,error:r??void 0,complete:i??void 0}:o=n,s.destination=new Wa(o),s}return t})(Hi);function vt(e){qa(e)}function Ga(e){throw e}var Xa={closed:!0,next:br,error:Ga,complete:br},Qa=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Ya(e){return e}function Ja(e){return e.length===0?Ya:e.length===1?e[0]:function(n){return e.reduce(function(r,i){return i(r)},n)}}var Pt=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var i=this,s=el(t)?t:new vn(t,n,r);return Mt(function(){var o=i,a=o.operator,l=o.source;s.add(a?a.call(s,l):l?i._subscribe(s):i._trySubscribe(s))}),s},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=Sr(n),new n(function(i,s){var o=new vn({next:function(a){try{t(a)}catch(l){s(l),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[Qa]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Ja(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=Sr(t),new t(function(r,i){var s;n.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},e.create=function(t){return new e(t)},e})();function Sr(e){var t;return(t=e??Ka.Promise)!==null&&t!==void 0?t:Promise}function Za(e){return e&&je(e.next)&&je(e.error)&&je(e.complete)}function el(e){return e&&e instanceof Hi||Za(e)&&Ui(e)}var tl=Bi(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Ne=(function(e){yt(t,e);function t(){var n=e.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return t.prototype.lift=function(n){var r=new kr(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new tl},t.prototype.next=function(n){var r=this;Mt(function(){var i,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=yn(r.currentObservers),a=o.next();!a.done;a=o.next()){var l=a.value;l.next(n)}}catch(u){i={error:u}}finally{try{a&&!a.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(n){var r=this;Mt(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var i=r.observers;i.length;)i.shift().error(n)}})},t.prototype.complete=function(){var n=this;Mt(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,i=this,s=i.hasError,o=i.isStopped,a=i.observers;return s||o?$i:(this.currentObservers=null,a.push(n),new $t(function(){r.currentObservers=null,wn(a,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,i=r.hasError,s=r.thrownError,o=r.isStopped;i?n.error(s):o&&n.complete()},t.prototype.asObservable=function(){var n=new Pt;return n.source=this,n},t.create=function(n,r){return new kr(n,r)},t})(Pt),kr=(function(e){yt(t,e);function t(n,r){var i=e.call(this)||this;return i.destination=n,i.source=r,i}return t.prototype.next=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,n)},t.prototype.error=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,n)},t.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},t.prototype._subscribe=function(n){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&i!==void 0?i:$i},t})(Ne),We=(function(e){yt(t,e);function t(n){var r=e.call(this)||this;return r._value=n,r}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(n){var r=e.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},t.prototype.getValue=function(){var n=this,r=n.hasError,i=n.thrownError,s=n._value;if(r)throw i;return this._throwIfClosed(),s},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t})(Ne);const re=[];for(let e=0;e<256;++e)re.push((e+256).toString(16).slice(1));function nl(e,t=0){return(re[e[t+0]]+re[e[t+1]]+re[e[t+2]]+re[e[t+3]]+"-"+re[e[t+4]]+re[e[t+5]]+"-"+re[e[t+6]]+re[e[t+7]]+"-"+re[e[t+8]]+re[e[t+9]]+"-"+re[e[t+10]]+re[e[t+11]]+re[e[t+12]]+re[e[t+13]]+re[e[t+14]]+re[e[t+15]]).toLowerCase()}let Xt;const rl=new Uint8Array(16);function il(){if(!Xt){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Xt=crypto.getRandomValues.bind(crypto)}return Xt(rl)}const sl=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),wr={randomUUID:sl};function Cn(e,t,n){var i;if(wr.randomUUID&&!e)return wr.randomUUID();e=e||{};const r=e.random??((i=e.rng)==null?void 0:i.call(e))??il();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,nl(r)}var se=(e=>(e.CALL="call",e.RESULT="result",e.PARTIAL_CALL="partial-call",e.ERROR="error",e.CANCELLED="cancelled",e))(se||{}),K=(e=>(e.TEXT_START="TEXT_START",e.TEXT_DELTA="TEXT_DELTA",e.TEXT_END="TEXT_END",e.TOOL_CALL_START="TOOL_CALL_START",e.TOOL_CALL_ARGS="TOOL_CALL_ARGS",e.TOOL_CALL_ARGS_DELTA="TOOL_CALL_ARGS_DELTA",e.TOOL_CALL_END="TOOL_CALL_END",e.TOOL_CALL_RESULT="TOOL_CALL_RESULT",e.RUN_STARTED="RUN_STARTED",e.RUN_FINISHED="RUN_FINISHED",e.RUN_ERROR="RUN_ERROR",e.RUN_METADATA="RUN_METADATA",e.REASONING_START="REASONING_START",e.REASONING_DELTA="REASONING_DELTA",e.REASONING_END="REASONING_END",e))(K||{});function ol(e){return!e||e.remoteStopCapable&&e.remoteRunId?null:e.remoteStopCapable?"__preparing__":e.remoteStopReason??""}const al=e=>{try{return JSON.parse(e)}catch{return}},vr=e=>({toolCallId:e.id,toolName:e.function.name,args:e.function.arguments,parsedArgs:al(e.function.arguments),status:se.CALL});function ll(e,t){const n={error:"tool_call_interrupted",note:"User continued before tool produced a result."};return e.map(r=>{var i;return(i=r.parts)!=null&&i.length?{...r,parts:r.parts.map(s=>{if(s.type!=="tool-invocation"||![se.CALL,se.PARTIAL_CALL].includes(s.toolInvocation.status))return s;let o;if(typeof s.toolInvocation.args=="string")try{o=JSON.parse(s.toolInvocation.args)}catch{return{...s,toolInvocation:{...s.toolInvocation,args:JSON.stringify({}),parsedArgs:o,status:se.RESULT,result:{error:"invalid_args",raw:s.toolInvocation.args}}}}return{...s,toolInvocation:{...s.toolInvocation,args:s.toolInvocation.args,parsedArgs:o,status:se.RESULT,result:n}}})}:r})}function In(e){if(e instanceof DOMException&&e.name==="AbortError")return!0;if(e instanceof Error){if(e.name==="AbortError")return!0;const t=e.message.toLowerCase();return t.includes("aborted")||t.includes("abort")}return!1}function Cr(e){if(e instanceof Error){const n=e.message.trim();if(n)return n}return String(e??"").trim()||"Failed to send message"}function Ir(e,t){return{id:`local-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,role:"assistant",parts:[{type:"text",text:e}],meta:{source:"local",status:(t==null?void 0:t.status)??"final",sessionKey:t==null?void 0:t.sessionKey,timestamp:new Date().toISOString()}}}class ul{constructor(t){F(this,"currentMessageId");F(this,"currentReasoningMessageId");F(this,"currentReasoningContent","");F(this,"currentToolCallId");F(this,"currentToolCallMessageId");F(this,"currentToolCallName");F(this,"currentToolCallArgs","");F(this,"emittedToolCallIds",new Set);this.sessionManager=t}findAssistantMessageById(t){const n=t==null?void 0:t.trim();return n?this.sessionManager.getMessages().find(i=>i.role==="assistant"&&i.id===n)??null:null}findAssistantMessageByToolCallId(t){var r;if(!t)return null;const n=this.sessionManager.getMessages();for(let i=n.length-1;i>=0;i-=1){const s=n[i];if(s.role!=="assistant")continue;if((r=s.parts)==null?void 0:r.some(a=>a.type==="tool-invocation"&&a.toolInvocation.toolCallId===t))return s}return null}findAssistantMessageForCurrentTool(t){var r;const n=this.findAssistantMessageById(this.currentToolCallMessageId);return(r=n==null?void 0:n.parts)!=null&&r.some(i=>i.type==="tool-invocation"&&i.toolInvocation.toolCallId===t)?n:this.findAssistantMessageByToolCallId(t)}reset(){this.currentMessageId=void 0,this.currentReasoningMessageId=void 0,this.currentReasoningContent="",this.currentToolCallId=void 0,this.currentToolCallMessageId=void 0,this.currentToolCallName=void 0,this.currentToolCallArgs="",this.emittedToolCallIds.clear()}emitToolCallEvents(){const t=this.sessionManager.getMessages();for(const n of t)if(!(n.role!=="assistant"||!n.parts))for(const r of n.parts){if(r.type!=="tool-invocation")continue;const i=r.toolInvocation;i.status===se.CALL&&!this.emittedToolCallIds.has(i.toolCallId)&&(this.emittedToolCallIds.add(i.toolCallId),this.sessionManager.toolCall$.next({toolCall:{id:i.toolCallId,type:"function",function:{name:i.toolName,arguments:i.args}}}))}}handleEvent(t){switch(t.type){case K.RUN_STARTED:break;case K.TEXT_START:this.handleTextStart(t);break;case K.TEXT_DELTA:this.handleTextContent(t);break;case K.TEXT_END:this.handleTextEnd();break;case K.REASONING_START:this.handleReasoningStart(t);break;case K.REASONING_DELTA:this.handleReasoningContent(t);break;case K.REASONING_END:this.handleReasoningEnd();break;case K.TOOL_CALL_START:this.handleToolCallStart(t);break;case K.TOOL_CALL_ARGS_DELTA:this.handleToolCallArgsDelta(t);break;case K.TOOL_CALL_ARGS:this.handleToolCallArgs(t);break;case K.TOOL_CALL_END:this.handleToolCallEnd(),this.emitToolCallEvents();break;case K.TOOL_CALL_RESULT:this.handleToolCallResult(t);break}}handleTextStart(t){this.currentMessageId=t.messageId}appendTextDelta(t,n){const r=[...t.parts||[]],i=r[r.length-1];return i&&i.type==="text"?{...t,parts:[...r.slice(0,-1),{type:"text",text:`${i.text}${n}`}]}:{...t,parts:[...r,{type:"text",text:n}]}}handleTextContent(t){if(!t.delta||this.currentMessageId!==t.messageId)return;const r=this.sessionManager.getMessages().find(i=>i.role==="assistant"&&i.id===this.currentMessageId);r?this.sessionManager.updateMessage(this.appendTextDelta(r,t.delta)):this.sessionManager.addMessages([{id:this.currentMessageId,role:"assistant",parts:[{type:"text",text:t.delta}]}])}handleTextEnd(){this.currentMessageId=void 0}updateReasoningPart(t,n){var s;const r=[...t.parts||[]];let i=-1;for(let o=r.length-1;o>=0;o-=1)if(((s=r[o])==null?void 0:s.type)==="reasoning"){i=o;break}return i>=0?{...t,parts:[...r.slice(0,i),{type:"reasoning",reasoning:n,details:[]},...r.slice(i+1)]}:{...t,parts:[...r,{type:"reasoning",reasoning:n,details:[]}]}}handleReasoningStart(t){this.currentReasoningMessageId=t.messageId,this.currentReasoningContent=""}handleReasoningContent(t){if(!t.delta||this.currentReasoningMessageId!==t.messageId)return;this.currentReasoningContent+=t.delta;const n=this.currentReasoningContent,r=this.currentReasoningMessageId,s=this.sessionManager.getMessages().find(o=>o.role==="assistant"&&o.id===r);s?this.sessionManager.updateMessage(this.updateReasoningPart(s,n)):this.sessionManager.addMessages([{id:r,role:"assistant",parts:[{type:"reasoning",reasoning:n,details:[]}]}])}handleReasoningEnd(){this.currentReasoningMessageId=void 0,this.currentReasoningContent=""}handleToolCallStart(t){var l;this.currentToolCallId=t.toolCallId,this.currentToolCallName=t.toolName,this.currentToolCallArgs="",this.currentToolCallMessageId=t.messageId;const n={type:"tool-invocation",toolInvocation:{status:se.PARTIAL_CALL,toolCallId:this.currentToolCallId,toolName:this.currentToolCallName,args:""}},r=this.sessionManager.getMessages(),i=(l=t.messageId)==null?void 0:l.trim(),s=this.findAssistantMessageById(i);if(s){this.currentToolCallMessageId=s.id;const u=s.parts.find(d=>d.type==="tool-invocation"&&d.toolInvocation.toolCallId===this.currentToolCallId);if(u&&u.type==="tool-invocation"){this.currentToolCallArgs=u.toolInvocation.args;return}this.sessionManager.updateMessage({...s,parts:[...s.parts||[],n]});return}if(i){this.currentToolCallMessageId=i,this.sessionManager.addMessages([{id:i,role:"assistant",parts:[n]}]);return}const o=this.findAssistantMessageByToolCallId(this.currentToolCallId);if(o){this.currentToolCallMessageId=o.id;const u=o.parts.find(d=>d.type==="tool-invocation"&&d.toolInvocation.toolCallId===this.currentToolCallId);this.currentToolCallArgs=(u==null?void 0:u.type)==="tool-invocation"?u.toolInvocation.args:"";return}const a=r[r.length-1];if(a&&a.role==="assistant")this.currentToolCallMessageId=a.id,this.sessionManager.updateMessage({...a,parts:[...a.parts||[],n]});else{const u=Cn();this.currentToolCallMessageId=u,this.sessionManager.addMessages([{id:u,role:"assistant",parts:[n]}])}}handleToolCallArgsDelta(t){var i;if(this.currentToolCallId!==t.toolCallId)return;this.currentToolCallArgs+=t.argsDelta;const n=this.findAssistantMessageForCurrentTool(t.toolCallId);if(!n||n.role!=="assistant"||!((i=n.parts)!=null&&i.length))return;const r=[...n.parts];for(let s=r.length-1;s>=0;s--){const o=r[s];if(o.type==="tool-invocation"&&o.toolInvocation.toolCallId===t.toolCallId){let a;try{a=JSON.parse(this.currentToolCallArgs)}catch{}r[s]={...o,toolInvocation:{...o.toolInvocation,status:se.PARTIAL_CALL,args:this.currentToolCallArgs,parsedArgs:a}};break}}this.sessionManager.updateMessage({...n,parts:r})}handleToolCallArgs(t){this.currentToolCallId===t.toolCallId&&(this.currentToolCallArgs=t.args,this.handleToolCallArgsDelta({type:K.TOOL_CALL_ARGS_DELTA,toolCallId:t.toolCallId,argsDelta:""}))}handleToolCallEnd(){var t;if(!(!this.currentToolCallId||!this.currentToolCallName)){try{const n={id:this.currentToolCallId,type:"function",function:{name:this.currentToolCallName,arguments:this.currentToolCallArgs}},r=this.findAssistantMessageForCurrentTool(this.currentToolCallId);if(r&&r.role==="assistant"){const i=[...r.parts||[]];for(let s=i.length-1;s>=0;s--){const o=i[s];if(o.type==="tool-invocation"&&o.toolInvocation.toolCallId===this.currentToolCallId){i[s]={...o,toolInvocation:{...vr(n),status:se.CALL}};break}}this.sessionManager.updateMessage({...r,parts:i})}else{const i=((t=this.currentToolCallMessageId)==null?void 0:t.trim())||Cn();this.sessionManager.addMessages([{id:i,role:"assistant",parts:[{type:"tool-invocation",toolInvocation:{...vr(n),status:se.CALL}}]}])}}catch{}this.currentToolCallId=void 0,this.currentToolCallMessageId=void 0,this.currentToolCallName=void 0,this.currentToolCallArgs=""}}handleToolCallResult(t){this.sessionManager.addToolResult({toolCallId:t.toolCallId,result:t.content,status:se.RESULT})}}class cl{constructor(){F(this,"disposables",[]);F(this,"addDisposable",t=>{this.disposables.push(t)});F(this,"dispose",()=>{this.disposables.forEach(t=>t()),this.disposables=[]})}}class dl extends cl{constructor(n=null,r){super();F(this,"_messages$",new We([]));F(this,"messages$");F(this,"threadId$",new We(null));F(this,"isAgentResponding$",new We(!1));F(this,"activeRun$",new We(null));F(this,"lastError$",new We(null));F(this,"isAwaitingResponse$",new We(!1));F(this,"runCompleted$",new Ne);F(this,"runError$",new Ne);F(this,"runMetadata$",new Ne);F(this,"activeSubscription",null);F(this,"addMessagesEvent$",new Ne);F(this,"updateMessageEvent$",new Ne);F(this,"setMessagesEvent$",new Ne);F(this,"toolCall$",new Ne);F(this,"eventHandler",new ul(this));F(this,"runIdCounter",0);F(this,"metadataParsers");F(this,"callbacks");F(this,"getMessages",()=>this._messages$.getValue());F(this,"setMessages",n=>{this._messages$.next(n),this.setMessagesEvent$.next({messages:n})});F(this,"handleEvent",n=>{this.eventHandler.handleEvent(n)});F(this,"setCallbacks",n=>{this.callbacks=n});F(this,"reset",()=>{this.abortAgentRun(),this._messages$.next([]),this.eventHandler.reset(),this.threadId$.next(null),this.isAgentResponding$.next(!1),this.activeRun$.next(null),this.lastError$.next(null),this.isAwaitingResponse$.next(!1),this.runIdCounter+=1});F(this,"addMessages",n=>{const i=[...this.getMessages()];for(const s of n){const o=i.findIndex(a=>a.id===s.id);o>=0?i[o]=s:i.push(s)}this._messages$.next(i),this.addMessagesEvent$.next({messages:n}),this.isAwaitingResponse$.getValue()&&n.some(s=>s.role==="assistant")&&this.isAwaitingResponse$.next(!1)});F(this,"removeMessages",n=>{n.length!==0&&this._messages$.next(this.getMessages().filter(r=>!n.includes(r.id)))});F(this,"updateMessage",n=>{this._messages$.next(this.getMessages().map(r=>r.id===n.id?n:r)),this.updateMessageEvent$.next({message:n}),this.isAwaitingResponse$.getValue()&&n.role==="assistant"&&this.isAwaitingResponse$.next(!1)});F(this,"addToolResult",(n,r)=>{const i=this.getMessages().find(o=>o.parts.find(a=>a.type==="tool-invocation"&&a.toolInvocation.toolCallId===n.toolCallId));if(!i)return;const s={...i,parts:i.parts.map(o=>o.type==="tool-invocation"&&o.toolInvocation.toolCallId===n.toolCallId?{...o,toolInvocation:{...o.toolInvocation,result:n.result??void 0,status:n.status,error:n.error??void 0,cancelled:n.cancelled??void 0}}:o)};this.updateMessage(s)});F(this,"send",async n=>{(this.activeRun$.getValue()||this.activeSubscription)&&this.abortAgentRun(),this.lastError$.next(null);const r=n.message.trim();r&&(this.addMessages([{id:Cn(),role:"user",parts:[{type:"text",text:r}]}]),await this.runAgent({metadata:n.metadata,sessionId:n.sessionId,agentId:n.agentId,stopCapable:n.stopCapable,stopReason:n.stopReason,sourceMessage:r,restoreDraftOnError:n.restoreDraftOnError}))});F(this,"resume",async n=>{var o,a;const r=(o=n.remoteRunId)==null?void 0:o.trim(),i=(a=n.sessionId)==null?void 0:a.trim();if(!r)return;const s=this.activeRun$.getValue();(s==null?void 0:s.remoteRunId)!==r&&(s||(this.lastError$.next(null),await this.runAgent({metadata:n.metadata,sessionId:i,agentId:n.agentId,stopCapable:n.stopCapable,stopReason:n.stopReason})))});F(this,"stop",async()=>{var i,s;const n=this.activeRun$.getValue();if(!n)return;const r=n.sessionId;this.abortAgentRun(),r&&await((s=(i=this.callbacks).onRunSettled)==null?void 0:s.call(i,{sourceSessionId:r}))});F(this,"handleAgentResponse",n=>{this.activeSubscription&&this.activeSubscription.unsubscribe(),this.activeSubscription=n.subscribe(r=>{var i,s,o,a,l,u,d,c,p;if(r.type===K.RUN_METADATA){const h=r,m=this.activeRun$.getValue(),x=((i=h.runId)==null?void 0:i.trim())||(m?`ui-${m.localRunId}`:"");this.metadataParsers&&m&&this.isMatchingRun(m,x)&&this.processRunMetadata(m,h.metadata),this.runMetadata$.next({runId:x,metadata:h.metadata});return}if(this.handleEvent(r),r.type===K.RUN_FINISHED){this.isAgentResponding$.next(!1),this.isAwaitingResponse$.next(!1),this.activeSubscription=null;const h=this.activeRun$.getValue(),m=((s=r.runId)==null?void 0:s.trim())||(h?`ui-${h.localRunId}`:"");if(!h||!this.isMatchingRun(h,m))return;const x=h.sessionId;this.activeRun$.next(null),x&&((a=(o=this.callbacks).onRunSettled)==null||a.call(o,{sourceSessionId:x}))}else if(r.type===K.RUN_ERROR){this.isAgentResponding$.next(!1),this.isAwaitingResponse$.next(!1),this.activeSubscription=null;const h=this.activeRun$.getValue(),m=((l=r.runId)==null?void 0:l.trim())||(h?`ui-${h.localRunId}`:""),x=In(r.error);if(this.runError$.next({runId:m,error:r.error,isAbort:x}),!h||!this.isMatchingRun(h,m)){this.activeRun$.next(null);return}const S=h.sessionId;if(x){this.activeRun$.next(null),S&&((d=(u=this.callbacks).onRunSettled)==null||d.call(u,{sourceSessionId:S}));return}const g=Cr(r.error);this.lastError$.next(g),this.activeRun$.next(null),S&&this.addMessages([Ir(g,{sessionKey:S,status:"error"})]),(p=(c=this.callbacks).onRunError)==null||p.call(c,{error:g,sourceMessage:h.sourceMessage,restoreDraft:h.restoreDraftOnError})}})});F(this,"abortAgentRun",()=>{var n,r,i;(i=(n=this.agentProvider)==null?void 0:(r=n.agent).abortRun)==null||i.call(r),this.activeSubscription&&(this.activeSubscription.unsubscribe(),this.activeSubscription=null,this.isAgentResponding$.next(!1),this.isAwaitingResponse$.next(!1)),this.activeRun$.next(null)});F(this,"runAgent",async n=>{var o,a,l,u;if(!this.agentProvider)return;(this.activeRun$.getValue()||this.activeSubscription)&&this.abortAgentRun();const r=++this.runIdCounter,i=`ui-${r}`,s={localRunId:r,sessionId:n==null?void 0:n.sessionId,...n!=null&&n.agentId?{agentId:n.agentId}:{},remoteStopCapable:!!(n!=null&&n.stopCapable),...n!=null&&n.stopReason?{remoteStopReason:n.stopReason}:{},sourceMessage:n==null?void 0:n.sourceMessage,restoreDraftOnError:n==null?void 0:n.restoreDraftOnError};this.activeRun$.next(s),this.isAgentResponding$.next(!0),this.isAwaitingResponse$.next(!0);try{const d=ll(this.getMessages()),c=typeof(n==null?void 0:n.threadId)=="string"&&n.threadId.trim()?n.threadId:this.threadId$.getValue()??"",p=await this.agentProvider.agent.run({threadId:c,runId:i,messages:d,tools:this.agentProvider.getToolDefs(),context:this.agentProvider.getContexts(),...n!=null&&n.metadata?{metadata:n.metadata}:{}});this.handleAgentResponse(p)}catch(d){const c=In(d);c?console.info("Agent run aborted"):console.error("Error running agent:",d),this.isAgentResponding$.next(!1),this.isAwaitingResponse$.next(!1);const p=this.activeRun$.getValue();if(this.activeRun$.next(null),this.runError$.next({runId:i,error:d,isAbort:c}),!c&&p){const h=Cr(d);this.lastError$.next(h),p.sessionId&&this.addMessages([Ir(h,{sessionKey:p.sessionId,status:"error"})]),(a=(o=this.callbacks).onRunError)==null||a.call(o,{error:h,sourceMessage:p.sourceMessage,restoreDraft:p.restoreDraftOnError})}else c&&(p!=null&&p.sessionId)&&((u=(l=this.callbacks).onRunSettled)==null||u.call(l,{sourceSessionId:p.sessionId}))}});F(this,"processRunMetadata",(n,r)=>{if(!this.metadataParsers)return;const i=this.metadataParsers.parseReady(r);if(i){this.applyReadyMetadata(n,i);return}const s=this.metadataParsers.parseFinal(r);s&&this.applyFinalMetadata(n,s)});F(this,"applyReadyMetadata",(n,r)=>{var s,o,a,l,u;const i={...n};(s=r.remoteRunId)!=null&&s.trim()&&(i.remoteRunId=r.remoteRunId.trim()),typeof r.stopCapable=="boolean"&&(i.remoteStopCapable=r.stopCapable),(o=r.stopReason)!=null&&o.trim()&&(i.remoteStopReason=r.stopReason.trim()),(a=r.sessionId)!=null&&a.trim()&&(i.sessionId=r.sessionId.trim(),(u=(l=this.callbacks).onSessionChanged)==null||u.call(l,i.sessionId)),this.activeRun$.next(i)});F(this,"applyFinalMetadata",(n,r)=>{var o,a,l,u;const i=n.sessionId,s=r.sessionId;s&&s!==i&&((a=(o=this.callbacks).onSessionChanged)==null||a.call(o,s)),this.activeRun$.next(null),i&&((u=(l=this.callbacks).onRunSettled)==null||u.call(l,{sourceSessionId:i,resultSessionId:s}))});F(this,"isMatchingRun",(n,r)=>r.trim()?r===`ui-${n.localRunId}`:!1);F(this,"connectToolExecutor",()=>{const n=this.toolCall$.subscribe(async({toolCall:r})=>{var s;const i=(s=this.agentProvider)==null?void 0:s.getToolExecutor(r.function.name);if(i)try{const o=JSON.parse(r.function.arguments),a=await i(o);this.addToolResult({toolCallId:r.id,result:a,status:se.RESULT}),this.runAgent()}catch(o){console.error("[AgentChatController] handleAddToolResult error",o),this.addToolResult({toolCallId:r.id,error:o instanceof Error?o.message:String(o),status:se.ERROR}),this.runAgent()}});return()=>n.unsubscribe()});this.agentProvider=n;const{initialMessages:i=[],metadataParsers:s,callbacks:o={}}=r||{};this.metadataParsers=s??null,this.callbacks=o,this._messages$.next(i),this.messages$=this._messages$.asObservable(),this.agentProvider&&this.addDisposable(this.connectToolExecutor())}}function hl(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const fl=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,pl=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ml={};function Rr(e,t){return(ml.jsx?pl:fl).test(e)}const gl=/[ \t\n\f\r]/g;function xl(e){return typeof e=="object"?e.type==="text"?Tr(e.value):!1:Tr(e)}function Tr(e){return e.replace(gl,"")===""}class bt{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}bt.prototype.normal={};bt.prototype.property={};bt.prototype.space=void 0;function Ki(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new bt(n,r,t)}function Rn(e){return e.toLowerCase()}class pe{constructor(t,n){this.attribute=n,this.property=t}}pe.prototype.attribute="";pe.prototype.booleanish=!1;pe.prototype.boolean=!1;pe.prototype.commaOrSpaceSeparated=!1;pe.prototype.commaSeparated=!1;pe.prototype.defined=!1;pe.prototype.mustUseProperty=!1;pe.prototype.number=!1;pe.prototype.overloadedBoolean=!1;pe.prototype.property="";pe.prototype.spaceSeparated=!1;pe.prototype.space=void 0;let yl=0;const $=Ve(),ee=Ve(),Tn=Ve(),E=Ve(),Y=Ve(),Ye=Ve(),ge=Ve();function Ve(){return 2**++yl}const An=Object.freeze(Object.defineProperty({__proto__:null,boolean:$,booleanish:ee,commaOrSpaceSeparated:ge,commaSeparated:Ye,number:E,overloadedBoolean:Tn,spaceSeparated:Y},Symbol.toStringTag,{value:"Module"})),Qt=Object.keys(An);class Hn extends pe{constructor(t,n,r,i){let s=-1;if(super(t,n),Ar(this,"space",i),typeof r=="number")for(;++s<Qt.length;){const o=Qt[s];Ar(this,Qt[s],(r&An[o])===An[o])}}}Hn.prototype.defined=!0;function Ar(e,t,n){n&&(e[t]=n)}function et(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Hn(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Rn(r)]=r,n[Rn(s.attribute)]=r}return new bt(t,n,e.space)}const Vi=et({properties:{ariaActiveDescendant:null,ariaAtomic:ee,ariaAutoComplete:null,ariaBusy:ee,ariaChecked:ee,ariaColCount:E,ariaColIndex:E,ariaColSpan:E,ariaControls:Y,ariaCurrent:null,ariaDescribedBy:Y,ariaDetails:null,ariaDisabled:ee,ariaDropEffect:Y,ariaErrorMessage:null,ariaExpanded:ee,ariaFlowTo:Y,ariaGrabbed:ee,ariaHasPopup:null,ariaHidden:ee,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Y,ariaLevel:E,ariaLive:null,ariaModal:ee,ariaMultiLine:ee,ariaMultiSelectable:ee,ariaOrientation:null,ariaOwns:Y,ariaPlaceholder:null,ariaPosInSet:E,ariaPressed:ee,ariaReadOnly:ee,ariaRelevant:null,ariaRequired:ee,ariaRoleDescription:Y,ariaRowCount:E,ariaRowIndex:E,ariaRowSpan:E,ariaSelected:ee,ariaSetSize:E,ariaSort:null,ariaValueMax:E,ariaValueMin:E,ariaValueNow:E,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function qi(e,t){return t in e?e[t]:t}function Wi(e,t){return qi(e,t.toLowerCase())}const bl=et({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ye,acceptCharset:Y,accessKey:Y,action:null,allow:null,allowFullScreen:$,allowPaymentRequest:$,allowUserMedia:$,alt:null,as:null,async:$,autoCapitalize:null,autoComplete:Y,autoFocus:$,autoPlay:$,blocking:Y,capture:null,charSet:null,checked:$,cite:null,className:Y,cols:E,colSpan:null,content:null,contentEditable:ee,controls:$,controlsList:Y,coords:E|Ye,crossOrigin:null,data:null,dateTime:null,decoding:null,default:$,defer:$,dir:null,dirName:null,disabled:$,download:Tn,draggable:ee,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:$,formTarget:null,headers:Y,height:E,hidden:Tn,high:E,href:null,hrefLang:null,htmlFor:Y,httpEquiv:Y,id:null,imageSizes:null,imageSrcSet:null,inert:$,inputMode:null,integrity:null,is:null,isMap:$,itemId:null,itemProp:Y,itemRef:Y,itemScope:$,itemType:Y,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:$,low:E,manifest:null,max:null,maxLength:E,media:null,method:null,min:null,minLength:E,multiple:$,muted:$,name:null,nonce:null,noModule:$,noValidate:$,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:$,optimum:E,pattern:null,ping:Y,placeholder:null,playsInline:$,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:$,referrerPolicy:null,rel:Y,required:$,reversed:$,rows:E,rowSpan:E,sandbox:Y,scope:null,scoped:$,seamless:$,selected:$,shadowRootClonable:$,shadowRootDelegatesFocus:$,shadowRootMode:null,shape:null,size:E,sizes:null,slot:null,span:E,spellCheck:ee,src:null,srcDoc:null,srcLang:null,srcSet:null,start:E,step:null,style:null,tabIndex:E,target:null,title:null,translate:null,type:null,typeMustMatch:$,useMap:null,value:ee,width:E,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Y,axis:null,background:null,bgColor:null,border:E,borderColor:null,bottomMargin:E,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:$,declare:$,event:null,face:null,frame:null,frameBorder:null,hSpace:E,leftMargin:E,link:null,longDesc:null,lowSrc:null,marginHeight:E,marginWidth:E,noResize:$,noHref:$,noShade:$,noWrap:$,object:null,profile:null,prompt:null,rev:null,rightMargin:E,rules:null,scheme:null,scrolling:ee,standby:null,summary:null,text:null,topMargin:E,valueType:null,version:null,vAlign:null,vLink:null,vSpace:E,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:$,disableRemotePlayback:$,prefix:null,property:null,results:E,security:null,unselectable:null},space:"html",transform:Wi}),Sl=et({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ge,accentHeight:E,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:E,amplitude:E,arabicForm:null,ascent:E,attributeName:null,attributeType:null,azimuth:E,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:E,by:null,calcMode:null,capHeight:E,className:Y,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:E,diffuseConstant:E,direction:null,display:null,dur:null,divisor:E,dominantBaseline:null,download:$,dx:null,dy:null,edgeMode:null,editable:null,elevation:E,enableBackground:null,end:null,event:null,exponent:E,externalResourcesRequired:null,fill:null,fillOpacity:E,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Ye,g2:Ye,glyphName:Ye,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:E,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:E,horizOriginX:E,horizOriginY:E,id:null,ideographic:E,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:E,k:E,k1:E,k2:E,k3:E,k4:E,kernelMatrix:ge,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:E,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:E,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:E,overlineThickness:E,paintOrder:null,panose1:null,path:null,pathLength:E,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Y,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:E,pointsAtY:E,pointsAtZ:E,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ge,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ge,rev:ge,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ge,requiredFeatures:ge,requiredFonts:ge,requiredFormats:ge,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:E,specularExponent:E,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:E,strikethroughThickness:E,string:null,stroke:null,strokeDashArray:ge,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:E,strokeOpacity:E,strokeWidth:null,style:null,surfaceScale:E,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ge,tabIndex:E,tableValues:null,target:null,targetX:E,targetY:E,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ge,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:E,underlineThickness:E,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:E,values:null,vAlphabetic:E,vMathematical:E,vectorEffect:null,vHanging:E,vIdeographic:E,version:null,vertAdvY:E,vertOriginX:E,vertOriginY:E,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:E,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:qi}),Gi=et({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Xi=et({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Wi}),Qi=et({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),kl={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},wl=/[A-Z]/g,Er=/-[a-z]/g,vl=/^data[-\w.:]+$/i;function Cl(e,t){const n=Rn(t);let r=t,i=pe;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&vl.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Er,Rl);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Er.test(s)){let o=s.replace(wl,Il);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Hn}return new i(r,t)}function Il(e){return"-"+e.toLowerCase()}function Rl(e){return e.charAt(1).toUpperCase()}const Tl=Ki([Vi,bl,Gi,Xi,Qi],"html"),Kn=Ki([Vi,Sl,Gi,Xi,Qi],"svg");function Al(e){return e.join(" ").trim()}var Ge={},Yt,Mr;function El(){if(Mr)return Yt;Mr=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,l=`
|
|
4
4
|
`,u="/",d="*",c="",p="comment",h="declaration";function m(S,g){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];g=g||{};var v=1,k=1;function T(O){var P=O.match(t);P&&(v+=P.length);var G=O.lastIndexOf(l);k=~G?O.length-G:k+O.length}function N(){var O={line:v,column:k};return function(P){return P.position=new w(O),U(),P}}function w(O){this.start=O,this.end={line:v,column:k},this.source=g.source}w.prototype.content=S;function _(O){var P=new Error(g.source+":"+v+":"+k+": "+O);if(P.reason=O,P.filename=g.source,P.line=v,P.column=k,P.source=S,!g.silent)throw P}function z(O){var P=O.exec(S);if(P){var G=P[0];return T(G),S=S.slice(G.length),P}}function U(){z(n)}function C(O){var P;for(O=O||[];P=j();)P!==!1&&O.push(P);return O}function j(){var O=N();if(!(u!=S.charAt(0)||d!=S.charAt(1))){for(var P=2;c!=S.charAt(P)&&(d!=S.charAt(P)||u!=S.charAt(P+1));)++P;if(P+=2,c===S.charAt(P-1))return _("End of comment missing");var G=S.slice(2,P-2);return k+=2,T(G),S=S.slice(P),k+=2,O({type:p,comment:G})}}function L(){var O=N(),P=z(r);if(P){if(j(),!z(i))return _("property missing ':'");var G=z(s),J=O({type:h,property:x(P[0].replace(e,c)),value:G?x(G[0].replace(e,c)):c});return z(o),J}}function W(){var O=[];C(O);for(var P;P=L();)P!==!1&&(O.push(P),C(O));return O}return U(),W()}function x(S){return S?S.replace(a,c):c}return Yt=m,Yt}var Nr;function Ml(){if(Nr)return Ge;Nr=1;var e=Ge&&Ge.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.default=n;const t=e(El());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const o=(0,t.default)(r),a=typeof i=="function";return o.forEach(l=>{if(l.type!=="declaration")return;const{property:u,value:d}=l;a?i(u,d,l):d&&(s=s||{},s[u]=d)}),s}return Ge}var it={},Pr;function Nl(){if(Pr)return it;Pr=1,Object.defineProperty(it,"__esModule",{value:!0}),it.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(u){return!u||n.test(u)||e.test(u)},o=function(u,d){return d.toUpperCase()},a=function(u,d){return"".concat(d,"-")},l=function(u,d){return d===void 0&&(d={}),s(u)?u:(u=u.toLowerCase(),d.reactCompat?u=u.replace(i,a):u=u.replace(r,a),u.replace(t,o))};return it.camelCase=l,it}var st,jr;function Pl(){if(jr)return st;jr=1;var e=st&&st.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Ml()),n=Nl();function r(i,s){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(a,l){a&&l&&(o[(0,n.camelCase)(a,s)]=l)}),o}return r.default=r,st=r,st}var jl=Pl();const Ll=vi(jl),Yi=Ji("end"),Vn=Ji("start");function Ji(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function _l(e){const t=Vn(e),n=Yi(e);if(t&&n)return{start:t,end:n}}function ct(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Lr(e.position):"start"in e||"end"in e?Lr(e):"line"in e||"column"in e?En(e):""}function En(e){return _r(e&&e.line)+":"+_r(e&&e.column)}function Lr(e){return En(e&&e.start)+"-"+En(e&&e.end)}function _r(e){return e&&typeof e=="number"?e:1}class le extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=ct(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}le.prototype.file="";le.prototype.name="";le.prototype.reason="";le.prototype.message="";le.prototype.stack="";le.prototype.column=void 0;le.prototype.line=void 0;le.prototype.ancestors=void 0;le.prototype.cause=void 0;le.prototype.fatal=void 0;le.prototype.place=void 0;le.prototype.ruleId=void 0;le.prototype.source=void 0;const qn={}.hasOwnProperty,Ol=new Map,Dl=/[A-Z]/g,Fl=new Set(["table","tbody","thead","tfoot","tr"]),zl=new Set(["td","th"]),Zi="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Bl(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Gl(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Wl(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Kn:Tl,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=es(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function es(e,t,n){if(t.type==="element")return $l(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Ul(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Kl(e,t,n);if(t.type==="mdxjsEsm")return Hl(e,t);if(t.type==="root")return Vl(e,t,n);if(t.type==="text")return ql(e,t)}function $l(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Kn,e.schema=i),e.ancestors.push(t);const s=ns(e,t.tagName,!1),o=Xl(e,t);let a=Gn(e,t);return Fl.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!xl(l):!0})),ts(e,o,s,t),Wn(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function Ul(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}gt(e,t.position)}function Hl(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);gt(e,t.position)}function Kl(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Kn,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:ns(e,t.name,!0),o=Ql(e,t),a=Gn(e,t);return ts(e,o,s,t),Wn(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function Vl(e,t,n){const r={};return Wn(r,Gn(e,t)),e.create(t,e.Fragment,r,n)}function ql(e,t){return t.value}function ts(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Wn(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Wl(e,t,n){return r;function r(i,s,o,a){const u=Array.isArray(o.children)?n:t;return a?u(s,o,a):u(s,o)}}function Gl(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=Vn(r);return t(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function Xl(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&qn.call(t.properties,i)){const s=Yl(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&zl.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Ql(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else gt(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else gt(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Gn(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Ol;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const u=i.get(l)||0;o=l+"-"+u,i.set(l,u+1)}}const a=es(e,s,o);a!==void 0&&n.push(a)}return n}function Yl(e,t,n){const r=Cl(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?hl(n):Al(n)),r.property==="style"){let i=typeof n=="object"?n:Jl(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Zl(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?kl[r.property]||r.property:r.attribute,n]}}function Jl(e,t){try{return Ll(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new le("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=Zi+"#cannot-parse-style-attribute",i}}function ns(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=Rr(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=Rr(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return qn.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);gt(e)}function gt(e,t){const n=new le("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Zi+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Zl(e){const t={};let n;for(n in e)qn.call(e,n)&&(t[eu(n)]=e[n]);return t}function eu(e){let t=e.replace(Dl,tu);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function tu(e){return"-"+e.toLowerCase()}const Jt={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},nu={};function Xn(e,t){const n=nu,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return rs(e,r,i)}function rs(e,t,n){if(ru(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Or(e.children,t,n)}return Array.isArray(e)?Or(e,t,n):""}function Or(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=rs(e[i],t,n);return r.join("")}function ru(e){return!!(e&&typeof e=="object")}const Dr=document.createElement("i");function Qn(e){const t="&"+e+";";Dr.innerHTML=t;const n=Dr.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function xe(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function Se(e,t){return e.length>0?(xe(e,e.length,0,t),e):t}const Fr={}.hasOwnProperty;function is(e){const t={};let n=-1;for(;++n<e.length;)iu(t,e[n]);return t}function iu(e,t){let n;for(n in t){const i=(Fr.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){Fr.call(i,o)||(i[o]=[]);const a=s[o];su(i[o],Array.isArray(a)?a:a?[a]:[])}}}function su(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);xe(e,0,0,r)}function ss(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ce(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ue=De(/[A-Za-z]/),ae=De(/[\dA-Za-z]/),ou=De(/[#-'*+\--9=?A-Z^-~]/);function jt(e){return e!==null&&(e<32||e===127)}const Mn=De(/\d/),au=De(/[\dA-Fa-f]/),lu=De(/[!-/:-@[-`{-~]/);function D(e){return e!==null&&e<-2}function Q(e){return e!==null&&(e<0||e===32)}function H(e){return e===-2||e===-1||e===32}const Ut=De(new RegExp("\\p{P}|\\p{S}","u")),Ke=De(/\s/);function De(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function tt(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&ae(e.charCodeAt(n+1))&&ae(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function q(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return H(l)?(e.enter(n),a(l)):t(l)}function a(l){return H(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const uu={tokenize:cu};function cu(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),q(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return D(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const du={tokenize:hu},zr={tokenize:fu};function hu(e){const t=this,n=[];let r=0,i,s,o;return a;function a(k){if(r<n.length){const T=n[r];return t.containerState=T[1],e.attempt(T[0].continuation,l,u)(k)}return u(k)}function l(k){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();const T=t.events.length;let N=T,w;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){w=t.events[N][1].end;break}g(r);let _=T;for(;_<t.events.length;)t.events[_][1].end={...w},_++;return xe(t.events,N+1,0,t.events.slice(T)),t.events.length=_,u(k)}return a(k)}function u(k){if(r===n.length){if(!i)return p(k);if(i.currentConstruct&&i.currentConstruct.concrete)return m(k);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(zr,d,c)(k)}function d(k){return i&&v(),g(r),p(k)}function c(k){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(k)}function p(k){return t.containerState={},e.attempt(zr,h,m)(k)}function h(k){return r++,n.push([t.currentConstruct,t.containerState]),p(k)}function m(k){if(k===null){i&&v(),g(0),e.consume(k);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),x(k)}function x(k){if(k===null){S(e.exit("chunkFlow"),!0),g(0),e.consume(k);return}return D(k)?(e.consume(k),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(k),x)}function S(k,T){const N=t.sliceStream(k);if(T&&N.push(null),k.previous=s,s&&(s.next=k),s=k,i.defineSkip(k.start),i.write(N),t.parser.lazy[k.start.line]){let w=i.events.length;for(;w--;)if(i.events[w][1].start.offset<o&&(!i.events[w][1].end||i.events[w][1].end.offset>o))return;const _=t.events.length;let z=_,U,C;for(;z--;)if(t.events[z][0]==="exit"&&t.events[z][1].type==="chunkFlow"){if(U){C=t.events[z][1].end;break}U=!0}for(g(r),w=_;w<t.events.length;)t.events[w][1].end={...C},w++;xe(t.events,z+1,0,t.events.slice(_)),t.events.length=w}}function g(k){let T=n.length;for(;T-- >k;){const N=n[T];t.containerState=N[1],N[0].exit.call(t,e)}n.length=k}function v(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function fu(e,t,n){return q(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Je(e){if(e===null||Q(e)||Ke(e))return 1;if(Ut(e))return 2}function Ht(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const Nn={name:"attention",resolveAll:pu,tokenize:mu};function pu(e,t){let n=-1,r,i,s,o,a,l,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},p={...e[n][1].start};Br(c,-l),Br(p,l),o={type:l>1?"strongSequence":"emphasisSequence",start:c,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Se(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Se(u,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),u=Se(u,Ht(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Se(u,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Se(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,xe(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function mu(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Je(r);let s;return o;function o(l){return s=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===s)return e.consume(l),a;const u=e.exit("attentionSequence"),d=Je(l),c=!d||d===2&&i||n.includes(l),p=!i||i===2&&d||n.includes(r);return u._open=!!(s===42?c:c&&(i||!p)),u._close=!!(s===42?p:p&&(d||!c)),t(l)}}function Br(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const gu={name:"autolink",tokenize:xu};function xu(e,t,n){let r=0;return i;function i(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(h){return ue(h)?(e.consume(h),o):h===64?n(h):u(h)}function o(h){return h===43||h===45||h===46||ae(h)?(r=1,a(h)):u(h)}function a(h){return h===58?(e.consume(h),r=0,l):(h===43||h===45||h===46||ae(h))&&r++<32?(e.consume(h),a):(r=0,u(h))}function l(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||jt(h)?n(h):(e.consume(h),l)}function u(h){return h===64?(e.consume(h),d):ou(h)?(e.consume(h),u):n(h)}function d(h){return ae(h)?c(h):n(h)}function c(h){return h===46?(e.consume(h),r=0,d):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):p(h)}function p(h){if((h===45||ae(h))&&r++<63){const m=h===45?p:c;return e.consume(h),m}return n(h)}}const St={partial:!0,tokenize:yu};function yu(e,t,n){return r;function r(s){return H(s)?q(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||D(s)?t(s):n(s)}}const os={continuation:{tokenize:Su},exit:ku,name:"blockQuote",tokenize:bu};function bu(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return H(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function Su(e,t,n){const r=this;return i;function i(o){return H(o)?q(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(os,t,n)(o)}}function ku(e){e.exit("blockQuote")}const as={name:"characterEscape",tokenize:wu};function wu(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return lu(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const ls={name:"characterReference",tokenize:vu};function vu(e,t,n){const r=this;let i=0,s,o;return a;function a(c){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),l}function l(c){return c===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(c),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,o=ae,d(c))}function u(c){return c===88||c===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(c),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=au,d):(e.enter("characterReferenceValue"),s=7,o=Mn,d(c))}function d(c){if(c===59&&i){const p=e.exit("characterReferenceValue");return o===ae&&!Qn(r.sliceSerialize(p))?n(c):(e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(c)&&i++<s?(e.consume(c),d):n(c)}}const $r={partial:!0,tokenize:Iu},Ur={concrete:!0,name:"codeFenced",tokenize:Cu};function Cu(e,t,n){const r=this,i={partial:!0,tokenize:N};let s=0,o=0,a;return l;function l(w){return u(w)}function u(w){const _=r.events[r.events.length-1];return s=_&&_[1].type==="linePrefix"?_[2].sliceSerialize(_[1],!0).length:0,a=w,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(w)}function d(w){return w===a?(o++,e.consume(w),d):o<3?n(w):(e.exit("codeFencedFenceSequence"),H(w)?q(e,c,"whitespace")(w):c(w))}function c(w){return w===null||D(w)?(e.exit("codeFencedFence"),r.interrupt?t(w):e.check($r,x,T)(w)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(w))}function p(w){return w===null||D(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(w)):H(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),q(e,h,"whitespace")(w)):w===96&&w===a?n(w):(e.consume(w),p)}function h(w){return w===null||D(w)?c(w):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(w))}function m(w){return w===null||D(w)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(w)):w===96&&w===a?n(w):(e.consume(w),m)}function x(w){return e.attempt(i,T,S)(w)}function S(w){return e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),g}function g(w){return s>0&&H(w)?q(e,v,"linePrefix",s+1)(w):v(w)}function v(w){return w===null||D(w)?e.check($r,x,T)(w):(e.enter("codeFlowValue"),k(w))}function k(w){return w===null||D(w)?(e.exit("codeFlowValue"),v(w)):(e.consume(w),k)}function T(w){return e.exit("codeFenced"),t(w)}function N(w,_,z){let U=0;return C;function C(P){return w.enter("lineEnding"),w.consume(P),w.exit("lineEnding"),j}function j(P){return w.enter("codeFencedFence"),H(P)?q(w,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):L(P)}function L(P){return P===a?(w.enter("codeFencedFenceSequence"),W(P)):z(P)}function W(P){return P===a?(U++,w.consume(P),W):U>=o?(w.exit("codeFencedFenceSequence"),H(P)?q(w,O,"whitespace")(P):O(P)):z(P)}function O(P){return P===null||D(P)?(w.exit("codeFencedFence"),_(P)):z(P)}}}function Iu(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Zt={name:"codeIndented",tokenize:Tu},Ru={partial:!0,tokenize:Au};function Tu(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),q(e,s,"linePrefix",5)(u)}function s(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?l(u):D(u)?e.attempt(Ru,o,l)(u):(e.enter("codeFlowValue"),a(u))}function a(u){return u===null||D(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),a)}function l(u){return e.exit("codeIndented"),t(u)}}function Au(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):D(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):q(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):D(o)?i(o):n(o)}}const Eu={name:"codeText",previous:Nu,resolve:Mu,tokenize:Pu};function Mu(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Nu(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Pu(e,t,n){let r=0,i,s;return o;function o(c){return e.enter("codeText"),e.enter("codeTextSequence"),a(c)}function a(c){return c===96?(e.consume(c),r++,a):(e.exit("codeTextSequence"),l(c))}function l(c){return c===null?n(c):c===32?(e.enter("space"),e.consume(c),e.exit("space"),l):c===96?(s=e.enter("codeTextSequence"),i=0,d(c)):D(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(c))}function u(c){return c===null||c===32||c===96||D(c)?(e.exit("codeTextData"),l(c)):(e.consume(c),u)}function d(c){return c===96?(e.consume(c),i++,d):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(c)):(s.type="codeTextData",u(c))}}class ju{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&ot(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),ot(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ot(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);ot(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ot(this.left,n.reverse())}}}function ot(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function us(e){const t={};let n=-1,r,i,s,o,a,l,u;const d=new ju(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Lu(d,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=d.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(d.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...d.get(i)[1].start},a=d.slice(i,n),a.unshift(r),d.splice(i,n-i+1,a))}}return xe(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function Lu(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],u={};let d,c,p=-1,h=n,m=0,x=0;const S=[x];for(;h;){for(;e.get(++i)[1]!==h;);s.push(i),h._tokenizer||(d=r.sliceStream(h),h.next||d.push(null),c&&o.defineSkip(h.start),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),c=h,h=h.next}for(h=n;++p<a.length;)a[p][0]==="exit"&&a[p-1][0]==="enter"&&a[p][1].type===a[p-1][1].type&&a[p][1].start.line!==a[p][1].end.line&&(x=p+1,S.push(x),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(o.events=[],h?(h._tokenizer=void 0,h.previous=void 0):S.pop(),p=S.length;p--;){const g=a.slice(S[p],S[p+1]),v=s.pop();l.push([v,v+g.length-1]),e.splice(v,2,g)}for(l.reverse(),p=-1;++p<l.length;)u[m+l[p][0]]=m+l[p][1],m+=l[p][1]-l[p][0]-1;return u}const _u={resolve:Du,tokenize:Fu},Ou={partial:!0,tokenize:zu};function Du(e){return us(e),e}function Fu(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):D(a)?e.check(Ou,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function zu(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),q(e,s,"linePrefix")}function s(o){if(o===null||D(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function cs(e,t,n,r,i,s,o,a,l){const u=l||Number.POSITIVE_INFINITY;let d=0;return c;function c(g){return g===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(g),e.exit(s),p):g===null||g===32||g===41||jt(g)?n(g):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),x(g))}function p(g){return g===62?(e.enter(s),e.consume(g),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),h(g))}function h(g){return g===62?(e.exit("chunkString"),e.exit(a),p(g)):g===null||g===60||D(g)?n(g):(e.consume(g),g===92?m:h)}function m(g){return g===60||g===62||g===92?(e.consume(g),h):h(g)}function x(g){return!d&&(g===null||g===41||Q(g))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(g)):d<u&&g===40?(e.consume(g),d++,x):g===41?(e.consume(g),d--,x):g===null||g===32||g===40||jt(g)?n(g):(e.consume(g),g===92?S:x)}function S(g){return g===40||g===41||g===92?(e.consume(g),x):x(g)}}function ds(e,t,n,r,i,s){const o=this;let a=0,l;return u;function u(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(s),d}function d(h){return a>999||h===null||h===91||h===93&&!l||h===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(h):h===93?(e.exit(s),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):D(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),c(h))}function c(h){return h===null||h===91||h===93||D(h)||a++>999?(e.exit("chunkString"),d(h)):(e.consume(h),l||(l=!H(h)),h===92?p:c)}function p(h){return h===91||h===92||h===93?(e.consume(h),a++,c):c(h)}}function hs(e,t,n,r,i,s){let o;return a;function a(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),o=p===40?41:p,l):n(p)}function l(p){return p===o?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),u(p))}function u(p){return p===o?(e.exit(s),l(o)):p===null?n(p):D(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),q(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===o||p===null||D(p)?(e.exit("chunkString"),u(p)):(e.consume(p),p===92?c:d)}function c(p){return p===o||p===92?(e.consume(p),d):d(p)}}function dt(e,t){let n;return r;function r(i){return D(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):H(i)?q(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Bu={name:"definition",tokenize:Uu},$u={partial:!0,tokenize:Hu};function Uu(e,t,n){const r=this;let i;return s;function s(h){return e.enter("definition"),o(h)}function o(h){return ds.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function a(h){return i=Ce(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),l):n(h)}function l(h){return Q(h)?dt(e,u)(h):u(h)}function u(h){return cs(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function d(h){return e.attempt($u,c,c)(h)}function c(h){return H(h)?q(e,p,"whitespace")(h):p(h)}function p(h){return h===null||D(h)?(e.exit("definition"),r.parser.defined.push(i),t(h)):n(h)}}function Hu(e,t,n){return r;function r(a){return Q(a)?dt(e,i)(a):n(a)}function i(a){return hs(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return H(a)?q(e,o,"whitespace")(a):o(a)}function o(a){return a===null||D(a)?t(a):n(a)}}const Ku={name:"hardBreakEscape",tokenize:Vu};function Vu(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return D(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const qu={name:"headingAtx",resolve:Wu,tokenize:Gu};function Wu(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},xe(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function Gu(e,t,n){let r=0;return i;function i(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||Q(d)?(e.exit("atxHeadingSequence"),a(d)):n(d)}function a(d){return d===35?(e.enter("atxHeadingSequence"),l(d)):d===null||D(d)?(e.exit("atxHeading"),t(d)):H(d)?q(e,a,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function l(d){return d===35?(e.consume(d),l):(e.exit("atxHeadingSequence"),a(d))}function u(d){return d===null||d===35||Q(d)?(e.exit("atxHeadingText"),a(d)):(e.consume(d),u)}}const Xu=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Hr=["pre","script","style","textarea"],Qu={concrete:!0,name:"htmlFlow",resolveTo:Zu,tokenize:ec},Yu={partial:!0,tokenize:nc},Ju={partial:!0,tokenize:tc};function Zu(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function ec(e,t,n){const r=this;let i,s,o,a,l;return u;function u(b){return d(b)}function d(b){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(b),c}function c(b){return b===33?(e.consume(b),p):b===47?(e.consume(b),s=!0,x):b===63?(e.consume(b),i=3,r.interrupt?t:y):ue(b)?(e.consume(b),o=String.fromCharCode(b),S):n(b)}function p(b){return b===45?(e.consume(b),i=2,h):b===91?(e.consume(b),i=5,a=0,m):ue(b)?(e.consume(b),i=4,r.interrupt?t:y):n(b)}function h(b){return b===45?(e.consume(b),r.interrupt?t:y):n(b)}function m(b){const he="CDATA[";return b===he.charCodeAt(a++)?(e.consume(b),a===he.length?r.interrupt?t:L:m):n(b)}function x(b){return ue(b)?(e.consume(b),o=String.fromCharCode(b),S):n(b)}function S(b){if(b===null||b===47||b===62||Q(b)){const he=b===47,Ie=o.toLowerCase();return!he&&!s&&Hr.includes(Ie)?(i=1,r.interrupt?t(b):L(b)):Xu.includes(o.toLowerCase())?(i=6,he?(e.consume(b),g):r.interrupt?t(b):L(b)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(b):s?v(b):k(b))}return b===45||ae(b)?(e.consume(b),o+=String.fromCharCode(b),S):n(b)}function g(b){return b===62?(e.consume(b),r.interrupt?t:L):n(b)}function v(b){return H(b)?(e.consume(b),v):C(b)}function k(b){return b===47?(e.consume(b),C):b===58||b===95||ue(b)?(e.consume(b),T):H(b)?(e.consume(b),k):C(b)}function T(b){return b===45||b===46||b===58||b===95||ae(b)?(e.consume(b),T):N(b)}function N(b){return b===61?(e.consume(b),w):H(b)?(e.consume(b),N):k(b)}function w(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),l=b,_):H(b)?(e.consume(b),w):z(b)}function _(b){return b===l?(e.consume(b),l=null,U):b===null||D(b)?n(b):(e.consume(b),_)}function z(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||Q(b)?N(b):(e.consume(b),z)}function U(b){return b===47||b===62||H(b)?k(b):n(b)}function C(b){return b===62?(e.consume(b),j):n(b)}function j(b){return b===null||D(b)?L(b):H(b)?(e.consume(b),j):n(b)}function L(b){return b===45&&i===2?(e.consume(b),G):b===60&&i===1?(e.consume(b),J):b===62&&i===4?(e.consume(b),de):b===63&&i===3?(e.consume(b),y):b===93&&i===5?(e.consume(b),ye):D(b)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Yu,be,W)(b)):b===null||D(b)?(e.exit("htmlFlowData"),W(b)):(e.consume(b),L)}function W(b){return e.check(Ju,O,be)(b)}function O(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),P}function P(b){return b===null||D(b)?W(b):(e.enter("htmlFlowData"),L(b))}function G(b){return b===45?(e.consume(b),y):L(b)}function J(b){return b===47?(e.consume(b),o="",ce):L(b)}function ce(b){if(b===62){const he=o.toLowerCase();return Hr.includes(he)?(e.consume(b),de):L(b)}return ue(b)&&o.length<8?(e.consume(b),o+=String.fromCharCode(b),ce):L(b)}function ye(b){return b===93?(e.consume(b),y):L(b)}function y(b){return b===62?(e.consume(b),de):b===45&&i===2?(e.consume(b),y):L(b)}function de(b){return b===null||D(b)?(e.exit("htmlFlowData"),be(b)):(e.consume(b),de)}function be(b){return e.exit("htmlFlow"),t(b)}}function tc(e,t,n){const r=this;return i;function i(o){return D(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function nc(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(St,t,n)}}const rc={name:"htmlText",tokenize:ic};function ic(e,t,n){const r=this;let i,s,o;return a;function a(y){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(y),l}function l(y){return y===33?(e.consume(y),u):y===47?(e.consume(y),N):y===63?(e.consume(y),k):ue(y)?(e.consume(y),z):n(y)}function u(y){return y===45?(e.consume(y),d):y===91?(e.consume(y),s=0,m):ue(y)?(e.consume(y),v):n(y)}function d(y){return y===45?(e.consume(y),h):n(y)}function c(y){return y===null?n(y):y===45?(e.consume(y),p):D(y)?(o=c,J(y)):(e.consume(y),c)}function p(y){return y===45?(e.consume(y),h):c(y)}function h(y){return y===62?G(y):y===45?p(y):c(y)}function m(y){const de="CDATA[";return y===de.charCodeAt(s++)?(e.consume(y),s===de.length?x:m):n(y)}function x(y){return y===null?n(y):y===93?(e.consume(y),S):D(y)?(o=x,J(y)):(e.consume(y),x)}function S(y){return y===93?(e.consume(y),g):x(y)}function g(y){return y===62?G(y):y===93?(e.consume(y),g):x(y)}function v(y){return y===null||y===62?G(y):D(y)?(o=v,J(y)):(e.consume(y),v)}function k(y){return y===null?n(y):y===63?(e.consume(y),T):D(y)?(o=k,J(y)):(e.consume(y),k)}function T(y){return y===62?G(y):k(y)}function N(y){return ue(y)?(e.consume(y),w):n(y)}function w(y){return y===45||ae(y)?(e.consume(y),w):_(y)}function _(y){return D(y)?(o=_,J(y)):H(y)?(e.consume(y),_):G(y)}function z(y){return y===45||ae(y)?(e.consume(y),z):y===47||y===62||Q(y)?U(y):n(y)}function U(y){return y===47?(e.consume(y),G):y===58||y===95||ue(y)?(e.consume(y),C):D(y)?(o=U,J(y)):H(y)?(e.consume(y),U):G(y)}function C(y){return y===45||y===46||y===58||y===95||ae(y)?(e.consume(y),C):j(y)}function j(y){return y===61?(e.consume(y),L):D(y)?(o=j,J(y)):H(y)?(e.consume(y),j):U(y)}function L(y){return y===null||y===60||y===61||y===62||y===96?n(y):y===34||y===39?(e.consume(y),i=y,W):D(y)?(o=L,J(y)):H(y)?(e.consume(y),L):(e.consume(y),O)}function W(y){return y===i?(e.consume(y),i=void 0,P):y===null?n(y):D(y)?(o=W,J(y)):(e.consume(y),W)}function O(y){return y===null||y===34||y===39||y===60||y===61||y===96?n(y):y===47||y===62||Q(y)?U(y):(e.consume(y),O)}function P(y){return y===47||y===62||Q(y)?U(y):n(y)}function G(y){return y===62?(e.consume(y),e.exit("htmlTextData"),e.exit("htmlText"),t):n(y)}function J(y){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),ce}function ce(y){return H(y)?q(e,ye,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(y):ye(y)}function ye(y){return e.enter("htmlTextData"),o(y)}}const Yn={name:"labelEnd",resolveAll:lc,resolveTo:uc,tokenize:cc},sc={tokenize:dc},oc={tokenize:hc},ac={tokenize:fc};function lc(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&xe(e,0,e.length,n),e}function uc(e,t){let n=e.length,r=0,i,s,o,a;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},d={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",u,t]],a=Se(a,e.slice(s+1,s+r+3)),a=Se(a,[["enter",d,t]]),a=Se(a,Ht(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=Se(a,[["exit",d,t],e[o-2],e[o-1],["exit",u,t]]),a=Se(a,e.slice(o+1)),a=Se(a,[["exit",l,t]]),xe(e,s,e.length,a),e}function cc(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(p){return s?s._inactive?c(p):(o=r.parser.defined.includes(Ce(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),l):n(p)}function l(p){return p===40?e.attempt(sc,d,o?d:c)(p):p===91?e.attempt(oc,d,o?u:c)(p):o?d(p):c(p)}function u(p){return e.attempt(ac,d,c)(p)}function d(p){return t(p)}function c(p){return s._balanced=!0,n(p)}}function dc(e,t,n){return r;function r(c){return e.enter("resource"),e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),i}function i(c){return Q(c)?dt(e,s)(c):s(c)}function s(c){return c===41?d(c):cs(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(c)}function o(c){return Q(c)?dt(e,l)(c):d(c)}function a(c){return n(c)}function l(c){return c===34||c===39||c===40?hs(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(c):d(c)}function u(c){return Q(c)?dt(e,d)(c):d(c)}function d(c){return c===41?(e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),e.exit("resource"),t):n(c)}}function hc(e,t,n){const r=this;return i;function i(a){return ds.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Ce(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function fc(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const pc={name:"labelStartImage",resolveAll:Yn.resolveAll,tokenize:mc};function mc(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const gc={name:"labelStartLink",resolveAll:Yn.resolveAll,tokenize:xc};function xc(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const en={name:"lineEnding",tokenize:yc};function yc(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),q(e,t,"linePrefix")}}const Nt={name:"thematicBreak",tokenize:bc};function bc(e,t,n){let r=0,i;return s;function s(u){return e.enter("thematicBreak"),o(u)}function o(u){return i=u,a(u)}function a(u){return u===i?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||D(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===i?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),H(u)?q(e,a,"whitespace")(u):a(u))}}const fe={continuation:{tokenize:vc},exit:Ic,name:"list",tokenize:wc},Sc={partial:!0,tokenize:Rc},kc={partial:!0,tokenize:Cc};function wc(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(h){const m=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Mn(h)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(Nt,n,u)(h):u(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(h)}return n(h)}function l(h){return Mn(h)&&++o<10?(e.consume(h),l):(!r.interrupt||o<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),u(h)):n(h)}function u(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(St,r.interrupt?n:d,e.attempt(Sc,p,c))}function d(h){return r.containerState.initialBlankLine=!0,s++,p(h)}function c(h){return H(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),p):n(h)}function p(h){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function vc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(St,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,q(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!H(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(kc,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,q(e,e.attempt(fe,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Cc(e,t,n){const r=this;return q(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function Ic(e){e.exit(this.containerState.type)}function Rc(e,t,n){const r=this;return q(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!H(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const Kr={name:"setextUnderline",resolveTo:Tc,tokenize:Ac};function Tc(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function Ac(e,t,n){const r=this;let i;return s;function s(u){let d=r.events.length,c;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){c=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter("setextHeadingLine"),i=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===i?(e.consume(u),a):(e.exit("setextHeadingLineSequence"),H(u)?q(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||D(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Ec={tokenize:Mc};function Mc(e){const t=this,n=e.attempt(St,r,e.attempt(this.parser.constructs.flowInitial,i,q(e,e.attempt(this.parser.constructs.flow,i,e.attempt(_u,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Nc={resolveAll:ps()},Pc=fs("string"),jc=fs("text");function fs(e){return{resolveAll:ps(e==="text"?Lc:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(d){return u(d)?s(d):a(d)}function a(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),l}function l(d){return u(d)?(n.exit("data"),s(d)):(n.consume(d),l)}function u(d){if(d===null)return!0;const c=i[d];let p=-1;if(c)for(;++p<c.length;){const h=c[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function ps(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function Lc(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,a=0,l;for(;s--;){const u=i[s];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(u===-2)l=!0,a++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const u={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const _c={42:fe,43:fe,45:fe,48:fe,49:fe,50:fe,51:fe,52:fe,53:fe,54:fe,55:fe,56:fe,57:fe,62:os},Oc={91:Bu},Dc={[-2]:Zt,[-1]:Zt,32:Zt},Fc={35:qu,42:Nt,45:[Kr,Nt],60:Qu,61:Kr,95:Nt,96:Ur,126:Ur},zc={38:ls,92:as},Bc={[-5]:en,[-4]:en,[-3]:en,33:pc,38:ls,42:Nn,60:[gu,rc],91:gc,92:[Ku,as],93:Yn,95:Nn,96:Eu},$c={null:[Nn,Nc]},Uc={null:[42,95]},Hc={null:[]},Kc=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Uc,contentInitial:Oc,disable:Hc,document:_c,flow:Fc,flowInitial:Dc,insideSpan:$c,string:zc,text:Bc},Symbol.toStringTag,{value:"Module"}));function Vc(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:_(N),check:_(w),consume:v,enter:k,exit:T,interrupt:_(w,{interrupt:!0})},u={code:null,containerState:{},defineSkip:x,events:[],now:m,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:c};let d=t.tokenize.call(u,l);return t.resolveAll&&s.push(t),u;function c(j){return o=Se(o,j),S(),o[o.length-1]!==null?[]:(z(t,0),u.events=Ht(s,u.events,u),u.events)}function p(j,L){return Wc(h(j),L)}function h(j){return qc(o,j)}function m(){const{_bufferIndex:j,_index:L,line:W,column:O,offset:P}=r;return{_bufferIndex:j,_index:L,line:W,column:O,offset:P}}function x(j){i[j.line]=j.column,C()}function S(){let j;for(;r._index<o.length;){const L=o[r._index];if(typeof L=="string")for(j=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===j&&r._bufferIndex<L.length;)g(L.charCodeAt(r._bufferIndex));else g(L)}}function g(j){d=d(j)}function v(j){D(j)?(r.line++,r.column=1,r.offset+=j===-3?2:1,C()):j!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=j}function k(j,L){const W=L||{};return W.type=j,W.start=m(),u.events.push(["enter",W,u]),a.push(W),W}function T(j){const L=a.pop();return L.end=m(),u.events.push(["exit",L,u]),L}function N(j,L){z(j,L.from)}function w(j,L){L.restore()}function _(j,L){return W;function W(O,P,G){let J,ce,ye,y;return Array.isArray(O)?be(O):"tokenize"in O?be([O]):de(O);function de(Z){return _e;function _e(ke){const Ae=ke!==null&&Z[ke],ne=ke!==null&&Z.null,ze=[...Array.isArray(Ae)?Ae:Ae?[Ae]:[],...Array.isArray(ne)?ne:ne?[ne]:[]];return be(ze)(ke)}}function be(Z){return J=Z,ce=0,Z.length===0?G:b(Z[ce])}function b(Z){return _e;function _e(ke){return y=U(),ye=Z,Z.partial||(u.currentConstruct=Z),Z.name&&u.parser.constructs.disable.null.includes(Z.name)?Ie():Z.tokenize.call(L?Object.assign(Object.create(u),L):u,l,he,Ie)(ke)}}function he(Z){return j(ye,y),P}function Ie(Z){return y.restore(),++ce<J.length?b(J[ce]):G}}}function z(j,L){j.resolveAll&&!s.includes(j)&&s.push(j),j.resolve&&xe(u.events,L,u.events.length-L,j.resolve(u.events.slice(L),u)),j.resolveTo&&(u.events=j.resolveTo(u.events,u))}function U(){const j=m(),L=u.previous,W=u.currentConstruct,O=u.events.length,P=Array.from(a);return{from:O,restore:G};function G(){r=j,u.previous=L,u.currentConstruct=W,u.events.length=O,a=P,C()}}function C(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function qc(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function Wc(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as s,j as t,D as oe,a_ as ae,a$ as ne,aE as W,a1 as ie,w as le,b0 as ce,q as de,aA as ue,b1 as me}from"./vendor-d7E8OgNx.js";import{Y as we,D as Y,t as i,c as X,_ as xe}from"./index-Dl6t70wA.js";function pe(){const{isOpen:T,mode:g,tabs:A,activeTabId:N,currentTab:x,currentUrl:l,navVersion:p,close:F,toggleMode:$,goBack:I,goForward:_,canGoBack:O,canGoForward:G,navigate:y,syncUrl:S,setActiveTab:V,closeTab:H,openNewTab:q}=we(),[k,j]=s.useState(""),[E,C]=s.useState(!1),[J,h]=s.useState(!1),[d,D]=s.useState(()=>({x:Math.max(40,window.innerWidth-520),y:80})),[n,B]=s.useState({w:480,h:600}),[L,K]=s.useState(420),u=s.useRef(null),m=s.useRef(null),b=s.useRef(null),z=s.useRef(null),P=s.useRef(p),a=(x==null?void 0:x.kind)==="docs";s.useEffect(()=>{if(!a){j("");return}try{const e=new URL(l);j(e.pathname)}catch{j(l)}},[l,N,a]),s.useEffect(()=>{var e;if(a){if(p!==P.current){P.current=p;return}if((e=z.current)!=null&&e.contentWindow)try{const r=new URL(l).pathname;z.current.contentWindow.postMessage({type:"docs-navigate",path:r},"*")}catch{}}},[l,p,a]),s.useEffect(()=>{g==="floating"&&D(e=>({x:Math.max(40,window.innerWidth-n.w-40),y:e.y}))},[g,n.w]),s.useEffect(()=>{const e=r=>{var o;a&&((o=r.data)==null?void 0:o.type)==="docs-route-change"&&typeof r.data.url=="string"&&S(r.data.url)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[S,a]);const Q=s.useCallback(e=>{if(e.preventDefault(),!a)return;const r=k.trim();r&&(r.startsWith("/")?y(`${Y}${r}`):r.startsWith("http")?y(r):y(`${Y}/${r}`))},[k,y,a]),Z=s.useCallback(e=>{g==="floating"&&(C(!0),u.current={startX:e.clientX,startY:e.clientY,startPosX:d.x,startPosY:d.y})},[g,d]);s.useEffect(()=>{if(!E)return;const e=o=>{u.current&&D({x:u.current.startPosX+(o.clientX-u.current.startX),y:u.current.startPosY+(o.clientY-u.current.startY)})},r=()=>{C(!1),u.current=null};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",r),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",r)}},[E]);const M=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0);const r=e.currentTarget.dataset.axis;m.current={startX:e.clientX,startY:e.clientY,startW:n.w,startH:n.h};const o=w=>{m.current&&B(v=>({w:r==="y"?v.w:Math.max(360,m.current.startW+(w.clientX-m.current.startX)),h:r==="x"?v.h:Math.max(400,m.current.startH+(w.clientY-m.current.startY))}))},f=()=>{h(!1),m.current=null,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",f)};window.addEventListener("mousemove",o),window.addEventListener("mouseup",f)},[n]),ee=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0),b.current={startX:e.clientX,startW:L};const r=f=>{if(!b.current)return;const w=b.current.startX-f.clientX;K(Math.max(320,Math.min(860,b.current.startW+w)))},o=()=>{h(!1),b.current=null,window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)},[L]),te=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0);const r=e.clientX,o=n.w,f=d.x,w=re=>{const se=r-re.clientX,U=Math.max(360,o+se);B(R=>({...R,w:U})),D(R=>({...R,x:f-(U-o)}))},v=()=>{h(!1),window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",v)};window.addEventListener("mousemove",w),window.addEventListener("mouseup",v)},[n.w,d.x]);if(!T)return null;const c=g==="docked";return t.jsxs("div",{className:X("flex flex-col bg-white overflow-hidden relative",c?"h-full border-l border-gray-200 shrink-0":"rounded-2xl shadow-2xl border border-gray-200"),style:c?{width:L}:{position:"fixed",left:d.x,top:d.y,width:n.w,height:n.h,zIndex:9999},children:[c&&t.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:ee}),t.jsxs("div",{className:X("flex items-center justify-between px-4 py-2.5 bg-gray-50 border-b border-gray-200 shrink-0 select-none",!c&&"cursor-grab active:cursor-grabbing"),onMouseDown:c?void 0:Z,children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t.jsx(oe,{className:"w-4 h-4 text-primary shrink-0"}),t.jsx("span",{className:"text-sm font-semibold text-gray-900 truncate",children:i("docBrowserTitle")})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:$,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:c?i("docBrowserFloatMode"):i("docBrowserDockMode"),children:c?t.jsx(ae,{className:"w-3.5 h-3.5"}):t.jsx(ne,{className:"w-3.5 h-3.5"})}),t.jsx("button",{onClick:F,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:i("docBrowserClose"),children:t.jsx(W,{className:"w-3.5 h-3.5"})})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-2 bg-white border-b border-gray-100 overflow-x-auto custom-scrollbar",children:[A.map(e=>{const r=e.id===N;return t.jsxs("div",{className:X("inline-flex items-center gap-1 h-7 px-1.5 rounded-lg text-xs border max-w-[220px] shrink-0 transition-colors",r?"bg-blue-50 border-blue-300 text-blue-700":"bg-gray-50 border-gray-200 text-gray-600 hover:bg-gray-100"),children:[t.jsx("button",{type:"button",onClick:()=>V(e.id),className:"truncate text-left px-1",title:e.title,children:e.title||i("docBrowserTabUntitled")}),t.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),H(e.id)},className:"rounded p-0.5 hover:bg-black/10","aria-label":i("docBrowserCloseTab"),children:t.jsx(W,{className:"w-3 h-3"})})]},e.id)}),t.jsx("button",{onClick:()=>q(void 0,{kind:"docs",title:"Docs"}),className:"inline-flex items-center justify-center w-7 h-7 rounded-lg border border-gray-200 bg-white text-gray-600 hover:bg-gray-100 shrink-0",title:i("docBrowserNewTab"),children:t.jsx(ie,{className:"w-3.5 h-3.5"})})]}),a&&t.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0",children:[t.jsx("button",{onClick:I,disabled:!O,className:"p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors",children:t.jsx(le,{className:"w-4 h-4"})}),t.jsx("button",{onClick:_,disabled:!G,className:"p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors",children:t.jsx(ce,{className:"w-4 h-4"})}),t.jsxs("form",{onSubmit:Q,className:"flex-1 relative",children:[t.jsx(de,{className:"w-3.5 h-3.5 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),t.jsx("input",{type:"text",value:k,onChange:e=>j(e.target.value),placeholder:i("docBrowserSearchPlaceholder"),className:"w-full h-8 pl-8 pr-3 rounded-lg bg-gray-50 border border-gray-200 text-xs text-gray-700 focus:outline-none focus:ring-1 focus:ring-primary/30 focus:border-primary/40 transition-colors placeholder:text-gray-400"})]})]}),t.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[t.jsx("iframe",{ref:z,src:l,className:"absolute inset-0 w-full h-full border-0",title:(x==null?void 0:x.title)||"NextClaw Docs",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms",allow:"clipboard-read; clipboard-write"},`${N}:${p}`),(J||E)&&t.jsx("div",{className:"absolute inset-0 z-10"})]}),a&&xe(l)&&t.jsx("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-50 border-t border-gray-200 shrink-0",children:t.jsxs("a",{href:l,target:"_blank",rel:"noopener noreferrer","data-doc-external":!0,className:"flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover font-medium transition-colors",children:[i("docBrowserOpenExternal"),t.jsx(ue,{className:"w-3 h-3"})]})}),!c&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:te}),t.jsx("div",{className:"absolute top-0 right-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:M,"data-axis":"x"}),t.jsx("div",{className:"absolute bottom-0 left-0 h-1.5 w-full cursor-ns-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:M,"data-axis":"y"}),t.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-se-resize z-30 flex items-center justify-center text-gray-300 hover:text-gray-500 transition-colors",onMouseDown:M,children:t.jsx(me,{className:"w-3 h-3 rotate-[-45deg]"})})]})]})}export{pe as DocBrowser};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,r as d}from"./vendor-d7E8OgNx.js";import{c as a}from"./index-Dl6t70wA.js";const c={active:{dot:"bg-emerald-500",text:"text-emerald-600",bg:"bg-emerald-50"},ready:{dot:"bg-emerald-500",text:"text-emerald-600",bg:"bg-emerald-50"},inactive:{dot:"bg-gray-300",text:"text-gray-400",bg:"bg-gray-100/80"},setup:{dot:"bg-gray-300",text:"text-gray-400",bg:"bg-gray-100/80"},warning:{dot:"bg-amber-400",text:"text-amber-600",bg:"bg-amber-50"}};function b({status:s,label:r,className:n}){const t=c[s];return e.jsxs("div",{className:a("inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full px-2 py-0.5",t.bg,n),children:[e.jsx("span",{className:a("h-1.5 w-1.5 rounded-full",t.dot)}),e.jsx("span",{className:a("text-[11px] font-medium",t.text),children:r})]})}function p({name:s,src:r,className:n,imgClassName:t,fallback:o}){const[l,g]=d.useState(!1),i=!!r&&!l;return e.jsx("div",{className:a("inline-flex shrink-0 items-center justify-center overflow-hidden",n),children:i?e.jsx("img",{src:r,alt:`${s} logo`,className:a("block h-6 w-6 object-contain",t),onError:()=>g(!0),draggable:!1}):o??e.jsx("span",{className:"text-lg font-bold uppercase",children:s.slice(0,1)})})}export{p as L,b as S};
|