bailian-cli 1.3.1 → 1.3.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 (2) hide show
  1. package/dist/bailian.mjs +92 -92
  2. package/package.json +2 -2
package/dist/bailian.mjs CHANGED
@@ -115,87 +115,87 @@ This process keeps the local port open for the console; press Ctrl+C when finish
115
115
  `)):process.stderr.write(`No credentials to clear.
116
116
  `)}})}));function Ni(e){let t=[],n;if(e.system&&(n=e.system),e.messagesFile){let r=e.messagesFile,i=Be(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 Pi,Fi=M((()=>{H(),I(),Pi=m({name:`text chat`,description:`Send a chat completion (OpenAI compatible, 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}=Ni(t),i=r;if(i.length===0)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your message:`});e||(process.stderr.write(`Chat cancelled.
117
117
  `),process.exit(1)),i=[{role:`user`,content:e}]}else V(`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=h(e.output),c=[];n&&c.push({role:`system`,content:n}),c.push(...i);let l={model:a,messages:c,max_tokens:t.maxTokens??4096,stream:o};if(t.temperature!==void 0&&(l.temperature=t.temperature),t.topP!==void 0&&(l.top_p=t.topP),t.enableThinking&&(l.enable_thinking=!0,t.thinkingBudget!==void 0&&(l.thinking_budget=t.thinkingBudget)),t.tool&&(l.tools=t.tool.map(e=>{try{return JSON.parse(e)}catch{let t=Be(e,`utf-8`);return JSON.parse(t)}})),e.dryRun){P({request:l},s);return}let u=f(e.baseUrl);if(o){let t=await fe(e,{url:u,method:`POST`,body:l,stream:!0}),n=``,r=!1,i=s===`text`,a=e.noColor?``:`\x1B[2m`,o=e.noColor?``:`\x1B[0m`,c=process.stdout.isTTY,d=s===`json`?process.stderr:c?process.stdout:process.stderr,f=process.stdout;for await(let e of se(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,d.write(`${a}Thinking:\n`)),i&&d.write(t.reasoning_content)),t.content&&(i&&r&&(d.write(`${o}\n\nResponse:\n`),r=!1),n+=t.content,i&&f.write(t.content))}}catch{}}r&&d.write(o),s===`json`?P({content:n},s):f.write(`
118
- `)}else{let t=await k(e,{url:u,method:`POST`,body:l}),n=t.choices?.[0]?.message?.content??``;e.quiet||s===`text`?F(n):P(t,s)}}})}));function Ii(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 Li,Ri,zi=M((()=>{H(),I(),Li=[`Chelsie`,`Cherry`,`Ethan`,`Serena`,`Tina`],Ri=m({name:`omni`,description:`Multimodal chat with text + audio output (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: ${Li.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(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your message:`});e||(process.stderr.write(`Omni chat cancelled.
119
- `),process.exit(1)),n=[e]}else V(`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=h(e.output),c=[];t.system&&c.push({role:`system`,content:t.system});let l=new Set([`system`,`user`,`assistant`]);for(let e of n){let t=e.indexOf(`:`),n=t===-1?``:e.slice(0,t);if(l.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 u=t.image||[],d=t.audio||[],p=t.video||[],m=[],g=[],_=[];if(u.length>0||d.length>0||p.length>0){let t=await A(e);for(let e of u){let n=await j(e,t.token,r);m.push(n)}for(let e of d){let n=await j(e,t.token,r);g.push(n)}for(let e of p)if(e.includes(`,`)){let n=e.split(`,`).map(e=>e.trim()).filter(Boolean);for(let e of n){let n=await j(e,t.token,r);_.push(`frame:${n}`)}}else{let n=await j(e,t.token,r);_.push(n)}}if(m.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 m)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){P({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 fe(e,{url:f(e.baseUrl),method:`POST`,body:v,stream:!0}),b=``,x=``,S=process.stdout.isTTY,C=process.stdout;for await(let e of se(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,S&&C.write(t.content)),t.audio?.data&&(x+=t.audio.data)}}catch{}}S&&b&&C.write(`
120
- `);let w;if(x&&!o){let n=Buffer.from(x,`base64`),r=Ii(n.length),i=Buffer.concat([r,n]),a=t.audioOut;if(!a){let{join:t}=await import(`path`);a=t(he(e,{subDir:`omni`}),`omni_${Date.now()}.wav`)}He(a,i),w=a,e.quiet||process.stderr.write(`Audio saved: ${a}\n`)}if(!S||s===`json`){let e={content:b};w&&(e.audio_saved=w,e.voice=i),P(e,s)}}})}));function Bi(e){let t=process.stderr.isTTY,n=0,r=null,i=e;return{start(){t&&(r=setInterval(()=>{process.stderr.write(`\r${Hi[n%Hi.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(`
121
- `)}}}var Hi,Ui=M((()=>{Hi=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`]}));async function Wi(e,n){let r=Date.now()+n.timeoutSec*1e3,a=Bi(`Polling...`);e.quiet||a.start();try{for(;Date.now()<r;){let r=await k(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 Gi=M((()=>{Ui()}));async function Ki(e,n,r){let a=await fetch(e,{headers:Ce()});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);ze(Ue(n),{recursive:!0});let c=Le(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{Ve(n)}catch{}}return{size:u}}function qi(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 Ji=M((()=>{Ui()}));function Yi(e){let t=e.concurrent;return Math.max(1,t??1)}async function Xi(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 Zi(e,t,n){return Promise.all(e.map(({url:e,destPath:r})=>t(e,r,n).then(()=>r)))}var Qi=M((()=>{}));function $i(e,t){if(e)return(t?ea:ta)[e]??e}var ea,ta,na=M((()=>{ea={"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},ta={"16:9":`1664*928`,"4:3":`1472*1104`,"1:1":`1328*1328`,"3:4":`1104*1472`,"9:16":`928*1664`}})),ra,ia,aa,oa,sa=M((()=>{ra=`Enable watermark (true/false). Omit flag to use CLI default (true).`,ia=`Enable prompt extend (true/false). Omit flag to use CLI default (true).`,aa=`Enable prompt extend (true/false). Omit flag: true for qwen-image sync; parameter omitted on async models (API default).`,oa=`Enable prompt extend (true/false). Omit flag to omit the parameter (DashScope default).`}));function ca(e){return fa.some(t=>e.startsWith(t))}async function la(e,n,r,a,o,s){let c=T(e.baseUrl),l=(await Xi(s,e,()=>k(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 da(l,a,e,o)}async function ua(e,n,r,a,o,s){let c=w(e.baseUrl),l=(await Xi(s,e,()=>k(e,{url:c,method:`POST`,body:r,async:!0}),`tasks`)).map(e=>e.output.task_id);if(a.noWait||e.async){P({task_ids:l},o);return}let u=a.pollInterval??3,d=l.map(t=>Wi(e,{url:xe(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 da(p,a,e,o,l.length===1?l[0]:void 0,l)}async function da(e,t,n,r,i,a){let o=he(n,{flagDir:t.outDir,subDir:t.outDir?void 0:`images`}),s=t.prompt||t._positional?.[0]||``,c=t.outPrefix||y(`image`,s),l=await Zi(e.length>1?e.map((e,t)=>({url:e,destPath:Ge(o,`${c}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:e[0],destPath:Ge(o,`${c}.png`)}],Ki,{quiet:n.quiet});if(n.quiet)F(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),P(t,r)}}var fa,pa,ma=M((()=>{Gi(),Ji(),Qi(),H(),I(),na(),sa(),fa=[`qwen-image-2.0`,`qwen-image-max`],pa=m({name:`image generate`,description:`Generate images (Qwen-Image / wan2.x)`,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 <bool>`,description:aa},{flag:`--watermark <bool>`,description:ra},{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 --prompt-extend false`,`bl image generate --prompt "Logo" --watermark false`,`bl image generate --prompt "An alien in the space" --watermark false`,`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(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your image prompt:`});e||(process.stderr.write(`Image generation cancelled.
123
- `),process.exit(1)),n=e}else V(`prompt`,`bl image generate --prompt <text>`);let r=t.model||e.defaultImageModel||`qwen-image-2.0`,i=ca(r),a=$i(t.size||`1:1`,i),o=t.n??1,s=Yi(t),c=pe(t.promptExtend,i?!0:void 0,`prompt-extend`),l=ge(t.watermark),u={model:r,input:{messages:[{role:`user`,content:[{text:n}]}]},parameters:{size:a,n:o,seed:t.seed,prompt_extend:c,watermark:l,negative_prompt:t.negativePrompt||void 0}},d=h(e.output);if(e.dryRun){P({request:u,mode:i?`sync`:`async`},d);return}e.quiet||process.stderr.write(`[Model: ${r}] [Mode: ${i?`sync`:`async`}]\n`),i?await la(e,r,u,t,d,s):await ua(e,r,u,t,d,s)}})})),ha,ga=M((()=>{Ji(),Qi(),H(),I(),na(),sa(),ha=m({name:`image edit`,description:`Edit an existing image with text instructions (Qwen-Image)`,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 <bool>`,description:ia},{flag:`--watermark <bool>`,description:ra},{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`,`bl image edit --image ./photo.png --prompt "把背景换成海滩" --watermark false`],async run(e,n){let r=[];Array.isArray(n.image)?r=n.image:typeof n.image==`string`&&(r=[n.image]),r.length===0&&V(`image`,`bl image edit --image <url> --prompt <text>`);let a=n.prompt;if(!a)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your edit instruction:`});e||(process.stderr.write(`Image editing cancelled.
124
- `),process.exit(1)),a=e}else V(`prompt`,`bl image edit --image <url> --prompt <text>`);let o=n.model||e.defaultImageModel||`qwen-image-2.0`,s=await A(e),c=await Promise.all(r.map(e=>j(e,s.token,o))),l=n.n??1,u=pe(n.promptExtend,!0,`prompt-extend`),d=c.map(e=>({image:e}));d.push({text:a});let f=ge(n.watermark),p={model:o,input:{messages:[{role:`user`,content:d}]},parameters:{size:$i(n.size,!0),n:l,seed:n.seed,prompt_extend:u,watermark:f,negative_prompt:n.negativePrompt||void 0}};be(p.parameters);let m=h(e.output);if(e.dryRun){P({request:p},m);return}e.quiet||process.stderr.write(`[Model: ${o}] [Mode: sync] [Images: ${c.length}]\n`);let g=T(e.baseUrl),_=(await Xi(Yi(n),e,()=>k(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=he(e,{flagDir:n.outDir,subDir:n.outDir?void 0:`images`}),b=n.outPrefix||y(`edited`,n?.prompt),x=await Zi(_.length>1?_.map((e,t)=>({url:e,destPath:Ge(v,`${b}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:_[0],destPath:Ge(v,`${b}.png`)}],Ki,{quiet:e.quiet});e.quiet?F(x.join(`
125
- `)):P({urls:_,saved:x,total:_.length},m)}})}));function _a(e){if(e)return va[e.toLowerCase()]||e}var va,ya,ba=M((()=>{Gi(),Ji(),Qi(),H(),I(),sa(),va={"720p":`1280*720`,"1080p":`1920*1080`,"480p":`832*480`},ya=m({name:`video generate`,description:`Generate a video from text or image (happyhorse-1.0-t2v / happyhorse-1.0-i2v / wan2.6-t2v)`,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 <bool>`,description:oa},{flag:`--watermark <bool>`,description:ra},{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`,`bl video generate --prompt "A cat playing with a ball" --watermark false`],async run(e,n){let r=n.prompt;if(!r)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your video prompt:`});e||(process.stderr.write(`Video generation cancelled.
126
- `),process.exit(1)),r=e}else V(`prompt`,`bl video generate --prompt <text>`);let a=n.model||e.defaultVideoModel||(n.image?`happyhorse-1.0-i2v`:`happyhorse-1.0-t2v`),o=h(e.output),s=n.image,c;s&&(c=await j(s,(await A(e)).token,a));let l=ge(n.watermark),u=pe(n.promptExtend,void 0,`prompt-extend`),d={model:a,input:{prompt:r,negative_prompt:n.negativePrompt||void 0,...c?{media:[{type:`first_frame`,url:c}]}:{}},parameters:{resolution:_a(n.resolution)||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,prompt_extend:u,watermark:l,seed:n.seed}};if(e.dryRun){P({request:d},o);return}let f=Yi(n),p=Ee(e.baseUrl),m=(await Xi(f,e,()=>k(e,{url:p,method:`POST`,body:d,async:!0}),`tasks`)).map(e=>e.output.task_id);if(e.quiet||process.stderr.write(`[Model: ${a}]\n`),n.noWait||e.async){P(m.length===1?{task_id:m[0]}:{task_ids:m},o);return}let g=n.pollInterval??5,_=m.map(t=>Wi(e,{url:xe(e.baseUrl,t),intervalSec:g,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}})),v=await Promise.all(_),y=[];for(let e=0;e<v.length;e++){let t=v[e],n=t.output.video_url||t.output.results&&t.output.results[0]?.url;n&&y.push({taskId:m[e],videoUrl:n})}if(y.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 Ki(y[0].videoUrl,t,{quiet:e.quiet});e.quiet?F(t):P({task_id:y[0].taskId,video_url:y[0].videoUrl,status:`SUCCEEDED`,saved:t,size:qi(r)},o);return}let b=he(e,{subDir:`videos`}),{join:x}=await import(`path`),S=[];await Promise.all(y.map(async({taskId:t,videoUrl:n})=>{let r=x(b,`${t}.mp4`);await Ki(n,r,{quiet:e.quiet}),S.push({task_id:t,video_url:n,saved:r})})),S.length===1?P(S[0],o):P({videos:S,total:S.length},o)}})})),xa,Sa=M((()=>{Gi(),Ji(),H(),I(),sa(),xa=m({name:`video edit`,description:`Edit a video with happyhorse-1.0-video-edit (style transfer, object replacement, etc.)`,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 <bool>`,description:oa},{flag:`--watermark <bool>`,description:ra},{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`,`bl video edit --video https://example.com/input.mp4 --prompt "给视频里的小猫穿上衣服" --watermark false`],async run(e,n){let r=n.video;if(!r)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter the video URL to edit:`});e||(process.stderr.write(`Video editing cancelled.
118
+ `)}else{let t=await k(e,{url:u,method:`POST`,body:l}),n=t.choices?.[0]?.message?.content??``;e.quiet||s===`text`?F(n):P(t,s)}}})}));function Ii(e){let n=e.split(`?`)[0].split(`#`)[0],r=We(n).slice(1).toLowerCase();if(!r)throw new t(`Cannot infer audio format from "${e}". Use a file/URL whose path ends with: ${Bi.join(`, `)}.`,i.USAGE);let a=zi[r];if(!a)throw new t(`Unsupported audio extension ".${r}" for "${e}". Supported extensions: ${Bi.join(`, `)}.`,i.USAGE);return a}function Li(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 Ri,zi,Bi,Vi,Hi=M((()=>{H(),I(),Ri=[`Chelsie`,`Cherry`,`Ethan`,`Serena`,`Tina`],zi={wav:`wav`,mp3:`mp3`,amr:`amr`,aac:`aac`,m4a:`aac`,ogg:`ogg`,"3gp":`3gp`,"3gpp":`3gpp`},Bi=Object.keys(zi),Vi=m({name:`omni`,description:`Multimodal chat with text + audio output (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 (.wav/.mp3/.amr/.aac/.m4a/.ogg/.3gp/.3gpp)`,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: ${Ri.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(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your message:`});e||(process.stderr.write(`Omni chat cancelled.
119
+ `),process.exit(1)),n=[e]}else V(`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=h(e.output),c=[];t.system&&c.push({role:`system`,content:t.system});let l=new Set([`system`,`user`,`assistant`]);for(let e of n){let t=e.indexOf(`:`),n=t===-1?``:e.slice(0,t);if(l.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 u=t.image||[],d=t.audio||[],p=t.video||[],m=[],g=[],_=[];if(u.length>0||d.length>0||p.length>0){let t=await A(e);for(let e of u){let n=await j(e,t.token,r);m.push(n)}for(let e of d){let n=await j(e,t.token,r);g.push({source:e,data:n})}for(let e of p)if(e.includes(`,`)){let n=e.split(`,`).map(e=>e.trim()).filter(Boolean);for(let e of n){let n=await j(e,t.token,r);_.push(`frame:${n}`)}}else{let n=await j(e,t.token,r);_.push(n)}}if(m.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 m)n.push({type:`image_url`,image_url:{url:e}});for(let{source:e,data:t}of g)n.push({type:`input_audio`,input_audio:{data:t,format:Ii(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){P({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 fe(e,{url:f(e.baseUrl),method:`POST`,body:v,stream:!0}),b=``,x=``,S=process.stdout.isTTY,C=process.stdout;for await(let e of se(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,S&&C.write(t.content)),t.audio?.data&&(x+=t.audio.data)}}catch{}}S&&b&&C.write(`
120
+ `);let w;if(x&&!o){let n=Buffer.from(x,`base64`),r=Li(n.length),i=Buffer.concat([r,n]),a=t.audioOut;if(!a){let{join:t}=await import(`path`);a=t(he(e,{subDir:`omni`}),`omni_${Date.now()}.wav`)}He(a,i),w=a,e.quiet||process.stderr.write(`Audio saved: ${a}\n`)}if(!S||s===`json`){let e={content:b};w&&(e.audio_saved=w,e.voice=i),P(e,s)}}})}));function Ui(e){let t=process.stderr.isTTY,n=0,r=null,i=e;return{start(){t&&(r=setInterval(()=>{process.stderr.write(`\r${Gi[n%Gi.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 Wi(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 Gi,Ki=M((()=>{Gi=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`]}));async function qi(e,n){let r=Date.now()+n.timeoutSec*1e3,a=Ui(`Polling...`);e.quiet||a.start();try{for(;Date.now()<r;){let r=await k(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 Ji=M((()=>{Ki()}));async function Yi(e,n,r){let a=await fetch(e,{headers:Ce()});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);ze(Ue(n),{recursive:!0});let c=Le(n),l=o>0&&!r?.quiet?Wi(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{Ve(n)}catch{}}return{size:u}}function Xi(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 Zi=M((()=>{Ki()}));function Qi(e){let t=e.concurrent;return Math.max(1,t??1)}async function $i(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 ea(e,t,n){return Promise.all(e.map(({url:e,destPath:r})=>t(e,r,n).then(()=>r)))}var ta=M((()=>{}));function na(e,t){if(e)return(t?ra:ia)[e]??e}var ra,ia,aa=M((()=>{ra={"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},ia={"16:9":`1664*928`,"4:3":`1472*1104`,"1:1":`1328*1328`,"3:4":`1104*1472`,"9:16":`928*1664`}})),oa,sa,ca,la,ua=M((()=>{oa=`Enable watermark (true/false). Omit flag to use CLI default (true).`,sa=`Enable prompt extend (true/false). Omit flag to use CLI default (true).`,ca=`Enable prompt extend (true/false). Omit flag: true for qwen-image sync; parameter omitted on async models (API default).`,la=`Enable prompt extend (true/false). Omit flag to omit the parameter (DashScope default).`}));function da(e){return ha.some(t=>e.startsWith(t))}async function fa(e,n,r,a,o,s){let c=T(e.baseUrl),l=(await $i(s,e,()=>k(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 ma(l,a,e,o)}async function pa(e,n,r,a,o,s){let c=w(e.baseUrl),l=(await $i(s,e,()=>k(e,{url:c,method:`POST`,body:r,async:!0}),`tasks`)).map(e=>e.output.task_id);if(a.noWait||e.async){P({task_ids:l},o);return}let u=a.pollInterval??3,d=l.map(t=>qi(e,{url:xe(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 ma(p,a,e,o,l.length===1?l[0]:void 0,l)}async function ma(e,t,n,r,i,a){let o=he(n,{flagDir:t.outDir,subDir:t.outDir?void 0:`images`}),s=t.prompt||t._positional?.[0]||``,c=t.outPrefix||y(`image`,s),l=await ea(e.length>1?e.map((e,t)=>({url:e,destPath:Ge(o,`${c}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:e[0],destPath:Ge(o,`${c}.png`)}],Yi,{quiet:n.quiet});if(n.quiet)F(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),P(t,r)}}var ha,ga,_a=M((()=>{Ji(),Zi(),ta(),H(),I(),aa(),ua(),ha=[`qwen-image-2.0`,`qwen-image-max`],ga=m({name:`image generate`,description:`Generate images (Qwen-Image / wan2.x)`,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 <bool>`,description:ca},{flag:`--watermark <bool>`,description:oa},{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 --prompt-extend false`,`bl image generate --prompt "Logo" --watermark false`,`bl image generate --prompt "An alien in the space" --watermark false`,`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(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your image prompt:`});e||(process.stderr.write(`Image generation cancelled.
123
+ `),process.exit(1)),n=e}else V(`prompt`,`bl image generate --prompt <text>`);let r=t.model||e.defaultImageModel||`qwen-image-2.0`,i=da(r),a=na(t.size||`1:1`,i),o=t.n??1,s=Qi(t),c=pe(t.promptExtend,i?!0:void 0,`prompt-extend`),l=ge(t.watermark),u={model:r,input:{messages:[{role:`user`,content:[{text:n}]}]},parameters:{size:a,n:o,seed:t.seed,prompt_extend:c,watermark:l,negative_prompt:t.negativePrompt||void 0}},d=h(e.output);if(e.dryRun){P({request:u,mode:i?`sync`:`async`},d);return}e.quiet||process.stderr.write(`[Model: ${r}] [Mode: ${i?`sync`:`async`}]\n`),i?await fa(e,r,u,t,d,s):await pa(e,r,u,t,d,s)}})})),va,ya=M((()=>{Zi(),ta(),H(),I(),aa(),ua(),va=m({name:`image edit`,description:`Edit an existing image with text instructions (Qwen-Image)`,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 <bool>`,description:sa},{flag:`--watermark <bool>`,description:oa},{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`,`bl image edit --image ./photo.png --prompt "把背景换成海滩" --watermark false`],async run(e,n){let r=[];Array.isArray(n.image)?r=n.image:typeof n.image==`string`&&(r=[n.image]),r.length===0&&V(`image`,`bl image edit --image <url> --prompt <text>`);let a=n.prompt;if(!a)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your edit instruction:`});e||(process.stderr.write(`Image editing cancelled.
124
+ `),process.exit(1)),a=e}else V(`prompt`,`bl image edit --image <url> --prompt <text>`);let o=n.model||e.defaultImageModel||`qwen-image-2.0`,s=await A(e),c=await Promise.all(r.map(e=>j(e,s.token,o))),l=n.n??1,u=pe(n.promptExtend,!0,`prompt-extend`),d=c.map(e=>({image:e}));d.push({text:a});let f=ge(n.watermark),p={model:o,input:{messages:[{role:`user`,content:d}]},parameters:{size:na(n.size,!0),n:l,seed:n.seed,prompt_extend:u,watermark:f,negative_prompt:n.negativePrompt||void 0}};be(p.parameters);let m=h(e.output);if(e.dryRun){P({request:p},m);return}e.quiet||process.stderr.write(`[Model: ${o}] [Mode: sync] [Images: ${c.length}]\n`);let g=T(e.baseUrl),_=(await $i(Qi(n),e,()=>k(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=he(e,{flagDir:n.outDir,subDir:n.outDir?void 0:`images`}),b=n.outPrefix||y(`edited`,n?.prompt),x=await ea(_.length>1?_.map((e,t)=>({url:e,destPath:Ge(v,`${b}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:_[0],destPath:Ge(v,`${b}.png`)}],Yi,{quiet:e.quiet});e.quiet?F(x.join(`
125
+ `)):P({urls:_,saved:x,total:_.length},m)}})}));function ba(e){if(e)return xa[e.toLowerCase()]||e}var xa,Sa,Ca=M((()=>{Ji(),Zi(),ta(),H(),I(),ua(),xa={"720p":`1280*720`,"1080p":`1920*1080`,"480p":`832*480`},Sa=m({name:`video generate`,description:`Generate a video from text or image (happyhorse-1.0-t2v / happyhorse-1.0-i2v / wan2.6-t2v)`,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 <bool>`,description:la},{flag:`--watermark <bool>`,description:oa},{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`,`bl video generate --prompt "A cat playing with a ball" --watermark false`],async run(e,n){let r=n.prompt;if(!r)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your video prompt:`});e||(process.stderr.write(`Video generation cancelled.
126
+ `),process.exit(1)),r=e}else V(`prompt`,`bl video generate --prompt <text>`);let a=n.model||e.defaultVideoModel||(n.image?`happyhorse-1.0-i2v`:`happyhorse-1.0-t2v`),o=h(e.output),s=n.image,c;s&&(c=await j(s,(await A(e)).token,a));let l=ge(n.watermark),u=pe(n.promptExtend,void 0,`prompt-extend`),d={model:a,input:{prompt:r,negative_prompt:n.negativePrompt||void 0,...c?{media:[{type:`first_frame`,url:c}]}:{}},parameters:{resolution:ba(n.resolution)||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,prompt_extend:u,watermark:l,seed:n.seed}};if(e.dryRun){P({request:d},o);return}let f=Qi(n),p=Ee(e.baseUrl),m=(await $i(f,e,()=>k(e,{url:p,method:`POST`,body:d,async:!0}),`tasks`)).map(e=>e.output.task_id);if(e.quiet||process.stderr.write(`[Model: ${a}]\n`),n.noWait||e.async){P(m.length===1?{task_id:m[0]}:{task_ids:m},o);return}let g=n.pollInterval??5,_=m.map(t=>qi(e,{url:xe(e.baseUrl,t),intervalSec:g,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}})),v=await Promise.all(_),y=[];for(let e=0;e<v.length;e++){let t=v[e],n=t.output.video_url||t.output.results&&t.output.results[0]?.url;n&&y.push({taskId:m[e],videoUrl:n})}if(y.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 Yi(y[0].videoUrl,t,{quiet:e.quiet});e.quiet?F(t):P({task_id:y[0].taskId,video_url:y[0].videoUrl,status:`SUCCEEDED`,saved:t,size:Xi(r)},o);return}let b=he(e,{subDir:`videos`}),{join:x}=await import(`path`),S=[];await Promise.all(y.map(async({taskId:t,videoUrl:n})=>{let r=x(b,`${t}.mp4`);await Yi(n,r,{quiet:e.quiet}),S.push({task_id:t,video_url:n,saved:r})})),S.length===1?P(S[0],o):P({videos:S,total:S.length},o)}})})),wa,Ta=M((()=>{Ji(),Zi(),H(),I(),ua(),wa=m({name:`video edit`,description:`Edit a video with happyhorse-1.0-video-edit (style transfer, object replacement, etc.)`,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 <bool>`,description:la},{flag:`--watermark <bool>`,description:oa},{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`,`bl video edit --video https://example.com/input.mp4 --prompt "给视频里的小猫穿上衣服" --watermark false`],async run(e,n){let r=n.video;if(!r)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter the video URL to edit:`});e||(process.stderr.write(`Video editing cancelled.
127
127
  `),process.exit(1)),r=e}else V(`video`,`bl video edit --video <url> --prompt <text>`);let a=n.prompt;if(!a&&E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your edit instruction:`});e||(process.stderr.write(`Video editing cancelled.
128
128
  `),process.exit(1)),a=e}let o=n.model||`happyhorse-1.0-video-edit`,s=h(e.output),c=await A(e),l=[{type:`video`,url:await j(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 j(t,c.token,o);l.push({type:`reference_image`,url:e})}}let d=pe(n.promptExtend,void 0,`prompt-extend`),f=ge(n.watermark),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:f,seed:n.seed}};if(e.dryRun){P({request:p},s);return}let m=(await k(e,{url:Ee(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){P({task_id:m},s);return}let g=n.pollInterval??15,_=await Wi(e,{url:xe(e.baseUrl,m),intervalSec:g,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}}),v=_.output.video_url||_.output.results&&_.output.results[0]?.url;if(!v)throw new t(`Task completed but no video URL returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Ki(v,t,{quiet:e.quiet});e.quiet?F(t):P({task_id:m,video_url:v,status:`SUCCEEDED`,saved:t,size:qi(r)},s);return}let y=await import(`path`),b=he(e,{subDir:`videos`}),x=y.join(b,`${m}.mp4`);await Ki(v,x,{quiet:e.quiet}),P({task_id:m,video_url:v,saved:x},s)}})})),Ca,wa=M((()=>{Gi(),Ji(),H(),I(),sa(),Ca=m({name:`video ref`,description:`Reference-to-video generation (happyhorse-1.0-r2v / wan2.6-r2v): multi-subject, multi-shot with voice`,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 <bool>`,description:oa},{flag:`--watermark <bool>`,description:ra},{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`,`bl video ref --prompt "图1在喝水" --image person.jpg --watermark false`],async run(e,n){let r=n.prompt;if(!r)if(E({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
+ `)),n.noWait||e.async){P({task_id:m},s);return}let g=n.pollInterval??15,_=await qi(e,{url:xe(e.baseUrl,m),intervalSec:g,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}}),v=_.output.video_url||_.output.results&&_.output.results[0]?.url;if(!v)throw new t(`Task completed but no video URL returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Yi(v,t,{quiet:e.quiet});e.quiet?F(t):P({task_id:m,video_url:v,status:`SUCCEEDED`,saved:t,size:Xi(r)},s);return}let y=await import(`path`),b=he(e,{subDir:`videos`}),x=y.join(b,`${m}.mp4`);await Yi(v,x,{quiet:e.quiet}),P({task_id:m,video_url:v,saved:x},s)}})})),Ea,Da=M((()=>{Ji(),Zi(),H(),I(),ua(),Ea=m({name:`video ref`,description:`Reference-to-video generation (happyhorse-1.0-r2v / wan2.6-r2v): multi-subject, multi-shot with voice`,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 <bool>`,description:la},{flag:`--watermark <bool>`,description:oa},{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`,`bl video ref --prompt "图1在喝水" --image person.jpg --watermark false`],async run(e,n){let r=n.prompt;if(!r)if(E({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.
130
130
  `),process.exit(1)),r=e}else V(`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=h(e.output),d=await A(e),f=[];for(let e=0;e<a.length;e++){let t={type:`reference_image`,url:await j(a[e],d.token,l)};s[e]&&(t.reference_voice=await j(s[e],d.token,l)),f.push(t)}for(let e=0;e<o.length;e++){let t={type:`reference_video`,url:await j(o[e],d.token,l)};c[e]&&(t.reference_voice=await j(c[e],d.token,l)),f.push(t)}let p=pe(n.promptExtend,void 0,`prompt-extend`),m=ge(n.watermark),g={model:l,input:{prompt:r,media:f},parameters:{resolution:n.resolution||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,prompt_extend:p,watermark:m,seed:n.seed}};if(e.dryRun){P({request:g},u);return}let _=(await k(e,{url:Ee(e.baseUrl),method:`POST`,body:g,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){P({task_id:_},u);return}let v=n.pollInterval??15,y=await Wi(e,{url:xe(e.baseUrl,_),intervalSec:v,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}}),b=y.output.video_url||y.output.results&&y.output.results[0]?.url;if(!b)throw new t(`Task completed but no video URL returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Ki(b,t,{quiet:e.quiet});e.quiet?F(t):P({task_id:_,video_url:b,status:`SUCCEEDED`,saved:t,size:qi(r)},u);return}let{join:x}=await import(`path`),S=x(he(e,{subDir:`videos`}),`${_}.mp4`);await Ki(b,S,{quiet:e.quiet}),P({task_id:_,video_url:b,saved:S},u)}})})),Ta,Ea=M((()=>{H(),I(),Ta=m({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||V(`task-id`,`bl video task get --task-id <id>`);let r=h(e.output);if(e.dryRun){P({task_id:n},r);return}let i=await k(e,{url:xe(e.baseUrl,n)});if(e.quiet){F(i.output.task_status);return}P({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)}})})),Da,Oa=M((()=>{Ji(),H(),I(),Da=m({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||V(`task-id`,`bl video download --task-id <id> --out <path>`);let a=n.out;a||V(`out`,`bl video download --task-id <id> --out video.mp4`);let o=h(e.output);if(e.dryRun){P({task_id:r,action:`download`,out:a},o);return}let s=await k(e,{url:xe(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 Ki(c,a,{quiet:e.quiet});if(e.quiet){F(a);return}P({saved:a,size:qi(l)},o)}})}));function ka(e){let t=We(e).toLowerCase().split(`?`)[0];return!!(Ma.has(t)||/\.(mp4|mov|avi|mkv|webm|flv|wmv)(\?|$)/i.test(e))}async function Aa(e){if(e.startsWith(`data:`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`oss://`))return e;if(!Re(e))throw new t(`File not found: ${e}`,i.USAGE);let n=We(e).toLowerCase(),r=ja[n];if(!r)throw new t(`Unsupported image format "${n}". Supported: jpg, jpeg, png, webp`,i.USAGE);return`data:${r};base64,${Be(e).toString(`base64`)}`}var ja,Ma,Na,Pa=M((()=>{H(),I(),ja={".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".webp":`image/webp`},Ma=new Set([`.mp4`,`.mov`,`.avi`,`.mkv`,`.webm`,`.flv`,`.wmv`]),Na=m({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&&ka(r)&&(a.push(r),r=void 0);let s=a.length>0,c=s?`Describe the video.`:`Describe the image.`,l=n.prompt||c;if(!r&&!s)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter image/video path or URL:`});e||(process.stderr.write(`Vision describe cancelled.
132
- `),process.exit(1)),ka(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 u=h(e.output);if(e.dryRun){P({request:{prompt:l,image:r,video:a.length?a:void 0,model:o}},u);return}let d=[];if(a.length>0)for(let n of a){let r=n;if(D(n)){if(!Re(n))throw new t(`Video file not found: ${n}`,i.USAGE);r=await j(n,(await A(e)).token,o)}d.push({type:`video_url`,video_url:{url:r}})}if(r){let t=await Aa(r),n=t;if(D(r)&&t.startsWith(`data:`)){let{statSync:t}=await import(`fs`);if(t(r).size>5*1024*1024){let t=await A(e);n=await j(r,t.token,o)}}d.push({type:`image_url`,image_url:{url:n}})}d.push({type:`text`,text:l});let p={model:o,messages:[{role:`user`,content:d}]},m=await k(e,{url:f(e.baseUrl),method:`POST`,body:p}),g=m.choices?.[0]?.message?.content;if(u!==`text`){P(m,u);return}F(g||``)}})})),Fa,Ia=M((()=>{I(),Fa=m({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=ue(),r=h(e.output),i={region:e.region,base_url:e.baseUrl,output:e.output,timeout:e.timeout,config_file:S()};n.api_key&&(i.api_key=O(n.api_key)),n.access_token&&(i.access_token=O(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),P(i,r)}})})),La,Ra,za,Ba,Va=M((()=>{I(),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`],Ra=new Set([`api_key`,`access_token`,`access_key_id`,`access_key_secret`]),za={"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`},Ba=m({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=za[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=h(e.output);if(e.dryRun){P({would_set:{[o]:a}},s);return}let c=ue();if(c[o]=o===`timeout`?Number(a):a,await De(c),!e.quiet){let e=Ra.has(o)?O(String(c[o])):c[o];P({[o]:e},s)}}})})),Ha,Ua,Wa=M((()=>{Ha=[`auth `,`config `,`update`],Ua=m({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(()=>(bm(),vm)),a=n.command;if(a){let e=r[a];if(!e)throw new t(`Command "${a}" not found.`,i.USAGE);let n=b(e);process.stdout.write(JSON.stringify(n,null,2)+`
134
- `);return}let o=Object.values(r).filter(e=>!Ha.some(t=>e.name.startsWith(t))).map(e=>b(e));process.stdout.write(JSON.stringify(o,null,2)+`
135
- `)}})}));bi(),ki(),Mi(),Fi(),zi(),ma(),ga(),ba(),Sa(),wa(),Ea(),Oa(),Pa(),Ia(),Va(),Wa();var Ga=`1.3.1`,Ka,qa=M((()=>{Ka=Ga}));function Ja(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 Ya(){try{let e=Be(no(),`utf-8`);return JSON.parse(e)}catch{return null}}function Xa(e){try{He(no(),JSON.stringify(e))}catch{}}async function Za(e=io){try{let t=to.replace(`/`,`%2f`),n=await fetch(`${eo}/${t}/latest`,{headers:{Accept:`application/json`,...Ce()},signal:AbortSignal.timeout(e)});return n.ok?(await n.json()).version??null:null}catch{return null}}function Qa(){return ao}async function $a(e){if(process.env.CI||!process.stderr.isTTY)return;let t=Ya(),n=Date.now();if(t&&n-t.lastChecked<ro){t.latestVersion&&Ja(t.latestVersion,e)&&(ao=t.latestVersion);return}let r=await Za();r&&(Xa({lastChecked:n,latestVersion:r}),r&&Ja(r,e)&&(ao=r))}var eo,to,no,ro,io,ao,oo=M((()=>{eo=`https://registry.npmjs.org`,to=`bailian-cli`,no=()=>Ge(x(),`update-state.json`),ro=14400*1e3,io=3e3,ao=null}));function so(){return{cmd:`npm install -g ${to}@latest`,label:`npm`}}function co(e){let{green:t,yellow:n,reset:r}=e;process.stderr.write(`
131
+ `)),n.noWait||e.async){P({task_id:_},u);return}let v=n.pollInterval??15,y=await qi(e,{url:xe(e.baseUrl,_),intervalSec:v,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}}),b=y.output.video_url||y.output.results&&y.output.results[0]?.url;if(!b)throw new t(`Task completed but no video URL returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Yi(b,t,{quiet:e.quiet});e.quiet?F(t):P({task_id:_,video_url:b,status:`SUCCEEDED`,saved:t,size:Xi(r)},u);return}let{join:x}=await import(`path`),S=x(he(e,{subDir:`videos`}),`${_}.mp4`);await Yi(b,S,{quiet:e.quiet}),P({task_id:_,video_url:b,saved:S},u)}})})),Oa,ka=M((()=>{H(),I(),Oa=m({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||V(`task-id`,`bl video task get --task-id <id>`);let r=h(e.output);if(e.dryRun){P({task_id:n},r);return}let i=await k(e,{url:xe(e.baseUrl,n)});if(e.quiet){F(i.output.task_status);return}P({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)}})})),Aa,ja=M((()=>{Zi(),H(),I(),Aa=m({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||V(`task-id`,`bl video download --task-id <id> --out <path>`);let a=n.out;a||V(`out`,`bl video download --task-id <id> --out video.mp4`);let o=h(e.output);if(e.dryRun){P({task_id:r,action:`download`,out:a},o);return}let s=await k(e,{url:xe(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 Yi(c,a,{quiet:e.quiet});if(e.quiet){F(a);return}P({saved:a,size:Xi(l)},o)}})}));function Ma(e){let t=We(e).toLowerCase().split(`?`)[0];return!!(Fa.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(!Re(e))throw new t(`File not found: ${e}`,i.USAGE);let n=We(e).toLowerCase(),r=Pa[n];if(!r)throw new t(`Unsupported image format "${n}". Supported: jpg, jpeg, png, webp`,i.USAGE);return`data:${r};base64,${Be(e).toString(`base64`)}`}var Pa,Fa,Ia,La=M((()=>{H(),I(),Pa={".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".webp":`image/webp`},Fa=new Set([`.mp4`,`.mov`,`.avi`,`.mkv`,`.webm`,`.flv`,`.wmv`]),Ia=m({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&&Ma(r)&&(a.push(r),r=void 0);let s=a.length>0,c=s?`Describe the video.`:`Describe the image.`,l=n.prompt||c;if(!r&&!s)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter image/video path or URL:`});e||(process.stderr.write(`Vision describe cancelled.
132
+ `),process.exit(1)),Ma(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 u=h(e.output);if(e.dryRun){P({request:{prompt:l,image:r,video:a.length?a:void 0,model:o}},u);return}let d=[];if(a.length>0)for(let n of a){let r=n;if(D(n)){if(!Re(n))throw new t(`Video file not found: ${n}`,i.USAGE);r=await j(n,(await A(e)).token,o)}d.push({type:`video_url`,video_url:{url:r}})}if(r){let t=await Na(r),n=t;if(D(r)&&t.startsWith(`data:`)){let{statSync:t}=await import(`fs`);if(t(r).size>5*1024*1024){let t=await A(e);n=await j(r,t.token,o)}}d.push({type:`image_url`,image_url:{url:n}})}d.push({type:`text`,text:l});let p={model:o,messages:[{role:`user`,content:d}]},m=await k(e,{url:f(e.baseUrl),method:`POST`,body:p}),g=m.choices?.[0]?.message?.content;if(u!==`text`){P(m,u);return}F(g||``)}})})),Ra,za=M((()=>{I(),Ra=m({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=ue(),r=h(e.output),i={region:e.region,base_url:e.baseUrl,output:e.output,timeout:e.timeout,config_file:S()};n.api_key&&(i.api_key=O(n.api_key)),n.access_token&&(i.access_token=O(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),P(i,r)}})})),Ba,Va,Ha,Ua,Wa=M((()=>{I(),Ba=[`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`],Va=new Set([`api_key`,`access_token`,`access_key_id`,`access_key_secret`]),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`},Ua=m({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(!Ba.includes(o))throw new t(`Invalid config key "${r}". Valid keys: ${Ba.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=h(e.output);if(e.dryRun){P({would_set:{[o]:a}},s);return}let c=ue();if(c[o]=o===`timeout`?Number(a):a,await De(c),!e.quiet){let e=Va.has(o)?O(String(c[o])):c[o];P({[o]:e},s)}}})})),Ga,Ka,qa=M((()=>{Ga=[`auth `,`config `,`update`],Ka=m({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(()=>(Cm(),xm)),a=n.command;if(a){let e=r[a];if(!e)throw new t(`Command "${a}" not found.`,i.USAGE);let n=b(e);process.stdout.write(JSON.stringify(n,null,2)+`
134
+ `);return}let o=Object.values(r).filter(e=>!Ga.some(t=>e.name.startsWith(t))).map(e=>b(e));process.stdout.write(JSON.stringify(o,null,2)+`
135
+ `)}})}));bi(),ki(),Mi(),Fi(),Hi(),_a(),ya(),Ca(),Ta(),Da(),ka(),ja(),La(),za(),Wa(),qa();var Ja=`1.3.3`,Ya,Xa=M((()=>{Ya=Ja}));function Za(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 Qa(){try{let e=Be(ao(),`utf-8`);return JSON.parse(e)}catch{return null}}function $a(e){try{He(ao(),JSON.stringify(e))}catch{}}async function eo(e=so){try{let t=io.replace(`/`,`%2f`),n=await fetch(`${ro}/${t}/latest`,{headers:{Accept:`application/json`,...Ce()},signal:AbortSignal.timeout(e)});return n.ok?(await n.json()).version??null:null}catch{return null}}function to(){return co}async function no(e){if(process.env.CI||!process.stderr.isTTY)return;let t=Qa(),n=Date.now();if(t&&n-t.lastChecked<oo){t.latestVersion&&Za(t.latestVersion,e)&&(co=t.latestVersion);return}let r=await eo();r&&($a({lastChecked:n,latestVersion:r}),r&&Za(r,e)&&(co=r))}var ro,io,ao,oo,so,co,lo=M((()=>{ro=`https://registry.npmjs.org`,io=`bailian-cli`,ao=()=>Ge(x(),`update-state.json`),oo=14400*1e3,so=3e3,co=null}));function uo(){return{cmd:`npm install -g ${io}@latest`,label:`npm`}}function fo(e){let{green:t,yellow:n,reset:r}=e;process.stderr.write(`
136
136
  Updating agent skill...
137
- `);try{Ke(`npx skills update ${lo} -g -y`,{stdio:`inherit`}),process.stderr.write(`${t}\u2713 Agent skill updated.${r}\n`)}catch{process.stderr.write(`${n}Agent skill update skipped. Run manually: npx skills update ${lo} -g -y${r}\n`)}}var lo,uo,fo=M((()=>{qa(),oo(),lo=`bailian-cli`,uo=m({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}${Ka}${r}\n`),process.stderr.write(`Checking for updates...
138
- `);let i=await Za(5e3);if(i&&i===Ka){process.stderr.write(`${t}\u2713 Already up to date (${Ka}).${r}\n`);return}i&&process.stderr.write(`Latest version: ${t}${i}${r}\n\n`);let{cmd:a,label:o}=so();process.stderr.write(`Updating ${to} via ${o}...\n\n`);try{Ke(a,{stdio:`inherit`});try{let e=Ke(`bl --version 2>/dev/null`,{encoding:`utf-8`}).trim().replace(/^bl\s+/,``);process.stderr.write(`\n${t}\u2713 Update complete: ${Ka} \u2192 ${e}${r}\n`);try{He(Ge(x(),`update-state.json`),JSON.stringify({lastChecked:Date.now(),latestVersion:e}))}catch{}}catch{process.stderr.write(`\n${t}\u2713 Update complete.${r}\n`)}co({green:t,yellow:n,reset:r})}catch{process.stderr.write(`
137
+ `);try{Ke(`npx skills update ${po} -g -y`,{stdio:`inherit`}),process.stderr.write(`${t}\u2713 Agent skill updated.${r}\n`)}catch{process.stderr.write(`${n}Agent skill update skipped. Run manually: npx skills update ${po} -g -y${r}\n`)}}var po,mo,ho=M((()=>{Xa(),lo(),po=`bailian-cli`,mo=m({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}${Ya}${r}\n`),process.stderr.write(`Checking for updates...
138
+ `);let i=await eo(5e3);if(i&&i===Ya){process.stderr.write(`${t}\u2713 Already up to date (${Ya}).${r}\n`);return}i&&process.stderr.write(`Latest version: ${t}${i}${r}\n\n`);let{cmd:a,label:o}=uo();process.stderr.write(`Updating ${io} via ${o}...\n\n`);try{Ke(a,{stdio:`inherit`});try{let e=Ke(`bl --version 2>/dev/null`,{encoding:`utf-8`}).trim().replace(/^bl\s+/,``);process.stderr.write(`\n${t}\u2713 Update complete: ${Ya} \u2192 ${e}${r}\n`);try{He(Ge(x(),`update-state.json`),JSON.stringify({lastChecked:Date.now(),latestVersion:e}))}catch{}}catch{process.stderr.write(`\n${t}\u2713 Update complete.${r}\n`)}fo({green:t,yellow:n,reset:r})}catch{process.stderr.write(`
139
139
  Automatic update failed. Please run manually:
140
- `),process.stderr.write(` ${a}\n\n`)}}})})),po,mo=M((()=>{H(),I(),po=m({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||V(`app-id`,`bl app call --app-id <id> --prompt <text>`);let r=t.prompt;r||V(`prompt`,`bl app call --app-id <id> --prompt <text>`);let i=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,a=h(e.output),o={input:{prompt:r},parameters:{incremental_output:i}};t.sessionId&&(o.input.session_id=t.sessionId);let s=t.image;s&&s.length>0&&(o.input.image_list=s);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
140
+ `),process.stderr.write(` ${a}\n\n`)}}})})),go,_o=M((()=>{H(),I(),go=m({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||V(`app-id`,`bl app call --app-id <id> --prompt <text>`);let r=t.prompt;r||V(`prompt`,`bl app call --app-id <id> --prompt <text>`);let i=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,a=h(e.output),o={input:{prompt:r},parameters:{incremental_output:i}};t.sessionId&&(o.input.session_id=t.sessionId);let s=t.image;s&&s.length>0&&(o.input.image_list=s);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
141
141
  `),process.exit(1)}if(e.dryRun){P({endpoint:c(e.baseUrl,n),request:o},a);return}let u=c(e.baseUrl,n);if(i){let n=await fe(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 se(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`?P({text:r,session_id:i},a):process.stdout.write(`
142
- `)}else{let t=await k(e,{url:u,method:`POST`,body:o}),n=t.output?.text??``;e.quiet||a===`text`?F(n):P(t,a)}}})})),ho,go,_o=M((()=>{I(),ho=`zeldaEasy.broadscope-bailian.app-control.list`,go=m({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=h(e.output),s=await me(e),c={reqDTO:{name:n,notInTypes:[10],type:5,statuses:[1,4],page_no:r,page_size:i}};if(e.dryRun){P({api:ho,data:c,region:a,token:s.token.slice(0,8)+`...`},o);return}let l=await d(e,s.token,{api:ho,data:c,region:a}),u=l?.data?.DataV2?.data?.data?.list??[];P({total:l?.data?.DataV2?.data?.data?.total??0,apps:u.map(e=>({code:e.code,name:e.name,user_prompt_params:e.config?.user_prompt_params??[]}))},o)}})})),vo,yo=M((()=>{H(),I(),vo=m({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||V(`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
142
+ `)}else{let t=await k(e,{url:u,method:`POST`,body:o}),n=t.output?.text??``;e.quiet||a===`text`?F(n):P(t,a)}}})})),vo,yo,bo=M((()=>{I(),vo=`zeldaEasy.broadscope-bailian.app-control.list`,yo=m({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=h(e.output),s=await me(e),c={reqDTO:{name:n,notInTypes:[10],type:5,statuses:[1,4],page_no:r,page_size:i}};if(e.dryRun){P({api:vo,data:c,region:a,token:s.token.slice(0,8)+`...`},o);return}let l=await d(e,s.token,{api:vo,data:c,region:a}),u=l?.data?.DataV2?.data?.data?.list??[];P({total:l?.data?.DataV2?.data?.data?.total??0,apps:u.map(e=>({code:e.code,name:e.name,user_prompt_params:e.config?.user_prompt_params??[]}))},o)}})})),xo,So=M((()=>{H(),I(),xo=m({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||V(`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
143
143
  `),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
144
- `),process.exit(1)),t.profileSchema&&(r.profile_schema=t.profileSchema),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=h(e.output);if(e.dryRun){P({endpoint:re(e.baseUrl),request:r},i);return}let a=await k(e,{url:re(e.baseUrl),method:`POST`,body:r});e.quiet||i===`text`?F(`Memory added. IDs: ${a.memory_ids?.join(`, `)||`none`}`):P(a,i)}})})),bo,xo=M((()=>{H(),I(),bo=m({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||V(`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
144
+ `),process.exit(1)),t.profileSchema&&(r.profile_schema=t.profileSchema),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=h(e.output);if(e.dryRun){P({endpoint:re(e.baseUrl),request:r},i);return}let a=await k(e,{url:re(e.baseUrl),method:`POST`,body:r});e.quiet||i===`text`?F(`Memory added. IDs: ${a.memory_ids?.join(`, `)||`none`}`):P(a,i)}})})),Co,wo=M((()=>{H(),I(),Co=m({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||V(`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
145
145
  `),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
146
- `),process.exit(1)),t.topK!==void 0&&(r.top_k=t.topK),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=h(e.output);if(e.dryRun){P({endpoint:oe(e.baseUrl),request:r},i);return}let a=await k(e,{url:oe(e.baseUrl),method:`POST`,body:r});if(e.quiet||i===`text`)if(!a.memory_nodes||a.memory_nodes.length===0)F(`No memory nodes found.`);else for(let e of a.memory_nodes)F(`[${e.memory_node_id}] ${e.content}`);else P(a,i)}})})),So,Co=M((()=>{H(),I(),So=m({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||V(`user-id`,`bl memory list --user-id <id>`);let r=h(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=`${ie(e.baseUrl)}?${i.toString()}`;if(e.dryRun){P({endpoint:a,method:`GET`},r);return}let o=await k(e,{url:a,method:`GET`});if(e.quiet||r===`text`)if(!o.memory_nodes||o.memory_nodes.length===0)F(`No memory nodes found.`);else{for(let e of o.memory_nodes)F(`[${e.memory_node_id}] ${e.content}`);o.total!==void 0&&F(`\nTotal: ${o.total}`)}else P(o,r)}})})),wo,To=M((()=>{H(),I(),wo=m({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||V(`node-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let r=t.userId;r||V(`user-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let i=t.content;i||V(`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=h(e.output);if(e.dryRun){P({endpoint:ae(e.baseUrl,n),method:`PATCH`,request:a},o);return}let s=await k(e,{url:ae(e.baseUrl,n),method:`PATCH`,body:a});e.quiet||o===`text`?F(`Memory node ${n} updated.`):P(s,o)}})})),Eo,Do=M((()=>{H(),I(),Eo=m({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||V(`node-id`,`bl memory delete --node-id <id> --user-id <id>`);let r=t.userId;r||V(`user-id`,`bl memory delete --node-id <id> --user-id <id>`);let i=h(e.output),a=new URLSearchParams({user_id:r});t.memoryLibraryId&&a.set(`memory_library_id`,t.memoryLibraryId);let o=`${ae(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){P({endpoint:o,method:`DELETE`},i);return}let s=await k(e,{url:o,method:`DELETE`});e.quiet||i===`text`?F(`Memory node ${n} deleted.`):P(s,i)}})})),Oo,ko=M((()=>{H(),I(),Oo=m({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||V(`name`,`bl memory profile create --name <name> --attributes <json>`);let r=t.attributes;r||V(`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
147
- `),process.exit(1)}let a={name:n,attributes:i};t.description&&(a.description=t.description);let o=h(e.output);if(e.dryRun){P({endpoint:ce(e.baseUrl),request:a},o);return}let s=await k(e,{url:ce(e.baseUrl),method:`POST`,body:a});e.quiet||o===`text`?F(`Profile schema created: ${s.profile_schema_id}`):P(s,o)}})})),Ao,jo=M((()=>{H(),I(),Ao=m({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||V(`schema-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let r=t.userId;r||V(`user-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let i=h(e.output),a=new URLSearchParams({user_id:r}),o=`${Te(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){P({endpoint:o,method:`GET`},i);return}let s=await k(e,{url:o,method:`GET`});if(e.quiet||i===`text`)if(s.profile?.attributes)for(let e of s.profile.attributes)F(`${e.name}: ${e.value??`(empty)`}`);else F(`No profile data found.`);else P(s,i)}})}));async function Mo(e,t,n,r,i){t.topK!==void 0&&t.rerankTopN===void 0&&(process.stderr.write(`Warning: --top-k is deprecated. Use --rerank-top-n instead.
148
- `),t.rerankTopN=t.topK);let a={index_id:n,query:r,search_filters:[]};if(t.denseSimilarityTopK!==void 0&&(a.dense_similarity_top_k=t.denseSimilarityTopK),t.sparseSimilarityTopK!==void 0&&(a.sparse_similarity_top_k=t.sparseSimilarityTopK),t.rerank&&(a.enable_reranking=!0),t.rerankTopN!==void 0&&(a.rerank_top_n=t.rerankTopN),t.rerankModel){let e={model_name:t.rerankModel};t.rerankMode&&(e.rerank_mode=t.rerankMode),t.rerankInstruct&&(e.rerank_instruct=t.rerankInstruct),a.rerank=[e]}let o=ee(e.baseUrl);if(e.dryRun){P({endpoint:o,request:a},i);return}let s=await k(e,{url:o,method:`POST`,body:a}),c=s.data?.nodes||[];e.quiet||i===`text`?Po(c.map(e=>({text:e.text,score:e.score}))):P(s,i)}async function No(e,n,r,a,o){let s=n.accessKeyId||e.accessKeyId,c=n.accessKeySecret||e.accessKeySecret,l=n.workspaceId||e.workspaceId;if(!s||!c)throw new t(`No credentials found.
146
+ `),process.exit(1)),t.topK!==void 0&&(r.top_k=t.topK),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=h(e.output);if(e.dryRun){P({endpoint:oe(e.baseUrl),request:r},i);return}let a=await k(e,{url:oe(e.baseUrl),method:`POST`,body:r});if(e.quiet||i===`text`)if(!a.memory_nodes||a.memory_nodes.length===0)F(`No memory nodes found.`);else for(let e of a.memory_nodes)F(`[${e.memory_node_id}] ${e.content}`);else P(a,i)}})})),To,Eo=M((()=>{H(),I(),To=m({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||V(`user-id`,`bl memory list --user-id <id>`);let r=h(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=`${ie(e.baseUrl)}?${i.toString()}`;if(e.dryRun){P({endpoint:a,method:`GET`},r);return}let o=await k(e,{url:a,method:`GET`});if(e.quiet||r===`text`)if(!o.memory_nodes||o.memory_nodes.length===0)F(`No memory nodes found.`);else{for(let e of o.memory_nodes)F(`[${e.memory_node_id}] ${e.content}`);o.total!==void 0&&F(`\nTotal: ${o.total}`)}else P(o,r)}})})),Do,Oo=M((()=>{H(),I(),Do=m({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||V(`node-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let r=t.userId;r||V(`user-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let i=t.content;i||V(`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=h(e.output);if(e.dryRun){P({endpoint:ae(e.baseUrl,n),method:`PATCH`,request:a},o);return}let s=await k(e,{url:ae(e.baseUrl,n),method:`PATCH`,body:a});e.quiet||o===`text`?F(`Memory node ${n} updated.`):P(s,o)}})})),ko,Ao=M((()=>{H(),I(),ko=m({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||V(`node-id`,`bl memory delete --node-id <id> --user-id <id>`);let r=t.userId;r||V(`user-id`,`bl memory delete --node-id <id> --user-id <id>`);let i=h(e.output),a=new URLSearchParams({user_id:r});t.memoryLibraryId&&a.set(`memory_library_id`,t.memoryLibraryId);let o=`${ae(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){P({endpoint:o,method:`DELETE`},i);return}let s=await k(e,{url:o,method:`DELETE`});e.quiet||i===`text`?F(`Memory node ${n} deleted.`):P(s,i)}})})),jo,Mo=M((()=>{H(),I(),jo=m({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||V(`name`,`bl memory profile create --name <name> --attributes <json>`);let r=t.attributes;r||V(`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
147
+ `),process.exit(1)}let a={name:n,attributes:i};t.description&&(a.description=t.description);let o=h(e.output);if(e.dryRun){P({endpoint:ce(e.baseUrl),request:a},o);return}let s=await k(e,{url:ce(e.baseUrl),method:`POST`,body:a});e.quiet||o===`text`?F(`Profile schema created: ${s.profile_schema_id}`):P(s,o)}})})),No,Po=M((()=>{H(),I(),No=m({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||V(`schema-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let r=t.userId;r||V(`user-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let i=h(e.output),a=new URLSearchParams({user_id:r}),o=`${Te(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){P({endpoint:o,method:`GET`},i);return}let s=await k(e,{url:o,method:`GET`});if(e.quiet||i===`text`)if(s.profile?.attributes)for(let e of s.profile.attributes)F(`${e.name}: ${e.value??`(empty)`}`);else F(`No profile data found.`);else P(s,i)}})}));async function Fo(e,t,n,r,i){t.topK!==void 0&&t.rerankTopN===void 0&&(process.stderr.write(`Warning: --top-k is deprecated. Use --rerank-top-n instead.
148
+ `),t.rerankTopN=t.topK);let a={index_id:n,query:r,search_filters:[]};if(t.denseSimilarityTopK!==void 0&&(a.dense_similarity_top_k=t.denseSimilarityTopK),t.sparseSimilarityTopK!==void 0&&(a.sparse_similarity_top_k=t.sparseSimilarityTopK),t.rerank&&(a.enable_reranking=!0),t.rerankTopN!==void 0&&(a.rerank_top_n=t.rerankTopN),t.rerankModel){let e={model_name:t.rerankModel};t.rerankMode&&(e.rerank_mode=t.rerankMode),t.rerankInstruct&&(e.rerank_instruct=t.rerankInstruct),a.rerank=[e]}let o=ee(e.baseUrl);if(e.dryRun){P({endpoint:o,request:a},i);return}let s=await k(e,{url:o,method:`POST`,body:a}),c=s.data?.nodes||[];e.quiet||i===`text`?Lo(c.map(e=>({text:e.text,score:e.score}))):P(s,i)}async function Io(e,n,r,a,o){let s=n.accessKeyId||e.accessKeyId,c=n.accessKeySecret||e.accessKeySecret,l=n.workspaceId||e.workspaceId;if(!s||!c)throw new t(`No credentials found.
149
149
  Preferred: set DASHSCOPE_API_KEY or pass --api-key.
150
150
  Legacy (deprecated): set ALIBABA_CLOUD_ACCESS_KEY_ID / ALIBABA_CLOUD_ACCESS_KEY_SECRET.`,i.AUTH);if(!l)throw new t(`Knowledge retrieve requires a workspace ID.
151
151
  Set via: --workspace-id flag, or env: BAILIAN_WORKSPACE_ID, or config: bl config set workspace_id <id>`,i.USAGE);process.stderr.write(`Warning: AK/SK auth for knowledge retrieve is deprecated. Prefer --api-key or DASHSCOPE_API_KEY.
152
152
  `);let u={IndexId:r,Query:a};if(n.topK!==void 0&&n.rerankTopN===void 0&&(process.stderr.write(`Warning: --top-k is deprecated. Use --rerank-top-n instead.
153
- `),n.rerankTopN=n.topK),n.rerank&&(u.EnableReranking=!0),n.rerankTopN!==void 0&&(u.RerankTopN=n.rerankTopN),n.denseSimilarityTopK!==void 0&&(u.DenseSimilarityTopK=n.denseSimilarityTopK),n.sparseSimilarityTopK!==void 0&&(u.SparseSimilarityTopK=n.sparseSimilarityTopK),n.rerankModel){let e={ModelName:n.rerankModel};n.rerankMode&&(e.RerankMode=n.rerankMode),n.rerankInstruct&&(e.RerankInstruct=n.rerankInstruct),u.Rerank=[e]}let d=`/${l}/index/retrieve`;if(e.dryRun){P({endpoint:`https://${Fo}${d}`,workspaceId:l,request:u},o);return}let f=JSON.stringify(u),p=_e({accessKeyId:s,accessKeySecret:c,action:`Retrieve`,version:`2023-12-29`,body:f,host:Fo,pathname:d}),m=`https://${Fo}${d}`;e.verbose&&(process.stderr.write(`> POST ${m}\n`),process.stderr.write(`> AK: ${O(s)}\n`));let h=e.timeout*1e3,g=await fetch(m,{method:`POST`,headers:{...p,...Ce()},body:f,signal:AbortSignal.timeout(h)});e.verbose&&process.stderr.write(`< ${g.status} ${g.statusText}\n`);let _=await g.json();if(!g.ok||_.Code&&_.Code!==`Success`)throw new t(`Knowledge retrieve failed: ${_.Code||g.status} - ${_.Message||g.statusText}`,i.GENERAL);let v=_.Data?.Nodes||[];e.quiet||o===`text`?Po(v.map(e=>({text:e.Text,score:e.Score}))):P(_,o)}function Po(e){if(e.length===0)F(`No results found.`);else for(let t=0;t<e.length;t++){let n=e[t];F(`[${t+1}] (score: ${n.score.toFixed(4)})`),F(n.text),F(``)}}var Fo,Io,Lo=M((()=>{H(),I(),Fo=`bailian.cn-beijing.aliyuncs.com`,Io=m({name:`knowledge retrieve`,description:`Retrieve from a Bailian knowledge base`,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:`--dense-similarity-top-k <n>`,description:`Dense retrieval top K`,type:`number`},{flag:`--sparse-similarity-top-k <n>`,description:`Sparse retrieval top K`,type:`number`},{flag:`--rerank`,description:`Enable reranking`},{flag:`--rerank-top-n <n>`,description:`Rerank top N results`,type:`number`},{flag:`--rerank-model <name>`,description:`Rerank model, e.g. qwen3-rerank-hybrid`},{flag:`--rerank-mode <mode>`,description:`Rerank mode: qa, similar, or custom`},{flag:`--rerank-instruct <text>`,description:`Custom rerank instruction, when mode=custom`},{flag:`--top-k <n>`,description:`Number of results (deprecated, use --rerank-top-n)`,type:`number`},{flag:`--workspace-id <id>`,description:`Bailian workspace ID (required for AK/SK auth)`},{flag:`--access-key-id <key>`,description:`Alibaba Cloud Access Key ID (deprecated)`},{flag:`--access-key-secret <key>`,description:`Alibaba Cloud Access Key Secret (deprecated)`}],examples:[`bl knowledge retrieve --index-id idx_xxx --query "如何使用阿里云百炼"`,`bl knowledge retrieve --index-id idx_xxx --query "API限流" --rerank --rerank-model qwen3-rerank-hybrid`],async run(e,t){let n=t.indexId;n||V(`index-id`,`bl knowledge retrieve --index-id <id> --query <text>`);let r=t.query;r||V(`query`,`bl knowledge retrieve --index-id <id> --query <text>`);let i=h(e.output),a=!!e.apiKey,o=!!(t.accessKeyId&&t.accessKeySecret);if(a)await Mo(e,t,n,r,i);else if(o)await No(e,t,n,r,i);else{let a=!1;try{await A(e),a=!0}catch{}a?await Mo(e,t,n,r,i):await No(e,t,n,r,i)}}})}));async function Ro(e){if(e.apiKey||e.fileApiKey||e.accessTokenEnv||e.fileAccessToken)return;let n=process.env.DASHSCOPE_API_KEY,r;if(n&&(E({nonInteractive:e.nonInteractive})?await Yr({message:`Found DASHSCOPE_API_KEY in environment (${O(n)}). Save it to config file?`})&&(r=n):r=n),!r){if(!E({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 De({...ue(),api_key:r}),e.fileApiKey=r;let a=e.configPath??`~/.bailian/config.json`;process.stderr.write(`API key saved to ${a}\n`)}var zo=M((()=>{H()}));function Bo(e){let t={};for(let n of e){let e=n.indexOf(`=`);e<=0&&(process.stderr.write(`Error: --arg must be in K=V form, got: ${n}\n`),process.exit(1));let r=n.slice(0,e).trim(),i=n.slice(e+1);try{t[r]=JSON.parse(i)}catch{t[r]=i}}return t}var Vo,Ho=M((()=>{H(),I(),zo(),Vo=m({name:`mcp call`,description:`Call a tool on an MCP server (tools/call)`,usage:`bl mcp call <server-code>.<tool> [--arg k=v ...] [--json '{...}'] [--url <url>]`,options:[{flag:`<server-code>.<tool>`,description:`Server code and tool name joined by a dot, e.g. market-cmapi00073529.SmartStockSelection`,required:!0},{flag:`--arg <kv>`,description:`Tool argument (repeatable). Values parsed as JSON if possible, else string.`,type:`array`},{flag:`--json <obj>`,description:`Full arguments object as JSON; merged with --arg (arg wins).`},{flag:`--query <text>`,description:`Shortcut for --arg query=<text> (mirrors many DashScope MCP tools).`},{flag:`--url <url>`,description:`Override the MCP endpoint URL (for non-Bailian servers)`}],examples:[`bl mcp call market-cmapi00073529.SmartStockSelection --query "筛选ROE>15%的消费股"`,`bl mcp call market-cmapi00073529.FinQuery --json '{"q":"贵州茅台","limit":5}'`,`bl mcp call market-cmapi00073529.SmartFundSelection --arg riskLevel=R3 --arg minScale=10`],async run(e,t){let n=(t._positional??[])[0];n||V(`<server-code>.<tool>`,`bl mcp call <server-code>.<tool>`);let r=n.indexOf(`.`);(r<=0||r===n.length-1)&&(process.stderr.write(`Error: target must be <server-code>.<tool>, got "${n}".\n`),process.exit(1));let i=n.slice(0,r),a=n.slice(r+1),s={};if(t.json)try{let e=JSON.parse(t.json);(!e||typeof e!=`object`||Array.isArray(e))&&(process.stderr.write(`Error: --json must decode to an object.
154
- `),process.exit(1)),s=e}catch(e){process.stderr.write(`Error: --json is not valid JSON — ${e.message}\n`),process.exit(1)}Object.assign(s,Bo(t.arg??[])),t.query!==void 0&&(s.query=t.query);let c=t.url||l(e.baseUrl,i),u=h(e.output);if(e.dryRun){P({server:i,url:c,tool:a,arguments:s},u);return}await Ro(e);let d=new o(e,c);await d.initialize();let f=await d.callTool(a,s);if(f.isError){let e=f.content.map(e=>e.text||``).join(`
155
- `);process.stderr.write(`Tool error: ${e}\n`),process.exit(1)}P(f,u)}})})),Uo,Wo,Go=M((()=>{I(),Uo=`zeldaEasy.broadscope-bailian.mcp-server.PageList`,Wo=m({name:`mcp list`,description:`List MCP servers activated under your Bailian account`,usage:`bl mcp list [flags]`,options:[{flag:`--name <text>`,description:`Filter by server name (substring match)`},{flag:`--type <type>`,description:`Server type: OFFICIAL | PRIVATE (default: OFFICIAL)`},{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 mcp list`,`bl mcp list --name 金融`,`bl mcp list --output json`],async run(e,n){let r=n.name||``,a=n.type||`OFFICIAL`,o=n.page||1,s=n.pageSize||30,c=n.region||`cn-beijing`,l=h(e.output),u={reqDTO:{type:a,displayTools:!1,activated:1,pageNo:o,pageSize:s,serverName:r}};if(e.dryRun){P({api:Uo,data:u,region:c},l);return}let f=(await d(e,(await me(e)).token,{api:Uo,data:u,region:c}))?.data??{};if(f.success===!1){let e=f.errorCode??`UnknownError`,n=f.errorMsg??e,r=e===`BailianGateway.Login.NotLogined`?"Run `bl auth login --console` to refresh your console session.":void 0;throw new t(`Console gateway: ${n}`,i.AUTH,r)}let p=(f.DataV2??{}).data?.data??{},m=p.mcpServerDetailList??[];P({total:p.total??0,servers:m.map(e=>({code:e.serverCode??``,name:e.serverName??``,description:e.description,type:e.type??``,source:e.source,bizType:e.bizType,installType:e.installType,streamable:e.streamable===!0}))},l)}})})),Ko,qo=M((()=>{H(),I(),zo(),Ko=m({name:`mcp tools`,description:`List tools exposed by an MCP server (tools/list)`,usage:`bl mcp tools <server-code> [--url <url>]`,options:[{flag:`<server-code>`,description:"Server code from `bl mcp list` (e.g. market-cmapi00073529)",required:!0},{flag:`--url <url>`,description:`Override the MCP endpoint URL (for non-Bailian servers)`}],examples:[`bl mcp tools market-cmapi00073529`,`bl mcp tools market-cmapi00073529 --output json`,`bl mcp tools my-server --url https://example.com/mcp`],async run(e,t){let n=(t._positional??[])[0];n||V(`server-code`,`bl mcp tools <server-code>`);let r=t.url||l(e.baseUrl,n),i=h(e.output);if(e.dryRun){P({server:n,url:r,action:`tools/list`},i);return}await Ro(e);let a=new o(e,r);await a.initialize(),P({server:n,url:r,tools:await a.listTools()},i)}})})),Jo,Yo=M((()=>{Ui(),H(),I(),Jo=m({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=ne(e.baseUrl),r=h(e.output);if(t.listTools){if(e.dryRun){P({endpoint:n,action:`tools/list`},r);return}let t=new o(e,n);await t.initialize(),P({tools:await t.listTools()},r);return}let i=t.query;if(!i)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your search query:`});e||(process.stderr.write(`Search cancelled.
156
- `),process.exit(1)),i=e}else V(`query`,`bl search web --query <text>`);if(e.dryRun){P({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=Bi(`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(`
157
- `);process.stderr.write(`Search error: ${e}\n`),process.exit(1)}if(r===`json`)P(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)?P({pages:t.pages,total:t.pages.length},r):P(t,r)}catch{P({text:e.text},r)}}catch(e){throw s.stop(`Failed.`),e}}})}));function Xo(e){let t=ts[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.
158
- `),process.stdout.write(`See: ${$o}\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 Zo(e,n,r,a,o){let s=await Xi(Yi(a),e,()=>k(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=he(e,{subDir:`speech`}),d=await Zi(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}}),Ki,{quiet:e.quiet});if(e.quiet)F(d.join(`
159
- `));else if(d.length===1){let e=s[0].output?.audio?.expires_at;P({saved:d[0],audio_url:c[0],model:r.model,voice:r.input.voice,...e?{url_expires_at:e}:{}},o)}else P({saved:d,audio_urls:c,total:d.length,model:r.model,voice:r.input.voice},o)}async function Qo(e,t,n,r,i){let a=await fe(e,{url:t,method:`POST`,body:n,stream:!0,headers:{Accept:`text/event-stream`,"X-DashScope-SSE":`enable`}}),o=r.out,s=o?Le(o):null,c;try{for await(let t of se(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&&P({saved:o,...c?{audio_url:c}:{},model:n.model,voice:n.input.voice},i)}var $o,es,ts,ns,rs=M((()=>{Ji(),Qi(),H(),I(),$o=`${r.cn}/cosyvoice-clone-design-api`,es=[{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:`印尼语`}],ts={"cosyvoice-v3-flash":es,"cosyvoice-v3-plus":es,"cosyvoice-v3.5-flash":[],"cosyvoice-v3.5-plus":[],"cosyvoice-v2":[]},ns=m({name:`speech synthesize`,description:`Synthesize speech from text (CosyVoice TTS)`,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){Xo(r);return}let a=n.text;if(!a&&n.textFile){let e=n.textFile;try{a=Be(e,`utf-8`).trim()}catch{throw new t(`Cannot read text file: ${e}`,i.USAGE)}}if(!a)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter text to synthesize:`});e||(process.stderr.write(`Speech synthesis cancelled.
160
- `),process.exit(1)),a=e}else V(`text`,`bl speech synthesize --text <text>`);let o=n.voice||void 0;if(!o)if(E({nonInteractive:e.nonInteractive})){let e=ts[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 Xr({message:`Select a voice (default: ${t}):`,choices:n,defaultValue:t});r||(process.stderr.write(`Speech synthesis cancelled.
153
+ `),n.rerankTopN=n.topK),n.rerank&&(u.EnableReranking=!0),n.rerankTopN!==void 0&&(u.RerankTopN=n.rerankTopN),n.denseSimilarityTopK!==void 0&&(u.DenseSimilarityTopK=n.denseSimilarityTopK),n.sparseSimilarityTopK!==void 0&&(u.SparseSimilarityTopK=n.sparseSimilarityTopK),n.rerankModel){let e={ModelName:n.rerankModel};n.rerankMode&&(e.RerankMode=n.rerankMode),n.rerankInstruct&&(e.RerankInstruct=n.rerankInstruct),u.Rerank=[e]}let d=`/${l}/index/retrieve`;if(e.dryRun){P({endpoint:`https://${Ro}${d}`,workspaceId:l,request:u},o);return}let f=JSON.stringify(u),p=_e({accessKeyId:s,accessKeySecret:c,action:`Retrieve`,version:`2023-12-29`,body:f,host:Ro,pathname:d}),m=`https://${Ro}${d}`;e.verbose&&(process.stderr.write(`> POST ${m}\n`),process.stderr.write(`> AK: ${O(s)}\n`));let h=e.timeout*1e3,g=await fetch(m,{method:`POST`,headers:{...p,...Ce()},body:f,signal:AbortSignal.timeout(h)});e.verbose&&process.stderr.write(`< ${g.status} ${g.statusText}\n`);let _=await g.json();if(!g.ok||_.Code&&_.Code!==`Success`)throw new t(`Knowledge retrieve failed: ${_.Code||g.status} - ${_.Message||g.statusText}`,i.GENERAL);let v=_.Data?.Nodes||[];e.quiet||o===`text`?Lo(v.map(e=>({text:e.Text,score:e.Score}))):P(_,o)}function Lo(e){if(e.length===0)F(`No results found.`);else for(let t=0;t<e.length;t++){let n=e[t];F(`[${t+1}] (score: ${n.score.toFixed(4)})`),F(n.text),F(``)}}var Ro,zo,Bo=M((()=>{H(),I(),Ro=`bailian.cn-beijing.aliyuncs.com`,zo=m({name:`knowledge retrieve`,description:`Retrieve from a Bailian knowledge base`,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:`--dense-similarity-top-k <n>`,description:`Dense retrieval top K`,type:`number`},{flag:`--sparse-similarity-top-k <n>`,description:`Sparse retrieval top K`,type:`number`},{flag:`--rerank`,description:`Enable reranking`},{flag:`--rerank-top-n <n>`,description:`Rerank top N results`,type:`number`},{flag:`--rerank-model <name>`,description:`Rerank model, e.g. qwen3-rerank-hybrid`},{flag:`--rerank-mode <mode>`,description:`Rerank mode: qa, similar, or custom`},{flag:`--rerank-instruct <text>`,description:`Custom rerank instruction, when mode=custom`},{flag:`--top-k <n>`,description:`Number of results (deprecated, use --rerank-top-n)`,type:`number`},{flag:`--workspace-id <id>`,description:`Bailian workspace ID (only needed for deprecated AK/SK auth)`},{flag:`--access-key-id <key>`,description:`Deprecated: use global --api-key instead`},{flag:`--access-key-secret <key>`,description:`Deprecated: use global --api-key instead`}],notes:["Authentication: pass `--api-key <key>`. AK/SK auth is deprecated and will be removed in a future version.","`--workspace-id` is NOT required when using --api-key."],examples:[`bl knowledge retrieve --index-id idx_xxx --query "如何使用阿里云百炼"`,`bl knowledge retrieve --api-key $DASHSCOPE_API_KEY --index-id idx_xxx --query "RAG检索" --rerank --rerank-model qwen3-rerank-hybrid`],async run(e,t){let n=t.indexId;n||V(`index-id`,`bl knowledge retrieve --index-id <id> --query <text>`);let r=t.query;r||V(`query`,`bl knowledge retrieve --index-id <id> --query <text>`);let i=h(e.output),a=!!e.apiKey,o=!!(t.accessKeyId&&t.accessKeySecret);if(a)await Fo(e,t,n,r,i);else if(o)await Io(e,t,n,r,i);else{let a=!1;try{await A(e),a=!0}catch{}a?await Fo(e,t,n,r,i):await Io(e,t,n,r,i)}}})}));async function Vo(e){if(e.apiKey||e.fileApiKey||e.accessTokenEnv||e.fileAccessToken)return;let n=process.env.DASHSCOPE_API_KEY,r;if(n&&(E({nonInteractive:e.nonInteractive})?await Yr({message:`Found DASHSCOPE_API_KEY in environment (${O(n)}). Save it to config file?`})&&(r=n):r=n),!r){if(!E({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 De({...ue(),api_key:r}),e.fileApiKey=r;let a=e.configPath??`~/.bailian/config.json`;process.stderr.write(`API key saved to ${a}\n`)}var Ho=M((()=>{H()}));function Uo(e){let t={};for(let n of e){let e=n.indexOf(`=`);e<=0&&(process.stderr.write(`Error: --arg must be in K=V form, got: ${n}\n`),process.exit(1));let r=n.slice(0,e).trim(),i=n.slice(e+1);try{t[r]=JSON.parse(i)}catch{t[r]=i}}return t}var Wo,Go=M((()=>{H(),I(),Ho(),Wo=m({name:`mcp call`,description:`Call a tool on an MCP server (tools/call)`,usage:`bl mcp call <server-code>.<tool> [--arg k=v ...] [--json '{...}'] [--url <url>]`,options:[{flag:`<server-code>.<tool>`,description:`Server code and tool name joined by a dot, e.g. market-cmapi00073529.SmartStockSelection`,required:!0},{flag:`--arg <kv>`,description:`Tool argument (repeatable). Values parsed as JSON if possible, else string.`,type:`array`},{flag:`--json <obj>`,description:`Full arguments object as JSON; merged with --arg (arg wins).`},{flag:`--query <text>`,description:`Shortcut for --arg query=<text> (mirrors many DashScope MCP tools).`},{flag:`--url <url>`,description:`Override the MCP endpoint URL (for non-Bailian servers)`}],examples:[`bl mcp call market-cmapi00073529.SmartStockSelection --query "筛选ROE>15%的消费股"`,`bl mcp call market-cmapi00073529.FinQuery --json '{"q":"贵州茅台","limit":5}'`,`bl mcp call market-cmapi00073529.SmartFundSelection --arg riskLevel=R3 --arg minScale=10`],async run(e,t){let n=(t._positional??[])[0];n||V(`<server-code>.<tool>`,`bl mcp call <server-code>.<tool>`);let r=n.indexOf(`.`);(r<=0||r===n.length-1)&&(process.stderr.write(`Error: target must be <server-code>.<tool>, got "${n}".\n`),process.exit(1));let i=n.slice(0,r),a=n.slice(r+1),s={};if(t.json)try{let e=JSON.parse(t.json);(!e||typeof e!=`object`||Array.isArray(e))&&(process.stderr.write(`Error: --json must decode to an object.
154
+ `),process.exit(1)),s=e}catch(e){process.stderr.write(`Error: --json is not valid JSON — ${e.message}\n`),process.exit(1)}Object.assign(s,Uo(t.arg??[])),t.query!==void 0&&(s.query=t.query);let c=t.url||l(e.baseUrl,i),u=h(e.output);if(e.dryRun){P({server:i,url:c,tool:a,arguments:s},u);return}await Vo(e);let d=new o(e,c);await d.initialize();let f=await d.callTool(a,s);if(f.isError){let e=f.content.map(e=>e.text||``).join(`
155
+ `);process.stderr.write(`Tool error: ${e}\n`),process.exit(1)}P(f,u)}})})),Ko,qo,Jo=M((()=>{I(),Ko=`zeldaEasy.broadscope-bailian.mcp-server.PageList`,qo=m({name:`mcp list`,description:`List MCP servers activated under your Bailian account`,usage:`bl mcp list [flags]`,options:[{flag:`--name <text>`,description:`Filter by server name (substring match)`},{flag:`--type <type>`,description:`Server type: OFFICIAL | PRIVATE (default: OFFICIAL)`},{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 mcp list`,`bl mcp list --name 金融`,`bl mcp list --output json`],async run(e,n){let r=n.name||``,a=n.type||`OFFICIAL`,o=n.page||1,s=n.pageSize||30,c=n.region||`cn-beijing`,l=h(e.output),u={reqDTO:{type:a,displayTools:!1,activated:1,pageNo:o,pageSize:s,serverName:r}};if(e.dryRun){P({api:Ko,data:u,region:c},l);return}let f=(await d(e,(await me(e)).token,{api:Ko,data:u,region:c}))?.data??{};if(f.success===!1){let e=f.errorCode??`UnknownError`,n=f.errorMsg??e,r=e===`BailianGateway.Login.NotLogined`?"Run `bl auth login --console` to refresh your console session.":void 0;throw new t(`Console gateway: ${n}`,i.AUTH,r)}let p=(f.DataV2??{}).data?.data??{},m=p.mcpServerDetailList??[];P({total:p.total??0,servers:m.map(e=>({code:e.serverCode??``,name:e.serverName??``,description:e.description,type:e.type??``,source:e.source,bizType:e.bizType,installType:e.installType,streamable:e.streamable===!0}))},l)}})})),Yo,Xo=M((()=>{H(),I(),Ho(),Yo=m({name:`mcp tools`,description:`List tools exposed by an MCP server (tools/list)`,usage:`bl mcp tools <server-code> [--url <url>]`,options:[{flag:`<server-code>`,description:"Server code from `bl mcp list` (e.g. market-cmapi00073529)",required:!0},{flag:`--url <url>`,description:`Override the MCP endpoint URL (for non-Bailian servers)`}],examples:[`bl mcp tools market-cmapi00073529`,`bl mcp tools market-cmapi00073529 --output json`,`bl mcp tools my-server --url https://example.com/mcp`],async run(e,t){let n=(t._positional??[])[0];n||V(`server-code`,`bl mcp tools <server-code>`);let r=t.url||l(e.baseUrl,n),i=h(e.output);if(e.dryRun){P({server:n,url:r,action:`tools/list`},i);return}await Vo(e);let a=new o(e,r);await a.initialize(),P({server:n,url:r,tools:await a.listTools()},i)}})})),Zo,Qo=M((()=>{Ki(),H(),I(),Zo=m({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=ne(e.baseUrl),r=h(e.output);if(t.listTools){if(e.dryRun){P({endpoint:n,action:`tools/list`},r);return}let t=new o(e,n);await t.initialize(),P({tools:await t.listTools()},r);return}let i=t.query;if(!i)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your search query:`});e||(process.stderr.write(`Search cancelled.
156
+ `),process.exit(1)),i=e}else V(`query`,`bl search web --query <text>`);if(e.dryRun){P({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=Ui(`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(`
157
+ `);process.stderr.write(`Search error: ${e}\n`),process.exit(1)}if(r===`json`)P(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)?P({pages:t.pages,total:t.pages.length},r):P(t,r)}catch{P({text:e.text},r)}}catch(e){throw s.stop(`Failed.`),e}}})}));function $o(e){let t=is[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.
158
+ `),process.stdout.write(`See: ${ns}\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 es(e,n,r,a,o){let s=await $i(Qi(a),e,()=>k(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=he(e,{subDir:`speech`}),d=await ea(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}}),Yi,{quiet:e.quiet});if(e.quiet)F(d.join(`
159
+ `));else if(d.length===1){let e=s[0].output?.audio?.expires_at;P({saved:d[0],audio_url:c[0],model:r.model,voice:r.input.voice,...e?{url_expires_at:e}:{}},o)}else P({saved:d,audio_urls:c,total:d.length,model:r.model,voice:r.input.voice},o)}async function ts(e,t,n,r,i){let a=await fe(e,{url:t,method:`POST`,body:n,stream:!0,headers:{Accept:`text/event-stream`,"X-DashScope-SSE":`enable`}}),o=r.out,s=o?Le(o):null,c;try{for await(let t of se(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&&P({saved:o,...c?{audio_url:c}:{},model:n.model,voice:n.input.voice},i)}var ns,rs,is,as,os=M((()=>{Zi(),ta(),H(),I(),ns=`${r.cn}/cosyvoice-clone-design-api`,rs=[{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:`印尼语`}],is={"cosyvoice-v3-flash":rs,"cosyvoice-v3-plus":rs,"cosyvoice-v3.5-flash":[],"cosyvoice-v3.5-plus":[],"cosyvoice-v2":[]},as=m({name:`speech synthesize`,description:`Synthesize speech from text (CosyVoice TTS)`,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){$o(r);return}let a=n.text;if(!a&&n.textFile){let e=n.textFile;try{a=Be(e,`utf-8`).trim()}catch{throw new t(`Cannot read text file: ${e}`,i.USAGE)}}if(!a)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter text to synthesize:`});e||(process.stderr.write(`Speech synthesis cancelled.
160
+ `),process.exit(1)),a=e}else V(`text`,`bl speech synthesize --text <text>`);let o=n.voice||void 0;if(!o)if(E({nonInteractive:e.nonInteractive})){let e=is[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 Xr({message:`Select a voice (default: ${t}):`,choices:n,defaultValue:t});r||(process.stderr.write(`Speech synthesis cancelled.
161
161
  `),process.exit(1)),o=r}else{let e=await Jr({message:`Enter voice ID (clone/design voice):`});e||(process.stderr.write(`Speech synthesis cancelled.
162
- `),process.exit(1)),o=e}}else{let e=ts[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: ${$o}`,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),f=n.rate===void 0?void 0:Number(n.rate),p=n.pitch===void 0?void 0:Number(n.pitch),m=n.seed===void 0?void 0:Number(n.seed),g=n.enableSsml===!0?!0:void 0,_=n.stream===!0,v=h(e.output),y={model:r,input:{text:a,voice:o,format:l,sample_rate:u,volume:d,rate:f,pitch:p,seed:m,language_hints:s?[s]:void 0,instruction:c,enable_ssml:g}};if(be(y.input),e.dryRun){P({request:y},v);return}e.quiet||process.stderr.write(`[Model: ${r}] [Voice: ${o}]\n`);let b=ye(e.baseUrl);_?await Qo(e,b,y,n,v):await Zo(e,b,y,n,v)}})}));async function is(e,n,r,a,o,s){let c=(await k(e,{url:n,method:`POST`,body:r,async:!0})).output.task_id;if(a.noWait||e.async){P({task_id:c},o);return}let l=a.pollInterval??2,u=await Wi(e,{url:xe(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){P({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(`
162
+ `),process.exit(1)),o=e}}else{let e=is[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: ${ns}`,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),f=n.rate===void 0?void 0:Number(n.rate),p=n.pitch===void 0?void 0:Number(n.pitch),m=n.seed===void 0?void 0:Number(n.seed),g=n.enableSsml===!0?!0:void 0,_=n.stream===!0,v=h(e.output),y={model:r,input:{text:a,voice:o,format:l,sample_rate:u,volume:d,rate:f,pitch:p,seed:m,language_hints:s?[s]:void 0,instruction:c,enable_ssml:g}};if(be(y.input),e.dryRun){P({request:y},v);return}e.quiet||process.stderr.write(`[Model: ${r}] [Voice: ${o}]\n`);let b=ye(e.baseUrl);_?await ts(e,b,y,n,v):await es(e,b,y,n,v)}})}));async function ss(e,n,r,a,o,s){let c=(await k(e,{url:n,method:`POST`,body:r,async:!0})).output.task_id;if(a.noWait||e.async){P({task_id:c},o);return}let l=a.pollInterval??2,u=await qi(e,{url:xe(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){P({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(`
163
163
  `);continue}if(!n.transcription_url){r&&process.stdout.write(`
164
164
  `);continue}let a=await fetch(n.transcription_url,{headers:Ce()});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+`
165
165
  `);else F(JSON.stringify(o));r&&process.stdout.write(`
166
166
  `)}if(a.out){let t=a.out,n=f.length===1?f[0]:f;He(t,JSON.stringify(n,null,2)+`
167
- `),e.quiet||process.stderr.write(`Full result saved to: ${t}\n`)}}var as,os=M((()=>{Gi(),H(),I(),as=m({name:`speech recognize`,description:`Recognize speech from audio files (FunAudio-ASR)`,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&&V(`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.
168
- Hint: Add --diarization flag to enable speaker separation.`,i.USAGE);let s=n.model||`fun-asr`,c=h(e.output),l=await A(e),u=await Promise.all(r.map(e=>j(e,l.token,s))),d=n.channelId,f=n.language,p=n.vocabularyId,m={model:s,input:{file_urls:u},parameters:{channel_id:d===void 0?[0]:[d],language_hints:f?[f]:void 0,diarization_enabled:o?!0:void 0,speaker_count:a,vocabulary_id:p}};if(be(m.parameters),e.dryRun){P({request:m,mode:`async`},c);return}e.quiet||process.stderr.write(`[Model: ${s}] [Mode: async] [Files: ${u.length}]\n`),await is(e,ve(e.baseUrl),m,n,c,u.length)}})})),ss,cs=M((()=>{H(),I(),ss=m({name:`file upload`,description:`Upload a local file to DashScope temporary storage (48h)`,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||V(`file`,`bl file upload --file <path> --model <model>`);let r=t.model;r||V(`model`,`bl file upload --file <path> --model <model>`);let i=h(e.output);if(e.dryRun){P({action:`upload`,file:n,model:r},i);return}let a=await we({apiKey:(await A(e)).token,model:r,filePath:n});e.quiet?F(a):P({url:a,model:r,expires_in:`48 hours`,note:`When using this URL in API calls, add header: X-DashScope-OssResourceResolve: enable`},i)}})})),ls,us=M((()=>{H(),I(),ls=m({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||V(`api`,`bl console call --api <api> --data <json>`);let a=r.data;a||V(`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
169
- `),process.exit(1)}let s=r.region||`cn-beijing`,c=h(e.output),l;try{l=(await me(e)).token}catch(e){if(!(e instanceof t&&e.message===n))throw e}if(e.dryRun){P({api:i,data:o,region:s,token:l?l.slice(0,8)+`...`:null},c);return}P(await d(e,l,{api:i,data:o,region:s}),c)}})}));function ds(e){return e>=11904&&e<=40959||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=131072&&e<=195103}function U(e){let t=0;for(let n of e){let e=n.codePointAt(0)??0;t+=ds(e)?2:1}return t}function W(e,t){let n=t-U(e);return n>0?e+` `.repeat(n):e}var fs=M((()=>{}));function ps(e){return e.toLocaleString(`en-US`)}function ms(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function hs(e){return e.quotaInitTotal?`${((e.quotaInitTotal-e.quotaTotal)/e.quotaInitTotal*100).toFixed(1)}%`:`-`}function gs(e){for(let t of e){let e=Cs[t];if(e)return e}return`-`}function _s(e,t,n,r){let i=[`模型`,`类型`,`剩余/总量`,`使用率`,`过期时间`,`用完即停`],a=[`Model`,`Type`,`Remaining/Total`,`Usage`,`Expires`,`Auto-Stop`],o=e.map(e=>{let r=e.quotaInitTotal!=null&&e.quotaTotal!=null,i=r?ps(e.quotaTotal):`-`,a=r?ps(e.quotaInitTotal):`-`,o=t.get(e.model);return[e.model,n.get(e.model)||`-`,r?`${i} / ${a}`:`-`,hs(e),e.quotaValidityPeriod?ms(e.quotaValidityPeriod):`-`,e.quotaStatus===`UNKNOWN`?`Unsupported`:o===!0?`ON`:o===!1?`OFF`:`-`]}),s=i.map((e,t)=>Math.max(U(e),U(a[t]),...o.map(e=>U(e[t])))),c=r?e=>e:e=>`\x1b[2m${e}\x1b[0m`,l=r?e=>e:e=>`\x1b[1m${e}\x1b[0m`,u=r?e=>e:e=>`\x1b[32m${e}\x1b[0m`,d=r?e=>e:e=>`\x1b[33m${e}\x1b[0m`,f=i.length-1,p=i.map((e,t)=>l(W(e,s[t]))).join(` `),m=a.map((e,t)=>c(W(e,s[t]))).join(` `),h=s.map(e=>c(`─`.repeat(e))).join(`──`);process.stdout.write(p+`
167
+ `),e.quiet||process.stderr.write(`Full result saved to: ${t}\n`)}}var cs,ls=M((()=>{Ji(),H(),I(),cs=m({name:`speech recognize`,description:`Recognize speech from audio files (FunAudio-ASR)`,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&&V(`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.
168
+ Hint: Add --diarization flag to enable speaker separation.`,i.USAGE);let s=n.model||`fun-asr`,c=h(e.output),l=await A(e),u=await Promise.all(r.map(e=>j(e,l.token,s))),d=n.channelId,f=n.language,p=n.vocabularyId,m={model:s,input:{file_urls:u},parameters:{channel_id:d===void 0?[0]:[d],language_hints:f?[f]:void 0,diarization_enabled:o?!0:void 0,speaker_count:a,vocabulary_id:p}};if(be(m.parameters),e.dryRun){P({request:m,mode:`async`},c);return}e.quiet||process.stderr.write(`[Model: ${s}] [Mode: async] [Files: ${u.length}]\n`),await ss(e,ve(e.baseUrl),m,n,c,u.length)}})})),us,ds=M((()=>{H(),I(),us=m({name:`file upload`,description:`Upload a local file to DashScope temporary storage (48h)`,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||V(`file`,`bl file upload --file <path> --model <model>`);let r=t.model;r||V(`model`,`bl file upload --file <path> --model <model>`);let i=h(e.output);if(e.dryRun){P({action:`upload`,file:n,model:r},i);return}let a=await we({apiKey:(await A(e)).token,model:r,filePath:n});e.quiet?F(a):P({url:a,model:r,expires_in:`48 hours`,note:`When using this URL in API calls, add header: X-DashScope-OssResourceResolve: enable`},i)}})})),fs,ps=M((()=>{H(),I(),fs=m({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||V(`api`,`bl console call --api <api> --data <json>`);let a=r.data;a||V(`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
169
+ `),process.exit(1)}let s=r.region||`cn-beijing`,c=h(e.output),l;try{l=(await me(e)).token}catch(e){if(!(e instanceof t&&e.message===n))throw e}if(e.dryRun){P({api:i,data:o,region:s,token:l?l.slice(0,8)+`...`:null},c);return}P(await d(e,l,{api:i,data:o,region:s}),c)}})}));function ms(e){return e>=11904&&e<=40959||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=131072&&e<=195103}function U(e){let t=0;for(let n of e){let e=n.codePointAt(0)??0;t+=ms(e)?2:1}return t}function W(e,t){let n=t-U(e);return n>0?e+` `.repeat(n):e}var hs=M((()=>{}));function gs(e){return e.toLocaleString(`en-US`)}function _s(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function vs(e){return e.quotaInitTotal?`${((e.quotaInitTotal-e.quotaTotal)/e.quotaInitTotal*100).toFixed(1)}%`:`-`}function ys(e){for(let t of e){let e=Es[t];if(e)return e}return`-`}function bs(e,t,n,r){let i=[`模型`,`类型`,`剩余/总量`,`使用率`,`过期时间`,`用完即停`],a=[`Model`,`Type`,`Remaining/Total`,`Usage`,`Expires`,`Auto-Stop`],o=e.map(e=>{let r=e.quotaInitTotal!=null&&e.quotaTotal!=null,i=r?gs(e.quotaTotal):`-`,a=r?gs(e.quotaInitTotal):`-`,o=t.get(e.model);return[e.model,n.get(e.model)||`-`,r?`${i} / ${a}`:`-`,vs(e),e.quotaValidityPeriod?_s(e.quotaValidityPeriod):`-`,e.quotaStatus===`UNKNOWN`?`Unsupported`:o===!0?`ON`:o===!1?`OFF`:`-`]}),s=i.map((e,t)=>Math.max(U(e),U(a[t]),...o.map(e=>U(e[t])))),c=r?e=>e:e=>`\x1b[2m${e}\x1b[0m`,l=r?e=>e:e=>`\x1b[1m${e}\x1b[0m`,u=r?e=>e:e=>`\x1b[32m${e}\x1b[0m`,d=r?e=>e:e=>`\x1b[33m${e}\x1b[0m`,f=i.length-1,p=i.map((e,t)=>l(W(e,s[t]))).join(` `),m=a.map((e,t)=>c(W(e,s[t]))).join(` `),h=s.map(e=>c(`─`.repeat(e))).join(`──`);process.stdout.write(p+`
170
170
  `),process.stdout.write(m+`
171
171
  `),process.stdout.write(h+`
172
172
  `);for(let e of o){let t=e.map((e,t)=>{if(t===f){if(e===`ON`)return u(W(e,s[t]));if(e===`OFF`)return d(W(e,s[t]))}return W(e,s[t])});process.stdout.write(t.join(` `)+`
173
- `)}}function vs(e){let t=e.data;if(!t)return[];let n=t.DataV2;return n?n.data?.data?.freeTierQuotas||[]:t.data?.freeTierQuotas||[]}function ys(e){let t=e.data;if(!t)return[];let n=t.DataV2;return n?n.data?.data?.freeTierOnlyStatuses||[]:t.data?.freeTierOnlyStatuses||[]}async function bs(e,t){let n=[],r=1;for(;;){let i=await g(e,t,{pageNo:r,pageSize:50});if(n.push(...i.models),n.length>=i.total)break;r++}return n.filter(e=>typeof e.model==`string`&&e.model).map(e=>({name:e.model,type:gs(e.capabilities||[])}))}var xs,Ss,Cs,ws,Ts=M((()=>{I(),fs(),xs=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota`,Ss=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierOnlyStatus`,Cs={Reasoning:`Text`,TG:`Text`,VU:`Text`,IG:`Vision`,VG:`Vision`,"Realtime-Omni":`Multimodal`,"Multimodal-Omni":`Multimodal`,ASR:`Audio`,TTS:`Audio`,"Voice-Replication":`Audio`,"Realtime-Text-to-Speech":`Audio`,"Realtime-Voice-Replication":`Audio`,"Realtime-ASR":`Audio`,"Realtime-Audio-Translate":`Audio`,ME:`Embedding`,TR:`Embedding`},ws=m({name:`usage free`,description:`Query free-tier quota for models (all models if --model is omitted)`,usage:`bl usage free [--model <model>[,model2,...]] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s) to query, comma-separated for multiple; omit for all models`},{flag:`--expiring <days>`,description:`Only show quotas expiring within N days`},{flag:`--sort <field>`,description:`Sort by: remaining (ascending), expires (ascending)`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl usage free`,`bl usage free --model qwen3-max`,`bl usage free --model qwen3-max,qwen-turbo`,`bl usage free --expiring 30`,`bl usage free --sort remaining`,`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||void 0,r=Number(t.expiring)||0,i=[`remaining`,`expires`],a=t.sort||void 0;a&&!i.includes(a)&&(process.stderr.write(`Error: invalid --sort value "${a}". Must be one of: ${i.join(`, `)}\n`),process.exit(1));let o=t.region||`cn-beijing`,s=h(e.output),c=await me(e),l,u=new Map;if(n){l=[...new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean))];let t=await Promise.all(l.map(t=>g(e,c.token,{name:t,pageSize:50})));for(let e=0;e<l.length;e++){let n=t[e].models.find(t=>t.model===l[e]);n&&u.set(l[e],gs(n.capabilities||[]))}}else{let t=await bs(e,c.token);l=t.map(e=>e.name);for(let e of t)u.set(e.name,e.type)}let f={queryFreeTierQuotaRequest:{models:l}};if(e.dryRun){P({api:xs,data:f,region:o,token:c.token.slice(0,8)+`...`},s);return}let[p,m]=await Promise.all([d(e,c.token,{api:xs,data:f,region:o}),d(e,c.token,{api:Ss,data:{queryFreeTierOnlyStatusRequest:{models:l}},region:o})]);if(s===`json`){P(p,s);return}let _=vs(p),v=n?_:_.filter(e=>e.quotaStatus===`VALID`&&e.quotaInitTotal>0);if(r>0){let e=Date.now()+r*24*60*60*1e3;v=v.filter(t=>t.quotaValidityPeriod>0&&t.quotaValidityPeriod<=e)}if(a===`remaining`?v.sort((e,t)=>(e.quotaInitTotal?e.quotaTotal/e.quotaInitTotal:0)-(t.quotaInitTotal?t.quotaTotal/t.quotaInitTotal:0)):a===`expires`&&v.sort((e,t)=>(e.quotaValidityPeriod??0)-(t.quotaValidityPeriod??0)),v.length===0){process.stdout.write(`No free-tier quota found.
174
- `);return}let y=ys(m),b=new Map(y.map(e=>[e.model,e.freeTierOnly]));_s(v,b,u,e.noColor)}})}));function Es(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function Ds(e){let t=Es(e,`data`);if(!t)return e;let n=Es(t,`DataV2`);if(n){let e=Es(n,`data`);return(e?Es(e,`data`):void 0)??e??n}return Es(t,`data`)??t}async function Os(e,t,n,r,i,a){let o;for(let s=0;s<Fs;s++){let s=await d(e,t,{api:n,data:{[r]:o?{taskId:o}:{models:i}},region:a}),c=Ds(s);if(c.taskId&&Object.keys(c).length===1){o=c.taskId,await new Promise(e=>setTimeout(e,Ps));continue}return s}return null}async function ks(e,t){let n=[],r=1;for(;;){let i=await g(e,t,{pageNo:r,pageSize:50});if(n.push(...i.models),n.length>=i.total)break;r++}return n.map(e=>e.model).filter(Boolean)}var As,js,Ms,Ns,Ps,Fs,Is,Ls=M((()=>{I(),As=`zeldaEasy.broadscope-bailian.freeTrial.batchActivateFreeTierOnly`,js=`zeldaEasy.broadscope-bailian.freeTrial.batchDeactivateFreeTierOnly`,Ms=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota`,Ns=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierOnlyStatus`,Ps=500,Fs=20,Is=m({name:`usage freetier`,description:`Enable or disable auto-stop for free-tier models. Enables by default; use --off to disable`,usage:`bl usage freetier <--model <model>[,model2,...] | --all> [--off] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s), comma-separated for multiple`},{flag:`--all`,description:`Apply to all free-tier models`},{flag:`--on`,description:`Enable auto-stop (default behavior)`},{flag:`--off`,description:`Disable auto-stop`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl usage freetier --model qwen3-max`,`bl usage freetier --model qwen3-max,qwen-turbo`,`bl usage freetier --all`,`bl usage freetier --on --model qwen3-max`,`bl usage freetier --off --model qwen3-max`,`bl usage freetier --off --all`],async run(e,t){let n=t.model||void 0,r=!!t.all,i=!!t.off,a=t.region||`cn-beijing`,o=h(e.output);!n&&!r&&(process.stderr.write(`Error: missing required flag. Specify --model <model>[,model2,...] or --all
175
- `),process.exit(1));let s=await me(e),c;c=n?[...new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean))]:await ks(e,s.token);let l=i?js:As,u=i?`BatchDeactivateFreeTierOnlyRequest`:`BatchActivateFreeTierOnlyRequest`;if(e.dryRun){P({api:l,data:{[u]:{models:c}},region:a,token:s.token.slice(0,8)+`...`},o);return}if(i){let[t,n]=await Promise.all([d(e,s.token,{api:Ms,data:{queryFreeTierQuotaRequest:{models:c}},region:a}),d(e,s.token,{api:Ns,data:{queryFreeTierOnlyStatusRequest:{models:c}},region:a})]),r=Ds(t).freeTierQuotas??[],i=new Map(r.map(e=>[e.model,e])),o=Ds(n).freeTierOnlyStatuses??[],f=new Map(o.map(e=>[e.model,e.freeTierOnly]));for(let t of c){if(f.get(t)===!1){process.stderr.write(`Auto-stop is already disabled for "${t}".\n`);continue}let n=i.get(t);if(n&&n.quotaTotal>0&&f.get(t)===!0){process.stderr.write(`Cannot disable auto-stop for "${t}": free-tier quota has not been fully consumed. Please disable auto-stop after the quota is exhausted.\n`);continue}await Os(e,s.token,l,u,[t],a),process.stdout.write(`Disabled auto-stop for "${t}".\n`)}return}let f=[];for(let t of c){let n=await Os(e,s.token,l,u,[t],a);if(o===`json`){f.push(n);continue}if(n){let e=Ds(n).failureModels??[];e.length>0?process.stderr.write(`Failed to enable auto-stop for "${t}" (${e[0].errorCode}).\n`):process.stdout.write(`Enabled auto-stop for "${t}".\n`)}else process.stderr.write(`Warning: operation timed out for "${t}".\n`)}o===`json`&&P(f,o)}})}));function Rs(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function zs(e){let t=Rs(e,`data`);if(!t)return e;let n=Rs(t,`DataV2`);if(n){let e=Rs(n,`data`);return(e?Rs(e,`data`):void 0)??e??n}return Rs(t,`data`)??t}async function Bs(e,t,n,r,i){let a;for(let o=0;o<$s;o++){let o=await d(e,t,{api:n,data:a?{reqDTO:{...r,asyncTaskId:a}}:{reqDTO:r},region:i}),s=zs(o);if(s.taskId&&Object.keys(s).length===1){a=s.taskId,await new Promise(e=>setTimeout(e,Qs));continue}return o}return null}function Vs(e,t){if(t)return t;if(e.workspaceId)return e.workspaceId;process.stderr.write("Error: workspace-id is required. Set via --workspace-id, BAILIAN_WORKSPACE_ID, or `bl config set workspace_id <id>`.\n"),process.stderr.write("Hint: run `bl workspace list` to view available workspaces.\n"),process.exit(1)}function Hs(e){return e.toLocaleString(`en-US`)}function Us(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function Ws(e){let t=zs(e);if(t.callSuccessCount!==void 0||t.usages!==void 0)return t}function Gs(e){let t=zs(e);return{list:t.list??[],totalCount:t.totalCount??0,maxResults:t.maxResults??0}}function Ks(e){let t={};if(e.usages&&Array.isArray(e.usages))for(let n of e.usages)n.key&&n.value!=null&&(t[n.key]=n.value);if(e.usage&&typeof e.usage==`object`)for(let[n,r]of Object.entries(e.usage))r!=null&&(t[n]=r);return t}function qs(e){let t=e.unit?` [${e.unit}]`:``;return`${e.cn} (${e.en})${t}`}function Js(e,t,n,r,i){let a=i?e=>e:e=>`\x1b[1m${e}\x1b[0m`,o=i?e=>e:e=>`\x1b[2m${e}\x1b[0m`;process.stdout.write(`${o(`时间范围 Period:`)} ${Us(t)} ~ ${Us(n)} ${o(`(${r} 天)`)}\n\n`);let s=[[`调用模型数 (Models Called)`,Hs(e.modelCount??0)],[`调用成功次数 (Successful Calls)`,Hs(e.callSuccessCount??0)]];for(let t of e.usages??[]){let e=ec[t.key],n=e?qs(e):t.key;s.push([n,Hs(t.value)])}let c=Math.max(...s.map(([e])=>U(e)));for(let[e,t]of s)process.stdout.write(`${a(W(e,c+2))}${t}\n`)}function Ys(e,t,n,r,i){let a=i?e=>e:e=>`\x1b[1m${e}\x1b[0m`,o=i?e=>e:e=>`\x1b[2m${e}\x1b[0m`;if(process.stdout.write(`${o(`时间范围 Period:`)} ${Us(t)} ~ ${Us(n)} ${o(`(${r} 天)`)}\n\n`),e.length===0){process.stdout.write(`No usage data found.
176
- `);return}let s=new Set,c=e.map(e=>{let t=Ks(e);for(let e of Object.keys(t))s.add(e);return t}),l=[...s].sort((e,t)=>{let n=[`total_token`,`input_token`,`output_token`,`input_token_cache`,`image_number`,`video_duration`,`content_duration`,`tts_text_number`],r=n.indexOf(e),i=n.indexOf(t);return(r===-1?999:r)-(i===-1?999:i)}),u=[`模型`,`调用次数`,...l.map(e=>{let t=ec[e];return t?t.unit?`${t.cn} [${t.unit}]`:t.cn:e})],d=[`Model`,`Calls`,...l.map(e=>ec[e]?.en??e)],f=e.map((e,t)=>[e.model,Hs(e.callSuccessCount??0),...l.map(e=>{let n=c[t][e];return n==null?`-`:Hs(n)})]),p=u.map((e,t)=>Math.max(U(e),U(d[t]),...f.map(e=>U(e[t])))),m=u.map((e,t)=>a(W(e,p[t]))).join(` `),h=d.map((e,t)=>o(W(e,p[t]))).join(` `),g=p.map(e=>o(`─`.repeat(e))).join(`──`);process.stdout.write(m+`
173
+ `)}}function xs(e){let t=e.data;if(!t)return[];let n=t.DataV2;return n?n.data?.data?.freeTierQuotas||[]:t.data?.freeTierQuotas||[]}function Ss(e){let t=e.data;if(!t)return[];let n=t.DataV2;return n?n.data?.data?.freeTierOnlyStatuses||[]:t.data?.freeTierOnlyStatuses||[]}async function Cs(e,t){let n=[],r=1;for(;;){let i=await g(e,t,{pageNo:r,pageSize:50});if(n.push(...i.models),n.length>=i.total)break;r++}return n.filter(e=>typeof e.model==`string`&&e.model).map(e=>({name:e.model,type:ys(e.capabilities||[])}))}var ws,Ts,Es,Ds,Os=M((()=>{I(),hs(),ws=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota`,Ts=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierOnlyStatus`,Es={Reasoning:`Text`,TG:`Text`,VU:`Text`,IG:`Vision`,VG:`Vision`,"Realtime-Omni":`Multimodal`,"Multimodal-Omni":`Multimodal`,ASR:`Audio`,TTS:`Audio`,"Voice-Replication":`Audio`,"Realtime-Text-to-Speech":`Audio`,"Realtime-Voice-Replication":`Audio`,"Realtime-ASR":`Audio`,"Realtime-Audio-Translate":`Audio`,ME:`Embedding`,TR:`Embedding`},Ds=m({name:`usage free`,description:`Query free-tier quota for models (all models if --model is omitted)`,usage:`bl usage free [--model <model>[,model2,...]] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s) to query, comma-separated for multiple; omit for all models`},{flag:`--expiring <days>`,description:`Only show quotas expiring within N days`},{flag:`--sort <field>`,description:`Sort by: remaining (ascending), expires (ascending)`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl usage free`,`bl usage free --model qwen3-max`,`bl usage free --model qwen3-max,qwen-turbo`,`bl usage free --expiring 30`,`bl usage free --sort remaining`,`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||void 0,r=Number(t.expiring)||0,i=[`remaining`,`expires`],a=t.sort||void 0;a&&!i.includes(a)&&(process.stderr.write(`Error: invalid --sort value "${a}". Must be one of: ${i.join(`, `)}\n`),process.exit(1));let o=t.region||`cn-beijing`,s=h(e.output),c=await me(e),l,u=new Map;if(n){l=[...new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean))];let t=await Promise.all(l.map(t=>g(e,c.token,{name:t,pageSize:50})));for(let e=0;e<l.length;e++){let n=t[e].models.find(t=>t.model===l[e]);n&&u.set(l[e],ys(n.capabilities||[]))}}else{let t=await Cs(e,c.token);l=t.map(e=>e.name);for(let e of t)u.set(e.name,e.type)}let f={queryFreeTierQuotaRequest:{models:l}};if(e.dryRun){P({api:ws,data:f,region:o,token:c.token.slice(0,8)+`...`},s);return}let[p,m]=await Promise.all([d(e,c.token,{api:ws,data:f,region:o}),d(e,c.token,{api:Ts,data:{queryFreeTierOnlyStatusRequest:{models:l}},region:o})]);if(s===`json`){P(p,s);return}let _=xs(p),v=n?_:_.filter(e=>e.quotaStatus===`VALID`&&e.quotaInitTotal>0);if(r>0){let e=Date.now()+r*24*60*60*1e3;v=v.filter(t=>t.quotaValidityPeriod>0&&t.quotaValidityPeriod<=e)}if(a===`remaining`?v.sort((e,t)=>(e.quotaInitTotal?e.quotaTotal/e.quotaInitTotal:0)-(t.quotaInitTotal?t.quotaTotal/t.quotaInitTotal:0)):a===`expires`&&v.sort((e,t)=>(e.quotaValidityPeriod??0)-(t.quotaValidityPeriod??0)),v.length===0){process.stdout.write(`No free-tier quota found.
174
+ `);return}let y=Ss(m),b=new Map(y.map(e=>[e.model,e.freeTierOnly]));bs(v,b,u,e.noColor)}})}));function ks(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function As(e){let t=ks(e,`data`);if(!t)return e;let n=ks(t,`DataV2`);if(n){let e=ks(n,`data`);return(e?ks(e,`data`):void 0)??e??n}return ks(t,`data`)??t}async function js(e,t,n,r,i,a){let o;for(let s=0;s<Rs;s++){let s=await d(e,t,{api:n,data:{[r]:o?{taskId:o}:{models:i}},region:a}),c=As(s);if(c.taskId&&Object.keys(c).length===1){o=c.taskId,await new Promise(e=>setTimeout(e,Ls));continue}return s}return null}async function Ms(e,t){let n=[],r=1;for(;;){let i=await g(e,t,{pageNo:r,pageSize:50});if(n.push(...i.models),n.length>=i.total)break;r++}return n.map(e=>e.model).filter(Boolean)}var Ns,Ps,Fs,Is,Ls,Rs,zs,Bs=M((()=>{I(),Ns=`zeldaEasy.broadscope-bailian.freeTrial.batchActivateFreeTierOnly`,Ps=`zeldaEasy.broadscope-bailian.freeTrial.batchDeactivateFreeTierOnly`,Fs=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota`,Is=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierOnlyStatus`,Ls=500,Rs=20,zs=m({name:`usage freetier`,description:`Enable or disable auto-stop for free-tier models. Enables by default; use --off to disable`,usage:`bl usage freetier <--model <model>[,model2,...] | --all> [--off] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s), comma-separated for multiple`},{flag:`--all`,description:`Apply to all free-tier models`},{flag:`--on`,description:`Enable auto-stop (default behavior)`},{flag:`--off`,description:`Disable auto-stop`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl usage freetier --model qwen3-max`,`bl usage freetier --model qwen3-max,qwen-turbo`,`bl usage freetier --all`,`bl usage freetier --on --model qwen3-max`,`bl usage freetier --off --model qwen3-max`,`bl usage freetier --off --all`],async run(e,t){let n=t.model||void 0,r=!!t.all,i=!!t.off,a=t.region||`cn-beijing`,o=h(e.output);!n&&!r&&(process.stderr.write(`Error: missing required flag. Specify --model <model>[,model2,...] or --all
175
+ `),process.exit(1));let s=await me(e),c;c=n?[...new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean))]:await Ms(e,s.token);let l=i?Ps:Ns,u=i?`BatchDeactivateFreeTierOnlyRequest`:`BatchActivateFreeTierOnlyRequest`;if(e.dryRun){P({api:l,data:{[u]:{models:c}},region:a,token:s.token.slice(0,8)+`...`},o);return}if(i){let[t,n]=await Promise.all([d(e,s.token,{api:Fs,data:{queryFreeTierQuotaRequest:{models:c}},region:a}),d(e,s.token,{api:Is,data:{queryFreeTierOnlyStatusRequest:{models:c}},region:a})]),r=As(t).freeTierQuotas??[],i=new Map(r.map(e=>[e.model,e])),o=As(n).freeTierOnlyStatuses??[],f=new Map(o.map(e=>[e.model,e.freeTierOnly]));for(let t of c){if(f.get(t)===!1){process.stderr.write(`Auto-stop is already disabled for "${t}".\n`);continue}let n=i.get(t);if(n&&n.quotaTotal>0&&f.get(t)===!0){process.stderr.write(`Cannot disable auto-stop for "${t}": free-tier quota has not been fully consumed. Please disable auto-stop after the quota is exhausted.\n`);continue}await js(e,s.token,l,u,[t],a),process.stdout.write(`Disabled auto-stop for "${t}".\n`)}return}let f=[];for(let t of c){let n=await js(e,s.token,l,u,[t],a);if(o===`json`){f.push(n);continue}if(n){let e=As(n).failureModels??[];e.length>0?process.stderr.write(`Failed to enable auto-stop for "${t}" (${e[0].errorCode}).\n`):process.stdout.write(`Enabled auto-stop for "${t}".\n`)}else process.stderr.write(`Warning: operation timed out for "${t}".\n`)}o===`json`&&P(f,o)}})}));function Vs(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function Hs(e){let t=Vs(e,`data`);if(!t)return e;let n=Vs(t,`DataV2`);if(n){let e=Vs(n,`data`);return(e?Vs(e,`data`):void 0)??e??n}return Vs(t,`data`)??t}async function Us(e,t,n,r,i){let a;for(let o=0;o<nc;o++){let o=await d(e,t,{api:n,data:a?{reqDTO:{...r,asyncTaskId:a}}:{reqDTO:r},region:i}),s=Hs(o);if(s.taskId&&Object.keys(s).length===1){a=s.taskId,await new Promise(e=>setTimeout(e,tc));continue}return o}return null}function Ws(e,t){if(t)return t;if(e.workspaceId)return e.workspaceId;process.stderr.write("Error: workspace-id is required. Set via --workspace-id, BAILIAN_WORKSPACE_ID, or `bl config set workspace_id <id>`.\n"),process.stderr.write("Hint: run `bl workspace list` to view available workspaces.\n"),process.exit(1)}function Gs(e){return e.toLocaleString(`en-US`)}function Ks(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function qs(e){let t=Hs(e);if(t.callSuccessCount!==void 0||t.usages!==void 0)return t}function Js(e){let t=Hs(e);return{list:t.list??[],totalCount:t.totalCount??0,maxResults:t.maxResults??0}}function Ys(e){let t={};if(e.usages&&Array.isArray(e.usages))for(let n of e.usages)n.key&&n.value!=null&&(t[n.key]=n.value);if(e.usage&&typeof e.usage==`object`)for(let[n,r]of Object.entries(e.usage))r!=null&&(t[n]=r);return t}function Xs(e){let t=e.unit?` [${e.unit}]`:``;return`${e.cn} (${e.en})${t}`}function Zs(e,t,n,r,i){let a=i?e=>e:e=>`\x1b[1m${e}\x1b[0m`,o=i?e=>e:e=>`\x1b[2m${e}\x1b[0m`;process.stdout.write(`${o(`时间范围 Period:`)} ${Ks(t)} ~ ${Ks(n)} ${o(`(${r} 天)`)}\n\n`);let s=[[`调用模型数 (Models Called)`,Gs(e.modelCount??0)],[`调用成功次数 (Successful Calls)`,Gs(e.callSuccessCount??0)]];for(let t of e.usages??[]){let e=rc[t.key],n=e?Xs(e):t.key;s.push([n,Gs(t.value)])}let c=Math.max(...s.map(([e])=>U(e)));for(let[e,t]of s)process.stdout.write(`${a(W(e,c+2))}${t}\n`)}function Qs(e,t,n,r,i){let a=i?e=>e:e=>`\x1b[1m${e}\x1b[0m`,o=i?e=>e:e=>`\x1b[2m${e}\x1b[0m`;if(process.stdout.write(`${o(`时间范围 Period:`)} ${Ks(t)} ~ ${Ks(n)} ${o(`(${r} 天)`)}\n\n`),e.length===0){process.stdout.write(`No usage data found.
176
+ `);return}let s=new Set,c=e.map(e=>{let t=Ys(e);for(let e of Object.keys(t))s.add(e);return t}),l=[...s].sort((e,t)=>{let n=[`total_token`,`input_token`,`output_token`,`input_token_cache`,`image_number`,`video_duration`,`content_duration`,`tts_text_number`],r=n.indexOf(e),i=n.indexOf(t);return(r===-1?999:r)-(i===-1?999:i)}),u=[`模型`,`调用次数`,...l.map(e=>{let t=rc[e];return t?t.unit?`${t.cn} [${t.unit}]`:t.cn:e})],d=[`Model`,`Calls`,...l.map(e=>rc[e]?.en??e)],f=e.map((e,t)=>[e.model,Gs(e.callSuccessCount??0),...l.map(e=>{let n=c[t][e];return n==null?`-`:Gs(n)})]),p=u.map((e,t)=>Math.max(U(e),U(d[t]),...f.map(e=>U(e[t])))),m=u.map((e,t)=>a(W(e,p[t]))).join(` `),h=d.map((e,t)=>o(W(e,p[t]))).join(` `),g=p.map(e=>o(`─`.repeat(e))).join(`──`);process.stdout.write(m+`
177
177
  `),process.stdout.write(h+`
178
178
  `),process.stdout.write(g+`
179
179
  `);for(let e of f){let t=e.map((e,t)=>W(e,p[t]));process.stdout.write(t.join(` `)+`
180
180
  `)}process.stdout.write(o(`\n共 ${e.length} 个模型 (Total: ${e.length})`)+`
181
- `)}var Xs,Zs,Qs,$s,ec,tc,nc=M((()=>{I(),fs(),Xs=`zeldaEasy.bailian-telemetry.model.getModelUsageStatistic`,Zs=`zeldaEasy.bailian-telemetry.model.listModelUsageStatisticData`,Qs=500,$s=30,ec={total_token:{cn:`总 Token`,en:`Total Tokens`,unit:`tokens`},input_token:{cn:`输入 Token`,en:`Input Tokens`,unit:`tokens`},output_token:{cn:`输出 Token`,en:`Output Tokens`,unit:`tokens`},input_token_cache:{cn:`缓存 Token`,en:`Cached Tokens`,unit:`tokens`},input_token_cache_read:{cn:`缓存读取`,en:`Cache Read`,unit:`tokens`},input_token_cache_creation:{cn:`缓存创建`,en:`Cache Creation`,unit:`tokens`},thinking_input_token:{cn:`思考输入`,en:`Thinking Input`,unit:`tokens`},thinking_output_token:{cn:`思考输出`,en:`Thinking Output`,unit:`tokens`},text_input_token:{cn:`文本输入`,en:`Text Input`,unit:`tokens`},purein_text_output_token:{cn:`文本输出`,en:`Text Output`,unit:`tokens`},embedding_token:{cn:`向量`,en:`Embedding`,unit:`tokens`},image_number:{cn:`图片数`,en:`Images`,unit:`张`},video_duration:{cn:`视频时长`,en:`Video Duration`,unit:`秒`},content_duration:{cn:`音频时长`,en:`Audio Duration`,unit:`秒`},tts_text_number:{cn:`语音合成`,en:`TTS Chars`,unit:`字符`},total_token_avg:{cn:`平均 Token/次`,en:`Avg Tokens/Req`}},tc=m({name:`usage stats`,description:`Query model usage statistics`,usage:`bl usage stats [--model <model>] [--days <days>] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s), comma-separated; omit for overview`},{flag:`--days <days>`,description:`Number of days (default: 7)`},{flag:`--type <type>`,description:`Model type: Text, Vision, Multimodal, Audio, Embedding`},{flag:`--workspace-id <id>`,description:`Workspace ID (env: BAILIAN_WORKSPACE_ID)`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl usage stats`,`bl usage stats --days 30`,`bl usage stats --model qwen-turbo`,`bl usage stats --model qwen-turbo --days 7`,`bl usage stats --model qwen3.6-plus,deepseek-v4-pro`,`bl usage stats --type Text --days 14`,`bl usage stats --output json`],async run(e,t){let n=t.model||void 0,r=Number(t.days)||7,i=t.type||void 0,a=t.region||`cn-beijing`,o=h(e.output),s=Vs(e,t.workspaceId||void 0),c=await me(e),l=Date.now(),u=l-r*24*60*60*1e3;if(n){let t=[...new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean))],d={startTime:u,endTime:l,modelCallSource:`Online`,filterWorkspaceId:s,maxResults:50,skip:0,sortField:`success_count`,sortOrder:`DESC`};if(i&&(d.obsModelType=i),e.dryRun){P({api:Zs,data:{reqDTO:{...d,model:t.join(`,`)}},region:a},o);return}let f=await Promise.all(t.map(t=>Bs(e,c.token,Zs,{...d,model:t},a))),p=[],m=[];for(let e of f){if(!e)continue;m.push(e);let t=Gs(e);p.push(...t.list)}if(o===`json`){P(m.length===1?m[0]:m,o);return}Ys(p,u,l,r,e.noColor)}else{let t={startTime:u,endTime:l,modelCallSource:`Online`,filterWorkspaceId:s};if(i&&(t.obsModelType=i),e.dryRun){P({api:Xs,data:{reqDTO:t},region:a},o);return}let n=await Bs(e,c.token,Xs,t,a);if(n||(process.stderr.write(`Error: request timed out.
182
- `),process.exit(1)),o===`json`){P(n,o);return}let d=Ws(n);if(!d){process.stdout.write(`No usage data found.
183
- `);return}Js(d,u,l,r,e.noColor)}}})}));function rc(e,t){return e instanceof G?e:new G(`step_execution_error`,e instanceof Error?e.message:String(e),{step:t})}var G,ic=M((()=>{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 ac(){return cc}function oc(e,t,n,r){let i,a;n instanceof sc?(i=n,a=r):(i=cc,a=n??r),i.registerStep(e,t,a)}var sc,cc,lc=M((()=>{ic(),sc=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)}},cc=new sc}));function uc(){let e=te(dc);return e.clientName=`bailian-cli`,e}var dc,fc=M((()=>{dc={output:`json`,nonInteractive:!0,noColor:!0,quiet:!0,verbose:!1,yes:!1,dryRun:!1,help:!1,async:!1}}));function pc(e){return e.startsWith(`./`)||e.startsWith(`../`)}function mc(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))typeof a==`string`&&pc(a)?(n[i]=$e(t,a),r.push(i)):n[i]=a;return{input:n,resolvedKeys:r}}async function hc(e,t,n){let r=[];for(let i of t){let t=e[i];typeof t==`string`&&(await qe(t).then(()=>!0,()=>!1)||r.push(`Step "${n}" input "${i}" references file that does not exist: ${t}`))}return r}function gc(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 _c(e,t){if(Array.isArray(e)){e.forEach(e=>_c(e,t));return}if(K(e)){`$from`in e&&typeof e.$from==`string`&&t.add(e.$from);for(let n of Object.values(e))_c(n,t)}}async function vc(e,t){let n=[];for(let r of e)for(let[e,i]of Object.entries(r.input)){if(yc.includes(e)||typeof i!=`string`||!pc(i))continue;let a=$e(t,i);await qe(a).then(()=>!0,()=>!1)||n.push(`Step "${r.id}" input "${e}" references file that does not exist: ${a}`)}return n}var yc,bc=M((()=>{yc=[`download`,`out-dir`,`output`]}));async function xc(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 k(e,{url:f(e.baseUrl),method:`POST`,body:a,timeout:n.blRequestTimeoutSeconds,signal:n.signal})}async function Sc(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(D(i)){let t=await A(e);i=await j(i,t.token,r,{signal:n.signal})}s.push({type:`video_url`,video_url:{url:i}})}for(let t of i){let i=t;D(t)&&(i=await j(t,(await A(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 k(e,{url:f(e.baseUrl),method:`POST`,body:c,signal:n.signal})}function Cc(e){return Pc.some(t=>e.startsWith(t))}async function wc(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=Cc(r),a=t.n??1,o=pe(t[`prompt-extend`],i?!0:void 0,`prompt-extend`),s={model:r,input:{messages:[{role:`user`,content:[{text:t.prompt}]}]},parameters:{size:$i(t.size,i),n:a,seed:t.seed,prompt_extend:o,watermark:ge(t.watermark),negative_prompt:t[`negative-prompt`]||void 0}};if(i){let r=await k(e,{url:T(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 Ec(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await k(e,{url:w(e.baseUrl),method:`POST`,body:s,async:!0,signal:n.signal})).output.task_id,i=await jc(e,r,n),a=await Ec(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function Tc(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=Cc(i),o=t.n??1,s=pe(t[`prompt-extend`],a?!0:void 0,`prompt-extend`),c=[];for(let t of r){let r=t;D(t)&&(r=await j(t,(await A(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:$i(t.size,a),n:o,seed:t.seed,prompt_extend:s,watermark:ge(t.watermark),negative_prompt:t[`negative-prompt`]||void 0}};if(a){let r=await k(e,{url:T(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 Ec(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await k(e,{url:w(e.baseUrl),method:`POST`,body:l,async:!0,signal:n.signal})).output.task_id,i=await jc(e,r,n),a=await Ec(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function Ec(e,t,n){if(!t||e.length===0)return;await Je(t,{recursive:!0});let r=n&&n.length>0?n:`image`,i=e.length===1?[{url:e[0],destPath:Qe(t,`${r}.png`)}]:e.map((e,n)=>({url:e,destPath:Qe(t,`${r}_${String(n+1).padStart(3,`0`)}.png`)})),a=[];for(let{url:e,destPath:t}of i)await Ki(e,t,{quiet:!0}),a.push(t);return a}async function Dc(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(D(t.image)){let a=await A(e);i=await j(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:pe(t[`prompt-extend`],void 0,`prompt-extend`),watermark:ge(t.watermark),seed:t.seed}};be(a.parameters);let o=(await k(e,{url:Ee(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Mc(e,o,(t[`poll-interval`]??10)*1e3,(n.timeoutSeconds??900)*1e3,n)}async function Oc(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`]}};be(a.input);let o=await k(e,{url:ye(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 kc(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(D(a)){let r=await A(e);i.push(await j(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`]}};be(a.parameters);let o=(await k(e,{url:ve(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Mc(e,o,(t[`poll-interval`]??2)*1e3,(n.timeoutSeconds??300)*1e3,n)}function Ac(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 jc(e,t,n){return await Mc(e,t,3e3,e.timeout*1e3,n)}async function Mc(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 Nc(n,i?.signal),o++;let s=await k(e,{url:xe(e.baseUrl,t),method:`GET`,signal:i?.signal}),c=s.output.task_status;if(c===`SUCCEEDED`)return Ac(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 Nc(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 Pc,Fc=M((()=>{ic(),na(),Ji(),Pc=[`qwen-image-2.0`,`qwen-image-max`]}));function Ic(e){for(let t of Object.keys(Gc))oc(t,async(e,n)=>await Lc(t,e,n),e,qc[t])}async function Lc(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=Gc[e];if(!r)throw Error(`No direct API handler registered for step: ${e}`);let i=await r(n.blConfig??uc(),t,n),a=Kc[e];return a?a(i):{data:i,warnings:[],metadata:{}}}function Rc(e){if(!K(e))return;let t=[],n=q(e.task_id)??q(e.taskId);for(let r of Hc(e.urls))t.push({url:r,taskId:n,kind:Uc(r)});for(let r of Hc(e.saved))t.push({path:r,taskId:n,kind:Wc(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:Wc(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(Vc):[];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 zc(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(Vc);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(Vc);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?Bc(n):void 0}function Bc(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 Vc(e){return typeof e==`string`}function q(e){return typeof e==`string`&&e.length>0?e:void 0}function Hc(e){return Array.isArray(e)?e.map(q).filter(Vc):[]}function Uc(e){try{return Wc(new URL(e).pathname)}catch{return`artifact`}}function Wc(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 Gc,Kc,qc,Jc=M((()=>{lc(),fc(),bc(),Fc(),Gc={"text/chat":(e,t,n)=>xc(e,t,n),"vision/describe":(e,t,n)=>Sc(e,t,n),"image/generate":(e,t,n)=>wc(e,t,n),"image/edit":(e,t,n)=>Tc(e,t,n),"video/generate":(e,t,n)=>Dc(e,t,n),"speech/synthesize":(e,t,n)=>Oc(e,t,n),"speech/recognize":(e,t,n)=>kc(e,t,n)},Kc={"image/generate":e=>({data:e,artifacts:Rc(e),warnings:[],metadata:{}}),"image/edit":e=>({data:e,artifacts:Rc(e),warnings:[],metadata:{}}),"video/generate":e=>({data:e,artifacts:Rc(e),warnings:[],metadata:{}}),"speech/synthesize":e=>({data:e,artifacts:zc(e,`audio`),warnings:[],metadata:{}}),"speech/recognize":e=>({data:e,artifacts:zc(e,`transcript`),warnings:[],metadata:{}})},qc={"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`}]}}})),Yc=N((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})),Xc=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=Yc();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=N((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=Yc(),n=Xc();var r=Yc();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=Xc();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&&=te(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=te(this.rhs,e,n),this}get names(){return ee(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=te(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)||(O(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(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(ne(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=te(this.condition,e,t),this}get names(){let e=super.names;return ee(e,this.condition),this.else&&D(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=te(this.iteration,e,t),this}get names(){return D(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 ee(ee(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=te(this.iterable,e,t),this}get names(){return D(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&&D(e,this.catch.names),this.finally&&D(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?`
184
- `:``},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 D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function ee(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function te(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 O(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function ne(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${ce(e)}`}e.not=ne;let re=se(e.operators.AND);function ie(...e){return e.reduce(re)}e.and=ie;let ae=se(e.operators.OR);function oe(...e){return e.reduce(ae)}e.or=oe;function se(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${ce(n)} ${e} ${ce(r)}`}function ce(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),Y=N((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=Yc();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})),Zc=N((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`)}})),Qc=N((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=Zc();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])}})),$c=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=Qc(),n=J(),r=Zc(),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)}})),el=N((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})),tl=N((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})),nl=N((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=el(),n=tl(),r=Qc(),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
181
+ `)}var $s,ec,tc,nc,rc,ic,ac=M((()=>{I(),hs(),$s=`zeldaEasy.bailian-telemetry.model.getModelUsageStatistic`,ec=`zeldaEasy.bailian-telemetry.model.listModelUsageStatisticData`,tc=500,nc=30,rc={total_token:{cn:`总 Token`,en:`Total Tokens`,unit:`tokens`},input_token:{cn:`输入 Token`,en:`Input Tokens`,unit:`tokens`},output_token:{cn:`输出 Token`,en:`Output Tokens`,unit:`tokens`},input_token_cache:{cn:`缓存 Token`,en:`Cached Tokens`,unit:`tokens`},input_token_cache_read:{cn:`缓存读取`,en:`Cache Read`,unit:`tokens`},input_token_cache_creation:{cn:`缓存创建`,en:`Cache Creation`,unit:`tokens`},thinking_input_token:{cn:`思考输入`,en:`Thinking Input`,unit:`tokens`},thinking_output_token:{cn:`思考输出`,en:`Thinking Output`,unit:`tokens`},text_input_token:{cn:`文本输入`,en:`Text Input`,unit:`tokens`},purein_text_output_token:{cn:`文本输出`,en:`Text Output`,unit:`tokens`},embedding_token:{cn:`向量`,en:`Embedding`,unit:`tokens`},image_number:{cn:`图片数`,en:`Images`,unit:`张`},video_duration:{cn:`视频时长`,en:`Video Duration`,unit:`秒`},content_duration:{cn:`音频时长`,en:`Audio Duration`,unit:`秒`},tts_text_number:{cn:`语音合成`,en:`TTS Chars`,unit:`字符`},total_token_avg:{cn:`平均 Token/次`,en:`Avg Tokens/Req`}},ic=m({name:`usage stats`,description:`Query model usage statistics`,usage:`bl usage stats [--model <model>] [--days <days>] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s), comma-separated; omit for overview`},{flag:`--days <days>`,description:`Number of days (default: 7)`},{flag:`--type <type>`,description:`Model type: Text, Vision, Multimodal, Audio, Embedding`},{flag:`--workspace-id <id>`,description:`Workspace ID (env: BAILIAN_WORKSPACE_ID)`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl usage stats`,`bl usage stats --days 30`,`bl usage stats --model qwen-turbo`,`bl usage stats --model qwen-turbo --days 7`,`bl usage stats --model qwen3.6-plus,deepseek-v4-pro`,`bl usage stats --type Text --days 14`,`bl usage stats --output json`],async run(e,t){let n=t.model||void 0,r=Number(t.days)||7,i=t.type||void 0,a=t.region||`cn-beijing`,o=h(e.output),s=Ws(e,t.workspaceId||void 0),c=await me(e),l=Date.now(),u=l-r*24*60*60*1e3;if(n){let t=[...new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean))],d={startTime:u,endTime:l,modelCallSource:`Online`,filterWorkspaceId:s,maxResults:50,skip:0,sortField:`success_count`,sortOrder:`DESC`};if(i&&(d.obsModelType=i),e.dryRun){P({api:ec,data:{reqDTO:{...d,model:t.join(`,`)}},region:a},o);return}let f=await Promise.all(t.map(t=>Us(e,c.token,ec,{...d,model:t},a))),p=[],m=[];for(let e of f){if(!e)continue;m.push(e);let t=Js(e);p.push(...t.list)}if(o===`json`){P(m.length===1?m[0]:m,o);return}Qs(p,u,l,r,e.noColor)}else{let t={startTime:u,endTime:l,modelCallSource:`Online`,filterWorkspaceId:s};if(i&&(t.obsModelType=i),e.dryRun){P({api:$s,data:{reqDTO:t},region:a},o);return}let n=await Us(e,c.token,$s,t,a);if(n||(process.stderr.write(`Error: request timed out.
182
+ `),process.exit(1)),o===`json`){P(n,o);return}let d=qs(n);if(!d){process.stdout.write(`No usage data found.
183
+ `);return}Zs(d,u,l,r,e.noColor)}}})}));function oc(e,t){return e instanceof G?e:new G(`step_execution_error`,e instanceof Error?e.message:String(e),{step:t})}var G,sc=M((()=>{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 cc(){return dc}function lc(e,t,n,r){let i,a;n instanceof uc?(i=n,a=r):(i=dc,a=n??r),i.registerStep(e,t,a)}var uc,dc,fc=M((()=>{sc(),uc=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)}},dc=new uc}));function pc(){let e=te(mc);return e.clientName=`bailian-cli`,e}var mc,hc=M((()=>{mc={output:`json`,nonInteractive:!0,noColor:!0,quiet:!0,verbose:!1,yes:!1,dryRun:!1,help:!1,async:!1}}));function gc(e){return e.startsWith(`./`)||e.startsWith(`../`)}function _c(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))typeof a==`string`&&gc(a)?(n[i]=$e(t,a),r.push(i)):n[i]=a;return{input:n,resolvedKeys:r}}async function vc(e,t,n){let r=[];for(let i of t){let t=e[i];typeof t==`string`&&(await qe(t).then(()=>!0,()=>!1)||r.push(`Step "${n}" input "${i}" references file that does not exist: ${t}`))}return r}function yc(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 bc(e,t){if(Array.isArray(e)){e.forEach(e=>bc(e,t));return}if(K(e)){`$from`in e&&typeof e.$from==`string`&&t.add(e.$from);for(let n of Object.values(e))bc(n,t)}}async function xc(e,t){let n=[];for(let r of e)for(let[e,i]of Object.entries(r.input)){if(Sc.includes(e)||typeof i!=`string`||!gc(i))continue;let a=$e(t,i);await qe(a).then(()=>!0,()=>!1)||n.push(`Step "${r.id}" input "${e}" references file that does not exist: ${a}`)}return n}var Sc,Cc=M((()=>{Sc=[`download`,`out-dir`,`output`]}));async function wc(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 k(e,{url:f(e.baseUrl),method:`POST`,body:a,timeout:n.blRequestTimeoutSeconds,signal:n.signal})}async function Tc(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(D(i)){let t=await A(e);i=await j(i,t.token,r,{signal:n.signal})}s.push({type:`video_url`,video_url:{url:i}})}for(let t of i){let i=t;D(t)&&(i=await j(t,(await A(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 k(e,{url:f(e.baseUrl),method:`POST`,body:c,signal:n.signal})}function Ec(e){return Lc.some(t=>e.startsWith(t))}async function Dc(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=Ec(r),a=t.n??1,o=pe(t[`prompt-extend`],i?!0:void 0,`prompt-extend`),s={model:r,input:{messages:[{role:`user`,content:[{text:t.prompt}]}]},parameters:{size:na(t.size,i),n:a,seed:t.seed,prompt_extend:o,watermark:ge(t.watermark),negative_prompt:t[`negative-prompt`]||void 0}};if(i){let r=await k(e,{url:T(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 kc(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await k(e,{url:w(e.baseUrl),method:`POST`,body:s,async:!0,signal:n.signal})).output.task_id,i=await Pc(e,r,n),a=await kc(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function Oc(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=Ec(i),o=t.n??1,s=pe(t[`prompt-extend`],a?!0:void 0,`prompt-extend`),c=[];for(let t of r){let r=t;D(t)&&(r=await j(t,(await A(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:na(t.size,a),n:o,seed:t.seed,prompt_extend:s,watermark:ge(t.watermark),negative_prompt:t[`negative-prompt`]||void 0}};if(a){let r=await k(e,{url:T(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 kc(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await k(e,{url:w(e.baseUrl),method:`POST`,body:l,async:!0,signal:n.signal})).output.task_id,i=await Pc(e,r,n),a=await kc(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function kc(e,t,n){if(!t||e.length===0)return;await Je(t,{recursive:!0});let r=n&&n.length>0?n:`image`,i=e.length===1?[{url:e[0],destPath:Qe(t,`${r}.png`)}]:e.map((e,n)=>({url:e,destPath:Qe(t,`${r}_${String(n+1).padStart(3,`0`)}.png`)})),a=[];for(let{url:e,destPath:t}of i)await Yi(e,t,{quiet:!0}),a.push(t);return a}async function Ac(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(D(t.image)){let a=await A(e);i=await j(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:pe(t[`prompt-extend`],void 0,`prompt-extend`),watermark:ge(t.watermark),seed:t.seed}};be(a.parameters);let o=(await k(e,{url:Ee(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Fc(e,o,(t[`poll-interval`]??10)*1e3,(n.timeoutSeconds??900)*1e3,n)}async function jc(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`]}};be(a.input);let o=await k(e,{url:ye(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 Mc(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(D(a)){let r=await A(e);i.push(await j(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`]}};be(a.parameters);let o=(await k(e,{url:ve(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Fc(e,o,(t[`poll-interval`]??2)*1e3,(n.timeoutSeconds??300)*1e3,n)}function Nc(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 Pc(e,t,n){return await Fc(e,t,3e3,e.timeout*1e3,n)}async function Fc(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 Ic(n,i?.signal),o++;let s=await k(e,{url:xe(e.baseUrl,t),method:`GET`,signal:i?.signal}),c=s.output.task_status;if(c===`SUCCEEDED`)return Nc(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 Ic(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 Lc,Rc=M((()=>{sc(),aa(),Zi(),Lc=[`qwen-image-2.0`,`qwen-image-max`]}));function zc(e){for(let t of Object.keys(Jc))lc(t,async(e,n)=>await Bc(t,e,n),e,Xc[t])}async function Bc(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=Jc[e];if(!r)throw Error(`No direct API handler registered for step: ${e}`);let i=await r(n.blConfig??pc(),t,n),a=Yc[e];return a?a(i):{data:i,warnings:[],metadata:{}}}function Vc(e){if(!K(e))return;let t=[],n=q(e.task_id)??q(e.taskId);for(let r of Gc(e.urls))t.push({url:r,taskId:n,kind:Kc(r)});for(let r of Gc(e.saved))t.push({path:r,taskId:n,kind:qc(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:qc(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(Wc):[];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 Hc(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(Wc);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(Wc);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?Uc(n):void 0}function Uc(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 Wc(e){return typeof e==`string`}function q(e){return typeof e==`string`&&e.length>0?e:void 0}function Gc(e){return Array.isArray(e)?e.map(q).filter(Wc):[]}function Kc(e){try{return qc(new URL(e).pathname)}catch{return`artifact`}}function qc(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 Jc,Yc,Xc,Zc=M((()=>{fc(),hc(),Cc(),Rc(),Jc={"text/chat":(e,t,n)=>wc(e,t,n),"vision/describe":(e,t,n)=>Tc(e,t,n),"image/generate":(e,t,n)=>Dc(e,t,n),"image/edit":(e,t,n)=>Oc(e,t,n),"video/generate":(e,t,n)=>Ac(e,t,n),"speech/synthesize":(e,t,n)=>jc(e,t,n),"speech/recognize":(e,t,n)=>Mc(e,t,n)},Yc={"image/generate":e=>({data:e,artifacts:Vc(e),warnings:[],metadata:{}}),"image/edit":e=>({data:e,artifacts:Vc(e),warnings:[],metadata:{}}),"video/generate":e=>({data:e,artifacts:Vc(e),warnings:[],metadata:{}}),"speech/synthesize":e=>({data:e,artifacts:Hc(e,`audio`),warnings:[],metadata:{}}),"speech/recognize":e=>({data:e,artifacts:Hc(e,`transcript`),warnings:[],metadata:{}})},Xc={"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`}]}}})),Qc=N((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})),$c=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=Qc();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=N((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=Qc(),n=$c();var r=Qc();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=$c();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&&=te(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=te(this.rhs,e,n),this}get names(){return ee(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=te(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)||(O(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(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(ne(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=te(this.condition,e,t),this}get names(){let e=super.names;return ee(e,this.condition),this.else&&D(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=te(this.iteration,e,t),this}get names(){return D(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 ee(ee(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=te(this.iterable,e,t),this}get names(){return D(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&&D(e,this.catch.names),this.finally&&D(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?`
184
+ `:``},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 D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function ee(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function te(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 O(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function ne(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${ce(e)}`}e.not=ne;let re=se(e.operators.AND);function ie(...e){return e.reduce(re)}e.and=ie;let ae=se(e.operators.OR);function oe(...e){return e.reduce(ae)}e.or=oe;function se(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${ce(n)} ${e} ${ce(r)}`}function ce(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),Y=N((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=Qc();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})),el=N((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`)}})),tl=N((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=el();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])}})),nl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=tl(),n=J(),r=el(),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)}})),rl=N((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})),il=N((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})),al=N((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=rl(),n=il(),r=tl(),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
185
185
  || (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
186
186
  || (${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"
187
- || ${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}}})),rl=N((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)}`)}})),il=N((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=Zc(),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})),al=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=J(),n=Zc(),r=il(),i=Qc();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})),ol=N((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})),sl=N(((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}})),cl=N(((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`)}})),ll=N((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=sl(),r=cl(),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})),ul=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=$c(),n=nl(),r=tl(),i=nl(),a=rl(),o=al(),s=ol(),c=J(),l=Zc(),u=ll(),d=Y(),f=Qc();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&&O(e),D(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),ne(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&&O(e),ee(e),te(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 ie(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);ie(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 D(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 ee(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function te(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function O({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 ne(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&&re(e),t.return((0,c._)`${l.default.errors} === 0`))}function re({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 ie(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||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)),ae(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):ae(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function ae(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 oe(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(se(e,t),e.opts.allowUnionTypes||ce(e,t),le(e,e.dataTypes))}function se(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{de(e.dataTypes,t)||k(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),fe(e,t)}}function ce(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&k(e,`use allowUnionTypes to allow union type keyword`)}function le(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=>ue(t,e))&&k(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function ue(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function de(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function fe(e,t){let n=[];for(let r of e.dataTypes)de(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function k(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`,he(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 A=/^\/(?:[^~]|~0|~1)*$/,j=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function he(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!A.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=j.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=he})),dl=N((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}}})),fl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ll();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))}}})),pl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=J(),n=dl(),r=Zc(),i=ll(),a=Y(),o=ul();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}})),ml=N(((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}})),hl=N(((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}})),gl=N(((e,t)=>{let{isUUID:n}=hl(),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}})),_l=N(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=hl(),{SCHEMES:d,getSchemeHandler:f}=gl();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})),vl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=_l();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),yl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=ul();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=dl(),i=fl(),a=el(),o=pl(),s=J(),c=ll(),l=nl(),u=Y(),d=ml(),f=vl(),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=D(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(te.call(this,n,t),!t)return(0,u.eachItem)(n,e=>O.call(this,e)),this;re.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=>O.call(this,e,r):e=>r.type.forEach(t=>O.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]=ae(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 D(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 ee=/^[a-z_$][a-z0-9_$:-]*$/i;function te(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!ee.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 O(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?ne.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 ne(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 re(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=ae(t)),e.validateSchema=this.compile(t,!0))}let ie={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function ae(e){return{anyOf:[e,ie]}}})),bl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),xl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;let t=fl(),n=il(),r=J(),i=Zc(),a=pl(),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})),Sl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=bl(),n=xl();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),Cl=N((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})`)}}})),wl=N((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}))`)}}})),Tl=N((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`})),El=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=Tl();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}`)}}})),Dl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=il(),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})`)}}}})),Ol=N((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}`)}}})),kl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=il(),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)}}}})),Al=N((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}`)}}})),jl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=sl();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),Ml=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=nl(),n=J(),r=Y(),i=jl();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)})))}}}})),Nl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=jl();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}`)}}})),Pl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=jl();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}`}}}})),Fl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Cl(),n=wl(),r=El(),i=Dl(),a=Ol(),o=kl(),s=Al(),c=Ml(),l=Nl(),u=Pl();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]})),Il=N((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})),Ll=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;let t=J(),n=Y(),r=il(),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})),Rl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ll();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),zl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=il(),i=Il();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)))}}})),Bl=N((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)))}}}})),Vl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=J(),n=Y(),r=il();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},
187
+ || ${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}}})),ol=N((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)}`)}})),sl=N((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=el(),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})),cl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=J(),n=el(),r=sl(),i=tl();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})),ll=N((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})),ul=N(((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}})),dl=N(((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`)}})),fl=N((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=ul(),r=dl(),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})),pl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=nl(),n=al(),r=il(),i=al(),a=ol(),o=cl(),s=ll(),c=J(),l=el(),u=fl(),d=Y(),f=tl();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&&O(e),D(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),ne(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&&O(e),ee(e),te(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 ie(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);ie(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 D(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 ee(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function te(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function O({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 ne(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&&re(e),t.return((0,c._)`${l.default.errors} === 0`))}function re({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 ie(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||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)),ae(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):ae(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function ae(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 oe(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(se(e,t),e.opts.allowUnionTypes||ce(e,t),le(e,e.dataTypes))}function se(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{de(e.dataTypes,t)||k(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),fe(e,t)}}function ce(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&k(e,`use allowUnionTypes to allow union type keyword`)}function le(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=>ue(t,e))&&k(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function ue(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function de(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function fe(e,t){let n=[];for(let r of e.dataTypes)de(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function k(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`,he(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 A=/^\/(?:[^~]|~0|~1)*$/,j=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function he(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!A.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=j.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=he})),ml=N((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}}})),hl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=fl();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))}}})),gl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=J(),n=ml(),r=el(),i=fl(),a=Y(),o=pl();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}})),_l=N(((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}})),vl=N(((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}})),yl=N(((e,t)=>{let{isUUID:n}=vl(),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}})),bl=N(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=vl(),{SCHEMES:d,getSchemeHandler:f}=yl();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})),xl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=bl();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),Sl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=pl();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=ml(),i=hl(),a=rl(),o=gl(),s=J(),c=fl(),l=al(),u=Y(),d=_l(),f=xl(),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=D(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(te.call(this,n,t),!t)return(0,u.eachItem)(n,e=>O.call(this,e)),this;re.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=>O.call(this,e,r):e=>r.type.forEach(t=>O.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]=ae(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 D(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 ee=/^[a-z_$][a-z0-9_$:-]*$/i;function te(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!ee.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 O(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?ne.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 ne(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 re(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=ae(t)),e.validateSchema=this.compile(t,!0))}let ie={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function ae(e){return{anyOf:[e,ie]}}})),Cl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),wl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;let t=hl(),n=sl(),r=J(),i=el(),a=gl(),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})),Tl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Cl(),n=wl();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),El=N((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})`)}}})),Dl=N((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}))`)}}})),Ol=N((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`})),kl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=Ol();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}`)}}})),Al=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=sl(),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})`)}}}})),jl=N((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}`)}}})),Ml=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=sl(),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)}}}})),Nl=N((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}`)}}})),Pl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ul();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),Fl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=al(),n=J(),r=Y(),i=Pl();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)})))}}}})),Il=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=Pl();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}`)}}})),Ll=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=Pl();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}`}}}})),Rl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=El(),n=Dl(),r=kl(),i=Al(),a=jl(),o=Ml(),s=Nl(),c=Fl(),l=Il(),u=Ll();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]})),zl=N((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})),Bl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;let t=J(),n=Y(),r=sl(),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})),Vl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Bl();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),Hl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=sl(),i=zl();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)))}}})),Ul=N((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)))}}}})),Wl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=J(),n=Y(),r=sl();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},
188
188
  missingProperty: ${i},
