bailian-cli-runtime 1.14.0 → 1.14.2

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/index.mjs +20 -20
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import{a as e,c as t,d as n,f as r,h as i,i as a,l as o,m as s,o as c,p as l,r as u,s as d,t as f,u as p}from"./binary-update-Dxwl7hbM.mjs";import{BailianError as m,COMMAND_PACK_API_VERSION as h,CONSOLE_AUTH_FLAGS as g,Client as _,DEFAULT_INSTALL_PS1_URL as v,DEFAULT_INSTALL_SCRIPT_URL as y,ExitCode as b,GLOBAL_FLAGS as x,MODEL_AUTH_FLAGS as S,OPENAPI_AUTH_FLAGS as C,UsageError as w,buildSettings as T,buildSources as E,chatPath as D,credentialFlagDefs as O,describeAuthState as k,detectOutputFormat as A,flushTelemetry as j,formatOutput as ee,getConfigDir as te,getUpdateInstallMethod as M,isCompiledBinary as ne,isLocalFile as N,makeAuthStore as re,makeConfigStore as ie,maskToken as ae,resolveApiKey as oe,resolveBooleanFlag as se,resolveConsole as ce,resolveImageEditApi as le,resolveImageGenerateApi as ue,resolveModelBaseUrl as de,resolveOpenApi as fe,resolveWatermark as pe,speechRecognizePath as me,speechSynthesizePath as he,stripUndefined as ge,taskPath as _e,trackCommandExecution as ve,trackingHeaders as ye,videoGeneratePath as be}from"bailian-cli-core";import{homedir as xe}from"os";import{dirname as Se,join as Ce}from"path";import{createWriteStream as we,mkdirSync as Te,readFileSync as Ee,unlinkSync as De,writeFileSync as Oe}from"fs";import{EnvHttpProxyAgent as ke,setGlobalDispatcher as Ae}from"undici";import{existsSync as je}from"node:fs";import{access as Me,mkdir as Ne,open as Pe,readFile as Fe,realpath as Ie,stat as Le,unlink as Re,writeFile as ze}from"node:fs/promises";import{isAbsolute as Be,join as P,relative as Ve,resolve as He}from"node:path";import{pathToFileURL as Ue}from"node:url";import{spawn as We,spawnSync as Ge}from"node:child_process";var Ke=Object.create,qe=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Ye=Object.getOwnPropertyNames,Xe=Object.getPrototypeOf,Ze=Object.prototype.hasOwnProperty,F=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Qe=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Ye(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ze.call(e,s)&&s!==n&&qe(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Je(t,s))||r.enumerable});return e},$e=(e,t,n)=>(n=e==null?{}:Ke(Xe(e)),Qe(t||!e||!e.__esModule?qe(n,`default`,{value:e,enumerable:!0}):n,e));function et(e){return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function tt(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function nt(e){let t=0;for(;t<e.length&&!e[t].startsWith(`-`);)t++;let n=e.slice(t);return{path:e.slice(0,t),rest:n,hasHelpFlag:n.includes(`--help`),hasVersionFlag:n.includes(`--version`)}}function rt(e,t){let n={},r=new Set;for(let[e,r]of Object.entries(t))r.type===`switch`&&(n[e]=!1);let i=0;for(;i<e.length;){let a=e[i];if(!a.startsWith(`-`))throw new w(`Unexpected argument: ${a}`);if(!a.startsWith(`--`))throw new w(`Unknown flag "${a}". Use the --long form.`);let o=a.indexOf(`=`),s=o===-1?a.slice(2):a.slice(2,o),c=o===-1?void 0:a.slice(o+1);if(s===``)throw new w(`Unknown flag "${a}".`);let l=et(s),u=t[l];if(!u)throw new w(`Unknown flag "--${s}". Run with --help to see available options.`);if(u.type===`switch`){if(c!==void 0)throw new w(`Flag --${s} is a switch and takes no value.`);n[l]=!0,i++;continue}if(c===void 0){let t=e[i+1];if(t===void 0||t.startsWith(`--`))throw new w(`Flag --${s} requires a value.`);c=t,i+=2}else i+=1;if(u.choices&&!u.choices.includes(c))throw new w(`Flag --${s} must be one of: ${u.choices.join(`, `)}.`);if(u.type===`array`){let e=n[l];e?e.push(c):n[l]=[c];continue}if(r.has(l))throw new w(`Flag --${s} given more than once.`);if(r.add(l),u.type===`number`){let e=Number(c);if(!Number.isFinite(e))throw new w(`Flag --${s} requires a finite number.`);n[l]=e}else if(u.type===`boolean`){let e=c.trim().toLowerCase();if(e===`true`)n[l]=!0;else if(e===`false`)n[l]=!1;else throw new w(`Flag --${s} requires true or false.`)}else n[l]=c}let a=Object.entries(t).filter(([e,t])=>t.type!==`switch`&&t.required===!0&&n[e]===void 0).map(([e])=>`--${tt(e)}`);if(a.length>0)throw new w(`Missing required ${a.length>1?`flags`:`flag`}: ${a.join(`, `)}`);return n}const it=e=>e;function I(e,t){return e?e=>`\x1b[${t}m${e}\x1b[0m`:it}function at(e){return e.isTTY===!0}function ot(e){return!(`NO_COLOR`in process.env)&&at(e)}function L(e){let t=ot(e);return{bold:I(t,`1`),dim:I(t,`2`),green:I(t,`32`),yellow:I(t,`33`),red:I(t,`31`),cyan:I(t,`36`),blue:I(t,`34`),magenta:I(t,`35`),white:I(t,`37`),accent:I(t,`38;2;59;130;246`),logo:I(t,`38;2;97;92;237`),purple:I(t,`38;2;147;51;234`),brandBlue:I(t,`1;38;2;43;82;255`),keyPink:I(t,`38;2;236;72;153`),reset:t?`\x1B[0m`:``}}function st(e,t){let n=`--${tt(e)}`;return t.type===`switch`?n:`${n} ${t.choices?`<${t.choices.join(`|`)}>`:t.valueHint}`}var ct=class{root={children:new Map};cliName;authRequirements=new Set;constructor(e,t){this.cliName=t;for(let[t,n]of Object.entries(e))this.register(t,n)}register(e,t){let n={...x,...O(t)};for(let r of Object.keys(t.flags??{}))if(r in n)throw Error(`Command "${e}" redeclares reserved flag "${r}".`);let r=e.split(` `),i=this.root;for(let e of r)i.children.has(e)||i.children.set(e,{children:new Map}),i=i.children.get(e);i.command=t,this.authRequirements.add(t.auth)}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}helpExample(){let e=(t,n)=>{for(let[r,i]of t.children){if(i.command)return[...n,r].join(` `);let t=e(i,[...n,r]);if(t)return t}return null};return e(this.root,[])??`<resource> <command>`}locate(e){let t=this.root,n=[];for(let r of e){let e=t.children.get(r);if(!e)break;t=e,n.push(r)}if(t.command){let r=e.slice(n.length);return r.length===0?{kind:`leaf`,command:t.command,matched:n}:{kind:`unknown`,error:new w(`Unexpected argument: ${r.join(` `)}`,`${this.cliName} ${n.join(` `)} --help`)}}if(n.length===e.length&&t.children.size>0)return{kind:`group`,matched:n};if(n.length>0&&t.children.size>0){let r=Array.from(t.children.entries()).map(([e,t])=>{if(t.command)return` ${n.join(` `)} ${e} ${t.command.description}`;let r=Array.from(t.children.keys()).join(`, `);return` ${n.join(` `)} ${e} [${r}]`}).join(`
1
+ import{a as e,c as t,d as n,f as r,h as i,i as a,l as o,m as s,o as c,p as l,r as u,s as d,t as f,u as p}from"./binary-update-Dxwl7hbM.mjs";import{BailianError as m,COMMAND_PACK_API_VERSION as h,CONSOLE_AUTH_FLAGS as g,Client as _,DEFAULT_INSTALL_PS1_URL as v,DEFAULT_INSTALL_SCRIPT_URL as y,ExitCode as b,GLOBAL_FLAGS as x,MODEL_AUTH_FLAGS as S,OPENAPI_AUTH_FLAGS as C,UsageError as w,buildSettings as T,buildSources as E,chatPath as D,credentialFlagDefs as O,describeAuthState as k,detectOutputFormat as A,flushTelemetry as j,formatOutput as ee,getConfigDir as te,getUpdateInstallMethod as M,isCompiledBinary as ne,isLocalFile as N,makeAuthStore as re,makeConfigStore as ie,maskToken as ae,resolveApiKey as oe,resolveBooleanFlag as se,resolveConsole as ce,resolveImageEditApi as le,resolveImageGenerateApi as ue,resolveModelBaseUrl as de,resolveOpenApi as fe,resolveWatermark as pe,speechRecognizePath as me,speechSynthesizePath as he,stripUndefined as ge,taskPath as _e,trackCommandExecution as ve,videoGeneratePath as ye}from"bailian-cli-core";import{homedir as be}from"os";import{dirname as xe,join as Se}from"path";import{createWriteStream as Ce,mkdirSync as we,readFileSync as Te,unlinkSync as Ee,writeFileSync as De}from"fs";import{EnvHttpProxyAgent as Oe,setGlobalDispatcher as ke}from"undici";import{existsSync as Ae}from"node:fs";import{access as je,mkdir as Me,open as Ne,readFile as Pe,realpath as Fe,stat as Ie,unlink as Le,writeFile as Re}from"node:fs/promises";import{isAbsolute as ze,join as P,relative as Be,resolve as Ve}from"node:path";import{pathToFileURL as He}from"node:url";import{spawn as Ue,spawnSync as We}from"node:child_process";var Ge=Object.create,Ke=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,Je=Object.getOwnPropertyNames,Ye=Object.getPrototypeOf,Xe=Object.prototype.hasOwnProperty,F=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Ze=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Je(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Xe.call(e,s)&&s!==n&&Ke(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=qe(t,s))||r.enumerable});return e},Qe=(e,t,n)=>(n=e==null?{}:Ge(Ye(e)),Ze(t||!e||!e.__esModule?Ke(n,`default`,{value:e,enumerable:!0}):n,e));function $e(e){return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function et(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function tt(e){let t=0;for(;t<e.length&&!e[t].startsWith(`-`);)t++;let n=e.slice(t);return{path:e.slice(0,t),rest:n,hasHelpFlag:n.includes(`--help`),hasVersionFlag:n.includes(`--version`)}}function nt(e,t){let n={},r=new Set;for(let[e,r]of Object.entries(t))r.type===`switch`&&(n[e]=!1);let i=0;for(;i<e.length;){let a=e[i];if(!a.startsWith(`-`))throw new w(`Unexpected argument: ${a}`);if(!a.startsWith(`--`))throw new w(`Unknown flag "${a}". Use the --long form.`);let o=a.indexOf(`=`),s=o===-1?a.slice(2):a.slice(2,o),c=o===-1?void 0:a.slice(o+1);if(s===``)throw new w(`Unknown flag "${a}".`);let l=$e(s),u=t[l];if(!u)throw new w(`Unknown flag "--${s}". Run with --help to see available options.`);if(u.type===`switch`){if(c!==void 0)throw new w(`Flag --${s} is a switch and takes no value.`);n[l]=!0,i++;continue}if(c===void 0){let t=e[i+1];if(t===void 0||t.startsWith(`--`))throw new w(`Flag --${s} requires a value.`);c=t,i+=2}else i+=1;if(u.choices&&!u.choices.includes(c))throw new w(`Flag --${s} must be one of: ${u.choices.join(`, `)}.`);if(u.type===`array`){let e=n[l];e?e.push(c):n[l]=[c];continue}if(r.has(l))throw new w(`Flag --${s} given more than once.`);if(r.add(l),u.type===`number`){let e=Number(c);if(!Number.isFinite(e))throw new w(`Flag --${s} requires a finite number.`);n[l]=e}else if(u.type===`boolean`){let e=c.trim().toLowerCase();if(e===`true`)n[l]=!0;else if(e===`false`)n[l]=!1;else throw new w(`Flag --${s} requires true or false.`)}else n[l]=c}let a=Object.entries(t).filter(([e,t])=>t.type!==`switch`&&t.required===!0&&n[e]===void 0).map(([e])=>`--${et(e)}`);if(a.length>0)throw new w(`Missing required ${a.length>1?`flags`:`flag`}: ${a.join(`, `)}`);return n}const rt=e=>e;function I(e,t){return e?e=>`\x1b[${t}m${e}\x1b[0m`:rt}function it(e){return e.isTTY===!0}function at(e){return!(`NO_COLOR`in process.env)&&it(e)}function L(e){let t=at(e);return{bold:I(t,`1`),dim:I(t,`2`),green:I(t,`32`),yellow:I(t,`33`),red:I(t,`31`),cyan:I(t,`36`),blue:I(t,`34`),magenta:I(t,`35`),white:I(t,`37`),accent:I(t,`38;2;59;130;246`),logo:I(t,`38;2;97;92;237`),purple:I(t,`38;2;147;51;234`),brandBlue:I(t,`1;38;2;43;82;255`),keyPink:I(t,`38;2;236;72;153`),reset:t?`\x1B[0m`:``}}function ot(e,t){let n=`--${et(e)}`;return t.type===`switch`?n:`${n} ${t.choices?`<${t.choices.join(`|`)}>`:t.valueHint}`}var st=class{root={children:new Map};cliName;authRequirements=new Set;constructor(e,t){this.cliName=t;for(let[t,n]of Object.entries(e))this.register(t,n)}register(e,t){let n={...x,...O(t)};for(let r of Object.keys(t.flags??{}))if(r in n)throw Error(`Command "${e}" redeclares reserved flag "${r}".`);let r=e.split(` `),i=this.root;for(let e of r)i.children.has(e)||i.children.set(e,{children:new Map}),i=i.children.get(e);i.command=t,this.authRequirements.add(t.auth)}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}helpExample(){let e=(t,n)=>{for(let[r,i]of t.children){if(i.command)return[...n,r].join(` `);let t=e(i,[...n,r]);if(t)return t}return null};return e(this.root,[])??`<resource> <command>`}locate(e){let t=this.root,n=[];for(let r of e){let e=t.children.get(r);if(!e)break;t=e,n.push(r)}if(t.command){let r=e.slice(n.length);return r.length===0?{kind:`leaf`,command:t.command,matched:n}:{kind:`unknown`,error:new w(`Unexpected argument: ${r.join(` `)}`,`${this.cliName} ${n.join(` `)} --help`)}}if(n.length===e.length&&t.children.size>0)return{kind:`group`,matched:n};if(n.length>0&&t.children.size>0){let r=Array.from(t.children.entries()).map(([e,t])=>{if(t.command)return` ${n.join(` `)} ${e} ${t.command.description}`;let r=Array.from(t.children.keys()).join(`, `);return` ${n.join(` `)} ${e} [${r}]`}).join(`
2
2
  `);return{kind:`unknown`,error:new w(`Unknown command: ${this.cliName} ${e.join(` `)}\n\nAvailable commands:\n${r}`,`${this.cliName} ${n.join(` `)} --help`)}}return{kind:`unknown`,error:new w(`Unknown command: ${this.cliName} ${e.join(` `)}`,`${this.cliName} --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(`
3
- `)}buildFlagLines(e,t,n){let r=Object.entries(e).map(([e,t])=>({flag:st(e,t),desc:t.description})),i=Math.max(...r.map(e=>e.flag.length));return r.map(e=>` ${t(e.flag.padEnd(i+2))} ${n(e.desc)}`).join(`
3
+ `)}buildFlagLines(e,t,n){let r=Object.entries(e).map(([e,t])=>({flag:ot(e,t),desc:t.description})),i=Math.max(...r.map(e=>e.flag.length));return r.map(e=>` ${t(e.flag.padEnd(i+2))} ${n(e.desc)}`).join(`
4
4
  `)}buildAuthFlagSection(e,t,n,r,i,a,o){return this.authRequirements.has(e)?`${i(t)} ${o(n)}\n${this.buildFlagLines(r,a,o)}`:null}bold=(e,t)=>L(t).bold(e);accent=(e,t)=>L(t).accent(e);dim=(e,t)=>L(t).dim(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,e,t);return}let r=e.join(` `);t.write(`\n${this.bold(`Usage:`,t)} ${this.cliName} ${r} <command> [flags]\n\n`),t.write(`${this.bold(`Commands:`,t)}\n`),this.printChildren(n,r,t),r===`pipeline`&&this.printPipelineQuickStart(t),t.write(`
5
5
  `)}printPipelineQuickStart(e){let t=t=>this.bold(t,e),n=t=>this.dim(t,e);e.write(`
6
6
  ${t(`Minimal workflow.yaml:`)}
@@ -30,30 +30,30 @@ ${s}
30
30
  ${c?`${c}\n\n`:``}${r(`Getting Help:`)}
31
31
  ${a(`Add --help after any command to see its full list of flags, defaults,`)}
32
32
  ${a(`and usage examples. For example:`)} ${this.cliName} ${this.helpExample()} --help
33
- `)}printCommandHelp(e,t,n){let r=e=>this.bold(e,n),i=e=>this.accent(e,n),a=e=>this.dim(e,n),o=[this.cliName,...t].join(` `);n.write(`\n${e.description}\n`),n.write(`${r(`Usage:`)} ${o}${e.usageArgs?` ${e.usageArgs}`:``}\n`);let s=[...Object.entries(e.flags??{}),...Object.entries(O(e))];if(s.length>0){let e=s.map(([e,t])=>({flag:st(e,t),desc:t.description})),t=Math.max(...e.map(e=>e.flag.length));n.write(`\n${r(`Flags:`)}\n`);for(let r of e)n.write(` ${i(r.flag.padEnd(t+2))} ${a(r.desc)}\n`)}if(n.write(`\n${r(`Global Flags:`)}\n`),n.write(this.buildFlagLines(x,i,a)+`
34
- `),e.notes&&e.notes.length>0){n.write(`\n${r(`Notes:`)}\n`);for(let t of e.notes)n.write(` ${t}\n`)}if(e.exampleArgs&&e.exampleArgs.length>0){n.write(`\n${r(`Examples:`)}\n`);for(let t of e.exampleArgs)n.write(` ${a(t?`${o} ${t}`:o)}\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`)}};function lt(e,t){let{path:n,rest:r,hasHelpFlag:i,hasVersionFlag:a}=nt(e);if(a)return{kind:`version`};let o=t.locate(n);switch(o.kind){case`leaf`:return i?{kind:`help`,path:o.matched}:{kind:`run`,path:o.matched,command:o.command,rest:r};case`group`:return{kind:`help`,path:o.matched};case`unknown`:return{kind:`usageError`,error:o.error}}}function ut(e){return e.startsWith(xe())?e.replace(xe(),`~`):e}function dt(e,t,n){if(e.quiet||!at(process.stderr))return;let r=e.configPath?ut(e.configPath):`~/.bailian/config.json`,i=`${n.source} · api-key`,a=ae(t),o=L(process.stderr);process.stderr.write(`${o.brandBlue(`BAILIAN`)} ${o.dim(r)} ${o.dim(`|`)} ${o.dim(`Auth:`)} ${o.keyPink(a)} ${o.dim(i)}\n`)}const ft=`https://registry.npmjs.org`,pt=`bailian-cli`,mt=()=>Ce(te(),`update-state.json`),ht=3e3;function gt(e){let t=String(e).split(`+`)[0].split(`-`)[0].trim().split(`.`).map(e=>{let t=Number(e);return Number.isFinite(t)?t:0});return[t[0]??0,t[1]??0,t[2]??0]}function _t(e){let t=String(e).split(`+`)[0],n=t.indexOf(`-`);return n>=0?t.slice(n+1):``}function vt(e){return _t(e)!==``}function yt(e){return e.length>0&&/^[0-9]+$/.test(e)}function bt(e,t){let n=e?e.split(`.`):[],r=t?t.split(`.`):[];if(n.length===0&&r.length===0)return 0;if(n.length===0)return 1;if(r.length===0)return-1;let i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=n[e],i=r[e];if(t===void 0)return-1;if(i===void 0)return 1;let a=yt(t),o=yt(i);if(a&&o){let e=Number(t)-Number(i);if(e!==0)return e>0?1:-1}else if(a!==o)return a?-1:1;else if(t!==i)return t>i?1:-1}return 0}function xt(e,t){let[n,r,i]=gt(e),[a,o,s]=gt(t);return n===a?r===o?i===s?bt(_t(e),_t(t)):i>s?1:-1:r>o?1:-1:n>a?1:-1}function St(e,t){return xt(e,t)>0}function Ct(e,t){return kt(e,t)&&!vt(e)}function wt(){try{let e=Ee(mt(),`utf-8`);return JSON.parse(e)}catch{return null}}function Tt(e){try{Oe(mt(),JSON.stringify(e))}catch{}}async function Et(e=ht,t=pt){try{let n=t.replace(`/`,`%2f`),r=await fetch(`${ft}/${n}/latest`,{headers:{Accept:`application/json`,...ye()},signal:AbortSignal.timeout(e)});return r.ok?(await r.json()).version??null:null}catch{return null}}let Dt=null;function Ot(){return Dt}function kt(e,t){let[n,r]=gt(e),[i,a]=gt(t);return n>i||n===i&&r-a>3}function At(e){return e instanceof Error?e.message:String(e)}async function jt(e,t,n=pt,r=pt){let i=process.stderr.isTTY,a=i?`\x1B[32m`:``,o=i?`\x1B[33m`:``,s=i?`\x1B[36m`:``,c=i?`\x1B[2m`:``,l=i?`\x1B[0m`:``,u=M({clientName:r,npmPackage:n});if(u===`brew`||u===`winget`)return!1;let[d]=gt(t),[f]=gt(e),p=d>f;if(process.stderr.write(`
35
- `),process.stderr.write(` ${o}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${l}\n`),p?process.stderr.write(` ${o}⚡ Major update detected: ${e} → ${t}${l}\n`):process.stderr.write(` ${o}⚡ Significant update detected: ${e} → ${t}${l}\n`),process.stderr.write(` ${c}Auto-updating to keep your CLI up to date...${l}\n`),process.stderr.write(` ${o}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${l}\n\n`),u===`binary`)try{let{performBinaryUpdate:n}=await import(`./binary-update-B9ti3hFP.mjs`),r=await n(t);return Tt({lastChecked:Date.now(),latestVersion:r}),process.stderr.write(` ${a}✓ Update complete: ${e} → ${r}${l}\n`),process.stderr.write(` ${c}Run ${s}bl --version${l}${c} to verify.${l}\n\n`),Dt=null,!0}catch(e){process.stderr.write(` ${o}⚠ Auto-update failed: ${At(e)}${l}\n`);let t=e instanceof m&&e.hint?e.hint.replace(/^Re-run:\s*/i,``):process.platform===`win32`?`irm ${v} | iex`:`curl -fsSL ${y} | bash`;return process.stderr.write(` ${o} Re-run:${l} ${s}${t}${l}\n\n`),!1}let h=`npm install -g ${n}@latest`;try{let{execSync:r}=await import(`child_process`);r(h,{stdio:`inherit`});let i=null;try{let e=Ee(Ce(r(`npm root -g`,{encoding:`utf-8`}).trim(),n,`package.json`),`utf-8`);i=JSON.parse(e).version??null}catch(e){process.stderr.write(` ${o}⚠ Could not verify installed version: ${At(e)}${l}\n`)}Tt({lastChecked:Date.now(),latestVersion:i??t}),process.stderr.write(` ${a}✓ Update complete: ${e} → ${i??t}${l}\n`),process.stderr.write(` ${c}Run ${s}bl --version${l}${c} to verify.${l}\n\n`);try{process.stderr.write(` ${c}Syncing agent skill...${l}\n`),r(`npx skills add modelstudioai/cli --all -g -y`,{stdio:`inherit`}),process.stderr.write(` ${a}✓ Agent skill updated.${l}\n\n`)}catch(e){process.stderr.write(` ${o}⚠ Agent skill sync failed: ${At(e)}${l}\n`),process.stderr.write(` ${o} Run manually: npx skills add modelstudioai/cli --all -g -y${l}\n\n`)}return Dt=null,!0}catch(e){return process.stderr.write(` ${o}⚠ Auto-update failed: ${At(e)}${l}\n`),process.stderr.write(` ${o} If this is a permissions error (EACCES), retry with sudo or fix npm perms.${l}\n`),process.stderr.write(` ${o} Run manually:${l} ${s}${h}${l}\n\n`),!1}}async function Mt(e,t=pt,n=pt){let r=wt(),i=Date.now();if(r&&i-r.lastChecked<864e5)return;let a=M({clientName:n,npmPackage:t}),o=null;if(a===`binary`){try{let{fetchBinaryChannelVersion:e}=await import(`./binary-update-B9ti3hFP.mjs`);o=await e(`latest`,ht)}catch{o=null}o||=await Et(ht,t)}else o=await Et(ht,t);o&&(Tt({lastChecked:i,latestVersion:o}),o&&St(o,e)&&(Dt=o))}function Nt(e){return t=>{let n=r=>{let i=e[r];return i?i(t,()=>n(r+1)):Promise.resolve()};return n(0)}}const Pt=async(e,t)=>{let{command:n,settings:r,sources:i}=e,a={identity:e.identity,settings:r,baseUrl:de(i)};if(n.auth===`apiKey`){let t;try{t=oe(i)}catch(e){if(!r.dryRun)throw e}e.client=new _({...a,apiCred:t}),t&&dt(r,t.token,t)}else if(n.auth===`console`){let t;try{t=ce(i)}catch(e){if(!r.dryRun)throw e}t&&(e.client=new _({...a,consoleCred:t}))}else if(n.auth===`openapi`){let t;try{t=fe(i)}catch(e){if(!r.dryRun)throw e}e.client=new _({...a,openApiCred:t})}await t()},Ft=(e,t)=>ve({identity:e.identity,settings:e.settings,authMethod:e.command.auth},e.path,e.flags,t),It=async(e,t)=>{let n=Mt(e.identity.version,e.identity.npmPackage,e.identity.clientName).catch(()=>{});await t(),await n;let r=e.path.length===1&&e.path[0]===`update`,i=Ot();if(i&&!e.settings.quiet&&!r)if(Ct(i,e.identity.version))await jt(e.identity.version,i,e.identity.npmPackage,e.identity.clientName);else{let t=L(process.stderr);process.stderr.write(`\n ${t.yellow(`Update available: ${e.identity.version} → ${i}`)}\n`),process.stderr.write(` Run ${t.cyan(`${e.identity.binName} update`)} to upgrade\n\n`)}},Lt=e=>e.command.run(e);function Rt(e,t){return e[t]?.trim()||void 0}function zt(e=process.env){return{httpProxy:Rt(e,`HTTP_PROXY`),httpsProxy:Rt(e,`HTTPS_PROXY`),noProxy:Rt(e,`NO_PROXY`)}}function Bt(){let{httpProxy:e,httpsProxy:t,noProxy:n}=zt();if(!(!e&&!t))try{Ae(new ke({httpProxy:e,httpsProxy:t,noProxy:n}))}catch(e){throw new m(`Invalid proxy configuration: ${e instanceof Error?e.message:String(e)}`,b.USAGE,`Check HTTP_PROXY / HTTPS_PROXY values, e.g. export HTTPS_PROXY=http://127.0.0.1:7890`,{cause:e})}}const Vt=`https://bailian.console.aliyun.com`,Ht=`${Vt}/cn-beijing`,Ut=`${Ht}/?tab=app#/api-key`,Wt=`${Vt}/cn-beijing?tab=plan#/efm/subscription/overview`;function Gt(e){return`${Ht}?tab=mcp#/mcp-market/detail/${e}`}const Kt=Gt(`WebSearch`),qt=`https://help.aliyun.com/zh/model-studio/cosyvoice-voice-list`;let R;function Jt(){return`If the DashScope host is wrong, check baseUrl (--base-url, ${R} config show, or DASHSCOPE_BASE_URL).`}function z(e){return e.padEnd(13)}function Yt(e){return e.split(`
33
+ `)}printCommandHelp(e,t,n){let r=e=>this.bold(e,n),i=e=>this.accent(e,n),a=e=>this.dim(e,n),o=[this.cliName,...t].join(` `);n.write(`\n${e.description}\n`),n.write(`${r(`Usage:`)} ${o}${e.usageArgs?` ${e.usageArgs}`:``}\n`);let s=[...Object.entries(e.flags??{}),...Object.entries(O(e))];if(s.length>0){let e=s.map(([e,t])=>({flag:ot(e,t),desc:t.description})),t=Math.max(...e.map(e=>e.flag.length));n.write(`\n${r(`Flags:`)}\n`);for(let r of e)n.write(` ${i(r.flag.padEnd(t+2))} ${a(r.desc)}\n`)}if(n.write(`\n${r(`Global Flags:`)}\n`),n.write(this.buildFlagLines(x,i,a)+`
34
+ `),e.notes&&e.notes.length>0){n.write(`\n${r(`Notes:`)}\n`);for(let t of e.notes)n.write(` ${t}\n`)}if(e.exampleArgs&&e.exampleArgs.length>0){n.write(`\n${r(`Examples:`)}\n`);for(let t of e.exampleArgs)n.write(` ${a(t?`${o} ${t}`:o)}\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`)}};function ct(e,t){let{path:n,rest:r,hasHelpFlag:i,hasVersionFlag:a}=tt(e);if(a)return{kind:`version`};let o=t.locate(n);switch(o.kind){case`leaf`:return i?{kind:`help`,path:o.matched}:{kind:`run`,path:o.matched,command:o.command,rest:r};case`group`:return{kind:`help`,path:o.matched};case`unknown`:return{kind:`usageError`,error:o.error}}}function lt(e){return e.startsWith(be())?e.replace(be(),`~`):e}function ut(e,t,n){if(e.quiet||!it(process.stderr))return;let r=e.configPath?lt(e.configPath):`~/.bailian/config.json`,i=`${n.source} · api-key`,a=ae(t),o=L(process.stderr);process.stderr.write(`${o.brandBlue(`BAILIAN`)} ${o.dim(r)} ${o.dim(`|`)} ${o.dim(`Auth:`)} ${o.keyPink(a)} ${o.dim(i)}\n`)}const dt=`https://registry.npmjs.org`,ft=`bailian-cli`,pt=()=>Se(te(),`update-state.json`),mt=3e3;function ht(e){let t=String(e).split(`+`)[0].split(`-`)[0].trim().split(`.`).map(e=>{let t=Number(e);return Number.isFinite(t)?t:0});return[t[0]??0,t[1]??0,t[2]??0]}function gt(e){let t=String(e).split(`+`)[0],n=t.indexOf(`-`);return n>=0?t.slice(n+1):``}function _t(e){return gt(e)!==``}function vt(e){return e.length>0&&/^[0-9]+$/.test(e)}function yt(e,t){let n=e?e.split(`.`):[],r=t?t.split(`.`):[];if(n.length===0&&r.length===0)return 0;if(n.length===0)return 1;if(r.length===0)return-1;let i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=n[e],i=r[e];if(t===void 0)return-1;if(i===void 0)return 1;let a=vt(t),o=vt(i);if(a&&o){let e=Number(t)-Number(i);if(e!==0)return e>0?1:-1}else if(a!==o)return a?-1:1;else if(t!==i)return t>i?1:-1}return 0}function bt(e,t){let[n,r,i]=ht(e),[a,o,s]=ht(t);return n===a?r===o?i===s?yt(gt(e),gt(t)):i>s?1:-1:r>o?1:-1:n>a?1:-1}function xt(e,t){return bt(e,t)>0}function St(e,t){return Ot(e,t)&&!_t(e)}function Ct(){try{let e=Te(pt(),`utf-8`);return JSON.parse(e)}catch{return null}}function wt(e){try{De(pt(),JSON.stringify(e))}catch{}}async function Tt(e=mt,t=ft){try{let n=t.replace(`/`,`%2f`),r=await fetch(`${dt}/${n}/latest`,{headers:{Accept:`application/json`},signal:AbortSignal.timeout(e)});return r.ok?(await r.json()).version??null:null}catch{return null}}let Et=null;function Dt(){return Et}function Ot(e,t){let[n,r]=ht(e),[i,a]=ht(t);return n>i||n===i&&r-a>3}function kt(e){return e instanceof Error?e.message:String(e)}async function At(e,t,n=ft,r=ft){let i=process.stderr.isTTY,a=i?`\x1B[32m`:``,o=i?`\x1B[33m`:``,s=i?`\x1B[36m`:``,c=i?`\x1B[2m`:``,l=i?`\x1B[0m`:``,u=M({clientName:r,npmPackage:n});if(u===`brew`||u===`winget`)return!1;let[d]=ht(t),[f]=ht(e),p=d>f;if(process.stderr.write(`
35
+ `),process.stderr.write(` ${o}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${l}\n`),p?process.stderr.write(` ${o}⚡ Major update detected: ${e} → ${t}${l}\n`):process.stderr.write(` ${o}⚡ Significant update detected: ${e} → ${t}${l}\n`),process.stderr.write(` ${c}Auto-updating to keep your CLI up to date...${l}\n`),process.stderr.write(` ${o}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${l}\n\n`),u===`binary`)try{let{performBinaryUpdate:n}=await import(`./binary-update-B9ti3hFP.mjs`),r=await n(t);return wt({lastChecked:Date.now(),latestVersion:r}),process.stderr.write(` ${a}✓ Update complete: ${e} → ${r}${l}\n`),process.stderr.write(` ${c}Run ${s}bl --version${l}${c} to verify.${l}\n\n`),Et=null,!0}catch(e){process.stderr.write(` ${o}⚠ Auto-update failed: ${kt(e)}${l}\n`);let t=e instanceof m&&e.hint?e.hint.replace(/^Re-run:\s*/i,``):process.platform===`win32`?`irm ${v} | iex`:`curl -fsSL ${y} | bash`;return process.stderr.write(` ${o} Re-run:${l} ${s}${t}${l}\n\n`),!1}let h=`npm install -g ${n}@latest`;try{let{execSync:r}=await import(`child_process`);r(h,{stdio:`inherit`});let i=null;try{let e=Te(Se(r(`npm root -g`,{encoding:`utf-8`}).trim(),n,`package.json`),`utf-8`);i=JSON.parse(e).version??null}catch(e){process.stderr.write(` ${o}⚠ Could not verify installed version: ${kt(e)}${l}\n`)}wt({lastChecked:Date.now(),latestVersion:i??t}),process.stderr.write(` ${a}✓ Update complete: ${e} → ${i??t}${l}\n`),process.stderr.write(` ${c}Run ${s}bl --version${l}${c} to verify.${l}\n\n`);try{process.stderr.write(` ${c}Syncing agent skill...${l}\n`),r(`npx skills add modelstudioai/cli --all -g -y`,{stdio:`inherit`}),process.stderr.write(` ${a}✓ Agent skill updated.${l}\n\n`)}catch(e){process.stderr.write(` ${o}⚠ Agent skill sync failed: ${kt(e)}${l}\n`),process.stderr.write(` ${o} Run manually: npx skills add modelstudioai/cli --all -g -y${l}\n\n`)}return Et=null,!0}catch(e){return process.stderr.write(` ${o}⚠ Auto-update failed: ${kt(e)}${l}\n`),process.stderr.write(` ${o} If this is a permissions error (EACCES), retry with sudo or fix npm perms.${l}\n`),process.stderr.write(` ${o} Run manually:${l} ${s}${h}${l}\n\n`),!1}}async function jt(e,t=ft,n=ft){let r=Ct(),i=Date.now();if(r&&i-r.lastChecked<864e5)return;let a=M({clientName:n,npmPackage:t}),o=null;if(a===`binary`){try{let{fetchBinaryChannelVersion:e}=await import(`./binary-update-B9ti3hFP.mjs`);o=await e(`latest`,mt)}catch{o=null}o||=await Tt(mt,t)}else o=await Tt(mt,t);o&&(wt({lastChecked:i,latestVersion:o}),o&&xt(o,e)&&(Et=o))}function Mt(e){return t=>{let n=r=>{let i=e[r];return i?i(t,()=>n(r+1)):Promise.resolve()};return n(0)}}const Nt=async(e,t)=>{let{command:n,settings:r,sources:i}=e,a={identity:e.identity,settings:r,baseUrl:de(i)};if(n.auth===`apiKey`){let t;try{t=oe(i)}catch(e){if(!r.dryRun)throw e}e.client=new _({...a,apiCred:t}),t&&ut(r,t.token,t)}else if(n.auth===`console`){let t;try{t=ce(i)}catch(e){if(!r.dryRun)throw e}t&&(e.client=new _({...a,consoleCred:t}))}else if(n.auth===`openapi`){let t;try{t=fe(i)}catch(e){if(!r.dryRun)throw e}e.client=new _({...a,openApiCred:t})}await t()},Pt=(e,t)=>ve({identity:e.identity,settings:e.settings,authMethod:e.command.auth},e.path,e.flags,t),Ft=async(e,t)=>{let n=jt(e.identity.version,e.identity.npmPackage,e.identity.clientName).catch(()=>{});await t(),await n;let r=e.path.length===1&&e.path[0]===`update`,i=Dt();if(i&&!e.settings.quiet&&!r)if(St(i,e.identity.version))await At(e.identity.version,i,e.identity.npmPackage,e.identity.clientName);else{let t=L(process.stderr);process.stderr.write(`\n ${t.yellow(`Update available: ${e.identity.version} → ${i}`)}\n`),process.stderr.write(` Run ${t.cyan(`${e.identity.binName} update`)} to upgrade\n\n`)}},It=e=>e.command.run(e);function Lt(e,t){return e[t]?.trim()||void 0}function Rt(e=process.env){return{httpProxy:Lt(e,`HTTP_PROXY`),httpsProxy:Lt(e,`HTTPS_PROXY`),noProxy:Lt(e,`NO_PROXY`)}}function zt(){let{httpProxy:e,httpsProxy:t,noProxy:n}=Rt();if(!(!e&&!t))try{ke(new Oe({httpProxy:e,httpsProxy:t,noProxy:n}))}catch(e){throw new m(`Invalid proxy configuration: ${e instanceof Error?e.message:String(e)}`,b.USAGE,`Check HTTP_PROXY / HTTPS_PROXY values, e.g. export HTTPS_PROXY=http://127.0.0.1:7890`,{cause:e})}}const Bt=`https://bailian.console.aliyun.com`,Vt=`${Bt}/cn-beijing`,Ht=`${Vt}/?tab=app#/api-key`,Ut=`${Bt}/cn-beijing?tab=plan#/efm/subscription/overview`;function Wt(e){return`${Vt}?tab=mcp#/mcp-market/detail/${e}`}const Gt=Wt(`WebSearch`),Kt=`https://help.aliyun.com/zh/model-studio/cosyvoice-voice-list`;let R;function qt(){return`If the DashScope host is wrong, check baseUrl (--base-url, ${R} config show, or DASHSCOPE_BASE_URL).`}function z(e){return e.padEnd(13)}function Jt(e){return e.split(`
36
36
  `).map((e,t)=>t===0?e:` `.repeat(13)+e).join(`
37
- `)}function Xt(e){return e.exitCode===b.AUTH?Zt(e.hint)?e.hint:[e.hint,``,`${R} auth login --api-key <your-key>`,`${R} auth status`,`Get API Key: ${Ut}`].filter(e=>e!==void 0).join(`
38
- `):e.hint}function Zt(e){return e?e.includes(`auth login --console`)||e.includes(`auth login --open-api`)||e.includes(`--access-key-id`)||e.includes(`ALIBABA_CLOUD_ACCESS_KEY_`):!1}function Qt(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 A(e[n+1]||t);if(r?.startsWith(`--output=`))return A(r.slice(9))}return A(t)}function $t(e){let t=e.cause,n=t?.code,r=t?.message,i=[];return n&&i.push(n),r&&r!==n&&i.push(r),new m(`Network request failed: ${i.length>0?i.join(`: `):`unknown cause`}`,b.NETWORK,en(n),{cause:e})}function en(e){switch(e){case`ENOTFOUND`:case`EAI_AGAIN`:return`DNS resolution failed. Check DNS / network. ${Jt()}`;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.
39
- If you are behind a VPN or corporate proxy, route ${R} through it:\nexport HTTPS_PROXY=http://127.0.0.1:<proxy-port>`;case`ETIMEDOUT`:return`Connection timed out. Check your network. ${Jt()}`;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 and proxy (HTTP_PROXY / HTTPS_PROXY). ${Jt()}`}}function tn(e){let t=e.code,n=`Check the file path and permissions.`;return t===`ENOENT`?n=`File or directory not found.`:t===`EACCES`||t===`EPERM`?n=`Permission denied — check file or directory permissions.`:t===`ENOSPC`&&(n=`Disk full — free up space and try again.`),new m(`File system error: ${e.message}`,b.GENERAL,n,{cause:e})}function nn(e){let t=e.cause,n=0;for(;t instanceof Error&&n<5;)process.stderr.write(`${z(`Caused by:`)}${t.message}\n`),t=t.cause,n++}function rn(e){process.stderr.write(`\n${z(`Error:`)}${e.message}\n`);let t=Xt(e);t&&process.stderr.write(`${z(`Hint:`)}${Yt(t)}\n`);let n=e.api;if(n){if(n.httpStatus!==void 0){let e=n.apiCode?` (${n.apiCode})`:``;process.stderr.write(`${z(`Status:`)}HTTP ${n.httpStatus}${e}\n`)}else n.apiCode&&process.stderr.write(`${z(`Code:`)}${n.apiCode}\n`);n.requestId&&process.stderr.write(`${z(`Request ID:`)}${n.requestId}\n`)}nn(e),process.stderr.write(`${z(`Exit code:`)}${e.exitCode}\n`)}function B(e,t){if(R=t,e instanceof m&&(Qt()===`json`?process.stderr.write(JSON.stringify(e.toJSON(),null,2)+`
40
- `):rn(e),process.exit(e.exitCode)),e instanceof Error){if(e.name===`AbortError`||e.name===`TimeoutError`||e.message.includes(`timed out`))return B(new m(`Request timed out.`,b.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
41
- ${Jt()}\nRun: ${R} auth status — to check credentials.`,{cause:e}),R);if(e instanceof TypeError&&e.message===`fetch failed`)return B($t(e),R);let t=e.code;if(typeof t==`string`&&t.startsWith(`E`))return B(tn(e),R);process.stderr.write(`\n${z(`Error:`)}${e.message}\n`),nn(e),process.env.DASHSCOPE_VERBOSE===`1`&&process.stderr.write(`${e.stack}\n`)}else process.stderr.write(`\n${z(`Error:`)}${String(e)}\n`);process.exit(b.GENERAL)}function an(e){let t=L(process.stderr);process.stderr.write(`\n Welcome to ${t.purple(`Bailian`)} CLI!\n\n`),process.stderr.write(` Get started in 2 steps:
42
- `),process.stderr.write(` 1. Get your API Key: ${Ut}\n`),process.stderr.write(` 2. Login: ${e} auth login --api-key <your-key>\n\n`),process.stderr.write(` Token Plan:
43
- `),process.stderr.write(` 1. Get your API Key: ${Wt}\n`),process.stderr.write(` 2. Login: ${e} auth login --config token-plan --api-key <your-key>\n\n`)}function on(e){let t=L(process.stderr);process.stderr.write(`
37
+ `)}function Yt(e){return e.exitCode===b.AUTH?Xt(e.hint)?e.hint:[e.hint,``,`${R} auth login --api-key <your-key>`,`${R} auth status`,`Get API Key: ${Ht}`].filter(e=>e!==void 0).join(`
38
+ `):e.hint}function Xt(e){return e?e.includes(`auth login --console`)||e.includes(`auth login --open-api`)||e.includes(`--access-key-id`)||e.includes(`ALIBABA_CLOUD_ACCESS_KEY_`):!1}function Zt(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 A(e[n+1]||t);if(r?.startsWith(`--output=`))return A(r.slice(9))}return A(t)}function Qt(e){let t=e.cause,n=t?.code,r=t?.message,i=[];return n&&i.push(n),r&&r!==n&&i.push(r),new m(`Network request failed: ${i.length>0?i.join(`: `):`unknown cause`}`,b.NETWORK,$t(n),{cause:e})}function $t(e){switch(e){case`ENOTFOUND`:case`EAI_AGAIN`:return`DNS resolution failed. Check DNS / network. ${qt()}`;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.
39
+ If you are behind a VPN or corporate proxy, route ${R} through it:\nexport HTTPS_PROXY=http://127.0.0.1:<proxy-port>`;case`ETIMEDOUT`:return`Connection timed out. Check your network. ${qt()}`;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 and proxy (HTTP_PROXY / HTTPS_PROXY). ${qt()}`}}function en(e){let t=e.code,n=`Check the file path and permissions.`;return t===`ENOENT`?n=`File or directory not found.`:t===`EACCES`||t===`EPERM`?n=`Permission denied — check file or directory permissions.`:t===`ENOSPC`&&(n=`Disk full — free up space and try again.`),new m(`File system error: ${e.message}`,b.GENERAL,n,{cause:e})}function tn(e){let t=e.cause,n=0;for(;t instanceof Error&&n<5;)process.stderr.write(`${z(`Caused by:`)}${t.message}\n`),t=t.cause,n++}function nn(e){process.stderr.write(`\n${z(`Error:`)}${e.message}\n`);let t=Yt(e);t&&process.stderr.write(`${z(`Hint:`)}${Jt(t)}\n`);let n=e.api;if(n){if(n.httpStatus!==void 0){let e=n.apiCode?` (${n.apiCode})`:``;process.stderr.write(`${z(`Status:`)}HTTP ${n.httpStatus}${e}\n`)}else n.apiCode&&process.stderr.write(`${z(`Code:`)}${n.apiCode}\n`);n.requestId&&process.stderr.write(`${z(`Request ID:`)}${n.requestId}\n`)}tn(e),process.stderr.write(`${z(`Exit code:`)}${e.exitCode}\n`)}function B(e,t){if(R=t,e instanceof m&&(Zt()===`json`?process.stderr.write(JSON.stringify(e.toJSON(),null,2)+`
40
+ `):nn(e),process.exit(e.exitCode)),e instanceof Error){if(e.name===`AbortError`||e.name===`TimeoutError`||e.message.includes(`timed out`))return B(new m(`Request timed out.`,b.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
41
+ ${qt()}\nRun: ${R} auth status — to check credentials.`,{cause:e}),R);if(e instanceof TypeError&&e.message===`fetch failed`)return B(Qt(e),R);let t=e.code;if(typeof t==`string`&&t.startsWith(`E`))return B(en(e),R);process.stderr.write(`\n${z(`Error:`)}${e.message}\n`),tn(e),process.env.DASHSCOPE_VERBOSE===`1`&&process.stderr.write(`${e.stack}\n`)}else process.stderr.write(`\n${z(`Error:`)}${String(e)}\n`);process.exit(b.GENERAL)}function rn(e){let t=L(process.stderr);process.stderr.write(`\n Welcome to ${t.purple(`Bailian`)} CLI!\n\n`),process.stderr.write(` Get started in 2 steps:
42
+ `),process.stderr.write(` 1. Get your API Key: ${Ht}\n`),process.stderr.write(` 2. Login: ${e} auth login --api-key <your-key>\n\n`),process.stderr.write(` Token Plan:
43
+ `),process.stderr.write(` 1. Get your API Key: ${Ut}\n`),process.stderr.write(` 2. Login: ${e} auth login --config token-plan --api-key <your-key>\n\n`)}function an(e){let t=L(process.stderr);process.stderr.write(`
44
44
  🎯 Try these with your AI coding assistant:
45
45
 
46
46
  `),e.forEach((e,n)=>{process.stderr.write(`${t.dim(String(n+1))} ${e}\n`)}),process.stderr.write(`
47
- `)}function sn(e){return P(te(),`plugins`,e.npmPackage)}function cn(e){return P(sn(e),`package.json`)}function ln(e,t){return P(sn(e),`node_modules`,...t.split(`/`))}async function un(e){try{return JSON.parse(await Fe(e,`utf8`))}catch(t){throw new m(`Could not parse JSON file: ${e}`,b.GENERAL,`Repair or remove the invalid file and try again.`,{cause:t})}}async function dn(e){let t=cn(e);return je(t)?un(t):{dependencies:{}}}async function fn(e,t){return pn(ln(e,t))}async function pn(e){return un(P(e,`package.json`))}const mn=new Set([`none`,`apiKey`,`console`,`openapi`]),hn=/^[a-z0-9][a-z0-9-]*$/;function gn(e,t,n){if(t.name!==e)throw Error(`Package name mismatch: expected "${e}", received "${t.name??``}".`);let r=t.bailianCli;if(!r||r.type!==`command-pack`)throw Error(`Package "${e}" is missing bailianCli.type="command-pack".`);if(r.apiVersion!==h)throw Error(`Command Pack API ${r.apiVersion} is not supported; this CLI supports API ${h}.`);if(r.minCliVersion&&xt(n.version,r.minCliVersion)<0)throw Error(`Command Pack requires ${n.npmPackage} ${r.minCliVersion} or newer; current version is ${n.version}.`);if(!r.entry||Be(r.entry))throw Error(`Command Pack "${e}" must declare a relative bailianCli.entry.`);return r}function _n(e,t){let n=e.split(/\s+/).filter(Boolean).join(` `);if(!e||e!==n||!e.split(` `).every(e=>hn.test(e)))throw Error(`Invalid command path "${e}".`);if(!t.commandPrefixes.some(t=>e===t||e.startsWith(`${t} `)))throw Error(`Command "${e}" is outside the allowed prefixes: ${t.commandPrefixes.join(`, `)}.`)}function vn(e,t){if(!t||typeof t!=`object`)throw Error(`Command "${e}" must export an object.`);let n=t;if(!n.description||typeof n.description!=`string`)throw Error(`Command "${e}" is missing a description.`);if(!n.auth||!mn.has(n.auth))throw Error(`Command "${e}" has an invalid auth requirement.`);if(typeof n.run!=`function`)throw Error(`Command "${e}" is missing run(ctx).`)}function yn(e,t,n){return Object.fromEntries(Object.entries(t).map(([t,r])=>[t,{description:r.description,auth:r.auth,usageArgs:r.usageArgs,exampleArgs:r.exampleArgs,notes:r.notes,flags:r.flags,validate:r.validate,run:i=>{let a={identity:i.identity,settings:i.settings,flags:i.flags,client:i.client,output:{result(e,t){let n=i.settings.output===`text`&&t?.text!==void 0?t.text:ee(e,i.settings.output);process.stdout.write(`${n}\n`)},line(e){process.stdout.write(`${e}\n`)},write(e){process.stdout.write(e)}},errors:{general(e,t){return new m(e,b.GENERAL,t?.hint,{cause:t?.cause})},usage(e,t){return new w(e,t)},timeout(e=`Request timed out.`,t){return new m(e,b.TIMEOUT,t?.hint,{cause:t?.cause})}},credentials:{apiKey(){if(!n.credentialAccess?.includes(`apiKey`))throw new m(`Command Pack "${e}" is not allowed to access API-key credentials.`,b.GENERAL);if(r.auth!==`apiKey`)throw new m(`Command "${t}" must declare auth="apiKey" before accessing API-key credentials.`,b.GENERAL);let a=i.authStore.describe().apiKey;if(!a)throw new m(`No API key available to the Command Pack.`,b.AUTH);return a}}};return r.run(a)}}]))}async function bn(e,t,n,r,i=ln(r,e)){let a=gn(e,t,r),o=await Ie(i),s=await Ie(He(o,a.entry)),c=Ve(o,s);if(!c||c.startsWith(`..`)||Be(c))throw Error(`Command Pack entry must stay inside the package root: ${a.entry}`);let l=(await import(Ue(s).href)).default;if(!l||typeof l!=`object`||Array.isArray(l))throw Error(`Command Pack "${e}" must default-export a command map.`);let u=Object.entries(l);if(u.length===0)throw Error(`Command Pack "${e}" does not export any commands.`);for(let[e,t]of u)_n(e,n),vn(e,t);let d=yn(e,l,n);return new ct(d,r.binName),d}function xn(e){return e.startsWith(`file:`)?`linked`:`installed`}async function Sn(e,t,n){let r={...e},i=[],a;try{a=await dn(t)}catch(e){return{commands:r,reports:[{name:`(plugin sandbox)`,source:`installed`,status:`failed`,commands:[],error:e instanceof Error?e.message:String(e)}]}}for(let[e,o]of Object.entries(a.dependencies??{}).sort(([e],[t])=>e.localeCompare(t))){let a=xn(o),s=n.supported[e];if(!s){i.push({name:e,source:a,status:`failed`,commands:[],error:`Command Pack "${e}" is not supported by ${t.binName}.`});continue}try{let n=await fn(t,e),o=await bn(e,n,s,t),c=Object.keys(o).filter(e=>e in r);if(c.length>0)throw Error(`Command conflicts: ${c.join(`, `)}.`);Object.assign(r,o),i.push({name:e,version:n.version,source:a,status:`loaded`,commands:Object.keys(o).sort()})}catch(t){i.push({name:e,source:a,status:`failed`,commands:[],error:t instanceof Error?t.message:String(t)})}}return{commands:r,reports:i}}const Cn={name:`bailian-cli-command-packs`,private:!0,dependencies:{}},wn=new Set(`PATH.HOME.USER.LOGNAME.SHELL.TMPDIR.TEMP.TMP.LANG.TERM.NODE.NODE_PATH.NODE_OPTIONS.FORCE_COLOR.NO_COLOR.NPM_TOKEN.NODE_AUTH_TOKEN.HTTP_PROXY.HTTPS_PROXY.NO_PROXY.http_proxy.https_proxy.no_proxy.SystemRoot.ComSpec.APPDATA.PATHEXT`.split(`.`)),Tn=new Set([`registry`,`userconfig`,`globalconfig`,`cache`,`proxy`,`https_proxy`,`noproxy`,`strict_ssl`,`ca`,`cafile`]);function En(e){let t=/^(?:npm_config_|NPM_CONFIG_)(.+)$/.exec(e);return!!t&&Tn.has(t[1].toLowerCase())}function Dn(e,t){let n=Object.keys(t.supported);return n.length>0?`Allowed packages: ${n.join(`, `)}`:`${e.binName} does not currently support any Command Packs.`}function On(e=process.env){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(wn.has(n)||n.startsWith(`LC_`)||En(n))&&(t[n]=r);return t}async function kn(e){await Ne(e,{recursive:!0,mode:448});let t=P(e,`package.json`);je(t)||await ze(t,`${JSON.stringify(Cn,null,2)}\n`,{mode:384})}async function An(e,t){if(Ge(`npm`,[`--version`],{encoding:`utf-8`}).status!==0){let e=ne()?"Command Packs need a local npm. Install Node.js, or use `npm install -g bailian-cli` instead of the binary install.":`Install Node.js / npm and retry.`;throw new m(`npm is required to install, link, or remove Command Packs, but was not found on PATH.`,b.GENERAL,e)}await new Promise((n,r)=>{let i=We(`npm`,e,{cwd:t,env:On(),stdio:[`inherit`,`pipe`,`pipe`]});i.stdout.on(`data`,e=>process.stderr.write(e)),i.stderr.on(`data`,e=>process.stderr.write(e)),i.once(`error`,r),i.once(`close`,(t,i)=>{if(t===0){n();return}r(new m(`npm ${e[0]} failed${i?` with signal ${i}`:` with exit code ${t}`}.`,b.GENERAL))})})}async function jn(e){let t=sn(e);await kn(t);let n=P(t,`.lock`);for(let e=0;e<2;e++)try{let e=await Pe(n,`wx`,384);return await e.writeFile(`${process.pid} ${Date.now()}\n`),await e.close(),async()=>{try{await Re(n)}catch{}}}catch(e){if(e.code!==`EEXIST`)throw e;try{let e=await Le(n);if(Date.now()-e.mtimeMs>6e5){await Re(n);continue}}catch{continue}throw new m(`Another Command Pack install, link, or remove operation is already running.`,b.GENERAL,`Wait for it to finish and try again.`)}throw new m(`Could not acquire the Command Pack operation lock.`,b.GENERAL)}async function Mn(e,t){let n=await jn(e);try{return await t()}finally{await n()}}function Nn(e,t,n){let r=e.trim(),i=/^(@[^/\s]+\/[^@/\s]+)(?:@([a-zA-Z0-9][a-zA-Z0-9._-]*))?$/.exec(r);if(!i)throw new m(`Unsupported Command Pack package spec: "${e}".`,b.USAGE,`Use an allowlisted scoped package name with an optional version or tag.`);let a=i[1];if(!n.supported[a])throw new m(`Command Pack "${a}" is not allowlisted for ${t.binName}.`,b.USAGE,Dn(t,n));return{name:a,requested:r}}async function Pn(e,t,n,r){let i=r.supported[e],a=await pn(t);return{pjson:a,commands:await bn(e,a,i,n,t)}}function Fn(e,t){return t.startsWith(`file:`)?t:`${e}@${t}`}async function In(e,t,n){if(t){await An([`install`,Fn(e,t),`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],n);return}await An([`uninstall`,e,`--ignore-scripts`,`--no-fund`,`--no-audit`],n)}async function Ln(e,t,n){let{name:r,requested:i}=Nn(e,t,n);return Mn(t,async()=>{let e=sn(t),a=(await dn(t)).dependencies?.[r];try{await An([`install`,i,`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],e);let a=await Pn(r,ln(t,r),t,n);if(!a.pjson.version)throw new m(`Command Pack "${r}" has no package version.`,b.USAGE);return{name:r,version:a.pjson.version,commands:Object.keys(a.commands).sort()}}catch(t){try{await In(r,a,e)}catch{}throw t}})}async function Rn(e,t,n){let r=He(e);if(!je(P(r,`package.json`)))throw new m(`Command Pack path does not exist: ${r}`,b.USAGE);let i=(await pn(r)).name;if(!i||!n.supported[i])throw new m(`Local package "${i??`(unnamed)`}" is not an allowlisted Command Pack for ${t.binName}.`,b.USAGE,Dn(t,n));let a=await Pn(i,r,t,n);return Mn(t,async()=>{await An([`install`,`file:${r}`,`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],sn(t));let e=await Pn(i,ln(t,i),t,n);return{name:i,version:e.pjson.version??a.pjson.version,commands:Object.keys(e.commands).sort()}})}async function zn(e,t,n){if(!n.supported[e])throw new m(`Command Pack "${e}" is not allowlisted for ${t.binName}.`,b.USAGE,Dn(t,n));if(!(e in((await dn(t)).dependencies??{})))throw new m(`Command Pack "${e}" is not installed.`,b.USAGE);await Mn(t,()=>An([`uninstall`,e,`--ignore-scripts`,`--no-fund`,`--no-audit`],sn(t)))}async function Bn(e,t){return(await Sn({},e,t)).reports}function Vn(e,t){return{install:n=>Ln(n,e,t),link:n=>Rn(n,e,t),list:()=>Bn(e,t),remove:n=>zn(n,e,t)}}function Hn(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function Un(e){try{Bt()}catch(t){B(t,e)}process.on(`SIGINT`,()=>{process.stderr.write(`
47
+ `)}function on(e){return P(te(),`plugins`,e.npmPackage)}function sn(e){return P(on(e),`package.json`)}function cn(e,t){return P(on(e),`node_modules`,...t.split(`/`))}async function ln(e){try{return JSON.parse(await Pe(e,`utf8`))}catch(t){throw new m(`Could not parse JSON file: ${e}`,b.GENERAL,`Repair or remove the invalid file and try again.`,{cause:t})}}async function un(e){let t=sn(e);return Ae(t)?ln(t):{dependencies:{}}}async function dn(e,t){return fn(cn(e,t))}async function fn(e){return ln(P(e,`package.json`))}const pn=new Set([`none`,`apiKey`,`console`,`openapi`]),mn=/^[a-z0-9][a-z0-9-]*$/;function hn(e,t,n){if(t.name!==e)throw Error(`Package name mismatch: expected "${e}", received "${t.name??``}".`);let r=t.bailianCli;if(!r||r.type!==`command-pack`)throw Error(`Package "${e}" is missing bailianCli.type="command-pack".`);if(r.apiVersion!==h)throw Error(`Command Pack API ${r.apiVersion} is not supported; this CLI supports API ${h}.`);if(r.minCliVersion&&bt(n.version,r.minCliVersion)<0)throw Error(`Command Pack requires ${n.npmPackage} ${r.minCliVersion} or newer; current version is ${n.version}.`);if(!r.entry||ze(r.entry))throw Error(`Command Pack "${e}" must declare a relative bailianCli.entry.`);return r}function gn(e,t){let n=e.split(/\s+/).filter(Boolean).join(` `);if(!e||e!==n||!e.split(` `).every(e=>mn.test(e)))throw Error(`Invalid command path "${e}".`);if(!t.commandPrefixes.some(t=>e===t||e.startsWith(`${t} `)))throw Error(`Command "${e}" is outside the allowed prefixes: ${t.commandPrefixes.join(`, `)}.`)}function _n(e,t){if(!t||typeof t!=`object`)throw Error(`Command "${e}" must export an object.`);let n=t;if(!n.description||typeof n.description!=`string`)throw Error(`Command "${e}" is missing a description.`);if(!n.auth||!pn.has(n.auth))throw Error(`Command "${e}" has an invalid auth requirement.`);if(typeof n.run!=`function`)throw Error(`Command "${e}" is missing run(ctx).`)}function vn(e,t,n){return Object.fromEntries(Object.entries(t).map(([t,r])=>[t,{description:r.description,auth:r.auth,usageArgs:r.usageArgs,exampleArgs:r.exampleArgs,notes:r.notes,flags:r.flags,validate:r.validate,run:i=>{let a={identity:i.identity,settings:i.settings,flags:i.flags,client:i.client,output:{result(e,t){let n=i.settings.output===`text`&&t?.text!==void 0?t.text:ee(e,i.settings.output);process.stdout.write(`${n}\n`)},line(e){process.stdout.write(`${e}\n`)},write(e){process.stdout.write(e)}},errors:{general(e,t){return new m(e,b.GENERAL,t?.hint,{cause:t?.cause})},usage(e,t){return new w(e,t)},timeout(e=`Request timed out.`,t){return new m(e,b.TIMEOUT,t?.hint,{cause:t?.cause})}},credentials:{apiKey(){if(!n.credentialAccess?.includes(`apiKey`))throw new m(`Command Pack "${e}" is not allowed to access API-key credentials.`,b.GENERAL);if(r.auth!==`apiKey`)throw new m(`Command "${t}" must declare auth="apiKey" before accessing API-key credentials.`,b.GENERAL);let a=i.authStore.describe().apiKey;if(!a)throw new m(`No API key available to the Command Pack.`,b.AUTH);return a}}};return r.run(a)}}]))}async function yn(e,t,n,r,i=cn(r,e)){let a=hn(e,t,r),o=await Fe(i),s=await Fe(Ve(o,a.entry)),c=Be(o,s);if(!c||c.startsWith(`..`)||ze(c))throw Error(`Command Pack entry must stay inside the package root: ${a.entry}`);let l=(await import(He(s).href)).default;if(!l||typeof l!=`object`||Array.isArray(l))throw Error(`Command Pack "${e}" must default-export a command map.`);let u=Object.entries(l);if(u.length===0)throw Error(`Command Pack "${e}" does not export any commands.`);for(let[e,t]of u)gn(e,n),_n(e,t);let d=vn(e,l,n);return new st(d,r.binName),d}function bn(e){return e.startsWith(`file:`)?`linked`:`installed`}async function xn(e,t,n){let r={...e},i=[],a;try{a=await un(t)}catch(e){return{commands:r,reports:[{name:`(plugin sandbox)`,source:`installed`,status:`failed`,commands:[],error:e instanceof Error?e.message:String(e)}]}}for(let[e,o]of Object.entries(a.dependencies??{}).sort(([e],[t])=>e.localeCompare(t))){let a=bn(o),s=n.supported[e];if(!s){i.push({name:e,source:a,status:`failed`,commands:[],error:`Command Pack "${e}" is not supported by ${t.binName}.`});continue}try{let n=await dn(t,e),o=await yn(e,n,s,t),c=Object.keys(o).filter(e=>e in r);if(c.length>0)throw Error(`Command conflicts: ${c.join(`, `)}.`);Object.assign(r,o),i.push({name:e,version:n.version,source:a,status:`loaded`,commands:Object.keys(o).sort()})}catch(t){i.push({name:e,source:a,status:`failed`,commands:[],error:t instanceof Error?t.message:String(t)})}}return{commands:r,reports:i}}const Sn={name:`bailian-cli-command-packs`,private:!0,dependencies:{}},Cn=new Set(`PATH.HOME.USER.LOGNAME.SHELL.TMPDIR.TEMP.TMP.LANG.TERM.NODE.NODE_PATH.NODE_OPTIONS.FORCE_COLOR.NO_COLOR.NPM_TOKEN.NODE_AUTH_TOKEN.HTTP_PROXY.HTTPS_PROXY.NO_PROXY.http_proxy.https_proxy.no_proxy.SystemRoot.ComSpec.APPDATA.PATHEXT`.split(`.`)),wn=new Set([`registry`,`userconfig`,`globalconfig`,`cache`,`proxy`,`https_proxy`,`noproxy`,`strict_ssl`,`ca`,`cafile`]);function Tn(e){let t=/^(?:npm_config_|NPM_CONFIG_)(.+)$/.exec(e);return!!t&&wn.has(t[1].toLowerCase())}function En(e,t){let n=Object.keys(t.supported);return n.length>0?`Allowed packages: ${n.join(`, `)}`:`${e.binName} does not currently support any Command Packs.`}function Dn(e=process.env){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(Cn.has(n)||n.startsWith(`LC_`)||Tn(n))&&(t[n]=r);return t}async function On(e){await Me(e,{recursive:!0,mode:448});let t=P(e,`package.json`);Ae(t)||await Re(t,`${JSON.stringify(Sn,null,2)}\n`,{mode:384})}async function kn(e,t){if(We(`npm`,[`--version`],{encoding:`utf-8`}).status!==0){let e=ne()?"Command Packs need a local npm. Install Node.js, or use `npm install -g bailian-cli` instead of the binary install.":`Install Node.js / npm and retry.`;throw new m(`npm is required to install, link, or remove Command Packs, but was not found on PATH.`,b.GENERAL,e)}await new Promise((n,r)=>{let i=Ue(`npm`,e,{cwd:t,env:Dn(),stdio:[`inherit`,`pipe`,`pipe`]});i.stdout.on(`data`,e=>process.stderr.write(e)),i.stderr.on(`data`,e=>process.stderr.write(e)),i.once(`error`,r),i.once(`close`,(t,i)=>{if(t===0){n();return}r(new m(`npm ${e[0]} failed${i?` with signal ${i}`:` with exit code ${t}`}.`,b.GENERAL))})})}async function An(e){let t=on(e);await On(t);let n=P(t,`.lock`);for(let e=0;e<2;e++)try{let e=await Ne(n,`wx`,384);return await e.writeFile(`${process.pid} ${Date.now()}\n`),await e.close(),async()=>{try{await Le(n)}catch{}}}catch(e){if(e.code!==`EEXIST`)throw e;try{let e=await Ie(n);if(Date.now()-e.mtimeMs>6e5){await Le(n);continue}}catch{continue}throw new m(`Another Command Pack install, link, or remove operation is already running.`,b.GENERAL,`Wait for it to finish and try again.`)}throw new m(`Could not acquire the Command Pack operation lock.`,b.GENERAL)}async function jn(e,t){let n=await An(e);try{return await t()}finally{await n()}}function Mn(e,t,n){let r=e.trim(),i=/^(@[^/\s]+\/[^@/\s]+)(?:@([a-zA-Z0-9][a-zA-Z0-9._-]*))?$/.exec(r);if(!i)throw new m(`Unsupported Command Pack package spec: "${e}".`,b.USAGE,`Use an allowlisted scoped package name with an optional version or tag.`);let a=i[1];if(!n.supported[a])throw new m(`Command Pack "${a}" is not allowlisted for ${t.binName}.`,b.USAGE,En(t,n));return{name:a,requested:r}}async function Nn(e,t,n,r){let i=r.supported[e],a=await fn(t);return{pjson:a,commands:await yn(e,a,i,n,t)}}function Pn(e,t){return t.startsWith(`file:`)?t:`${e}@${t}`}async function Fn(e,t,n){if(t){await kn([`install`,Pn(e,t),`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],n);return}await kn([`uninstall`,e,`--ignore-scripts`,`--no-fund`,`--no-audit`],n)}async function In(e,t,n){let{name:r,requested:i}=Mn(e,t,n);return jn(t,async()=>{let e=on(t),a=(await un(t)).dependencies?.[r];try{await kn([`install`,i,`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],e);let a=await Nn(r,cn(t,r),t,n);if(!a.pjson.version)throw new m(`Command Pack "${r}" has no package version.`,b.USAGE);return{name:r,version:a.pjson.version,commands:Object.keys(a.commands).sort()}}catch(t){try{await Fn(r,a,e)}catch{}throw t}})}async function Ln(e,t,n){let r=Ve(e);if(!Ae(P(r,`package.json`)))throw new m(`Command Pack path does not exist: ${r}`,b.USAGE);let i=(await fn(r)).name;if(!i||!n.supported[i])throw new m(`Local package "${i??`(unnamed)`}" is not an allowlisted Command Pack for ${t.binName}.`,b.USAGE,En(t,n));let a=await Nn(i,r,t,n);return jn(t,async()=>{await kn([`install`,`file:${r}`,`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],on(t));let e=await Nn(i,cn(t,i),t,n);return{name:i,version:e.pjson.version??a.pjson.version,commands:Object.keys(e.commands).sort()}})}async function Rn(e,t,n){if(!n.supported[e])throw new m(`Command Pack "${e}" is not allowlisted for ${t.binName}.`,b.USAGE,En(t,n));if(!(e in((await un(t)).dependencies??{})))throw new m(`Command Pack "${e}" is not installed.`,b.USAGE);await jn(t,()=>kn([`uninstall`,e,`--ignore-scripts`,`--no-fund`,`--no-audit`],on(t)))}async function zn(e,t){return(await xn({},e,t)).reports}function Bn(e,t){return{install:n=>In(n,e,t),link:n=>Ln(n,e,t),list:()=>zn(e,t),remove:n=>Rn(n,e,t)}}function Vn(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function Hn(e){try{zt()}catch(t){B(t,e)}process.on(`SIGINT`,()=>{process.stderr.write(`
48
48
  Interrupted. Exiting.
49
- `),j(500).finally(()=>process.exit(130))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e})}function Wn(e,t){let{binName:n,version:r,npmPackage:i,clientName:a}=t,o={binName:n,version:r,npmPackage:i,clientName:a},s=t.commandPacks??{supported:{}},c=Vn(o,s),l;Un(n);let u=Nt([It,Ft,Pt,Lt]);function d(){return l||=Sn(e,o,s).then(e=>new ct(e.commands,n)),l}function f(e,r,i){if(e.printHelp(r,process.stderr),r.length>0)return;let a=!1;try{let e=k(E(rt(i,{...x,...S,...g,...C})));a=!!(e.apiKey||e.console)}catch{}a?t.quickStartTasks?.length&&on(t.quickStartTasks):an(n)}async function p(e,t){let i=lt(t,e);switch(i.kind){case`version`:process.stdout.write(`${n} ${r}\n`);return;case`help`:f(e,i.path,t);return;case`usageError`:B(i.error,n);return;case`run`:try{let e=O(i.command),t=rt(i.rest,{...x,...e,...i.command.flags}),n=Hn(t,[...Object.keys(x),...Object.keys(e)]),r=Hn(t,Object.keys(i.command.flags??{})),a=i.command.validate?.(r);if(a)throw new w(a);let s=E(n),l=T(s);await u({identity:o,path:i.path,command:i.command,flags:r,settings:l,sources:s,configStore:ie(s.configName),authStore:re(s),commandPacks:c,client:new _({identity:o,settings:l,baseUrl:de(s)})}),await j(1e3)}catch(t){if(t instanceof w&&i.rest.length===0){e.printHelp(i.path,process.stderr);return}await j(1e3),B(t,n)}return}}return{run(e=process.argv.slice(2)){return d().then(t=>p(t,e)).catch(e=>j(1e3).finally(()=>B(e,n)))}}}const Gn=`1.14.0`;function Kn(e,t){process.stdout.write(ee(e,t)+`
50
- `)}function qn(e){process.stdout.write(e+`
51
- `)}function Jn(e,t){!e||t||process.stderr.write(`request_id: ${e}\n`)}function Yn(e,t,{gap:n=2}={}){let r=e.map((e,n)=>{let r=e.length;for(let e of t){let t=e[n]??``;t.length>r&&(r=t.length)}return r}),i=` `.repeat(n),a=e=>e.map((e,t)=>(e??``).padEnd(r[t])).join(i),o=[];o.push(a(e));for(let e of t)o.push(a(e));return o}function Xn(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 V(e){let t=0;for(let n of e){let e=n.codePointAt(0)??0;t+=Xn(e)?2:1}return t}function Zn(e,t){let n=t-V(e);return n>0?e+` `.repeat(n):e}const Qn=` │ `,$n=[0,150,160],er=[176,205,250],tr=[160,160,170];function nr(e){if(`NO_COLOR`in process.env)return 0;let t=process.env.FORCE_COLOR;if(t!=null){if(t===`0`||t===`false`)return 0;if(t===`3`||t===`truecolor`)return 3;if(t===`2`)return 2;if(t===`1`||t===`true`||t===``)return 1}if(!at(e))return 0;let n=process.env.COLORTERM;if(n===`truecolor`||n===`24bit`)return 3;let r=process.env.TERM??``;return r===`dumb`?1:/-256(color)?$/i.test(r)?2:1}function rr(e,t,n){return e===t&&t===n?e<8?16:e>248?231:232+Math.round((e-8)/247*24):16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)}function ir(e,t,n,r){let i=Math.max(e,t,n)>127,a=i?128:64;return(r===48?i?100:40:i?90:30)+(e>=a|(t>=a?2:0)|(n>=a?4:0))}function ar(e,t,n,r,i=38){return e>=3?`${i};2;${t};${n};${r}`:e===2?`${i};5;${rr(t,n,r)}`:String(ir(t,n,r,i))}function or(e,[t,n,r],i){return e<=0?i:`\x1b[${ar(e,t,n,r)}m${i}\x1b[0m`}function sr(e,t,n){return t<=0?e:`\x1b[1;${ar(t,255,255,255,38)};${ar(t,n[0],n[1],n[2],48)}m${e}\x1b[0m`}function cr(e,t){let n=t-V(e);return n>0?` `.repeat(n)+e:e}function lr(e,t,n,r){let i=e==null?0:Math.max(0,Math.min(100,e)),a=e!=null,o=a?Math.round(i/100*n):0,s=``,c=``;for(let e=0;e<n;e++)a&&e<o?(s+=`█`,c+=or(r,$n,`█`)):(s+=` `,c+=` `);let l=a?er:tr;return s+=` ${t}`,c+=` ${or(r,l,t)}`,{plain:s,colored:c}}function ur(e){let t=nr(e.out??process.stdout),n=e.align??[],r=e.barColumns??[],i=e.headers.length,a={};for(let n of r){let r=n.width??20,i=[];for(let a=0;a<e.rows.length;a++){let e=n.percents[a]??null,o=n.labels?.[a]??(e==null?`-`:`${Number.isInteger(e)?e:e.toFixed(1)}%`);i.push(lr(e,o,r,t))}a[n.index]=i}let o=(t,n)=>a[n]?a[n][t].plain:e.rows[t][n]??``,s=e.headers.map((t,n)=>{let r=V(t);for(let t=0;t<e.rows.length;t++){let e=V(o(t,n));e>r&&(r=e)}return r}),c=[],l=e.headers.map((e,t)=>n[t]===`right`?cr(e,s[t]):Zn(e,s[t])).join(Qn),u=Math.max(V(l),...e.rows.map((e,t)=>V(Array.from({length:i},(e,n)=>o(t,n)).join(Qn))));c.push(sr(` ${Zn(l,u)} `,t,$n));let d=` ${or(t,$n,`│`)} `;for(let t=0;t<e.rows.length;t++){let r=[];for(let o=0;o<i;o++){let i=s[o];if(a[o]){let e=a[o][t],n=i-V(e.plain);r.push(n>0?e.colored+` `.repeat(n):e.colored);continue}let c=e.rows[t][o]??``,l=e.cellColor?.(t,o,c),u=n[o]===`right`?cr(c,i):Zn(c,i);l?r.push(n[o]===`right`?u.slice(0,u.length-c.length)+l:l+u.slice(c.length)):r.push(u)}let o=` `;for(let e=0;e<i;e++)o+=r[e],e<i-1&&(o+=d);c.push(o)}return c}const dr=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function fr(e){let t=process.stderr.isTTY,n=0,r=null,i=e;return{start(){t&&(r=setInterval(()=>{process.stderr.write(`\r${dr[n%dr.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 pr(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(`
52
- `)}}}async function mr(e,t,n){let r=Date.now()+n.timeoutSec*1e3,i=fr(`Polling...`);t.quiet||i.start();try{for(;Date.now()<r;){let r=await e.requestJson({path:n.url});if(n.getStatus&&!t.quiet&&i.update(`Status: ${n.getStatus(r)}`),n.isComplete(r))return i.stop(`Done.`),r;if(n.isFailed(r)){i.stop(`Failed.`),t.verbose&&process.stderr.write(`[verbose] Task response: ${JSON.stringify(r,null,2)}\n`);let e=n.getErrorMessage?.(r);throw new m(e?`Task failed: ${e}`:`Task failed.`,b.GENERAL,e?void 0:`Use --verbose to see full API response details.`)}await new Promise(e=>setTimeout(e,n.intervalSec*1e3))}}finally{i.stop()}throw new m(`Polling timed out.`,b.TIMEOUT,`Try increasing --timeout or check task status manually.`)}async function hr(e,t,n){let r=await fetch(e,{headers:ye()});if(!r.ok)throw new m(`Download failed: HTTP ${r.status}`,b.GENERAL);let i=Number(r.headers.get(`content-length`)||0),a=r.body?.getReader();if(!a)throw new m(`No response body`,b.GENERAL);Te(Se(t),{recursive:!0});let o=we(t),s=i>0&&!n?.quiet?pr(i,`Downloading`):null,c=0,l=!1;try{let e=new Promise((e,t)=>{o.on(`error`,t)});for(;;){let{done:t,value:n}=await Promise.race([a.read(),e]);if(t)break;o.write(n)||await new Promise(e=>o.once(`drain`,()=>e())),c+=n.byteLength,s?.update(c)}l=!0}finally{if(a.releaseLock(),s?.finish(),await new Promise((e,t)=>{o.on(`finish`,e),o.on(`error`,t),o.end()}),!l)try{De(t)}catch{}}return{size:c}}function gr(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`}function _r(e){return Math.max(1,e.concurrent??1)}async function vr(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 yr(e,t,n){return Promise.all(e.map(({url:e,destPath:r})=>t(e,r,n).then(()=>r)))}const br={"qwen-image-2.0":{"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},"qwen-image-fixed":{"16:9":`1664*928`,"4:3":`1472*1104`,"1:1":`1328*1328`,"3:4":`1104*1472`,"9:16":`928*1664`},wan27:{"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},"z-image":{"1:1":`1024*1024`,"16:9":`1280*720`,"9:16":`720*1280`,"4:3":`1152*864`,"3:4":`864*1152`,"3:2":`1248*832`,"2:3":`832*1248`},wan26:{"1:1":`1280*1280`,"16:9":`1696*960`,"9:16":`960*1696`,"4:3":`1472*1104`,"3:4":`1104*1472`},"wan-legacy":{"1:1":`1024*1024`,"16:9":`1280*720`,"9:16":`720*1280`,"3:4":`768*1152`,"4:3":`1152*768`},"wanx-v1":{"1:1":`1024*1024`,"9:16":`720*1280`,"3:4":`768*1152`,"16:9":`1280*720`},"wan25-i2i":{"1:1":`1280*1280`,"16:9":`1280*720`,"9:16":`720*1280`,"4:3":`1152*864`,"3:4":`864*1152`}};function xr(e,t){if(e)return br[typeof t==`boolean`?t?`qwen-image-2.0`:`qwen-image-fixed`:t][e]??e}const Sr=`Enable watermark (true/false). Omit flag to use CLI default (true).`,Cr=`Enable prompt extend (true/false). Omit flag to use CLI default (true).`,wr=`Enable prompt extend (true/false). Omit flag: true for qwen-image sync; parameter omitted on async models (API default).`,Tr=`Enable prompt extend (true/false). Omit flag to omit the parameter (DashScope default).`;var H=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 Er(e,t){return e instanceof H?e:new H(`step_execution_error`,e instanceof Error?e.message:String(e),{step:t})}var Dr=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 H(`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)}};const Or=new Dr;function kr(){return Or}function Ar(e,t,n,r){let i,a;n instanceof Dr?(i=n,a=r):(i=Or,a=n??r),i.registerStep(e,t,a)}function jr(){let e=E({}),t={...T(e),output:`json`,outputExplicit:!0,quiet:!0},n={binName:`bl`,version:`0.0.0-dev`,npmPackage:`bailian-cli`,clientName:`bailian-cli`},r;try{r=oe(e)}catch{}return{client:new _({identity:n,settings:t,baseUrl:de(e),apiCred:r}),settings:t}}const Mr=[`download`,`out-dir`,`output`];function Nr(e){return e.startsWith(`./`)||e.startsWith(`../`)}function Pr(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))typeof a==`string`&&Nr(a)?(n[i]=He(t,a),r.push(i)):n[i]=a;return{input:n,resolvedKeys:r}}async function Fr(e,t,n){let r=[];for(let i of t){let t=e[i];typeof t==`string`&&(await Me(t).then(()=>!0,()=>!1)||r.push(`Step "${n}" input "${i}" references file that does not exist: ${t}`))}return r}function Ir(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 U(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Lr(e,t){if(Array.isArray(e)){e.forEach(e=>Lr(e,t));return}if(U(e)){`$from`in e&&typeof e.$from==`string`&&t.add(e.$from);for(let n of Object.values(e))Lr(n,t)}}async function Rr(e,t){let n=[];for(let r of e)for(let[e,i]of Object.entries(r.input)){if(Mr.includes(e)||typeof i!=`string`||!Nr(i))continue;let a=He(t,i);await Me(a).then(()=>!0,()=>!1)||n.push(`Step "${r.id}" input "${e}" references file that does not exist: ${a}`)}return n}async function zr(e,t,n){if(!t.message)throw new H(`missing_input`,`text/chat requires 'message' input`,{step:`text/chat`});let r=t.model||`qwen3.8-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};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`]));let o=D();return await e.client.requestJson({path:o,method:`POST`,body:a,timeout:n.blRequestTimeoutSeconds,signal:n.signal})}async function Br(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;N(i)&&(i=await e.client.uploadFile(i,r,{signal:n.signal})),s.push({type:`video_url`,video_url:{url:i}})}for(let t of i){let i=t;N(t)&&(i=await e.client.uploadFile(t,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}]},l=D();return await e.client.requestJson({path:l,method:`POST`,body:c,signal:n.signal})}async function Vr(e,t,n){if(!t.prompt)throw new H(`missing_input`,`image/generate requires 'prompt' input`,{step:`image/generate`});let r=t.model||`qwen-image-2.0`,i=ue(r),a=t.n??1,o=se(t[`prompt-extend`],i.promptExtendDefault,`prompt-extend`),s={size:xr(t.size,i.sizeProfile),n:a,seed:t.seed,prompt_extend:o,watermark:pe(t.watermark)},c=i.inputStyle===`prompt`?{model:r,input:{prompt:t.prompt,negative_prompt:t[`negative-prompt`]||void 0},parameters:s}:{model:r,input:{messages:[{role:`user`,content:[{text:t.prompt}]}]},parameters:{...s,negative_prompt:t[`negative-prompt`]||void 0}};if(i.useSync){let r=await e.client.requestJson({path:i.path,method:`POST`,body:c,signal:n.signal}),a=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),o=await Ur(a,t[`out-dir`],t[`out-prefix`]);return{urls:a,request_id:r.request_id,...o?{saved:o}:{}}}let l=(await e.client.requestJson({path:i.path,method:`POST`,body:c,async:!0,signal:n.signal})).output.task_id,u=await Jr(e,l,n),d=await Ur(Array.isArray(u.urls)?u.urls:[],t[`out-dir`],t[`out-prefix`]);return d&&(u.saved=d),u}async function Hr(e,t,n){if(!t.prompt)throw new H(`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=le(i),o=t.n??1,s=se(t[`prompt-extend`],a.promptExtendDefault,`prompt-extend`),c=[];for(let t of r){let r=t;N(t)&&(r=await e.client.uploadFile(t,i,{signal:n.signal})),c.push(r)}let l={size:xr(t.size,a.sizeProfile),n:o,seed:t.seed,prompt_extend:s,watermark:pe(t.watermark)},u;if(a.inputStyle===`function-base-image`){let e=c[0];if(!e)throw new H(`missing_input`,`image/edit with wanx*-imageedit requires at least one image`,{step:`image/edit`});u={model:i,input:{function:t.function||`description_edit`,prompt:t.prompt,base_image_url:e},parameters:l}}else if(a.inputStyle===`prompt-images`)u={model:i,input:{prompt:t.prompt,images:c,negative_prompt:t[`negative-prompt`]||void 0},parameters:l};else{let e=c.map(e=>({image:e}));e.push({text:t.prompt}),u={model:i,input:{messages:[{role:`user`,content:e}]},parameters:{...l,negative_prompt:t[`negative-prompt`]||void 0}}}if(a.useSync){let r=await e.client.requestJson({path:a.path,method:`POST`,body:u,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),o=await Ur(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...o?{saved:o}:{}}}let d=(await e.client.requestJson({path:a.path,method:`POST`,body:u,async:!0,signal:n.signal})).output.task_id,f=await Jr(e,d,n),p=await Ur(Array.isArray(f.urls)?f.urls:[],t[`out-dir`],t[`out-prefix`]);return p&&(f.saved=p),f}async function Ur(e,t,n){if(!t||e.length===0)return;await Ne(t,{recursive:!0});let r=n&&n.length>0?n:`image`,i=e.length===1?[{url:e[0],destPath:P(t,`${r}.png`)}]:e.map((e,n)=>({url:e,destPath:P(t,`${r}_${String(n+1).padStart(3,`0`)}.png`)})),a=[];for(let{url:e,destPath:t}of i)await hr(e,t,{quiet:!0}),a.push(t);return a}async function Wr(e,t,n){if(!t.prompt)throw new H(`missing_input`,`video/generate requires 'prompt' input`,{step:`video/generate`});let r=t.model||(t.image?`happyhorse-1.1-i2v`:`happyhorse-1.1-t2v`),i;t.image&&(i=N(t.image)?await e.client.uploadFile(t.image,r,{signal:n.signal}):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:se(t[`prompt-extend`],void 0,`prompt-extend`),watermark:pe(t.watermark),seed:t.seed}};ge(a.parameters);let o=be(),s=(await e.client.requestJson({path:o,method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Yr(e,s,(t[`poll-interval`]??10)*1e3,(n.timeoutSeconds??900)*1e3,n)}async function Gr(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 H(`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`]}};ge(a.input);let o=he(),s=await e.client.requestJson({path:o,method:`POST`,body:a,signal:n.signal});return{audio_url:s.output.audio.url,url_expires_at:s.output.audio.expires_at,model:i,voice:t.voice,request_id:s.request_id}}async function Kr(e,t,n){let r=Array.isArray(t.url)?t.url:t.url?[t.url]:[];if(r.length===0)throw new H(`missing_input`,`speech/recognize requires 'url' input`,{step:`speech/recognize`});let i=[];for(let a of r)N(a)?i.push(await e.client.uploadFile(a,t.model||`fun-asr`,{signal:n.signal})):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`]}};ge(a.parameters);let o=me(),s=(await e.client.requestJson({path:o,method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Yr(e,s,(t[`poll-interval`]??2)*1e3,(n.timeoutSeconds??300)*1e3,n)}function qr(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 Jr(e,t,n){return await Yr(e,t,3e3,e.settings.timeout*1e3,n)}async function Yr(e,t,n,r,i){let a=Date.now(),o=0;for(;;){if(i?.signal?.aborted)throw new H(`aborted`,`Task polling was aborted`,{details:{taskId:t}});await Xr(n,i?.signal),o++;let s=_e(t),c=await e.client.requestJson({path:s,method:`GET`,signal:i?.signal}),l=c.output.task_status;if(l===`SUCCEEDED`)return qr(c);if(l===`FAILED`)throw new H(`async_task_failed`,c.output.message||c.output.code||`Task failed`,{details:{taskId:t,data:c}});let u=Date.now()-a;if(await i?.emitEvent?.({type:`step.polling`,timestamp:new Date().toISOString(),status:`running`,taskId:t,taskStatus:l,elapsedMs:u,pollAttempt:o}),u>r)throw new H(`async_poll_timeout`,`Task ${t} timed out after ${Math.round(r/1e3)}s`,{details:{taskId:t,timeoutMs:r,pollAttempts:o}})}}function Xr(e,t){return t?new Promise((n,r)=>{let i=setTimeout(()=>{o(),n()},e),a=()=>{o(),r(new H(`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))}const Zr={"text/chat":(e,t,n)=>zr(e,t,n),"vision/describe":(e,t,n)=>Br(e,t,n),"image/generate":(e,t,n)=>Vr(e,t,n),"image/edit":(e,t,n)=>Hr(e,t,n),"video/generate":(e,t,n)=>Wr(e,t,n),"speech/synthesize":(e,t,n)=>Gr(e,t,n),"speech/recognize":(e,t,n)=>Kr(e,t,n)},Qr={"image/generate":e=>({data:e,artifacts:ni(e),warnings:[],metadata:{}}),"image/edit":e=>({data:e,artifacts:ni(e),warnings:[],metadata:{}}),"video/generate":e=>({data:e,artifacts:ni(e),warnings:[],metadata:{}}),"speech/synthesize":e=>({data:e,artifacts:ri(e,`audio`),warnings:[],metadata:{}}),"speech/recognize":e=>({data:e,artifacts:ri(e,`transcript`),warnings:[],metadata:{}})},$r={"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`}]}};function ei(e){for(let t of Object.keys(Zr))Ar(t,async(e,n)=>await ti(t,e,n),e,$r[t])}async function ti(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=Zr[e];if(!r)throw Error(`No direct API handler registered for step: ${e}`);let i=await r(n.blEnv??jr(),t,n),a=Qr[e];return a?a(i):{data:i,warnings:[],metadata:{}}}function ni(e){if(!U(e))return;let t=[],n=W(e.task_id)??W(e.taskId);for(let r of oi(e.urls))t.push({url:r,taskId:n,kind:si(r)});for(let r of oi(e.saved))t.push({path:r,taskId:n,kind:ci(r)});let r=W(e.video_url)??W(e.videoUrl);r&&t.push({url:r,taskId:n,kind:`video`});let i=W(e.saved);if(i&&t.push({path:i,taskId:n,kind:ci(i)}),Array.isArray(e.videos))for(let n of e.videos){if(!U(n))continue;let e=W(n.task_id)??W(n.taskId),r=W(n.video_url)??W(n.videoUrl),i=W(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(W).filter(ai):[];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 ri(e,t){if(!U(e))return;let n=[],r=W(e.task_id)??W(e.taskId),i=[W(e.url),W(e.audio_url),W(e.audioUrl),W(e.output_url),W(e.outputUrl)].filter(ai);for(let e of i)n.push({url:e,taskId:r,kind:t});let a=[W(e.saved),W(e.path),W(e.output_path),W(e.outputPath)].filter(ai);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?ii(n):void 0}function ii(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 ai(e){return typeof e==`string`}function W(e){return typeof e==`string`&&e.length>0?e:void 0}function oi(e){return Array.isArray(e)?e.map(W).filter(ai):[]}function si(e){try{return ci(new URL(e).pathname)}catch{return`artifact`}}function ci(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 li=F((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})),ui=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=li();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}}})),G=F((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=li(),n=ui();var r=li();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=ui();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&&=k(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=k(this.rhs,e,n),this}get names(){return O(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=k(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)||(A(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(j(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=k(this.condition,e,t),this}get names(){let e=super.names;return O(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=k(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 O(O(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=k(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?`
53
- `:``},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 O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(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 A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function j(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${re(e)}`}e.not=j;let ee=N(e.operators.AND);function te(...e){return e.reduce(ee)}e.and=te;let M=N(e.operators.OR);function ne(...e){return e.reduce(M)}e.or=ne;function N(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${re(n)} ${e} ${re(r)}`}function re(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),K=F((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=G(),n=li();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})),q=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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`)}})),di=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=G(),n=K(),r=q();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])}})),fi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=di(),n=G(),r=q(),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)}})),pi=F((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})),mi=F((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})),hi=F((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=pi(),n=mi(),r=di(),i=G(),a=K();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
49
+ `),j(500).finally(()=>process.exit(130))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e})}function Un(e,t){let{binName:n,version:r,npmPackage:i,clientName:a}=t,o={binName:n,version:r,npmPackage:i,clientName:a},s=t.commandPacks??{supported:{}},c=Bn(o,s),l;Hn(n);let u=Mt([Ft,Pt,Nt,It]);function d(){return l||=xn(e,o,s).then(e=>new st(e.commands,n)),l}function f(e,r,i){if(e.printHelp(r,process.stderr),r.length>0)return;let a=!1;try{let e=k(E(nt(i,{...x,...S,...g,...C})));a=!!(e.apiKey||e.console)}catch{}a?t.quickStartTasks?.length&&an(t.quickStartTasks):rn(n)}async function p(e,t){let i=ct(t,e);switch(i.kind){case`version`:process.stdout.write(`${n} ${r}\n`);return;case`help`:f(e,i.path,t);return;case`usageError`:B(i.error,n);return;case`run`:try{let e=O(i.command),t=nt(i.rest,{...x,...e,...i.command.flags}),n=Vn(t,[...Object.keys(x),...Object.keys(e)]),r=Vn(t,Object.keys(i.command.flags??{})),a=i.command.validate?.(r);if(a)throw new w(a);let s=E(n),l=T(s);await u({identity:o,path:i.path,command:i.command,flags:r,settings:l,sources:s,configStore:ie(s.configName),authStore:re(s),commandPacks:c,client:new _({identity:o,settings:l,baseUrl:de(s)})}),await j(1e3)}catch(t){if(t instanceof w&&i.rest.length===0){e.printHelp(i.path,process.stderr);return}await j(1e3),B(t,n)}return}}return{run(e=process.argv.slice(2)){return d().then(t=>p(t,e)).catch(e=>j(1e3).finally(()=>B(e,n)))}}}const Wn=`1.14.2`;function Gn(e,t){process.stdout.write(ee(e,t)+`
50
+ `)}function Kn(e){process.stdout.write(e+`
51
+ `)}function qn(e,t){!e||t||process.stderr.write(`request_id: ${e}\n`)}function Jn(e,t,{gap:n=2}={}){let r=e.map((e,n)=>{let r=e.length;for(let e of t){let t=e[n]??``;t.length>r&&(r=t.length)}return r}),i=` `.repeat(n),a=e=>e.map((e,t)=>(e??``).padEnd(r[t])).join(i),o=[];o.push(a(e));for(let e of t)o.push(a(e));return o}function Yn(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 V(e){let t=0;for(let n of e){let e=n.codePointAt(0)??0;t+=Yn(e)?2:1}return t}function Xn(e,t){let n=t-V(e);return n>0?e+` `.repeat(n):e}const Zn=` │ `,Qn=[0,150,160],$n=[176,205,250],er=[160,160,170];function tr(e){if(`NO_COLOR`in process.env)return 0;let t=process.env.FORCE_COLOR;if(t!=null){if(t===`0`||t===`false`)return 0;if(t===`3`||t===`truecolor`)return 3;if(t===`2`)return 2;if(t===`1`||t===`true`||t===``)return 1}if(!it(e))return 0;let n=process.env.COLORTERM;if(n===`truecolor`||n===`24bit`)return 3;let r=process.env.TERM??``;return r===`dumb`?1:/-256(color)?$/i.test(r)?2:1}function nr(e,t,n){return e===t&&t===n?e<8?16:e>248?231:232+Math.round((e-8)/247*24):16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)}function rr(e,t,n,r){let i=Math.max(e,t,n)>127,a=i?128:64;return(r===48?i?100:40:i?90:30)+(e>=a|(t>=a?2:0)|(n>=a?4:0))}function ir(e,t,n,r,i=38){return e>=3?`${i};2;${t};${n};${r}`:e===2?`${i};5;${nr(t,n,r)}`:String(rr(t,n,r,i))}function ar(e,[t,n,r],i){return e<=0?i:`\x1b[${ir(e,t,n,r)}m${i}\x1b[0m`}function or(e,t,n){return t<=0?e:`\x1b[1;${ir(t,255,255,255,38)};${ir(t,n[0],n[1],n[2],48)}m${e}\x1b[0m`}function sr(e,t){let n=t-V(e);return n>0?` `.repeat(n)+e:e}function cr(e,t,n,r){let i=e==null?0:Math.max(0,Math.min(100,e)),a=e!=null,o=a?Math.round(i/100*n):0,s=``,c=``;for(let e=0;e<n;e++)a&&e<o?(s+=`█`,c+=ar(r,Qn,`█`)):(s+=` `,c+=` `);let l=a?$n:er;return s+=` ${t}`,c+=` ${ar(r,l,t)}`,{plain:s,colored:c}}function lr(e){let t=tr(e.out??process.stdout),n=e.align??[],r=e.barColumns??[],i=e.headers.length,a={};for(let n of r){let r=n.width??20,i=[];for(let a=0;a<e.rows.length;a++){let e=n.percents[a]??null,o=n.labels?.[a]??(e==null?`-`:`${Number.isInteger(e)?e:e.toFixed(1)}%`);i.push(cr(e,o,r,t))}a[n.index]=i}let o=(t,n)=>a[n]?a[n][t].plain:e.rows[t][n]??``,s=e.headers.map((t,n)=>{let r=V(t);for(let t=0;t<e.rows.length;t++){let e=V(o(t,n));e>r&&(r=e)}return r}),c=[],l=e.headers.map((e,t)=>n[t]===`right`?sr(e,s[t]):Xn(e,s[t])).join(Zn),u=Math.max(V(l),...e.rows.map((e,t)=>V(Array.from({length:i},(e,n)=>o(t,n)).join(Zn))));c.push(or(` ${Xn(l,u)} `,t,Qn));let d=` ${ar(t,Qn,`│`)} `;for(let t=0;t<e.rows.length;t++){let r=[];for(let o=0;o<i;o++){let i=s[o];if(a[o]){let e=a[o][t],n=i-V(e.plain);r.push(n>0?e.colored+` `.repeat(n):e.colored);continue}let c=e.rows[t][o]??``,l=e.cellColor?.(t,o,c),u=n[o]===`right`?sr(c,i):Xn(c,i);l?r.push(n[o]===`right`?u.slice(0,u.length-c.length)+l:l+u.slice(c.length)):r.push(u)}let o=` `;for(let e=0;e<i;e++)o+=r[e],e<i-1&&(o+=d);c.push(o)}return c}const ur=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function dr(e){let t=process.stderr.isTTY,n=0,r=null,i=e;return{start(){t&&(r=setInterval(()=>{process.stderr.write(`\r${ur[n%ur.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 fr(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(`
52
+ `)}}}async function pr(e,t,n){let r=Date.now()+n.timeoutSec*1e3,i=dr(`Polling...`);t.quiet||i.start();try{for(;Date.now()<r;){let r=await e.requestJson({path:n.url});if(n.getStatus&&!t.quiet&&i.update(`Status: ${n.getStatus(r)}`),n.isComplete(r))return i.stop(`Done.`),r;if(n.isFailed(r)){i.stop(`Failed.`),t.verbose&&process.stderr.write(`[verbose] Task response: ${JSON.stringify(r,null,2)}\n`);let e=n.getErrorMessage?.(r);throw new m(e?`Task failed: ${e}`:`Task failed.`,b.GENERAL,e?void 0:`Use --verbose to see full API response details.`)}await new Promise(e=>setTimeout(e,n.intervalSec*1e3))}}finally{i.stop()}throw new m(`Polling timed out.`,b.TIMEOUT,`Try increasing --timeout or check task status manually.`)}async function mr(e,t,n){let r=await fetch(e);if(!r.ok)throw new m(`Download failed: HTTP ${r.status}`,b.GENERAL);let i=Number(r.headers.get(`content-length`)||0),a=r.body?.getReader();if(!a)throw new m(`No response body`,b.GENERAL);we(xe(t),{recursive:!0});let o=Ce(t),s=i>0&&!n?.quiet?fr(i,`Downloading`):null,c=0,l=!1;try{let e=new Promise((e,t)=>{o.on(`error`,t)});for(;;){let{done:t,value:n}=await Promise.race([a.read(),e]);if(t)break;o.write(n)||await new Promise(e=>o.once(`drain`,()=>e())),c+=n.byteLength,s?.update(c)}l=!0}finally{if(a.releaseLock(),s?.finish(),await new Promise((e,t)=>{o.on(`finish`,e),o.on(`error`,t),o.end()}),!l)try{Ee(t)}catch{}}return{size:c}}function hr(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`}function gr(e){return Math.max(1,e.concurrent??1)}async function _r(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 vr(e,t,n){return Promise.all(e.map(({url:e,destPath:r})=>t(e,r,n).then(()=>r)))}const yr={"qwen-image-2.0":{"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},"qwen-image-fixed":{"16:9":`1664*928`,"4:3":`1472*1104`,"1:1":`1328*1328`,"3:4":`1104*1472`,"9:16":`928*1664`},wan27:{"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},"z-image":{"1:1":`1024*1024`,"16:9":`1280*720`,"9:16":`720*1280`,"4:3":`1152*864`,"3:4":`864*1152`,"3:2":`1248*832`,"2:3":`832*1248`},wan26:{"1:1":`1280*1280`,"16:9":`1696*960`,"9:16":`960*1696`,"4:3":`1472*1104`,"3:4":`1104*1472`},"wan-legacy":{"1:1":`1024*1024`,"16:9":`1280*720`,"9:16":`720*1280`,"3:4":`768*1152`,"4:3":`1152*768`},"wanx-v1":{"1:1":`1024*1024`,"9:16":`720*1280`,"3:4":`768*1152`,"16:9":`1280*720`},"wan25-i2i":{"1:1":`1280*1280`,"16:9":`1280*720`,"9:16":`720*1280`,"4:3":`1152*864`,"3:4":`864*1152`}};function br(e,t){if(e)return yr[typeof t==`boolean`?t?`qwen-image-2.0`:`qwen-image-fixed`:t][e]??e}const xr=`Enable watermark (true/false). Omit flag to use CLI default (true).`,Sr=`Enable prompt extend (true/false). Omit flag to use CLI default (true).`,Cr=`Enable prompt extend (true/false). Omit flag: true for qwen-image sync; parameter omitted on async models (API default).`,wr=`Enable prompt extend (true/false). Omit flag to omit the parameter (DashScope default).`;var H=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 Tr(e,t){return e instanceof H?e:new H(`step_execution_error`,e instanceof Error?e.message:String(e),{step:t})}var Er=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 H(`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)}};const Dr=new Er;function Or(){return Dr}function kr(e,t,n,r){let i,a;n instanceof Er?(i=n,a=r):(i=Dr,a=n??r),i.registerStep(e,t,a)}function Ar(){let e=E({}),t={...T(e),output:`json`,outputExplicit:!0,quiet:!0},n={binName:`bl`,version:`0.0.0-dev`,npmPackage:`bailian-cli`,clientName:`bailian-cli`},r;try{r=oe(e)}catch{}return{client:new _({identity:n,settings:t,baseUrl:de(e),apiCred:r}),settings:t}}const jr=[`download`,`out-dir`,`output`];function Mr(e){return e.startsWith(`./`)||e.startsWith(`../`)}function Nr(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))typeof a==`string`&&Mr(a)?(n[i]=Ve(t,a),r.push(i)):n[i]=a;return{input:n,resolvedKeys:r}}async function Pr(e,t,n){let r=[];for(let i of t){let t=e[i];typeof t==`string`&&(await je(t).then(()=>!0,()=>!1)||r.push(`Step "${n}" input "${i}" references file that does not exist: ${t}`))}return r}function Fr(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 U(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Ir(e,t){if(Array.isArray(e)){e.forEach(e=>Ir(e,t));return}if(U(e)){`$from`in e&&typeof e.$from==`string`&&t.add(e.$from);for(let n of Object.values(e))Ir(n,t)}}async function Lr(e,t){let n=[];for(let r of e)for(let[e,i]of Object.entries(r.input)){if(jr.includes(e)||typeof i!=`string`||!Mr(i))continue;let a=Ve(t,i);await je(a).then(()=>!0,()=>!1)||n.push(`Step "${r.id}" input "${e}" references file that does not exist: ${a}`)}return n}async function Rr(e,t,n){if(!t.message)throw new H(`missing_input`,`text/chat requires 'message' input`,{step:`text/chat`});let r=t.model||`qwen3.8-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};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`]));let o=D();return await e.client.requestJson({path:o,method:`POST`,body:a,timeout:n.blRequestTimeoutSeconds,signal:n.signal})}async function zr(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;N(i)&&(i=await e.client.uploadFile(i,r,{signal:n.signal})),s.push({type:`video_url`,video_url:{url:i}})}for(let t of i){let i=t;N(t)&&(i=await e.client.uploadFile(t,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}]},l=D();return await e.client.requestJson({path:l,method:`POST`,body:c,signal:n.signal})}async function Br(e,t,n){if(!t.prompt)throw new H(`missing_input`,`image/generate requires 'prompt' input`,{step:`image/generate`});let r=t.model||`qwen-image-3.0`,i=ue(r),a=t.n??1,o=se(t[`prompt-extend`],i.promptExtendDefault,`prompt-extend`),s={size:br(t.size,i.sizeProfile),n:a,seed:t.seed,prompt_extend:o,watermark:pe(t.watermark)},c=i.inputStyle===`prompt`?{model:r,input:{prompt:t.prompt,negative_prompt:t[`negative-prompt`]||void 0},parameters:s}:{model:r,input:{messages:[{role:`user`,content:[{text:t.prompt}]}]},parameters:{...s,negative_prompt:t[`negative-prompt`]||void 0}};if(i.useSync){let r=await e.client.requestJson({path:i.path,method:`POST`,body:c,signal:n.signal}),a=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),o=await Hr(a,t[`out-dir`],t[`out-prefix`]);return{urls:a,request_id:r.request_id,...o?{saved:o}:{}}}let l=(await e.client.requestJson({path:i.path,method:`POST`,body:c,async:!0,signal:n.signal})).output.task_id,u=await qr(e,l,n),d=await Hr(Array.isArray(u.urls)?u.urls:[],t[`out-dir`],t[`out-prefix`]);return d&&(u.saved=d),u}async function Vr(e,t,n){if(!t.prompt)throw new H(`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-3.0`,a=le(i),o=t.n??1,s=se(t[`prompt-extend`],a.promptExtendDefault,`prompt-extend`),c=[];for(let t of r){let r=t;N(t)&&(r=await e.client.uploadFile(t,i,{signal:n.signal})),c.push(r)}let l={size:br(t.size,a.sizeProfile),n:o,seed:t.seed,prompt_extend:s,watermark:pe(t.watermark)},u;if(a.inputStyle===`function-base-image`){let e=c[0];if(!e)throw new H(`missing_input`,`image/edit with wanx*-imageedit requires at least one image`,{step:`image/edit`});u={model:i,input:{function:t.function||`description_edit`,prompt:t.prompt,base_image_url:e},parameters:l}}else if(a.inputStyle===`prompt-images`)u={model:i,input:{prompt:t.prompt,images:c,negative_prompt:t[`negative-prompt`]||void 0},parameters:l};else{let e=c.map(e=>({image:e}));e.push({text:t.prompt}),u={model:i,input:{messages:[{role:`user`,content:e}]},parameters:{...l,negative_prompt:t[`negative-prompt`]||void 0}}}if(a.useSync){let r=await e.client.requestJson({path:a.path,method:`POST`,body:u,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),o=await Hr(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...o?{saved:o}:{}}}let d=(await e.client.requestJson({path:a.path,method:`POST`,body:u,async:!0,signal:n.signal})).output.task_id,f=await qr(e,d,n),p=await Hr(Array.isArray(f.urls)?f.urls:[],t[`out-dir`],t[`out-prefix`]);return p&&(f.saved=p),f}async function Hr(e,t,n){if(!t||e.length===0)return;await Me(t,{recursive:!0});let r=n&&n.length>0?n:`image`,i=e.length===1?[{url:e[0],destPath:P(t,`${r}.png`)}]:e.map((e,n)=>({url:e,destPath:P(t,`${r}_${String(n+1).padStart(3,`0`)}.png`)})),a=[];for(let{url:e,destPath:t}of i)await mr(e,t,{quiet:!0}),a.push(t);return a}async function Ur(e,t,n){if(!t.prompt)throw new H(`missing_input`,`video/generate requires 'prompt' input`,{step:`video/generate`});let r=t.model||(t.image?`happyhorse-1.1-i2v`:`happyhorse-1.1-t2v`),i;t.image&&(i=N(t.image)?await e.client.uploadFile(t.image,r,{signal:n.signal}):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:se(t[`prompt-extend`],void 0,`prompt-extend`),watermark:pe(t.watermark),seed:t.seed}};ge(a.parameters);let o=ye(),s=(await e.client.requestJson({path:o,method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Jr(e,s,(t[`poll-interval`]??10)*1e3,(n.timeoutSeconds??900)*1e3,n)}async function Wr(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 H(`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`]}};ge(a.input);let o=he(),s=await e.client.requestJson({path:o,method:`POST`,body:a,signal:n.signal});return{audio_url:s.output.audio.url,url_expires_at:s.output.audio.expires_at,model:i,voice:t.voice,request_id:s.request_id}}async function Gr(e,t,n){let r=Array.isArray(t.url)?t.url:t.url?[t.url]:[];if(r.length===0)throw new H(`missing_input`,`speech/recognize requires 'url' input`,{step:`speech/recognize`});let i=[];for(let a of r)N(a)?i.push(await e.client.uploadFile(a,t.model||`fun-asr`,{signal:n.signal})):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`]}};ge(a.parameters);let o=me(),s=(await e.client.requestJson({path:o,method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Jr(e,s,(t[`poll-interval`]??2)*1e3,(n.timeoutSeconds??300)*1e3,n)}function Kr(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 qr(e,t,n){return await Jr(e,t,3e3,e.settings.timeout*1e3,n)}async function Jr(e,t,n,r,i){let a=Date.now(),o=0;for(;;){if(i?.signal?.aborted)throw new H(`aborted`,`Task polling was aborted`,{details:{taskId:t}});await Yr(n,i?.signal),o++;let s=_e(t),c=await e.client.requestJson({path:s,method:`GET`,signal:i?.signal}),l=c.output.task_status;if(l===`SUCCEEDED`)return Kr(c);if(l===`FAILED`)throw new H(`async_task_failed`,c.output.message||c.output.code||`Task failed`,{details:{taskId:t,data:c}});let u=Date.now()-a;if(await i?.emitEvent?.({type:`step.polling`,timestamp:new Date().toISOString(),status:`running`,taskId:t,taskStatus:l,elapsedMs:u,pollAttempt:o}),u>r)throw new H(`async_poll_timeout`,`Task ${t} timed out after ${Math.round(r/1e3)}s`,{details:{taskId:t,timeoutMs:r,pollAttempts:o}})}}function Yr(e,t){return t?new Promise((n,r)=>{let i=setTimeout(()=>{o(),n()},e),a=()=>{o(),r(new H(`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))}const Xr={"text/chat":(e,t,n)=>Rr(e,t,n),"vision/describe":(e,t,n)=>zr(e,t,n),"image/generate":(e,t,n)=>Br(e,t,n),"image/edit":(e,t,n)=>Vr(e,t,n),"video/generate":(e,t,n)=>Ur(e,t,n),"speech/synthesize":(e,t,n)=>Wr(e,t,n),"speech/recognize":(e,t,n)=>Gr(e,t,n)},Zr={"image/generate":e=>({data:e,artifacts:ti(e),warnings:[],metadata:{}}),"image/edit":e=>({data:e,artifacts:ti(e),warnings:[],metadata:{}}),"video/generate":e=>({data:e,artifacts:ti(e),warnings:[],metadata:{}}),"speech/synthesize":e=>({data:e,artifacts:ni(e,`audio`),warnings:[],metadata:{}}),"speech/recognize":e=>({data:e,artifacts:ni(e,`transcript`),warnings:[],metadata:{}})},Qr={"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`}]}};function $r(e){for(let t of Object.keys(Xr))kr(t,async(e,n)=>await ei(t,e,n),e,Qr[t])}async function ei(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=Xr[e];if(!r)throw Error(`No direct API handler registered for step: ${e}`);let i=await r(n.blEnv??Ar(),t,n),a=Zr[e];return a?a(i):{data:i,warnings:[],metadata:{}}}function ti(e){if(!U(e))return;let t=[],n=W(e.task_id)??W(e.taskId);for(let r of ai(e.urls))t.push({url:r,taskId:n,kind:oi(r)});for(let r of ai(e.saved))t.push({path:r,taskId:n,kind:si(r)});let r=W(e.video_url)??W(e.videoUrl);r&&t.push({url:r,taskId:n,kind:`video`});let i=W(e.saved);if(i&&t.push({path:i,taskId:n,kind:si(i)}),Array.isArray(e.videos))for(let n of e.videos){if(!U(n))continue;let e=W(n.task_id)??W(n.taskId),r=W(n.video_url)??W(n.videoUrl),i=W(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(W).filter(ii):[];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 ni(e,t){if(!U(e))return;let n=[],r=W(e.task_id)??W(e.taskId),i=[W(e.url),W(e.audio_url),W(e.audioUrl),W(e.output_url),W(e.outputUrl)].filter(ii);for(let e of i)n.push({url:e,taskId:r,kind:t});let a=[W(e.saved),W(e.path),W(e.output_path),W(e.outputPath)].filter(ii);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?ri(n):void 0}function ri(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 ii(e){return typeof e==`string`}function W(e){return typeof e==`string`&&e.length>0?e:void 0}function ai(e){return Array.isArray(e)?e.map(W).filter(ii):[]}function oi(e){try{return si(new URL(e).pathname)}catch{return`artifact`}}function si(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 ci=F((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})),li=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=ci();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}}})),G=F((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=ci(),n=li();var r=ci();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=li();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&&=k(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=k(this.rhs,e,n),this}get names(){return O(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=k(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)||(A(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(j(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=k(this.condition,e,t),this}get names(){let e=super.names;return O(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=k(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 O(O(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=k(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?`
53
+ `:``},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 O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(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 A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function j(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${re(e)}`}e.not=j;let ee=N(e.operators.AND);function te(...e){return e.reduce(ee)}e.and=te;let M=N(e.operators.OR);function ne(...e){return e.reduce(M)}e.or=ne;function N(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${re(n)} ${e} ${re(r)}`}function re(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),K=F((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=G(),n=ci();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})),q=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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`)}})),ui=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=G(),n=K(),r=q();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])}})),di=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=ui(),n=G(),r=q(),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)}})),fi=F((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})),pi=F((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})),mi=F((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=fi(),n=pi(),r=ui(),i=G(),a=K();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
54
54
  || (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
55
55
  || (${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"
56
- || ${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}}})),gi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;let t=G(),n=K();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)}`)}})),J=F((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=G(),n=K(),r=q(),i=K();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})),_i=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=G(),n=q(),r=J(),i=di();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})),vi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=G(),n=K();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})),yi=F(((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}})),bi=F(((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`)}})),xi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=K(),n=yi(),r=bi(),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})),Si=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=fi(),n=hi(),r=mi(),i=hi(),a=gi(),o=_i(),s=vi(),c=G(),l=q(),u=xi(),d=K(),f=di();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&&A(e),D(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),j(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&&A(e),O(e),k(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 te(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);te(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 O(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function k(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function A({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 j(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&&ee(e),t.return((0,c._)`${l.default.errors} === 0`))}function ee({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 te(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(()=>ue(e,`$ref`,h.all.$ref.definition));return}p.jtd||ne(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)),M(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):M(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function M(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)&&ue(e,n.keyword,n.definition,t.type)})}function ne(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(N(e,t),e.opts.allowUnionTypes||re(e,t),ie(e,e.dataTypes))}function N(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{oe(e.dataTypes,t)||ce(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),se(e,t)}}function re(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&ce(e,`use allowUnionTypes to allow union type keyword`)}function ie(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=>ae(t,e))&&ce(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function ae(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function oe(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function se(e,t){let n=[];for(let r of e.dataTypes)oe(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function ce(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var le=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`,pe(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=le;function ue(e,t,n,r){let i=new le(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 de=/^\/(?:[^~]|~0|~1)*$/,fe=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function pe(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!de.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=fe.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=pe})),Ci=F((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}}})),wi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=xi();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))}}})),Ti=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=G(),n=Ci(),r=q(),i=xi(),a=K(),o=Si();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}})),Ei=F(((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}})),Di=F(((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}})),Oi=F(((e,t)=>{let{isUUID:n}=Di(),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}})),ki=F(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=Di(),{SCHEMES:d,getSchemeHandler:f}=Oi();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})),Ai=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ki();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),ji=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=Si();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=G();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=Ci(),i=wi(),a=pi(),o=Ti(),s=G(),c=xi(),l=hi(),u=K(),d=Ei(),f=Ai(),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(k.call(this,n,t),!t)return(0,u.eachItem)(n,e=>A.call(this,e)),this;ee.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=>A.call(this,e,r):e=>r.type.forEach(t=>A.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]=M(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 O=/^[a-z_$][a-z0-9_$:-]*$/i;function k(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!O.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 A(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?j.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 j(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 ee(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=M(t)),e.validateSchema=this.compile(t,!0))}let te={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function M(e){return{anyOf:[e,te]}}})),Mi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),Ni=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;let t=wi(),n=J(),r=G(),i=q(),a=Ti(),o=K(),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})),Pi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Mi(),n=Ni();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),Fi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),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})`)}}})),Ii=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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}))`)}}})),Li=F((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`})),Ri=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),r=Li();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}`)}}})),zi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=K(),r=G();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})`)}}}})),Bi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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}`)}}})),Vi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=G(),r=K();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)}}}})),Hi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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}`)}}})),Ui=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=yi();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),Wi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=hi(),n=G(),r=K(),i=Ui();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)})))}}}})),Gi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),r=Ui();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}`)}}})),Ki=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),r=Ui();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}`}}}})),qi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Fi(),n=Ii(),r=Ri(),i=zi(),a=Bi(),o=Vi(),s=Hi(),c=Wi(),l=Gi(),u=Ki();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]})),Ji=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;let t=G(),n=K(),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})),Yi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;let t=G(),n=K(),r=J(),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})),Xi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Yi();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),Zi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),r=J(),i=Ji();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)))}}})),Qi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K();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)))}}}})),$i=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=G(),n=K(),r=J();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},
56
+ || ${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}}})),hi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;let t=G(),n=K();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)}`)}})),J=F((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=G(),n=K(),r=q(),i=K();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})),gi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=G(),n=q(),r=J(),i=ui();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})),_i=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=G(),n=K();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})),vi=F(((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}})),yi=F(((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`)}})),bi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=K(),n=vi(),r=yi(),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})),xi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=di(),n=mi(),r=pi(),i=mi(),a=hi(),o=gi(),s=_i(),c=G(),l=q(),u=bi(),d=K(),f=ui();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&&A(e),D(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),j(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&&A(e),O(e),k(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 te(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);te(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 O(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function k(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function A({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 j(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&&ee(e),t.return((0,c._)`${l.default.errors} === 0`))}function ee({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 te(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(()=>ue(e,`$ref`,h.all.$ref.definition));return}p.jtd||ne(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)),M(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):M(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function M(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)&&ue(e,n.keyword,n.definition,t.type)})}function ne(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(N(e,t),e.opts.allowUnionTypes||re(e,t),ie(e,e.dataTypes))}function N(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{oe(e.dataTypes,t)||ce(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),se(e,t)}}function re(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&ce(e,`use allowUnionTypes to allow union type keyword`)}function ie(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=>ae(t,e))&&ce(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function ae(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function oe(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function se(e,t){let n=[];for(let r of e.dataTypes)oe(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function ce(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var le=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`,pe(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=le;function ue(e,t,n,r){let i=new le(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 de=/^\/(?:[^~]|~0|~1)*$/,fe=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function pe(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!de.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=fe.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=pe})),Si=F((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}}})),Ci=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=bi();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))}}})),wi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=G(),n=Si(),r=q(),i=bi(),a=K(),o=xi();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}})),Ti=F(((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}})),Ei=F(((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}})),Di=F(((e,t)=>{let{isUUID:n}=Ei(),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}})),Oi=F(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=Ei(),{SCHEMES:d,getSchemeHandler:f}=Di();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})),ki=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Oi();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),Ai=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=xi();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=G();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=Si(),i=Ci(),a=fi(),o=wi(),s=G(),c=bi(),l=mi(),u=K(),d=Ti(),f=ki(),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(k.call(this,n,t),!t)return(0,u.eachItem)(n,e=>A.call(this,e)),this;ee.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=>A.call(this,e,r):e=>r.type.forEach(t=>A.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]=M(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 O=/^[a-z_$][a-z0-9_$:-]*$/i;function k(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!O.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 A(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?j.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 j(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 ee(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=M(t)),e.validateSchema=this.compile(t,!0))}let te={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function M(e){return{anyOf:[e,te]}}})),ji=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),Mi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;let t=Ci(),n=J(),r=G(),i=q(),a=wi(),o=K(),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})),Ni=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ji(),n=Mi();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),Pi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),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})`)}}})),Fi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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}))`)}}})),Ii=F((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`})),Li=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),r=Ii();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}`)}}})),Ri=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=K(),r=G();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})`)}}}})),zi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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}`)}}})),Bi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=G(),r=K();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)}}}})),Vi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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}`)}}})),Hi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=vi();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),Ui=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=mi(),n=G(),r=K(),i=Hi();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)})))}}}})),Wi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),r=Hi();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}`)}}})),Gi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),r=Hi();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}`}}}})),Ki=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Pi(),n=Fi(),r=Li(),i=Ri(),a=zi(),o=Bi(),s=Vi(),c=Ui(),l=Wi(),u=Gi();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]})),qi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;let t=G(),n=K(),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})),Ji=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;let t=G(),n=K(),r=J(),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})),Yi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ji();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),Xi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),r=J(),i=qi();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)))}}})),Zi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K();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)))}}}})),Qi=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=G(),n=K(),r=J();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},
57
57
  missingProperty: ${i},
