bailian-cli 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README_CN.md +11 -11
  2. package/dist/bailian.mjs +169 -168
  3. package/package.json +2 -2
package/dist/bailian.mjs CHANGED
@@ -1,180 +1,181 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import{createRequire as e}from"node:module";import{BailianError as t,CONSOLE_GATEWAY_NO_TOKEN_MESSAGE as n,DOCS_HOSTS as r,ExitCode as i,GLOBAL_OPTIONS as a,McpClient as o,appCompletionEndpoint as s,callConsoleGateway as c,chatEndpoint as l,clearApiKey as u,defineCommand as d,detectOutputFormat as f,flushTelemetry as p,formatOutput as m,generateFilename as h,generateToolSchema as g,getConfigDir as _,getConfigPath as v,imageEndpoint as y,imageSyncEndpoint as b,isInteractive as x,isLocalFile as S,loadConfig as C,maskToken as w,mcpWebSearchEndpoint as T,memoryAddEndpoint as E,memoryListEndpoint as ee,memoryNodeEndpoint as te,memorySearchEndpoint as ne,parseSSE as re,profileSchemaEndpoint as ie,readConfigFile as ae,request as oe,requestJson as D,resolveConsoleGatewayCredential as se,resolveCredential as O,resolveFileUrl as k,resolveOutputDir as ce,signRequest as le,speechRecognizeEndpoint as ue,speechSynthesizeEndpoint as de,stripUndefined as fe,taskEndpoint as pe,trackCommandExecution as me,trackingHeaders as he,uploadFile as ge,userProfileEndpoint as _e,videoGenerateEndpoint as ve,writeConfigFile as ye}from"bailian-cli-core";import{execFile as be}from"node:child_process";import{randomBytes as xe}from"node:crypto";import Se from"node:http";import Ce,{stdin as we,stdout as Te}from"node:process";import*as Ee from"node:readline";import De from"node:readline";import{WriteStream as Oe}from"node:tty";import{createWriteStream as ke,existsSync as Ae,mkdirSync as je,readFileSync as Me,unlinkSync as Ne,writeFileSync as Pe}from"fs";import{dirname as Fe,extname as Ie,join as Le}from"path";import{execSync as Re}from"child_process";import{access as ze,mkdir as Be,readFile as Ve}from"node:fs/promises";import{dirname as He,extname as Ue,join as We,resolve as Ge}from"node:path";import{homedir as Ke}from"os";var qe=Object.create,Je=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,Xe=Object.getOwnPropertyNames,Ze=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty,A=(e,t)=>()=>(e&&(t=e(e=0)),t),j=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),$e=(e,t)=>{let n={};for(var r in e)Je(n,r,{get:e[r],enumerable:!0});return t||Je(n,Symbol.toStringTag,{value:`Module`}),n},et=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Xe(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Qe.call(e,s)&&s!==n&&Je(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Ye(t,s))||r.enumerable});return e},tt=(e,t,n)=>(n=e==null?{}:qe(Ze(e)),et(t||!e||!e.__esModule?Je(n,`default`,{value:e,enumerable:!0}):n,e)),nt=e(import.meta.url);function rt(e){return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function it(e){let t=e.flag.match(/^--([a-z][a-z0-9-]*)/i);return t?rt(t[1]):null}function at(e){return e.type===`boolean`?!0:e.type===`string`||e.type===`number`||e.type===`array`?!1:!e.flag.includes(`<`)&&!e.flag.includes(`[`)}function ot(e){let t=new Set,n=new Set,r=new Set;for(let i of e){let e=it(i);e&&(at(i)?t.add(e):i.type===`number`?n.add(e):i.type===`array`&&r.add(e))}return{booleans:t,numbers:n,arrays:r}}function st(e,t=[]){let n=ot(t),r=[],i=0;for(;i<e.length;){let t=e[i];if(t===`--`)break;if(t.startsWith(`--`)){let r=t.indexOf(`=`),a=rt(r===-1?t.slice(2):t.slice(2,r));if(!n.booleans.has(a)&&r===-1){let t=e[i+1];t===void 0||t.startsWith(`-`)?i+=1:i+=2}else i+=1;continue}if(t.startsWith(`-`)){i++;continue}r.push(t),i++}return r}function ct(e,n){let r=ot(n),a={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},o=0;for(;o<e.length;){let n=e[o];if(n===`--help`||n===`-h`){a.help=!0,o++;continue}if(n===`--`)break;if(n.startsWith(`--`)){let s=n.indexOf(`=`),c,l;s===-1?c=n.slice(2):(c=n.slice(2,s),l=n.slice(s+1));let u=rt(c);if(r.booleans.has(u)){a[u]=!0,o++;continue}if(l===void 0&&(o++,l=e[o]),l===void 0)throw new t(`Flag --${c} requires a value.`,i.USAGE);if(r.arrays.has(u)){let e=a[u];e?e.push(l):a[u]=[l]}else if(r.numbers.has(u)){let e=Number(l);if(!Number.isFinite(e))throw new t(`Flag --${c} requires a finite number.`,i.USAGE);a[u]=e}else a[u]=l}o++}return a}var lt,ut,dt,ft=A((()=>{lt=`https://bailian.console.aliyun.com`,ut=`${lt}/cn-beijing`,dt=`${ut}/?tab=app#/api-key`}));function pt(){let e=process.stderr.isTTY;return{purple:e?`\x1B[38;2;147;51;234m`:``,dim:e?`\x1B[2m`:``,reset:e?`\x1B[0m`:``}}function mt(){let{purple:e,reset:t}=pt();process.stderr.write(`\n Welcome to ${e}Bailian${t} CLI!\n\n`),process.stderr.write(` Get started in 2 steps:
4
- `),process.stderr.write(` 1. Get your API Key: ${dt}\n`),process.stderr.write(` 2. Login: bl auth login --api-key <your-key>
3
+ import{createRequire as e}from"node:module";import{BailianError as t,CONSOLE_GATEWAY_NO_TOKEN_MESSAGE as n,DOCS_HOSTS as r,ExitCode as i,GLOBAL_OPTIONS as a,McpClient as o,appCompletionEndpoint as s,callConsoleGateway as c,chatEndpoint as l,clearApiKey as u,defineCommand as d,detectOutputFormat as f,flushTelemetry as p,formatOutput as m,generateFilename as h,generateToolSchema as g,getConfigDir as _,getConfigPath as v,imageEndpoint as y,imageSyncEndpoint as b,isInteractive as x,isLocalFile as S,loadConfig as C,maskToken as w,mcpWebSearchEndpoint as T,memoryAddEndpoint as E,memoryListEndpoint as ee,memoryNodeEndpoint as te,memorySearchEndpoint as ne,parseSSE as re,profileSchemaEndpoint as ie,readConfigFile as D,request as ae,requestJson as O,resolveConsoleGatewayCredential as oe,resolveCredential as k,resolveFileUrl as A,resolveOutputDir as se,signRequest as ce,speechRecognizeEndpoint as le,speechSynthesizeEndpoint as ue,stripUndefined as de,taskEndpoint as fe,trackCommandExecution as pe,trackingHeaders as me,uploadFile as he,userProfileEndpoint as ge,videoGenerateEndpoint as _e,writeConfigFile as ve}from"bailian-cli-core";import ye,{stdin as be,stdout as xe}from"node:process";import*as Se from"node:readline";import Ce from"node:readline";import{WriteStream as we}from"node:tty";import{execFile as Te}from"node:child_process";import{randomBytes as Ee}from"node:crypto";import De from"node:http";import{createWriteStream as Oe,existsSync as ke,mkdirSync as Ae,readFileSync as je,unlinkSync as Me,writeFileSync as Ne}from"fs";import{dirname as Pe,extname as Fe,join as Ie}from"path";import{execSync as Le}from"child_process";import{access as Re,mkdir as ze,readFile as Be}from"node:fs/promises";import{dirname as Ve,extname as He,join as Ue,resolve as We}from"node:path";import{homedir as Ge}from"os";var Ke=Object.create,qe=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Ye=Object.getOwnPropertyNames,Xe=Object.getPrototypeOf,Ze=Object.prototype.hasOwnProperty,j=(e,t)=>()=>(e&&(t=e(e=0)),t),M=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Qe=(e,t)=>{let n={};for(var r in e)qe(n,r,{get:e[r],enumerable:!0});return t||qe(n,Symbol.toStringTag,{value:`Module`}),n},$e=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Ye(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ze.call(e,s)&&s!==n&&qe(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Je(t,s))||r.enumerable});return e},et=(e,t,n)=>(n=e==null?{}:Ke(Xe(e)),$e(t||!e||!e.__esModule?qe(n,`default`,{value:e,enumerable:!0}):n,e)),tt=e(import.meta.url);function nt(e){return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function rt(e){let t=e.flag.match(/^--([a-z][a-z0-9-]*)/i);return t?nt(t[1]):null}function it(e){return e.type===`boolean`?!0:e.type===`string`||e.type===`number`||e.type===`array`?!1:!e.flag.includes(`<`)&&!e.flag.includes(`[`)}function at(e){let t=new Set,n=new Set,r=new Set;for(let i of e){let e=rt(i);e&&(it(i)?t.add(e):i.type===`number`?n.add(e):i.type===`array`&&r.add(e))}return{booleans:t,numbers:n,arrays:r}}function ot(e,t=[]){let n=at(t),r=[],i=0;for(;i<e.length;){let t=e[i];if(t===`--`)break;if(t.startsWith(`--`)){let r=t.indexOf(`=`),a=nt(r===-1?t.slice(2):t.slice(2,r));if(!n.booleans.has(a)&&r===-1){let t=e[i+1];t===void 0||t.startsWith(`-`)?i+=1:i+=2}else i+=1;continue}if(t.startsWith(`-`)){i++;continue}r.push(t),i++}return r}function st(e,n){let r=at(n),a={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},o=0;for(;o<e.length;){let n=e[o];if(n===`--help`||n===`-h`){a.help=!0,o++;continue}if(n===`--`)break;if(n.startsWith(`--`)){let s=n.indexOf(`=`),c,l;s===-1?c=n.slice(2):(c=n.slice(2,s),l=n.slice(s+1));let u=nt(c);if(r.booleans.has(u)){a[u]=!0,o++;continue}if(l===void 0&&(o++,l=e[o]),l===void 0)throw new t(`Flag --${c} requires a value.`,i.USAGE);if(r.arrays.has(u)){let e=a[u];e?e.push(l):a[u]=[l]}else if(r.numbers.has(u)){let e=Number(l);if(!Number.isFinite(e))throw new t(`Flag --${c} requires a finite number.`,i.USAGE);a[u]=e}else a[u]=l}o++}return a}var ct,lt,ut,dt=j((()=>{ct=`https://bailian.console.aliyun.com`,lt=`${ct}/cn-beijing`,ut=`${lt}/?tab=app#/api-key`}));function ft(){let e=process.stderr.isTTY;return{purple:e?`\x1B[38;2;147;51;234m`:``,dim:e?`\x1B[2m`:``,reset:e?`\x1B[0m`:``}}function pt(){let{purple:e,reset:t}=ft();process.stderr.write(`\n Welcome to ${e}Bailian${t} CLI!\n\n`),process.stderr.write(` Get started in 2 steps:
4
+ `),process.stderr.write(` 1. Get your API Key: ${ut}\n`),process.stderr.write(` 2. Login: bl auth login --api-key <your-key>
5
5
 
6
- `)}function ht(){let{dim:e,reset:t}=pt();process.stderr.write(`
6
+ `)}function mt(){let{dim:e,reset:t}=ft();process.stderr.write(`
7
7
  🎯 Try these with your AI coding assistant:
8
8
 
9
- `),gt.forEach((n,r)=>{process.stderr.write(`${e}${r+1}${t} ${n}\n`)}),process.stderr.write(`
10
- `)}var gt,_t=A((()=>{ft(),gt=[`帮我生成一套鸭舌帽的亚马逊电商主图(白底 + 场景图 + 模特上身图)`,`帮我生成一段 3 分钟的幽默相声音频`,`帮我生成一套小红帽故事绘本 PDF(含插图)`,`帮我分析这个视频的内容并写一篇小红书文案`]}));function M(e,t){process.stdout.write(m(e,t)+`
11
- `)}function N(e){process.stdout.write(e+`
12
- `)}var P=A((()=>{}));function vt(e){St=e}function yt(){return St}function bt(e){Ct=e}function xt(e=process.stderr){Ct&&St.length>0&&Ct(St,e)}var St,Ct,wt=A((()=>{St=[],Ct=null})),Tt=j(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),Et=j(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c}));function Dt({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}function Ot(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Rt,``)}function kt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function At(e,t={}){if(typeof e!=`string`||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=Ot(e),e.length===0))return 0;e=e.replace(Ut(),` `);let n=t.ambiguousIsNarrow?1:2,r=0;for(let t of e){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159||e>=768&&e<=879))switch(Vt.eastAsianWidth(t)){case`F`:case`W`:r+=2;break;case`A`:r+=n;break;default:r+=1}}return r}function jt(){let e=new Map;for(let[t,n]of Object.entries(I)){for(let[t,r]of Object.entries(n))I[t]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[t]=I[t],e.set(r[0],r[1]);Object.defineProperty(I,t,{value:n,enumerable:!1})}return Object.defineProperty(I,`codes`,{value:e,enumerable:!1}),I.color.close=`\x1B[39m`,I.bgColor.close=`\x1B[49m`,I.color.ansi=Gt(),I.color.ansi256=Kt(),I.color.ansi16m=qt(),I.bgColor.ansi=Gt(Wt),I.bgColor.ansi256=Kt(Wt),I.bgColor.ansi16m=qt(Wt),Object.defineProperties(I,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>I.rgbToAnsi256(...I.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>I.ansi256ToAnsi(I.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>I.ansi256ToAnsi(I.hexToAnsi256(e)),enumerable:!1}}),I}function Mt(e,t,n){return String(e).normalize().replace(/\r\n/g,`
9
+ `),ht.forEach((n,r)=>{process.stderr.write(`${e}${r+1}${t} ${n}\n`)}),process.stderr.write(`
10
+ `)}var ht,gt=j((()=>{dt(),ht=[`帮我生成一套鸭舌帽的亚马逊电商主图(白底 + 场景图 + 模特上身图)`,`帮我生成一段 3 分钟的幽默相声音频`,`帮我生成一套小红帽故事绘本 PDF(含插图)`,`帮我分析这个视频的内容并写一篇小红书文案`]}));function N(e,t){process.stdout.write(m(e,t)+`
11
+ `)}function P(e){process.stdout.write(e+`
12
+ `)}var F=j((()=>{}));function _t(e){xt=e}function vt(){return xt}function yt(e){St=e}function bt(e=process.stderr){St&&xt.length>0&&St(xt,e)}var xt,St,Ct=j((()=>{xt=[],St=null})),wt=M(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),Tt=M(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c}));function Et({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}function Dt(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Lt,``)}function Ot(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function kt(e,t={}){if(typeof e!=`string`||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=Dt(e),e.length===0))return 0;e=e.replace(Ht(),` `);let n=t.ambiguousIsNarrow?1:2,r=0;for(let t of e){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159||e>=768&&e<=879))switch(Bt.eastAsianWidth(t)){case`F`:case`W`:r+=2;break;case`A`:r+=n;break;default:r+=1}}return r}function At(){let e=new Map;for(let[t,n]of Object.entries(L)){for(let[t,r]of Object.entries(n))L[t]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[t]=L[t],e.set(r[0],r[1]);Object.defineProperty(L,t,{value:n,enumerable:!1})}return Object.defineProperty(L,`codes`,{value:e,enumerable:!1}),L.color.close=`\x1B[39m`,L.bgColor.close=`\x1B[49m`,L.color.ansi=Wt(),L.color.ansi256=Gt(),L.color.ansi16m=Kt(),L.bgColor.ansi=Wt(Ut),L.bgColor.ansi256=Gt(Ut),L.bgColor.ansi16m=Kt(Ut),Object.defineProperties(L,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>L.rgbToAnsi256(...L.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>L.ansi256ToAnsi(L.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>L.ansi256ToAnsi(L.hexToAnsi256(e)),enumerable:!1}}),L}function jt(e,t,n){return String(e).normalize().replace(/\r\n/g,`
13
13
  `).split(`
14
- `).map(e=>un(e,t,n)).join(`
15
- `)}function Nt(e,t){if(e===t)return;let n=e.split(`
14
+ `).map(e=>ln(e,t,n)).join(`
15
+ `)}function Mt(e,t){if(e===t)return;let n=e.split(`
16
16
  `),r=t.split(`
17
- `),i=[];for(let e=0;e<Math.max(n.length,r.length);e++)n[e]!==r[e]&&i.push(e);return i}function Pt(e){return e===pn}function Ft(e,t){e.isTTY&&e.setRawMode(t)}function It({input:e=we,output:t=Te,overwrite:n=!0,hideCursor:r=!0}={}){let i=Ee.createInterface({input:e,output:t,prompt:``,tabSize:1});Ee.emitKeypressEvents(e,i),e.isTTY&&e.setRawMode(!0);let a=(i,{name:o})=>{if(String(i)===``){r&&t.write(F.cursor.show),process.exit(0);return}if(!n)return;let s=o===`return`?0:-1,c=o===`return`?-1:0;Ee.moveCursor(t,s,c,()=>{Ee.clearLine(t,1,()=>{e.once(`keypress`,a)})})};return r&&t.write(F.cursor.hide),e.once(`keypress`,a),()=>{e.off(`keypress`,a),r&&t.write(F.cursor.show),e.isTTY&&!Hn&&e.setRawMode(!1),i.terminal=!1,i.close()}}var F,Lt,Rt,zt,Bt,Vt,Ht,Ut,Wt,Gt,Kt,qt,I,Jt,Yt,Xt,Zt,Qt,$t,en,tn,nn,rn,an,on,sn,cn,ln,un,dn,fn,L,pn,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Un=A((()=>{F=Tt(),Lt=tt(Et(),1),Rt=Dt(),zt={exports:{}},(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-+(u==2))if(o+u<=i)a+=l;else break;o+=u}return a}})(zt),Bt=zt.exports,Vt=kt(Bt),Ht=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},Ut=kt(Ht),Wt=10,Gt=(e=0)=>t=>`\x1B[${t+e}m`,Kt=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,qt=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,I={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Object.keys(I.modifier),Jt=Object.keys(I.color),Yt=Object.keys(I.bgColor),[...Jt,...Yt],Xt=jt(),Zt=new Set([`\x1B`,`›`]),Qt=39,$t=`\x07`,en=`[`,tn=`]`,nn=`m`,rn=`${tn}8;;`,an=e=>`${Zt.values().next().value}${en}${e}${nn}`,on=e=>`${Zt.values().next().value}${rn}${e}${$t}`,sn=e=>e.split(` `).map(e=>At(e)),cn=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=At(Ot(e[e.length-1]));for(let[t,s]of r.entries()){let c=At(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),Zt.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(rn)),i){a?s===$t&&(i=!1,a=!1):s===nn&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},ln=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(At(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},un=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=sn(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=At(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),cn(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){cn(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){cn(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>ln(e)));let c=[...s.join(`
18
- `)];for(let[e,t]of c.entries()){if(r+=t,Zt.has(t)){let{groups:t}=RegExp(`(?:\\${en}(?<code>\\d+)m|\\${rn}(?<uri>.*)${$t})`).exec(c.slice(e).join(``))||{groups:{}};if(t.code!==void 0){let e=Number.parseFloat(t.code);i=e===Qt?void 0:e}else t.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}let n=Xt.codes.get(Number(i));c[e+1]===`
19
- `?(a&&(r+=on(``)),i&&n&&(r+=an(n))):t===`
20
- `&&(i&&n&&(r+=an(i)),a&&(r+=on(a)))}return r},dn=Object.defineProperty,fn=(e,t,n)=>t in e?dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,L=(e,t,n)=>(fn(e,typeof t==`symbol`?t:t+``,n),n),pn=Symbol(`clack:cancel`),mn=new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`]]),hn=new Set([`up`,`down`,`left`,`right`,`space`,`enter`]),gn=class{constructor({render:e,input:t=we,output:n=Te,...r},i=!0){L(this,`input`),L(this,`output`),L(this,`rl`),L(this,`opts`),L(this,`_track`,!1),L(this,`_render`),L(this,`_cursor`,0),L(this,`state`,`initial`),L(this,`value`),L(this,`error`,``),L(this,`subscribers`,new Map),L(this,`_prevFrame`,``),this.opts=r,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=e.bind(this),this._track=i,this.input=t,this.output=n}prompt(){let e=new Oe(0);return e._write=(e,t,n)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,``),this._cursor=this.rl.cursor,this.emit(`value`,this.value)),n()},this.input.pipe(e),this.rl=De.createInterface({input:this.input,output:e,tabSize:2,prompt:``,escapeCodeTimeout:50}),De.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on(`keypress`,this.onKeypress),Ft(this.input,!0),this.output.on(`resize`,this.render),this.render(),new Promise((e,t)=>{this.once(`submit`,()=>{this.output.write(F.cursor.show),this.output.off(`resize`,this.render),Ft(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(F.cursor.show),this.output.off(`resize`,this.render),Ft(this.input,!1),e(pn)})})}on(e,t){let n=this.subscribers.get(e)??[];n.push({cb:t}),this.subscribers.set(e,n)}once(e,t){let n=this.subscribers.get(e)??[];n.push({cb:t,once:!0}),this.subscribers.set(e,n)}emit(e,...t){let n=this.subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}unsubscribe(){this.subscribers.clear()}onKeypress(e,t){if(this.state===`error`&&(this.state=`active`),t?.name&&!this._track&&mn.has(t.name)&&this.emit(`cursor`,mn.get(t.name)),t?.name&&hn.has(t.name)&&this.emit(`cursor`,t.name),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),e===` `&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit(`value`,this.opts.placeholder))),e&&this.emit(`key`,e.toLowerCase()),t?.name===`return`){if(this.opts.validate){let e=this.opts.validate(this.value);e&&(this.error=e,this.state=`error`,this.rl.write(this.value))}this.state!==`error`&&(this.state=`submit`)}e===``&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
21
- `),Ft(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=Mt(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
22
- `).length-1;this.output.write(F.cursor.move(-999,e*-1))}render(){let e=Mt(this._render(this)??``,process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(F.cursor.hide);else{let t=Nt(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let n=t[0];this.output.write(F.cursor.move(0,n)),this.output.write(F.erase.lines(1));let r=e.split(`
23
- `);this.output.write(r[n]),this._prevFrame=e,this.output.write(F.cursor.move(0,r.length-n-1));return}else if(t&&t?.length>1){let n=t[0];this.output.write(F.cursor.move(0,n)),this.output.write(F.erase.down());let r=e.split(`
17
+ `),i=[];for(let e=0;e<Math.max(n.length,r.length);e++)n[e]!==r[e]&&i.push(e);return i}function Nt(e){return e===fn}function Pt(e,t){e.isTTY&&e.setRawMode(t)}function Ft({input:e=be,output:t=xe,overwrite:n=!0,hideCursor:r=!0}={}){let i=Se.createInterface({input:e,output:t,prompt:``,tabSize:1});Se.emitKeypressEvents(e,i),e.isTTY&&e.setRawMode(!0);let a=(i,{name:o})=>{if(String(i)===``){r&&t.write(I.cursor.show),process.exit(0);return}if(!n)return;let s=o===`return`?0:-1,c=o===`return`?-1:0;Se.moveCursor(t,s,c,()=>{Se.clearLine(t,1,()=>{e.once(`keypress`,a)})})};return r&&t.write(I.cursor.hide),e.once(`keypress`,a),()=>{e.off(`keypress`,a),r&&t.write(I.cursor.show),e.isTTY&&!Vn&&e.setRawMode(!1),i.terminal=!1,i.close()}}var I,It,Lt,Rt,zt,Bt,Vt,Ht,Ut,Wt,Gt,Kt,L,qt,Jt,Yt,Xt,Zt,Qt,$t,en,tn,nn,rn,an,on,sn,cn,ln,un,dn,R,fn,pn,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn=j((()=>{I=wt(),It=et(Tt(),1),Lt=Et(),Rt={exports:{}},(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-+(u==2))if(o+u<=i)a+=l;else break;o+=u}return a}})(Rt),zt=Rt.exports,Bt=Ot(zt),Vt=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},Ht=Ot(Vt),Ut=10,Wt=(e=0)=>t=>`\x1B[${t+e}m`,Gt=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Kt=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,L={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Object.keys(L.modifier),qt=Object.keys(L.color),Jt=Object.keys(L.bgColor),[...qt,...Jt],Yt=At(),Xt=new Set([`\x1B`,`›`]),Zt=39,Qt=`\x07`,$t=`[`,en=`]`,tn=`m`,nn=`${en}8;;`,rn=e=>`${Xt.values().next().value}${$t}${e}${tn}`,an=e=>`${Xt.values().next().value}${nn}${e}${Qt}`,on=e=>e.split(` `).map(e=>kt(e)),sn=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=kt(Dt(e[e.length-1]));for(let[t,s]of r.entries()){let c=kt(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),Xt.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(nn)),i){a?s===Qt&&(i=!1,a=!1):s===tn&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},cn=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(kt(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},ln=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=on(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=kt(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),sn(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){sn(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){sn(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>cn(e)));let c=[...s.join(`
18
+ `)];for(let[e,t]of c.entries()){if(r+=t,Xt.has(t)){let{groups:t}=RegExp(`(?:\\${$t}(?<code>\\d+)m|\\${nn}(?<uri>.*)${Qt})`).exec(c.slice(e).join(``))||{groups:{}};if(t.code!==void 0){let e=Number.parseFloat(t.code);i=e===Zt?void 0:e}else t.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}let n=Yt.codes.get(Number(i));c[e+1]===`
19
+ `?(a&&(r+=an(``)),i&&n&&(r+=rn(n))):t===`
20
+ `&&(i&&n&&(r+=rn(i)),a&&(r+=an(a)))}return r},un=Object.defineProperty,dn=(e,t,n)=>t in e?un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,R=(e,t,n)=>(dn(e,typeof t==`symbol`?t:t+``,n),n),fn=Symbol(`clack:cancel`),pn=new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`]]),mn=new Set([`up`,`down`,`left`,`right`,`space`,`enter`]),hn=class{constructor({render:e,input:t=be,output:n=xe,...r},i=!0){R(this,`input`),R(this,`output`),R(this,`rl`),R(this,`opts`),R(this,`_track`,!1),R(this,`_render`),R(this,`_cursor`,0),R(this,`state`,`initial`),R(this,`value`),R(this,`error`,``),R(this,`subscribers`,new Map),R(this,`_prevFrame`,``),this.opts=r,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=e.bind(this),this._track=i,this.input=t,this.output=n}prompt(){let e=new we(0);return e._write=(e,t,n)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,``),this._cursor=this.rl.cursor,this.emit(`value`,this.value)),n()},this.input.pipe(e),this.rl=Ce.createInterface({input:this.input,output:e,tabSize:2,prompt:``,escapeCodeTimeout:50}),Ce.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on(`keypress`,this.onKeypress),Pt(this.input,!0),this.output.on(`resize`,this.render),this.render(),new Promise((e,t)=>{this.once(`submit`,()=>{this.output.write(I.cursor.show),this.output.off(`resize`,this.render),Pt(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(I.cursor.show),this.output.off(`resize`,this.render),Pt(this.input,!1),e(fn)})})}on(e,t){let n=this.subscribers.get(e)??[];n.push({cb:t}),this.subscribers.set(e,n)}once(e,t){let n=this.subscribers.get(e)??[];n.push({cb:t,once:!0}),this.subscribers.set(e,n)}emit(e,...t){let n=this.subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}unsubscribe(){this.subscribers.clear()}onKeypress(e,t){if(this.state===`error`&&(this.state=`active`),t?.name&&!this._track&&pn.has(t.name)&&this.emit(`cursor`,pn.get(t.name)),t?.name&&mn.has(t.name)&&this.emit(`cursor`,t.name),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),e===` `&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit(`value`,this.opts.placeholder))),e&&this.emit(`key`,e.toLowerCase()),t?.name===`return`){if(this.opts.validate){let e=this.opts.validate(this.value);e&&(this.error=e,this.state=`error`,this.rl.write(this.value))}this.state!==`error`&&(this.state=`submit`)}e===``&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
21
+ `),Pt(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=jt(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
22
+ `).length-1;this.output.write(I.cursor.move(-999,e*-1))}render(){let e=jt(this._render(this)??``,process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(I.cursor.hide);else{let t=Mt(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let n=t[0];this.output.write(I.cursor.move(0,n)),this.output.write(I.erase.lines(1));let r=e.split(`
23
+ `);this.output.write(r[n]),this._prevFrame=e,this.output.write(I.cursor.move(0,r.length-n-1));return}else if(t&&t?.length>1){let n=t[0];this.output.write(I.cursor.move(0,n)),this.output.write(I.erase.down());let r=e.split(`
24
24
  `).slice(n);this.output.write(r.join(`
25
- `)),this._prevFrame=e;return}this.output.write(F.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},_n=class extends gn{get cursor(){return+!this.value}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`value`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(F.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}},vn=Object.defineProperty,yn=(e,t,n)=>t in e?vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bn=(e,t,n)=>(yn(e,typeof t==`symbol`?t:t+``,n),n),xn=class extends gn{constructor(e){super(e,!1),bn(this,`options`),bn(this,`cursor`,0);let{options:t}=e;this.options=Object.entries(t).flatMap(([e,t])=>[{value:e,group:!0,label:e},...t.map(t=>({...t,group:e}))]),this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case`space`:this.toggleValue();break}})}getGroupItems(e){return this.options.filter(t=>t.group===e)}isGroupSelected(e){return this.getGroupItems(e).every(e=>this.value.includes(e.value))}toggleValue(){let e=this.options[this.cursor];if(e.group===!0){let t=e.value,n=this.getGroupItems(t);this.isGroupSelected(t)?this.value=this.value.filter(e=>n.findIndex(t=>t.value===e)===-1):this.value=[...this.value,...n.map(e=>e.value)],this.value=Array.from(new Set(this.value))}else{let t=this.value.includes(e.value);this.value=t?this.value.filter(t=>t!==e.value):[...this.value,e.value]}}},Sn=Object.defineProperty,Cn=(e,t,n)=>t in e?Sn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wn=(e,t,n)=>(Cn(e,typeof t==`symbol`?t:t+``,n),n),Tn=class extends gn{constructor(e){super(e,!1),wn(this,`options`),wn(this,`cursor`,0),this.options=e.options,this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on(`key`,e=>{e===`a`&&this.toggleAll()}),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case`space`:this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let e=this.value.length===this.options.length;this.value=e?[]:this.options.map(e=>e.value)}toggleValue(){let e=this.value.includes(this._value);this.value=e?this.value.filter(e=>e!==this._value):[...this.value,this._value]}},En=Object.defineProperty,Dn=(e,t,n)=>t in e?En(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,On=(e,t,n)=>(Dn(e,typeof t==`symbol`?t:t+``,n),n),kn=class extends gn{constructor({mask:e,...t}){super(t),On(this,`valueWithCursor`,``),On(this,`_mask`,`•`),this._mask=e??`•`,this.on(`finalize`,()=>{this.valueWithCursor=this.masked}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${Lt.default.inverse(Lt.default.hidden(`_`))}`;else{let e=this.masked.slice(0,this.cursor),t=this.masked.slice(this.cursor);this.valueWithCursor=`${e}${Lt.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}},An=Object.defineProperty,jn=(e,t,n)=>t in e?An(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Mn=(e,t,n)=>(jn(e,typeof t==`symbol`?t:t+``,n),n),Nn=class extends gn{constructor(e){super(e,!1),Mn(this,`options`),Mn(this,`cursor`,0),this.options=e.options,this.cursor=this.options.findIndex(({value:t})=>t===e.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}},Pn=Object.defineProperty,Fn=(e,t,n)=>t in e?Pn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,In=(e,t,n)=>(Fn(e,typeof t==`symbol`?t:t+``,n),n),Ln=class extends gn{constructor(e){super(e,!1),In(this,`options`),In(this,`cursor`,0),this.options=e.options;let t=this.options.map(({value:[e]})=>e?.toLowerCase());this.cursor=Math.max(t.indexOf(e.initialValue),0),this.on(`key`,e=>{if(!t.includes(e))return;let n=this.options.find(({value:[t]})=>t?.toLowerCase()===e);n&&(this.value=n.value,this.state=`submit`,this.emit(`submit`))})}},Rn=Object.defineProperty,zn=(e,t,n)=>t in e?Rn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bn=(e,t,n)=>(zn(e,typeof t==`symbol`?t:t+``,n),n),Vn=class extends gn{constructor(e){super(e),Bn(this,`valueWithCursor`,``),this.on(`finalize`,()=>{this.value||=e.defaultValue,this.valueWithCursor=this.value}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${Lt.default.inverse(Lt.default.hidden(`_`))}`;else{let e=this.value.slice(0,this.cursor),t=this.value.slice(this.cursor);this.valueWithCursor=`${e}${Lt.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}},Hn=globalThis.process.platform.startsWith(`win`)})),Wn=$e({cancel:()=>wr,confirm:()=>_r,group:()=>kr,groupMultiselect:()=>xr,intro:()=>Tr,isCancel:()=>Pt,log:()=>Dr,multiselect:()=>br,note:()=>Cr,outro:()=>Er,password:()=>gr,select:()=>vr,selectKey:()=>yr,spinner:()=>Or,text:()=>hr});function Gn(){return Ce.platform===`win32`?!!Ce.env.CI||!!Ce.env.WT_SESSION||!!Ce.env.TERMINUS_SUBLIME||Ce.env.ConEmuTask===`{cmd::Cmder}`||Ce.env.TERM_PROGRAM===`Terminus-Sublime`||Ce.env.TERM_PROGRAM===`vscode`||Ce.env.TERM===`xterm-256color`||Ce.env.TERM===`alacritty`||Ce.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:Ce.env.TERM!==`linux`}function Kn(){let e=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(e,`g`)}var R,qn,Jn,z,Yn,Xn,Zn,Qn,$n,B,V,er,tr,nr,rr,ir,ar,or,sr,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar=A((()=>{Un(),R=tt(Et(),1),qn=Tt(),Jn=Gn(),z=(e,t)=>Jn?e:t,Yn=z(`◆`,`*`),Xn=z(`■`,`x`),Zn=z(`▲`,`x`),Qn=z(`◇`,`o`),$n=z(`┌`,`T`),B=z(`│`,`|`),V=z(`└`,`—`),er=z(`●`,`>`),tr=z(`○`,` `),nr=z(`◻`,`[•]`),rr=z(`◼`,`[+]`),ir=z(`◻`,`[ ]`),ar=z(`▪`,`•`),or=z(`─`,`-`),sr=z(`╮`,`+`),cr=z(`├`,`+`),lr=z(`╯`,`+`),ur=z(`●`,`•`),dr=z(`◆`,`*`),fr=z(`▲`,`!`),pr=z(`■`,`x`),mr=e=>{switch(e){case`initial`:case`active`:return R.default.cyan(Yn);case`cancel`:return R.default.red(Xn);case`error`:return R.default.yellow(Zn);case`submit`:return R.default.green(Qn)}},hr=e=>new Vn({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){let t=`${R.default.gray(B)}
26
- ${mr(this.state)} ${e.message}
27
- `,n=e.placeholder?R.default.inverse(e.placeholder[0])+R.default.dim(e.placeholder.slice(1)):R.default.inverse(R.default.hidden(`_`)),r=this.value?this.valueWithCursor:n;switch(this.state){case`error`:return`${t.trim()}
28
- ${R.default.yellow(B)} ${r}
29
- ${R.default.yellow(V)} ${R.default.yellow(this.error)}
30
- `;case`submit`:return`${t}${R.default.gray(B)} ${R.default.dim(this.value||e.placeholder)}`;case`cancel`:return`${t}${R.default.gray(B)} ${R.default.strikethrough(R.default.dim(this.value??``))}${this.value?.trim()?`
31
- `+R.default.gray(B):``}`;default:return`${t}${R.default.cyan(B)} ${r}
32
- ${R.default.cyan(V)}
33
- `}}}).prompt(),gr=e=>new kn({validate:e.validate,mask:e.mask??ar,render(){let t=`${R.default.gray(B)}
34
- ${mr(this.state)} ${e.message}
25
+ `)),this._prevFrame=e;return}this.output.write(I.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},gn=class extends hn{get cursor(){return+!this.value}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`value`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(I.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}},_n=Object.defineProperty,vn=(e,t,n)=>t in e?_n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yn=(e,t,n)=>(vn(e,typeof t==`symbol`?t:t+``,n),n),bn=class extends hn{constructor(e){super(e,!1),yn(this,`options`),yn(this,`cursor`,0);let{options:t}=e;this.options=Object.entries(t).flatMap(([e,t])=>[{value:e,group:!0,label:e},...t.map(t=>({...t,group:e}))]),this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case`space`:this.toggleValue();break}})}getGroupItems(e){return this.options.filter(t=>t.group===e)}isGroupSelected(e){return this.getGroupItems(e).every(e=>this.value.includes(e.value))}toggleValue(){let e=this.options[this.cursor];if(e.group===!0){let t=e.value,n=this.getGroupItems(t);this.isGroupSelected(t)?this.value=this.value.filter(e=>n.findIndex(t=>t.value===e)===-1):this.value=[...this.value,...n.map(e=>e.value)],this.value=Array.from(new Set(this.value))}else{let t=this.value.includes(e.value);this.value=t?this.value.filter(t=>t!==e.value):[...this.value,e.value]}}},xn=Object.defineProperty,Sn=(e,t,n)=>t in e?xn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Cn=(e,t,n)=>(Sn(e,typeof t==`symbol`?t:t+``,n),n),wn=class extends hn{constructor(e){super(e,!1),Cn(this,`options`),Cn(this,`cursor`,0),this.options=e.options,this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on(`key`,e=>{e===`a`&&this.toggleAll()}),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case`space`:this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let e=this.value.length===this.options.length;this.value=e?[]:this.options.map(e=>e.value)}toggleValue(){let e=this.value.includes(this._value);this.value=e?this.value.filter(e=>e!==this._value):[...this.value,this._value]}},Tn=Object.defineProperty,En=(e,t,n)=>t in e?Tn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Dn=(e,t,n)=>(En(e,typeof t==`symbol`?t:t+``,n),n),On=class extends hn{constructor({mask:e,...t}){super(t),Dn(this,`valueWithCursor`,``),Dn(this,`_mask`,`•`),this._mask=e??`•`,this.on(`finalize`,()=>{this.valueWithCursor=this.masked}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${It.default.inverse(It.default.hidden(`_`))}`;else{let e=this.masked.slice(0,this.cursor),t=this.masked.slice(this.cursor);this.valueWithCursor=`${e}${It.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}},kn=Object.defineProperty,An=(e,t,n)=>t in e?kn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jn=(e,t,n)=>(An(e,typeof t==`symbol`?t:t+``,n),n),Mn=class extends hn{constructor(e){super(e,!1),jn(this,`options`),jn(this,`cursor`,0),this.options=e.options,this.cursor=this.options.findIndex(({value:t})=>t===e.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}},Nn=Object.defineProperty,Pn=(e,t,n)=>t in e?Nn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fn=(e,t,n)=>(Pn(e,typeof t==`symbol`?t:t+``,n),n),In=class extends hn{constructor(e){super(e,!1),Fn(this,`options`),Fn(this,`cursor`,0),this.options=e.options;let t=this.options.map(({value:[e]})=>e?.toLowerCase());this.cursor=Math.max(t.indexOf(e.initialValue),0),this.on(`key`,e=>{if(!t.includes(e))return;let n=this.options.find(({value:[t]})=>t?.toLowerCase()===e);n&&(this.value=n.value,this.state=`submit`,this.emit(`submit`))})}},Ln=Object.defineProperty,Rn=(e,t,n)=>t in e?Ln(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,zn=(e,t,n)=>(Rn(e,typeof t==`symbol`?t:t+``,n),n),Bn=class extends hn{constructor(e){super(e),zn(this,`valueWithCursor`,``),this.on(`finalize`,()=>{this.value||=e.defaultValue,this.valueWithCursor=this.value}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${It.default.inverse(It.default.hidden(`_`))}`;else{let e=this.value.slice(0,this.cursor),t=this.value.slice(this.cursor);this.valueWithCursor=`${e}${It.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}},Vn=globalThis.process.platform.startsWith(`win`)})),Un=Qe({cancel:()=>Cr,confirm:()=>gr,group:()=>Or,groupMultiselect:()=>br,intro:()=>wr,isCancel:()=>Nt,log:()=>Er,multiselect:()=>yr,note:()=>Sr,outro:()=>Tr,password:()=>hr,select:()=>_r,selectKey:()=>vr,spinner:()=>Dr,text:()=>mr});function Wn(){return ye.platform===`win32`?!!ye.env.CI||!!ye.env.WT_SESSION||!!ye.env.TERMINUS_SUBLIME||ye.env.ConEmuTask===`{cmd::Cmder}`||ye.env.TERM_PROGRAM===`Terminus-Sublime`||ye.env.TERM_PROGRAM===`vscode`||ye.env.TERM===`xterm-256color`||ye.env.TERM===`alacritty`||ye.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:ye.env.TERM!==`linux`}function Gn(){let e=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(e,`g`)}var z,Kn,qn,B,Jn,Yn,Xn,Zn,Qn,V,H,$n,er,tr,nr,rr,ir,ar,or,sr,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr=j((()=>{Hn(),z=et(Tt(),1),Kn=wt(),qn=Wn(),B=(e,t)=>qn?e:t,Jn=B(`◆`,`*`),Yn=B(`■`,`x`),Xn=B(`▲`,`x`),Zn=B(`◇`,`o`),Qn=B(`┌`,`T`),V=B(`│`,`|`),H=B(`└`,`—`),$n=B(`●`,`>`),er=B(`○`,` `),tr=B(`◻`,`[•]`),nr=B(`◼`,`[+]`),rr=B(`◻`,`[ ]`),ir=B(`▪`,`•`),ar=B(`─`,`-`),or=B(`╮`,`+`),sr=B(`├`,`+`),cr=B(`╯`,`+`),lr=B(`●`,`•`),ur=B(`◆`,`*`),dr=B(`▲`,`!`),fr=B(`■`,`x`),pr=e=>{switch(e){case`initial`:case`active`:return z.default.cyan(Jn);case`cancel`:return z.default.red(Yn);case`error`:return z.default.yellow(Xn);case`submit`:return z.default.green(Zn)}},mr=e=>new Bn({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){let t=`${z.default.gray(V)}
26
+ ${pr(this.state)} ${e.message}
27
+ `,n=e.placeholder?z.default.inverse(e.placeholder[0])+z.default.dim(e.placeholder.slice(1)):z.default.inverse(z.default.hidden(`_`)),r=this.value?this.valueWithCursor:n;switch(this.state){case`error`:return`${t.trim()}
28
+ ${z.default.yellow(V)} ${r}
29
+ ${z.default.yellow(H)} ${z.default.yellow(this.error)}
30
+ `;case`submit`:return`${t}${z.default.gray(V)} ${z.default.dim(this.value||e.placeholder)}`;case`cancel`:return`${t}${z.default.gray(V)} ${z.default.strikethrough(z.default.dim(this.value??``))}${this.value?.trim()?`
31
+ `+z.default.gray(V):``}`;default:return`${t}${z.default.cyan(V)} ${r}
32
+ ${z.default.cyan(H)}
33
+ `}}}).prompt(),hr=e=>new On({validate:e.validate,mask:e.mask??ir,render(){let t=`${z.default.gray(V)}
34
+ ${pr(this.state)} ${e.message}
35
35
  `,n=this.valueWithCursor,r=this.masked;switch(this.state){case`error`:return`${t.trim()}
36
- ${R.default.yellow(B)} ${r}
37
- ${R.default.yellow(V)} ${R.default.yellow(this.error)}
38
- `;case`submit`:return`${t}${R.default.gray(B)} ${R.default.dim(r)}`;case`cancel`:return`${t}${R.default.gray(B)} ${R.default.strikethrough(R.default.dim(r??``))}${r?`
39
- `+R.default.gray(B):``}`;default:return`${t}${R.default.cyan(B)} ${n}
40
- ${R.default.cyan(V)}
41
- `}}}).prompt(),_r=e=>{let t=e.active??`Yes`,n=e.inactive??`No`;return new _n({active:t,inactive:n,initialValue:e.initialValue??!0,render(){let r=`${R.default.gray(B)}
42
- ${mr(this.state)} ${e.message}
43
- `,i=this.value?t:n;switch(this.state){case`submit`:return`${r}${R.default.gray(B)} ${R.default.dim(i)}`;case`cancel`:return`${r}${R.default.gray(B)} ${R.default.strikethrough(R.default.dim(i))}
44
- ${R.default.gray(B)}`;default:return`${r}${R.default.cyan(B)} ${this.value?`${R.default.green(er)} ${t}`:`${R.default.dim(tr)} ${R.default.dim(t)}`} ${R.default.dim(`/`)} ${this.value?`${R.default.dim(tr)} ${R.default.dim(n)}`:`${R.default.green(er)} ${n}`}
45
- ${R.default.cyan(V)}
46
- `}}}).prompt()},vr=e=>{let t=(e,t)=>{let n=e.label??String(e.value);return t===`active`?`${R.default.green(er)} ${n} ${e.hint?R.default.dim(`(${e.hint})`):``}`:t===`selected`?`${R.default.dim(n)}`:t===`cancelled`?`${R.default.strikethrough(R.default.dim(n))}`:`${R.default.dim(tr)} ${R.default.dim(n)}`},n=0;return new Nn({options:e.options,initialValue:e.initialValue,render(){let r=`${R.default.gray(B)}
47
- ${mr(this.state)} ${e.message}
48
- `;switch(this.state){case`submit`:return`${r}${R.default.gray(B)} ${t(this.options[this.cursor],`selected`)}`;case`cancel`:return`${r}${R.default.gray(B)} ${t(this.options[this.cursor],`cancelled`)}
49
- ${R.default.gray(B)}`;default:{let i=e.maxItems===void 0?1/0:Math.max(e.maxItems,5);this.cursor>=n+i-3?n=Math.max(Math.min(this.cursor-i+3,this.options.length-i),0):this.cursor<n+2&&(n=Math.max(this.cursor-2,0));let a=i<this.options.length&&n>0,o=i<this.options.length&&n+i<this.options.length;return`${r}${R.default.cyan(B)} ${this.options.slice(n,n+i).map((e,r,i)=>r===0&&a||r===i.length-1&&o?R.default.dim(`...`):t(e,r+n===this.cursor?`active`:`inactive`)).join(`
50
- ${R.default.cyan(B)} `)}
51
- ${R.default.cyan(V)}
52
- `}}}}).prompt()},yr=e=>{let t=(e,t=`inactive`)=>{let n=e.label??String(e.value);return t===`selected`?`${R.default.dim(n)}`:t===`cancelled`?`${R.default.strikethrough(R.default.dim(n))}`:t===`active`?`${R.default.bgCyan(R.default.gray(` ${e.value} `))} ${n} ${e.hint?R.default.dim(`(${e.hint})`):``}`:`${R.default.gray(R.default.bgWhite(R.default.inverse(` ${e.value} `)))} ${n} ${e.hint?R.default.dim(`(${e.hint})`):``}`};return new Ln({options:e.options,initialValue:e.initialValue,render(){let n=`${R.default.gray(B)}
53
- ${mr(this.state)} ${e.message}
54
- `;switch(this.state){case`submit`:return`${n}${R.default.gray(B)} ${t(this.options.find(e=>e.value===this.value),`selected`)}`;case`cancel`:return`${n}${R.default.gray(B)} ${t(this.options[0],`cancelled`)}
55
- ${R.default.gray(B)}`;default:return`${n}${R.default.cyan(B)} ${this.options.map((e,n)=>t(e,n===this.cursor?`active`:`inactive`)).join(`
56
- ${R.default.cyan(B)} `)}
57
- ${R.default.cyan(V)}
58
- `}}}).prompt()},br=e=>{let t=(e,t)=>{let n=e.label??String(e.value);return t===`active`?`${R.default.cyan(nr)} ${n} ${e.hint?R.default.dim(`(${e.hint})`):``}`:t===`selected`?`${R.default.green(rr)} ${R.default.dim(n)}`:t===`cancelled`?`${R.default.strikethrough(R.default.dim(n))}`:t===`active-selected`?`${R.default.green(rr)} ${n} ${e.hint?R.default.dim(`(${e.hint})`):``}`:t===`submitted`?`${R.default.dim(n)}`:`${R.default.dim(ir)} ${R.default.dim(n)}`};return new Tn({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
59
- ${R.default.reset(R.default.dim(`Press ${R.default.gray(R.default.bgWhite(R.default.inverse(` space `)))} to select, ${R.default.gray(R.default.bgWhite(R.default.inverse(` enter `)))} to submit`))}`},render(){let n=`${R.default.gray(B)}
60
- ${mr(this.state)} ${e.message}
61
- `;switch(this.state){case`submit`:return`${n}${R.default.gray(B)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`submitted`)).join(R.default.dim(`, `))||R.default.dim(`none`)}`;case`cancel`:{let e=this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`cancelled`)).join(R.default.dim(`, `));return`${n}${R.default.gray(B)} ${e.trim()?`${e}
62
- ${R.default.gray(B)}`:``}`}case`error`:{let e=this.error.split(`
63
- `).map((e,t)=>t===0?`${R.default.yellow(V)} ${R.default.yellow(e)}`:` ${e}`).join(`
64
- `);return n+R.default.yellow(B)+` `+this.options.map((e,n)=>{let r=this.value.includes(e.value),i=n===this.cursor;return i&&r?t(e,`active-selected`):r?t(e,`selected`):t(e,i?`active`:`inactive`)}).join(`
65
- ${R.default.yellow(B)} `)+`
36
+ ${z.default.yellow(V)} ${r}
37
+ ${z.default.yellow(H)} ${z.default.yellow(this.error)}
38
+ `;case`submit`:return`${t}${z.default.gray(V)} ${z.default.dim(r)}`;case`cancel`:return`${t}${z.default.gray(V)} ${z.default.strikethrough(z.default.dim(r??``))}${r?`
39
+ `+z.default.gray(V):``}`;default:return`${t}${z.default.cyan(V)} ${n}
40
+ ${z.default.cyan(H)}
41
+ `}}}).prompt(),gr=e=>{let t=e.active??`Yes`,n=e.inactive??`No`;return new gn({active:t,inactive:n,initialValue:e.initialValue??!0,render(){let r=`${z.default.gray(V)}
42
+ ${pr(this.state)} ${e.message}
43
+ `,i=this.value?t:n;switch(this.state){case`submit`:return`${r}${z.default.gray(V)} ${z.default.dim(i)}`;case`cancel`:return`${r}${z.default.gray(V)} ${z.default.strikethrough(z.default.dim(i))}
44
+ ${z.default.gray(V)}`;default:return`${r}${z.default.cyan(V)} ${this.value?`${z.default.green($n)} ${t}`:`${z.default.dim(er)} ${z.default.dim(t)}`} ${z.default.dim(`/`)} ${this.value?`${z.default.dim(er)} ${z.default.dim(n)}`:`${z.default.green($n)} ${n}`}
45
+ ${z.default.cyan(H)}
46
+ `}}}).prompt()},_r=e=>{let t=(e,t)=>{let n=e.label??String(e.value);return t===`active`?`${z.default.green($n)} ${n} ${e.hint?z.default.dim(`(${e.hint})`):``}`:t===`selected`?`${z.default.dim(n)}`:t===`cancelled`?`${z.default.strikethrough(z.default.dim(n))}`:`${z.default.dim(er)} ${z.default.dim(n)}`},n=0;return new Mn({options:e.options,initialValue:e.initialValue,render(){let r=`${z.default.gray(V)}
47
+ ${pr(this.state)} ${e.message}
48
+ `;switch(this.state){case`submit`:return`${r}${z.default.gray(V)} ${t(this.options[this.cursor],`selected`)}`;case`cancel`:return`${r}${z.default.gray(V)} ${t(this.options[this.cursor],`cancelled`)}
49
+ ${z.default.gray(V)}`;default:{let i=e.maxItems===void 0?1/0:Math.max(e.maxItems,5);this.cursor>=n+i-3?n=Math.max(Math.min(this.cursor-i+3,this.options.length-i),0):this.cursor<n+2&&(n=Math.max(this.cursor-2,0));let a=i<this.options.length&&n>0,o=i<this.options.length&&n+i<this.options.length;return`${r}${z.default.cyan(V)} ${this.options.slice(n,n+i).map((e,r,i)=>r===0&&a||r===i.length-1&&o?z.default.dim(`...`):t(e,r+n===this.cursor?`active`:`inactive`)).join(`
50
+ ${z.default.cyan(V)} `)}
51
+ ${z.default.cyan(H)}
52
+ `}}}}).prompt()},vr=e=>{let t=(e,t=`inactive`)=>{let n=e.label??String(e.value);return t===`selected`?`${z.default.dim(n)}`:t===`cancelled`?`${z.default.strikethrough(z.default.dim(n))}`:t===`active`?`${z.default.bgCyan(z.default.gray(` ${e.value} `))} ${n} ${e.hint?z.default.dim(`(${e.hint})`):``}`:`${z.default.gray(z.default.bgWhite(z.default.inverse(` ${e.value} `)))} ${n} ${e.hint?z.default.dim(`(${e.hint})`):``}`};return new In({options:e.options,initialValue:e.initialValue,render(){let n=`${z.default.gray(V)}
53
+ ${pr(this.state)} ${e.message}
54
+ `;switch(this.state){case`submit`:return`${n}${z.default.gray(V)} ${t(this.options.find(e=>e.value===this.value),`selected`)}`;case`cancel`:return`${n}${z.default.gray(V)} ${t(this.options[0],`cancelled`)}
55
+ ${z.default.gray(V)}`;default:return`${n}${z.default.cyan(V)} ${this.options.map((e,n)=>t(e,n===this.cursor?`active`:`inactive`)).join(`
56
+ ${z.default.cyan(V)} `)}
57
+ ${z.default.cyan(H)}
58
+ `}}}).prompt()},yr=e=>{let t=(e,t)=>{let n=e.label??String(e.value);return t===`active`?`${z.default.cyan(tr)} ${n} ${e.hint?z.default.dim(`(${e.hint})`):``}`:t===`selected`?`${z.default.green(nr)} ${z.default.dim(n)}`:t===`cancelled`?`${z.default.strikethrough(z.default.dim(n))}`:t===`active-selected`?`${z.default.green(nr)} ${n} ${e.hint?z.default.dim(`(${e.hint})`):``}`:t===`submitted`?`${z.default.dim(n)}`:`${z.default.dim(rr)} ${z.default.dim(n)}`};return new wn({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
59
+ ${z.default.reset(z.default.dim(`Press ${z.default.gray(z.default.bgWhite(z.default.inverse(` space `)))} to select, ${z.default.gray(z.default.bgWhite(z.default.inverse(` enter `)))} to submit`))}`},render(){let n=`${z.default.gray(V)}
60
+ ${pr(this.state)} ${e.message}
61
+ `;switch(this.state){case`submit`:return`${n}${z.default.gray(V)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`submitted`)).join(z.default.dim(`, `))||z.default.dim(`none`)}`;case`cancel`:{let e=this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`cancelled`)).join(z.default.dim(`, `));return`${n}${z.default.gray(V)} ${e.trim()?`${e}
62
+ ${z.default.gray(V)}`:``}`}case`error`:{let e=this.error.split(`
63
+ `).map((e,t)=>t===0?`${z.default.yellow(H)} ${z.default.yellow(e)}`:` ${e}`).join(`
64
+ `);return n+z.default.yellow(V)+` `+this.options.map((e,n)=>{let r=this.value.includes(e.value),i=n===this.cursor;return i&&r?t(e,`active-selected`):r?t(e,`selected`):t(e,i?`active`:`inactive`)}).join(`
65
+ ${z.default.yellow(V)} `)+`
66
66
  `+e+`
67
- `}default:return`${n}${R.default.cyan(B)} ${this.options.map((e,n)=>{let r=this.value.includes(e.value),i=n===this.cursor;return i&&r?t(e,`active-selected`):r?t(e,`selected`):t(e,i?`active`:`inactive`)}).join(`
68
- ${R.default.cyan(B)} `)}
69
- ${R.default.cyan(V)}
70
- `}}}).prompt()},xr=e=>{let t=(e,t,n=[])=>{let r=e.label??String(e.value),i=typeof e.group==`string`,a=i&&(n[n.indexOf(e)+1]??{group:!0}),o=i&&a.group===!0,s=i?`${o?V:B} `:``;return t===`active`?`${R.default.dim(s)}${R.default.cyan(nr)} ${r} ${e.hint?R.default.dim(`(${e.hint})`):``}`:t===`group-active`?`${s}${R.default.cyan(nr)} ${R.default.dim(r)}`:t===`group-active-selected`?`${s}${R.default.green(rr)} ${R.default.dim(r)}`:t===`selected`?`${R.default.dim(s)}${R.default.green(rr)} ${R.default.dim(r)}`:t===`cancelled`?`${R.default.strikethrough(R.default.dim(r))}`:t===`active-selected`?`${R.default.dim(s)}${R.default.green(rr)} ${r} ${e.hint?R.default.dim(`(${e.hint})`):``}`:t===`submitted`?`${R.default.dim(r)}`:`${R.default.dim(s)}${R.default.dim(ir)} ${R.default.dim(r)}`};return new xn({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
71
- ${R.default.reset(R.default.dim(`Press ${R.default.gray(R.default.bgWhite(R.default.inverse(` space `)))} to select, ${R.default.gray(R.default.bgWhite(R.default.inverse(` enter `)))} to submit`))}`},render(){let n=`${R.default.gray(B)}
72
- ${mr(this.state)} ${e.message}
73
- `;switch(this.state){case`submit`:return`${n}${R.default.gray(B)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`submitted`)).join(R.default.dim(`, `))}`;case`cancel`:{let e=this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`cancelled`)).join(R.default.dim(`, `));return`${n}${R.default.gray(B)} ${e.trim()?`${e}
74
- ${R.default.gray(B)}`:``}`}case`error`:{let e=this.error.split(`
75
- `).map((e,t)=>t===0?`${R.default.yellow(V)} ${R.default.yellow(e)}`:` ${e}`).join(`
76
- `);return`${n}${R.default.yellow(B)} ${this.options.map((e,n,r)=>{let i=this.value.includes(e.value)||e.group===!0&&this.isGroupSelected(`${e.value}`),a=n===this.cursor;return!a&&typeof e.group==`string`&&this.options[this.cursor].value===e.group?t(e,i?`group-active-selected`:`group-active`,r):a&&i?t(e,`active-selected`,r):i?t(e,`selected`,r):t(e,a?`active`:`inactive`,r)}).join(`
77
- ${R.default.yellow(B)} `)}
67
+ `}default:return`${n}${z.default.cyan(V)} ${this.options.map((e,n)=>{let r=this.value.includes(e.value),i=n===this.cursor;return i&&r?t(e,`active-selected`):r?t(e,`selected`):t(e,i?`active`:`inactive`)}).join(`
68
+ ${z.default.cyan(V)} `)}
69
+ ${z.default.cyan(H)}
70
+ `}}}).prompt()},br=e=>{let t=(e,t,n=[])=>{let r=e.label??String(e.value),i=typeof e.group==`string`,a=i&&(n[n.indexOf(e)+1]??{group:!0}),o=i&&a.group===!0,s=i?`${o?H:V} `:``;return t===`active`?`${z.default.dim(s)}${z.default.cyan(tr)} ${r} ${e.hint?z.default.dim(`(${e.hint})`):``}`:t===`group-active`?`${s}${z.default.cyan(tr)} ${z.default.dim(r)}`:t===`group-active-selected`?`${s}${z.default.green(nr)} ${z.default.dim(r)}`:t===`selected`?`${z.default.dim(s)}${z.default.green(nr)} ${z.default.dim(r)}`:t===`cancelled`?`${z.default.strikethrough(z.default.dim(r))}`:t===`active-selected`?`${z.default.dim(s)}${z.default.green(nr)} ${r} ${e.hint?z.default.dim(`(${e.hint})`):``}`:t===`submitted`?`${z.default.dim(r)}`:`${z.default.dim(s)}${z.default.dim(rr)} ${z.default.dim(r)}`};return new bn({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
71
+ ${z.default.reset(z.default.dim(`Press ${z.default.gray(z.default.bgWhite(z.default.inverse(` space `)))} to select, ${z.default.gray(z.default.bgWhite(z.default.inverse(` enter `)))} to submit`))}`},render(){let n=`${z.default.gray(V)}
72
+ ${pr(this.state)} ${e.message}
73
+ `;switch(this.state){case`submit`:return`${n}${z.default.gray(V)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`submitted`)).join(z.default.dim(`, `))}`;case`cancel`:{let e=this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`cancelled`)).join(z.default.dim(`, `));return`${n}${z.default.gray(V)} ${e.trim()?`${e}
74
+ ${z.default.gray(V)}`:``}`}case`error`:{let e=this.error.split(`
75
+ `).map((e,t)=>t===0?`${z.default.yellow(H)} ${z.default.yellow(e)}`:` ${e}`).join(`
76
+ `);return`${n}${z.default.yellow(V)} ${this.options.map((e,n,r)=>{let i=this.value.includes(e.value)||e.group===!0&&this.isGroupSelected(`${e.value}`),a=n===this.cursor;return!a&&typeof e.group==`string`&&this.options[this.cursor].value===e.group?t(e,i?`group-active-selected`:`group-active`,r):a&&i?t(e,`active-selected`,r):i?t(e,`selected`,r):t(e,a?`active`:`inactive`,r)}).join(`
77
+ ${z.default.yellow(V)} `)}
78
78
  ${e}
79
- `}default:return`${n}${R.default.cyan(B)} ${this.options.map((e,n,r)=>{let i=this.value.includes(e.value)||e.group===!0&&this.isGroupSelected(`${e.value}`),a=n===this.cursor;return!a&&typeof e.group==`string`&&this.options[this.cursor].value===e.group?t(e,i?`group-active-selected`:`group-active`,r):a&&i?t(e,`active-selected`,r):i?t(e,`selected`,r):t(e,a?`active`:`inactive`,r)}).join(`
80
- ${R.default.cyan(B)} `)}
81
- ${R.default.cyan(V)}
82
- `}}}).prompt()},Sr=e=>e.replace(Kn(),``),Cr=(e=``,t=``)=>{let n=`
79
+ `}default:return`${n}${z.default.cyan(V)} ${this.options.map((e,n,r)=>{let i=this.value.includes(e.value)||e.group===!0&&this.isGroupSelected(`${e.value}`),a=n===this.cursor;return!a&&typeof e.group==`string`&&this.options[this.cursor].value===e.group?t(e,i?`group-active-selected`:`group-active`,r):a&&i?t(e,`active-selected`,r):i?t(e,`selected`,r):t(e,a?`active`:`inactive`,r)}).join(`
80
+ ${z.default.cyan(V)} `)}
81
+ ${z.default.cyan(H)}
82
+ `}}}).prompt()},xr=e=>e.replace(Gn(),``),Sr=(e=``,t=``)=>{let n=`
83
83
  ${e}
84
84
  `.split(`
85
- `),r=Sr(t).length,i=Math.max(n.reduce((e,t)=>(t=Sr(t),t.length>e?t.length:e),0),r)+2,a=n.map(e=>`${R.default.gray(B)} ${R.default.dim(e)}${` `.repeat(i-Sr(e).length)}${R.default.gray(B)}`).join(`
86
- `);process.stdout.write(`${R.default.gray(B)}
87
- ${R.default.green(Qn)} ${R.default.reset(t)} ${R.default.gray(or.repeat(Math.max(i-r-1,1))+sr)}
85
+ `),r=xr(t).length,i=Math.max(n.reduce((e,t)=>(t=xr(t),t.length>e?t.length:e),0),r)+2,a=n.map(e=>`${z.default.gray(V)} ${z.default.dim(e)}${` `.repeat(i-xr(e).length)}${z.default.gray(V)}`).join(`
86
+ `);process.stdout.write(`${z.default.gray(V)}
87
+ ${z.default.green(Zn)} ${z.default.reset(t)} ${z.default.gray(ar.repeat(Math.max(i-r-1,1))+or)}
88
88
  ${a}
89
- ${R.default.gray(cr+or.repeat(i+2)+lr)}
90
- `)},wr=(e=``)=>{process.stdout.write(`${R.default.gray(V)} ${R.default.red(e)}
89
+ ${z.default.gray(sr+ar.repeat(i+2)+cr)}
90
+ `)},Cr=(e=``)=>{process.stdout.write(`${z.default.gray(H)} ${z.default.red(e)}
91
91
 
92
- `)},Tr=(e=``)=>{process.stdout.write(`${R.default.gray($n)} ${e}
93
- `)},Er=(e=``)=>{process.stdout.write(`${R.default.gray(B)}
94
- ${R.default.gray(V)} ${e}
92
+ `)},wr=(e=``)=>{process.stdout.write(`${z.default.gray(Qn)} ${e}
93
+ `)},Tr=(e=``)=>{process.stdout.write(`${z.default.gray(V)}
94
+ ${z.default.gray(H)} ${e}
95
95
 
96
- `)},Dr={message:(e=``,{symbol:t=R.default.gray(B)}={})=>{let n=[`${R.default.gray(B)}`];if(e){let[r,...i]=e.split(`
97
- `);n.push(`${t} ${r}`,...i.map(e=>`${R.default.gray(B)} ${e}`))}process.stdout.write(`${n.join(`
96
+ `)},Er={message:(e=``,{symbol:t=z.default.gray(V)}={})=>{let n=[`${z.default.gray(V)}`];if(e){let[r,...i]=e.split(`
97
+ `);n.push(`${t} ${r}`,...i.map(e=>`${z.default.gray(V)} ${e}`))}process.stdout.write(`${n.join(`
98
98
  `)}
99
- `)},info:e=>{Dr.message(e,{symbol:R.default.blue(ur)})},success:e=>{Dr.message(e,{symbol:R.default.green(dr)})},step:e=>{Dr.message(e,{symbol:R.default.green(Qn)})},warn:e=>{Dr.message(e,{symbol:R.default.yellow(fr)})},warning:e=>{Dr.warn(e)},error:e=>{Dr.message(e,{symbol:R.default.red(pr)})}},Or=()=>{let e=Jn?[`◒`,`◐`,`◓`,`◑`]:[`•`,`o`,`O`,`0`],t=Jn?80:120,n,r,i=!1,a=``,o=(o=``)=>{i=!0,n=It(),a=o.replace(/\.+$/,``),process.stdout.write(`${R.default.gray(B)}
100
- `);let s=0,c=0;r=setInterval(()=>{let t=R.default.magenta(e[s]),n=`.`.repeat(Math.floor(c)).slice(0,3);process.stdout.write(qn.cursor.move(-999,0)),process.stdout.write(qn.erase.down(1)),process.stdout.write(`${t} ${a}${n}`),s=s+1<e.length?s+1:0,c=c<e.length?c+.125:0},t)},s=(e=``,t=0)=>{a=e??a,i=!1,clearInterval(r);let o=t===0?R.default.green(Qn):t===1?R.default.red(Xn):R.default.red(Zn);process.stdout.write(qn.cursor.move(-999,0)),process.stdout.write(qn.erase.down(1)),process.stdout.write(`${o} ${a}
101
- `),n()},c=(e=``)=>{a=e??a},l=e=>{i&&s(e>1?`Something went wrong`:`Canceled`,e)};return process.on(`uncaughtExceptionMonitor`,()=>l(2)),process.on(`unhandledRejection`,()=>l(2)),process.on(`SIGINT`,()=>l(1)),process.on(`SIGTERM`,()=>l(1)),process.on(`exit`,l),{start:o,stop:s,message:c}},kr=async(e,t)=>{let n={},r=Object.keys(e);for(let i of r){let r=e[i],a=await r({results:n})?.catch(e=>{throw e});if(typeof t?.onCancel==`function`&&Pt(a)){n[i]=`canceled`,t.onCancel({results:n});continue}n[i]=a}return n}}));async function jr(e){if(!x())return;let{defaultValue:t,message:n}=e,r=await(await Promise.resolve().then(()=>(Ar(),Wn))).text({message:n,default:t,placeholder:t});if(typeof r!=`symbol`)return r}async function Mr(e){if(!x())return;let{message:t,initialValue:n}=e,r=await(await Promise.resolve().then(()=>(Ar(),Wn))).confirm({message:t,initialValue:n});if(typeof r!=`symbol`)return r}async function Nr(e){if(!x())return;let{message:t,choices:n,defaultValue:r}=e,i=await(await Promise.resolve().then(()=>(Ar(),Wn))).select({message:t,initialValue:r,options:n});if(typeof i!=`symbol`)return i}function H(e,n){throw yt().length>0&&(xt(process.stderr),process.exit(0)),new t(`Missing required argument: --${e}\nHint: In non-interactive (CI / agent) environments all required flags must be provided.\n In an interactive terminal, run without --${e} and the CLI will prompt for it.`,i.USAGE,n)}var U=A((()=>{wt()}));function Pr(){return process.env.BAILIAN_CONSOLE_ORIGIN||Yr}function Fr(e){return new Promise((t,n)=>{let r=0,i=[];e.on(`data`,e=>{if(r+=e.length,r>Jr){n(Error(`payload too large`));return}i.push(e)}),e.on(`end`,()=>t(Buffer.concat(i).toString(`utf8`))),e.on(`error`,n)})}function Ir(e){let t=e.headers[`content-type`];return Array.isArray(t)?t[0]??``:typeof t==`string`?t:``}function Lr(e){let t=e.split(`;`);for(let e of t){let t=e.trim();if(!t.toLowerCase().startsWith(`boundary=`))continue;let n=t.slice(9).trim();return(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`))&&(n=n.slice(1,-1)),n.length>0?n:null}return null}function Rr(e,t){let n=`--${t}`,r=e.split(n);for(let e=1;e<r.length;e++){let t=r[e];if(!/name\s*=\s*["'](?:access_token|accessToken)["']/i.test(t))continue;let n=t.match(/\r\n\r\n|\n\n/);if(!n||n.index===void 0)continue;let i=t.slice(n.index+n[0].length);if(i=i.replace(/(?:\r\n)+$/g,``).replace(/\n+$/g,``).trim(),i)return i}return null}function zr(e){for(let t of[`access_token`,`accessToken`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return null}function Br(e){let t=e.trim();if(t.charCodeAt(0)===65279&&(t=t.slice(1)),!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n,i=zr(r);if(i)return i;let a=r.data;if(a&&typeof a==`object`&&!Array.isArray(a)){let e=zr(a);if(e)return e}return null}function Vr(e,t){let n=t.toLowerCase();if(!e.trim())return null;if(n.includes(`multipart/form-data`)){let n=Lr(t);if(n){let t=Rr(e,n);if(t)return t}}if(n.includes(`application/json`)||n.includes(`text/json`)){let t=Br(e);if(t)return t}if(n.includes(`application/x-www-form-urlencoded`))try{let t=new URLSearchParams(e.trim()),n=t.get(`access_token`)??t.get(`accessToken`);if(n?.trim())return n.trim()}catch{}let r=Br(e);if(r)return r;try{let t=new URLSearchParams(e.trim()),n=t.get(`access_token`)??t.get(`accessToken`);if(n?.trim())return n.trim()}catch{}let i=Lr(t);if(i){let t=Rr(e,i);if(t)return t}return null}async function Hr(e){let t=new URL(e.url??`/`,`http://127.0.0.1`),n=t.searchParams.get(`access_token`)??t.searchParams.get(`accessToken`);if(n?.trim())return n.trim();let r=e.method??`GET`;if(r!==`POST`&&r!==`PUT`&&r!==`PATCH`)return null;let i=Ir(e);try{return Vr(await Fr(e),i)}catch{return null}}function Ur(e){return new Promise((t,n)=>{let r=e=>n(e);e.once(`error`,r),e.listen({port:0,host:`127.0.0.1`,exclusive:!0},()=>{e.off(`error`,r);let i=e.address();if(!i||typeof i==`string`){n(Error(`Expected TCP socket address`));return}t(i.port)})})}function Wr(e){let t=process.platform,n=t===`darwin`?`open`:t===`win32`?`cmd`:`xdg-open`,r=t===`win32`?[`/c`,`start`,``,e]:[e];return new Promise((e,t)=>{be(n,r,{windowsHide:!0},n=>{n?t(n):e()})})}async function Gr(e,t){process.stderr.write(`Testing key... `);let n={...e,apiKey:t};await D(n,{url:l(n.baseUrl),method:`POST`,body:{model:`qwen3.7-max`,messages:[{role:`user`,content:`hi`}],max_tokens:1}}),process.stderr.write(`Valid
102
- `);let r=ae();r.api_key=t,await ye(r),process.stderr.write(`Saved to ${v()}\n`)}async function Kr(e){let n=xe(16).toString(`hex`),r=Se.createServer(async(e,t)=>{try{if(e.method===`OPTIONS`){t.writeHead(204,{"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`GET, POST, PUT, PATCH, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),t.end();return}if(new URL(e.url??`/`,`http://127.0.0.1`).searchParams.get(`state`)!==n){t.writeHead(400,{"Content-Type":`text/plain; charset=utf-8`}),t.end(`bad state
103
- `);return}let i=await Hr(e);if(i)try{let e=ae();e.access_token=i,await ye(e),process.stderr.write(`access_token saved to ${v()}\n`)}catch{t.writeHead(500,{"Content-Type":`text/plain; charset=utf-8`}),t.end(`Failed to save access_token
104
- `);return}t.writeHead(200,{"Content-Type":`text/plain; charset=utf-8`,"Access-Control-Allow-Origin":`*`}),t.end(`OK
105
- `),i&&r.close()}catch{t.statusCode=500,t.end()}}),a;try{a=await Ur(r)}catch(e){throw new t(`Could not bind to 127.0.0.1 (no free port or permission denied): ${e instanceof Error?e.message:String(e)}`,i.USAGE)}let o=`${e}/console-login?notice=127.0.0.1:${a}?state=${encodeURIComponent(n)}`;try{await Wr(o),process.stderr.write(`Opened the login page in your default browser. This process keeps the local port open for the console; press Ctrl+C when finished (or wait for idle timeout).
106
- `)}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`Could not open the default browser (${t}). Open this URL manually:\n\n`),process.stdout.write(`${o}\n`),process.stderr.write(`
99
+ `)},info:e=>{Er.message(e,{symbol:z.default.blue(lr)})},success:e=>{Er.message(e,{symbol:z.default.green(ur)})},step:e=>{Er.message(e,{symbol:z.default.green(Zn)})},warn:e=>{Er.message(e,{symbol:z.default.yellow(dr)})},warning:e=>{Er.warn(e)},error:e=>{Er.message(e,{symbol:z.default.red(fr)})}},Dr=()=>{let e=qn?[`◒`,`◐`,`◓`,`◑`]:[`•`,`o`,`O`,`0`],t=qn?80:120,n,r,i=!1,a=``,o=(o=``)=>{i=!0,n=Ft(),a=o.replace(/\.+$/,``),process.stdout.write(`${z.default.gray(V)}
100
+ `);let s=0,c=0;r=setInterval(()=>{let t=z.default.magenta(e[s]),n=`.`.repeat(Math.floor(c)).slice(0,3);process.stdout.write(Kn.cursor.move(-999,0)),process.stdout.write(Kn.erase.down(1)),process.stdout.write(`${t} ${a}${n}`),s=s+1<e.length?s+1:0,c=c<e.length?c+.125:0},t)},s=(e=``,t=0)=>{a=e??a,i=!1,clearInterval(r);let o=t===0?z.default.green(Zn):t===1?z.default.red(Yn):z.default.red(Xn);process.stdout.write(Kn.cursor.move(-999,0)),process.stdout.write(Kn.erase.down(1)),process.stdout.write(`${o} ${a}
101
+ `),n()},c=(e=``)=>{a=e??a},l=e=>{i&&s(e>1?`Something went wrong`:`Canceled`,e)};return process.on(`uncaughtExceptionMonitor`,()=>l(2)),process.on(`unhandledRejection`,()=>l(2)),process.on(`SIGINT`,()=>l(1)),process.on(`SIGTERM`,()=>l(1)),process.on(`exit`,l),{start:o,stop:s,message:c}},Or=async(e,t)=>{let n={},r=Object.keys(e);for(let i of r){let r=e[i],a=await r({results:n})?.catch(e=>{throw e});if(typeof t?.onCancel==`function`&&Nt(a)){n[i]=`canceled`,t.onCancel({results:n});continue}n[i]=a}return n}}));async function Ar(e){if(!x())return;let{defaultValue:t,message:n}=e,r=await(await Promise.resolve().then(()=>(kr(),Un))).text({message:n,default:t,placeholder:t});if(typeof r!=`symbol`)return r}async function jr(e){if(!x())return;let{message:t,initialValue:n}=e,r=await(await Promise.resolve().then(()=>(kr(),Un))).confirm({message:t,initialValue:n});if(typeof r!=`symbol`)return r}async function Mr(e){if(!x())return;let{message:t,choices:n,defaultValue:r}=e,i=await(await Promise.resolve().then(()=>(kr(),Un))).select({message:t,initialValue:r,options:n});if(typeof i!=`symbol`)return i}function U(e,n){throw vt().length>0&&(bt(process.stderr),process.exit(0)),new t(`Missing required argument: --${e}\nHint: In non-interactive (CI / agent) environments all required flags must be provided.\n In an interactive terminal, run without --${e} and the CLI will prompt for it.`,i.USAGE,n)}var W=j((()=>{Ct()}));function Nr(){return process.env.BAILIAN_CONSOLE_ORIGIN||Xr}function Pr(e){return new Promise((t,n)=>{let r=0,i=[];e.on(`data`,e=>{if(r+=e.length,r>Yr){n(Error(`payload too large`));return}i.push(e)}),e.on(`end`,()=>t(Buffer.concat(i).toString(`utf8`))),e.on(`error`,n)})}function Fr(e){let t=e.headers[`content-type`];return Array.isArray(t)?t[0]??``:typeof t==`string`?t:``}function Ir(e){let t=e.split(`;`);for(let e of t){let t=e.trim();if(!t.toLowerCase().startsWith(`boundary=`))continue;let n=t.slice(9).trim();return(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`))&&(n=n.slice(1,-1)),n.length>0?n:null}return null}function Lr(e,t){let n=`--${t}`,r=e.split(n);for(let e=1;e<r.length;e++){let t=r[e];if(!/name\s*=\s*["'](?:access_token|accessToken)["']/i.test(t))continue;let n=t.match(/\r\n\r\n|\n\n/);if(!n||n.index===void 0)continue;let i=t.slice(n.index+n[0].length);if(i=i.replace(/(?:\r\n)+$/g,``).replace(/\n+$/g,``).trim(),i)return i}return null}function Rr(e){for(let t of[`access_token`,`accessToken`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return null}function zr(e){for(let t of[`api_key`,`apiKey`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return null}function Br(e){let t=e.trim();if(t.charCodeAt(0)===65279&&(t=t.slice(1)),!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n,i=Rr(r);if(i)return i;let a=r.data;if(a&&typeof a==`object`&&!Array.isArray(a)){let e=Rr(a);if(e)return e}return null}function Vr(e,t){let n=t.toLowerCase();if(!e.trim())return null;if(n.includes(`multipart/form-data`)){let n=Ir(t);if(n){let t=Lr(e,n);if(t)return t}}if(n.includes(`application/json`)||n.includes(`text/json`)){let t=Br(e);if(t)return t}if(n.includes(`application/x-www-form-urlencoded`))try{let t=new URLSearchParams(e.trim()),n=t.get(`access_token`)??t.get(`accessToken`);if(n?.trim())return n.trim()}catch{}let r=Br(e);if(r)return r;try{let t=new URLSearchParams(e.trim()),n=t.get(`access_token`)??t.get(`accessToken`);if(n?.trim())return n.trim()}catch{}let i=Ir(t);if(i){let t=Lr(e,i);if(t)return t}return null}function Hr(e){let t=e.trim();if(t.charCodeAt(0)===65279&&(t=t.slice(1)),!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n,i=zr(r);if(i)return i;let a=r.data;if(a&&typeof a==`object`&&!Array.isArray(a)){let e=zr(a);if(e)return e}return null}function Ur(e,t){let n=t.toLowerCase();if(!e.trim())return null;if(n.includes(`application/json`)||n.includes(`text/json`)){let t=Hr(e);if(t)return t}if(n.includes(`application/x-www-form-urlencoded`))try{let t=new URLSearchParams(e.trim()),n=t.get(`api_key`)??t.get(`apiKey`);if(n?.trim())return n.trim()}catch{}let r=Hr(e);if(r)return r;try{let t=new URLSearchParams(e.trim()),n=t.get(`api_key`)??t.get(`apiKey`);if(n?.trim())return n.trim()}catch{}return null}async function Wr(e){let t=new URL(e.url??`/`,`http://127.0.0.1`),n=t.searchParams.get(`access_token`)??t.searchParams.get(`accessToken`),r=t.searchParams.get(`api_key`)??t.searchParams.get(`apiKey`),i=e.method??`GET`;if(i!==`POST`&&i!==`PUT`&&i!==`PATCH`)return{accessToken:n?.trim()||null,apiKey:r?.trim()||null};let a=Fr(e),o;try{o=await Pr(e)}catch{return{accessToken:n?.trim()||null,apiKey:r?.trim()||null}}return{accessToken:n?.trim()||Vr(o,a),apiKey:r?.trim()||Ur(o,a)}}function Gr(e){return new Promise((t,n)=>{let r=e=>n(e);e.once(`error`,r),e.listen({port:0,host:`127.0.0.1`,exclusive:!0},()=>{e.off(`error`,r);let i=e.address();if(!i||typeof i==`string`){n(Error(`Expected TCP socket address`));return}t(i.port)})})}function Kr(e){let t=process.platform,n=t===`darwin`?`open`:t===`win32`?`cmd`:`xdg-open`,r=t===`win32`?[`/c`,`start`,``,e]:[e];return new Promise((e,t)=>{Te(n,r,{windowsHide:!0},n=>{n?t(n):e()})})}async function qr(e,n){let r=Ee(16).toString(`hex`),a,o=De.createServer(async(e,t)=>{try{if(e.method===`OPTIONS`){t.writeHead(204,{"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`GET, POST, PUT, PATCH, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),t.end();return}if(new URL(e.url??`/`,`http://127.0.0.1`).searchParams.get(`state`)!==r){t.writeHead(400,{"Content-Type":`text/plain; charset=utf-8`}),t.end(`bad state
102
+ `);return}let{accessToken:i,apiKey:s}=await Wr(e);if(i||s)try{if(i){let e=D();e.access_token=i,await ve(e),process.stderr.write(`access_token saved to ${v()}\n`)}s&&n?.onApiKey&&await n.onApiKey(s)}catch(e){a=e,t.writeHead(500,{"Content-Type":`text/plain; charset=utf-8`}),t.end(`Failed to save credentials
103
+ `),o.close();return}t.writeHead(200,{"Content-Type":`text/plain; charset=utf-8`,"Access-Control-Allow-Origin":`*`}),t.end(`OK
104
+ `),(i||s)&&o.close()}catch{t.statusCode=500,t.end()}}),s;try{s=await Gr(o)}catch(e){throw new t(`Could not bind to 127.0.0.1 (no free port or permission denied): ${e instanceof Error?e.message:String(e)}`,i.USAGE)}let c=`${e}/console-login?notice=127.0.0.1:${s}?state=${encodeURIComponent(r)}`;n?.needApiKey&&(c+=`&needapikey=true`);try{await Kr(c),process.stderr.write(`Opened the login page in your default browser. This process keeps the local port open for the console; press Ctrl+C when finished (or wait for idle timeout).
105
+ `)}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`Could not open the default browser (${t}). Open this URL manually:\n\n`),process.stdout.write(`${c}\n`),process.stderr.write(`
107
106
  This process keeps the local port open for the console; press Ctrl+C when finished (or wait for idle timeout).
108
- `)}await new Promise((e,t)=>{let n=!1,i=()=>{n||(n=!0,clearTimeout(a),e())},a=setTimeout(()=>{r.close()},qr);r.once(`close`,i),r.once(`error`,e=>{clearTimeout(a),n||(n=!0,t(e))})})}var qr,Jr,Yr,Xr,Zr=A((()=>{_t(),P(),U(),wt(),qr=900*1e3,Jr=65536,Yr=`https://bailian.console.aliyun.com`,Xr=d({name:`auth login`,description:`Authenticate with API key or console browser login (credentials can coexist)`,usage:`bl auth login --api-key <key> | bl auth login --console`,options:[{flag:`--api-key <key>`,description:`DashScope API key to store`},{flag:`--console`,description:`Sign in via browser; opens the console login URL in your default browser`,type:`boolean`}],examples:[`bl auth login --api-key sk-xxxxx`,`bl auth login --console`],async run(e,t){if(t.console){if(e.dryRun){N(`Would bind a free port on 127.0.0.1 and open the console login URL in your browser.`);return}await Kr(Pr());return}let n=process.env.DASHSCOPE_API_KEY;if(n&&!t.apiKey){let t=w(n);x({nonInteractive:e.nonInteractive})?await Mr({message:`Detected DASHSCOPE_API_KEY in environment (${t}).\nYou are already authenticated via env.\nDo you still want to configure local persistent credentials?`,initialValue:!1})||(process.stdout.write(`Login skipped. Using environment variables.
107
+ `)}if(await new Promise((e,t)=>{let n=!1,r=()=>{n||(n=!0,clearTimeout(i),e())},i=setTimeout(()=>{o.close()},Jr);o.once(`close`,r),o.once(`error`,e=>{clearTimeout(i),n||(n=!0,t(e))})}),a)throw a}var Jr,Yr,Xr,Zr=j((()=>{Jr=900*1e3,Yr=65536,Xr=`https://bailian.console.aliyun.com`}));function Qr(e){if(e instanceof t){if(e.exitCode===i.NETWORK||e.exitCode===i.TIMEOUT)return!0;let t=e.api?.httpStatus;return t===401||t!==void 0&&t>=500}return e instanceof Error?e.name===`AbortError`||e.name===`TimeoutError`||e.message.includes(`timed out`)||e.message===`fetch failed`:!1}async function $r(e,n){process.stderr.write(`Testing key... `);let r={...e,apiKey:n},a={url:l(r.baseUrl),method:`POST`,timeout:Math.min(e.timeout,30),body:{model:`qwen3.7-max`,messages:[{role:`user`,content:`hi`}],max_tokens:1}};for(let e=1;e<=3;e++)try{await O(r,a);break}catch(n){if(e>=3||!Qr(n))throw process.stderr.write(`
108
+ `),new t(`API key validation failed`,i.AUTH,`Invalid API key.`,{cause:n});let r=ei*2**(e-1);await new Promise(e=>setTimeout(e,r))}process.stderr.write(`Valid
109
+ `);let o=D();o.api_key=n,await ve(o),process.stderr.write(`Saved to ${v()}\n`)}var ei,ti,ni=j((()=>{gt(),F(),W(),Ct(),Zr(),ei=500,ti=d({name:`auth login`,description:`Authenticate with API key or console browser login (credentials can coexist)`,usage:`bl auth login --api-key <key> | bl auth login --console`,options:[{flag:`--api-key <key>`,description:`DashScope API key to store`},{flag:`--console`,description:`Sign in via browser; opens the console login URL in your default browser`,type:`boolean`}],examples:[`bl auth login --api-key sk-xxxxx`,`bl auth login --console`],async run(e,t){if(t.console){if(e.dryRun){P(`Would bind a free port on 127.0.0.1 and open the console login URL in your browser.`);return}let t=!!(e.apiKey||e.fileApiKey);await qr(Nr(),{needApiKey:!t,onApiKey:t=>$r(e,t)});return}let n=process.env.DASHSCOPE_API_KEY;if(n&&!t.apiKey){let t=w(n);x({nonInteractive:e.nonInteractive})?await jr({message:`Detected DASHSCOPE_API_KEY in environment (${t}).\nYou are already authenticated via env.\nDo you still want to configure local persistent credentials?`,initialValue:!1})||(process.stdout.write(`Login skipped. Using environment variables.
109
110
  `),process.exit(0)):process.stderr.write(`Warning: DASHSCOPE_API_KEY is already set in environment.
110
- `)}let r=t.apiKey||e.apiKey;r||(xt(process.stderr),process.exit(0)),e.dryRun?N(`Would validate and save API key.`):(await Gr(e,r),ht())}})}));function Qr(e){if(e.apiKey)return{configured:!0,source:`flag`,masked:w(e.apiKey)};if(e.fileApiKey)return{configured:!0,source:`config.json`,masked:w(e.fileApiKey)};let t=process.env.DASHSCOPE_API_KEY?.trim();return t?{configured:!0,source:`DASHSCOPE_API_KEY`,masked:w(t)}:{configured:!1}}function $r(e){return e.accessTokenEnv?{configured:!0,source:`DASHSCOPE_ACCESS_TOKEN`,masked:w(e.accessTokenEnv)}:e.fileAccessToken?{configured:!0,source:`config.json`,masked:w(e.fileAccessToken)}:{configured:!1}}async function ei(e){try{return await O(e)}catch{return}}async function ti(e){try{return await se(e)}catch{return}}async function ni(e){let t={api_key:Qr(e),access_token:$r(e)},n=await ei(e);n&&(t.dashscope_commands={method:n.method,source:n.source,masked:w(n.token)});let r=await ti(e);return r&&(t.console_gateway_commands={method:r.method,source:r.source,masked:w(r.token)}),t}function ri(e){return e.api_key.configured||e.access_token.configured||!!e.dashscope_commands||!!e.console_gateway_commands}function ii(e){N(`Authentication Status:`),N(` Stored credentials (can coexist):`),e.api_key.configured?N(` API key: ${e.api_key.source} ${e.api_key.masked}`):N(` API key: not configured`),e.access_token.configured?N(` Console token: ${e.access_token.source} ${e.access_token.masked}`):N(` Console token: not configured`),N(` Effective credential per command family:`),e.dashscope_commands?N(` DashScope API: ${e.dashscope_commands.method} (${e.dashscope_commands.source}) ${e.dashscope_commands.masked}`):N(` DashScope API: unavailable`),e.console_gateway_commands?N(` Console gateway: ${e.console_gateway_commands.method} (${e.console_gateway_commands.source}) ${e.console_gateway_commands.masked}`):N(` Console gateway: unavailable (run bl auth login --console)`)}var ai,oi=A((()=>{P(),ft(),ai=d({name:`auth status`,description:`Show current authentication state`,usage:`bl auth status`,examples:[`bl auth status`,`bl auth status --output json`],async run(e,t){let n=f(e.output),r=await ni(e);if(!ri(r)){M({authenticated:!1,message:`Not authenticated.`,hint:[`DashScope API: bl auth login --api-key <key> or DASHSCOPE_API_KEY`,`Console gateway: bl auth login --console or DASHSCOPE_ACCESS_TOKEN`,`Get API Key: ${dt}`].join(`
111
- `),...r},n);return}if(n!==`text`){M({authenticated:!0,...r},n);return}ii(r)}})}));async function si(){let e=ae();return e.access_token?(delete e.access_token,await ye(e),!0):!1}var ci,li=A((()=>{P(),ci=d({name:`auth logout`,description:`Clear stored credentials`,usage:`bl auth logout [--console] [--yes] [--dry-run]`,options:[{flag:`--console`,description:`Only clear the console access_token, keep api_key intact`,type:`boolean`},{flag:`--yes`,description:`Skip confirmation prompt`}],examples:[`bl auth logout`,`bl auth logout --console`,`bl auth logout --dry-run`,`bl auth logout --yes`],async run(e,t){let n=ae();if(t.console){let t=!!n.access_token;if(e.dryRun){N(t?`Would clear access_token from ~/.bailian/config.json`:`No console access_token to clear.`),N(`No changes made.`);return}t?(await si(),process.stderr.write(`Cleared access_token from ${v()}\n`),n.api_key&&process.stderr.write(`api_key is still configured and will be used for authentication.
111
+ `)}let r=t.apiKey||e.apiKey;r||(bt(process.stderr),process.exit(0)),e.dryRun?P(`Would validate and save API key.`):(await $r(e,r),mt())}})}));function ri(e){if(e.apiKey)return{configured:!0,source:`flag`,masked:w(e.apiKey)};if(e.fileApiKey)return{configured:!0,source:`config.json`,masked:w(e.fileApiKey)};let t=process.env.DASHSCOPE_API_KEY?.trim();return t?{configured:!0,source:`DASHSCOPE_API_KEY`,masked:w(t)}:{configured:!1}}function ii(e){return e.accessTokenEnv?{configured:!0,source:`DASHSCOPE_ACCESS_TOKEN`,masked:w(e.accessTokenEnv)}:e.fileAccessToken?{configured:!0,source:`config.json`,masked:w(e.fileAccessToken)}:{configured:!1}}async function ai(e){try{return await k(e)}catch{return}}async function oi(e){try{return await oe(e)}catch{return}}async function si(e){let t={api_key:ri(e),access_token:ii(e)},n=await ai(e);n&&(t.dashscope_commands={method:n.method,source:n.source,masked:w(n.token)});let r=await oi(e);return r&&(t.console_gateway_commands={method:r.method,source:r.source,masked:w(r.token)}),t}function ci(e){return e.api_key.configured||e.access_token.configured||!!e.dashscope_commands||!!e.console_gateway_commands}function li(e){P(`Authentication Status:`),P(` Stored credentials (can coexist):`),e.api_key.configured?P(` API key: ${e.api_key.source} ${e.api_key.masked}`):P(` API key: not configured`),e.access_token.configured?P(` Console token: ${e.access_token.source} ${e.access_token.masked}`):P(` Console token: not configured`),P(` Effective credential per command family:`),e.dashscope_commands?P(` DashScope API: ${e.dashscope_commands.method} (${e.dashscope_commands.source}) ${e.dashscope_commands.masked}`):P(` DashScope API: unavailable`),e.console_gateway_commands?P(` Console gateway: ${e.console_gateway_commands.method} (${e.console_gateway_commands.source}) ${e.console_gateway_commands.masked}`):P(` Console gateway: unavailable (run bl auth login --console)`)}var ui,di=j((()=>{F(),dt(),ui=d({name:`auth status`,description:`Show current authentication state`,usage:`bl auth status`,examples:[`bl auth status`,`bl auth status --output json`],async run(e,t){let n=f(e.output),r=await si(e);if(!ci(r)){N({authenticated:!1,message:`Not authenticated.`,hint:[`DashScope API: bl auth login --api-key <key> or DASHSCOPE_API_KEY`,`Console gateway: bl auth login --console or DASHSCOPE_ACCESS_TOKEN`,`Get API Key: ${ut}`].join(`
112
+ `),...r},n);return}if(n!==`text`){N({authenticated:!0,...r},n);return}li(r)}})}));async function fi(){let e=D();return e.access_token?(delete e.access_token,await ve(e),!0):!1}var pi,mi=j((()=>{F(),pi=d({name:`auth logout`,description:`Clear stored credentials`,usage:`bl auth logout [--console] [--yes] [--dry-run]`,options:[{flag:`--console`,description:`Only clear the console access_token, keep api_key intact`,type:`boolean`},{flag:`--yes`,description:`Skip confirmation prompt`}],examples:[`bl auth logout`,`bl auth logout --console`,`bl auth logout --dry-run`,`bl auth logout --yes`],async run(e,t){let n=D();if(t.console){let t=!!n.access_token;if(e.dryRun){P(t?`Would clear access_token from ~/.bailian/config.json`:`No console access_token to clear.`),P(`No changes made.`);return}t?(await fi(),process.stderr.write(`Cleared access_token from ${v()}\n`),n.api_key&&process.stderr.write(`api_key is still configured and will be used for authentication.
112
113
  `)):process.stderr.write(`No console access_token to clear.
113
- `);return}let r=!!(n.api_key||n.access_token);if(e.dryRun){N(r?`Would clear api_key / access_token from ~/.bailian/config.json`:`No credentials to clear.`),N(`No changes made.`);return}r?(await u(),process.stderr.write(`Cleared api_key / access_token from ~/.bailian/config.json
114
+ `);return}let r=!!(n.api_key||n.access_token);if(e.dryRun){P(r?`Would clear api_key / access_token from ~/.bailian/config.json`:`No credentials to clear.`),P(`No changes made.`);return}r?(await u(),process.stderr.write(`Cleared api_key / access_token from ~/.bailian/config.json
114
115
  `)):process.stderr.write(`No credentials to clear.
115
- `)}})}));function ui(e){let t=[],n;if(e.system&&(n=e.system),e.messagesFile){let r=e.messagesFile,i=Me(r===`-`?`/dev/stdin`:r,`utf-8`),a=JSON.parse(i);for(let e of a)e.role===`system`?n=typeof e.content==`string`?e.content:``:t.push(e)}if(e.message){let r=new Set([`system`,`user`,`assistant`]),i=e.message;for(let e of i){let i=e.indexOf(`:`),a=i===-1?``:e.slice(0,i);if(r.has(a)){let r=e.slice(i+1);a===`system`?n=r:t.push({role:a,content:r})}else t.push({role:`user`,content:e})}}return{system:n,messages:t}}var di,fi=A((()=>{U(),P(),di=d({name:`text chat`,description:`Send a chat completion (OpenAI compatible, DashScope)`,apiDocs:`/compatibility-of-openai-with-dashscope`,usage:`bl text chat --message <text> [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: qwen3.7-max)`},{flag:`--message <text>`,description:`Message text (repeatable, prefix role: to set role)`,required:!0,type:`array`},{flag:`--messages-file <path>`,description:`JSON file with messages array (use - for stdin)`},{flag:`--system <text>`,description:`System prompt`},{flag:`--max-tokens <n>`,description:`Maximum tokens to generate (default: 4096)`,type:`number`},{flag:`--temperature <n>`,description:`Sampling temperature (0.0, 2.0]`,type:`number`},{flag:`--top-p <n>`,description:`Nucleus sampling threshold`,type:`number`},{flag:`--stream`,description:`Stream response tokens (default: on in TTY)`},{flag:`--tool <json-or-path>`,description:`Tool definition as JSON or file path (repeatable)`,type:`array`},{flag:`--enable-thinking`,description:`Enable thinking/reasoning mode (for qwen3/qwq models)`},{flag:`--thinking-budget <n>`,description:`Max tokens for thinking (default: 4096)`,type:`number`}],examples:[`bl text chat --message "What is Qwen?"`,`bl text chat --model qwen-max --system "You are a coding assistant." --message "Write fizzbuzz in Python"`,`bl text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"`,`cat conversation.json | bl text chat --messages-file - --stream`,`bl text chat --message "Hello" --output json`,`bl text chat --model qwq-plus --message "Solve 1+1" --enable-thinking`],async run(e,t){let{system:n,messages:r}=ui(t),i=r;if(i.length===0)if(x({nonInteractive:e.nonInteractive})){let e=await jr({message:`Enter your message:`});e||(process.stderr.write(`Chat cancelled.
116
- `),process.exit(1)),i=[{role:`user`,content:e}]}else H(`message`,`bl text chat --message <text>`);let a=t.model||e.defaultTextModel||`qwen3.7-max`,o=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,s=f(e.output),c=[];n&&c.push({role:`system`,content:n}),c.push(...i);let u={model:a,messages:c,max_tokens:t.maxTokens??4096,stream:o};if(t.temperature!==void 0&&(u.temperature=t.temperature),t.topP!==void 0&&(u.top_p=t.topP),t.enableThinking&&(u.enable_thinking=!0,t.thinkingBudget!==void 0&&(u.thinking_budget=t.thinkingBudget)),t.tool&&(u.tools=t.tool.map(e=>{try{return JSON.parse(e)}catch{let t=Me(e,`utf-8`);return JSON.parse(t)}})),e.dryRun){M({request:u},s);return}let d=l(e.baseUrl);if(o){let t=await oe(e,{url:d,method:`POST`,body:u,stream:!0}),n=``,r=!1,i=s===`text`,a=e.noColor?``:`\x1B[2m`,o=e.noColor?``:`\x1B[0m`,c=process.stdout.isTTY,l=s===`json`?process.stderr:c?process.stdout:process.stderr,f=process.stdout;for await(let e of re(t)){if(e.data===`[DONE]`)break;try{let t=JSON.parse(e.data);for(let e of t.choices){let t=e.delta;t.reasoning_content&&(i&&!r&&(r=!0,l.write(`${a}Thinking:\n`)),i&&l.write(t.reasoning_content)),t.content&&(i&&r&&(l.write(`${o}\n\nResponse:\n`),r=!1),n+=t.content,i&&f.write(t.content))}}catch{}}r&&l.write(o),s===`json`?M({content:n},s):f.write(`
117
- `)}else{let t=await D(e,{url:d,method:`POST`,body:u}),n=t.choices?.[0]?.message?.content??``;e.quiet||s===`text`?N(n):M(t,s)}}})}));function pi(e){let t=Buffer.alloc(44);return t.write(`RIFF`,0),t.writeUInt32LE(36+e,4),t.write(`WAVE`,8),t.write(`fmt `,12),t.writeUInt32LE(16,16),t.writeUInt16LE(1,20),t.writeUInt16LE(1,22),t.writeUInt32LE(24e3,24),t.writeUInt32LE(48e3,28),t.writeUInt16LE(2,32),t.writeUInt16LE(16,34),t.write(`data`,36),t.writeUInt32LE(e,40),t}var mi,hi,gi=A((()=>{U(),P(),mi=[`Chelsie`,`Cherry`,`Ethan`,`Serena`,`Tina`],hi=d({name:`omni`,description:`Multimodal chat with text + audio output (Qwen-Omni)`,apiDocs:`/model-studio/qwen-omni`,usage:`bl omni --message <text> [flags]`,options:[{flag:`--message <text>`,description:`Message text (repeatable, prefix role: to set role)`,required:!0,type:`array`},{flag:`--model <model>`,description:`Model ID (default: qwen3.5-omni-plus)`},{flag:`--system <text>`,description:`System prompt`},{flag:`--image <url>`,description:`Image URL or local file (repeatable)`,type:`array`},{flag:`--audio <url>`,description:`Audio URL or local file (repeatable)`,type:`array`},{flag:`--video <url>`,description:`Video file URL / local path, or comma-separated frame URLs`,type:`array`},{flag:`--voice <voice>`,description:`Output voice (default: Cherry). Options: ${mi.join(`, `)}`},{flag:`--audio-format <fmt>`,description:`Audio output format (default: wav)`},{flag:`--audio-out <path>`,description:`Save audio to file (default: auto-generate)`},{flag:`--text-only`,description:`Output text only, no audio generation`},{flag:`--max-tokens <n>`,description:`Maximum tokens to generate`,type:`number`},{flag:`--temperature <n>`,description:`Sampling temperature (0.0, 2.0]`,type:`number`}],examples:[`bl omni --message "你好,你是谁?"`,`bl omni --message "描述这张图片" --image ./photo.jpg`,`bl omni --message "这段音频在说什么?" --audio https://example.com/audio.wav`,`bl omni --message "总结这个视频" --video https://example.com/video.mp4`,`bl omni --message "这个视频讲了什么" --video ./local-video.mp4 --text-only`,`bl omni --message "用四川话回答:今天天气怎么样" --voice Serena`,`bl omni --message "Hello" --text-only --output json`,`bl omni --message "朗读这段话" --audio-out greeting.wav`],async run(e,t){let n=[];if(t.message&&(n=t.message),n.length===0)if(x({nonInteractive:e.nonInteractive})){let e=await jr({message:`Enter your message:`});e||(process.stderr.write(`Omni chat cancelled.
118
- `),process.exit(1)),n=[e]}else H(`message`,`bl text omni --message <text>`);let r=t.model||e.defaultOmniModel||`qwen3.5-omni-plus`,i=t.voice||`Cherry`,a=t.audioFormat||`wav`,o=t.textOnly===!0,s=f(e.output),c=[];t.system&&c.push({role:`system`,content:t.system});let u=new Set([`system`,`user`,`assistant`]);for(let e of n){let t=e.indexOf(`:`),n=t===-1?``:e.slice(0,t);if(u.has(n)){let r=e.slice(t+1);n===`system`?c.push({role:`system`,content:r}):c.push({role:n,content:r})}else c.push({role:`user`,content:e})}let d=t.image||[],p=t.audio||[],m=t.video||[],h=[],g=[],_=[];if(d.length>0||p.length>0||m.length>0){let t=await O(e);for(let e of d){let n=await k(e,t.token,r);h.push(n)}for(let e of p){let n=await k(e,t.token,r);g.push(n)}for(let e of m)if(e.includes(`,`)){let n=e.split(`,`).map(e=>e.trim()).filter(Boolean);for(let e of n){let n=await k(e,t.token,r);_.push(`frame:${n}`)}}else{let n=await k(e,t.token,r);_.push(n)}}if(h.length>0||g.length>0||_.length>0){for(let e=c.length-1;e>=0;e--)if(c[e].role===`user`){let t=c[e].content,n=[];typeof t==`string`?n.push({type:`text`,text:t}):Array.isArray(t)&&n.push(...t);for(let e of h)n.push({type:`image_url`,image_url:{url:e}});for(let e of g)n.push({type:`audio_url`,audio_url:{url:e}});let r=_.filter(e=>e.startsWith(`frame:`)).map(e=>e.slice(6)),i=_.filter(e=>!e.startsWith(`frame:`));r.length>0&&n.push({type:`video`,video:r});for(let e of i)n.push({type:`video_url`,video_url:{url:e}});c[e]={role:`user`,content:n};break}}let v={model:r,messages:c,stream:!0,stream_options:{include_usage:!0}};if(o||(v.modalities=[`text`,`audio`],v.audio={voice:i,format:a}),t.maxTokens!==void 0&&(v.max_tokens=t.maxTokens),t.temperature!==void 0&&(v.temperature=t.temperature),e.dryRun){M({request:v},s);return}if(!e.quiet){let e=o?`text-only`:`text+audio, voice: ${i}`;process.stderr.write(`[Model: ${r}] [${e}]\n`)}let y=await oe(e,{url:l(e.baseUrl),method:`POST`,body:v,stream:!0}),b=``,S=``,C=process.stdout.isTTY,w=process.stdout;for await(let e of re(y)){if(e.data===`[DONE]`)break;try{let t=JSON.parse(e.data);for(let e of t.choices){let t=e.delta;t.content&&(b+=t.content,C&&w.write(t.content)),t.audio?.data&&(S+=t.audio.data)}}catch{}}C&&b&&w.write(`
119
- `);let T;if(S&&!o){let n=Buffer.from(S,`base64`),r=pi(n.length),i=Buffer.concat([r,n]),a=t.audioOut;if(!a){let{join:t}=await import(`path`);a=t(ce(e,{subDir:`omni`}),`omni_${Date.now()}.wav`)}Pe(a,i),T=a,e.quiet||process.stderr.write(`Audio saved: ${a}\n`)}if(!C||s===`json`){let e={content:b};T&&(e.audio_saved=T,e.voice=i),M(e,s)}}})}));function _i(e){let t=process.stderr.isTTY,n=0,r=null,i=e;return{start(){t&&(r=setInterval(()=>{process.stderr.write(`\r${yi[n%yi.length]} ${i}`),n++},80))},update(e){i=e},stop(e){r&&=(clearInterval(r),null),t&&(process.stderr.write(`\r\x1B[K`),e&&process.stderr.write(`${e}\n`))}}}function vi(e,t=``){let n=process.stderr.isTTY;return{update(r){if(!n)return;let i=Math.min(1,r/e),a=Math.round(30*i),o=30-a,s=`█`.repeat(a)+`░`.repeat(o),c=`${Math.round(i*100)}%`;process.stderr.write(`\r${t} ${s} ${c}`)},finish(){n&&process.stderr.write(`
120
- `)}}}var yi,bi=A((()=>{yi=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`]}));async function xi(e,n){let r=Date.now()+n.timeoutSec*1e3,a=_i(`Polling...`);e.quiet||a.start();try{for(;Date.now()<r;){let r=await D(e,{url:n.url});if(n.getStatus&&!e.quiet&&a.update(`Status: ${n.getStatus(r)}`),n.isComplete(r))return a.stop(`Done.`),r;if(n.isFailed(r)){a.stop(`Failed.`),e.verbose&&process.stderr.write(`[verbose] Task response: ${JSON.stringify(r,null,2)}\n`);let o=n.getErrorMessage?.(r);throw new t(o?`Task failed: ${o}`:`Task failed.`,i.GENERAL,o?void 0:`Use --verbose to see full API response details.`)}await new Promise(e=>setTimeout(e,n.intervalSec*1e3))}}finally{a.stop()}throw new t(`Polling timed out.`,i.TIMEOUT,`Try increasing --timeout or check task status manually.`)}var Si=A((()=>{bi()}));async function Ci(e,n,r){let a=await fetch(e,{headers:he()});if(!a.ok)throw new t(`Download failed: HTTP ${a.status}`,i.GENERAL);let o=Number(a.headers.get(`content-length`)||0),s=a.body?.getReader();if(!s)throw new t(`No response body`,i.GENERAL);je(Fe(n),{recursive:!0});let c=ke(n),l=o>0&&!r?.quiet?vi(o,`Downloading`):null,u=0,d=!1;try{let e=new Promise((e,t)=>{c.on(`error`,t)});for(;;){let{done:t,value:n}=await Promise.race([s.read(),e]);if(t)break;c.write(n)||await new Promise(e=>c.once(`drain`,()=>e())),u+=n.byteLength,l?.update(u)}d=!0}finally{if(s.releaseLock(),l?.finish(),await new Promise((e,t)=>{c.on(`finish`,e),c.on(`error`,t),c.end()}),!d)try{Ne(n)}catch{}}return{size:u}}function wi(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}var Ti=A((()=>{bi()}));function Ei(e){let t=e.concurrent;return Math.max(1,t??1)}async function Di(e,t,n,r=`requests`){if(e<=1)return[await n(0)];t.quiet||process.stderr.write(`[Concurrent: ${e} ${r}]\n`);let i=Array.from({length:e},(e,t)=>n(t));return Promise.all(i)}async function Oi(e,t,n){return Promise.all(e.map(({url:e,destPath:r})=>t(e,r,n).then(()=>r)))}var ki=A((()=>{}));function Ai(e,t){if(e)return(t?ji:Mi)[e]??e}var ji,Mi,Ni=A((()=>{ji={"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},Mi={"16:9":`1664*928`,"4:3":`1472*1104`,"1:1":`1328*1328`,"3:4":`1104*1472`,"9:16":`928*1664`}}));function Pi(e){return Ri.some(t=>e.startsWith(t))}async function Fi(e,n,r,a,o,s){let c=b(e.baseUrl),l=(await Di(s,e,()=>D(e,{url:c,method:`POST`,body:r}))).flatMap(e=>e.output.choices||[]).flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);if(l.length===0)throw new t(`Generation completed but no images returned.`,i.GENERAL);await Li(l,a,e,o)}async function Ii(e,n,r,a,o,s){let c=y(e.baseUrl),l=(await Di(s,e,()=>D(e,{url:c,method:`POST`,body:r,async:!0}),`tasks`)).map(e=>e.output.task_id);if(a.noWait||e.async){M({task_ids:l},o);return}let u=a.pollInterval??3,d=l.map(t=>xi(e,{url:pe(e.baseUrl,t),intervalSec:u,timeoutSec:e.timeout,isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}})),f=await Promise.all(d),p=[];for(let e of f){if(e.output.choices){let t=e.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);p.push(...t)}if(e.output.results){let t=e.output.results.map(e=>e.url).filter(Boolean);t.length>0&&p.length===0&&p.push(...t)}}if(p.length===0)throw new t(`All tasks completed but no images returned.`,i.GENERAL);await Li(p,a,e,o,l.length===1?l[0]:void 0,l)}async function Li(e,t,n,r,i,a){let o=ce(n,{flagDir:t.outDir,subDir:t.outDir?void 0:`images`}),s=t.prompt||t._positional?.[0]||``,c=t.outPrefix||h(`image`,s),l=await Oi(e.length>1?e.map((e,t)=>({url:e,destPath:Le(o,`${c}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:e[0],destPath:Le(o,`${c}.png`)}],Ci,{quiet:n.quiet});if(n.quiet)N(l.join(`
121
- `));else{let t={urls:e,saved:l,total:e.length};i&&(t.task_id=i),a&&a.length>1&&(t.task_ids=a),M(t,r)}}var Ri,zi,Bi=A((()=>{Si(),Ti(),ki(),U(),P(),Ni(),Ri=[`qwen-image-2.0`,`qwen-image-max`],zi=d({name:`image generate`,description:`Generate images (Qwen-Image / wan2.x)`,apiDocs:`/best-practice/wanx/text-to-image`,usage:`bl image generate --prompt <text> [flags]`,options:[{flag:`--prompt <text>`,description:`Image description`,required:!0},{flag:`--model <model>`,description:`Model ID (default: qwen-image-2.0)`},{flag:`--size <W*H>`,description:`Image size: ratio (3:4, 16:9, 1:1) or pixels (2048*2048)`},{flag:`--n <count>`,description:`Number of images per request (default: 1, max: 6)`,type:`number`},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--prompt-extend`,description:`Automatically extend prompt for better results (default: true for qwen-image)`},{flag:`--no-prompt-extend`,description:`Disable prompt extend`},{flag:`--watermark`,description:`Add watermark to generated images`},{flag:`--no-wait`,description:`Return task ID immediately without waiting (async models only)`},{flag:`--out-dir <dir>`,description:`Download images to directory`},{flag:`--out-prefix <prefix>`,description:`Filename prefix (default: image)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 3)`,type:`number`}],examples:[`bl image generate --prompt "一只穿太空服的猫在火星上"`,`bl image generate --prompt "Logo design" --n 3 --out-dir ./generated/`,`bl image generate --prompt "Mountain landscape" --size 2688*1536`,`bl image generate --prompt "A castle" --seed 42 --no-prompt-extend`,`bl image generate --prompt "sunset" --model wan2.6-t2i --no-wait --quiet`,`bl image generate --prompt "Pro quality" --model qwen-image-2.0-pro`,`bl image generate --prompt "Product shots" --n 2 --concurrent 3 # 6 images in parallel`],async run(e,t){let n=t.prompt??t._positional?.[0];if(!n)if(x({nonInteractive:e.nonInteractive})){let e=await jr({message:`Enter your image prompt:`});e||(process.stderr.write(`Image generation cancelled.
122
- `),process.exit(1)),n=e}else H(`prompt`,`bl image generate --prompt <text>`);let r=t.model||e.defaultImageModel||`qwen-image-2.0`,i=Pi(r),a=Ai(t.size||`1:1`,i),o=t.n??1,s=Ei(t),c;t.noPromptExtend===!0?c=!1:(t.promptExtend===!0||i)&&(c=!0);let l={model:r,input:{messages:[{role:`user`,content:[{text:n}]}]},parameters:{size:a,n:o,seed:t.seed,prompt_extend:c,watermark:t.watermark===!0?!0:void 0,negative_prompt:t.negativePrompt||void 0}},u=f(e.output);if(e.dryRun){M({request:l,mode:i?`sync`:`async`},u);return}e.quiet||process.stderr.write(`[Model: ${r}] [Mode: ${i?`sync`:`async`}]\n`),i?await Fi(e,r,l,t,u,s):await Ii(e,r,l,t,u,s)}})})),Vi,Hi=A((()=>{Ti(),ki(),U(),P(),Ni(),Vi=d({name:`image edit`,description:`Edit an existing image with text instructions (Qwen-Image)`,apiDocs:`/developer-reference/qwen-image-edit-api`,usage:`bl image edit --image <url> --prompt <text> [flags]`,options:[{flag:`--image <url>`,description:`Source image URL or local file path (repeatable for multi-image merge)`,required:!0,type:`array`},{flag:`--prompt <text>`,description:`Edit instruction text`,required:!0},{flag:`--model <model>`,description:`Model ID (default: qwen-image-2.0)`},{flag:`--size <W*H>`,description:`Output image size: ratio (3:4, 16:9) or pixels (2048*2048)`},{flag:`--n <count>`,description:`Number of images (default: 1, max: 6)`,type:`number`},{flag:`--seed <n>`,description:`Random seed for reproducible results`,type:`number`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--prompt-extend`,description:`Enable prompt smart rewrite (default: true)`},{flag:`--no-prompt-extend`,description:`Disable prompt extend`},{flag:`--watermark`,description:`Add watermark to output images`},{flag:`--out-dir <dir>`,description:`Download images to directory`},{flag:`--out-prefix <prefix>`,description:`Filename prefix (default: edited)`}],examples:[`bl image edit --image ./photo.png --prompt "把背景换成海滩"`,`bl image edit --image https://example.com/logo.png --prompt "Change color to blue" --n 3`,`bl image edit --image ./a.png --image ./b.png --prompt "把两张图合并成一张拼图"`,`bl image edit --image https://example.com/photo.png --prompt "Remove the person" --model qwen-image-2.0-pro`],async run(e,n){let r=[];Array.isArray(n.image)?r=n.image:typeof n.image==`string`&&(r=[n.image]),r.length===0&&H(`image`,`bl image edit --image <url> --prompt <text>`);let a=n.prompt;if(!a)if(x({nonInteractive:e.nonInteractive})){let e=await jr({message:`Enter your edit instruction:`});e||(process.stderr.write(`Image editing cancelled.
123
- `),process.exit(1)),a=e}else H(`prompt`,`bl image edit --image <url> --prompt <text>`);let o=n.model||e.defaultImageModel||`qwen-image-2.0`,s=await O(e),c=await Promise.all(r.map(e=>k(e,s.token,o))),l=n.n??1,u;u=n.noPromptExtend===!0?!1:(n.promptExtend,!0);let d=c.map(e=>({image:e}));d.push({text:a});let p={model:o,input:{messages:[{role:`user`,content:d}]},parameters:{size:Ai(n.size,!0),n:l,seed:n.seed,prompt_extend:u,watermark:n.watermark===!0?!0:void 0,negative_prompt:n.negativePrompt||void 0}};fe(p.parameters);let m=f(e.output);if(e.dryRun){M({request:p},m);return}e.quiet||process.stderr.write(`[Model: ${o}] [Mode: sync] [Images: ${c.length}]\n`);let g=b(e.baseUrl),_=(await Di(Ei(n),e,()=>D(e,{url:g,method:`POST`,body:p}))).flatMap(e=>e.output.choices||[]).flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);if(_.length===0)throw new t(`Edit completed but no images returned.`,i.GENERAL);let v=ce(e,{flagDir:n.outDir,subDir:n.outDir?void 0:`images`}),y=n.outPrefix||h(`edited`,n?.prompt),S=await Oi(_.length>1?_.map((e,t)=>({url:e,destPath:Le(v,`${y}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:_[0],destPath:Le(v,`${y}.png`)}],Ci,{quiet:e.quiet});e.quiet?N(S.join(`
124
- `)):M({urls:_,saved:S,total:_.length},m)}})}));function Ui(e){if(e)return Wi[e.toLowerCase()]||e}var Wi,Gi,Ki=A((()=>{Si(),Ti(),ki(),U(),P(),Wi={"720p":`1280*720`,"1080p":`1920*1080`,"480p":`832*480`},Gi=d({name:`video generate`,description:`Generate a video from text or image (happyhorse-1.0-t2v / happyhorse-1.0-i2v / wan2.6-t2v)`,apiDocs:`/best-practice/wanx/text-to-video`,usage:`bl video generate --prompt <text> [--image <url>] [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-t2v, or happyhorse-1.0-i2v with --image)`},{flag:`--prompt <text>`,description:`Video description`,required:!0},{flag:`--image <url>`,description:`Input image URL for image-to-video generation`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--resolution <res>`,description:`Resolution (e.g. 1280*720, 960*960)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (e.g. 16:9, 1:1)`},{flag:`--duration <seconds>`,description:`Video duration in seconds (default: 5)`,type:`number`},{flag:`--prompt-extend`,description:`Automatically extend prompt for better results`},{flag:`--watermark`,description:`Add watermark to generated video`},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--download <path>`,description:`Save video to file on completion`},{flag:`--no-wait`,description:`Return task ID immediately without waiting`},{flag:`--async`,description:`Return task ID immediately (agent/CI mode, same as --no-wait)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 5)`,type:`number`}],examples:[`bl video generate --prompt "一个人在读书,静态镜头"`,`bl video generate --prompt "Ocean waves at sunset." --download sunset.mp4`,`bl video generate --image https://example.com/cat.png --prompt "让画面中的猫动起来"`,`bl video generate --prompt "Mountain landscape" --resolution 1280*720 --duration 5`],async run(e,n){let r=n.prompt;if(!r)if(x({nonInteractive:e.nonInteractive})){let e=await jr({message:`Enter your video prompt:`});e||(process.stderr.write(`Video generation cancelled.
125
- `),process.exit(1)),r=e}else H(`prompt`,`bl video generate --prompt <text>`);let a=n.model||e.defaultVideoModel||(n.image?`happyhorse-1.0-i2v`:`happyhorse-1.0-t2v`),o=f(e.output),s=n.image,c;s&&(c=await k(s,(await O(e)).token,a));let l={model:a,input:{prompt:r,negative_prompt:n.negativePrompt||void 0,...c?{media:[{type:`first_frame`,url:c}]}:{}},parameters:{resolution:Ui(n.resolution)||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,prompt_extend:n.promptExtend===!0?!0:void 0,watermark:n.watermark===!0?!0:void 0,seed:n.seed}};if(e.dryRun){M({request:l},o);return}let u=Ei(n),d=ve(e.baseUrl),p=(await Di(u,e,()=>D(e,{url:d,method:`POST`,body:l,async:!0}),`tasks`)).map(e=>e.output.task_id);if(e.quiet||process.stderr.write(`[Model: ${a}]\n`),n.noWait||e.async){M(p.length===1?{task_id:p[0]}:{task_ids:p},o);return}let m=n.pollInterval??5,h=p.map(t=>xi(e,{url:pe(e.baseUrl,t),intervalSec:m,timeoutSec:e.timeout,isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}})),g=await Promise.all(h),_=[];for(let e=0;e<g.length;e++){let t=g[e],n=t.output.video_url||t.output.results&&t.output.results[0]?.url;n&&_.push({taskId:p[e],videoUrl:n})}if(_.length===0)throw new t(`All tasks completed but no video URLs returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Ci(_[0].videoUrl,t,{quiet:e.quiet});e.quiet?N(t):M({task_id:_[0].taskId,video_url:_[0].videoUrl,status:`SUCCEEDED`,saved:t,size:wi(r)},o);return}let v=ce(e,{subDir:`videos`}),{join:y}=await import(`path`),b=[];await Promise.all(_.map(async({taskId:t,videoUrl:n})=>{let r=y(v,`${t}.mp4`);await Ci(n,r,{quiet:e.quiet}),b.push({task_id:t,video_url:n,saved:r})})),b.length===1?M(b[0],o):M({videos:b,total:b.length},o)}})})),qi,Ji=A((()=>{Si(),Ti(),U(),P(),qi=d({name:`video edit`,description:`Edit a video with happyhorse-1.0-video-edit (style transfer, object replacement, etc.)`,apiDocs:`/best-practice/wanx/video-edit`,usage:`bl video edit --video <url> --prompt <text> [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-video-edit)`},{flag:`--video <url>`,description:`Input video URL or local file (mp4/mov, 2-10s)`,required:!0},{flag:`--prompt <text>`,description:`Edit instruction (e.g. "将画面转换为黏土风格")`},{flag:`--ref-image <url>`,description:`Reference image URL (up to 4, comma-separated)`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--resolution <res>`,description:`Resolution: 720P or 1080P (default: 1080P)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (16:9, 9:16, 1:1, 4:3, 3:4)`},{flag:`--duration <seconds>`,description:`Output video duration in seconds (2-10)`,type:`number`},{flag:`--audio-setting <mode>`,description:`Audio: auto (default) or origin (keep original)`},{flag:`--prompt-extend`,description:`Enable prompt intelligent rewriting (default: true)`},{flag:`--no-prompt-extend`,description:`Disable prompt intelligent rewriting`},{flag:`--watermark`,description:`Add "AI生成" watermark`},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--download <path>`,description:`Save video to file on completion`},{flag:`--no-wait`,description:`Return task ID immediately without waiting`},{flag:`--async`,description:`Return task ID immediately (agent/CI mode, same as --no-wait)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 15)`,type:`number`}],examples:[`bl video edit --video https://example.com/input.mp4 --prompt "将整个画面转换为黏土风格"`,`bl video edit --video https://example.com/input.mp4 --prompt "替换衣服为图片中的款式" --ref-image https://example.com/clothes.png`,`bl video edit --video https://example.com/input.mp4 --prompt "Convert to anime style" --resolution 720P --download output.mp4`],async run(e,n){let r=n.video;if(!r)if(x({nonInteractive:e.nonInteractive})){let e=await jr({message:`Enter the video URL to edit:`});e||(process.stderr.write(`Video editing cancelled.
126
- `),process.exit(1)),r=e}else H(`video`,`bl video edit --video <url> --prompt <text>`);let a=n.prompt;if(!a&&x({nonInteractive:e.nonInteractive})){let e=await jr({message:`Enter your edit instruction:`});e||(process.stderr.write(`Video editing cancelled.
127
- `),process.exit(1)),a=e}let o=n.model||`happyhorse-1.0-video-edit`,s=f(e.output),c=await O(e),l=[{type:`video`,url:await k(r,c.token,o)}],u=n.refImage;if(u){let e=u.split(`,`).map(e=>e.trim()).filter(Boolean);for(let t of e){let e=await k(t,c.token,o);l.push({type:`reference_image`,url:e})}}let d=n.noPromptExtend===!0?!1:n.promptExtend===!0?!0:void 0,p={model:o,input:{prompt:a||void 0,negative_prompt:n.negativePrompt||void 0,media:l},parameters:{resolution:n.resolution||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,audio_setting:n.audioSetting||void 0,prompt_extend:d,watermark:n.watermark===!0?!0:void 0,seed:n.seed}};if(e.dryRun){M({request:p},s);return}let m=(await D(e,{url:ve(e.baseUrl),method:`POST`,body:p,async:!0})).output.task_id;if(e.quiet||(process.stderr.write(`[Model: ${o}]\n`),process.stderr.write(`Note: Video editing typically takes 5-8 minutes. Please be patient.
128
- `)),n.noWait||e.async){M({task_id:m},s);return}let h=n.pollInterval??15,g=await xi(e,{url:pe(e.baseUrl,m),intervalSec:h,timeoutSec:Math.max(e.timeout,600),isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}}),_=g.output.video_url||g.output.results&&g.output.results[0]?.url;if(!_)throw new t(`Task completed but no video URL returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Ci(_,t,{quiet:e.quiet});e.quiet?N(t):M({task_id:m,video_url:_,status:`SUCCEEDED`,saved:t,size:wi(r)},s);return}let v=await import(`path`),y=ce(e,{subDir:`videos`}),b=v.join(y,`${m}.mp4`);await Ci(_,b,{quiet:e.quiet}),M({task_id:m,video_url:_,saved:b},s)}})})),Yi,Xi=A((()=>{Si(),Ti(),U(),P(),Yi=d({name:`video ref`,description:`Reference-to-video generation (happyhorse-1.0-r2v / wan2.6-r2v): multi-subject, multi-shot with voice`,apiDocs:`/best-practice/wanx/video-reference`,usage:`bl video ref --prompt <text> --image <url>... [--ref-video <url>...] [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-r2v)`},{flag:`--prompt <text>`,description:`Video description with reference markers (图1, 视频1, etc.)`,required:!0},{flag:`--image <url>`,description:`Reference image URL or local file (repeatable for multiple subjects)`,type:`array`},{flag:`--ref-video <url>`,description:`Reference video URL or local file (repeatable)`,type:`array`},{flag:`--image-voice <url>`,description:`Voice URL for corresponding image (pairs by position)`,type:`array`},{flag:`--video-voice <url>`,description:`Voice URL for corresponding ref-video (pairs by position)`,type:`array`},{flag:`--resolution <res>`,description:`Resolution: 720P or 1080P (default: 720P)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (16:9, 9:16, 1:1)`},{flag:`--duration <seconds>`,description:`Video duration in seconds (2-10, default: 5)`,type:`number`},{flag:`--prompt-extend`,description:`Enable prompt intelligent rewriting`},{flag:`--no-prompt-extend`,description:`Disable prompt intelligent rewriting`},{flag:`--watermark`,description:`Add watermark to generated video`},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--download <path>`,description:`Save video to file on completion`},{flag:`--no-wait`,description:`Return task ID immediately without waiting`},{flag:`--async`,description:`Return task ID immediately (agent/CI mode, same as --no-wait)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 15)`,type:`number`}],examples:[`bl video ref --prompt "图1在草地上奔跑" --image person.jpg`,`bl video ref --prompt "视频1在弹吉他,图1走过来" --ref-video scene.mp4 --image person.jpg`,`bl video ref --prompt "图1说话" --image person.jpg --image-voice voice.mp3 --resolution 1080P`,`bl video ref --prompt "图1和图2在对话" --image a.jpg --image b.jpg --image-voice va.mp3 --image-voice vb.mp3`],async run(e,n){let r=n.prompt;if(!r)if(x({nonInteractive:e.nonInteractive})){let e=await jr({message:`Enter your video prompt (use 图1, 视频1 to reference inputs):`});e||(process.stderr.write(`Video generation cancelled.
129
- `),process.exit(1)),r=e}else H(`prompt`,`bl video ref --prompt <text> --image <url>`);let a=n.image||[],o=n.refVideo||[];if(a.length===0&&o.length===0)throw new t(`At least one --image or --ref-video is required.`,i.USAGE,`bl video ref --prompt "描述" --image person.jpg`);let s=n.imageVoice||[],c=n.videoVoice||[],l=n.model||`happyhorse-1.0-r2v`,u=f(e.output),d=await O(e),p=[];for(let e=0;e<a.length;e++){let t={type:`reference_image`,url:await k(a[e],d.token,l)};s[e]&&(t.reference_voice=await k(s[e],d.token,l)),p.push(t)}for(let e=0;e<o.length;e++){let t={type:`reference_video`,url:await k(o[e],d.token,l)};c[e]&&(t.reference_voice=await k(c[e],d.token,l)),p.push(t)}let m=n.noPromptExtend===!0?!1:n.promptExtend===!0?!0:void 0,h={model:l,input:{prompt:r,media:p},parameters:{resolution:n.resolution||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,prompt_extend:m,watermark:n.watermark===!0?!0:void 0,seed:n.seed}};if(e.dryRun){M({request:h},u);return}let g=(await D(e,{url:ve(e.baseUrl),method:`POST`,body:h,async:!0})).output.task_id;if(e.quiet||(process.stderr.write(`[Model: ${l}]\n`),process.stderr.write(`Note: Reference-to-video typically takes 5-10 minutes. Please be patient.
130
- `)),n.noWait||e.async){M({task_id:g},u);return}let _=n.pollInterval??15,v=await xi(e,{url:pe(e.baseUrl,g),intervalSec:_,timeoutSec:Math.max(e.timeout,600),isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}}),y=v.output.video_url||v.output.results&&v.output.results[0]?.url;if(!y)throw new t(`Task completed but no video URL returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Ci(y,t,{quiet:e.quiet});e.quiet?N(t):M({task_id:g,video_url:y,status:`SUCCEEDED`,saved:t,size:wi(r)},u);return}let{join:b}=await import(`path`),S=b(ce(e,{subDir:`videos`}),`${g}.mp4`);await Ci(y,S,{quiet:e.quiet}),M({task_id:g,video_url:y,saved:S},u)}})})),Zi,Qi=A((()=>{U(),P(),Zi=d({name:`video task get`,description:`Query async task status`,usage:`bl video task get --task-id <id>`,options:[{flag:`--task-id <id>`,description:`Async task ID`}],examples:[`bl video task get --task-id 3b256896-3e70-xxxx-xxxx-xxxxxxxxxxxx`,`bl video task get --task-id 3b256896-3e70-xxxx --output json`],async run(e,t){let n=t.taskId;n||H(`task-id`,`bl video task get --task-id <id>`);let r=f(e.output);if(e.dryRun){M({task_id:n},r);return}let i=await D(e,{url:pe(e.baseUrl,n)});if(e.quiet){N(i.output.task_status);return}M({task_id:i.output.task_id,task_status:i.output.task_status,video_url:i.output.video_url,results:i.output.results,submit_time:i.output.submit_time,end_time:i.output.end_time},r)}})})),$i,ea=A((()=>{Ti(),U(),P(),$i=d({name:`video download`,description:`Download a completed video by task ID`,usage:`bl video download --task-id <id> --out <path>`,options:[{flag:`--task-id <id>`,description:`Task ID to download from`},{flag:`--out <path>`,description:`Output file path`}],examples:[`bl video download --task-id 3b256896-xxxx --out video.mp4`,`bl video download --task-id 3b256896-xxxx --out video.mp4 --quiet`],async run(e,n){let r=n.taskId;r||H(`task-id`,`bl video download --task-id <id> --out <path>`);let a=n.out;a||H(`out`,`bl video download --task-id <id> --out video.mp4`);let o=f(e.output);if(e.dryRun){M({task_id:r,action:`download`,out:a},o);return}let s=await D(e,{url:pe(e.baseUrl,r)});if(s.output.task_status!==`SUCCEEDED`)throw new t(`Task is not complete (status: ${s.output.task_status}).`,i.GENERAL,`Wait for the task to complete before downloading.`);let c=s.output.video_url||s.output.results&&s.output.results[0]?.url;if(!c)throw new t(`No download URL available for this task.`,i.GENERAL);let{size:l}=await Ci(c,a,{quiet:e.quiet});if(e.quiet){N(a);return}M({saved:a,size:wi(l)},o)}})}));function ta(e){let t=Ie(e).toLowerCase().split(`?`)[0];return!!(ia.has(t)||/\.(mp4|mov|avi|mkv|webm|flv|wmv)(\?|$)/i.test(e))}async function na(e){if(e.startsWith(`data:`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`oss://`))return e;if(!Ae(e))throw new t(`File not found: ${e}`,i.USAGE);let n=Ie(e).toLowerCase(),r=ra[n];if(!r)throw new t(`Unsupported image format "${n}". Supported: jpg, jpeg, png, webp`,i.USAGE);return`data:${r};base64,${Me(e).toString(`base64`)}`}var ra,ia,aa,oa=A((()=>{U(),P(),ra={".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".webp":`image/webp`},ia=new Set([`.mp4`,`.mov`,`.avi`,`.mkv`,`.webm`,`.flv`,`.wmv`]),aa=d({name:`vision describe`,description:`Describe an image or video using Qwen-VL`,usage:`bl vision describe --image <path-or-url> [--video <url>] [--prompt <text>]`,options:[{flag:`--image <path-or-url>`,description:`Local image path or URL`},{flag:`--video <url>`,description:`Video file URL or local path (mp4/mov/avi/mkv/webm)`,type:`array`},{flag:`--prompt <text>`,description:`Question about the content (default: auto-detected)`},{flag:`--model <model>`,description:`Vision model (default: qwen-vl-max)`}],examples:[`bl vision describe --image photo.jpg`,`bl vision describe --image https://example.com/photo.jpg --prompt "这只狗是什么品种?"`,`bl vision describe --video https://example.com/video.mp4 --prompt "总结视频内容"`,`bl vision describe --video ./local-video.mp4`,`bl vision describe --image photo.png --prompt "Extract the text" --model qwen-vl-plus`],async run(e,n){let r=n.image??n._positional?.[0],a=n.video??[],o=n.model||`qwen-vl-max`;r&&ta(r)&&(a.push(r),r=void 0);let s=a.length>0,c=s?`Describe the video.`:`Describe the image.`,u=n.prompt||c;if(!r&&!s)if(x({nonInteractive:e.nonInteractive})){let e=await jr({message:`Enter image/video path or URL:`});e||(process.stderr.write(`Vision describe cancelled.
131
- `),process.exit(1)),ta(e)?a.push(e):r=e}else throw new t(`Missing required argument --image or --video.`,i.USAGE,`bl vision describe --image <path-or-url>
132
- bl vision describe --video <url-or-path>`);let d=f(e.output);if(e.dryRun){M({request:{prompt:u,image:r,video:a.length?a:void 0,model:o}},d);return}let p=[];if(a.length>0)for(let n of a){let r=n;if(S(n)){if(!Ae(n))throw new t(`Video file not found: ${n}`,i.USAGE);r=await k(n,(await O(e)).token,o)}p.push({type:`video_url`,video_url:{url:r}})}if(r){let t=await na(r),n=t;if(S(r)&&t.startsWith(`data:`)){let{statSync:t}=await import(`fs`);if(t(r).size>5*1024*1024){let t=await O(e);n=await k(r,t.token,o)}}p.push({type:`image_url`,image_url:{url:n}})}p.push({type:`text`,text:u});let m={model:o,messages:[{role:`user`,content:p}]},h=await D(e,{url:l(e.baseUrl),method:`POST`,body:m}),g=h.choices?.[0]?.message?.content;if(d!==`text`){M(h,d);return}N(g||``)}})})),sa,ca=A((()=>{P(),sa=d({name:`config show`,description:`Display current configuration`,usage:`bl config show`,examples:[`bl config show`,`bl config show --output json`],async run(e,t){let n=ae(),r=f(e.output),i={region:e.region,base_url:e.baseUrl,output:e.output,timeout:e.timeout,config_file:v()};n.api_key&&(i.api_key=w(n.api_key)),n.access_token&&(i.access_token=w(n.access_token)),n.default_text_model&&(i.default_text_model=n.default_text_model),n.default_video_model&&(i.default_video_model=n.default_video_model),n.default_image_model&&(i.default_image_model=n.default_image_model),M(i,r)}})})),la,ua,da,fa=A((()=>{P(),la=[`region`,`base_url`,`output`,`output_dir`,`timeout`,`api_key`,`access_token`,`default_text_model`,`default_video_model`,`default_image_model`,`default_speech_model`,`default_omni_model`,`access_key_id`,`access_key_secret`,`workspace_id`],ua={"base-url":`base_url`,"output-dir":`output_dir`,"api-key":`api_key`,"access-token":`access_token`,"default-text-model":`default_text_model`,"default-video-model":`default_video_model`,"default-image-model":`default_image_model`,"default-speech-model":`default_speech_model`,"default-omni-model":`default_omni_model`,"access-key-id":`access_key_id`,"access-key-secret":`access_key_secret`,"workspace-id":`workspace_id`},da=d({name:`config set`,description:`Set a config value`,usage:`bl config set --key <key> --value <value>`,options:[{flag:`--key <key>`,description:`Config key (region, base_url, output, output_dir, timeout, api_key, access_token, default_*_model, access_key_id, access_key_secret, workspace_id)`},{flag:`--value <value>`,description:`Value to set`}],examples:[`bl config set --key output --value json`,`bl config set --key timeout --value 600`,`bl config set --key base_url --value https://dashscope.aliyuncs.com`],async run(e,n){let r=n.key,a=n.value;if(!r||a===void 0)throw new t(`--key and --value are required.`,i.USAGE,`bl config set --key <key> --value <value>`);let o=ua[r]||r;if(!la.includes(o))throw new t(`Invalid config key "${r}". Valid keys: ${la.join(`, `)}`,i.USAGE);if(o===`region`&&![`cn`,`us`,`intl`].includes(a))throw new t(`Invalid region "${a}". Valid values: cn, us, intl`,i.USAGE);if(o===`output`&&![`text`,`json`].includes(a))throw new t(`Invalid output format "${a}". Valid values: text, json`,i.USAGE);if(o===`timeout`){let e=Number(a);if(isNaN(e)||e<=0)throw new t(`Invalid timeout "${a}". Must be a positive number.`,i.USAGE)}let s=f(e.output);if(e.dryRun){M({would_set:{[o]:a}},s);return}let c=ae();c[o]=o===`timeout`?Number(a):a,await ye(c),e.quiet||M({[o]:c[o]},s)}})})),pa,ma,ha=A((()=>{pa=[`auth `,`config `,`update`],ma=d({name:`config export-schema`,description:`Export all (or one) CLI command(s) as Anthropic/OpenAI-compatible JSON tool schemas`,usage:`bl config export-schema [--command "<name>"]`,options:[{flag:`--command <name>`,description:`Export schema for a specific command only (e.g. "image generate")`}],examples:[`bl config export-schema`,`bl config export-schema --command "video generate"`],async run(e,n){let{commands:r}=await Promise.resolve().then(()=>(jd(),kd)),a=n.command;if(a){let e=r[a];if(!e)throw new t(`Command "${a}" not found.`,i.USAGE);let n=g(e);process.stdout.write(JSON.stringify(n,null,2)+`
133
- `);return}let o=Object.values(r).filter(e=>!pa.some(t=>e.name.startsWith(t))).map(e=>g(e));process.stdout.write(JSON.stringify(o,null,2)+`
134
- `)}})}));Zr(),oi(),li(),fi(),gi(),Bi(),Hi(),Ki(),Ji(),Xi(),Qi(),ea(),oa(),ca(),fa(),ha();var ga=`1.1.1`,_a,va=A((()=>{_a=ga}));function ya(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if((n[e]??0)>(r[e]??0))return!0;if((n[e]??0)<(r[e]??0))return!1}return!1}function ba(){try{let e=Me(Da(),`utf-8`);return JSON.parse(e)}catch{return null}}function xa(e){try{Pe(Da(),JSON.stringify(e))}catch{}}async function Sa(e=ka){try{let t=Ea.replace(`/`,`%2f`),n=await fetch(`${Ta}/${t}/latest`,{headers:{Accept:`application/json`,...he()},signal:AbortSignal.timeout(e)});return n.ok?(await n.json()).version??null:null}catch{return null}}function Ca(){return Aa}async function wa(e){if(process.env.CI||!process.stderr.isTTY)return;let t=ba(),n=Date.now();if(t&&n-t.lastChecked<Oa){t.latestVersion&&ya(t.latestVersion,e)&&(Aa=t.latestVersion);return}let r=await Sa();r&&(xa({lastChecked:n,latestVersion:r}),r&&ya(r,e)&&(Aa=r))}var Ta,Ea,Da,Oa,ka,Aa,ja=A((()=>{Ta=`https://registry.npmjs.org`,Ea=`bailian-cli`,Da=()=>Le(_(),`update-state.json`),Oa=14400*1e3,ka=3e3,Aa=null}));function Ma(){return{cmd:`npm install -g ${Ea}@latest`,label:`npm`}}var Na,Pa=A((()=>{va(),ja(),Na=d({name:`update`,description:`Update bl to the latest version`,usage:`bl update`,examples:[`bl update`],async run(){let e=process.stderr.isTTY,t=e?`\x1B[32m`:``,n=e?`\x1B[33m`:``,r=e?`\x1B[0m`:``;process.stderr.write(`Current version: ${n}${_a}${r}\n`),process.stderr.write(`Checking for updates...
135
- `);let i=await Sa(5e3);if(i&&i===_a){process.stderr.write(`${t}\u2713 Already up to date (${_a}).${r}\n`);return}i&&process.stderr.write(`Latest version: ${t}${i}${r}\n\n`);let{cmd:a,label:o}=Ma();process.stderr.write(`Updating ${Ea} via ${o}...\n\n`);try{Re(a,{stdio:`inherit`});try{let e=Re(`bl --version 2>/dev/null`,{encoding:`utf-8`}).trim().replace(/^bl\s+/,``);process.stderr.write(`\n${t}\u2713 Update complete: ${_a} \u2192 ${e}${r}\n`);try{Pe(Le(_(),`update-state.json`),JSON.stringify({lastChecked:Date.now(),latestVersion:e}))}catch{}}catch{process.stderr.write(`\n${t}\u2713 Update complete.${r}\n`)}}catch{process.stderr.write(`
116
+ `)}})}));function hi(e){let t=[],n;if(e.system&&(n=e.system),e.messagesFile){let r=e.messagesFile,i=je(r===`-`?`/dev/stdin`:r,`utf-8`),a=JSON.parse(i);for(let e of a)e.role===`system`?n=typeof e.content==`string`?e.content:``:t.push(e)}if(e.message){let r=new Set([`system`,`user`,`assistant`]),i=e.message;for(let e of i){let i=e.indexOf(`:`),a=i===-1?``:e.slice(0,i);if(r.has(a)){let r=e.slice(i+1);a===`system`?n=r:t.push({role:a,content:r})}else t.push({role:`user`,content:e})}}return{system:n,messages:t}}var gi,_i=j((()=>{W(),F(),gi=d({name:`text chat`,description:`Send a chat completion (OpenAI compatible, DashScope)`,apiDocs:`/compatibility-of-openai-with-dashscope`,usage:`bl text chat --message <text> [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: qwen3.7-max)`},{flag:`--message <text>`,description:`Message text (repeatable, prefix role: to set role)`,required:!0,type:`array`},{flag:`--messages-file <path>`,description:`JSON file with messages array (use - for stdin)`},{flag:`--system <text>`,description:`System prompt`},{flag:`--max-tokens <n>`,description:`Maximum tokens to generate (default: 4096)`,type:`number`},{flag:`--temperature <n>`,description:`Sampling temperature (0.0, 2.0]`,type:`number`},{flag:`--top-p <n>`,description:`Nucleus sampling threshold`,type:`number`},{flag:`--stream`,description:`Stream response tokens (default: on in TTY)`},{flag:`--tool <json-or-path>`,description:`Tool definition as JSON or file path (repeatable)`,type:`array`},{flag:`--enable-thinking`,description:`Enable thinking/reasoning mode (for qwen3/qwq models)`},{flag:`--thinking-budget <n>`,description:`Max tokens for thinking (default: 4096)`,type:`number`}],examples:[`bl text chat --message "What is Qwen?"`,`bl text chat --model qwen-max --system "You are a coding assistant." --message "Write fizzbuzz in Python"`,`bl text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"`,`cat conversation.json | bl text chat --messages-file - --stream`,`bl text chat --message "Hello" --output json`,`bl text chat --model qwq-plus --message "Solve 1+1" --enable-thinking`],async run(e,t){let{system:n,messages:r}=hi(t),i=r;if(i.length===0)if(x({nonInteractive:e.nonInteractive})){let e=await Ar({message:`Enter your message:`});e||(process.stderr.write(`Chat cancelled.
117
+ `),process.exit(1)),i=[{role:`user`,content:e}]}else U(`message`,`bl text chat --message <text>`);let a=t.model||e.defaultTextModel||`qwen3.7-max`,o=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,s=f(e.output),c=[];n&&c.push({role:`system`,content:n}),c.push(...i);let u={model:a,messages:c,max_tokens:t.maxTokens??4096,stream:o};if(t.temperature!==void 0&&(u.temperature=t.temperature),t.topP!==void 0&&(u.top_p=t.topP),t.enableThinking&&(u.enable_thinking=!0,t.thinkingBudget!==void 0&&(u.thinking_budget=t.thinkingBudget)),t.tool&&(u.tools=t.tool.map(e=>{try{return JSON.parse(e)}catch{let t=je(e,`utf-8`);return JSON.parse(t)}})),e.dryRun){N({request:u},s);return}let d=l(e.baseUrl);if(o){let t=await ae(e,{url:d,method:`POST`,body:u,stream:!0}),n=``,r=!1,i=s===`text`,a=e.noColor?``:`\x1B[2m`,o=e.noColor?``:`\x1B[0m`,c=process.stdout.isTTY,l=s===`json`?process.stderr:c?process.stdout:process.stderr,f=process.stdout;for await(let e of re(t)){if(e.data===`[DONE]`)break;try{let t=JSON.parse(e.data);for(let e of t.choices){let t=e.delta;t.reasoning_content&&(i&&!r&&(r=!0,l.write(`${a}Thinking:\n`)),i&&l.write(t.reasoning_content)),t.content&&(i&&r&&(l.write(`${o}\n\nResponse:\n`),r=!1),n+=t.content,i&&f.write(t.content))}}catch{}}r&&l.write(o),s===`json`?N({content:n},s):f.write(`
118
+ `)}else{let t=await O(e,{url:d,method:`POST`,body:u}),n=t.choices?.[0]?.message?.content??``;e.quiet||s===`text`?P(n):N(t,s)}}})}));function vi(e){let t=Buffer.alloc(44);return t.write(`RIFF`,0),t.writeUInt32LE(36+e,4),t.write(`WAVE`,8),t.write(`fmt `,12),t.writeUInt32LE(16,16),t.writeUInt16LE(1,20),t.writeUInt16LE(1,22),t.writeUInt32LE(24e3,24),t.writeUInt32LE(48e3,28),t.writeUInt16LE(2,32),t.writeUInt16LE(16,34),t.write(`data`,36),t.writeUInt32LE(e,40),t}var yi,bi,xi=j((()=>{W(),F(),yi=[`Chelsie`,`Cherry`,`Ethan`,`Serena`,`Tina`],bi=d({name:`omni`,description:`Multimodal chat with text + audio output (Qwen-Omni)`,apiDocs:`/model-studio/qwen-omni`,usage:`bl omni --message <text> [flags]`,options:[{flag:`--message <text>`,description:`Message text (repeatable, prefix role: to set role)`,required:!0,type:`array`},{flag:`--model <model>`,description:`Model ID (default: qwen3.5-omni-plus)`},{flag:`--system <text>`,description:`System prompt`},{flag:`--image <url>`,description:`Image URL or local file (repeatable)`,type:`array`},{flag:`--audio <url>`,description:`Audio URL or local file (repeatable)`,type:`array`},{flag:`--video <url>`,description:`Video file URL / local path, or comma-separated frame URLs`,type:`array`},{flag:`--voice <voice>`,description:`Output voice (default: Cherry). Options: ${yi.join(`, `)}`},{flag:`--audio-format <fmt>`,description:`Audio output format (default: wav)`},{flag:`--audio-out <path>`,description:`Save audio to file (default: auto-generate)`},{flag:`--text-only`,description:`Output text only, no audio generation`},{flag:`--max-tokens <n>`,description:`Maximum tokens to generate`,type:`number`},{flag:`--temperature <n>`,description:`Sampling temperature (0.0, 2.0]`,type:`number`}],examples:[`bl omni --message "你好,你是谁?"`,`bl omni --message "描述这张图片" --image ./photo.jpg`,`bl omni --message "这段音频在说什么?" --audio https://example.com/audio.wav`,`bl omni --message "总结这个视频" --video https://example.com/video.mp4`,`bl omni --message "这个视频讲了什么" --video ./local-video.mp4 --text-only`,`bl omni --message "用四川话回答:今天天气怎么样" --voice Serena`,`bl omni --message "Hello" --text-only --output json`,`bl omni --message "朗读这段话" --audio-out greeting.wav`],async run(e,t){let n=[];if(t.message&&(n=t.message),n.length===0)if(x({nonInteractive:e.nonInteractive})){let e=await Ar({message:`Enter your message:`});e||(process.stderr.write(`Omni chat cancelled.
119
+ `),process.exit(1)),n=[e]}else U(`message`,`bl text omni --message <text>`);let r=t.model||e.defaultOmniModel||`qwen3.5-omni-plus`,i=t.voice||`Cherry`,a=t.audioFormat||`wav`,o=t.textOnly===!0,s=f(e.output),c=[];t.system&&c.push({role:`system`,content:t.system});let u=new Set([`system`,`user`,`assistant`]);for(let e of n){let t=e.indexOf(`:`),n=t===-1?``:e.slice(0,t);if(u.has(n)){let r=e.slice(t+1);n===`system`?c.push({role:`system`,content:r}):c.push({role:n,content:r})}else c.push({role:`user`,content:e})}let d=t.image||[],p=t.audio||[],m=t.video||[],h=[],g=[],_=[];if(d.length>0||p.length>0||m.length>0){let t=await k(e);for(let e of d){let n=await A(e,t.token,r);h.push(n)}for(let e of p){let n=await A(e,t.token,r);g.push(n)}for(let e of m)if(e.includes(`,`)){let n=e.split(`,`).map(e=>e.trim()).filter(Boolean);for(let e of n){let n=await A(e,t.token,r);_.push(`frame:${n}`)}}else{let n=await A(e,t.token,r);_.push(n)}}if(h.length>0||g.length>0||_.length>0){for(let e=c.length-1;e>=0;e--)if(c[e].role===`user`){let t=c[e].content,n=[];typeof t==`string`?n.push({type:`text`,text:t}):Array.isArray(t)&&n.push(...t);for(let e of h)n.push({type:`image_url`,image_url:{url:e}});for(let e of g)n.push({type:`audio_url`,audio_url:{url:e}});let r=_.filter(e=>e.startsWith(`frame:`)).map(e=>e.slice(6)),i=_.filter(e=>!e.startsWith(`frame:`));r.length>0&&n.push({type:`video`,video:r});for(let e of i)n.push({type:`video_url`,video_url:{url:e}});c[e]={role:`user`,content:n};break}}let v={model:r,messages:c,stream:!0,stream_options:{include_usage:!0}};if(o||(v.modalities=[`text`,`audio`],v.audio={voice:i,format:a}),t.maxTokens!==void 0&&(v.max_tokens=t.maxTokens),t.temperature!==void 0&&(v.temperature=t.temperature),e.dryRun){N({request:v},s);return}if(!e.quiet){let e=o?`text-only`:`text+audio, voice: ${i}`;process.stderr.write(`[Model: ${r}] [${e}]\n`)}let y=await ae(e,{url:l(e.baseUrl),method:`POST`,body:v,stream:!0}),b=``,S=``,C=process.stdout.isTTY,w=process.stdout;for await(let e of re(y)){if(e.data===`[DONE]`)break;try{let t=JSON.parse(e.data);for(let e of t.choices){let t=e.delta;t.content&&(b+=t.content,C&&w.write(t.content)),t.audio?.data&&(S+=t.audio.data)}}catch{}}C&&b&&w.write(`
120
+ `);let T;if(S&&!o){let n=Buffer.from(S,`base64`),r=vi(n.length),i=Buffer.concat([r,n]),a=t.audioOut;if(!a){let{join:t}=await import(`path`);a=t(se(e,{subDir:`omni`}),`omni_${Date.now()}.wav`)}Ne(a,i),T=a,e.quiet||process.stderr.write(`Audio saved: ${a}\n`)}if(!C||s===`json`){let e={content:b};T&&(e.audio_saved=T,e.voice=i),N(e,s)}}})}));function Si(e){let t=process.stderr.isTTY,n=0,r=null,i=e;return{start(){t&&(r=setInterval(()=>{process.stderr.write(`\r${wi[n%wi.length]} ${i}`),n++},80))},update(e){i=e},stop(e){r&&=(clearInterval(r),null),t&&(process.stderr.write(`\r\x1B[K`),e&&process.stderr.write(`${e}\n`))}}}function Ci(e,t=``){let n=process.stderr.isTTY;return{update(r){if(!n)return;let i=Math.min(1,r/e),a=Math.round(30*i),o=30-a,s=`█`.repeat(a)+`░`.repeat(o),c=`${Math.round(i*100)}%`;process.stderr.write(`\r${t} ${s} ${c}`)},finish(){n&&process.stderr.write(`
121
+ `)}}}var wi,Ti=j((()=>{wi=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`]}));async function Ei(e,n){let r=Date.now()+n.timeoutSec*1e3,a=Si(`Polling...`);e.quiet||a.start();try{for(;Date.now()<r;){let r=await O(e,{url:n.url});if(n.getStatus&&!e.quiet&&a.update(`Status: ${n.getStatus(r)}`),n.isComplete(r))return a.stop(`Done.`),r;if(n.isFailed(r)){a.stop(`Failed.`),e.verbose&&process.stderr.write(`[verbose] Task response: ${JSON.stringify(r,null,2)}\n`);let o=n.getErrorMessage?.(r);throw new t(o?`Task failed: ${o}`:`Task failed.`,i.GENERAL,o?void 0:`Use --verbose to see full API response details.`)}await new Promise(e=>setTimeout(e,n.intervalSec*1e3))}}finally{a.stop()}throw new t(`Polling timed out.`,i.TIMEOUT,`Try increasing --timeout or check task status manually.`)}var Di=j((()=>{Ti()}));async function Oi(e,n,r){let a=await fetch(e,{headers:me()});if(!a.ok)throw new t(`Download failed: HTTP ${a.status}`,i.GENERAL);let o=Number(a.headers.get(`content-length`)||0),s=a.body?.getReader();if(!s)throw new t(`No response body`,i.GENERAL);Ae(Pe(n),{recursive:!0});let c=Oe(n),l=o>0&&!r?.quiet?Ci(o,`Downloading`):null,u=0,d=!1;try{let e=new Promise((e,t)=>{c.on(`error`,t)});for(;;){let{done:t,value:n}=await Promise.race([s.read(),e]);if(t)break;c.write(n)||await new Promise(e=>c.once(`drain`,()=>e())),u+=n.byteLength,l?.update(u)}d=!0}finally{if(s.releaseLock(),l?.finish(),await new Promise((e,t)=>{c.on(`finish`,e),c.on(`error`,t),c.end()}),!d)try{Me(n)}catch{}}return{size:u}}function ki(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}var Ai=j((()=>{Ti()}));function ji(e){let t=e.concurrent;return Math.max(1,t??1)}async function Mi(e,t,n,r=`requests`){if(e<=1)return[await n(0)];t.quiet||process.stderr.write(`[Concurrent: ${e} ${r}]\n`);let i=Array.from({length:e},(e,t)=>n(t));return Promise.all(i)}async function Ni(e,t,n){return Promise.all(e.map(({url:e,destPath:r})=>t(e,r,n).then(()=>r)))}var Pi=j((()=>{}));function Fi(e,t){if(e)return(t?Ii:Li)[e]??e}var Ii,Li,Ri=j((()=>{Ii={"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},Li={"16:9":`1664*928`,"4:3":`1472*1104`,"1:1":`1328*1328`,"3:4":`1104*1472`,"9:16":`928*1664`}}));function zi(e){return Ui.some(t=>e.startsWith(t))}async function Bi(e,n,r,a,o,s){let c=b(e.baseUrl),l=(await Mi(s,e,()=>O(e,{url:c,method:`POST`,body:r}))).flatMap(e=>e.output.choices||[]).flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);if(l.length===0)throw new t(`Generation completed but no images returned.`,i.GENERAL);await Hi(l,a,e,o)}async function Vi(e,n,r,a,o,s){let c=y(e.baseUrl),l=(await Mi(s,e,()=>O(e,{url:c,method:`POST`,body:r,async:!0}),`tasks`)).map(e=>e.output.task_id);if(a.noWait||e.async){N({task_ids:l},o);return}let u=a.pollInterval??3,d=l.map(t=>Ei(e,{url:fe(e.baseUrl,t),intervalSec:u,timeoutSec:e.timeout,isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}})),f=await Promise.all(d),p=[];for(let e of f){if(e.output.choices){let t=e.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);p.push(...t)}if(e.output.results){let t=e.output.results.map(e=>e.url).filter(Boolean);t.length>0&&p.length===0&&p.push(...t)}}if(p.length===0)throw new t(`All tasks completed but no images returned.`,i.GENERAL);await Hi(p,a,e,o,l.length===1?l[0]:void 0,l)}async function Hi(e,t,n,r,i,a){let o=se(n,{flagDir:t.outDir,subDir:t.outDir?void 0:`images`}),s=t.prompt||t._positional?.[0]||``,c=t.outPrefix||h(`image`,s),l=await Ni(e.length>1?e.map((e,t)=>({url:e,destPath:Ie(o,`${c}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:e[0],destPath:Ie(o,`${c}.png`)}],Oi,{quiet:n.quiet});if(n.quiet)P(l.join(`
122
+ `));else{let t={urls:e,saved:l,total:e.length};i&&(t.task_id=i),a&&a.length>1&&(t.task_ids=a),N(t,r)}}var Ui,Wi,Gi=j((()=>{Di(),Ai(),Pi(),W(),F(),Ri(),Ui=[`qwen-image-2.0`,`qwen-image-max`],Wi=d({name:`image generate`,description:`Generate images (Qwen-Image / wan2.x)`,apiDocs:`/best-practice/wanx/text-to-image`,usage:`bl image generate --prompt <text> [flags]`,options:[{flag:`--prompt <text>`,description:`Image description`,required:!0},{flag:`--model <model>`,description:`Model ID (default: qwen-image-2.0)`},{flag:`--size <W*H>`,description:`Image size: ratio (3:4, 16:9, 1:1) or pixels (2048*2048)`},{flag:`--n <count>`,description:`Number of images per request (default: 1, max: 6)`,type:`number`},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--prompt-extend`,description:`Automatically extend prompt for better results (default: true for qwen-image)`},{flag:`--no-prompt-extend`,description:`Disable prompt extend`},{flag:`--watermark`,description:`Add watermark to generated images`},{flag:`--no-wait`,description:`Return task ID immediately without waiting (async models only)`},{flag:`--out-dir <dir>`,description:`Download images to directory`},{flag:`--out-prefix <prefix>`,description:`Filename prefix (default: image)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 3)`,type:`number`}],examples:[`bl image generate --prompt "一只穿太空服的猫在火星上"`,`bl image generate --prompt "Logo design" --n 3 --out-dir ./generated/`,`bl image generate --prompt "Mountain landscape" --size 2688*1536`,`bl image generate --prompt "A castle" --seed 42 --no-prompt-extend`,`bl image generate --prompt "sunset" --model wan2.6-t2i --no-wait --quiet`,`bl image generate --prompt "Pro quality" --model qwen-image-2.0-pro`,`bl image generate --prompt "Product shots" --n 2 --concurrent 3 # 6 images in parallel`],async run(e,t){let n=t.prompt??t._positional?.[0];if(!n)if(x({nonInteractive:e.nonInteractive})){let e=await Ar({message:`Enter your image prompt:`});e||(process.stderr.write(`Image generation cancelled.
123
+ `),process.exit(1)),n=e}else U(`prompt`,`bl image generate --prompt <text>`);let r=t.model||e.defaultImageModel||`qwen-image-2.0`,i=zi(r),a=Fi(t.size||`1:1`,i),o=t.n??1,s=ji(t),c;t.noPromptExtend===!0?c=!1:(t.promptExtend===!0||i)&&(c=!0);let l={model:r,input:{messages:[{role:`user`,content:[{text:n}]}]},parameters:{size:a,n:o,seed:t.seed,prompt_extend:c,watermark:t.watermark===!0?!0:void 0,negative_prompt:t.negativePrompt||void 0}},u=f(e.output);if(e.dryRun){N({request:l,mode:i?`sync`:`async`},u);return}e.quiet||process.stderr.write(`[Model: ${r}] [Mode: ${i?`sync`:`async`}]\n`),i?await Bi(e,r,l,t,u,s):await Vi(e,r,l,t,u,s)}})})),Ki,qi=j((()=>{Ai(),Pi(),W(),F(),Ri(),Ki=d({name:`image edit`,description:`Edit an existing image with text instructions (Qwen-Image)`,apiDocs:`/developer-reference/qwen-image-edit-api`,usage:`bl image edit --image <url> --prompt <text> [flags]`,options:[{flag:`--image <url>`,description:`Source image URL or local file path (repeatable for multi-image merge)`,required:!0,type:`array`},{flag:`--prompt <text>`,description:`Edit instruction text`,required:!0},{flag:`--model <model>`,description:`Model ID (default: qwen-image-2.0)`},{flag:`--size <W*H>`,description:`Output image size: ratio (3:4, 16:9) or pixels (2048*2048)`},{flag:`--n <count>`,description:`Number of images (default: 1, max: 6)`,type:`number`},{flag:`--seed <n>`,description:`Random seed for reproducible results`,type:`number`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--prompt-extend`,description:`Enable prompt smart rewrite (default: true)`},{flag:`--no-prompt-extend`,description:`Disable prompt extend`},{flag:`--watermark`,description:`Add watermark to output images`},{flag:`--out-dir <dir>`,description:`Download images to directory`},{flag:`--out-prefix <prefix>`,description:`Filename prefix (default: edited)`}],examples:[`bl image edit --image ./photo.png --prompt "把背景换成海滩"`,`bl image edit --image https://example.com/logo.png --prompt "Change color to blue" --n 3`,`bl image edit --image ./a.png --image ./b.png --prompt "把两张图合并成一张拼图"`,`bl image edit --image https://example.com/photo.png --prompt "Remove the person" --model qwen-image-2.0-pro`],async run(e,n){let r=[];Array.isArray(n.image)?r=n.image:typeof n.image==`string`&&(r=[n.image]),r.length===0&&U(`image`,`bl image edit --image <url> --prompt <text>`);let a=n.prompt;if(!a)if(x({nonInteractive:e.nonInteractive})){let e=await Ar({message:`Enter your edit instruction:`});e||(process.stderr.write(`Image editing cancelled.
124
+ `),process.exit(1)),a=e}else U(`prompt`,`bl image edit --image <url> --prompt <text>`);let o=n.model||e.defaultImageModel||`qwen-image-2.0`,s=await k(e),c=await Promise.all(r.map(e=>A(e,s.token,o))),l=n.n??1,u;u=n.noPromptExtend===!0?!1:(n.promptExtend,!0);let d=c.map(e=>({image:e}));d.push({text:a});let p={model:o,input:{messages:[{role:`user`,content:d}]},parameters:{size:Fi(n.size,!0),n:l,seed:n.seed,prompt_extend:u,watermark:n.watermark===!0?!0:void 0,negative_prompt:n.negativePrompt||void 0}};de(p.parameters);let m=f(e.output);if(e.dryRun){N({request:p},m);return}e.quiet||process.stderr.write(`[Model: ${o}] [Mode: sync] [Images: ${c.length}]\n`);let g=b(e.baseUrl),_=(await Mi(ji(n),e,()=>O(e,{url:g,method:`POST`,body:p}))).flatMap(e=>e.output.choices||[]).flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);if(_.length===0)throw new t(`Edit completed but no images returned.`,i.GENERAL);let v=se(e,{flagDir:n.outDir,subDir:n.outDir?void 0:`images`}),y=n.outPrefix||h(`edited`,n?.prompt),S=await Ni(_.length>1?_.map((e,t)=>({url:e,destPath:Ie(v,`${y}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:_[0],destPath:Ie(v,`${y}.png`)}],Oi,{quiet:e.quiet});e.quiet?P(S.join(`
125
+ `)):N({urls:_,saved:S,total:_.length},m)}})}));function Ji(e){if(e)return Yi[e.toLowerCase()]||e}var Yi,Xi,Zi=j((()=>{Di(),Ai(),Pi(),W(),F(),Yi={"720p":`1280*720`,"1080p":`1920*1080`,"480p":`832*480`},Xi=d({name:`video generate`,description:`Generate a video from text or image (happyhorse-1.0-t2v / happyhorse-1.0-i2v / wan2.6-t2v)`,apiDocs:`/best-practice/wanx/text-to-video`,usage:`bl video generate --prompt <text> [--image <url>] [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-t2v, or happyhorse-1.0-i2v with --image)`},{flag:`--prompt <text>`,description:`Video description`,required:!0},{flag:`--image <url>`,description:`Input image URL for image-to-video generation`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--resolution <res>`,description:`Resolution (e.g. 1280*720, 960*960)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (e.g. 16:9, 1:1)`},{flag:`--duration <seconds>`,description:`Video duration in seconds (default: 5)`,type:`number`},{flag:`--prompt-extend`,description:`Automatically extend prompt for better results`},{flag:`--watermark`,description:`Add watermark to generated video`},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--download <path>`,description:`Save video to file on completion`},{flag:`--no-wait`,description:`Return task ID immediately without waiting`},{flag:`--async`,description:`Return task ID immediately (agent/CI mode, same as --no-wait)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 5)`,type:`number`}],examples:[`bl video generate --prompt "一个人在读书,静态镜头"`,`bl video generate --prompt "Ocean waves at sunset." --download sunset.mp4`,`bl video generate --image https://example.com/cat.png --prompt "让画面中的猫动起来"`,`bl video generate --prompt "Mountain landscape" --resolution 1280*720 --duration 5`],async run(e,n){let r=n.prompt;if(!r)if(x({nonInteractive:e.nonInteractive})){let e=await Ar({message:`Enter your video prompt:`});e||(process.stderr.write(`Video generation cancelled.
126
+ `),process.exit(1)),r=e}else U(`prompt`,`bl video generate --prompt <text>`);let a=n.model||e.defaultVideoModel||(n.image?`happyhorse-1.0-i2v`:`happyhorse-1.0-t2v`),o=f(e.output),s=n.image,c;s&&(c=await A(s,(await k(e)).token,a));let l={model:a,input:{prompt:r,negative_prompt:n.negativePrompt||void 0,...c?{media:[{type:`first_frame`,url:c}]}:{}},parameters:{resolution:Ji(n.resolution)||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,prompt_extend:n.promptExtend===!0?!0:void 0,watermark:n.watermark===!0?!0:void 0,seed:n.seed}};if(e.dryRun){N({request:l},o);return}let u=ji(n),d=_e(e.baseUrl),p=(await Mi(u,e,()=>O(e,{url:d,method:`POST`,body:l,async:!0}),`tasks`)).map(e=>e.output.task_id);if(e.quiet||process.stderr.write(`[Model: ${a}]\n`),n.noWait||e.async){N(p.length===1?{task_id:p[0]}:{task_ids:p},o);return}let m=n.pollInterval??5,h=p.map(t=>Ei(e,{url:fe(e.baseUrl,t),intervalSec:m,timeoutSec:e.timeout,isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}})),g=await Promise.all(h),_=[];for(let e=0;e<g.length;e++){let t=g[e],n=t.output.video_url||t.output.results&&t.output.results[0]?.url;n&&_.push({taskId:p[e],videoUrl:n})}if(_.length===0)throw new t(`All tasks completed but no video URLs returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Oi(_[0].videoUrl,t,{quiet:e.quiet});e.quiet?P(t):N({task_id:_[0].taskId,video_url:_[0].videoUrl,status:`SUCCEEDED`,saved:t,size:ki(r)},o);return}let v=se(e,{subDir:`videos`}),{join:y}=await import(`path`),b=[];await Promise.all(_.map(async({taskId:t,videoUrl:n})=>{let r=y(v,`${t}.mp4`);await Oi(n,r,{quiet:e.quiet}),b.push({task_id:t,video_url:n,saved:r})})),b.length===1?N(b[0],o):N({videos:b,total:b.length},o)}})})),Qi,$i=j((()=>{Di(),Ai(),W(),F(),Qi=d({name:`video edit`,description:`Edit a video with happyhorse-1.0-video-edit (style transfer, object replacement, etc.)`,apiDocs:`/best-practice/wanx/video-edit`,usage:`bl video edit --video <url> --prompt <text> [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-video-edit)`},{flag:`--video <url>`,description:`Input video URL or local file (mp4/mov, 2-10s)`,required:!0},{flag:`--prompt <text>`,description:`Edit instruction (e.g. "将画面转换为黏土风格")`},{flag:`--ref-image <url>`,description:`Reference image URL (up to 4, comma-separated)`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--resolution <res>`,description:`Resolution: 720P or 1080P (default: 1080P)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (16:9, 9:16, 1:1, 4:3, 3:4)`},{flag:`--duration <seconds>`,description:`Output video duration in seconds (2-10)`,type:`number`},{flag:`--audio-setting <mode>`,description:`Audio: auto (default) or origin (keep original)`},{flag:`--prompt-extend`,description:`Enable prompt intelligent rewriting (default: true)`},{flag:`--no-prompt-extend`,description:`Disable prompt intelligent rewriting`},{flag:`--watermark`,description:`Add "AI生成" watermark`},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--download <path>`,description:`Save video to file on completion`},{flag:`--no-wait`,description:`Return task ID immediately without waiting`},{flag:`--async`,description:`Return task ID immediately (agent/CI mode, same as --no-wait)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 15)`,type:`number`}],examples:[`bl video edit --video https://example.com/input.mp4 --prompt "将整个画面转换为黏土风格"`,`bl video edit --video https://example.com/input.mp4 --prompt "替换衣服为图片中的款式" --ref-image https://example.com/clothes.png`,`bl video edit --video https://example.com/input.mp4 --prompt "Convert to anime style" --resolution 720P --download output.mp4`],async run(e,n){let r=n.video;if(!r)if(x({nonInteractive:e.nonInteractive})){let e=await Ar({message:`Enter the video URL to edit:`});e||(process.stderr.write(`Video editing cancelled.
127
+ `),process.exit(1)),r=e}else U(`video`,`bl video edit --video <url> --prompt <text>`);let a=n.prompt;if(!a&&x({nonInteractive:e.nonInteractive})){let e=await Ar({message:`Enter your edit instruction:`});e||(process.stderr.write(`Video editing cancelled.
128
+ `),process.exit(1)),a=e}let o=n.model||`happyhorse-1.0-video-edit`,s=f(e.output),c=await k(e),l=[{type:`video`,url:await A(r,c.token,o)}],u=n.refImage;if(u){let e=u.split(`,`).map(e=>e.trim()).filter(Boolean);for(let t of e){let e=await A(t,c.token,o);l.push({type:`reference_image`,url:e})}}let d=n.noPromptExtend===!0?!1:n.promptExtend===!0?!0:void 0,p={model:o,input:{prompt:a||void 0,negative_prompt:n.negativePrompt||void 0,media:l},parameters:{resolution:n.resolution||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,audio_setting:n.audioSetting||void 0,prompt_extend:d,watermark:n.watermark===!0?!0:void 0,seed:n.seed}};if(e.dryRun){N({request:p},s);return}let m=(await O(e,{url:_e(e.baseUrl),method:`POST`,body:p,async:!0})).output.task_id;if(e.quiet||(process.stderr.write(`[Model: ${o}]\n`),process.stderr.write(`Note: Video editing typically takes 5-8 minutes. Please be patient.
129
+ `)),n.noWait||e.async){N({task_id:m},s);return}let h=n.pollInterval??15,g=await Ei(e,{url:fe(e.baseUrl,m),intervalSec:h,timeoutSec:Math.max(e.timeout,600),isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}}),_=g.output.video_url||g.output.results&&g.output.results[0]?.url;if(!_)throw new t(`Task completed but no video URL returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Oi(_,t,{quiet:e.quiet});e.quiet?P(t):N({task_id:m,video_url:_,status:`SUCCEEDED`,saved:t,size:ki(r)},s);return}let v=await import(`path`),y=se(e,{subDir:`videos`}),b=v.join(y,`${m}.mp4`);await Oi(_,b,{quiet:e.quiet}),N({task_id:m,video_url:_,saved:b},s)}})})),ea,ta=j((()=>{Di(),Ai(),W(),F(),ea=d({name:`video ref`,description:`Reference-to-video generation (happyhorse-1.0-r2v / wan2.6-r2v): multi-subject, multi-shot with voice`,apiDocs:`/best-practice/wanx/video-reference`,usage:`bl video ref --prompt <text> --image <url>... [--ref-video <url>...] [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-r2v)`},{flag:`--prompt <text>`,description:`Video description with reference markers (图1, 视频1, etc.)`,required:!0},{flag:`--image <url>`,description:`Reference image URL or local file (repeatable for multiple subjects)`,type:`array`},{flag:`--ref-video <url>`,description:`Reference video URL or local file (repeatable)`,type:`array`},{flag:`--image-voice <url>`,description:`Voice URL for corresponding image (pairs by position)`,type:`array`},{flag:`--video-voice <url>`,description:`Voice URL for corresponding ref-video (pairs by position)`,type:`array`},{flag:`--resolution <res>`,description:`Resolution: 720P or 1080P (default: 720P)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (16:9, 9:16, 1:1)`},{flag:`--duration <seconds>`,description:`Video duration in seconds (2-10, default: 5)`,type:`number`},{flag:`--prompt-extend`,description:`Enable prompt intelligent rewriting`},{flag:`--no-prompt-extend`,description:`Disable prompt intelligent rewriting`},{flag:`--watermark`,description:`Add watermark to generated video`},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--download <path>`,description:`Save video to file on completion`},{flag:`--no-wait`,description:`Return task ID immediately without waiting`},{flag:`--async`,description:`Return task ID immediately (agent/CI mode, same as --no-wait)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 15)`,type:`number`}],examples:[`bl video ref --prompt "图1在草地上奔跑" --image person.jpg`,`bl video ref --prompt "视频1在弹吉他,图1走过来" --ref-video scene.mp4 --image person.jpg`,`bl video ref --prompt "图1说话" --image person.jpg --image-voice voice.mp3 --resolution 1080P`,`bl video ref --prompt "图1和图2在对话" --image a.jpg --image b.jpg --image-voice va.mp3 --image-voice vb.mp3`],async run(e,n){let r=n.prompt;if(!r)if(x({nonInteractive:e.nonInteractive})){let e=await Ar({message:`Enter your video prompt (use 图1, 视频1 to reference inputs):`});e||(process.stderr.write(`Video generation cancelled.
130
+ `),process.exit(1)),r=e}else U(`prompt`,`bl video ref --prompt <text> --image <url>`);let a=n.image||[],o=n.refVideo||[];if(a.length===0&&o.length===0)throw new t(`At least one --image or --ref-video is required.`,i.USAGE,`bl video ref --prompt "描述" --image person.jpg`);let s=n.imageVoice||[],c=n.videoVoice||[],l=n.model||`happyhorse-1.0-r2v`,u=f(e.output),d=await k(e),p=[];for(let e=0;e<a.length;e++){let t={type:`reference_image`,url:await A(a[e],d.token,l)};s[e]&&(t.reference_voice=await A(s[e],d.token,l)),p.push(t)}for(let e=0;e<o.length;e++){let t={type:`reference_video`,url:await A(o[e],d.token,l)};c[e]&&(t.reference_voice=await A(c[e],d.token,l)),p.push(t)}let m=n.noPromptExtend===!0?!1:n.promptExtend===!0?!0:void 0,h={model:l,input:{prompt:r,media:p},parameters:{resolution:n.resolution||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,prompt_extend:m,watermark:n.watermark===!0?!0:void 0,seed:n.seed}};if(e.dryRun){N({request:h},u);return}let g=(await O(e,{url:_e(e.baseUrl),method:`POST`,body:h,async:!0})).output.task_id;if(e.quiet||(process.stderr.write(`[Model: ${l}]\n`),process.stderr.write(`Note: Reference-to-video typically takes 5-10 minutes. Please be patient.
131
+ `)),n.noWait||e.async){N({task_id:g},u);return}let _=n.pollInterval??15,v=await Ei(e,{url:fe(e.baseUrl,g),intervalSec:_,timeoutSec:Math.max(e.timeout,600),isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}}),y=v.output.video_url||v.output.results&&v.output.results[0]?.url;if(!y)throw new t(`Task completed but no video URL returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Oi(y,t,{quiet:e.quiet});e.quiet?P(t):N({task_id:g,video_url:y,status:`SUCCEEDED`,saved:t,size:ki(r)},u);return}let{join:b}=await import(`path`),S=b(se(e,{subDir:`videos`}),`${g}.mp4`);await Oi(y,S,{quiet:e.quiet}),N({task_id:g,video_url:y,saved:S},u)}})})),na,ra=j((()=>{W(),F(),na=d({name:`video task get`,description:`Query async task status`,usage:`bl video task get --task-id <id>`,options:[{flag:`--task-id <id>`,description:`Async task ID`}],examples:[`bl video task get --task-id 3b256896-3e70-xxxx-xxxx-xxxxxxxxxxxx`,`bl video task get --task-id 3b256896-3e70-xxxx --output json`],async run(e,t){let n=t.taskId;n||U(`task-id`,`bl video task get --task-id <id>`);let r=f(e.output);if(e.dryRun){N({task_id:n},r);return}let i=await O(e,{url:fe(e.baseUrl,n)});if(e.quiet){P(i.output.task_status);return}N({task_id:i.output.task_id,task_status:i.output.task_status,video_url:i.output.video_url,results:i.output.results,submit_time:i.output.submit_time,end_time:i.output.end_time},r)}})})),ia,aa=j((()=>{Ai(),W(),F(),ia=d({name:`video download`,description:`Download a completed video by task ID`,usage:`bl video download --task-id <id> --out <path>`,options:[{flag:`--task-id <id>`,description:`Task ID to download from`},{flag:`--out <path>`,description:`Output file path`}],examples:[`bl video download --task-id 3b256896-xxxx --out video.mp4`,`bl video download --task-id 3b256896-xxxx --out video.mp4 --quiet`],async run(e,n){let r=n.taskId;r||U(`task-id`,`bl video download --task-id <id> --out <path>`);let a=n.out;a||U(`out`,`bl video download --task-id <id> --out video.mp4`);let o=f(e.output);if(e.dryRun){N({task_id:r,action:`download`,out:a},o);return}let s=await O(e,{url:fe(e.baseUrl,r)});if(s.output.task_status!==`SUCCEEDED`)throw new t(`Task is not complete (status: ${s.output.task_status}).`,i.GENERAL,`Wait for the task to complete before downloading.`);let c=s.output.video_url||s.output.results&&s.output.results[0]?.url;if(!c)throw new t(`No download URL available for this task.`,i.GENERAL);let{size:l}=await Oi(c,a,{quiet:e.quiet});if(e.quiet){P(a);return}N({saved:a,size:ki(l)},o)}})}));function oa(e){let t=Fe(e).toLowerCase().split(`?`)[0];return!!(la.has(t)||/\.(mp4|mov|avi|mkv|webm|flv|wmv)(\?|$)/i.test(e))}async function sa(e){if(e.startsWith(`data:`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`oss://`))return e;if(!ke(e))throw new t(`File not found: ${e}`,i.USAGE);let n=Fe(e).toLowerCase(),r=ca[n];if(!r)throw new t(`Unsupported image format "${n}". Supported: jpg, jpeg, png, webp`,i.USAGE);return`data:${r};base64,${je(e).toString(`base64`)}`}var ca,la,ua,da=j((()=>{W(),F(),ca={".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".webp":`image/webp`},la=new Set([`.mp4`,`.mov`,`.avi`,`.mkv`,`.webm`,`.flv`,`.wmv`]),ua=d({name:`vision describe`,description:`Describe an image or video using Qwen-VL`,usage:`bl vision describe --image <path-or-url> [--video <url>] [--prompt <text>]`,options:[{flag:`--image <path-or-url>`,description:`Local image path or URL`},{flag:`--video <url>`,description:`Video file URL or local path (mp4/mov/avi/mkv/webm)`,type:`array`},{flag:`--prompt <text>`,description:`Question about the content (default: auto-detected)`},{flag:`--model <model>`,description:`Vision model (default: qwen3-vl-plus)`}],examples:[`bl vision describe --image photo.jpg`,`bl vision describe --image https://example.com/photo.jpg --prompt "这只狗是什么品种?"`,`bl vision describe --video https://example.com/video.mp4 --prompt "总结视频内容"`,`bl vision describe --video ./local-video.mp4`,`bl vision describe --image photo.png --prompt "Extract the text" --model qwen-vl-plus`],async run(e,n){let r=n.image??n._positional?.[0],a=n.video??[],o=n.model||`qwen3-vl-plus`;r&&oa(r)&&(a.push(r),r=void 0);let s=a.length>0,c=s?`Describe the video.`:`Describe the image.`,u=n.prompt||c;if(!r&&!s)if(x({nonInteractive:e.nonInteractive})){let e=await Ar({message:`Enter image/video path or URL:`});e||(process.stderr.write(`Vision describe cancelled.
132
+ `),process.exit(1)),oa(e)?a.push(e):r=e}else throw new t(`Missing required argument --image or --video.`,i.USAGE,`bl vision describe --image <path-or-url>
133
+ bl vision describe --video <url-or-path>`);let d=f(e.output);if(e.dryRun){N({request:{prompt:u,image:r,video:a.length?a:void 0,model:o}},d);return}let p=[];if(a.length>0)for(let n of a){let r=n;if(S(n)){if(!ke(n))throw new t(`Video file not found: ${n}`,i.USAGE);r=await A(n,(await k(e)).token,o)}p.push({type:`video_url`,video_url:{url:r}})}if(r){let t=await sa(r),n=t;if(S(r)&&t.startsWith(`data:`)){let{statSync:t}=await import(`fs`);if(t(r).size>5*1024*1024){let t=await k(e);n=await A(r,t.token,o)}}p.push({type:`image_url`,image_url:{url:n}})}p.push({type:`text`,text:u});let m={model:o,messages:[{role:`user`,content:p}]},h=await O(e,{url:l(e.baseUrl),method:`POST`,body:m}),g=h.choices?.[0]?.message?.content;if(d!==`text`){N(h,d);return}P(g||``)}})})),fa,pa=j((()=>{F(),fa=d({name:`config show`,description:`Display current configuration`,usage:`bl config show`,examples:[`bl config show`,`bl config show --output json`],async run(e,t){let n=D(),r=f(e.output),i={region:e.region,base_url:e.baseUrl,output:e.output,timeout:e.timeout,config_file:v()};n.api_key&&(i.api_key=w(n.api_key)),n.access_token&&(i.access_token=w(n.access_token)),n.default_text_model&&(i.default_text_model=n.default_text_model),n.default_video_model&&(i.default_video_model=n.default_video_model),n.default_image_model&&(i.default_image_model=n.default_image_model),N(i,r)}})})),ma,ha,ga,_a=j((()=>{F(),ma=[`region`,`base_url`,`output`,`output_dir`,`timeout`,`api_key`,`access_token`,`default_text_model`,`default_video_model`,`default_image_model`,`default_speech_model`,`default_omni_model`,`access_key_id`,`access_key_secret`,`workspace_id`],ha={"base-url":`base_url`,"output-dir":`output_dir`,"api-key":`api_key`,"access-token":`access_token`,"default-text-model":`default_text_model`,"default-video-model":`default_video_model`,"default-image-model":`default_image_model`,"default-speech-model":`default_speech_model`,"default-omni-model":`default_omni_model`,"access-key-id":`access_key_id`,"access-key-secret":`access_key_secret`,"workspace-id":`workspace_id`},ga=d({name:`config set`,description:`Set a config value`,usage:`bl config set --key <key> --value <value>`,options:[{flag:`--key <key>`,description:`Config key (region, base_url, output, output_dir, timeout, api_key, access_token, default_*_model, access_key_id, access_key_secret, workspace_id)`},{flag:`--value <value>`,description:`Value to set`}],examples:[`bl config set --key output --value json`,`bl config set --key timeout --value 600`,`bl config set --key base_url --value https://dashscope.aliyuncs.com`],async run(e,n){let r=n.key,a=n.value;if(!r||a===void 0)throw new t(`--key and --value are required.`,i.USAGE,`bl config set --key <key> --value <value>`);let o=ha[r]||r;if(!ma.includes(o))throw new t(`Invalid config key "${r}". Valid keys: ${ma.join(`, `)}`,i.USAGE);if(o===`region`&&![`cn`,`us`,`intl`].includes(a))throw new t(`Invalid region "${a}". Valid values: cn, us, intl`,i.USAGE);if(o===`output`&&![`text`,`json`].includes(a))throw new t(`Invalid output format "${a}". Valid values: text, json`,i.USAGE);if(o===`timeout`){let e=Number(a);if(isNaN(e)||e<=0)throw new t(`Invalid timeout "${a}". Must be a positive number.`,i.USAGE)}let s=f(e.output);if(e.dryRun){N({would_set:{[o]:a}},s);return}let c=D();c[o]=o===`timeout`?Number(a):a,await ve(c),e.quiet||N({[o]:c[o]},s)}})})),va,ya,ba=j((()=>{va=[`auth `,`config `,`update`],ya=d({name:`config export-schema`,description:`Export all (or one) CLI command(s) as Anthropic/OpenAI-compatible JSON tool schemas`,usage:`bl config export-schema [--command "<name>"]`,options:[{flag:`--command <name>`,description:`Export schema for a specific command only (e.g. "image generate")`}],examples:[`bl config export-schema`,`bl config export-schema --command "video generate"`],async run(e,n){let{commands:r}=await Promise.resolve().then(()=>(Ld(),Fd)),a=n.command;if(a){let e=r[a];if(!e)throw new t(`Command "${a}" not found.`,i.USAGE);let n=g(e);process.stdout.write(JSON.stringify(n,null,2)+`
134
+ `);return}let o=Object.values(r).filter(e=>!va.some(t=>e.name.startsWith(t))).map(e=>g(e));process.stdout.write(JSON.stringify(o,null,2)+`
135
+ `)}})}));ni(),di(),mi(),_i(),xi(),Gi(),qi(),Zi(),$i(),ta(),ra(),aa(),da(),pa(),_a(),ba();var xa=`1.1.3`,Sa,Ca=j((()=>{Sa=xa}));function wa(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if((n[e]??0)>(r[e]??0))return!0;if((n[e]??0)<(r[e]??0))return!1}return!1}function Ta(){try{let e=je(Ma(),`utf-8`);return JSON.parse(e)}catch{return null}}function Ea(e){try{Ne(Ma(),JSON.stringify(e))}catch{}}async function Da(e=Pa){try{let t=ja.replace(`/`,`%2f`),n=await fetch(`${Aa}/${t}/latest`,{headers:{Accept:`application/json`,...me()},signal:AbortSignal.timeout(e)});return n.ok?(await n.json()).version??null:null}catch{return null}}function Oa(){return Fa}async function ka(e){if(process.env.CI||!process.stderr.isTTY)return;let t=Ta(),n=Date.now();if(t&&n-t.lastChecked<Na){t.latestVersion&&wa(t.latestVersion,e)&&(Fa=t.latestVersion);return}let r=await Da();r&&(Ea({lastChecked:n,latestVersion:r}),r&&wa(r,e)&&(Fa=r))}var Aa,ja,Ma,Na,Pa,Fa,Ia=j((()=>{Aa=`https://registry.npmjs.org`,ja=`bailian-cli`,Ma=()=>Ie(_(),`update-state.json`),Na=14400*1e3,Pa=3e3,Fa=null}));function La(){return{cmd:`npm install -g ${ja}@latest`,label:`npm`}}var Ra,za=j((()=>{Ca(),Ia(),Ra=d({name:`update`,description:`Update bl to the latest version`,usage:`bl update`,examples:[`bl update`],async run(){let e=process.stderr.isTTY,t=e?`\x1B[32m`:``,n=e?`\x1B[33m`:``,r=e?`\x1B[0m`:``;process.stderr.write(`Current version: ${n}${Sa}${r}\n`),process.stderr.write(`Checking for updates...
136
+ `);let i=await Da(5e3);if(i&&i===Sa){process.stderr.write(`${t}\u2713 Already up to date (${Sa}).${r}\n`);return}i&&process.stderr.write(`Latest version: ${t}${i}${r}\n\n`);let{cmd:a,label:o}=La();process.stderr.write(`Updating ${ja} via ${o}...\n\n`);try{Le(a,{stdio:`inherit`});try{let e=Le(`bl --version 2>/dev/null`,{encoding:`utf-8`}).trim().replace(/^bl\s+/,``);process.stderr.write(`\n${t}\u2713 Update complete: ${Sa} \u2192 ${e}${r}\n`);try{Ne(Ie(_(),`update-state.json`),JSON.stringify({lastChecked:Date.now(),latestVersion:e}))}catch{}}catch{process.stderr.write(`\n${t}\u2713 Update complete.${r}\n`)}}catch{process.stderr.write(`
136
137
  Automatic update failed. Please run manually:
137
- `),process.stderr.write(` ${a}\n\n`)}}})})),Fa,Ia=A((()=>{U(),P(),Fa=d({name:`app call`,description:`Call a Bailian application (agent or workflow)`,usage:`bl app call --app-id <id> --prompt <text> [flags]`,options:[{flag:`--app-id <id>`,description:`Application ID (required)`,required:!0},{flag:`--prompt <text>`,description:`Input prompt text`,required:!0},{flag:`--image <url>`,description:`Image URL(s) to pass to the app (repeatable)`,type:`array`},{flag:`--file-id <id>`,description:`Pre-uploaded file ID(s) (repeatable)`,type:`array`},{flag:`--session-id <id>`,description:`Session ID for multi-turn conversation`},{flag:`--stream`,description:`Stream response (default: on in TTY)`},{flag:`--pipeline-ids <ids>`,description:`Knowledge base pipeline IDs (comma-separated)`},{flag:`--memory-id <id>`,description:`Memory ID for long-term memory`},{flag:`--biz-params <json>`,description:`Business parameters JSON (workflow variables)`},{flag:`--has-thoughts`,description:`Show agent thinking process`}],examples:[`bl app call --app-id abc123 --prompt "你好"`,`bl app call --app-id abc123 --prompt "描述这张图片" --image https://example.com/photo.jpg`,`bl app call --app-id abc123 --prompt "分析图片" --image img1.jpg --image img2.jpg`,`bl app call --app-id abc123 --prompt "继续" --session-id sess_xxx --stream`,`bl app call --app-id abc123 --prompt "搜索资料" --pipeline-ids pipe1,pipe2`,`bl app call --app-id abc123 --prompt "开始" --biz-params '{"key":"value"}'`],async run(e,t){let n=t.appId;n||H(`app-id`,`bl app call --app-id <id> --prompt <text>`);let r=t.prompt;r||H(`prompt`,`bl app call --app-id <id> --prompt <text>`);let i=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,a=f(e.output),o={input:{prompt:r},parameters:{incremental_output:i}};t.sessionId&&(o.input.session_id=t.sessionId);let c=t.image;c&&c.length>0&&(o.input.image_list=c);let l=t.fileId;if(l&&l.length>0&&(o.input.file_ids=l),t.hasThoughts&&(o.parameters.has_thoughts=!0),t.pipelineIds){let e=t.pipelineIds.split(`,`).map(e=>e.trim()).filter(Boolean);o.parameters.rag_options={pipeline_ids:e}}if(t.memoryId&&(o.parameters.memory_id=t.memoryId),t.bizParams)try{o.input.biz_params=JSON.parse(t.bizParams)}catch{process.stderr.write(`Error: --biz-params must be valid JSON
138
- `),process.exit(1)}if(e.dryRun){M({endpoint:s(e.baseUrl,n),request:o},a);return}let u=s(e.baseUrl,n);if(i){let n=await oe(e,{url:u,method:`POST`,body:o,headers:{"X-DashScope-SSE":`enable`},stream:!0}),r=``,i=``,s=a===`text`,c=e.noColor?``:`\x1B[2m`,l=e.noColor?``:`\x1B[0m`;for await(let e of re(n)){if(e.data===`[DONE]`)break;try{let n=JSON.parse(e.data),a=n.output?.text;if(a&&(s&&process.stdout.write(a),r+=a),n.output?.session_id&&(i=n.output.session_id),n.output?.thoughts&&t.hasThoughts)for(let e of n.output.thoughts)e.thought&&process.stderr.write(`${c}[Thinking] ${e.thought}${l}\n`),e.action_name&&process.stderr.write(`${c}[Action] ${e.action_name}: ${e.action_input||``}${l}\n`),e.observation&&process.stderr.write(`${c}[Observation] ${e.observation}${l}\n`)}catch{}}i&&!e.quiet&&process.stderr.write(`${c}Session ID: ${i}${l}\n`),a===`json`?M({text:r,session_id:i},a):process.stdout.write(`
139
- `)}else{let t=await D(e,{url:u,method:`POST`,body:o}),n=t.output?.text??``;e.quiet||a===`text`?N(n):M(t,a)}}})})),La,Ra,za=A((()=>{P(),La=`zeldaEasy.broadscope-bailian.app-control.list`,Ra=d({name:`app list`,description:`List Bailian applications`,usage:`bl app list [flags]`,options:[{flag:`--name <name>`,description:`Filter by app name (keyword search)`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--page-size <n>`,description:`Results per page (default: 30)`,type:`number`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl app list`,`bl app list --name 客服`,`bl app list --page 2 --page-size 10`,`bl app list --output json`],async run(e,t){let n=t.name||``,r=t.page||1,i=t.pageSize||30,a=t.region||`cn-beijing`,o=f(e.output),s=await se(e),l={reqDTO:{name:n,notInTypes:[10],type:5,statuses:[1,4],page_no:r,page_size:i}};if(e.dryRun){M({api:La,data:l,region:a,token:s.token.slice(0,8)+`...`},o);return}let u=await c(e,s.token,{api:La,data:l,region:a}),d=u?.data?.DataV2?.data?.data?.list??[];M({total:u?.data?.DataV2?.data?.data?.total??0,apps:d.map(e=>({code:e.code,name:e.name,user_prompt_params:e.config?.user_prompt_params??[]}))},o)}})})),Ba,Va=A((()=>{U(),P(),Ba=d({name:`memory add`,description:`Add memory from messages or custom content`,usage:`bl memory add --user-id <id> [--messages <json>] [--content <text>] [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--messages <json>`,description:`Messages JSON array: [{"role":"user","content":"..."},...]`},{flag:`--content <text>`,description:`Custom content text to memorize`},{flag:`--profile-schema <id>`,description:`Profile schema ID for user profiling`},{flag:`--memory-library-id <id>`,description:`Memory library ID (isolate memory space)`}],examples:[`bl memory add --user-id user1 --content "用户喜欢Python编程"`,`bl memory add --user-id user1 --messages '[{"role":"user","content":"我喜欢旅行"}]'`,`bl memory add --user-id user1 --content "住在北京" --profile-schema schema_xxx`],async run(e,t){let n=t.userId;n||H(`user-id`,`bl memory add --user-id <id>`);let r={user_id:n};if(t.messages)try{r.messages=JSON.parse(t.messages)}catch{process.stderr.write(`Error: --messages must be valid JSON array
138
+ `),process.stderr.write(` ${a}\n\n`)}}})})),Ba,Va=j((()=>{W(),F(),Ba=d({name:`app call`,description:`Call a Bailian application (agent or workflow)`,usage:`bl app call --app-id <id> --prompt <text> [flags]`,options:[{flag:`--app-id <id>`,description:`Application ID (required)`,required:!0},{flag:`--prompt <text>`,description:`Input prompt text`,required:!0},{flag:`--image <url>`,description:`Image URL(s) to pass to the app (repeatable)`,type:`array`},{flag:`--file-id <id>`,description:`Pre-uploaded file ID(s) (repeatable)`,type:`array`},{flag:`--session-id <id>`,description:`Session ID for multi-turn conversation`},{flag:`--stream`,description:`Stream response (default: on in TTY)`},{flag:`--pipeline-ids <ids>`,description:`Knowledge base pipeline IDs (comma-separated)`},{flag:`--memory-id <id>`,description:`Memory ID for long-term memory`},{flag:`--biz-params <json>`,description:`Business parameters JSON (workflow variables)`},{flag:`--has-thoughts`,description:`Show agent thinking process`}],examples:[`bl app call --app-id abc123 --prompt "你好"`,`bl app call --app-id abc123 --prompt "描述这张图片" --image https://example.com/photo.jpg`,`bl app call --app-id abc123 --prompt "分析图片" --image img1.jpg --image img2.jpg`,`bl app call --app-id abc123 --prompt "继续" --session-id sess_xxx --stream`,`bl app call --app-id abc123 --prompt "搜索资料" --pipeline-ids pipe1,pipe2`,`bl app call --app-id abc123 --prompt "开始" --biz-params '{"key":"value"}'`],async run(e,t){let n=t.appId;n||U(`app-id`,`bl app call --app-id <id> --prompt <text>`);let r=t.prompt;r||U(`prompt`,`bl app call --app-id <id> --prompt <text>`);let i=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,a=f(e.output),o={input:{prompt:r},parameters:{incremental_output:i}};t.sessionId&&(o.input.session_id=t.sessionId);let c=t.image;c&&c.length>0&&(o.input.image_list=c);let l=t.fileId;if(l&&l.length>0&&(o.input.file_ids=l),t.hasThoughts&&(o.parameters.has_thoughts=!0),t.pipelineIds){let e=t.pipelineIds.split(`,`).map(e=>e.trim()).filter(Boolean);o.parameters.rag_options={pipeline_ids:e}}if(t.memoryId&&(o.parameters.memory_id=t.memoryId),t.bizParams)try{o.input.biz_params=JSON.parse(t.bizParams)}catch{process.stderr.write(`Error: --biz-params must be valid JSON
139
+ `),process.exit(1)}if(e.dryRun){N({endpoint:s(e.baseUrl,n),request:o},a);return}let u=s(e.baseUrl,n);if(i){let n=await ae(e,{url:u,method:`POST`,body:o,headers:{"X-DashScope-SSE":`enable`},stream:!0}),r=``,i=``,s=a===`text`,c=e.noColor?``:`\x1B[2m`,l=e.noColor?``:`\x1B[0m`;for await(let e of re(n)){if(e.data===`[DONE]`)break;try{let n=JSON.parse(e.data),a=n.output?.text;if(a&&(s&&process.stdout.write(a),r+=a),n.output?.session_id&&(i=n.output.session_id),n.output?.thoughts&&t.hasThoughts)for(let e of n.output.thoughts)e.thought&&process.stderr.write(`${c}[Thinking] ${e.thought}${l}\n`),e.action_name&&process.stderr.write(`${c}[Action] ${e.action_name}: ${e.action_input||``}${l}\n`),e.observation&&process.stderr.write(`${c}[Observation] ${e.observation}${l}\n`)}catch{}}i&&!e.quiet&&process.stderr.write(`${c}Session ID: ${i}${l}\n`),a===`json`?N({text:r,session_id:i},a):process.stdout.write(`
140
+ `)}else{let t=await O(e,{url:u,method:`POST`,body:o}),n=t.output?.text??``;e.quiet||a===`text`?P(n):N(t,a)}}})})),Ha,Ua,Wa=j((()=>{F(),Ha=`zeldaEasy.broadscope-bailian.app-control.list`,Ua=d({name:`app list`,description:`List Bailian applications`,usage:`bl app list [flags]`,options:[{flag:`--name <name>`,description:`Filter by app name (keyword search)`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--page-size <n>`,description:`Results per page (default: 30)`,type:`number`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl app list`,`bl app list --name 客服`,`bl app list --page 2 --page-size 10`,`bl app list --output json`],async run(e,t){let n=t.name||``,r=t.page||1,i=t.pageSize||30,a=t.region||`cn-beijing`,o=f(e.output),s=await oe(e),l={reqDTO:{name:n,notInTypes:[10],type:5,statuses:[1,4],page_no:r,page_size:i}};if(e.dryRun){N({api:Ha,data:l,region:a,token:s.token.slice(0,8)+`...`},o);return}let u=await c(e,s.token,{api:Ha,data:l,region:a}),d=u?.data?.DataV2?.data?.data?.list??[];N({total:u?.data?.DataV2?.data?.data?.total??0,apps:d.map(e=>({code:e.code,name:e.name,user_prompt_params:e.config?.user_prompt_params??[]}))},o)}})})),Ga,Ka=j((()=>{W(),F(),Ga=d({name:`memory add`,description:`Add memory from messages or custom content`,usage:`bl memory add --user-id <id> [--messages <json>] [--content <text>] [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--messages <json>`,description:`Messages JSON array: [{"role":"user","content":"..."},...]`},{flag:`--content <text>`,description:`Custom content text to memorize`},{flag:`--profile-schema <id>`,description:`Profile schema ID for user profiling`},{flag:`--memory-library-id <id>`,description:`Memory library ID (isolate memory space)`}],examples:[`bl memory add --user-id user1 --content "用户喜欢Python编程"`,`bl memory add --user-id user1 --messages '[{"role":"user","content":"我喜欢旅行"}]'`,`bl memory add --user-id user1 --content "住在北京" --profile-schema schema_xxx`],async run(e,t){let n=t.userId;n||U(`user-id`,`bl memory add --user-id <id>`);let r={user_id:n};if(t.messages)try{r.messages=JSON.parse(t.messages)}catch{process.stderr.write(`Error: --messages must be valid JSON array
140
141
  `),process.exit(1)}t.content&&(r.custom_content=t.content),!r.messages&&!r.custom_content&&(process.stderr.write(`Error: at least one of --messages or --content is required
141
- `),process.exit(1)),t.profileSchema&&(r.profile_schema=t.profileSchema),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=f(e.output);if(e.dryRun){M({endpoint:E(e.baseUrl),request:r},i);return}let a=await D(e,{url:E(e.baseUrl),method:`POST`,body:r});e.quiet||i===`text`?N(`Memory added. IDs: ${a.memory_ids?.join(`, `)||`none`}`):M(a,i)}})})),Ha,Ua=A((()=>{U(),P(),Ha=d({name:`memory search`,description:`Search memory nodes by query or messages`,usage:`bl memory search --user-id <id> [--query <text>] [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--query <text>`,description:`Search query text`},{flag:`--messages <json>`,description:`Messages JSON array for context-based search`},{flag:`--top-k <n>`,description:`Number of results to return (default: 10)`,type:`number`},{flag:`--memory-library-id <id>`,description:`Memory library ID`}],examples:[`bl memory search --user-id user1 --query "编程偏好"`,`bl memory search --user-id user1 --messages '[{"role":"user","content":"推荐一本书"}]' --top-k 5`],async run(e,t){let n=t.userId;n||H(`user-id`,`bl memory search --user-id <id>`);let r={user_id:n};if(t.query&&(r.query=t.query),t.messages)try{r.messages=JSON.parse(t.messages)}catch{process.stderr.write(`Error: --messages must be valid JSON array
142
+ `),process.exit(1)),t.profileSchema&&(r.profile_schema=t.profileSchema),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=f(e.output);if(e.dryRun){N({endpoint:E(e.baseUrl),request:r},i);return}let a=await O(e,{url:E(e.baseUrl),method:`POST`,body:r});e.quiet||i===`text`?P(`Memory added. IDs: ${a.memory_ids?.join(`, `)||`none`}`):N(a,i)}})})),qa,Ja=j((()=>{W(),F(),qa=d({name:`memory search`,description:`Search memory nodes by query or messages`,usage:`bl memory search --user-id <id> [--query <text>] [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--query <text>`,description:`Search query text`},{flag:`--messages <json>`,description:`Messages JSON array for context-based search`},{flag:`--top-k <n>`,description:`Number of results to return (default: 10)`,type:`number`},{flag:`--memory-library-id <id>`,description:`Memory library ID`}],examples:[`bl memory search --user-id user1 --query "编程偏好"`,`bl memory search --user-id user1 --messages '[{"role":"user","content":"推荐一本书"}]' --top-k 5`],async run(e,t){let n=t.userId;n||U(`user-id`,`bl memory search --user-id <id>`);let r={user_id:n};if(t.query&&(r.query=t.query),t.messages)try{r.messages=JSON.parse(t.messages)}catch{process.stderr.write(`Error: --messages must be valid JSON array
142
143
  `),process.exit(1)}!r.messages&&r.query&&(r.messages=[{role:`user`,content:r.query}]),!r.query&&!r.messages&&(process.stderr.write(`Error: at least one of --query or --messages is required
143
- `),process.exit(1)),t.topK!==void 0&&(r.top_k=t.topK),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=f(e.output);if(e.dryRun){M({endpoint:ne(e.baseUrl),request:r},i);return}let a=await D(e,{url:ne(e.baseUrl),method:`POST`,body:r});if(e.quiet||i===`text`)if(!a.memory_nodes||a.memory_nodes.length===0)N(`No memory nodes found.`);else for(let e of a.memory_nodes)N(`[${e.memory_node_id}] ${e.content}`);else M(a,i)}})})),Wa,Ga=A((()=>{U(),P(),Wa=d({name:`memory list`,description:`List memory nodes for a user`,usage:`bl memory list --user-id <id> [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--page-size <n>`,description:`Results per page (default: 10)`,type:`number`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--memory-library-id <id>`,description:`Memory library ID`}],examples:[`bl memory list --user-id user1`,`bl memory list --user-id user1 --page-size 20 --page 2`],async run(e,t){let n=t.userId;n||H(`user-id`,`bl memory list --user-id <id>`);let r=f(e.output),i=new URLSearchParams;i.set(`user_id`,n),t.pageSize!==void 0&&i.set(`page_size`,String(t.pageSize)),t.page!==void 0&&i.set(`page_num`,String(t.page)),t.memoryLibraryId&&i.set(`memory_library_id`,t.memoryLibraryId);let a=`${ee(e.baseUrl)}?${i.toString()}`;if(e.dryRun){M({endpoint:a,method:`GET`},r);return}let o=await D(e,{url:a,method:`GET`});if(e.quiet||r===`text`)if(!o.memory_nodes||o.memory_nodes.length===0)N(`No memory nodes found.`);else{for(let e of o.memory_nodes)N(`[${e.memory_node_id}] ${e.content}`);o.total!==void 0&&N(`\nTotal: ${o.total}`)}else M(o,r)}})})),Ka,qa=A((()=>{U(),P(),Ka=d({name:`memory update`,description:`Update a memory node content`,usage:`bl memory update --node-id <id> --user-id <id> --content <text>`,options:[{flag:`--node-id <id>`,description:`Memory node ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--content <text>`,description:`New content for the memory node (required)`,required:!0},{flag:`--memory-library-id <id>`,description:`Memory library ID (non-default library)`}],examples:[`bl memory update --node-id node_xxx --user-id user1 --content "更新后的记忆内容"`],async run(e,t){let n=t.nodeId;n||H(`node-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let r=t.userId;r||H(`user-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let i=t.content;i||H(`content`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let a={user_id:r,custom_content:i};t.memoryLibraryId&&(a.memory_library_id=t.memoryLibraryId);let o=f(e.output);if(e.dryRun){M({endpoint:te(e.baseUrl,n),method:`PATCH`,request:a},o);return}let s=await D(e,{url:te(e.baseUrl,n),method:`PATCH`,body:a});e.quiet||o===`text`?N(`Memory node ${n} updated.`):M(s,o)}})})),Ja,Ya=A((()=>{U(),P(),Ja=d({name:`memory delete`,description:`Delete a memory node`,usage:`bl memory delete --node-id <id> --user-id <id>`,options:[{flag:`--node-id <id>`,description:`Memory node ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--memory-library-id <id>`,description:`Memory library ID (non-default library)`}],examples:[`bl memory delete --node-id node_xxx --user-id user1`],async run(e,t){let n=t.nodeId;n||H(`node-id`,`bl memory delete --node-id <id> --user-id <id>`);let r=t.userId;r||H(`user-id`,`bl memory delete --node-id <id> --user-id <id>`);let i=f(e.output),a=new URLSearchParams({user_id:r});t.memoryLibraryId&&a.set(`memory_library_id`,t.memoryLibraryId);let o=`${te(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){M({endpoint:o,method:`DELETE`},i);return}let s=await D(e,{url:o,method:`DELETE`});e.quiet||i===`text`?N(`Memory node ${n} deleted.`):M(s,i)}})})),Xa,Za=A((()=>{U(),P(),Xa=d({name:`memory profile create`,description:`Create a user profile schema for memory profiling`,usage:`bl memory profile create --name <name> --attributes <json> [flags]`,options:[{flag:`--name <name>`,description:`Schema name (required)`,required:!0},{flag:`--description <text>`,description:`Schema description`},{flag:`--attributes <json>`,description:`Attributes JSON array: [{"name":"age","description":"年龄"}]`,required:!0}],examples:[`bl memory profile create --name "user_basic" --attributes '[{"name":"age","description":"年龄"},{"name":"hobby","description":"爱好"}]'`],async run(e,t){let n=t.name;n||H(`name`,`bl memory profile create --name <name> --attributes <json>`);let r=t.attributes;r||H(`attributes`,`bl memory profile create --name <name> --attributes <json>`);let i;try{i=JSON.parse(r)}catch{process.stderr.write(`Error: --attributes must be valid JSON array
144
- `),process.exit(1)}let a={name:n,attributes:i};t.description&&(a.description=t.description);let o=f(e.output);if(e.dryRun){M({endpoint:ie(e.baseUrl),request:a},o);return}let s=await D(e,{url:ie(e.baseUrl),method:`POST`,body:a});e.quiet||o===`text`?N(`Profile schema created: ${s.profile_schema_id}`):M(s,o)}})})),Qa,$a=A((()=>{U(),P(),Qa=d({name:`memory profile get`,description:`Get user profile by schema ID and user ID`,usage:`bl memory profile get --schema-id <id> --user-id <id>`,options:[{flag:`--schema-id <id>`,description:`Profile schema ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0}],examples:[`bl memory profile get --schema-id schema_xxx --user-id user1`],async run(e,t){let n=t.schemaId;n||H(`schema-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let r=t.userId;r||H(`user-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let i=f(e.output),a=new URLSearchParams({user_id:r}),o=`${_e(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){M({endpoint:o,method:`GET`},i);return}let s=await D(e,{url:o,method:`GET`});if(e.quiet||i===`text`)if(s.profile?.attributes)for(let e of s.profile.attributes)N(`${e.name}: ${e.value??`(empty)`}`);else N(`No profile data found.`);else M(s,i)}})})),eo,to,no=A((()=>{U(),P(),eo=`bailian.cn-beijing.aliyuncs.com`,to=d({name:`knowledge retrieve`,description:`Retrieve from a Bailian knowledge base (requires AK/SK)`,usage:`bl knowledge retrieve --index-id <id> --query <text> [flags]`,options:[{flag:`--index-id <id>`,description:`Knowledge base index ID (required)`,required:!0},{flag:`--query <text>`,description:`Search query (required)`,required:!0},{flag:`--workspace-id <id>`,description:`Bailian workspace ID (or env BAILIAN_WORKSPACE_ID)`},{flag:`--top-k <n>`,description:`Number of results (default: 10)`,type:`number`},{flag:`--rerank`,description:`Enable rerank`},{flag:`--rerank-top-n <n>`,description:`Rerank top N results`,type:`number`},{flag:`--access-key-id <key>`,description:`Alibaba Cloud Access Key ID (or env)`},{flag:`--access-key-secret <key>`,description:`Alibaba Cloud Access Key Secret (or env)`}],examples:[`bl knowledge retrieve --index-id idx_xxx --query "如何使用阿里云百炼" --workspace-id ws_xxx`,`bl knowledge retrieve --index-id idx_xxx --query "API限流" --top-k 5 --rerank`],async run(e,n){let r=n.indexId;r||H(`index-id`,`bl knowledge retrieve --index-id <id> --query <text>`);let a=n.query;a||H(`query`,`bl knowledge retrieve --index-id <id> --query <text>`);let o=n.accessKeyId||e.accessKeyId,s=n.accessKeySecret||e.accessKeySecret,c=n.workspaceId||e.workspaceId;if(!o||!s)throw new t(`Knowledge retrieve requires Alibaba Cloud AK/SK.
144
+ `),process.exit(1)),t.topK!==void 0&&(r.top_k=t.topK),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=f(e.output);if(e.dryRun){N({endpoint:ne(e.baseUrl),request:r},i);return}let a=await O(e,{url:ne(e.baseUrl),method:`POST`,body:r});if(e.quiet||i===`text`)if(!a.memory_nodes||a.memory_nodes.length===0)P(`No memory nodes found.`);else for(let e of a.memory_nodes)P(`[${e.memory_node_id}] ${e.content}`);else N(a,i)}})})),Ya,Xa=j((()=>{W(),F(),Ya=d({name:`memory list`,description:`List memory nodes for a user`,usage:`bl memory list --user-id <id> [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--page-size <n>`,description:`Results per page (default: 10)`,type:`number`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--memory-library-id <id>`,description:`Memory library ID`}],examples:[`bl memory list --user-id user1`,`bl memory list --user-id user1 --page-size 20 --page 2`],async run(e,t){let n=t.userId;n||U(`user-id`,`bl memory list --user-id <id>`);let r=f(e.output),i=new URLSearchParams;i.set(`user_id`,n),t.pageSize!==void 0&&i.set(`page_size`,String(t.pageSize)),t.page!==void 0&&i.set(`page_num`,String(t.page)),t.memoryLibraryId&&i.set(`memory_library_id`,t.memoryLibraryId);let a=`${ee(e.baseUrl)}?${i.toString()}`;if(e.dryRun){N({endpoint:a,method:`GET`},r);return}let o=await O(e,{url:a,method:`GET`});if(e.quiet||r===`text`)if(!o.memory_nodes||o.memory_nodes.length===0)P(`No memory nodes found.`);else{for(let e of o.memory_nodes)P(`[${e.memory_node_id}] ${e.content}`);o.total!==void 0&&P(`\nTotal: ${o.total}`)}else N(o,r)}})})),Za,Qa=j((()=>{W(),F(),Za=d({name:`memory update`,description:`Update a memory node content`,usage:`bl memory update --node-id <id> --user-id <id> --content <text>`,options:[{flag:`--node-id <id>`,description:`Memory node ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--content <text>`,description:`New content for the memory node (required)`,required:!0},{flag:`--memory-library-id <id>`,description:`Memory library ID (non-default library)`}],examples:[`bl memory update --node-id node_xxx --user-id user1 --content "更新后的记忆内容"`],async run(e,t){let n=t.nodeId;n||U(`node-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let r=t.userId;r||U(`user-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let i=t.content;i||U(`content`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let a={user_id:r,custom_content:i};t.memoryLibraryId&&(a.memory_library_id=t.memoryLibraryId);let o=f(e.output);if(e.dryRun){N({endpoint:te(e.baseUrl,n),method:`PATCH`,request:a},o);return}let s=await O(e,{url:te(e.baseUrl,n),method:`PATCH`,body:a});e.quiet||o===`text`?P(`Memory node ${n} updated.`):N(s,o)}})})),$a,eo=j((()=>{W(),F(),$a=d({name:`memory delete`,description:`Delete a memory node`,usage:`bl memory delete --node-id <id> --user-id <id>`,options:[{flag:`--node-id <id>`,description:`Memory node ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--memory-library-id <id>`,description:`Memory library ID (non-default library)`}],examples:[`bl memory delete --node-id node_xxx --user-id user1`],async run(e,t){let n=t.nodeId;n||U(`node-id`,`bl memory delete --node-id <id> --user-id <id>`);let r=t.userId;r||U(`user-id`,`bl memory delete --node-id <id> --user-id <id>`);let i=f(e.output),a=new URLSearchParams({user_id:r});t.memoryLibraryId&&a.set(`memory_library_id`,t.memoryLibraryId);let o=`${te(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){N({endpoint:o,method:`DELETE`},i);return}let s=await O(e,{url:o,method:`DELETE`});e.quiet||i===`text`?P(`Memory node ${n} deleted.`):N(s,i)}})})),to,no=j((()=>{W(),F(),to=d({name:`memory profile create`,description:`Create a user profile schema for memory profiling`,usage:`bl memory profile create --name <name> --attributes <json> [flags]`,options:[{flag:`--name <name>`,description:`Schema name (required)`,required:!0},{flag:`--description <text>`,description:`Schema description`},{flag:`--attributes <json>`,description:`Attributes JSON array: [{"name":"age","description":"年龄"}]`,required:!0}],examples:[`bl memory profile create --name "user_basic" --attributes '[{"name":"age","description":"年龄"},{"name":"hobby","description":"爱好"}]'`],async run(e,t){let n=t.name;n||U(`name`,`bl memory profile create --name <name> --attributes <json>`);let r=t.attributes;r||U(`attributes`,`bl memory profile create --name <name> --attributes <json>`);let i;try{i=JSON.parse(r)}catch{process.stderr.write(`Error: --attributes must be valid JSON array
145
+ `),process.exit(1)}let a={name:n,attributes:i};t.description&&(a.description=t.description);let o=f(e.output);if(e.dryRun){N({endpoint:ie(e.baseUrl),request:a},o);return}let s=await O(e,{url:ie(e.baseUrl),method:`POST`,body:a});e.quiet||o===`text`?P(`Profile schema created: ${s.profile_schema_id}`):N(s,o)}})})),ro,io=j((()=>{W(),F(),ro=d({name:`memory profile get`,description:`Get user profile by schema ID and user ID`,usage:`bl memory profile get --schema-id <id> --user-id <id>`,options:[{flag:`--schema-id <id>`,description:`Profile schema ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0}],examples:[`bl memory profile get --schema-id schema_xxx --user-id user1`],async run(e,t){let n=t.schemaId;n||U(`schema-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let r=t.userId;r||U(`user-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let i=f(e.output),a=new URLSearchParams({user_id:r}),o=`${ge(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){N({endpoint:o,method:`GET`},i);return}let s=await O(e,{url:o,method:`GET`});if(e.quiet||i===`text`)if(s.profile?.attributes)for(let e of s.profile.attributes)P(`${e.name}: ${e.value??`(empty)`}`);else P(`No profile data found.`);else N(s,i)}})})),ao,oo,so=j((()=>{W(),F(),ao=`bailian.cn-beijing.aliyuncs.com`,oo=d({name:`knowledge retrieve`,description:`Retrieve from a Bailian knowledge base (requires AK/SK)`,usage:`bl knowledge retrieve --index-id <id> --query <text> [flags]`,options:[{flag:`--index-id <id>`,description:`Knowledge base index ID (required)`,required:!0},{flag:`--query <text>`,description:`Search query (required)`,required:!0},{flag:`--workspace-id <id>`,description:`Bailian workspace ID (or env BAILIAN_WORKSPACE_ID)`},{flag:`--top-k <n>`,description:`Number of results (default: 10)`,type:`number`},{flag:`--rerank`,description:`Enable rerank`},{flag:`--rerank-top-n <n>`,description:`Rerank top N results`,type:`number`},{flag:`--access-key-id <key>`,description:`Alibaba Cloud Access Key ID (or env)`},{flag:`--access-key-secret <key>`,description:`Alibaba Cloud Access Key Secret (or env)`}],examples:[`bl knowledge retrieve --index-id idx_xxx --query "如何使用阿里云百炼" --workspace-id ws_xxx`,`bl knowledge retrieve --index-id idx_xxx --query "API限流" --top-k 5 --rerank`],async run(e,n){let r=n.indexId;r||U(`index-id`,`bl knowledge retrieve --index-id <id> --query <text>`);let a=n.query;a||U(`query`,`bl knowledge retrieve --index-id <id> --query <text>`);let o=n.accessKeyId||e.accessKeyId,s=n.accessKeySecret||e.accessKeySecret,c=n.workspaceId||e.workspaceId;if(!o||!s)throw new t(`Knowledge retrieve requires Alibaba Cloud AK/SK.
145
146
  Set via: --access-key-id / --access-key-secret flags,
146
147
  or env: ALIBABA_CLOUD_ACCESS_KEY_ID / ALIBABA_CLOUD_ACCESS_KEY_SECRET,
147
148
  or config: bl config set access_key_id <key>`,i.AUTH);if(!c)throw new t(`Knowledge retrieve requires a workspace ID.
148
- Set via: --workspace-id flag, or env: BAILIAN_WORKSPACE_ID, or config: bl config set workspace_id <id>`,i.USAGE);let l={IndexId:r,Query:a};n.topK!==void 0&&(l.TopK=n.topK),n.rerank&&(l.Rerank=!0),n.rerankTopN!==void 0&&(l.RerankTopN=n.rerankTopN);let u=f(e.output),d=`/${c}/index/retrieve`;if(e.dryRun){M({endpoint:`https://${eo}${d}`,workspaceId:c,request:l},u);return}let p=JSON.stringify(l),m=le({accessKeyId:o,accessKeySecret:s,action:`Retrieve`,version:`2023-12-29`,body:p,host:eo,pathname:d}),h=`https://${eo}${d}`;e.verbose&&(process.stderr.write(`> POST ${h}\n`),process.stderr.write(`> AK: ${o.slice(0,8)}...\n`));let g=e.timeout*1e3,_=await fetch(h,{method:`POST`,headers:{...m,...he()},body:p,signal:AbortSignal.timeout(g)});e.verbose&&process.stderr.write(`< ${_.status} ${_.statusText}\n`);let v=await _.json();if(!_.ok||v.Code&&v.Code!==`Success`)throw new t(`Knowledge retrieve failed: ${v.Code||_.status} - ${v.Message||_.statusText}`,i.GENERAL);if(e.quiet||u===`text`){let e=v.Data?.Nodes||[];if(e.length===0)N(`No results found.`);else for(let t=0;t<e.length;t++){let n=e[t];N(`[${t+1}] (score: ${n.Score.toFixed(4)})`),N(n.Text),N(``)}}else M(v,u)}})})),ro,io=A((()=>{bi(),U(),P(),ro=d({name:`search web`,description:`Search the web using DashScope MCP WebSearch service`,usage:`bl search web --query <text> [flags]`,options:[{flag:`--query <text>`,description:`Search query text`,required:!0},{flag:`--count <n>`,description:`Number of search results (default: 10)`,type:`number`},{flag:`--list-tools`,description:`List available MCP tools and exit`}],examples:[`bl search web --query "阿里云百炼最新功能"`,`bl search web --query "TypeScript 5.9 new features" --count 5`,`bl search web --query "今日新闻"`,`bl search web --list-tools`],async run(e,t){let n=T(e.baseUrl),r=f(e.output);if(t.listTools){if(e.dryRun){M({endpoint:n,action:`tools/list`},r);return}let t=new o(e,n);await t.initialize(),M({tools:await t.listTools()},r);return}let i=t.query;if(!i)if(x({nonInteractive:e.nonInteractive})){let e=await jr({message:`Enter your search query:`});e||(process.stderr.write(`Search cancelled.
149
- `),process.exit(1)),i=e}else H(`query`,`bl search web --query <text>`);if(e.dryRun){M({endpoint:n,action:`tools/call`,tool:`bailian_web_search`,arguments:{query:i,count:t.count||void 0}},r);return}let a=new o(e,n),s=_i(`Initializing search...`);e.quiet||s.start();try{await a.initialize(),e.quiet||s.update(`Searching...`);let n={query:i};t.count&&(n.count=t.count);let o=await a.callTool(`bailian_web_search`,n);if(e.quiet||s.stop(`Done.`),o.isError){let e=o.content.map(e=>e.text||``).join(`
150
- `);process.stderr.write(`Search error: ${e}\n`),process.exit(1)}if(r===`json`)M(o,r);else for(let e of o.content)if(e.type===`text`&&e.text)try{let t=JSON.parse(e.text);t.pages&&Array.isArray(t.pages)?M({pages:t.pages,total:t.pages.length},r):M(t,r)}catch{M({text:e.text},r)}}catch(e){throw s.stop(`Failed.`),e}}})}));function ao(e){let t=uo[e];if(!t){process.stdout.write(`No built-in voice list available for model: ${e}\n`);return}if(t.length===0){process.stdout.write(`Model ${e} has no system voices.\n`),process.stdout.write(`Use clone or design voices created via the CosyVoice API.
151
- `),process.stdout.write(`See: ${co}\n`);return}let n=(e,t)=>e.padEnd(t);process.stdout.write(`\nSystem voices for ${e}:\n`),process.stdout.write(`${n(`VOICE ID`,26)} ${n(`NAME`,10)} ${n(`DESCRIPTION`,16)} LANGUAGE\n`),process.stdout.write(`${`-`.repeat(26)} ${`-`.repeat(10)} ${`-`.repeat(16)} ${`-`.repeat(12)}\n`);for(let e of t)process.stdout.write(`${n(e.voice,26)} ${n(e.name,10)} ${n(e.desc,16)} ${e.lang}\n`);process.stdout.write(`\nTotal: ${t.length} voices\n`)}async function oo(e,n,r,a,o){let s=await Di(Ei(a),e,()=>D(e,{url:n,method:`POST`,body:r})),c=s.map(e=>e.output?.audio?.url).filter(Boolean);if(c.length===0)throw new t(`API returned no audio URL.`,i.GENERAL);let l=await import(`path`),u=ce(e,{subDir:`speech`}),d=await Oi(c.map((e,t)=>{let n=a.out;if(!(n&&c.length===1)){let e=Date.now(),i=c.length>1?`_${String(t+1).padStart(3,`0`)}`:``,a=r.input.format??`mp3`;n=l.join(u,`tts_${e}${i}.${a}`)}return{url:e,destPath:n}}),Ci,{quiet:e.quiet});if(e.quiet)N(d.join(`
152
- `));else if(d.length===1){let e=s[0].output?.audio?.expires_at;M({saved:d[0],audio_url:c[0],model:r.model,voice:r.input.voice,...e?{url_expires_at:e}:{}},o)}else M({saved:d,audio_urls:c,total:d.length,model:r.model,voice:r.input.voice},o)}async function so(e,t,n,r,i){let a=await oe(e,{url:t,method:`POST`,body:n,stream:!0,headers:{Accept:`text/event-stream`,"X-DashScope-SSE":`enable`}}),o=r.out,s=o?ke(o):null,c;try{for await(let t of re(a)){if(!t.data||t.data===`[DONE]`)continue;let n;try{n=JSON.parse(t.data)}catch{continue}let r=n.output?.audio?.data;if(r){let e=Buffer.from(r,`base64`);s?s.write(e)||await new Promise(e=>s.once(`drain`,()=>e())):process.stdout.write(e)}if(n.output?.finish_reason===`stop`){c=n.output?.audio?.url,c&&!e.quiet&&process.stderr.write(`\nFull audio URL: ${c}\n`);break}}}finally{s&&(await new Promise((e,t)=>{s.on(`finish`,e),s.on(`error`,t),s.end()}),!e.quiet&&o&&process.stderr.write(`Saved: ${o}\n`))}o&&M({saved:o,...c?{audio_url:c}:{},model:n.model,voice:n.input.voice},i)}var co,lo,uo,fo,po=A((()=>{Ti(),ki(),U(),P(),co=`${r.cn}/cosyvoice-clone-design-api`,lo=[{voice:`longanyang`,name:`龙安洋`,desc:`阳光大男孩`,lang:`中文/英文`},{voice:`longanhuan`,name:`龙安欢`,desc:`欢脱元气女`,lang:`中文/英文`},{voice:`longantai_v3`,name:`龙安台`,desc:`嗲甜台湾女`,lang:`中文/英文`},{voice:`longhua_v3`,name:`龙华`,desc:`元气甜美女`,lang:`中文/英文`},{voice:`longcheng_v3`,name:`龙橙`,desc:`智慧青年男`,lang:`中文/英文`},{voice:`longze_v3`,name:`龙泽`,desc:`温暖元气男`,lang:`中文/英文`},{voice:`longzhe_v3`,name:`龙哲`,desc:`呆板大暖男`,lang:`中文/英文`},{voice:`longyan_v3`,name:`龙颜`,desc:`温暖春风女`,lang:`中文/英文`},{voice:`longxing_v3`,name:`龙星`,desc:`温婉邻家女`,lang:`中文/英文`},{voice:`longtian_v3`,name:`龙天`,desc:`磁性理智男`,lang:`中文/英文`},{voice:`longwan_v3`,name:`龙婉`,desc:`细腻柔声女`,lang:`中文/英文`},{voice:`longqiang_v3`,name:`龙嫱`,desc:`浪漫风情女`,lang:`中文/英文`},{voice:`longfeifei_v3`,name:`龙菲菲`,desc:`甜美娇气女`,lang:`中文/英文`},{voice:`longhao_v3`,name:`龙浩`,desc:`多情忧郁男`,lang:`中文/英文`},{voice:`longanrou_v3`,name:`龙安柔`,desc:`温柔娴静女`,lang:`中文/英文`},{voice:`longxiaochun_v3`,name:`龙小淳`,desc:`知性积极女`,lang:`中文/英文`},{voice:`longxiaoxia_v3`,name:`龙小夏`,desc:`沉稳权威女`,lang:`中文/英文`},{voice:`longyumi_v3`,name:`YUMI`,desc:`正经青年女`,lang:`中文/英文`},{voice:`longanyun_v3`,name:`龙安昀`,desc:`居家暖男`,lang:`中文/英文`},{voice:`longanwen_v3`,name:`龙安温`,desc:`优雅知性女`,lang:`中文/英文`},{voice:`longanli_v3`,name:`龙安莉`,desc:`利落从容女`,lang:`中文/英文`},{voice:`longanlang_v3`,name:`龙安朗`,desc:`清爽利落男`,lang:`中文/英文`},{voice:`longyingmu_v3`,name:`龙应沐`,desc:`优雅知性女`,lang:`中文/英文`},{voice:`longyingxun_v3`,name:`龙应询`,desc:`年轻青涩男`,lang:`中文/英文`},{voice:`longyingjing_v3`,name:`龙应静`,desc:`低调冷静女`,lang:`中文/英文`},{voice:`longyingling_v3`,name:`龙应聆`,desc:`温和共情女`,lang:`中文/英文`},{voice:`longyingtao_v3`,name:`龙应桃`,desc:`温柔淡定女`,lang:`中文/英文`},{voice:`longyingxiao_v3`,name:`龙应笑`,desc:`清甜推销女`,lang:`中文/英文`},{voice:`longfei_v3`,name:`龙飞`,desc:`热血磁性男`,lang:`中文/英文`},{voice:`longhuhu_v3`,name:`龙呼呼`,desc:`天真烂漫女童`,lang:`中文/英文`},{voice:`longpaopao_v3`,name:`龙泡泡`,desc:`飞天泡泡音`,lang:`中文/英文`},{voice:`longjielidou_v3`,name:`龙杰力豆`,desc:`阳光顽皮男`,lang:`中文/英文`},{voice:`longxian_v3`,name:`龙仙`,desc:`豪放可爱女`,lang:`中文/英文`},{voice:`longling_v3`,name:`龙铃`,desc:`稚气呆板女`,lang:`中文/英文`},{voice:`longshanshan_v3`,name:`龙闪闪`,desc:`戏剧化童声`,lang:`中文/英文`},{voice:`longniuniu_v3`,name:`龙牛牛`,desc:`阳光男童声`,lang:`中文/英文`},{voice:`longjiaxin_v3`,name:`龙嘉欣`,desc:`优雅粤语女`,lang:`粤语/英文`},{voice:`longjiayi_v3`,name:`龙嘉怡`,desc:`知性粤语女`,lang:`粤语/英文`},{voice:`longanyue_v3`,name:`龙安粤`,desc:`欢脱粤语男`,lang:`粤语/英文`},{voice:`longlaotie_v3`,name:`龙老铁`,desc:`东北直率男`,lang:`东北话/英文`},{voice:`longshange_v3`,name:`龙陕哥`,desc:`原味陕北男`,lang:`陕西话/英文`},{voice:`longanmin_v3`,name:`龙安闽`,desc:`清纯萝莉女`,lang:`闽南话/英文`},{voice:`loongabby_v3`,name:`loongabby`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongandy_v3`,name:`loongandy`,desc:`美式英文男`,lang:`美式英语`},{voice:`loongannie_v3`,name:`loongannie`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongava_v3`,name:`loongava`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongbeth_v3`,name:`loongbeth`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongbetty_v3`,name:`loongbetty`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongcally_v3`,name:`loongcally`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongcindy_v3`,name:`loongcindy`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongdavid_v3`,name:`loongdavid`,desc:`美式英文男`,lang:`美式英语`},{voice:`loongdonna_v3`,name:`loongdonna`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongemily_v3`,name:`loongemily`,desc:`英式英文女`,lang:`英式英语`},{voice:`loongeric_v3`,name:`loongeric`,desc:`英式英文男`,lang:`英式英语`},{voice:`loongluna_v3`,name:`loongluna`,desc:`英式英文女`,lang:`英式英语`},{voice:`loongluca_v3`,name:`loongluca`,desc:`英式英文男`,lang:`英式英语`},{voice:`loongriko_v3`,name:`Riko`,desc:`二次元霓虹女`,lang:`日语`},{voice:`loongtomoka_v3`,name:`loongtomoka`,desc:`日语女`,lang:`日语`},{voice:`loongtomoya_v3`,name:`loongtomoya`,desc:`日语男`,lang:`日语`},{voice:`loongyuuna_v3`,name:`Yuuna`,desc:`日语女`,lang:`日语`},{voice:`loongyuuma_v3`,name:`Yuuma`,desc:`日语男`,lang:`日语`},{voice:`loongkyong_v3`,name:`loongkyong`,desc:`韩语女`,lang:`韩语`},{voice:`loongjihun_v3`,name:`Jihun`,desc:`韩语男`,lang:`韩语`},{voice:`loongindah_v3`,name:`loongindah`,desc:`印尼女`,lang:`印尼语`}],uo={"cosyvoice-v3-flash":lo,"cosyvoice-v3-plus":lo,"cosyvoice-v3.5-flash":[],"cosyvoice-v3.5-plus":[],"cosyvoice-v2":[]},fo=d({name:`speech synthesize`,description:`Synthesize speech from text (CosyVoice TTS)`,apiDocs:`/developer-reference/cosyvoice`,usage:`bl speech synthesize --text <text> [flags]`,options:[{flag:`--text <text>`,description:`Text to synthesize into speech`,required:!0},{flag:`--text-file <path>`,description:`Read text from a file instead of --text`},{flag:`--model <model>`,description:`Model ID (default: cosyvoice-v3-flash). System voices available for cosyvoice-v3-flash`},{flag:`--voice <voice>`,description:`Voice ID. Use --list-voices to see system voices for cosyvoice-v3-flash; for v3.5-flash provide a clone/design voice ID`},{flag:`--list-voices`,description:`List available system voices for the selected model and exit`},{flag:`--format <format>`,description:`Audio format: mp3, pcm, wav, opus (default: mp3)`},{flag:`--sample-rate <rate>`,description:`Audio sample rate in Hz (e.g. 24000)`},{flag:`--volume <volume>`,description:`Volume 0-100 (default: 50)`},{flag:`--rate <rate>`,description:`Speech rate 0.5-2.0 (default: 1.0)`},{flag:`--pitch <pitch>`,description:`Pitch multiplier 0.5-2.0 (default: 1.0)`},{flag:`--seed <seed>`,description:`Random seed 0-65535 for reproducible synthesis`},{flag:`--language <lang>`,description:`Language hint (e.g. zh, en, ja, ko, fr, de)`},{flag:`--instruction <text>`,description:`Natural language instruction to control speech style (e.g. "请用温柔的语调")`},{flag:`--enable-ssml`,description:`Enable SSML markup parsing in input text`},{flag:`--out <path>`,description:`Save audio to file (default: auto-generate in temp dir)`},{flag:`--stream`,description:`Stream raw PCM audio to stdout (pipe to player)`}],examples:[`bl speech synthesize --list-voices --model cosyvoice-v3-flash`,`bl speech synthesize --text "你好,我是千问" --voice <voice_id>`,`bl speech synthesize --text "Hello world" --voice <voice_id> --language en`,`bl speech synthesize --text-file script.txt --out speech.wav --voice <voice_id>`,`bl speech synthesize --text "今天天气真好" --voice <voice_id> --instruction "请用温柔的语调说话"`,`bl speech synthesize --text "Hello" --voice <voice_id> --format wav --sample-rate 24000`,`# Stream to audio player (macOS)`,`bl speech synthesize --text "你好" --voice <voice_id> --stream | afplay -`,`# Pipe to ffplay`,`bl speech synthesize --text "Hello" --voice <voice_id> --stream | ffplay -nodisp -autoexit -f s16le -ar 24000 -ac 1 -`],async run(e,n){let r=n.model||e.defaultSpeechModel||`cosyvoice-v3-flash`;if(n.listVoices){ao(r);return}let a=n.text;if(!a&&n.textFile){let e=n.textFile;try{a=Me(e,`utf-8`).trim()}catch{throw new t(`Cannot read text file: ${e}`,i.USAGE)}}if(!a)if(x({nonInteractive:e.nonInteractive})){let e=await jr({message:`Enter text to synthesize:`});e||(process.stderr.write(`Speech synthesis cancelled.
153
- `),process.exit(1)),a=e}else H(`text`,`bl speech synthesize --text <text>`);let o=n.voice||void 0;if(!o)if(x({nonInteractive:e.nonInteractive})){let e=uo[r];if(e&&e.length>0){let t=e[0].voice,n=e.map(e=>({value:e.voice,label:`${e.name} (${e.voice})`,hint:`${e.desc} · ${e.lang}`})),r=await Nr({message:`Select a voice (default: ${t}):`,choices:n,defaultValue:t});r||(process.stderr.write(`Speech synthesis cancelled.
154
- `),process.exit(1)),o=r}else{let e=await jr({message:`Enter voice ID (clone/design voice):`});e||(process.stderr.write(`Speech synthesis cancelled.
155
- `),process.exit(1)),o=e}}else{let e=uo[r];throw e&&e.length>0?new t(`--voice is required.\nRun the following to see available voices:\n bl speech synthesize --list-voices --model ${r}`,i.USAGE):new t(`--voice is required. Model ${r} has no built-in system voices.\nCreate a clone or design voice first, then pass its ID via --voice <voice_id>.\nSee: ${co}`,i.USAGE)}let s=n.language||void 0,c=n.instruction||void 0,l=n.format||void 0,u=n.sampleRate===void 0?void 0:Number(n.sampleRate),d=n.volume===void 0?void 0:Number(n.volume),p=n.rate===void 0?void 0:Number(n.rate),m=n.pitch===void 0?void 0:Number(n.pitch),h=n.seed===void 0?void 0:Number(n.seed),g=n.enableSsml===!0?!0:void 0,_=n.stream===!0,v=f(e.output),y={model:r,input:{text:a,voice:o,format:l,sample_rate:u,volume:d,rate:p,pitch:m,seed:h,language_hints:s?[s]:void 0,instruction:c,enable_ssml:g}};if(fe(y.input),e.dryRun){M({request:y},v);return}e.quiet||process.stderr.write(`[Model: ${r}] [Voice: ${o}]\n`);let b=de(e.baseUrl);_?await so(e,b,y,n,v):await oo(e,b,y,n,v)}})}));async function mo(e,n,r,a,o,s){let c=(await D(e,{url:n,method:`POST`,body:r,async:!0})).output.task_id;if(a.noWait||e.async){M({task_id:c},o);return}let l=a.pollInterval??2,u=await xi(e,{url:pe(e.baseUrl,c),intervalSec:l,timeoutSec:e.timeout,isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>e.output.message}),d=u.output.results??[];if(d.length===0){M({task_id:c,status:u.output.task_status},o);return}let f=[];for(let e=0;e<d.length;e++){let n=d[e],r=s>1;if(r&&process.stdout.write(`=== [${e+1}/${d.length}] ${n.file_url??``} ===\n`),n.subtask_status===`FAILED`){let e=n.message??n.code??`unknown error`;process.stdout.write(`[FAILED] ${n.file_url??``} — ${e}\n`),r&&process.stdout.write(`
149
+ Set via: --workspace-id flag, or env: BAILIAN_WORKSPACE_ID, or config: bl config set workspace_id <id>`,i.USAGE);let l={IndexId:r,Query:a};n.topK!==void 0&&(l.TopK=n.topK),n.rerank&&(l.Rerank=!0),n.rerankTopN!==void 0&&(l.RerankTopN=n.rerankTopN);let u=f(e.output),d=`/${c}/index/retrieve`;if(e.dryRun){N({endpoint:`https://${ao}${d}`,workspaceId:c,request:l},u);return}let p=JSON.stringify(l),m=ce({accessKeyId:o,accessKeySecret:s,action:`Retrieve`,version:`2023-12-29`,body:p,host:ao,pathname:d}),h=`https://${ao}${d}`;e.verbose&&(process.stderr.write(`> POST ${h}\n`),process.stderr.write(`> AK: ${o.slice(0,8)}...\n`));let g=e.timeout*1e3,_=await fetch(h,{method:`POST`,headers:{...m,...me()},body:p,signal:AbortSignal.timeout(g)});e.verbose&&process.stderr.write(`< ${_.status} ${_.statusText}\n`);let v=await _.json();if(!_.ok||v.Code&&v.Code!==`Success`)throw new t(`Knowledge retrieve failed: ${v.Code||_.status} - ${v.Message||_.statusText}`,i.GENERAL);if(e.quiet||u===`text`){let e=v.Data?.Nodes||[];if(e.length===0)P(`No results found.`);else for(let t=0;t<e.length;t++){let n=e[t];P(`[${t+1}] (score: ${n.Score.toFixed(4)})`),P(n.Text),P(``)}}else N(v,u)}})})),co,lo=j((()=>{Ti(),W(),F(),co=d({name:`search web`,description:`Search the web using DashScope MCP WebSearch service`,usage:`bl search web --query <text> [flags]`,options:[{flag:`--query <text>`,description:`Search query text`,required:!0},{flag:`--count <n>`,description:`Number of search results (default: 10)`,type:`number`},{flag:`--list-tools`,description:`List available MCP tools and exit`}],examples:[`bl search web --query "阿里云百炼最新功能"`,`bl search web --query "TypeScript 5.9 new features" --count 5`,`bl search web --query "今日新闻"`,`bl search web --list-tools`],async run(e,t){let n=T(e.baseUrl),r=f(e.output);if(t.listTools){if(e.dryRun){N({endpoint:n,action:`tools/list`},r);return}let t=new o(e,n);await t.initialize(),N({tools:await t.listTools()},r);return}let i=t.query;if(!i)if(x({nonInteractive:e.nonInteractive})){let e=await Ar({message:`Enter your search query:`});e||(process.stderr.write(`Search cancelled.
150
+ `),process.exit(1)),i=e}else U(`query`,`bl search web --query <text>`);if(e.dryRun){N({endpoint:n,action:`tools/call`,tool:`bailian_web_search`,arguments:{query:i,count:t.count||void 0}},r);return}let a=new o(e,n),s=Si(`Initializing search...`);e.quiet||s.start();try{await a.initialize(),e.quiet||s.update(`Searching...`);let n={query:i};t.count&&(n.count=t.count);let o=await a.callTool(`bailian_web_search`,n);if(e.quiet||s.stop(`Done.`),o.isError){let e=o.content.map(e=>e.text||``).join(`
151
+ `);process.stderr.write(`Search error: ${e}\n`),process.exit(1)}if(r===`json`)N(o,r);else for(let e of o.content)if(e.type===`text`&&e.text)try{let t=JSON.parse(e.text);t.pages&&Array.isArray(t.pages)?N({pages:t.pages,total:t.pages.length},r):N(t,r)}catch{N({text:e.text},r)}}catch(e){throw s.stop(`Failed.`),e}}})}));function uo(e){let t=go[e];if(!t){process.stdout.write(`No built-in voice list available for model: ${e}\n`);return}if(t.length===0){process.stdout.write(`Model ${e} has no system voices.\n`),process.stdout.write(`Use clone or design voices created via the CosyVoice API.
152
+ `),process.stdout.write(`See: ${mo}\n`);return}let n=(e,t)=>e.padEnd(t);process.stdout.write(`\nSystem voices for ${e}:\n`),process.stdout.write(`${n(`VOICE ID`,26)} ${n(`NAME`,10)} ${n(`DESCRIPTION`,16)} LANGUAGE\n`),process.stdout.write(`${`-`.repeat(26)} ${`-`.repeat(10)} ${`-`.repeat(16)} ${`-`.repeat(12)}\n`);for(let e of t)process.stdout.write(`${n(e.voice,26)} ${n(e.name,10)} ${n(e.desc,16)} ${e.lang}\n`);process.stdout.write(`\nTotal: ${t.length} voices\n`)}async function fo(e,n,r,a,o){let s=await Mi(ji(a),e,()=>O(e,{url:n,method:`POST`,body:r})),c=s.map(e=>e.output?.audio?.url).filter(Boolean);if(c.length===0)throw new t(`API returned no audio URL.`,i.GENERAL);let l=await import(`path`),u=se(e,{subDir:`speech`}),d=await Ni(c.map((e,t)=>{let n=a.out;if(!(n&&c.length===1)){let e=Date.now(),i=c.length>1?`_${String(t+1).padStart(3,`0`)}`:``,a=r.input.format??`mp3`;n=l.join(u,`tts_${e}${i}.${a}`)}return{url:e,destPath:n}}),Oi,{quiet:e.quiet});if(e.quiet)P(d.join(`
153
+ `));else if(d.length===1){let e=s[0].output?.audio?.expires_at;N({saved:d[0],audio_url:c[0],model:r.model,voice:r.input.voice,...e?{url_expires_at:e}:{}},o)}else N({saved:d,audio_urls:c,total:d.length,model:r.model,voice:r.input.voice},o)}async function po(e,t,n,r,i){let a=await ae(e,{url:t,method:`POST`,body:n,stream:!0,headers:{Accept:`text/event-stream`,"X-DashScope-SSE":`enable`}}),o=r.out,s=o?Oe(o):null,c;try{for await(let t of re(a)){if(!t.data||t.data===`[DONE]`)continue;let n;try{n=JSON.parse(t.data)}catch{continue}let r=n.output?.audio?.data;if(r){let e=Buffer.from(r,`base64`);s?s.write(e)||await new Promise(e=>s.once(`drain`,()=>e())):process.stdout.write(e)}if(n.output?.finish_reason===`stop`){c=n.output?.audio?.url,c&&!e.quiet&&process.stderr.write(`\nFull audio URL: ${c}\n`);break}}}finally{s&&(await new Promise((e,t)=>{s.on(`finish`,e),s.on(`error`,t),s.end()}),!e.quiet&&o&&process.stderr.write(`Saved: ${o}\n`))}o&&N({saved:o,...c?{audio_url:c}:{},model:n.model,voice:n.input.voice},i)}var mo,ho,go,_o,vo=j((()=>{Ai(),Pi(),W(),F(),mo=`${r.cn}/cosyvoice-clone-design-api`,ho=[{voice:`longanyang`,name:`龙安洋`,desc:`阳光大男孩`,lang:`中文/英文`},{voice:`longanhuan`,name:`龙安欢`,desc:`欢脱元气女`,lang:`中文/英文`},{voice:`longantai_v3`,name:`龙安台`,desc:`嗲甜台湾女`,lang:`中文/英文`},{voice:`longhua_v3`,name:`龙华`,desc:`元气甜美女`,lang:`中文/英文`},{voice:`longcheng_v3`,name:`龙橙`,desc:`智慧青年男`,lang:`中文/英文`},{voice:`longze_v3`,name:`龙泽`,desc:`温暖元气男`,lang:`中文/英文`},{voice:`longzhe_v3`,name:`龙哲`,desc:`呆板大暖男`,lang:`中文/英文`},{voice:`longyan_v3`,name:`龙颜`,desc:`温暖春风女`,lang:`中文/英文`},{voice:`longxing_v3`,name:`龙星`,desc:`温婉邻家女`,lang:`中文/英文`},{voice:`longtian_v3`,name:`龙天`,desc:`磁性理智男`,lang:`中文/英文`},{voice:`longwan_v3`,name:`龙婉`,desc:`细腻柔声女`,lang:`中文/英文`},{voice:`longqiang_v3`,name:`龙嫱`,desc:`浪漫风情女`,lang:`中文/英文`},{voice:`longfeifei_v3`,name:`龙菲菲`,desc:`甜美娇气女`,lang:`中文/英文`},{voice:`longhao_v3`,name:`龙浩`,desc:`多情忧郁男`,lang:`中文/英文`},{voice:`longanrou_v3`,name:`龙安柔`,desc:`温柔娴静女`,lang:`中文/英文`},{voice:`longxiaochun_v3`,name:`龙小淳`,desc:`知性积极女`,lang:`中文/英文`},{voice:`longxiaoxia_v3`,name:`龙小夏`,desc:`沉稳权威女`,lang:`中文/英文`},{voice:`longyumi_v3`,name:`YUMI`,desc:`正经青年女`,lang:`中文/英文`},{voice:`longanyun_v3`,name:`龙安昀`,desc:`居家暖男`,lang:`中文/英文`},{voice:`longanwen_v3`,name:`龙安温`,desc:`优雅知性女`,lang:`中文/英文`},{voice:`longanli_v3`,name:`龙安莉`,desc:`利落从容女`,lang:`中文/英文`},{voice:`longanlang_v3`,name:`龙安朗`,desc:`清爽利落男`,lang:`中文/英文`},{voice:`longyingmu_v3`,name:`龙应沐`,desc:`优雅知性女`,lang:`中文/英文`},{voice:`longyingxun_v3`,name:`龙应询`,desc:`年轻青涩男`,lang:`中文/英文`},{voice:`longyingjing_v3`,name:`龙应静`,desc:`低调冷静女`,lang:`中文/英文`},{voice:`longyingling_v3`,name:`龙应聆`,desc:`温和共情女`,lang:`中文/英文`},{voice:`longyingtao_v3`,name:`龙应桃`,desc:`温柔淡定女`,lang:`中文/英文`},{voice:`longyingxiao_v3`,name:`龙应笑`,desc:`清甜推销女`,lang:`中文/英文`},{voice:`longfei_v3`,name:`龙飞`,desc:`热血磁性男`,lang:`中文/英文`},{voice:`longhuhu_v3`,name:`龙呼呼`,desc:`天真烂漫女童`,lang:`中文/英文`},{voice:`longpaopao_v3`,name:`龙泡泡`,desc:`飞天泡泡音`,lang:`中文/英文`},{voice:`longjielidou_v3`,name:`龙杰力豆`,desc:`阳光顽皮男`,lang:`中文/英文`},{voice:`longxian_v3`,name:`龙仙`,desc:`豪放可爱女`,lang:`中文/英文`},{voice:`longling_v3`,name:`龙铃`,desc:`稚气呆板女`,lang:`中文/英文`},{voice:`longshanshan_v3`,name:`龙闪闪`,desc:`戏剧化童声`,lang:`中文/英文`},{voice:`longniuniu_v3`,name:`龙牛牛`,desc:`阳光男童声`,lang:`中文/英文`},{voice:`longjiaxin_v3`,name:`龙嘉欣`,desc:`优雅粤语女`,lang:`粤语/英文`},{voice:`longjiayi_v3`,name:`龙嘉怡`,desc:`知性粤语女`,lang:`粤语/英文`},{voice:`longanyue_v3`,name:`龙安粤`,desc:`欢脱粤语男`,lang:`粤语/英文`},{voice:`longlaotie_v3`,name:`龙老铁`,desc:`东北直率男`,lang:`东北话/英文`},{voice:`longshange_v3`,name:`龙陕哥`,desc:`原味陕北男`,lang:`陕西话/英文`},{voice:`longanmin_v3`,name:`龙安闽`,desc:`清纯萝莉女`,lang:`闽南话/英文`},{voice:`loongabby_v3`,name:`loongabby`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongandy_v3`,name:`loongandy`,desc:`美式英文男`,lang:`美式英语`},{voice:`loongannie_v3`,name:`loongannie`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongava_v3`,name:`loongava`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongbeth_v3`,name:`loongbeth`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongbetty_v3`,name:`loongbetty`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongcally_v3`,name:`loongcally`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongcindy_v3`,name:`loongcindy`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongdavid_v3`,name:`loongdavid`,desc:`美式英文男`,lang:`美式英语`},{voice:`loongdonna_v3`,name:`loongdonna`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongemily_v3`,name:`loongemily`,desc:`英式英文女`,lang:`英式英语`},{voice:`loongeric_v3`,name:`loongeric`,desc:`英式英文男`,lang:`英式英语`},{voice:`loongluna_v3`,name:`loongluna`,desc:`英式英文女`,lang:`英式英语`},{voice:`loongluca_v3`,name:`loongluca`,desc:`英式英文男`,lang:`英式英语`},{voice:`loongriko_v3`,name:`Riko`,desc:`二次元霓虹女`,lang:`日语`},{voice:`loongtomoka_v3`,name:`loongtomoka`,desc:`日语女`,lang:`日语`},{voice:`loongtomoya_v3`,name:`loongtomoya`,desc:`日语男`,lang:`日语`},{voice:`loongyuuna_v3`,name:`Yuuna`,desc:`日语女`,lang:`日语`},{voice:`loongyuuma_v3`,name:`Yuuma`,desc:`日语男`,lang:`日语`},{voice:`loongkyong_v3`,name:`loongkyong`,desc:`韩语女`,lang:`韩语`},{voice:`loongjihun_v3`,name:`Jihun`,desc:`韩语男`,lang:`韩语`},{voice:`loongindah_v3`,name:`loongindah`,desc:`印尼女`,lang:`印尼语`}],go={"cosyvoice-v3-flash":ho,"cosyvoice-v3-plus":ho,"cosyvoice-v3.5-flash":[],"cosyvoice-v3.5-plus":[],"cosyvoice-v2":[]},_o=d({name:`speech synthesize`,description:`Synthesize speech from text (CosyVoice TTS)`,apiDocs:`/developer-reference/cosyvoice`,usage:`bl speech synthesize --text <text> [flags]`,options:[{flag:`--text <text>`,description:`Text to synthesize into speech`,required:!0},{flag:`--text-file <path>`,description:`Read text from a file instead of --text`},{flag:`--model <model>`,description:`Model ID (default: cosyvoice-v3-flash). System voices available for cosyvoice-v3-flash`},{flag:`--voice <voice>`,description:`Voice ID. Use --list-voices to see system voices for cosyvoice-v3-flash; for v3.5-flash provide a clone/design voice ID`},{flag:`--list-voices`,description:`List available system voices for the selected model and exit`},{flag:`--format <format>`,description:`Audio format: mp3, pcm, wav, opus (default: mp3)`},{flag:`--sample-rate <rate>`,description:`Audio sample rate in Hz (e.g. 24000)`},{flag:`--volume <volume>`,description:`Volume 0-100 (default: 50)`},{flag:`--rate <rate>`,description:`Speech rate 0.5-2.0 (default: 1.0)`},{flag:`--pitch <pitch>`,description:`Pitch multiplier 0.5-2.0 (default: 1.0)`},{flag:`--seed <seed>`,description:`Random seed 0-65535 for reproducible synthesis`},{flag:`--language <lang>`,description:`Language hint (e.g. zh, en, ja, ko, fr, de)`},{flag:`--instruction <text>`,description:`Natural language instruction to control speech style (e.g. "请用温柔的语调")`},{flag:`--enable-ssml`,description:`Enable SSML markup parsing in input text`},{flag:`--out <path>`,description:`Save audio to file (default: auto-generate in temp dir)`},{flag:`--stream`,description:`Stream raw PCM audio to stdout (pipe to player)`}],examples:[`bl speech synthesize --list-voices --model cosyvoice-v3-flash`,`bl speech synthesize --text "你好,我是千问" --voice <voice_id>`,`bl speech synthesize --text "Hello world" --voice <voice_id> --language en`,`bl speech synthesize --text-file script.txt --out speech.wav --voice <voice_id>`,`bl speech synthesize --text "今天天气真好" --voice <voice_id> --instruction "请用温柔的语调说话"`,`bl speech synthesize --text "Hello" --voice <voice_id> --format wav --sample-rate 24000`,`# Stream to audio player (macOS)`,`bl speech synthesize --text "你好" --voice <voice_id> --stream | afplay -`,`# Pipe to ffplay`,`bl speech synthesize --text "Hello" --voice <voice_id> --stream | ffplay -nodisp -autoexit -f s16le -ar 24000 -ac 1 -`],async run(e,n){let r=n.model||e.defaultSpeechModel||`cosyvoice-v3-flash`;if(n.listVoices){uo(r);return}let a=n.text;if(!a&&n.textFile){let e=n.textFile;try{a=je(e,`utf-8`).trim()}catch{throw new t(`Cannot read text file: ${e}`,i.USAGE)}}if(!a)if(x({nonInteractive:e.nonInteractive})){let e=await Ar({message:`Enter text to synthesize:`});e||(process.stderr.write(`Speech synthesis cancelled.
154
+ `),process.exit(1)),a=e}else U(`text`,`bl speech synthesize --text <text>`);let o=n.voice||void 0;if(!o)if(x({nonInteractive:e.nonInteractive})){let e=go[r];if(e&&e.length>0){let t=e[0].voice,n=e.map(e=>({value:e.voice,label:`${e.name} (${e.voice})`,hint:`${e.desc} · ${e.lang}`})),r=await Mr({message:`Select a voice (default: ${t}):`,choices:n,defaultValue:t});r||(process.stderr.write(`Speech synthesis cancelled.
155
+ `),process.exit(1)),o=r}else{let e=await Ar({message:`Enter voice ID (clone/design voice):`});e||(process.stderr.write(`Speech synthesis cancelled.
156
+ `),process.exit(1)),o=e}}else{let e=go[r];throw e&&e.length>0?new t(`--voice is required.\nRun the following to see available voices:\n bl speech synthesize --list-voices --model ${r}`,i.USAGE):new t(`--voice is required. Model ${r} has no built-in system voices.\nCreate a clone or design voice first, then pass its ID via --voice <voice_id>.\nSee: ${mo}`,i.USAGE)}let s=n.language||void 0,c=n.instruction||void 0,l=n.format||void 0,u=n.sampleRate===void 0?void 0:Number(n.sampleRate),d=n.volume===void 0?void 0:Number(n.volume),p=n.rate===void 0?void 0:Number(n.rate),m=n.pitch===void 0?void 0:Number(n.pitch),h=n.seed===void 0?void 0:Number(n.seed),g=n.enableSsml===!0?!0:void 0,_=n.stream===!0,v=f(e.output),y={model:r,input:{text:a,voice:o,format:l,sample_rate:u,volume:d,rate:p,pitch:m,seed:h,language_hints:s?[s]:void 0,instruction:c,enable_ssml:g}};if(de(y.input),e.dryRun){N({request:y},v);return}e.quiet||process.stderr.write(`[Model: ${r}] [Voice: ${o}]\n`);let b=ue(e.baseUrl);_?await po(e,b,y,n,v):await fo(e,b,y,n,v)}})}));async function yo(e,n,r,a,o,s){let c=(await O(e,{url:n,method:`POST`,body:r,async:!0})).output.task_id;if(a.noWait||e.async){N({task_id:c},o);return}let l=a.pollInterval??2,u=await Ei(e,{url:fe(e.baseUrl,c),intervalSec:l,timeoutSec:e.timeout,isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>e.output.message}),d=u.output.results??[];if(d.length===0){N({task_id:c,status:u.output.task_status},o);return}let f=[];for(let e=0;e<d.length;e++){let n=d[e],r=s>1;if(r&&process.stdout.write(`=== [${e+1}/${d.length}] ${n.file_url??``} ===\n`),n.subtask_status===`FAILED`){let e=n.message??n.code??`unknown error`;process.stdout.write(`[FAILED] ${n.file_url??``} — ${e}\n`),r&&process.stdout.write(`
156
157
  `);continue}if(!n.transcription_url){r&&process.stdout.write(`
157
- `);continue}let a=await fetch(n.transcription_url,{headers:he()});if(!a.ok)throw new t(`Failed to download transcription: HTTP ${a.status}`,i.GENERAL);let o=await a.json();f.push(o);let c=o.transcripts;if(c&&c.length>0)for(let e of c)if(e.sentences&&e.sentences.length>0)for(let t of e.sentences){let e=t.speaker_id===void 0?``:` [Speaker ${t.speaker_id}]`;process.stdout.write(`${t.text}${e}\n`)}else e.text&&process.stdout.write(e.text+`
158
- `);else N(JSON.stringify(o));r&&process.stdout.write(`
159
- `)}if(a.out){let t=a.out,n=f.length===1?f[0]:f;Pe(t,JSON.stringify(n,null,2)+`
160
- `),e.quiet||process.stderr.write(`Full result saved to: ${t}\n`)}}var ho,go=A((()=>{Si(),U(),P(),ho=d({name:`speech recognize`,description:`Recognize speech from audio files (FunAudio-ASR)`,apiDocs:`/developer-reference/recording-file-recognition`,usage:`bl speech recognize --url <audio-url> [flags]`,options:[{flag:`--url <url>`,description:`Audio file URL or local file path (repeatable, max 100)`,required:!0,type:`array`},{flag:`--model <model>`,description:`Model ID (default: fun-asr)`},{flag:`--language <lang>`,description:`Language hint (e.g. zh, en, ja)`},{flag:`--diarization`,description:`Enable automatic speaker diarization`},{flag:`--speaker-count <n>`,description:`Expected number of speakers (requires --diarization)`,type:`number`},{flag:`--vocabulary-id <id>`,description:`Hot-word vocabulary ID for improved accuracy`},{flag:`--channel-id <n>`,description:`Audio channel ID (default: 0)`,type:`number`},{flag:`--out <path>`,description:`Save full transcription result to JSON file`},{flag:`--no-wait`,description:`Return task ID immediately without polling`},{flag:`--poll-interval <seconds>`,description:`Polling interval in seconds (default: 2)`,type:`number`}],examples:[`bl speech recognize --url https://example.com/audio.mp3`,`bl speech recognize --url https://example.com/a.mp3 --url https://example.com/b.mp3`,`bl speech recognize --url https://example.com/meeting.wav --diarization --speaker-count 3`,`bl speech recognize --url https://example.com/audio.mp3 --language zh`,`bl speech recognize --url https://example.com/audio.mp3 --vocabulary-id vocab-abc123`,`bl speech recognize --url https://example.com/audio.mp3 --out result.json`,`bl speech recognize --url https://example.com/audio.mp3 --no-wait --quiet`],async run(e,n){let r=[];Array.isArray(n.url)?r=n.url:typeof n.url==`string`&&(r=[n.url]),r.length===0&&H(`url`,`bl speech recognize --url <audio-url>`);let a=n.speakerCount,o=n.diarization===!0;if(a!==void 0&&!o)throw new t(`--speaker-count requires --diarization to be enabled.
161
- Hint: Add --diarization flag to enable speaker separation.`,i.USAGE);let s=n.model||`fun-asr`,c=f(e.output),l=await O(e),u=await Promise.all(r.map(e=>k(e,l.token,s))),d=n.channelId,p=n.language,m=n.vocabularyId,h={model:s,input:{file_urls:u},parameters:{channel_id:d===void 0?[0]:[d],language_hints:p?[p]:void 0,diarization_enabled:o?!0:void 0,speaker_count:a,vocabulary_id:m}};if(fe(h.parameters),e.dryRun){M({request:h,mode:`async`},c);return}e.quiet||process.stderr.write(`[Model: ${s}] [Mode: async] [Files: ${u.length}]\n`),await mo(e,ue(e.baseUrl),h,n,c,u.length)}})})),_o,vo=A((()=>{U(),P(),_o=d({name:`file upload`,description:`Upload a local file to DashScope temporary storage (48h)`,apiDocs:`/developer-reference/get-temporary-file-url`,usage:`bl file upload --file <path> --model <model>`,options:[{flag:`--file <path>`,description:`Local file to upload (image, video, audio)`,required:!0},{flag:`--model <model>`,description:`Target model name (file is bound to this model)`,required:!0}],examples:[`bl file upload --file photo.jpg --model qwen-vl-max`,`bl file upload --file video.mp4 --model wan2.1-t2v-plus`,`bl file upload --file audio.wav --model qwen3-asr-flash`,`bl file upload --file cat.png --model qwen-image-2.0`],async run(e,t){let n=t.file;n||H(`file`,`bl file upload --file <path> --model <model>`);let r=t.model;r||H(`model`,`bl file upload --file <path> --model <model>`);let i=f(e.output);if(e.dryRun){M({action:`upload`,file:n,model:r},i);return}let a=await ge({apiKey:(await O(e)).token,model:r,filePath:n});e.quiet?N(a):M({url:a,model:r,expires_in:`48 hours`,note:`When using this URL in API calls, add header: X-DashScope-OssResourceResolve: enable`},i)}})})),yo,bo=A((()=>{U(),P(),yo=d({name:`console call`,description:`Call a Bailian console API via the CLI gateway`,usage:`bl console call --api <api> --data <json> [flags]`,options:[{flag:`--api <api>`,description:`API name (e.g. zeldaEasy.broadscope-bailian.memory-library.getLibraries)`,required:!0},{flag:`--data <json>`,description:`Request data as JSON string`,required:!0},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl console call --api zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota --data '{"queryFreeTierQuotaRequest":{"models":["qwen3-max"]}}'`,`bl console call --api some.api.name --data '{"key":"value"}' --region cn-beijing`],async run(e,r){let i=r.api;i||H(`api`,`bl console call --api <api> --data <json>`);let a=r.data;a||H(`data`,`bl console call --api <api> --data <json>`);let o;try{o=JSON.parse(a)}catch{process.stderr.write(`Error: --data must be valid JSON
162
- `),process.exit(1)}let s=r.region||`cn-beijing`,l=f(e.output),u;try{u=(await se(e)).token}catch(e){if(!(e instanceof t&&e.message===n))throw e}if(e.dryRun){M({api:i,data:o,region:s,token:u?u.slice(0,8)+`...`:null},l);return}M(await c(e,u,{api:i,data:o,region:s}),l)}})})),xo,So,Co=A((()=>{U(),P(),xo=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota`,So=d({name:`usage free`,description:`Query free-tier quota for a model`,usage:`bl usage free --model <model> [flags]`,options:[{flag:`--model <model>`,description:`Model name to query (e.g. qwen3-max, qwen-turbo)`,required:!0},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl usage free --model qwen3-max`,`bl usage free --model qwen-turbo --output json`,`bl usage free --model qwen3-max --region cn-beijing`],async run(e,t){let n=t.model;n||H(`model`,`bl usage free --model <model>`);let r=t.region||`cn-beijing`,i=f(e.output),a=await se(e),o={queryFreeTierQuotaRequest:{models:[n]}};if(e.dryRun){M({api:xo,data:o,region:r,token:a.token.slice(0,8)+`...`},i);return}M(await c(e,a.token,{api:xo,data:o,region:r}),i)}})}));function wo(e,t){return e instanceof W?e:new W(`step_execution_error`,e instanceof Error?e.message:String(e),{step:t})}var W,To=A((()=>{W=class extends Error{code;step;details;constructor(e,t,n){super(t),this.name=`PipelineError`,this.code=e,this.step=n?.step,this.details=n?.details}toJSON(){return{code:this.code,message:this.message,...this.step?{step:this.step}:{},...this.details?{details:this.details}:{}}}}}));function Eo(){return ko}function Do(e,t,n,r){let i,a;n instanceof Oo?(i=n,a=r):(i=ko,a=n??r),i.registerStep(e,t,a)}var Oo,ko,Ao=A((()=>{To(),Oo=class{handlers=new Map;outputSchemas=new Map;registerStep(e,t,n){this.handlers.set(e,t),n&&this.outputSchemas.set(e,n)}executeStep(e,t,n){let r=this.handlers.get(e);if(!r)throw new W(`unknown_step`,`Unknown step type: ${e}`,{details:{available:this.listSteps()}});return r(t,n)}hasStep(e){return this.handlers.has(e)}listSteps(){return Array.from(this.handlers.keys()).sort()}getOutputSchema(e){return this.outputSchemas.get(e)}},ko=new Oo}));function jo(){let e=C(Mo);return e.clientName=`bailian-cli`,e}var Mo,No=A((()=>{Mo={output:`json`,nonInteractive:!0,noColor:!0,quiet:!0,verbose:!1,yes:!1,dryRun:!1,help:!1,async:!1}}));function Po(e){return e.startsWith(`./`)||e.startsWith(`../`)}function Fo(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))typeof a==`string`&&Po(a)?(n[i]=Ge(t,a),r.push(i)):n[i]=a;return{input:n,resolvedKeys:r}}async function Io(e,t,n){let r=[];for(let i of t){let t=e[i];typeof t==`string`&&(await ze(t).then(()=>!0,()=>!1)||r.push(`Step "${n}" input "${i}" references file that does not exist: ${t}`))}return r}function Lo(e){if(e===void 0)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m)?$/);if(!t)return;let n=Number(t[1]);if(!Number.isFinite(n)||n<=0)return;let r=t[2]??`s`;return r===`ms`?n/1e3:r===`m`?n*60:n}function G(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Ro(e,t){if(Array.isArray(e)){e.forEach(e=>Ro(e,t));return}if(G(e)){`$from`in e&&typeof e.$from==`string`&&t.add(e.$from);for(let n of Object.values(e))Ro(n,t)}}async function zo(e,t){let n=[];for(let r of e)for(let[e,i]of Object.entries(r.input)){if(Bo.includes(e)||typeof i!=`string`||!Po(i))continue;let a=Ge(t,i);await ze(a).then(()=>!0,()=>!1)||n.push(`Step "${r.id}" input "${e}" references file that does not exist: ${a}`)}return n}var Bo,Vo=A((()=>{Bo=[`download`,`out-dir`,`output`]}));async function Ho(e,t,n){if(!t.message)throw new W(`missing_input`,`text/chat requires 'message' input`,{step:`text/chat`});let r=t.model||`qwen3.7-max`,i=[];t.system&&i.push({role:`system`,content:t.system}),i.push({role:`user`,content:t.message});let a={model:r,messages:i,max_tokens:t[`max-tokens`]??4096,stream:!1};return t.temperature!==void 0&&(a.temperature=t.temperature),t[`top-p`]!==void 0&&(a.top_p=t[`top-p`]),t[`enable-thinking`]&&(a.enable_thinking=!0,t[`thinking-budget`]!==void 0&&(a.thinking_budget=t[`thinking-budget`])),await D(e,{url:l(e.baseUrl),method:`POST`,body:a,timeout:n.blRequestTimeoutSeconds,signal:n.signal})}async function Uo(e,t,n){let r=t.model||`qwen-vl-max`,i=Array.isArray(t.image)?t.image:t.image?[t.image]:[],a=t.video?`Describe the video.`:`Describe the image.`,o=t.prompt||a,s=[];if(t.video){let i=t.video;if(S(i)){let t=await O(e);i=await k(i,t.token,r,{signal:n.signal})}s.push({type:`video_url`,video_url:{url:i}})}for(let t of i){let i=t;S(t)&&(i=await k(t,(await O(e)).token,r,{signal:n.signal})),s.push({type:`image_url`,image_url:{url:i}})}s.push({type:`text`,text:o});let c={model:r,messages:[{role:`user`,content:s}]};return await D(e,{url:l(e.baseUrl),method:`POST`,body:c,signal:n.signal})}function Wo(e){return ts.some(t=>e.startsWith(t))}async function Go(e,t,n){if(!t.prompt)throw new W(`missing_input`,`image/generate requires 'prompt' input`,{step:`image/generate`});let r=t.model||`qwen-image-2.0`,i=Wo(r),a=t.n??1,o;t[`no-prompt-extend`]?o=!1:(t[`prompt-extend`]||i)&&(o=!0);let s={model:r,input:{messages:[{role:`user`,content:[{text:t.prompt}]}]},parameters:{size:Ai(t.size,i),n:a,seed:t.seed,prompt_extend:o,watermark:t.watermark===!0?!0:void 0,negative_prompt:t[`negative-prompt`]||void 0}};if(i){let r=await D(e,{url:b(e.baseUrl),method:`POST`,body:s,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),a=await qo(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await D(e,{url:y(e.baseUrl),method:`POST`,body:s,async:!0,signal:n.signal})).output.task_id,i=await Qo(e,r,n),a=await qo(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function Ko(e,t,n){if(!t.prompt)throw new W(`missing_input`,`image/edit requires 'prompt' input`,{step:`image/edit`});let r=Array.isArray(t.image)?t.image:t.image?[t.image]:[],i=t.model||`qwen-image-2.0`,a=Wo(i),o=t.n??1,s;t[`no-prompt-extend`]?s=!1:(t[`prompt-extend`]||a)&&(s=!0);let c=[];for(let t of r){let r=t;S(t)&&(r=await k(t,(await O(e)).token,i,{signal:n.signal})),c.push({image:r})}c.push({text:t.prompt});let l={model:i,input:{messages:[{role:`user`,content:c}]},parameters:{size:Ai(t.size,a),n:o,seed:t.seed,prompt_extend:s,watermark:t.watermark===!0?!0:void 0,negative_prompt:t[`negative-prompt`]||void 0}};if(a){let r=await D(e,{url:b(e.baseUrl),method:`POST`,body:l,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),a=await qo(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await D(e,{url:y(e.baseUrl),method:`POST`,body:l,async:!0,signal:n.signal})).output.task_id,i=await Qo(e,r,n),a=await qo(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function qo(e,t,n){if(!t||e.length===0)return;await Be(t,{recursive:!0});let r=n&&n.length>0?n:`image`,i=e.length===1?[{url:e[0],destPath:We(t,`${r}.png`)}]:e.map((e,n)=>({url:e,destPath:We(t,`${r}_${String(n+1).padStart(3,`0`)}.png`)})),a=[];for(let{url:e,destPath:t}of i)await Ci(e,t,{quiet:!0}),a.push(t);return a}async function Jo(e,t,n){if(!t.prompt)throw new W(`missing_input`,`video/generate requires 'prompt' input`,{step:`video/generate`});let r=t.model||(t.image?`happyhorse-1.0-i2v`:`happyhorse-1.0-t2v`),i;if(t.image)if(S(t.image)){let a=await O(e);i=await k(t.image,a.token,r,{signal:n.signal})}else i=t.image;let a={model:r,input:{prompt:t.prompt,negative_prompt:t[`negative-prompt`]||void 0,...i?{media:[{type:`first_frame`,url:i}]}:{}},parameters:{resolution:t.resolution||void 0,ratio:t.ratio||void 0,duration:t.duration,prompt_extend:t[`prompt-extend`],watermark:t.watermark,seed:t.seed}};fe(a.parameters);let o=(await D(e,{url:ve(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await $o(e,o,(t[`poll-interval`]??10)*1e3,(n.timeoutSeconds??900)*1e3,n)}async function Yo(e,t,n){let r=t.text;if(!r&&t[`text-file`]){let{readFileSync:e}=await import(`node:fs`);r=e(t[`text-file`],`utf-8`).trim()}if(!r)throw new W(`missing_input`,`speech/synthesize requires 'text' input`,{step:`speech/synthesize`});let i=t.model||`cosyvoice-v3-flash`,a={model:i,input:{text:r,voice:t.voice,format:t.format,sample_rate:t[`sample-rate`],volume:t.volume,rate:t.rate,pitch:t.pitch,seed:t.seed,language_hints:t.language?[t.language]:void 0,instruction:t.instruction,enable_ssml:t[`enable-ssml`]}};fe(a.input);let o=await D(e,{url:de(e.baseUrl),method:`POST`,body:a,signal:n.signal});return{audio_url:o.output.audio.url,url_expires_at:o.output.audio.expires_at,model:i,voice:t.voice,request_id:o.request_id}}async function Xo(e,t,n){let r=Array.isArray(t.url)?t.url:t.url?[t.url]:[];if(r.length===0)throw new W(`missing_input`,`speech/recognize requires 'url' input`,{step:`speech/recognize`});let i=[];for(let a of r)if(S(a)){let r=await O(e);i.push(await k(a,r.token,t.model||`fun-asr`,{signal:n.signal}))}else i.push(a);let a={model:t.model||`fun-asr`,input:{file_urls:i},parameters:{channel_id:t[`channel-id`]===void 0?void 0:[t[`channel-id`]],language_hints:t.language?[t.language]:void 0,diarization_enabled:t.diarization,speaker_count:t[`speaker-count`],vocabulary_id:t[`vocabulary-id`]}};fe(a.parameters);let o=(await D(e,{url:ue(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await $o(e,o,(t[`poll-interval`]??2)*1e3,(n.timeoutSeconds??300)*1e3,n)}function Zo(e){let{output:t,request_id:n,usage:r}=e,i={task_id:t.task_id,task_status:t.task_status,request_id:n};if(t.video_url&&(i.video_url=t.video_url),t.choices){let e=t.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);e.length>0&&(i.urls=e)}if(t.results){let e=t.results.map(e=>e.url).filter(Boolean);e.length>0&&!i.urls&&(i.urls=e)}return t.task_metrics&&(i.task_metrics=t.task_metrics),r&&(i.usage=r),i}async function Qo(e,t,n){return await $o(e,t,3e3,e.timeout*1e3,n)}async function $o(e,t,n,r,i){let a=Date.now(),o=0;for(;;){if(i?.signal?.aborted)throw new W(`aborted`,`Task polling was aborted`,{details:{taskId:t}});await es(n,i?.signal),o++;let s=await D(e,{url:pe(e.baseUrl,t),method:`GET`,signal:i?.signal}),c=s.output.task_status;if(c===`SUCCEEDED`)return Zo(s);if(c===`FAILED`)throw new W(`async_task_failed`,s.output.message||s.output.code||`Task failed`,{details:{taskId:t,data:s}});let l=Date.now()-a;if(await i?.emitEvent?.({type:`step.polling`,timestamp:new Date().toISOString(),status:`running`,taskId:t,taskStatus:c,elapsedMs:l,pollAttempt:o}),l>r)throw new W(`async_poll_timeout`,`Task ${t} timed out after ${Math.round(r/1e3)}s`,{details:{taskId:t,timeoutMs:r,pollAttempts:o}})}}function es(e,t){return t?new Promise((n,r)=>{let i=setTimeout(()=>{o(),n()},e),a=()=>{o(),r(new W(`aborted`,`Poll delay was aborted`))},o=()=>{clearTimeout(i),t.removeEventListener(`abort`,a)};t.aborted?a():t.addEventListener(`abort`,a,{once:!0})}):new Promise(t=>setTimeout(t,e))}var ts,ns=A((()=>{To(),Ni(),Ti(),ts=[`qwen-image-2.0`,`qwen-image-max`]}));function rs(e){for(let t of Object.keys(fs))Do(t,async(e,n)=>await is(t,e,n),e,ms[t])}async function is(e,t,n){if(n.dryRun)return{metadata:{dryRun:!0,step:e,plannedInput:t},warnings:[{code:`dry_run_skipped`,message:`Step ${e} was not executed in dry-run mode`}]};let r=fs[e];if(!r)throw Error(`No direct API handler registered for step: ${e}`);let i=await r(n.blConfig??jo(),t,n),a=ps[e];return a?a(i):{data:i,warnings:[],metadata:{}}}function as(e){if(!G(e))return;let t=[],n=K(e.task_id)??K(e.taskId);for(let r of ls(e.urls))t.push({url:r,taskId:n,kind:us(r)});for(let r of ls(e.saved))t.push({path:r,taskId:n,kind:ds(r)});let r=K(e.video_url)??K(e.videoUrl);r&&t.push({url:r,taskId:n,kind:`video`});let i=K(e.saved);if(i&&t.push({path:i,taskId:n,kind:ds(i)}),Array.isArray(e.videos))for(let n of e.videos){if(!G(n))continue;let e=K(n.task_id)??K(n.taskId),r=K(n.video_url)??K(n.videoUrl),i=K(n.saved);r&&t.push({url:r,taskId:e,kind:`video`}),i&&t.push({path:i,taskId:e,kind:`video`})}let a=Array.isArray(e.task_ids)?e.task_ids.map(K).filter(cs):[];for(let e of a)t.push({taskId:e,kind:`task`});return t.length===0&&n&&t.push({taskId:n,kind:`task`}),t.length>0?t:void 0}function os(e,t){if(!G(e))return;let n=[],r=K(e.task_id)??K(e.taskId),i=[K(e.url),K(e.audio_url),K(e.audioUrl),K(e.output_url),K(e.outputUrl)].filter(cs);for(let e of i)n.push({url:e,taskId:r,kind:t});let a=[K(e.saved),K(e.path),K(e.output_path),K(e.outputPath)].filter(cs);for(let e of a)n.push({path:e,taskId:r,kind:t});return n.length===0&&r&&n.push({taskId:r,kind:`task`}),n.length>0?ss(n):void 0}function ss(e){let t=new Set,n=[];for(let r of e){let e=`${r.kind??``}:${r.taskId??``}:${r.url??``}:${r.path??``}`;t.has(e)||(t.add(e),n.push(r))}return n}function cs(e){return typeof e==`string`}function K(e){return typeof e==`string`&&e.length>0?e:void 0}function ls(e){return Array.isArray(e)?e.map(K).filter(cs):[]}function us(e){try{return ds(new URL(e).pathname)}catch{return`artifact`}}function ds(e){let t=e.toLowerCase();return t.endsWith(`.mp4`)||t.endsWith(`.mov`)||t.endsWith(`.webm`)?`video`:t.endsWith(`.png`)||t.endsWith(`.jpg`)||t.endsWith(`.jpeg`)||t.endsWith(`.webp`)?`image`:`artifact`}var fs,ps,ms,hs=A((()=>{Ao(),No(),Vo(),ns(),fs={"text/chat":(e,t,n)=>Ho(e,t,n),"vision/describe":(e,t,n)=>Uo(e,t,n),"image/generate":(e,t,n)=>Go(e,t,n),"image/edit":(e,t,n)=>Ko(e,t,n),"video/generate":(e,t,n)=>Jo(e,t,n),"speech/synthesize":(e,t,n)=>Yo(e,t,n),"speech/recognize":(e,t,n)=>Xo(e,t,n)},ps={"image/generate":e=>({data:e,artifacts:as(e),warnings:[],metadata:{}}),"image/edit":e=>({data:e,artifacts:as(e),warnings:[],metadata:{}}),"video/generate":e=>({data:e,artifacts:as(e),warnings:[],metadata:{}}),"speech/synthesize":e=>({data:e,artifacts:os(e,`audio`),warnings:[],metadata:{}}),"speech/recognize":e=>({data:e,artifacts:os(e,`transcript`),warnings:[],metadata:{}})},ms={"text/chat":{description:`LLM text completion via chat API`,paths:[{path:`/data/choices/0/message/content`,description:`Generated text content`},{path:`/data/choices/0/message/role`,description:`Message role (assistant)`},{path:`/data/usage/total_tokens`,description:`Total token usage`}]},"vision/describe":{description:`Multimodal vision understanding (image/video to text)`,paths:[{path:`/data/choices/0/message/content`,description:`Generated description text`},{path:`/data/choices/0/message/role`,description:`Message role (assistant)`},{path:`/data/usage/total_tokens`,description:`Total token usage`}]},"image/generate":{description:`Text-to-image generation`,paths:[{path:`/data/urls`,description:`Array of generated image URLs`},{path:`/data/urls/0`,description:`First generated image URL`},{path:`/data/task_id`,description:`Async task ID (if applicable)`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"image/edit":{description:`Image editing with reference image(s)`,paths:[{path:`/data/urls`,description:`Array of generated image URLs`},{path:`/data/urls/0`,description:`First generated image URL`},{path:`/data/task_id`,description:`Async task ID (if applicable)`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"video/generate":{description:`Video generation (text-to-video or image-to-video)`,paths:[{path:`/data/video_url`,description:`Generated video URL`},{path:`/data/task_id`,description:`Async task ID`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"speech/synthesize":{description:`Text-to-speech synthesis`,paths:[{path:`/data/audio_url`,description:`Generated audio URL`},{path:`/data/url_expires_at`,description:`Audio URL expiration time`},{path:`/artifacts/0/url`,description:`First artifact URL`}]},"speech/recognize":{description:`Speech recognition (ASR)`,paths:[{path:`/data/text`,description:`Full transcribed text`},{path:`/data/task_id`,description:`Async task ID`},{path:`/artifacts/0/taskId`,description:`Task ID from artifact`}]}}})),gs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;let a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),_s=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=gs();var n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;let o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),q=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;let t=gs(),n=_s();var r=gs();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=_s();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=ne(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=ne(this.rhs,e,n),this}get names(){return te(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=ne(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(re(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>ee(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(ie(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=ne(this.condition,e,t),this}get names(){let e=super.names;return te(e,this.condition),this.else&&ee(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=ne(this.iteration,e,t),this}get names(){return ee(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return te(te(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=ne(this.iterable,e,t),this}get names(){return ee(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&ee(e,this.catch.names),this.finally&&ee(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
163
- `:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function ee(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function te(e,n){return n instanceof t._CodeOrName?ee(e,n.names):e}function ne(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function re(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function ie(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${k(e)}`}e.not=ie;let ae=O(e.operators.AND);function oe(...e){return e.reduce(ae)}e.and=oe;let D=O(e.operators.OR);function se(...e){return e.reduce(D)}e.or=se;function O(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${k(n)} ${e} ${k(r)}`}function k(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),J=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;let t=q(),n=gs();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;let _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),vs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),ys=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=q(),n=J(),r=vs();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}let u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),bs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=ys(),n=q(),r=vs(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),xs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRules=e.isJSONType=void 0;let t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),Ss=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),Cs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;let t=xs(),n=Ss(),r=ys(),i=q(),a=J();var o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;let u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
158
+ `);continue}let a=await fetch(n.transcription_url,{headers:me()});if(!a.ok)throw new t(`Failed to download transcription: HTTP ${a.status}`,i.GENERAL);let o=await a.json();f.push(o);let c=o.transcripts;if(c&&c.length>0)for(let e of c)if(e.sentences&&e.sentences.length>0)for(let t of e.sentences){let e=t.speaker_id===void 0?``:` [Speaker ${t.speaker_id}]`;process.stdout.write(`${t.text}${e}\n`)}else e.text&&process.stdout.write(e.text+`
159
+ `);else P(JSON.stringify(o));r&&process.stdout.write(`
160
+ `)}if(a.out){let t=a.out,n=f.length===1?f[0]:f;Ne(t,JSON.stringify(n,null,2)+`
161
+ `),e.quiet||process.stderr.write(`Full result saved to: ${t}\n`)}}var bo,xo=j((()=>{Di(),W(),F(),bo=d({name:`speech recognize`,description:`Recognize speech from audio files (FunAudio-ASR)`,apiDocs:`/developer-reference/recording-file-recognition`,usage:`bl speech recognize --url <audio-url> [flags]`,options:[{flag:`--url <url>`,description:`Audio file URL or local file path (repeatable, max 100)`,required:!0,type:`array`},{flag:`--model <model>`,description:`Model ID (default: fun-asr)`},{flag:`--language <lang>`,description:`Language hint (e.g. zh, en, ja)`},{flag:`--diarization`,description:`Enable automatic speaker diarization`},{flag:`--speaker-count <n>`,description:`Expected number of speakers (requires --diarization)`,type:`number`},{flag:`--vocabulary-id <id>`,description:`Hot-word vocabulary ID for improved accuracy`},{flag:`--channel-id <n>`,description:`Audio channel ID (default: 0)`,type:`number`},{flag:`--out <path>`,description:`Save full transcription result to JSON file`},{flag:`--no-wait`,description:`Return task ID immediately without polling`},{flag:`--poll-interval <seconds>`,description:`Polling interval in seconds (default: 2)`,type:`number`}],examples:[`bl speech recognize --url https://example.com/audio.mp3`,`bl speech recognize --url https://example.com/a.mp3 --url https://example.com/b.mp3`,`bl speech recognize --url https://example.com/meeting.wav --diarization --speaker-count 3`,`bl speech recognize --url https://example.com/audio.mp3 --language zh`,`bl speech recognize --url https://example.com/audio.mp3 --vocabulary-id vocab-abc123`,`bl speech recognize --url https://example.com/audio.mp3 --out result.json`,`bl speech recognize --url https://example.com/audio.mp3 --no-wait --quiet`],async run(e,n){let r=[];Array.isArray(n.url)?r=n.url:typeof n.url==`string`&&(r=[n.url]),r.length===0&&U(`url`,`bl speech recognize --url <audio-url>`);let a=n.speakerCount,o=n.diarization===!0;if(a!==void 0&&!o)throw new t(`--speaker-count requires --diarization to be enabled.
162
+ Hint: Add --diarization flag to enable speaker separation.`,i.USAGE);let s=n.model||`fun-asr`,c=f(e.output),l=await k(e),u=await Promise.all(r.map(e=>A(e,l.token,s))),d=n.channelId,p=n.language,m=n.vocabularyId,h={model:s,input:{file_urls:u},parameters:{channel_id:d===void 0?[0]:[d],language_hints:p?[p]:void 0,diarization_enabled:o?!0:void 0,speaker_count:a,vocabulary_id:m}};if(de(h.parameters),e.dryRun){N({request:h,mode:`async`},c);return}e.quiet||process.stderr.write(`[Model: ${s}] [Mode: async] [Files: ${u.length}]\n`),await yo(e,le(e.baseUrl),h,n,c,u.length)}})})),So,Co=j((()=>{W(),F(),So=d({name:`file upload`,description:`Upload a local file to DashScope temporary storage (48h)`,apiDocs:`/developer-reference/get-temporary-file-url`,usage:`bl file upload --file <path> --model <model>`,options:[{flag:`--file <path>`,description:`Local file to upload (image, video, audio)`,required:!0},{flag:`--model <model>`,description:`Target model name (file is bound to this model)`,required:!0}],examples:[`bl file upload --file photo.jpg --model qwen3-vl-plus`,`bl file upload --file video.mp4 --model wan2.1-t2v-plus`,`bl file upload --file audio.wav --model qwen3-asr-flash`,`bl file upload --file cat.png --model qwen-image-2.0`],async run(e,t){let n=t.file;n||U(`file`,`bl file upload --file <path> --model <model>`);let r=t.model;r||U(`model`,`bl file upload --file <path> --model <model>`);let i=f(e.output);if(e.dryRun){N({action:`upload`,file:n,model:r},i);return}let a=await he({apiKey:(await k(e)).token,model:r,filePath:n});e.quiet?P(a):N({url:a,model:r,expires_in:`48 hours`,note:`When using this URL in API calls, add header: X-DashScope-OssResourceResolve: enable`},i)}})})),wo,To=j((()=>{W(),F(),wo=d({name:`console call`,description:`Call a Bailian console API via the CLI gateway`,usage:`bl console call --api <api> --data <json> [flags]`,options:[{flag:`--api <api>`,description:`API name (e.g. zeldaEasy.broadscope-bailian.memory-library.getLibraries)`,required:!0},{flag:`--data <json>`,description:`Request data as JSON string`,required:!0},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl console call --api zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota --data '{"queryFreeTierQuotaRequest":{"models":["qwen3-max"]}}'`,`bl console call --api some.api.name --data '{"key":"value"}' --region cn-beijing`],async run(e,r){let i=r.api;i||U(`api`,`bl console call --api <api> --data <json>`);let a=r.data;a||U(`data`,`bl console call --api <api> --data <json>`);let o;try{o=JSON.parse(a)}catch{process.stderr.write(`Error: --data must be valid JSON
163
+ `),process.exit(1)}let s=r.region||`cn-beijing`,l=f(e.output),u;try{u=(await oe(e)).token}catch(e){if(!(e instanceof t&&e.message===n))throw e}if(e.dryRun){N({api:i,data:o,region:s,token:u?u.slice(0,8)+`...`:null},l);return}N(await c(e,u,{api:i,data:o,region:s}),l)}})})),Eo,Do,Oo=j((()=>{W(),F(),Eo=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota`,Do=d({name:`usage free`,description:`Query free-tier quota for a model`,usage:`bl usage free --model <model> [flags]`,options:[{flag:`--model <model>`,description:`Model name to query (e.g. qwen3-max, qwen-turbo)`,required:!0},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl usage free --model qwen3-max`,`bl usage free --model qwen-turbo --output json`,`bl usage free --model qwen3-max --region cn-beijing`],async run(e,t){let n=t.model;n||U(`model`,`bl usage free --model <model>`);let r=t.region||`cn-beijing`,i=f(e.output),a=await oe(e),o={queryFreeTierQuotaRequest:{models:[n]}};if(e.dryRun){N({api:Eo,data:o,region:r,token:a.token.slice(0,8)+`...`},i);return}N(await c(e,a.token,{api:Eo,data:o,region:r}),i)}})}));function ko(e,t){return e instanceof G?e:new G(`step_execution_error`,e instanceof Error?e.message:String(e),{step:t})}var G,Ao=j((()=>{G=class extends Error{code;step;details;constructor(e,t,n){super(t),this.name=`PipelineError`,this.code=e,this.step=n?.step,this.details=n?.details}toJSON(){return{code:this.code,message:this.message,...this.step?{step:this.step}:{},...this.details?{details:this.details}:{}}}}}));function jo(){return Po}function Mo(e,t,n,r){let i,a;n instanceof No?(i=n,a=r):(i=Po,a=n??r),i.registerStep(e,t,a)}var No,Po,Fo=j((()=>{Ao(),No=class{handlers=new Map;outputSchemas=new Map;registerStep(e,t,n){this.handlers.set(e,t),n&&this.outputSchemas.set(e,n)}executeStep(e,t,n){let r=this.handlers.get(e);if(!r)throw new G(`unknown_step`,`Unknown step type: ${e}`,{details:{available:this.listSteps()}});return r(t,n)}hasStep(e){return this.handlers.has(e)}listSteps(){return Array.from(this.handlers.keys()).sort()}getOutputSchema(e){return this.outputSchemas.get(e)}},Po=new No}));function Io(){let e=C(Lo);return e.clientName=`bailian-cli`,e}var Lo,Ro=j((()=>{Lo={output:`json`,nonInteractive:!0,noColor:!0,quiet:!0,verbose:!1,yes:!1,dryRun:!1,help:!1,async:!1}}));function zo(e){return e.startsWith(`./`)||e.startsWith(`../`)}function Bo(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))typeof a==`string`&&zo(a)?(n[i]=We(t,a),r.push(i)):n[i]=a;return{input:n,resolvedKeys:r}}async function Vo(e,t,n){let r=[];for(let i of t){let t=e[i];typeof t==`string`&&(await Re(t).then(()=>!0,()=>!1)||r.push(`Step "${n}" input "${i}" references file that does not exist: ${t}`))}return r}function Ho(e){if(e===void 0)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m)?$/);if(!t)return;let n=Number(t[1]);if(!Number.isFinite(n)||n<=0)return;let r=t[2]??`s`;return r===`ms`?n/1e3:r===`m`?n*60:n}function K(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Uo(e,t){if(Array.isArray(e)){e.forEach(e=>Uo(e,t));return}if(K(e)){`$from`in e&&typeof e.$from==`string`&&t.add(e.$from);for(let n of Object.values(e))Uo(n,t)}}async function Wo(e,t){let n=[];for(let r of e)for(let[e,i]of Object.entries(r.input)){if(Go.includes(e)||typeof i!=`string`||!zo(i))continue;let a=We(t,i);await Re(a).then(()=>!0,()=>!1)||n.push(`Step "${r.id}" input "${e}" references file that does not exist: ${a}`)}return n}var Go,Ko=j((()=>{Go=[`download`,`out-dir`,`output`]}));async function qo(e,t,n){if(!t.message)throw new G(`missing_input`,`text/chat requires 'message' input`,{step:`text/chat`});let r=t.model||`qwen3.7-max`,i=[];t.system&&i.push({role:`system`,content:t.system}),i.push({role:`user`,content:t.message});let a={model:r,messages:i,max_tokens:t[`max-tokens`]??4096,stream:!1};return t.temperature!==void 0&&(a.temperature=t.temperature),t[`top-p`]!==void 0&&(a.top_p=t[`top-p`]),t[`enable-thinking`]&&(a.enable_thinking=!0,t[`thinking-budget`]!==void 0&&(a.thinking_budget=t[`thinking-budget`])),await O(e,{url:l(e.baseUrl),method:`POST`,body:a,timeout:n.blRequestTimeoutSeconds,signal:n.signal})}async function Jo(e,t,n){let r=t.model||`qwen3-vl-plus`,i=Array.isArray(t.image)?t.image:t.image?[t.image]:[],a=t.video?`Describe the video.`:`Describe the image.`,o=t.prompt||a,s=[];if(t.video){let i=t.video;if(S(i)){let t=await k(e);i=await A(i,t.token,r,{signal:n.signal})}s.push({type:`video_url`,video_url:{url:i}})}for(let t of i){let i=t;S(t)&&(i=await A(t,(await k(e)).token,r,{signal:n.signal})),s.push({type:`image_url`,image_url:{url:i}})}s.push({type:`text`,text:o});let c={model:r,messages:[{role:`user`,content:s}]};return await O(e,{url:l(e.baseUrl),method:`POST`,body:c,signal:n.signal})}function Yo(e){return os.some(t=>e.startsWith(t))}async function Xo(e,t,n){if(!t.prompt)throw new G(`missing_input`,`image/generate requires 'prompt' input`,{step:`image/generate`});let r=t.model||`qwen-image-2.0`,i=Yo(r),a=t.n??1,o;t[`no-prompt-extend`]?o=!1:(t[`prompt-extend`]||i)&&(o=!0);let s={model:r,input:{messages:[{role:`user`,content:[{text:t.prompt}]}]},parameters:{size:Fi(t.size,i),n:a,seed:t.seed,prompt_extend:o,watermark:t.watermark===!0?!0:void 0,negative_prompt:t[`negative-prompt`]||void 0}};if(i){let r=await O(e,{url:b(e.baseUrl),method:`POST`,body:s,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),a=await Qo(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await O(e,{url:y(e.baseUrl),method:`POST`,body:s,async:!0,signal:n.signal})).output.task_id,i=await rs(e,r,n),a=await Qo(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function Zo(e,t,n){if(!t.prompt)throw new G(`missing_input`,`image/edit requires 'prompt' input`,{step:`image/edit`});let r=Array.isArray(t.image)?t.image:t.image?[t.image]:[],i=t.model||`qwen-image-2.0`,a=Yo(i),o=t.n??1,s;t[`no-prompt-extend`]?s=!1:(t[`prompt-extend`]||a)&&(s=!0);let c=[];for(let t of r){let r=t;S(t)&&(r=await A(t,(await k(e)).token,i,{signal:n.signal})),c.push({image:r})}c.push({text:t.prompt});let l={model:i,input:{messages:[{role:`user`,content:c}]},parameters:{size:Fi(t.size,a),n:o,seed:t.seed,prompt_extend:s,watermark:t.watermark===!0?!0:void 0,negative_prompt:t[`negative-prompt`]||void 0}};if(a){let r=await O(e,{url:b(e.baseUrl),method:`POST`,body:l,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),a=await Qo(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await O(e,{url:y(e.baseUrl),method:`POST`,body:l,async:!0,signal:n.signal})).output.task_id,i=await rs(e,r,n),a=await Qo(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function Qo(e,t,n){if(!t||e.length===0)return;await ze(t,{recursive:!0});let r=n&&n.length>0?n:`image`,i=e.length===1?[{url:e[0],destPath:Ue(t,`${r}.png`)}]:e.map((e,n)=>({url:e,destPath:Ue(t,`${r}_${String(n+1).padStart(3,`0`)}.png`)})),a=[];for(let{url:e,destPath:t}of i)await Oi(e,t,{quiet:!0}),a.push(t);return a}async function $o(e,t,n){if(!t.prompt)throw new G(`missing_input`,`video/generate requires 'prompt' input`,{step:`video/generate`});let r=t.model||(t.image?`happyhorse-1.0-i2v`:`happyhorse-1.0-t2v`),i;if(t.image)if(S(t.image)){let a=await k(e);i=await A(t.image,a.token,r,{signal:n.signal})}else i=t.image;let a={model:r,input:{prompt:t.prompt,negative_prompt:t[`negative-prompt`]||void 0,...i?{media:[{type:`first_frame`,url:i}]}:{}},parameters:{resolution:t.resolution||void 0,ratio:t.ratio||void 0,duration:t.duration,prompt_extend:t[`prompt-extend`],watermark:t.watermark,seed:t.seed}};de(a.parameters);let o=(await O(e,{url:_e(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await is(e,o,(t[`poll-interval`]??10)*1e3,(n.timeoutSeconds??900)*1e3,n)}async function es(e,t,n){let r=t.text;if(!r&&t[`text-file`]){let{readFileSync:e}=await import(`node:fs`);r=e(t[`text-file`],`utf-8`).trim()}if(!r)throw new G(`missing_input`,`speech/synthesize requires 'text' input`,{step:`speech/synthesize`});let i=t.model||`cosyvoice-v3-flash`,a={model:i,input:{text:r,voice:t.voice,format:t.format,sample_rate:t[`sample-rate`],volume:t.volume,rate:t.rate,pitch:t.pitch,seed:t.seed,language_hints:t.language?[t.language]:void 0,instruction:t.instruction,enable_ssml:t[`enable-ssml`]}};de(a.input);let o=await O(e,{url:ue(e.baseUrl),method:`POST`,body:a,signal:n.signal});return{audio_url:o.output.audio.url,url_expires_at:o.output.audio.expires_at,model:i,voice:t.voice,request_id:o.request_id}}async function ts(e,t,n){let r=Array.isArray(t.url)?t.url:t.url?[t.url]:[];if(r.length===0)throw new G(`missing_input`,`speech/recognize requires 'url' input`,{step:`speech/recognize`});let i=[];for(let a of r)if(S(a)){let r=await k(e);i.push(await A(a,r.token,t.model||`fun-asr`,{signal:n.signal}))}else i.push(a);let a={model:t.model||`fun-asr`,input:{file_urls:i},parameters:{channel_id:t[`channel-id`]===void 0?void 0:[t[`channel-id`]],language_hints:t.language?[t.language]:void 0,diarization_enabled:t.diarization,speaker_count:t[`speaker-count`],vocabulary_id:t[`vocabulary-id`]}};de(a.parameters);let o=(await O(e,{url:le(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await is(e,o,(t[`poll-interval`]??2)*1e3,(n.timeoutSeconds??300)*1e3,n)}function ns(e){let{output:t,request_id:n,usage:r}=e,i={task_id:t.task_id,task_status:t.task_status,request_id:n};if(t.video_url&&(i.video_url=t.video_url),t.choices){let e=t.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);e.length>0&&(i.urls=e)}if(t.results){let e=t.results.map(e=>e.url).filter(Boolean);e.length>0&&!i.urls&&(i.urls=e)}return t.task_metrics&&(i.task_metrics=t.task_metrics),r&&(i.usage=r),i}async function rs(e,t,n){return await is(e,t,3e3,e.timeout*1e3,n)}async function is(e,t,n,r,i){let a=Date.now(),o=0;for(;;){if(i?.signal?.aborted)throw new G(`aborted`,`Task polling was aborted`,{details:{taskId:t}});await as(n,i?.signal),o++;let s=await O(e,{url:fe(e.baseUrl,t),method:`GET`,signal:i?.signal}),c=s.output.task_status;if(c===`SUCCEEDED`)return ns(s);if(c===`FAILED`)throw new G(`async_task_failed`,s.output.message||s.output.code||`Task failed`,{details:{taskId:t,data:s}});let l=Date.now()-a;if(await i?.emitEvent?.({type:`step.polling`,timestamp:new Date().toISOString(),status:`running`,taskId:t,taskStatus:c,elapsedMs:l,pollAttempt:o}),l>r)throw new G(`async_poll_timeout`,`Task ${t} timed out after ${Math.round(r/1e3)}s`,{details:{taskId:t,timeoutMs:r,pollAttempts:o}})}}function as(e,t){return t?new Promise((n,r)=>{let i=setTimeout(()=>{o(),n()},e),a=()=>{o(),r(new G(`aborted`,`Poll delay was aborted`))},o=()=>{clearTimeout(i),t.removeEventListener(`abort`,a)};t.aborted?a():t.addEventListener(`abort`,a,{once:!0})}):new Promise(t=>setTimeout(t,e))}var os,ss=j((()=>{Ao(),Ri(),Ai(),os=[`qwen-image-2.0`,`qwen-image-max`]}));function cs(e){for(let t of Object.keys(_s))Mo(t,async(e,n)=>await ls(t,e,n),e,ys[t])}async function ls(e,t,n){if(n.dryRun)return{metadata:{dryRun:!0,step:e,plannedInput:t},warnings:[{code:`dry_run_skipped`,message:`Step ${e} was not executed in dry-run mode`}]};let r=_s[e];if(!r)throw Error(`No direct API handler registered for step: ${e}`);let i=await r(n.blConfig??Io(),t,n),a=vs[e];return a?a(i):{data:i,warnings:[],metadata:{}}}function us(e){if(!K(e))return;let t=[],n=q(e.task_id)??q(e.taskId);for(let r of ms(e.urls))t.push({url:r,taskId:n,kind:hs(r)});for(let r of ms(e.saved))t.push({path:r,taskId:n,kind:gs(r)});let r=q(e.video_url)??q(e.videoUrl);r&&t.push({url:r,taskId:n,kind:`video`});let i=q(e.saved);if(i&&t.push({path:i,taskId:n,kind:gs(i)}),Array.isArray(e.videos))for(let n of e.videos){if(!K(n))continue;let e=q(n.task_id)??q(n.taskId),r=q(n.video_url)??q(n.videoUrl),i=q(n.saved);r&&t.push({url:r,taskId:e,kind:`video`}),i&&t.push({path:i,taskId:e,kind:`video`})}let a=Array.isArray(e.task_ids)?e.task_ids.map(q).filter(ps):[];for(let e of a)t.push({taskId:e,kind:`task`});return t.length===0&&n&&t.push({taskId:n,kind:`task`}),t.length>0?t:void 0}function ds(e,t){if(!K(e))return;let n=[],r=q(e.task_id)??q(e.taskId),i=[q(e.url),q(e.audio_url),q(e.audioUrl),q(e.output_url),q(e.outputUrl)].filter(ps);for(let e of i)n.push({url:e,taskId:r,kind:t});let a=[q(e.saved),q(e.path),q(e.output_path),q(e.outputPath)].filter(ps);for(let e of a)n.push({path:e,taskId:r,kind:t});return n.length===0&&r&&n.push({taskId:r,kind:`task`}),n.length>0?fs(n):void 0}function fs(e){let t=new Set,n=[];for(let r of e){let e=`${r.kind??``}:${r.taskId??``}:${r.url??``}:${r.path??``}`;t.has(e)||(t.add(e),n.push(r))}return n}function ps(e){return typeof e==`string`}function q(e){return typeof e==`string`&&e.length>0?e:void 0}function ms(e){return Array.isArray(e)?e.map(q).filter(ps):[]}function hs(e){try{return gs(new URL(e).pathname)}catch{return`artifact`}}function gs(e){let t=e.toLowerCase();return t.endsWith(`.mp4`)||t.endsWith(`.mov`)||t.endsWith(`.webm`)?`video`:t.endsWith(`.png`)||t.endsWith(`.jpg`)||t.endsWith(`.jpeg`)||t.endsWith(`.webp`)?`image`:`artifact`}var _s,vs,ys,bs=j((()=>{Fo(),Ro(),Ko(),ss(),_s={"text/chat":(e,t,n)=>qo(e,t,n),"vision/describe":(e,t,n)=>Jo(e,t,n),"image/generate":(e,t,n)=>Xo(e,t,n),"image/edit":(e,t,n)=>Zo(e,t,n),"video/generate":(e,t,n)=>$o(e,t,n),"speech/synthesize":(e,t,n)=>es(e,t,n),"speech/recognize":(e,t,n)=>ts(e,t,n)},vs={"image/generate":e=>({data:e,artifacts:us(e),warnings:[],metadata:{}}),"image/edit":e=>({data:e,artifacts:us(e),warnings:[],metadata:{}}),"video/generate":e=>({data:e,artifacts:us(e),warnings:[],metadata:{}}),"speech/synthesize":e=>({data:e,artifacts:ds(e,`audio`),warnings:[],metadata:{}}),"speech/recognize":e=>({data:e,artifacts:ds(e,`transcript`),warnings:[],metadata:{}})},ys={"text/chat":{description:`LLM text completion via chat API`,paths:[{path:`/data/choices/0/message/content`,description:`Generated text content`},{path:`/data/choices/0/message/role`,description:`Message role (assistant)`},{path:`/data/usage/total_tokens`,description:`Total token usage`}]},"vision/describe":{description:`Multimodal vision understanding (image/video to text)`,paths:[{path:`/data/choices/0/message/content`,description:`Generated description text`},{path:`/data/choices/0/message/role`,description:`Message role (assistant)`},{path:`/data/usage/total_tokens`,description:`Total token usage`}]},"image/generate":{description:`Text-to-image generation`,paths:[{path:`/data/urls`,description:`Array of generated image URLs`},{path:`/data/urls/0`,description:`First generated image URL`},{path:`/data/task_id`,description:`Async task ID (if applicable)`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"image/edit":{description:`Image editing with reference image(s)`,paths:[{path:`/data/urls`,description:`Array of generated image URLs`},{path:`/data/urls/0`,description:`First generated image URL`},{path:`/data/task_id`,description:`Async task ID (if applicable)`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"video/generate":{description:`Video generation (text-to-video or image-to-video)`,paths:[{path:`/data/video_url`,description:`Generated video URL`},{path:`/data/task_id`,description:`Async task ID`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"speech/synthesize":{description:`Text-to-speech synthesis`,paths:[{path:`/data/audio_url`,description:`Generated audio URL`},{path:`/data/url_expires_at`,description:`Audio URL expiration time`},{path:`/artifacts/0/url`,description:`First artifact URL`}]},"speech/recognize":{description:`Speech recognition (ASR)`,paths:[{path:`/data/text`,description:`Full transcribed text`},{path:`/data/task_id`,description:`Async task ID`},{path:`/artifacts/0/taskId`,description:`Task ID from artifact`}]}}})),xs=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;let a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),Ss=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=xs();var n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;let o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),J=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;let t=xs(),n=Ss();var r=xs();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=Ss();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=ne(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=ne(this.rhs,e,n),this}get names(){return te(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=ne(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(re(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>ee(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(ie(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=ne(this.condition,e,t),this}get names(){let e=super.names;return te(e,this.condition),this.else&&ee(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=ne(this.iteration,e,t),this}get names(){return ee(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return te(te(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=ne(this.iterable,e,t),this}get names(){return ee(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&ee(e,this.catch.names),this.finally&&ee(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
164
+ `:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function ee(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function te(e,n){return n instanceof t._CodeOrName?ee(e,n.names):e}function ne(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function re(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function ie(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${A(e)}`}e.not=ie;let D=k(e.operators.AND);function ae(...e){return e.reduce(D)}e.and=ae;let O=k(e.operators.OR);function oe(...e){return e.reduce(O)}e.or=oe;function k(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${A(n)} ${e} ${A(r)}`}function A(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),Y=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;let t=J(),n=xs();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;let _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),Cs=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),ws=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=J(),n=Y(),r=Cs();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}let u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),Ts=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=ws(),n=J(),r=Cs(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),Es=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRules=e.isJSONType=void 0;let t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),Ds=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),Os=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;let t=Es(),n=Ds(),r=ws(),i=J(),a=Y();var o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;let u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
164
165
  || (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
165
166
  || (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
166
- || ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}e.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;s.number&&delete s.integer;for(let e in s)o=(0,i.and)(o,m(e,t,n,r));return o}e.checkDataTypes=h;let g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}e.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),ws=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;let t=q(),n=J();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}e.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),Ts=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;let t=q(),n=J(),r=vs(),i=J();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}e.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}e.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}e.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=m;let h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}e.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=v})),Es=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=q(),n=vs(),r=Ts(),i=ys();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=u(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let d=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},d),e.pass(d,()=>e.error(!0))}e.macroKeywordCode=a;function o(e,i){let{gen:a,keyword:o,schema:d,parentSchema:f,$data:p,it:m}=e;l(m,i);let h=u(a,o,!p&&i.compile?i.compile.call(m.self,d,f,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)b(),i.modifying&&s(e),x(()=>e.error());else{let t=i.async?v():y();i.modifying&&s(e),x(()=>c(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>b((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),b(t.nil),e}function b(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!p||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function x(e){a.if((0,t.not)(i.valid??g),e)}}e.funcKeywordCode=o;function s(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function c(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function l({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function u(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function d(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}e.validSchemaType=d;function f({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}e.validateKeywordUsage=f})),Ds=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=q(),n=J();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=a})),Os=j(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),ks=j(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else (p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),As=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=J(),n=Os(),r=ks(),i=new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function a(e,t=!0){return typeof e==`boolean`?!0:t===!0?!s(e):t?c(e)<=t:!1}e.inlineRef=a;let o=new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function s(e){for(let t in e){if(o.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(s)||typeof n==`object`&&s(n))return!0}return!1}function c(e){let n=0;for(let r in e)if(r===`$ref`||(n++,!i.has(r)&&(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=c(e)),n===1/0)))return 1/0;return n}function l(e,t=``,n){return n!==!1&&(t=f(t)),u(e,e.parse(t))}e.getFullPath=l;function u(e,t){return e.serialize(t).split(`#`)[0]+`#`}e._getFullPath=u;let d=/#\/?$/;function f(e){return e?e.replace(d,``):``}e.normalizeId=f;function p(e,t,n){return n=f(n),e.resolve(t,n)}e.resolveUrl=p;let m=/^[a-z_][-a-z0-9._]*$/i;function h(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=f(e[i]||t),s={"":o},c=l(a,o,!1),u={},d=new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=l.call(this,e[i])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),s[t]=o;function l(t){let n=this.opts.uriResolver.resolve;if(t=f(o?n(o,t):t),d.has(t))throw h(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?p(e,r.schema,t):t!==f(a)&&(t[0]===`#`?(p(e,u[t],t),u[t]=e):this.refs[t]=a),t}function g(e){if(typeof e==`string`){if(!m.test(e))throw Error(`invalid anchor "${e}"`);l.call(this,`#${e}`)}}}),u;function p(e,t,r){if(t!==void 0&&!n(e,t))throw h(r)}function h(e){return Error(`reference "${e}" resolves to more than one schema`)}}e.getSchemaRefs=h})),js=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=bs(),n=Cs(),r=Ss(),i=Cs(),a=ws(),o=Es(),s=Ds(),c=q(),l=vs(),u=As(),d=J(),f=ys();function p(e){if(S(e)&&(w(e),x(e))){_(e);return}m(e,()=>(0,t.topBoolOrEmptySchema)(e))}e.validateFunctionCode=p;function m({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,c._)`${l.default.data}, ${l.default.valCxt}`,r.$async,()=>{e.code((0,c._)`"use strict"; ${y(n,i)}`),g(e,i),e.code(a)}):e.func(t,(0,c._)`${l.default.data}, ${h(i)}`,r.$async,()=>e.code(y(n,i)).code(a))}function h(e){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${e.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(e,t){e.if(l.default.valCxt,()=>{e.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),e.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),e.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),e.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{e.var(l.default.instancePath,(0,c._)`""`),e.var(l.default.parentData,(0,c._)`undefined`),e.var(l.default.parentDataProperty,(0,c._)`undefined`),e.var(l.default.rootData,l.default.data),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function _(e){let{schema:t,opts:n,gen:r}=e;m(e,()=>{n.$comment&&t.$comment&&re(e),ee(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),ie(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function b(e,n){if(S(e)&&(w(e),x(e))){C(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function x({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function S(e){return typeof e.schema!=`boolean`}function C(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&re(e),te(e),ne(e);let a=r.const(`_errs`,l.default.errors);T(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function w(e){(0,d.checkUnknownRules)(e),E(e)}function T(e,t){if(e.opts.jtd)return oe(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);oe(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function E(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function ee(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function te(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function ne(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function re({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function ie(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&ae(e),t.return((0,c._)`${l.default.errors} === 0`))}function ae({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function oe(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>me(e,`$ref`,h.all.$ref.definition));return}p.jtd||se(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),D(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):D(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function D(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&me(e,n.keyword,n.definition,t.type)})}function se(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(O(e,t),e.opts.allowUnionTypes||k(e,t),ce(e,e.dataTypes))}function O(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{ue(e.dataTypes,t)||fe(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),de(e,t)}}function k(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&fe(e,`use allowUnionTypes to allow union type keyword`)}function ce(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>le(t,e))&&fe(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function le(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function ue(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function de(e,t){let n=[];for(let r of e.dataTypes)ue(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function fe(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var pe=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,_e(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,l.default.errors))}result(e,t,n){this.failResult((0,c.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,c.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,c._)`${t} !== undefined && (${(0,c.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?f.reportExtraError:f.reportError)(this,this.def.error,t)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=c.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=c.nil,t=c.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,c.or)((0,c._)`${r} === undefined`,t)),e!==c.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==c.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,c.or)(o(),s());function o(){if(n.length){if(!(t instanceof c.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,c._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,c._)`!${n}(${t})`}return c.nil}}subschema(e,t){let n=(0,s.getSubschema)(this.it,e);(0,s.extendSubschemaData)(n,this.it,e),(0,s.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return b(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=d.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=d.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,c.Name)),!0}};e.KeywordCxt=pe;function me(e,t,n,r){let i=new pe(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}let he=/^\/(?:[^~]|~0|~1)*$/,ge=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function _e(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!he.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=ge.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(u(`property/index`,s));return r[t-s]}if(s>t)throw Error(u(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,c._)`${a}${(0,c.getProperty)((0,d.unescapeJsonPointer)(e))}`,o=(0,c._)`${o} && ${a}`);return o;function u(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}e.getData=_e})),Ms=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),Ns=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=As();e.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),Ps=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=q(),n=Ms(),r=vs(),i=As(),a=J(),o=js();var s=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};e.SchemaEnv=s;function c(e){let a=d.call(this,e);if(a)return a;let s=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:c,lines:l}=this.opts.code,{ownProperties:u}=this.opts,f=new t.CodeGen(this.scope,{es5:c,lines:l,ownProperties:u}),p;e.$async&&(p=f.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let m=f.scopeName(`validate`);e.validateName=m;let h={gen:f,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:f.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:s,baseId:e.baseId||s,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,o.validateFunctionCode)(h),f.optimize(this.opts.code.optimize);let n=f.toString();g=`${f.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:m,validateCode:n,scopeValues:f._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}e.compileSchema=c;function l(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=p.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new s({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=u.call(this,a)}e.resolveRef=l;function u(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:c.call(this,e)}function d(e){for(let t of this._compilations)if(f(t,e))return t}e.getCompilingSchema=d;function f(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return g.call(this,n,e);let o=(0,i.normalizeId)(r),l=this.refs[o]||this.schemas[o];if(typeof l==`string`){let t=m.call(this,e,l);return typeof t?.schema==`object`?g.call(this,n,t):void 0}if(typeof l?.schema==`object`){if(l.validate||c.call(this,l),o===(0,i.normalizeId)(t)){let{schema:t}=l,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new s({schema:t,schemaId:n,root:e,baseId:a})}return g.call(this,n,l)}}e.resolveSchema=m;let h=new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function g(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!h.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=m.call(this,r,e)}let{schemaId:c}=this.opts;if(o||=new s({schema:n,schemaId:c,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),Fs=j(((e,t)=>{t.exports={$id:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,description:`Meta-schema for $data reference (JSON AnySchema extension proposal)`,type:`object`,required:[`$data`],properties:{$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},additionalProperties:!1}})),Is=j(((e,t)=>{let n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),i=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),a=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),o=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function s(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}let c=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function l(e){return e.length=0,!0}function u(e,t,n){if(e.length){let r=s(e);if(r!==``)t.push(r);else return n.error=!0,!1;e.length=0}return!0}function d(e){let t=0,n={error:!1,address:``,zone:``},r=[],i=[],a=!1,o=!1,c=u;for(let s=0;s<e.length;s++){let u=e[s];if(!(u===`[`||u===`]`))if(u===`:`){if(a===!0&&(o=!0),!c(i,r,n))break;if(++t>7){n.error=!0;break}s>0&&e[s-1]===`:`&&(a=!0),r.push(`:`);continue}else if(u===`%`){if(!c(i,r,n))break;c=l}else{i.push(u);continue}}return i.length&&(c===l?n.zone=i.join(``):o?r.push(i.join(``)):r.push(s(i))),n.address=r.join(``),n}function f(e){if(p(e,`:`)<2)return{host:e,isIPV6:!1};let t=d(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+=`%`+t.zone,n+=`%25`+t.zone),{host:e,isIPV6:!0,escapedHost:n}}}function p(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function m(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}else{n.push(t);break}}else if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}else if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}let h={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},g=/[@/?#:]/g,_=/[@/?#]/g;function v(e,t){let n=t?_:g;return n.lastIndex=0,e.replace(n,e=>h[e])}function y(e,t=!1){if(e.indexOf(`%`)===-1)return e;let n=``;for(let r=0;r<e.length;r++){if(e[r]===`%`&&r+2<e.length){let o=e.slice(r+1,r+3);if(i(o)){let e=o.toUpperCase(),i=String.fromCharCode(parseInt(e,16));t&&a(i)?n+=i:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function b(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&a(i)?t+=i:t+=`%`+e,n+=2;continue}}o(e[n])?t+=e[n]:t+=escape(e[n])}return t}function x(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function S(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push(`@`)),e.host!==void 0){let n=unescape(e.host);if(!r(n)){let e=f(n);n=e.isIPV6===!0?`[${e.escapedHost}]`:v(n,!1)}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:c,recomposeAuthority:S,reescapeHostDelimiters:v,normalizePercentEncoding:y,normalizePathEncoding:b,escapePreservingEscapes:x,removeDotSegments:m,isIPv4:r,isUUID:n,normalizeIPv6:f,stringArrayToHexStripped:s}})),Ls=j(((e,t)=>{let{isUUID:n}=Is(),r=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let[t,n]=e.resourceName.split(`?`);e.path=t&&t!==`/`?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=y(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=y(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}let h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={http:h,https:g,ws:_,wss:{scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},urn:{scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},"urn:uuid":{scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0}};Object.setPrototypeOf(v,null);function y(e){return e&&(v[e]||v[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:v,isValidSchemeName:a,getSchemeHandler:y}})),Rs=j(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=Is(),{SCHEMES:d,getSchemeHandler:f}=Ls();function p(e,t){return typeof e==`string`?e=S(e,t):typeof e==`object`&&(e=x(_(e,t),t)),e}function m(e,t,n){let r=n?Object.assign({scheme:`null`},n):{scheme:`null`},i=h(x(e,r),x(t,r),r,!0);return r.skipEscape=!0,_(i,r)}function h(e,t,n,i){let a={};return i||(e=x(_(e,n),n),t=x(_(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?a.path=`/`+t.path:e.path?a.path=e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:a.path=t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,t.query===void 0?a.query=e.query:a.query=t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function g(e,t,n){let r=w(e,n),i=w(t,n);return r!==void 0&&i!==void 0&&r.toLowerCase()===i.toLowerCase()}function _(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},o=Object.assign({},t),c=[],l=f(o.scheme||n.scheme);l&&l.serialize&&l.serialize(n,o),n.path!==void 0&&(o.skipEscape?n.path=a(n.path):(n.path=s(n.path),n.scheme!==void 0&&(n.path=n.path.split(`%3A`).join(`:`)))),o.reference!==`suffix`&&n.scheme&&c.push(n.scheme,`:`);let u=i(n);if(u!==void 0&&(o.reference!==`suffix`&&c.push(`//`),c.push(u),n.path&&n.path[0]!==`/`&&c.push(`/`)),n.path!==void 0){let e=n.path;!o.absolutePath&&(!l||!l.absolutePath)&&(e=r(e)),u===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),c.push(e)}return n.query!==void 0&&c.push(`?`,n.query),n.fragment!==void 0&&c.push(`#`,n.fragment),c.join(``)}let v=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function y(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==`/`)return`URI path must start with "/" when authority is present.`;if(typeof e.port==`number`&&(e.port<0||e.port>65535))return`URI port is malformed.`}function b(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},a=!1,s=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let d=e.match(v);if(d){i.scheme=d[1],i.userinfo=d[3],i.host=d[4],i.port=parseInt(d[5],10),i.path=d[6]||``,i.query=d[7],i.fragment=d[8],isNaN(i.port)&&(i.port=d[5]);let t=y(i,d);if(t!==void 0&&(i.error=i.error||t,a=!0),i.host)if(l(i.host)===!1){let e=n(i.host);i.host=e.host.toLowerCase(),s=e.isIPV6}else s=!0;i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?i.reference=`same-document`:i.scheme===void 0?i.reference=`relative`:i.fragment===void 0?i.reference=`absolute`:i.reference=`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let p=f(r.scheme||i.scheme);if(!r.unicodeSupport&&(!p||!p.unicodeSupport)&&i.host&&(r.domainHost||p&&p.domainHost)&&s===!1&&u(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(e){i.error=i.error||`Host's domain name can not be converted to ASCII: `+e}if((!p||p&&!p.skipNormalize)&&(e.indexOf(`%`)!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=c(unescape(i.host),s))),i.path&&=o(i.path),i.fragment))try{i.fragment=encodeURI(decodeURIComponent(i.fragment))}catch{i.error=i.error||`URI malformed`}p&&p.parse&&p.parse(i,r)}else i.error=i.error||`URI can not be parsed.`;return{parsed:i,malformedAuthorityOrPort:a}}function x(e,t){return b(e,t).parsed}function S(e,t){return C(e,t).normalized}function C(e,t){let{parsed:n,malformedAuthorityOrPort:r}=b(e,t);return{normalized:r?e:_(n,t),malformedAuthorityOrPort:r}}function w(e,t){if(typeof e==`string`){let{normalized:n,malformedAuthorityOrPort:r}=C(e,t);return r?void 0:n}if(typeof e==`object`)return _(e,t)}let T={SCHEMES:d,normalize:p,resolve:m,resolveComponent:h,equal:g,serialize:_,parse:x};t.exports=T,t.exports.default=T,t.exports.fastUri=T})),zs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Rs();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),Bs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=js();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=q();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return n.CodeGen}});let r=Ms(),i=Ns(),a=xs(),o=Ps(),s=q(),c=As(),l=Cs(),u=J(),d=Fs(),f=zs(),p=(e,t)=>new RegExp(e,t);p.code=`new RegExp`;let m=[`removeAdditional`,`useDefaults`,`coerceTypes`],h=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),g={errorDataPath:``,format:"`validateFormats: false` can be used instead.",nullable:`"nullable" keyword is supported by default.`,jsonPointers:`Deprecated jsPropertySyntax can be used instead.`,extendRefs:`Deprecated ignoreKeywordsWithRef can be used instead.`,missingRefs:`Pass empty schema with $id that should be ignored to ajv.addSchema.`,processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:`"uniqueItems" keyword is always validated.`,unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:`Map is used as cache, schema object as key.`,serialize:`Map is used as cache, schema object as key.`,ajvErrors:`It is default now.`},_={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`};function v(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??p,a=e.uriResolver??f.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??200,loopEnum:e.loopEnum??200,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var y=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...v(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:h,es5:t,lines:n}),this.logger=ee(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),b.call(this,g,e,`NOT SUPPORTED`),b.call(this,_,e,`DEPRECATED`,`warn`),this._metaOpts=T.call(this),e.formats&&C.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&w.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),S.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=d;n===`id`&&(r={...d},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw Error(`$schema must be a string`);if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(`meta-schema not available`),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=x.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new o.SchemaEnv({schema:{},schemaId:n});if(t=o.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case`undefined`:return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case`string`:{let t=x.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,c.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(ne.call(this,n,t),!t)return(0,u.eachItem)(n,e=>re.call(this,e)),this;ae.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>re.call(this,e,r):e=>r.type.forEach(t=>re.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=D(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};y.ValidationError=r.default,y.MissingRefError=i.default,e.default=y;function b(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function x(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function S(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function C(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function w(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function T(){let e={...this.opts};for(let t of m)delete e[t];return e}let E={log(){},warn(){},error(){}};function ee(e){if(e===!1)return E;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}let te=/^[a-z_$][a-z0-9_$:-]*$/i;function ne(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!te.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function re(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?ie.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function ie(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function ae(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=D(t)),e.validateSchema=this.compile(t,!0))}let oe={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function D(e){return{anyOf:[e,oe]}}})),Vs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),Hs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;let t=Ns(),n=Ts(),r=q(),i=vs(),a=Ps(),o=J(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);if(h instanceof a.SchemaEnv)return _(h);return v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0)if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}if(l.items!==!0)if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}e.callRef=l,e.default=s})),Us=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Vs(),n=Hs();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),Ws=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),Gs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),Ks=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),qs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=J(),r=Ks();e.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),Js=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ts(),n=J(),r=q();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),Ys=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),Xs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ts(),n=q(),r=J();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),Zs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),Qs=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Os();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),$s=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Cs(),n=q(),r=J(),i=Qs();e.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),ec=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=J(),r=Qs();e.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),tc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=J(),r=Qs();e.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),nc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ws(),n=Gs(),r=qs(),i=Js(),a=Ys(),o=Xs(),s=Zs(),c=$s(),l=ec(),u=tc();e.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),rc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;let t=q(),n=J(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=i,e.default=r})),ic=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;let t=q(),n=J(),r=Ts(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}e.validateTuple=a,e.default=i})),ac=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ic();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),oc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=J(),r=Ts(),i=rc();e.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),sc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=J();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),cc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=q(),n=J(),r=Ts();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
167
+ || ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}e.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;s.number&&delete s.integer;for(let e in s)o=(0,i.and)(o,m(e,t,n,r));return o}e.checkDataTypes=h;let g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}e.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),ks=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;let t=J(),n=Y();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}e.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),As=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;let t=J(),n=Y(),r=Cs(),i=Y();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}e.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}e.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}e.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=m;let h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}e.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=v})),js=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=J(),n=Cs(),r=As(),i=ws();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=u(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let d=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},d),e.pass(d,()=>e.error(!0))}e.macroKeywordCode=a;function o(e,i){let{gen:a,keyword:o,schema:d,parentSchema:f,$data:p,it:m}=e;l(m,i);let h=u(a,o,!p&&i.compile?i.compile.call(m.self,d,f,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)b(),i.modifying&&s(e),x(()=>e.error());else{let t=i.async?v():y();i.modifying&&s(e),x(()=>c(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>b((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),b(t.nil),e}function b(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!p||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function x(e){a.if((0,t.not)(i.valid??g),e)}}e.funcKeywordCode=o;function s(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function c(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function l({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function u(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function d(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}e.validSchemaType=d;function f({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}e.validateKeywordUsage=f})),Ms=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=J(),n=Y();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=a})),Ns=M(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),Ps=M(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else (p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),Fs=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=Y(),n=Ns(),r=Ps(),i=new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function a(e,t=!0){return typeof e==`boolean`?!0:t===!0?!s(e):t?c(e)<=t:!1}e.inlineRef=a;let o=new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function s(e){for(let t in e){if(o.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(s)||typeof n==`object`&&s(n))return!0}return!1}function c(e){let n=0;for(let r in e)if(r===`$ref`||(n++,!i.has(r)&&(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=c(e)),n===1/0)))return 1/0;return n}function l(e,t=``,n){return n!==!1&&(t=f(t)),u(e,e.parse(t))}e.getFullPath=l;function u(e,t){return e.serialize(t).split(`#`)[0]+`#`}e._getFullPath=u;let d=/#\/?$/;function f(e){return e?e.replace(d,``):``}e.normalizeId=f;function p(e,t,n){return n=f(n),e.resolve(t,n)}e.resolveUrl=p;let m=/^[a-z_][-a-z0-9._]*$/i;function h(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=f(e[i]||t),s={"":o},c=l(a,o,!1),u={},d=new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=l.call(this,e[i])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),s[t]=o;function l(t){let n=this.opts.uriResolver.resolve;if(t=f(o?n(o,t):t),d.has(t))throw h(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?p(e,r.schema,t):t!==f(a)&&(t[0]===`#`?(p(e,u[t],t),u[t]=e):this.refs[t]=a),t}function g(e){if(typeof e==`string`){if(!m.test(e))throw Error(`invalid anchor "${e}"`);l.call(this,`#${e}`)}}}),u;function p(e,t,r){if(t!==void 0&&!n(e,t))throw h(r)}function h(e){return Error(`reference "${e}" resolves to more than one schema`)}}e.getSchemaRefs=h})),Is=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=Ts(),n=Os(),r=Ds(),i=Os(),a=ks(),o=js(),s=Ms(),c=J(),l=Cs(),u=Fs(),d=Y(),f=ws();function p(e){if(S(e)&&(w(e),x(e))){_(e);return}m(e,()=>(0,t.topBoolOrEmptySchema)(e))}e.validateFunctionCode=p;function m({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,c._)`${l.default.data}, ${l.default.valCxt}`,r.$async,()=>{e.code((0,c._)`"use strict"; ${y(n,i)}`),g(e,i),e.code(a)}):e.func(t,(0,c._)`${l.default.data}, ${h(i)}`,r.$async,()=>e.code(y(n,i)).code(a))}function h(e){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${e.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(e,t){e.if(l.default.valCxt,()=>{e.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),e.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),e.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),e.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{e.var(l.default.instancePath,(0,c._)`""`),e.var(l.default.parentData,(0,c._)`undefined`),e.var(l.default.parentDataProperty,(0,c._)`undefined`),e.var(l.default.rootData,l.default.data),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function _(e){let{schema:t,opts:n,gen:r}=e;m(e,()=>{n.$comment&&t.$comment&&re(e),ee(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),ie(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function b(e,n){if(S(e)&&(w(e),x(e))){C(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function x({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function S(e){return typeof e.schema!=`boolean`}function C(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&re(e),te(e),ne(e);let a=r.const(`_errs`,l.default.errors);T(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function w(e){(0,d.checkUnknownRules)(e),E(e)}function T(e,t){if(e.opts.jtd)return ae(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);ae(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function E(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function ee(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function te(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function ne(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function re({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function ie(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&D(e),t.return((0,c._)`${l.default.errors} === 0`))}function D({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function ae(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>pe(e,`$ref`,h.all.$ref.definition));return}p.jtd||oe(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),O(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):O(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function O(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&pe(e,n.keyword,n.definition,t.type)})}function oe(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(k(e,t),e.opts.allowUnionTypes||A(e,t),se(e,e.dataTypes))}function k(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{le(e.dataTypes,t)||de(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),ue(e,t)}}function A(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&de(e,`use allowUnionTypes to allow union type keyword`)}function se(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>ce(t,e))&&de(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function ce(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function le(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function ue(e,t){let n=[];for(let r of e.dataTypes)le(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function de(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var fe=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,ge(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,l.default.errors))}result(e,t,n){this.failResult((0,c.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,c.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,c._)`${t} !== undefined && (${(0,c.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?f.reportExtraError:f.reportError)(this,this.def.error,t)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=c.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=c.nil,t=c.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,c.or)((0,c._)`${r} === undefined`,t)),e!==c.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==c.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,c.or)(o(),s());function o(){if(n.length){if(!(t instanceof c.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,c._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,c._)`!${n}(${t})`}return c.nil}}subschema(e,t){let n=(0,s.getSubschema)(this.it,e);(0,s.extendSubschemaData)(n,this.it,e),(0,s.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return b(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=d.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=d.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,c.Name)),!0}};e.KeywordCxt=fe;function pe(e,t,n,r){let i=new fe(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}let me=/^\/(?:[^~]|~0|~1)*$/,he=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ge(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!me.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=he.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(u(`property/index`,s));return r[t-s]}if(s>t)throw Error(u(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,c._)`${a}${(0,c.getProperty)((0,d.unescapeJsonPointer)(e))}`,o=(0,c._)`${o} && ${a}`);return o;function u(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}e.getData=ge})),Ls=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),Rs=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Fs();e.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),zs=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=J(),n=Ls(),r=Cs(),i=Fs(),a=Y(),o=Is();var s=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};e.SchemaEnv=s;function c(e){let a=d.call(this,e);if(a)return a;let s=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:c,lines:l}=this.opts.code,{ownProperties:u}=this.opts,f=new t.CodeGen(this.scope,{es5:c,lines:l,ownProperties:u}),p;e.$async&&(p=f.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let m=f.scopeName(`validate`);e.validateName=m;let h={gen:f,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:f.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:s,baseId:e.baseId||s,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,o.validateFunctionCode)(h),f.optimize(this.opts.code.optimize);let n=f.toString();g=`${f.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:m,validateCode:n,scopeValues:f._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}e.compileSchema=c;function l(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=p.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new s({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=u.call(this,a)}e.resolveRef=l;function u(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:c.call(this,e)}function d(e){for(let t of this._compilations)if(f(t,e))return t}e.getCompilingSchema=d;function f(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return g.call(this,n,e);let o=(0,i.normalizeId)(r),l=this.refs[o]||this.schemas[o];if(typeof l==`string`){let t=m.call(this,e,l);return typeof t?.schema==`object`?g.call(this,n,t):void 0}if(typeof l?.schema==`object`){if(l.validate||c.call(this,l),o===(0,i.normalizeId)(t)){let{schema:t}=l,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new s({schema:t,schemaId:n,root:e,baseId:a})}return g.call(this,n,l)}}e.resolveSchema=m;let h=new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function g(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!h.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=m.call(this,r,e)}let{schemaId:c}=this.opts;if(o||=new s({schema:n,schemaId:c,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),Bs=M(((e,t)=>{t.exports={$id:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,description:`Meta-schema for $data reference (JSON AnySchema extension proposal)`,type:`object`,required:[`$data`],properties:{$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},additionalProperties:!1}})),Vs=M(((e,t)=>{let n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),i=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),a=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),o=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function s(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}let c=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function l(e){return e.length=0,!0}function u(e,t,n){if(e.length){let r=s(e);if(r!==``)t.push(r);else return n.error=!0,!1;e.length=0}return!0}function d(e){let t=0,n={error:!1,address:``,zone:``},r=[],i=[],a=!1,o=!1,c=u;for(let s=0;s<e.length;s++){let u=e[s];if(!(u===`[`||u===`]`))if(u===`:`){if(a===!0&&(o=!0),!c(i,r,n))break;if(++t>7){n.error=!0;break}s>0&&e[s-1]===`:`&&(a=!0),r.push(`:`);continue}else if(u===`%`){if(!c(i,r,n))break;c=l}else{i.push(u);continue}}return i.length&&(c===l?n.zone=i.join(``):o?r.push(i.join(``)):r.push(s(i))),n.address=r.join(``),n}function f(e){if(p(e,`:`)<2)return{host:e,isIPV6:!1};let t=d(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+=`%`+t.zone,n+=`%25`+t.zone),{host:e,isIPV6:!0,escapedHost:n}}}function p(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function m(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}else{n.push(t);break}}else if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}else if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}let h={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},g=/[@/?#:]/g,_=/[@/?#]/g;function v(e,t){let n=t?_:g;return n.lastIndex=0,e.replace(n,e=>h[e])}function y(e,t=!1){if(e.indexOf(`%`)===-1)return e;let n=``;for(let r=0;r<e.length;r++){if(e[r]===`%`&&r+2<e.length){let o=e.slice(r+1,r+3);if(i(o)){let e=o.toUpperCase(),i=String.fromCharCode(parseInt(e,16));t&&a(i)?n+=i:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function b(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&a(i)?t+=i:t+=`%`+e,n+=2;continue}}o(e[n])?t+=e[n]:t+=escape(e[n])}return t}function x(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function S(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push(`@`)),e.host!==void 0){let n=unescape(e.host);if(!r(n)){let e=f(n);n=e.isIPV6===!0?`[${e.escapedHost}]`:v(n,!1)}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:c,recomposeAuthority:S,reescapeHostDelimiters:v,normalizePercentEncoding:y,normalizePathEncoding:b,escapePreservingEscapes:x,removeDotSegments:m,isIPv4:r,isUUID:n,normalizeIPv6:f,stringArrayToHexStripped:s}})),Hs=M(((e,t)=>{let{isUUID:n}=Vs(),r=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let[t,n]=e.resourceName.split(`?`);e.path=t&&t!==`/`?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=y(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=y(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}let h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={http:h,https:g,ws:_,wss:{scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},urn:{scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},"urn:uuid":{scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0}};Object.setPrototypeOf(v,null);function y(e){return e&&(v[e]||v[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:v,isValidSchemeName:a,getSchemeHandler:y}})),Us=M(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=Vs(),{SCHEMES:d,getSchemeHandler:f}=Hs();function p(e,t){return typeof e==`string`?e=S(e,t):typeof e==`object`&&(e=x(_(e,t),t)),e}function m(e,t,n){let r=n?Object.assign({scheme:`null`},n):{scheme:`null`},i=h(x(e,r),x(t,r),r,!0);return r.skipEscape=!0,_(i,r)}function h(e,t,n,i){let a={};return i||(e=x(_(e,n),n),t=x(_(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?a.path=`/`+t.path:e.path?a.path=e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:a.path=t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,t.query===void 0?a.query=e.query:a.query=t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function g(e,t,n){let r=w(e,n),i=w(t,n);return r!==void 0&&i!==void 0&&r.toLowerCase()===i.toLowerCase()}function _(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},o=Object.assign({},t),c=[],l=f(o.scheme||n.scheme);l&&l.serialize&&l.serialize(n,o),n.path!==void 0&&(o.skipEscape?n.path=a(n.path):(n.path=s(n.path),n.scheme!==void 0&&(n.path=n.path.split(`%3A`).join(`:`)))),o.reference!==`suffix`&&n.scheme&&c.push(n.scheme,`:`);let u=i(n);if(u!==void 0&&(o.reference!==`suffix`&&c.push(`//`),c.push(u),n.path&&n.path[0]!==`/`&&c.push(`/`)),n.path!==void 0){let e=n.path;!o.absolutePath&&(!l||!l.absolutePath)&&(e=r(e)),u===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),c.push(e)}return n.query!==void 0&&c.push(`?`,n.query),n.fragment!==void 0&&c.push(`#`,n.fragment),c.join(``)}let v=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function y(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==`/`)return`URI path must start with "/" when authority is present.`;if(typeof e.port==`number`&&(e.port<0||e.port>65535))return`URI port is malformed.`}function b(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},a=!1,s=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let d=e.match(v);if(d){i.scheme=d[1],i.userinfo=d[3],i.host=d[4],i.port=parseInt(d[5],10),i.path=d[6]||``,i.query=d[7],i.fragment=d[8],isNaN(i.port)&&(i.port=d[5]);let t=y(i,d);if(t!==void 0&&(i.error=i.error||t,a=!0),i.host)if(l(i.host)===!1){let e=n(i.host);i.host=e.host.toLowerCase(),s=e.isIPV6}else s=!0;i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?i.reference=`same-document`:i.scheme===void 0?i.reference=`relative`:i.fragment===void 0?i.reference=`absolute`:i.reference=`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let p=f(r.scheme||i.scheme);if(!r.unicodeSupport&&(!p||!p.unicodeSupport)&&i.host&&(r.domainHost||p&&p.domainHost)&&s===!1&&u(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(e){i.error=i.error||`Host's domain name can not be converted to ASCII: `+e}if((!p||p&&!p.skipNormalize)&&(e.indexOf(`%`)!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=c(unescape(i.host),s))),i.path&&=o(i.path),i.fragment))try{i.fragment=encodeURI(decodeURIComponent(i.fragment))}catch{i.error=i.error||`URI malformed`}p&&p.parse&&p.parse(i,r)}else i.error=i.error||`URI can not be parsed.`;return{parsed:i,malformedAuthorityOrPort:a}}function x(e,t){return b(e,t).parsed}function S(e,t){return C(e,t).normalized}function C(e,t){let{parsed:n,malformedAuthorityOrPort:r}=b(e,t);return{normalized:r?e:_(n,t),malformedAuthorityOrPort:r}}function w(e,t){if(typeof e==`string`){let{normalized:n,malformedAuthorityOrPort:r}=C(e,t);return r?void 0:n}if(typeof e==`object`)return _(e,t)}let T={SCHEMES:d,normalize:p,resolve:m,resolveComponent:h,equal:g,serialize:_,parse:x};t.exports=T,t.exports.default=T,t.exports.fastUri=T})),Ws=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Us();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),Gs=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=Is();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=J();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return n.CodeGen}});let r=Ls(),i=Rs(),a=Es(),o=zs(),s=J(),c=Fs(),l=Os(),u=Y(),d=Bs(),f=Ws(),p=(e,t)=>new RegExp(e,t);p.code=`new RegExp`;let m=[`removeAdditional`,`useDefaults`,`coerceTypes`],h=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),g={errorDataPath:``,format:"`validateFormats: false` can be used instead.",nullable:`"nullable" keyword is supported by default.`,jsonPointers:`Deprecated jsPropertySyntax can be used instead.`,extendRefs:`Deprecated ignoreKeywordsWithRef can be used instead.`,missingRefs:`Pass empty schema with $id that should be ignored to ajv.addSchema.`,processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:`"uniqueItems" keyword is always validated.`,unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:`Map is used as cache, schema object as key.`,serialize:`Map is used as cache, schema object as key.`,ajvErrors:`It is default now.`},_={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`};function v(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??p,a=e.uriResolver??f.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??200,loopEnum:e.loopEnum??200,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var y=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...v(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:h,es5:t,lines:n}),this.logger=ee(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),b.call(this,g,e,`NOT SUPPORTED`),b.call(this,_,e,`DEPRECATED`,`warn`),this._metaOpts=T.call(this),e.formats&&C.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&w.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),S.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=d;n===`id`&&(r={...d},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw Error(`$schema must be a string`);if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(`meta-schema not available`),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=x.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new o.SchemaEnv({schema:{},schemaId:n});if(t=o.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case`undefined`:return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case`string`:{let t=x.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,c.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(ne.call(this,n,t),!t)return(0,u.eachItem)(n,e=>re.call(this,e)),this;D.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>re.call(this,e,r):e=>r.type.forEach(t=>re.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=O(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};y.ValidationError=r.default,y.MissingRefError=i.default,e.default=y;function b(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function x(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function S(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function C(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function w(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function T(){let e={...this.opts};for(let t of m)delete e[t];return e}let E={log(){},warn(){},error(){}};function ee(e){if(e===!1)return E;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}let te=/^[a-z_$][a-z0-9_$:-]*$/i;function ne(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!te.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function re(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?ie.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function ie(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function D(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=O(t)),e.validateSchema=this.compile(t,!0))}let ae={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function O(e){return{anyOf:[e,ae]}}})),Ks=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),qs=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;let t=Rs(),n=As(),r=J(),i=Cs(),a=zs(),o=Y(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);if(h instanceof a.SchemaEnv)return _(h);return v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0)if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}if(l.items!==!0)if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}e.callRef=l,e.default=s})),Js=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ks(),n=qs();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),Ys=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),Xs=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),Zs=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),Qs=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=Zs();e.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),$s=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=As(),n=Y(),r=J();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),ec=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),tc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=As(),n=J(),r=Y();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),nc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),rc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ns();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),ic=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Os(),n=J(),r=Y(),i=rc();e.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),ac=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=rc();e.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),oc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=rc();e.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),sc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ys(),n=Xs(),r=Qs(),i=$s(),a=ec(),o=tc(),s=nc(),c=ic(),l=ac(),u=oc();e.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),cc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;let t=J(),n=Y(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=i,e.default=r})),lc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;let t=J(),n=Y(),r=As(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}e.validateTuple=a,e.default=i})),uc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=lc();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),dc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=As(),i=cc();e.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),fc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),pc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=J(),n=Y(),r=As();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
167
168
  missingProperty: ${i},
168
169
  depsCount: ${n},
169
- deps: ${r}}`};let i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=s,e.default=i})),lc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=J();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),uc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ts(),n=q(),r=vs(),i=J();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),dc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=js(),n=Ts(),r=J(),i=uc();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),fc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ts(),n=q(),r=J(),i=J();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),pc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),mc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:Ts().validateUnion,error:{message:`must match a schema in anyOf`}}})),hc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=J();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),gc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),_c=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=J(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),vc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),yc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=rc(),n=ac(),r=ic(),i=oc(),a=sc(),o=cc(),s=lc(),c=uc(),l=dc(),u=fc(),d=pc(),f=mc(),p=hc(),m=gc(),h=_c(),g=vc();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),bc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),xc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[bc().default]})),Sc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),Cc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Us(),n=nc(),r=yc(),i=xc(),a=Sc();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),wc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),Tc=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=q(),n=wc(),r=Ps(),i=Ns(),a=J();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();o.if(!1);for(let e in r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),Ec=j(((e,t)=>{t.exports={$schema:`http://json-schema.org/draft-07/schema#`,$id:`http://json-schema.org/draft-07/schema#`,title:`Core schema meta-schema`,definitions:{schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},type:[`object`,`boolean`],properties:{$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},default:!0}})),Dc=j(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;let n=Bs(),r=Cc(),i=Tc(),a=Ec(),o=[`/properties`],s=`http://json-schema.org/draft-07/schema`;var c=class extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(e,s,!1),this.refs[`http://json-schema.org/schema`]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,`__esModule`,{value:!0}),e.default=c;var l=js();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=q();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return u.CodeGen}});var d=Ms();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return d.default}});var f=Ns();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return f.default}})}));function Oc(e,t=`schema`){let n=[];return Mc(e,t,n),n.length===0&&!Hc.validateSchema(e)&&n.push(...Nc(Hc.errors,t)),n}function kc(e,t){let n=Fc(t,e,`input`);return n.ok?G(n.value)?{ok:!0,value:n.value}:{ok:!1,issues:[`input must be an object`]}:{ok:!1,issues:n.issues}}function Ac(e){if(e===``)return{ok:!0,segments:[]};if(!e.startsWith(`/`))return{ok:!1,segments:[],issue:`must start with /`};let t=e.slice(1).split(`/`),n=[];for(let e of t){if(e.match(/~(?![01])/))return{ok:!1,segments:[],issue:`contains invalid escape sequence`};n.push(e.replace(/~1/g,`/`).replace(/~0/g,`~`))}return{ok:!0,segments:n}}function jc(e,t){let n=Ac(t);if(!n.ok)return;let r=e;for(let e of n.segments){if(Array.isArray(r)){if(!/^(0|[1-9]\d*)$/.test(e))return;r=r[Number(e)];continue}if(G(r)){r=r[e];continue}return}return r}function Mc(e,t,n){if(!G(e)){n.push(`${t} must be an object`);return}for(let r of Object.keys(e))Bc.has(r)||n.push(`${t} has unsupported keyword "${r}"`);if(`type`in e&&Pc(e.type,`${t}.type`,n),`properties`in e)if(!G(e.properties))n.push(`${t}.properties must be an object`);else for(let[r,i]of Object.entries(e.properties))Mc(i,`${t}.properties.${r}`,n);if(`items`in e&&Mc(e.items,`${t}.items`,n),`required`in e&&(!Array.isArray(e.required)||!e.required.every(e=>typeof e==`string`))&&n.push(`${t}.required must be an array of strings`),`enum`in e&&!Array.isArray(e.enum)&&n.push(`${t}.enum must be an array`),`description`in e&&typeof e.description!=`string`&&n.push(`${t}.description must be a string`),`format`in e&&typeof e.format!=`string`&&n.push(`${t}.format must be a string`),`additionalProperties`in e){let r=e.additionalProperties;r!==!0&&r!==!1&&!G(r)?n.push(`${t}.additionalProperties must be a boolean or schema object`):G(r)&&Mc(r,`${t}.additionalProperties`,n)}}function Nc(e,t){return!e||e.length===0?[`${t} is invalid`]:e.map(e=>`${e.instancePath?`${t}${e.instancePath.replace(/\//g,`.`)}`:t} ${e.message??`is invalid`}${e.keyword?` (${e.keyword})`:``}`)}function Pc(e,t,n){let r=Array.isArray(e)?e:[e];if(r.length===0){n.push(`${t} must not be empty`);return}for(let e of r)Vc.has(e)||n.push(`${t} has unsupported type "${String(e)}"`)}function Fc(e,t,n){if((e==null||e===``)&&t.default!==void 0&&(e=t.default),t.enum&&e!==void 0){let r=t.enum.map(Lc);if(!r.includes(Lc(e)))return{ok:!1,issues:[`${n} must be one of: ${r.join(`, `)}`]}}let r=Ic(t);if(r.size===0)return{ok:!0,value:e};if(r.size>1){if(Array.isArray(e)&&r.has(`array`)){if(!t.items)return{ok:!0,value:e};let r=[],i=[];return e.forEach((e,a)=>{let o=Fc(e,t.items,`${n}.${a}`);o.ok?r[a]=o.value:i.push(...o.issues)}),i.length>0?{ok:!1,issues:i}:{ok:!0,value:r}}if(!(G(e)&&r.has(`object`))&&r.has(`string`)&&!Array.isArray(e)&&!G(e))return{ok:!0,value:String(e)}}if(r.has(`object`)){if(!G(e))return{ok:!1,issues:[`${n} must be an object`]};let r={...e},i=[];for(let e of t.required??[]){let t=r[e];(t==null||t===``)&&i.push(`Missing required input "${e}"`)}for(let[e,a]of Object.entries(t.properties??{})){let t=r[e];if((t==null||t===``)&&a.default===void 0)continue;let o=Fc(t,a,`${n}.${e}`);o.ok?r[e]=o.value:i.push(...o.issues)}if(t.additionalProperties===!1)for(let e of Object.keys(r))t.properties?.[e]||i.push(`Unknown input "${e}"`);return i.length>0?{ok:!1,issues:i}:{ok:!0,value:r}}if(r.has(`array`)){if(!Array.isArray(e))return{ok:!1,issues:[`${n} must be an array`]};if(!t.items)return{ok:!0,value:e};let r=[],i=[];return e.forEach((e,a)=>{let o=Fc(e,t.items,`${n}.${a}`);o.ok?r[a]=o.value:i.push(...o.issues)}),i.length>0?{ok:!1,issues:i}:{ok:!0,value:r}}if(r.has(`string`))return{ok:!0,value:String(e)};if(r.has(`number`)||r.has(`integer`)){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?r.has(`integer`)&&!Number.isInteger(t)?{ok:!1,issues:[`${n} must be an integer`]}:{ok:!0,value:t}:{ok:!1,issues:[`${n} must be a number`]}}return r.has(`boolean`)?typeof e==`boolean`?{ok:!0,value:e}:e===`true`||e===`1`?{ok:!0,value:!0}:e===`false`||e===`0`?{ok:!0,value:!1}:{ok:!1,issues:[`${n} must be a boolean`]}:r.has(`null`)?e===null?{ok:!0,value:e}:{ok:!1,issues:[`${n} must be null`]}:{ok:!0,value:e}}function Ic(e){let t=e.type===void 0?[]:Array.isArray(e.type)?e.type:[e.type];return new Set(t)}function Lc(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}var Rc,zc,Bc,Vc,Hc,Uc=A((()=>{Rc=tt(Dc(),1),Vo(),zc=Rc.default,Bc=new Set([`type`,`properties`,`items`,`required`,`enum`,`default`,`description`,`format`,`additionalProperties`]),Vc=new Set([`string`,`number`,`integer`,`boolean`,`array`,`object`,`null`]),Hc=new zc({allErrors:!0,coerceTypes:!1,strict:!1,useDefaults:!1})}));function Wc(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}function Gc(e,t,n,r){let i={},a={},o=[],s=!1;for(let[c,l]of Object.entries(e.input)){let e=Zc(l,t,n,r);i[c]=e.value,a[c]=e.redacted,e.sensitive&&(s=!0,o.push(c))}return{value:i,redacted:a,sensitiveKeys:o,sensitive:s}}function Kc(e,t,n){let r={},i=[];for(let[a,o]of Object.entries(e.input)){let e=Qc(o,t,n);r[a]=e.redacted,e.sensitive&&i.push(a)}return{redacted:r,sensitiveKeys:i}}function qc(e,t,n,r){return tl(e,e=>Zc(e,t,n,r))}function Jc(e){return tl(e,e=>Y(e,e,!1,e!==void 0))}function Yc(e){return{...e.data===void 0?{}:{data:cl},...e.artifacts?{artifacts:e.artifacts.map(ol)}:{},...e.warnings?{warnings:e.warnings.map(e=>({code:e.code,message:e.message}))}:{},metadata:{...e.metadata?.step?{step:e.metadata.step}:{},redacted:!0}}}function Xc(e){return{code:e.code,message:cl,...e.step?{step:e.step}:{},details:{redacted:!0}}}function Zc(e,t,n,r){if(Array.isArray(e)){let i=e.map(e=>Zc(e,t,n,r));return Y(i.map(e=>e.value),i.map(e=>e.redacted),i.some(e=>e.sensitive))}if(!sl(e)){if(!G(e))return Y(e,e,!1,e!==void 0);let i={},a={},o=!1;for(let[s,c]of Object.entries(e)){let e=Zc(c,t,n,r);i[s]=e.value,a[s]=e.redacted,o||=e.sensitive}return Y(i,a,o)}if(`$input`in e){let t=jc(n,e.$input);return Y(t,t,!1,t!==void 0)}if(`$from`in e){let t=e.$from,n=r.get(t);if(!n)throw new W(`pipeline_reference_error`,`Step output not found: ${t}`);let i=typeof e.path==`string`?e.path:``,a=jc(n,i);if(a===void 0)throw new W(`pipeline_reference_error`,`Step output path not found: ${t}${i}`);return Y(a,a,!1,!0)}if(`$env`in e){let n=$c(t.env,e.$env,!1);return Y(n,n,!1,n!==void 0)}if(`$secret`in e){let n=$c(t.secrets,e.$secret,!0);return Y(n,cl,!0,n!==void 0)}if(`$concat`in e){let i=e.$concat.map(e=>Zc(e,t,n,r)),a=i.map(e=>Wc(e.value)).join(``),o=i.some(e=>e.sensitive);return Y(a,i.map(e=>e.sensitive?cl:Wc(e.value)).join(``),o)}if(`$coalesce`in e){let i=e.$coalesce,a;for(let e of i)try{let i=Zc(e,t,n,r);if(i.exists&&i.value!==void 0&&i.value!==null)return i}catch(e){a=e;continue}if(a)throw a;return Y(void 0,void 0,!1,!1)}if(`$js`in e){let i=e.$js,a=e.args??{},o={},s={},c=!1;for(let[e,i]of Object.entries(a)){let a=Zc(i,t,n,r);o[e]=a.value,s[e]=a.redacted,c||=a.sensitive}try{let e=Function(`args`,`return (${i})`)(o);return Y(e,c?cl:e,c)}catch(e){throw new W(`pipeline_js_error`,`$js expression failed: ${e instanceof Error?e.message:String(e)}`)}}return Y(e,e,!1)}function Qc(e,t,n){if(Array.isArray(e)){let r=e.map(e=>Qc(e,t,n));return Y(r.map(e=>e.value),r.map(e=>e.redacted),r.some(e=>e.sensitive))}if(!sl(e)){if(!G(e))return Y(e,e,!1,e!==void 0);let r={},i=!1;for(let[a,o]of Object.entries(e)){let e=Qc(o,t,n);r[a]=e.redacted,i||=e.sensitive}return Y(r,r,i)}if(`$input`in e){let t=jc(n,e.$input);return Y(t,t,!1,t!==void 0)}if(`$from`in e)return Y({...e},{...e},!1);if(`$env`in e){let n=$c(t.env,e.$env,!1);return Y(n,n,!1,n!==void 0)}if(`$secret`in e)return $c(t.secrets,e.$secret,!0),Y(cl,cl,!0,!0);if(`$concat`in e){let r=e.$concat.map(e=>Qc(e,t,n));if(r.some((t,n)=>{let r=e.$concat[n];return G(r)&&`$from`in r}))return Y({...e},{...e},r.some(e=>e.sensitive));let i=r.map(e=>Wc(e.value)).join(``),a=r.some(e=>e.sensitive);return Y(i,r.map(e=>e.sensitive?cl:Wc(e.value)).join(``),a)}if(`$coalesce`in e){let r=e.$coalesce;if(r.some(e=>G(e)&&`$from`in e))return Y({...e},{...e},!1);for(let e of r){let r=Qc(e,t,n);if(r.exists&&r.value!==void 0&&r.value!==null)return r}return Y(void 0,void 0,!1,!1)}if(`$js`in e){let r=e.args??{};if(Object.values(r).some(e=>G(e)&&`$from`in e))return Y({...e},{...e},!1);let i=e.$js,a={},o=!1;for(let[e,i]of Object.entries(r)){let r=Qc(i,t,n);a[e]=r.value,o||=r.sensitive}try{let e=Function(`args`,`return (${i})`)(a);return Y(e,o?cl:e,o)}catch{return Y({...e},{...e},!1)}}return Y(e,e,!1)}function $c(e,t,n){if(!el(e,t))throw new W(n?`pipeline_secret_error`:`pipeline_env_error`,`${n?`Secret`:`Environment`} binding is not declared: ${t}`);let r=e[t],i=typeof r==`string`?{from:`env`,name:r,required:!0}:r,a=i.from===`env`||i.from===void 0?process.env[i.name]:void 0;if(a!==void 0&&a!==``)return a;if(i.default!==void 0)return i.default;if(i.required!==!1)throw new W(n?`pipeline_secret_error`:`pipeline_env_error`,`${n?`Secret`:`Environment`} binding not found: ${t}`)}function el(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function Y(e,t,n,r=!0){return{value:e,redacted:t,sensitive:n,exists:r}}function tl(e,t){if(typeof e==`boolean`)return e;if(G(e)&&`$exists`in e)try{return t(e.$exists).exists}catch(e){if(e instanceof W&&e.code===`pipeline_reference_error`)return!1;throw e}if(G(e)&&`$and`in e){if(!Array.isArray(e.$and)||e.$and.length===0)throw al(`$and must be a non-empty array`);return e.$and.every(e=>tl(e,t))}if(G(e)&&`$or`in e){if(!Array.isArray(e.$or)||e.$or.length===0)throw al(`$or must be a non-empty array`);return e.$or.some(e=>tl(e,t))}if(G(e)&&`$not`in e)return!tl(e.$not,t);let n=nl(e);if(n){let[e,r]=n.operands,i=t(e).value,a=t(r).value;switch(n.operator){case`$eq`:return rl(i,a);case`$ne`:return!rl(i,a);case`$gt`:return il(i,a,n.operator)>0;case`$gte`:return il(i,a,n.operator)>=0;case`$lt`:return il(i,a,n.operator)<0;case`$lte`:return il(i,a,n.operator)<=0;case`$in`:if(!Array.isArray(a))throw al(`$in right operand must be an array`);return a.some(e=>rl(e,i));case`$contains`:if(Array.isArray(i))return i.some(e=>rl(e,a));if(typeof i==`string`&&typeof a==`string`)return i.includes(a);throw al(`$contains left operand must be an array or string`)}}return!!t(e).value}function nl(e){if(G(e)){for(let t of[`$eq`,`$ne`,`$gt`,`$gte`,`$lt`,`$lte`,`$in`,`$contains`])if(t in e){if(!Array.isArray(e[t])||e[t].length!==2)throw al(`${t} must be a two-item array`);return{operator:t,operands:e[t]}}}}function rl(e,t){return JSON.stringify(e)===JSON.stringify(t)}function il(e,t,n){if(typeof e==`number`&&Number.isFinite(e)&&typeof t==`number`&&Number.isFinite(t))return e-t;if(typeof e==`string`&&typeof t==`string`)return e.localeCompare(t);throw al(`${n} operands must both be finite numbers or both be strings`)}function al(e){return new W(`pipeline_condition_error`,e)}function ol(e){return{id:e.id,kind:e.kind,mediaType:e.mediaType,metadata:e.metadata?{redacted:!0}:void 0}}function sl(e){return G(e)&&(`$input`in e||`$from`in e||`$env`in e||`$secret`in e||`$concat`in e||`$coalesce`in e||`$js`in e)}var cl,ll=A((()=>{To(),Uc(),Vo(),cl=`[redacted]`}));function ul(e){Do(`logic/switch`,e=>{let t=dl(e.cases);for(let e of t)if(Jc(e.condition))return{data:{selected:e.key,value:e.value,matched:!0}};if(`defaultValue`in e)return{data:{selected:typeof e.defaultKey==`string`?e.defaultKey:`default`,value:e.defaultValue,matched:!1}};throw new W(`logic_no_match`,`logic/switch did not match any case`,{step:`logic/switch`,details:{caseCount:t.length}})},e,ml),Do(`logic/select`,e=>{let t=fl(e.candidates);for(let e of t)if(!(e.available!==void 0&&!Jc(e.available))&&e.value!==void 0&&e.value!==null)return{data:{source:e.source,value:e.value,matched:!0}};if(`defaultValue`in e)return{data:{source:typeof e.defaultSource==`string`?e.defaultSource:`default`,value:e.defaultValue,matched:!1}};throw new W(`logic_no_candidate`,`logic/select did not receive an available candidate`,{step:`logic/select`,details:{candidateCount:t.length}})},e,hl),Do(`logic/assert`,e=>{let t=typeof e.message==`string`?e.message:`Logic assertion failed`,n=G(e.metadata)?e.metadata:void 0;if(!Jc(pl(e.condition))){if(e.soft===!0)return{data:{ok:!1,message:t,...n?{metadata:n}:{}}};throw new W(`logic_assertion_failed`,t,{step:`logic/assert`,details:n??{}})}return{data:{ok:!0,...e.message===void 0?{}:{message:t},...n?{metadata:n}:{}}}},e,gl)}function dl(e){if(!Array.isArray(e))throw new W(`logic_input_error`,`cases must be an array`,{step:`logic/switch`});return e}function fl(e){if(!Array.isArray(e))throw new W(`logic_input_error`,`candidates must be an array`,{step:`logic/select`});return e}function pl(e){if(e===void 0)throw new W(`logic_input_error`,`condition is required`,{step:`logic/assert`});return e}var ml,hl,gl,_l=A((()=>{To(),Ao(),Vo(),ll(),ml={description:`Conditional branch selection from a list of cases`,paths:[{path:`/data/selected`,description:`Key of the matched case`},{path:`/data/value`,description:`Value of the matched case`},{path:`/data/matched`,description:`Whether a case was matched (boolean)`}]},hl={description:`Select first available value from candidates`,paths:[{path:`/data/source`,description:`Source identifier of the selected candidate`},{path:`/data/value`,description:`Value of the selected candidate`},{path:`/data/matched`,description:`Whether a candidate was matched (boolean)`}]},gl={description:`Assert a condition is true`,paths:[{path:`/data/ok`,description:`Whether the assertion passed (boolean)`},{path:`/data/message`,description:`Assertion message`}]}}));function vl(e){Do(`script/js`,e=>{let t=e.code;if(!t||typeof t!=`string`)throw new W(`script_js_error`,`script/js requires a 'code' string input`,{step:`script/js`});let n=e.args??{};try{return{data:Function(`args`,t)(n)??{}}}catch(e){throw new W(`script_js_error`,`script/js execution failed: ${e instanceof Error?e.message:String(e)}`,{step:`script/js`})}},e,yl)}var yl,bl=A((()=>{To(),Ao(),yl={description:`Execute inline JavaScript; output shape is user-defined by the return value`,paths:[{path:`/data`,description:`Return value of the script (user-defined structure)`}]}}));function xl(e=Eo()){return Sl.has(e)?e:(Sl.add(e),rs(e),ul(e),vl(e),e)}var Sl,Cl=A((()=>{Ao(),hs(),_l(),bl(),Sl=new WeakSet}));function wl(e){let t=e.steps.map((t,n)=>({step:t,dependencies:[],dependents:[],index:n+1,total:e.steps.length})),n=new Map(t.map(e=>[e.step.id,e]));for(let r of t){let t=new Set(r.step.dependsOn??[]);Ro(r.step.input,t),r.step.when!==void 0&&Ro(r.step.when,t),r.dependencies=Array.from(t).sort((t,n)=>e.steps.findIndex(e=>e.id===t)-e.steps.findIndex(e=>e.id===n));for(let e of r.dependencies)n.get(e)?.dependents.push(r.step.id)}return t}function Tl(e){let t=new Set(e.map(e=>e.step.id)),n=new Set,r=[];for(;t.size>0;){let i=!1;for(let a of e)t.has(a.step.id)&&a.dependencies.every(e=>n.has(e))&&(r.push(a),n.add(a.step.id),t.delete(a.step.id),i=!0);if(!i)break}return r}function El(e,t,n){return e.filter(e=>t.has(e.step.id)?e.dependencies.every(e=>{let t=n.get(e);return t?.status===`succeeded`||t?.status===`failed`||t?.status===`skipped`}):!1)}function Dl(e,t){let n=new Map(e.map((e,t)=>[e.step.id,t]));return[...t].sort((e,t)=>(n.get(e.id)??0)-(n.get(t.id)??0))}function Ol(e){if(e===void 0)return 1;if(!Number.isInteger(e)||e<1)throw new W(`pipeline_validation_error`,`Invalid pipeline execution options`,{details:{issues:[`concurrency must be a positive integer`]}});return e}var kl=A((()=>{To(),Vo()})),Al,jl=A((()=>{Al=`workflow/v1`}));function Ml(e,t=Eo()){let n=Fl(e);return n.length>0?n:Il(e,t)}function Nl(e,t=Eo()){if(Fl(e).length>0)return[];let n=[],r=new Map(e.steps.map(e=>[e.id,e.type]));for(let i of e.steps)zl(i.input,i.id,r,t,n);return n}function Pl(e,t){if(!e.inputs)return t;let n=kc(e.inputs,t);if(n.ok)return n.value;throw new W(`pipeline_validation_error`,`Invalid pipeline runtime input`,{details:{issues:n.issues}})}function Fl(e){let t=[];if(!G(e))return t.push(`structural: pipeline must be an object`),t;if(e.version!==`workflow/v1`&&t.push(`structural: pipeline.version must be "${Al}"`),!Array.isArray(e.steps))return t.push(`structural: pipeline.steps must be an array`),t;e.steps.length===0&&t.push(`structural: pipeline.steps must contain at least one step`);for(let[n,r]of e.steps.entries()){if(!G(r)){t.push(`structural: step at index ${n} must be an object`);continue}(!r.id||typeof r.id!=`string`)&&t.push(`structural: step at index ${n} must have a string id`),(!r.type||typeof r.type!=`string`)&&t.push(`structural: step at index ${n} must have a string type`),G(r.input)||t.push(`structural: step at index ${n} must have an input object`)}return t}function Il(e,t){let n=[];e.inputs&&n.push(...Oc(e.inputs,`pipeline.inputs`));let r=e.steps,i=new Set;for(let[e,a]of r.entries()){let r=a.id||`#${e}`;i.has(a.id)&&n.push(`duplicate step id "${a.id}"`),i.add(a.id),t.hasStep(a.type)||n.push(`semantic: step "${r}" references unknown type "${a.type}"`),a.dependsOn!==void 0&&(!Array.isArray(a.dependsOn)||!a.dependsOn.every(e=>typeof e==`string`))&&n.push(`semantic: step "${r}" dependsOn must be an array of step id strings`),a.retry!==void 0&&Rl(a.retry,r,n),a.timeout!==void 0&&Lo(a.timeout)===void 0&&n.push(`semantic: step "${r}" timeout must be a positive number of seconds or duration string`)}for(let e of r){for(let t of e.dependsOn??[])i.has(t)||n.push(`semantic: step "${e.id}" references missing step "${t}"`),t===e.id&&n.push(`semantic: step "${e.id}" references itself`);Ll(e.input,e.id,i,n)}let a=new Map;for(let e of r){let t=new Set(e.dependsOn??[]);Ro(e.input,t),e.when!==void 0&&Ro(e.when,t),a.set(e.id,t)}for(let e of Bl(a))n.push(`semantic: pipeline graph contains cycle: ${e.join(` -> `)}`);return n}function Ll(e,t,n,r){if(Array.isArray(e)){e.forEach(e=>Ll(e,t,n,r));return}if(G(e)){`$from`in e&&typeof e.$from==`string`&&(n.has(e.$from)||r.push(`semantic: step "${t}" $from references missing step "${e.$from}"`));for(let i of Object.values(e))Ll(i,t,n,r)}}function Rl(e,t,n){if(!G(e)){n.push(`step "${t}" retry must be an object`);return}let r=e.maxAttempts;r!==void 0&&(typeof r!=`number`||!Number.isInteger(r)||r<1)&&n.push(`step "${t}" retry.maxAttempts must be a positive integer`),e.backoff!==void 0&&e.backoff!==`none`&&e.backoff!==`linear`&&e.backoff!==`exponential`&&n.push(`step "${t}" retry.backoff must be none, linear, or exponential`)}function zl(e,t,n,r,i){if(Array.isArray(e)){e.forEach(e=>zl(e,t,n,r,i));return}if(G(e)){if(`$from`in e&&typeof e.$from==`string`&&typeof e.path==`string`){let a=n.get(e.$from);if(a){let n=r.getOutputSchema(a);if(n){let r=e.path;if(!n.paths.some(e=>r===e.path||r.startsWith(e.path+`/`))){let o=n.paths.map(e=>e.path).join(`, `);i.push(`hint: step "${t}" references path "${r}" from "${e.$from}" (${a}), which is not a known output path. Known paths: ${o}`)}}}return}for(let a of Object.values(e))zl(a,t,n,r,i)}}function Bl(e){let t=[],n=new Set,r=new Set,i=[],a=o=>{if(n.has(o)){let e=i.indexOf(o);t.push([...i.slice(e),o]);return}if(!r.has(o)){n.add(o),i.push(o);for(let t of e.get(o)??[])e.has(t)&&a(t);i.pop(),n.delete(o),r.add(o)}};for(let t of e.keys())a(t);return t}var Vl=A((()=>{To(),Ao(),Uc(),jl(),Vo()}));async function Hl(e,t={},n={}){return await Wl(e,t,n)}async function*Ul(e,t={},n={}){let r=new tu(1024),i=new AbortController,a=()=>i.abort();n.signal?.aborted?a():n.signal?.addEventListener(`abort`,a,{once:!0});let o=!1,s;Wl(e,t,{...n,signal:i.signal,onEvent:async e=>{await r.push(e)}}).then(()=>{o=!0,r.close()},e=>{s=e,o=!0,r.close()});try{for(;!o||r.size>0;){let e=await r.shift();if(e){yield e;continue}if(s)throw s}if(s)throw s}finally{i.abort(),n.signal?.removeEventListener(`abort`,a),r.close()}}async function Wl(e,t,n){let r=n.stepDispatcher??Eo(),i=Ml(e,r);if(i.length>0)throw new W(`pipeline_validation_error`,`Invalid pipeline definition`,{details:{issues:i}});let a=Pl(e,t);if(n.basePath){let t=await zo(e.steps,n.basePath);if(t.length>0)throw new W(`pipeline_file_not_found`,t.join(`; `),{details:{issues:t}})}let o=jo(),s=wl(e),c=Ol(n.concurrency),l=[],u=new Map,d=new Map,f=[],p=async e=>{await n.onEvent?.(e)};if(await p({type:`pipeline.started`,timestamp:X(),status:n.dryRun?`planned`:`running`,stepCount:e.steps.length,dryRun:!!n.dryRun}),n.dryRun){for(let t of Tl(s)){let n=Kc(t.step,e,a),r={id:t.step.id,type:t.step.type,status:`planned`,dependencies:t.dependencies,input:n.redacted,...t.step.when===void 0?{}:{condition:`pending`}};l.push(r),await p({type:`step.input.resolved`,timestamp:X(),status:`planned`,step:Z(t),input:Jl(n.redacted,n.sensitiveKeys)}),await p({type:`step.planned`,timestamp:X(),status:`planned`,step:Z(t),input:Jl(n.redacted,n.sensitiveKeys),...t.step.when===void 0?{}:{condition:`pending`}})}return await p({type:`pipeline.planned`,timestamp:X(),status:`planned`,stepCount:l.length,artifactCount:f.length}),{status:`planned`,version:Al,steps:l,artifacts:f}}let m=new Set(s.map(e=>e.step.id)),h=new Map;for(;m.size>0||h.size>0;){let t=!1;for(let i of El(s,m,u)){if(h.size>=c)break;if(!m.has(i.step.id))continue;let s=i.dependencies.map(e=>u.get(e)),g=s.find(e=>e?.status===`failed`);if(g){let e=`dependency ${g.id} failed`;ql(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:X(),status:`running`,step:Z(i),reason:e}),m.delete(i.step.id),t=!0;continue}if(s.length>0&&s.every(e=>e?.status===`skipped`)){let e=`all dependencies skipped`;ql(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:X(),status:`running`,step:Z(i),reason:e}),m.delete(i.step.id),t=!0;continue}if(!(i.step.when===void 0||qc(i.step.when,e,a,d))){let e=`condition evaluated to false`;ql(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e,condition:`false`}),await p({type:`step.skipped`,timestamp:X(),status:`running`,step:Z(i),reason:e}),m.delete(i.step.id),t=!0;continue}let _=Gl(i,e,a,d,f,p,n,o,r);h.set(i.step.id,_),m.delete(i.step.id),t=!0}if(h.size>0){let e=await Promise.race(h.values());h.delete(e.id),ql(l,u,e),t=!0}if(!t)throw new W(`pipeline_graph_error`,`Workflow graph did not make progress`,{details:{remaining:Array.from(m)}})}let g=Dl(s,l),_=g.find(e=>e.status===`failed`);if(_?.error){let e=s.find(e=>e.step.id===_.id);return await p({type:`pipeline.failed`,timestamp:X(),status:`failed`,stepCount:g.length,artifactCount:f.length,failedStep:e?Z(e):{id:_.id,type:_.type,dependencies:_.dependencies,index:g.findIndex(e=>e.id===_.id)+1,total:g.length},error:_.error}),{status:`failed`,version:Al,steps:g,artifacts:f}}return await p({type:`pipeline.succeeded`,timestamp:X(),status:`succeeded`,stepCount:g.length,artifactCount:f.length}),{status:`succeeded`,version:Al,steps:g,artifacts:f}}async function Gl(e,t,n,r,i,a,o,s,c){let l=Math.max(1,Math.floor(e.step.retry?.maxAttempts??1)),u,d,f=!1,p=new Date().toISOString(),m=p;for(let h=1;h<=l;h++){p=new Date().toISOString(),await a({type:`step.started`,timestamp:X(),status:`running`,step:Z(e),timing:{startedAt:p},attempt:h});try{let l=Gc(e.step,t,n,r),u=l.value,g=l.redacted;if(o.basePath){let t=Fo(u,o.basePath);u=t.input,g=Fo(l.redacted,o.basePath).input;let n=await Io(u,t.resolvedKeys.filter(e=>!Bo.includes(e)),e.step.id);if(n.length>0)throw new W(`pipeline_file_not_found`,n.join(`; `),{step:e.step.type,details:{issues:n}})}d=g,f=l.sensitive,await a({type:`step.input.resolved`,timestamp:X(),status:`running`,step:Z(e),input:Jl(g,l.sensitiveKeys)});let _=await Kl(e.step,u,o,Z(e),a,s,c);r.set(e.step.id,_);let v=l.sensitive?Yc(_):_;v.artifacts&&i.push(...v.artifacts),m=new Date().toISOString();for(let t of v.artifacts??[])await a({type:`artifact.created`,timestamp:X(),status:`running`,step:Z(e),artifact:t});return await a({type:`step.succeeded`,timestamp:X(),status:`running`,step:Z(e),timing:Zl(p,m),output:Yl(v),attempt:h,...v.warnings&&v.warnings.length>0?{warnings:v.warnings}:{}}),{id:e.step.id,type:e.step.type,status:`succeeded`,dependencies:e.dependencies,input:l.redacted,output:v,startedAt:p,finishedAt:m,attempts:h,...e.step.when===void 0?{}:{condition:`true`}}}catch(t){let n=wo(t,e.step.type);if(u=f?Xc(n.toJSON()):n.toJSON(),m=new Date().toISOString(),h<l){await a({type:`step.retrying`,timestamp:X(),status:`running`,step:Z(e),attempt:h,nextAttempt:h+1,error:u});let t=Ql(e.step.retry?.backoff,h,o.retryDelayBaseMs??eu);t>0&&await(o.sleep??$l)(t);continue}}}let h=u??{code:`pipeline_step_failed`,message:`Step ${e.step.id} failed`,step:e.step.type,details:{}};return await a({type:`step.failed`,timestamp:X(),status:`failed`,step:Z(e),timing:Zl(p,m),attempt:l,error:h}),{id:e.step.id,type:e.step.type,status:`failed`,dependencies:e.dependencies,...d?{input:d}:{},error:h,startedAt:p,finishedAt:m,attempts:l}}async function Kl(e,t,n,r,i,a,o){let s=Lo(e.timeout)??n.timeoutSeconds,c={dryRun:!1,signal:n.signal,timeoutSeconds:s,blRequestTimeoutSeconds:n.blRequestTimeoutSeconds,emitEvent:async e=>{e.type===`step.polling`&&await i({...e,type:`step.polling`,timestamp:e.timestamp??X(),status:`running`,step:r,taskId:e.taskId,taskStatus:e.taskStatus,elapsedMs:e.elapsedMs,pollAttempt:e.pollAttempt})},blConfig:a};if(!s)return await o.executeStep(e.type,t,c);let l=new AbortController,u=()=>l.abort();n.signal?.aborted?u():n.signal?.addEventListener(`abort`,u,{once:!0});let d=s*1e3,f=setTimeout(()=>l.abort(),d);c.signal=l.signal;try{return await Promise.race([o.executeStep(e.type,t,c),new Promise((t,n)=>{l.signal.addEventListener(`abort`,()=>{n(new W(`step_timeout`,`Step ${e.id} exceeded timeout ${s}s`,{step:e.type}))},{once:!0})})])}finally{clearTimeout(f),n.signal?.removeEventListener(`abort`,u)}}function ql(e,t,n){e.push(n),t.set(n.id,n)}function X(){return new Date().toISOString()}function Z(e){return{id:e.step.id,type:e.step.type,dependencies:e.dependencies,index:e.index,total:e.total}}function Jl(e,t=[]){return{keys:Object.keys(e).sort(),...t.length>0?{redactedKeys:t.sort()}:{}}}function Yl(e){return{...e.data===void 0?{}:{dataType:Xl(e.data)},artifactCount:e.artifacts?.length??0,warningCount:e.warnings?.length??0,...e.metadata?{metadata:e.metadata}:{}}}function Xl(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e}function Zl(e,t){return{startedAt:e,finishedAt:t,durationMs:Math.max(0,Date.parse(t)-Date.parse(e))}}function Ql(e=`none`,t,n){return e===`none`?0:e===`linear`?n*t:n*2**(t-1)}function $l(e){return new Promise(t=>setTimeout(t,e))}var eu,tu,nu=A((()=>{To(),No(),Ao(),ll(),kl(),Vo(),Vl(),jl(),eu=100,tu=class{items=[];takers=[];pushWaiters=[];closed=!1;maxSize;constructor(e){this.maxSize=e}get size(){return this.items.length}async push(e){for(;!this.closed&&this.items.length>=this.maxSize;)await new Promise(e=>this.pushWaiters.push(e));if(this.closed)return;let t=this.takers.shift();if(t){t(e);return}this.items.push(e)}async shift(){let e=this.items.shift();if(e!==void 0)return this.wakePushWaiter(),e;if(!this.closed)return await new Promise(e=>this.takers.push(e))}close(){if(!this.closed){this.closed=!0;for(let e of this.takers.splice(0))e(void 0);for(let e of this.pushWaiters.splice(0))e()}}wakePushWaiter(){this.pushWaiters.shift()?.()}}})),Q=j((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),c=e=>!!e&&typeof e==`object`&&e[s]===t,l=e=>!!e&&typeof e==`object`&&e[s]===n,u=e=>!!e&&typeof e==`object`&&e[s]===r,d=e=>!!e&&typeof e==`object`&&e[s]===i,f=e=>!!e&&typeof e==`object`&&e[s]===a,p=e=>!!e&&typeof e==`object`&&e[s]===o;function m(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function h(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=e=>(f(e)||m(e))&&!!e.anchor,e.isAlias=c,e.isCollection=m,e.isDocument=l,e.isMap=u,e.isNode=h,e.isPair=d,e.isScalar=f,e.isSeq=p})),ru=j((e=>{var t=Q();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function a(e,n){let r=l(n);t.isDocument(e)?o(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):o(null,e,r,Object.freeze([]))}a.BREAK=n,a.SKIP=r,a.REMOVE=i;function o(e,r,a,s){let c=u(e,r,a,s);if(t.isNode(c)||t.isPair(c))return d(e,s,c),o(e,c,a,s);if(typeof c!=`symbol`){if(t.isCollection(r)){s=Object.freeze(s.concat(r));for(let e=0;e<r.items.length;++e){let t=o(e,r.items[e],a,s);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){s=Object.freeze(s.concat(r));let e=o(`key`,r.key,a,s);if(e===n)return n;e===i&&(r.key=null);let t=o(`value`,r.value,a,s);if(t===n)return n;t===i&&(r.value=null)}}return c}async function s(e,n){let r=l(n);t.isDocument(e)?await c(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await c(null,e,r,Object.freeze([]))}s.BREAK=n,s.SKIP=r,s.REMOVE=i;async function c(e,r,a,o){let s=await u(e,r,a,o);if(t.isNode(s)||t.isPair(s))return d(e,o,s),c(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await c(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await c(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await c(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function l(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function u(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function d(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=a,e.visitAsync=s})),iu=j((e=>{var t=Q(),n=ru();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},i=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var a=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+i(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)t===`!!`&&n===`tag:yaml.org,2002:`||(!e||a.some(e=>e.startsWith(n)))&&r.push(`%TAG ${t} ${n}`);return r.join(`
170
- `)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),au=j((e=>{var t=Q(),n=ru();function r(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function i(e){let t=new Set;return n.visit(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function a(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function o(e,n){let r=[],o=new Map,s=null;return{onAnchor:t=>{r.push(t),s??=i(e);let o=a(n,s);return s.add(o),o},setAnchors:()=>{for(let e of r){let n=o.get(e);if(typeof n==`object`&&n.anchor&&(t.isScalar(n.node)||t.isCollection(n.node)))n.node.anchor=n.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:o}}e.anchorIsValid=r,e.anchorNames=i,e.createNodeAnchors=o,e.findNewAnchor=a})),ou=j((e=>{function t(e,n,r,i){if(i&&typeof i==`object`)if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let r=i[n],a=t(e,i,String(n),r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),a=t(e,i,n,r);a===void 0?i.delete(n):a!==r&&i.set(n,a)}else if(i instanceof Set)for(let n of Array.from(i)){let r=t(e,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let a=t(e,i,n,r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}return e.call(n,r,i)}e.applyReviver=t})),su=j((e=>{var t=Q();function n(e,r,i){if(Array.isArray(e))return e.map((e,t)=>n(e,String(t),i));if(e&&typeof e.toJSON==`function`){if(!i||!t.hasAnchor(e))return e.toJSON(r,i);let n={aliasCount:0,count:1,res:void 0};i.anchors.set(e,n),i.onCreate=e=>{n.res=e,delete i.onCreate};let a=e.toJSON(r,i);return i.onCreate&&i.onCreate(a),a}return typeof e==`bigint`&&!i?.keep?Number(e):e}e.toJS=n})),cu=j((e=>{var t=ou(),n=Q(),r=su();e.NodeBase=class{constructor(e){Object.defineProperty(this,n.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:a,onAnchor:o,reviver:s}={}){if(!n.isDocument(e))throw TypeError(`A document argument is required`);let c={anchors:new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof a==`number`?a:100},l=r.toJS(this,``,c);if(typeof o==`function`)for(let{count:e,res:t}of c.anchors.values())o(t,e);return typeof s==`function`?t.applyReviver(s,{"":l},``,l):l}}})),lu=j((e=>{var t=au(),n=ru(),r=Q(),i=cu(),a=su(),o=class extends i.NodeBase{constructor(e){super(r.ALIAS),this.source=e,Object.defineProperty(this,`tag`,{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){let i;t?.aliasResolveCache?i=t.aliasResolveCache:(i=[],n.visit(e,{Node:(e,t)=>{(r.isAlias(t)||r.hasAnchor(t))&&i.push(t)}}),t&&(t.aliasResolveCache=i));let a;for(let e of i){if(e===this)break;e.anchor===this.source&&(a=e)}return a}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,o=this.resolve(r,t);if(!o){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let c=n.get(o);if(c||=(a.toJS(o,null,t),n.get(o)),c?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(c.count+=1,c.aliasCount===0&&(c.aliasCount=s(r,o,n)),c.count*c.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return c.res}toString(e,n,r){let i=`*${this.source}`;if(e){if(t.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${i} `}return i}};function s(e,t,n){if(r.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(r.isCollection(t)){let r=0;for(let i of t.items){let t=s(e,i,n);t>r&&(r=t)}return r}else if(r.isPair(t)){let r=s(e,t.key,n),i=s(e,t.value,n);return Math.max(r,i)}return 1}e.Alias=o})),$=j((e=>{var t=Q(),n=cu(),r=su();let i=e=>!e||typeof e!=`function`&&typeof e!=`object`;var a=class extends n.NodeBase{constructor(e){super(t.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:r.toJS(this.value,e,t)}toString(){return String(this.value)}};a.BLOCK_FOLDED=`BLOCK_FOLDED`,a.BLOCK_LITERAL=`BLOCK_LITERAL`,a.PLAIN=`PLAIN`,a.QUOTE_DOUBLE=`QUOTE_DOUBLE`,a.QUOTE_SINGLE=`QUOTE_SINGLE`,e.Scalar=a,e.isScalarValue=i})),uu=j((e=>{var t=lu(),n=Q(),r=$();function i(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function a(e,a,o){if(n.isDocument(e)&&(e=e.contents),n.isNode(e))return e;if(n.isPair(e)){let t=o.schema[n.MAP].createNode?.(o.schema,null,o);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:s,onAnchor:c,onTagObj:l,schema:u,sourceObjects:d}=o,f;if(s&&e&&typeof e==`object`){if(f=d.get(e),f)return f.anchor??=c(e),new t.Alias(f.anchor);f={anchor:null,node:null},d.set(e,f)}a?.startsWith(`!!`)&&(a=`tag:yaml.org,2002:`+a.slice(2));let p=i(e,a,u.tags);if(!p){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new r.Scalar(e);return f&&(f.node=t),t}p=e instanceof Map?u[n.MAP]:Symbol.iterator in Object(e)?u[n.SEQ]:u[n.MAP]}l&&(l(p),delete o.onTagObj);let m=p?.createNode?p.createNode(o.schema,e,o):typeof p?.nodeClass?.from==`function`?p.nodeClass.from(o.schema,e,o):new r.Scalar(e);return a?m.tag=a:p.default||(m.tag=p.tag),f&&(f.node=m),m}e.createNode=a})),du=j((e=>{var t=uu(),n=Q(),r=cu();function i(e,n,r){let i=r;for(let e=n.length-1;e>=0;--e){let t=n[e];if(typeof t==`number`&&Number.isInteger(t)&&t>=0){let e=[];e[t]=i,i=e}else i=new Map([[t,i]])}return t.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}let a=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;e.Collection=class extends r.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,`schema`,{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>n.isNode(t)||n.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(a(e))this.add(t);else{let[r,...a]=e,o=this.get(r,!0);if(n.isCollection(o))o.addIn(a,t);else if(o===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(n.isCollection(i))return i.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,a=this.get(r,!0);return i.length===0?!t&&n.isScalar(a)?a.value:a:n.isCollection(a)?a.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!n.isPair(t))return!1;let r=t.value;return r==null||e&&n.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let i=this.get(t,!0);return n.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...a]=e;if(a.length===0)this.set(r,t);else{let e=this.get(r,!0);if(n.isCollection(e))e.setIn(a,t);else if(e===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}},e.collectionFromPath=i,e.isEmptyPath=a})),fu=j((e=>{let t=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function n(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}e.indentComment=n,e.lineComment=(e,t,r)=>e.endsWith(`
170
+ deps: ${r}}`};let i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=s,e.default=i})),mc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),hc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=As(),n=J(),r=Cs(),i=Y();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),gc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Is(),n=As(),r=Y(),i=hc();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),_c=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=As(),n=J(),r=Y(),i=Y();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),vc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Y();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),yc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:As().validateUnion,error:{message:`must match a schema in anyOf`}}})),bc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),xc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Y();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),Sc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),Cc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Y();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),wc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=cc(),n=uc(),r=lc(),i=dc(),a=fc(),o=pc(),s=mc(),c=hc(),l=gc(),u=_c(),d=vc(),f=yc(),p=bc(),m=xc(),h=Sc(),g=Cc();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),Tc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),Ec=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[Tc().default]})),Dc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),Oc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Js(),n=sc(),r=wc(),i=Ec(),a=Dc();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),kc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),Ac=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=kc(),r=zs(),i=Rs(),a=Y();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();o.if(!1);for(let e in r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),jc=M(((e,t)=>{t.exports={$schema:`http://json-schema.org/draft-07/schema#`,$id:`http://json-schema.org/draft-07/schema#`,title:`Core schema meta-schema`,definitions:{schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},type:[`object`,`boolean`],properties:{$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},default:!0}})),Mc=M(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;let n=Gs(),r=Oc(),i=Ac(),a=jc(),o=[`/properties`],s=`http://json-schema.org/draft-07/schema`;var c=class extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(e,s,!1),this.refs[`http://json-schema.org/schema`]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,`__esModule`,{value:!0}),e.default=c;var l=Is();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=J();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return u.CodeGen}});var d=Ls();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return d.default}});var f=Rs();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return f.default}})}));function Nc(e,t=`schema`){let n=[];return Lc(e,t,n),n.length===0&&!qc.validateSchema(e)&&n.push(...Rc(qc.errors,t)),n}function Pc(e,t){let n=Bc(t,e,`input`);return n.ok?K(n.value)?{ok:!0,value:n.value}:{ok:!1,issues:[`input must be an object`]}:{ok:!1,issues:n.issues}}function Fc(e){if(e===``)return{ok:!0,segments:[]};if(!e.startsWith(`/`))return{ok:!1,segments:[],issue:`must start with /`};let t=e.slice(1).split(`/`),n=[];for(let e of t){if(e.match(/~(?![01])/))return{ok:!1,segments:[],issue:`contains invalid escape sequence`};n.push(e.replace(/~1/g,`/`).replace(/~0/g,`~`))}return{ok:!0,segments:n}}function Ic(e,t){let n=Fc(t);if(!n.ok)return;let r=e;for(let e of n.segments){if(Array.isArray(r)){if(!/^(0|[1-9]\d*)$/.test(e))return;r=r[Number(e)];continue}if(K(r)){r=r[e];continue}return}return r}function Lc(e,t,n){if(!K(e)){n.push(`${t} must be an object`);return}for(let r of Object.keys(e))Gc.has(r)||n.push(`${t} has unsupported keyword "${r}"`);if(`type`in e&&zc(e.type,`${t}.type`,n),`properties`in e)if(!K(e.properties))n.push(`${t}.properties must be an object`);else for(let[r,i]of Object.entries(e.properties))Lc(i,`${t}.properties.${r}`,n);if(`items`in e&&Lc(e.items,`${t}.items`,n),`required`in e&&(!Array.isArray(e.required)||!e.required.every(e=>typeof e==`string`))&&n.push(`${t}.required must be an array of strings`),`enum`in e&&!Array.isArray(e.enum)&&n.push(`${t}.enum must be an array`),`description`in e&&typeof e.description!=`string`&&n.push(`${t}.description must be a string`),`format`in e&&typeof e.format!=`string`&&n.push(`${t}.format must be a string`),`additionalProperties`in e){let r=e.additionalProperties;r!==!0&&r!==!1&&!K(r)?n.push(`${t}.additionalProperties must be a boolean or schema object`):K(r)&&Lc(r,`${t}.additionalProperties`,n)}}function Rc(e,t){return!e||e.length===0?[`${t} is invalid`]:e.map(e=>`${e.instancePath?`${t}${e.instancePath.replace(/\//g,`.`)}`:t} ${e.message??`is invalid`}${e.keyword?` (${e.keyword})`:``}`)}function zc(e,t,n){let r=Array.isArray(e)?e:[e];if(r.length===0){n.push(`${t} must not be empty`);return}for(let e of r)Kc.has(e)||n.push(`${t} has unsupported type "${String(e)}"`)}function Bc(e,t,n){if((e==null||e===``)&&t.default!==void 0&&(e=t.default),t.enum&&e!==void 0){let r=t.enum.map(Hc);if(!r.includes(Hc(e)))return{ok:!1,issues:[`${n} must be one of: ${r.join(`, `)}`]}}let r=Vc(t);if(r.size===0)return{ok:!0,value:e};if(r.size>1){if(Array.isArray(e)&&r.has(`array`)){if(!t.items)return{ok:!0,value:e};let r=[],i=[];return e.forEach((e,a)=>{let o=Bc(e,t.items,`${n}.${a}`);o.ok?r[a]=o.value:i.push(...o.issues)}),i.length>0?{ok:!1,issues:i}:{ok:!0,value:r}}if(!(K(e)&&r.has(`object`))&&r.has(`string`)&&!Array.isArray(e)&&!K(e))return{ok:!0,value:String(e)}}if(r.has(`object`)){if(!K(e))return{ok:!1,issues:[`${n} must be an object`]};let r={...e},i=[];for(let e of t.required??[]){let t=r[e];(t==null||t===``)&&i.push(`Missing required input "${e}"`)}for(let[e,a]of Object.entries(t.properties??{})){let t=r[e];if((t==null||t===``)&&a.default===void 0)continue;let o=Bc(t,a,`${n}.${e}`);o.ok?r[e]=o.value:i.push(...o.issues)}if(t.additionalProperties===!1)for(let e of Object.keys(r))t.properties?.[e]||i.push(`Unknown input "${e}"`);return i.length>0?{ok:!1,issues:i}:{ok:!0,value:r}}if(r.has(`array`)){if(!Array.isArray(e))return{ok:!1,issues:[`${n} must be an array`]};if(!t.items)return{ok:!0,value:e};let r=[],i=[];return e.forEach((e,a)=>{let o=Bc(e,t.items,`${n}.${a}`);o.ok?r[a]=o.value:i.push(...o.issues)}),i.length>0?{ok:!1,issues:i}:{ok:!0,value:r}}if(r.has(`string`))return{ok:!0,value:String(e)};if(r.has(`number`)||r.has(`integer`)){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?r.has(`integer`)&&!Number.isInteger(t)?{ok:!1,issues:[`${n} must be an integer`]}:{ok:!0,value:t}:{ok:!1,issues:[`${n} must be a number`]}}return r.has(`boolean`)?typeof e==`boolean`?{ok:!0,value:e}:e===`true`||e===`1`?{ok:!0,value:!0}:e===`false`||e===`0`?{ok:!0,value:!1}:{ok:!1,issues:[`${n} must be a boolean`]}:r.has(`null`)?e===null?{ok:!0,value:e}:{ok:!1,issues:[`${n} must be null`]}:{ok:!0,value:e}}function Vc(e){let t=e.type===void 0?[]:Array.isArray(e.type)?e.type:[e.type];return new Set(t)}function Hc(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}var Uc,Wc,Gc,Kc,qc,Jc=j((()=>{Uc=et(Mc(),1),Ko(),Wc=Uc.default,Gc=new Set([`type`,`properties`,`items`,`required`,`enum`,`default`,`description`,`format`,`additionalProperties`]),Kc=new Set([`string`,`number`,`integer`,`boolean`,`array`,`object`,`null`]),qc=new Wc({allErrors:!0,coerceTypes:!1,strict:!1,useDefaults:!1})}));function Yc(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}function Xc(e,t,n,r){let i={},a={},o=[],s=!1;for(let[c,l]of Object.entries(e.input)){let e=nl(l,t,n,r);i[c]=e.value,a[c]=e.redacted,e.sensitive&&(s=!0,o.push(c))}return{value:i,redacted:a,sensitiveKeys:o,sensitive:s}}function Zc(e,t,n){let r={},i=[];for(let[a,o]of Object.entries(e.input)){let e=rl(o,t,n);r[a]=e.redacted,e.sensitive&&i.push(a)}return{redacted:r,sensitiveKeys:i}}function Qc(e,t,n,r){return ol(e,e=>nl(e,t,n,r))}function $c(e){return ol(e,e=>X(e,e,!1,e!==void 0))}function el(e){return{...e.data===void 0?{}:{data:pl},...e.artifacts?{artifacts:e.artifacts.map(dl)}:{},...e.warnings?{warnings:e.warnings.map(e=>({code:e.code,message:e.message}))}:{},metadata:{...e.metadata?.step?{step:e.metadata.step}:{},redacted:!0}}}function tl(e){return{code:e.code,message:pl,...e.step?{step:e.step}:{},details:{redacted:!0}}}function nl(e,t,n,r){if(Array.isArray(e)){let i=e.map(e=>nl(e,t,n,r));return X(i.map(e=>e.value),i.map(e=>e.redacted),i.some(e=>e.sensitive))}if(!fl(e)){if(!K(e))return X(e,e,!1,e!==void 0);let i={},a={},o=!1;for(let[s,c]of Object.entries(e)){let e=nl(c,t,n,r);i[s]=e.value,a[s]=e.redacted,o||=e.sensitive}return X(i,a,o)}if(`$input`in e){let t=Ic(n,e.$input);return X(t,t,!1,t!==void 0)}if(`$from`in e){let t=e.$from,n=r.get(t);if(!n)throw new G(`pipeline_reference_error`,`Step output not found: ${t}`);let i=typeof e.path==`string`?e.path:``,a=Ic(n,i);if(a===void 0)throw new G(`pipeline_reference_error`,`Step output path not found: ${t}${i}`);return X(a,a,!1,!0)}if(`$env`in e){let n=il(t.env,e.$env,!1);return X(n,n,!1,n!==void 0)}if(`$secret`in e){let n=il(t.secrets,e.$secret,!0);return X(n,pl,!0,n!==void 0)}if(`$concat`in e){let i=e.$concat.map(e=>nl(e,t,n,r)),a=i.map(e=>Yc(e.value)).join(``),o=i.some(e=>e.sensitive);return X(a,i.map(e=>e.sensitive?pl:Yc(e.value)).join(``),o)}if(`$coalesce`in e){let i=e.$coalesce,a;for(let e of i)try{let i=nl(e,t,n,r);if(i.exists&&i.value!==void 0&&i.value!==null)return i}catch(e){a=e;continue}if(a)throw a;return X(void 0,void 0,!1,!1)}if(`$js`in e){let i=e.$js,a=e.args??{},o={},s={},c=!1;for(let[e,i]of Object.entries(a)){let a=nl(i,t,n,r);o[e]=a.value,s[e]=a.redacted,c||=a.sensitive}try{let e=Function(`args`,`return (${i})`)(o);return X(e,c?pl:e,c)}catch(e){throw new G(`pipeline_js_error`,`$js expression failed: ${e instanceof Error?e.message:String(e)}`)}}return X(e,e,!1)}function rl(e,t,n){if(Array.isArray(e)){let r=e.map(e=>rl(e,t,n));return X(r.map(e=>e.value),r.map(e=>e.redacted),r.some(e=>e.sensitive))}if(!fl(e)){if(!K(e))return X(e,e,!1,e!==void 0);let r={},i=!1;for(let[a,o]of Object.entries(e)){let e=rl(o,t,n);r[a]=e.redacted,i||=e.sensitive}return X(r,r,i)}if(`$input`in e){let t=Ic(n,e.$input);return X(t,t,!1,t!==void 0)}if(`$from`in e)return X({...e},{...e},!1);if(`$env`in e){let n=il(t.env,e.$env,!1);return X(n,n,!1,n!==void 0)}if(`$secret`in e)return il(t.secrets,e.$secret,!0),X(pl,pl,!0,!0);if(`$concat`in e){let r=e.$concat.map(e=>rl(e,t,n));if(r.some((t,n)=>{let r=e.$concat[n];return K(r)&&`$from`in r}))return X({...e},{...e},r.some(e=>e.sensitive));let i=r.map(e=>Yc(e.value)).join(``),a=r.some(e=>e.sensitive);return X(i,r.map(e=>e.sensitive?pl:Yc(e.value)).join(``),a)}if(`$coalesce`in e){let r=e.$coalesce;if(r.some(e=>K(e)&&`$from`in e))return X({...e},{...e},!1);for(let e of r){let r=rl(e,t,n);if(r.exists&&r.value!==void 0&&r.value!==null)return r}return X(void 0,void 0,!1,!1)}if(`$js`in e){let r=e.args??{};if(Object.values(r).some(e=>K(e)&&`$from`in e))return X({...e},{...e},!1);let i=e.$js,a={},o=!1;for(let[e,i]of Object.entries(r)){let r=rl(i,t,n);a[e]=r.value,o||=r.sensitive}try{let e=Function(`args`,`return (${i})`)(a);return X(e,o?pl:e,o)}catch{return X({...e},{...e},!1)}}return X(e,e,!1)}function il(e,t,n){if(!al(e,t))throw new G(n?`pipeline_secret_error`:`pipeline_env_error`,`${n?`Secret`:`Environment`} binding is not declared: ${t}`);let r=e[t],i=typeof r==`string`?{from:`env`,name:r,required:!0}:r,a=i.from===`env`||i.from===void 0?process.env[i.name]:void 0;if(a!==void 0&&a!==``)return a;if(i.default!==void 0)return i.default;if(i.required!==!1)throw new G(n?`pipeline_secret_error`:`pipeline_env_error`,`${n?`Secret`:`Environment`} binding not found: ${t}`)}function al(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function X(e,t,n,r=!0){return{value:e,redacted:t,sensitive:n,exists:r}}function ol(e,t){if(typeof e==`boolean`)return e;if(K(e)&&`$exists`in e)try{return t(e.$exists).exists}catch(e){if(e instanceof G&&e.code===`pipeline_reference_error`)return!1;throw e}if(K(e)&&`$and`in e){if(!Array.isArray(e.$and)||e.$and.length===0)throw ul(`$and must be a non-empty array`);return e.$and.every(e=>ol(e,t))}if(K(e)&&`$or`in e){if(!Array.isArray(e.$or)||e.$or.length===0)throw ul(`$or must be a non-empty array`);return e.$or.some(e=>ol(e,t))}if(K(e)&&`$not`in e)return!ol(e.$not,t);let n=sl(e);if(n){let[e,r]=n.operands,i=t(e).value,a=t(r).value;switch(n.operator){case`$eq`:return cl(i,a);case`$ne`:return!cl(i,a);case`$gt`:return ll(i,a,n.operator)>0;case`$gte`:return ll(i,a,n.operator)>=0;case`$lt`:return ll(i,a,n.operator)<0;case`$lte`:return ll(i,a,n.operator)<=0;case`$in`:if(!Array.isArray(a))throw ul(`$in right operand must be an array`);return a.some(e=>cl(e,i));case`$contains`:if(Array.isArray(i))return i.some(e=>cl(e,a));if(typeof i==`string`&&typeof a==`string`)return i.includes(a);throw ul(`$contains left operand must be an array or string`)}}return!!t(e).value}function sl(e){if(K(e)){for(let t of[`$eq`,`$ne`,`$gt`,`$gte`,`$lt`,`$lte`,`$in`,`$contains`])if(t in e){if(!Array.isArray(e[t])||e[t].length!==2)throw ul(`${t} must be a two-item array`);return{operator:t,operands:e[t]}}}}function cl(e,t){return JSON.stringify(e)===JSON.stringify(t)}function ll(e,t,n){if(typeof e==`number`&&Number.isFinite(e)&&typeof t==`number`&&Number.isFinite(t))return e-t;if(typeof e==`string`&&typeof t==`string`)return e.localeCompare(t);throw ul(`${n} operands must both be finite numbers or both be strings`)}function ul(e){return new G(`pipeline_condition_error`,e)}function dl(e){return{id:e.id,kind:e.kind,mediaType:e.mediaType,metadata:e.metadata?{redacted:!0}:void 0}}function fl(e){return K(e)&&(`$input`in e||`$from`in e||`$env`in e||`$secret`in e||`$concat`in e||`$coalesce`in e||`$js`in e)}var pl,ml=j((()=>{Ao(),Jc(),Ko(),pl=`[redacted]`}));function hl(e){Mo(`logic/switch`,e=>{let t=gl(e.cases);for(let e of t)if($c(e.condition))return{data:{selected:e.key,value:e.value,matched:!0}};if(`defaultValue`in e)return{data:{selected:typeof e.defaultKey==`string`?e.defaultKey:`default`,value:e.defaultValue,matched:!1}};throw new G(`logic_no_match`,`logic/switch did not match any case`,{step:`logic/switch`,details:{caseCount:t.length}})},e,yl),Mo(`logic/select`,e=>{let t=_l(e.candidates);for(let e of t)if(!(e.available!==void 0&&!$c(e.available))&&e.value!==void 0&&e.value!==null)return{data:{source:e.source,value:e.value,matched:!0}};if(`defaultValue`in e)return{data:{source:typeof e.defaultSource==`string`?e.defaultSource:`default`,value:e.defaultValue,matched:!1}};throw new G(`logic_no_candidate`,`logic/select did not receive an available candidate`,{step:`logic/select`,details:{candidateCount:t.length}})},e,bl),Mo(`logic/assert`,e=>{let t=typeof e.message==`string`?e.message:`Logic assertion failed`,n=K(e.metadata)?e.metadata:void 0;if(!$c(vl(e.condition))){if(e.soft===!0)return{data:{ok:!1,message:t,...n?{metadata:n}:{}}};throw new G(`logic_assertion_failed`,t,{step:`logic/assert`,details:n??{}})}return{data:{ok:!0,...e.message===void 0?{}:{message:t},...n?{metadata:n}:{}}}},e,xl)}function gl(e){if(!Array.isArray(e))throw new G(`logic_input_error`,`cases must be an array`,{step:`logic/switch`});return e}function _l(e){if(!Array.isArray(e))throw new G(`logic_input_error`,`candidates must be an array`,{step:`logic/select`});return e}function vl(e){if(e===void 0)throw new G(`logic_input_error`,`condition is required`,{step:`logic/assert`});return e}var yl,bl,xl,Sl=j((()=>{Ao(),Fo(),Ko(),ml(),yl={description:`Conditional branch selection from a list of cases`,paths:[{path:`/data/selected`,description:`Key of the matched case`},{path:`/data/value`,description:`Value of the matched case`},{path:`/data/matched`,description:`Whether a case was matched (boolean)`}]},bl={description:`Select first available value from candidates`,paths:[{path:`/data/source`,description:`Source identifier of the selected candidate`},{path:`/data/value`,description:`Value of the selected candidate`},{path:`/data/matched`,description:`Whether a candidate was matched (boolean)`}]},xl={description:`Assert a condition is true`,paths:[{path:`/data/ok`,description:`Whether the assertion passed (boolean)`},{path:`/data/message`,description:`Assertion message`}]}}));function Cl(e){Mo(`script/js`,e=>{let t=e.code;if(!t||typeof t!=`string`)throw new G(`script_js_error`,`script/js requires a 'code' string input`,{step:`script/js`});let n=e.args??{};try{return{data:Function(`args`,t)(n)??{}}}catch(e){throw new G(`script_js_error`,`script/js execution failed: ${e instanceof Error?e.message:String(e)}`,{step:`script/js`})}},e,wl)}var wl,Tl=j((()=>{Ao(),Fo(),wl={description:`Execute inline JavaScript; output shape is user-defined by the return value`,paths:[{path:`/data`,description:`Return value of the script (user-defined structure)`}]}}));function El(e=jo()){return Dl.has(e)?e:(Dl.add(e),cs(e),hl(e),Cl(e),e)}var Dl,Ol=j((()=>{Fo(),bs(),Sl(),Tl(),Dl=new WeakSet}));function kl(e){let t=e.steps.map((t,n)=>({step:t,dependencies:[],dependents:[],index:n+1,total:e.steps.length})),n=new Map(t.map(e=>[e.step.id,e]));for(let r of t){let t=new Set(r.step.dependsOn??[]);Uo(r.step.input,t),r.step.when!==void 0&&Uo(r.step.when,t),r.dependencies=Array.from(t).sort((t,n)=>e.steps.findIndex(e=>e.id===t)-e.steps.findIndex(e=>e.id===n));for(let e of r.dependencies)n.get(e)?.dependents.push(r.step.id)}return t}function Al(e){let t=new Set(e.map(e=>e.step.id)),n=new Set,r=[];for(;t.size>0;){let i=!1;for(let a of e)t.has(a.step.id)&&a.dependencies.every(e=>n.has(e))&&(r.push(a),n.add(a.step.id),t.delete(a.step.id),i=!0);if(!i)break}return r}function jl(e,t,n){return e.filter(e=>t.has(e.step.id)?e.dependencies.every(e=>{let t=n.get(e);return t?.status===`succeeded`||t?.status===`failed`||t?.status===`skipped`}):!1)}function Ml(e,t){let n=new Map(e.map((e,t)=>[e.step.id,t]));return[...t].sort((e,t)=>(n.get(e.id)??0)-(n.get(t.id)??0))}function Nl(e){if(e===void 0)return 1;if(!Number.isInteger(e)||e<1)throw new G(`pipeline_validation_error`,`Invalid pipeline execution options`,{details:{issues:[`concurrency must be a positive integer`]}});return e}var Pl=j((()=>{Ao(),Ko()})),Fl,Il=j((()=>{Fl=`workflow/v1`}));function Ll(e,t=jo()){let n=Bl(e);return n.length>0?n:Vl(e,t)}function Rl(e,t=jo()){if(Bl(e).length>0)return[];let n=[],r=new Map(e.steps.map(e=>[e.id,e.type]));for(let i of e.steps)Wl(i.input,i.id,r,t,n);return n}function zl(e,t){if(!e.inputs)return t;let n=Pc(e.inputs,t);if(n.ok)return n.value;throw new G(`pipeline_validation_error`,`Invalid pipeline runtime input`,{details:{issues:n.issues}})}function Bl(e){let t=[];if(!K(e))return t.push(`structural: pipeline must be an object`),t;if(e.version!==`workflow/v1`&&t.push(`structural: pipeline.version must be "${Fl}"`),!Array.isArray(e.steps))return t.push(`structural: pipeline.steps must be an array`),t;e.steps.length===0&&t.push(`structural: pipeline.steps must contain at least one step`);for(let[n,r]of e.steps.entries()){if(!K(r)){t.push(`structural: step at index ${n} must be an object`);continue}(!r.id||typeof r.id!=`string`)&&t.push(`structural: step at index ${n} must have a string id`),(!r.type||typeof r.type!=`string`)&&t.push(`structural: step at index ${n} must have a string type`),K(r.input)||t.push(`structural: step at index ${n} must have an input object`)}return t}function Vl(e,t){let n=[];e.inputs&&n.push(...Nc(e.inputs,`pipeline.inputs`));let r=e.steps,i=new Set;for(let[e,a]of r.entries()){let r=a.id||`#${e}`;i.has(a.id)&&n.push(`duplicate step id "${a.id}"`),i.add(a.id),t.hasStep(a.type)||n.push(`semantic: step "${r}" references unknown type "${a.type}"`),a.dependsOn!==void 0&&(!Array.isArray(a.dependsOn)||!a.dependsOn.every(e=>typeof e==`string`))&&n.push(`semantic: step "${r}" dependsOn must be an array of step id strings`),a.retry!==void 0&&Ul(a.retry,r,n),a.timeout!==void 0&&Ho(a.timeout)===void 0&&n.push(`semantic: step "${r}" timeout must be a positive number of seconds or duration string`)}for(let e of r){for(let t of e.dependsOn??[])i.has(t)||n.push(`semantic: step "${e.id}" references missing step "${t}"`),t===e.id&&n.push(`semantic: step "${e.id}" references itself`);Hl(e.input,e.id,i,n)}let a=new Map;for(let e of r){let t=new Set(e.dependsOn??[]);Uo(e.input,t),e.when!==void 0&&Uo(e.when,t),a.set(e.id,t)}for(let e of Gl(a))n.push(`semantic: pipeline graph contains cycle: ${e.join(` -> `)}`);return n}function Hl(e,t,n,r){if(Array.isArray(e)){e.forEach(e=>Hl(e,t,n,r));return}if(K(e)){`$from`in e&&typeof e.$from==`string`&&(n.has(e.$from)||r.push(`semantic: step "${t}" $from references missing step "${e.$from}"`));for(let i of Object.values(e))Hl(i,t,n,r)}}function Ul(e,t,n){if(!K(e)){n.push(`step "${t}" retry must be an object`);return}let r=e.maxAttempts;r!==void 0&&(typeof r!=`number`||!Number.isInteger(r)||r<1)&&n.push(`step "${t}" retry.maxAttempts must be a positive integer`),e.backoff!==void 0&&e.backoff!==`none`&&e.backoff!==`linear`&&e.backoff!==`exponential`&&n.push(`step "${t}" retry.backoff must be none, linear, or exponential`)}function Wl(e,t,n,r,i){if(Array.isArray(e)){e.forEach(e=>Wl(e,t,n,r,i));return}if(K(e)){if(`$from`in e&&typeof e.$from==`string`&&typeof e.path==`string`){let a=n.get(e.$from);if(a){let n=r.getOutputSchema(a);if(n){let r=e.path;if(!n.paths.some(e=>r===e.path||r.startsWith(e.path+`/`))){let o=n.paths.map(e=>e.path).join(`, `);i.push(`hint: step "${t}" references path "${r}" from "${e.$from}" (${a}), which is not a known output path. Known paths: ${o}`)}}}return}for(let a of Object.values(e))Wl(a,t,n,r,i)}}function Gl(e){let t=[],n=new Set,r=new Set,i=[],a=o=>{if(n.has(o)){let e=i.indexOf(o);t.push([...i.slice(e),o]);return}if(!r.has(o)){n.add(o),i.push(o);for(let t of e.get(o)??[])e.has(t)&&a(t);i.pop(),n.delete(o),r.add(o)}};for(let t of e.keys())a(t);return t}var Kl=j((()=>{Ao(),Fo(),Jc(),Il(),Ko()}));async function ql(e,t={},n={}){return await Yl(e,t,n)}async function*Jl(e,t={},n={}){let r=new su(1024),i=new AbortController,a=()=>i.abort();n.signal?.aborted?a():n.signal?.addEventListener(`abort`,a,{once:!0});let o=!1,s;Yl(e,t,{...n,signal:i.signal,onEvent:async e=>{await r.push(e)}}).then(()=>{o=!0,r.close()},e=>{s=e,o=!0,r.close()});try{for(;!o||r.size>0;){let e=await r.shift();if(e){yield e;continue}if(s)throw s}if(s)throw s}finally{i.abort(),n.signal?.removeEventListener(`abort`,a),r.close()}}async function Yl(e,t,n){let r=n.stepDispatcher??jo(),i=Ll(e,r);if(i.length>0)throw new G(`pipeline_validation_error`,`Invalid pipeline definition`,{details:{issues:i}});let a=zl(e,t);if(n.basePath){let t=await Wo(e.steps,n.basePath);if(t.length>0)throw new G(`pipeline_file_not_found`,t.join(`; `),{details:{issues:t}})}let o=Io(),s=kl(e),c=Nl(n.concurrency),l=[],u=new Map,d=new Map,f=[],p=async e=>{await n.onEvent?.(e)};if(await p({type:`pipeline.started`,timestamp:Z(),status:n.dryRun?`planned`:`running`,stepCount:e.steps.length,dryRun:!!n.dryRun}),n.dryRun){for(let t of Al(s)){let n=Zc(t.step,e,a),r={id:t.step.id,type:t.step.type,status:`planned`,dependencies:t.dependencies,input:n.redacted,...t.step.when===void 0?{}:{condition:`pending`}};l.push(r),await p({type:`step.input.resolved`,timestamp:Z(),status:`planned`,step:$l(t),input:eu(n.redacted,n.sensitiveKeys)}),await p({type:`step.planned`,timestamp:Z(),status:`planned`,step:$l(t),input:eu(n.redacted,n.sensitiveKeys),...t.step.when===void 0?{}:{condition:`pending`}})}return await p({type:`pipeline.planned`,timestamp:Z(),status:`planned`,stepCount:l.length,artifactCount:f.length}),{status:`planned`,version:Fl,steps:l,artifacts:f}}let m=new Set(s.map(e=>e.step.id)),h=new Map;for(;m.size>0||h.size>0;){let t=!1;for(let i of jl(s,m,u)){if(h.size>=c)break;if(!m.has(i.step.id))continue;let s=i.dependencies.map(e=>u.get(e)),g=s.find(e=>e?.status===`failed`);if(g){let e=`dependency ${g.id} failed`;Ql(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:Z(),status:`running`,step:$l(i),reason:e}),m.delete(i.step.id),t=!0;continue}if(s.length>0&&s.every(e=>e?.status===`skipped`)){let e=`all dependencies skipped`;Ql(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:Z(),status:`running`,step:$l(i),reason:e}),m.delete(i.step.id),t=!0;continue}if(!(i.step.when===void 0||Qc(i.step.when,e,a,d))){let e=`condition evaluated to false`;Ql(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e,condition:`false`}),await p({type:`step.skipped`,timestamp:Z(),status:`running`,step:$l(i),reason:e}),m.delete(i.step.id),t=!0;continue}let _=Xl(i,e,a,d,f,p,n,o,r);h.set(i.step.id,_),m.delete(i.step.id),t=!0}if(h.size>0){let e=await Promise.race(h.values());h.delete(e.id),Ql(l,u,e),t=!0}if(!t)throw new G(`pipeline_graph_error`,`Workflow graph did not make progress`,{details:{remaining:Array.from(m)}})}let g=Ml(s,l),_=g.find(e=>e.status===`failed`);if(_?.error){let e=s.find(e=>e.step.id===_.id);return await p({type:`pipeline.failed`,timestamp:Z(),status:`failed`,stepCount:g.length,artifactCount:f.length,failedStep:e?$l(e):{id:_.id,type:_.type,dependencies:_.dependencies,index:g.findIndex(e=>e.id===_.id)+1,total:g.length},error:_.error}),{status:`failed`,version:Fl,steps:g,artifacts:f}}return await p({type:`pipeline.succeeded`,timestamp:Z(),status:`succeeded`,stepCount:g.length,artifactCount:f.length}),{status:`succeeded`,version:Fl,steps:g,artifacts:f}}async function Xl(e,t,n,r,i,a,o,s,c){let l=Math.max(1,Math.floor(e.step.retry?.maxAttempts??1)),u,d,f=!1,p=new Date().toISOString(),m=p;for(let h=1;h<=l;h++){p=new Date().toISOString(),await a({type:`step.started`,timestamp:Z(),status:`running`,step:$l(e),timing:{startedAt:p},attempt:h});try{let l=Xc(e.step,t,n,r),u=l.value,g=l.redacted;if(o.basePath){let t=Bo(u,o.basePath);u=t.input,g=Bo(l.redacted,o.basePath).input;let n=await Vo(u,t.resolvedKeys.filter(e=>!Go.includes(e)),e.step.id);if(n.length>0)throw new G(`pipeline_file_not_found`,n.join(`; `),{step:e.step.type,details:{issues:n}})}d=g,f=l.sensitive,await a({type:`step.input.resolved`,timestamp:Z(),status:`running`,step:$l(e),input:eu(g,l.sensitiveKeys)});let _=await Zl(e.step,u,o,$l(e),a,s,c);r.set(e.step.id,_);let v=l.sensitive?el(_):_;v.artifacts&&i.push(...v.artifacts),m=new Date().toISOString();for(let t of v.artifacts??[])await a({type:`artifact.created`,timestamp:Z(),status:`running`,step:$l(e),artifact:t});return await a({type:`step.succeeded`,timestamp:Z(),status:`running`,step:$l(e),timing:ru(p,m),output:tu(v),attempt:h,...v.warnings&&v.warnings.length>0?{warnings:v.warnings}:{}}),{id:e.step.id,type:e.step.type,status:`succeeded`,dependencies:e.dependencies,input:l.redacted,output:v,startedAt:p,finishedAt:m,attempts:h,...e.step.when===void 0?{}:{condition:`true`}}}catch(t){let n=ko(t,e.step.type);if(u=f?tl(n.toJSON()):n.toJSON(),m=new Date().toISOString(),h<l){await a({type:`step.retrying`,timestamp:Z(),status:`running`,step:$l(e),attempt:h,nextAttempt:h+1,error:u});let t=iu(e.step.retry?.backoff,h,o.retryDelayBaseMs??ou);t>0&&await(o.sleep??au)(t);continue}}}let h=u??{code:`pipeline_step_failed`,message:`Step ${e.step.id} failed`,step:e.step.type,details:{}};return await a({type:`step.failed`,timestamp:Z(),status:`failed`,step:$l(e),timing:ru(p,m),attempt:l,error:h}),{id:e.step.id,type:e.step.type,status:`failed`,dependencies:e.dependencies,...d?{input:d}:{},error:h,startedAt:p,finishedAt:m,attempts:l}}async function Zl(e,t,n,r,i,a,o){let s=Ho(e.timeout)??n.timeoutSeconds,c={dryRun:!1,signal:n.signal,timeoutSeconds:s,blRequestTimeoutSeconds:n.blRequestTimeoutSeconds,emitEvent:async e=>{e.type===`step.polling`&&await i({...e,type:`step.polling`,timestamp:e.timestamp??Z(),status:`running`,step:r,taskId:e.taskId,taskStatus:e.taskStatus,elapsedMs:e.elapsedMs,pollAttempt:e.pollAttempt})},blConfig:a};if(!s)return await o.executeStep(e.type,t,c);let l=new AbortController,u=()=>l.abort();n.signal?.aborted?u():n.signal?.addEventListener(`abort`,u,{once:!0});let d=s*1e3,f=setTimeout(()=>l.abort(),d);c.signal=l.signal;try{return await Promise.race([o.executeStep(e.type,t,c),new Promise((t,n)=>{l.signal.addEventListener(`abort`,()=>{n(new G(`step_timeout`,`Step ${e.id} exceeded timeout ${s}s`,{step:e.type}))},{once:!0})})])}finally{clearTimeout(f),n.signal?.removeEventListener(`abort`,u)}}function Ql(e,t,n){e.push(n),t.set(n.id,n)}function Z(){return new Date().toISOString()}function $l(e){return{id:e.step.id,type:e.step.type,dependencies:e.dependencies,index:e.index,total:e.total}}function eu(e,t=[]){return{keys:Object.keys(e).sort(),...t.length>0?{redactedKeys:t.sort()}:{}}}function tu(e){return{...e.data===void 0?{}:{dataType:nu(e.data)},artifactCount:e.artifacts?.length??0,warningCount:e.warnings?.length??0,...e.metadata?{metadata:e.metadata}:{}}}function nu(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e}function ru(e,t){return{startedAt:e,finishedAt:t,durationMs:Math.max(0,Date.parse(t)-Date.parse(e))}}function iu(e=`none`,t,n){return e===`none`?0:e===`linear`?n*t:n*2**(t-1)}function au(e){return new Promise(t=>setTimeout(t,e))}var ou,su,cu=j((()=>{Ao(),Ro(),Fo(),ml(),Pl(),Ko(),Kl(),Il(),ou=100,su=class{items=[];takers=[];pushWaiters=[];closed=!1;maxSize;constructor(e){this.maxSize=e}get size(){return this.items.length}async push(e){for(;!this.closed&&this.items.length>=this.maxSize;)await new Promise(e=>this.pushWaiters.push(e));if(this.closed)return;let t=this.takers.shift();if(t){t(e);return}this.items.push(e)}async shift(){let e=this.items.shift();if(e!==void 0)return this.wakePushWaiter(),e;if(!this.closed)return await new Promise(e=>this.takers.push(e))}close(){if(!this.closed){this.closed=!0;for(let e of this.takers.splice(0))e(void 0);for(let e of this.pushWaiters.splice(0))e()}}wakePushWaiter(){this.pushWaiters.shift()?.()}}})),Q=M((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),c=e=>!!e&&typeof e==`object`&&e[s]===t,l=e=>!!e&&typeof e==`object`&&e[s]===n,u=e=>!!e&&typeof e==`object`&&e[s]===r,d=e=>!!e&&typeof e==`object`&&e[s]===i,f=e=>!!e&&typeof e==`object`&&e[s]===a,p=e=>!!e&&typeof e==`object`&&e[s]===o;function m(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function h(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=e=>(f(e)||m(e))&&!!e.anchor,e.isAlias=c,e.isCollection=m,e.isDocument=l,e.isMap=u,e.isNode=h,e.isPair=d,e.isScalar=f,e.isSeq=p})),lu=M((e=>{var t=Q();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function a(e,n){let r=l(n);t.isDocument(e)?o(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):o(null,e,r,Object.freeze([]))}a.BREAK=n,a.SKIP=r,a.REMOVE=i;function o(e,r,a,s){let c=u(e,r,a,s);if(t.isNode(c)||t.isPair(c))return d(e,s,c),o(e,c,a,s);if(typeof c!=`symbol`){if(t.isCollection(r)){s=Object.freeze(s.concat(r));for(let e=0;e<r.items.length;++e){let t=o(e,r.items[e],a,s);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){s=Object.freeze(s.concat(r));let e=o(`key`,r.key,a,s);if(e===n)return n;e===i&&(r.key=null);let t=o(`value`,r.value,a,s);if(t===n)return n;t===i&&(r.value=null)}}return c}async function s(e,n){let r=l(n);t.isDocument(e)?await c(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await c(null,e,r,Object.freeze([]))}s.BREAK=n,s.SKIP=r,s.REMOVE=i;async function c(e,r,a,o){let s=await u(e,r,a,o);if(t.isNode(s)||t.isPair(s))return d(e,o,s),c(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await c(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await c(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await c(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function l(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function u(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function d(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=a,e.visitAsync=s})),uu=M((e=>{var t=Q(),n=lu();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},i=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var a=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+i(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)t===`!!`&&n===`tag:yaml.org,2002:`||(!e||a.some(e=>e.startsWith(n)))&&r.push(`%TAG ${t} ${n}`);return r.join(`
171
+ `)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),du=M((e=>{var t=Q(),n=lu();function r(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function i(e){let t=new Set;return n.visit(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function a(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function o(e,n){let r=[],o=new Map,s=null;return{onAnchor:t=>{r.push(t),s??=i(e);let o=a(n,s);return s.add(o),o},setAnchors:()=>{for(let e of r){let n=o.get(e);if(typeof n==`object`&&n.anchor&&(t.isScalar(n.node)||t.isCollection(n.node)))n.node.anchor=n.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:o}}e.anchorIsValid=r,e.anchorNames=i,e.createNodeAnchors=o,e.findNewAnchor=a})),fu=M((e=>{function t(e,n,r,i){if(i&&typeof i==`object`)if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let r=i[n],a=t(e,i,String(n),r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),a=t(e,i,n,r);a===void 0?i.delete(n):a!==r&&i.set(n,a)}else if(i instanceof Set)for(let n of Array.from(i)){let r=t(e,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let a=t(e,i,n,r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}return e.call(n,r,i)}e.applyReviver=t})),pu=M((e=>{var t=Q();function n(e,r,i){if(Array.isArray(e))return e.map((e,t)=>n(e,String(t),i));if(e&&typeof e.toJSON==`function`){if(!i||!t.hasAnchor(e))return e.toJSON(r,i);let n={aliasCount:0,count:1,res:void 0};i.anchors.set(e,n),i.onCreate=e=>{n.res=e,delete i.onCreate};let a=e.toJSON(r,i);return i.onCreate&&i.onCreate(a),a}return typeof e==`bigint`&&!i?.keep?Number(e):e}e.toJS=n})),mu=M((e=>{var t=fu(),n=Q(),r=pu();e.NodeBase=class{constructor(e){Object.defineProperty(this,n.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:a,onAnchor:o,reviver:s}={}){if(!n.isDocument(e))throw TypeError(`A document argument is required`);let c={anchors:new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof a==`number`?a:100},l=r.toJS(this,``,c);if(typeof o==`function`)for(let{count:e,res:t}of c.anchors.values())o(t,e);return typeof s==`function`?t.applyReviver(s,{"":l},``,l):l}}})),hu=M((e=>{var t=du(),n=lu(),r=Q(),i=mu(),a=pu(),o=class extends i.NodeBase{constructor(e){super(r.ALIAS),this.source=e,Object.defineProperty(this,`tag`,{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){let i;t?.aliasResolveCache?i=t.aliasResolveCache:(i=[],n.visit(e,{Node:(e,t)=>{(r.isAlias(t)||r.hasAnchor(t))&&i.push(t)}}),t&&(t.aliasResolveCache=i));let a;for(let e of i){if(e===this)break;e.anchor===this.source&&(a=e)}return a}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,o=this.resolve(r,t);if(!o){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let c=n.get(o);if(c||=(a.toJS(o,null,t),n.get(o)),c?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(c.count+=1,c.aliasCount===0&&(c.aliasCount=s(r,o,n)),c.count*c.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return c.res}toString(e,n,r){let i=`*${this.source}`;if(e){if(t.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${i} `}return i}};function s(e,t,n){if(r.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(r.isCollection(t)){let r=0;for(let i of t.items){let t=s(e,i,n);t>r&&(r=t)}return r}else if(r.isPair(t)){let r=s(e,t.key,n),i=s(e,t.value,n);return Math.max(r,i)}return 1}e.Alias=o})),$=M((e=>{var t=Q(),n=mu(),r=pu();let i=e=>!e||typeof e!=`function`&&typeof e!=`object`;var a=class extends n.NodeBase{constructor(e){super(t.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:r.toJS(this.value,e,t)}toString(){return String(this.value)}};a.BLOCK_FOLDED=`BLOCK_FOLDED`,a.BLOCK_LITERAL=`BLOCK_LITERAL`,a.PLAIN=`PLAIN`,a.QUOTE_DOUBLE=`QUOTE_DOUBLE`,a.QUOTE_SINGLE=`QUOTE_SINGLE`,e.Scalar=a,e.isScalarValue=i})),gu=M((e=>{var t=hu(),n=Q(),r=$();function i(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function a(e,a,o){if(n.isDocument(e)&&(e=e.contents),n.isNode(e))return e;if(n.isPair(e)){let t=o.schema[n.MAP].createNode?.(o.schema,null,o);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:s,onAnchor:c,onTagObj:l,schema:u,sourceObjects:d}=o,f;if(s&&e&&typeof e==`object`){if(f=d.get(e),f)return f.anchor??=c(e),new t.Alias(f.anchor);f={anchor:null,node:null},d.set(e,f)}a?.startsWith(`!!`)&&(a=`tag:yaml.org,2002:`+a.slice(2));let p=i(e,a,u.tags);if(!p){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new r.Scalar(e);return f&&(f.node=t),t}p=e instanceof Map?u[n.MAP]:Symbol.iterator in Object(e)?u[n.SEQ]:u[n.MAP]}l&&(l(p),delete o.onTagObj);let m=p?.createNode?p.createNode(o.schema,e,o):typeof p?.nodeClass?.from==`function`?p.nodeClass.from(o.schema,e,o):new r.Scalar(e);return a?m.tag=a:p.default||(m.tag=p.tag),f&&(f.node=m),m}e.createNode=a})),_u=M((e=>{var t=gu(),n=Q(),r=mu();function i(e,n,r){let i=r;for(let e=n.length-1;e>=0;--e){let t=n[e];if(typeof t==`number`&&Number.isInteger(t)&&t>=0){let e=[];e[t]=i,i=e}else i=new Map([[t,i]])}return t.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}let a=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;e.Collection=class extends r.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,`schema`,{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>n.isNode(t)||n.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(a(e))this.add(t);else{let[r,...a]=e,o=this.get(r,!0);if(n.isCollection(o))o.addIn(a,t);else if(o===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(n.isCollection(i))return i.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,a=this.get(r,!0);return i.length===0?!t&&n.isScalar(a)?a.value:a:n.isCollection(a)?a.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!n.isPair(t))return!1;let r=t.value;return r==null||e&&n.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let i=this.get(t,!0);return n.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...a]=e;if(a.length===0)this.set(r,t);else{let e=this.get(r,!0);if(n.isCollection(e))e.setIn(a,t);else if(e===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}},e.collectionFromPath=i,e.isEmptyPath=a})),vu=M((e=>{let t=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function n(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}e.indentComment=n,e.lineComment=(e,t,r)=>e.endsWith(`
171
172
  `)?n(r,t):r.includes(`
172
173
  `)?`
173
- `+n(r,t):(e.endsWith(` `)?``:` `)+r,e.stringifyComment=t})),pu=j((e=>{let t=`block`,n=`quoted`;function r(e,r,a=`flow`,{indentAtStart:o,lineWidth:s=80,minContentWidth:c=20,onFold:l,onOverflow:u}={}){if(!s||s<0)return e;s<c&&(c=0);let d=Math.max(1+c,1+s-r.length);if(e.length<=d)return e;let f=[],p={},m=s-r.length;typeof o==`number`&&(o>s-Math.max(2,c)?f.push(0):m=s-o);let h,g,_=!1,v=-1,y=-1,b=-1;a===t&&(v=i(e,v,r.length),v!==-1&&(m=v+d));for(let o;o=e[v+=1];){if(a===n&&o===`\\`){switch(y=v,e[v+1]){case`x`:v+=3;break;case`u`:v+=5;break;case`U`:v+=9;break;default:v+=1}b=v}if(o===`
174
+ `+n(r,t):(e.endsWith(` `)?``:` `)+r,e.stringifyComment=t})),yu=M((e=>{let t=`block`,n=`quoted`;function r(e,r,a=`flow`,{indentAtStart:o,lineWidth:s=80,minContentWidth:c=20,onFold:l,onOverflow:u}={}){if(!s||s<0)return e;s<c&&(c=0);let d=Math.max(1+c,1+s-r.length);if(e.length<=d)return e;let f=[],p={},m=s-r.length;typeof o==`number`&&(o>s-Math.max(2,c)?f.push(0):m=s-o);let h,g,_=!1,v=-1,y=-1,b=-1;a===t&&(v=i(e,v,r.length),v!==-1&&(m=v+d));for(let o;o=e[v+=1];){if(a===n&&o===`\\`){switch(y=v,e[v+1]){case`x`:v+=3;break;case`u`:v+=5;break;case`U`:v+=9;break;default:v+=1}b=v}if(o===`
174
175
  `)a===t&&(v=i(e,v,r.length)),m=v+r.length+d,h=void 0;else{if(o===` `&&g&&g!==` `&&g!==`
175
176
  `&&g!==` `){let t=e[v+1];t&&t!==` `&&t!==`
176
177
  `&&t!==` `&&(h=v)}if(v>=m)if(h)f.push(h),m=h+d,h=void 0;else if(a===n){for(;g===` `||g===` `;)g=o,o=e[v+=1],_=!0;let t=v>b+1?v-2:y-1;if(p[t])return e;f.push(t),p[t]=!0,m=t+d,h=void 0}else _=!0}g=o}if(_&&u&&u(),f.length===0)return e;l&&l();let x=e.slice(0,f[0]);for(let t=0;t<f.length;++t){let i=f[t],o=f[t+1]||e.length;i===0?x=`\n${r}${e.slice(0,o)}`:(a===n&&p[i]&&(x+=`${e[i]}\\`),x+=`\n${r}${e.slice(i+1,o)}`)}return x}function i(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
177
- `);r=t,i=t+1,a=e[i]}return r}e.FOLD_BLOCK=t,e.FOLD_FLOW=`flow`,e.FOLD_QUOTED=n,e.foldFlowLines=r})),mu=j((e=>{var t=$(),n=pu();let r=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),i=e=>/^(%|---|\.\.\.)/m.test(e);function a(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
178
+ `);r=t,i=t+1,a=e[i]}return r}e.FOLD_BLOCK=t,e.FOLD_FLOW=`flow`,e.FOLD_QUOTED=n,e.foldFlowLines=r})),bu=M((e=>{var t=$(),n=yu();let r=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),i=e=>/^(%|---|\.\.\.)/m.test(e);function a(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
178
179
  `){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function o(e,t){let a=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return a;let{implicitKey:o}=t,s=t.options.doubleQuotedMinMultiLineLength,c=t.indent||(i(e)?` `:``),l=``,u=0;for(let e=0,t=a[e];t;t=a[++e])if(t===` `&&a[e+1]===`\\`&&a[e+2]===`n`&&(l+=a.slice(u,e)+`\\ `,e+=1,u=e,t=`\\`),t===`\\`)switch(a[e+1]){case`u`:{l+=a.slice(u,e);let t=a.substr(e+2,4);switch(t){case`0000`:l+=`\\0`;break;case`0007`:l+=`\\a`;break;case`000b`:l+=`\\v`;break;case`001b`:l+=`\\e`;break;case`0085`:l+=`\\N`;break;case`00a0`:l+=`\\_`;break;case`2028`:l+=`\\L`;break;case`2029`:l+=`\\P`;break;default:t.substr(0,2)===`00`?l+=`\\x`+t.substr(2):l+=a.substr(e,6)}e+=5,u=e+1}break;case`n`:if(o||a[e+2]===`"`||a.length<s)e+=1;else{for(l+=a.slice(u,e)+`
179
180
 
180
181
  `;a[e+2]===`\\`&&a[e+3]===`n`&&a[e+4]!==`"`;)l+=`
@@ -192,29 +193,29 @@ Hint: Add --diarization flag to enable speaker separation.`,i.USAGE);let s=n.mod
192
193
  $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${g}`),i=!1,a=r(u,!0);p!==`folded`&&o!==t.Scalar.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let c=n.foldFlowLines(`${T}${e}${b}`,g,n.FOLD_BLOCK,a);if(!i)return`>${E}\n${g}${c}`}return s=s.replace(/\n+/g,`$&${g}`),`|${E}\n${g}${T}${s}${b}`}function d(e,a,o,s){let{type:l,value:d}=e,{actualString:f,implicitKey:p,indent:m,indentStep:h,inFlow:g}=a;if(p&&d.includes(`
193
194
  `)||g&&/[[\]{},]/.test(d))return c(d,a);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(d))return p||g||!d.includes(`
194
195
  `)?c(d,a):u(e,a,o,s);if(!p&&!g&&l!==t.Scalar.PLAIN&&d.includes(`
195
- `))return u(e,a,o,s);if(i(d)){if(m===``)return a.forceBlockIndent=!0,u(e,a,o,s);if(p&&m===h)return c(d,a)}let _=d.replace(/\n+/g,`$&\n${m}`);if(f){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(_),{compat:t,tags:n}=a.doc.schema;if(n.some(e)||t?.some(e))return c(d,a)}return p?_:n.foldFlowLines(_,m,n.FOLD_FLOW,r(a,!1))}function f(e,n,r,i){let{implicitKey:a,inFlow:l}=n,f=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:p}=e;p!==t.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(f.value)&&(p=t.Scalar.QUOTE_DOUBLE);let m=e=>{switch(e){case t.Scalar.BLOCK_FOLDED:case t.Scalar.BLOCK_LITERAL:return a||l?c(f.value,n):u(f,n,r,i);case t.Scalar.QUOTE_DOUBLE:return o(f.value,n);case t.Scalar.QUOTE_SINGLE:return s(f.value,n);case t.Scalar.PLAIN:return d(f,n,r,i);default:return null}},h=m(p);if(h===null){let{defaultKeyType:e,defaultStringType:t}=n.options,r=a&&e||t;if(h=m(r),h===null)throw Error(`Unsupported default string type ${r}`)}return h}e.stringifyString=f})),hu=j((e=>{var t=au(),n=Q(),r=fu(),i=mu();function a(e,t){let n=Object.assign({blockQuote:!0,commentString:r.stringifyComment,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),i;switch(n.collectionStyle){case`block`:i=!1;break;case`flow`:i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:i,options:n}}function o(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let r,i;if(n.isScalar(t)){i=t.value;let n=e.filter(e=>e.identify?.(i));if(n.length>1){let e=n.filter(e=>e.test);e.length>0&&(n=e)}r=n.find(e=>e.format===t.format)??n.find(e=>!e.format)}else i=t,r=e.find(e=>e.nodeClass&&i instanceof e.nodeClass);if(!r){let e=i?.constructor?.name??(i===null?`null`:typeof i);throw Error(`Tag not resolved for ${e} value`)}return r}function s(e,r,{anchors:i,doc:a}){if(!a.directives)return``;let o=[],s=(n.isScalar(e)||n.isCollection(e))&&e.anchor;s&&t.anchorIsValid(s)&&(i.add(s),o.push(`&${s}`));let c=e.tag??(r.default?null:r.tag);return c&&o.push(a.directives.tagString(c)),o.join(` `)}function c(e,t,r,a){if(n.isPair(e))return e.toString(t,r,a);if(n.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let c,l=n.isNode(e)?e:t.doc.createNode(e,{onTagObj:e=>c=e});c??=o(t.doc.schema.tags,l);let u=s(l,c,t);u.length>0&&(t.indentAtStart=(t.indentAtStart??0)+u.length+1);let d=typeof c.stringify==`function`?c.stringify(l,t,r,a):n.isScalar(l)?i.stringifyString(l,t,r,a):l.toString(t,r,a);return u?n.isScalar(l)||d[0]===`{`||d[0]===`[`?`${u} ${d}`:`${u}\n${t.indent}${d}`:d}e.createStringifyContext=a,e.stringify=c})),gu=j((e=>{var t=Q(),n=$(),r=hu(),i=fu();function a({key:e,value:a},o,s,c){let{allNullValues:l,doc:u,indent:d,indentStep:f,options:{commentString:p,indentSeq:m,simpleKeys:h}}=o,g=t.isNode(e)&&e.comment||null;if(h){if(g)throw Error(`With simple keys, key nodes cannot have comments`);if(t.isCollection(e)||!t.isNode(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let _=!h&&(!e||g&&a==null&&!o.inFlow||t.isCollection(e)||(t.isScalar(e)?e.type===n.Scalar.BLOCK_FOLDED||e.type===n.Scalar.BLOCK_LITERAL:typeof e==`object`));o=Object.assign({},o,{allNullValues:!1,implicitKey:!_&&(h||!l),indent:d+f});let v=!1,y=!1,b=r.stringify(e,o,()=>v=!0,()=>y=!0);if(!_&&!o.inFlow&&b.length>1024){if(h)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);_=!0}if(o.inFlow){if(l||a==null)return v&&s&&s(),b===``?`?`:_?`? ${b}`:b}else if(l&&!h||a==null&&_)return b=`? ${b}`,g&&!v?b+=i.lineComment(b,o.indent,p(g)):y&&c&&c(),b;v&&(g=null),_?(g&&(b+=i.lineComment(b,o.indent,p(g))),b=`? ${b}\n${d}:`):(b=`${b}:`,g&&(b+=i.lineComment(b,o.indent,p(g))));let x,S,C;t.isNode(a)?(x=!!a.spaceBefore,S=a.commentBefore,C=a.comment):(x=!1,S=null,C=null,a&&typeof a==`object`&&(a=u.createNode(a))),o.implicitKey=!1,!_&&!g&&t.isScalar(a)&&(o.indentAtStart=b.length+1),y=!1,!m&&f.length>=2&&!o.inFlow&&!_&&t.isSeq(a)&&!a.flow&&!a.tag&&!a.anchor&&(o.indent=o.indent.substring(2));let w=!1,T=r.stringify(a,o,()=>w=!0,()=>y=!0),E=` `;if(g||x||S){if(E=x?`
196
+ `))return u(e,a,o,s);if(i(d)){if(m===``)return a.forceBlockIndent=!0,u(e,a,o,s);if(p&&m===h)return c(d,a)}let _=d.replace(/\n+/g,`$&\n${m}`);if(f){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(_),{compat:t,tags:n}=a.doc.schema;if(n.some(e)||t?.some(e))return c(d,a)}return p?_:n.foldFlowLines(_,m,n.FOLD_FLOW,r(a,!1))}function f(e,n,r,i){let{implicitKey:a,inFlow:l}=n,f=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:p}=e;p!==t.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(f.value)&&(p=t.Scalar.QUOTE_DOUBLE);let m=e=>{switch(e){case t.Scalar.BLOCK_FOLDED:case t.Scalar.BLOCK_LITERAL:return a||l?c(f.value,n):u(f,n,r,i);case t.Scalar.QUOTE_DOUBLE:return o(f.value,n);case t.Scalar.QUOTE_SINGLE:return s(f.value,n);case t.Scalar.PLAIN:return d(f,n,r,i);default:return null}},h=m(p);if(h===null){let{defaultKeyType:e,defaultStringType:t}=n.options,r=a&&e||t;if(h=m(r),h===null)throw Error(`Unsupported default string type ${r}`)}return h}e.stringifyString=f})),xu=M((e=>{var t=du(),n=Q(),r=vu(),i=bu();function a(e,t){let n=Object.assign({blockQuote:!0,commentString:r.stringifyComment,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),i;switch(n.collectionStyle){case`block`:i=!1;break;case`flow`:i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:i,options:n}}function o(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let r,i;if(n.isScalar(t)){i=t.value;let n=e.filter(e=>e.identify?.(i));if(n.length>1){let e=n.filter(e=>e.test);e.length>0&&(n=e)}r=n.find(e=>e.format===t.format)??n.find(e=>!e.format)}else i=t,r=e.find(e=>e.nodeClass&&i instanceof e.nodeClass);if(!r){let e=i?.constructor?.name??(i===null?`null`:typeof i);throw Error(`Tag not resolved for ${e} value`)}return r}function s(e,r,{anchors:i,doc:a}){if(!a.directives)return``;let o=[],s=(n.isScalar(e)||n.isCollection(e))&&e.anchor;s&&t.anchorIsValid(s)&&(i.add(s),o.push(`&${s}`));let c=e.tag??(r.default?null:r.tag);return c&&o.push(a.directives.tagString(c)),o.join(` `)}function c(e,t,r,a){if(n.isPair(e))return e.toString(t,r,a);if(n.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let c,l=n.isNode(e)?e:t.doc.createNode(e,{onTagObj:e=>c=e});c??=o(t.doc.schema.tags,l);let u=s(l,c,t);u.length>0&&(t.indentAtStart=(t.indentAtStart??0)+u.length+1);let d=typeof c.stringify==`function`?c.stringify(l,t,r,a):n.isScalar(l)?i.stringifyString(l,t,r,a):l.toString(t,r,a);return u?n.isScalar(l)||d[0]===`{`||d[0]===`[`?`${u} ${d}`:`${u}\n${t.indent}${d}`:d}e.createStringifyContext=a,e.stringify=c})),Su=M((e=>{var t=Q(),n=$(),r=xu(),i=vu();function a({key:e,value:a},o,s,c){let{allNullValues:l,doc:u,indent:d,indentStep:f,options:{commentString:p,indentSeq:m,simpleKeys:h}}=o,g=t.isNode(e)&&e.comment||null;if(h){if(g)throw Error(`With simple keys, key nodes cannot have comments`);if(t.isCollection(e)||!t.isNode(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let _=!h&&(!e||g&&a==null&&!o.inFlow||t.isCollection(e)||(t.isScalar(e)?e.type===n.Scalar.BLOCK_FOLDED||e.type===n.Scalar.BLOCK_LITERAL:typeof e==`object`));o=Object.assign({},o,{allNullValues:!1,implicitKey:!_&&(h||!l),indent:d+f});let v=!1,y=!1,b=r.stringify(e,o,()=>v=!0,()=>y=!0);if(!_&&!o.inFlow&&b.length>1024){if(h)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);_=!0}if(o.inFlow){if(l||a==null)return v&&s&&s(),b===``?`?`:_?`? ${b}`:b}else if(l&&!h||a==null&&_)return b=`? ${b}`,g&&!v?b+=i.lineComment(b,o.indent,p(g)):y&&c&&c(),b;v&&(g=null),_?(g&&(b+=i.lineComment(b,o.indent,p(g))),b=`? ${b}\n${d}:`):(b=`${b}:`,g&&(b+=i.lineComment(b,o.indent,p(g))));let x,S,C;t.isNode(a)?(x=!!a.spaceBefore,S=a.commentBefore,C=a.comment):(x=!1,S=null,C=null,a&&typeof a==`object`&&(a=u.createNode(a))),o.implicitKey=!1,!_&&!g&&t.isScalar(a)&&(o.indentAtStart=b.length+1),y=!1,!m&&f.length>=2&&!o.inFlow&&!_&&t.isSeq(a)&&!a.flow&&!a.tag&&!a.anchor&&(o.indent=o.indent.substring(2));let w=!1,T=r.stringify(a,o,()=>w=!0,()=>y=!0),E=` `;if(g||x||S){if(E=x?`
196
197
  `:``,S){let e=p(S);E+=`\n${i.indentComment(e,o.indent)}`}T===``&&!o.inFlow?E===`
197
198
  `&&C&&(E=`
198
199
 
199
200
  `):E+=`\n${o.indent}`}else if(!_&&t.isCollection(a)){let e=T[0],t=T.indexOf(`
200
201
  `),n=t!==-1,r=o.inFlow??a.flow??a.items.length===0;if(n||!r){let r=!1;if(n&&(e===`&`||e===`!`)){let n=T.indexOf(` `);e===`&`&&n!==-1&&n<t&&T[n+1]===`!`&&(n=T.indexOf(` `,n+1)),(n===-1||t<n)&&(r=!0)}r||(E=`\n${o.indent}`)}}else (T===``||T[0]===`
201
- `)&&(E=``);return b+=E+T,o.inFlow?w&&s&&s():C&&!w?b+=i.lineComment(b,o.indent,p(C)):y&&c&&c(),b}e.stringifyPair=a})),_u=j((e=>{var t=nt(`process`);function n(e,...t){e===`debug`&&console.log(...t)}function r(e,n){(e===`debug`||e===`warn`)&&(typeof t.emitWarning==`function`?t.emitWarning(n):console.warn(n))}e.debug=n,e.warn=r})),vu=j((e=>{var t=Q(),n=$();let r={identify:e=>e===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new n.Scalar(Symbol(`<<`)),{addToJSMap:a}),stringify:()=>`<<`},i=(e,i)=>(r.identify(i)||t.isScalar(i)&&(!i.type||i.type===n.Scalar.PLAIN)&&r.identify(i.value))&&e?.doc.schema.tags.some(e=>e.tag===r.tag&&e.default);function a(e,n,r){if(r=e&&t.isAlias(r)?r.resolve(e.doc):r,t.isSeq(r))for(let t of r.items)o(e,n,t);else if(Array.isArray(r))for(let t of r)o(e,n,t);else o(e,n,r)}function o(e,n,r){let i=e&&t.isAlias(r)?r.resolve(e.doc):r;if(!t.isMap(i))throw Error(`Merge sources must be maps or map aliases`);let a=i.toJSON(null,e,Map);for(let[e,t]of a)n instanceof Map?n.has(e)||n.set(e,t):n instanceof Set?n.add(e):Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0});return n}e.addMergeToJSMap=a,e.isMergeKey=i,e.merge=r})),yu=j((e=>{var t=_u(),n=vu(),r=hu(),i=Q(),a=su();function o(e,t,{key:r,value:o}){if(i.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,o);else if(n.isMergeKey(e,r))n.addMergeToJSMap(e,t,o);else{let n=a.toJS(r,``,e);if(t instanceof Map)t.set(n,a.toJS(o,n,e));else if(t instanceof Set)t.add(n);else{let i=s(r,n,e),c=a.toJS(o,i,e);i in t?Object.defineProperty(t,i,{value:c,writable:!0,enumerable:!0,configurable:!0}):t[i]=c}}return t}function s(e,n,a){if(n===null)return``;if(typeof n!=`object`)return String(n);if(i.isNode(e)&&a?.doc){let n=r.createStringifyContext(a.doc,{});n.anchors=new Set;for(let e of a.anchors.keys())n.anchors.add(e.anchor);n.inFlow=!0,n.inStringifyKey=!0;let i=e.toString(n);if(!a.mapKeyWarned){let e=JSON.stringify(i);e.length>40&&(e=e.substring(0,36)+`..."`),t.warn(a.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),a.mapKeyWarned=!0}return i}return JSON.stringify(n)}e.addPairToJSMap=o})),bu=j((e=>{var t=uu(),n=gu(),r=yu(),i=Q();function a(e,n,r){return new o(t.createNode(e,void 0,r),t.createNode(n,void 0,r))}var o=class e{constructor(e,t=null){Object.defineProperty(this,i.NODE_TYPE,{value:i.PAIR}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return i.isNode(n)&&(n=n.clone(t)),i.isNode(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){let n=t?.mapAsMap?new Map:{};return r.addPairToJSMap(t,n,this)}toString(e,t,r){return e?.doc?n.stringifyPair(this,e,t,r):JSON.stringify(this)}};e.Pair=o,e.createPair=a})),xu=j((e=>{var t=Q(),n=hu(),r=fu();function i(e,t,n){return(t.inFlow??e.flow?o:a)(e,t,n)}function a({comment:e,items:i},a,{blockItemPrefix:o,flowChars:c,itemIndent:l,onChompKeep:u,onComment:d}){let{indent:f,options:{commentString:p}}=a,m=Object.assign({},a,{indent:l,type:null}),h=!1,g=[];for(let e=0;e<i.length;++e){let c=i[e],u=null;if(t.isNode(c))!h&&c.spaceBefore&&g.push(``),s(a,g,c.commentBefore,h),c.comment&&(u=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(!h&&e.spaceBefore&&g.push(``),s(a,g,e.commentBefore,h))}h=!1;let d=n.stringify(c,m,()=>u=null,()=>h=!0);u&&(d+=r.lineComment(d,l,p(u))),h&&u&&(h=!1),g.push(o+d)}let _;if(g.length===0)_=c.start+c.end;else{_=g[0];for(let e=1;e<g.length;++e){let t=g[e];_+=t?`\n${f}${t}`:`
202
+ `)&&(E=``);return b+=E+T,o.inFlow?w&&s&&s():C&&!w?b+=i.lineComment(b,o.indent,p(C)):y&&c&&c(),b}e.stringifyPair=a})),Cu=M((e=>{var t=tt(`process`);function n(e,...t){e===`debug`&&console.log(...t)}function r(e,n){(e===`debug`||e===`warn`)&&(typeof t.emitWarning==`function`?t.emitWarning(n):console.warn(n))}e.debug=n,e.warn=r})),wu=M((e=>{var t=Q(),n=$();let r={identify:e=>e===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new n.Scalar(Symbol(`<<`)),{addToJSMap:a}),stringify:()=>`<<`},i=(e,i)=>(r.identify(i)||t.isScalar(i)&&(!i.type||i.type===n.Scalar.PLAIN)&&r.identify(i.value))&&e?.doc.schema.tags.some(e=>e.tag===r.tag&&e.default);function a(e,n,r){if(r=e&&t.isAlias(r)?r.resolve(e.doc):r,t.isSeq(r))for(let t of r.items)o(e,n,t);else if(Array.isArray(r))for(let t of r)o(e,n,t);else o(e,n,r)}function o(e,n,r){let i=e&&t.isAlias(r)?r.resolve(e.doc):r;if(!t.isMap(i))throw Error(`Merge sources must be maps or map aliases`);let a=i.toJSON(null,e,Map);for(let[e,t]of a)n instanceof Map?n.has(e)||n.set(e,t):n instanceof Set?n.add(e):Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0});return n}e.addMergeToJSMap=a,e.isMergeKey=i,e.merge=r})),Tu=M((e=>{var t=Cu(),n=wu(),r=xu(),i=Q(),a=pu();function o(e,t,{key:r,value:o}){if(i.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,o);else if(n.isMergeKey(e,r))n.addMergeToJSMap(e,t,o);else{let n=a.toJS(r,``,e);if(t instanceof Map)t.set(n,a.toJS(o,n,e));else if(t instanceof Set)t.add(n);else{let i=s(r,n,e),c=a.toJS(o,i,e);i in t?Object.defineProperty(t,i,{value:c,writable:!0,enumerable:!0,configurable:!0}):t[i]=c}}return t}function s(e,n,a){if(n===null)return``;if(typeof n!=`object`)return String(n);if(i.isNode(e)&&a?.doc){let n=r.createStringifyContext(a.doc,{});n.anchors=new Set;for(let e of a.anchors.keys())n.anchors.add(e.anchor);n.inFlow=!0,n.inStringifyKey=!0;let i=e.toString(n);if(!a.mapKeyWarned){let e=JSON.stringify(i);e.length>40&&(e=e.substring(0,36)+`..."`),t.warn(a.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),a.mapKeyWarned=!0}return i}return JSON.stringify(n)}e.addPairToJSMap=o})),Eu=M((e=>{var t=gu(),n=Su(),r=Tu(),i=Q();function a(e,n,r){return new o(t.createNode(e,void 0,r),t.createNode(n,void 0,r))}var o=class e{constructor(e,t=null){Object.defineProperty(this,i.NODE_TYPE,{value:i.PAIR}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return i.isNode(n)&&(n=n.clone(t)),i.isNode(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){let n=t?.mapAsMap?new Map:{};return r.addPairToJSMap(t,n,this)}toString(e,t,r){return e?.doc?n.stringifyPair(this,e,t,r):JSON.stringify(this)}};e.Pair=o,e.createPair=a})),Du=M((e=>{var t=Q(),n=xu(),r=vu();function i(e,t,n){return(t.inFlow??e.flow?o:a)(e,t,n)}function a({comment:e,items:i},a,{blockItemPrefix:o,flowChars:c,itemIndent:l,onChompKeep:u,onComment:d}){let{indent:f,options:{commentString:p}}=a,m=Object.assign({},a,{indent:l,type:null}),h=!1,g=[];for(let e=0;e<i.length;++e){let c=i[e],u=null;if(t.isNode(c))!h&&c.spaceBefore&&g.push(``),s(a,g,c.commentBefore,h),c.comment&&(u=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(!h&&e.spaceBefore&&g.push(``),s(a,g,e.commentBefore,h))}h=!1;let d=n.stringify(c,m,()=>u=null,()=>h=!0);u&&(d+=r.lineComment(d,l,p(u))),h&&u&&(h=!1),g.push(o+d)}let _;if(g.length===0)_=c.start+c.end;else{_=g[0];for(let e=1;e<g.length;++e){let t=g[e];_+=t?`\n${f}${t}`:`
202
203
  `}}return e?(_+=`
203
204
  `+r.indentComment(p(e),f),d&&d()):h&&u&&u(),_}function o({items:e},i,{flowChars:a,itemIndent:o}){let{indent:c,indentStep:l,flowCollectionPadding:u,options:{commentString:d}}=i;o+=l;let f=Object.assign({},i,{indent:o,inFlow:!0,type:null}),p=!1,m=0,h=[];for(let a=0;a<e.length;++a){let c=e[a],l=null;if(t.isNode(c))c.spaceBefore&&h.push(``),s(i,h,c.commentBefore,!1),c.comment&&(l=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(e.spaceBefore&&h.push(``),s(i,h,e.commentBefore,!1),e.comment&&(p=!0));let n=t.isNode(c.value)?c.value:null;n?(n.comment&&(l=n.comment),n.commentBefore&&(p=!0)):c.value==null&&e?.comment&&(l=e.comment)}l&&(p=!0);let u=n.stringify(c,f,()=>l=null);p||=h.length>m||u.includes(`
204
205
  `),a<e.length-1?u+=`,`:i.options.trailingComma&&(i.options.lineWidth>0&&(p||=h.reduce((e,t)=>e+t.length+2,2)+(u.length+2)>i.options.lineWidth),p&&(u+=`,`)),l&&(u+=r.lineComment(u,o,d(l))),h.push(u),m=h.length}let{start:g,end:_}=a;if(h.length===0)return g+_;if(!p){let e=h.reduce((e,t)=>e+t.length+2,2);p=i.options.lineWidth>0&&e>i.options.lineWidth}if(p){let e=g;for(let t of h)e+=t?`\n${l}${c}${t}`:`
205
- `;return`${e}\n${c}${_}`}else return`${g}${u}${h.join(` `)}${u}${_}`}function s({indent:e,options:{commentString:t}},n,i,a){if(i&&a&&(i=i.replace(/^\n+/,``)),i){let a=r.indentComment(t(i),e);n.push(a.trimStart())}}e.stringifyCollection=i})),Su=j((e=>{var t=xu(),n=yu(),r=du(),i=Q(),a=bu(),o=$();function s(e,t){let n=i.isScalar(t)?t.value:t;for(let r of e)if(i.isPair(r)&&(r.key===t||r.key===n||i.isScalar(r.key)&&r.key.value===n))return r}e.YAMLMap=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(i.MAP,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,o=new this(e),s=(e,s)=>{if(typeof i==`function`)s=i.call(t,e,s);else if(Array.isArray(i)&&!i.includes(e))return;(s!==void 0||r)&&o.items.push(a.createPair(e,s,n))};if(t instanceof Map)for(let[e,n]of t)s(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))s(e,t[e]);return typeof e.sortMapEntries==`function`&&o.items.sort(e.sortMapEntries),o}add(e,t){let n;n=i.isPair(e)?e:!e||typeof e!=`object`||!(`key`in e)?new a.Pair(e,e?.value):new a.Pair(e.key,e.value);let r=s(this.items,n.key),c=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);i.isScalar(r.value)&&o.isScalarValue(n.value)?r.value.value=n.value:r.value=n.value}else if(c){let e=this.items.findIndex(e=>c(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=s(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=s(this.items,e)?.value;return(!t&&i.isScalar(n)?n.value:n)??void 0}has(e){return!!s(this.items,e)}set(e,t){this.add(new a.Pair(e,t),!0)}toJSON(e,t,r){let i=r?new r:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(i);for(let e of this.items)n.addPairToJSMap(t,i,e);return i}toString(e,n,r){if(!e)return JSON.stringify(this);for(let e of this.items)if(!i.isPair(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),t.stringifyCollection(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:r,onComment:n})}},e.findPair=s})),Cu=j((e=>{var t=Q(),n=Su();e.map={collection:`map`,default:!0,nodeClass:n.YAMLMap,tag:`tag:yaml.org,2002:map`,resolve(e,n){return t.isMap(e)||n(`Expected a mapping for this tag`),e},createNode:(e,t,r)=>n.YAMLMap.from(e,t,r)}})),wu=j((e=>{var t=uu(),n=xu(),r=du(),i=Q(),a=$(),o=su(),s=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(i.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=c(e);return typeof t==`number`?this.items.splice(t,1).length>0:!1}get(e,t){let n=c(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&i.isScalar(r)?r.value:r}has(e){let t=c(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=c(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];i.isScalar(r)&&a.isScalarValue(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(o.toJS(e,String(r++),t));return n}toString(e,t,r){return e?n.stringifyCollection(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,n,r){let{replacer:i}=r,a=new this(e);if(n&&Symbol.iterator in Object(n)){let e=0;for(let o of n){if(typeof i==`function`){let t=n instanceof Set?o:String(e++);o=i.call(n,t,o)}a.items.push(t.createNode(o,void 0,r))}}return a}};function c(e){let t=i.isScalar(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}e.YAMLSeq=s})),Tu=j((e=>{var t=Q(),n=wu();e.seq={collection:`seq`,default:!0,nodeClass:n.YAMLSeq,tag:`tag:yaml.org,2002:seq`,resolve(e,n){return t.isSeq(e)||n(`Expected a sequence for this tag`),e},createNode:(e,t,r)=>n.YAMLSeq.from(e,t,r)}})),Eu=j((e=>{var t=mu();e.string={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,n,r,i){return n=Object.assign({actualString:!0},n),t.stringifyString(e,n,r,i)}}})),Du=j((e=>{var t=$();let n={identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new t.Scalar(null),stringify:({source:e},t)=>typeof e==`string`&&n.test.test(e)?e:t.options.nullStr};e.nullTag=n})),Ou=j((e=>{var t=$();let n={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new t.Scalar(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},r){return e&&n.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?r.options.trueStr:r.options.falseStr}};e.boolTag=n})),ku=j((e=>{function t({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^\d/.test(a)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-- >0;)a+=`0`}return a}e.stringifyNumber=t})),Au=j((e=>{var t=$(),n=ku();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let n=new t.Scalar(parseFloat(e)),r=e.indexOf(`.`);return r!==-1&&e[e.length-1]===`0`&&(n.minFractionDigits=e.length-r-1),n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),ju=j((e=>{var t=ku();let n=e=>typeof e==`bigint`||Number.isInteger(e),r=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function i(e,r,i){let{value:a}=e;return n(a)&&a>=0?i+a.toString(r):t.stringifyNumber(e)}e.int={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},e.intHex={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)},e.intOct={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>r(e,2,8,n),stringify:e=>i(e,8,`0o`)}})),Mu=j((e=>{var t=Cu(),n=Du(),r=Tu(),i=Eu(),a=Ou(),o=Au(),s=ju();e.schema=[t.map,r.seq,i.string,n.nullTag,a.boolTag,s.intOct,s.int,s.intHex,o.floatNaN,o.floatExp,o.float]})),Nu=j((e=>{var t=$(),n=Cu(),r=Tu();function i(e){return typeof e==`bigint`||Number.isInteger(e)}let a=({value:e})=>JSON.stringify(e),o=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:a},{identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:a},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:a},{identify:i,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>i(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:a}];e.schema=[n.map,r.seq].concat(o,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}})})),Pu=j((e=>{var t=nt(`buffer`),n=$(),r=mu();e.binary={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,n){if(typeof t.Buffer==`function`)return t.Buffer.from(e,`base64`);if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}else return n(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:i,value:a},o,s,c){if(!a)return``;let l=a,u;if(typeof t.Buffer==`function`)u=l instanceof t.Buffer?l.toString(`base64`):t.Buffer.from(l.buffer).toString(`base64`);else if(typeof btoa==`function`){let e=``;for(let t=0;t<l.length;++t)e+=String.fromCharCode(l[t]);u=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(i??=n.Scalar.BLOCK_LITERAL,i!==n.Scalar.QUOTE_DOUBLE){let e=Math.max(o.options.lineWidth-o.indent.length,o.options.minContentWidth),t=Math.ceil(u.length/e),r=Array(t);for(let n=0,i=0;n<t;++n,i+=e)r[n]=u.substr(i,e);u=r.join(i===n.Scalar.BLOCK_LITERAL?`
206
- `:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),Fu=j((e=>{var t=Q(),n=bu(),r=$(),i=wu();function a(e,i){if(t.isSeq(e))for(let a=0;a<e.items.length;++a){let o=e.items[a];if(!t.isPair(o)){if(t.isMap(o)){o.items.length>1&&i(`Each pair must have its own sequence indicator`);let e=o.items[0]||new n.Pair(new r.Scalar(null));if(o.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${o.commentBefore}\n${e.key.commentBefore}`:o.commentBefore),o.comment){let t=e.value??e.key;t.comment=t.comment?`${o.comment}\n${t.comment}`:o.comment}o=e}e.items[a]=t.isPair(o)?o:new n.Pair(o)}}else i(`Expected a sequence for this tag`);return e}function o(e,t,r){let{replacer:a}=r,o=new i.YAMLSeq(e);o.tag=`tag:yaml.org,2002:pairs`;let s=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof a==`function`&&(e=a.call(t,String(s++),e));let i,c;if(Array.isArray(e))if(e.length===2)i=e[0],c=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`);else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)i=t[0],c=e[i];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else i=e;o.items.push(n.createPair(i,c,r))}return o}let s={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:a,createNode:o};e.createPairs=o,e.pairs=s,e.resolvePairs=a})),Iu=j((e=>{var t=Q(),n=su(),r=Su(),i=wu(),a=Fu(),o=class e extends i.YAMLSeq{constructor(){super(),this.add=r.YAMLMap.prototype.add.bind(this),this.delete=r.YAMLMap.prototype.delete.bind(this),this.get=r.YAMLMap.prototype.get.bind(this),this.has=r.YAMLMap.prototype.has.bind(this),this.set=r.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=new Map;r?.onCreate&&r.onCreate(i);for(let e of this.items){let a,o;if(t.isPair(e)?(a=n.toJS(e.key,``,r),o=n.toJS(e.value,a,r)):a=n.toJS(e,``,r),i.has(a))throw Error(`Ordered maps must not include duplicate keys`);i.set(a,o)}return i}static from(e,t,n){let r=a.createPairs(e,t,n),i=new this;return i.items=r.items,i}};o.tag=`tag:yaml.org,2002:omap`;let s={collection:`seq`,identify:e=>e instanceof Map,nodeClass:o,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,n){let r=a.resolvePairs(e,n),i=[];for(let{key:e}of r.items)t.isScalar(e)&&(i.includes(e.value)?n(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new o,r)},createNode:(e,t,n)=>o.from(e,t,n)};e.YAMLOMap=o,e.omap=s})),Lu=j((e=>{var t=$();function n({value:e,source:t},n){return t&&(e?r:i).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}let r={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new t.Scalar(!0),stringify:n},i={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new t.Scalar(!1),stringify:n};e.falseTag=i,e.trueTag=r})),Ru=j((e=>{var t=$(),n=ku();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let n=new t.Scalar(parseFloat(e.replace(/_/g,``))),r=e.indexOf(`.`);if(r!==-1){let t=e.substring(r+1).replace(/_/g,``);t[t.length-1]===`0`&&(n.minFractionDigits=t.length)}return n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),zu=j((e=>{var t=ku();let n=e=>typeof e==`bigint`||Number.isInteger(e);function r(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function i(e,r,i){let{value:a}=e;if(n(a)){let e=a.toString(r);return a<0?`-`+i+e.substr(1):i+e}return t.stringifyNumber(e)}let a={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>r(e,2,2,n),stringify:e=>i(e,2,`0b`)},o={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>r(e,1,8,n),stringify:e=>i(e,8,`0`)},s={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},c={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)};e.int=s,e.intBin=a,e.intHex=c,e.intOct=o})),Bu=j((e=>{var t=Q(),n=bu(),r=Su(),i=class e extends r.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(e){let i;i=t.isPair(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new n.Pair(e.key,null):new n.Pair(e,null),r.findPair(this.items,i.key)||this.items.push(i)}get(e,n){let i=r.findPair(this.items,e);return!n&&t.isPair(i)?t.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=r.findPair(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new n.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,r){let{replacer:i}=r,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof i==`function`&&(e=i.call(t,e,e)),a.items.push(n.createPair(e,null,r));return a}};i.tag=`tag:yaml.org,2002:set`;let a={collection:`map`,identify:e=>e instanceof Set,nodeClass:i,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>i.from(e,t,n),resolve(e,n){if(t.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new i,e);n(`Set items must all have null values`)}else n(`Expected a mapping for this tag`);return e}};e.YAMLSet=i,e.set=a})),Vu=j((e=>{var t=ku();function n(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function r(e){let{value:n}=e,r=e=>e;if(typeof n==`bigint`)r=e=>BigInt(e);else if(isNaN(n)||!isFinite(n))return t.stringifyNumber(e);let i=``;n<0&&(i=`-`,n*=r(-1));let a=r(60),o=[n%a];return n<60?o.unshift(0):(n=(n-o[0])/a,o.unshift(n%a),n>=60&&(n=(n-o[0])/a,o.unshift(n))),i+o.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}let i={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>n(e,r),stringify:r},a={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>n(e,!1),stringify:r},o={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(o.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,r,i,a,s,c,l]=t.map(Number),u=t[7]?Number((t[7]+`00`).substr(1,3)):0,d=Date.UTC(r,i-1,a,s||0,c||0,l||0,u),f=t[8];if(f&&f!==`Z`){let e=n(f,!1);Math.abs(e)<30&&(e*=60),d-=6e4*e}return new Date(d)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``};e.floatTime=a,e.intTime=i,e.timestamp=o})),Hu=j((e=>{var t=Cu(),n=Du(),r=Tu(),i=Eu(),a=Pu(),o=Lu(),s=Ru(),c=zu(),l=vu(),u=Iu(),d=Fu(),f=Bu(),p=Vu();e.schema=[t.map,r.seq,i.string,n.nullTag,o.trueTag,o.falseTag,c.intBin,c.intOct,c.int,c.intHex,s.floatNaN,s.floatExp,s.float,a.binary,l.merge,u.omap,d.pairs,f.set,p.intTime,p.floatTime,p.timestamp]})),Uu=j((e=>{var t=Cu(),n=Du(),r=Tu(),i=Eu(),a=Ou(),o=Au(),s=ju(),c=Mu(),l=Nu(),u=Pu(),d=vu(),f=Iu(),p=Fu(),m=Hu(),h=Bu(),g=Vu();let _=new Map([[`core`,c.schema],[`failsafe`,[t.map,r.seq,i.string]],[`json`,l.schema],[`yaml11`,m.schema],[`yaml-1.1`,m.schema]]),v={binary:u.binary,bool:a.boolTag,float:o.float,floatExp:o.floatExp,floatNaN:o.floatNaN,floatTime:g.floatTime,int:s.int,intHex:s.intHex,intOct:s.intOct,intTime:g.intTime,map:t.map,merge:d.merge,null:n.nullTag,omap:f.omap,pairs:p.pairs,seq:r.seq,set:h.set,timestamp:g.timestamp},y={"tag:yaml.org,2002:binary":u.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":f.omap,"tag:yaml.org,2002:pairs":p.pairs,"tag:yaml.org,2002:set":h.set,"tag:yaml.org,2002:timestamp":g.timestamp};function b(e,t,n){let r=_.get(t);if(r&&!e)return n&&!r.includes(d.merge)?r.concat(d.merge):r.slice();let i=r;if(!i)if(Array.isArray(e))i=[];else{let e=Array.from(_.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(d.merge)),i.reduce((e,t)=>{let n=typeof t==`string`?v[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(v).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}e.coreKnownTags=y,e.getTags=b})),Wu=j((e=>{var t=Q(),n=Cu(),r=Tu(),i=Eu(),a=Uu();let o=(e,t)=>e.key<t.key?-1:+(e.key>t.key);e.Schema=class e{constructor({compat:e,customTags:s,merge:c,resolveKnownTags:l,schema:u,sortMapEntries:d,toStringDefaults:f}){this.compat=Array.isArray(e)?a.getTags(e,`compat`):e?a.getTags(null,e):null,this.name=typeof u==`string`&&u||`core`,this.knownTags=l?a.coreKnownTags:{},this.tags=a.getTags(s,this.name,c),this.toStringOptions=f??null,Object.defineProperty(this,t.MAP,{value:n.map}),Object.defineProperty(this,t.SCALAR,{value:i.string}),Object.defineProperty(this,t.SEQ,{value:r.seq}),this.sortMapEntries=typeof d==`function`?d:d===!0?o:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}}})),Gu=j((e=>{var t=Q(),n=hu(),r=fu();function i(e,i){let a=[],o=i.directives===!0;if(i.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(a.push(t),o=!0):e.directives.docStart&&(o=!0)}o&&a.push(`---`);let s=n.createStringifyContext(e,i),{commentString:c}=s.options;if(e.commentBefore){a.length!==1&&a.unshift(``);let t=c(e.commentBefore);a.unshift(r.indentComment(t,``))}let l=!1,u=null;if(e.contents){if(t.isNode(e.contents)){if(e.contents.spaceBefore&&o&&a.push(``),e.contents.commentBefore){let t=c(e.contents.commentBefore);a.push(r.indentComment(t,``))}s.forceBlockIndent=!!e.comment,u=e.contents.comment}let i=u?void 0:()=>l=!0,d=n.stringify(e.contents,s,()=>u=null,i);u&&(d+=r.lineComment(d,``,c(u))),(d[0]===`|`||d[0]===`>`)&&a[a.length-1]===`---`?a[a.length-1]=`--- ${d}`:a.push(d)}else a.push(n.stringify(e.contents,s));if(e.directives?.docEnd)if(e.comment){let t=c(e.comment);t.includes(`
206
+ `;return`${e}\n${c}${_}`}else return`${g}${u}${h.join(` `)}${u}${_}`}function s({indent:e,options:{commentString:t}},n,i,a){if(i&&a&&(i=i.replace(/^\n+/,``)),i){let a=r.indentComment(t(i),e);n.push(a.trimStart())}}e.stringifyCollection=i})),Ou=M((e=>{var t=Du(),n=Tu(),r=_u(),i=Q(),a=Eu(),o=$();function s(e,t){let n=i.isScalar(t)?t.value:t;for(let r of e)if(i.isPair(r)&&(r.key===t||r.key===n||i.isScalar(r.key)&&r.key.value===n))return r}e.YAMLMap=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(i.MAP,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,o=new this(e),s=(e,s)=>{if(typeof i==`function`)s=i.call(t,e,s);else if(Array.isArray(i)&&!i.includes(e))return;(s!==void 0||r)&&o.items.push(a.createPair(e,s,n))};if(t instanceof Map)for(let[e,n]of t)s(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))s(e,t[e]);return typeof e.sortMapEntries==`function`&&o.items.sort(e.sortMapEntries),o}add(e,t){let n;n=i.isPair(e)?e:!e||typeof e!=`object`||!(`key`in e)?new a.Pair(e,e?.value):new a.Pair(e.key,e.value);let r=s(this.items,n.key),c=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);i.isScalar(r.value)&&o.isScalarValue(n.value)?r.value.value=n.value:r.value=n.value}else if(c){let e=this.items.findIndex(e=>c(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=s(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=s(this.items,e)?.value;return(!t&&i.isScalar(n)?n.value:n)??void 0}has(e){return!!s(this.items,e)}set(e,t){this.add(new a.Pair(e,t),!0)}toJSON(e,t,r){let i=r?new r:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(i);for(let e of this.items)n.addPairToJSMap(t,i,e);return i}toString(e,n,r){if(!e)return JSON.stringify(this);for(let e of this.items)if(!i.isPair(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),t.stringifyCollection(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:r,onComment:n})}},e.findPair=s})),ku=M((e=>{var t=Q(),n=Ou();e.map={collection:`map`,default:!0,nodeClass:n.YAMLMap,tag:`tag:yaml.org,2002:map`,resolve(e,n){return t.isMap(e)||n(`Expected a mapping for this tag`),e},createNode:(e,t,r)=>n.YAMLMap.from(e,t,r)}})),Au=M((e=>{var t=gu(),n=Du(),r=_u(),i=Q(),a=$(),o=pu(),s=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(i.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=c(e);return typeof t==`number`?this.items.splice(t,1).length>0:!1}get(e,t){let n=c(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&i.isScalar(r)?r.value:r}has(e){let t=c(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=c(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];i.isScalar(r)&&a.isScalarValue(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(o.toJS(e,String(r++),t));return n}toString(e,t,r){return e?n.stringifyCollection(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,n,r){let{replacer:i}=r,a=new this(e);if(n&&Symbol.iterator in Object(n)){let e=0;for(let o of n){if(typeof i==`function`){let t=n instanceof Set?o:String(e++);o=i.call(n,t,o)}a.items.push(t.createNode(o,void 0,r))}}return a}};function c(e){let t=i.isScalar(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}e.YAMLSeq=s})),ju=M((e=>{var t=Q(),n=Au();e.seq={collection:`seq`,default:!0,nodeClass:n.YAMLSeq,tag:`tag:yaml.org,2002:seq`,resolve(e,n){return t.isSeq(e)||n(`Expected a sequence for this tag`),e},createNode:(e,t,r)=>n.YAMLSeq.from(e,t,r)}})),Mu=M((e=>{var t=bu();e.string={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,n,r,i){return n=Object.assign({actualString:!0},n),t.stringifyString(e,n,r,i)}}})),Nu=M((e=>{var t=$();let n={identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new t.Scalar(null),stringify:({source:e},t)=>typeof e==`string`&&n.test.test(e)?e:t.options.nullStr};e.nullTag=n})),Pu=M((e=>{var t=$();let n={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new t.Scalar(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},r){return e&&n.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?r.options.trueStr:r.options.falseStr}};e.boolTag=n})),Fu=M((e=>{function t({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^\d/.test(a)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-- >0;)a+=`0`}return a}e.stringifyNumber=t})),Iu=M((e=>{var t=$(),n=Fu();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let n=new t.Scalar(parseFloat(e)),r=e.indexOf(`.`);return r!==-1&&e[e.length-1]===`0`&&(n.minFractionDigits=e.length-r-1),n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),Lu=M((e=>{var t=Fu();let n=e=>typeof e==`bigint`||Number.isInteger(e),r=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function i(e,r,i){let{value:a}=e;return n(a)&&a>=0?i+a.toString(r):t.stringifyNumber(e)}e.int={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},e.intHex={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)},e.intOct={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>r(e,2,8,n),stringify:e=>i(e,8,`0o`)}})),Ru=M((e=>{var t=ku(),n=Nu(),r=ju(),i=Mu(),a=Pu(),o=Iu(),s=Lu();e.schema=[t.map,r.seq,i.string,n.nullTag,a.boolTag,s.intOct,s.int,s.intHex,o.floatNaN,o.floatExp,o.float]})),zu=M((e=>{var t=$(),n=ku(),r=ju();function i(e){return typeof e==`bigint`||Number.isInteger(e)}let a=({value:e})=>JSON.stringify(e),o=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:a},{identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:a},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:a},{identify:i,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>i(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:a}];e.schema=[n.map,r.seq].concat(o,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}})})),Bu=M((e=>{var t=tt(`buffer`),n=$(),r=bu();e.binary={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,n){if(typeof t.Buffer==`function`)return t.Buffer.from(e,`base64`);if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}else return n(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:i,value:a},o,s,c){if(!a)return``;let l=a,u;if(typeof t.Buffer==`function`)u=l instanceof t.Buffer?l.toString(`base64`):t.Buffer.from(l.buffer).toString(`base64`);else if(typeof btoa==`function`){let e=``;for(let t=0;t<l.length;++t)e+=String.fromCharCode(l[t]);u=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(i??=n.Scalar.BLOCK_LITERAL,i!==n.Scalar.QUOTE_DOUBLE){let e=Math.max(o.options.lineWidth-o.indent.length,o.options.minContentWidth),t=Math.ceil(u.length/e),r=Array(t);for(let n=0,i=0;n<t;++n,i+=e)r[n]=u.substr(i,e);u=r.join(i===n.Scalar.BLOCK_LITERAL?`
207
+ `:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),Vu=M((e=>{var t=Q(),n=Eu(),r=$(),i=Au();function a(e,i){if(t.isSeq(e))for(let a=0;a<e.items.length;++a){let o=e.items[a];if(!t.isPair(o)){if(t.isMap(o)){o.items.length>1&&i(`Each pair must have its own sequence indicator`);let e=o.items[0]||new n.Pair(new r.Scalar(null));if(o.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${o.commentBefore}\n${e.key.commentBefore}`:o.commentBefore),o.comment){let t=e.value??e.key;t.comment=t.comment?`${o.comment}\n${t.comment}`:o.comment}o=e}e.items[a]=t.isPair(o)?o:new n.Pair(o)}}else i(`Expected a sequence for this tag`);return e}function o(e,t,r){let{replacer:a}=r,o=new i.YAMLSeq(e);o.tag=`tag:yaml.org,2002:pairs`;let s=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof a==`function`&&(e=a.call(t,String(s++),e));let i,c;if(Array.isArray(e))if(e.length===2)i=e[0],c=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`);else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)i=t[0],c=e[i];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else i=e;o.items.push(n.createPair(i,c,r))}return o}let s={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:a,createNode:o};e.createPairs=o,e.pairs=s,e.resolvePairs=a})),Hu=M((e=>{var t=Q(),n=pu(),r=Ou(),i=Au(),a=Vu(),o=class e extends i.YAMLSeq{constructor(){super(),this.add=r.YAMLMap.prototype.add.bind(this),this.delete=r.YAMLMap.prototype.delete.bind(this),this.get=r.YAMLMap.prototype.get.bind(this),this.has=r.YAMLMap.prototype.has.bind(this),this.set=r.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=new Map;r?.onCreate&&r.onCreate(i);for(let e of this.items){let a,o;if(t.isPair(e)?(a=n.toJS(e.key,``,r),o=n.toJS(e.value,a,r)):a=n.toJS(e,``,r),i.has(a))throw Error(`Ordered maps must not include duplicate keys`);i.set(a,o)}return i}static from(e,t,n){let r=a.createPairs(e,t,n),i=new this;return i.items=r.items,i}};o.tag=`tag:yaml.org,2002:omap`;let s={collection:`seq`,identify:e=>e instanceof Map,nodeClass:o,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,n){let r=a.resolvePairs(e,n),i=[];for(let{key:e}of r.items)t.isScalar(e)&&(i.includes(e.value)?n(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new o,r)},createNode:(e,t,n)=>o.from(e,t,n)};e.YAMLOMap=o,e.omap=s})),Uu=M((e=>{var t=$();function n({value:e,source:t},n){return t&&(e?r:i).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}let r={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new t.Scalar(!0),stringify:n},i={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new t.Scalar(!1),stringify:n};e.falseTag=i,e.trueTag=r})),Wu=M((e=>{var t=$(),n=Fu();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let n=new t.Scalar(parseFloat(e.replace(/_/g,``))),r=e.indexOf(`.`);if(r!==-1){let t=e.substring(r+1).replace(/_/g,``);t[t.length-1]===`0`&&(n.minFractionDigits=t.length)}return n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),Gu=M((e=>{var t=Fu();let n=e=>typeof e==`bigint`||Number.isInteger(e);function r(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function i(e,r,i){let{value:a}=e;if(n(a)){let e=a.toString(r);return a<0?`-`+i+e.substr(1):i+e}return t.stringifyNumber(e)}let a={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>r(e,2,2,n),stringify:e=>i(e,2,`0b`)},o={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>r(e,1,8,n),stringify:e=>i(e,8,`0`)},s={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},c={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)};e.int=s,e.intBin=a,e.intHex=c,e.intOct=o})),Ku=M((e=>{var t=Q(),n=Eu(),r=Ou(),i=class e extends r.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(e){let i;i=t.isPair(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new n.Pair(e.key,null):new n.Pair(e,null),r.findPair(this.items,i.key)||this.items.push(i)}get(e,n){let i=r.findPair(this.items,e);return!n&&t.isPair(i)?t.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=r.findPair(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new n.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,r){let{replacer:i}=r,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof i==`function`&&(e=i.call(t,e,e)),a.items.push(n.createPair(e,null,r));return a}};i.tag=`tag:yaml.org,2002:set`;let a={collection:`map`,identify:e=>e instanceof Set,nodeClass:i,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>i.from(e,t,n),resolve(e,n){if(t.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new i,e);n(`Set items must all have null values`)}else n(`Expected a mapping for this tag`);return e}};e.YAMLSet=i,e.set=a})),qu=M((e=>{var t=Fu();function n(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function r(e){let{value:n}=e,r=e=>e;if(typeof n==`bigint`)r=e=>BigInt(e);else if(isNaN(n)||!isFinite(n))return t.stringifyNumber(e);let i=``;n<0&&(i=`-`,n*=r(-1));let a=r(60),o=[n%a];return n<60?o.unshift(0):(n=(n-o[0])/a,o.unshift(n%a),n>=60&&(n=(n-o[0])/a,o.unshift(n))),i+o.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}let i={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>n(e,r),stringify:r},a={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>n(e,!1),stringify:r},o={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(o.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,r,i,a,s,c,l]=t.map(Number),u=t[7]?Number((t[7]+`00`).substr(1,3)):0,d=Date.UTC(r,i-1,a,s||0,c||0,l||0,u),f=t[8];if(f&&f!==`Z`){let e=n(f,!1);Math.abs(e)<30&&(e*=60),d-=6e4*e}return new Date(d)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``};e.floatTime=a,e.intTime=i,e.timestamp=o})),Ju=M((e=>{var t=ku(),n=Nu(),r=ju(),i=Mu(),a=Bu(),o=Uu(),s=Wu(),c=Gu(),l=wu(),u=Hu(),d=Vu(),f=Ku(),p=qu();e.schema=[t.map,r.seq,i.string,n.nullTag,o.trueTag,o.falseTag,c.intBin,c.intOct,c.int,c.intHex,s.floatNaN,s.floatExp,s.float,a.binary,l.merge,u.omap,d.pairs,f.set,p.intTime,p.floatTime,p.timestamp]})),Yu=M((e=>{var t=ku(),n=Nu(),r=ju(),i=Mu(),a=Pu(),o=Iu(),s=Lu(),c=Ru(),l=zu(),u=Bu(),d=wu(),f=Hu(),p=Vu(),m=Ju(),h=Ku(),g=qu();let _=new Map([[`core`,c.schema],[`failsafe`,[t.map,r.seq,i.string]],[`json`,l.schema],[`yaml11`,m.schema],[`yaml-1.1`,m.schema]]),v={binary:u.binary,bool:a.boolTag,float:o.float,floatExp:o.floatExp,floatNaN:o.floatNaN,floatTime:g.floatTime,int:s.int,intHex:s.intHex,intOct:s.intOct,intTime:g.intTime,map:t.map,merge:d.merge,null:n.nullTag,omap:f.omap,pairs:p.pairs,seq:r.seq,set:h.set,timestamp:g.timestamp},y={"tag:yaml.org,2002:binary":u.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":f.omap,"tag:yaml.org,2002:pairs":p.pairs,"tag:yaml.org,2002:set":h.set,"tag:yaml.org,2002:timestamp":g.timestamp};function b(e,t,n){let r=_.get(t);if(r&&!e)return n&&!r.includes(d.merge)?r.concat(d.merge):r.slice();let i=r;if(!i)if(Array.isArray(e))i=[];else{let e=Array.from(_.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(d.merge)),i.reduce((e,t)=>{let n=typeof t==`string`?v[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(v).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}e.coreKnownTags=y,e.getTags=b})),Xu=M((e=>{var t=Q(),n=ku(),r=ju(),i=Mu(),a=Yu();let o=(e,t)=>e.key<t.key?-1:+(e.key>t.key);e.Schema=class e{constructor({compat:e,customTags:s,merge:c,resolveKnownTags:l,schema:u,sortMapEntries:d,toStringDefaults:f}){this.compat=Array.isArray(e)?a.getTags(e,`compat`):e?a.getTags(null,e):null,this.name=typeof u==`string`&&u||`core`,this.knownTags=l?a.coreKnownTags:{},this.tags=a.getTags(s,this.name,c),this.toStringOptions=f??null,Object.defineProperty(this,t.MAP,{value:n.map}),Object.defineProperty(this,t.SCALAR,{value:i.string}),Object.defineProperty(this,t.SEQ,{value:r.seq}),this.sortMapEntries=typeof d==`function`?d:d===!0?o:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}}})),Zu=M((e=>{var t=Q(),n=xu(),r=vu();function i(e,i){let a=[],o=i.directives===!0;if(i.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(a.push(t),o=!0):e.directives.docStart&&(o=!0)}o&&a.push(`---`);let s=n.createStringifyContext(e,i),{commentString:c}=s.options;if(e.commentBefore){a.length!==1&&a.unshift(``);let t=c(e.commentBefore);a.unshift(r.indentComment(t,``))}let l=!1,u=null;if(e.contents){if(t.isNode(e.contents)){if(e.contents.spaceBefore&&o&&a.push(``),e.contents.commentBefore){let t=c(e.contents.commentBefore);a.push(r.indentComment(t,``))}s.forceBlockIndent=!!e.comment,u=e.contents.comment}let i=u?void 0:()=>l=!0,d=n.stringify(e.contents,s,()=>u=null,i);u&&(d+=r.lineComment(d,``,c(u))),(d[0]===`|`||d[0]===`>`)&&a[a.length-1]===`---`?a[a.length-1]=`--- ${d}`:a.push(d)}else a.push(n.stringify(e.contents,s));if(e.directives?.docEnd)if(e.comment){let t=c(e.comment);t.includes(`
207
208
  `)?(a.push(`...`),a.push(r.indentComment(t,``))):a.push(`... ${t}`)}else a.push(`...`);else{let t=e.comment;t&&l&&(t=t.replace(/^\n+/,``)),t&&((!l||u)&&a[a.length-1]!==``&&a.push(``),a.push(r.indentComment(c(t),``)))}return a.join(`
208
209
  `)+`
209
- `}e.stringifyDocument=i})),Ku=j((e=>{var t=lu(),n=du(),r=Q(),i=bu(),a=su(),o=Wu(),s=Gu(),c=au(),l=ou(),u=uu(),d=iu(),f=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,r.NODE_TYPE,{value:r.DOC});let i=null;typeof t==`function`||Array.isArray(t)?i=t:n===void 0&&t&&(n=t,t=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=a;let{version:o}=a;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new d.Directives({version:o}),this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,i,n)}clone(){let t=Object.create(e.prototype,{[r.NODE_TYPE]:{value:r.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=r.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){p(this.contents)&&this.contents.add(e)}addIn(e,t){p(this.contents)&&this.contents.addIn(e,t)}createAlias(e,n){if(!e.anchor){let t=c.anchorNames(this);e.anchor=!n||t.has(n)?c.findNewAnchor(n||`a`,t):n}return new t.Alias(e.anchor)}createNode(e,t,n){let i;if(typeof t==`function`)e=t.call({"":e},``,e),i=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),i=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:l,onTagObj:d,tag:f}=n??{},{onAnchor:p,setAnchors:m,sourceObjects:h}=c.createNodeAnchors(this,o||`a`),g={aliasDuplicateObjects:a??!0,keepUndefined:l??!1,onAnchor:p,onTagObj:d,replacer:i,schema:this.schema,sourceObjects:h},_=u.createNode(e,f,g);return s&&r.isCollection(_)&&(_.flow=!0),m(),_}createPair(e,t,n={}){let r=this.createNode(e,null,n),a=this.createNode(t,null,n);return new i.Pair(r,a)}delete(e){return p(this.contents)?this.contents.delete(e):!1}deleteIn(e){return n.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):p(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return r.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return n.isEmptyPath(e)?!t&&r.isScalar(this.contents)?this.contents.value:this.contents:r.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return r.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return n.isEmptyPath(e)?this.contents!==void 0:r.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=n.collectionFromPath(this.schema,[e],t):p(this.contents)&&this.contents.set(e,t)}setIn(e,t){n.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=n.collectionFromPath(this.schema,Array.from(e),t):p(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new d.Directives({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new d.Directives({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new o.Schema(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},c=a.toJS(this.contents,t??``,s);if(typeof i==`function`)for(let{count:e,res:t}of s.anchors.values())i(t,e);return typeof o==`function`?l.applyReviver(o,{"":c},``,c):c}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return s.stringifyDocument(this,e)}};function p(e){if(r.isCollection(e))return!0;throw Error(`Expected a YAML collection as document contents`)}e.Document=f})),qu=j((e=>{var t=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},n=class extends t{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},r=class extends t{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}};e.YAMLError=t,e.YAMLParseError=n,e.YAMLWarning=r,e.prettifyError=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
210
- `),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}}})),Ju=j((e=>{function t(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}e.resolveProps=t})),Yu=j((e=>{function t(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
211
- `))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let n of e.items){for(let e of n.start)if(e.type===`newline`)return!0;if(n.sep){for(let e of n.sep)if(e.type===`newline`)return!0}if(t(n.key)||t(n.value))return!0}return!1;default:return!0}}e.containsNewline=t})),Xu=j((e=>{var t=Yu();function n(e,n,r){if(n?.type===`flow-collection`){let i=n.end[0];i.indent===e&&(i.source===`]`||i.source===`}`)&&t.containsNewline(n)&&r(i,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}e.flowIndentCheck=n})),Zu=j((e=>{var t=Q();function n(e,n,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let a=typeof i==`function`?i:(e,n)=>e===n||t.isScalar(e)&&t.isScalar(n)&&e.value===n.value;return n.some(e=>a(e.key,r))}e.mapIncludes=n})),Qu=j((e=>{var t=bu(),n=Su(),r=Ju(),i=Yu(),a=Xu(),o=Zu();let s=`All mapping items must start at the same column`;function c({composeNode:e,composeEmptyNode:c},l,u,d,f){let p=new(f?.nodeClass??n.YAMLMap)(l.schema);l.atRoot&&=!1;let m=u.offset,h=null;for(let n of u.items){let{start:f,key:g,sep:_,value:v}=n,y=r.resolveProps(f,{indicator:`explicit-key-ind`,next:g??_?.[0],offset:m,onError:d,parentIndent:u.indent,startOnNewline:!0}),b=!y.found;if(b){if(g&&(g.type===`block-seq`?d(m,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in g&&g.indent!==u.indent&&d(m,`BAD_INDENT`,s)),!y.anchor&&!y.tag&&!_){h=y.end,y.comment&&(p.comment?p.comment+=`
210
+ `}e.stringifyDocument=i})),Qu=M((e=>{var t=hu(),n=_u(),r=Q(),i=Eu(),a=pu(),o=Xu(),s=Zu(),c=du(),l=fu(),u=gu(),d=uu(),f=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,r.NODE_TYPE,{value:r.DOC});let i=null;typeof t==`function`||Array.isArray(t)?i=t:n===void 0&&t&&(n=t,t=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=a;let{version:o}=a;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new d.Directives({version:o}),this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,i,n)}clone(){let t=Object.create(e.prototype,{[r.NODE_TYPE]:{value:r.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=r.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){p(this.contents)&&this.contents.add(e)}addIn(e,t){p(this.contents)&&this.contents.addIn(e,t)}createAlias(e,n){if(!e.anchor){let t=c.anchorNames(this);e.anchor=!n||t.has(n)?c.findNewAnchor(n||`a`,t):n}return new t.Alias(e.anchor)}createNode(e,t,n){let i;if(typeof t==`function`)e=t.call({"":e},``,e),i=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),i=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:l,onTagObj:d,tag:f}=n??{},{onAnchor:p,setAnchors:m,sourceObjects:h}=c.createNodeAnchors(this,o||`a`),g={aliasDuplicateObjects:a??!0,keepUndefined:l??!1,onAnchor:p,onTagObj:d,replacer:i,schema:this.schema,sourceObjects:h},_=u.createNode(e,f,g);return s&&r.isCollection(_)&&(_.flow=!0),m(),_}createPair(e,t,n={}){let r=this.createNode(e,null,n),a=this.createNode(t,null,n);return new i.Pair(r,a)}delete(e){return p(this.contents)?this.contents.delete(e):!1}deleteIn(e){return n.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):p(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return r.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return n.isEmptyPath(e)?!t&&r.isScalar(this.contents)?this.contents.value:this.contents:r.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return r.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return n.isEmptyPath(e)?this.contents!==void 0:r.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=n.collectionFromPath(this.schema,[e],t):p(this.contents)&&this.contents.set(e,t)}setIn(e,t){n.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=n.collectionFromPath(this.schema,Array.from(e),t):p(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new d.Directives({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new d.Directives({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new o.Schema(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},c=a.toJS(this.contents,t??``,s);if(typeof i==`function`)for(let{count:e,res:t}of s.anchors.values())i(t,e);return typeof o==`function`?l.applyReviver(o,{"":c},``,c):c}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return s.stringifyDocument(this,e)}};function p(e){if(r.isCollection(e))return!0;throw Error(`Expected a YAML collection as document contents`)}e.Document=f})),$u=M((e=>{var t=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},n=class extends t{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},r=class extends t{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}};e.YAMLError=t,e.YAMLParseError=n,e.YAMLWarning=r,e.prettifyError=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
211
+ `),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}}})),ed=M((e=>{function t(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}e.resolveProps=t})),td=M((e=>{function t(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
212
+ `))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let n of e.items){for(let e of n.start)if(e.type===`newline`)return!0;if(n.sep){for(let e of n.sep)if(e.type===`newline`)return!0}if(t(n.key)||t(n.value))return!0}return!1;default:return!0}}e.containsNewline=t})),nd=M((e=>{var t=td();function n(e,n,r){if(n?.type===`flow-collection`){let i=n.end[0];i.indent===e&&(i.source===`]`||i.source===`}`)&&t.containsNewline(n)&&r(i,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}e.flowIndentCheck=n})),rd=M((e=>{var t=Q();function n(e,n,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let a=typeof i==`function`?i:(e,n)=>e===n||t.isScalar(e)&&t.isScalar(n)&&e.value===n.value;return n.some(e=>a(e.key,r))}e.mapIncludes=n})),id=M((e=>{var t=Eu(),n=Ou(),r=ed(),i=td(),a=nd(),o=rd();let s=`All mapping items must start at the same column`;function c({composeNode:e,composeEmptyNode:c},l,u,d,f){let p=new(f?.nodeClass??n.YAMLMap)(l.schema);l.atRoot&&=!1;let m=u.offset,h=null;for(let n of u.items){let{start:f,key:g,sep:_,value:v}=n,y=r.resolveProps(f,{indicator:`explicit-key-ind`,next:g??_?.[0],offset:m,onError:d,parentIndent:u.indent,startOnNewline:!0}),b=!y.found;if(b){if(g&&(g.type===`block-seq`?d(m,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in g&&g.indent!==u.indent&&d(m,`BAD_INDENT`,s)),!y.anchor&&!y.tag&&!_){h=y.end,y.comment&&(p.comment?p.comment+=`
212
213
  `+y.comment:p.comment=y.comment);continue}(y.newlineAfterProp||i.containsNewline(g))&&d(g??f[f.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else y.found?.indent!==u.indent&&d(m,`BAD_INDENT`,s);l.atKey=!0;let x=y.end,S=g?e(l,g,y,d):c(l,x,f,null,y,d);l.schema.compat&&a.flowIndentCheck(u.indent,g,d),l.atKey=!1,o.mapIncludes(l,p.items,S)&&d(x,`DUPLICATE_KEY`,`Map keys must be unique`);let C=r.resolveProps(_??[],{indicator:`map-value-ind`,next:v,offset:S.range[2],onError:d,parentIndent:u.indent,startOnNewline:!g||g.type===`block-scalar`});if(m=C.end,C.found){b&&(v?.type===`block-map`&&!C.hasNewline&&d(m,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),l.options.strict&&y.start<C.found.offset-1024&&d(S.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let r=v?e(l,v,C,d):c(l,m,_,null,C,d);l.schema.compat&&a.flowIndentCheck(u.indent,v,d),m=r.range[2];let i=new t.Pair(S,r);l.options.keepSourceTokens&&(i.srcToken=n),p.items.push(i)}else{b&&d(S.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),C.comment&&(S.comment?S.comment+=`
213
- `+C.comment:S.comment=C.comment);let e=new t.Pair(S);l.options.keepSourceTokens&&(e.srcToken=n),p.items.push(e)}}return h&&h<m&&d(h,`IMPOSSIBLE`,`Map comment with trailing content`),p.range=[u.offset,m,h??m],p}e.resolveBlockMap=c})),$u=j((e=>{var t=wu(),n=Ju(),r=Xu();function i({composeNode:e,composeEmptyNode:i},a,o,s,c){let l=new(c?.nodeClass??t.YAMLSeq)(a.schema);a.atRoot&&=!1,a.atKey&&=!1;let u=o.offset,d=null;for(let{start:t,value:c}of o.items){let f=n.resolveProps(t,{indicator:`seq-item-ind`,next:c,offset:u,onError:s,parentIndent:o.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||c)c?.type===`block-seq`?s(f.end,`BAD_INDENT`,`All sequence items must start at the same column`):s(u,`MISSING_CHAR`,`Sequence item without - indicator`);else{d=f.end,f.comment&&(l.comment=f.comment);continue}let p=c?e(a,c,f,s):i(a,f.end,t,null,f,s);a.schema.compat&&r.flowIndentCheck(o.indent,c,s),u=p.range[2],l.items.push(p)}return l.range=[o.offset,u,d??u],l}e.resolveBlockSeq=i})),ed=j((e=>{function t(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}e.resolveEnd=t})),td=j((e=>{var t=Q(),n=bu(),r=Su(),i=wu(),a=ed(),o=Ju(),s=Yu(),c=Zu();let l=`Block collections are not allowed within flow collections`,u=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function d({composeNode:e,composeEmptyNode:d},f,p,m,h){let g=p.start.source===`{`,_=g?`flow map`:`flow sequence`,v=new(h?.nodeClass??(g?r.YAMLMap:i.YAMLSeq))(f.schema);v.flow=!0;let y=f.atRoot;y&&(f.atRoot=!1),f.atKey&&=!1;let b=p.offset+p.start.source.length;for(let i=0;i<p.items.length;++i){let a=p.items[i],{start:h,key:y,sep:x,value:S}=a,C=o.resolveProps(h,{flow:_,indicator:`explicit-key-ind`,next:y??x?.[0],offset:b,onError:m,parentIndent:p.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!x&&!S){i===0&&C.comma?m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`):i<p.items.length-1&&m(C.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${_}`),C.comment&&(v.comment?v.comment+=`
214
+ `+C.comment:S.comment=C.comment);let e=new t.Pair(S);l.options.keepSourceTokens&&(e.srcToken=n),p.items.push(e)}}return h&&h<m&&d(h,`IMPOSSIBLE`,`Map comment with trailing content`),p.range=[u.offset,m,h??m],p}e.resolveBlockMap=c})),ad=M((e=>{var t=Au(),n=ed(),r=nd();function i({composeNode:e,composeEmptyNode:i},a,o,s,c){let l=new(c?.nodeClass??t.YAMLSeq)(a.schema);a.atRoot&&=!1,a.atKey&&=!1;let u=o.offset,d=null;for(let{start:t,value:c}of o.items){let f=n.resolveProps(t,{indicator:`seq-item-ind`,next:c,offset:u,onError:s,parentIndent:o.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||c)c?.type===`block-seq`?s(f.end,`BAD_INDENT`,`All sequence items must start at the same column`):s(u,`MISSING_CHAR`,`Sequence item without - indicator`);else{d=f.end,f.comment&&(l.comment=f.comment);continue}let p=c?e(a,c,f,s):i(a,f.end,t,null,f,s);a.schema.compat&&r.flowIndentCheck(o.indent,c,s),u=p.range[2],l.items.push(p)}return l.range=[o.offset,u,d??u],l}e.resolveBlockSeq=i})),od=M((e=>{function t(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}e.resolveEnd=t})),sd=M((e=>{var t=Q(),n=Eu(),r=Ou(),i=Au(),a=od(),o=ed(),s=td(),c=rd();let l=`Block collections are not allowed within flow collections`,u=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function d({composeNode:e,composeEmptyNode:d},f,p,m,h){let g=p.start.source===`{`,_=g?`flow map`:`flow sequence`,v=new(h?.nodeClass??(g?r.YAMLMap:i.YAMLSeq))(f.schema);v.flow=!0;let y=f.atRoot;y&&(f.atRoot=!1),f.atKey&&=!1;let b=p.offset+p.start.source.length;for(let i=0;i<p.items.length;++i){let a=p.items[i],{start:h,key:y,sep:x,value:S}=a,C=o.resolveProps(h,{flow:_,indicator:`explicit-key-ind`,next:y??x?.[0],offset:b,onError:m,parentIndent:p.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!x&&!S){i===0&&C.comma?m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`):i<p.items.length-1&&m(C.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${_}`),C.comment&&(v.comment?v.comment+=`
214
215
  `+C.comment:v.comment=C.comment),b=C.end;continue}!g&&f.options.strict&&s.containsNewline(y)&&m(y,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(i===0)C.comma&&m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`);else if(C.comma||m(C.start,`MISSING_CHAR`,`Missing , between ${_} items`),C.comment){let e=``;loop:for(let t of h)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let n=v.items[v.items.length-1];t.isPair(n)&&(n=n.value??n.key),n.comment?n.comment+=`
215
216
  `+e:n.comment=e,C.comment=C.comment.substring(e.length+1)}}if(!g&&!x&&!C.found){let t=S?e(f,S,C,m):d(f,C.end,x,null,C,m);v.items.push(t),b=t.range[2],u(S)&&m(t.range,`BLOCK_IN_FLOW`,l)}else{f.atKey=!0;let t=C.end,i=y?e(f,y,C,m):d(f,t,h,null,C,m);u(y)&&m(i.range,`BLOCK_IN_FLOW`,l),f.atKey=!1;let s=o.resolveProps(x??[],{flow:_,indicator:`map-value-ind`,next:S,offset:i.range[2],onError:m,parentIndent:p.indent,startOnNewline:!1});if(s.found){if(!g&&!C.found&&f.options.strict){if(x)for(let e of x){if(e===s.found)break;if(e.type===`newline`){m(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}C.start<s.found.offset-1024&&m(s.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else S&&(`source`in S&&S.source?.[0]===`:`?m(S,`MISSING_CHAR`,`Missing space after : in ${_}`):m(s.start,`MISSING_CHAR`,`Missing , or : between ${_} items`));let w=S?e(f,S,s,m):s.found?d(f,s.end,x,null,s,m):null;w?u(S)&&m(w.range,`BLOCK_IN_FLOW`,l):s.comment&&(i.comment?i.comment+=`
216
217
  `+s.comment:i.comment=s.comment);let T=new n.Pair(i,w);if(f.options.keepSourceTokens&&(T.srcToken=a),g){let e=v;c.mapIncludes(f,e.items,i)&&m(t,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(T)}else{let e=new r.YAMLMap(f.schema);e.flow=!0,e.items.push(T);let t=(w??i).range;e.range=[i.range[0],t[1],t[2]],v.items.push(e)}b=w?w.range[2]:s.end}}let x=g?`}`:`]`,[S,...C]=p.end,w=b;if(S?.source===x)w=S.offset+S.source.length;else{let e=_[0].toUpperCase()+_.substring(1),t=y?`${e} must end with a ${x}`:`${e} in block collection must be sufficiently indented and end with a ${x}`;m(b,y?`MISSING_CHAR`:`BAD_INDENT`,t),S&&S.source.length!==1&&C.unshift(S)}if(C.length>0){let e=a.resolveEnd(C,w,f.options.strict,m);e.comment&&(v.comment?v.comment+=`
217
- `+e.comment:v.comment=e.comment),v.range=[p.offset,w,e.offset]}else v.range=[p.offset,w,w];return v}e.resolveFlowCollection=d})),nd=j((e=>{var t=Q(),n=$(),r=Su(),i=wu(),a=Qu(),o=$u(),s=td();function c(e,t,n,r,i,c){let l=n.type===`block-map`?a.resolveBlockMap(e,t,n,r,c):n.type===`block-seq`?o.resolveBlockSeq(e,t,n,r,c):s.resolveFlowCollection(e,t,n,r,c),u=l.constructor;return i===`!`||i===u.tagName?(l.tag=u.tagName,l):(i&&(l.tag=i),l)}function l(e,a,o,s,l){let u=s.tag,d=u?a.directives.tagName(u.source,e=>l(u,`TAG_RESOLVE_FAILED`,e)):null;if(o.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=s,n=e&&u?e.offset>u.offset?e:u:e??u;n&&(!t||t.offset<n.offset)&&l(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let f=o.type===`block-map`?`map`:o.type===`block-seq`?`seq`:o.start.source===`{`?`map`:`seq`;if(!u||!d||d===`!`||d===r.YAMLMap.tagName&&f===`map`||d===i.YAMLSeq.tagName&&f===`seq`)return c(e,a,o,l,d);let p=a.schema.tags.find(e=>e.tag===d&&e.collection===f);if(!p){let t=a.schema.knownTags[d];if(t?.collection===f)a.schema.tags.push(Object.assign({},t,{default:!1})),p=t;else return t?l(u,`BAD_COLLECTION_TYPE`,`${t.tag} used for ${f} collection, but expects ${t.collection??`scalar`}`,!0):l(u,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${d}`,!0),c(e,a,o,l,d)}let m=c(e,a,o,l,d,p),h=p.resolve?.(m,e=>l(u,`TAG_RESOLVE_FAILED`,e),a.options)??m,g=t.isNode(h)?h:new n.Scalar(h);return g.range=m.range,g.tag=d,p?.format&&(g.format=p.format),g}e.composeCollection=l})),rd=j((e=>{var t=$();function n(e,n,a){let o=n.offset,s=r(n,e.options.strict,a);if(!s)return{value:``,type:null,comment:``,range:[o,o,o]};let c=s.mode===`>`?t.Scalar.BLOCK_FOLDED:t.Scalar.BLOCK_LITERAL,l=n.source?i(n.source):[],u=l.length;for(let e=l.length-1;e>=0;--e){let t=l[e][1];if(t===``||t===`\r`)u=e;else break}if(u===0){let e=s.chomp===`+`&&l.length>0?`
218
+ `+e.comment:v.comment=e.comment),v.range=[p.offset,w,e.offset]}else v.range=[p.offset,w,w];return v}e.resolveFlowCollection=d})),cd=M((e=>{var t=Q(),n=$(),r=Ou(),i=Au(),a=id(),o=ad(),s=sd();function c(e,t,n,r,i,c){let l=n.type===`block-map`?a.resolveBlockMap(e,t,n,r,c):n.type===`block-seq`?o.resolveBlockSeq(e,t,n,r,c):s.resolveFlowCollection(e,t,n,r,c),u=l.constructor;return i===`!`||i===u.tagName?(l.tag=u.tagName,l):(i&&(l.tag=i),l)}function l(e,a,o,s,l){let u=s.tag,d=u?a.directives.tagName(u.source,e=>l(u,`TAG_RESOLVE_FAILED`,e)):null;if(o.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=s,n=e&&u?e.offset>u.offset?e:u:e??u;n&&(!t||t.offset<n.offset)&&l(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let f=o.type===`block-map`?`map`:o.type===`block-seq`?`seq`:o.start.source===`{`?`map`:`seq`;if(!u||!d||d===`!`||d===r.YAMLMap.tagName&&f===`map`||d===i.YAMLSeq.tagName&&f===`seq`)return c(e,a,o,l,d);let p=a.schema.tags.find(e=>e.tag===d&&e.collection===f);if(!p){let t=a.schema.knownTags[d];if(t?.collection===f)a.schema.tags.push(Object.assign({},t,{default:!1})),p=t;else return t?l(u,`BAD_COLLECTION_TYPE`,`${t.tag} used for ${f} collection, but expects ${t.collection??`scalar`}`,!0):l(u,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${d}`,!0),c(e,a,o,l,d)}let m=c(e,a,o,l,d,p),h=p.resolve?.(m,e=>l(u,`TAG_RESOLVE_FAILED`,e),a.options)??m,g=t.isNode(h)?h:new n.Scalar(h);return g.range=m.range,g.tag=d,p?.format&&(g.format=p.format),g}e.composeCollection=l})),ld=M((e=>{var t=$();function n(e,n,a){let o=n.offset,s=r(n,e.options.strict,a);if(!s)return{value:``,type:null,comment:``,range:[o,o,o]};let c=s.mode===`>`?t.Scalar.BLOCK_FOLDED:t.Scalar.BLOCK_LITERAL,l=n.source?i(n.source):[],u=l.length;for(let e=l.length-1;e>=0;--e){let t=l[e][1];if(t===``||t===`\r`)u=e;else break}if(u===0){let e=s.chomp===`+`&&l.length>0?`
218
219
  `.repeat(Math.max(1,l.length-1)):``,t=o+s.length;return n.source&&(t+=n.source.length),{value:e,type:c,comment:s.comment,range:[o,t,t]}}let d=n.indent+s.indent,f=n.offset+s.length,p=0;for(let t=0;t<u;++t){let[n,r]=l[t];if(r===``||r===`\r`)s.indent===0&&n.length>d&&(d=n.length);else{n.length<d&&a(f+n.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),s.indent===0&&(d=n.length),p=t,d===0&&!e.atRoot&&a(f,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}f+=n.length+r.length+1}for(let e=l.length-1;e>=u;--e)l[e][0].length>d&&(u=e+1);let m=``,h=``,g=!1;for(let e=0;e<p;++e)m+=l[e][0].slice(d)+`
219
220
  `;for(let e=p;e<u;++e){let[n,r]=l[e];f+=n.length+r.length+1;let i=r[r.length-1]===`\r`;if(i&&(r=r.slice(0,-1)),r&&n.length<d){let e=`Block scalar lines must not be less indented than their ${s.indent?`explicit indentation indicator`:`first line`}`;a(f-r.length-(i?2:1),`BAD_INDENT`,e),n=``}c===t.Scalar.BLOCK_LITERAL?(m+=h+n.slice(d)+r,h=`
220
221
  `):n.length>d||r[0]===` `?(h===` `?h=`
@@ -229,7 +230,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
229
230
  `+l[e][0].slice(d);m[m.length-1]!==`
230
231
  `&&(m+=`
231
232
  `);break;default:m+=`
232
- `}let _=o+s.length+n.source.length;return{value:m,type:c,comment:s.comment,range:[o,_,_]}}function r({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function i(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}e.resolveBlockScalar=n})),id=j((e=>{var t=$(),n=ed();function r(e,r,o){let{offset:c,type:l,source:u,end:d}=e,f,p,m=(e,t,n)=>o(c+e,t,n);switch(l){case`scalar`:f=t.Scalar.PLAIN,p=i(u,m);break;case`single-quoted-scalar`:f=t.Scalar.QUOTE_SINGLE,p=a(u,m);break;case`double-quoted-scalar`:f=t.Scalar.QUOTE_DOUBLE,p=s(u,m);break;default:return o(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${l}`),{value:``,type:null,comment:``,range:[c,c+u.length,c+u.length]}}let h=c+u.length,g=n.resolveEnd(d,h,r,o);return{value:p,type:f,comment:g.comment,range:[c,h,g.offset]}}function i(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`;break}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),o(e)}function a(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),o(e.slice(1,-1)).replace(/''/g,`'`)}function o(e){let t,n;try{t=RegExp(`(.*?)(?<![ ])[ ]*\r?
233
+ `}let _=o+s.length+n.source.length;return{value:m,type:c,comment:s.comment,range:[o,_,_]}}function r({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function i(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}e.resolveBlockScalar=n})),ud=M((e=>{var t=$(),n=od();function r(e,r,o){let{offset:c,type:l,source:u,end:d}=e,f,p,m=(e,t,n)=>o(c+e,t,n);switch(l){case`scalar`:f=t.Scalar.PLAIN,p=i(u,m);break;case`single-quoted-scalar`:f=t.Scalar.QUOTE_SINGLE,p=a(u,m);break;case`double-quoted-scalar`:f=t.Scalar.QUOTE_DOUBLE,p=s(u,m);break;default:return o(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${l}`),{value:``,type:null,comment:``,range:[c,c+u.length,c+u.length]}}let h=c+u.length,g=n.resolveEnd(d,h,r,o);return{value:p,type:f,comment:g.comment,range:[c,h,g.offset]}}function i(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`;break}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),o(e)}function a(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),o(e.slice(1,-1)).replace(/''/g,`'`)}function o(e){let t,n;try{t=RegExp(`(.*?)(?<![ ])[ ]*\r?
233
234
  `,`sy`),n=RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
234
235
  `,`sy`)}catch{t=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=t.exec(e);if(!r)return e;let i=r[1],a=` `,o=t.lastIndex;for(n.lastIndex=o;r=n.exec(e);)r[1]===``?a===`
235
236
  `?i+=a:a=`
@@ -244,10 +245,10 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
244
245
  `);)r===`
245
246
  `&&(n+=`
246
247
  `),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}let l={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
247
- `,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function u(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;if(isNaN(a)){let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}return String.fromCodePoint(a)}e.resolveFlowScalar=r})),ad=j((e=>{var t=Q(),n=$(),r=rd(),i=id();function a(e,a,c,l){let{value:u,type:d,comment:f,range:p}=a.type===`block-scalar`?r.resolveBlockScalar(e,a,l):i.resolveFlowScalar(a,e.options.strict,l),m=c?e.directives.tagName(c.source,e=>l(c,`TAG_RESOLVE_FAILED`,e)):null,h;h=e.options.stringKeys&&e.atKey?e.schema[t.SCALAR]:m?o(e.schema,u,m,c,l):a.type===`scalar`?s(e,u,a,l):e.schema[t.SCALAR];let g;try{let r=h.resolve(u,e=>l(c??a,`TAG_RESOLVE_FAILED`,e),e.options);g=t.isScalar(r)?r:new n.Scalar(r)}catch(e){let t=e instanceof Error?e.message:String(e);l(c??a,`TAG_RESOLVE_FAILED`,t),g=new n.Scalar(u)}return g.range=p,g.source=u,d&&(g.type=d),m&&(g.tag=m),h.format&&(g.format=h.format),f&&(g.comment=f),g}function o(e,n,r,i,a){if(r===`!`)return e[t.SCALAR];let o=[];for(let t of e.tags)if(!t.collection&&t.tag===r)if(t.default&&t.test)o.push(t);else return t;for(let e of o)if(e.test?.test(n))return e;let s=e.knownTags[r];return s&&!s.collection?(e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(a(i,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${r}`,r!==`tag:yaml.org,2002:str`),e[t.SCALAR])}function s({atKey:e,directives:n,schema:r},i,a,o){let s=r.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(i))||r[t.SCALAR];if(r.compat){let e=r.compat.find(e=>e.default&&e.test?.test(i))??r[t.SCALAR];s.tag!==e.tag&&o(a,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${n.tagString(s.tag)} or ${n.tagString(e.tag)}`,!0)}return s}e.composeScalar=a})),od=j((e=>{function t(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}e.emptyScalarPosition=t})),sd=j((e=>{var t=lu(),n=Q(),r=nd(),i=ad(),a=ed(),o=od();let s={composeNode:c,composeEmptyNode:l};function c(e,t,a,o){let c=e.atKey,{spaceBefore:d,comment:f,anchor:p,tag:m}=a,h,g=!0;switch(t.type){case`alias`:h=u(e,t,o),(p||m)&&o(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:h=i.composeScalar(e,t,m,o),p&&(h.anchor=p.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{h=r.composeCollection(s,e,t,a,o),p&&(h.anchor=p.source.substring(1))}catch(e){o(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:o(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),g=!1}return h??=l(e,t.offset,void 0,null,a,o),p&&h.anchor===``&&o(p,`BAD_ALIAS`,`Anchor cannot be an empty string`),c&&e.options.stringKeys&&(!n.isScalar(h)||typeof h.value!=`string`||h.tag&&h.tag!==`tag:yaml.org,2002:str`)&&o(m??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),d&&(h.spaceBefore=!0),f&&(t.type===`scalar`&&t.source===``?h.comment=f:h.commentBefore=f),e.options.keepSourceTokens&&g&&(h.srcToken=t),h}function l(e,t,n,r,{spaceBefore:a,comment:s,anchor:c,tag:l,end:u},d){let f={type:`scalar`,offset:o.emptyScalarPosition(t,n,r),indent:-1,source:``},p=i.composeScalar(e,f,l,d);return c&&(p.anchor=c.source.substring(1),p.anchor===``&&d(c,`BAD_ALIAS`,`Anchor cannot be an empty string`)),a&&(p.spaceBefore=!0),s&&(p.comment=s,p.range[2]=u),p}function u({options:e},{offset:n,source:r,end:i},o){let s=new t.Alias(r.substring(1));s.source===``&&o(n,`BAD_ALIAS`,`Alias cannot be an empty string`),s.source.endsWith(`:`)&&o(n+r.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let c=n+r.length,l=a.resolveEnd(i,c,e.strict,o);return s.range=[n,c,l.offset],l.comment&&(s.comment=l.comment),s}e.composeEmptyNode=l,e.composeNode=c})),cd=j((e=>{var t=Ku(),n=sd(),r=ed(),i=Ju();function a(e,a,{offset:o,start:s,value:c,end:l},u){let d=Object.assign({_directives:a},e),f=new t.Document(void 0,d),p={atKey:!1,atRoot:!0,directives:f.directives,options:f.options,schema:f.schema},m=i.resolveProps(s,{indicator:`doc-start`,next:c??l?.[0],offset:o,onError:u,parentIndent:0,startOnNewline:!0});m.found&&(f.directives.docStart=!0,c&&(c.type===`block-map`||c.type===`block-seq`)&&!m.hasNewline&&u(m.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),f.contents=c?n.composeNode(p,c,m,u):n.composeEmptyNode(p,m.end,s,null,m,u);let h=f.contents.range[2],g=r.resolveEnd(l,h,!1,u);return g.comment&&(f.comment=g.comment),f.range=[o,h,g.offset],f}e.composeDoc=a})),ld=j((e=>{var t=nt(`process`),n=iu(),r=Ku(),i=qu(),a=Q(),o=cd(),s=ed();function c(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function l(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
248
+ `,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function u(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;if(isNaN(a)){let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}return String.fromCodePoint(a)}e.resolveFlowScalar=r})),dd=M((e=>{var t=Q(),n=$(),r=ld(),i=ud();function a(e,a,c,l){let{value:u,type:d,comment:f,range:p}=a.type===`block-scalar`?r.resolveBlockScalar(e,a,l):i.resolveFlowScalar(a,e.options.strict,l),m=c?e.directives.tagName(c.source,e=>l(c,`TAG_RESOLVE_FAILED`,e)):null,h;h=e.options.stringKeys&&e.atKey?e.schema[t.SCALAR]:m?o(e.schema,u,m,c,l):a.type===`scalar`?s(e,u,a,l):e.schema[t.SCALAR];let g;try{let r=h.resolve(u,e=>l(c??a,`TAG_RESOLVE_FAILED`,e),e.options);g=t.isScalar(r)?r:new n.Scalar(r)}catch(e){let t=e instanceof Error?e.message:String(e);l(c??a,`TAG_RESOLVE_FAILED`,t),g=new n.Scalar(u)}return g.range=p,g.source=u,d&&(g.type=d),m&&(g.tag=m),h.format&&(g.format=h.format),f&&(g.comment=f),g}function o(e,n,r,i,a){if(r===`!`)return e[t.SCALAR];let o=[];for(let t of e.tags)if(!t.collection&&t.tag===r)if(t.default&&t.test)o.push(t);else return t;for(let e of o)if(e.test?.test(n))return e;let s=e.knownTags[r];return s&&!s.collection?(e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(a(i,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${r}`,r!==`tag:yaml.org,2002:str`),e[t.SCALAR])}function s({atKey:e,directives:n,schema:r},i,a,o){let s=r.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(i))||r[t.SCALAR];if(r.compat){let e=r.compat.find(e=>e.default&&e.test?.test(i))??r[t.SCALAR];s.tag!==e.tag&&o(a,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${n.tagString(s.tag)} or ${n.tagString(e.tag)}`,!0)}return s}e.composeScalar=a})),fd=M((e=>{function t(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}e.emptyScalarPosition=t})),pd=M((e=>{var t=hu(),n=Q(),r=cd(),i=dd(),a=od(),o=fd();let s={composeNode:c,composeEmptyNode:l};function c(e,t,a,o){let c=e.atKey,{spaceBefore:d,comment:f,anchor:p,tag:m}=a,h,g=!0;switch(t.type){case`alias`:h=u(e,t,o),(p||m)&&o(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:h=i.composeScalar(e,t,m,o),p&&(h.anchor=p.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{h=r.composeCollection(s,e,t,a,o),p&&(h.anchor=p.source.substring(1))}catch(e){o(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:o(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),g=!1}return h??=l(e,t.offset,void 0,null,a,o),p&&h.anchor===``&&o(p,`BAD_ALIAS`,`Anchor cannot be an empty string`),c&&e.options.stringKeys&&(!n.isScalar(h)||typeof h.value!=`string`||h.tag&&h.tag!==`tag:yaml.org,2002:str`)&&o(m??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),d&&(h.spaceBefore=!0),f&&(t.type===`scalar`&&t.source===``?h.comment=f:h.commentBefore=f),e.options.keepSourceTokens&&g&&(h.srcToken=t),h}function l(e,t,n,r,{spaceBefore:a,comment:s,anchor:c,tag:l,end:u},d){let f={type:`scalar`,offset:o.emptyScalarPosition(t,n,r),indent:-1,source:``},p=i.composeScalar(e,f,l,d);return c&&(p.anchor=c.source.substring(1),p.anchor===``&&d(c,`BAD_ALIAS`,`Anchor cannot be an empty string`)),a&&(p.spaceBefore=!0),s&&(p.comment=s,p.range[2]=u),p}function u({options:e},{offset:n,source:r,end:i},o){let s=new t.Alias(r.substring(1));s.source===``&&o(n,`BAD_ALIAS`,`Alias cannot be an empty string`),s.source.endsWith(`:`)&&o(n+r.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let c=n+r.length,l=a.resolveEnd(i,c,e.strict,o);return s.range=[n,c,l.offset],l.comment&&(s.comment=l.comment),s}e.composeEmptyNode=l,e.composeNode=c})),md=M((e=>{var t=Qu(),n=pd(),r=od(),i=ed();function a(e,a,{offset:o,start:s,value:c,end:l},u){let d=Object.assign({_directives:a},e),f=new t.Document(void 0,d),p={atKey:!1,atRoot:!0,directives:f.directives,options:f.options,schema:f.schema},m=i.resolveProps(s,{indicator:`doc-start`,next:c??l?.[0],offset:o,onError:u,parentIndent:0,startOnNewline:!0});m.found&&(f.directives.docStart=!0,c&&(c.type===`block-map`||c.type===`block-seq`)&&!m.hasNewline&&u(m.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),f.contents=c?n.composeNode(p,c,m,u):n.composeEmptyNode(p,m.end,s,null,m,u);let h=f.contents.range[2],g=r.resolveEnd(l,h,!1,u);return g.comment&&(f.comment=g.comment),f.range=[o,h,g.offset],f}e.composeDoc=a})),hd=M((e=>{var t=tt(`process`),n=uu(),r=Qu(),i=$u(),a=Q(),o=md(),s=od();function c(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function l(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
248
249
 
249
250
  `:`
250
- `)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}e.Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let a=c(e);r?this.warnings.push(new i.YAMLWarning(a,t,n)):this.errors.push(new i.YAMLParseError(a,t,n))},this.directives=new n.Directives({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=l(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(a.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];a.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:l(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(t.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=c(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=o.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=s.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),n=new r.Document(void 0,e);this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),n.range=[0,t,t],this.decorate(n,!1),yield n}}}})),ud=j((e=>{var t=rd(),n=id(),r=qu(),i=mu();function a(e,i=!0,a){if(e){let o=(e,t,n)=>{let i=typeof e==`number`?e:Array.isArray(e)?e[0]:e.offset;if(a)a(i,t,n);else throw new r.YAMLParseError([i,i+1],t,n)};switch(e.type){case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return n.resolveFlowScalar(e,i,o);case`block-scalar`:return t.resolveBlockScalar({options:{strict:i}},e,o)}}return null}function o(e,t){let{implicitKey:n=!1,indent:r,inFlow:a=!1,offset:o=-1,type:s=`PLAIN`}=t,c=i.stringifyString({type:s,value:e},{implicitKey:n,indent:r>0?` `.repeat(r):``,inFlow:a,options:{blockQuote:!0,lineWidth:-1}}),u=t.end??[{type:`newline`,offset:-1,indent:r,source:`
251
+ `)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}e.Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let a=c(e);r?this.warnings.push(new i.YAMLWarning(a,t,n)):this.errors.push(new i.YAMLParseError(a,t,n))},this.directives=new n.Directives({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=l(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(a.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];a.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:l(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(t.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=c(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=o.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=s.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),n=new r.Document(void 0,e);this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),n.range=[0,t,t],this.decorate(n,!1),yield n}}}})),gd=M((e=>{var t=ld(),n=ud(),r=$u(),i=bu();function a(e,i=!0,a){if(e){let o=(e,t,n)=>{let i=typeof e==`number`?e:Array.isArray(e)?e[0]:e.offset;if(a)a(i,t,n);else throw new r.YAMLParseError([i,i+1],t,n)};switch(e.type){case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return n.resolveFlowScalar(e,i,o);case`block-scalar`:return t.resolveBlockScalar({options:{strict:i}},e,o)}}return null}function o(e,t){let{implicitKey:n=!1,indent:r,inFlow:a=!1,offset:o=-1,type:s=`PLAIN`}=t,c=i.stringifyString({type:s,value:e},{implicitKey:n,indent:r>0?` `.repeat(r):``,inFlow:a,options:{blockQuote:!0,lineWidth:-1}}),u=t.end??[{type:`newline`,offset:-1,indent:r,source:`
251
252
  `}];switch(c[0]){case`|`:case`>`:{let e=c.indexOf(`
252
253
  `),t=c.substring(0,e),n=c.substring(e+1)+`
253
254
  `,i=[{type:`block-scalar-header`,offset:o,indent:r,source:t}];return l(i,u)||i.push({type:`newline`,offset:-1,indent:r,source:`
@@ -255,9 +256,9 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
255
256
  `),r=t.substring(0,n),i=t.substring(n+1)+`
256
257
  `;if(e.type===`block-scalar`){let t=e.props[0];if(t.type!==`block-scalar-header`)throw Error(`Invalid block scalar header`);t.source=r,e.source=i}else{let{offset:t}=e,n=`indent`in e?e.indent:-1,a=[{type:`block-scalar-header`,offset:t,indent:n,source:r}];l(a,`end`in e?e.end:void 0)||a.push({type:`newline`,offset:-1,indent:n,source:`
257
258
  `});for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:`block-scalar`,indent:n,props:a,source:i})}}function l(e,t){if(t)for(let n of t)switch(n.type){case`space`:case`comment`:e.push(n);break;case`newline`:return e.push(n),!0}return!1}function u(e,t,n){switch(e.type){case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:e.type=n,e.source=t;break;case`block-scalar`:{let r=e.props.slice(1),i=t.length;e.props[0].type===`block-scalar-header`&&(i-=e.props[0].source.length);for(let e of r)e.offset+=i;delete e.props,Object.assign(e,{type:n,source:t,end:r});break}case`block-map`:case`block-seq`:{let r={type:`newline`,offset:e.offset+t.length,indent:e.indent,source:`
258
- `};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let r=`indent`in e?e.indent:-1,i=`end`in e&&Array.isArray(e.end)?e.end.filter(e=>e.type===`space`||e.type===`comment`||e.type===`newline`):[];for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}e.createScalarToken=o,e.resolveAsScalar=a,e.setScalarValue=s})),dd=j((e=>{let t=e=>`type`in e?n(e):r(e);function n(e){switch(e.type){case`block-scalar`:{let t=``;for(let r of e.props)t+=n(r);return t+e.source}case`block-map`:case`block-seq`:{let t=``;for(let n of e.items)t+=r(n);return t}case`flow-collection`:{let t=e.start.source;for(let n of e.items)t+=r(n);for(let n of e.end)t+=n.source;return t}case`document`:{let t=r(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if(`end`in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function r({start:e,key:t,sep:r,value:i}){let a=``;for(let t of e)a+=t.source;if(t&&(a+=n(t)),r)for(let e of r)a+=e.source;return i&&(a+=n(i)),a}e.stringify=t})),fd=j((e=>{let t=Symbol(`break visit`),n=Symbol(`skip children`),r=Symbol(`remove item`);function i(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),a(Object.freeze([]),e,t)}i.BREAK=t,i.SKIP=n,i.REMOVE=r,i.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},i.parentCollection=(e,t)=>{let n=i.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],a=n?.[r];if(a&&`items`in a)return a;throw Error(`Parent collection not found`)};function a(e,n,i){let o=i(n,e);if(typeof o==`symbol`)return o;for(let s of[`key`,`value`]){let c=n[s];if(c&&`items`in c){for(let n=0;n<c.items.length;++n){let o=a(Object.freeze(e.concat([[s,n]])),c.items[n],i);if(typeof o==`number`)n=o-1;else if(o===t)return t;else o===r&&(c.items.splice(n,1),--n)}typeof o==`function`&&s===`key`&&(o=o(n,e))}}return typeof o==`function`?o(n,e):o}e.visit=i})),pd=j((e=>{var t=ud(),n=dd(),r=fd();let i=e=>!!e&&`items`in e,a=e=>!!e&&(e.type===`scalar`||e.type===`single-quoted-scalar`||e.type===`double-quoted-scalar`||e.type===`block-scalar`);function o(e){switch(e){case``:return`<BOM>`;case``:return`<DOC>`;case``:return`<FLOW_END>`;case``:return`<SCALAR>`;default:return JSON.stringify(e)}}function s(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
259
+ `};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let r=`indent`in e?e.indent:-1,i=`end`in e&&Array.isArray(e.end)?e.end.filter(e=>e.type===`space`||e.type===`comment`||e.type===`newline`):[];for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}e.createScalarToken=o,e.resolveAsScalar=a,e.setScalarValue=s})),_d=M((e=>{let t=e=>`type`in e?n(e):r(e);function n(e){switch(e.type){case`block-scalar`:{let t=``;for(let r of e.props)t+=n(r);return t+e.source}case`block-map`:case`block-seq`:{let t=``;for(let n of e.items)t+=r(n);return t}case`flow-collection`:{let t=e.start.source;for(let n of e.items)t+=r(n);for(let n of e.end)t+=n.source;return t}case`document`:{let t=r(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if(`end`in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function r({start:e,key:t,sep:r,value:i}){let a=``;for(let t of e)a+=t.source;if(t&&(a+=n(t)),r)for(let e of r)a+=e.source;return i&&(a+=n(i)),a}e.stringify=t})),vd=M((e=>{let t=Symbol(`break visit`),n=Symbol(`skip children`),r=Symbol(`remove item`);function i(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),a(Object.freeze([]),e,t)}i.BREAK=t,i.SKIP=n,i.REMOVE=r,i.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},i.parentCollection=(e,t)=>{let n=i.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],a=n?.[r];if(a&&`items`in a)return a;throw Error(`Parent collection not found`)};function a(e,n,i){let o=i(n,e);if(typeof o==`symbol`)return o;for(let s of[`key`,`value`]){let c=n[s];if(c&&`items`in c){for(let n=0;n<c.items.length;++n){let o=a(Object.freeze(e.concat([[s,n]])),c.items[n],i);if(typeof o==`number`)n=o-1;else if(o===t)return t;else o===r&&(c.items.splice(n,1),--n)}typeof o==`function`&&s===`key`&&(o=o(n,e))}}return typeof o==`function`?o(n,e):o}e.visit=i})),yd=M((e=>{var t=gd(),n=_d(),r=vd();let i=e=>!!e&&`items`in e,a=e=>!!e&&(e.type===`scalar`||e.type===`single-quoted-scalar`||e.type===`double-quoted-scalar`||e.type===`block-scalar`);function o(e){switch(e){case``:return`<BOM>`;case``:return`<DOC>`;case``:return`<FLOW_END>`;case``:return`<SCALAR>`;default:return JSON.stringify(e)}}function s(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
259
260
  `:case`\r
260
- `:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}e.createScalarToken=t.createScalarToken,e.resolveAsScalar=t.resolveAsScalar,e.setScalarValue=t.setScalarValue,e.stringify=n.stringify,e.visit=r.visit,e.BOM=``,e.DOCUMENT=``,e.FLOW_END=``,e.SCALAR=``,e.isCollection=i,e.isScalar=a,e.prettyToken=o,e.tokenType=s})),md=j((e=>{var t=pd();function n(e){switch(e){case void 0:case` `:case`
261
+ `:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}e.createScalarToken=t.createScalarToken,e.resolveAsScalar=t.resolveAsScalar,e.setScalarValue=t.setScalarValue,e.stringify=n.stringify,e.visit=r.visit,e.BOM=``,e.DOCUMENT=``,e.FLOW_END=``,e.SCALAR=``,e.isCollection=i,e.isScalar=a,e.prettyToken=o,e.tokenType=s})),bd=M((e=>{var t=yd();function n(e){switch(e){case void 0:case` `:case`
261
262
  `:case`\r`:case` `:return!0;default:return!1}}let r=new Set(`0123456789ABCDEFabcdef`),i=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),a=new Set(`,[]{}`),o=new Set(` ,[]{}
262
263
  \r `),s=e=>!e||o.has(e);e.Lexer=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
263
264
  `?!0:t===`\r`?this.buffer[e+1]===`
@@ -276,21 +277,21 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
276
277
  `,t=this.buffer[i+1]):r=i),t===`#`||e&&a.has(t))break;if(o===`
277
278
  `){let e=this.continueScalar(i+1);if(e===-1)break;i=Math.max(i,e-2)}}else{if(e&&a.has(o))break;r=i}return!o&&!this.atEnd?this.setNext(`plain-scalar`):(yield t.SCALAR,yield*this.pushToIndex(r+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){switch(this.charAt(0)){case`!`:return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case`&`:return(yield*this.pushUntil(s))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case`-`:case`?`:case`:`:{let e=this.flowLevel>0,t=this.charAt(1);if(n(t)||e&&a.has(t))return e?this.flowKey&&=!1:this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!n(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(i.has(t))t=this.buffer[++e];else if(t===`%`&&r.has(this.buffer[e+1])&&r.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
278
279
  `?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
279
- `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}})),hd=j((e=>{e.LineCounter=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}}})),gd=j((e=>{var t=nt(`process`),n=pd(),r=md();function i(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function a(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function o(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function s(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function c(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function l(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!i(t.start,`explicit-key-ind`)&&!i(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,o(t.value)?t.value.end?Array.prototype.push.apply(t.value.end,t.sep):t.value.end=t.sep:Array.prototype.push.apply(t.start,t.sep),delete t.sep)}e.Parser=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new r.Lexer,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,t.env.LOG_TOKENS&&console.log(`|`,n.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=n.tokenType(e);if(!r){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(r===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=r,yield*this.step(),r){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&l(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&a(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case`directive-line`:yield{type:`directive`,offset:this.offset,source:this.source};return;case`byte-order-mark`:case`space`:case`comment`:case`newline`:yield this.sourceToken;return;case`doc-mode`:case`doc-start`:{let e={type:`document`,offset:this.offset,start:[]};this.type===`doc-start`&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case`doc-start`:a(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type===`map-value-ind`){let t=c(s(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case`space`:case`comment`:case`newline`:e.props.push(this.sourceToken);return;case`scalar`:if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf(`
280
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}})),xd=M((e=>{e.LineCounter=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}}})),Sd=M((e=>{var t=tt(`process`),n=yd(),r=bd();function i(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function a(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function o(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function s(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function c(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function l(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!i(t.start,`explicit-key-ind`)&&!i(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,o(t.value)?t.value.end?Array.prototype.push.apply(t.value.end,t.sep):t.value.end=t.sep:Array.prototype.push.apply(t.start,t.sep),delete t.sep)}e.Parser=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new r.Lexer,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,t.env.LOG_TOKENS&&console.log(`|`,n.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=n.tokenType(e);if(!r){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(r===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=r,yield*this.step(),r){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&l(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&a(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case`directive-line`:yield{type:`directive`,offset:this.offset,source:this.source};return;case`byte-order-mark`:case`space`:case`comment`:case`newline`:yield this.sourceToken;return;case`doc-mode`:case`doc-start`:{let e={type:`document`,offset:this.offset,start:[]};this.type===`doc-start`&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case`doc-start`:a(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type===`map-value-ind`){let t=c(s(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case`space`:case`comment`:case`newline`:e.props.push(this.sourceToken);return;case`scalar`:if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf(`
280
281
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
281
282
  `,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,a=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(a=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(a.push(this.sourceToken),e.items.push({start:a,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey)if(!t.sep)if(i(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=c(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(i(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(o(t.key)&&!i(t.sep,`newline`)){let e=c(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else a.length>0?t.sep=t.sep.concat(a,this.sourceToken):t.sep.push(this.sourceToken);else t.sep?t.value||r?e.items.push({start:a,key:null,sep:[this.sourceToken]}):i(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:a,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!i(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:a});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||i(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=c(s(t));l(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
282
283
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
283
- `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),_d=j((e=>{var t=ld(),n=Ku(),r=qu(),i=_u(),a=Q(),o=hd(),s=gd();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),vd=j((e=>{var t=ld(),n=Ku(),r=Wu(),i=qu(),a=lu(),o=Q(),s=bu(),c=$(),l=Su(),u=wu(),d=pd(),f=md(),p=hd(),m=gd(),h=_d(),g=ru();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.CST=d,e.Lexer=f.Lexer,e.LineCounter=p.LineCounter,e.Parser=m.Parser,e.parse=h.parse,e.parseAllDocuments=h.parseAllDocuments,e.parseDocument=h.parseDocument,e.stringify=h.stringify,e.visit=g.visit,e.visitAsync=g.visitAsync}));async function yd(e){let t=await Ve(e,`utf-8`).catch(e=>{process.stderr.write(`Error: cannot read pipeline file: ${e.message}\n`),process.exit(2)}),n=Ue(e).toLowerCase(),r;if(n===`.yaml`||n===`.yml`){let{parse:e}=await Promise.resolve().then(()=>tt(vd(),1));r=e(t)}else try{r=JSON.parse(t)}catch{let{parse:e}=await Promise.resolve().then(()=>tt(vd(),1));r=e(t)}return r}var bd=A((()=>{}));async function xd(e){let t=e.input,n=e.inputFile;if(t&&n&&(process.stderr.write(`Error: use --input or --input-file, not both
284
- `),process.exit(2)),t)return JSON.parse(t);if(n){let e=await Ve(Ge(n),`utf-8`);return JSON.parse(e)}return{}}function Sd(e){let t=`[${e.type}]`;if(`stepCount`in e){process.stderr.write(`${t} ${e.stepCount} step${e.stepCount===1?``:`s`}\n`);return}`step`in e&&e.step?process.stderr.write(`${t} ${Cd(e.step)}\n`):process.stderr.write(`${t}\n`)}function Cd(e){return`${e.index!==void 0&&e.total!==void 0?`${e.index}/${e.total} `:``}${e.id} (${e.type})`}function wd(e){let t=e.status===`succeeded`?`+`:e.status===`failed`?`x`:`~`;process.stdout.write(`\nPipeline ${e.status} [${t}]\n\n`);for(let t of e.steps){let e=` [${t.status===`succeeded`?`+`:t.status===`failed`?`x`:t.status===`skipped`?`-`:`~`}] ${t.id} (${t.type}) — ${t.status}`;t.skipReason&&(e+=` (${t.skipReason})`),t.error&&(e+=`: ${t.error.message}`),process.stdout.write(e+`
284
+ `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),Cd=M((e=>{var t=hd(),n=Qu(),r=$u(),i=Cu(),a=Q(),o=xd(),s=Sd();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),wd=M((e=>{var t=hd(),n=Qu(),r=Xu(),i=$u(),a=hu(),o=Q(),s=Eu(),c=$(),l=Ou(),u=Au(),d=yd(),f=bd(),p=xd(),m=Sd(),h=Cd(),g=lu();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.CST=d,e.Lexer=f.Lexer,e.LineCounter=p.LineCounter,e.Parser=m.Parser,e.parse=h.parse,e.parseAllDocuments=h.parseAllDocuments,e.parseDocument=h.parseDocument,e.stringify=h.stringify,e.visit=g.visit,e.visitAsync=g.visitAsync}));async function Td(e){let t=await Be(e,`utf-8`).catch(e=>{process.stderr.write(`Error: cannot read pipeline file: ${e.message}\n`),process.exit(2)}),n=He(e).toLowerCase(),r;if(n===`.yaml`||n===`.yml`){let{parse:e}=await Promise.resolve().then(()=>et(wd(),1));r=e(t)}else try{r=JSON.parse(t)}catch{let{parse:e}=await Promise.resolve().then(()=>et(wd(),1));r=e(t)}return r}var Ed=j((()=>{}));async function Dd(e){let t=e.input,n=e.inputFile;if(t&&n&&(process.stderr.write(`Error: use --input or --input-file, not both
285
+ `),process.exit(2)),t)return JSON.parse(t);if(n){let e=await Be(We(n),`utf-8`);return JSON.parse(e)}return{}}function Od(e){let t=`[${e.type}]`;if(`stepCount`in e){process.stderr.write(`${t} ${e.stepCount} step${e.stepCount===1?``:`s`}\n`);return}`step`in e&&e.step?process.stderr.write(`${t} ${kd(e.step)}\n`):process.stderr.write(`${t}\n`)}function kd(e){return`${e.index!==void 0&&e.total!==void 0?`${e.index}/${e.total} `:``}${e.id} (${e.type})`}function Ad(e){let t=e.status===`succeeded`?`+`:e.status===`failed`?`x`:`~`;process.stdout.write(`\nPipeline ${e.status} [${t}]\n\n`);for(let t of e.steps){let e=` [${t.status===`succeeded`?`+`:t.status===`failed`?`x`:t.status===`skipped`?`-`:`~`}] ${t.id} (${t.type}) — ${t.status}`;t.skipReason&&(e+=` (${t.skipReason})`),t.error&&(e+=`: ${t.error.message}`),process.stdout.write(e+`
285
286
  `)}process.stdout.write(`
286
- `)}var Td,Ed=A((()=>{P(),Cl(),nu(),bd(),Td=d({name:`pipeline run`,description:`Run a pipeline workflow definition`,usage:`bl pipeline run <file> [flags]`,options:[{flag:`--input <json>`,description:`Runtime input as inline JSON`},{flag:`--input-file <path>`,description:`Runtime input from a JSON file`},{flag:`--concurrency <n>`,description:`Max parallel steps (default: 1)`,type:`number`},{flag:`--events <format>`,description:`Emit lifecycle events: jsonl`},{flag:`--timeout <seconds>`,description:`Default step timeout in seconds`,type:`number`}],examples:[`bl pipeline run workflow.yaml --input '{"brief":"hello"}'`,`bl pipeline run workflow.json --input-file inputs.json --concurrency 3`,`bl pipeline run workflow.yaml --dry-run`,`bl pipeline run workflow.json --events jsonl`,`bl pipeline run workflow.yaml --output json`],async run(e,t){let n=(t._positional??[])[0];n||(process.stderr.write(`Error: pipeline file is required
287
+ `)}var jd,Md=j((()=>{F(),Ol(),cu(),Ed(),jd=d({name:`pipeline run`,description:`Run a pipeline workflow definition`,usage:`bl pipeline run <file> [flags]`,options:[{flag:`--input <json>`,description:`Runtime input as inline JSON`},{flag:`--input-file <path>`,description:`Runtime input from a JSON file`},{flag:`--concurrency <n>`,description:`Max parallel steps (default: 1)`,type:`number`},{flag:`--events <format>`,description:`Emit lifecycle events: jsonl`},{flag:`--timeout <seconds>`,description:`Default step timeout in seconds`,type:`number`}],examples:[`bl pipeline run workflow.yaml --input '{"brief":"hello"}'`,`bl pipeline run workflow.json --input-file inputs.json --concurrency 3`,`bl pipeline run workflow.yaml --dry-run`,`bl pipeline run workflow.json --events jsonl`,`bl pipeline run workflow.yaml --output json`],async run(e,t){let n=(t._positional??[])[0];n||(process.stderr.write(`Error: pipeline file is required
287
288
  Usage: bl pipeline run <file>
288
- `),process.exit(2)),xl();let r=t.events;r!==void 0&&r!==`jsonl`&&(process.stderr.write(`Error: unsupported --events format: ${r}. Supported: jsonl\n`),process.exit(2));let i=Ge(n),a=await yd(i),o=await xd(t),s=He(i);if(r===`jsonl`){for await(let e of Ul(a,o,{concurrency:t.concurrency,basePath:s,dryRun:t.dryRun,timeoutSeconds:t.timeout}))process.stdout.write(JSON.stringify(e)+`
289
- `);return}let c=await Hl(a,o,{concurrency:t.concurrency,basePath:s,dryRun:t.dryRun,timeoutSeconds:t.timeout,onEvent:t.verbose?Sd:void 0});e.output===`json`?M(c,`json`):wd(c),c.status===`failed`&&(process.exitCode=1)}})})),Dd,Od=A((()=>{P(),Cl(),Vl(),bd(),Dd=d({name:`pipeline validate`,description:`Validate a pipeline definition without executing`,usage:`bl pipeline validate <file>`,options:[],examples:[`bl pipeline validate workflow.yaml`,`bl pipeline validate workflow.json --output json`],async run(e,t){let n=(t._positional??[])[0];n||(process.stderr.write(`Error: pipeline file is required
289
+ `),process.exit(2)),El();let r=t.events;r!==void 0&&r!==`jsonl`&&(process.stderr.write(`Error: unsupported --events format: ${r}. Supported: jsonl\n`),process.exit(2));let i=We(n),a=await Td(i),o=await Dd(t),s=Ve(i);if(r===`jsonl`){for await(let e of Jl(a,o,{concurrency:t.concurrency,basePath:s,dryRun:t.dryRun,timeoutSeconds:t.timeout}))process.stdout.write(JSON.stringify(e)+`
290
+ `);return}let c=await ql(a,o,{concurrency:t.concurrency,basePath:s,dryRun:t.dryRun,timeoutSeconds:t.timeout,onEvent:t.verbose?Od:void 0});e.output===`json`?N(c,`json`):Ad(c),c.status===`failed`&&(process.exitCode=1)}})})),Nd,Pd=j((()=>{F(),Ol(),Kl(),Ed(),Nd=d({name:`pipeline validate`,description:`Validate a pipeline definition without executing`,usage:`bl pipeline validate <file>`,options:[],examples:[`bl pipeline validate workflow.yaml`,`bl pipeline validate workflow.json --output json`],async run(e,t){let n=(t._positional??[])[0];n||(process.stderr.write(`Error: pipeline file is required
290
291
  Usage: bl pipeline validate <file>
291
- `),process.exit(2)),xl();let r=await yd(Ge(n)),i=Ml(r),a=i.length===0?Nl(r):[];if(e.output===`json`)M({valid:i.length===0,issues:i,...a.length>0?{hints:a}:{}},`json`),i.length>0&&(process.exitCode=1);else if(i.length===0){process.stdout.write(`Pipeline definition is valid.
292
+ `),process.exit(2)),El();let r=await Td(We(n)),i=Ll(r),a=i.length===0?Rl(r):[];if(e.output===`json`)N({valid:i.length===0,issues:i,...a.length>0?{hints:a}:{}},`json`),i.length>0&&(process.exitCode=1);else if(i.length===0){process.stdout.write(`Pipeline definition is valid.
292
293
  `);for(let e of a)process.stderr.write(` hint: ${e}\n`)}else{process.stderr.write(`Pipeline validation failed:
293
- `);for(let e of i)process.stderr.write(` - ${e}\n`);process.exitCode=1}}})})),kd=$e({commands:()=>Ad}),Ad,jd=A((()=>{Pa(),Ia(),za(),Va(),Ua(),Ga(),qa(),Ya(),Za(),$a(),no(),io(),po(),go(),vo(),bo(),Co(),Ed(),Od(),Ad={"auth login":Xr,"auth status":ai,"auth logout":ci,"text chat":di,omni:hi,"image generate":zi,"image edit":Vi,"video generate":Gi,"video edit":qi,"video ref":Yi,"video task get":Zi,"video download":$i,"vision describe":aa,"app call":Fa,"app list":Ra,"memory add":Ba,"memory search":Ha,"memory list":Wa,"memory update":Ka,"memory delete":Ja,"memory profile create":Xa,"memory profile get":Qa,"knowledge retrieve":to,"search web":ro,"speech synthesize":fo,"speech recognize":ho,"file upload":_o,"console call":yo,"usage free":So,"pipeline run":Td,"pipeline validate":Dd,"config show":sa,"config set":da,"config export-schema":ma,update:Na}}));jd();const Md=new class{root={children:new Map};constructor(e){for(let[t,n]of Object.entries(e))this.register(t,n)}register(e,t){let n=e.split(` `),r=this.root;for(let e of n)r.children.has(e)||r.children.set(e,{children:new Map}),r=r.children.get(e);r.command=t}getAllCommands(){let e=[],t=n=>{n.command&&e.push(n.command);for(let e of n.children.values())t(e)};return t(this.root),e}isGroupPath(e){let t=this.root;for(let n of e){let e=t.children.get(n);if(!e)return!1;t=e}return!t.command&&t.children.size>0}resolve(e){let n=this.root,r=[];for(let t of e){let e=n.children.get(t);if(!e)break;n=e,r.push(t)}if(n.command)return{command:n.command,extra:e.slice(r.length)};if(r.length>0&&n.children.size===1){let[,t]=n.children.entries().next().value;if(t.command)return{command:t.command,extra:e.slice(r.length)}}if(r.length>0&&n.children.size>0){let a=Array.from(n.children.entries()).map(([e,t])=>{if(t.command)return` ${r.join(` `)} ${e} ${t.command.description}`;let n=Array.from(t.children.keys()).join(`, `);return` ${r.join(` `)} ${e} [${n}]`}).join(`
294
+ `);for(let e of i)process.stderr.write(` - ${e}\n`);process.exitCode=1}}})})),Fd=Qe({commands:()=>Id}),Id,Ld=j((()=>{za(),Va(),Wa(),Ka(),Ja(),Xa(),Qa(),eo(),no(),io(),so(),lo(),vo(),xo(),Co(),To(),Oo(),Md(),Pd(),Id={"auth login":ti,"auth status":ui,"auth logout":pi,"text chat":gi,omni:bi,"image generate":Wi,"image edit":Ki,"video generate":Xi,"video edit":Qi,"video ref":ea,"video task get":na,"video download":ia,"vision describe":ua,"app call":Ba,"app list":Ua,"memory add":Ga,"memory search":qa,"memory list":Ya,"memory update":Za,"memory delete":$a,"memory profile create":to,"memory profile get":ro,"knowledge retrieve":oo,"search web":co,"speech synthesize":_o,"speech recognize":bo,"file upload":So,"console call":wo,"usage free":Do,"pipeline run":jd,"pipeline validate":Nd,"config show":fa,"config set":ga,"config export-schema":ya,update:Ra}}));Ld();const Rd=new class{root={children:new Map};constructor(e){for(let[t,n]of Object.entries(e))this.register(t,n)}register(e,t){let n=e.split(` `),r=this.root;for(let e of n)r.children.has(e)||r.children.set(e,{children:new Map}),r=r.children.get(e);r.command=t}getAllCommands(){let e=[],t=n=>{n.command&&e.push(n.command);for(let e of n.children.values())t(e)};return t(this.root),e}isGroupPath(e){let t=this.root;for(let n of e){let e=t.children.get(n);if(!e)return!1;t=e}return!t.command&&t.children.size>0}resolve(e){let n=this.root,r=[];for(let t of e){let e=n.children.get(t);if(!e)break;n=e,r.push(t)}if(n.command)return{command:n.command,extra:e.slice(r.length)};if(r.length>0&&n.children.size===1){let[,t]=n.children.entries().next().value;if(t.command)return{command:t.command,extra:e.slice(r.length)}}if(r.length>0&&n.children.size>0){let a=Array.from(n.children.entries()).map(([e,t])=>{if(t.command)return` ${r.join(` `)} ${e} ${t.command.description}`;let n=Array.from(t.children.keys()).join(`, `);return` ${r.join(` `)} ${e} [${n}]`}).join(`
294
295
  `);throw new t(`Unknown command: bl ${e.join(` `)}\n\nAvailable commands:\n${a}`,i.USAGE,`bl ${r.join(` `)} --help`)}throw new t(`Unknown command: bl ${e.join(` `)}`,i.USAGE,`bl --help`)}buildResourceLines(e,t){let n=[],r=(e,t)=>{for(let[i,a]of e.children){let e=t?`${t} ${i}`:i;a.command&&n.push({path:e,desc:a.command.description}),a.children.size>0&&r(a,e)}};r(this.root,``);let i=Math.max(...n.map(e=>e.path.length));return n.map(n=>` ${e(n.path.padEnd(i+2))} ${t(n.desc)}`).join(`
295
296
  `)}buildGlobalFlagLines(e,t){let n=Math.max(...a.map(e=>e.flag.length));return a.map(r=>` ${e(r.flag.padEnd(n+2))} ${t(r.description)}`).join(`
296
297
  `)}bold=(e,t)=>t.isTTY?`\x1b[1m${e}\x1b[0m`:e;accent=(e,t)=>t.isTTY?`\x1b[38;2;59;130;246m${e}\x1b[0m`:e;dim=(e,t)=>t.isTTY?`\x1b[2m${e}\x1b[0m`:e;printHelp(e,t=process.stdout,n=`cn`){if(e.length===0){this.printRootHelp(t);return}let r=this.root;for(let n of e){let e=r.children.get(n);if(!e){this.printRootHelp(t);return}r=e}if(r.command){this.printCommandHelp(r.command,t,n);return}let i=e.join(` `);t.write(`\n${this.bold(`Usage:`,t)} bl ${i} <command> [flags]\n\n`),t.write(`${this.bold(`Commands:`,t)}\n`),this.printChildren(r,i,t),i===`pipeline`&&this.printPipelineQuickStart(t),t.write(`
@@ -321,13 +322,13 @@ ${o}
321
322
  ${n(`Getting Help:`)}
322
323
  ${i(`Add --help after any command to see its full list of options, defaults,`)}
323
324
  ${i(`and usage examples. For example:`)} bl text chat --help
324
- `)}printCommandHelp(e,t,n=`cn`){let i=e=>this.bold(e,t),a=e=>this.accent(e,t),o=e=>this.dim(e,t);if(t.write(`\n${e.description}\n`),e.usage&&t.write(`${i(`Usage:`)} ${e.usage}\n`),e.options&&e.options.length>0){let n=Math.max(...e.options.map(e=>e.flag.length));t.write(`\n${i(`Options:`)}\n`);for(let r of e.options)t.write(` ${a(r.flag.padEnd(n+2))} ${o(r.description)}\n`)}if(e.examples&&e.examples.length>0){t.write(`\n${i(`Examples:`)}\n`);for(let n of e.examples)t.write(` ${o(n)}\n`)}e.apiDocs&&t.write(`\n${i(`API Reference:`)} ${o(r[n]+e.apiDocs)}\n`),t.write(`\n${o(`Global flags (--api-key, --output, --quiet, etc.) are always available.`)}\n`),t.write(`${o(`Run`)} bl --help ${o(`for the full list.`)}\n`)}printChildren(e,t,n){let r=[],i=(e,t)=>{for(let[n,a]of e.children)a.command&&r.push({fullName:`${t} ${n}`,description:a.command.description}),a.children.size>0&&i(a,`${t} ${n}`)};i(e,t);let a=Math.max(...r.map(e=>e.fullName.length));for(let{fullName:e,description:t}of r)n.write(` ${this.accent(e.padEnd(a),n)} ${this.dim(t,n)}\n`)}}(Ad);U();async function Nd(e){if(e.apiKey||e.fileApiKey||e.accessTokenEnv||e.fileAccessToken)return;let n=process.env.DASHSCOPE_API_KEY,r;if(n&&(x({nonInteractive:e.nonInteractive})?await Mr({message:`Found DASHSCOPE_API_KEY in environment (${w(n)}). Save it to config file?`})&&(r=n):r=n),!r){if(!x({nonInteractive:e.nonInteractive}))throw new t(`No API key found.`,i.AUTH,`Set DASHSCOPE_API_KEY environment variable, pass --api-key, or run interactively to be prompted.`);let n=await jr({message:`Enter your DashScope API key:`});if(!n)throw new t(`API key is required.`,i.AUTH);r=n}await ye({...ae(),api_key:r}),e.fileApiKey=r;let a=e.configPath??`~/.bailian/config.json`;process.stderr.write(`API key saved to ${a}\n`)}ft();function Pd(e){return e.padEnd(13)}function Fd(e){return e.split(`
325
+ `)}printCommandHelp(e,t,n=`cn`){let i=e=>this.bold(e,t),a=e=>this.accent(e,t),o=e=>this.dim(e,t);if(t.write(`\n${e.description}\n`),e.usage&&t.write(`${i(`Usage:`)} ${e.usage}\n`),e.options&&e.options.length>0){let n=Math.max(...e.options.map(e=>e.flag.length));t.write(`\n${i(`Options:`)}\n`);for(let r of e.options)t.write(` ${a(r.flag.padEnd(n+2))} ${o(r.description)}\n`)}if(e.examples&&e.examples.length>0){t.write(`\n${i(`Examples:`)}\n`);for(let n of e.examples)t.write(` ${o(n)}\n`)}e.apiDocs&&t.write(`\n${i(`API Reference:`)} ${o(r[n]+e.apiDocs)}\n`),t.write(`\n${o(`Global flags (--api-key, --output, --quiet, etc.) are always available.`)}\n`),t.write(`${o(`Run`)} bl --help ${o(`for the full list.`)}\n`)}printChildren(e,t,n){let r=[],i=(e,t)=>{for(let[n,a]of e.children)a.command&&r.push({fullName:`${t} ${n}`,description:a.command.description}),a.children.size>0&&i(a,`${t} ${n}`)};i(e,t);let a=Math.max(...r.map(e=>e.fullName.length));for(let{fullName:e,description:t}of r)n.write(` ${this.accent(e.padEnd(a),n)} ${this.dim(t,n)}\n`)}}(Id);W();async function zd(e){if(e.apiKey||e.fileApiKey||e.accessTokenEnv||e.fileAccessToken)return;let n=process.env.DASHSCOPE_API_KEY,r;if(n&&(x({nonInteractive:e.nonInteractive})?await jr({message:`Found DASHSCOPE_API_KEY in environment (${w(n)}). Save it to config file?`})&&(r=n):r=n),!r){if(!x({nonInteractive:e.nonInteractive}))throw new t(`No API key found.`,i.AUTH,`Set DASHSCOPE_API_KEY environment variable, pass --api-key, or run interactively to be prompted.`);let n=await Ar({message:`Enter your DashScope API key:`});if(!n)throw new t(`API key is required.`,i.AUTH);r=n}await ve({...D(),api_key:r}),e.fileApiKey=r;let a=e.configPath??`~/.bailian/config.json`;process.stderr.write(`API key saved to ${a}\n`)}dt();function Bd(e){return e.padEnd(13)}function Vd(e){return e.split(`
325
326
  `).map((e,t)=>t===0?e:` `.repeat(13)+e).join(`
326
- `)}function Id(e){return e.exitCode===i.AUTH?e.message===n?e.hint:[e.hint,``,`bl auth login --api-key <your-key>`,`bl auth status`,`Get API Key: ${dt}`].filter(e=>e!==void 0).join(`
327
- `):e.hint}function Ld(e=process.argv.slice(2),t=process.env.DASHSCOPE_OUTPUT){for(let n=0;n<e.length;n++){let r=e[n];if(r===`--output`)return f(e[n+1]||t);if(r?.startsWith(`--output=`))return f(r.slice(9))}return f(t)}function Rd(e){let n=e.cause,r=n?.code,a=n?.message,o=[];return r&&o.push(r),a&&a!==r&&o.push(a),new t(`Network request failed: ${o.length>0?o.join(`: `):`unknown cause`}`,i.NETWORK,zd(r),{cause:e})}function zd(e){switch(e){case`ENOTFOUND`:case`EAI_AGAIN`:return`DNS resolution failed. Check DASHSCOPE_BASE_URL or your DNS / network.`;case`ECONNREFUSED`:return`Connection refused. Check the target host/port and proxy settings.`;case`ECONNRESET`:return`Connection reset by peer. Retry, or check proxy / firewall.`;case`ETIMEDOUT`:return`Connection timed out. Check your network or try a different region.`;case`CERT_HAS_EXPIRED`:case`UNABLE_TO_VERIFY_LEAF_SIGNATURE`:case`DEPTH_ZERO_SELF_SIGNED_CERT`:return`TLS certificate error. Check system clock and CA bundle.`;default:return`Check network connection, proxy settings (HTTP_PROXY / HTTPS_PROXY), and DASHSCOPE_BASE_URL.`}}function Bd(e){let n=e.code,r=`Check the file path and permissions.`;return n===`ENOENT`?r=`File or directory not found.`:n===`EACCES`||n===`EPERM`?r=`Permission denied — check file or directory permissions.`:n===`ENOSPC`&&(r=`Disk full — free up space and try again.`),new t(`File system error: ${e.message}`,i.GENERAL,r,{cause:e})}function Vd(e){let t=e.cause,n=0;for(;t instanceof Error&&n<5;)process.stderr.write(`${Pd(`Caused by:`)}${t.message}\n`),t=t.cause,n++}function Hd(e){process.stderr.write(`\n${Pd(`Error:`)}${e.message}\n`);let t=Id(e);t&&process.stderr.write(`${Pd(`Hint:`)}${Fd(t)}\n`);let n=e.api;if(n){if(n.httpStatus!==void 0){let e=n.apiCode?` (${n.apiCode})`:``;process.stderr.write(`${Pd(`Status:`)}HTTP ${n.httpStatus}${e}\n`)}else n.apiCode&&process.stderr.write(`${Pd(`Code:`)}${n.apiCode}\n`);n.requestId&&process.stderr.write(`${Pd(`Request ID:`)}${n.requestId}\n`)}Vd(e),process.stderr.write(`${Pd(`Exit code:`)}${e.exitCode}\n`)}function Ud(e){if(e instanceof t&&(Ld()===`json`?process.stderr.write(JSON.stringify(e.toJSON(),null,2)+`
328
- `):Hd(e),process.exit(e.exitCode)),e instanceof Error){if(e.name===`AbortError`||e.name===`TimeoutError`||e.message.includes(`timed out`))return Ud(new t(`Request timed out.`,i.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
327
+ `)}function Hd(e){return e.exitCode===i.AUTH?e.message===n?e.hint:[e.hint,``,`bl auth login --api-key <your-key>`,`bl auth status`,`Get API Key: ${ut}`].filter(e=>e!==void 0).join(`
328
+ `):e.hint}function Ud(e=process.argv.slice(2),t=process.env.DASHSCOPE_OUTPUT){for(let n=0;n<e.length;n++){let r=e[n];if(r===`--output`)return f(e[n+1]||t);if(r?.startsWith(`--output=`))return f(r.slice(9))}return f(t)}function Wd(e){let n=e.cause,r=n?.code,a=n?.message,o=[];return r&&o.push(r),a&&a!==r&&o.push(a),new t(`Network request failed: ${o.length>0?o.join(`: `):`unknown cause`}`,i.NETWORK,Gd(r),{cause:e})}function Gd(e){switch(e){case`ENOTFOUND`:case`EAI_AGAIN`:return`DNS resolution failed. Check DASHSCOPE_BASE_URL or your DNS / network.`;case`ECONNREFUSED`:return`Connection refused. Check the target host/port and proxy settings.`;case`ECONNRESET`:return`Connection reset by peer. Retry, or check proxy / firewall.`;case`ETIMEDOUT`:return`Connection timed out. Check your network or try a different region.`;case`CERT_HAS_EXPIRED`:case`UNABLE_TO_VERIFY_LEAF_SIGNATURE`:case`DEPTH_ZERO_SELF_SIGNED_CERT`:return`TLS certificate error. Check system clock and CA bundle.`;default:return`Check network connection, proxy settings (HTTP_PROXY / HTTPS_PROXY), and DASHSCOPE_BASE_URL.`}}function Kd(e){let n=e.code,r=`Check the file path and permissions.`;return n===`ENOENT`?r=`File or directory not found.`:n===`EACCES`||n===`EPERM`?r=`Permission denied — check file or directory permissions.`:n===`ENOSPC`&&(r=`Disk full — free up space and try again.`),new t(`File system error: ${e.message}`,i.GENERAL,r,{cause:e})}function qd(e){let t=e.cause,n=0;for(;t instanceof Error&&n<5;)process.stderr.write(`${Bd(`Caused by:`)}${t.message}\n`),t=t.cause,n++}function Jd(e){process.stderr.write(`\n${Bd(`Error:`)}${e.message}\n`);let t=Hd(e);t&&process.stderr.write(`${Bd(`Hint:`)}${Vd(t)}\n`);let n=e.api;if(n){if(n.httpStatus!==void 0){let e=n.apiCode?` (${n.apiCode})`:``;process.stderr.write(`${Bd(`Status:`)}HTTP ${n.httpStatus}${e}\n`)}else n.apiCode&&process.stderr.write(`${Bd(`Code:`)}${n.apiCode}\n`);n.requestId&&process.stderr.write(`${Bd(`Request ID:`)}${n.requestId}\n`)}qd(e),process.stderr.write(`${Bd(`Exit code:`)}${e.exitCode}\n`)}function Yd(e){if(e instanceof t&&(Ud()===`json`?process.stderr.write(JSON.stringify(e.toJSON(),null,2)+`
329
+ `):Jd(e),process.exit(e.exitCode)),e instanceof Error){if(e.name===`AbortError`||e.name===`TimeoutError`||e.message.includes(`timed out`))return Yd(new t(`Request timed out.`,i.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
329
330
  If this happens on every request with a valid API key, you may be hitting the wrong region.
330
331
  Run: bl auth status — to check your credentials and region.
331
- Run: bl config set --key region --value cn — to override the region.`,{cause:e}));if(e instanceof TypeError&&e.message===`fetch failed`)return Ud(Rd(e));let n=e.code;if(typeof n==`string`&&n.startsWith(`E`))return Ud(Bd(e));process.stderr.write(`\n${Pd(`Error:`)}${e.message}\n`),Vd(e),process.env.DASHSCOPE_VERBOSE===`1`&&process.stderr.write(`${e.stack}\n`)}else process.stderr.write(`\n${Pd(`Error:`)}${String(e)}\n`);process.exit(i.GENERAL)}const Wd=`\x1B[0m`,Gd=`\x1B[2m`;function Kd(e){return e.startsWith(Ke())?e.replace(Ke(),`~`):e}function qd(e,t,n){if(e.quiet||!process.stderr.isTTY)return;let r=e.configPath?Kd(e.configPath):`~/.bailian/config.json`,i=e.fileRegion?`${e.fileRegion} (file)`:`cn (default)`,a=n?`${n.source} · ${n.method}`:e.apiKey?`flag · api-key`:`config`,o=w(t);process.stderr.write(`BAILIAN${Wd} ${Gd}${r}${Wd} ${Gd}|${Wd} ${Gd}Region:${Wd} ${i}${Wd} ${Gd}|${Wd} ${Gd}Auth:${Wd} ${o}${Wd} ${Gd}${a}${Wd}\n`)}ja(),_t(),va(),wt(),bt((e,t)=>{let n=process.argv.slice(2),r=n.indexOf(`--region`),i=r>=0&&n[r+1]||process.env.DASHSCOPE_REGION||ae().region||`cn`;Md.printHelp(e,t,i)}),process.on(`SIGINT`,()=>{process.stderr.write(`
332
+ Run: bl config set --key region --value cn — to override the region.`,{cause:e}));if(e instanceof TypeError&&e.message===`fetch failed`)return Yd(Wd(e));let n=e.code;if(typeof n==`string`&&n.startsWith(`E`))return Yd(Kd(e));process.stderr.write(`\n${Bd(`Error:`)}${e.message}\n`),qd(e),process.env.DASHSCOPE_VERBOSE===`1`&&process.stderr.write(`${e.stack}\n`)}else process.stderr.write(`\n${Bd(`Error:`)}${String(e)}\n`);process.exit(i.GENERAL)}const Xd=`\x1B[0m`,Zd=`\x1B[2m`;function Qd(e){return e.startsWith(Ge())?e.replace(Ge(),`~`):e}function $d(e,t,n){if(e.quiet||!process.stderr.isTTY)return;let r=e.configPath?Qd(e.configPath):`~/.bailian/config.json`,i=e.fileRegion?`${e.fileRegion} (file)`:`cn (default)`,a=n?`${n.source} · ${n.method}`:e.apiKey?`flag · api-key`:`config`,o=w(t);process.stderr.write(`BAILIAN${Xd} ${Zd}${r}${Xd} ${Zd}|${Xd} ${Zd}Region:${Xd} ${i}${Xd} ${Zd}|${Xd} ${Zd}Auth:${Xd} ${o}${Xd} ${Zd}${a}${Xd}\n`)}Ia(),gt(),Ca(),Ct(),yt((e,t)=>{let n=process.argv.slice(2),r=n.indexOf(`--region`),i=r>=0&&n[r+1]||process.env.DASHSCOPE_REGION||D().region||`cn`;Rd.printHelp(e,t,i)}),process.on(`SIGINT`,()=>{process.stderr.write(`
332
333
  Interrupted. Exiting.
333
- `),p(500).finally(()=>process.exit(130))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e});const Jd=[[`auth`,`login`],[`auth`,`logout`],[`config`,`show`],[`config`,`set`],[`config`,`export-schema`],[`update`],[`knowledge`,`retrieve`],[`pipeline`,`run`],[`pipeline`,`validate`],[`model`,`list`],[`app`,`list`],[`console`,`call`],[`usage`,`free`]];async function Yd(){let e=process.argv.slice(2);(e.includes(`--version`)||e.includes(`-v`))&&(process.stdout.write(`bl ${_a}\n`),process.exit(0));let t=st(e,a);if(e.includes(`--help`)||e.includes(`-h`)){let n=e.indexOf(`--region`),r=n>=0&&e[n+1]||process.env.DASHSCOPE_REGION||ae().region||`cn`;Md.printHelp(t,process.stderr,r),process.exit(0)}if(t.length===0){Md.printHelp([],process.stderr);let t=C(ct(e,a));t.clientName=`bailian-cli`,t.clientVersion=_a,t.apiKey||t.fileApiKey||t.fileAccessToken||t.accessTokenEnv?ht():mt(),process.exit(0)}if(Md.isGroupPath(t)){let n=e.indexOf(`--region`),r=n>=0&&e[n+1]||process.env.DASHSCOPE_REGION||ae().region||`cn`;Md.printHelp(t,process.stderr,r),process.exit(0)}let{command:n,extra:r}=Md.resolve(t),i=ct(e,[...a,...n.options??[]]);r.length>0&&(i._positional=r);let o=C(i);if(o.clientName=`bailian-cli`,o.clientVersion=_a,!Jd.some(e=>e.every((e,n)=>t[n]===e))){await Nd(o);try{let e=await O(o);qd(o,e.token,e)}catch{}}let s=wa(_a).catch(()=>{});vt(t),t[0]===`auth`&&t[1]===`login`&&!i.console&&!String(i.apiKey??``).trim()&&!String(o.apiKey??``).trim()&&!process.env.DASHSCOPE_API_KEY?.trim()&&(xt(process.stderr),process.exit(0)),await me(o,t,i,()=>n.execute(o,i)),await s;let c=t.length===1&&t[0]===`update`,l=Ca();if(l&&!o.quiet&&!c){let e=process.stderr.isTTY,t=e?`\x1B[33m`:``,n=e?`\x1B[36m`:``,r=e?`\x1B[0m`:``;process.stderr.write(`\n ${t}Update available: ${_a} → ${l}${r}\n`),process.stderr.write(` Run ${n}bl update${r} to upgrade\n\n`)}await p(1e3)}Yd().catch(e=>{p(1e3).finally(()=>Ud(e))});export{};
334
+ `),p(500).finally(()=>process.exit(130))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e});const ef=[[`auth`,`login`],[`auth`,`logout`],[`config`,`show`],[`config`,`set`],[`config`,`export-schema`],[`update`],[`knowledge`,`retrieve`],[`pipeline`,`run`],[`pipeline`,`validate`],[`model`,`list`],[`app`,`list`],[`console`,`call`],[`usage`,`free`]];async function tf(){let e=process.argv.slice(2);(e.includes(`--version`)||e.includes(`-v`))&&(process.stdout.write(`bl ${Sa}\n`),process.exit(0));let t=ot(e,a);if(e.includes(`--help`)||e.includes(`-h`)){let n=e.indexOf(`--region`),r=n>=0&&e[n+1]||process.env.DASHSCOPE_REGION||D().region||`cn`;Rd.printHelp(t,process.stderr,r),process.exit(0)}if(t.length===0){Rd.printHelp([],process.stderr);let t=C(st(e,a));t.clientName=`bailian-cli`,t.clientVersion=Sa,t.apiKey||t.fileApiKey||t.fileAccessToken||t.accessTokenEnv?mt():pt(),process.exit(0)}if(Rd.isGroupPath(t)){let n=e.indexOf(`--region`),r=n>=0&&e[n+1]||process.env.DASHSCOPE_REGION||D().region||`cn`;Rd.printHelp(t,process.stderr,r),process.exit(0)}let{command:n,extra:r}=Rd.resolve(t),i=st(e,[...a,...n.options??[]]);r.length>0&&(i._positional=r);let o=C(i);if(o.clientName=`bailian-cli`,o.clientVersion=Sa,!ef.some(e=>e.every((e,n)=>t[n]===e))){await zd(o);try{let e=await k(o);$d(o,e.token,e)}catch{}}let s=ka(Sa).catch(()=>{});_t(t),t[0]===`auth`&&t[1]===`login`&&!i.console&&!String(i.apiKey??``).trim()&&!String(o.apiKey??``).trim()&&!process.env.DASHSCOPE_API_KEY?.trim()&&(bt(process.stderr),process.exit(0)),await pe(o,t,i,()=>n.execute(o,i)),await s;let c=t.length===1&&t[0]===`update`,l=Oa();if(l&&!o.quiet&&!c){let e=process.stderr.isTTY,t=e?`\x1B[33m`:``,n=e?`\x1B[36m`:``,r=e?`\x1B[0m`:``;process.stderr.write(`\n ${t}Update available: ${Sa} → ${l}${r}\n`),process.stderr.write(` Run ${n}bl update${r} to upgrade\n\n`)}await p(1e3)}tf().catch(e=>{p(1e3).finally(()=>Yd(e))});export{};