189
189
  depsCount: ${n},
190
- 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})),Hl=N((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)}}})),Ul=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=il(),n=J(),r=Zc(),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)}}}})),Wl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ul(),n=il(),r=Y(),i=Ul();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)}}}})),Gl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=il(),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())})})}}}})),Kl=N((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`}}})),ql=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:il().validateUnion,error:{message:`must match a schema in anyOf`}}})),Jl=N((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)})})}}}})),Yl=N((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)})}}})),Xl=N((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})),Zl=N((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`)}}})),Ql=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Il(),n=Rl(),r=Ll(),i=zl(),a=Bl(),o=Vl(),s=Hl(),c=Ul(),l=Wl(),u=Gl(),d=Kl(),f=ql(),p=Jl(),m=Yl(),h=Xl(),g=Zl();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=_})),$l=N((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})`}}}}})),eu=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[$l().default]})),tu=N((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`]})),nu=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Sl(),n=Fl(),r=Ql(),i=eu(),a=tu();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),ru=N((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={}))})),iu=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=ru(),r=pl(),i=fl(),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}}}}})),au=N(((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}})),ou=N(((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=yl(),r=nu(),i=iu(),a=au(),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=ul();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=dl();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return d.default}});var f=fl();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return f.default}})}));function su(e,t=`schema`){let n=[];return du(e,t,n),n.length===0&&!xu.validateSchema(e)&&n.push(...fu(xu.errors,t)),n}function cu(e,t){let n=mu(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 lu(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 uu(e,t){let n=lu(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)){if(e===`__proto__`||e===`constructor`||e===`prototype`||!Object.prototype.hasOwnProperty.call(r,e))return;r=r[e];continue}return}return r}function du(e,t,n){if(!K(e)){n.push(`${t} must be an object`);return}for(let r of Object.keys(e))yu.has(r)||n.push(`${t} has unsupported keyword "${r}"`);if(`type`in e&&pu(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))du(i,`${t}.properties.${r}`,n);if(`items`in e&&du(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)&&du(r,`${t}.additionalProperties`,n)}}function fu(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 pu(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)bu.has(e)||n.push(`${t} has unsupported type "${String(e)}"`)}function mu(e,t,n){if((e==null||e===``)&&t.default!==void 0&&(e=t.default),t.enum&&e!==void 0){let r=t.enum.map(gu);if(!r.includes(gu(e)))return{ok:!1,issues:[`${n} must be one of: ${r.join(`, `)}`]}}let r=hu(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=mu(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=mu(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=mu(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 hu(e){let t=e.type===void 0?[]:Array.isArray(e.type)?e.type:[e.type];return new Set(t)}function gu(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}var _u,vu,yu,bu,xu,Su=M((()=>{_u=mt(ou(),1),bc(),vu=_u.default,yu=new Set([`type`,`properties`,`items`,`required`,`enum`,`default`,`description`,`format`,`additionalProperties`]),bu=new Set([`string`,`number`,`integer`,`boolean`,`array`,`object`,`null`]),xu=new vu({allErrors:!0,coerceTypes:!1,strict:!1,useDefaults:!1})}));function Cu(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}function wu(e,t,n,r){let i={},a={},o=[],s=!1;for(let[c,l]of Object.entries(e.input)){let e=Au(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 Tu(e,t,n){let r={},i=[];for(let[a,o]of Object.entries(e.input)){let e=ju(o,t,n);r[a]=e.redacted,e.sensitive&&i.push(a)}return{redacted:r,sensitiveKeys:i}}function Eu(e,t,n,r){return Pu(e,e=>Au(e,t,n,r))}function Du(e){return Pu(e,e=>X(e,e,!1,e!==void 0))}function Ou(e){return{...e.data===void 0?{}:{data:Vu},...e.artifacts?{artifacts:e.artifacts.map(zu)}:{},...e.warnings?{warnings:e.warnings.map(e=>({code:e.code,message:e.message}))}:{},metadata:{...e.metadata?.step?{step:e.metadata.step}:{},redacted:!0}}}function ku(e){return{code:e.code,message:Vu,...e.step?{step:e.step}:{},details:{redacted:!0}}}function Au(e,t,n,r){if(Array.isArray(e)){let i=e.map(e=>Au(e,t,n,r));return X(i.map(e=>e.value),i.map(e=>e.redacted),i.some(e=>e.sensitive))}if(!Bu(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=Au(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=uu(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=uu(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=Mu(t.env,e.$env,!1);return X(n,n,!1,n!==void 0)}if(`$secret`in e){let n=Mu(t.secrets,e.$secret,!0);return X(n,Vu,!0,n!==void 0)}if(`$concat`in e){let i=e.$concat.map(e=>Au(e,t,n,r)),a=i.map(e=>Cu(e.value)).join(``),o=i.some(e=>e.sensitive);return X(a,i.map(e=>e.sensitive?Vu:Cu(e.value)).join(``),o)}if(`$coalesce`in e){let i=e.$coalesce,a;for(let e of i)try{let i=Au(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=Au(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?Vu: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 ju(e,t,n){if(Array.isArray(e)){let r=e.map(e=>ju(e,t,n));return X(r.map(e=>e.value),r.map(e=>e.redacted),r.some(e=>e.sensitive))}if(!Bu(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=ju(o,t,n);r[a]=e.redacted,i||=e.sensitive}return X(r,r,i)}if(`$input`in e){let t=uu(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=Mu(t.env,e.$env,!1);return X(n,n,!1,n!==void 0)}if(`$secret`in e)return Mu(t.secrets,e.$secret,!0),X(Vu,Vu,!0,!0);if(`$concat`in e){let r=e.$concat.map(e=>ju(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=>Cu(e.value)).join(``),a=r.some(e=>e.sensitive);return X(i,r.map(e=>e.sensitive?Vu:Cu(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=ju(e,t,n);if(r.exists&&r.value!==void 0&&r.value!==null)return r}return X(void 0,void 0,!1,!1)}return`$js`in e?X({...e},{...e},!1):X(e,e,!1)}function Mu(e,t,n){if(!Nu(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 Nu(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 Pu(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 Ru(`$and must be a non-empty array`);return e.$and.every(e=>Pu(e,t))}if(K(e)&&`$or`in e){if(!Array.isArray(e.$or)||e.$or.length===0)throw Ru(`$or must be a non-empty array`);return e.$or.some(e=>Pu(e,t))}if(K(e)&&`$not`in e)return!Pu(e.$not,t);let n=Fu(e);if(n){let[e,r]=n.operands,i=t(e).value,a=t(r).value;switch(n.operator){case`$eq`:return Iu(i,a);case`$ne`:return!Iu(i,a);case`$gt`:return Lu(i,a,n.operator)>0;case`$gte`:return Lu(i,a,n.operator)>=0;case`$lt`:return Lu(i,a,n.operator)<0;case`$lte`:return Lu(i,a,n.operator)<=0;case`$in`:if(!Array.isArray(a))throw Ru(`$in right operand must be an array`);return a.some(e=>Iu(e,i));case`$contains`:if(Array.isArray(i))return i.some(e=>Iu(e,a));if(typeof i==`string`&&typeof a==`string`)return i.includes(a);throw Ru(`$contains left operand must be an array or string`)}}return!!t(e).value}function Fu(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 Ru(`${t} must be a two-item array`);return{operator:t,operands:e[t]}}}}function Iu(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Lu(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 Ru(`${n} operands must both be finite numbers or both be strings`)}function Ru(e){return new G(`pipeline_condition_error`,e)}function zu(e){return{id:e.id,kind:e.kind,mediaType:e.mediaType,metadata:e.metadata?{redacted:!0}:void 0}}function Bu(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 Vu,Hu=M((()=>{ic(),Su(),bc(),Vu=`[redacted]`}));function Uu(e){oc(`logic/switch`,e=>{let t=Wu(e.cases);for(let e of t)if(Du(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,qu),oc(`logic/select`,e=>{let t=Gu(e.candidates);for(let e of t)if(!(e.available!==void 0&&!Du(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,Ju),oc(`logic/assert`,e=>{let t=typeof e.message==`string`?e.message:`Logic assertion failed`,n=K(e.metadata)?e.metadata:void 0;if(!Du(Ku(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,Yu)}function Wu(e){if(!Array.isArray(e))throw new G(`logic_input_error`,`cases must be an array`,{step:`logic/switch`});return e}function Gu(e){if(!Array.isArray(e))throw new G(`logic_input_error`,`candidates must be an array`,{step:`logic/select`});return e}function Ku(e){if(e===void 0)throw new G(`logic_input_error`,`condition is required`,{step:`logic/assert`});return e}var qu,Ju,Yu,Xu=M((()=>{ic(),lc(),bc(),Hu(),qu={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)`}]},Ju={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)`}]},Yu={description:`Assert a condition is true`,paths:[{path:`/data/ok`,description:`Whether the assertion passed (boolean)`},{path:`/data/message`,description:`Assertion message`}]}}));function Zu(e){oc(`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,Qu)}var Qu,$u=M((()=>{ic(),lc(),Qu={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 ed(e=ac()){return td.has(e)?e:(td.add(e),Ic(e),Uu(e),Zu(e),e)}var td,nd=M((()=>{lc(),Jc(),Xu(),$u(),td=new WeakSet}));function rd(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??[]);_c(r.step.input,t),r.step.when!==void 0&&_c(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 id(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 ad(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 od(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 sd(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 Math.min(e,cd)}var cd,ld=M((()=>{ic(),bc(),cd=64})),ud,dd=M((()=>{ud=`workflow/v1`}));function fd(e,t=ac()){let n=hd(e);return n.length>0?n:gd(e,t)}function pd(e,t=ac()){if(hd(e).length>0)return[];let n=[],r=new Map(e.steps.map(e=>[e.id,e.type]));for(let i of e.steps)yd(i.input,i.id,r,t,n);return n}function md(e,t){if(!e.inputs)return t;let n=cu(e.inputs,t);if(n.ok)return n.value;throw new G(`pipeline_validation_error`,`Invalid pipeline runtime input`,{details:{issues:n.issues}})}function hd(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 "${ud}"`),!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 gd(e,t){let n=[];e.inputs&&n.push(...su(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&&vd(a.retry,r,n),a.timeout!==void 0&&gc(a.timeout)===void 0&&n.push(`semantic: step "${r}" timeout must be a positive number of seconds or duration string`),a.type===`script/js`&&typeof(K(a.input)?a.input.code:void 0)!=`string`&&n.push(`semantic: step "${r}" (script/js) requires a literal string "code"; code sourced from another step ($from) or an expression is not allowed, since it would execute untrusted text as host code`)}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`);_d(e.input,e.id,i,n)}let a=new Map;for(let e of r){let t=new Set(e.dependsOn??[]);_c(e.input,t),e.when!==void 0&&_c(e.when,t),a.set(e.id,t)}for(let e of bd(a))n.push(`semantic: pipeline graph contains cycle: ${e.join(` -> `)}`);return n}function _d(e,t,n,r){if(Array.isArray(e)){e.forEach(e=>_d(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))_d(i,t,n,r)}}function vd(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 yd(e,t,n,r,i){if(Array.isArray(e)){e.forEach(e=>yd(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))yd(a,t,n,r,i)}}function bd(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 xd=M((()=>{ic(),lc(),Su(),dd(),bc()}));async function Sd(e,t={},n={}){return await wd(e,t,n)}async function*Cd(e,t={},n={}){let r=new Id(1024),i=new AbortController,a=()=>i.abort();n.signal?.aborted?a():n.signal?.addEventListener(`abort`,a,{once:!0});let o=!1,s;wd(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 wd(e,t,n){let r=n.stepDispatcher??ac(),i=fd(e,r);if(i.length>0)throw new G(`pipeline_validation_error`,`Invalid pipeline definition`,{details:{issues:i}});let a=md(e,t);if(n.basePath){let t=await vc(e.steps,n.basePath);if(t.length>0)throw new G(`pipeline_file_not_found`,t.join(`; `),{details:{issues:t}})}let o=uc(),s=rd(e),c=sd(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 id(s)){let n=Tu(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:Od(t),input:kd(n.redacted,n.sensitiveKeys)}),await p({type:`step.planned`,timestamp:Z(),status:`planned`,step:Od(t),input:kd(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:ud,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 ad(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`;Dd(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:Od(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`;Dd(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:Od(i),reason:e}),m.delete(i.step.id),t=!0;continue}if(!(i.step.when===void 0||Eu(i.step.when,e,a,d))){let e=`condition evaluated to false`;Dd(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:Od(i),reason:e}),m.delete(i.step.id),t=!0;continue}let _=Td(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),Dd(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=od(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?Od(e):{id:_.id,type:_.type,dependencies:_.dependencies,index:g.findIndex(e=>e.id===_.id)+1,total:g.length},error:_.error}),{status:`failed`,version:ud,steps:g,artifacts:f}}return await p({type:`pipeline.succeeded`,timestamp:Z(),status:`succeeded`,stepCount:g.length,artifactCount:f.length}),{status:`succeeded`,version:ud,steps:g,artifacts:f}}async function Td(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:Od(e),timing:{startedAt:p},attempt:h});try{let l=wu(e.step,t,n,r),u=l.value,g=l.redacted;if(o.basePath){let t=mc(u,o.basePath);u=t.input,g=mc(l.redacted,o.basePath).input;let n=await hc(u,t.resolvedKeys.filter(e=>!yc.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:Od(e),input:kd(g,l.sensitiveKeys)});let _=await Ed(e.step,u,o,Od(e),a,s,c);r.set(e.step.id,_);let v=l.sensitive?Ou(_):_;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:Od(e),artifact:t});return await a({type:`step.succeeded`,timestamp:Z(),status:`running`,step:Od(e),timing:Md(p,m),output:Ad(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=rc(t,e.step.type);if(u=f?ku(n.toJSON()):n.toJSON(),m=new Date().toISOString(),h<l){await a({type:`step.retrying`,timestamp:Z(),status:`running`,step:Od(e),attempt:h,nextAttempt:h+1,error:u});let t=Nd(e.step.retry?.backoff,h,o.retryDelayBaseMs??Fd);t>0&&await(o.sleep??Pd)(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:Od(e),timing:Md(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 Ed(e,t,n,r,i,a,o){let s=gc(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 Dd(e,t,n){e.push(n),t.set(n.id,n)}function Z(){return new Date().toISOString()}function Od(e){return{id:e.step.id,type:e.step.type,dependencies:e.dependencies,index:e.index,total:e.total}}function kd(e,t=[]){return{keys:Object.keys(e).sort(),...t.length>0?{redactedKeys:t.sort()}:{}}}function Ad(e){return{...e.data===void 0?{}:{dataType:jd(e.data)},artifactCount:e.artifacts?.length??0,warningCount:e.warnings?.length??0,...e.metadata?{metadata:e.metadata}:{}}}function jd(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e}function Md(e,t){return{startedAt:e,finishedAt:t,durationMs:Math.max(0,Date.parse(t)-Date.parse(e))}}function Nd(e=`none`,t,n){return e===`none`?0:e===`linear`?n*t:n*2**(t-1)}function Pd(e){return new Promise(t=>setTimeout(t,e))}var Fd,Id,Ld=M((()=>{ic(),fc(),lc(),Hu(),ld(),bc(),xd(),dd(),Fd=100,Id=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=N((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})),Rd=N((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})),zd=N((e=>{var t=Q(),n=Rd();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(`
191
- `)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),Bd=N((e=>{var t=Q(),n=Rd();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})),Vd=N((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})),Hd=N((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})),Ud=N((e=>{var t=Vd(),n=Q(),r=Hd();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}}})),Wd=N((e=>{var t=Bd(),n=Rd(),r=Q(),i=Ud(),a=Hd(),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})),$=N((e=>{var t=Q(),n=Ud(),r=Hd();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})),Gd=N((e=>{var t=Wd(),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})),Kd=N((e=>{var t=Gd(),n=Q(),r=Ud();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})),qd=N((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(`
190
+ 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})),Gl=N((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)}}})),Kl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=sl(),n=J(),r=el(),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)}}}})),ql=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=pl(),n=sl(),r=Y(),i=Kl();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)}}}})),Jl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=sl(),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())})})}}}})),Yl=N((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`}}})),Xl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:sl().validateUnion,error:{message:`must match a schema in anyOf`}}})),Zl=N((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)})})}}}})),Ql=N((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)})}}})),$l=N((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})),eu=N((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`)}}})),tu=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=zl(),n=Vl(),r=Bl(),i=Hl(),a=Ul(),o=Wl(),s=Gl(),c=Kl(),l=ql(),u=Jl(),d=Yl(),f=Xl(),p=Zl(),m=Ql(),h=$l(),g=eu();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=_})),nu=N((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})`}}}}})),ru=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[nu().default]})),iu=N((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`]})),au=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Tl(),n=Rl(),r=tu(),i=ru(),a=iu();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),ou=N((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={}))})),su=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=ou(),r=gl(),i=hl(),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}}}}})),cu=N(((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}})),lu=N(((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=Sl(),r=au(),i=su(),a=cu(),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=pl();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=ml();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return d.default}});var f=hl();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return f.default}})}));function uu(e,t=`schema`){let n=[];return mu(e,t,n),n.length===0&&!wu.validateSchema(e)&&n.push(...hu(wu.errors,t)),n}function du(e,t){let n=_u(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 fu(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 pu(e,t){let n=fu(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)){if(e===`__proto__`||e===`constructor`||e===`prototype`||!Object.prototype.hasOwnProperty.call(r,e))return;r=r[e];continue}return}return r}function mu(e,t,n){if(!K(e)){n.push(`${t} must be an object`);return}for(let r of Object.keys(e))Su.has(r)||n.push(`${t} has unsupported keyword "${r}"`);if(`type`in e&&gu(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))mu(i,`${t}.properties.${r}`,n);if(`items`in e&&mu(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)&&mu(r,`${t}.additionalProperties`,n)}}function hu(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 gu(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)Cu.has(e)||n.push(`${t} has unsupported type "${String(e)}"`)}function _u(e,t,n){if((e==null||e===``)&&t.default!==void 0&&(e=t.default),t.enum&&e!==void 0){let r=t.enum.map(yu);if(!r.includes(yu(e)))return{ok:!1,issues:[`${n} must be one of: ${r.join(`, `)}`]}}let r=vu(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=_u(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=_u(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=_u(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 vu(e){let t=e.type===void 0?[]:Array.isArray(e.type)?e.type:[e.type];return new Set(t)}function yu(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}var bu,xu,Su,Cu,wu,Tu=M((()=>{bu=mt(lu(),1),Cc(),xu=bu.default,Su=new Set([`type`,`properties`,`items`,`required`,`enum`,`default`,`description`,`format`,`additionalProperties`]),Cu=new Set([`string`,`number`,`integer`,`boolean`,`array`,`object`,`null`]),wu=new xu({allErrors:!0,coerceTypes:!1,strict:!1,useDefaults:!1})}));function Eu(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}function Du(e,t,n,r){let i={},a={},o=[],s=!1;for(let[c,l]of Object.entries(e.input)){let e=Nu(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 Ou(e,t,n){let r={},i=[];for(let[a,o]of Object.entries(e.input)){let e=Pu(o,t,n);r[a]=e.redacted,e.sensitive&&i.push(a)}return{redacted:r,sensitiveKeys:i}}function ku(e,t,n,r){return Lu(e,e=>Nu(e,t,n,r))}function Au(e){return Lu(e,e=>X(e,e,!1,e!==void 0))}function ju(e){return{...e.data===void 0?{}:{data:Wu},...e.artifacts?{artifacts:e.artifacts.map(Hu)}:{},...e.warnings?{warnings:e.warnings.map(e=>({code:e.code,message:e.message}))}:{},metadata:{...e.metadata?.step?{step:e.metadata.step}:{},redacted:!0}}}function Mu(e){return{code:e.code,message:Wu,...e.step?{step:e.step}:{},details:{redacted:!0}}}function Nu(e,t,n,r){if(Array.isArray(e)){let i=e.map(e=>Nu(e,t,n,r));return X(i.map(e=>e.value),i.map(e=>e.redacted),i.some(e=>e.sensitive))}if(!Uu(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=Nu(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=pu(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=pu(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=Fu(t.env,e.$env,!1);return X(n,n,!1,n!==void 0)}if(`$secret`in e){let n=Fu(t.secrets,e.$secret,!0);return X(n,Wu,!0,n!==void 0)}if(`$concat`in e){let i=e.$concat.map(e=>Nu(e,t,n,r)),a=i.map(e=>Eu(e.value)).join(``),o=i.some(e=>e.sensitive);return X(a,i.map(e=>e.sensitive?Wu:Eu(e.value)).join(``),o)}if(`$coalesce`in e){let i=e.$coalesce,a;for(let e of i)try{let i=Nu(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=Nu(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?Wu: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 Pu(e,t,n){if(Array.isArray(e)){let r=e.map(e=>Pu(e,t,n));return X(r.map(e=>e.value),r.map(e=>e.redacted),r.some(e=>e.sensitive))}if(!Uu(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=Pu(o,t,n);r[a]=e.redacted,i||=e.sensitive}return X(r,r,i)}if(`$input`in e){let t=pu(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=Fu(t.env,e.$env,!1);return X(n,n,!1,n!==void 0)}if(`$secret`in e)return Fu(t.secrets,e.$secret,!0),X(Wu,Wu,!0,!0);if(`$concat`in e){let r=e.$concat.map(e=>Pu(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=>Eu(e.value)).join(``),a=r.some(e=>e.sensitive);return X(i,r.map(e=>e.sensitive?Wu:Eu(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=Pu(e,t,n);if(r.exists&&r.value!==void 0&&r.value!==null)return r}return X(void 0,void 0,!1,!1)}return`$js`in e?X({...e},{...e},!1):X(e,e,!1)}function Fu(e,t,n){if(!Iu(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 Iu(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 Lu(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 Vu(`$and must be a non-empty array`);return e.$and.every(e=>Lu(e,t))}if(K(e)&&`$or`in e){if(!Array.isArray(e.$or)||e.$or.length===0)throw Vu(`$or must be a non-empty array`);return e.$or.some(e=>Lu(e,t))}if(K(e)&&`$not`in e)return!Lu(e.$not,t);let n=Ru(e);if(n){let[e,r]=n.operands,i=t(e).value,a=t(r).value;switch(n.operator){case`$eq`:return zu(i,a);case`$ne`:return!zu(i,a);case`$gt`:return Bu(i,a,n.operator)>0;case`$gte`:return Bu(i,a,n.operator)>=0;case`$lt`:return Bu(i,a,n.operator)<0;case`$lte`:return Bu(i,a,n.operator)<=0;case`$in`:if(!Array.isArray(a))throw Vu(`$in right operand must be an array`);return a.some(e=>zu(e,i));case`$contains`:if(Array.isArray(i))return i.some(e=>zu(e,a));if(typeof i==`string`&&typeof a==`string`)return i.includes(a);throw Vu(`$contains left operand must be an array or string`)}}return!!t(e).value}function Ru(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 Vu(`${t} must be a two-item array`);return{operator:t,operands:e[t]}}}}function zu(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Bu(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 Vu(`${n} operands must both be finite numbers or both be strings`)}function Vu(e){return new G(`pipeline_condition_error`,e)}function Hu(e){return{id:e.id,kind:e.kind,mediaType:e.mediaType,metadata:e.metadata?{redacted:!0}:void 0}}function Uu(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 Wu,Gu=M((()=>{sc(),Tu(),Cc(),Wu=`[redacted]`}));function Ku(e){lc(`logic/switch`,e=>{let t=qu(e.cases);for(let e of t)if(Au(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,Xu),lc(`logic/select`,e=>{let t=Ju(e.candidates);for(let e of t)if(!(e.available!==void 0&&!Au(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,Zu),lc(`logic/assert`,e=>{let t=typeof e.message==`string`?e.message:`Logic assertion failed`,n=K(e.metadata)?e.metadata:void 0;if(!Au(Yu(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,Qu)}function qu(e){if(!Array.isArray(e))throw new G(`logic_input_error`,`cases must be an array`,{step:`logic/switch`});return e}function Ju(e){if(!Array.isArray(e))throw new G(`logic_input_error`,`candidates must be an array`,{step:`logic/select`});return e}function Yu(e){if(e===void 0)throw new G(`logic_input_error`,`condition is required`,{step:`logic/assert`});return e}var Xu,Zu,Qu,$u=M((()=>{sc(),fc(),Cc(),Gu(),Xu={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)`}]},Zu={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)`}]},Qu={description:`Assert a condition is true`,paths:[{path:`/data/ok`,description:`Whether the assertion passed (boolean)`},{path:`/data/message`,description:`Assertion message`}]}}));function ed(e){lc(`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,td)}var td,nd=M((()=>{sc(),fc(),td={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 rd(e=cc()){return id.has(e)?e:(id.add(e),zc(e),Ku(e),ed(e),e)}var id,ad=M((()=>{fc(),Zc(),$u(),nd(),id=new WeakSet}));function od(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??[]);bc(r.step.input,t),r.step.when!==void 0&&bc(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 sd(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 cd(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 ld(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 ud(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 Math.min(e,dd)}var dd,fd=M((()=>{sc(),Cc(),dd=64})),pd,md=M((()=>{pd=`workflow/v1`}));function hd(e,t=cc()){let n=vd(e);return n.length>0?n:yd(e,t)}function gd(e,t=cc()){if(vd(e).length>0)return[];let n=[],r=new Map(e.steps.map(e=>[e.id,e.type]));for(let i of e.steps)Sd(i.input,i.id,r,t,n);return n}function _d(e,t){if(!e.inputs)return t;let n=du(e.inputs,t);if(n.ok)return n.value;throw new G(`pipeline_validation_error`,`Invalid pipeline runtime input`,{details:{issues:n.issues}})}function vd(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 "${pd}"`),!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 yd(e,t){let n=[];e.inputs&&n.push(...uu(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&&xd(a.retry,r,n),a.timeout!==void 0&&yc(a.timeout)===void 0&&n.push(`semantic: step "${r}" timeout must be a positive number of seconds or duration string`),a.type===`script/js`&&typeof(K(a.input)?a.input.code:void 0)!=`string`&&n.push(`semantic: step "${r}" (script/js) requires a literal string "code"; code sourced from another step ($from) or an expression is not allowed, since it would execute untrusted text as host code`)}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`);bd(e.input,e.id,i,n)}let a=new Map;for(let e of r){let t=new Set(e.dependsOn??[]);bc(e.input,t),e.when!==void 0&&bc(e.when,t),a.set(e.id,t)}for(let e of Cd(a))n.push(`semantic: pipeline graph contains cycle: ${e.join(` -> `)}`);return n}function bd(e,t,n,r){if(Array.isArray(e)){e.forEach(e=>bd(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))bd(i,t,n,r)}}function xd(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 Sd(e,t,n,r,i){if(Array.isArray(e)){e.forEach(e=>Sd(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))Sd(a,t,n,r,i)}}function Cd(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 wd=M((()=>{sc(),fc(),Tu(),md(),Cc()}));async function Td(e,t={},n={}){return await Dd(e,t,n)}async function*Ed(e,t={},n={}){let r=new zd(1024),i=new AbortController,a=()=>i.abort();n.signal?.aborted?a():n.signal?.addEventListener(`abort`,a,{once:!0});let o=!1,s;Dd(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 Dd(e,t,n){let r=n.stepDispatcher??cc(),i=hd(e,r);if(i.length>0)throw new G(`pipeline_validation_error`,`Invalid pipeline definition`,{details:{issues:i}});let a=_d(e,t);if(n.basePath){let t=await xc(e.steps,n.basePath);if(t.length>0)throw new G(`pipeline_file_not_found`,t.join(`; `),{details:{issues:t}})}let o=pc(),s=od(e),c=ud(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 sd(s)){let n=Ou(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:jd(t),input:Md(n.redacted,n.sensitiveKeys)}),await p({type:`step.planned`,timestamp:Z(),status:`planned`,step:jd(t),input:Md(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:pd,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 cd(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`;Ad(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:jd(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`;Ad(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:jd(i),reason:e}),m.delete(i.step.id),t=!0;continue}if(!(i.step.when===void 0||ku(i.step.when,e,a,d))){let e=`condition evaluated to false`;Ad(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:jd(i),reason:e}),m.delete(i.step.id),t=!0;continue}let _=Od(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),Ad(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=ld(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?jd(e):{id:_.id,type:_.type,dependencies:_.dependencies,index:g.findIndex(e=>e.id===_.id)+1,total:g.length},error:_.error}),{status:`failed`,version:pd,steps:g,artifacts:f}}return await p({type:`pipeline.succeeded`,timestamp:Z(),status:`succeeded`,stepCount:g.length,artifactCount:f.length}),{status:`succeeded`,version:pd,steps:g,artifacts:f}}async function Od(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:jd(e),timing:{startedAt:p},attempt:h});try{let l=Du(e.step,t,n,r),u=l.value,g=l.redacted;if(o.basePath){let t=_c(u,o.basePath);u=t.input,g=_c(l.redacted,o.basePath).input;let n=await vc(u,t.resolvedKeys.filter(e=>!Sc.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:jd(e),input:Md(g,l.sensitiveKeys)});let _=await kd(e.step,u,o,jd(e),a,s,c);r.set(e.step.id,_);let v=l.sensitive?ju(_):_;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:jd(e),artifact:t});return await a({type:`step.succeeded`,timestamp:Z(),status:`running`,step:jd(e),timing:Fd(p,m),output:Nd(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=oc(t,e.step.type);if(u=f?Mu(n.toJSON()):n.toJSON(),m=new Date().toISOString(),h<l){await a({type:`step.retrying`,timestamp:Z(),status:`running`,step:jd(e),attempt:h,nextAttempt:h+1,error:u});let t=Id(e.step.retry?.backoff,h,o.retryDelayBaseMs??Rd);t>0&&await(o.sleep??Ld)(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:jd(e),timing:Fd(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 kd(e,t,n,r,i,a,o){let s=yc(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 Ad(e,t,n){e.push(n),t.set(n.id,n)}function Z(){return new Date().toISOString()}function jd(e){return{id:e.step.id,type:e.step.type,dependencies:e.dependencies,index:e.index,total:e.total}}function Md(e,t=[]){return{keys:Object.keys(e).sort(),...t.length>0?{redactedKeys:t.sort()}:{}}}function Nd(e){return{...e.data===void 0?{}:{dataType:Pd(e.data)},artifactCount:e.artifacts?.length??0,warningCount:e.warnings?.length??0,...e.metadata?{metadata:e.metadata}:{}}}function Pd(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e}function Fd(e,t){return{startedAt:e,finishedAt:t,durationMs:Math.max(0,Date.parse(t)-Date.parse(e))}}function Id(e=`none`,t,n){return e===`none`?0:e===`linear`?n*t:n*2**(t-1)}function Ld(e){return new Promise(t=>setTimeout(t,e))}var Rd,zd,Bd=M((()=>{sc(),hc(),fc(),Gu(),fd(),Cc(),wd(),md(),Rd=100,zd=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=N((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})),Vd=N((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})),Hd=N((e=>{var t=Q(),n=Vd();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(`
191
+ `)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),Ud=N((e=>{var t=Q(),n=Vd();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})),Wd=N((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})),Gd=N((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})),Kd=N((e=>{var t=Wd(),n=Q(),r=Gd();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}}})),qd=N((e=>{var t=Ud(),n=Vd(),r=Q(),i=Kd(),a=Gd(),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})),$=N((e=>{var t=Q(),n=Kd(),r=Gd();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})),Jd=N((e=>{var t=qd(),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})),Yd=N((e=>{var t=Jd(),n=Q(),r=Kd();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})),Xd=N((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(`
192
192
  `)?n(r,t):r.includes(`
193
193
  `)?`
194
- `+n(r,t):(e.endsWith(` `)?``:` `)+r,e.stringifyComment=t})),Jd=N((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===`
194
+ `+n(r,t):(e.endsWith(` `)?``:` `)+r,e.stringifyComment=t})),Zd=N((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===`
195
195
  `)a===t&&(v=i(e,v,r.length)),m=v+r.length+d,h=void 0;else{if(o===` `&&g&&g!==` `&&g!==`
196
196
  `&&g!==` `){let t=e[v+1];t&&t!==` `&&t!==`
197
197
  `&&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!==`
198
- `);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})),Yd=N((e=>{var t=$(),n=Jd();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]===`
198
+ `);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})),Qd=N((e=>{var t=$(),n=Zd();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]===`
199
199
  `){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)+`
200
200
 
201
201
  `;a[e+2]===`\\`&&a[e+3]===`n`&&a[e+4]!==`"`;)l+=`
@@ -213,29 +213,29 @@ Hint: Add --diarization flag to enable speaker separation.`,i.USAGE);let s=n.mod
213
213
  $&`).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(`
214
214
  `)||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(`
215
215
  `)?c(d,a):u(e,a,o,s);if(!p&&!g&&l!==t.Scalar.PLAIN&&d.includes(`
216
- `))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})),Xd=N((e=>{var t=Bd(),n=Q(),r=qd(),i=Yd();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})),Zd=N((e=>{var t=Q(),n=$(),r=Xd(),i=qd();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?`
216
+ `))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})),$d=N((e=>{var t=Ud(),n=Q(),r=Xd(),i=Qd();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})),ef=N((e=>{var t=Q(),n=$(),r=$d(),i=Xd();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?`
217
217
  `:``,S){let e=p(S);E+=`\n${i.indentComment(e,o.indent)}`}T===``&&!o.inFlow?E===`
218
218
  `&&C&&(E=`
219
219
 
220
220
  `):E+=`\n${o.indent}`}else if(!_&&t.isCollection(a)){let e=T[0],t=T.indexOf(`
221
221
  `),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]===`
222
- `)&&(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})),Qd=N((e=>{var t=ht(`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})),$d=N((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})),ef=N((e=>{var t=Qd(),n=$d(),r=Xd(),i=Q(),a=Hd();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})),tf=N((e=>{var t=Gd(),n=Zd(),r=ef(),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})),nf=N((e=>{var t=Q(),n=Xd(),r=qd();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}`:`
222
+ `)&&(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})),tf=N((e=>{var t=ht(`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})),nf=N((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})),rf=N((e=>{var t=tf(),n=nf(),r=$d(),i=Q(),a=Gd();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})),af=N((e=>{var t=Jd(),n=ef(),r=rf(),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})),of=N((e=>{var t=Q(),n=$d(),r=Xd();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}`:`
223
223
  `}}return e?(_+=`
224
224
  `+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(`
225
225
  `),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}`:`
226
- `;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})),rf=N((e=>{var t=nf(),n=ef(),r=Kd(),i=Q(),a=tf(),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})),af=N((e=>{var t=Q(),n=rf();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)}})),of=N((e=>{var t=Gd(),n=nf(),r=Kd(),i=Q(),a=$(),o=Hd(),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})),sf=N((e=>{var t=Q(),n=of();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)}})),cf=N((e=>{var t=Yd();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)}}})),lf=N((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})),uf=N((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})),df=N((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})),ff=N((e=>{var t=$(),n=df();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})),pf=N((e=>{var t=df();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`)}})),mf=N((e=>{var t=af(),n=lf(),r=sf(),i=cf(),a=uf(),o=ff(),s=pf();e.schema=[t.map,r.seq,i.string,n.nullTag,a.boolTag,s.intOct,s.int,s.intHex,o.floatNaN,o.floatExp,o.float]})),hf=N((e=>{var t=$(),n=af(),r=sf();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}})})),gf=N((e=>{var t=ht(`buffer`),n=$(),r=Yd();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?`
227
- `:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),_f=N((e=>{var t=Q(),n=tf(),r=$(),i=of();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})),vf=N((e=>{var t=Q(),n=Hd(),r=rf(),i=of(),a=_f(),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})),yf=N((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})),bf=N((e=>{var t=$(),n=df();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})),xf=N((e=>{var t=df();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})),Sf=N((e=>{var t=Q(),n=tf(),r=rf(),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})),Cf=N((e=>{var t=df();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})),wf=N((e=>{var t=af(),n=lf(),r=sf(),i=cf(),a=gf(),o=yf(),s=bf(),c=xf(),l=$d(),u=vf(),d=_f(),f=Sf(),p=Cf();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]})),Tf=N((e=>{var t=af(),n=lf(),r=sf(),i=cf(),a=uf(),o=ff(),s=pf(),c=mf(),l=hf(),u=gf(),d=$d(),f=vf(),p=_f(),m=wf(),h=Sf(),g=Cf();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})),Ef=N((e=>{var t=Q(),n=af(),r=sf(),i=cf(),a=Tf();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}}})),Df=N((e=>{var t=Q(),n=Xd(),r=qd();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(`
226
+ `;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})),sf=N((e=>{var t=of(),n=rf(),r=Yd(),i=Q(),a=af(),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})),cf=N((e=>{var t=Q(),n=sf();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)}})),lf=N((e=>{var t=Jd(),n=of(),r=Yd(),i=Q(),a=$(),o=Gd(),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})),uf=N((e=>{var t=Q(),n=lf();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)}})),df=N((e=>{var t=Qd();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)}}})),ff=N((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})),pf=N((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})),mf=N((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})),hf=N((e=>{var t=$(),n=mf();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})),gf=N((e=>{var t=mf();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`)}})),_f=N((e=>{var t=cf(),n=ff(),r=uf(),i=df(),a=pf(),o=hf(),s=gf();e.schema=[t.map,r.seq,i.string,n.nullTag,a.boolTag,s.intOct,s.int,s.intHex,o.floatNaN,o.floatExp,o.float]})),vf=N((e=>{var t=$(),n=cf(),r=uf();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}})})),yf=N((e=>{var t=ht(`buffer`),n=$(),r=Qd();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?`
227
+ `:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),bf=N((e=>{var t=Q(),n=af(),r=$(),i=lf();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})),xf=N((e=>{var t=Q(),n=Gd(),r=sf(),i=lf(),a=bf(),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})),Sf=N((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})),Cf=N((e=>{var t=$(),n=mf();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})),wf=N((e=>{var t=mf();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})),Tf=N((e=>{var t=Q(),n=af(),r=sf(),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})),Ef=N((e=>{var t=mf();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})),Df=N((e=>{var t=cf(),n=ff(),r=uf(),i=df(),a=yf(),o=Sf(),s=Cf(),c=wf(),l=nf(),u=xf(),d=bf(),f=Tf(),p=Ef();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]})),Of=N((e=>{var t=cf(),n=ff(),r=uf(),i=df(),a=pf(),o=hf(),s=gf(),c=_f(),l=vf(),u=yf(),d=nf(),f=xf(),p=bf(),m=Df(),h=Tf(),g=Ef();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})),kf=N((e=>{var t=Q(),n=cf(),r=uf(),i=df(),a=Of();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}}})),Af=N((e=>{var t=Q(),n=$d(),r=Xd();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(`
228
228
  `)?(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(`
229
229
  `)+`
230
- `}e.stringifyDocument=i})),Of=N((e=>{var t=Wd(),n=Kd(),r=Q(),i=tf(),a=Hd(),o=Ef(),s=Df(),c=Bd(),l=Vd(),u=Gd(),d=zd(),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})),kf=N((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)+`…
231
- `),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`}}})),Af=N((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})),jf=N((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(`
232
- `))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})),Mf=N((e=>{var t=jf();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})),Nf=N((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})),Pf=N((e=>{var t=tf(),n=rf(),r=Af(),i=jf(),a=Mf(),o=Nf();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+=`
230
+ `}e.stringifyDocument=i})),jf=N((e=>{var t=qd(),n=Yd(),r=Q(),i=af(),a=Gd(),o=kf(),s=Af(),c=Ud(),l=Wd(),u=Jd(),d=Hd(),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})),Mf=N((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)+`…
231
+ `),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`}}})),Nf=N((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})),Pf=N((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(`
232
+ `))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})),Ff=N((e=>{var t=Pf();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})),If=N((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})),Lf=N((e=>{var t=af(),n=sf(),r=Nf(),i=Pf(),a=Ff(),o=If();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+=`
233
233
  `+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+=`
234
- `+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})),Ff=N((e=>{var t=of(),n=Af(),r=Mf();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})),If=N((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})),Lf=N((e=>{var t=Q(),n=tf(),r=rf(),i=of(),a=If(),o=Af(),s=jf(),c=Nf();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+=`
234
+ `+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})),Rf=N((e=>{var t=lf(),n=Nf(),r=Ff();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})),zf=N((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})),Bf=N((e=>{var t=Q(),n=af(),r=sf(),i=lf(),a=zf(),o=Nf(),s=Pf(),c=If();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+=`
235
235
  `+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+=`
236
236
  `+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+=`
237
237
  `+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+=`
238
- `+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})),Rf=N((e=>{var t=Q(),n=$(),r=rf(),i=of(),a=Pf(),o=Ff(),s=Lf();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})),zf=N((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?`
238
+ `+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})),Vf=N((e=>{var t=Q(),n=$(),r=sf(),i=lf(),a=Lf(),o=Rf(),s=Bf();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})),Hf=N((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?`
239
239
  `.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)+`
240
240
  `;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=`
241
241
  `):n.length>d||r[0]===` `?(h===` `?h=`
@@ -250,7 +250,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
250
250
  `+l[e][0].slice(d);m[m.length-1]!==`
251
251
  `&&(m+=`
252
252
  `);break;default:m+=`
253
- `}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})),Bf=N((e=>{var t=$(),n=If();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?
253
+ `}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})),Uf=N((e=>{var t=$(),n=zf();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?
254
254
  `,`sy`),n=RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
255
255
  `,`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===`
256
256
  `?i+=a:a=`
@@ -265,10 +265,10 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
265
265
  `);)r===`
266
266
  `&&(n+=`
267
267
  `),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:`
268
- `,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})),Vf=N((e=>{var t=Q(),n=$(),r=zf(),i=Bf();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})),Hf=N((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})),Uf=N((e=>{var t=Wd(),n=Q(),r=Rf(),i=Vf(),a=If(),o=Hf();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})),Wf=N((e=>{var t=Of(),n=Uf(),r=If(),i=Af();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})),Gf=N((e=>{var t=ht(`process`),n=zd(),r=Of(),i=kf(),a=Q(),o=Wf(),s=If();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?`
268
+ `,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})),Wf=N((e=>{var t=Q(),n=$(),r=Hf(),i=Uf();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})),Gf=N((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})),Kf=N((e=>{var t=qd(),n=Q(),r=Vf(),i=Wf(),a=zf(),o=Gf();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})),qf=N((e=>{var t=jf(),n=Kf(),r=zf(),i=Nf();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})),Jf=N((e=>{var t=ht(`process`),n=Hd(),r=jf(),i=Mf(),a=Q(),o=qf(),s=zf();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?`
269
269
 
270
270
  `:`
271
- `)+(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}}}})),Kf=N((e=>{var t=zf(),n=Bf(),r=kf(),i=Yd();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:`
271
+ `)+(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}}}})),Yf=N((e=>{var t=Hf(),n=Uf(),r=Mf(),i=Qd();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:`
272
272
  `}];switch(c[0]){case`|`:case`>`:{let e=c.indexOf(`
273
273
  `),t=c.substring(0,e),n=c.substring(e+1)+`
274
274
  `,i=[{type:`block-scalar-header`,offset:o,indent:r,source:t}];return l(i,u)||i.push({type:`newline`,offset:-1,indent:r,source:`
@@ -276,9 +276,9 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
276
276
  `),r=t.substring(0,n),i=t.substring(n+1)+`
277
277
  `;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:`
278
278
  `});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:`
279
- `};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})),qf=N((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})),Jf=N((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})),Yf=N((e=>{var t=Kf(),n=qf(),r=Jf();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`
279
+ `};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})),Xf=N((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})),Zf=N((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})),Qf=N((e=>{var t=Yf(),n=Xf(),r=Zf();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`
280
280
  `:case`\r
281
- `: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})),Xf=N((e=>{var t=Yf();function n(e){switch(e){case void 0:case` `:case`
281
+ `: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})),$f=N((e=>{var t=Qf();function n(e){switch(e){case void 0:case` `:case`
282
282
  `:case`\r`:case` `:return!0;default:return!1}}let r=new Set(`0123456789ABCDEFabcdef`),i=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),a=new Set(`,[]{}`),o=new Set(` ,[]{}
283
283
  \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===`
284
284
  `?!0:t===`\r`?this.buffer[e+1]===`
@@ -297,61 +297,61 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
297
297
  `,t=this.buffer[i+1]):r=i),t===`#`||e&&a.has(t))break;if(o===`
298
298
  `){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===`
299
299
  `?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
300
- `?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)}}})),Zf=N((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}}}}})),Qf=N((e=>{var t=ht(`process`),n=Yf(),r=Xf();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(`
300
+ `?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)}}})),ep=N((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}}}}})),tp=N((e=>{var t=ht(`process`),n=Qf(),r=$f();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(`
301
301
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
302
302
  `,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(`
303
303
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
304
- `,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())}}}})),$f=N((e=>{var t=Gf(),n=Of(),r=kf(),i=Qd(),a=Q(),o=Zf(),s=Qf();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})),ep=N((e=>{var t=Gf(),n=Of(),r=Ef(),i=kf(),a=Wd(),o=Q(),s=tf(),c=$(),l=rf(),u=of(),d=Yf(),f=Xf(),p=Zf(),m=Qf(),h=$f(),g=Rd();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 tp(e){let t=await Ye(e,`utf-8`).catch(e=>{process.stderr.write(`Error: cannot read pipeline file: ${e.message}\n`),process.exit(2)}),n=Ze(e).toLowerCase(),r;if(n===`.yaml`||n===`.yml`){let{parse:e}=await Promise.resolve().then(()=>mt(ep(),1));r=e(t)}else try{r=JSON.parse(t)}catch{let{parse:e}=await Promise.resolve().then(()=>mt(ep(),1));r=e(t)}return r}var np=M((()=>{}));async function rp(e){let t=e.input,n=e.inputFile;if(t&&n&&(process.stderr.write(`Error: use --input or --input-file, not both
305
- `),process.exit(2)),t)return JSON.parse(t);if(n){let e=await Ye($e(n),`utf-8`);return JSON.parse(e)}return{}}function ip(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} ${ap(e.step)}\n`):process.stderr.write(`${t}\n`)}function ap(e){return`${e.index!==void 0&&e.total!==void 0?`${e.index}/${e.total} `:``}${e.id} (${e.type})`}function op(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+`
304
+ `,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())}}}})),np=N((e=>{var t=Jf(),n=jf(),r=Mf(),i=tf(),a=Q(),o=ep(),s=tp();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})),rp=N((e=>{var t=Jf(),n=jf(),r=kf(),i=Mf(),a=qd(),o=Q(),s=af(),c=$(),l=sf(),u=lf(),d=Qf(),f=$f(),p=ep(),m=tp(),h=np(),g=Vd();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 ip(e){let t=await Ye(e,`utf-8`).catch(e=>{process.stderr.write(`Error: cannot read pipeline file: ${e.message}\n`),process.exit(2)}),n=Ze(e).toLowerCase(),r;if(n===`.yaml`||n===`.yml`){let{parse:e}=await Promise.resolve().then(()=>mt(rp(),1));r=e(t)}else try{r=JSON.parse(t)}catch{let{parse:e}=await Promise.resolve().then(()=>mt(rp(),1));r=e(t)}return r}var ap=M((()=>{}));async function op(e){let t=e.input,n=e.inputFile;if(t&&n&&(process.stderr.write(`Error: use --input or --input-file, not both
305
+ `),process.exit(2)),t)return JSON.parse(t);if(n){let e=await Ye($e(n),`utf-8`);return JSON.parse(e)}return{}}function sp(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} ${cp(e.step)}\n`):process.stderr.write(`${t}\n`)}function cp(e){return`${e.index!==void 0&&e.total!==void 0?`${e.index}/${e.total} `:``}${e.id} (${e.type})`}function lp(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+`
306
306
  `)}process.stdout.write(`
307
- `)}var sp,cp=M((()=>{I(),nd(),Ld(),np(),sp=m({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
307
+ `)}var up,dp=M((()=>{I(),ad(),Bd(),ap(),up=m({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
308
308
  Usage: bl pipeline run <file>
309
- `),process.exit(2)),ed();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=$e(n),a=await tp(i),o=await rp(t),s=Xe(i);if(r===`jsonl`){for await(let e of Cd(a,o,{concurrency:t.concurrency,basePath:s,dryRun:t.dryRun,timeoutSeconds:t.timeout}))process.stdout.write(JSON.stringify(e)+`
310
- `);return}let c=await Sd(a,o,{concurrency:t.concurrency,basePath:s,dryRun:t.dryRun,timeoutSeconds:t.timeout,onEvent:t.verbose?ip:void 0});e.output===`json`?P(c,`json`):op(c),c.status===`failed`&&(process.exitCode=1)}})})),lp,up=M((()=>{I(),nd(),xd(),np(),lp=m({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
309
+ `),process.exit(2)),rd();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=$e(n),a=await ip(i),o=await op(t),s=Xe(i);if(r===`jsonl`){for await(let e of Ed(a,o,{concurrency:t.concurrency,basePath:s,dryRun:t.dryRun,timeoutSeconds:t.timeout}))process.stdout.write(JSON.stringify(e)+`
310
+ `);return}let c=await Td(a,o,{concurrency:t.concurrency,basePath:s,dryRun:t.dryRun,timeoutSeconds:t.timeout,onEvent:t.verbose?sp:void 0});e.output===`json`?P(c,`json`):lp(c),c.status===`failed`&&(process.exitCode=1)}})})),fp,pp=M((()=>{I(),ad(),wd(),ap(),fp=m({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
311
311
  Usage: bl pipeline validate <file>
312
- `),process.exit(2)),ed();let r=await tp($e(n)),i=fd(r),a=i.length===0?pd(r):[];if(e.output===`json`)P({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.
312
+ `),process.exit(2)),rd();let r=await ip($e(n)),i=hd(r),a=i.length===0?gd(r):[];if(e.output===`json`)P({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.
313
313
  `);for(let e of a)process.stderr.write(` hint: ${e}\n`)}else{process.stderr.write(`Pipeline validation failed:
314
- `);for(let e of i)process.stderr.write(` - ${e}\n`);process.exitCode=1}}})}));function dp(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}K`:String(e)}function fp(e,t){let n=t?new nt({level:0}):tt,r=[];r.push(n.cyan.bold(`需求理解`)),e.taskSummary&&(r.push(``),r.push(e.taskSummary)),e.scenarioHints.length&&(r.push(``),r.push(`${n.dim(`场景特征`)} ${e.scenarioHints.join(` · `)}`));let i=e.inputModality.map(e=>vp[e]??e),a=e.outputModality.map(e=>vp[e]??e);if(i.length||a.length){r.push(``);let e=[];i.length&&e.push(`${n.dim(`输入`)} ${i.join(`, `)}`),a.length&&e.push(`${n.dim(`输出`)} ${a.join(`, `)}`),r.push(e.join(` `))}let o=e.requiredCapabilities.map(e=>yp[e]??e);o.length&&r.push(`${n.dim(`所需能力`)} ${o.join(`, `)}`);let s=bp[e.budget]??e.budget,c=xp[e.qualityPreference]??e.qualityPreference;r.push(``),r.push(`${n.dim(`预算倾向`)} ${s} ${n.dim(`质量偏好`)} ${c}`);let l=e.modelPreference;if(l&&l.mode!==`unconstrained`){r.push(``);let e=Sp[l.mode]??l.mode,t=[n.dim(`推荐模式`)+` ${n.yellow(e)}`];l.targets?.length&&t.push(n.dim(`目标`)+` ${l.targets.join(`, `)}`),l.excludes?.length&&t.push(n.dim(`排除`)+` ${l.excludes.join(`, `)}`),r.push(t.join(` `))}if(e.segments?.length){r.push(``),r.push(n.dim(`任务拆解`));for(let[t,i]of e.segments.entries()){let e=i.outputModality.map(e=>vp[e]??e).join(`, `);r.push(` ${n.dim(`${t+1}.`)} ${i.step}${e?n.dim(` → ${e}`):``}`)}}return et(r.join(`
315
- `),{padding:{top:0,bottom:0,left:1,right:1},margin:{top:0,bottom:0,left:1,right:0},borderColor:`cyan`,borderStyle:`round`,dimBorder:!0})}function pp(e,t,n){let r=[n.green.bold,n.blue.bold,n.magenta.bold][t]??n.white.bold,i=Cp[t]??`推荐 #${t+1}`,a=[];a.push(r(`⬢ 推荐 #${t+1} — ${i}`)),a.push(``),a.push(`${n.bold(e.name)} ${n.dim(`(${e.model})`)}`),a.push(``),a.push(`${n.cyan(`推荐理由`)} ${e.reason}`),e.highlights.length&&(a.push(``),a.push(e.highlights.map(e=>n.bgGray.white(` ${e} `)).join(` `)));let o=[];e.contextWindow&&o.push(`上下文 ${dp(e.contextWindow)}`),e.maxOutputTokens&&o.push(`最大输出 ${dp(e.maxOutputTokens)}`),o.length&&(a.push(``),a.push(n.dim(o.join(` · `))));let s=u(e.docUrl);return s&&(a.push(``),a.push(n.dim(`文档 ${s}`))),et(a.join(`
316
- `),{padding:{top:0,bottom:0,left:1,right:1},margin:{top:0,bottom:0,left:1,right:0},borderColor:`gray`,borderStyle:`round`,dimBorder:!0})}function mp(e,t){let n=t?new nt({level:0}):tt;return e.map((e,t)=>pp(e,t,n)).join(`
317
- `)}function hp(e,t,n){let r=n?new nt({level:0}):tt,i=[];i.push(` ${r.yellow.bold(`⚡ 组合方案`)} ${e}`);for(let[e,{step:n,recommendations:a,warnings:o}]of t.entries()){if(i.push(``),i.push(r.bold(` ━━━ Step ${e+1}: ${n} ━━━`)),o?.length)for(let e of o)i.push(` ${r.yellow(`⚠`)} ${r.yellow(e)}`);i.push(``),i.push(a.map((e,t)=>pp(e,t,r)).join(`
314
+ `);for(let e of i)process.stderr.write(` - ${e}\n`);process.exitCode=1}}})}));function mp(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}K`:String(e)}function hp(e,t){let n=t?new nt({level:0}):tt,r=[];r.push(n.cyan.bold(`需求理解`)),e.taskSummary&&(r.push(``),r.push(e.taskSummary)),e.scenarioHints.length&&(r.push(``),r.push(`${n.dim(`场景特征`)} ${e.scenarioHints.join(` · `)}`));let i=e.inputModality.map(e=>xp[e]??e),a=e.outputModality.map(e=>xp[e]??e);if(i.length||a.length){r.push(``);let e=[];i.length&&e.push(`${n.dim(`输入`)} ${i.join(`, `)}`),a.length&&e.push(`${n.dim(`输出`)} ${a.join(`, `)}`),r.push(e.join(` `))}let o=e.requiredCapabilities.map(e=>Sp[e]??e);o.length&&r.push(`${n.dim(`所需能力`)} ${o.join(`, `)}`);let s=Cp[e.budget]??e.budget,c=wp[e.qualityPreference]??e.qualityPreference;r.push(``),r.push(`${n.dim(`预算倾向`)} ${s} ${n.dim(`质量偏好`)} ${c}`);let l=e.modelPreference;if(l&&l.mode!==`unconstrained`){r.push(``);let e=Tp[l.mode]??l.mode,t=[n.dim(`推荐模式`)+` ${n.yellow(e)}`];l.targets?.length&&t.push(n.dim(`目标`)+` ${l.targets.join(`, `)}`),l.excludes?.length&&t.push(n.dim(`排除`)+` ${l.excludes.join(`, `)}`),r.push(t.join(` `))}if(e.segments?.length){r.push(``),r.push(n.dim(`任务拆解`));for(let[t,i]of e.segments.entries()){let e=i.outputModality.map(e=>xp[e]??e).join(`, `);r.push(` ${n.dim(`${t+1}.`)} ${i.step}${e?n.dim(` → ${e}`):``}`)}}return et(r.join(`
315
+ `),{padding:{top:0,bottom:0,left:1,right:1},margin:{top:0,bottom:0,left:1,right:0},borderColor:`cyan`,borderStyle:`round`,dimBorder:!0})}function gp(e,t,n){let r=[n.green.bold,n.blue.bold,n.magenta.bold][t]??n.white.bold,i=Ep[t]??`推荐 #${t+1}`,a=[];a.push(r(`⬢ 推荐 #${t+1} — ${i}`)),a.push(``),a.push(`${n.bold(e.name)} ${n.dim(`(${e.model})`)}`),a.push(``),a.push(`${n.cyan(`推荐理由`)} ${e.reason}`),e.highlights.length&&(a.push(``),a.push(e.highlights.map(e=>n.bgGray.white(` ${e} `)).join(` `)));let o=[];e.contextWindow&&o.push(`上下文 ${mp(e.contextWindow)}`),e.maxOutputTokens&&o.push(`最大输出 ${mp(e.maxOutputTokens)}`),o.length&&(a.push(``),a.push(n.dim(o.join(` · `))));let s=u(e.docUrl);return s&&(a.push(``),a.push(n.dim(`文档 ${s}`))),et(a.join(`
316
+ `),{padding:{top:0,bottom:0,left:1,right:1},margin:{top:0,bottom:0,left:1,right:0},borderColor:`gray`,borderStyle:`round`,dimBorder:!0})}function _p(e,t){let n=t?new nt({level:0}):tt;return e.map((e,t)=>gp(e,t,n)).join(`
317
+ `)}function vp(e,t,n){let r=n?new nt({level:0}):tt,i=[];i.push(` ${r.yellow.bold(`⚡ 组合方案`)} ${e}`);for(let[e,{step:n,recommendations:a,warnings:o}]of t.entries()){if(i.push(``),i.push(r.bold(` ━━━ Step ${e+1}: ${n} ━━━`)),o?.length)for(let e of o)i.push(` ${r.yellow(`⚠`)} ${r.yellow(e)}`);i.push(``),i.push(a.map((e,t)=>gp(e,t,r)).join(`
318
318
  `))}return i.join(`