58
58
  depsCount: ${n},
59
- 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})),ea=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K();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)}}})),ta=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=G(),r=q(),i=K();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)}}}})),na=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Si(),n=J(),r=K(),i=ta();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)}}}})),ra=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=G(),r=K(),i=K();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())})})}}}})),ia=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=K();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`}}})),aa=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:J().validateUnion,error:{message:`must match a schema in anyOf`}}})),oa=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K();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)})})}}}})),sa=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=K();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)})}}})),ca=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),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})),la=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=K();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`)}}})),ua=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ji(),n=Xi(),r=Yi(),i=Zi(),a=Qi(),o=$i(),s=ea(),c=ta(),l=na(),u=ra(),d=ia(),f=aa(),p=oa(),m=sa(),h=ca(),g=la();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=_})),da=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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})`}}}}})),fa=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[da().default]})),pa=F((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`]})),ma=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Pi(),n=qi(),r=ua(),i=fa(),a=pa();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),ha=F((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={}))})),ga=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=ha(),r=Ti(),i=wi(),a=K();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}}}}})),_a=F(((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}}));const va=$e(F(((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=ji(),r=ma(),i=ga(),a=_a(),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=Si();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=G();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=Ci();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return d.default}});var f=wi();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return f.default}})}))(),1).default,ya=new Set([`type`,`properties`,`items`,`required`,`enum`,`default`,`description`,`format`,`additionalProperties`]),ba=new Set([`string`,`number`,`integer`,`boolean`,`array`,`object`,`null`]),xa=new va({allErrors:!0,coerceTypes:!1,strict:!1,useDefaults:!1});function Sa(e,t=`schema`){let n=[];return Ea(e,t,n),n.length===0&&!xa.validateSchema(e)&&n.push(...Da(xa.errors,t)),n}function Ca(e,t){let n=ka(t,e,`input`);return n.ok?U(n.value)?{ok:!0,value:n.value}:{ok:!1,issues:[`input must be an object`]}:{ok:!1,issues:n.issues}}function wa(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 Ta(e,t){let n=wa(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(U(r)){if(e===`__proto__`||e===`constructor`||e===`prototype`||!Object.prototype.hasOwnProperty.call(r,e))return;r=r[e];continue}return}return r}function Ea(e,t,n){if(!U(e)){n.push(`${t} must be an object`);return}for(let r of Object.keys(e))ya.has(r)||n.push(`${t} has unsupported keyword "${r}"`);if(`type`in e&&Oa(e.type,`${t}.type`,n),`properties`in e)if(!U(e.properties))n.push(`${t}.properties must be an object`);else for(let[r,i]of Object.entries(e.properties))Ea(i,`${t}.properties.${r}`,n);if(`items`in e&&Ea(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&&!U(r)?n.push(`${t}.additionalProperties must be a boolean or schema object`):U(r)&&Ea(r,`${t}.additionalProperties`,n)}}function Da(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 Oa(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)ba.has(e)||n.push(`${t} has unsupported type "${String(e)}"`)}function ka(e,t,n){if((e==null||e===``)&&t.default!==void 0&&(e=t.default),t.enum&&e!==void 0){let r=t.enum.map(ja);if(!r.includes(ja(e)))return{ok:!1,issues:[`${n} must be one of: ${r.join(`, `)}`]}}let r=Aa(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=ka(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(!(U(e)&&r.has(`object`))&&r.has(`string`)&&!Array.isArray(e)&&!U(e))return{ok:!0,value:String(e)}}if(r.has(`object`)){if(!U(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=ka(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=ka(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 Aa(e){let t=e.type===void 0?[]:Array.isArray(e.type)?e.type:[e.type];return new Set(t)}function ja(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}const Y=`[redacted]`;function Ma(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}function Na(e,t,n,r){let i={},a={},o=[],s=!1;for(let[c,l]of Object.entries(e.input)){let e=X(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 Pa(e,t,n){let r={},i=[];for(let[a,o]of Object.entries(e.input)){let e=za(o,t,n);r[a]=e.redacted,e.sensitive&&i.push(a)}return{redacted:r,sensitiveKeys:i}}function Fa(e,t,n,r){return Ha(e,e=>X(e,t,n,r))}function Ia(e){return Ha(e,e=>Z(e,e,!1,e!==void 0))}function La(e){return{...e.data===void 0?{}:{data:Y},...e.artifacts?{artifacts:e.artifacts.map(qa)}:{},...e.warnings?{warnings:e.warnings.map(e=>({code:e.code,message:e.message}))}:{},metadata:{...e.metadata?.step?{step:e.metadata.step}:{},redacted:!0}}}function Ra(e){return{code:e.code,message:Y,...e.step?{step:e.step}:{},details:{redacted:!0}}}function X(e,t,n,r){if(Array.isArray(e)){let i=e.map(e=>X(e,t,n,r));return Z(i.map(e=>e.value),i.map(e=>e.redacted),i.some(e=>e.sensitive))}if(!Ja(e)){if(!U(e))return Z(e,e,!1,e!==void 0);let i={},a={},o=!1;for(let[s,c]of Object.entries(e)){let e=X(c,t,n,r);i[s]=e.value,a[s]=e.redacted,o||=e.sensitive}return Z(i,a,o)}if(`$input`in e){let t=Ta(n,e.$input);return Z(t,t,!1,t!==void 0)}if(`$from`in e){let t=e.$from,n=r.get(t);if(!n)throw new H(`pipeline_reference_error`,`Step output not found: ${t}`);let i=typeof e.path==`string`?e.path:``,a=Ta(n,i);if(a===void 0)throw new H(`pipeline_reference_error`,`Step output path not found: ${t}${i}`);return Z(a,a,!1,!0)}if(`$env`in e){let n=Ba(t.env,e.$env,!1);return Z(n,n,!1,n!==void 0)}if(`$secret`in e){let n=Ba(t.secrets,e.$secret,!0);return Z(n,Y,!0,n!==void 0)}if(`$concat`in e){let i=e.$concat.map(e=>X(e,t,n,r)),a=i.map(e=>Ma(e.value)).join(``),o=i.some(e=>e.sensitive);return Z(a,i.map(e=>e.sensitive?Y:Ma(e.value)).join(``),o)}if(`$coalesce`in e){let i=e.$coalesce,a;for(let e of i)try{let i=X(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 Z(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=X(i,t,n,r);o[e]=a.value,s[e]=a.redacted,c||=a.sensitive}try{let e=Function(`args`,`return (${i})`)(o);return Z(e,c?Y:e,c)}catch(e){throw new H(`pipeline_js_error`,`$js expression failed: ${e instanceof Error?e.message:String(e)}`)}}return Z(e,e,!1)}function za(e,t,n){if(Array.isArray(e)){let r=e.map(e=>za(e,t,n));return Z(r.map(e=>e.value),r.map(e=>e.redacted),r.some(e=>e.sensitive))}if(!Ja(e)){if(!U(e))return Z(e,e,!1,e!==void 0);let r={},i=!1;for(let[a,o]of Object.entries(e)){let e=za(o,t,n);r[a]=e.redacted,i||=e.sensitive}return Z(r,r,i)}if(`$input`in e){let t=Ta(n,e.$input);return Z(t,t,!1,t!==void 0)}if(`$from`in e)return Z({...e},{...e},!1);if(`$env`in e){let n=Ba(t.env,e.$env,!1);return Z(n,n,!1,n!==void 0)}if(`$secret`in e)return Ba(t.secrets,e.$secret,!0),Z(Y,Y,!0,!0);if(`$concat`in e){let r=e.$concat.map(e=>za(e,t,n));if(r.some((t,n)=>{let r=e.$concat[n];return U(r)&&`$from`in r}))return Z({...e},{...e},r.some(e=>e.sensitive));let i=r.map(e=>Ma(e.value)).join(``),a=r.some(e=>e.sensitive);return Z(i,r.map(e=>e.sensitive?Y:Ma(e.value)).join(``),a)}if(`$coalesce`in e){let r=e.$coalesce;if(r.some(e=>U(e)&&`$from`in e))return Z({...e},{...e},!1);for(let e of r){let r=za(e,t,n);if(r.exists&&r.value!==void 0&&r.value!==null)return r}return Z(void 0,void 0,!1,!1)}return`$js`in e?Z({...e},{...e},!1):Z(e,e,!1)}function Ba(e,t,n){if(!Va(e,t))throw new H(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 H(n?`pipeline_secret_error`:`pipeline_env_error`,`${n?`Secret`:`Environment`} binding not found: ${t}`)}function Va(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function Z(e,t,n,r=!0){return{value:e,redacted:t,sensitive:n,exists:r}}function Ha(e,t){if(typeof e==`boolean`)return e;if(U(e)&&`$exists`in e)try{return t(e.$exists).exists}catch(e){if(e instanceof H&&e.code===`pipeline_reference_error`)return!1;throw e}if(U(e)&&`$and`in e){if(!Array.isArray(e.$and)||e.$and.length===0)throw Ka(`$and must be a non-empty array`);return e.$and.every(e=>Ha(e,t))}if(U(e)&&`$or`in e){if(!Array.isArray(e.$or)||e.$or.length===0)throw Ka(`$or must be a non-empty array`);return e.$or.some(e=>Ha(e,t))}if(U(e)&&`$not`in e)return!Ha(e.$not,t);let n=Ua(e);if(n){let[e,r]=n.operands,i=t(e).value,a=t(r).value;switch(n.operator){case`$eq`:return Wa(i,a);case`$ne`:return!Wa(i,a);case`$gt`:return Ga(i,a,n.operator)>0;case`$gte`:return Ga(i,a,n.operator)>=0;case`$lt`:return Ga(i,a,n.operator)<0;case`$lte`:return Ga(i,a,n.operator)<=0;case`$in`:if(!Array.isArray(a))throw Ka(`$in right operand must be an array`);return a.some(e=>Wa(e,i));case`$contains`:if(Array.isArray(i))return i.some(e=>Wa(e,a));if(typeof i==`string`&&typeof a==`string`)return i.includes(a);throw Ka(`$contains left operand must be an array or string`)}}return!!t(e).value}function Ua(e){if(U(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 Ka(`${t} must be a two-item array`);return{operator:t,operands:e[t]}}}}function Wa(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Ga(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 Ka(`${n} operands must both be finite numbers or both be strings`)}function Ka(e){return new H(`pipeline_condition_error`,e)}function qa(e){return{id:e.id,kind:e.kind,mediaType:e.mediaType,metadata:e.metadata?{redacted:!0}:void 0}}function Ja(e){return U(e)&&(`$input`in e||`$from`in e||`$env`in e||`$secret`in e||`$concat`in e||`$coalesce`in e||`$js`in e)}const Ya={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)`}]},Xa={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)`}]},Za={description:`Assert a condition is true`,paths:[{path:`/data/ok`,description:`Whether the assertion passed (boolean)`},{path:`/data/message`,description:`Assertion message`}]};function Qa(e){Ar(`logic/switch`,e=>{let t=$a(e.cases);for(let e of t)if(Ia(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 H(`logic_no_match`,`logic/switch did not match any case`,{step:`logic/switch`,details:{caseCount:t.length}})},e,Ya),Ar(`logic/select`,e=>{let t=eo(e.candidates);for(let e of t)if(!(e.available!==void 0&&!Ia(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 H(`logic_no_candidate`,`logic/select did not receive an available candidate`,{step:`logic/select`,details:{candidateCount:t.length}})},e,Xa),Ar(`logic/assert`,e=>{let t=typeof e.message==`string`?e.message:`Logic assertion failed`,n=U(e.metadata)?e.metadata:void 0;if(!Ia(to(e.condition))){if(e.soft===!0)return{data:{ok:!1,message:t,...n?{metadata:n}:{}}};throw new H(`logic_assertion_failed`,t,{step:`logic/assert`,details:n??{}})}return{data:{ok:!0,...e.message===void 0?{}:{message:t},...n?{metadata:n}:{}}}},e,Za)}function $a(e){if(!Array.isArray(e))throw new H(`logic_input_error`,`cases must be an array`,{step:`logic/switch`});return e}function eo(e){if(!Array.isArray(e))throw new H(`logic_input_error`,`candidates must be an array`,{step:`logic/select`});return e}function to(e){if(e===void 0)throw new H(`logic_input_error`,`condition is required`,{step:`logic/assert`});return e}const no={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 ro(e){Ar(`script/js`,e=>{let t=e.code;if(!t||typeof t!=`string`)throw new H(`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 H(`script_js_error`,`script/js execution failed: ${e instanceof Error?e.message:String(e)}`,{step:`script/js`})}},e,no)}const io=new WeakSet;function ao(e=kr()){return io.has(e)?e:(io.add(e),ei(e),Qa(e),ro(e),e)}function oo(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??[]);Lr(r.step.input,t),r.step.when!==void 0&&Lr(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 so(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 co(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 lo(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 uo(e){if(e===void 0)return 1;if(!Number.isInteger(e)||e<1)throw new H(`pipeline_validation_error`,`Invalid pipeline execution options`,{details:{issues:[`concurrency must be a positive integer`]}});return Math.min(e,64)}const fo=`workflow/v1`;function po(e,t=kr()){let n=go(e);return n.length>0?n:_o(e,t)}function mo(e,t=kr()){if(go(e).length>0)return[];let n=[],r=new Map(e.steps.map(e=>[e.id,e.type]));for(let i of e.steps)bo(i.input,i.id,r,t,n);return n}function ho(e,t){if(!e.inputs)return t;let n=Ca(e.inputs,t);if(n.ok)return n.value;throw new H(`pipeline_validation_error`,`Invalid pipeline runtime input`,{details:{issues:n.issues}})}function go(e){let t=[];if(!U(e))return t.push(`structural: pipeline must be an object`),t;if(e.version!==`workflow/v1`&&t.push(`structural: pipeline.version must be "${fo}"`),!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(!U(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`),U(r.input)||t.push(`structural: step at index ${n} must have an input object`)}return t}function _o(e,t){let n=[];e.inputs&&n.push(...Sa(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&&yo(a.retry,r,n),a.timeout!==void 0&&Ir(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(U(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`);vo(e.input,e.id,i,n)}let a=new Map;for(let e of r){let t=new Set(e.dependsOn??[]);Lr(e.input,t),e.when!==void 0&&Lr(e.when,t),a.set(e.id,t)}for(let e of xo(a))n.push(`semantic: pipeline graph contains cycle: ${e.join(` -> `)}`);return n}function vo(e,t,n,r){if(Array.isArray(e)){e.forEach(e=>vo(e,t,n,r));return}if(U(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))vo(i,t,n,r)}}function yo(e,t,n){if(!U(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 bo(e,t,n,r,i){if(Array.isArray(e)){e.forEach(e=>bo(e,t,n,r,i));return}if(U(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))bo(a,t,n,r,i)}}function xo(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}async function So(e,t={},n={}){return await wo(e,t,n)}async function*Co(e,t={},n={}){let r=new Po(1024),i=new AbortController,a=()=>i.abort();n.signal?.aborted?a():n.signal?.addEventListener(`abort`,a,{once:!0});let o=!1,s;wo(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 wo(e,t,n){let r=n.stepDispatcher??kr(),i=po(e,r);if(i.length>0)throw new H(`pipeline_validation_error`,`Invalid pipeline definition`,{details:{issues:i}});let a=ho(e,t);if(n.basePath){let t=await Rr(e.steps,n.basePath);if(t.length>0)throw new H(`pipeline_file_not_found`,t.join(`; `),{details:{issues:t}})}let o=jr(),s=oo(e),c=uo(n.concurrency),l=[],u=new Map,d=new Map,f=[],p=async e=>{await n.onEvent?.(e)};if(await p({type:`pipeline.started`,timestamp:Q(),status:n.dryRun?`planned`:`running`,stepCount:e.steps.length,dryRun:!!n.dryRun}),n.dryRun){for(let t of so(s)){let n=Pa(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:Q(),status:`planned`,step:$(t),input:Oo(n.redacted,n.sensitiveKeys)}),await p({type:`step.planned`,timestamp:Q(),status:`planned`,step:$(t),input:Oo(n.redacted,n.sensitiveKeys),...t.step.when===void 0?{}:{condition:`pending`}})}return await p({type:`pipeline.planned`,timestamp:Q(),status:`planned`,stepCount:l.length,artifactCount:f.length}),{status:`planned`,version:fo,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 co(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`;Do(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:Q(),status:`running`,step:$(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`;Do(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:Q(),status:`running`,step:$(i),reason:e}),m.delete(i.step.id),t=!0;continue}if(!(i.step.when===void 0||Fa(i.step.when,e,a,d))){let e=`condition evaluated to false`;Do(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:Q(),status:`running`,step:$(i),reason:e}),m.delete(i.step.id),t=!0;continue}let _=To(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),Do(l,u,e),t=!0}if(!t)throw new H(`pipeline_graph_error`,`Workflow graph did not make progress`,{details:{remaining:Array.from(m)}})}let g=lo(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:Q(),status:`failed`,stepCount:g.length,artifactCount:f.length,failedStep:e?$(e):{id:_.id,type:_.type,dependencies:_.dependencies,index:g.findIndex(e=>e.id===_.id)+1,total:g.length},error:_.error}),{status:`failed`,version:fo,steps:g,artifacts:f}}return await p({type:`pipeline.succeeded`,timestamp:Q(),status:`succeeded`,stepCount:g.length,artifactCount:f.length}),{status:`succeeded`,version:fo,steps:g,artifacts:f}}async function To(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:Q(),status:`running`,step:$(e),timing:{startedAt:p},attempt:h});try{let l=Na(e.step,t,n,r),u=l.value,g=l.redacted;if(o.basePath){let t=Pr(u,o.basePath);u=t.input,g=Pr(l.redacted,o.basePath).input;let n=await Fr(u,t.resolvedKeys.filter(e=>!Mr.includes(e)),e.step.id);if(n.length>0)throw new H(`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:Q(),status:`running`,step:$(e),input:Oo(g,l.sensitiveKeys)});let _=await Eo(e.step,u,o,$(e),a,s,c);r.set(e.step.id,_);let v=l.sensitive?La(_):_;v.artifacts&&i.push(...v.artifacts),m=new Date().toISOString();for(let t of v.artifacts??[])await a({type:`artifact.created`,timestamp:Q(),status:`running`,step:$(e),artifact:t});return await a({type:`step.succeeded`,timestamp:Q(),status:`running`,step:$(e),timing:jo(p,m),output:ko(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=Er(t,e.step.type);if(u=f?Ra(n.toJSON()):n.toJSON(),m=new Date().toISOString(),h<l){await a({type:`step.retrying`,timestamp:Q(),status:`running`,step:$(e),attempt:h,nextAttempt:h+1,error:u});let t=Mo(e.step.retry?.backoff,h,o.retryDelayBaseMs??100);t>0&&await(o.sleep??No)(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:Q(),status:`failed`,step:$(e),timing:jo(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 Eo(e,t,n,r,i,a,o){let s=Ir(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??Q(),status:`running`,step:r,taskId:e.taskId,taskStatus:e.taskStatus,elapsedMs:e.elapsedMs,pollAttempt:e.pollAttempt})},blEnv: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 H(`step_timeout`,`Step ${e.id} exceeded timeout ${s}s`,{step:e.type}))},{once:!0})})])}finally{clearTimeout(f),n.signal?.removeEventListener(`abort`,u)}}function Do(e,t,n){e.push(n),t.set(n.id,n)}function Q(){return new Date().toISOString()}function $(e){return{id:e.step.id,type:e.step.type,dependencies:e.dependencies,index:e.index,total:e.total}}function Oo(e,t=[]){return{keys:Object.keys(e).sort(),...t.length>0?{redactedKeys:t.sort()}:{}}}function ko(e){return{...e.data===void 0?{}:{dataType:Ao(e.data)},artifactCount:e.artifacts?.length??0,warningCount:e.warnings?.length??0,...e.metadata?{metadata:e.metadata}:{}}}function Ao(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e}function jo(e,t){return{startedAt:e,finishedAt:t,durationMs:Math.max(0,Date.parse(t)-Date.parse(e))}}function Mo(e=`none`,t,n){return e===`none`?0:e===`linear`?n*t:n*2**(t-1)}function No(e){return new Promise(t=>setTimeout(t,e))}var Po=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()?.()}};export{Ut as API_KEY_PAGE,Ht as BAILIAN_CONSOLE,Vt as BAILIAN_CONSOLE_ROOT,Tr as BOOL_FLAG_PROMPT_EXTEND_API_DEFAULT,Cr as BOOL_FLAG_PROMPT_EXTEND_CLI_TRUE,wr as BOOL_FLAG_PROMPT_EXTEND_IMAGE_GENERATE,Sr as BOOL_FLAG_WATERMARK,Gn as CLI_VERSION,ct as CommandRegistry,Kt as MCP_WEBSEARCH_PAGE,pt as NPM_PACKAGE,ft as NPM_REGISTRY,Wt as TOKEN_PLAN_PAGE,qt as VOICE_TTS_PAGE,L as ansi,Mt as checkForUpdate,mo as collectPipelineHints,po as collectPipelineIssues,Nt as compose,Wn as createCli,pr as createProgressBar,fr as createSpinner,V as displayWidth,hr as downloadFile,yr as downloadParallel,qn as emitBare,Jn as emitRequestId,Kn as emitResult,f as ensureBinaryPathEntries,So as executePipeline,u as fetchBinaryChannelManifest,a as fetchBinaryChannelVersion,Et as fetchLatestVersion,gr as formatBytes,Yn as formatTable,e as getBinaryBinRoot,c as getBinaryCurrentPath,d as getBinaryShareRoot,t as getBinaryVersionsDir,_r as getConcurrency,Ot as getPendingUpdateNotification,B as handleError,ao as initPipelineSteps,at as isTerminal,o as isValidUpdateTargetVersion,dt as maybeShowStatusBar,Gt as mcpMarketplaceDetailPage,p as normalizeBinaryVersion,Zn as padEnd,rt as parseFlags,nt as parsePath,n as performBinaryUpdate,mr as poll,on as printQuickStart,an as printWelcomeBanner,r as pruneBinaryVersions,l as readCurrentVersionDir,ur as renderBoxTable,lt as resolve,s as resolveBinaryDownloadSpec,xr as resolveImageSize,vr as runConcurrent,Bt as setupProxyFromEnv,Co as streamPipelineEvents,ot as supportsColor,i as switchCurrentToVersion};
59
+ 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})),$i=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K();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)}}})),ea=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=G(),r=q(),i=K();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)}}}})),ta=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=xi(),n=J(),r=K(),i=ea();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)}}}})),na=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=G(),r=K(),i=K();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())})})}}}})),ra=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=K();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`}}})),ia=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:J().validateUnion,error:{message:`must match a schema in anyOf`}}})),aa=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K();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)})})}}}})),oa=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=K();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)})}}})),sa=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),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})),ca=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=K();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`)}}})),la=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=qi(),n=Yi(),r=Ji(),i=Xi(),a=Zi(),o=Qi(),s=$i(),c=ea(),l=ta(),u=na(),d=ra(),f=ia(),p=aa(),m=oa(),h=sa(),g=ca();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=_})),ua=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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})`}}}}})),da=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[ua().default]})),fa=F((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`]})),pa=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ni(),n=Ki(),r=la(),i=da(),a=fa();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),ma=F((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={}))})),ha=F((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=ma(),r=wi(),i=Ci(),a=K();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}}}}})),ga=F(((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}}));const _a=Qe(F(((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=Ai(),r=pa(),i=ha(),a=ga(),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=xi();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=G();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=Si();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return d.default}});var f=Ci();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return f.default}})}))(),1).default,va=new Set([`type`,`properties`,`items`,`required`,`enum`,`default`,`description`,`format`,`additionalProperties`]),ya=new Set([`string`,`number`,`integer`,`boolean`,`array`,`object`,`null`]),ba=new _a({allErrors:!0,coerceTypes:!1,strict:!1,useDefaults:!1});function xa(e,t=`schema`){let n=[];return Ta(e,t,n),n.length===0&&!ba.validateSchema(e)&&n.push(...Ea(ba.errors,t)),n}function Sa(e,t){let n=Oa(t,e,`input`);return n.ok?U(n.value)?{ok:!0,value:n.value}:{ok:!1,issues:[`input must be an object`]}:{ok:!1,issues:n.issues}}function Ca(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 wa(e,t){let n=Ca(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(U(r)){if(e===`__proto__`||e===`constructor`||e===`prototype`||!Object.prototype.hasOwnProperty.call(r,e))return;r=r[e];continue}return}return r}function Ta(e,t,n){if(!U(e)){n.push(`${t} must be an object`);return}for(let r of Object.keys(e))va.has(r)||n.push(`${t} has unsupported keyword "${r}"`);if(`type`in e&&Da(e.type,`${t}.type`,n),`properties`in e)if(!U(e.properties))n.push(`${t}.properties must be an object`);else for(let[r,i]of Object.entries(e.properties))Ta(i,`${t}.properties.${r}`,n);if(`items`in e&&Ta(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&&!U(r)?n.push(`${t}.additionalProperties must be a boolean or schema object`):U(r)&&Ta(r,`${t}.additionalProperties`,n)}}function Ea(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 Da(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)ya.has(e)||n.push(`${t} has unsupported type "${String(e)}"`)}function Oa(e,t,n){if((e==null||e===``)&&t.default!==void 0&&(e=t.default),t.enum&&e!==void 0){let r=t.enum.map(Aa);if(!r.includes(Aa(e)))return{ok:!1,issues:[`${n} must be one of: ${r.join(`, `)}`]}}let r=ka(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=Oa(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(!(U(e)&&r.has(`object`))&&r.has(`string`)&&!Array.isArray(e)&&!U(e))return{ok:!0,value:String(e)}}if(r.has(`object`)){if(!U(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=Oa(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=Oa(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 ka(e){let t=e.type===void 0?[]:Array.isArray(e.type)?e.type:[e.type];return new Set(t)}function Aa(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}const Y=`[redacted]`;function ja(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}function Ma(e,t,n,r){let i={},a={},o=[],s=!1;for(let[c,l]of Object.entries(e.input)){let e=X(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 Na(e,t,n){let r={},i=[];for(let[a,o]of Object.entries(e.input)){let e=Ra(o,t,n);r[a]=e.redacted,e.sensitive&&i.push(a)}return{redacted:r,sensitiveKeys:i}}function Pa(e,t,n,r){return Va(e,e=>X(e,t,n,r))}function Fa(e){return Va(e,e=>Z(e,e,!1,e!==void 0))}function Ia(e){return{...e.data===void 0?{}:{data:Y},...e.artifacts?{artifacts:e.artifacts.map(Ka)}:{},...e.warnings?{warnings:e.warnings.map(e=>({code:e.code,message:e.message}))}:{},metadata:{...e.metadata?.step?{step:e.metadata.step}:{},redacted:!0}}}function La(e){return{code:e.code,message:Y,...e.step?{step:e.step}:{},details:{redacted:!0}}}function X(e,t,n,r){if(Array.isArray(e)){let i=e.map(e=>X(e,t,n,r));return Z(i.map(e=>e.value),i.map(e=>e.redacted),i.some(e=>e.sensitive))}if(!qa(e)){if(!U(e))return Z(e,e,!1,e!==void 0);let i={},a={},o=!1;for(let[s,c]of Object.entries(e)){let e=X(c,t,n,r);i[s]=e.value,a[s]=e.redacted,o||=e.sensitive}return Z(i,a,o)}if(`$input`in e){let t=wa(n,e.$input);return Z(t,t,!1,t!==void 0)}if(`$from`in e){let t=e.$from,n=r.get(t);if(!n)throw new H(`pipeline_reference_error`,`Step output not found: ${t}`);let i=typeof e.path==`string`?e.path:``,a=wa(n,i);if(a===void 0)throw new H(`pipeline_reference_error`,`Step output path not found: ${t}${i}`);return Z(a,a,!1,!0)}if(`$env`in e){let n=za(t.env,e.$env,!1);return Z(n,n,!1,n!==void 0)}if(`$secret`in e){let n=za(t.secrets,e.$secret,!0);return Z(n,Y,!0,n!==void 0)}if(`$concat`in e){let i=e.$concat.map(e=>X(e,t,n,r)),a=i.map(e=>ja(e.value)).join(``),o=i.some(e=>e.sensitive);return Z(a,i.map(e=>e.sensitive?Y:ja(e.value)).join(``),o)}if(`$coalesce`in e){let i=e.$coalesce,a;for(let e of i)try{let i=X(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 Z(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=X(i,t,n,r);o[e]=a.value,s[e]=a.redacted,c||=a.sensitive}try{let e=Function(`args`,`return (${i})`)(o);return Z(e,c?Y:e,c)}catch(e){throw new H(`pipeline_js_error`,`$js expression failed: ${e instanceof Error?e.message:String(e)}`)}}return Z(e,e,!1)}function Ra(e,t,n){if(Array.isArray(e)){let r=e.map(e=>Ra(e,t,n));return Z(r.map(e=>e.value),r.map(e=>e.redacted),r.some(e=>e.sensitive))}if(!qa(e)){if(!U(e))return Z(e,e,!1,e!==void 0);let r={},i=!1;for(let[a,o]of Object.entries(e)){let e=Ra(o,t,n);r[a]=e.redacted,i||=e.sensitive}return Z(r,r,i)}if(`$input`in e){let t=wa(n,e.$input);return Z(t,t,!1,t!==void 0)}if(`$from`in e)return Z({...e},{...e},!1);if(`$env`in e){let n=za(t.env,e.$env,!1);return Z(n,n,!1,n!==void 0)}if(`$secret`in e)return za(t.secrets,e.$secret,!0),Z(Y,Y,!0,!0);if(`$concat`in e){let r=e.$concat.map(e=>Ra(e,t,n));if(r.some((t,n)=>{let r=e.$concat[n];return U(r)&&`$from`in r}))return Z({...e},{...e},r.some(e=>e.sensitive));let i=r.map(e=>ja(e.value)).join(``),a=r.some(e=>e.sensitive);return Z(i,r.map(e=>e.sensitive?Y:ja(e.value)).join(``),a)}if(`$coalesce`in e){let r=e.$coalesce;if(r.some(e=>U(e)&&`$from`in e))return Z({...e},{...e},!1);for(let e of r){let r=Ra(e,t,n);if(r.exists&&r.value!==void 0&&r.value!==null)return r}return Z(void 0,void 0,!1,!1)}return`$js`in e?Z({...e},{...e},!1):Z(e,e,!1)}function za(e,t,n){if(!Ba(e,t))throw new H(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 H(n?`pipeline_secret_error`:`pipeline_env_error`,`${n?`Secret`:`Environment`} binding not found: ${t}`)}function Ba(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function Z(e,t,n,r=!0){return{value:e,redacted:t,sensitive:n,exists:r}}function Va(e,t){if(typeof e==`boolean`)return e;if(U(e)&&`$exists`in e)try{return t(e.$exists).exists}catch(e){if(e instanceof H&&e.code===`pipeline_reference_error`)return!1;throw e}if(U(e)&&`$and`in e){if(!Array.isArray(e.$and)||e.$and.length===0)throw Ga(`$and must be a non-empty array`);return e.$and.every(e=>Va(e,t))}if(U(e)&&`$or`in e){if(!Array.isArray(e.$or)||e.$or.length===0)throw Ga(`$or must be a non-empty array`);return e.$or.some(e=>Va(e,t))}if(U(e)&&`$not`in e)return!Va(e.$not,t);let n=Ha(e);if(n){let[e,r]=n.operands,i=t(e).value,a=t(r).value;switch(n.operator){case`$eq`:return Ua(i,a);case`$ne`:return!Ua(i,a);case`$gt`:return Wa(i,a,n.operator)>0;case`$gte`:return Wa(i,a,n.operator)>=0;case`$lt`:return Wa(i,a,n.operator)<0;case`$lte`:return Wa(i,a,n.operator)<=0;case`$in`:if(!Array.isArray(a))throw Ga(`$in right operand must be an array`);return a.some(e=>Ua(e,i));case`$contains`:if(Array.isArray(i))return i.some(e=>Ua(e,a));if(typeof i==`string`&&typeof a==`string`)return i.includes(a);throw Ga(`$contains left operand must be an array or string`)}}return!!t(e).value}function Ha(e){if(U(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 Ga(`${t} must be a two-item array`);return{operator:t,operands:e[t]}}}}function Ua(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Wa(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 Ga(`${n} operands must both be finite numbers or both be strings`)}function Ga(e){return new H(`pipeline_condition_error`,e)}function Ka(e){return{id:e.id,kind:e.kind,mediaType:e.mediaType,metadata:e.metadata?{redacted:!0}:void 0}}function qa(e){return U(e)&&(`$input`in e||`$from`in e||`$env`in e||`$secret`in e||`$concat`in e||`$coalesce`in e||`$js`in e)}const Ja={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)`}]},Ya={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)`}]},Xa={description:`Assert a condition is true`,paths:[{path:`/data/ok`,description:`Whether the assertion passed (boolean)`},{path:`/data/message`,description:`Assertion message`}]};function Za(e){kr(`logic/switch`,e=>{let t=Qa(e.cases);for(let e of t)if(Fa(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 H(`logic_no_match`,`logic/switch did not match any case`,{step:`logic/switch`,details:{caseCount:t.length}})},e,Ja),kr(`logic/select`,e=>{let t=$a(e.candidates);for(let e of t)if(!(e.available!==void 0&&!Fa(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 H(`logic_no_candidate`,`logic/select did not receive an available candidate`,{step:`logic/select`,details:{candidateCount:t.length}})},e,Ya),kr(`logic/assert`,e=>{let t=typeof e.message==`string`?e.message:`Logic assertion failed`,n=U(e.metadata)?e.metadata:void 0;if(!Fa(eo(e.condition))){if(e.soft===!0)return{data:{ok:!1,message:t,...n?{metadata:n}:{}}};throw new H(`logic_assertion_failed`,t,{step:`logic/assert`,details:n??{}})}return{data:{ok:!0,...e.message===void 0?{}:{message:t},...n?{metadata:n}:{}}}},e,Xa)}function Qa(e){if(!Array.isArray(e))throw new H(`logic_input_error`,`cases must be an array`,{step:`logic/switch`});return e}function $a(e){if(!Array.isArray(e))throw new H(`logic_input_error`,`candidates must be an array`,{step:`logic/select`});return e}function eo(e){if(e===void 0)throw new H(`logic_input_error`,`condition is required`,{step:`logic/assert`});return e}const to={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 no(e){kr(`script/js`,e=>{let t=e.code;if(!t||typeof t!=`string`)throw new H(`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 H(`script_js_error`,`script/js execution failed: ${e instanceof Error?e.message:String(e)}`,{step:`script/js`})}},e,to)}const ro=new WeakSet;function io(e=Or()){return ro.has(e)?e:(ro.add(e),$r(e),Za(e),no(e),e)}function ao(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??[]);Ir(r.step.input,t),r.step.when!==void 0&&Ir(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 oo(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 so(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 co(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 lo(e){if(e===void 0)return 1;if(!Number.isInteger(e)||e<1)throw new H(`pipeline_validation_error`,`Invalid pipeline execution options`,{details:{issues:[`concurrency must be a positive integer`]}});return Math.min(e,64)}const uo=`workflow/v1`;function fo(e,t=Or()){let n=ho(e);return n.length>0?n:go(e,t)}function po(e,t=Or()){if(ho(e).length>0)return[];let n=[],r=new Map(e.steps.map(e=>[e.id,e.type]));for(let i of e.steps)yo(i.input,i.id,r,t,n);return n}function mo(e,t){if(!e.inputs)return t;let n=Sa(e.inputs,t);if(n.ok)return n.value;throw new H(`pipeline_validation_error`,`Invalid pipeline runtime input`,{details:{issues:n.issues}})}function ho(e){let t=[];if(!U(e))return t.push(`structural: pipeline must be an object`),t;if(e.version!==`workflow/v1`&&t.push(`structural: pipeline.version must be "${uo}"`),!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(!U(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`),U(r.input)||t.push(`structural: step at index ${n} must have an input object`)}return t}function go(e,t){let n=[];e.inputs&&n.push(...xa(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&&vo(a.retry,r,n),a.timeout!==void 0&&Fr(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(U(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`);_o(e.input,e.id,i,n)}let a=new Map;for(let e of r){let t=new Set(e.dependsOn??[]);Ir(e.input,t),e.when!==void 0&&Ir(e.when,t),a.set(e.id,t)}for(let e of bo(a))n.push(`semantic: pipeline graph contains cycle: ${e.join(` -> `)}`);return n}function _o(e,t,n,r){if(Array.isArray(e)){e.forEach(e=>_o(e,t,n,r));return}if(U(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))_o(i,t,n,r)}}function vo(e,t,n){if(!U(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 yo(e,t,n,r,i){if(Array.isArray(e)){e.forEach(e=>yo(e,t,n,r,i));return}if(U(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))yo(a,t,n,r,i)}}function bo(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}async function xo(e,t={},n={}){return await Co(e,t,n)}async function*So(e,t={},n={}){let r=new No(1024),i=new AbortController,a=()=>i.abort();n.signal?.aborted?a():n.signal?.addEventListener(`abort`,a,{once:!0});let o=!1,s;Co(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 Co(e,t,n){let r=n.stepDispatcher??Or(),i=fo(e,r);if(i.length>0)throw new H(`pipeline_validation_error`,`Invalid pipeline definition`,{details:{issues:i}});let a=mo(e,t);if(n.basePath){let t=await Lr(e.steps,n.basePath);if(t.length>0)throw new H(`pipeline_file_not_found`,t.join(`; `),{details:{issues:t}})}let o=Ar(),s=ao(e),c=lo(n.concurrency),l=[],u=new Map,d=new Map,f=[],p=async e=>{await n.onEvent?.(e)};if(await p({type:`pipeline.started`,timestamp:Q(),status:n.dryRun?`planned`:`running`,stepCount:e.steps.length,dryRun:!!n.dryRun}),n.dryRun){for(let t of oo(s)){let n=Na(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:Q(),status:`planned`,step:$(t),input:Do(n.redacted,n.sensitiveKeys)}),await p({type:`step.planned`,timestamp:Q(),status:`planned`,step:$(t),input:Do(n.redacted,n.sensitiveKeys),...t.step.when===void 0?{}:{condition:`pending`}})}return await p({type:`pipeline.planned`,timestamp:Q(),status:`planned`,stepCount:l.length,artifactCount:f.length}),{status:`planned`,version:uo,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 so(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`;Eo(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:Q(),status:`running`,step:$(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`;Eo(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:Q(),status:`running`,step:$(i),reason:e}),m.delete(i.step.id),t=!0;continue}if(!(i.step.when===void 0||Pa(i.step.when,e,a,d))){let e=`condition evaluated to false`;Eo(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:Q(),status:`running`,step:$(i),reason:e}),m.delete(i.step.id),t=!0;continue}let _=wo(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),Eo(l,u,e),t=!0}if(!t)throw new H(`pipeline_graph_error`,`Workflow graph did not make progress`,{details:{remaining:Array.from(m)}})}let g=co(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:Q(),status:`failed`,stepCount:g.length,artifactCount:f.length,failedStep:e?$(e):{id:_.id,type:_.type,dependencies:_.dependencies,index:g.findIndex(e=>e.id===_.id)+1,total:g.length},error:_.error}),{status:`failed`,version:uo,steps:g,artifacts:f}}return await p({type:`pipeline.succeeded`,timestamp:Q(),status:`succeeded`,stepCount:g.length,artifactCount:f.length}),{status:`succeeded`,version:uo,steps:g,artifacts:f}}async function wo(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:Q(),status:`running`,step:$(e),timing:{startedAt:p},attempt:h});try{let l=Ma(e.step,t,n,r),u=l.value,g=l.redacted;if(o.basePath){let t=Nr(u,o.basePath);u=t.input,g=Nr(l.redacted,o.basePath).input;let n=await Pr(u,t.resolvedKeys.filter(e=>!jr.includes(e)),e.step.id);if(n.length>0)throw new H(`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:Q(),status:`running`,step:$(e),input:Do(g,l.sensitiveKeys)});let _=await To(e.step,u,o,$(e),a,s,c);r.set(e.step.id,_);let v=l.sensitive?Ia(_):_;v.artifacts&&i.push(...v.artifacts),m=new Date().toISOString();for(let t of v.artifacts??[])await a({type:`artifact.created`,timestamp:Q(),status:`running`,step:$(e),artifact:t});return await a({type:`step.succeeded`,timestamp:Q(),status:`running`,step:$(e),timing:Ao(p,m),output:Oo(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=Tr(t,e.step.type);if(u=f?La(n.toJSON()):n.toJSON(),m=new Date().toISOString(),h<l){await a({type:`step.retrying`,timestamp:Q(),status:`running`,step:$(e),attempt:h,nextAttempt:h+1,error:u});let t=jo(e.step.retry?.backoff,h,o.retryDelayBaseMs??100);t>0&&await(o.sleep??Mo)(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:Q(),status:`failed`,step:$(e),timing:Ao(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 To(e,t,n,r,i,a,o){let s=Fr(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??Q(),status:`running`,step:r,taskId:e.taskId,taskStatus:e.taskStatus,elapsedMs:e.elapsedMs,pollAttempt:e.pollAttempt})},blEnv: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 H(`step_timeout`,`Step ${e.id} exceeded timeout ${s}s`,{step:e.type}))},{once:!0})})])}finally{clearTimeout(f),n.signal?.removeEventListener(`abort`,u)}}function Eo(e,t,n){e.push(n),t.set(n.id,n)}function Q(){return new Date().toISOString()}function $(e){return{id:e.step.id,type:e.step.type,dependencies:e.dependencies,index:e.index,total:e.total}}function Do(e,t=[]){return{keys:Object.keys(e).sort(),...t.length>0?{redactedKeys:t.sort()}:{}}}function Oo(e){return{...e.data===void 0?{}:{dataType:ko(e.data)},artifactCount:e.artifacts?.length??0,warningCount:e.warnings?.length??0,...e.metadata?{metadata:e.metadata}:{}}}function ko(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e}function Ao(e,t){return{startedAt:e,finishedAt:t,durationMs:Math.max(0,Date.parse(t)-Date.parse(e))}}function jo(e=`none`,t,n){return e===`none`?0:e===`linear`?n*t:n*2**(t-1)}function Mo(e){return new Promise(t=>setTimeout(t,e))}var No=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()?.()}};export{Ht as API_KEY_PAGE,Vt as BAILIAN_CONSOLE,Bt as BAILIAN_CONSOLE_ROOT,wr as BOOL_FLAG_PROMPT_EXTEND_API_DEFAULT,Sr as BOOL_FLAG_PROMPT_EXTEND_CLI_TRUE,Cr as BOOL_FLAG_PROMPT_EXTEND_IMAGE_GENERATE,xr as BOOL_FLAG_WATERMARK,Wn as CLI_VERSION,st as CommandRegistry,Gt as MCP_WEBSEARCH_PAGE,ft as NPM_PACKAGE,dt as NPM_REGISTRY,Ut as TOKEN_PLAN_PAGE,Kt as VOICE_TTS_PAGE,L as ansi,jt as checkForUpdate,po as collectPipelineHints,fo as collectPipelineIssues,Mt as compose,Un as createCli,fr as createProgressBar,dr as createSpinner,V as displayWidth,mr as downloadFile,vr as downloadParallel,Kn as emitBare,qn as emitRequestId,Gn as emitResult,f as ensureBinaryPathEntries,xo as executePipeline,u as fetchBinaryChannelManifest,a as fetchBinaryChannelVersion,Tt as fetchLatestVersion,hr as formatBytes,Jn as formatTable,e as getBinaryBinRoot,c as getBinaryCurrentPath,d as getBinaryShareRoot,t as getBinaryVersionsDir,gr as getConcurrency,Dt as getPendingUpdateNotification,B as handleError,io as initPipelineSteps,it as isTerminal,o as isValidUpdateTargetVersion,ut as maybeShowStatusBar,Wt as mcpMarketplaceDetailPage,p as normalizeBinaryVersion,Xn as padEnd,nt as parseFlags,tt as parsePath,n as performBinaryUpdate,pr as poll,an as printQuickStart,rn as printWelcomeBanner,r as pruneBinaryVersions,l as readCurrentVersionDir,lr as renderBoxTable,ct as resolve,s as resolveBinaryDownloadSpec,br as resolveImageSize,_r as runConcurrent,zt as setupProxyFromEnv,So as streamPipelineEvents,at as supportsColor,i as switchCurrentToVersion};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bailian-cli-runtime",
3
- "version": "1.14.0",
3
+ "version": "1.14.2",
4
4
  "description": "Runtime framework for bailian-cli (createCli, registry, args, output, pipeline). See https://www.npmjs.com/package/bailian-cli for usage.",
5
5
  "homepage": "https://bailian.console.aliyun.com/cli",
6
6
  "bugs": {
@@ -30,7 +30,7 @@
30
30
  "boxen": "^8.0.1",
31
31
  "chalk": "^5.6.2",
32
32
  "undici": "^6.27.0",
33
- "bailian-cli-core": "1.14.0"
33
+ "bailian-cli-core": "1.14.2"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@clack/prompts": "^0.7.0",