319
- `)}function gp(e,t){return e.type===`pipeline`?hp(e.summary,e.steps,t):mp(e.recommendations,t)}function _p(e){return e.type===`pipeline`?e.steps.length===0:e.recommendations.length===0}var vp,yp,bp,xp,Sp,Cp,wp,Tp=M((()=>{I(),Ui(),H(),vp={Text:`文本`,Image:`图片`,Video:`视频`,Audio:`音频`},yp={TG:`文本生成`,VU:`视觉理解`,IG:`图像生成`,VG:`视频生成`,TTS:`语音合成`,ASR:`语音识别`,Reasoning:`推理`},bp={low:`低成本优先`,medium:`适中`,high:`高投入`},xp={flagship:`旗舰优先`,balanced:`均衡`,"cost-optimized":`性价比优先`},Sp={scoped:`限定范围`,comparison:`对比评估`,alternative:`替代推荐`},Cp=[`最佳推荐`,`次优选择`,`备选参考`],wp=m({name:`advisor recommend`,description:`Recommend the best models for your use case (intent analysis → candidate recall → LLM ranking)`,usage:`bl advisor recommend <prompt> [flags]`,options:[{flag:`--message <text>`,description:`Describe your requirements (alternative to positional prompt)`},{flag:`--dry-run`,description:`Show intent analysis and candidate list without LLM ranking`},{flag:`--output <format>`,description:`Output format: text (default in TTY), json, yaml`}],examples:[`bl advisor recommend --message "I need a visual-understanding chatbot"`,`bl advisor recommend --message "Build an Agent that auto-generates animations"`,`bl advisor recommend --message "Legal contract review, high precision required"`,`bl advisor recommend --message "Low-cost high-concurrency online customer service" --output json`,`bl advisor recommend --message "Long document summarization" --dry-run`,`bl advisor recommend # Interactive input`],async run(e,t){let n=t._positional??[],r=t.message||n.join(` `);if(!r.trim())if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`描述你的需求:`});e||(process.stderr.write(`已取消。
319
+ `)}function yp(e,t){return e.type===`pipeline`?vp(e.summary,e.steps,t):_p(e.recommendations,t)}function bp(e){return e.type===`pipeline`?e.steps.length===0:e.recommendations.length===0}var xp,Sp,Cp,wp,Tp,Ep,Dp,Op=M((()=>{I(),Ki(),H(),xp={Text:`文本`,Image:`图片`,Video:`视频`,Audio:`音频`},Sp={TG:`文本生成`,VU:`视觉理解`,IG:`图像生成`,VG:`视频生成`,TTS:`语音合成`,ASR:`语音识别`,Reasoning:`推理`},Cp={low:`低成本优先`,medium:`适中`,high:`高投入`},wp={flagship:`旗舰优先`,balanced:`均衡`,"cost-optimized":`性价比优先`},Tp={scoped:`限定范围`,comparison:`对比评估`,alternative:`替代推荐`},Ep=[`最佳推荐`,`次优选择`,`备选参考`],Dp=m({name:`advisor recommend`,description:`Recommend the best models for your use case (intent analysis → candidate recall → LLM ranking)`,usage:`bl advisor recommend <prompt> [flags]`,options:[{flag:`--message <text>`,description:`Describe your requirements (alternative to positional prompt)`},{flag:`--dry-run`,description:`Show intent analysis and candidate list without LLM ranking`},{flag:`--output <format>`,description:`Output format: text (default in TTY), json, yaml`}],examples:[`bl advisor recommend --message "I need a visual-understanding chatbot"`,`bl advisor recommend --message "Build an Agent that auto-generates animations"`,`bl advisor recommend --message "Legal contract review, high precision required"`,`bl advisor recommend --message "Low-cost high-concurrency online customer service" --output json`,`bl advisor recommend --message "Long document summarization" --dry-run`,`bl advisor recommend # Interactive input`],async run(e,t){let n=t._positional??[],r=t.message||n.join(` `);if(!r.trim())if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`描述你的需求:`});e||(process.stderr.write(`已取消。
320
320
  `),process.exit(1)),r=e}else V(`message`,`bl advisor recommend "你的需求"`);let i=h(e.output),a={onPrepareStart:()=>process.stderr.write(`初始化中...
321
321
  `)};process.stderr.write(`正在分析需求...
322
322
  `);let[o,c]=await Promise.all([C(e,a),s(e,r)]);c.confidence===0?process.stderr.write(`需求分析超时,使用默认参数继续...
323
323
  `):process.stderr.write(`
324
- `);let l=await de(e,o,r,50,c);if(e.dryRun){P({userInput:r,intent:c,candidateCount:l.length,candidates:l.map(({model:e,score:t})=>({model:e.model,score:t})),top:3},i);return}let u=Bi(`正在推荐最佳模型...`);u.start();let d=await le(e,l,c,r,3);if(u.stop(),_p(d)){F(`暂无满足该需求的模型。`);return}if(i!==`text`){P(d,i);return}F(fp(c,e.noColor)),F(``),F(gp(d,e.noColor))}})}));function Ep(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function Dp(e){let t=Ep(e,`data`);if(!t)return e;let n=Ep(t,`DataV2`);if(n){let e=Ep(n,`data`);return(e?Ep(e,`data`):void 0)??e??n}return Ep(t,`data`)??t}function Op(e,t){let n=t?e=>e:e=>`\x1b[1m${e}\x1b[0m`,r=t?e=>e:e=>`\x1b[2m${e}\x1b[0m`,i=t?e=>e:e=>`\x1b[32m${e}\x1b[0m`,a=[`空间名称`,`Workspace ID`,`默认空间`],o=[`Name`,``,`Default`],s=e.map(e=>[e.agentName,e.workspaceId,e.defaultAgent?`Yes`:`-`]),c=a.map((e,t)=>Math.max(U(e),U(o[t]),...s.map(e=>U(e[t])))),l=a.map((e,t)=>n(W(e,c[t]))).join(` `),u=o.map((e,t)=>r(W(e,c[t]))).join(` `),d=c.map(e=>r(`─`.repeat(e))).join(`──`);process.stdout.write(l+`
324
+ `);let l=await de(e,o,r,50,c);if(e.dryRun){P({userInput:r,intent:c,candidateCount:l.length,candidates:l.map(({model:e,score:t})=>({model:e.model,score:t})),top:3},i);return}let u=Ui(`正在推荐最佳模型...`);u.start();let d=await le(e,l,c,r,3);if(u.stop(),bp(d)){F(`暂无满足该需求的模型。`);return}if(i!==`text`){P(d,i);return}F(hp(c,e.noColor)),F(``),F(yp(d,e.noColor))}})}));function kp(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function Ap(e){let t=kp(e,`data`);if(!t)return e;let n=kp(t,`DataV2`);if(n){let e=kp(n,`data`);return(e?kp(e,`data`):void 0)??e??n}return kp(t,`data`)??t}function jp(e,t){let n=t?e=>e:e=>`\x1b[1m${e}\x1b[0m`,r=t?e=>e:e=>`\x1b[2m${e}\x1b[0m`,i=t?e=>e:e=>`\x1b[32m${e}\x1b[0m`,a=[`空间名称`,`Workspace ID`,`默认空间`],o=[`Name`,``,`Default`],s=e.map(e=>[e.agentName,e.workspaceId,e.defaultAgent?`Yes`:`-`]),c=a.map((e,t)=>Math.max(U(e),U(o[t]),...s.map(e=>U(e[t])))),l=a.map((e,t)=>n(W(e,c[t]))).join(` `),u=o.map((e,t)=>r(W(e,c[t]))).join(` `),d=c.map(e=>r(`─`.repeat(e))).join(`──`);process.stdout.write(l+`
325
325
  `),process.stdout.write(u+`
326
326
  `),process.stdout.write(d+`
327
327
  `);for(let e of s){let t=e.map((e,t)=>t===2&&e===`Yes`?i(W(e,c[t])):W(e,c[t]));process.stdout.write(t.join(` `)+`
328
328
  `)}process.stdout.write(r(`\n共 ${e.length} 个空间 (Total: ${e.length})`)+`
329
- `)}var kp,Ap,jp=M((()=>{I(),fs(),kp=`zeldaEasy.bailian-dash-workspace.space.listWorkspaces`,Ap=m({name:`workspace list`,description:`List all workspaces`,usage:`bl workspace list [flags]`,options:[{flag:`--list <n>`,description:`Limit number of results`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl workspace list`,`bl workspace list --list 5`,`bl workspace list --output json`],async run(e,t){let n=t.region||`cn-beijing`,r=Number(t.list)||0,i=h(e.output),a=await me(e);if(e.dryRun){P({api:kp,data:{},region:n},i);return}let o=await d(e,a.token,{api:kp,data:{},region:n});if(i===`json`){P(o,i);return}let s=Dp(o).data;if(!Array.isArray(s)||s.length===0){process.stdout.write(`No workspace found.
330
- `);return}let c=s;r>0&&(c=c.slice(0,r)),Op(c,e.noColor)}})}));function Mp(e,t){if(!e)return 0;let n=e.count_limit_period||t;return n?Math.floor(e.count_limit*60/n):0}function Np(e,t){if(!e)return 0;let n=e.usage_limit_period||t;return n?Math.floor(e.usage_limit*60/n):0}function Pp(e){return e.toLocaleString(`en-US`)}function Fp(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function Ip(e){let t=Fp(e,`data`);if(!t)return e;let n=Fp(t,`DataV2`);if(n){let e=Fp(n,`data`);return(e?Fp(e,`data`):void 0)??e??n}return Fp(t,`data`)??t}async function Lp(e,t,n,r){let i=[],a=1;for(;;){let o={pageNo:a,pageSize:50,group:!1,queryQpmInfo:!0,ignoreWorkspaceServiceSite:!0};r&&(o.supports={selfServiceLimitIncrease:!0});let s=Ip(await d(e,t,{api:zp,data:{input:o},region:n})),c=s.list??[],l=s.total??0;if(i.push(...c),i.length>=l||c.length===0)break;a++}return i}function Rp(e,t){let n=t?e=>e:e=>`\x1b[1m${e}\x1b[0m`,r=t?e=>e:e=>`\x1b[2m${e}\x1b[0m`,i=[`模型`,`RPM`,`TPM`,`可设上限 TPM`],a=[`Model`,`Req/min`,`Token/min`,`Max TPM`],o=e.map(e=>{let t=e.qpmInfo,n=t?.[`model-default`],r=t?.[`user-spec`],i=Mp(n),a=Np(n),o=Mp(r,n?.count_limit_period)||i,s=Np(r,n?.usage_limit_period)||a,c=a*2;return[e.model,o>0?Pp(o):`-`,s>0?Pp(s):`-`,c>0?Pp(c):`-`]});if(o.length===0){process.stdout.write(`No models found.
329
+ `)}var Mp,Np,Pp=M((()=>{I(),hs(),Mp=`zeldaEasy.bailian-dash-workspace.space.listWorkspaces`,Np=m({name:`workspace list`,description:`List all workspaces`,usage:`bl workspace list [flags]`,options:[{flag:`--list <n>`,description:`Limit number of results`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl workspace list`,`bl workspace list --list 5`,`bl workspace list --output json`],async run(e,t){let n=t.region||`cn-beijing`,r=Number(t.list)||0,i=h(e.output),a=await me(e);if(e.dryRun){P({api:Mp,data:{},region:n},i);return}let o=await d(e,a.token,{api:Mp,data:{},region:n});if(i===`json`){P(o,i);return}let s=Ap(o).data;if(!Array.isArray(s)||s.length===0){process.stdout.write(`No workspace found.
330
+ `);return}let c=s;r>0&&(c=c.slice(0,r)),jp(c,e.noColor)}})}));function Fp(e,t){if(!e)return 0;let n=e.count_limit_period||t;return n?Math.floor(e.count_limit*60/n):0}function Ip(e,t){if(!e)return 0;let n=e.usage_limit_period||t;return n?Math.floor(e.usage_limit*60/n):0}function Lp(e){return e.toLocaleString(`en-US`)}function Rp(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function zp(e){let t=Rp(e,`data`);if(!t)return e;let n=Rp(t,`DataV2`);if(n){let e=Rp(n,`data`);return(e?Rp(e,`data`):void 0)??e??n}return Rp(t,`data`)??t}async function Bp(e,t,n,r){let i=[],a=1;for(;;){let o={pageNo:a,pageSize:50,group:!1,queryQpmInfo:!0,ignoreWorkspaceServiceSite:!0};r&&(o.supports={selfServiceLimitIncrease:!0});let s=zp(await d(e,t,{api:Hp,data:{input:o},region:n})),c=s.list??[],l=s.total??0;if(i.push(...c),i.length>=l||c.length===0)break;a++}return i}function Vp(e,t){let n=t?e=>e:e=>`\x1b[1m${e}\x1b[0m`,r=t?e=>e:e=>`\x1b[2m${e}\x1b[0m`,i=[`模型`,`RPM`,`TPM`,`可设上限 TPM`],a=[`Model`,`Req/min`,`Token/min`,`Max TPM`],o=e.map(e=>{let t=e.qpmInfo,n=t?.[`model-default`],r=t?.[`user-spec`],i=Fp(n),a=Ip(n),o=Fp(r,n?.count_limit_period)||i,s=Ip(r,n?.usage_limit_period)||a,c=a*2;return[e.model,o>0?Lp(o):`-`,s>0?Lp(s):`-`,c>0?Lp(c):`-`]});if(o.length===0){process.stdout.write(`No models found.
331
331
  `);return}let s=i.map((e,t)=>Math.max(U(e),U(a[t]),...o.map(e=>U(e[t])))),c=i.map((e,t)=>n(W(e,s[t]))).join(` `),l=a.map((e,t)=>r(W(e,s[t]))).join(` `),u=s.map(e=>r(`─`.repeat(e))).join(`──`);process.stdout.write(c+`
332
332
  `),process.stdout.write(l+`
333
333
  `),process.stdout.write(u+`
334
334
  `);for(let e of o)process.stdout.write(e.map((e,t)=>W(e,s[t])).join(` `)+`
335
335
  `);process.stdout.write(r(`\n共 ${e.length} 个模型 (Total: ${e.length})`)+`
336
- `)}var zp,Bp,Vp=M((()=>{I(),fs(),zp=`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,Bp=m({name:`quota list`,description:`View model RPM/TPM rate limits`,usage:`bl quota list [--model <model>] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s), comma-separated`},{flag:`--all`,description:`Show all models, not just self-service ones`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl quota list`,`bl quota list --model qwen3.6-plus`,`bl quota list --model qwen3.6-plus,qwen-turbo`,`bl quota list --all`,`bl quota list --output json`],async run(e,t){let n=t.model||void 0,r=!!t.all,i=t.region||`cn-beijing`,a=h(e.output),o=await me(e);if(e.dryRun){let e={pageNo:1,pageSize:50,group:!1,queryQpmInfo:!0,ignoreWorkspaceServiceSite:!0};r||(e.supports={selfServiceLimitIncrease:!0}),P({api:zp,data:{input:e},region:i},a);return}let s=await Lp(e,o.token,i,!r);if(n){let e=new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean));s=s.filter(t=>e.has(t.model)),s.length===0&&(process.stderr.write(`Error: no matching models found for "${n}".\n`),process.exit(1))}if(a===`json`){P(s,a);return}Rp(s,e.noColor)}})}));function Hp(e,t){if(!e)return 0;let n=e.usage_limit_period||t;return n?Math.floor(e.usage_limit*60/n):0}function Up(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function Wp(e){let t=Up(e,`data`);if(!t)return e;let n=Up(t,`DataV2`);if(n){let e=Up(n,`data`);return(e?Up(e,`data`):void 0)??e??n}return Up(t,`data`)??t}async function Gp(e,t,n,r){return(Wp(await d(e,t,{api:Kp,data:{input:{pageNo:1,pageSize:50,name:r,group:!1,queryQpmInfo:!0,ignoreWorkspaceServiceSite:!0,supports:{selfServiceLimitIncrease:!0}}},region:n})).list??[]).find(e=>e.model===r&&e.qpmInfo)}var Kp,qp,Jp,Yp=M((()=>{I(),Kp=`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,qp=`zeldaEasy.broadscope-platform.modelInstance.updateFoundationModelLimits`,Jp=m({name:`quota request`,description:`Request a temporary quota increase`,usage:`bl quota request --model <model> --tpm <value> [flags]`,options:[{flag:`--model <model>`,description:`Model name (required)`,required:!0},{flag:`--tpm <value>`,description:`Target TPM value (required)`,required:!0},{flag:`--yes`,description:`Skip downgrade confirmation`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl quota request --model qwen-turbo --tpm 100000`,`bl quota request --model qwen3.6-plus --tpm 8000000 --yes`,`bl quota request --model qwen-turbo --tpm 100000 --output json`],async run(e,n){let r=n.model;r||(process.stderr.write(`Error: --model is required.
336
+ `)}var Hp,Up,Wp=M((()=>{I(),hs(),Hp=`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,Up=m({name:`quota list`,description:`View model RPM/TPM rate limits`,usage:`bl quota list [--model <model>] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s), comma-separated`},{flag:`--all`,description:`Show all models, not just self-service ones`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl quota list`,`bl quota list --model qwen3.6-plus`,`bl quota list --model qwen3.6-plus,qwen-turbo`,`bl quota list --all`,`bl quota list --output json`],async run(e,t){let n=t.model||void 0,r=!!t.all,i=t.region||`cn-beijing`,a=h(e.output),o=await me(e);if(e.dryRun){let e={pageNo:1,pageSize:50,group:!1,queryQpmInfo:!0,ignoreWorkspaceServiceSite:!0};r||(e.supports={selfServiceLimitIncrease:!0}),P({api:Hp,data:{input:e},region:i},a);return}let s=await Bp(e,o.token,i,!r);if(n){let e=new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean));s=s.filter(t=>e.has(t.model)),s.length===0&&(process.stderr.write(`Error: no matching models found for "${n}".\n`),process.exit(1))}if(a===`json`){P(s,a);return}Vp(s,e.noColor)}})}));function Gp(e,t){if(!e)return 0;let n=e.usage_limit_period||t;return n?Math.floor(e.usage_limit*60/n):0}function Kp(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function qp(e){let t=Kp(e,`data`);if(!t)return e;let n=Kp(t,`DataV2`);if(n){let e=Kp(n,`data`);return(e?Kp(e,`data`):void 0)??e??n}return Kp(t,`data`)??t}async function Jp(e,t,n,r){return(qp(await d(e,t,{api:Yp,data:{input:{pageNo:1,pageSize:50,name:r,group:!1,queryQpmInfo:!0,ignoreWorkspaceServiceSite:!0,supports:{selfServiceLimitIncrease:!0}}},region:n})).list??[]).find(e=>e.model===r&&e.qpmInfo)}var Yp,Xp,Zp,Qp=M((()=>{I(),Yp=`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,Xp=`zeldaEasy.broadscope-platform.modelInstance.updateFoundationModelLimits`,Zp=m({name:`quota request`,description:`Request a temporary quota increase`,usage:`bl quota request --model <model> --tpm <value> [flags]`,options:[{flag:`--model <model>`,description:`Model name (required)`,required:!0},{flag:`--tpm <value>`,description:`Target TPM value (required)`,required:!0},{flag:`--yes`,description:`Skip downgrade confirmation`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl quota request --model qwen-turbo --tpm 100000`,`bl quota request --model qwen3.6-plus --tpm 8000000 --yes`,`bl quota request --model qwen-turbo --tpm 100000 --output json`],async run(e,n){let r=n.model;r||(process.stderr.write(`Error: --model is required.
337
337
  `),process.exit(1));let i=Number(n.tpm);(!i||i<=0)&&(process.stderr.write(`Error: --tpm must be a positive number.
338
- `),process.exit(1));let a=!!n.yes||e.yes,o=n.region||`cn-beijing`,s=h(e.output),c=await me(e),l=await Gp(e,c.token,o,r);l||(process.stderr.write(`Error: model "${r}" not found or does not support self-service quota increase.\n`),process.stderr.write("Hint: run `bl quota list` to view available models.\n"),process.exit(1));let u=l.qpmInfo[`model-default`],f=l.qpmInfo[`user-spec`],p=Hp(u),m=Hp(f,u?.usage_limit_period)||p,g=p*2;(i<p||i>g)&&(process.stderr.write(`Error: TPM value ${i.toLocaleString()} is out of range.\n Current: ${m.toLocaleString()}\n Range: ${p.toLocaleString()} ~ ${g.toLocaleString()}\n`),process.exit(1));let _={input:{model:r,limit:{usage_limit:i},originalQpmInfo:l.qpmInfo}};if(e.dryRun){P({api:qp,data:_,region:o},s);return}let v=async n=>{n&&(_.input.confirmedDowngrade=!0);try{return await d(e,c.token,{api:qp,data:_,region:o})}catch(e){throw e instanceof t&&e.message.includes(`NotLogined`)&&(process.stderr.write("Error: session expired. Run `bl auth login --console` to re-authenticate.\n"),process.exit(1)),e}},y=await v(),b=Wp(y);if(b.needConfirm){let e=b.confirmCode;e===`Refresh_Required`&&(process.stderr.write(`Error: rate limit has been updated externally. Please retry.
338
+ `),process.exit(1));let a=!!n.yes||e.yes,o=n.region||`cn-beijing`,s=h(e.output),c=await me(e),l=await Jp(e,c.token,o,r);l||(process.stderr.write(`Error: model "${r}" not found or does not support self-service quota increase.\n`),process.stderr.write("Hint: run `bl quota list` to view available models.\n"),process.exit(1));let u=l.qpmInfo[`model-default`],f=l.qpmInfo[`user-spec`],p=Gp(u),m=Gp(f,u?.usage_limit_period)||p,g=p*2;(i<p||i>g)&&(process.stderr.write(`Error: TPM value ${i.toLocaleString()} is out of range.\n Current: ${m.toLocaleString()}\n Range: ${p.toLocaleString()} ~ ${g.toLocaleString()}\n`),process.exit(1));let _={input:{model:r,limit:{usage_limit:i},originalQpmInfo:l.qpmInfo}};if(e.dryRun){P({api:Xp,data:_,region:o},s);return}let v=async n=>{n&&(_.input.confirmedDowngrade=!0);try{return await d(e,c.token,{api:Xp,data:_,region:o})}catch(e){throw e instanceof t&&e.message.includes(`NotLogined`)&&(process.stderr.write("Error: session expired. Run `bl auth login --console` to re-authenticate.\n"),process.exit(1)),e}},y=await v(),b=qp(y);if(b.needConfirm){let e=b.confirmCode;e===`Refresh_Required`&&(process.stderr.write(`Error: rate limit has been updated externally. Please retry.
339
339
  `),process.exit(1)),e===`Downgrade`&&(a||(process.stderr.write(`Warning: target TPM (${i.toLocaleString()}) is lower than current (${m.toLocaleString()}).\nUse --yes to confirm downgrade.
340
- `),process.exit(1)),y=await v(!0))}if(s===`json`){P(y,s);return}process.stdout.write(`Quota updated for "${r}": TPM ${m.toLocaleString()} → ${i.toLocaleString()}\n`)}})}));function Xp(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function Zp(e){let t=Xp(e,`data`);if(!t)return e;let n=Xp(t,`DataV2`);if(n){let e=Xp(n,`data`);return(e?Xp(e,`data`):void 0)??e??n}return Xp(t,`data`)??t}function Qp(e){if(!e)return`-`;try{let t=new Date(e);return isNaN(t.getTime())?e:`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)} ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}catch{return e}}function $p(e){return e.toLocaleString(`en-US`)}function em(e,t,n){let r=t?e=>e:e=>`\x1b[1m${e}\x1b[0m`,i=t?e=>e:e=>`\x1b[2m${e}\x1b[0m`,a=[`模型`,`Token 账号限流`,`申请时间`],o=[`Model`,`Token Limit`,`Applied At`],s=e.map(e=>[e.deployedModel,$p(e.usageLimit),Qp(e.gmtCreate)]),c=a.map((e,t)=>Math.max(U(e),U(o[t]),...s.map(e=>U(e[t])))),l=a.map((e,t)=>r(W(e,c[t]))).join(` `),u=o.map((e,t)=>i(W(e,c[t]))).join(` `),d=c.map(e=>i(`─`.repeat(e))).join(`──`);process.stdout.write(l+`
340
+ `),process.exit(1)),y=await v(!0))}if(s===`json`){P(y,s);return}process.stdout.write(`Quota updated for "${r}": TPM ${m.toLocaleString()} → ${i.toLocaleString()}\n`)}})}));function $p(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function em(e){let t=$p(e,`data`);if(!t)return e;let n=$p(t,`DataV2`);if(n){let e=$p(n,`data`);return(e?$p(e,`data`):void 0)??e??n}return $p(t,`data`)??t}function tm(e){if(!e)return`-`;try{let t=new Date(e);return isNaN(t.getTime())?e:`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)} ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}catch{return e}}function nm(e){return e.toLocaleString(`en-US`)}function rm(e,t,n){let r=t?e=>e:e=>`\x1b[1m${e}\x1b[0m`,i=t?e=>e:e=>`\x1b[2m${e}\x1b[0m`,a=[`模型`,`Token 账号限流`,`申请时间`],o=[`Model`,`Token Limit`,`Applied At`],s=e.map(e=>[e.deployedModel,nm(e.usageLimit),tm(e.gmtCreate)]),c=a.map((e,t)=>Math.max(U(e),U(o[t]),...s.map(e=>U(e[t])))),l=a.map((e,t)=>r(W(e,c[t]))).join(` `),u=o.map((e,t)=>i(W(e,c[t]))).join(` `),d=c.map(e=>i(`─`.repeat(e))).join(`──`);process.stdout.write(l+`
341
341
  `),process.stdout.write(u+`
342
342
  `),process.stdout.write(d+`
343
343
  `);for(let e of s)process.stdout.write(e.map((e,t)=>W(e,c[t])).join(` `)+`
344
344
  `);process.stdout.write(i(`\n共 ${n} 条记录 (Total: ${n})`)+`
345
- `)}var tm,nm,rm=M((()=>{I(),fs(),tm=`zeldaEasy.broadscope-platform.modelInstance.listModelLimitApplications`,nm=m({name:`quota history`,description:`View quota change history`,usage:`bl quota history [flags]`,options:[{flag:`--page <n>`,description:`Page number (default: 1)`},{flag:`--page-size <n>`,description:`Page size (default: 10)`},{flag:`--model <model>`,description:`Filter by model name`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl quota history`,`bl quota history --page 2`,`bl quota history --page-size 20`,`bl quota history --model qwen-turbo`,`bl quota history --output json`],async run(e,n){let r=Number(n.page)||1,i=Number(n.pageSize)||10,a=n.model||void 0,o=n.region||`cn-beijing`,s=h(e.output),c=await me(e),l={input:{pageNo:r,pageSize:i}};if(e.dryRun){P({api:tm,data:l,region:o},s);return}let u;try{u=await d(e,c.token,{api:tm,data:l,region:o})}catch(e){throw e instanceof t&&e.message.includes(`NotLogined`)&&(process.stderr.write("Error: session expired. Run `bl auth login --console` to re-authenticate.\n"),process.exit(1)),e}if(s===`json`){P(u,s);return}let f=Zp(u),p=f.records??[],m=f.items??p.length;if(a&&(p=p.filter(e=>e.deployedModel===a)),p.length===0){process.stdout.write(`No quota change history found.
346
- `);return}em(p,e.noColor,a?p.length:m)}})}));function im(e,t){if(!e)return 0;let n=e.count_limit_period||t;return n?Math.floor(e.count_limit*60/n):0}function am(e,t){if(!e)return 0;let n=e.usage_limit_period||t;return n?Math.floor(e.usage_limit*60/n):0}function om(e){return e.toLocaleString(`en-US`)}function sm(e,t){if(t<=0)return`-`;let n=Math.round(e/t*100);return`${om(e)}/${om(t)} (${n}%)`}function cm(e,t){if(t<=0)return`-`;let n=e/t*100;return n>=100?`已限流`:n>=80?`接近限流`:`正常`}function lm(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function um(e){let t=lm(e,`data`);if(!t)return e;let n=lm(t,`DataV2`);if(n){let e=lm(n,`data`);return(e?lm(e,`data`):void 0)??e??n}return lm(t,`data`)??t}async function dm(e,t,n){let r=[],i=1;for(;;){let a=um(await d(e,t,{api:mm,data:{input:{pageNo:i,pageSize:50,group:!1,queryQpmInfo:!0,ignoreWorkspaceServiceSite:!0,supports:{selfServiceLimitIncrease:!0}}},region:n})),o=a.list??[],s=a.total??0;if(r.push(...o),r.length>=s||o.length===0)break;i++}return r}async function fm(e,t,n,r,i){let a=Date.now(),o=a-i*60*1e3;try{let i=um(await d(e,t,{api:hm,data:{reqDTO:{monitorType:`Advanced`,metricFilters:[{aggMethod:`sum_pm`,metricName:`model_total_amount`},{aggMethod:`sum_pm`,metricName:`model_call_count`}],labelFilters:{resourceId:r,resourceType:`model`},startTime:o,endTime:a}},region:n})),s=i.data??i;if(!Array.isArray(s))return{rpm:0,tpm:0};let c=0,l=0;for(let e of s){if(e.aggMethod!==`sum_pm`||!e.points?.length)continue;let t=e.points[e.points.length-1].value??0;e.metricName===`model_call_count`&&(c=Math.round(t)),e.metricName===`model_total_amount`&&(l=Math.round(t))}return{rpm:c,tpm:l}}catch{return{rpm:-1,tpm:-1}}}function pm(e,t){let n=t?e=>e:e=>`\x1b[1m${e}\x1b[0m`,r=t?e=>e:e=>`\x1b[2m${e}\x1b[0m`,i=t?e=>e:e=>`\x1b[32m${e}\x1b[0m`,a=t?e=>e:e=>`\x1b[33m${e}\x1b[0m`,o=t?e=>e:e=>`\x1b[31m${e}\x1b[0m`,s=[`模型`,`RPM 用量/限额`,`TPM 用量/限额`,`状态`],c=[`Model`,`RPM Usage/Limit`,`TPM Usage/Limit`,`Status`],l=e.map(e=>{let t=e.rpmUsage<0?`-`:sm(e.rpmUsage,e.rpmLimit),n=e.tpmUsage<0?`-`:sm(e.tpmUsage,e.tpmLimit),r=Math.max(e.rpmLimit>0?e.rpmUsage/e.rpmLimit*100:0,e.tpmLimit>0?e.tpmUsage/e.tpmLimit*100:0),i=e.rpmUsage<0?`-`:cm(Math.max(e.rpmUsage,e.tpmUsage),Math.max(e.rpmLimit,e.tpmLimit));return{cells:[e.model,t,n,i],maxPct:r}});if(l.length===0){process.stdout.write(`No models found.
345
+ `)}var im,am,om=M((()=>{I(),hs(),im=`zeldaEasy.broadscope-platform.modelInstance.listModelLimitApplications`,am=m({name:`quota history`,description:`View quota change history`,usage:`bl quota history [flags]`,options:[{flag:`--page <n>`,description:`Page number (default: 1)`},{flag:`--page-size <n>`,description:`Page size (default: 10)`},{flag:`--model <model>`,description:`Filter by model name`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl quota history`,`bl quota history --page 2`,`bl quota history --page-size 20`,`bl quota history --model qwen-turbo`,`bl quota history --output json`],async run(e,n){let r=Number(n.page)||1,i=Number(n.pageSize)||10,a=n.model||void 0,o=n.region||`cn-beijing`,s=h(e.output),c=await me(e),l={input:{pageNo:r,pageSize:i}};if(e.dryRun){P({api:im,data:l,region:o},s);return}let u;try{u=await d(e,c.token,{api:im,data:l,region:o})}catch(e){throw e instanceof t&&e.message.includes(`NotLogined`)&&(process.stderr.write("Error: session expired. Run `bl auth login --console` to re-authenticate.\n"),process.exit(1)),e}if(s===`json`){P(u,s);return}let f=em(u),p=f.records??[],m=f.items??p.length;if(a&&(p=p.filter(e=>e.deployedModel===a)),p.length===0){process.stdout.write(`No quota change history found.
346
+ `);return}rm(p,e.noColor,a?p.length:m)}})}));function sm(e,t){if(!e)return 0;let n=e.count_limit_period||t;return n?Math.floor(e.count_limit*60/n):0}function cm(e,t){if(!e)return 0;let n=e.usage_limit_period||t;return n?Math.floor(e.usage_limit*60/n):0}function lm(e){return e.toLocaleString(`en-US`)}function um(e,t){if(t<=0)return`-`;let n=Math.round(e/t*100);return`${lm(e)}/${lm(t)} (${n}%)`}function dm(e,t){if(t<=0)return`-`;let n=e/t*100;return n>=100?`已限流`:n>=80?`接近限流`:`正常`}function fm(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function pm(e){let t=fm(e,`data`);if(!t)return e;let n=fm(t,`DataV2`);if(n){let e=fm(n,`data`);return(e?fm(e,`data`):void 0)??e??n}return fm(t,`data`)??t}async function mm(e,t,n){let r=[],i=1;for(;;){let a=pm(await d(e,t,{api:_m,data:{input:{pageNo:i,pageSize:50,group:!1,queryQpmInfo:!0,ignoreWorkspaceServiceSite:!0,supports:{selfServiceLimitIncrease:!0}}},region:n})),o=a.list??[],s=a.total??0;if(r.push(...o),r.length>=s||o.length===0)break;i++}return r}async function hm(e,t,n,r,i){let a=Date.now(),o=a-i*60*1e3;try{let i=pm(await d(e,t,{api:vm,data:{reqDTO:{monitorType:`Advanced`,metricFilters:[{aggMethod:`sum_pm`,metricName:`model_total_amount`},{aggMethod:`sum_pm`,metricName:`model_call_count`}],labelFilters:{resourceId:r,resourceType:`model`},startTime:o,endTime:a}},region:n})),s=i.data??i;if(!Array.isArray(s))return{rpm:0,tpm:0};let c=0,l=0;for(let e of s){if(e.aggMethod!==`sum_pm`||!e.points?.length)continue;let t=e.points[e.points.length-1].value??0;e.metricName===`model_call_count`&&(c=Math.round(t)),e.metricName===`model_total_amount`&&(l=Math.round(t))}return{rpm:c,tpm:l}}catch{return{rpm:-1,tpm:-1}}}function gm(e,t){let n=t?e=>e:e=>`\x1b[1m${e}\x1b[0m`,r=t?e=>e:e=>`\x1b[2m${e}\x1b[0m`,i=t?e=>e:e=>`\x1b[32m${e}\x1b[0m`,a=t?e=>e:e=>`\x1b[33m${e}\x1b[0m`,o=t?e=>e:e=>`\x1b[31m${e}\x1b[0m`,s=[`模型`,`RPM 用量/限额`,`TPM 用量/限额`,`状态`],c=[`Model`,`RPM Usage/Limit`,`TPM Usage/Limit`,`Status`],l=e.map(e=>{let t=e.rpmUsage<0?`-`:um(e.rpmUsage,e.rpmLimit),n=e.tpmUsage<0?`-`:um(e.tpmUsage,e.tpmLimit),r=Math.max(e.rpmLimit>0?e.rpmUsage/e.rpmLimit*100:0,e.tpmLimit>0?e.tpmUsage/e.tpmLimit*100:0),i=e.rpmUsage<0?`-`:dm(Math.max(e.rpmUsage,e.tpmUsage),Math.max(e.rpmLimit,e.tpmLimit));return{cells:[e.model,t,n,i],maxPct:r}});if(l.length===0){process.stdout.write(`No models found.
347
347
  `);return}let u=s.map((e,t)=>Math.max(U(e),U(c[t]),...l.map(e=>U(e.cells[t])))),d=s.map((e,t)=>n(W(e,u[t]))).join(` `),f=c.map((e,t)=>r(W(e,u[t]))).join(` `),p=u.map(e=>r(`─`.repeat(e))).join(`──`);process.stdout.write(d+`
348
348
  `),process.stdout.write(f+`
349
349
  `),process.stdout.write(p+`
350
350
  `);for(let e of l){let t=e.cells.map((e,t)=>{if(t===3){if(e===`已限流`)return o(W(e,u[t]));if(e===`接近限流`)return a(W(e,u[t]));if(e===`正常`)return i(W(e,u[t]))}return W(e,u[t])});process.stdout.write(t.join(` `)+`
351
351
  `)}process.stdout.write(r(`\n共 ${e.length} 个模型 (Total: ${e.length})`)+`
352
- `)}var mm,hm,gm,_m=M((()=>{I(),fs(),mm=`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,hm=`zeldaEasy.bailian-telemetry.monitor.getMonitorData`,gm=m({name:`quota check`,description:`Check current usage against rate limits`,usage:`bl quota check [--model <model>] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s), comma-separated`},{flag:`--period <minutes>`,description:`Query usage for the last N minutes (default: 2)`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl quota check`,`bl quota check --model qwen3.6-plus`,`bl quota check --period 5`,`bl quota check --model qwen3.6-plus,qwen-turbo`,`bl quota check --output json`],async run(e,t){let n=t.model||void 0,r=Number(t.period)||2;r<1&&(process.stderr.write(`Error: --period must be at least 1 minute.
353
- `),process.exit(1));let i=r,a=t.region||`cn-beijing`,o=h(e.output),s=await me(e);if(e.dryRun){P({apis:[mm,hm],region:a},o);return}let c=await dm(e,s.token,a);if(n){let e=new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean));c=c.filter(t=>e.has(t.model))}if(c=c.filter(e=>e.qpmInfo),c.length===0){process.stdout.write(`No models found.
354
- `);return}let l=await Promise.all(c.map(t=>fm(e,s.token,a,t.model,i))),u=c.map((e,t)=>{let n=e.qpmInfo,r=n[`model-default`],i=n[`user-spec`],a=im(i,r?.count_limit_period)||im(r),o=am(i,r?.usage_limit_period)||am(r);return{model:e.model,rpmUsage:l[t].rpm,rpmLimit:a,tpmUsage:l[t].tpm,tpmLimit:o}});if(o===`json`){P(u,o);return}pm(u,e.noColor)}})})),vm=ft({commands:()=>ym}),ym,bm=M((()=>{fo(),mo(),_o(),yo(),xo(),Co(),To(),Do(),ko(),jo(),Lo(),Ho(),Go(),qo(),Yo(),rs(),os(),cs(),us(),Ts(),Ls(),nc(),cp(),up(),Tp(),jp(),Vp(),Yp(),rm(),_m(),ym={"auth login":yi,"auth status":Oi,"auth logout":ji,"text chat":Pi,omni:Ri,"image generate":pa,"image edit":ha,"video generate":ya,"video edit":xa,"video ref":Ca,"video task get":Ta,"video download":Da,"vision describe":Na,"app call":po,"app list":go,"memory add":vo,"memory search":bo,"memory list":So,"memory update":wo,"memory delete":Eo,"memory profile create":Oo,"memory profile get":Ao,"knowledge retrieve":Io,"mcp list":Wo,"mcp tools":Ko,"mcp call":Vo,"search web":Jo,"speech synthesize":ns,"speech recognize":as,"file upload":ss,"console call":ls,"usage free":ws,"usage freetier":Is,"usage stats":tc,"pipeline run":sp,"pipeline validate":lp,"config show":Fa,"config set":Ba,"config export-schema":Ua,"advisor recommend":wp,"workspace list":Ap,"quota list":Bp,"quota request":Jp,"quota history":nm,"quota check":gm,update:uo}}));bm();const xm=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(`
352
+ `)}var _m,vm,ym,bm=M((()=>{I(),hs(),_m=`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,vm=`zeldaEasy.bailian-telemetry.monitor.getMonitorData`,ym=m({name:`quota check`,description:`Check current usage against rate limits`,usage:`bl quota check [--model <model>] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s), comma-separated`},{flag:`--period <minutes>`,description:`Query usage for the last N minutes (default: 2)`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl quota check`,`bl quota check --model qwen3.6-plus`,`bl quota check --period 5`,`bl quota check --model qwen3.6-plus,qwen-turbo`,`bl quota check --output json`],async run(e,t){let n=t.model||void 0,r=Number(t.period)||2;r<1&&(process.stderr.write(`Error: --period must be at least 1 minute.
353
+ `),process.exit(1));let i=r,a=t.region||`cn-beijing`,o=h(e.output),s=await me(e);if(e.dryRun){P({apis:[_m,vm],region:a},o);return}let c=await mm(e,s.token,a);if(n){let e=new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean));c=c.filter(t=>e.has(t.model))}if(c=c.filter(e=>e.qpmInfo),c.length===0){process.stdout.write(`No models found.
354
+ `);return}let l=await Promise.all(c.map(t=>hm(e,s.token,a,t.model,i))),u=c.map((e,t)=>{let n=e.qpmInfo,r=n[`model-default`],i=n[`user-spec`],a=sm(i,r?.count_limit_period)||sm(r),o=cm(i,r?.usage_limit_period)||cm(r);return{model:e.model,rpmUsage:l[t].rpm,rpmLimit:a,tpmUsage:l[t].tpm,tpmLimit:o}});if(o===`json`){P(u,o);return}gm(u,e.noColor)}})})),xm=ft({commands:()=>Sm}),Sm,Cm=M((()=>{ho(),_o(),bo(),So(),wo(),Eo(),Oo(),Ao(),Mo(),Po(),Bo(),Go(),Jo(),Xo(),Qo(),os(),ls(),ds(),ps(),Os(),Bs(),ac(),dp(),pp(),Op(),Pp(),Wp(),Qp(),om(),bm(),Sm={"auth login":yi,"auth status":Oi,"auth logout":ji,"text chat":Pi,omni:Vi,"image generate":ga,"image edit":va,"video generate":Sa,"video edit":wa,"video ref":Ea,"video task get":Oa,"video download":Aa,"vision describe":Ia,"app call":go,"app list":yo,"memory add":xo,"memory search":Co,"memory list":To,"memory update":Do,"memory delete":ko,"memory profile create":jo,"memory profile get":No,"knowledge retrieve":zo,"mcp list":qo,"mcp tools":Yo,"mcp call":Wo,"search web":Zo,"speech synthesize":as,"speech recognize":cs,"file upload":us,"console call":fs,"usage free":Ds,"usage freetier":zs,"usage stats":ic,"pipeline run":up,"pipeline validate":fp,"config show":Ra,"config set":Ua,"config export-schema":Ka,"advisor recommend":Dp,"workspace list":Np,"quota list":Up,"quota request":Zp,"quota history":am,"quota check":ym,update:mo}}));Cm();const wm=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(`
355
355
  `);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(`
356
356
  `)}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(`
357
357
  `)}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){if(e.length===0){this.printRootHelp(t);return}let n=this.root;for(let r of e){let e=n.children.get(r);if(!e){this.printRootHelp(t);return}n=e}if(n.command){this.printCommandHelp(n.command,t);return}let r=e.join(` `);t.write(`\n${this.bold(`Usage:`,t)} bl ${r} <command> [flags]\n\n`),t.write(`${this.bold(`Commands:`,t)}\n`),this.printChildren(n,r,t),r===`pipeline`&&this.printPipelineQuickStart(t),t.write(`
@@ -382,15 +382,15 @@ ${o}
382
382
  ${n(`Getting Help:`)}
383
383
  ${i(`Add --help after any command to see its full list of options, defaults,`)}
384
384
  ${i(`and usage examples. For example:`)} bl text chat --help
385
- `)}printCommandHelp(e,t){let n=e=>this.bold(e,t),r=e=>this.accent(e,t),i=e=>this.dim(e,t);if(t.write(`\n${e.description}\n`),e.usage&&t.write(`${n(`Usage:`)} ${e.usage}\n`),e.options&&e.options.length>0){let a=Math.max(...e.options.map(e=>e.flag.length));t.write(`\n${n(`Options:`)}\n`);for(let n of e.options)t.write(` ${r(n.flag.padEnd(a+2))} ${i(n.description)}\n`)}if(e.examples&&e.examples.length>0){t.write(`\n${n(`Examples:`)}\n`);for(let n of e.examples)t.write(` ${i(n)}\n`)}t.write(`\n${i(`Global flags (--api-key, --output, --quiet, etc.) are always available.`)}\n`),t.write(`${i(`Run`)} bl --help ${i(`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`)}}(ym);function Sm(e,...t){for(let n of t){let t=e[n]?.trim();if(t)return t}}function Cm(e=process.env){return{httpProxy:Sm(e,`http_proxy`,`HTTP_PROXY`),httpsProxy:Sm(e,`https_proxy`,`HTTPS_PROXY`),noProxy:Sm(e,`no_proxy`,`NO_PROXY`)}}function wm(){let{httpProxy:e,httpsProxy:n,noProxy:r}=Cm();if(!(!e&&!n))try{it(new rt({httpProxy:e,httpsProxy:n,noProxy:r}))}catch(e){throw new t(`Invalid proxy configuration: ${e instanceof Error?e.message:String(e)}`,i.USAGE,`Check HTTP_PROXY / HTTPS_PROXY values, e.g. export HTTPS_PROXY=http://127.0.0.1:7890`,{cause:e})}}Et();function Tm(e){return e.padEnd(13)}function Em(e){return e.split(`
385
+ `)}printCommandHelp(e,t){let n=e=>this.bold(e,t),r=e=>this.accent(e,t),i=e=>this.dim(e,t);if(t.write(`\n${e.description}\n`),e.usage&&t.write(`${n(`Usage:`)} ${e.usage}\n`),e.options&&e.options.length>0){let a=Math.max(...e.options.map(e=>e.flag.length));t.write(`\n${n(`Options:`)}\n`);for(let n of e.options)t.write(` ${r(n.flag.padEnd(a+2))} ${i(n.description)}\n`)}if(e.notes&&e.notes.length>0){t.write(`\n${n(`Notes:`)}\n`);for(let n of e.notes)t.write(` ${n}\n`)}if(e.examples&&e.examples.length>0){t.write(`\n${n(`Examples:`)}\n`);for(let n of e.examples)t.write(` ${i(n)}\n`)}t.write(`\n${i(`Global flags (--api-key, --output, --quiet, etc.) are always available.`)}\n`),t.write(`${i(`Run`)} bl --help ${i(`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`)}}(Sm);function Tm(e,...t){for(let n of t){let t=e[n]?.trim();if(t)return t}}function Em(e=process.env){return{httpProxy:Tm(e,`http_proxy`,`HTTP_PROXY`),httpsProxy:Tm(e,`https_proxy`,`HTTPS_PROXY`),noProxy:Tm(e,`no_proxy`,`NO_PROXY`)}}function Dm(){let{httpProxy:e,httpsProxy:n,noProxy:r}=Em();if(!(!e&&!n))try{it(new rt({httpProxy:e,httpsProxy:n,noProxy:r}))}catch(e){throw new t(`Invalid proxy configuration: ${e instanceof Error?e.message:String(e)}`,i.USAGE,`Check HTTP_PROXY / HTTPS_PROXY values, e.g. export HTTPS_PROXY=http://127.0.0.1:7890`,{cause:e})}}Et();function Om(e){return e.padEnd(13)}function km(e){return e.split(`
386
386
  `).map((e,t)=>t===0?e:` `.repeat(13)+e).join(`
387
- `)}function Dm(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: ${Tt}`].filter(e=>e!==void 0).join(`
388
- `):e.hint}function Om(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 h(e[n+1]||t);if(r?.startsWith(`--output=`))return h(r.slice(9))}return h(t)}function km(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,Am(r),{cause:e})}function Am(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.
387
+ `)}function Am(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: ${Tt}`].filter(e=>e!==void 0).join(`
388
+ `):e.hint}function jm(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 h(e[n+1]||t);if(r?.startsWith(`--output=`))return h(r.slice(9))}return h(t)}function Mm(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,Nm(r),{cause:e})}function Nm(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.
389
389
  If you are behind a VPN or corporate proxy, route bl through it:
390
- export HTTPS_PROXY=http://127.0.0.1:<proxy-port>`;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 jm(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 Mm(e){let t=e.cause,n=0;for(;t instanceof Error&&n<5;)process.stderr.write(`${Tm(`Caused by:`)}${t.message}\n`),t=t.cause,n++}function Nm(e){process.stderr.write(`\n${Tm(`Error:`)}${e.message}\n`);let t=Dm(e);t&&process.stderr.write(`${Tm(`Hint:`)}${Em(t)}\n`);let n=e.api;if(n){if(n.httpStatus!==void 0){let e=n.apiCode?` (${n.apiCode})`:``;process.stderr.write(`${Tm(`Status:`)}HTTP ${n.httpStatus}${e}\n`)}else n.apiCode&&process.stderr.write(`${Tm(`Code:`)}${n.apiCode}\n`);n.requestId&&process.stderr.write(`${Tm(`Request ID:`)}${n.requestId}\n`)}Mm(e),process.stderr.write(`${Tm(`Exit code:`)}${e.exitCode}\n`)}function Pm(e){if(e instanceof t&&(Om()===`json`?process.stderr.write(JSON.stringify(e.toJSON(),null,2)+`
391
- `):Nm(e),process.exit(e.exitCode)),e instanceof Error){if(e.name===`AbortError`||e.name===`TimeoutError`||e.message.includes(`timed out`))return Pm(new t(`Request timed out.`,i.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
390
+ export HTTPS_PROXY=http://127.0.0.1:<proxy-port>`;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 Pm(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 Fm(e){let t=e.cause,n=0;for(;t instanceof Error&&n<5;)process.stderr.write(`${Om(`Caused by:`)}${t.message}\n`),t=t.cause,n++}function Im(e){process.stderr.write(`\n${Om(`Error:`)}${e.message}\n`);let t=Am(e);t&&process.stderr.write(`${Om(`Hint:`)}${km(t)}\n`);let n=e.api;if(n){if(n.httpStatus!==void 0){let e=n.apiCode?` (${n.apiCode})`:``;process.stderr.write(`${Om(`Status:`)}HTTP ${n.httpStatus}${e}\n`)}else n.apiCode&&process.stderr.write(`${Om(`Code:`)}${n.apiCode}\n`);n.requestId&&process.stderr.write(`${Om(`Request ID:`)}${n.requestId}\n`)}Fm(e),process.stderr.write(`${Om(`Exit code:`)}${e.exitCode}\n`)}function Lm(e){if(e instanceof t&&(jm()===`json`?process.stderr.write(JSON.stringify(e.toJSON(),null,2)+`
391
+ `):Im(e),process.exit(e.exitCode)),e instanceof Error){if(e.name===`AbortError`||e.name===`TimeoutError`||e.message.includes(`timed out`))return Lm(new t(`Request timed out.`,i.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
392
392
  If this happens on every request with a valid API key, you may be hitting the wrong region.
393
393
  Run: bl auth status — to check your credentials and region.
394
- Run: bl config set --key region --value cn — to override the region.`,{cause:e}));if(e instanceof TypeError&&e.message===`fetch failed`)return Pm(km(e));let n=e.code;if(typeof n==`string`&&n.startsWith(`E`))return Pm(jm(e));process.stderr.write(`\n${Tm(`Error:`)}${e.message}\n`),Mm(e),process.env.DASHSCOPE_VERBOSE===`1`&&process.stderr.write(`${e.stack}\n`)}else process.stderr.write(`\n${Tm(`Error:`)}${String(e)}\n`);process.exit(i.GENERAL)}const Fm=`\x1B[0m`,Im=`\x1B[2m`;function Lm(e){return e.startsWith(at())?e.replace(at(),`~`):e}function Rm(e,t,n){if(e.quiet||!process.stderr.isTTY)return;let r=e.configPath?Lm(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=O(t);process.stderr.write(`BAILIAN${Fm} ${Im}${r}${Fm} ${Im}|${Fm} ${Im}Region:${Fm} ${i}${Fm} ${Im}|${Fm} ${Im}Auth:${Fm} ${o}${Fm} ${Im}${a}${Fm}\n`)}zo(),oo(),jt(),qa(),Rt();try{wm()}catch(e){Pm(e)}Pt((e,t)=>{xm.printHelp(e,t)}),process.on(`SIGINT`,()=>{process.stderr.write(`
394
+ Run: bl config set --key region --value cn — to override the region.`,{cause:e}));if(e instanceof TypeError&&e.message===`fetch failed`)return Lm(Mm(e));let n=e.code;if(typeof n==`string`&&n.startsWith(`E`))return Lm(Pm(e));process.stderr.write(`\n${Om(`Error:`)}${e.message}\n`),Fm(e),process.env.DASHSCOPE_VERBOSE===`1`&&process.stderr.write(`${e.stack}\n`)}else process.stderr.write(`\n${Om(`Error:`)}${String(e)}\n`);process.exit(i.GENERAL)}const Rm=`\x1B[0m`,zm=`\x1B[2m`;function Bm(e){return e.startsWith(at())?e.replace(at(),`~`):e}function Vm(e,t,n){if(e.quiet||!process.stderr.isTTY)return;let r=e.configPath?Bm(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=O(t);process.stderr.write(`BAILIAN${Rm} ${zm}${r}${Rm} ${zm}|${Rm} ${zm}Region:${Rm} ${i}${Rm} ${zm}|${Rm} ${zm}Auth:${Rm} ${o}${Rm} ${zm}${a}${Rm}\n`)}Ho(),lo(),jt(),Xa(),Rt();try{Dm()}catch(e){Lm(e)}Pt((e,t)=>{wm.printHelp(e,t)}),process.on(`SIGINT`,()=>{process.stderr.write(`
395
395
  Interrupted. Exiting.
396
- `),_(500).finally(()=>process.exit(130))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e});const zm=[[`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`],[`usage`,`freetier`],[`usage`,`stats`],[`mcp`,`list`],[`mcp`,`tools`],[`mcp`,`call`],[`workspace`,`list`],[`quota`,`list`],[`quota`,`request`],[`quota`,`history`],[`quota`,`check`]];async function Bm(){let e=process.argv.slice(2);e[0]===`--`&&(e=e.slice(1)),(e.includes(`--version`)||e.includes(`-v`))&&(process.stdout.write(`bl ${Ka}\n`),process.exit(0));let t=xt(e,a);if((e.includes(`--help`)||e.includes(`-h`))&&(xm.printHelp(t,process.stderr),process.exit(0)),t.length===0){xm.printHelp([],process.stderr);let t=te(St(e,a));t.clientName=`bailian-cli`,t.clientVersion=Ka,t.apiKey||t.fileApiKey||t.fileAccessToken||t.accessTokenEnv?kt():Ot(),process.exit(0)}xm.isGroupPath(t)&&(xm.printHelp(t,process.stderr),process.exit(0));let{command:n,extra:r}=xm.resolve(t),i=St(e,[...a,...n.options??[]]);r.length>0&&(i._positional=r);let o=te(i);if(o.clientName=`bailian-cli`,o.clientVersion=Ka,!zm.some(e=>e.every((e,n)=>t[n]===e))){await Ro(o);try{let e=await A(o);Rm(o,e.token,e)}catch{}}let s=$a(Ka).catch(()=>{});Mt(t),t[0]===`auth`&&t[1]===`login`&&!i.console&&!String(i.apiKey??``).trim()&&!String(o.apiKey??``).trim()&&!process.env.DASHSCOPE_API_KEY?.trim()&&(Ft(process.stderr),process.exit(0)),await Se(o,t,i,()=>n.execute(o,i)),await s;let c=t.length===1&&t[0]===`update`,l=Qa();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: ${Ka} → ${l}${r}\n`),process.stderr.write(` Run ${n}bl update${r} to upgrade\n\n`)}await _(1e3)}Bm().catch(e=>{_(1e3).finally(()=>Pm(e))});export{};
396
+ `),_(500).finally(()=>process.exit(130))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e});const Hm=[[`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`],[`usage`,`freetier`],[`usage`,`stats`],[`mcp`,`list`],[`mcp`,`tools`],[`mcp`,`call`],[`workspace`,`list`],[`quota`,`list`],[`quota`,`request`],[`quota`,`history`],[`quota`,`check`]];async function Um(){let e=process.argv.slice(2);e[0]===`--`&&(e=e.slice(1)),(e.includes(`--version`)||e.includes(`-v`))&&(process.stdout.write(`bl ${Ya}\n`),process.exit(0));let t=xt(e,a);if((e.includes(`--help`)||e.includes(`-h`))&&(wm.printHelp(t,process.stderr),process.exit(0)),t.length===0){wm.printHelp([],process.stderr);let t=te(St(e,a));t.clientName=`bailian-cli`,t.clientVersion=Ya,t.apiKey||t.fileApiKey||t.fileAccessToken||t.accessTokenEnv?kt():Ot(),process.exit(0)}wm.isGroupPath(t)&&(wm.printHelp(t,process.stderr),process.exit(0));let{command:n,extra:r}=wm.resolve(t),i=St(e,[...a,...n.options??[]]);r.length>0&&(i._positional=r);let o=te(i);if(o.clientName=`bailian-cli`,o.clientVersion=Ya,!Hm.some(e=>e.every((e,n)=>t[n]===e))){await Vo(o);try{let e=await A(o);Vm(o,e.token,e)}catch{}}let s=no(Ya).catch(()=>{});Mt(t),t[0]===`auth`&&t[1]===`login`&&!i.console&&!String(i.apiKey??``).trim()&&!String(o.apiKey??``).trim()&&!process.env.DASHSCOPE_API_KEY?.trim()&&(Ft(process.stderr),process.exit(0)),await Se(o,t,i,()=>n.execute(o,i)),await s;let c=t.length===1&&t[0]===`update`,l=to();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: ${Ya} → ${l}${r}\n`),process.stderr.write(` Run ${n}bl update${r} to upgrade\n\n`)}await _(1e3)}Um().catch(e=>{_(1e3).finally(()=>Lm(e))});export{};