bailian-cli 1.4.2 โ 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -13
- package/README.zh.md +25 -13
- package/dist/bailian.mjs +1 -388
- package/package.json +8 -17
package/dist/bailian.mjs
CHANGED
|
@@ -1,390 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import{
|
|
4
|
-
`),process.stderr.write(` 1. Get your API Key: ${Et}\n`),process.stderr.write(` 2. Login: bl auth login --api-key <your-key>
|
|
5
|
-
|
|
6
|
-
`)}function jt(){let{dim:e,reset:t}=kt();process.stderr.write(`
|
|
7
|
-
๐ฏ Try these with your AI coding assistant:
|
|
8
|
-
|
|
9
|
-
`),Mt.forEach((n,r)=>{process.stderr.write(`${e}${r+1}${t} ${n}\n`)}),process.stderr.write(`
|
|
10
|
-
`)}var Mt,Nt=M((()=>{Ot(),Mt=[`Help me generate a set of Amazon e-commerce main images for baseball caps (white background + lifestyle shots + model wear shots)`,`Help me generate a 3-minute humorous crosstalk audio clip`,`Help me generate a Little Red Riding Hood picture-book PDF (with illustrations)`,`Help me analyze this video and write a Xiaohongshu-style post`]}));function P(e,t){process.stdout.write(y(e,t)+`
|
|
11
|
-
`)}function F(e){process.stdout.write(e+`
|
|
12
|
-
`)}var I=M((()=>{}));function Pt(e){Rt=e}function Ft(){return Rt}function It(e){zt=e}function Lt(e=process.stderr){zt&&Rt.length>0&&zt(Rt,e)}var Rt,zt,Bt=M((()=>{Rt=[],zt=null})),Vt=N(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),Ht=N(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c}));function Ut({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}function Wt(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(en,``)}function Gt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function Kt(e,t={}){if(typeof e!=`string`||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=Wt(e),e.length===0))return 0;e=e.replace(on(),` `);let n=t.ambiguousIsNarrow?1:2,r=0;for(let t of e){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159||e>=768&&e<=879))switch(rn.eastAsianWidth(t)){case`F`:case`W`:r+=2;break;case`A`:r+=n;break;default:r+=1}}return r}function qt(){let e=new Map;for(let[t,n]of Object.entries(R)){for(let[t,r]of Object.entries(n))R[t]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[t]=R[t],e.set(r[0],r[1]);Object.defineProperty(R,t,{value:n,enumerable:!1})}return Object.defineProperty(R,`codes`,{value:e,enumerable:!1}),R.color.close=`\x1B[39m`,R.bgColor.close=`\x1B[49m`,R.color.ansi=cn(),R.color.ansi256=ln(),R.color.ansi16m=un(),R.bgColor.ansi=cn(sn),R.bgColor.ansi256=ln(sn),R.bgColor.ansi16m=un(sn),Object.defineProperties(R,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>R.rgbToAnsi256(...R.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>R.ansi256ToAnsi(R.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>R.ansi256ToAnsi(R.hexToAnsi256(e)),enumerable:!1}}),R}function Jt(e,t,n){return String(e).normalize().replace(/\r\n/g,`
|
|
13
|
-
`).split(`
|
|
14
|
-
`).map(e=>En(e,t,n)).join(`
|
|
15
|
-
`)}function Yt(e,t){if(e===t)return;let n=e.split(`
|
|
16
|
-
`),r=t.split(`
|
|
17
|
-
`),i=[];for(let e=0;e<Math.max(n.length,r.length);e++)n[e]!==r[e]&&i.push(e);return i}function Xt(e){return e===An}function Zt(e,t){e.isTTY&&e.setRawMode(t)}function Qt({input:e=Ae,output:t=je,overwrite:n=!0,hideCursor:r=!0}={}){let i=Me.createInterface({input:e,output:t,prompt:``,tabSize:1});Me.emitKeypressEvents(e,i),e.isTTY&&e.setRawMode(!0);let a=(i,{name:o})=>{if(String(i)===``){r&&t.write(L.cursor.show),process.exit(0);return}if(!n)return;let s=o===`return`?0:-1,c=o===`return`?-1:0;Me.moveCursor(t,s,c,()=>{Me.clearLine(t,1,()=>{e.once(`keypress`,a)})})};return r&&t.write(L.cursor.hide),e.once(`keypress`,a),()=>{e.off(`keypress`,a),r&&t.write(L.cursor.show),e.isTTY&&!ar&&e.setRawMode(!1),i.terminal=!1,i.close()}}var L,$t,en,tn,nn,rn,an,on,sn,cn,ln,un,R,dn,fn,pn,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,Zn,Qn,$n,er,tr,nr,rr,ir,ar,or=M((()=>{L=Vt(),$t=ht(Ht(),1),en=Ut(),tn={exports:{}},(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-+(u==2))if(o+u<=i)a+=l;else break;o+=u}return a}})(tn),nn=tn.exports,rn=Gt(nn),an=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},on=Gt(an),sn=10,cn=(e=0)=>t=>`\x1B[${t+e}m`,ln=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,un=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,R={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Object.keys(R.modifier),dn=Object.keys(R.color),fn=Object.keys(R.bgColor),[...dn,...fn],pn=qt(),mn=new Set([`\x1B`,`ย`]),hn=39,gn=`\x07`,_n=`[`,vn=`]`,yn=`m`,bn=`${vn}8;;`,xn=e=>`${mn.values().next().value}${_n}${e}${yn}`,Sn=e=>`${mn.values().next().value}${bn}${e}${gn}`,Cn=e=>e.split(` `).map(e=>Kt(e)),wn=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=Kt(Wt(e[e.length-1]));for(let[t,s]of r.entries()){let c=Kt(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),mn.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(bn)),i){a?s===gn&&(i=!1,a=!1):s===yn&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Tn=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(Kt(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},En=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=Cn(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=Kt(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),wn(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){wn(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){wn(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>Tn(e)));let c=[...s.join(`
|
|
18
|
-
`)];for(let[e,t]of c.entries()){if(r+=t,mn.has(t)){let{groups:t}=RegExp(`(?:\\${_n}(?<code>\\d+)m|\\${bn}(?<uri>.*)${gn})`).exec(c.slice(e).join(``))||{groups:{}};if(t.code!==void 0){let e=Number.parseFloat(t.code);i=e===hn?void 0:e}else t.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}let n=pn.codes.get(Number(i));c[e+1]===`
|
|
19
|
-
`?(a&&(r+=Sn(``)),i&&n&&(r+=xn(n))):t===`
|
|
20
|
-
`&&(i&&n&&(r+=xn(i)),a&&(r+=Sn(a)))}return r},Dn=Object.defineProperty,On=(e,t,n)=>t in e?Dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,kn=(e,t,n)=>(On(e,typeof t==`symbol`?t:t+``,n),n),An=Symbol(`clack:cancel`),jn=new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`]]),Mn=new Set([`up`,`down`,`left`,`right`,`space`,`enter`]),Nn=class{constructor({render:e,input:t=Ae,output:n=je,...r},i=!0){kn(this,`input`),kn(this,`output`),kn(this,`rl`),kn(this,`opts`),kn(this,`_track`,!1),kn(this,`_render`),kn(this,`_cursor`,0),kn(this,`state`,`initial`),kn(this,`value`),kn(this,`error`,``),kn(this,`subscribers`,new Map),kn(this,`_prevFrame`,``),this.opts=r,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=e.bind(this),this._track=i,this.input=t,this.output=n}prompt(){let e=new Pe(0);return e._write=(e,t,n)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,``),this._cursor=this.rl.cursor,this.emit(`value`,this.value)),n()},this.input.pipe(e),this.rl=Ne.createInterface({input:this.input,output:e,tabSize:2,prompt:``,escapeCodeTimeout:50}),Ne.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on(`keypress`,this.onKeypress),Zt(this.input,!0),this.output.on(`resize`,this.render),this.render(),new Promise((e,t)=>{this.once(`submit`,()=>{this.output.write(L.cursor.show),this.output.off(`resize`,this.render),Zt(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(L.cursor.show),this.output.off(`resize`,this.render),Zt(this.input,!1),e(An)})})}on(e,t){let n=this.subscribers.get(e)??[];n.push({cb:t}),this.subscribers.set(e,n)}once(e,t){let n=this.subscribers.get(e)??[];n.push({cb:t,once:!0}),this.subscribers.set(e,n)}emit(e,...t){let n=this.subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}unsubscribe(){this.subscribers.clear()}onKeypress(e,t){if(this.state===`error`&&(this.state=`active`),t?.name&&!this._track&&jn.has(t.name)&&this.emit(`cursor`,jn.get(t.name)),t?.name&&Mn.has(t.name)&&this.emit(`cursor`,t.name),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),e===` `&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit(`value`,this.opts.placeholder))),e&&this.emit(`key`,e.toLowerCase()),t?.name===`return`){if(this.opts.validate){let e=this.opts.validate(this.value);e&&(this.error=e,this.state=`error`,this.rl.write(this.value))}this.state!==`error`&&(this.state=`submit`)}e===``&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
|
|
21
|
-
`),Zt(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=Jt(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
|
|
22
|
-
`).length-1;this.output.write(L.cursor.move(-999,e*-1))}render(){let e=Jt(this._render(this)??``,process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(L.cursor.hide);else{let t=Yt(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let n=t[0];this.output.write(L.cursor.move(0,n)),this.output.write(L.erase.lines(1));let r=e.split(`
|
|
23
|
-
`);this.output.write(r[n]),this._prevFrame=e,this.output.write(L.cursor.move(0,r.length-n-1));return}else if(t&&t?.length>1){let n=t[0];this.output.write(L.cursor.move(0,n)),this.output.write(L.erase.down());let r=e.split(`
|
|
24
|
-
`).slice(n);this.output.write(r.join(`
|
|
25
|
-
`)),this._prevFrame=e;return}this.output.write(L.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},Pn=class extends Nn{get cursor(){return+!this.value}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`value`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(L.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}},Fn=Object.defineProperty,In=(e,t,n)=>t in e?Fn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ln=(e,t,n)=>(In(e,typeof t==`symbol`?t:t+``,n),n),Rn=class extends Nn{constructor(e){super(e,!1),Ln(this,`options`),Ln(this,`cursor`,0);let{options:t}=e;this.options=Object.entries(t).flatMap(([e,t])=>[{value:e,group:!0,label:e},...t.map(t=>({...t,group:e}))]),this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case`space`:this.toggleValue();break}})}getGroupItems(e){return this.options.filter(t=>t.group===e)}isGroupSelected(e){return this.getGroupItems(e).every(e=>this.value.includes(e.value))}toggleValue(){let e=this.options[this.cursor];if(e.group===!0){let t=e.value,n=this.getGroupItems(t);this.isGroupSelected(t)?this.value=this.value.filter(e=>n.findIndex(t=>t.value===e)===-1):this.value=[...this.value,...n.map(e=>e.value)],this.value=Array.from(new Set(this.value))}else{let t=this.value.includes(e.value);this.value=t?this.value.filter(t=>t!==e.value):[...this.value,e.value]}}},zn=Object.defineProperty,Bn=(e,t,n)=>t in e?zn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Vn=(e,t,n)=>(Bn(e,typeof t==`symbol`?t:t+``,n),n),Hn=class extends Nn{constructor(e){super(e,!1),Vn(this,`options`),Vn(this,`cursor`,0),this.options=e.options,this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on(`key`,e=>{e===`a`&&this.toggleAll()}),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case`space`:this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let e=this.value.length===this.options.length;this.value=e?[]:this.options.map(e=>e.value)}toggleValue(){let e=this.value.includes(this._value);this.value=e?this.value.filter(e=>e!==this._value):[...this.value,this._value]}},Un=Object.defineProperty,Wn=(e,t,n)=>t in e?Un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gn=(e,t,n)=>(Wn(e,typeof t==`symbol`?t:t+``,n),n),Kn=class extends Nn{constructor({mask:e,...t}){super(t),Gn(this,`valueWithCursor`,``),Gn(this,`_mask`,`โข`),this._mask=e??`โข`,this.on(`finalize`,()=>{this.valueWithCursor=this.masked}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${$t.default.inverse($t.default.hidden(`_`))}`;else{let e=this.masked.slice(0,this.cursor),t=this.masked.slice(this.cursor);this.valueWithCursor=`${e}${$t.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}},qn=Object.defineProperty,Jn=(e,t,n)=>t in e?qn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Yn=(e,t,n)=>(Jn(e,typeof t==`symbol`?t:t+``,n),n),Xn=class extends Nn{constructor(e){super(e,!1),Yn(this,`options`),Yn(this,`cursor`,0),this.options=e.options,this.cursor=this.options.findIndex(({value:t})=>t===e.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}},Zn=Object.defineProperty,Qn=(e,t,n)=>t in e?Zn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$n=(e,t,n)=>(Qn(e,typeof t==`symbol`?t:t+``,n),n),er=class extends Nn{constructor(e){super(e,!1),$n(this,`options`),$n(this,`cursor`,0),this.options=e.options;let t=this.options.map(({value:[e]})=>e?.toLowerCase());this.cursor=Math.max(t.indexOf(e.initialValue),0),this.on(`key`,e=>{if(!t.includes(e))return;let n=this.options.find(({value:[t]})=>t?.toLowerCase()===e);n&&(this.value=n.value,this.state=`submit`,this.emit(`submit`))})}},tr=Object.defineProperty,nr=(e,t,n)=>t in e?tr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rr=(e,t,n)=>(nr(e,typeof t==`symbol`?t:t+``,n),n),ir=class extends Nn{constructor(e){super(e),rr(this,`valueWithCursor`,``),this.on(`finalize`,()=>{this.value||=e.defaultValue,this.valueWithCursor=this.value}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${$t.default.inverse($t.default.hidden(`_`))}`;else{let e=this.value.slice(0,this.cursor),t=this.value.slice(this.cursor);this.valueWithCursor=`${e}${$t.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}},ar=globalThis.process.platform.startsWith(`win`)})),sr=pt({cancel:()=>Hr,confirm:()=>Fr,group:()=>qr,groupMultiselect:()=>zr,intro:()=>Ur,isCancel:()=>Xt,log:()=>Gr,multiselect:()=>Rr,note:()=>Vr,outro:()=>Wr,password:()=>Pr,select:()=>Ir,selectKey:()=>Lr,spinner:()=>Kr,text:()=>Nr});function cr(){return ke.platform===`win32`?!!ke.env.CI||!!ke.env.WT_SESSION||!!ke.env.TERMINUS_SUBLIME||ke.env.ConEmuTask===`{cmd::Cmder}`||ke.env.TERM_PROGRAM===`Terminus-Sublime`||ke.env.TERM_PROGRAM===`vscode`||ke.env.TERM===`xterm-256color`||ke.env.TERM===`alacritty`||ke.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:ke.env.TERM!==`linux`}function lr(){let e=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(e,`g`)}var z,ur,dr,B,fr,pr,mr,hr,gr,V,_r,vr,yr,br,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar,jr,Mr,Nr,Pr,Fr,Ir,Lr,Rr,zr,Br,Vr,Hr,Ur,Wr,Gr,Kr,qr,Jr=M((()=>{or(),z=ht(Ht(),1),ur=Vt(),dr=cr(),B=(e,t)=>dr?e:t,fr=B(`โ`,`*`),pr=B(`โ `,`x`),mr=B(`โฒ`,`x`),hr=B(`โ`,`o`),gr=B(`โ`,`T`),V=B(`โ`,`|`),_r=B(`โ`,`โ`),vr=B(`โ`,`>`),yr=B(`โ`,` `),br=B(`โป`,`[โข]`),xr=B(`โผ`,`[+]`),Sr=B(`โป`,`[ ]`),Cr=B(`โช`,`โข`),wr=B(`โ`,`-`),Tr=B(`โฎ`,`+`),Er=B(`โ`,`+`),Dr=B(`โฏ`,`+`),Or=B(`โ`,`โข`),kr=B(`โ`,`*`),Ar=B(`โฒ`,`!`),jr=B(`โ `,`x`),Mr=e=>{switch(e){case`initial`:case`active`:return z.default.cyan(fr);case`cancel`:return z.default.red(pr);case`error`:return z.default.yellow(mr);case`submit`:return z.default.green(hr)}},Nr=e=>new ir({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){let t=`${z.default.gray(V)}
|
|
26
|
-
${Mr(this.state)} ${e.message}
|
|
27
|
-
`,n=e.placeholder?z.default.inverse(e.placeholder[0])+z.default.dim(e.placeholder.slice(1)):z.default.inverse(z.default.hidden(`_`)),r=this.value?this.valueWithCursor:n;switch(this.state){case`error`:return`${t.trim()}
|
|
28
|
-
${z.default.yellow(V)} ${r}
|
|
29
|
-
${z.default.yellow(_r)} ${z.default.yellow(this.error)}
|
|
30
|
-
`;case`submit`:return`${t}${z.default.gray(V)} ${z.default.dim(this.value||e.placeholder)}`;case`cancel`:return`${t}${z.default.gray(V)} ${z.default.strikethrough(z.default.dim(this.value??``))}${this.value?.trim()?`
|
|
31
|
-
`+z.default.gray(V):``}`;default:return`${t}${z.default.cyan(V)} ${r}
|
|
32
|
-
${z.default.cyan(_r)}
|
|
33
|
-
`}}}).prompt(),Pr=e=>new Kn({validate:e.validate,mask:e.mask??Cr,render(){let t=`${z.default.gray(V)}
|
|
34
|
-
${Mr(this.state)} ${e.message}
|
|
35
|
-
`,n=this.valueWithCursor,r=this.masked;switch(this.state){case`error`:return`${t.trim()}
|
|
36
|
-
${z.default.yellow(V)} ${r}
|
|
37
|
-
${z.default.yellow(_r)} ${z.default.yellow(this.error)}
|
|
38
|
-
`;case`submit`:return`${t}${z.default.gray(V)} ${z.default.dim(r)}`;case`cancel`:return`${t}${z.default.gray(V)} ${z.default.strikethrough(z.default.dim(r??``))}${r?`
|
|
39
|
-
`+z.default.gray(V):``}`;default:return`${t}${z.default.cyan(V)} ${n}
|
|
40
|
-
${z.default.cyan(_r)}
|
|
41
|
-
`}}}).prompt(),Fr=e=>{let t=e.active??`Yes`,n=e.inactive??`No`;return new Pn({active:t,inactive:n,initialValue:e.initialValue??!0,render(){let r=`${z.default.gray(V)}
|
|
42
|
-
${Mr(this.state)} ${e.message}
|
|
43
|
-
`,i=this.value?t:n;switch(this.state){case`submit`:return`${r}${z.default.gray(V)} ${z.default.dim(i)}`;case`cancel`:return`${r}${z.default.gray(V)} ${z.default.strikethrough(z.default.dim(i))}
|
|
44
|
-
${z.default.gray(V)}`;default:return`${r}${z.default.cyan(V)} ${this.value?`${z.default.green(vr)} ${t}`:`${z.default.dim(yr)} ${z.default.dim(t)}`} ${z.default.dim(`/`)} ${this.value?`${z.default.dim(yr)} ${z.default.dim(n)}`:`${z.default.green(vr)} ${n}`}
|
|
45
|
-
${z.default.cyan(_r)}
|
|
46
|
-
`}}}).prompt()},Ir=e=>{let t=(e,t)=>{let n=e.label??String(e.value);return t===`active`?`${z.default.green(vr)} ${n} ${e.hint?z.default.dim(`(${e.hint})`):``}`:t===`selected`?`${z.default.dim(n)}`:t===`cancelled`?`${z.default.strikethrough(z.default.dim(n))}`:`${z.default.dim(yr)} ${z.default.dim(n)}`},n=0;return new Xn({options:e.options,initialValue:e.initialValue,render(){let r=`${z.default.gray(V)}
|
|
47
|
-
${Mr(this.state)} ${e.message}
|
|
48
|
-
`;switch(this.state){case`submit`:return`${r}${z.default.gray(V)} ${t(this.options[this.cursor],`selected`)}`;case`cancel`:return`${r}${z.default.gray(V)} ${t(this.options[this.cursor],`cancelled`)}
|
|
49
|
-
${z.default.gray(V)}`;default:{let i=e.maxItems===void 0?1/0:Math.max(e.maxItems,5);this.cursor>=n+i-3?n=Math.max(Math.min(this.cursor-i+3,this.options.length-i),0):this.cursor<n+2&&(n=Math.max(this.cursor-2,0));let a=i<this.options.length&&n>0,o=i<this.options.length&&n+i<this.options.length;return`${r}${z.default.cyan(V)} ${this.options.slice(n,n+i).map((e,r,i)=>r===0&&a||r===i.length-1&&o?z.default.dim(`...`):t(e,r+n===this.cursor?`active`:`inactive`)).join(`
|
|
50
|
-
${z.default.cyan(V)} `)}
|
|
51
|
-
${z.default.cyan(_r)}
|
|
52
|
-
`}}}}).prompt()},Lr=e=>{let t=(e,t=`inactive`)=>{let n=e.label??String(e.value);return t===`selected`?`${z.default.dim(n)}`:t===`cancelled`?`${z.default.strikethrough(z.default.dim(n))}`:t===`active`?`${z.default.bgCyan(z.default.gray(` ${e.value} `))} ${n} ${e.hint?z.default.dim(`(${e.hint})`):``}`:`${z.default.gray(z.default.bgWhite(z.default.inverse(` ${e.value} `)))} ${n} ${e.hint?z.default.dim(`(${e.hint})`):``}`};return new er({options:e.options,initialValue:e.initialValue,render(){let n=`${z.default.gray(V)}
|
|
53
|
-
${Mr(this.state)} ${e.message}
|
|
54
|
-
`;switch(this.state){case`submit`:return`${n}${z.default.gray(V)} ${t(this.options.find(e=>e.value===this.value),`selected`)}`;case`cancel`:return`${n}${z.default.gray(V)} ${t(this.options[0],`cancelled`)}
|
|
55
|
-
${z.default.gray(V)}`;default:return`${n}${z.default.cyan(V)} ${this.options.map((e,n)=>t(e,n===this.cursor?`active`:`inactive`)).join(`
|
|
56
|
-
${z.default.cyan(V)} `)}
|
|
57
|
-
${z.default.cyan(_r)}
|
|
58
|
-
`}}}).prompt()},Rr=e=>{let t=(e,t)=>{let n=e.label??String(e.value);return t===`active`?`${z.default.cyan(br)} ${n} ${e.hint?z.default.dim(`(${e.hint})`):``}`:t===`selected`?`${z.default.green(xr)} ${z.default.dim(n)}`:t===`cancelled`?`${z.default.strikethrough(z.default.dim(n))}`:t===`active-selected`?`${z.default.green(xr)} ${n} ${e.hint?z.default.dim(`(${e.hint})`):``}`:t===`submitted`?`${z.default.dim(n)}`:`${z.default.dim(Sr)} ${z.default.dim(n)}`};return new Hn({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
|
|
59
|
-
${z.default.reset(z.default.dim(`Press ${z.default.gray(z.default.bgWhite(z.default.inverse(` space `)))} to select, ${z.default.gray(z.default.bgWhite(z.default.inverse(` enter `)))} to submit`))}`},render(){let n=`${z.default.gray(V)}
|
|
60
|
-
${Mr(this.state)} ${e.message}
|
|
61
|
-
`;switch(this.state){case`submit`:return`${n}${z.default.gray(V)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`submitted`)).join(z.default.dim(`, `))||z.default.dim(`none`)}`;case`cancel`:{let e=this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`cancelled`)).join(z.default.dim(`, `));return`${n}${z.default.gray(V)} ${e.trim()?`${e}
|
|
62
|
-
${z.default.gray(V)}`:``}`}case`error`:{let e=this.error.split(`
|
|
63
|
-
`).map((e,t)=>t===0?`${z.default.yellow(_r)} ${z.default.yellow(e)}`:` ${e}`).join(`
|
|
64
|
-
`);return n+z.default.yellow(V)+` `+this.options.map((e,n)=>{let r=this.value.includes(e.value),i=n===this.cursor;return i&&r?t(e,`active-selected`):r?t(e,`selected`):t(e,i?`active`:`inactive`)}).join(`
|
|
65
|
-
${z.default.yellow(V)} `)+`
|
|
66
|
-
`+e+`
|
|
67
|
-
`}default:return`${n}${z.default.cyan(V)} ${this.options.map((e,n)=>{let r=this.value.includes(e.value),i=n===this.cursor;return i&&r?t(e,`active-selected`):r?t(e,`selected`):t(e,i?`active`:`inactive`)}).join(`
|
|
68
|
-
${z.default.cyan(V)} `)}
|
|
69
|
-
${z.default.cyan(_r)}
|
|
70
|
-
`}}}).prompt()},zr=e=>{let t=(e,t,n=[])=>{let r=e.label??String(e.value),i=typeof e.group==`string`,a=i&&(n[n.indexOf(e)+1]??{group:!0}),o=i&&a.group===!0,s=i?`${o?_r:V} `:``;return t===`active`?`${z.default.dim(s)}${z.default.cyan(br)} ${r} ${e.hint?z.default.dim(`(${e.hint})`):``}`:t===`group-active`?`${s}${z.default.cyan(br)} ${z.default.dim(r)}`:t===`group-active-selected`?`${s}${z.default.green(xr)} ${z.default.dim(r)}`:t===`selected`?`${z.default.dim(s)}${z.default.green(xr)} ${z.default.dim(r)}`:t===`cancelled`?`${z.default.strikethrough(z.default.dim(r))}`:t===`active-selected`?`${z.default.dim(s)}${z.default.green(xr)} ${r} ${e.hint?z.default.dim(`(${e.hint})`):``}`:t===`submitted`?`${z.default.dim(r)}`:`${z.default.dim(s)}${z.default.dim(Sr)} ${z.default.dim(r)}`};return new Rn({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
|
|
71
|
-
${z.default.reset(z.default.dim(`Press ${z.default.gray(z.default.bgWhite(z.default.inverse(` space `)))} to select, ${z.default.gray(z.default.bgWhite(z.default.inverse(` enter `)))} to submit`))}`},render(){let n=`${z.default.gray(V)}
|
|
72
|
-
${Mr(this.state)} ${e.message}
|
|
73
|
-
`;switch(this.state){case`submit`:return`${n}${z.default.gray(V)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`submitted`)).join(z.default.dim(`, `))}`;case`cancel`:{let e=this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`cancelled`)).join(z.default.dim(`, `));return`${n}${z.default.gray(V)} ${e.trim()?`${e}
|
|
74
|
-
${z.default.gray(V)}`:``}`}case`error`:{let e=this.error.split(`
|
|
75
|
-
`).map((e,t)=>t===0?`${z.default.yellow(_r)} ${z.default.yellow(e)}`:` ${e}`).join(`
|
|
76
|
-
`);return`${n}${z.default.yellow(V)} ${this.options.map((e,n,r)=>{let i=this.value.includes(e.value)||e.group===!0&&this.isGroupSelected(`${e.value}`),a=n===this.cursor;return!a&&typeof e.group==`string`&&this.options[this.cursor].value===e.group?t(e,i?`group-active-selected`:`group-active`,r):a&&i?t(e,`active-selected`,r):i?t(e,`selected`,r):t(e,a?`active`:`inactive`,r)}).join(`
|
|
77
|
-
${z.default.yellow(V)} `)}
|
|
78
|
-
${e}
|
|
79
|
-
`}default:return`${n}${z.default.cyan(V)} ${this.options.map((e,n,r)=>{let i=this.value.includes(e.value)||e.group===!0&&this.isGroupSelected(`${e.value}`),a=n===this.cursor;return!a&&typeof e.group==`string`&&this.options[this.cursor].value===e.group?t(e,i?`group-active-selected`:`group-active`,r):a&&i?t(e,`active-selected`,r):i?t(e,`selected`,r):t(e,a?`active`:`inactive`,r)}).join(`
|
|
80
|
-
${z.default.cyan(V)} `)}
|
|
81
|
-
${z.default.cyan(_r)}
|
|
82
|
-
`}}}).prompt()},Br=e=>e.replace(lr(),``),Vr=(e=``,t=``)=>{let n=`
|
|
83
|
-
${e}
|
|
84
|
-
`.split(`
|
|
85
|
-
`),r=Br(t).length,i=Math.max(n.reduce((e,t)=>(t=Br(t),t.length>e?t.length:e),0),r)+2,a=n.map(e=>`${z.default.gray(V)} ${z.default.dim(e)}${` `.repeat(i-Br(e).length)}${z.default.gray(V)}`).join(`
|
|
86
|
-
`);process.stdout.write(`${z.default.gray(V)}
|
|
87
|
-
${z.default.green(hr)} ${z.default.reset(t)} ${z.default.gray(wr.repeat(Math.max(i-r-1,1))+Tr)}
|
|
88
|
-
${a}
|
|
89
|
-
${z.default.gray(Er+wr.repeat(i+2)+Dr)}
|
|
90
|
-
`)},Hr=(e=``)=>{process.stdout.write(`${z.default.gray(_r)} ${z.default.red(e)}
|
|
91
|
-
|
|
92
|
-
`)},Ur=(e=``)=>{process.stdout.write(`${z.default.gray(gr)} ${e}
|
|
93
|
-
`)},Wr=(e=``)=>{process.stdout.write(`${z.default.gray(V)}
|
|
94
|
-
${z.default.gray(_r)} ${e}
|
|
95
|
-
|
|
96
|
-
`)},Gr={message:(e=``,{symbol:t=z.default.gray(V)}={})=>{let n=[`${z.default.gray(V)}`];if(e){let[r,...i]=e.split(`
|
|
97
|
-
`);n.push(`${t} ${r}`,...i.map(e=>`${z.default.gray(V)} ${e}`))}process.stdout.write(`${n.join(`
|
|
98
|
-
`)}
|
|
99
|
-
`)},info:e=>{Gr.message(e,{symbol:z.default.blue(Or)})},success:e=>{Gr.message(e,{symbol:z.default.green(kr)})},step:e=>{Gr.message(e,{symbol:z.default.green(hr)})},warn:e=>{Gr.message(e,{symbol:z.default.yellow(Ar)})},warning:e=>{Gr.warn(e)},error:e=>{Gr.message(e,{symbol:z.default.red(jr)})}},Kr=()=>{let e=dr?[`โ`,`โ`,`โ`,`โ`]:[`โข`,`o`,`O`,`0`],t=dr?80:120,n,r,i=!1,a=``,o=(o=``)=>{i=!0,n=Qt(),a=o.replace(/\.+$/,``),process.stdout.write(`${z.default.gray(V)}
|
|
100
|
-
`);let s=0,c=0;r=setInterval(()=>{let t=z.default.magenta(e[s]),n=`.`.repeat(Math.floor(c)).slice(0,3);process.stdout.write(ur.cursor.move(-999,0)),process.stdout.write(ur.erase.down(1)),process.stdout.write(`${t} ${a}${n}`),s=s+1<e.length?s+1:0,c=c<e.length?c+.125:0},t)},s=(e=``,t=0)=>{a=e??a,i=!1,clearInterval(r);let o=t===0?z.default.green(hr):t===1?z.default.red(pr):z.default.red(mr);process.stdout.write(ur.cursor.move(-999,0)),process.stdout.write(ur.erase.down(1)),process.stdout.write(`${o} ${a}
|
|
101
|
-
`),n()},c=(e=``)=>{a=e??a},l=e=>{i&&s(e>1?`Something went wrong`:`Canceled`,e)};return process.on(`uncaughtExceptionMonitor`,()=>l(2)),process.on(`unhandledRejection`,()=>l(2)),process.on(`SIGINT`,()=>l(1)),process.on(`SIGTERM`,()=>l(1)),process.on(`exit`,l),{start:o,stop:s,message:c}},qr=async(e,t)=>{let n={},r=Object.keys(e);for(let i of r){let r=e[i],a=await r({results:n})?.catch(e=>{throw e});if(typeof t?.onCancel==`function`&&Xt(a)){n[i]=`canceled`,t.onCancel({results:n});continue}n[i]=a}return n}}));async function Yr(e){if(!D())return;let{defaultValue:t,message:n}=e,r=await(await Promise.resolve().then(()=>(Jr(),sr))).text({message:n,default:t,placeholder:t});if(typeof r!=`symbol`)return r}async function Xr(e){if(!D())return;let{message:t,initialValue:n}=e,r=await(await Promise.resolve().then(()=>(Jr(),sr))).confirm({message:t,initialValue:n});if(typeof r!=`symbol`)return r}async function Zr(e){if(!D())return;let{message:t,choices:n,defaultValue:r}=e,i=await(await Promise.resolve().then(()=>(Jr(),sr))).select({message:t,initialValue:r,options:n});if(typeof i!=`symbol`)return i}function H(e,n){throw Ft().length>0&&(Lt(process.stderr),process.exit(0)),new t(`Missing required argument: --${e}\nHint: In non-interactive (CI / agent) environments all required flags must be provided.\n In an interactive terminal, run without --${e} and the CLI will prompt for it.`,i.USAGE,n)}var U=M((()=>{Bt()}));function Qr(e){return e&&yi[e]||yi.domestic}function $r(e){return new Promise((t,n)=>{let r=0,i=[];e.on(`data`,e=>{if(r+=e.length,r>vi){n(Error(`payload too large`));return}i.push(e)}),e.on(`end`,()=>t(Buffer.concat(i).toString(`utf8`))),e.on(`error`,n)})}function ei(e){let t=e.headers[`content-type`];return Array.isArray(t)?t[0]??``:typeof t==`string`?t:``}function ti(e){let t=e.split(`;`);for(let e of t){let t=e.trim();if(!t.toLowerCase().startsWith(`boundary=`))continue;let n=t.slice(9).trim();return(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`))&&(n=n.slice(1,-1)),n.length>0?n:null}return null}function ni(e,t){let n=`--${t}`,r=e.split(n);for(let e=1;e<r.length;e++){let t=r[e];if(!/name\s*=\s*["'](?:access_token|accessToken)["']/i.test(t))continue;let n=t.match(/\r\n\r\n|\n\n/);if(!n||n.index===void 0)continue;let i=t.slice(n.index+n[0].length);if(i=i.replace(/(?:\r\n)+$/g,``).replace(/\n+$/g,``).trim(),i)return i}return null}function ri(e){for(let t of[`access_token`,`accessToken`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return null}function ii(e){for(let t of[`api_key`,`apiKey`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return null}function ai(e){let t=e.trim();if(t.charCodeAt(0)===65279&&(t=t.slice(1)),!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n,i=ri(r);if(i)return i;let a=r.data;if(a&&typeof a==`object`&&!Array.isArray(a)){let e=ri(a);if(e)return e}return null}function oi(e,t){let n=t.toLowerCase();if(!e.trim())return null;if(n.includes(`multipart/form-data`)){let n=ti(t);if(n){let t=ni(e,n);if(t)return t}}if(n.includes(`application/json`)||n.includes(`text/json`)){let t=ai(e);if(t)return t}if(n.includes(`application/x-www-form-urlencoded`))try{let t=new URLSearchParams(e.trim()),n=t.get(`access_token`)??t.get(`accessToken`);if(n?.trim())return n.trim()}catch{}let r=ai(e);if(r)return r;try{let t=new URLSearchParams(e.trim()),n=t.get(`access_token`)??t.get(`accessToken`);if(n?.trim())return n.trim()}catch{}let i=ti(t);if(i){let t=ni(e,i);if(t)return t}return null}function si(e){let t=e.trim();if(t.charCodeAt(0)===65279&&(t=t.slice(1)),!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n,i=ii(r);if(i)return i;let a=r.data;if(a&&typeof a==`object`&&!Array.isArray(a)){let e=ii(a);if(e)return e}return null}function ci(e,t){let n=t.toLowerCase();if(!e.trim())return null;if(n.includes(`application/json`)||n.includes(`text/json`)){let t=si(e);if(t)return t}if(n.includes(`application/x-www-form-urlencoded`))try{let t=new URLSearchParams(e.trim()),n=t.get(`api_key`)??t.get(`apiKey`);if(n?.trim())return n.trim()}catch{}let r=si(e);if(r)return r;try{let t=new URLSearchParams(e.trim()),n=t.get(`api_key`)??t.get(`apiKey`);if(n?.trim())return n.trim()}catch{}return null}function li(e,...t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim())return t.trim()}return null}function ui(e,t){let n={baseUrl:null,consoleSite:null,consoleRegion:null,consoleSwitchAgent:null,workspaceId:null};if(!e.trim())return n;let r=null,i=t.toLowerCase();if(i.includes(`application/json`)||i.includes(`text/json`))try{let t=JSON.parse(e.trim());t&&typeof t==`object`&&!Array.isArray(t)&&(r=t)}catch{}if(!r&&i.includes(`application/x-www-form-urlencoded`))try{let t=new URLSearchParams(e.trim());r=Object.fromEntries(t)}catch{}if(!r)try{let t=JSON.parse(e.trim());t&&typeof t==`object`&&!Array.isArray(t)&&(r=t)}catch{}return r?{baseUrl:li(r,`base_url`,`baseUrl`),consoleSite:li(r,`console_site`,`consoleSite`),consoleRegion:li(r,`console_region`,`consoleRegion`),consoleSwitchAgent:li(r,`console_switch_agent`,`consoleSwitchAgent`),workspaceId:li(r,`workspace_id`,`workspaceId`)}:n}async function di(e){let t=new URL(e.url??`/`,`http://127.0.0.1`),n=t.searchParams.get(`access_token`)??t.searchParams.get(`accessToken`),r=t.searchParams.get(`api_key`)??t.searchParams.get(`apiKey`),i=t.searchParams.get(`base_url`)??t.searchParams.get(`baseUrl`),a=t.searchParams.get(`console_site`)??t.searchParams.get(`consoleSite`),o=t.searchParams.get(`console_region`)??t.searchParams.get(`consoleRegion`),s=t.searchParams.get(`console_switch_agent`)??t.searchParams.get(`consoleSwitchAgent`),c=t.searchParams.get(`workspace_id`)??t.searchParams.get(`workspaceId`),l={baseUrl:i?.trim()||null,consoleSite:a?.trim()||null,consoleRegion:o?.trim()||null,consoleSwitchAgent:s?.trim()||null,workspaceId:c?.trim()||null},u=e.method??`GET`;if(u!==`POST`&&u!==`PUT`&&u!==`PATCH`)return{accessToken:n?.trim()||null,apiKey:r?.trim()||null,...l};let d=ei(e),f;try{f=await $r(e)}catch{return{accessToken:n?.trim()||null,apiKey:r?.trim()||null,...l}}let p=n?.trim()||oi(f,d),m=r?.trim()||ci(f,d),h=ui(f,d);return{accessToken:p,apiKey:m,baseUrl:l.baseUrl||h.baseUrl,consoleSite:l.consoleSite||h.consoleSite,consoleRegion:l.consoleRegion||h.consoleRegion,consoleSwitchAgent:l.consoleSwitchAgent||h.consoleSwitchAgent,workspaceId:l.workspaceId||h.workspaceId}}function fi(e){return new Promise((t,n)=>{let r=e=>n(e);e.once(`error`,r),e.listen({port:0,host:`127.0.0.1`,exclusive:!0},()=>{e.off(`error`,r);let i=e.address();if(!i||typeof i==`string`){n(Error(`Expected TCP socket address`));return}t(i.port)})})}function pi(e){let t=process.platform,n=t===`darwin`?`open`:t===`win32`?`cmd`:`xdg-open`,r=t===`win32`?[`/c`,`start`,``,e]:[e];return new Promise((e,t)=>{Fe(n,r,{windowsHide:!0},n=>{n?t(n):e()})})}function mi(e){if(e instanceof t){if(e.exitCode===i.NETWORK||e.exitCode===i.TIMEOUT)return!0;let t=e.api?.httpStatus;return t===401||t!==void 0&&t>=500}return e instanceof Error?e.name===`AbortError`||e.name===`TimeoutError`||e.message.includes(`timed out`)||e.message===`fetch failed`:!1}async function hi(e,n,r){process.stderr.write(`Testing key... `);let a={...e,apiKey:n,baseUrl:r},o={url:f(a.baseUrl),method:`POST`,timeout:Math.min(e.timeout,30),body:{model:`qwen3.7-max`,messages:[{role:`user`,content:`hi`}],max_tokens:1}};for(let e=1;e<=3;e++)try{await k(a,o);break}catch(n){if(e>=3||!mi(n))throw process.stderr.write(`Failed
|
|
102
|
-
`),new t(`API key validation failed`,i.AUTH,`Invalid API key.`,{cause:n});let r=bi*2**(e-1);await new Promise(e=>setTimeout(e,r))}process.stderr.write(`Valid
|
|
103
|
-
`);let s=de();s.api_key=n,await Oe(s)}async function gi(e,n,r){let a=Ie(16).toString(`hex`),o,s=Le.createServer(async(e,t)=>{try{if(e.method===`OPTIONS`){t.writeHead(204,{"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`GET, POST, PUT, PATCH, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),t.end();return}if(new URL(e.url??`/`,`http://127.0.0.1`).searchParams.get(`state`)!==a){t.writeHead(400,{"Content-Type":`text/plain; charset=utf-8`}),t.end(`bad state
|
|
104
|
-
`);return}let{accessToken:r,apiKey:i,baseUrl:c,consoleSite:l,consoleRegion:u,consoleSwitchAgent:d,workspaceId:f}=await di(e),p=r||c||l||u||d||f;if(p||i)try{if(p){let e=de();r&&(e.access_token=r),c&&(e.base_url=c),l&&(e.console_site=l),u&&(e.console_region=u),d&&(e.console_switch_agent=Number(d)),f&&(e.workspace_id=f),await Oe(e),process.stderr.write(`Config saved to ${C()}\n`)}i&&await hi(n,i,c||n.baseUrl)}catch(e){o=e,t.writeHead(500,{"Content-Type":`text/plain; charset=utf-8`}),t.end(`Failed to save credentials
|
|
105
|
-
`),s.close();return}t.writeHead(200,{"Content-Type":`text/plain; charset=utf-8`,"Access-Control-Allow-Origin":`*`}),t.end(`OK
|
|
106
|
-
`),(p||i)&&s.close()}catch{t.statusCode=500,t.end()}}),c;try{c=await fi(s)}catch(e){throw new t(`Could not bind to 127.0.0.1 (no free port or permission denied): ${e instanceof Error?e.message:String(e)}`,i.USAGE)}let l=`${e}/console-login?notice=127.0.0.1:${c}?state=${encodeURIComponent(a)}`;r?.needApiKey&&(l+=`&needapikey=true`);try{await pi(l),process.stderr.write(`Opened the login page in your default browser. This process keeps the local port open for the console; press Ctrl+C when finished (or wait for idle timeout).
|
|
107
|
-
`)}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`Could not open the default browser (${t}). Open this URL manually:\n\n`),process.stdout.write(`${l}\n`),process.stderr.write(`
|
|
108
|
-
This process keeps the local port open for the console; press Ctrl+C when finished (or wait for idle timeout).
|
|
109
|
-
`)}if(await new Promise((e,t)=>{let n=!1,r=()=>{n||(n=!0,clearTimeout(i),e())},i=setTimeout(()=>{s.close()},_i);s.once(`close`,r),s.once(`error`,e=>{clearTimeout(i),n||(n=!0,t(e))})}),o)throw o}var _i,vi,yi,bi,xi=M((()=>{_i=900*1e3,vi=65536,yi={domestic:`https://bailian.console.aliyun.com`,international:`https://modelstudio.console.alibabacloud.com`},bi=500})),Si,Ci=M((()=>{Nt(),I(),U(),Bt(),xi(),Si=m({name:`auth login`,description:`Authenticate with API key or console browser login (credentials can coexist)`,skipDefaultApiKeySetup:!0,usage:`bl auth login --api-key <key> | bl auth login --console`,options:[{flag:`--api-key <key>`,description:`DashScope API key to store`},{flag:`--base-url <url>`,description:`DashScope API base URL (used with --api-key for validation)`},{flag:`--console`,description:`Sign in via browser; use --console-site to choose domestic (default) or international`}],examples:[`bl auth login --api-key sk-xxxxx`,`bl auth login --console`],async run(e,t){if(t.console){if(e.dryRun){F(`Would bind a free port on 127.0.0.1 and open the console login URL in your browser.`);return}let t=!!(e.apiKey||e.fileApiKey);await gi(Qr(e.consoleSite||`domestic`),e,{needApiKey:!t});return}let n=process.env.DASHSCOPE_API_KEY;if(n&&!t.apiKey){let t=O(n);D({nonInteractive:e.nonInteractive})?await Xr({message:`Detected DASHSCOPE_API_KEY in environment (${t}).\nYou are already authenticated via env.\nDo you still want to configure local persistent credentials?`,initialValue:!1})||(process.stdout.write(`Login skipped. Using environment variables.
|
|
110
|
-
`),process.exit(0)):process.stderr.write(`Warning: DASHSCOPE_API_KEY is already set in environment.
|
|
111
|
-
`)}let r=t.apiKey||e.apiKey;r||(Lt(process.stderr),process.exit(0));let i=t.baseUrl||void 0,a=i?{...e,baseUrl:i}:e;if(e.dryRun)F(`Would validate and save API key.`);else{if(i){let e=de();e.base_url=i,await Oe(e)}await hi(a,r,a.baseUrl),jt()}}})}));function wi(e){if(e.apiKey)return{configured:!0,source:`flag`,masked:O(e.apiKey)};if(e.fileApiKey)return{configured:!0,source:`config.json`,masked:O(e.fileApiKey)};let t=process.env.DASHSCOPE_API_KEY?.trim();return t?{configured:!0,source:`DASHSCOPE_API_KEY`,masked:O(t)}:{configured:!1}}function Ti(e){return e.accessTokenEnv?{configured:!0,source:`DASHSCOPE_ACCESS_TOKEN`,masked:O(e.accessTokenEnv)}:e.fileAccessToken?{configured:!0,source:`config.json`,masked:O(e.fileAccessToken)}:{configured:!1}}async function Ei(e){try{return await A(e)}catch{return}}async function Di(e){try{return await he(e)}catch{return}}async function Oi(e){let t={api_key:wi(e),access_token:Ti(e)},n=await Ei(e);n&&(t.dashscope_commands={method:n.method,source:n.source,masked:O(n.token)});let r=await Di(e);return r&&(t.console_gateway_commands={method:r.method,source:r.source,masked:O(r.token)}),t}function ki(e){return e.api_key.configured||e.access_token.configured||!!e.dashscope_commands||!!e.console_gateway_commands}function Ai(e){F(`Authentication Status:`),F(` Stored credentials (can coexist):`),e.api_key.configured?F(` API key: ${e.api_key.source} ${e.api_key.masked}`):F(` API key: not configured`),e.access_token.configured?F(` Console token: ${e.access_token.source} ${e.access_token.masked}`):F(` Console token: not configured`),F(` Effective credential per command family:`),e.dashscope_commands?F(` DashScope API: ${e.dashscope_commands.method} (${e.dashscope_commands.source}) ${e.dashscope_commands.masked}`):F(` DashScope API: unavailable`),e.console_gateway_commands?F(` Console gateway: ${e.console_gateway_commands.method} (${e.console_gateway_commands.source}) ${e.console_gateway_commands.masked}`):F(` Console gateway: unavailable (run bl auth login --console)`)}var ji,Mi=M((()=>{I(),Ot(),ji=m({name:`auth status`,description:`Show current authentication state`,usage:`bl auth status`,options:[{flag:`--console-region <region>`,description:`Console region`},{flag:`--console-site <site>`,description:`Console site: domestic, international`},{flag:`--console-switch-agent <uid>`,description:`Switch agent UID`,type:`number`}],examples:[`bl auth status`,`bl auth status --output json`],async run(e,t){let n=h(e.output),r=await Oi(e);if(!ki(r)){P({authenticated:!1,message:`Not authenticated.`,hint:[`DashScope API: bl auth login --api-key <key> or DASHSCOPE_API_KEY`,`Console gateway: bl auth login --console or DASHSCOPE_ACCESS_TOKEN`,`Get API Key: ${Et}`].join(`
|
|
112
|
-
`),...r},n);return}if(n!==`text`){P({authenticated:!0,...r},n);return}Ai(r)}})}));async function Ni(){let e=de();return e.access_token?(delete e.access_token,await Oe(e),!0):!1}var Pi,Fi=M((()=>{I(),Pi=m({name:`auth logout`,description:`Clear stored credentials`,skipDefaultApiKeySetup:!0,usage:`bl auth logout [--console] [--yes] [--dry-run]`,options:[{flag:`--console`,description:`Only clear the console access_token, keep api_key intact`,type:`boolean`},{flag:`--yes`,description:`Skip confirmation prompt`}],examples:[`bl auth logout`,`bl auth logout --console`,`bl auth logout --dry-run`,`bl auth logout --yes`],async run(e,t){let n=de();if(t.console){let t=!!n.access_token;if(e.dryRun){F(t?`Would clear access_token from ~/.bailian/config.json`:`No console access_token to clear.`),F(`No changes made.`);return}t?(await Ni(),process.stderr.write(`Cleared access_token from ${C()}\n`),n.api_key&&process.stderr.write(`api_key is still configured and will be used for authentication.
|
|
113
|
-
`)):process.stderr.write(`No console access_token to clear.
|
|
114
|
-
`);return}let r=!!(n.api_key||n.access_token);if(e.dryRun){F(r?`Would clear api_key / access_token from ~/.bailian/config.json`:`No credentials to clear.`),F(`No changes made.`);return}r?(await p(),process.stderr.write(`Cleared api_key / access_token from ~/.bailian/config.json
|
|
115
|
-
`)):process.stderr.write(`No credentials to clear.
|
|
116
|
-
`)}})}));function Ii(e){let t=[],n;if(e.system&&(n=e.system),e.messagesFile){let r=e.messagesFile,i=Ve(r===`-`?`/dev/stdin`:r,`utf-8`),a=JSON.parse(i);for(let e of a)e.role===`system`?n=typeof e.content==`string`?e.content:``:t.push(e)}if(e.message){let r=new Set([`system`,`user`,`assistant`]),i=e.message;for(let e of i){let i=e.indexOf(`:`),a=i===-1?``:e.slice(0,i);if(r.has(a)){let r=e.slice(i+1);a===`system`?n=r:t.push({role:a,content:r})}else t.push({role:`user`,content:e})}}return{system:n,messages:t}}var Li,Ri=M((()=>{U(),I(),Li=m({name:`text chat`,description:`Send a chat completion (OpenAI compatible, DashScope)`,usage:`bl text chat --message <text> [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: qwen3.7-max)`},{flag:`--message <text>`,description:`Message text (repeatable, prefix role: to set role)`,required:!0,type:`array`},{flag:`--messages-file <path>`,description:`JSON file with messages array (use - for stdin)`},{flag:`--system <text>`,description:`System prompt`},{flag:`--max-tokens <n>`,description:`Maximum tokens to generate (default: 4096)`,type:`number`},{flag:`--temperature <n>`,description:`Sampling temperature (0.0, 2.0]`,type:`number`},{flag:`--top-p <n>`,description:`Nucleus sampling threshold`,type:`number`},{flag:`--stream`,description:`Stream response tokens (default: on in TTY)`},{flag:`--tool <json-or-path>`,description:`Tool definition as JSON or file path (repeatable)`,type:`array`},{flag:`--enable-thinking`,description:`Enable thinking/reasoning mode (for qwen3/qwq models)`},{flag:`--thinking-budget <n>`,description:`Max tokens for thinking (default: 4096)`,type:`number`}],examples:[`bl text chat --message "What is Qwen?"`,`bl text chat --model qwen-max --system "You are a coding assistant." --message "Write fizzbuzz in Python"`,`bl text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"`,`cat conversation.json | bl text chat --messages-file - --stream`,`bl text chat --message "Hello" --output json`,`bl text chat --model qwq-plus --message "Solve 1+1" --enable-thinking`],async run(e,t){let{system:n,messages:r}=Ii(t),i=r;if(i.length===0)if(D({nonInteractive:e.nonInteractive})){let e=await Yr({message:`Enter your message:`});e||(process.stderr.write(`Chat cancelled.
|
|
117
|
-
`),process.exit(1)),i=[{role:`user`,content:e}]}else H(`message`,`bl text chat --message <text>`);let a=t.model||e.defaultTextModel||`qwen3.7-max`,o=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,s=h(e.output),c=[];n&&c.push({role:`system`,content:n}),c.push(...i);let l={model:a,messages:c,max_tokens:t.maxTokens??4096,stream:o};if(t.temperature!==void 0&&(l.temperature=t.temperature),t.topP!==void 0&&(l.top_p=t.topP),t.enableThinking&&(l.enable_thinking=!0,t.thinkingBudget!==void 0&&(l.thinking_budget=t.thinkingBudget)),t.tool&&(l.tools=t.tool.map(e=>{try{return JSON.parse(e)}catch{let t=Ve(e,`utf-8`);return JSON.parse(t)}})),e.dryRun){P({request:l},s);return}let u=f(e.baseUrl);if(o){let t=await pe(e,{url:u,method:`POST`,body:l,stream:!0}),n=``,r=!1,i=s===`text`,a=e.noColor?``:`\x1B[2m`,o=e.noColor?``:`\x1B[0m`,c=process.stdout.isTTY,d=s===`json`?process.stderr:c?process.stdout:process.stderr,f=process.stdout;for await(let e of ce(t)){if(e.data===`[DONE]`)break;try{let t=JSON.parse(e.data);for(let e of t.choices){let t=e.delta;t.reasoning_content&&(i&&!r&&(r=!0,d.write(`${a}Thinking:\n`)),i&&d.write(t.reasoning_content)),t.content&&(i&&r&&(d.write(`${o}\n\nResponse:\n`),r=!1),n+=t.content,i&&f.write(t.content))}}catch{}}r&&d.write(o),s===`json`?P({content:n},s):f.write(`
|
|
118
|
-
`)}else{let t=await k(e,{url:u,method:`POST`,body:l}),n=t.choices?.[0]?.message?.content??``;e.quiet||s===`text`?F(n):P(t,s)}}})}));function zi(){let e=(e,t)=>e.padEnd(t);process.stdout.write(`
|
|
119
|
-
Omni output voices:
|
|
120
|
-
`),process.stdout.write(`${e(`VOICE ID`,12)} ${e(`NAME`,14)} ${e(`DESCRIPTION`,14)} LANGUAGE\n`),process.stdout.write(`${`-`.repeat(12)} ${`-`.repeat(14)} ${`-`.repeat(14)} ${`-`.repeat(12)}\n`);for(let t of Hi)process.stdout.write(`${e(t.voice,12)} ${e(t.name,14)} ${e(t.desc,14)} ${t.lang}\n`);process.stdout.write(`\nTotal: ${Hi.length} voices\n`)}function Bi(e){let n=e.split(`?`)[0].split(`#`)[0],r=Ge(n).slice(1).toLowerCase();if(!r)throw new t(`Cannot infer audio format from "${e}". Use a file/URL whose path ends with: ${Wi.join(`, `)}.`,i.USAGE);let a=Ui[r];if(!a)throw new t(`Unsupported audio extension ".${r}" for "${e}". Supported extensions: ${Wi.join(`, `)}.`,i.USAGE);return a}function Vi(e){let t=Buffer.alloc(44);return t.write(`RIFF`,0),t.writeUInt32LE(36+e,4),t.write(`WAVE`,8),t.write(`fmt `,12),t.writeUInt32LE(16,16),t.writeUInt16LE(1,20),t.writeUInt16LE(1,22),t.writeUInt32LE(24e3,24),t.writeUInt32LE(48e3,28),t.writeUInt16LE(2,32),t.writeUInt16LE(16,34),t.write(`data`,36),t.writeUInt32LE(e,40),t}var Hi,Ui,Wi,Gi,Ki=M((()=>{U(),I(),Hi=[{voice:`Tina`,name:`็ๅฆน`,desc:`็็พไบฒๅ`,lang:`ไธญๆ/่ฑๆ`},{voice:`Dylan`,name:`ๅไบฌ-ๆไธ`,desc:`่กๅๅฐๅนด`,lang:`ไธญๆ/ๅไบฌ`},{voice:`Kiki`,name:`็ฒค่ฏญ-้ฟๆธ
`,desc:`็็พๆธฏๅฆน`,lang:`ไธญๆ/่ฑๆ`},{voice:`Li`,name:`ๅไบฌ-่ๆ`,desc:`ๅไบฌๅคงๅ`,lang:`ไธญๆ/่ฑๆ`},{voice:`Sunny`,name:`ๅๅท-ๆดๅฟ`,desc:`็้ฃๅทๅฆน`,lang:`ไธญๆ`},{voice:`Marcus`,name:`้่ฅฟ-็งฆๅท`,desc:`้ๅๆฑๅญ`,lang:`ไธญๆ/่ฑๆ`},{voice:`Eric`,name:`ๅๅท-็จๅท`,desc:`ๆ้ฝๅคงๅฅ`,lang:`ไธญๆ/่ฑๆ`},{voice:`Rocky`,name:`็ฒค่ฏญ-้ฟๅผบ`,desc:`ๅนฝ้ปๆธฏไป`,lang:`ไธญๆ/่ฑๆ`},{voice:`Jennifer`,name:`่ฉนๅฆฎๅผ`,desc:`็พๅงๅคงๅฅณไธป`,lang:`ไธญๆ/่ฑๆ`},{voice:`Ryan`,name:`็่ถ`,desc:`็พๅงๅผ ๅ็ท`,lang:`ไธญๆ/่ฑๆ`},{voice:`Katerina`,name:`ๅกๆท็ณๅจ`,desc:`ๅพกๅงๆทฑๆ
ๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`Peter`,name:`ๅคฉๆดฅ-ๆๅฝผๅพ`,desc:`ๅคฉๆดฅๆงๅ`,lang:`ไธญๆ/่ฑๆ`},{voice:`Ethan`,name:`ๆจ็
ฆ`,desc:`ๅๆนๅฃ้ณ็ท`,lang:`ไธญๆ/่ฑๆ`}],Ui={wav:`wav`,mp3:`mp3`,amr:`amr`,aac:`aac`,m4a:`aac`,ogg:`ogg`,"3gp":`3gp`,"3gpp":`3gpp`},Wi=Object.keys(Ui),Gi=m({name:`omni`,description:`Multimodal chat with text + audio output (Qwen-Omni)`,usage:`bl omni --message <text> [flags]`,options:[{flag:`--message <text>`,description:`Message text (repeatable, prefix role: to set role)`,required:!0,type:`array`},{flag:`--model <model>`,description:`Model ID (default: qwen3.5-omni-plus)`},{flag:`--system <text>`,description:`System prompt`},{flag:`--image <url>`,description:`Image URL or local file (repeatable)`,type:`array`},{flag:`--audio <url>`,description:`Audio URL or local file (.wav/.mp3/.amr/.aac/.m4a/.ogg/.3gp/.3gpp)`,type:`array`},{flag:`--video <url>`,description:`Video file URL / local path, or comma-separated frame URLs`,type:`array`},{flag:`--voice <voice>`,description:`Output voice ID (default: Tina). Use --list-voices to see all options`},{flag:`--list-voices`,description:`List available output voices and exit`},{flag:`--audio-format <fmt>`,description:`Audio output format (default: wav)`},{flag:`--audio-out <path>`,description:`Save audio to file (default: auto-generate)`},{flag:`--text-only`,description:`Output text only, no audio generation`},{flag:`--max-tokens <n>`,description:`Maximum tokens to generate`,type:`number`},{flag:`--temperature <n>`,description:`Sampling temperature (0.0, 2.0]`,type:`number`}],examples:[`bl omni --list-voices`,`bl omni --message "Hello, who are you?"`,`bl omni --message "Describe this image" --image ./photo.jpg`,`bl omni --message "What is this audio saying?" --audio https://example.com/audio.wav`,`bl omni --message "Summarize this video" --video https://example.com/video.mp4`,`bl omni --message "What is this video about?" --video ./local-video.mp4 --text-only`,`bl omni --message "Answer in Sichuan dialect: How's the weather today?" --voice Sunny`,`bl omni --message "Hello" --text-only --output json`,`bl omni --message "Read this passage aloud" --audio-out greeting.wav`],async run(e,t){if(t.listVoices){zi();return}let n=[];if(t.message&&(n=t.message),n.length===0)if(D({nonInteractive:e.nonInteractive})){let e=await Yr({message:`Enter your message:`});e||(process.stderr.write(`Omni chat cancelled.
|
|
121
|
-
`),process.exit(1)),n=[e]}else H(`message`,`bl text omni --message <text>`);let r=t.model||e.defaultOmniModel||`qwen3.5-omni-plus`,i=t.voice||`Tina`,a=t.audioFormat||`wav`,o=t.textOnly===!0,s=h(e.output),c=[];t.system&&c.push({role:`system`,content:t.system});let l=new Set([`system`,`user`,`assistant`]);for(let e of n){let t=e.indexOf(`:`),n=t===-1?``:e.slice(0,t);if(l.has(n)){let r=e.slice(t+1);n===`system`?c.push({role:`system`,content:r}):c.push({role:n,content:r})}else c.push({role:`user`,content:e})}let u=t.image||[],d=t.audio||[],p=t.video||[],m=[],g=[],_=[];if(u.length>0||d.length>0||p.length>0){let t=await A(e);for(let e of u){let n=await j(e,t.token,r);m.push(n)}for(let e of d){let n=await j(e,t.token,r);g.push({source:e,data:n})}for(let e of p)if(e.includes(`,`)){let n=e.split(`,`).map(e=>e.trim()).filter(Boolean);for(let e of n){let n=await j(e,t.token,r);_.push(`frame:${n}`)}}else{let n=await j(e,t.token,r);_.push(n)}}if(m.length>0||g.length>0||_.length>0){for(let e=c.length-1;e>=0;e--)if(c[e].role===`user`){let t=c[e].content,n=[];typeof t==`string`?n.push({type:`text`,text:t}):Array.isArray(t)&&n.push(...t);for(let e of m)n.push({type:`image_url`,image_url:{url:e}});for(let{source:e,data:t}of g)n.push({type:`input_audio`,input_audio:{data:t,format:Bi(e)}});let r=_.filter(e=>e.startsWith(`frame:`)).map(e=>e.slice(6)),i=_.filter(e=>!e.startsWith(`frame:`));r.length>0&&n.push({type:`video`,video:r});for(let e of i)n.push({type:`video_url`,video_url:{url:e}});c[e]={role:`user`,content:n};break}}let v={model:r,messages:c,stream:!0,stream_options:{include_usage:!0}};if(o||(v.modalities=[`text`,`audio`],v.audio={voice:i,format:a}),t.maxTokens!==void 0&&(v.max_tokens=t.maxTokens),t.temperature!==void 0&&(v.temperature=t.temperature),e.dryRun){P({request:v},s);return}if(!e.quiet){let e=o?`text-only`:`text+audio, voice: ${i}`;process.stderr.write(`[Model: ${r}] [${e}]\n`)}let y=await pe(e,{url:f(e.baseUrl),method:`POST`,body:v,stream:!0}),b=``,x=``,S=process.stdout.isTTY,C=process.stdout;for await(let e of ce(y)){if(e.data===`[DONE]`)break;try{let t=JSON.parse(e.data);for(let e of t.choices){let t=e.delta;t.content&&(b+=t.content,S&&C.write(t.content)),t.audio?.data&&(x+=t.audio.data)}}catch{}}S&&b&&C.write(`
|
|
122
|
-
`);let w;if(x&&!o){let n=Buffer.from(x,`base64`),r=Vi(n.length),i=Buffer.concat([r,n]),a=t.audioOut;if(!a){let{join:t}=await import(`path`);a=t(ge(e,{subDir:`omni`}),`omni_${Date.now()}.wav`)}Ue(a,i),w=a,e.quiet||process.stderr.write(`Audio saved: ${a}\n`)}if(!S||s===`json`){let e={content:b};w&&(e.audio_saved=w,e.voice=i),P(e,s)}}})}));function qi(e){let t=process.stderr.isTTY,n=0,r=null,i=e;return{start(){t&&(r=setInterval(()=>{process.stderr.write(`\r${Yi[n%Yi.length]} ${i}`),n++},80))},update(e){i=e},stop(e){r&&=(clearInterval(r),null),t&&(process.stderr.write(`\r\x1B[K`),e&&process.stderr.write(`${e}\n`))}}}function Ji(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(`
|
|
123
|
-
`)}}}var Yi,Xi=M((()=>{Yi=[`โ `,`โ `,`โ น`,`โ ธ`,`โ ผ`,`โ ด`,`โ ฆ`,`โ ง`,`โ `,`โ `]}));async function Zi(e,n){let r=Date.now()+n.timeoutSec*1e3,a=qi(`Polling...`);e.quiet||a.start();try{for(;Date.now()<r;){let r=await k(e,{url:n.url});if(n.getStatus&&!e.quiet&&a.update(`Status: ${n.getStatus(r)}`),n.isComplete(r))return a.stop(`Done.`),r;if(n.isFailed(r)){a.stop(`Failed.`),e.verbose&&process.stderr.write(`[verbose] Task response: ${JSON.stringify(r,null,2)}\n`);let o=n.getErrorMessage?.(r);throw new t(o?`Task failed: ${o}`:`Task failed.`,i.GENERAL,o?void 0:`Use --verbose to see full API response details.`)}await new Promise(e=>setTimeout(e,n.intervalSec*1e3))}}finally{a.stop()}throw new t(`Polling timed out.`,i.TIMEOUT,`Try increasing --timeout or check task status manually.`)}var Qi=M((()=>{Xi()}));async function $i(e,n,r){let a=await fetch(e,{headers:we()});if(!a.ok)throw new t(`Download failed: HTTP ${a.status}`,i.GENERAL);let o=Number(a.headers.get(`content-length`)||0),s=a.body?.getReader();if(!s)throw new t(`No response body`,i.GENERAL);Be(We(n),{recursive:!0});let c=Re(n),l=o>0&&!r?.quiet?Ji(o,`Downloading`):null,u=0,d=!1;try{let e=new Promise((e,t)=>{c.on(`error`,t)});for(;;){let{done:t,value:n}=await Promise.race([s.read(),e]);if(t)break;c.write(n)||await new Promise(e=>c.once(`drain`,()=>e())),u+=n.byteLength,l?.update(u)}d=!0}finally{if(s.releaseLock(),l?.finish(),await new Promise((e,t)=>{c.on(`finish`,e),c.on(`error`,t),c.end()}),!d)try{He(n)}catch{}}return{size:u}}function ea(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}var ta=M((()=>{Xi()}));function na(e){let t=e.concurrent;return Math.max(1,t??1)}async function ra(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 ia(e,t,n){return Promise.all(e.map(({url:e,destPath:r})=>t(e,r,n).then(()=>r)))}var aa=M((()=>{}));function oa(e,t){if(e)return(t?sa:ca)[e]??e}var sa,ca,la=M((()=>{sa={"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},ca={"16:9":`1664*928`,"4:3":`1472*1104`,"1:1":`1328*1328`,"3:4":`1104*1472`,"9:16":`928*1664`}})),ua,da,fa,pa,ma=M((()=>{ua=`Enable watermark (true/false). Omit flag to use CLI default (true).`,da=`Enable prompt extend (true/false). Omit flag to use CLI default (true).`,fa=`Enable prompt extend (true/false). Omit flag: true for qwen-image sync; parameter omitted on async models (API default).`,pa=`Enable prompt extend (true/false). Omit flag to omit the parameter (DashScope default).`}));function ha(e){return ya.some(t=>e.startsWith(t))}async function ga(e,n,r,a,o,s){let c=E(e.baseUrl),l=(await ra(s,e,()=>k(e,{url:c,method:`POST`,body:r}))).flatMap(e=>e.output.choices||[]).flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);if(l.length===0)throw new t(`Generation completed but no images returned.`,i.GENERAL);await va(l,a,e,o)}async function _a(e,n,r,a,o,s){let c=T(e.baseUrl),l=(await ra(s,e,()=>k(e,{url:c,method:`POST`,body:r,async:!0}),`tasks`)).map(e=>e.output.task_id);if(a.noWait||e.async){P({task_ids:l},o);return}let u=a.pollInterval??3,d=l.map(t=>Zi(e,{url:Se(e.baseUrl,t),intervalSec:u,timeoutSec:e.timeout,isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}})),f=await Promise.all(d),p=[];for(let e of f){if(e.output.choices){let t=e.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);p.push(...t)}if(e.output.results){let t=e.output.results.map(e=>e.url).filter(Boolean);t.length>0&&p.length===0&&p.push(...t)}}if(p.length===0)throw new t(`All tasks completed but no images returned.`,i.GENERAL);await va(p,a,e,o,l.length===1?l[0]:void 0,l)}async function va(e,t,n,r,i,a){let o=ge(n,{flagDir:t.outDir,subDir:t.outDir?void 0:`images`}),s=t.prompt||t._positional?.[0]||``,c=t.outPrefix||b(`image`,s),l=await ia(e.length>1?e.map((e,t)=>({url:e,destPath:Ke(o,`${c}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:e[0],destPath:Ke(o,`${c}.png`)}],$i,{quiet:n.quiet});if(n.quiet)F(l.join(`
|
|
124
|
-
`));else{let t={urls:e,saved:l,total:e.length};i&&(t.task_id=i),a&&a.length>1&&(t.task_ids=a),P(t,r)}}var ya,ba,xa=M((()=>{Qi(),ta(),aa(),U(),I(),la(),ma(),ya=[`qwen-image-2.0`,`qwen-image-max`],ba=m({name:`image generate`,description:`Generate images (Qwen-Image / wan2.x)`,usage:`bl image generate --prompt <text> [flags]`,options:[{flag:`--prompt <text>`,description:`Image description`,required:!0},{flag:`--model <model>`,description:`Model ID (default: qwen-image-2.0)`},{flag:`--size <W*H>`,description:`Image size: ratio (3:4, 16:9, 1:1) or pixels (2048*2048)`},{flag:`--n <count>`,description:`Number of images per request (default: 1, max: 6)`,type:`number`},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--prompt-extend <bool>`,description:fa},{flag:`--watermark <bool>`,description:ua},{flag:`--no-wait`,description:`Return task ID immediately without waiting (async models only)`},{flag:`--out-dir <dir>`,description:`Download images to directory`},{flag:`--out-prefix <prefix>`,description:`Filename prefix (default: image)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 3)`,type:`number`}],examples:[`bl image generate --prompt "A cat in a spacesuit on Mars"`,`bl image generate --prompt "Logo design" --n 3 --out-dir ./generated/`,`bl image generate --prompt "Mountain landscape" --size 2688*1536`,`bl image generate --prompt "A castle" --seed 42 --prompt-extend false`,`bl image generate --prompt "Logo" --watermark false`,`bl image generate --prompt "An alien in the space" --watermark false`,`bl image generate --prompt "sunset" --model wan2.6-t2i --no-wait --quiet`,`bl image generate --prompt "Pro quality" --model qwen-image-2.0-pro`,`bl image generate --prompt "Product shots" --n 2 --concurrent 3 # 6 images in parallel`],async run(e,t){let n=t.prompt??t._positional?.[0];if(!n)if(D({nonInteractive:e.nonInteractive})){let e=await Yr({message:`Enter your image prompt:`});e||(process.stderr.write(`Image generation cancelled.
|
|
125
|
-
`),process.exit(1)),n=e}else H(`prompt`,`bl image generate --prompt <text>`);let r=t.model||e.defaultImageModel||`qwen-image-2.0`,i=ha(r),a=oa(t.size||`1:1`,i),o=t.n??1,s=na(t),c=me(t.promptExtend,i?!0:void 0,`prompt-extend`),l=_e(t.watermark),u={model:r,input:{messages:[{role:`user`,content:[{text:n}]}]},parameters:{size:a,n:o,seed:t.seed,prompt_extend:c,watermark:l,negative_prompt:t.negativePrompt||void 0}},d=h(e.output);if(e.dryRun){P({request:u,mode:i?`sync`:`async`},d);return}e.quiet||process.stderr.write(`[Model: ${r}] [Mode: ${i?`sync`:`async`}]\n`),i?await ga(e,r,u,t,d,s):await _a(e,r,u,t,d,s)}})})),Sa,Ca=M((()=>{ta(),aa(),U(),I(),la(),ma(),Sa=m({name:`image edit`,description:`Edit an existing image with text instructions (Qwen-Image)`,usage:`bl image edit --image <url> --prompt <text> [flags]`,options:[{flag:`--image <url>`,description:`Source image URL or local file path (repeatable for multi-image merge)`,required:!0,type:`array`},{flag:`--prompt <text>`,description:`Edit instruction text`,required:!0},{flag:`--model <model>`,description:`Model ID (default: qwen-image-2.0)`},{flag:`--size <W*H>`,description:`Output image size: ratio (3:4, 16:9) or pixels (2048*2048)`},{flag:`--n <count>`,description:`Number of images (default: 1, max: 6)`,type:`number`},{flag:`--seed <n>`,description:`Random seed for reproducible results`,type:`number`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--prompt-extend <bool>`,description:da},{flag:`--watermark <bool>`,description:ua},{flag:`--out-dir <dir>`,description:`Download images to directory`},{flag:`--out-prefix <prefix>`,description:`Filename prefix (default: edited)`}],examples:[`bl image edit --image ./photo.png --prompt "Replace the background with a beach"`,`bl image edit --image https://example.com/logo.png --prompt "Change color to blue" --n 3`,`bl image edit --image ./a.png --image ./b.png --prompt "Merge two images into one collage"`,`bl image edit --image https://example.com/photo.png --prompt "Remove the person" --model qwen-image-2.0-pro`,`bl image edit --image ./photo.png --prompt "Replace the background with a beach" --watermark false`],async run(e,n){let r=[];Array.isArray(n.image)?r=n.image:typeof n.image==`string`&&(r=[n.image]),r.length===0&&H(`image`,`bl image edit --image <url> --prompt <text>`);let a=n.prompt;if(!a)if(D({nonInteractive:e.nonInteractive})){let e=await Yr({message:`Enter your edit instruction:`});e||(process.stderr.write(`Image editing cancelled.
|
|
126
|
-
`),process.exit(1)),a=e}else H(`prompt`,`bl image edit --image <url> --prompt <text>`);let o=n.model||e.defaultImageModel||`qwen-image-2.0`,s=await A(e),c=await Promise.all(r.map(e=>j(e,s.token,o))),l=n.n??1,u=me(n.promptExtend,!0,`prompt-extend`),d=c.map(e=>({image:e}));d.push({text:a});let f=_e(n.watermark),p={model:o,input:{messages:[{role:`user`,content:d}]},parameters:{size:oa(n.size,!0),n:l,seed:n.seed,prompt_extend:u,watermark:f,negative_prompt:n.negativePrompt||void 0}};xe(p.parameters);let m=h(e.output);if(e.dryRun){P({request:p},m);return}e.quiet||process.stderr.write(`[Model: ${o}] [Mode: sync] [Images: ${c.length}]\n`);let g=E(e.baseUrl),_=(await ra(na(n),e,()=>k(e,{url:g,method:`POST`,body:p}))).flatMap(e=>e.output.choices||[]).flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);if(_.length===0)throw new t(`Edit completed but no images returned.`,i.GENERAL);let v=ge(e,{flagDir:n.outDir,subDir:n.outDir?void 0:`images`}),y=n.outPrefix||b(`edited`,n?.prompt),x=await ia(_.length>1?_.map((e,t)=>({url:e,destPath:Ke(v,`${y}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:_[0],destPath:Ke(v,`${y}.png`)}],$i,{quiet:e.quiet});e.quiet?F(x.join(`
|
|
127
|
-
`)):P({urls:_,saved:x,total:_.length},m)}})})),wa,Ta=M((()=>{Qi(),ta(),aa(),U(),I(),ma(),wa=m({name:`video generate`,description:`Generate a video from text or image (happyhorse-1.1-t2v / happyhorse-1.1-i2v / wan2.6-t2v)`,usage:`bl video generate --prompt <text> [--image <url>] [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.1-t2v, or happyhorse-1.1-i2v with --image)`},{flag:`--prompt <text>`,description:`Video description`,required:!0},{flag:`--image <url>`,description:`Input image URL for image-to-video generation`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--resolution <res>`,description:`Resolution: 720P or 1080P (default: 1080P)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (e.g. 16:9, 9:16, 1:1)`},{flag:`--duration <seconds>`,description:`Video duration in seconds (default: 5)`,type:`number`},{flag:`--prompt-extend <bool>`,description:pa},{flag:`--watermark <bool>`,description:ua},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--download <path>`,description:`Save video to file on completion`},{flag:`--no-wait`,description:`Return task ID immediately without waiting`},{flag:`--async`,description:`Return task ID immediately (agent/CI mode, same as --no-wait)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 5)`,type:`number`}],examples:[`bl video generate --prompt "A person reading a book, static shot"`,`bl video generate --prompt "Ocean waves at sunset." --download sunset.mp4`,`bl video generate --image https://example.com/cat.png --prompt "Make the cat in the scene move"`,`bl video generate --prompt "Mountain landscape" --resolution 720P --duration 5`,`bl video generate --prompt "A cat playing with a ball" --watermark false`],async run(e,n){let r=n.prompt;if(!r)if(D({nonInteractive:e.nonInteractive})){let e=await Yr({message:`Enter your video prompt:`});e||(process.stderr.write(`Video generation cancelled.
|
|
128
|
-
`),process.exit(1)),r=e}else H(`prompt`,`bl video generate --prompt <text>`);let a=n.model||e.defaultVideoModel||(n.image?`happyhorse-1.1-i2v`:`happyhorse-1.1-t2v`),o=h(e.output),s=n.image,c;s&&(c=await j(s,(await A(e)).token,a));let l=_e(n.watermark),u=me(n.promptExtend,void 0,`prompt-extend`),d={model:a,input:{prompt:r,negative_prompt:n.negativePrompt||void 0,...c?{media:[{type:`first_frame`,url:c}]}:{}},parameters:{resolution:n.resolution||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,prompt_extend:u,watermark:l,seed:n.seed}};if(e.dryRun){P({request:d},o);return}let f=na(n),p=De(e.baseUrl),m=(await ra(f,e,()=>k(e,{url:p,method:`POST`,body:d,async:!0}),`tasks`)).map(e=>e.output.task_id);if(e.quiet||process.stderr.write(`[Model: ${a}]\n`),n.noWait||e.async){P(m.length===1?{task_id:m[0]}:{task_ids:m},o);return}let g=n.pollInterval??5,_=m.map(t=>Zi(e,{url:Se(e.baseUrl,t),intervalSec:g,timeoutSec:e.timeout,isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}})),v=await Promise.all(_),y=[];for(let e=0;e<v.length;e++){let t=v[e],n=t.output.video_url||t.output.results&&t.output.results[0]?.url;n&&y.push({taskId:m[e],videoUrl:n})}if(y.length===0)throw new t(`All tasks completed but no video URLs returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await $i(y[0].videoUrl,t,{quiet:e.quiet});e.quiet?F(t):P({task_id:y[0].taskId,video_url:y[0].videoUrl,status:`SUCCEEDED`,saved:t,size:ea(r)},o);return}let b=ge(e,{subDir:`videos`}),{join:x}=await import(`path`),S=[];await Promise.all(y.map(async({taskId:t,videoUrl:n})=>{let r=x(b,`${t}.mp4`);await $i(n,r,{quiet:e.quiet}),S.push({task_id:t,video_url:n,saved:r})})),S.length===1?P(S[0],o):P({videos:S,total:S.length},o)}})})),Ea,Da=M((()=>{Qi(),ta(),U(),I(),ma(),Ea=m({name:`video edit`,description:`Edit a video with happyhorse-1.0-video-edit (style transfer, object replacement, etc.)`,usage:`bl video edit --video <url> --prompt <text> [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-video-edit)`},{flag:`--video <url>`,description:`Input video URL or local file (mp4/mov, 2-10s)`,required:!0},{flag:`--prompt <text>`,description:`Edit instruction (e.g. "Convert the scene to a claymation style")`},{flag:`--ref-image <url>`,description:`Reference image URL (up to 4, comma-separated)`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--resolution <res>`,description:`Resolution: 720P or 1080P (default: 1080P)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (16:9, 9:16, 1:1, 4:3, 3:4)`},{flag:`--duration <seconds>`,description:`Output video duration in seconds (2-10)`,type:`number`},{flag:`--audio-setting <mode>`,description:`Audio: auto (default) or origin (keep original)`},{flag:`--prompt-extend <bool>`,description:pa},{flag:`--watermark <bool>`,description:ua},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--download <path>`,description:`Save video to file on completion`},{flag:`--no-wait`,description:`Return task ID immediately without waiting`},{flag:`--async`,description:`Return task ID immediately (agent/CI mode, same as --no-wait)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 15)`,type:`number`}],examples:[`bl video edit --video https://example.com/input.mp4 --prompt "Convert the entire scene to claymation style"`,`bl video edit --video https://example.com/input.mp4 --prompt "Replace the outfit with the style shown in the image" --ref-image https://example.com/clothes.png`,`bl video edit --video https://example.com/input.mp4 --prompt "Convert to anime style" --resolution 720P --download output.mp4`,`bl video edit --video https://example.com/input.mp4 --prompt "Put clothes on the kitten in the video" --watermark false`],async run(e,n){let r=n.video;if(!r)if(D({nonInteractive:e.nonInteractive})){let e=await Yr({message:`Enter the video URL to edit:`});e||(process.stderr.write(`Video editing cancelled.
|
|
129
|
-
`),process.exit(1)),r=e}else H(`video`,`bl video edit --video <url> --prompt <text>`);let a=n.prompt;if(!a&&D({nonInteractive:e.nonInteractive})){let e=await Yr({message:`Enter your edit instruction:`});e||(process.stderr.write(`Video editing cancelled.
|
|
130
|
-
`),process.exit(1)),a=e}let o=n.model||`happyhorse-1.0-video-edit`,s=h(e.output),c=await A(e),l=[{type:`video`,url:await j(r,c.token,o)}],u=n.refImage;if(u){let e=u.split(`,`).map(e=>e.trim()).filter(Boolean);for(let t of e){let e=await j(t,c.token,o);l.push({type:`reference_image`,url:e})}}let d=me(n.promptExtend,void 0,`prompt-extend`),f=_e(n.watermark),p={model:o,input:{prompt:a||void 0,negative_prompt:n.negativePrompt||void 0,media:l},parameters:{resolution:n.resolution||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,audio_setting:n.audioSetting||void 0,prompt_extend:d,watermark:f,seed:n.seed}};if(e.dryRun){P({request:p},s);return}let m=(await k(e,{url:De(e.baseUrl),method:`POST`,body:p,async:!0})).output.task_id;if(e.quiet||(process.stderr.write(`[Model: ${o}]\n`),process.stderr.write(`Note: Video editing typically takes 5-8 minutes. Please be patient.
|
|
131
|
-
`)),n.noWait||e.async){P({task_id:m},s);return}let g=n.pollInterval??15,_=await Zi(e,{url:Se(e.baseUrl,m),intervalSec:g,timeoutSec:Math.max(e.timeout,600),isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}}),v=_.output.video_url||_.output.results&&_.output.results[0]?.url;if(!v)throw new t(`Task completed but no video URL returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await $i(v,t,{quiet:e.quiet});e.quiet?F(t):P({task_id:m,video_url:v,status:`SUCCEEDED`,saved:t,size:ea(r)},s);return}let y=await import(`path`),b=ge(e,{subDir:`videos`}),x=y.join(b,`${m}.mp4`);await $i(v,x,{quiet:e.quiet}),P({task_id:m,video_url:v,saved:x},s)}})})),Oa,ka=M((()=>{Qi(),ta(),U(),I(),ma(),Oa=m({name:`video ref`,description:`Reference-to-video generation (happyhorse-1.1-r2v / wan2.6-r2v): multi-subject, multi-shot with voice`,usage:`bl video ref --prompt <text> --image <url>... [--ref-video <url>...] [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.1-r2v)`},{flag:`--prompt <text>`,description:`Video description with reference markers (image1, video1, etc.)`,required:!0},{flag:`--image <url>`,description:`Reference image URL or local file (repeatable for multiple subjects)`,type:`array`},{flag:`--ref-video <url>`,description:`Reference video URL or local file (repeatable)`,type:`array`},{flag:`--image-voice <url>`,description:`Voice URL for corresponding image (pairs by position)`,type:`array`},{flag:`--video-voice <url>`,description:`Voice URL for corresponding ref-video (pairs by position)`,type:`array`},{flag:`--resolution <res>`,description:`Resolution: 720P or 1080P (default: 1080P)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (16:9, 9:16, 1:1)`},{flag:`--duration <seconds>`,description:`Video duration in seconds (default: 5)`,type:`number`},{flag:`--prompt-extend <bool>`,description:pa},{flag:`--watermark <bool>`,description:ua},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--download <path>`,description:`Save video to file on completion`},{flag:`--no-wait`,description:`Return task ID immediately without waiting`},{flag:`--async`,description:`Return task ID immediately (agent/CI mode, same as --no-wait)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 15)`,type:`number`}],examples:[`bl video ref --prompt "Image1 running on the grass" --image person.jpg`,`bl video ref --prompt "Video 1 plays guitar, Image 1 walks over" --ref-video scene.mp4 --image person.jpg`,`bl video ref --prompt "Image 1 speaks" --image person.jpg --image-voice voice.mp3 --resolution 1080P`,`bl video ref --prompt "Image 1 and Image 2 have a conversation" --image a.jpg --image b.jpg --image-voice va.mp3 --image-voice vb.mp3`,`bl video ref --prompt "Image 1 drinks water" --image person.jpg --watermark false`],async run(e,n){let r=n.prompt;if(!r)if(D({nonInteractive:e.nonInteractive})){let e=await Yr({message:`Enter your video prompt (use Image1, Video1 to reference inputs):`});e||(process.stderr.write(`Video generation cancelled.
|
|
132
|
-
`),process.exit(1)),r=e}else H(`prompt`,`bl video ref --prompt <text> --image <url>`);let a=n.image||[],o=n.refVideo||[];if(a.length===0&&o.length===0)throw new t(`At least one --image or --ref-video is required.`,i.USAGE,`bl video ref --prompt "description" --image person.jpg`);let s=n.imageVoice||[],c=n.videoVoice||[],l=n.model||`happyhorse-1.1-r2v`,u=h(e.output),d=await A(e),f=[];for(let e=0;e<a.length;e++){let t={type:`reference_image`,url:await j(a[e],d.token,l)};s[e]&&(t.reference_voice=await j(s[e],d.token,l)),f.push(t)}for(let e=0;e<o.length;e++){let t={type:`reference_video`,url:await j(o[e],d.token,l)};c[e]&&(t.reference_voice=await j(c[e],d.token,l)),f.push(t)}let p=me(n.promptExtend,void 0,`prompt-extend`),m=_e(n.watermark),g={model:l,input:{prompt:r,media:f},parameters:{resolution:n.resolution||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,prompt_extend:p,watermark:m,seed:n.seed}};if(e.dryRun){P({request:g},u);return}let _=(await k(e,{url:De(e.baseUrl),method:`POST`,body:g,async:!0})).output.task_id;if(e.quiet||(process.stderr.write(`[Model: ${l}]\n`),process.stderr.write(`Note: Reference-to-video typically takes 5-10 minutes. Please be patient.
|
|
133
|
-
`)),n.noWait||e.async){P({task_id:_},u);return}let v=n.pollInterval??15,y=await Zi(e,{url:Se(e.baseUrl,_),intervalSec:v,timeoutSec:Math.max(e.timeout,600),isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}}),b=y.output.video_url||y.output.results&&y.output.results[0]?.url;if(!b)throw new t(`Task completed but no video URL returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await $i(b,t,{quiet:e.quiet});e.quiet?F(t):P({task_id:_,video_url:b,status:`SUCCEEDED`,saved:t,size:ea(r)},u);return}let{join:x}=await import(`path`),S=x(ge(e,{subDir:`videos`}),`${_}.mp4`);await $i(b,S,{quiet:e.quiet}),P({task_id:_,video_url:b,saved:S},u)}})})),Aa,ja=M((()=>{U(),I(),Aa=m({name:`video task get`,description:`Query async task status`,usage:`bl video task get --task-id <id>`,options:[{flag:`--task-id <id>`,description:`Async task ID`}],examples:[`bl video task get --task-id 3b256896-3e70-xxxx-xxxx-xxxxxxxxxxxx`,`bl video task get --task-id 3b256896-3e70-xxxx --output json`],async run(e,t){let n=t.taskId;n||H(`task-id`,`bl video task get --task-id <id>`);let r=h(e.output);if(e.dryRun){P({task_id:n},r);return}let i=await k(e,{url:Se(e.baseUrl,n)});if(e.quiet){F(i.output.task_status);return}P({task_id:i.output.task_id,task_status:i.output.task_status,video_url:i.output.video_url,results:i.output.results,submit_time:i.output.submit_time,end_time:i.output.end_time},r)}})})),Ma,Na=M((()=>{ta(),U(),I(),Ma=m({name:`video download`,description:`Download a completed video by task ID`,usage:`bl video download --task-id <id> --out <path>`,options:[{flag:`--task-id <id>`,description:`Task ID to download from`},{flag:`--out <path>`,description:`Output file path`}],examples:[`bl video download --task-id 3b256896-xxxx --out video.mp4`,`bl video download --task-id 3b256896-xxxx --out video.mp4 --quiet`],async run(e,n){let r=n.taskId;r||H(`task-id`,`bl video download --task-id <id> --out <path>`);let a=n.out;a||H(`out`,`bl video download --task-id <id> --out video.mp4`);let o=h(e.output);if(e.dryRun){P({task_id:r,action:`download`,out:a},o);return}let s=await k(e,{url:Se(e.baseUrl,r)});if(s.output.task_status!==`SUCCEEDED`)throw new t(`Task is not complete (status: ${s.output.task_status}).`,i.GENERAL,`Wait for the task to complete before downloading.`);let c=s.output.video_url||s.output.results&&s.output.results[0]?.url;if(!c)throw new t(`No download URL available for this task.`,i.GENERAL);let{size:l}=await $i(c,a,{quiet:e.quiet});if(e.quiet){F(a);return}P({saved:a,size:ea(l)},o)}})}));function Pa(e){let t=Ge(e).toLowerCase().split(`?`)[0];return!!(La.has(t)||/\.(mp4|mov|avi|mkv|webm|flv|wmv)(\?|$)/i.test(e))}async function Fa(e){if(e.startsWith(`data:`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`oss://`))return e;if(!ze(e))throw new t(`File not found: ${e}`,i.USAGE);let n=Ge(e).toLowerCase(),r=Ia[n];if(!r)throw new t(`Unsupported image format "${n}". Supported: jpg, jpeg, png, webp`,i.USAGE);return`data:${r};base64,${Ve(e).toString(`base64`)}`}var Ia,La,Ra,za=M((()=>{U(),I(),Ia={".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".webp":`image/webp`},La=new Set([`.mp4`,`.mov`,`.avi`,`.mkv`,`.webm`,`.flv`,`.wmv`]),Ra=m({name:`vision describe`,description:`Describe an image or video using Qwen-VL`,usage:`bl vision describe --image <path-or-url> [--video <url>] [--prompt <text>]`,options:[{flag:`--image <path-or-url>`,description:`Local image path or URL`},{flag:`--video <url>`,description:`Video file URL or local path (mp4/mov/avi/mkv/webm)`,type:`array`},{flag:`--prompt <text>`,description:`Question about the content (default: auto-detected)`},{flag:`--model <model>`,description:`Vision model (default: qwen3-vl-plus)`}],examples:[`bl vision describe --image photo.jpg`,`bl vision describe --image https://example.com/photo.jpg --prompt "What breed is this dog?"`,`bl vision describe --video https://example.com/video.mp4 --prompt "Summarize the video content"`,`bl vision describe --video ./local-video.mp4`,`bl vision describe --image photo.png --prompt "Extract the text" --model qwen-vl-plus`],async run(e,n){let r=n.image??n._positional?.[0],a=n.video??[],o=n.model||`qwen3-vl-plus`;r&&Pa(r)&&(a.push(r),r=void 0);let s=a.length>0,c=s?`Describe the video.`:`Describe the image.`,l=n.prompt||c;if(!r&&!s)if(D({nonInteractive:e.nonInteractive})){let e=await Yr({message:`Enter image/video path or URL:`});e||(process.stderr.write(`Vision describe cancelled.
|
|
134
|
-
`),process.exit(1)),Pa(e)?a.push(e):r=e}else throw new t(`Missing required argument --image or --video.`,i.USAGE,`bl vision describe --image <path-or-url>
|
|
135
|
-
bl vision describe --video <url-or-path>`);let u=h(e.output);if(e.dryRun){P({request:{prompt:l,image:r,video:a.length?a:void 0,model:o}},u);return}let d=[];if(a.length>0)for(let n of a){let r=n;if(ee(n)){if(!ze(n))throw new t(`Video file not found: ${n}`,i.USAGE);r=await j(n,(await A(e)).token,o)}d.push({type:`video_url`,video_url:{url:r}})}if(r){let t=await Fa(r),n=t;if(ee(r)&&t.startsWith(`data:`)){let{statSync:t}=await import(`fs`);if(t(r).size>5*1024*1024){let t=await A(e);n=await j(r,t.token,o)}}d.push({type:`image_url`,image_url:{url:n}})}d.push({type:`text`,text:l});let p={model:o,messages:[{role:`user`,content:d}]},m=await k(e,{url:f(e.baseUrl),method:`POST`,body:p}),g=m.choices?.[0]?.message?.content;if(u!==`text`){P(m,u);return}F(g||``)}})})),Ba,Va=M((()=>{I(),Ba=m({name:`config show`,description:`Display current configuration`,skipDefaultApiKeySetup:!0,usage:`bl config show`,examples:[`bl config show`,`bl config show --output json`],async run(e,t){let n=de(),r=h(e.output),i={...n,base_url:e.baseUrl,output:e.output,timeout:e.timeout,config_file:C()};typeof i.api_key==`string`&&(i.api_key=O(i.api_key)),typeof i.access_token==`string`&&(i.access_token=O(i.access_token)),typeof i.access_key_id==`string`&&(i.access_key_id=O(i.access_key_id)),typeof i.access_key_secret==`string`&&(i.access_key_secret=O(i.access_key_secret)),P(i,r)}})})),Ha,Ua,Wa,Ga,Ka=M((()=>{I(),Ha=[`base_url`,`output`,`output_dir`,`timeout`,`api_key`,`access_token`,`default_text_model`,`default_video_model`,`default_image_model`,`default_speech_model`,`default_omni_model`,`access_key_id`,`access_key_secret`,`workspace_id`],Ua=new Set([`api_key`,`access_token`,`access_key_id`,`access_key_secret`]),Wa={"base-url":`base_url`,"output-dir":`output_dir`,"api-key":`api_key`,"access-token":`access_token`,"default-text-model":`default_text_model`,"default-video-model":`default_video_model`,"default-image-model":`default_image_model`,"default-speech-model":`default_speech_model`,"default-omni-model":`default_omni_model`,"access-key-id":`access_key_id`,"access-key-secret":`access_key_secret`,"workspace-id":`workspace_id`},Ga=m({name:`config set`,description:`Set a config value`,skipDefaultApiKeySetup:!0,usage:`bl config set --key <key> --value <value>`,options:[{flag:`--key <key>`,description:`Config key (base_url, output, output_dir, timeout, api_key, access_token, default_*_model, access_key_id, access_key_secret, workspace_id)`},{flag:`--value <value>`,description:`Value to set`}],examples:[`bl config set --key output --value json`,`bl config set --key timeout --value 600`,`bl config set --key base_url --value https://dashscope.aliyuncs.com`],async run(e,n){let r=n.key,a=n.value;if(!r||a===void 0)throw new t(`--key and --value are required.`,i.USAGE,`bl config set --key <key> --value <value>`);let o=Wa[r]||r;if(!Ha.includes(o))throw new t(`Invalid config key "${r}". Valid keys: ${Ha.join(`, `)}`,i.USAGE);if(o===`output`&&![`text`,`json`].includes(a))throw new t(`Invalid output format "${a}". Valid values: text, json`,i.USAGE);if(o===`timeout`){let e=Number(a);if(isNaN(e)||e<=0)throw new t(`Invalid timeout "${a}". Must be a positive number.`,i.USAGE)}let s=h(e.output);if(e.dryRun){P({would_set:{[o]:a}},s);return}let c=de();if(c[o]=o===`timeout`?Number(a):a,await Oe(c),!e.quiet){let e=Ua.has(o)?O(String(c[o])):c[o];P({[o]:e},s)}}})})),qa,Ja,Ya=M((()=>{qa=[`auth `,`config `,`update`],Ja=m({name:`config export-schema`,description:`Export all (or one) CLI command(s) as Anthropic/OpenAI-compatible JSON tool schemas`,skipDefaultApiKeySetup:!0,usage:`bl config export-schema [--command "<name>"]`,options:[{flag:`--command <name>`,description:`Export schema for a specific command only (e.g. "image generate")`}],examples:[`bl config export-schema`,`bl config export-schema --command "video generate"`],async run(e,n){let{commands:r}=await Promise.resolve().then(()=>(Em(),wm)),a=n.command;if(a){let e=r[a];if(!e)throw new t(`Command "${a}" not found.`,i.USAGE);let n=x(e);process.stdout.write(JSON.stringify(n,null,2)+`
|
|
136
|
-
`);return}let o=Object.values(r).filter(e=>!qa.some(t=>e.name.startsWith(t))).map(e=>x(e));process.stdout.write(JSON.stringify(o,null,2)+`
|
|
137
|
-
`)}})}));Ci(),Mi(),Fi(),Ri(),Ki(),xa(),Ca(),Ta(),Da(),ka(),ja(),Na(),za(),Va(),Ka(),Ya();var Xa=`1.4.2`,Za,Qa=M((()=>{Za=Xa}));function $a(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if((n[e]??0)>(r[e]??0))return!0;if((n[e]??0)<(r[e]??0))return!1}return!1}function eo(){try{let e=Ve(so(),`utf-8`);return JSON.parse(e)}catch{return null}}function to(e){try{Ue(so(),JSON.stringify(e))}catch{}}async function no(e=lo){try{let t=oo.replace(`/`,`%2f`),n=await fetch(`${ao}/${t}/latest`,{headers:{Accept:`application/json`,...we()},signal:AbortSignal.timeout(e)});return n.ok?(await n.json()).version??null:null}catch{return null}}function ro(){return uo}async function io(e){if(process.env.CI||!process.stderr.isTTY)return;let t=eo(),n=Date.now();if(t&&n-t.lastChecked<co){t.latestVersion&&$a(t.latestVersion,e)&&(uo=t.latestVersion);return}let r=await no();r&&(to({lastChecked:n,latestVersion:r}),r&&$a(r,e)&&(uo=r))}var ao,oo,so,co,lo,uo,fo=M((()=>{ao=`https://registry.npmjs.org`,oo=`bailian-cli`,so=()=>Ke(S(),`update-state.json`),co=14400*1e3,lo=3e3,uo=null}));function po(){return{cmd:`npm install -g ${oo}@latest`,label:`npm`}}function mo(e){let{green:t,yellow:n,reset:r}=e;process.stderr.write(`
|
|
138
|
-
Updating agent skill...
|
|
139
|
-
`);try{qe(ho,{stdio:`inherit`}),process.stderr.write(`${t}\u2713 Agent skill updated.${r}\n`)}catch{process.stderr.write(`${n}Agent skill update skipped. Run manually: ${ho}${r}\n`)}}var ho,go,_o=M((()=>{Qa(),fo(),ho=`npx skills add modelstudioai/cli --all -g -y`,go=m({name:`update`,description:`Update bl to the latest version`,skipDefaultApiKeySetup:!0,usage:`bl update`,examples:[`bl update`],async run(){let e=process.stderr.isTTY,t=e?`\x1B[32m`:``,n=e?`\x1B[33m`:``,r=e?`\x1B[0m`:``;process.stderr.write(`Current version: ${n}${Za}${r}\n`),process.stderr.write(`Checking for updates...
|
|
140
|
-
`);let i=await no(5e3);if(i&&i===Za){process.stderr.write(`${t}\u2713 Already up to date (${Za}).${r}\n`),mo({green:t,yellow:n,reset:r});return}i&&process.stderr.write(`Latest version: ${t}${i}${r}\n\n`);let{cmd:a,label:o}=po();process.stderr.write(`Updating ${oo} via ${o}...\n\n`);try{qe(a,{stdio:`inherit`});try{let e=qe(`bl --version 2>/dev/null`,{encoding:`utf-8`}).trim().replace(/^bl\s+/,``);process.stderr.write(`\n${t}\u2713 Update complete: ${Za} \u2192 ${e}${r}\n`);try{Ue(Ke(S(),`update-state.json`),JSON.stringify({lastChecked:Date.now(),latestVersion:e}))}catch{}}catch{process.stderr.write(`\n${t}\u2713 Update complete.${r}\n`)}mo({green:t,yellow:n,reset:r})}catch{process.stderr.write(`
|
|
141
|
-
Automatic update failed. Please run manually:
|
|
142
|
-
`),process.stderr.write(` ${a}\n\n`)}}})})),vo,yo=M((()=>{U(),I(),vo=m({name:`app call`,description:`Call a Bailian application (agent or workflow)`,usage:`bl app call --app-id <id> --prompt <text> [flags]`,options:[{flag:`--app-id <id>`,description:`Application ID (required)`,required:!0},{flag:`--prompt <text>`,description:`Input prompt text`,required:!0},{flag:`--image <url>`,description:`Image URL(s) to pass to the app (repeatable)`,type:`array`},{flag:`--file-id <id>`,description:`Pre-uploaded file ID(s) (repeatable)`,type:`array`},{flag:`--session-id <id>`,description:`Session ID for multi-turn conversation`},{flag:`--stream`,description:`Stream response (default: on in TTY)`},{flag:`--pipeline-ids <ids>`,description:`Knowledge base pipeline IDs (comma-separated)`},{flag:`--memory-id <id>`,description:`Memory ID for long-term memory`},{flag:`--biz-params <json>`,description:`Business parameters JSON (workflow variables)`},{flag:`--has-thoughts`,description:`Show agent thinking process`}],examples:[`bl app call --app-id abc123 --prompt "Hello"`,`bl app call --app-id abc123 --prompt "Describe this image" --image https://example.com/photo.jpg`,`bl app call --app-id abc123 --prompt "Analyze the image" --image img1.jpg --image img2.jpg`,`bl app call --app-id abc123 --prompt "Continue" --session-id sess_xxx --stream`,`bl app call --app-id abc123 --prompt "Search for materials" --pipeline-ids pipe1,pipe2`,`bl app call --app-id abc123 --prompt "Start" --biz-params '{"key":"value"}'`],async run(e,t){let n=t.appId;n||H(`app-id`,`bl app call --app-id <id> --prompt <text>`);let r=t.prompt;r||H(`prompt`,`bl app call --app-id <id> --prompt <text>`);let i=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,a=h(e.output),o={input:{prompt:r},parameters:{incremental_output:i}};t.sessionId&&(o.input.session_id=t.sessionId);let s=t.image;s&&s.length>0&&(o.input.image_list=s);let l=t.fileId;if(l&&l.length>0&&(o.input.file_ids=l),t.hasThoughts&&(o.parameters.has_thoughts=!0),t.pipelineIds){let e=t.pipelineIds.split(`,`).map(e=>e.trim()).filter(Boolean);o.parameters.rag_options={pipeline_ids:e}}if(t.memoryId&&(o.parameters.memory_id=t.memoryId),t.bizParams)try{o.input.biz_params=JSON.parse(t.bizParams)}catch{process.stderr.write(`Error: --biz-params must be valid JSON
|
|
143
|
-
`),process.exit(1)}if(e.dryRun){P({endpoint:c(e.baseUrl,n),request:o},a);return}let u=c(e.baseUrl,n);if(i){let n=await pe(e,{url:u,method:`POST`,body:o,headers:{"X-DashScope-SSE":`enable`},stream:!0}),r=``,i=``,s=a===`text`,c=e.noColor?``:`\x1B[2m`,l=e.noColor?``:`\x1B[0m`;for await(let e of ce(n)){if(e.data===`[DONE]`)break;try{let n=JSON.parse(e.data),a=n.output?.text;if(a&&(s&&process.stdout.write(a),r+=a),n.output?.session_id&&(i=n.output.session_id),n.output?.thoughts&&t.hasThoughts)for(let e of n.output.thoughts)e.thought&&process.stderr.write(`${c}[Thinking] ${e.thought}${l}\n`),e.action_name&&process.stderr.write(`${c}[Action] ${e.action_name}: ${e.action_input||``}${l}\n`),e.observation&&process.stderr.write(`${c}[Observation] ${e.observation}${l}\n`)}catch{}}i&&!e.quiet&&process.stderr.write(`${c}Session ID: ${i}${l}\n`),a===`json`?P({text:r,session_id:i},a):process.stdout.write(`
|
|
144
|
-
`)}else{let t=await k(e,{url:u,method:`POST`,body:o}),n=t.output?.text??``;e.quiet||a===`text`?F(n):P(t,a)}}})})),bo,xo,So=M((()=>{I(),bo=`zeldaEasy.broadscope-bailian.app-control.list`,xo=m({name:`app list`,description:`List Bailian applications`,skipDefaultApiKeySetup:!0,usage:`bl app list [flags]`,options:[{flag:`--name <name>`,description:`Filter by app name (keyword search)`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--page-size <n>`,description:`Results per page (default: 30)`,type:`number`},{flag:`--console-region <region>`,description:`Console region`},{flag:`--console-site <site>`,description:`Console site: domestic, international`},{flag:`--console-switch-agent <uid>`,description:`Switch agent UID`,type:`number`}],examples:[`bl app list`,`bl app list --name customer service`,`bl app list --page 2 --page-size 10`,`bl app list --output json`],async run(e,t){let n=t.name||``,r=t.page||1,i=t.pageSize||30,a=h(e.output),o=await he(e),s={reqDTO:{name:n,notInTypes:[10],type:5,statuses:[1,4],page_no:r,page_size:i}};if(e.dryRun){P({api:bo,data:s,token:o.token.slice(0,8)+`...`},a);return}let c=await d(e,o.token,{api:bo,data:s}),l=c?.data?.DataV2?.data?.data?.list??[];P({total:c?.data?.DataV2?.data?.data?.total??0,apps:l.map(e=>({code:e.code,name:e.name,user_prompt_params:e.config?.user_prompt_params??[]}))},a)}})})),Co,wo=M((()=>{U(),I(),Co=m({name:`memory add`,description:`Add memory from messages or custom content`,usage:`bl memory add --user-id <id> [--messages <json>] [--content <text>] [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--messages <json>`,description:`Messages JSON array: [{"role":"user","content":"..."},...]`},{flag:`--content <text>`,description:`Custom content text to memorize`},{flag:`--profile-schema <id>`,description:`Profile schema ID for user profiling`},{flag:`--memory-library-id <id>`,description:`Memory library ID (isolate memory space)`}],examples:[`bl memory add --user-id user1 --content "The user likes Python programming"`,`bl memory add --user-id user1 --messages '[{"role":"user","content":"I like traveling"}]'`,`bl memory add --user-id user1 --content "Lives in Beijing" --profile-schema schema_xxx`],async run(e,t){let n=t.userId;n||H(`user-id`,`bl memory add --user-id <id>`);let r={user_id:n};if(t.messages)try{r.messages=JSON.parse(t.messages)}catch{process.stderr.write(`Error: --messages must be valid JSON array
|
|
145
|
-
`),process.exit(1)}t.content&&(r.custom_content=t.content),!r.messages&&!r.custom_content&&(process.stderr.write(`Error: at least one of --messages or --content is required
|
|
146
|
-
`),process.exit(1)),t.profileSchema&&(r.profile_schema=t.profileSchema),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=h(e.output);if(e.dryRun){P({endpoint:ie(e.baseUrl),request:r},i);return}let a=await k(e,{url:ie(e.baseUrl),method:`POST`,body:r});e.quiet||i===`text`?F(`Memory added. IDs: ${a.memory_ids?.join(`, `)||`none`}`):P(a,i)}})})),To,Eo=M((()=>{U(),I(),To=m({name:`memory search`,description:`Search memory nodes by query or messages`,usage:`bl memory search --user-id <id> [--query <text>] [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--query <text>`,description:`Search query text`},{flag:`--messages <json>`,description:`Messages JSON array for context-based search`},{flag:`--top-k <n>`,description:`Number of results to return (default: 10)`,type:`number`},{flag:`--memory-library-id <id>`,description:`Memory library ID`}],examples:[`bl memory search --user-id user1 --query "programming preferences"`,`bl memory search --user-id user1 --messages '[{"role":"user","content":"recommend a book"}]' --top-k 5`],async run(e,t){let n=t.userId;n||H(`user-id`,`bl memory search --user-id <id>`);let r={user_id:n};if(t.query&&(r.query=t.query),t.messages)try{r.messages=JSON.parse(t.messages)}catch{process.stderr.write(`Error: --messages must be valid JSON array
|
|
147
|
-
`),process.exit(1)}!r.messages&&r.query&&(r.messages=[{role:`user`,content:r.query}]),!r.query&&!r.messages&&(process.stderr.write(`Error: at least one of --query or --messages is required
|
|
148
|
-
`),process.exit(1)),t.topK!==void 0&&(r.top_k=t.topK),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=h(e.output);if(e.dryRun){P({endpoint:se(e.baseUrl),request:r},i);return}let a=await k(e,{url:se(e.baseUrl),method:`POST`,body:r});if(e.quiet||i===`text`)if(!a.memory_nodes||a.memory_nodes.length===0)F(`No memory nodes found.`);else for(let e of a.memory_nodes)F(`[${e.memory_node_id}] ${e.content}`);else P(a,i)}})})),Do,Oo=M((()=>{U(),I(),Do=m({name:`memory list`,description:`List memory nodes for a user`,usage:`bl memory list --user-id <id> [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--page-size <n>`,description:`Results per page (default: 10)`,type:`number`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--memory-library-id <id>`,description:`Memory library ID`}],examples:[`bl memory list --user-id user1`,`bl memory list --user-id user1 --page-size 20 --page 2`],async run(e,t){let n=t.userId;n||H(`user-id`,`bl memory list --user-id <id>`);let r=h(e.output),i=new URLSearchParams;i.set(`user_id`,n),t.pageSize!==void 0&&i.set(`page_size`,String(t.pageSize)),t.page!==void 0&&i.set(`page_num`,String(t.page)),t.memoryLibraryId&&i.set(`memory_library_id`,t.memoryLibraryId);let a=`${ae(e.baseUrl)}?${i.toString()}`;if(e.dryRun){P({endpoint:a,method:`GET`},r);return}let o=await k(e,{url:a,method:`GET`});if(e.quiet||r===`text`)if(!o.memory_nodes||o.memory_nodes.length===0)F(`No memory nodes found.`);else{for(let e of o.memory_nodes)F(`[${e.memory_node_id}] ${e.content}`);o.total!==void 0&&F(`\nTotal: ${o.total}`)}else P(o,r)}})})),ko,Ao=M((()=>{U(),I(),ko=m({name:`memory update`,description:`Update a memory node content`,usage:`bl memory update --node-id <id> --user-id <id> --content <text>`,options:[{flag:`--node-id <id>`,description:`Memory node ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--content <text>`,description:`New content for the memory node (required)`,required:!0},{flag:`--memory-library-id <id>`,description:`Memory library ID (non-default library)`}],examples:[`bl memory update --node-id node_xxx --user-id user1 --content "updated memory content"`],async run(e,t){let n=t.nodeId;n||H(`node-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let r=t.userId;r||H(`user-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let i=t.content;i||H(`content`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let a={user_id:r,custom_content:i};t.memoryLibraryId&&(a.memory_library_id=t.memoryLibraryId);let o=h(e.output);if(e.dryRun){P({endpoint:oe(e.baseUrl,n),method:`PATCH`,request:a},o);return}let s=await k(e,{url:oe(e.baseUrl,n),method:`PATCH`,body:a});e.quiet||o===`text`?F(`Memory node ${n} updated.`):P(s,o)}})})),jo,Mo=M((()=>{U(),I(),jo=m({name:`memory delete`,description:`Delete a memory node`,usage:`bl memory delete --node-id <id> --user-id <id>`,options:[{flag:`--node-id <id>`,description:`Memory node ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--memory-library-id <id>`,description:`Memory library ID (non-default library)`}],examples:[`bl memory delete --node-id node_xxx --user-id user1`],async run(e,t){let n=t.nodeId;n||H(`node-id`,`bl memory delete --node-id <id> --user-id <id>`);let r=t.userId;r||H(`user-id`,`bl memory delete --node-id <id> --user-id <id>`);let i=h(e.output),a=new URLSearchParams({user_id:r});t.memoryLibraryId&&a.set(`memory_library_id`,t.memoryLibraryId);let o=`${oe(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){P({endpoint:o,method:`DELETE`},i);return}let s=await k(e,{url:o,method:`DELETE`});e.quiet||i===`text`?F(`Memory node ${n} deleted.`):P(s,i)}})})),No,Po=M((()=>{U(),I(),No=m({name:`memory profile create`,description:`Create a user profile schema for memory profiling`,usage:`bl memory profile create --name <name> --attributes <json> [flags]`,options:[{flag:`--name <name>`,description:`Schema name (required)`,required:!0},{flag:`--description <text>`,description:`Schema description`},{flag:`--attributes <json>`,description:`Attributes JSON array: [{"name":"age","description":"age"}]`,required:!0}],examples:[`bl memory profile create --name "user_basic" --attributes '[{"name":"age","description":"age"},{"name":"hobby","description":"hobby"}]'`],async run(e,t){let n=t.name;n||H(`name`,`bl memory profile create --name <name> --attributes <json>`);let r=t.attributes;r||H(`attributes`,`bl memory profile create --name <name> --attributes <json>`);let i;try{i=JSON.parse(r)}catch{process.stderr.write(`Error: --attributes must be valid JSON array
|
|
149
|
-
`),process.exit(1)}let a={name:n,attributes:i};t.description&&(a.description=t.description);let o=h(e.output);if(e.dryRun){P({endpoint:le(e.baseUrl),request:a},o);return}let s=await k(e,{url:le(e.baseUrl),method:`POST`,body:a});e.quiet||o===`text`?F(`Profile schema created: ${s.profile_schema_id}`):P(s,o)}})})),Fo,Io=M((()=>{U(),I(),Fo=m({name:`memory profile get`,description:`Get user profile by schema ID and user ID`,usage:`bl memory profile get --schema-id <id> --user-id <id>`,options:[{flag:`--schema-id <id>`,description:`Profile schema ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0}],examples:[`bl memory profile get --schema-id schema_xxx --user-id user1`],async run(e,t){let n=t.schemaId;n||H(`schema-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let r=t.userId;r||H(`user-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let i=h(e.output),a=new URLSearchParams({user_id:r}),o=`${Ee(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){P({endpoint:o,method:`GET`},i);return}let s=await k(e,{url:o,method:`GET`});if(e.quiet||i===`text`)if(s.profile?.attributes)for(let e of s.profile.attributes)F(`${e.name}: ${e.value??`(empty)`}`);else F(`No profile data found.`);else P(s,i)}})}));async function Lo(e,t,n,r,i){t.topK!==void 0&&t.rerankTopN===void 0&&(process.stderr.write(`Warning: --top-k is deprecated. Use --rerank-top-n instead.
|
|
150
|
-
`),t.rerankTopN=t.topK);let a={index_id:n,query:r,search_filters:[]};if(t.denseSimilarityTopK!==void 0&&(a.dense_similarity_top_k=t.denseSimilarityTopK),t.sparseSimilarityTopK!==void 0&&(a.sparse_similarity_top_k=t.sparseSimilarityTopK),t.rerank&&(a.enable_reranking=!0),t.rerankTopN!==void 0&&(a.rerank_top_n=t.rerankTopN),t.rerankModel){let e={model_name:t.rerankModel};t.rerankMode&&(e.rerank_mode=t.rerankMode),t.rerankInstruct&&(e.rerank_instruct=t.rerankInstruct),a.rerank=[e]}let o=te(e.baseUrl);if(e.dryRun){P({endpoint:o,request:a},i);return}let s=await k(e,{url:o,method:`POST`,body:a}),c=s.data?.nodes||[];e.quiet||i===`text`?zo(c.map(e=>({text:e.text,score:e.score}))):P(s,i)}async function Ro(e,n,r,a,o){let s=n.accessKeyId||e.accessKeyId,c=n.accessKeySecret||e.accessKeySecret,l=n.workspaceId||e.workspaceId;if(!s||!c)throw new t(`No credentials found.
|
|
151
|
-
Preferred: set DASHSCOPE_API_KEY or pass --api-key.
|
|
152
|
-
Legacy (deprecated): set ALIBABA_CLOUD_ACCESS_KEY_ID / ALIBABA_CLOUD_ACCESS_KEY_SECRET.`,i.AUTH);if(!l)throw new t(`Knowledge retrieve requires a workspace ID.
|
|
153
|
-
Set via: --workspace-id flag, or env: BAILIAN_WORKSPACE_ID, or config: bl config set workspace_id <id>`,i.USAGE);process.stderr.write(`Warning: AK/SK auth for knowledge retrieve is deprecated. Prefer --api-key or DASHSCOPE_API_KEY.
|
|
154
|
-
`);let u={IndexId:r,Query:a};if(n.topK!==void 0&&n.rerankTopN===void 0&&(process.stderr.write(`Warning: --top-k is deprecated. Use --rerank-top-n instead.
|
|
155
|
-
`),n.rerankTopN=n.topK),n.rerank&&(u.EnableReranking=!0),n.rerankTopN!==void 0&&(u.RerankTopN=n.rerankTopN),n.denseSimilarityTopK!==void 0&&(u.DenseSimilarityTopK=n.denseSimilarityTopK),n.sparseSimilarityTopK!==void 0&&(u.SparseSimilarityTopK=n.sparseSimilarityTopK),n.rerankModel){let e={ModelName:n.rerankModel};n.rerankMode&&(e.RerankMode=n.rerankMode),n.rerankInstruct&&(e.RerankInstruct=n.rerankInstruct),u.Rerank=[e]}let d=`/${l}/index/retrieve`;if(e.dryRun){P({endpoint:`https://${Bo}${d}`,workspaceId:l,request:u},o);return}let f=JSON.stringify(u),p=ve({accessKeyId:s,accessKeySecret:c,action:`Retrieve`,version:`2023-12-29`,body:f,host:Bo,pathname:d}),m=`https://${Bo}${d}`;e.verbose&&(process.stderr.write(`> POST ${m}\n`),process.stderr.write(`> AK: ${O(s)}\n`));let h=e.timeout*1e3,g=await fetch(m,{method:`POST`,headers:{...p,...we()},body:f,signal:AbortSignal.timeout(h)});e.verbose&&process.stderr.write(`< ${g.status} ${g.statusText}\n`);let _=await g.json();if(!g.ok||_.Code&&_.Code!==`Success`)throw new t(`Knowledge retrieve failed: ${_.Code||g.status} - ${_.Message||g.statusText}`,i.GENERAL);let v=_.Data?.Nodes||[];e.quiet||o===`text`?zo(v.map(e=>({text:e.Text,score:e.Score}))):P(_,o)}function zo(e){if(e.length===0)F(`No results found.`);else for(let t=0;t<e.length;t++){let n=e[t];F(`[${t+1}] (score: ${n.score.toFixed(4)})`),F(n.text),F(``)}}var Bo,Vo,Ho=M((()=>{U(),I(),Bo=`bailian.cn-beijing.aliyuncs.com`,Vo=m({name:`knowledge retrieve`,description:`Retrieve from a Bailian knowledge base`,skipDefaultApiKeySetup:!0,usage:`bl knowledge retrieve --index-id <id> --query <text> [flags]`,options:[{flag:`--index-id <id>`,description:`Knowledge base index ID (required)`,required:!0},{flag:`--query <text>`,description:`Search query (required)`,required:!0},{flag:`--dense-similarity-top-k <n>`,description:`Dense retrieval top K`,type:`number`},{flag:`--sparse-similarity-top-k <n>`,description:`Sparse retrieval top K`,type:`number`},{flag:`--rerank`,description:`Enable reranking`},{flag:`--rerank-top-n <n>`,description:`Rerank top N results`,type:`number`},{flag:`--rerank-model <name>`,description:`Rerank model, e.g. qwen3-rerank-hybrid`},{flag:`--rerank-mode <mode>`,description:`Rerank mode: qa, similar, or custom`},{flag:`--rerank-instruct <text>`,description:`Custom rerank instruction, when mode=custom`},{flag:`--top-k <n>`,description:`Number of results (deprecated, use --rerank-top-n)`,type:`number`},{flag:`--workspace-id <id>`,description:`Bailian workspace ID (only needed for deprecated AK/SK auth)`},{flag:`--access-key-id <key>`,description:`Deprecated: use global --api-key instead`},{flag:`--access-key-secret <key>`,description:`Deprecated: use global --api-key instead`}],notes:["Authentication: pass `--api-key <key>`. AK/SK auth is deprecated and will be removed in a future version.","`--workspace-id` is NOT required when using --api-key."],examples:[`bl knowledge retrieve --index-id idx_xxx --query "How to use Alibaba Cloud Bailian"`,`bl knowledge retrieve --api-key $DASHSCOPE_API_KEY --index-id idx_xxx --query "RAG retrieval" --rerank --rerank-model qwen3-rerank-hybrid`],async run(e,t){let n=t.indexId;n||H(`index-id`,`bl knowledge retrieve --index-id <id> --query <text>`);let r=t.query;r||H(`query`,`bl knowledge retrieve --index-id <id> --query <text>`);let i=h(e.output),a=!!e.apiKey,o=!!(t.accessKeyId&&t.accessKeySecret);if(a)await Lo(e,t,n,r,i);else if(o)await Ro(e,t,n,r,i);else{let a=!1;try{await A(e),a=!0}catch{}a?await Lo(e,t,n,r,i):await Ro(e,t,n,r,i)}}})}));async function Uo(e){if(e.apiKey||e.fileApiKey||e.accessTokenEnv||e.fileAccessToken)return;let n=process.env.DASHSCOPE_API_KEY,r;if(n&&(D({nonInteractive:e.nonInteractive})?await Xr({message:`Found DASHSCOPE_API_KEY in environment (${O(n)}). Save it to config file?`})&&(r=n):r=n),!r){if(!D({nonInteractive:e.nonInteractive}))throw new t(`No API key found.`,i.AUTH,`Set DASHSCOPE_API_KEY environment variable, pass --api-key, or run interactively to be prompted.`);let n=await Yr({message:`Enter your DashScope API key:`});if(!n)throw new t(`API key is required.`,i.AUTH);r=n}await Oe({...de(),api_key:r}),e.fileApiKey=r;let a=e.configPath??`~/.bailian/config.json`;process.stderr.write(`API key saved to ${a}\n`)}var Wo=M((()=>{U()}));function Go(e){let t={};for(let n of e){let e=n.indexOf(`=`);e<=0&&(process.stderr.write(`Error: --arg must be in K=V form, got: ${n}\n`),process.exit(1));let r=n.slice(0,e).trim(),i=n.slice(e+1);try{t[r]=JSON.parse(i)}catch{t[r]=i}}return t}var Ko,qo=M((()=>{U(),I(),Wo(),Ko=m({name:`mcp call`,description:`Call a tool on an MCP server (tools/call)`,skipDefaultApiKeySetup:!0,usage:`bl mcp call <server-code>.<tool> [--arg k=v ...] [--json '{...}'] [--url <url>]`,options:[{flag:`<server-code>.<tool>`,description:`Server code and tool name joined by a dot, e.g. market-cmapi00073529.SmartStockSelection`,required:!0},{flag:`--arg <kv>`,description:`Tool argument (repeatable). Values parsed as JSON if possible, else string.`,type:`array`},{flag:`--json <obj>`,description:`Full arguments object as JSON; merged with --arg (arg wins).`},{flag:`--query <text>`,description:`Shortcut for --arg query=<text> (mirrors many DashScope MCP tools).`},{flag:`--url <url>`,description:`Override the MCP endpoint URL (for non-Bailian servers)`}],examples:[`bl mcp call market-cmapi00073529.SmartStockSelection --query "Screen consumer stocks with ROE > 15%"`,`bl mcp call market-cmapi00073529.FinQuery --json '{"q":"Guizhou Maotai","limit":5}'`,`bl mcp call market-cmapi00073529.SmartFundSelection --arg riskLevel=R3 --arg minScale=10`],async run(e,t){let n=(t._positional??[])[0];n||H(`<server-code>.<tool>`,`bl mcp call <server-code>.<tool>`);let r=n.indexOf(`.`);(r<=0||r===n.length-1)&&(process.stderr.write(`Error: target must be <server-code>.<tool>, got "${n}".\n`),process.exit(1));let i=n.slice(0,r),a=n.slice(r+1),s={};if(t.json)try{let e=JSON.parse(t.json);(!e||typeof e!=`object`||Array.isArray(e))&&(process.stderr.write(`Error: --json must decode to an object.
|
|
156
|
-
`),process.exit(1)),s=e}catch(e){process.stderr.write(`Error: --json is not valid JSON โ ${e.message}\n`),process.exit(1)}Object.assign(s,Go(t.arg??[])),t.query!==void 0&&(s.query=t.query);let c=t.url||l(e.baseUrl,i),u=h(e.output);if(e.dryRun){P({server:i,url:c,tool:a,arguments:s},u);return}await Uo(e);let d=new o(e,c);await d.initialize();let f=await d.callTool(a,s);if(f.isError){let e=f.content.map(e=>e.text||``).join(`
|
|
157
|
-
`);process.stderr.write(`Tool error: ${e}\n`),process.exit(1)}P(f,u)}})})),Jo,Yo,Xo=M((()=>{I(),Jo=`zeldaEasy.broadscope-bailian.mcp-server.PageList`,Yo=m({name:`mcp list`,description:`List MCP servers activated under your Bailian account`,skipDefaultApiKeySetup:!0,usage:`bl mcp list [flags]`,options:[{flag:`--name <text>`,description:`Filter by server name (substring match)`},{flag:`--type <type>`,description:`Server type: OFFICIAL | PRIVATE (default: OFFICIAL)`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--page-size <n>`,description:`Results per page (default: 30)`,type:`number`},{flag:`--console-region <region>`,description:`Console region`},{flag:`--console-site <site>`,description:`Console site: domestic, international`},{flag:`--console-switch-agent <uid>`,description:`Switch agent UID`,type:`number`}],examples:[`bl mcp list`,`bl mcp list --name finance`,`bl mcp list --output json`],async run(e,n){let r=n.name||``,a=n.type||`OFFICIAL`,o=n.page||1,s=n.pageSize||30,c=h(e.output),l={reqDTO:{type:a,displayTools:!1,activated:1,pageNo:o,pageSize:s,serverName:r}};if(e.dryRun){P({api:Jo,data:l,...g(e)},c);return}let u=(await d(e,(await he(e)).token,{api:Jo,data:l}))?.data??{};if(u.success===!1){let e=u.errorCode??`UnknownError`,n=u.errorMsg??e,r=e===`BailianGateway.Login.NotLogined`?"Run `bl auth login --console` to refresh your console session.":void 0;throw new t(`Console gateway: ${n}`,i.AUTH,r)}let f=(u.DataV2??{}).data?.data??{},p=f.mcpServerDetailList??[];P({total:f.total??0,servers:p.map(e=>({code:e.serverCode??``,name:e.serverName??``,description:e.description,type:e.type??``,source:e.source,bizType:e.bizType,installType:e.installType,streamable:e.streamable===!0}))},c)}})})),Zo,Qo=M((()=>{U(),I(),Wo(),Zo=m({name:`mcp tools`,description:`List tools exposed by an MCP server (tools/list)`,skipDefaultApiKeySetup:!0,usage:`bl mcp tools <server-code> [--url <url>]`,options:[{flag:`<server-code>`,description:"Server code from `bl mcp list` (e.g. market-cmapi00073529)",required:!0},{flag:`--url <url>`,description:`Override the MCP endpoint URL (for non-Bailian servers)`}],examples:[`bl mcp tools market-cmapi00073529`,`bl mcp tools market-cmapi00073529 --output json`,`bl mcp tools my-server --url https://example.com/mcp`],async run(e,t){let n=(t._positional??[])[0];n||H(`server-code`,`bl mcp tools <server-code>`);let r=t.url||l(e.baseUrl,n),i=h(e.output);if(e.dryRun){P({server:n,url:r,action:`tools/list`},i);return}await Uo(e);let a=new o(e,r);await a.initialize(),P({server:n,url:r,tools:await a.listTools()},i)}})})),$o,es=M((()=>{Xi(),U(),I(),$o=m({name:`search web`,description:`Search the web using DashScope MCP WebSearch service`,usage:`bl search web --query <text> [flags]`,options:[{flag:`--query <text>`,description:`Search query text`,required:!0},{flag:`--count <n>`,description:`Number of search results (default: 10)`,type:`number`},{flag:`--list-tools`,description:`List available MCP tools and exit`}],examples:[`bl search web --query "Alibaba Cloud Bailian latest features"`,`bl search web --query "TypeScript 5.9 new features" --count 5`,`bl search web --query "Today's news"`,`bl search web --list-tools`],async run(e,t){let n=re(e.baseUrl),r=h(e.output);if(t.listTools){if(e.dryRun){P({endpoint:n,action:`tools/list`},r);return}let t=new o(e,n);await t.initialize(),P({tools:await t.listTools()},r);return}let i=t.query;if(!i)if(D({nonInteractive:e.nonInteractive})){let e=await Yr({message:`Enter your search query:`});e||(process.stderr.write(`Search cancelled.
|
|
158
|
-
`),process.exit(1)),i=e}else H(`query`,`bl search web --query <text>`);if(e.dryRun){P({endpoint:n,action:`tools/call`,tool:`bailian_web_search`,arguments:{query:i,count:t.count||void 0}},r);return}let a=new o(e,n),s=qi(`Initializing search...`);e.quiet||s.start();try{await a.initialize(),e.quiet||s.update(`Searching...`);let n={query:i};t.count&&(n.count=t.count);let o=await a.callTool(`bailian_web_search`,n);if(e.quiet||s.stop(`Done.`),o.isError){let e=o.content.map(e=>e.text||``).join(`
|
|
159
|
-
`);process.stderr.write(`Search error: ${e}\n`),process.exit(1)}if(r===`json`)P(o,r);else for(let e of o.content)if(e.type===`text`&&e.text)try{let t=JSON.parse(e.text);t.pages&&Array.isArray(t.pages)?P({pages:t.pages,total:t.pages.length},r):P(t,r)}catch{P({text:e.text},r)}}catch(e){throw s.stop(`Failed.`),e}}})}));function ts(e){let t=os[e];if(!t){process.stdout.write(`No built-in voice list available for model: ${e}\n`),process.stdout.write(`Browse voices in the console: ${Dt}\n`);return}if(t.length===0){process.stdout.write(`Model ${e} has no system voices.\n`),process.stdout.write(`Use clone or design voices created via the CosyVoice API.
|
|
160
|
-
`),process.stdout.write(`See: ${is}\n`),process.stdout.write(`Browse voices in the console: ${Dt}\n`);return}let n=(e,t)=>e.padEnd(t);process.stdout.write(`\nSystem voices for ${e}:\n`),process.stdout.write(`${n(`VOICE ID`,26)} ${n(`NAME`,10)} ${n(`DESCRIPTION`,16)} LANGUAGE\n`),process.stdout.write(`${`-`.repeat(26)} ${`-`.repeat(10)} ${`-`.repeat(16)} ${`-`.repeat(12)}\n`);for(let e of t)process.stdout.write(`${n(e.voice,26)} ${n(e.name,10)} ${n(e.desc,16)} ${e.lang}\n`);process.stdout.write(`\nTotal: ${t.length} voices\n`),process.stdout.write(`Preview and browse more voices in the console: \n${Dt}\n`)}async function ns(e,n,r,a,o){let s=await ra(na(a),e,()=>k(e,{url:n,method:`POST`,body:r})),c=s.map(e=>e.output?.audio?.url).filter(Boolean);if(c.length===0)throw new t(`API returned no audio URL.`,i.GENERAL);let l=await import(`path`),u=ge(e,{subDir:`speech`}),d=await ia(c.map((e,t)=>{let n=a.out;if(!(n&&c.length===1)){let e=Date.now(),i=c.length>1?`_${String(t+1).padStart(3,`0`)}`:``,a=r.input.format??`mp3`;n=l.join(u,`tts_${e}${i}.${a}`)}return{url:e,destPath:n}}),$i,{quiet:e.quiet});if(e.quiet)F(d.join(`
|
|
161
|
-
`));else if(d.length===1){let e=s[0].output?.audio?.expires_at;P({saved:d[0],audio_url:c[0],model:r.model,voice:r.input.voice,...e?{url_expires_at:e}:{}},o)}else P({saved:d,audio_urls:c,total:d.length,model:r.model,voice:r.input.voice},o)}async function rs(e,t,n,r,i){let a=await pe(e,{url:t,method:`POST`,body:n,stream:!0,headers:{Accept:`text/event-stream`,"X-DashScope-SSE":`enable`}}),o=r.out,s=o?Re(o):null,c;try{for await(let t of ce(a)){if(!t.data||t.data===`[DONE]`)continue;let n;try{n=JSON.parse(t.data)}catch{continue}let r=n.output?.audio?.data;if(r){let e=Buffer.from(r,`base64`);s?s.write(e)||await new Promise(e=>s.once(`drain`,()=>e())):process.stdout.write(e)}if(n.output?.finish_reason===`stop`){c=n.output?.audio?.url,c&&!e.quiet&&process.stderr.write(`\nFull audio URL: ${c}\n`);break}}}finally{s&&(await new Promise((e,t)=>{s.on(`finish`,e),s.on(`error`,t),s.end()}),!e.quiet&&o&&process.stderr.write(`Saved: ${o}\n`))}o&&P({saved:o,...c?{audio_url:c}:{},model:n.model,voice:n.input.voice},i)}var is,as,os,ss,cs=M((()=>{Ot(),ta(),aa(),U(),I(),is=`${r.cn}/cosyvoice-clone-design-api`,as=[{voice:`longanyang`,name:`้พๅฎๆด`,desc:`้ณๅ
ๅคง็ทๅญฉ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longanhuan_v3`,name:`้พๅฎๆฌข`,desc:`ๆฌข่ฑๅ
ๆฐๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longantai_v3`,name:`้พๅฎๅฐ`,desc:`ๅฒ็ๅฐๆนพๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longhua_v3`,name:`้พๅ`,desc:`ๅ
ๆฐ็็พๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longcheng_v3`,name:`้พๆฉ`,desc:`ๆบๆ
ง้ๅนด็ท`,lang:`ไธญๆ/่ฑๆ`},{voice:`longze_v3`,name:`้พๆณฝ`,desc:`ๆธฉๆๅ
ๆฐ็ท`,lang:`ไธญๆ/่ฑๆ`},{voice:`longzhe_v3`,name:`้พๅฒ`,desc:`ๅๆฟๅคงๆ็ท`,lang:`ไธญๆ/่ฑๆ`},{voice:`longyan_v3`,name:`้พ้ข`,desc:`ๆธฉๆๆฅ้ฃๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longxing_v3`,name:`้พๆ`,desc:`ๆธฉๅฉ้ปๅฎถๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longtian_v3`,name:`้พๅคฉ`,desc:`็ฃๆง็ๆบ็ท`,lang:`ไธญๆ/่ฑๆ`},{voice:`longwan_v3`,name:`้พๅฉ`,desc:`็ป่
ปๆๅฃฐๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longqiang_v3`,name:`้พๅซฑ`,desc:`ๆตชๆผซ้ฃๆ
ๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longfeifei_v3`,name:`้พ่ฒ่ฒ`,desc:`็็พๅจๆฐๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longhao_v3`,name:`้พๆตฉ`,desc:`ๅคๆ
ๅฟง้็ท`,lang:`ไธญๆ/่ฑๆ`},{voice:`longanrou_v3`,name:`้พๅฎๆ`,desc:`ๆธฉๆๅจด้ๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longxiaochun_v3`,name:`้พๅฐๆทณ`,desc:`็ฅๆง็งฏๆๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longxiaoxia_v3`,name:`้พๅฐๅค`,desc:`ๆฒ็จณๆๅจๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longyumi_v3`,name:`YUMI`,desc:`ๆญฃ็ป้ๅนดๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longanyun_v3`,name:`้พๅฎๆ`,desc:`ๅฑ
ๅฎถๆ็ท`,lang:`ไธญๆ/่ฑๆ`},{voice:`longanwen_v3`,name:`้พๅฎๆธฉ`,desc:`ไผ้
็ฅๆงๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longanli_v3`,name:`้พๅฎ่`,desc:`ๅฉ่ฝไปๅฎนๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longanlang_v3`,name:`้พๅฎๆ`,desc:`ๆธ
็ฝๅฉ่ฝ็ท`,lang:`ไธญๆ/่ฑๆ`},{voice:`longyingmu_v3`,name:`้พๅบๆฒ`,desc:`ไผ้
็ฅๆงๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longyingxun_v3`,name:`้พๅบ่ฏข`,desc:`ๅนด่ฝป้ๆถฉ็ท`,lang:`ไธญๆ/่ฑๆ`},{voice:`longyingjing_v3`,name:`้พๅบ้`,desc:`ไฝ่ฐๅท้ๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longyingling_v3`,name:`้พๅบ่`,desc:`ๆธฉๅๅ
ฑๆ
ๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longyingtao_v3`,name:`้พๅบๆก`,desc:`ๆธฉๆๆทกๅฎๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longyingxiao_v3`,name:`้พๅบ็ฌ`,desc:`ๆธ
็ๆจ้ๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longfei_v3`,name:`้พ้ฃ`,desc:`็ญ่ก็ฃๆง็ท`,lang:`ไธญๆ/่ฑๆ`},{voice:`longhuhu_v3`,name:`้พๅผๅผ`,desc:`ๅคฉ็็ๆผซๅฅณ็ซฅ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longpaopao_v3`,name:`้พๆณกๆณก`,desc:`้ฃๅคฉๆณกๆณก้ณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longjielidou_v3`,name:`้พๆฐๅ่ฑ`,desc:`้ณๅ
้กฝ็ฎ็ท`,lang:`ไธญๆ/่ฑๆ`},{voice:`longxian_v3`,name:`้พไป`,desc:`่ฑชๆพๅฏ็ฑๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longling_v3`,name:`้พ้`,desc:`็จๆฐๅๆฟๅฅณ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longshanshan_v3`,name:`้พ้ช้ช`,desc:`ๆๅงๅ็ซฅๅฃฐ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longniuniu_v3`,name:`้พ็็`,desc:`้ณๅ
็ท็ซฅๅฃฐ`,lang:`ไธญๆ/่ฑๆ`},{voice:`longjiaxin_v3`,name:`้พๅๆฌฃ`,desc:`ไผ้
็ฒค่ฏญๅฅณ`,lang:`็ฒค่ฏญ/่ฑๆ`},{voice:`longjiayi_v3`,name:`้พๅๆก`,desc:`็ฅๆง็ฒค่ฏญๅฅณ`,lang:`็ฒค่ฏญ/่ฑๆ`},{voice:`longanyue_v3`,name:`้พๅฎ็ฒค`,desc:`ๆฌข่ฑ็ฒค่ฏญ็ท`,lang:`็ฒค่ฏญ/่ฑๆ`},{voice:`longlaotie_v3`,name:`้พ่้`,desc:`ไธๅ็ด็็ท`,lang:`ไธๅ่ฏ/่ฑๆ`},{voice:`longshange_v3`,name:`้พ้ๅฅ`,desc:`ๅๅณ้ๅ็ท`,lang:`้่ฅฟ่ฏ/่ฑๆ`},{voice:`longanmin_v3`,name:`้พๅฎ้ฝ`,desc:`ๆธ
็บฏ่่ๅฅณ`,lang:`้ฝๅ่ฏ/่ฑๆ`},{voice:`loongabby_v3`,name:`loongabby`,desc:`็พๅผ่ฑๆๅฅณ`,lang:`็พๅผ่ฑ่ฏญ`},{voice:`loongandy_v3`,name:`loongandy`,desc:`็พๅผ่ฑๆ็ท`,lang:`็พๅผ่ฑ่ฏญ`},{voice:`loongannie_v3`,name:`loongannie`,desc:`็พๅผ่ฑๆๅฅณ`,lang:`็พๅผ่ฑ่ฏญ`},{voice:`loongava_v3`,name:`loongava`,desc:`็พๅผ่ฑๆๅฅณ`,lang:`็พๅผ่ฑ่ฏญ`},{voice:`loongbeth_v3`,name:`loongbeth`,desc:`็พๅผ่ฑๆๅฅณ`,lang:`็พๅผ่ฑ่ฏญ`},{voice:`loongbetty_v3`,name:`loongbetty`,desc:`็พๅผ่ฑๆๅฅณ`,lang:`็พๅผ่ฑ่ฏญ`},{voice:`loongcally_v3`,name:`loongcally`,desc:`็พๅผ่ฑๆๅฅณ`,lang:`็พๅผ่ฑ่ฏญ`},{voice:`loongcindy_v3`,name:`loongcindy`,desc:`็พๅผ่ฑๆๅฅณ`,lang:`็พๅผ่ฑ่ฏญ`},{voice:`loongdavid_v3`,name:`loongdavid`,desc:`็พๅผ่ฑๆ็ท`,lang:`็พๅผ่ฑ่ฏญ`},{voice:`loongdonna_v3`,name:`loongdonna`,desc:`็พๅผ่ฑๆๅฅณ`,lang:`็พๅผ่ฑ่ฏญ`},{voice:`loongemily_v3`,name:`loongemily`,desc:`่ฑๅผ่ฑๆๅฅณ`,lang:`่ฑๅผ่ฑ่ฏญ`},{voice:`loongeric_v3`,name:`loongeric`,desc:`่ฑๅผ่ฑๆ็ท`,lang:`่ฑๅผ่ฑ่ฏญ`},{voice:`loongluna_v3`,name:`loongluna`,desc:`่ฑๅผ่ฑๆๅฅณ`,lang:`่ฑๅผ่ฑ่ฏญ`},{voice:`loongluca_v3`,name:`loongluca`,desc:`่ฑๅผ่ฑๆ็ท`,lang:`่ฑๅผ่ฑ่ฏญ`},{voice:`loongriko_v3`,name:`Riko`,desc:`ไบๆฌกๅ
้่นๅฅณ`,lang:`ๆฅ่ฏญ`},{voice:`loongtomoka_v3`,name:`loongtomoka`,desc:`ๆฅ่ฏญๅฅณ`,lang:`ๆฅ่ฏญ`},{voice:`loongtomoya_v3`,name:`loongtomoya`,desc:`ๆฅ่ฏญ็ท`,lang:`ๆฅ่ฏญ`},{voice:`loongyuuna_v3`,name:`Yuuna`,desc:`ๆฅ่ฏญๅฅณ`,lang:`ๆฅ่ฏญ`},{voice:`loongyuuma_v3`,name:`Yuuma`,desc:`ๆฅ่ฏญ็ท`,lang:`ๆฅ่ฏญ`},{voice:`loongkyong_v3`,name:`loongkyong`,desc:`้ฉ่ฏญๅฅณ`,lang:`้ฉ่ฏญ`},{voice:`loongjihun_v3`,name:`Jihun`,desc:`้ฉ่ฏญ็ท`,lang:`้ฉ่ฏญ`},{voice:`loongindah_v3`,name:`loongindah`,desc:`ๅฐๅฐผๅฅณ`,lang:`ๅฐๅฐผ่ฏญ`}],os={"cosyvoice-v3-flash":as,"cosyvoice-v3-plus":as,"cosyvoice-v3.5-flash":[],"cosyvoice-v3.5-plus":[],"cosyvoice-v2":[]},ss=m({name:`speech synthesize`,description:`Synthesize speech from text (CosyVoice TTS)`,usage:`bl speech synthesize --text <text> [flags]`,options:[{flag:`--text <text>`,description:`Text to synthesize into speech`,required:!0},{flag:`--text-file <path>`,description:`Read text from a file instead of --text`},{flag:`--model <model>`,description:`Model ID (default: cosyvoice-v3-flash). System voices available for cosyvoice-v3-flash`},{flag:`--voice <voice>`,description:`Voice ID. Use --list-voices to see built-in voices for cosyvoice-v3-flash; for v3.5-flash provide a clone/design voice ID`},{flag:`--list-voices`,description:`List built-in system voices for the selected model and exit (console link shown in output)`},{flag:`--format <format>`,description:`Audio format: mp3, pcm, wav, opus (default: mp3)`},{flag:`--sample-rate <rate>`,description:`Audio sample rate in Hz (e.g. 24000)`},{flag:`--volume <volume>`,description:`Volume 0-100 (default: 50)`},{flag:`--rate <rate>`,description:`Speech rate 0.5-2.0 (default: 1.0)`},{flag:`--pitch <pitch>`,description:`Pitch multiplier 0.5-2.0 (default: 1.0)`},{flag:`--seed <seed>`,description:`Random seed 0-65535 for reproducible synthesis`},{flag:`--language <lang>`,description:`Language hint (e.g. zh, en, ja, ko, fr, de)`},{flag:`--instruction <text>`,description:`Natural language instruction to control speech style (e.g. "Use a gentle tone"๏ผ`},{flag:`--enable-ssml`,description:`Enable SSML markup parsing in input text`},{flag:`--out <path>`,description:`Save audio to file (default: auto-generate in temp dir)`},{flag:`--stream`,description:`Stream raw PCM audio to stdout (pipe to player)`}],examples:[`bl speech synthesize --list-voices --model cosyvoice-v3-flash`,`bl speech synthesize --text "Hello, I am Qwen" --voice <voice_id>`,`bl speech synthesize --text "Hello world" --voice <voice_id> --language en`,`bl speech synthesize --text-file script.txt --out speech.wav --voice <voice_id>`,`bl speech synthesize --text "Today is a good day" --voice <voice_id> --instruction "Use a gentle tone"`,`bl speech synthesize --text "Hello" --voice <voice_id> --format wav --sample-rate 24000`,`# Stream to audio player (macOS)`,`bl speech synthesize --text "Hello" --voice <voice_id> --stream | afplay -`,`# Pipe to ffplay`,`bl speech synthesize --text "Hello" --voice <voice_id> --stream | ffplay -nodisp -autoexit -f s16le -ar 24000 -ac 1 -`],async run(e,n){let r=n.model||e.defaultSpeechModel||`cosyvoice-v3-flash`;if(n.listVoices){ts(r);return}let a=n.text;if(!a&&n.textFile){let e=n.textFile;try{a=Ve(e,`utf-8`).trim()}catch{throw new t(`Cannot read text file: ${e}`,i.USAGE)}}if(!a)if(D({nonInteractive:e.nonInteractive})){let e=await Yr({message:`Enter text to synthesize:`});e||(process.stderr.write(`Speech synthesis cancelled.
|
|
162
|
-
`),process.exit(1)),a=e}else H(`text`,`bl speech synthesize --text <text>`);let o=n.voice||void 0;if(!o)if(D({nonInteractive:e.nonInteractive})){let e=os[r];if(e&&e.length>0){let t=e[0].voice,n=e.map(e=>({value:e.voice,label:`${e.name} (${e.voice})`,hint:`${e.desc} ยท ${e.lang}`})),r=await Zr({message:`Select a voice (default: ${t}):`,choices:n,defaultValue:t});r||(process.stderr.write(`Speech synthesis cancelled.
|
|
163
|
-
`),process.exit(1)),o=r}else{let e=await Yr({message:`Enter voice ID (clone/design voice):`});e||(process.stderr.write(`Speech synthesis cancelled.
|
|
164
|
-
`),process.exit(1)),o=e}}else{let e=os[r];throw e&&e.length>0?new t(`--voice is required.\nRun the following to see available voices:\n bl speech synthesize --list-voices --model ${r}\nBrowse more voices: ${Dt}`,i.USAGE):new t(`--voice is required. Model ${r} has no built-in system voices.\nCreate a clone or design voice first, then pass its ID via --voice <voice_id>.\nSee: ${is}`,i.USAGE)}let s=n.language||void 0,c=n.instruction||void 0,l=n.format||void 0,u=n.sampleRate===void 0?void 0:Number(n.sampleRate),d=n.volume===void 0?void 0:Number(n.volume),f=n.rate===void 0?void 0:Number(n.rate),p=n.pitch===void 0?void 0:Number(n.pitch),m=n.seed===void 0?void 0:Number(n.seed),g=n.enableSsml===!0?!0:void 0,_=n.stream===!0,v=h(e.output),y={model:r,input:{text:a,voice:o,format:l,sample_rate:u,volume:d,rate:f,pitch:p,seed:m,language_hints:s?[s]:void 0,instruction:c,enable_ssml:g}};if(xe(y.input),e.dryRun){P({request:y},v);return}e.quiet||process.stderr.write(`[Model: ${r}] [Voice: ${o}]\n`);let b=be(e.baseUrl);_?await rs(e,b,y,n,v):await ns(e,b,y,n,v)}})}));async function ls(e,n,r,a,o,s){let c=(await k(e,{url:n,method:`POST`,body:r,async:!0})).output.task_id;if(a.noWait||e.async){P({task_id:c},o);return}let l=a.pollInterval??2,u=await Zi(e,{url:Se(e.baseUrl,c),intervalSec:l,timeoutSec:e.timeout,isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>e.output.message}),d=u.output.results??[];if(d.length===0){P({task_id:c,status:u.output.task_status},o);return}let f=[];for(let e=0;e<d.length;e++){let n=d[e],r=s>1;if(r&&process.stdout.write(`=== [${e+1}/${d.length}] ${n.file_url??``} ===\n`),n.subtask_status===`FAILED`){let e=n.message??n.code??`unknown error`;process.stdout.write(`[FAILED] ${n.file_url??``} โ ${e}\n`),r&&process.stdout.write(`
|
|
165
|
-
`);continue}if(!n.transcription_url){r&&process.stdout.write(`
|
|
166
|
-
`);continue}let a=await fetch(n.transcription_url,{headers:we()});if(!a.ok)throw new t(`Failed to download transcription: HTTP ${a.status}`,i.GENERAL);let o=await a.json();f.push(o);let c=o.transcripts;if(c&&c.length>0)for(let e of c)if(e.sentences&&e.sentences.length>0)for(let t of e.sentences){let e=t.speaker_id===void 0?``:` [Speaker ${t.speaker_id}]`;process.stdout.write(`${t.text}${e}\n`)}else e.text&&process.stdout.write(e.text+`
|
|
167
|
-
`);else F(JSON.stringify(o));r&&process.stdout.write(`
|
|
168
|
-
`)}if(a.out){let t=a.out,n=f.length===1?f[0]:f;Ue(t,JSON.stringify(n,null,2)+`
|
|
169
|
-
`),e.quiet||process.stderr.write(`Full result saved to: ${t}\n`)}}var us,ds=M((()=>{Qi(),U(),I(),us=m({name:`speech recognize`,description:`Recognize speech from audio files (FunAudio-ASR)`,usage:`bl speech recognize --url <audio-url> [flags]`,options:[{flag:`--url <url>`,description:`Audio file URL or local file path (repeatable, max 100)`,required:!0,type:`array`},{flag:`--model <model>`,description:`Model ID (default: fun-asr)`},{flag:`--language <lang>`,description:`Language hint (e.g. zh, en, ja)`},{flag:`--diarization`,description:`Enable automatic speaker diarization`},{flag:`--speaker-count <n>`,description:`Expected number of speakers (requires --diarization)`,type:`number`},{flag:`--vocabulary-id <id>`,description:`Hot-word vocabulary ID for improved accuracy`},{flag:`--channel-id <n>`,description:`Audio channel ID (default: 0)`,type:`number`},{flag:`--out <path>`,description:`Save full transcription result to JSON file`},{flag:`--no-wait`,description:`Return task ID immediately without polling`},{flag:`--poll-interval <seconds>`,description:`Polling interval in seconds (default: 2)`,type:`number`}],examples:[`bl speech recognize --url https://example.com/audio.mp3`,`bl speech recognize --url https://example.com/a.mp3 --url https://example.com/b.mp3`,`bl speech recognize --url https://example.com/meeting.wav --diarization --speaker-count 3`,`bl speech recognize --url https://example.com/audio.mp3 --language zh`,`bl speech recognize --url https://example.com/audio.mp3 --vocabulary-id vocab-abc123`,`bl speech recognize --url https://example.com/audio.mp3 --out result.json`,`bl speech recognize --url https://example.com/audio.mp3 --no-wait --quiet`],async run(e,n){let r=[];Array.isArray(n.url)?r=n.url:typeof n.url==`string`&&(r=[n.url]),r.length===0&&H(`url`,`bl speech recognize --url <audio-url>`);let a=n.speakerCount,o=n.diarization===!0;if(a!==void 0&&!o)throw new t(`--speaker-count requires --diarization to be enabled.
|
|
170
|
-
Hint: Add --diarization flag to enable speaker separation.`,i.USAGE);let s=n.model||`fun-asr`,c=h(e.output),l=await A(e),u=await Promise.all(r.map(e=>j(e,l.token,s))),d=n.channelId,f=n.language,p=n.vocabularyId,m={model:s,input:{file_urls:u},parameters:{channel_id:d===void 0?[0]:[d],language_hints:f?[f]:void 0,diarization_enabled:o?!0:void 0,speaker_count:a,vocabulary_id:p}};if(xe(m.parameters),e.dryRun){P({request:m,mode:`async`},c);return}e.quiet||process.stderr.write(`[Model: ${s}] [Mode: async] [Files: ${u.length}]\n`),await ls(e,ye(e.baseUrl),m,n,c,u.length)}})})),fs,ps=M((()=>{U(),I(),fs=m({name:`file upload`,description:`Upload a local file to DashScope temporary storage (48h)`,usage:`bl file upload --file <path> --model <model>`,options:[{flag:`--file <path>`,description:`Local file to upload (image, video, audio)`,required:!0},{flag:`--model <model>`,description:`Target model name (file is bound to this model)`,required:!0}],examples:[`bl file upload --file photo.jpg --model qwen3-vl-plus`,`bl file upload --file video.mp4 --model wan2.1-t2v-plus`,`bl file upload --file audio.wav --model qwen3-asr-flash`,`bl file upload --file cat.png --model qwen-image-2.0`],async run(e,t){let n=t.file;n||H(`file`,`bl file upload --file <path> --model <model>`);let r=t.model;r||H(`model`,`bl file upload --file <path> --model <model>`);let i=h(e.output);if(e.dryRun){P({action:`upload`,file:n,model:r},i);return}let a=await Te({apiKey:(await A(e)).token,model:r,filePath:n});e.quiet?F(a):P({url:a,model:r,expires_in:`48 hours`,note:`When using this URL in API calls, add header: X-DashScope-OssResourceResolve: enable`},i)}})})),ms,hs=M((()=>{U(),I(),ms=m({name:`console call`,description:`Call a Bailian console API via the CLI gateway`,skipDefaultApiKeySetup:!0,usage:`bl console call --api <api> --data <json> [flags]`,options:[{flag:`--api <api>`,description:`API name (e.g. zeldaEasy.broadscope-bailian.memory-library.getLibraries)`,required:!0},{flag:`--data <json>`,description:`Request data as JSON string`,required:!0},{flag:`--console-region <region>`,description:`Console region`},{flag:`--console-site <site>`,description:`Console site: domestic, international`},{flag:`--console-switch-agent <uid>`,description:`Switch agent UID`,type:`number`}],examples:[`bl console call --api zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota --data '{"queryFreeTierQuotaRequest":{"models":["qwen3-max"]}}'`,`bl console call --api some.api.name --data '{"key":"value"}' --console-region cn-beijing`],async run(e,r){let i=r.api;i||H(`api`,`bl console call --api <api> --data <json>`);let a=r.data;a||H(`data`,`bl console call --api <api> --data <json>`);let o;try{o=JSON.parse(a)}catch{process.stderr.write(`Error: --data must be valid JSON
|
|
171
|
-
`),process.exit(1)}let s=h(e.output),c;try{c=(await he(e)).token}catch(e){if(!(e instanceof t&&e.message===n))throw e}if(e.dryRun){P({api:i,data:o,token:c?c.slice(0,8)+`...`:null,...g(e)},s);return}P(await d(e,c,{api:i,data:o}),s)}})}));function gs(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 _s(e){let t=0;for(let n of e){let e=n.codePointAt(0)??0;t+=gs(e)?2:1}return t}function W(e,t){let n=t-_s(e);return n>0?e+` `.repeat(n):e}var vs=M((()=>{}));function ys(e){return e.toLocaleString(`en-US`)}function bs(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function xs(e){return e.quotaInitTotal?`${((e.quotaInitTotal-e.quotaTotal)/e.quotaInitTotal*100).toFixed(1)}%`:`-`}function Ss(e){for(let t of e){let e=ks[t];if(e)return e}return`-`}function Cs(e,t,n,r){let i=[`Model`,`Type`,`Remaining/Total`,`Usage`,`Expires`,`Auto-Stop`],a=e.map(e=>{let r=e.quotaInitTotal!=null&&e.quotaTotal!=null,i=r?ys(e.quotaTotal):`-`,a=r?ys(e.quotaInitTotal):`-`,o=t.get(e.model);return[e.model,n.get(e.model)||`-`,r?`${i} / ${a}`:`-`,xs(e),e.quotaValidityPeriod?bs(e.quotaValidityPeriod):`-`,e.quotaStatus===`UNKNOWN`?`Unsupported`:o===!0?`ON`:o===!1?`OFF`:`-`]}),o=i.map((e,t)=>Math.max(_s(e),...a.map(e=>_s(e[t])))),s=r?e=>e:e=>`\x1b[2m${e}\x1b[0m`,c=r?e=>e:e=>`\x1b[1m${e}\x1b[0m`,l=r?e=>e:e=>`\x1b[32m${e}\x1b[0m`,u=r?e=>e:e=>`\x1b[33m${e}\x1b[0m`,d=i.length-1,f=i.map((e,t)=>c(W(e,o[t]))).join(` `),p=o.map(e=>s(`โ`.repeat(e))).join(`โโ`);process.stdout.write(f+`
|
|
172
|
-
`),process.stdout.write(p+`
|
|
173
|
-
`);for(let e of a){let t=e.map((e,t)=>{if(t===d){if(e===`ON`)return l(W(e,o[t]));if(e===`OFF`)return u(W(e,o[t]))}return W(e,o[t])});process.stdout.write(t.join(` `)+`
|
|
174
|
-
`)}}function ws(e){let t=e.data;if(!t)return[];let n=t.DataV2;return n?n.data?.data?.freeTierQuotas||[]:t.data?.freeTierQuotas||[]}function Ts(e){let t=e.data;if(!t)return[];let n=t.DataV2;return n?n.data?.data?.freeTierOnlyStatuses||[]:t.data?.freeTierOnlyStatuses||[]}async function Es(e,t){let n=[],r=1;for(;;){let i=await _(e,t,{pageNo:r,pageSize:50});if(n.push(...i.models),n.length>=i.total)break;r++}return n.filter(e=>typeof e.model==`string`&&e.model).map(e=>({name:e.model,type:Ss(e.capabilities||[])}))}var Ds,Os,ks,As,js=M((()=>{I(),vs(),Ds=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota`,Os=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierOnlyStatus`,ks={Reasoning:`Text`,TG:`Text`,VU:`Text`,IG:`Vision`,VG:`Vision`,"Realtime-Omni":`Multimodal`,"Multimodal-Omni":`Multimodal`,ASR:`Audio`,TTS:`Audio`,"Voice-Replication":`Audio`,"Realtime-Text-to-Speech":`Audio`,"Realtime-Voice-Replication":`Audio`,"Realtime-ASR":`Audio`,"Realtime-Audio-Translate":`Audio`,ME:`Embedding`,TR:`Embedding`},As=m({name:`usage free`,description:`Query free-tier quota for models (all models if --model is omitted)`,skipDefaultApiKeySetup:!0,usage:`bl usage free [--model <model>[,model2,...]] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s) to query, comma-separated for multiple; omit for all models`},{flag:`--expiring <days>`,description:`Only show quotas expiring within N days`},{flag:`--sort <field>`,description:`Sort by: remaining (ascending), expires (ascending)`},{flag:`--console-region <region>`,description:`Console region`},{flag:`--console-site <site>`,description:`Console site: domestic, international`},{flag:`--console-switch-agent <uid>`,description:`Switch agent UID`,type:`number`}],examples:[`bl usage free`,`bl usage free --model qwen3-max`,`bl usage free --model qwen3-max,qwen-turbo`,`bl usage free --expiring 30`,`bl usage free --sort remaining`,`bl usage free --model qwen-turbo --output json`,`bl usage free --model qwen3-max --console-region cn-beijing`],async run(e,t){let n=t.model||void 0,r=Number(t.expiring)||0,i=[`remaining`,`expires`],a=t.sort||void 0;a&&!i.includes(a)&&(process.stderr.write(`Error: invalid --sort value "${a}". Must be one of: ${i.join(`, `)}\n`),process.exit(1));let o=h(e.output),s,c=new Map;s=n?[...new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean))]:[];let l={queryFreeTierQuotaRequest:{models:s}};if(e.dryRun){P({api:Ds,data:l},o);return}let u=await he(e);if(n){let t=await Promise.all(s.map(t=>_(e,u.token,{name:t,pageSize:50})));for(let e=0;e<s.length;e++){let n=t[e].models.find(t=>t.model===s[e]);n&&c.set(s[e],Ss(n.capabilities||[]))}}else{let t=await Es(e,u.token);s=t.map(e=>e.name);for(let e of t)c.set(e.name,e.type);l.queryFreeTierQuotaRequest.models=s}let[f,p]=await Promise.all([d(e,u.token,{api:Ds,data:l}),d(e,u.token,{api:Os,data:{queryFreeTierOnlyStatusRequest:{models:s}}})]),m=ws(f),g=n?m:m.filter(e=>e.quotaStatus===`VALID`&&e.quotaInitTotal>0);if(r>0){let e=Date.now()+r*24*60*60*1e3;g=g.filter(t=>t.quotaValidityPeriod>0&&t.quotaValidityPeriod<=e)}a===`remaining`?g.sort((e,t)=>(e.quotaInitTotal?e.quotaTotal/e.quotaInitTotal:0)-(t.quotaInitTotal?t.quotaTotal/t.quotaInitTotal:0)):a===`expires`&&g.sort((e,t)=>(e.quotaValidityPeriod??0)-(t.quotaValidityPeriod??0));let v=Ts(p),y=new Map(v.map(e=>[e.model,e.freeTierOnly]));if(o===`json`){P(g.map(e=>{let t=e.quotaInitTotal!=null&&e.quotaTotal!=null,n=t?e.quotaInitTotal-e.quotaTotal:0,r=y.get(e.model),i=e.quotaStatus===`UNKNOWN`?`unsupported`:r===!0?!0:r===!1?!1:null;return{model:e.model,type:c.get(e.model)||null,remaining:t?e.quotaTotal:null,total:t?e.quotaInitTotal:null,usagePercent:t&&e.quotaInitTotal>0?Math.round(n/e.quotaInitTotal*1e3)/10:null,expires:e.quotaValidityPeriod?bs(e.quotaValidityPeriod):null,autoStop:i}}),o);return}if(g.length===0){process.stdout.write(`No free-tier quota found.
|
|
175
|
-
`);return}Cs(g,y,c,e.noColor)}})}));function Ms(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function Ns(e){let t=Ms(e,`data`);if(!t)return e;let n=Ms(t,`DataV2`);if(n){let e=Ms(n,`data`);return(e?Ms(e,`data`):void 0)??e??n}return Ms(t,`data`)??t}async function Ps(e,t,n,r,i){let a;for(let o=0;o<Vs;o++){let o=await d(e,t,{api:n,data:{[r]:a?{taskId:a}:{models:i}}}),s=Ns(o);if(s.taskId&&Object.keys(s).length===1){a=s.taskId,await new Promise(e=>setTimeout(e,Bs));continue}return o}return null}async function Fs(e,t){let n=[],r=1;for(;;){let i=await _(e,t,{pageNo:r,pageSize:50});if(n.push(...i.models),n.length>=i.total)break;r++}return n.map(e=>e.model).filter(Boolean)}var Is,Ls,Rs,zs,Bs,Vs,Hs,Us=M((()=>{I(),Is=`zeldaEasy.broadscope-bailian.freeTrial.batchActivateFreeTierOnly`,Ls=`zeldaEasy.broadscope-bailian.freeTrial.batchDeactivateFreeTierOnly`,Rs=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota`,zs=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierOnlyStatus`,Bs=500,Vs=20,Hs=m({name:`usage freetier`,description:`Enable or disable auto-stop for free-tier models. Enables by default; use --off to disable`,skipDefaultApiKeySetup:!0,usage:`bl usage freetier <--model <model>[,model2,...] | --all> [--off] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s), comma-separated for multiple`},{flag:`--all`,description:`Apply to all free-tier models`},{flag:`--on`,description:`Enable auto-stop (default behavior)`},{flag:`--off`,description:`Disable auto-stop`},{flag:`--console-region <region>`,description:`Console region`},{flag:`--console-site <site>`,description:`Console site: domestic, international`},{flag:`--console-switch-agent <uid>`,description:`Switch agent UID`,type:`number`}],examples:[`bl usage freetier --model qwen3-max`,`bl usage freetier --model qwen3-max,qwen-turbo`,`bl usage freetier --all`,`bl usage freetier --on --model qwen3-max`,`bl usage freetier --off --model qwen3-max`,`bl usage freetier --off --all`],async run(e,t){let n=t.model||void 0,r=!!t.all,i=!!t.off,a=h(e.output);!n&&!r&&(process.stderr.write(`Error: missing required flag. Specify --model <model>[,model2,...] or --all
|
|
176
|
-
`),process.exit(1));let o;o=n?[...new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean))]:[];let s=i?Ls:Is,c=i?`BatchDeactivateFreeTierOnlyRequest`:`BatchActivateFreeTierOnlyRequest`;if(e.dryRun){P({api:s,data:{[c]:{models:o}}},a);return}let l=await he(e);if(n||(o=await Fs(e,l.token)),i){let[t,n]=await Promise.all([d(e,l.token,{api:Rs,data:{queryFreeTierQuotaRequest:{models:o}}}),d(e,l.token,{api:zs,data:{queryFreeTierOnlyStatusRequest:{models:o}}})]),r=Ns(t).freeTierQuotas??[],i=new Map(r.map(e=>[e.model,e])),a=Ns(n).freeTierOnlyStatuses??[],u=new Map(a.map(e=>[e.model,e.freeTierOnly]));for(let t of o){if(u.get(t)===!1){process.stderr.write(`Auto-stop is already disabled for "${t}".\n`);continue}let n=i.get(t);if(n&&n.quotaTotal>0&&u.get(t)===!0){process.stderr.write(`Cannot disable auto-stop for "${t}": free-tier quota has not been fully consumed. Please disable auto-stop after the quota is exhausted.\n`);continue}await Ps(e,l.token,s,c,[t]),process.stdout.write(`Disabled auto-stop for "${t}".\n`)}return}let u=[];for(let t of o){let n=await Ps(e,l.token,s,c,[t]);if(a===`json`){u.push(n);continue}if(n){let e=Ns(n).failureModels??[];e.length>0?process.stderr.write(`Failed to enable auto-stop for "${t}" (${e[0].errorCode}).\n`):process.stdout.write(`Enabled auto-stop for "${t}".\n`)}else process.stderr.write(`Warning: operation timed out for "${t}".\n`)}a===`json`&&P(u,a)}})}));function Ws(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function Gs(e){let t=Ws(e,`data`);if(!t)return e;let n=Ws(t,`DataV2`);if(n){let e=Ws(n,`data`);return(e?Ws(e,`data`):void 0)??e??n}return Ws(t,`data`)??t}async function Ks(e,t,n,r){let i;for(let a=0;a<ac;a++){let a=await d(e,t,{api:n,data:i?{reqDTO:{...r,asyncTaskId:i}}:{reqDTO:r}}),o=Gs(a);if(o.taskId&&Object.keys(o).length===1){i=o.taskId,await new Promise(e=>setTimeout(e,ic));continue}return a}return null}function qs(e,t){if(t)return t;if(e.workspaceId)return e.workspaceId;process.stderr.write("Error: workspace-id is required. Set via --workspace-id, BAILIAN_WORKSPACE_ID, or `bl config set workspace_id <id>`.\n"),process.stderr.write("Hint: run `bl workspace list` to view available workspaces.\n"),process.exit(1)}function Js(e){return e.toLocaleString(`en-US`)}function Ys(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function Xs(e){let t=Gs(e);if(t.callSuccessCount!==void 0||t.usages!==void 0)return t}function Zs(e){let t=Gs(e);return{list:t.list??[],totalCount:t.totalCount??0,maxResults:t.maxResults??0}}function Qs(e){let t={};if(e.usages&&Array.isArray(e.usages))for(let n of e.usages)n.key&&n.value!=null&&(t[n.key]=n.value);if(e.usage&&typeof e.usage==`object`)for(let[n,r]of Object.entries(e.usage))r!=null&&(t[n]=r);return t}function $s(e){let t=e.unit?` [${e.unit}]`:``;return`${e.en}${t}`}function ec(e,t,n,r,i){let a=i?e=>e:e=>`\x1b[1m${e}\x1b[0m`,o=i?e=>e:e=>`\x1b[2m${e}\x1b[0m`;process.stdout.write(`${o(`Time Range Period:`)} ${Ys(t)} ~ ${Ys(n)} ${o(`(${r} days)`)}\n\n`);let s=[[`Models Called`,Js(e.modelCount??0)],[`Successful Calls`,Js(e.callSuccessCount??0)]];for(let t of e.usages??[]){let e=oc[t.key],n=e?$s(e):t.key;s.push([n,Js(t.value)])}let c=Math.max(...s.map(([e])=>_s(e)));for(let[e,t]of s)process.stdout.write(`${a(W(e,c+2))}${t}\n`)}function tc(e,t,n,r,i){let a=i?e=>e:e=>`\x1b[1m${e}\x1b[0m`,o=i?e=>e:e=>`\x1b[2m${e}\x1b[0m`;if(process.stdout.write(`${o(`Time Range Period:`)} ${Ys(t)} ~ ${Ys(n)} ${o(`(${r} days)`)}\n\n`),e.length===0){process.stdout.write(`No usage data found.
|
|
177
|
-
`);return}let s=new Set,c=e.map(e=>{let t=Qs(e);for(let e of Object.keys(t))s.add(e);return t}),l=[...s].sort((e,t)=>{let n=[`total_token`,`input_token`,`output_token`,`input_token_cache`,`image_number`,`video_duration`,`content_duration`,`tts_text_number`],r=n.indexOf(e),i=n.indexOf(t);return(r===-1?999:r)-(i===-1?999:i)}),u=[`Model`,`Calls`,...l.map(e=>oc[e]?.en??e)],d=e.map((e,t)=>[e.model,Js(e.callSuccessCount??0),...l.map(e=>{let n=c[t][e];return n==null?`-`:Js(n)})]),f=u.map((e,t)=>Math.max(_s(e),...d.map(e=>_s(e[t])))),p=u.map((e,t)=>a(W(e,f[t]))).join(` `),m=f.map(e=>o(`โ`.repeat(e))).join(`โโ`);process.stdout.write(p+`
|
|
178
|
-
`),process.stdout.write(m+`
|
|
179
|
-
`);for(let e of d){let t=e.map((e,t)=>W(e,f[t]));process.stdout.write(t.join(` `)+`
|
|
180
|
-
`)}process.stdout.write(o(`\nTotal: ${e.length} models`)+`
|
|
181
|
-
`)}var nc,rc,ic,ac,oc,sc,cc=M((()=>{I(),vs(),nc=`zeldaEasy.bailian-telemetry.model.getModelUsageStatistic`,rc=`zeldaEasy.bailian-telemetry.model.listModelUsageStatisticData`,ic=500,ac=30,oc={total_token:{en:`Total Tokens`,unit:`tokens`},input_token:{en:`Input Tokens`,unit:`tokens`},output_token:{en:`Output Tokens`,unit:`tokens`},input_token_cache:{en:`Cached Tokens`,unit:`tokens`},input_token_cache_read:{en:`Cache Read`,unit:`tokens`},input_token_cache_creation:{en:`Cache Creation`,unit:`tokens`},thinking_input_token:{en:`Thinking Input`,unit:`tokens`},thinking_output_token:{en:`Thinking Output`,unit:`tokens`},text_input_token:{en:`Text Input`,unit:`tokens`},purein_text_output_token:{en:`Text Output`,unit:`tokens`},embedding_token:{en:`Embedding`,unit:`tokens`},image_number:{en:`Images`,unit:`images`},video_duration:{en:`Video Duration`,unit:`sec`},content_duration:{en:`Audio Duration`,unit:`sec`},tts_text_number:{en:`TTS Chars`,unit:`chars`},total_token_avg:{en:`Avg Tokens/Req`}},sc=m({name:`usage stats`,description:`Query model usage statistics`,skipDefaultApiKeySetup:!0,usage:`bl usage stats [--model <model>] [--days <days>] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s), comma-separated; omit for overview`},{flag:`--days <days>`,description:`Number of days (default: 7)`},{flag:`--type <type>`,description:`Model type: Text, Vision, Multimodal, Audio, Embedding`},{flag:`--workspace-id <id>`,description:`Workspace ID (env: BAILIAN_WORKSPACE_ID)`},{flag:`--console-region <region>`,description:`Console region`},{flag:`--console-site <site>`,description:`Console site: domestic, international`},{flag:`--console-switch-agent <uid>`,description:`Switch agent UID`,type:`number`}],examples:[`bl usage stats`,`bl usage stats --days 30`,`bl usage stats --model qwen-turbo`,`bl usage stats --model qwen-turbo --days 7`,`bl usage stats --model qwen3.6-plus,deepseek-v4-pro`,`bl usage stats --type Text --days 14`,`bl usage stats --output json`],async run(e,t){let n=t.model||void 0,r=Number(t.days)||7,i=t.type||void 0,a=h(e.output),o=qs(e,t.workspaceId||void 0),s=Date.now(),c=s-r*24*60*60*1e3;if(n){let t=[...new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean))],l={startTime:c,endTime:s,modelCallSource:`Online`,filterWorkspaceId:o,maxResults:50,skip:0,sortField:`success_count`,sortOrder:`DESC`};if(i&&(l.obsModelType=i),e.dryRun){P({api:rc,data:{reqDTO:{...l,model:t.join(`,`)}}},a);return}let u=await he(e),d=await Promise.all(t.map(t=>Ks(e,u.token,rc,{...l,model:t}))),f=[];for(let e of d){if(!e)continue;let t=Zs(e);f.push(...t.list)}if(a===`json`){let e=f.map(e=>{let t=Qs(e),n={model:e.model,successfulCalls:e.callSuccessCount??0};for(let[e,r]of Object.entries(t))n[e]=r;return n});P({period:{start:Ys(c),end:Ys(s),days:r},items:e},a);return}tc(f,c,s,r,e.noColor)}else{let t={startTime:c,endTime:s,modelCallSource:`Online`,filterWorkspaceId:o};if(i&&(t.obsModelType=i),e.dryRun){P({api:nc,data:{reqDTO:t}},a);return}let n=await Ks(e,(await he(e)).token,nc,t);n||(process.stderr.write(`Error: request timed out.
|
|
182
|
-
`),process.exit(1));let l=Xs(n);if(a===`json`){if(!l){P({period:{start:Ys(c),end:Ys(s),days:r},modelsCalled:0,successfulCalls:0},a);return}P({period:{start:Ys(c),end:Ys(s),days:r},modelsCalled:l.modelCount??0,successfulCalls:l.callSuccessCount??0,usages:(l.usages??[]).map(e=>({key:e.key,value:e.value,unit:e.unit,label:oc[e.key]?.en??e.key}))},a);return}if(!l){process.stdout.write(`No usage data found.
|
|
183
|
-
`);return}ec(l,c,s,r,e.noColor)}}})}));function lc(e,t){return e instanceof G?e:new G(`step_execution_error`,e instanceof Error?e.message:String(e),{step:t})}var G,uc=M((()=>{G=class extends Error{code;step;details;constructor(e,t,n){super(t),this.name=`PipelineError`,this.code=e,this.step=n?.step,this.details=n?.details}toJSON(){return{code:this.code,message:this.message,...this.step?{step:this.step}:{},...this.details?{details:this.details}:{}}}}}));function dc(){return mc}function fc(e,t,n,r){let i,a;n instanceof pc?(i=n,a=r):(i=mc,a=n??r),i.registerStep(e,t,a)}var pc,mc,hc=M((()=>{uc(),pc=class{handlers=new Map;outputSchemas=new Map;registerStep(e,t,n){this.handlers.set(e,t),n&&this.outputSchemas.set(e,n)}executeStep(e,t,n){let r=this.handlers.get(e);if(!r)throw new G(`unknown_step`,`Unknown step type: ${e}`,{details:{available:this.listSteps()}});return r(t,n)}hasStep(e){return this.handlers.has(e)}listSteps(){return Array.from(this.handlers.keys()).sort()}getOutputSchema(e){return this.outputSchemas.get(e)}},mc=new pc}));function gc(){let e=ne(_c);return e.clientName=`bailian-cli`,e}var _c,vc=M((()=>{_c={output:`json`,nonInteractive:!0,noColor:!0,quiet:!0,verbose:!1,yes:!1,dryRun:!1,help:!1,async:!1}}));function yc(e){return e.startsWith(`./`)||e.startsWith(`../`)}function bc(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))typeof a==`string`&&yc(a)?(n[i]=et(t,a),r.push(i)):n[i]=a;return{input:n,resolvedKeys:r}}async function xc(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 Sc(e){if(e===void 0)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m)?$/);if(!t)return;let n=Number(t[1]);if(!Number.isFinite(n)||n<=0)return;let r=t[2]??`s`;return r===`ms`?n/1e3:r===`m`?n*60:n}function K(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Cc(e,t){if(Array.isArray(e)){e.forEach(e=>Cc(e,t));return}if(K(e)){`$from`in e&&typeof e.$from==`string`&&t.add(e.$from);for(let n of Object.values(e))Cc(n,t)}}async function wc(e,t){let n=[];for(let r of e)for(let[e,i]of Object.entries(r.input)){if(Tc.includes(e)||typeof i!=`string`||!yc(i))continue;let a=et(t,i);await Je(a).then(()=>!0,()=>!1)||n.push(`Step "${r.id}" input "${e}" references file that does not exist: ${a}`)}return n}var Tc,Ec=M((()=>{Tc=[`download`,`out-dir`,`output`]}));async function Dc(e,t,n){if(!t.message)throw new G(`missing_input`,`text/chat requires 'message' input`,{step:`text/chat`});let r=t.model||`qwen3.7-max`,i=[];t.system&&i.push({role:`system`,content:t.system}),i.push({role:`user`,content:t.message});let a={model:r,messages:i,max_tokens:t[`max-tokens`]??4096,stream:!1};return t.temperature!==void 0&&(a.temperature=t.temperature),t[`top-p`]!==void 0&&(a.top_p=t[`top-p`]),t[`enable-thinking`]&&(a.enable_thinking=!0,t[`thinking-budget`]!==void 0&&(a.thinking_budget=t[`thinking-budget`])),await k(e,{url:f(e.baseUrl),method:`POST`,body:a,timeout:n.blRequestTimeoutSeconds,signal:n.signal})}async function Oc(e,t,n){let r=t.model||`qwen3-vl-plus`,i=Array.isArray(t.image)?t.image:t.image?[t.image]:[],a=t.video?`Describe the video.`:`Describe the image.`,o=t.prompt||a,s=[];if(t.video){let i=t.video;if(ee(i)){let t=await A(e);i=await j(i,t.token,r,{signal:n.signal})}s.push({type:`video_url`,video_url:{url:i}})}for(let t of i){let i=t;ee(t)&&(i=await j(t,(await A(e)).token,r,{signal:n.signal})),s.push({type:`image_url`,image_url:{url:i}})}s.push({type:`text`,text:o});let c={model:r,messages:[{role:`user`,content:s}]};return await k(e,{url:f(e.baseUrl),method:`POST`,body:c,signal:n.signal})}function kc(e){return Bc.some(t=>e.startsWith(t))}async function Ac(e,t,n){if(!t.prompt)throw new G(`missing_input`,`image/generate requires 'prompt' input`,{step:`image/generate`});let r=t.model||`qwen-image-2.0`,i=kc(r),a=t.n??1,o=me(t[`prompt-extend`],i?!0:void 0,`prompt-extend`),s={model:r,input:{messages:[{role:`user`,content:[{text:t.prompt}]}]},parameters:{size:oa(t.size,i),n:a,seed:t.seed,prompt_extend:o,watermark:_e(t.watermark),negative_prompt:t[`negative-prompt`]||void 0}};if(i){let r=await k(e,{url:E(e.baseUrl),method:`POST`,body:s,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),a=await Mc(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await k(e,{url:T(e.baseUrl),method:`POST`,body:s,async:!0,signal:n.signal})).output.task_id,i=await Lc(e,r,n),a=await Mc(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function jc(e,t,n){if(!t.prompt)throw new G(`missing_input`,`image/edit requires 'prompt' input`,{step:`image/edit`});let r=Array.isArray(t.image)?t.image:t.image?[t.image]:[],i=t.model||`qwen-image-2.0`,a=kc(i),o=t.n??1,s=me(t[`prompt-extend`],a?!0:void 0,`prompt-extend`),c=[];for(let t of r){let r=t;ee(t)&&(r=await j(t,(await A(e)).token,i,{signal:n.signal})),c.push({image:r})}c.push({text:t.prompt});let l={model:i,input:{messages:[{role:`user`,content:c}]},parameters:{size:oa(t.size,a),n:o,seed:t.seed,prompt_extend:s,watermark:_e(t.watermark),negative_prompt:t[`negative-prompt`]||void 0}};if(a){let r=await k(e,{url:E(e.baseUrl),method:`POST`,body:l,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),a=await Mc(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await k(e,{url:T(e.baseUrl),method:`POST`,body:l,async:!0,signal:n.signal})).output.task_id,i=await Lc(e,r,n),a=await Mc(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function Mc(e,t,n){if(!t||e.length===0)return;await Ye(t,{recursive:!0});let r=n&&n.length>0?n:`image`,i=e.length===1?[{url:e[0],destPath:$e(t,`${r}.png`)}]:e.map((e,n)=>({url:e,destPath:$e(t,`${r}_${String(n+1).padStart(3,`0`)}.png`)})),a=[];for(let{url:e,destPath:t}of i)await $i(e,t,{quiet:!0}),a.push(t);return a}async function Nc(e,t,n){if(!t.prompt)throw new G(`missing_input`,`video/generate requires 'prompt' input`,{step:`video/generate`});let r=t.model||(t.image?`happyhorse-1.1-i2v`:`happyhorse-1.1-t2v`),i;if(t.image)if(ee(t.image)){let a=await A(e);i=await j(t.image,a.token,r,{signal:n.signal})}else i=t.image;let a={model:r,input:{prompt:t.prompt,negative_prompt:t[`negative-prompt`]||void 0,...i?{media:[{type:`first_frame`,url:i}]}:{}},parameters:{resolution:t.resolution||void 0,ratio:t.ratio||void 0,duration:t.duration,prompt_extend:me(t[`prompt-extend`],void 0,`prompt-extend`),watermark:_e(t.watermark),seed:t.seed}};xe(a.parameters);let o=(await k(e,{url:De(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Rc(e,o,(t[`poll-interval`]??10)*1e3,(n.timeoutSeconds??900)*1e3,n)}async function Pc(e,t,n){let r=t.text;if(!r&&t[`text-file`]){let{readFileSync:e}=await import(`node:fs`);r=e(t[`text-file`],`utf-8`).trim()}if(!r)throw new G(`missing_input`,`speech/synthesize requires 'text' input`,{step:`speech/synthesize`});let i=t.model||`cosyvoice-v3-flash`,a={model:i,input:{text:r,voice:t.voice,format:t.format,sample_rate:t[`sample-rate`],volume:t.volume,rate:t.rate,pitch:t.pitch,seed:t.seed,language_hints:t.language?[t.language]:void 0,instruction:t.instruction,enable_ssml:t[`enable-ssml`]}};xe(a.input);let o=await k(e,{url:be(e.baseUrl),method:`POST`,body:a,signal:n.signal});return{audio_url:o.output.audio.url,url_expires_at:o.output.audio.expires_at,model:i,voice:t.voice,request_id:o.request_id}}async function Fc(e,t,n){let r=Array.isArray(t.url)?t.url:t.url?[t.url]:[];if(r.length===0)throw new G(`missing_input`,`speech/recognize requires 'url' input`,{step:`speech/recognize`});let i=[];for(let a of r)if(ee(a)){let r=await A(e);i.push(await j(a,r.token,t.model||`fun-asr`,{signal:n.signal}))}else i.push(a);let a={model:t.model||`fun-asr`,input:{file_urls:i},parameters:{channel_id:t[`channel-id`]===void 0?void 0:[t[`channel-id`]],language_hints:t.language?[t.language]:void 0,diarization_enabled:t.diarization,speaker_count:t[`speaker-count`],vocabulary_id:t[`vocabulary-id`]}};xe(a.parameters);let o=(await k(e,{url:ye(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Rc(e,o,(t[`poll-interval`]??2)*1e3,(n.timeoutSeconds??300)*1e3,n)}function Ic(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 Lc(e,t,n){return await Rc(e,t,3e3,e.timeout*1e3,n)}async function Rc(e,t,n,r,i){let a=Date.now(),o=0;for(;;){if(i?.signal?.aborted)throw new G(`aborted`,`Task polling was aborted`,{details:{taskId:t}});await zc(n,i?.signal),o++;let s=await k(e,{url:Se(e.baseUrl,t),method:`GET`,signal:i?.signal}),c=s.output.task_status;if(c===`SUCCEEDED`)return Ic(s);if(c===`FAILED`)throw new G(`async_task_failed`,s.output.message||s.output.code||`Task failed`,{details:{taskId:t,data:s}});let l=Date.now()-a;if(await i?.emitEvent?.({type:`step.polling`,timestamp:new Date().toISOString(),status:`running`,taskId:t,taskStatus:c,elapsedMs:l,pollAttempt:o}),l>r)throw new G(`async_poll_timeout`,`Task ${t} timed out after ${Math.round(r/1e3)}s`,{details:{taskId:t,timeoutMs:r,pollAttempts:o}})}}function zc(e,t){return t?new Promise((n,r)=>{let i=setTimeout(()=>{o(),n()},e),a=()=>{o(),r(new G(`aborted`,`Poll delay was aborted`))},o=()=>{clearTimeout(i),t.removeEventListener(`abort`,a)};t.aborted?a():t.addEventListener(`abort`,a,{once:!0})}):new Promise(t=>setTimeout(t,e))}var Bc,Vc=M((()=>{uc(),la(),ta(),Bc=[`qwen-image-2.0`,`qwen-image-max`]}));function Hc(e){for(let t of Object.keys(Zc))fc(t,async(e,n)=>await Uc(t,e,n),e,$c[t])}async function Uc(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=Zc[e];if(!r)throw Error(`No direct API handler registered for step: ${e}`);let i=await r(n.blConfig??gc(),t,n),a=Qc[e];return a?a(i):{data:i,warnings:[],metadata:{}}}function Wc(e){if(!K(e))return;let t=[],n=q(e.task_id)??q(e.taskId);for(let r of Jc(e.urls))t.push({url:r,taskId:n,kind:Yc(r)});for(let r of Jc(e.saved))t.push({path:r,taskId:n,kind:Xc(r)});let r=q(e.video_url)??q(e.videoUrl);r&&t.push({url:r,taskId:n,kind:`video`});let i=q(e.saved);if(i&&t.push({path:i,taskId:n,kind:Xc(i)}),Array.isArray(e.videos))for(let n of e.videos){if(!K(n))continue;let e=q(n.task_id)??q(n.taskId),r=q(n.video_url)??q(n.videoUrl),i=q(n.saved);r&&t.push({url:r,taskId:e,kind:`video`}),i&&t.push({path:i,taskId:e,kind:`video`})}let a=Array.isArray(e.task_ids)?e.task_ids.map(q).filter(qc):[];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 Gc(e,t){if(!K(e))return;let n=[],r=q(e.task_id)??q(e.taskId),i=[q(e.url),q(e.audio_url),q(e.audioUrl),q(e.output_url),q(e.outputUrl)].filter(qc);for(let e of i)n.push({url:e,taskId:r,kind:t});let a=[q(e.saved),q(e.path),q(e.output_path),q(e.outputPath)].filter(qc);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?Kc(n):void 0}function Kc(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 qc(e){return typeof e==`string`}function q(e){return typeof e==`string`&&e.length>0?e:void 0}function Jc(e){return Array.isArray(e)?e.map(q).filter(qc):[]}function Yc(e){try{return Xc(new URL(e).pathname)}catch{return`artifact`}}function Xc(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 Zc,Qc,$c,el=M((()=>{hc(),vc(),Ec(),Vc(),Zc={"text/chat":(e,t,n)=>Dc(e,t,n),"vision/describe":(e,t,n)=>Oc(e,t,n),"image/generate":(e,t,n)=>Ac(e,t,n),"image/edit":(e,t,n)=>jc(e,t,n),"video/generate":(e,t,n)=>Nc(e,t,n),"speech/synthesize":(e,t,n)=>Pc(e,t,n),"speech/recognize":(e,t,n)=>Fc(e,t,n)},Qc={"image/generate":e=>({data:e,artifacts:Wc(e),warnings:[],metadata:{}}),"image/edit":e=>({data:e,artifacts:Wc(e),warnings:[],metadata:{}}),"video/generate":e=>({data:e,artifacts:Wc(e),warnings:[],metadata:{}}),"speech/synthesize":e=>({data:e,artifacts:Gc(e,`audio`),warnings:[],metadata:{}}),"speech/recognize":e=>({data:e,artifacts:Gc(e,`transcript`),warnings:[],metadata:{}})},$c={"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`}]}}})),tl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;let a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),nl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=tl();var n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;let o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),J=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;let t=tl(),n=nl();var r=tl();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=nl();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=te(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=te(this.rhs,e,n),this}get names(){return ee(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=te(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(ne(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(O(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=te(this.condition,e,t),this}get names(){let e=super.names;return ee(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=te(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return ee(ee(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=te(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
184
|
-
`:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function ee(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function te(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function ne(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function O(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${ce(e)}`}e.not=O;let re=se(e.operators.AND);function ie(...e){return e.reduce(re)}e.and=ie;let ae=se(e.operators.OR);function oe(...e){return e.reduce(ae)}e.or=oe;function se(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${ce(n)} ${e} ${ce(r)}`}function ce(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),Y=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;let t=J(),n=tl();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})),rl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),il=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=J(),n=Y(),r=rl();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])}})),al=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=il(),n=J(),r=rl(),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)}})),ol=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRules=e.isJSONType=void 0;let t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),sl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),cl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;let t=ol(),n=sl(),r=il(),i=J(),a=Y();var o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;let u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
|
|
185
|
-
|| (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
|
|
186
|
-
|| (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
|
|
187
|
-
|| ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}e.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;s.number&&delete s.integer;for(let e in s)o=(0,i.and)(o,m(e,t,n,r));return o}e.checkDataTypes=h;let g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}e.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),ll=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;let t=J(),n=Y();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}e.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),ul=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;let t=J(),n=Y(),r=rl(),i=Y();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}e.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}e.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}e.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=m;let h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}e.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=v})),dl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=J(),n=rl(),r=ul(),i=il();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})),fl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=J(),n=Y();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=a})),pl=N(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),ml=N(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else (p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),hl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=Y(),n=pl(),r=ml(),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})),gl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=al(),n=cl(),r=sl(),i=cl(),a=ll(),o=dl(),s=fl(),c=J(),l=rl(),u=hl(),d=Y(),f=il();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&&ne(e),D(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),O(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&&ne(e),ee(e),te(e);let a=r.const(`_errs`,l.default.errors);T(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function w(e){(0,d.checkUnknownRules)(e),E(e)}function T(e,t){if(e.opts.jtd)return ie(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);ie(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function E(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function D(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function ee(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function te(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function ne({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 O(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&re(e),t.return((0,c._)`${l.default.errors} === 0`))}function re({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function ie(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>me(e,`$ref`,h.all.$ref.definition));return}p.jtd||oe(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),ae(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):ae(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function ae(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&me(e,n.keyword,n.definition,t.type)})}function oe(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(se(e,t),e.opts.allowUnionTypes||ce(e,t),le(e,e.dataTypes))}function se(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{de(e.dataTypes,t)||pe(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),fe(e,t)}}function ce(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&pe(e,`use allowUnionTypes to allow union type keyword`)}function le(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>ue(t,e))&&pe(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function ue(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function de(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function fe(e,t){let n=[];for(let r of e.dataTypes)de(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function pe(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var k=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`,j(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=k;function me(e,t,n,r){let i=new k(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}let he=/^\/(?:[^~]|~0|~1)*$/,A=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function j(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!he.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=A.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=j})),_l=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),vl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=hl();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))}}})),yl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=J(),n=_l(),r=rl(),i=hl(),a=Y(),o=gl();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}})),bl=N(((e,t)=>{t.exports={$id:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,description:`Meta-schema for $data reference (JSON AnySchema extension proposal)`,type:`object`,required:[`$data`],properties:{$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},additionalProperties:!1}})),xl=N(((e,t)=>{let n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),i=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),a=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),o=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function s(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}let c=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function l(e){return e.length=0,!0}function u(e,t,n){if(e.length){let r=s(e);if(r!==``)t.push(r);else return n.error=!0,!1;e.length=0}return!0}function d(e){let t=0,n={error:!1,address:``,zone:``},r=[],i=[],a=!1,o=!1,c=u;for(let s=0;s<e.length;s++){let u=e[s];if(!(u===`[`||u===`]`))if(u===`:`){if(a===!0&&(o=!0),!c(i,r,n))break;if(++t>7){n.error=!0;break}s>0&&e[s-1]===`:`&&(a=!0),r.push(`:`);continue}else if(u===`%`){if(!c(i,r,n))break;c=l}else{i.push(u);continue}}return i.length&&(c===l?n.zone=i.join(``):o?r.push(i.join(``)):r.push(s(i))),n.address=r.join(``),n}function f(e){if(p(e,`:`)<2)return{host:e,isIPV6:!1};let t=d(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+=`%`+t.zone,n+=`%25`+t.zone),{host:e,isIPV6:!0,escapedHost:n}}}function p(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function m(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}else{n.push(t);break}}else if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}else if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}let h={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},g=/[@/?#:]/g,_=/[@/?#]/g;function v(e,t){let n=t?_:g;return n.lastIndex=0,e.replace(n,e=>h[e])}function y(e,t=!1){if(e.indexOf(`%`)===-1)return e;let n=``;for(let r=0;r<e.length;r++){if(e[r]===`%`&&r+2<e.length){let o=e.slice(r+1,r+3);if(i(o)){let e=o.toUpperCase(),i=String.fromCharCode(parseInt(e,16));t&&a(i)?n+=i:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function b(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&a(i)?t+=i:t+=`%`+e,n+=2;continue}}o(e[n])?t+=e[n]:t+=escape(e[n])}return t}function x(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function S(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push(`@`)),e.host!==void 0){let n=unescape(e.host);if(!r(n)){let e=f(n);n=e.isIPV6===!0?`[${e.escapedHost}]`:v(n,!1)}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:c,recomposeAuthority:S,reescapeHostDelimiters:v,normalizePercentEncoding:y,normalizePathEncoding:b,escapePreservingEscapes:x,removeDotSegments:m,isIPv4:r,isUUID:n,normalizeIPv6:f,stringArrayToHexStripped:s}})),Sl=N(((e,t)=>{let{isUUID:n}=xl(),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}})),Cl=N(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=xl(),{SCHEMES:d,getSchemeHandler:f}=Sl();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})),wl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Cl();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),Tl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=gl();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=J();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return n.CodeGen}});let r=_l(),i=vl(),a=ol(),o=yl(),s=J(),c=hl(),l=cl(),u=Y(),d=bl(),f=wl(),p=(e,t)=>new RegExp(e,t);p.code=`new RegExp`;let m=[`removeAdditional`,`useDefaults`,`coerceTypes`],h=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),g={errorDataPath:``,format:"`validateFormats: false` can be used instead.",nullable:`"nullable" keyword is supported by default.`,jsonPointers:`Deprecated jsPropertySyntax can be used instead.`,extendRefs:`Deprecated ignoreKeywordsWithRef can be used instead.`,missingRefs:`Pass empty schema with $id that should be ignored to ajv.addSchema.`,processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:`"uniqueItems" keyword is always validated.`,unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:`Map is used as cache, schema object as key.`,serialize:`Map is used as cache, schema object as key.`,ajvErrors:`It is default now.`},_={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`};function v(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??p,a=e.uriResolver??f.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??200,loopEnum:e.loopEnum??200,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var y=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...v(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:h,es5:t,lines:n}),this.logger=D(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),b.call(this,g,e,`NOT SUPPORTED`),b.call(this,_,e,`DEPRECATED`,`warn`),this._metaOpts=T.call(this),e.formats&&C.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&w.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),S.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=d;n===`id`&&(r={...d},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw Error(`$schema must be a string`);if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(`meta-schema not available`),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=x.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new o.SchemaEnv({schema:{},schemaId:n});if(t=o.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case`undefined`:return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case`string`:{let t=x.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,c.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(te.call(this,n,t),!t)return(0,u.eachItem)(n,e=>ne.call(this,e)),this;re.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>ne.call(this,e,r):e=>r.type.forEach(t=>ne.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=ae(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};y.ValidationError=r.default,y.MissingRefError=i.default,e.default=y;function b(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function x(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function S(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function C(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function w(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function T(){let e={...this.opts};for(let t of m)delete e[t];return e}let E={log(){},warn(){},error(){}};function D(e){if(e===!1)return E;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}let ee=/^[a-z_$][a-z0-9_$:-]*$/i;function te(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!ee.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function ne(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?O.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 O(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function re(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=ae(t)),e.validateSchema=this.compile(t,!0))}let ie={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function ae(e){return{anyOf:[e,ie]}}})),El=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),Dl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;let t=vl(),n=ul(),r=J(),i=rl(),a=yl(),o=Y(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);if(h instanceof a.SchemaEnv)return _(h);return v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0)if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}if(l.items!==!0)if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}e.callRef=l,e.default=s})),Ol=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=El(),n=Dl();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),kl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),Al=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),jl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),Ml=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=jl();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}`)}}})),Nl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ul(),n=Y(),r=J();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),Pl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),Fl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ul(),n=J(),r=Y();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),Il=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),Ll=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=pl();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),Rl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=cl(),n=J(),r=Y(),i=Ll();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)})))}}}})),zl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=Ll();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}`)}}})),Bl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=Ll();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}`}}}})),Vl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=kl(),n=Al(),r=Ml(),i=Nl(),a=Pl(),o=Fl(),s=Il(),c=Rl(),l=zl(),u=Bl();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]})),Hl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;let t=J(),n=Y(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=i,e.default=r})),Ul=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;let t=J(),n=Y(),r=ul(),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})),Wl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ul();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),Gl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=ul(),i=Hl();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)))}}})),Kl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),ql=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=J(),n=Y(),r=ul();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
|
|
188
|
-
missingProperty: ${i},
|
|
189
|
-
depsCount: ${n},
|
|
190
|
-
deps: ${r}}`};let i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=s,e.default=i})),Jl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),Yl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ul(),n=J(),r=rl(),i=Y();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),Xl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=gl(),n=ul(),r=Y(),i=Yl();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)}}}})),Zl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ul(),n=J(),r=Y(),i=Y();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),Ql=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Y();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),$l=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:ul().validateUnion,error:{message:`must match a schema in anyOf`}}})),eu=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),tu=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Y();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),nu=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),ru=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Y();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),iu=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Hl(),n=Wl(),r=Ul(),i=Gl(),a=Kl(),o=ql(),s=Jl(),c=Yl(),l=Xl(),u=Zl(),d=Ql(),f=$l(),p=eu(),m=tu(),h=nu(),g=ru();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=_})),au=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),ou=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[au().default]})),su=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),cu=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ol(),n=Vl(),r=iu(),i=ou(),a=su();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),lu=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),uu=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=lu(),r=yl(),i=vl(),a=Y();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();o.if(!1);for(let e in r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),du=N(((e,t)=>{t.exports={$schema:`http://json-schema.org/draft-07/schema#`,$id:`http://json-schema.org/draft-07/schema#`,title:`Core schema meta-schema`,definitions:{schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},type:[`object`,`boolean`],properties:{$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},default:!0}})),fu=N(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;let n=Tl(),r=cu(),i=uu(),a=du(),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=gl();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=J();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return u.CodeGen}});var d=_l();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return d.default}});var f=vl();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return f.default}})}));function pu(e,t=`schema`){let n=[];return _u(e,t,n),n.length===0&&!Du.validateSchema(e)&&n.push(...vu(Du.errors,t)),n}function mu(e,t){let n=bu(t,e,`input`);return n.ok?K(n.value)?{ok:!0,value:n.value}:{ok:!1,issues:[`input must be an object`]}:{ok:!1,issues:n.issues}}function hu(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 gu(e,t){let n=hu(t);if(!n.ok)return;let r=e;for(let e of n.segments){if(Array.isArray(r)){if(!/^(0|[1-9]\d*)$/.test(e))return;r=r[Number(e)];continue}if(K(r)){if(e===`__proto__`||e===`constructor`||e===`prototype`||!Object.prototype.hasOwnProperty.call(r,e))return;r=r[e];continue}return}return r}function _u(e,t,n){if(!K(e)){n.push(`${t} must be an object`);return}for(let r of Object.keys(e))Tu.has(r)||n.push(`${t} has unsupported keyword "${r}"`);if(`type`in e&&yu(e.type,`${t}.type`,n),`properties`in e)if(!K(e.properties))n.push(`${t}.properties must be an object`);else for(let[r,i]of Object.entries(e.properties))_u(i,`${t}.properties.${r}`,n);if(`items`in e&&_u(e.items,`${t}.items`,n),`required`in e&&(!Array.isArray(e.required)||!e.required.every(e=>typeof e==`string`))&&n.push(`${t}.required must be an array of strings`),`enum`in e&&!Array.isArray(e.enum)&&n.push(`${t}.enum must be an array`),`description`in e&&typeof e.description!=`string`&&n.push(`${t}.description must be a string`),`format`in e&&typeof e.format!=`string`&&n.push(`${t}.format must be a string`),`additionalProperties`in e){let r=e.additionalProperties;r!==!0&&r!==!1&&!K(r)?n.push(`${t}.additionalProperties must be a boolean or schema object`):K(r)&&_u(r,`${t}.additionalProperties`,n)}}function vu(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 yu(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)Eu.has(e)||n.push(`${t} has unsupported type "${String(e)}"`)}function bu(e,t,n){if((e==null||e===``)&&t.default!==void 0&&(e=t.default),t.enum&&e!==void 0){let r=t.enum.map(Su);if(!r.includes(Su(e)))return{ok:!1,issues:[`${n} must be one of: ${r.join(`, `)}`]}}let r=xu(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=bu(e,t.items,`${n}.${a}`);o.ok?r[a]=o.value:i.push(...o.issues)}),i.length>0?{ok:!1,issues:i}:{ok:!0,value:r}}if(!(K(e)&&r.has(`object`))&&r.has(`string`)&&!Array.isArray(e)&&!K(e))return{ok:!0,value:String(e)}}if(r.has(`object`)){if(!K(e))return{ok:!1,issues:[`${n} must be an object`]};let r={...e},i=[];for(let e of t.required??[]){let t=r[e];(t==null||t===``)&&i.push(`Missing required input "${e}"`)}for(let[e,a]of Object.entries(t.properties??{})){let t=r[e];if((t==null||t===``)&&a.default===void 0)continue;let o=bu(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=bu(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 xu(e){let t=e.type===void 0?[]:Array.isArray(e.type)?e.type:[e.type];return new Set(t)}function Su(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}var Cu,wu,Tu,Eu,Du,Ou=M((()=>{Cu=ht(fu(),1),Ec(),wu=Cu.default,Tu=new Set([`type`,`properties`,`items`,`required`,`enum`,`default`,`description`,`format`,`additionalProperties`]),Eu=new Set([`string`,`number`,`integer`,`boolean`,`array`,`object`,`null`]),Du=new wu({allErrors:!0,coerceTypes:!1,strict:!1,useDefaults:!1})}));function ku(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}function Au(e,t,n,r){let i={},a={},o=[],s=!1;for(let[c,l]of Object.entries(e.input)){let e=Iu(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 ju(e,t,n){let r={},i=[];for(let[a,o]of Object.entries(e.input)){let e=Lu(o,t,n);r[a]=e.redacted,e.sensitive&&i.push(a)}return{redacted:r,sensitiveKeys:i}}function Mu(e,t,n,r){return Bu(e,e=>Iu(e,t,n,r))}function Nu(e){return Bu(e,e=>X(e,e,!1,e!==void 0))}function Pu(e){return{...e.data===void 0?{}:{data:qu},...e.artifacts?{artifacts:e.artifacts.map(Gu)}:{},...e.warnings?{warnings:e.warnings.map(e=>({code:e.code,message:e.message}))}:{},metadata:{...e.metadata?.step?{step:e.metadata.step}:{},redacted:!0}}}function Fu(e){return{code:e.code,message:qu,...e.step?{step:e.step}:{},details:{redacted:!0}}}function Iu(e,t,n,r){if(Array.isArray(e)){let i=e.map(e=>Iu(e,t,n,r));return X(i.map(e=>e.value),i.map(e=>e.redacted),i.some(e=>e.sensitive))}if(!Ku(e)){if(!K(e))return X(e,e,!1,e!==void 0);let i={},a={},o=!1;for(let[s,c]of Object.entries(e)){let e=Iu(c,t,n,r);i[s]=e.value,a[s]=e.redacted,o||=e.sensitive}return X(i,a,o)}if(`$input`in e){let t=gu(n,e.$input);return X(t,t,!1,t!==void 0)}if(`$from`in e){let t=e.$from,n=r.get(t);if(!n)throw new G(`pipeline_reference_error`,`Step output not found: ${t}`);let i=typeof e.path==`string`?e.path:``,a=gu(n,i);if(a===void 0)throw new G(`pipeline_reference_error`,`Step output path not found: ${t}${i}`);return X(a,a,!1,!0)}if(`$env`in e){let n=Ru(t.env,e.$env,!1);return X(n,n,!1,n!==void 0)}if(`$secret`in e){let n=Ru(t.secrets,e.$secret,!0);return X(n,qu,!0,n!==void 0)}if(`$concat`in e){let i=e.$concat.map(e=>Iu(e,t,n,r)),a=i.map(e=>ku(e.value)).join(``),o=i.some(e=>e.sensitive);return X(a,i.map(e=>e.sensitive?qu:ku(e.value)).join(``),o)}if(`$coalesce`in e){let i=e.$coalesce,a;for(let e of i)try{let i=Iu(e,t,n,r);if(i.exists&&i.value!==void 0&&i.value!==null)return i}catch(e){a=e;continue}if(a)throw a;return X(void 0,void 0,!1,!1)}if(`$js`in e){let i=e.$js,a=e.args??{},o={},s={},c=!1;for(let[e,i]of Object.entries(a)){let a=Iu(i,t,n,r);o[e]=a.value,s[e]=a.redacted,c||=a.sensitive}try{let e=Function(`args`,`return (${i})`)(o);return X(e,c?qu:e,c)}catch(e){throw new G(`pipeline_js_error`,`$js expression failed: ${e instanceof Error?e.message:String(e)}`)}}return X(e,e,!1)}function Lu(e,t,n){if(Array.isArray(e)){let r=e.map(e=>Lu(e,t,n));return X(r.map(e=>e.value),r.map(e=>e.redacted),r.some(e=>e.sensitive))}if(!Ku(e)){if(!K(e))return X(e,e,!1,e!==void 0);let r={},i=!1;for(let[a,o]of Object.entries(e)){let e=Lu(o,t,n);r[a]=e.redacted,i||=e.sensitive}return X(r,r,i)}if(`$input`in e){let t=gu(n,e.$input);return X(t,t,!1,t!==void 0)}if(`$from`in e)return X({...e},{...e},!1);if(`$env`in e){let n=Ru(t.env,e.$env,!1);return X(n,n,!1,n!==void 0)}if(`$secret`in e)return Ru(t.secrets,e.$secret,!0),X(qu,qu,!0,!0);if(`$concat`in e){let r=e.$concat.map(e=>Lu(e,t,n));if(r.some((t,n)=>{let r=e.$concat[n];return K(r)&&`$from`in r}))return X({...e},{...e},r.some(e=>e.sensitive));let i=r.map(e=>ku(e.value)).join(``),a=r.some(e=>e.sensitive);return X(i,r.map(e=>e.sensitive?qu:ku(e.value)).join(``),a)}if(`$coalesce`in e){let r=e.$coalesce;if(r.some(e=>K(e)&&`$from`in e))return X({...e},{...e},!1);for(let e of r){let r=Lu(e,t,n);if(r.exists&&r.value!==void 0&&r.value!==null)return r}return X(void 0,void 0,!1,!1)}return`$js`in e?X({...e},{...e},!1):X(e,e,!1)}function Ru(e,t,n){if(!zu(e,t))throw new G(n?`pipeline_secret_error`:`pipeline_env_error`,`${n?`Secret`:`Environment`} binding is not declared: ${t}`);let r=e[t],i=typeof r==`string`?{from:`env`,name:r,required:!0}:r,a=i.from===`env`||i.from===void 0?process.env[i.name]:void 0;if(a!==void 0&&a!==``)return a;if(i.default!==void 0)return i.default;if(i.required!==!1)throw new G(n?`pipeline_secret_error`:`pipeline_env_error`,`${n?`Secret`:`Environment`} binding not found: ${t}`)}function zu(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function X(e,t,n,r=!0){return{value:e,redacted:t,sensitive:n,exists:r}}function Bu(e,t){if(typeof e==`boolean`)return e;if(K(e)&&`$exists`in e)try{return t(e.$exists).exists}catch(e){if(e instanceof G&&e.code===`pipeline_reference_error`)return!1;throw e}if(K(e)&&`$and`in e){if(!Array.isArray(e.$and)||e.$and.length===0)throw Wu(`$and must be a non-empty array`);return e.$and.every(e=>Bu(e,t))}if(K(e)&&`$or`in e){if(!Array.isArray(e.$or)||e.$or.length===0)throw Wu(`$or must be a non-empty array`);return e.$or.some(e=>Bu(e,t))}if(K(e)&&`$not`in e)return!Bu(e.$not,t);let n=Vu(e);if(n){let[e,r]=n.operands,i=t(e).value,a=t(r).value;switch(n.operator){case`$eq`:return Hu(i,a);case`$ne`:return!Hu(i,a);case`$gt`:return Uu(i,a,n.operator)>0;case`$gte`:return Uu(i,a,n.operator)>=0;case`$lt`:return Uu(i,a,n.operator)<0;case`$lte`:return Uu(i,a,n.operator)<=0;case`$in`:if(!Array.isArray(a))throw Wu(`$in right operand must be an array`);return a.some(e=>Hu(e,i));case`$contains`:if(Array.isArray(i))return i.some(e=>Hu(e,a));if(typeof i==`string`&&typeof a==`string`)return i.includes(a);throw Wu(`$contains left operand must be an array or string`)}}return!!t(e).value}function Vu(e){if(K(e)){for(let t of[`$eq`,`$ne`,`$gt`,`$gte`,`$lt`,`$lte`,`$in`,`$contains`])if(t in e){if(!Array.isArray(e[t])||e[t].length!==2)throw Wu(`${t} must be a two-item array`);return{operator:t,operands:e[t]}}}}function Hu(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Uu(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 Wu(`${n} operands must both be finite numbers or both be strings`)}function Wu(e){return new G(`pipeline_condition_error`,e)}function Gu(e){return{id:e.id,kind:e.kind,mediaType:e.mediaType,metadata:e.metadata?{redacted:!0}:void 0}}function Ku(e){return K(e)&&(`$input`in e||`$from`in e||`$env`in e||`$secret`in e||`$concat`in e||`$coalesce`in e||`$js`in e)}var qu,Ju=M((()=>{uc(),Ou(),Ec(),qu=`[redacted]`}));function Yu(e){fc(`logic/switch`,e=>{let t=Xu(e.cases);for(let e of t)if(Nu(e.condition))return{data:{selected:e.key,value:e.value,matched:!0}};if(`defaultValue`in e)return{data:{selected:typeof e.defaultKey==`string`?e.defaultKey:`default`,value:e.defaultValue,matched:!1}};throw new G(`logic_no_match`,`logic/switch did not match any case`,{step:`logic/switch`,details:{caseCount:t.length}})},e,$u),fc(`logic/select`,e=>{let t=Zu(e.candidates);for(let e of t)if(!(e.available!==void 0&&!Nu(e.available))&&e.value!==void 0&&e.value!==null)return{data:{source:e.source,value:e.value,matched:!0}};if(`defaultValue`in e)return{data:{source:typeof e.defaultSource==`string`?e.defaultSource:`default`,value:e.defaultValue,matched:!1}};throw new G(`logic_no_candidate`,`logic/select did not receive an available candidate`,{step:`logic/select`,details:{candidateCount:t.length}})},e,ed),fc(`logic/assert`,e=>{let t=typeof e.message==`string`?e.message:`Logic assertion failed`,n=K(e.metadata)?e.metadata:void 0;if(!Nu(Qu(e.condition))){if(e.soft===!0)return{data:{ok:!1,message:t,...n?{metadata:n}:{}}};throw new G(`logic_assertion_failed`,t,{step:`logic/assert`,details:n??{}})}return{data:{ok:!0,...e.message===void 0?{}:{message:t},...n?{metadata:n}:{}}}},e,td)}function Xu(e){if(!Array.isArray(e))throw new G(`logic_input_error`,`cases must be an array`,{step:`logic/switch`});return e}function Zu(e){if(!Array.isArray(e))throw new G(`logic_input_error`,`candidates must be an array`,{step:`logic/select`});return e}function Qu(e){if(e===void 0)throw new G(`logic_input_error`,`condition is required`,{step:`logic/assert`});return e}var $u,ed,td,nd=M((()=>{uc(),hc(),Ec(),Ju(),$u={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)`}]},ed={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)`}]},td={description:`Assert a condition is true`,paths:[{path:`/data/ok`,description:`Whether the assertion passed (boolean)`},{path:`/data/message`,description:`Assertion message`}]}}));function rd(e){fc(`script/js`,e=>{let t=e.code;if(!t||typeof t!=`string`)throw new G(`script_js_error`,`script/js requires a 'code' string input`,{step:`script/js`});let n=e.args??{};try{return{data:Function(`args`,t)(n)??{}}}catch(e){throw new G(`script_js_error`,`script/js execution failed: ${e instanceof Error?e.message:String(e)}`,{step:`script/js`})}},e,id)}var id,ad=M((()=>{uc(),hc(),id={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 od(e=dc()){return sd.has(e)?e:(sd.add(e),Hc(e),Yu(e),rd(e),e)}var sd,cd=M((()=>{hc(),el(),nd(),ad(),sd=new WeakSet}));function ld(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??[]);Cc(r.step.input,t),r.step.when!==void 0&&Cc(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 ud(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 dd(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 fd(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 pd(e){if(e===void 0)return 1;if(!Number.isInteger(e)||e<1)throw new G(`pipeline_validation_error`,`Invalid pipeline execution options`,{details:{issues:[`concurrency must be a positive integer`]}});return Math.min(e,md)}var md,hd=M((()=>{uc(),Ec(),md=64})),gd,_d=M((()=>{gd=`workflow/v1`}));function vd(e,t=dc()){let n=xd(e);return n.length>0?n:Sd(e,t)}function yd(e,t=dc()){if(xd(e).length>0)return[];let n=[],r=new Map(e.steps.map(e=>[e.id,e.type]));for(let i of e.steps)Td(i.input,i.id,r,t,n);return n}function bd(e,t){if(!e.inputs)return t;let n=mu(e.inputs,t);if(n.ok)return n.value;throw new G(`pipeline_validation_error`,`Invalid pipeline runtime input`,{details:{issues:n.issues}})}function xd(e){let t=[];if(!K(e))return t.push(`structural: pipeline must be an object`),t;if(e.version!==`workflow/v1`&&t.push(`structural: pipeline.version must be "${gd}"`),!Array.isArray(e.steps))return t.push(`structural: pipeline.steps must be an array`),t;e.steps.length===0&&t.push(`structural: pipeline.steps must contain at least one step`);for(let[n,r]of e.steps.entries()){if(!K(r)){t.push(`structural: step at index ${n} must be an object`);continue}(!r.id||typeof r.id!=`string`)&&t.push(`structural: step at index ${n} must have a string id`),(!r.type||typeof r.type!=`string`)&&t.push(`structural: step at index ${n} must have a string type`),K(r.input)||t.push(`structural: step at index ${n} must have an input object`)}return t}function Sd(e,t){let n=[];e.inputs&&n.push(...pu(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&&wd(a.retry,r,n),a.timeout!==void 0&&Sc(a.timeout)===void 0&&n.push(`semantic: step "${r}" timeout must be a positive number of seconds or duration string`),a.type===`script/js`&&typeof(K(a.input)?a.input.code:void 0)!=`string`&&n.push(`semantic: step "${r}" (script/js) requires a literal string "code"; code sourced from another step ($from) or an expression is not allowed, since it would execute untrusted text as host code`)}for(let e of r){for(let t of e.dependsOn??[])i.has(t)||n.push(`semantic: step "${e.id}" references missing step "${t}"`),t===e.id&&n.push(`semantic: step "${e.id}" references itself`);Cd(e.input,e.id,i,n)}let a=new Map;for(let e of r){let t=new Set(e.dependsOn??[]);Cc(e.input,t),e.when!==void 0&&Cc(e.when,t),a.set(e.id,t)}for(let e of Ed(a))n.push(`semantic: pipeline graph contains cycle: ${e.join(` -> `)}`);return n}function Cd(e,t,n,r){if(Array.isArray(e)){e.forEach(e=>Cd(e,t,n,r));return}if(K(e)){`$from`in e&&typeof e.$from==`string`&&(n.has(e.$from)||r.push(`semantic: step "${t}" $from references missing step "${e.$from}"`));for(let i of Object.values(e))Cd(i,t,n,r)}}function wd(e,t,n){if(!K(e)){n.push(`step "${t}" retry must be an object`);return}let r=e.maxAttempts;r!==void 0&&(typeof r!=`number`||!Number.isInteger(r)||r<1)&&n.push(`step "${t}" retry.maxAttempts must be a positive integer`),e.backoff!==void 0&&e.backoff!==`none`&&e.backoff!==`linear`&&e.backoff!==`exponential`&&n.push(`step "${t}" retry.backoff must be none, linear, or exponential`)}function Td(e,t,n,r,i){if(Array.isArray(e)){e.forEach(e=>Td(e,t,n,r,i));return}if(K(e)){if(`$from`in e&&typeof e.$from==`string`&&typeof e.path==`string`){let a=n.get(e.$from);if(a){let n=r.getOutputSchema(a);if(n){let r=e.path;if(!n.paths.some(e=>r===e.path||r.startsWith(e.path+`/`))){let o=n.paths.map(e=>e.path).join(`, `);i.push(`hint: step "${t}" references path "${r}" from "${e.$from}" (${a}), which is not a known output path. Known paths: ${o}`)}}}return}for(let a of Object.values(e))Td(a,t,n,r,i)}}function Ed(e){let t=[],n=new Set,r=new Set,i=[],a=o=>{if(n.has(o)){let e=i.indexOf(o);t.push([...i.slice(e),o]);return}if(!r.has(o)){n.add(o),i.push(o);for(let t of e.get(o)??[])e.has(t)&&a(t);i.pop(),n.delete(o),r.add(o)}};for(let t of e.keys())a(t);return t}var Dd=M((()=>{uc(),hc(),Ou(),_d(),Ec()}));async function Od(e,t={},n={}){return await Ad(e,t,n)}async function*kd(e,t={},n={}){let r=new Hd(1024),i=new AbortController,a=()=>i.abort();n.signal?.aborted?a():n.signal?.addEventListener(`abort`,a,{once:!0});let o=!1,s;Ad(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 Ad(e,t,n){let r=n.stepDispatcher??dc(),i=vd(e,r);if(i.length>0)throw new G(`pipeline_validation_error`,`Invalid pipeline definition`,{details:{issues:i}});let a=bd(e,t);if(n.basePath){let t=await wc(e.steps,n.basePath);if(t.length>0)throw new G(`pipeline_file_not_found`,t.join(`; `),{details:{issues:t}})}let o=gc(),s=ld(e),c=pd(n.concurrency),l=[],u=new Map,d=new Map,f=[],p=async e=>{await n.onEvent?.(e)};if(await p({type:`pipeline.started`,timestamp:Z(),status:n.dryRun?`planned`:`running`,stepCount:e.steps.length,dryRun:!!n.dryRun}),n.dryRun){for(let t of ud(s)){let n=ju(t.step,e,a),r={id:t.step.id,type:t.step.type,status:`planned`,dependencies:t.dependencies,input:n.redacted,...t.step.when===void 0?{}:{condition:`pending`}};l.push(r),await p({type:`step.input.resolved`,timestamp:Z(),status:`planned`,step:Pd(t),input:Fd(n.redacted,n.sensitiveKeys)}),await p({type:`step.planned`,timestamp:Z(),status:`planned`,step:Pd(t),input:Fd(n.redacted,n.sensitiveKeys),...t.step.when===void 0?{}:{condition:`pending`}})}return await p({type:`pipeline.planned`,timestamp:Z(),status:`planned`,stepCount:l.length,artifactCount:f.length}),{status:`planned`,version:gd,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 dd(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`;Nd(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:Z(),status:`running`,step:Pd(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`;Nd(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:Z(),status:`running`,step:Pd(i),reason:e}),m.delete(i.step.id),t=!0;continue}if(!(i.step.when===void 0||Mu(i.step.when,e,a,d))){let e=`condition evaluated to false`;Nd(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e,condition:`false`}),await p({type:`step.skipped`,timestamp:Z(),status:`running`,step:Pd(i),reason:e}),m.delete(i.step.id),t=!0;continue}let _=jd(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),Nd(l,u,e),t=!0}if(!t)throw new G(`pipeline_graph_error`,`Workflow graph did not make progress`,{details:{remaining:Array.from(m)}})}let g=fd(s,l),_=g.find(e=>e.status===`failed`);if(_?.error){let e=s.find(e=>e.step.id===_.id);return await p({type:`pipeline.failed`,timestamp:Z(),status:`failed`,stepCount:g.length,artifactCount:f.length,failedStep:e?Pd(e):{id:_.id,type:_.type,dependencies:_.dependencies,index:g.findIndex(e=>e.id===_.id)+1,total:g.length},error:_.error}),{status:`failed`,version:gd,steps:g,artifacts:f}}return await p({type:`pipeline.succeeded`,timestamp:Z(),status:`succeeded`,stepCount:g.length,artifactCount:f.length}),{status:`succeeded`,version:gd,steps:g,artifacts:f}}async function jd(e,t,n,r,i,a,o,s,c){let l=Math.max(1,Math.floor(e.step.retry?.maxAttempts??1)),u,d,f=!1,p=new Date().toISOString(),m=p;for(let h=1;h<=l;h++){p=new Date().toISOString(),await a({type:`step.started`,timestamp:Z(),status:`running`,step:Pd(e),timing:{startedAt:p},attempt:h});try{let l=Au(e.step,t,n,r),u=l.value,g=l.redacted;if(o.basePath){let t=bc(u,o.basePath);u=t.input,g=bc(l.redacted,o.basePath).input;let n=await xc(u,t.resolvedKeys.filter(e=>!Tc.includes(e)),e.step.id);if(n.length>0)throw new G(`pipeline_file_not_found`,n.join(`; `),{step:e.step.type,details:{issues:n}})}d=g,f=l.sensitive,await a({type:`step.input.resolved`,timestamp:Z(),status:`running`,step:Pd(e),input:Fd(g,l.sensitiveKeys)});let _=await Md(e.step,u,o,Pd(e),a,s,c);r.set(e.step.id,_);let v=l.sensitive?Pu(_):_;v.artifacts&&i.push(...v.artifacts),m=new Date().toISOString();for(let t of v.artifacts??[])await a({type:`artifact.created`,timestamp:Z(),status:`running`,step:Pd(e),artifact:t});return await a({type:`step.succeeded`,timestamp:Z(),status:`running`,step:Pd(e),timing:Rd(p,m),output:Id(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=lc(t,e.step.type);if(u=f?Fu(n.toJSON()):n.toJSON(),m=new Date().toISOString(),h<l){await a({type:`step.retrying`,timestamp:Z(),status:`running`,step:Pd(e),attempt:h,nextAttempt:h+1,error:u});let t=zd(e.step.retry?.backoff,h,o.retryDelayBaseMs??Vd);t>0&&await(o.sleep??Bd)(t);continue}}}let h=u??{code:`pipeline_step_failed`,message:`Step ${e.step.id} failed`,step:e.step.type,details:{}};return await a({type:`step.failed`,timestamp:Z(),status:`failed`,step:Pd(e),timing:Rd(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 Md(e,t,n,r,i,a,o){let s=Sc(e.timeout)??n.timeoutSeconds,c={dryRun:!1,signal:n.signal,timeoutSeconds:s,blRequestTimeoutSeconds:n.blRequestTimeoutSeconds,emitEvent:async e=>{e.type===`step.polling`&&await i({...e,type:`step.polling`,timestamp:e.timestamp??Z(),status:`running`,step:r,taskId:e.taskId,taskStatus:e.taskStatus,elapsedMs:e.elapsedMs,pollAttempt:e.pollAttempt})},blConfig:a};if(!s)return await o.executeStep(e.type,t,c);let l=new AbortController,u=()=>l.abort();n.signal?.aborted?u():n.signal?.addEventListener(`abort`,u,{once:!0});let d=s*1e3,f=setTimeout(()=>l.abort(),d);c.signal=l.signal;try{return await Promise.race([o.executeStep(e.type,t,c),new Promise((t,n)=>{l.signal.addEventListener(`abort`,()=>{n(new G(`step_timeout`,`Step ${e.id} exceeded timeout ${s}s`,{step:e.type}))},{once:!0})})])}finally{clearTimeout(f),n.signal?.removeEventListener(`abort`,u)}}function Nd(e,t,n){e.push(n),t.set(n.id,n)}function Z(){return new Date().toISOString()}function Pd(e){return{id:e.step.id,type:e.step.type,dependencies:e.dependencies,index:e.index,total:e.total}}function Fd(e,t=[]){return{keys:Object.keys(e).sort(),...t.length>0?{redactedKeys:t.sort()}:{}}}function Id(e){return{...e.data===void 0?{}:{dataType:Ld(e.data)},artifactCount:e.artifacts?.length??0,warningCount:e.warnings?.length??0,...e.metadata?{metadata:e.metadata}:{}}}function Ld(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e}function Rd(e,t){return{startedAt:e,finishedAt:t,durationMs:Math.max(0,Date.parse(t)-Date.parse(e))}}function zd(e=`none`,t,n){return e===`none`?0:e===`linear`?n*t:n*2**(t-1)}function Bd(e){return new Promise(t=>setTimeout(t,e))}var Vd,Hd,Ud=M((()=>{uc(),vc(),hc(),Ju(),hd(),Ec(),Dd(),_d(),Vd=100,Hd=class{items=[];takers=[];pushWaiters=[];closed=!1;maxSize;constructor(e){this.maxSize=e}get size(){return this.items.length}async push(e){for(;!this.closed&&this.items.length>=this.maxSize;)await new Promise(e=>this.pushWaiters.push(e));if(this.closed)return;let t=this.takers.shift();if(t){t(e);return}this.items.push(e)}async shift(){let e=this.items.shift();if(e!==void 0)return this.wakePushWaiter(),e;if(!this.closed)return await new Promise(e=>this.takers.push(e))}close(){if(!this.closed){this.closed=!0;for(let e of this.takers.splice(0))e(void 0);for(let e of this.pushWaiters.splice(0))e()}}wakePushWaiter(){this.pushWaiters.shift()?.()}}})),Q=N((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),c=e=>!!e&&typeof e==`object`&&e[s]===t,l=e=>!!e&&typeof e==`object`&&e[s]===n,u=e=>!!e&&typeof e==`object`&&e[s]===r,d=e=>!!e&&typeof e==`object`&&e[s]===i,f=e=>!!e&&typeof e==`object`&&e[s]===a,p=e=>!!e&&typeof e==`object`&&e[s]===o;function m(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function h(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=e=>(f(e)||m(e))&&!!e.anchor,e.isAlias=c,e.isCollection=m,e.isDocument=l,e.isMap=u,e.isNode=h,e.isPair=d,e.isScalar=f,e.isSeq=p})),Wd=N((e=>{var t=Q();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function a(e,n){let r=l(n);t.isDocument(e)?o(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):o(null,e,r,Object.freeze([]))}a.BREAK=n,a.SKIP=r,a.REMOVE=i;function o(e,r,a,s){let c=u(e,r,a,s);if(t.isNode(c)||t.isPair(c))return d(e,s,c),o(e,c,a,s);if(typeof c!=`symbol`){if(t.isCollection(r)){s=Object.freeze(s.concat(r));for(let e=0;e<r.items.length;++e){let t=o(e,r.items[e],a,s);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){s=Object.freeze(s.concat(r));let e=o(`key`,r.key,a,s);if(e===n)return n;e===i&&(r.key=null);let t=o(`value`,r.value,a,s);if(t===n)return n;t===i&&(r.value=null)}}return c}async function s(e,n){let r=l(n);t.isDocument(e)?await c(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await c(null,e,r,Object.freeze([]))}s.BREAK=n,s.SKIP=r,s.REMOVE=i;async function c(e,r,a,o){let s=await u(e,r,a,o);if(t.isNode(s)||t.isPair(s))return d(e,o,s),c(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await c(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await c(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await c(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function l(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function u(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function d(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=a,e.visitAsync=s})),Gd=N((e=>{var t=Q(),n=Wd();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},i=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var a=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+i(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)t===`!!`&&n===`tag:yaml.org,2002:`||(!e||a.some(e=>e.startsWith(n)))&&r.push(`%TAG ${t} ${n}`);return r.join(`
|
|
191
|
-
`)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),Kd=N((e=>{var t=Q(),n=Wd();function r(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function i(e){let t=new Set;return n.visit(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function a(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function o(e,n){let r=[],o=new Map,s=null;return{onAnchor:t=>{r.push(t),s??=i(e);let o=a(n,s);return s.add(o),o},setAnchors:()=>{for(let e of r){let n=o.get(e);if(typeof n==`object`&&n.anchor&&(t.isScalar(n.node)||t.isCollection(n.node)))n.node.anchor=n.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:o}}e.anchorIsValid=r,e.anchorNames=i,e.createNodeAnchors=o,e.findNewAnchor=a})),qd=N((e=>{function t(e,n,r,i){if(i&&typeof i==`object`)if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let r=i[n],a=t(e,i,String(n),r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),a=t(e,i,n,r);a===void 0?i.delete(n):a!==r&&i.set(n,a)}else if(i instanceof Set)for(let n of Array.from(i)){let r=t(e,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let a=t(e,i,n,r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}return e.call(n,r,i)}e.applyReviver=t})),Jd=N((e=>{var t=Q();function n(e,r,i){if(Array.isArray(e))return e.map((e,t)=>n(e,String(t),i));if(e&&typeof e.toJSON==`function`){if(!i||!t.hasAnchor(e))return e.toJSON(r,i);let n={aliasCount:0,count:1,res:void 0};i.anchors.set(e,n),i.onCreate=e=>{n.res=e,delete i.onCreate};let a=e.toJSON(r,i);return i.onCreate&&i.onCreate(a),a}return typeof e==`bigint`&&!i?.keep?Number(e):e}e.toJS=n})),Yd=N((e=>{var t=qd(),n=Q(),r=Jd();e.NodeBase=class{constructor(e){Object.defineProperty(this,n.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:a,onAnchor:o,reviver:s}={}){if(!n.isDocument(e))throw TypeError(`A document argument is required`);let c={anchors:new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof a==`number`?a:100},l=r.toJS(this,``,c);if(typeof o==`function`)for(let{count:e,res:t}of c.anchors.values())o(t,e);return typeof s==`function`?t.applyReviver(s,{"":l},``,l):l}}})),Xd=N((e=>{var t=Kd(),n=Wd(),r=Q(),i=Yd(),a=Jd(),o=class extends i.NodeBase{constructor(e){super(r.ALIAS),this.source=e,Object.defineProperty(this,`tag`,{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){let i;t?.aliasResolveCache?i=t.aliasResolveCache:(i=[],n.visit(e,{Node:(e,t)=>{(r.isAlias(t)||r.hasAnchor(t))&&i.push(t)}}),t&&(t.aliasResolveCache=i));let a;for(let e of i){if(e===this)break;e.anchor===this.source&&(a=e)}return a}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,o=this.resolve(r,t);if(!o){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let c=n.get(o);if(c||=(a.toJS(o,null,t),n.get(o)),c?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(c.count+=1,c.aliasCount===0&&(c.aliasCount=s(r,o,n)),c.count*c.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return c.res}toString(e,n,r){let i=`*${this.source}`;if(e){if(t.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${i} `}return i}};function s(e,t,n){if(r.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(r.isCollection(t)){let r=0;for(let i of t.items){let t=s(e,i,n);t>r&&(r=t)}return r}else if(r.isPair(t)){let r=s(e,t.key,n),i=s(e,t.value,n);return Math.max(r,i)}return 1}e.Alias=o})),$=N((e=>{var t=Q(),n=Yd(),r=Jd();let i=e=>!e||typeof e!=`function`&&typeof e!=`object`;var a=class extends n.NodeBase{constructor(e){super(t.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:r.toJS(this.value,e,t)}toString(){return String(this.value)}};a.BLOCK_FOLDED=`BLOCK_FOLDED`,a.BLOCK_LITERAL=`BLOCK_LITERAL`,a.PLAIN=`PLAIN`,a.QUOTE_DOUBLE=`QUOTE_DOUBLE`,a.QUOTE_SINGLE=`QUOTE_SINGLE`,e.Scalar=a,e.isScalarValue=i})),Zd=N((e=>{var t=Xd(),n=Q(),r=$();function i(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function a(e,a,o){if(n.isDocument(e)&&(e=e.contents),n.isNode(e))return e;if(n.isPair(e)){let t=o.schema[n.MAP].createNode?.(o.schema,null,o);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:s,onAnchor:c,onTagObj:l,schema:u,sourceObjects:d}=o,f;if(s&&e&&typeof e==`object`){if(f=d.get(e),f)return f.anchor??=c(e),new t.Alias(f.anchor);f={anchor:null,node:null},d.set(e,f)}a?.startsWith(`!!`)&&(a=`tag:yaml.org,2002:`+a.slice(2));let p=i(e,a,u.tags);if(!p){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new r.Scalar(e);return f&&(f.node=t),t}p=e instanceof Map?u[n.MAP]:Symbol.iterator in Object(e)?u[n.SEQ]:u[n.MAP]}l&&(l(p),delete o.onTagObj);let m=p?.createNode?p.createNode(o.schema,e,o):typeof p?.nodeClass?.from==`function`?p.nodeClass.from(o.schema,e,o):new r.Scalar(e);return a?m.tag=a:p.default||(m.tag=p.tag),f&&(f.node=m),m}e.createNode=a})),Qd=N((e=>{var t=Zd(),n=Q(),r=Yd();function i(e,n,r){let i=r;for(let e=n.length-1;e>=0;--e){let t=n[e];if(typeof t==`number`&&Number.isInteger(t)&&t>=0){let e=[];e[t]=i,i=e}else i=new Map([[t,i]])}return t.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}let a=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;e.Collection=class extends r.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,`schema`,{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>n.isNode(t)||n.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(a(e))this.add(t);else{let[r,...a]=e,o=this.get(r,!0);if(n.isCollection(o))o.addIn(a,t);else if(o===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(n.isCollection(i))return i.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,a=this.get(r,!0);return i.length===0?!t&&n.isScalar(a)?a.value:a:n.isCollection(a)?a.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!n.isPair(t))return!1;let r=t.value;return r==null||e&&n.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let i=this.get(t,!0);return n.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...a]=e;if(a.length===0)this.set(r,t);else{let e=this.get(r,!0);if(n.isCollection(e))e.setIn(a,t);else if(e===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}},e.collectionFromPath=i,e.isEmptyPath=a})),$d=N((e=>{let t=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function n(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}e.indentComment=n,e.lineComment=(e,t,r)=>e.endsWith(`
|
|
192
|
-
`)?n(r,t):r.includes(`
|
|
193
|
-
`)?`
|
|
194
|
-
`+n(r,t):(e.endsWith(` `)?``:` `)+r,e.stringifyComment=t})),ef=N((e=>{let t=`block`,n=`quoted`;function r(e,r,a=`flow`,{indentAtStart:o,lineWidth:s=80,minContentWidth:c=20,onFold:l,onOverflow:u}={}){if(!s||s<0)return e;s<c&&(c=0);let d=Math.max(1+c,1+s-r.length);if(e.length<=d)return e;let f=[],p={},m=s-r.length;typeof o==`number`&&(o>s-Math.max(2,c)?f.push(0):m=s-o);let h,g,_=!1,v=-1,y=-1,b=-1;a===t&&(v=i(e,v,r.length),v!==-1&&(m=v+d));for(let o;o=e[v+=1];){if(a===n&&o===`\\`){switch(y=v,e[v+1]){case`x`:v+=3;break;case`u`:v+=5;break;case`U`:v+=9;break;default:v+=1}b=v}if(o===`
|
|
195
|
-
`)a===t&&(v=i(e,v,r.length)),m=v+r.length+d,h=void 0;else{if(o===` `&&g&&g!==` `&&g!==`
|
|
196
|
-
`&&g!==` `){let t=e[v+1];t&&t!==` `&&t!==`
|
|
197
|
-
`&&t!==` `&&(h=v)}if(v>=m)if(h)f.push(h),m=h+d,h=void 0;else if(a===n){for(;g===` `||g===` `;)g=o,o=e[v+=1],_=!0;let t=v>b+1?v-2:y-1;if(p[t])return e;f.push(t),p[t]=!0,m=t+d,h=void 0}else _=!0}g=o}if(_&&u&&u(),f.length===0)return e;l&&l();let x=e.slice(0,f[0]);for(let t=0;t<f.length;++t){let i=f[t],o=f[t+1]||e.length;i===0?x=`\n${r}${e.slice(0,o)}`:(a===n&&p[i]&&(x+=`${e[i]}\\`),x+=`\n${r}${e.slice(i+1,o)}`)}return x}function i(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
|
|
198
|
-
`);r=t,i=t+1,a=e[i]}return r}e.FOLD_BLOCK=t,e.FOLD_FLOW=`flow`,e.FOLD_QUOTED=n,e.foldFlowLines=r})),tf=N((e=>{var t=$(),n=ef();let r=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),i=e=>/^(%|---|\.\.\.)/m.test(e);function a(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
|
|
199
|
-
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function o(e,t){let a=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return a;let{implicitKey:o}=t,s=t.options.doubleQuotedMinMultiLineLength,c=t.indent||(i(e)?` `:``),l=``,u=0;for(let e=0,t=a[e];t;t=a[++e])if(t===` `&&a[e+1]===`\\`&&a[e+2]===`n`&&(l+=a.slice(u,e)+`\\ `,e+=1,u=e,t=`\\`),t===`\\`)switch(a[e+1]){case`u`:{l+=a.slice(u,e);let t=a.substr(e+2,4);switch(t){case`0000`:l+=`\\0`;break;case`0007`:l+=`\\a`;break;case`000b`:l+=`\\v`;break;case`001b`:l+=`\\e`;break;case`0085`:l+=`\\N`;break;case`00a0`:l+=`\\_`;break;case`2028`:l+=`\\L`;break;case`2029`:l+=`\\P`;break;default:t.substr(0,2)===`00`?l+=`\\x`+t.substr(2):l+=a.substr(e,6)}e+=5,u=e+1}break;case`n`:if(o||a[e+2]===`"`||a.length<s)e+=1;else{for(l+=a.slice(u,e)+`
|
|
200
|
-
|
|
201
|
-
`;a[e+2]===`\\`&&a[e+3]===`n`&&a[e+4]!==`"`;)l+=`
|
|
202
|
-
`,e+=2;l+=c,a[e+2]===` `&&(l+=`\\`),e+=1,u=e+1}break;default:e+=1}return l=u?l+a.slice(u):a,o?l:n.foldFlowLines(l,c,n.FOLD_QUOTED,r(t,!1))}function s(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
203
|
-
`)||/[ \t]\n|\n[ \t]/.test(e))return o(e,t);let a=t.indent||(i(e)?` `:``),s=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${a}`)+`'`;return t.implicitKey?s:n.foldFlowLines(s,a,n.FOLD_FLOW,r(t,!1))}function c(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=o;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?s:i&&!t?o:n?s:o}return r(e,t)}let l;try{l=RegExp(`(^|(?<!
|
|
204
|
-
))
|
|
205
|
-
+(?!
|
|
206
|
-
|$)`,`g`)}catch{l=/\n+(?!\n|$)/g}function u({comment:e,type:o,value:s},u,d,f){let{blockQuote:p,commentString:m,lineWidth:h}=u.options;if(!p||/\n[\t ]+$/.test(s))return c(s,u);let g=u.indent||(u.forceBlockIndent||i(s)?` `:``),_=p===`literal`?!0:p===`folded`||o===t.Scalar.BLOCK_FOLDED?!1:o===t.Scalar.BLOCK_LITERAL?!0:!a(s,h,g.length);if(!s)return _?`|
|
|
207
|
-
`:`>
|
|
208
|
-
`;let v,y;for(y=s.length;y>0;--y){let e=s[y-1];if(e!==`
|
|
209
|
-
`&&e!==` `&&e!==` `)break}let b=s.substring(y),x=b.indexOf(`
|
|
210
|
-
`);x===-1?v=`-`:s===b||x!==b.length-1?(v=`+`,f&&f()):v=``,b&&=(s=s.slice(0,-b.length),b[b.length-1]===`
|
|
211
|
-
`&&(b=b.slice(0,-1)),b.replace(l,`$&${g}`));let S=!1,C,w=-1;for(C=0;C<s.length;++C){let e=s[C];if(e===` `)S=!0;else if(e===`
|
|
212
|
-
`)w=C;else break}let T=s.substring(0,w<C?w+1:C);T&&=(s=s.substring(T.length),T.replace(/\n+/g,`$&${g}`));let E=(S?g?`2`:`1`:``)+v;if(e&&(E+=` `+m(e.replace(/ ?[\r\n]+/g,` `)),d&&d()),!_){let e=s.replace(/\n+/g,`
|
|
213
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${g}`),i=!1,a=r(u,!0);p!==`folded`&&o!==t.Scalar.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let c=n.foldFlowLines(`${T}${e}${b}`,g,n.FOLD_BLOCK,a);if(!i)return`>${E}\n${g}${c}`}return s=s.replace(/\n+/g,`$&${g}`),`|${E}\n${g}${T}${s}${b}`}function d(e,a,o,s){let{type:l,value:d}=e,{actualString:f,implicitKey:p,indent:m,indentStep:h,inFlow:g}=a;if(p&&d.includes(`
|
|
214
|
-
`)||g&&/[[\]{},]/.test(d))return c(d,a);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(d))return p||g||!d.includes(`
|
|
215
|
-
`)?c(d,a):u(e,a,o,s);if(!p&&!g&&l!==t.Scalar.PLAIN&&d.includes(`
|
|
216
|
-
`))return u(e,a,o,s);if(i(d)){if(m===``)return a.forceBlockIndent=!0,u(e,a,o,s);if(p&&m===h)return c(d,a)}let _=d.replace(/\n+/g,`$&\n${m}`);if(f){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(_),{compat:t,tags:n}=a.doc.schema;if(n.some(e)||t?.some(e))return c(d,a)}return p?_:n.foldFlowLines(_,m,n.FOLD_FLOW,r(a,!1))}function f(e,n,r,i){let{implicitKey:a,inFlow:l}=n,f=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:p}=e;p!==t.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(f.value)&&(p=t.Scalar.QUOTE_DOUBLE);let m=e=>{switch(e){case t.Scalar.BLOCK_FOLDED:case t.Scalar.BLOCK_LITERAL:return a||l?c(f.value,n):u(f,n,r,i);case t.Scalar.QUOTE_DOUBLE:return o(f.value,n);case t.Scalar.QUOTE_SINGLE:return s(f.value,n);case t.Scalar.PLAIN:return d(f,n,r,i);default:return null}},h=m(p);if(h===null){let{defaultKeyType:e,defaultStringType:t}=n.options,r=a&&e||t;if(h=m(r),h===null)throw Error(`Unsupported default string type ${r}`)}return h}e.stringifyString=f})),nf=N((e=>{var t=Kd(),n=Q(),r=$d(),i=tf();function a(e,t){let n=Object.assign({blockQuote:!0,commentString:r.stringifyComment,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),i;switch(n.collectionStyle){case`block`:i=!1;break;case`flow`:i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:i,options:n}}function o(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let r,i;if(n.isScalar(t)){i=t.value;let n=e.filter(e=>e.identify?.(i));if(n.length>1){let e=n.filter(e=>e.test);e.length>0&&(n=e)}r=n.find(e=>e.format===t.format)??n.find(e=>!e.format)}else i=t,r=e.find(e=>e.nodeClass&&i instanceof e.nodeClass);if(!r){let e=i?.constructor?.name??(i===null?`null`:typeof i);throw Error(`Tag not resolved for ${e} value`)}return r}function s(e,r,{anchors:i,doc:a}){if(!a.directives)return``;let o=[],s=(n.isScalar(e)||n.isCollection(e))&&e.anchor;s&&t.anchorIsValid(s)&&(i.add(s),o.push(`&${s}`));let c=e.tag??(r.default?null:r.tag);return c&&o.push(a.directives.tagString(c)),o.join(` `)}function c(e,t,r,a){if(n.isPair(e))return e.toString(t,r,a);if(n.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let c,l=n.isNode(e)?e:t.doc.createNode(e,{onTagObj:e=>c=e});c??=o(t.doc.schema.tags,l);let u=s(l,c,t);u.length>0&&(t.indentAtStart=(t.indentAtStart??0)+u.length+1);let d=typeof c.stringify==`function`?c.stringify(l,t,r,a):n.isScalar(l)?i.stringifyString(l,t,r,a):l.toString(t,r,a);return u?n.isScalar(l)||d[0]===`{`||d[0]===`[`?`${u} ${d}`:`${u}\n${t.indent}${d}`:d}e.createStringifyContext=a,e.stringify=c})),rf=N((e=>{var t=Q(),n=$(),r=nf(),i=$d();function a({key:e,value:a},o,s,c){let{allNullValues:l,doc:u,indent:d,indentStep:f,options:{commentString:p,indentSeq:m,simpleKeys:h}}=o,g=t.isNode(e)&&e.comment||null;if(h){if(g)throw Error(`With simple keys, key nodes cannot have comments`);if(t.isCollection(e)||!t.isNode(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let _=!h&&(!e||g&&a==null&&!o.inFlow||t.isCollection(e)||(t.isScalar(e)?e.type===n.Scalar.BLOCK_FOLDED||e.type===n.Scalar.BLOCK_LITERAL:typeof e==`object`));o=Object.assign({},o,{allNullValues:!1,implicitKey:!_&&(h||!l),indent:d+f});let v=!1,y=!1,b=r.stringify(e,o,()=>v=!0,()=>y=!0);if(!_&&!o.inFlow&&b.length>1024){if(h)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);_=!0}if(o.inFlow){if(l||a==null)return v&&s&&s(),b===``?`?`:_?`? ${b}`:b}else if(l&&!h||a==null&&_)return b=`? ${b}`,g&&!v?b+=i.lineComment(b,o.indent,p(g)):y&&c&&c(),b;v&&(g=null),_?(g&&(b+=i.lineComment(b,o.indent,p(g))),b=`? ${b}\n${d}:`):(b=`${b}:`,g&&(b+=i.lineComment(b,o.indent,p(g))));let x,S,C;t.isNode(a)?(x=!!a.spaceBefore,S=a.commentBefore,C=a.comment):(x=!1,S=null,C=null,a&&typeof a==`object`&&(a=u.createNode(a))),o.implicitKey=!1,!_&&!g&&t.isScalar(a)&&(o.indentAtStart=b.length+1),y=!1,!m&&f.length>=2&&!o.inFlow&&!_&&t.isSeq(a)&&!a.flow&&!a.tag&&!a.anchor&&(o.indent=o.indent.substring(2));let w=!1,T=r.stringify(a,o,()=>w=!0,()=>y=!0),E=` `;if(g||x||S){if(E=x?`
|
|
217
|
-
`:``,S){let e=p(S);E+=`\n${i.indentComment(e,o.indent)}`}T===``&&!o.inFlow?E===`
|
|
218
|
-
`&&C&&(E=`
|
|
219
|
-
|
|
220
|
-
`):E+=`\n${o.indent}`}else if(!_&&t.isCollection(a)){let e=T[0],t=T.indexOf(`
|
|
221
|
-
`),n=t!==-1,r=o.inFlow??a.flow??a.items.length===0;if(n||!r){let r=!1;if(n&&(e===`&`||e===`!`)){let n=T.indexOf(` `);e===`&`&&n!==-1&&n<t&&T[n+1]===`!`&&(n=T.indexOf(` `,n+1)),(n===-1||t<n)&&(r=!0)}r||(E=`\n${o.indent}`)}}else (T===``||T[0]===`
|
|
222
|
-
`)&&(E=``);return b+=E+T,o.inFlow?w&&s&&s():C&&!w?b+=i.lineComment(b,o.indent,p(C)):y&&c&&c(),b}e.stringifyPair=a})),af=N((e=>{var t=gt(`process`);function n(e,...t){e===`debug`&&console.log(...t)}function r(e,n){(e===`debug`||e===`warn`)&&(typeof t.emitWarning==`function`?t.emitWarning(n):console.warn(n))}e.debug=n,e.warn=r})),of=N((e=>{var t=Q(),n=$();let r={identify:e=>e===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new n.Scalar(Symbol(`<<`)),{addToJSMap:a}),stringify:()=>`<<`},i=(e,i)=>(r.identify(i)||t.isScalar(i)&&(!i.type||i.type===n.Scalar.PLAIN)&&r.identify(i.value))&&e?.doc.schema.tags.some(e=>e.tag===r.tag&&e.default);function a(e,n,r){if(r=e&&t.isAlias(r)?r.resolve(e.doc):r,t.isSeq(r))for(let t of r.items)o(e,n,t);else if(Array.isArray(r))for(let t of r)o(e,n,t);else o(e,n,r)}function o(e,n,r){let i=e&&t.isAlias(r)?r.resolve(e.doc):r;if(!t.isMap(i))throw Error(`Merge sources must be maps or map aliases`);let a=i.toJSON(null,e,Map);for(let[e,t]of a)n instanceof Map?n.has(e)||n.set(e,t):n instanceof Set?n.add(e):Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0});return n}e.addMergeToJSMap=a,e.isMergeKey=i,e.merge=r})),sf=N((e=>{var t=af(),n=of(),r=nf(),i=Q(),a=Jd();function o(e,t,{key:r,value:o}){if(i.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,o);else if(n.isMergeKey(e,r))n.addMergeToJSMap(e,t,o);else{let n=a.toJS(r,``,e);if(t instanceof Map)t.set(n,a.toJS(o,n,e));else if(t instanceof Set)t.add(n);else{let i=s(r,n,e),c=a.toJS(o,i,e);i in t?Object.defineProperty(t,i,{value:c,writable:!0,enumerable:!0,configurable:!0}):t[i]=c}}return t}function s(e,n,a){if(n===null)return``;if(typeof n!=`object`)return String(n);if(i.isNode(e)&&a?.doc){let n=r.createStringifyContext(a.doc,{});n.anchors=new Set;for(let e of a.anchors.keys())n.anchors.add(e.anchor);n.inFlow=!0,n.inStringifyKey=!0;let i=e.toString(n);if(!a.mapKeyWarned){let e=JSON.stringify(i);e.length>40&&(e=e.substring(0,36)+`..."`),t.warn(a.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),a.mapKeyWarned=!0}return i}return JSON.stringify(n)}e.addPairToJSMap=o})),cf=N((e=>{var t=Zd(),n=rf(),r=sf(),i=Q();function a(e,n,r){return new o(t.createNode(e,void 0,r),t.createNode(n,void 0,r))}var o=class e{constructor(e,t=null){Object.defineProperty(this,i.NODE_TYPE,{value:i.PAIR}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return i.isNode(n)&&(n=n.clone(t)),i.isNode(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){let n=t?.mapAsMap?new Map:{};return r.addPairToJSMap(t,n,this)}toString(e,t,r){return e?.doc?n.stringifyPair(this,e,t,r):JSON.stringify(this)}};e.Pair=o,e.createPair=a})),lf=N((e=>{var t=Q(),n=nf(),r=$d();function i(e,t,n){return(t.inFlow??e.flow?o:a)(e,t,n)}function a({comment:e,items:i},a,{blockItemPrefix:o,flowChars:c,itemIndent:l,onChompKeep:u,onComment:d}){let{indent:f,options:{commentString:p}}=a,m=Object.assign({},a,{indent:l,type:null}),h=!1,g=[];for(let e=0;e<i.length;++e){let c=i[e],u=null;if(t.isNode(c))!h&&c.spaceBefore&&g.push(``),s(a,g,c.commentBefore,h),c.comment&&(u=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(!h&&e.spaceBefore&&g.push(``),s(a,g,e.commentBefore,h))}h=!1;let d=n.stringify(c,m,()=>u=null,()=>h=!0);u&&(d+=r.lineComment(d,l,p(u))),h&&u&&(h=!1),g.push(o+d)}let _;if(g.length===0)_=c.start+c.end;else{_=g[0];for(let e=1;e<g.length;++e){let t=g[e];_+=t?`\n${f}${t}`:`
|
|
223
|
-
`}}return e?(_+=`
|
|
224
|
-
`+r.indentComment(p(e),f),d&&d()):h&&u&&u(),_}function o({items:e},i,{flowChars:a,itemIndent:o}){let{indent:c,indentStep:l,flowCollectionPadding:u,options:{commentString:d}}=i;o+=l;let f=Object.assign({},i,{indent:o,inFlow:!0,type:null}),p=!1,m=0,h=[];for(let a=0;a<e.length;++a){let c=e[a],l=null;if(t.isNode(c))c.spaceBefore&&h.push(``),s(i,h,c.commentBefore,!1),c.comment&&(l=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(e.spaceBefore&&h.push(``),s(i,h,e.commentBefore,!1),e.comment&&(p=!0));let n=t.isNode(c.value)?c.value:null;n?(n.comment&&(l=n.comment),n.commentBefore&&(p=!0)):c.value==null&&e?.comment&&(l=e.comment)}l&&(p=!0);let u=n.stringify(c,f,()=>l=null);p||=h.length>m||u.includes(`
|
|
225
|
-
`),a<e.length-1?u+=`,`:i.options.trailingComma&&(i.options.lineWidth>0&&(p||=h.reduce((e,t)=>e+t.length+2,2)+(u.length+2)>i.options.lineWidth),p&&(u+=`,`)),l&&(u+=r.lineComment(u,o,d(l))),h.push(u),m=h.length}let{start:g,end:_}=a;if(h.length===0)return g+_;if(!p){let e=h.reduce((e,t)=>e+t.length+2,2);p=i.options.lineWidth>0&&e>i.options.lineWidth}if(p){let e=g;for(let t of h)e+=t?`\n${l}${c}${t}`:`
|
|
226
|
-
`;return`${e}\n${c}${_}`}else return`${g}${u}${h.join(` `)}${u}${_}`}function s({indent:e,options:{commentString:t}},n,i,a){if(i&&a&&(i=i.replace(/^\n+/,``)),i){let a=r.indentComment(t(i),e);n.push(a.trimStart())}}e.stringifyCollection=i})),uf=N((e=>{var t=lf(),n=sf(),r=Qd(),i=Q(),a=cf(),o=$();function s(e,t){let n=i.isScalar(t)?t.value:t;for(let r of e)if(i.isPair(r)&&(r.key===t||r.key===n||i.isScalar(r.key)&&r.key.value===n))return r}e.YAMLMap=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(i.MAP,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,o=new this(e),s=(e,s)=>{if(typeof i==`function`)s=i.call(t,e,s);else if(Array.isArray(i)&&!i.includes(e))return;(s!==void 0||r)&&o.items.push(a.createPair(e,s,n))};if(t instanceof Map)for(let[e,n]of t)s(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))s(e,t[e]);return typeof e.sortMapEntries==`function`&&o.items.sort(e.sortMapEntries),o}add(e,t){let n;n=i.isPair(e)?e:!e||typeof e!=`object`||!(`key`in e)?new a.Pair(e,e?.value):new a.Pair(e.key,e.value);let r=s(this.items,n.key),c=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);i.isScalar(r.value)&&o.isScalarValue(n.value)?r.value.value=n.value:r.value=n.value}else if(c){let e=this.items.findIndex(e=>c(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=s(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=s(this.items,e)?.value;return(!t&&i.isScalar(n)?n.value:n)??void 0}has(e){return!!s(this.items,e)}set(e,t){this.add(new a.Pair(e,t),!0)}toJSON(e,t,r){let i=r?new r:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(i);for(let e of this.items)n.addPairToJSMap(t,i,e);return i}toString(e,n,r){if(!e)return JSON.stringify(this);for(let e of this.items)if(!i.isPair(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),t.stringifyCollection(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:r,onComment:n})}},e.findPair=s})),df=N((e=>{var t=Q(),n=uf();e.map={collection:`map`,default:!0,nodeClass:n.YAMLMap,tag:`tag:yaml.org,2002:map`,resolve(e,n){return t.isMap(e)||n(`Expected a mapping for this tag`),e},createNode:(e,t,r)=>n.YAMLMap.from(e,t,r)}})),ff=N((e=>{var t=Zd(),n=lf(),r=Qd(),i=Q(),a=$(),o=Jd(),s=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(i.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=c(e);return typeof t==`number`?this.items.splice(t,1).length>0:!1}get(e,t){let n=c(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&i.isScalar(r)?r.value:r}has(e){let t=c(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=c(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];i.isScalar(r)&&a.isScalarValue(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(o.toJS(e,String(r++),t));return n}toString(e,t,r){return e?n.stringifyCollection(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,n,r){let{replacer:i}=r,a=new this(e);if(n&&Symbol.iterator in Object(n)){let e=0;for(let o of n){if(typeof i==`function`){let t=n instanceof Set?o:String(e++);o=i.call(n,t,o)}a.items.push(t.createNode(o,void 0,r))}}return a}};function c(e){let t=i.isScalar(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}e.YAMLSeq=s})),pf=N((e=>{var t=Q(),n=ff();e.seq={collection:`seq`,default:!0,nodeClass:n.YAMLSeq,tag:`tag:yaml.org,2002:seq`,resolve(e,n){return t.isSeq(e)||n(`Expected a sequence for this tag`),e},createNode:(e,t,r)=>n.YAMLSeq.from(e,t,r)}})),mf=N((e=>{var t=tf();e.string={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,n,r,i){return n=Object.assign({actualString:!0},n),t.stringifyString(e,n,r,i)}}})),hf=N((e=>{var t=$();let n={identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new t.Scalar(null),stringify:({source:e},t)=>typeof e==`string`&&n.test.test(e)?e:t.options.nullStr};e.nullTag=n})),gf=N((e=>{var t=$();let n={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new t.Scalar(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},r){return e&&n.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?r.options.trueStr:r.options.falseStr}};e.boolTag=n})),_f=N((e=>{function t({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^\d/.test(a)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-- >0;)a+=`0`}return a}e.stringifyNumber=t})),vf=N((e=>{var t=$(),n=_f();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let n=new t.Scalar(parseFloat(e)),r=e.indexOf(`.`);return r!==-1&&e[e.length-1]===`0`&&(n.minFractionDigits=e.length-r-1),n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),yf=N((e=>{var t=_f();let n=e=>typeof e==`bigint`||Number.isInteger(e),r=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function i(e,r,i){let{value:a}=e;return n(a)&&a>=0?i+a.toString(r):t.stringifyNumber(e)}e.int={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},e.intHex={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)},e.intOct={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>r(e,2,8,n),stringify:e=>i(e,8,`0o`)}})),bf=N((e=>{var t=df(),n=hf(),r=pf(),i=mf(),a=gf(),o=vf(),s=yf();e.schema=[t.map,r.seq,i.string,n.nullTag,a.boolTag,s.intOct,s.int,s.intHex,o.floatNaN,o.floatExp,o.float]})),xf=N((e=>{var t=$(),n=df(),r=pf();function i(e){return typeof e==`bigint`||Number.isInteger(e)}let a=({value:e})=>JSON.stringify(e),o=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:a},{identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:a},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:a},{identify:i,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>i(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:a}];e.schema=[n.map,r.seq].concat(o,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}})})),Sf=N((e=>{var t=gt(`buffer`),n=$(),r=tf();e.binary={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,n){if(typeof t.Buffer==`function`)return t.Buffer.from(e,`base64`);if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}else return n(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:i,value:a},o,s,c){if(!a)return``;let l=a,u;if(typeof t.Buffer==`function`)u=l instanceof t.Buffer?l.toString(`base64`):t.Buffer.from(l.buffer).toString(`base64`);else if(typeof btoa==`function`){let e=``;for(let t=0;t<l.length;++t)e+=String.fromCharCode(l[t]);u=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(i??=n.Scalar.BLOCK_LITERAL,i!==n.Scalar.QUOTE_DOUBLE){let e=Math.max(o.options.lineWidth-o.indent.length,o.options.minContentWidth),t=Math.ceil(u.length/e),r=Array(t);for(let n=0,i=0;n<t;++n,i+=e)r[n]=u.substr(i,e);u=r.join(i===n.Scalar.BLOCK_LITERAL?`
|
|
227
|
-
`:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),Cf=N((e=>{var t=Q(),n=cf(),r=$(),i=ff();function a(e,i){if(t.isSeq(e))for(let a=0;a<e.items.length;++a){let o=e.items[a];if(!t.isPair(o)){if(t.isMap(o)){o.items.length>1&&i(`Each pair must have its own sequence indicator`);let e=o.items[0]||new n.Pair(new r.Scalar(null));if(o.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${o.commentBefore}\n${e.key.commentBefore}`:o.commentBefore),o.comment){let t=e.value??e.key;t.comment=t.comment?`${o.comment}\n${t.comment}`:o.comment}o=e}e.items[a]=t.isPair(o)?o:new n.Pair(o)}}else i(`Expected a sequence for this tag`);return e}function o(e,t,r){let{replacer:a}=r,o=new i.YAMLSeq(e);o.tag=`tag:yaml.org,2002:pairs`;let s=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof a==`function`&&(e=a.call(t,String(s++),e));let i,c;if(Array.isArray(e))if(e.length===2)i=e[0],c=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`);else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)i=t[0],c=e[i];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else i=e;o.items.push(n.createPair(i,c,r))}return o}let s={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:a,createNode:o};e.createPairs=o,e.pairs=s,e.resolvePairs=a})),wf=N((e=>{var t=Q(),n=Jd(),r=uf(),i=ff(),a=Cf(),o=class e extends i.YAMLSeq{constructor(){super(),this.add=r.YAMLMap.prototype.add.bind(this),this.delete=r.YAMLMap.prototype.delete.bind(this),this.get=r.YAMLMap.prototype.get.bind(this),this.has=r.YAMLMap.prototype.has.bind(this),this.set=r.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=new Map;r?.onCreate&&r.onCreate(i);for(let e of this.items){let a,o;if(t.isPair(e)?(a=n.toJS(e.key,``,r),o=n.toJS(e.value,a,r)):a=n.toJS(e,``,r),i.has(a))throw Error(`Ordered maps must not include duplicate keys`);i.set(a,o)}return i}static from(e,t,n){let r=a.createPairs(e,t,n),i=new this;return i.items=r.items,i}};o.tag=`tag:yaml.org,2002:omap`;let s={collection:`seq`,identify:e=>e instanceof Map,nodeClass:o,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,n){let r=a.resolvePairs(e,n),i=[];for(let{key:e}of r.items)t.isScalar(e)&&(i.includes(e.value)?n(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new o,r)},createNode:(e,t,n)=>o.from(e,t,n)};e.YAMLOMap=o,e.omap=s})),Tf=N((e=>{var t=$();function n({value:e,source:t},n){return t&&(e?r:i).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}let r={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new t.Scalar(!0),stringify:n},i={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new t.Scalar(!1),stringify:n};e.falseTag=i,e.trueTag=r})),Ef=N((e=>{var t=$(),n=_f();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let n=new t.Scalar(parseFloat(e.replace(/_/g,``))),r=e.indexOf(`.`);if(r!==-1){let t=e.substring(r+1).replace(/_/g,``);t[t.length-1]===`0`&&(n.minFractionDigits=t.length)}return n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),Df=N((e=>{var t=_f();let n=e=>typeof e==`bigint`||Number.isInteger(e);function r(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function i(e,r,i){let{value:a}=e;if(n(a)){let e=a.toString(r);return a<0?`-`+i+e.substr(1):i+e}return t.stringifyNumber(e)}let a={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>r(e,2,2,n),stringify:e=>i(e,2,`0b`)},o={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>r(e,1,8,n),stringify:e=>i(e,8,`0`)},s={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},c={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)};e.int=s,e.intBin=a,e.intHex=c,e.intOct=o})),Of=N((e=>{var t=Q(),n=cf(),r=uf(),i=class e extends r.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(e){let i;i=t.isPair(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new n.Pair(e.key,null):new n.Pair(e,null),r.findPair(this.items,i.key)||this.items.push(i)}get(e,n){let i=r.findPair(this.items,e);return!n&&t.isPair(i)?t.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=r.findPair(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new n.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,r){let{replacer:i}=r,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof i==`function`&&(e=i.call(t,e,e)),a.items.push(n.createPair(e,null,r));return a}};i.tag=`tag:yaml.org,2002:set`;let a={collection:`map`,identify:e=>e instanceof Set,nodeClass:i,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>i.from(e,t,n),resolve(e,n){if(t.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new i,e);n(`Set items must all have null values`)}else n(`Expected a mapping for this tag`);return e}};e.YAMLSet=i,e.set=a})),kf=N((e=>{var t=_f();function n(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function r(e){let{value:n}=e,r=e=>e;if(typeof n==`bigint`)r=e=>BigInt(e);else if(isNaN(n)||!isFinite(n))return t.stringifyNumber(e);let i=``;n<0&&(i=`-`,n*=r(-1));let a=r(60),o=[n%a];return n<60?o.unshift(0):(n=(n-o[0])/a,o.unshift(n%a),n>=60&&(n=(n-o[0])/a,o.unshift(n))),i+o.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}let i={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>n(e,r),stringify:r},a={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>n(e,!1),stringify:r},o={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(o.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,r,i,a,s,c,l]=t.map(Number),u=t[7]?Number((t[7]+`00`).substr(1,3)):0,d=Date.UTC(r,i-1,a,s||0,c||0,l||0,u),f=t[8];if(f&&f!==`Z`){let e=n(f,!1);Math.abs(e)<30&&(e*=60),d-=6e4*e}return new Date(d)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``};e.floatTime=a,e.intTime=i,e.timestamp=o})),Af=N((e=>{var t=df(),n=hf(),r=pf(),i=mf(),a=Sf(),o=Tf(),s=Ef(),c=Df(),l=of(),u=wf(),d=Cf(),f=Of(),p=kf();e.schema=[t.map,r.seq,i.string,n.nullTag,o.trueTag,o.falseTag,c.intBin,c.intOct,c.int,c.intHex,s.floatNaN,s.floatExp,s.float,a.binary,l.merge,u.omap,d.pairs,f.set,p.intTime,p.floatTime,p.timestamp]})),jf=N((e=>{var t=df(),n=hf(),r=pf(),i=mf(),a=gf(),o=vf(),s=yf(),c=bf(),l=xf(),u=Sf(),d=of(),f=wf(),p=Cf(),m=Af(),h=Of(),g=kf();let _=new Map([[`core`,c.schema],[`failsafe`,[t.map,r.seq,i.string]],[`json`,l.schema],[`yaml11`,m.schema],[`yaml-1.1`,m.schema]]),v={binary:u.binary,bool:a.boolTag,float:o.float,floatExp:o.floatExp,floatNaN:o.floatNaN,floatTime:g.floatTime,int:s.int,intHex:s.intHex,intOct:s.intOct,intTime:g.intTime,map:t.map,merge:d.merge,null:n.nullTag,omap:f.omap,pairs:p.pairs,seq:r.seq,set:h.set,timestamp:g.timestamp},y={"tag:yaml.org,2002:binary":u.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":f.omap,"tag:yaml.org,2002:pairs":p.pairs,"tag:yaml.org,2002:set":h.set,"tag:yaml.org,2002:timestamp":g.timestamp};function b(e,t,n){let r=_.get(t);if(r&&!e)return n&&!r.includes(d.merge)?r.concat(d.merge):r.slice();let i=r;if(!i)if(Array.isArray(e))i=[];else{let e=Array.from(_.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(d.merge)),i.reduce((e,t)=>{let n=typeof t==`string`?v[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(v).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}e.coreKnownTags=y,e.getTags=b})),Mf=N((e=>{var t=Q(),n=df(),r=pf(),i=mf(),a=jf();let o=(e,t)=>e.key<t.key?-1:+(e.key>t.key);e.Schema=class e{constructor({compat:e,customTags:s,merge:c,resolveKnownTags:l,schema:u,sortMapEntries:d,toStringDefaults:f}){this.compat=Array.isArray(e)?a.getTags(e,`compat`):e?a.getTags(null,e):null,this.name=typeof u==`string`&&u||`core`,this.knownTags=l?a.coreKnownTags:{},this.tags=a.getTags(s,this.name,c),this.toStringOptions=f??null,Object.defineProperty(this,t.MAP,{value:n.map}),Object.defineProperty(this,t.SCALAR,{value:i.string}),Object.defineProperty(this,t.SEQ,{value:r.seq}),this.sortMapEntries=typeof d==`function`?d:d===!0?o:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}}})),Nf=N((e=>{var t=Q(),n=nf(),r=$d();function i(e,i){let a=[],o=i.directives===!0;if(i.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(a.push(t),o=!0):e.directives.docStart&&(o=!0)}o&&a.push(`---`);let s=n.createStringifyContext(e,i),{commentString:c}=s.options;if(e.commentBefore){a.length!==1&&a.unshift(``);let t=c(e.commentBefore);a.unshift(r.indentComment(t,``))}let l=!1,u=null;if(e.contents){if(t.isNode(e.contents)){if(e.contents.spaceBefore&&o&&a.push(``),e.contents.commentBefore){let t=c(e.contents.commentBefore);a.push(r.indentComment(t,``))}s.forceBlockIndent=!!e.comment,u=e.contents.comment}let i=u?void 0:()=>l=!0,d=n.stringify(e.contents,s,()=>u=null,i);u&&(d+=r.lineComment(d,``,c(u))),(d[0]===`|`||d[0]===`>`)&&a[a.length-1]===`---`?a[a.length-1]=`--- ${d}`:a.push(d)}else a.push(n.stringify(e.contents,s));if(e.directives?.docEnd)if(e.comment){let t=c(e.comment);t.includes(`
|
|
228
|
-
`)?(a.push(`...`),a.push(r.indentComment(t,``))):a.push(`... ${t}`)}else a.push(`...`);else{let t=e.comment;t&&l&&(t=t.replace(/^\n+/,``)),t&&((!l||u)&&a[a.length-1]!==``&&a.push(``),a.push(r.indentComment(c(t),``)))}return a.join(`
|
|
229
|
-
`)+`
|
|
230
|
-
`}e.stringifyDocument=i})),Pf=N((e=>{var t=Xd(),n=Qd(),r=Q(),i=cf(),a=Jd(),o=Mf(),s=Nf(),c=Kd(),l=qd(),u=Zd(),d=Gd(),f=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,r.NODE_TYPE,{value:r.DOC});let i=null;typeof t==`function`||Array.isArray(t)?i=t:n===void 0&&t&&(n=t,t=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=a;let{version:o}=a;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new d.Directives({version:o}),this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,i,n)}clone(){let t=Object.create(e.prototype,{[r.NODE_TYPE]:{value:r.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=r.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){p(this.contents)&&this.contents.add(e)}addIn(e,t){p(this.contents)&&this.contents.addIn(e,t)}createAlias(e,n){if(!e.anchor){let t=c.anchorNames(this);e.anchor=!n||t.has(n)?c.findNewAnchor(n||`a`,t):n}return new t.Alias(e.anchor)}createNode(e,t,n){let i;if(typeof t==`function`)e=t.call({"":e},``,e),i=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),i=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:l,onTagObj:d,tag:f}=n??{},{onAnchor:p,setAnchors:m,sourceObjects:h}=c.createNodeAnchors(this,o||`a`),g={aliasDuplicateObjects:a??!0,keepUndefined:l??!1,onAnchor:p,onTagObj:d,replacer:i,schema:this.schema,sourceObjects:h},_=u.createNode(e,f,g);return s&&r.isCollection(_)&&(_.flow=!0),m(),_}createPair(e,t,n={}){let r=this.createNode(e,null,n),a=this.createNode(t,null,n);return new i.Pair(r,a)}delete(e){return p(this.contents)?this.contents.delete(e):!1}deleteIn(e){return n.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):p(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return r.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return n.isEmptyPath(e)?!t&&r.isScalar(this.contents)?this.contents.value:this.contents:r.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return r.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return n.isEmptyPath(e)?this.contents!==void 0:r.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=n.collectionFromPath(this.schema,[e],t):p(this.contents)&&this.contents.set(e,t)}setIn(e,t){n.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=n.collectionFromPath(this.schema,Array.from(e),t):p(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new d.Directives({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new d.Directives({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new o.Schema(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},c=a.toJS(this.contents,t??``,s);if(typeof i==`function`)for(let{count:e,res:t}of s.anchors.values())i(t,e);return typeof o==`function`?l.applyReviver(o,{"":c},``,c):c}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return s.stringifyDocument(this,e)}};function p(e){if(r.isCollection(e))return!0;throw Error(`Expected a YAML collection as document contents`)}e.Document=f})),Ff=N((e=>{var t=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},n=class extends t{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},r=class extends t{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}};e.YAMLError=t,e.YAMLParseError=n,e.YAMLWarning=r,e.prettifyError=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`โฆ`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`โฆ`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`โฆ
|
|
231
|
-
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}}})),If=N((e=>{function t(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}e.resolveProps=t})),Lf=N((e=>{function t(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
|
|
232
|
-
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let n of e.items){for(let e of n.start)if(e.type===`newline`)return!0;if(n.sep){for(let e of n.sep)if(e.type===`newline`)return!0}if(t(n.key)||t(n.value))return!0}return!1;default:return!0}}e.containsNewline=t})),Rf=N((e=>{var t=Lf();function n(e,n,r){if(n?.type===`flow-collection`){let i=n.end[0];i.indent===e&&(i.source===`]`||i.source===`}`)&&t.containsNewline(n)&&r(i,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}e.flowIndentCheck=n})),zf=N((e=>{var t=Q();function n(e,n,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let a=typeof i==`function`?i:(e,n)=>e===n||t.isScalar(e)&&t.isScalar(n)&&e.value===n.value;return n.some(e=>a(e.key,r))}e.mapIncludes=n})),Bf=N((e=>{var t=cf(),n=uf(),r=If(),i=Lf(),a=Rf(),o=zf();let s=`All mapping items must start at the same column`;function c({composeNode:e,composeEmptyNode:c},l,u,d,f){let p=new(f?.nodeClass??n.YAMLMap)(l.schema);l.atRoot&&=!1;let m=u.offset,h=null;for(let n of u.items){let{start:f,key:g,sep:_,value:v}=n,y=r.resolveProps(f,{indicator:`explicit-key-ind`,next:g??_?.[0],offset:m,onError:d,parentIndent:u.indent,startOnNewline:!0}),b=!y.found;if(b){if(g&&(g.type===`block-seq`?d(m,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in g&&g.indent!==u.indent&&d(m,`BAD_INDENT`,s)),!y.anchor&&!y.tag&&!_){h=y.end,y.comment&&(p.comment?p.comment+=`
|
|
233
|
-
`+y.comment:p.comment=y.comment);continue}(y.newlineAfterProp||i.containsNewline(g))&&d(g??f[f.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else y.found?.indent!==u.indent&&d(m,`BAD_INDENT`,s);l.atKey=!0;let x=y.end,S=g?e(l,g,y,d):c(l,x,f,null,y,d);l.schema.compat&&a.flowIndentCheck(u.indent,g,d),l.atKey=!1,o.mapIncludes(l,p.items,S)&&d(x,`DUPLICATE_KEY`,`Map keys must be unique`);let C=r.resolveProps(_??[],{indicator:`map-value-ind`,next:v,offset:S.range[2],onError:d,parentIndent:u.indent,startOnNewline:!g||g.type===`block-scalar`});if(m=C.end,C.found){b&&(v?.type===`block-map`&&!C.hasNewline&&d(m,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),l.options.strict&&y.start<C.found.offset-1024&&d(S.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let r=v?e(l,v,C,d):c(l,m,_,null,C,d);l.schema.compat&&a.flowIndentCheck(u.indent,v,d),m=r.range[2];let i=new t.Pair(S,r);l.options.keepSourceTokens&&(i.srcToken=n),p.items.push(i)}else{b&&d(S.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),C.comment&&(S.comment?S.comment+=`
|
|
234
|
-
`+C.comment:S.comment=C.comment);let e=new t.Pair(S);l.options.keepSourceTokens&&(e.srcToken=n),p.items.push(e)}}return h&&h<m&&d(h,`IMPOSSIBLE`,`Map comment with trailing content`),p.range=[u.offset,m,h??m],p}e.resolveBlockMap=c})),Vf=N((e=>{var t=ff(),n=If(),r=Rf();function i({composeNode:e,composeEmptyNode:i},a,o,s,c){let l=new(c?.nodeClass??t.YAMLSeq)(a.schema);a.atRoot&&=!1,a.atKey&&=!1;let u=o.offset,d=null;for(let{start:t,value:c}of o.items){let f=n.resolveProps(t,{indicator:`seq-item-ind`,next:c,offset:u,onError:s,parentIndent:o.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||c)c?.type===`block-seq`?s(f.end,`BAD_INDENT`,`All sequence items must start at the same column`):s(u,`MISSING_CHAR`,`Sequence item without - indicator`);else{d=f.end,f.comment&&(l.comment=f.comment);continue}let p=c?e(a,c,f,s):i(a,f.end,t,null,f,s);a.schema.compat&&r.flowIndentCheck(o.indent,c,s),u=p.range[2],l.items.push(p)}return l.range=[o.offset,u,d??u],l}e.resolveBlockSeq=i})),Hf=N((e=>{function t(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}e.resolveEnd=t})),Uf=N((e=>{var t=Q(),n=cf(),r=uf(),i=ff(),a=Hf(),o=If(),s=Lf(),c=zf();let l=`Block collections are not allowed within flow collections`,u=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function d({composeNode:e,composeEmptyNode:d},f,p,m,h){let g=p.start.source===`{`,_=g?`flow map`:`flow sequence`,v=new(h?.nodeClass??(g?r.YAMLMap:i.YAMLSeq))(f.schema);v.flow=!0;let y=f.atRoot;y&&(f.atRoot=!1),f.atKey&&=!1;let b=p.offset+p.start.source.length;for(let i=0;i<p.items.length;++i){let a=p.items[i],{start:h,key:y,sep:x,value:S}=a,C=o.resolveProps(h,{flow:_,indicator:`explicit-key-ind`,next:y??x?.[0],offset:b,onError:m,parentIndent:p.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!x&&!S){i===0&&C.comma?m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`):i<p.items.length-1&&m(C.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${_}`),C.comment&&(v.comment?v.comment+=`
|
|
235
|
-
`+C.comment:v.comment=C.comment),b=C.end;continue}!g&&f.options.strict&&s.containsNewline(y)&&m(y,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(i===0)C.comma&&m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`);else if(C.comma||m(C.start,`MISSING_CHAR`,`Missing , between ${_} items`),C.comment){let e=``;loop:for(let t of h)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let n=v.items[v.items.length-1];t.isPair(n)&&(n=n.value??n.key),n.comment?n.comment+=`
|
|
236
|
-
`+e:n.comment=e,C.comment=C.comment.substring(e.length+1)}}if(!g&&!x&&!C.found){let t=S?e(f,S,C,m):d(f,C.end,x,null,C,m);v.items.push(t),b=t.range[2],u(S)&&m(t.range,`BLOCK_IN_FLOW`,l)}else{f.atKey=!0;let t=C.end,i=y?e(f,y,C,m):d(f,t,h,null,C,m);u(y)&&m(i.range,`BLOCK_IN_FLOW`,l),f.atKey=!1;let s=o.resolveProps(x??[],{flow:_,indicator:`map-value-ind`,next:S,offset:i.range[2],onError:m,parentIndent:p.indent,startOnNewline:!1});if(s.found){if(!g&&!C.found&&f.options.strict){if(x)for(let e of x){if(e===s.found)break;if(e.type===`newline`){m(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}C.start<s.found.offset-1024&&m(s.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else S&&(`source`in S&&S.source?.[0]===`:`?m(S,`MISSING_CHAR`,`Missing space after : in ${_}`):m(s.start,`MISSING_CHAR`,`Missing , or : between ${_} items`));let w=S?e(f,S,s,m):s.found?d(f,s.end,x,null,s,m):null;w?u(S)&&m(w.range,`BLOCK_IN_FLOW`,l):s.comment&&(i.comment?i.comment+=`
|
|
237
|
-
`+s.comment:i.comment=s.comment);let T=new n.Pair(i,w);if(f.options.keepSourceTokens&&(T.srcToken=a),g){let e=v;c.mapIncludes(f,e.items,i)&&m(t,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(T)}else{let e=new r.YAMLMap(f.schema);e.flow=!0,e.items.push(T);let t=(w??i).range;e.range=[i.range[0],t[1],t[2]],v.items.push(e)}b=w?w.range[2]:s.end}}let x=g?`}`:`]`,[S,...C]=p.end,w=b;if(S?.source===x)w=S.offset+S.source.length;else{let e=_[0].toUpperCase()+_.substring(1),t=y?`${e} must end with a ${x}`:`${e} in block collection must be sufficiently indented and end with a ${x}`;m(b,y?`MISSING_CHAR`:`BAD_INDENT`,t),S&&S.source.length!==1&&C.unshift(S)}if(C.length>0){let e=a.resolveEnd(C,w,f.options.strict,m);e.comment&&(v.comment?v.comment+=`
|
|
238
|
-
`+e.comment:v.comment=e.comment),v.range=[p.offset,w,e.offset]}else v.range=[p.offset,w,w];return v}e.resolveFlowCollection=d})),Wf=N((e=>{var t=Q(),n=$(),r=uf(),i=ff(),a=Bf(),o=Vf(),s=Uf();function c(e,t,n,r,i,c){let l=n.type===`block-map`?a.resolveBlockMap(e,t,n,r,c):n.type===`block-seq`?o.resolveBlockSeq(e,t,n,r,c):s.resolveFlowCollection(e,t,n,r,c),u=l.constructor;return i===`!`||i===u.tagName?(l.tag=u.tagName,l):(i&&(l.tag=i),l)}function l(e,a,o,s,l){let u=s.tag,d=u?a.directives.tagName(u.source,e=>l(u,`TAG_RESOLVE_FAILED`,e)):null;if(o.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=s,n=e&&u?e.offset>u.offset?e:u:e??u;n&&(!t||t.offset<n.offset)&&l(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let f=o.type===`block-map`?`map`:o.type===`block-seq`?`seq`:o.start.source===`{`?`map`:`seq`;if(!u||!d||d===`!`||d===r.YAMLMap.tagName&&f===`map`||d===i.YAMLSeq.tagName&&f===`seq`)return c(e,a,o,l,d);let p=a.schema.tags.find(e=>e.tag===d&&e.collection===f);if(!p){let t=a.schema.knownTags[d];if(t?.collection===f)a.schema.tags.push(Object.assign({},t,{default:!1})),p=t;else return t?l(u,`BAD_COLLECTION_TYPE`,`${t.tag} used for ${f} collection, but expects ${t.collection??`scalar`}`,!0):l(u,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${d}`,!0),c(e,a,o,l,d)}let m=c(e,a,o,l,d,p),h=p.resolve?.(m,e=>l(u,`TAG_RESOLVE_FAILED`,e),a.options)??m,g=t.isNode(h)?h:new n.Scalar(h);return g.range=m.range,g.tag=d,p?.format&&(g.format=p.format),g}e.composeCollection=l})),Gf=N((e=>{var t=$();function n(e,n,a){let o=n.offset,s=r(n,e.options.strict,a);if(!s)return{value:``,type:null,comment:``,range:[o,o,o]};let c=s.mode===`>`?t.Scalar.BLOCK_FOLDED:t.Scalar.BLOCK_LITERAL,l=n.source?i(n.source):[],u=l.length;for(let e=l.length-1;e>=0;--e){let t=l[e][1];if(t===``||t===`\r`)u=e;else break}if(u===0){let e=s.chomp===`+`&&l.length>0?`
|
|
239
|
-
`.repeat(Math.max(1,l.length-1)):``,t=o+s.length;return n.source&&(t+=n.source.length),{value:e,type:c,comment:s.comment,range:[o,t,t]}}let d=n.indent+s.indent,f=n.offset+s.length,p=0;for(let t=0;t<u;++t){let[n,r]=l[t];if(r===``||r===`\r`)s.indent===0&&n.length>d&&(d=n.length);else{n.length<d&&a(f+n.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),s.indent===0&&(d=n.length),p=t,d===0&&!e.atRoot&&a(f,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}f+=n.length+r.length+1}for(let e=l.length-1;e>=u;--e)l[e][0].length>d&&(u=e+1);let m=``,h=``,g=!1;for(let e=0;e<p;++e)m+=l[e][0].slice(d)+`
|
|
240
|
-
`;for(let e=p;e<u;++e){let[n,r]=l[e];f+=n.length+r.length+1;let i=r[r.length-1]===`\r`;if(i&&(r=r.slice(0,-1)),r&&n.length<d){let e=`Block scalar lines must not be less indented than their ${s.indent?`explicit indentation indicator`:`first line`}`;a(f-r.length-(i?2:1),`BAD_INDENT`,e),n=``}c===t.Scalar.BLOCK_LITERAL?(m+=h+n.slice(d)+r,h=`
|
|
241
|
-
`):n.length>d||r[0]===` `?(h===` `?h=`
|
|
242
|
-
`:!g&&h===`
|
|
243
|
-
`&&(h=`
|
|
244
|
-
|
|
245
|
-
`),m+=h+n.slice(d)+r,h=`
|
|
246
|
-
`,g=!0):r===``?h===`
|
|
247
|
-
`?m+=`
|
|
248
|
-
`:h=`
|
|
249
|
-
`:(m+=h+r,h=` `,g=!1)}switch(s.chomp){case`-`:break;case`+`:for(let e=u;e<l.length;++e)m+=`
|
|
250
|
-
`+l[e][0].slice(d);m[m.length-1]!==`
|
|
251
|
-
`&&(m+=`
|
|
252
|
-
`);break;default:m+=`
|
|
253
|
-
`}let _=o+s.length+n.source.length;return{value:m,type:c,comment:s.comment,range:[o,_,_]}}function r({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function i(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}e.resolveBlockScalar=n})),Kf=N((e=>{var t=$(),n=Hf();function r(e,r,o){let{offset:c,type:l,source:u,end:d}=e,f,p,m=(e,t,n)=>o(c+e,t,n);switch(l){case`scalar`:f=t.Scalar.PLAIN,p=i(u,m);break;case`single-quoted-scalar`:f=t.Scalar.QUOTE_SINGLE,p=a(u,m);break;case`double-quoted-scalar`:f=t.Scalar.QUOTE_DOUBLE,p=s(u,m);break;default:return o(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${l}`),{value:``,type:null,comment:``,range:[c,c+u.length,c+u.length]}}let h=c+u.length,g=n.resolveEnd(d,h,r,o);return{value:p,type:f,comment:g.comment,range:[c,h,g.offset]}}function i(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`;break}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),o(e)}function a(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),o(e.slice(1,-1)).replace(/''/g,`'`)}function o(e){let t,n;try{t=RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
254
|
-
`,`sy`),n=RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
255
|
-
`,`sy`)}catch{t=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=t.exec(e);if(!r)return e;let i=r[1],a=` `,o=t.lastIndex;for(n.lastIndex=o;r=n.exec(e);)r[1]===``?a===`
|
|
256
|
-
`?i+=a:a=`
|
|
257
|
-
`:(i+=a+r[1],a=` `),o=n.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,r=s.exec(e),i+a+(r?.[1]??``)}function s(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(!(i===`\r`&&e[r+1]===`
|
|
258
|
-
`))if(i===`
|
|
259
|
-
`){let{fold:t,offset:i}=c(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=l[i];if(a)n+=a;else if(i===`
|
|
260
|
-
`)for(i=e[r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`\r`&&e[r+1]===`
|
|
261
|
-
`)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a={x:2,u:4,U:8}[i];n+=u(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
|
|
262
|
-
`&&!(a===`\r`&&e[r+2]===`
|
|
263
|
-
`)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function c(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
|
|
264
|
-
`||r===`\r`)&&!(r===`\r`&&e[t+2]!==`
|
|
265
|
-
`);)r===`
|
|
266
|
-
`&&(n+=`
|
|
267
|
-
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}let l={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
|
|
268
|
-
`,r:`\r`,t:` `,v:`\v`,N:`ย
`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function u(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;if(isNaN(a)){let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}return String.fromCodePoint(a)}e.resolveFlowScalar=r})),qf=N((e=>{var t=Q(),n=$(),r=Gf(),i=Kf();function a(e,a,c,l){let{value:u,type:d,comment:f,range:p}=a.type===`block-scalar`?r.resolveBlockScalar(e,a,l):i.resolveFlowScalar(a,e.options.strict,l),m=c?e.directives.tagName(c.source,e=>l(c,`TAG_RESOLVE_FAILED`,e)):null,h;h=e.options.stringKeys&&e.atKey?e.schema[t.SCALAR]:m?o(e.schema,u,m,c,l):a.type===`scalar`?s(e,u,a,l):e.schema[t.SCALAR];let g;try{let r=h.resolve(u,e=>l(c??a,`TAG_RESOLVE_FAILED`,e),e.options);g=t.isScalar(r)?r:new n.Scalar(r)}catch(e){let t=e instanceof Error?e.message:String(e);l(c??a,`TAG_RESOLVE_FAILED`,t),g=new n.Scalar(u)}return g.range=p,g.source=u,d&&(g.type=d),m&&(g.tag=m),h.format&&(g.format=h.format),f&&(g.comment=f),g}function o(e,n,r,i,a){if(r===`!`)return e[t.SCALAR];let o=[];for(let t of e.tags)if(!t.collection&&t.tag===r)if(t.default&&t.test)o.push(t);else return t;for(let e of o)if(e.test?.test(n))return e;let s=e.knownTags[r];return s&&!s.collection?(e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(a(i,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${r}`,r!==`tag:yaml.org,2002:str`),e[t.SCALAR])}function s({atKey:e,directives:n,schema:r},i,a,o){let s=r.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(i))||r[t.SCALAR];if(r.compat){let e=r.compat.find(e=>e.default&&e.test?.test(i))??r[t.SCALAR];s.tag!==e.tag&&o(a,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${n.tagString(s.tag)} or ${n.tagString(e.tag)}`,!0)}return s}e.composeScalar=a})),Jf=N((e=>{function t(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}e.emptyScalarPosition=t})),Yf=N((e=>{var t=Xd(),n=Q(),r=Wf(),i=qf(),a=Hf(),o=Jf();let s={composeNode:c,composeEmptyNode:l};function c(e,t,a,o){let c=e.atKey,{spaceBefore:d,comment:f,anchor:p,tag:m}=a,h,g=!0;switch(t.type){case`alias`:h=u(e,t,o),(p||m)&&o(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:h=i.composeScalar(e,t,m,o),p&&(h.anchor=p.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{h=r.composeCollection(s,e,t,a,o),p&&(h.anchor=p.source.substring(1))}catch(e){o(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:o(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),g=!1}return h??=l(e,t.offset,void 0,null,a,o),p&&h.anchor===``&&o(p,`BAD_ALIAS`,`Anchor cannot be an empty string`),c&&e.options.stringKeys&&(!n.isScalar(h)||typeof h.value!=`string`||h.tag&&h.tag!==`tag:yaml.org,2002:str`)&&o(m??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),d&&(h.spaceBefore=!0),f&&(t.type===`scalar`&&t.source===``?h.comment=f:h.commentBefore=f),e.options.keepSourceTokens&&g&&(h.srcToken=t),h}function l(e,t,n,r,{spaceBefore:a,comment:s,anchor:c,tag:l,end:u},d){let f={type:`scalar`,offset:o.emptyScalarPosition(t,n,r),indent:-1,source:``},p=i.composeScalar(e,f,l,d);return c&&(p.anchor=c.source.substring(1),p.anchor===``&&d(c,`BAD_ALIAS`,`Anchor cannot be an empty string`)),a&&(p.spaceBefore=!0),s&&(p.comment=s,p.range[2]=u),p}function u({options:e},{offset:n,source:r,end:i},o){let s=new t.Alias(r.substring(1));s.source===``&&o(n,`BAD_ALIAS`,`Alias cannot be an empty string`),s.source.endsWith(`:`)&&o(n+r.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let c=n+r.length,l=a.resolveEnd(i,c,e.strict,o);return s.range=[n,c,l.offset],l.comment&&(s.comment=l.comment),s}e.composeEmptyNode=l,e.composeNode=c})),Xf=N((e=>{var t=Pf(),n=Yf(),r=Hf(),i=If();function a(e,a,{offset:o,start:s,value:c,end:l},u){let d=Object.assign({_directives:a},e),f=new t.Document(void 0,d),p={atKey:!1,atRoot:!0,directives:f.directives,options:f.options,schema:f.schema},m=i.resolveProps(s,{indicator:`doc-start`,next:c??l?.[0],offset:o,onError:u,parentIndent:0,startOnNewline:!0});m.found&&(f.directives.docStart=!0,c&&(c.type===`block-map`||c.type===`block-seq`)&&!m.hasNewline&&u(m.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),f.contents=c?n.composeNode(p,c,m,u):n.composeEmptyNode(p,m.end,s,null,m,u);let h=f.contents.range[2],g=r.resolveEnd(l,h,!1,u);return g.comment&&(f.comment=g.comment),f.range=[o,h,g.offset],f}e.composeDoc=a})),Zf=N((e=>{var t=gt(`process`),n=Gd(),r=Pf(),i=Ff(),a=Q(),o=Xf(),s=Hf();function c(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function l(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
|
|
269
|
-
|
|
270
|
-
`:`
|
|
271
|
-
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}e.Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let a=c(e);r?this.warnings.push(new i.YAMLWarning(a,t,n)):this.errors.push(new i.YAMLParseError(a,t,n))},this.directives=new n.Directives({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=l(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(a.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];a.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:l(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(t.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=c(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=o.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=s.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),n=new r.Document(void 0,e);this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),n.range=[0,t,t],this.decorate(n,!1),yield n}}}})),Qf=N((e=>{var t=Gf(),n=Kf(),r=Ff(),i=tf();function a(e,i=!0,a){if(e){let o=(e,t,n)=>{let i=typeof e==`number`?e:Array.isArray(e)?e[0]:e.offset;if(a)a(i,t,n);else throw new r.YAMLParseError([i,i+1],t,n)};switch(e.type){case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return n.resolveFlowScalar(e,i,o);case`block-scalar`:return t.resolveBlockScalar({options:{strict:i}},e,o)}}return null}function o(e,t){let{implicitKey:n=!1,indent:r,inFlow:a=!1,offset:o=-1,type:s=`PLAIN`}=t,c=i.stringifyString({type:s,value:e},{implicitKey:n,indent:r>0?` `.repeat(r):``,inFlow:a,options:{blockQuote:!0,lineWidth:-1}}),u=t.end??[{type:`newline`,offset:-1,indent:r,source:`
|
|
272
|
-
`}];switch(c[0]){case`|`:case`>`:{let e=c.indexOf(`
|
|
273
|
-
`),t=c.substring(0,e),n=c.substring(e+1)+`
|
|
274
|
-
`,i=[{type:`block-scalar-header`,offset:o,indent:r,source:t}];return l(i,u)||i.push({type:`newline`,offset:-1,indent:r,source:`
|
|
275
|
-
`}),{type:`block-scalar`,offset:o,indent:r,props:i,source:n}}case`"`:return{type:`double-quoted-scalar`,offset:o,indent:r,source:c,end:u};case`'`:return{type:`single-quoted-scalar`,offset:o,indent:r,source:c,end:u};default:return{type:`scalar`,offset:o,indent:r,source:c,end:u}}}function s(e,t,n={}){let{afterKey:r=!1,implicitKey:a=!1,inFlow:o=!1,type:s}=n,l=`indent`in e?e.indent:null;if(r&&typeof l==`number`&&(l+=2),!s)switch(e.type){case`single-quoted-scalar`:s=`QUOTE_SINGLE`;break;case`double-quoted-scalar`:s=`QUOTE_DOUBLE`;break;case`block-scalar`:{let t=e.props[0];if(t.type!==`block-scalar-header`)throw Error(`Invalid block scalar header`);s=t.source[0]===`>`?`BLOCK_FOLDED`:`BLOCK_LITERAL`;break}default:s=`PLAIN`}let d=i.stringifyString({type:s,value:t},{implicitKey:a||l===null,indent:l!==null&&l>0?` `.repeat(l):``,inFlow:o,options:{blockQuote:!0,lineWidth:-1}});switch(d[0]){case`|`:case`>`:c(e,d);break;case`"`:u(e,d,`double-quoted-scalar`);break;case`'`:u(e,d,`single-quoted-scalar`);break;default:u(e,d,`scalar`)}}function c(e,t){let n=t.indexOf(`
|
|
276
|
-
`),r=t.substring(0,n),i=t.substring(n+1)+`
|
|
277
|
-
`;if(e.type===`block-scalar`){let t=e.props[0];if(t.type!==`block-scalar-header`)throw Error(`Invalid block scalar header`);t.source=r,e.source=i}else{let{offset:t}=e,n=`indent`in e?e.indent:-1,a=[{type:`block-scalar-header`,offset:t,indent:n,source:r}];l(a,`end`in e?e.end:void 0)||a.push({type:`newline`,offset:-1,indent:n,source:`
|
|
278
|
-
`});for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:`block-scalar`,indent:n,props:a,source:i})}}function l(e,t){if(t)for(let n of t)switch(n.type){case`space`:case`comment`:e.push(n);break;case`newline`:return e.push(n),!0}return!1}function u(e,t,n){switch(e.type){case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:e.type=n,e.source=t;break;case`block-scalar`:{let r=e.props.slice(1),i=t.length;e.props[0].type===`block-scalar-header`&&(i-=e.props[0].source.length);for(let e of r)e.offset+=i;delete e.props,Object.assign(e,{type:n,source:t,end:r});break}case`block-map`:case`block-seq`:{let r={type:`newline`,offset:e.offset+t.length,indent:e.indent,source:`
|
|
279
|
-
`};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let r=`indent`in e?e.indent:-1,i=`end`in e&&Array.isArray(e.end)?e.end.filter(e=>e.type===`space`||e.type===`comment`||e.type===`newline`):[];for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}e.createScalarToken=o,e.resolveAsScalar=a,e.setScalarValue=s})),$f=N((e=>{let t=e=>`type`in e?n(e):r(e);function n(e){switch(e.type){case`block-scalar`:{let t=``;for(let r of e.props)t+=n(r);return t+e.source}case`block-map`:case`block-seq`:{let t=``;for(let n of e.items)t+=r(n);return t}case`flow-collection`:{let t=e.start.source;for(let n of e.items)t+=r(n);for(let n of e.end)t+=n.source;return t}case`document`:{let t=r(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if(`end`in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function r({start:e,key:t,sep:r,value:i}){let a=``;for(let t of e)a+=t.source;if(t&&(a+=n(t)),r)for(let e of r)a+=e.source;return i&&(a+=n(i)),a}e.stringify=t})),ep=N((e=>{let t=Symbol(`break visit`),n=Symbol(`skip children`),r=Symbol(`remove item`);function i(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),a(Object.freeze([]),e,t)}i.BREAK=t,i.SKIP=n,i.REMOVE=r,i.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},i.parentCollection=(e,t)=>{let n=i.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],a=n?.[r];if(a&&`items`in a)return a;throw Error(`Parent collection not found`)};function a(e,n,i){let o=i(n,e);if(typeof o==`symbol`)return o;for(let s of[`key`,`value`]){let c=n[s];if(c&&`items`in c){for(let n=0;n<c.items.length;++n){let o=a(Object.freeze(e.concat([[s,n]])),c.items[n],i);if(typeof o==`number`)n=o-1;else if(o===t)return t;else o===r&&(c.items.splice(n,1),--n)}typeof o==`function`&&s===`key`&&(o=o(n,e))}}return typeof o==`function`?o(n,e):o}e.visit=i})),tp=N((e=>{var t=Qf(),n=$f(),r=ep();let i=e=>!!e&&`items`in e,a=e=>!!e&&(e.type===`scalar`||e.type===`single-quoted-scalar`||e.type===`double-quoted-scalar`||e.type===`block-scalar`);function o(e){switch(e){case`๏ปฟ`:return`<BOM>`;case``:return`<DOC>`;case``:return`<FLOW_END>`;case``:return`<SCALAR>`;default:return JSON.stringify(e)}}function s(e){switch(e){case`๏ปฟ`:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
|
|
280
|
-
`:case`\r
|
|
281
|
-
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}e.createScalarToken=t.createScalarToken,e.resolveAsScalar=t.resolveAsScalar,e.setScalarValue=t.setScalarValue,e.stringify=n.stringify,e.visit=r.visit,e.BOM=`๏ปฟ`,e.DOCUMENT=``,e.FLOW_END=``,e.SCALAR=``,e.isCollection=i,e.isScalar=a,e.prettyToken=o,e.tokenType=s})),np=N((e=>{var t=tp();function n(e){switch(e){case void 0:case` `:case`
|
|
282
|
-
`:case`\r`:case` `:return!0;default:return!1}}let r=new Set(`0123456789ABCDEFabcdef`),i=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),a=new Set(`,[]{}`),o=new Set(` ,[]{}
|
|
283
|
-
\r `),s=e=>!e||o.has(e);e.Lexer=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
|
|
284
|
-
`?!0:t===`\r`?this.buffer[e+1]===`
|
|
285
|
-
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;t===` `;)t=this.buffer[++n+e];if(t===`\r`){let t=this.buffer[n+e+1];if(t===`
|
|
286
|
-
`||!t&&!this.atEnd)return e+n+1}return t===`
|
|
287
|
-
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&n(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
|
|
288
|
-
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===t.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}else n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield t.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&n(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!n(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&n(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,yield*this.parseBlockStart()}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(s),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,r,i=-1;do e=yield*this.pushNewline(),e>0?(r=yield*this.pushSpaces(!1),this.indentValue=i=r):r=0,r+=yield*this.pushSpaces(!0);while(e+r>0);let a=this.getLine();if(a===null)return this.setNext(`flow`);if((i!==-1&&i<this.indentNext&&a[0]!==`#`||i===0&&(a.startsWith(`---`)||a.startsWith(`...`))&&n(a[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(a[0]===`]`||a[0]===`}`)))return this.flowLevel=0,yield t.FLOW_END,yield*this.parseLineStart();let o=0;for(;a[o]===`,`;)o+=yield*this.pushCount(1),o+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(o+=yield*this.pushIndicators(),a[o]){case void 0:return`flow`;case`#`:return yield*this.pushCount(a.length-o),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(s),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||n(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
|
|
289
|
-
`,this.pos);if(r!==-1){for(;r!==-1;){let e=this.continueScalar(r+1);if(e===-1)break;r=n.indexOf(`
|
|
290
|
-
`,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>n(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,n=0,r;loop:for(let t=this.pos;r=this.buffer[t];++t)switch(r){case` `:n+=1;break;case`
|
|
291
|
-
`:e=t,n=0;break;case`\r`:{let e=this.buffer[t+1];if(!e&&!this.atEnd)return this.setNext(`block-scalar`);if(e===`
|
|
292
|
-
`)break}default:break loop}if(!r&&!this.atEnd)return this.setNext(`block-scalar`);if(n>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=n:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let t=this.continueScalar(e+1);if(t===-1)break;e=this.buffer.indexOf(`
|
|
293
|
-
`,t)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext(`block-scalar`);e=this.buffer.length}}let i=e+1;for(r=this.buffer[i];r===` `;)r=this.buffer[++i];if(r===` `){for(;r===` `||r===` `||r===`\r`||r===`
|
|
294
|
-
`;)r=this.buffer[++i];e=i-1}else if(!this.blockScalarKeep)do{let t=e-1,r=this.buffer[t];r===`\r`&&(r=this.buffer[--t]);let i=t;for(;r===` `;)r=this.buffer[--t];if(r===`
|
|
295
|
-
`&&t>=this.pos&&t+1+n>i)e=t;else break}while(!0);return yield t.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,r=this.pos-1,i=this.pos-1,o;for(;o=this.buffer[++i];)if(o===`:`){let t=this.buffer[i+1];if(n(t)||e&&a.has(t))break;r=i}else if(n(o)){let t=this.buffer[i+1];if(o===`\r`&&(t===`
|
|
296
|
-
`?(i+=1,o=`
|
|
297
|
-
`,t=this.buffer[i+1]):r=i),t===`#`||e&&a.has(t))break;if(o===`
|
|
298
|
-
`){let e=this.continueScalar(i+1);if(e===-1)break;i=Math.max(i,e-2)}}else{if(e&&a.has(o))break;r=i}return!o&&!this.atEnd?this.setNext(`plain-scalar`):(yield t.SCALAR,yield*this.pushToIndex(r+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){switch(this.charAt(0)){case`!`:return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case`&`:return(yield*this.pushUntil(s))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case`-`:case`?`:case`:`:{let e=this.flowLevel>0,t=this.charAt(1);if(n(t)||e&&a.has(t))return e?this.flowKey&&=!1:this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!n(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(i.has(t))t=this.buffer[++e];else if(t===`%`&&r.has(this.buffer[e+1])&&r.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
299
|
-
`?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
|
|
300
|
-
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}})),rp=N((e=>{e.LineCounter=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}}})),ip=N((e=>{var t=gt(`process`),n=tp(),r=np();function i(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function a(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function o(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function s(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function c(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function l(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!i(t.start,`explicit-key-ind`)&&!i(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,o(t.value)?t.value.end?Array.prototype.push.apply(t.value.end,t.sep):t.value.end=t.sep:Array.prototype.push.apply(t.start,t.sep),delete t.sep)}e.Parser=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new r.Lexer,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,t.env.LOG_TOKENS&&console.log(`|`,n.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=n.tokenType(e);if(!r){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(r===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=r,yield*this.step(),r){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&l(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&a(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case`directive-line`:yield{type:`directive`,offset:this.offset,source:this.source};return;case`byte-order-mark`:case`space`:case`comment`:case`newline`:yield this.sourceToken;return;case`doc-mode`:case`doc-start`:{let e={type:`document`,offset:this.offset,start:[]};this.type===`doc-start`&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case`doc-start`:a(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type===`map-value-ind`){let t=c(s(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case`space`:case`comment`:case`newline`:e.props.push(this.sourceToken);return;case`scalar`:if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf(`
|
|
301
|
-
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
302
|
-
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,a=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(a=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(a.push(this.sourceToken),e.items.push({start:a,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey)if(!t.sep)if(i(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=c(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(i(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(o(t.key)&&!i(t.sep,`newline`)){let e=c(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else a.length>0?t.sep=t.sep.concat(a,this.sourceToken):t.sep.push(this.sourceToken);else t.sep?t.value||r?e.items.push({start:a,key:null,sep:[this.sourceToken]}):i(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:a,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!i(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:a});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||i(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=c(s(t));l(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
|
|
303
|
-
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
304
|
-
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),ap=N((e=>{var t=Zf(),n=Pf(),r=Ff(),i=af(),a=Q(),o=rp(),s=ip();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),op=N((e=>{var t=Zf(),n=Pf(),r=Mf(),i=Ff(),a=Xd(),o=Q(),s=cf(),c=$(),l=uf(),u=ff(),d=tp(),f=np(),p=rp(),m=ip(),h=ap(),g=Wd();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.CST=d,e.Lexer=f.Lexer,e.LineCounter=p.LineCounter,e.Parser=m.Parser,e.parse=h.parse,e.parseAllDocuments=h.parseAllDocuments,e.parseDocument=h.parseDocument,e.stringify=h.stringify,e.visit=g.visit,e.visitAsync=g.visitAsync}));async function sp(e){let t=await Xe(e,`utf-8`).catch(e=>{process.stderr.write(`Error: cannot read pipeline file: ${e.message}\n`),process.exit(2)}),n=Qe(e).toLowerCase(),r;if(n===`.yaml`||n===`.yml`){let{parse:e}=await Promise.resolve().then(()=>ht(op(),1));r=e(t)}else try{r=JSON.parse(t)}catch{let{parse:e}=await Promise.resolve().then(()=>ht(op(),1));r=e(t)}return r}var cp=M((()=>{}));async function lp(e){let t=e.input,n=e.inputFile;if(t&&n&&(process.stderr.write(`Error: use --input or --input-file, not both
|
|
305
|
-
`),process.exit(2)),t)return JSON.parse(t);if(n){let e=await Xe(et(n),`utf-8`);return JSON.parse(e)}return{}}function up(e){let t=`[${e.type}]`;if(`stepCount`in e){process.stderr.write(`${t} ${e.stepCount} step${e.stepCount===1?``:`s`}\n`);return}`step`in e&&e.step?process.stderr.write(`${t} ${dp(e.step)}\n`):process.stderr.write(`${t}\n`)}function dp(e){return`${e.index!==void 0&&e.total!==void 0?`${e.index}/${e.total} `:``}${e.id} (${e.type})`}function fp(e){let t=e.status===`succeeded`?`+`:e.status===`failed`?`x`:`~`;process.stdout.write(`\nPipeline ${e.status} [${t}]\n\n`);for(let t of e.steps){let e=` [${t.status===`succeeded`?`+`:t.status===`failed`?`x`:t.status===`skipped`?`-`:`~`}] ${t.id} (${t.type}) โ ${t.status}`;t.skipReason&&(e+=` (${t.skipReason})`),t.error&&(e+=`: ${t.error.message}`),process.stdout.write(e+`
|
|
306
|
-
`)}process.stdout.write(`
|
|
307
|
-
`)}var pp,mp=M((()=>{I(),cd(),Ud(),cp(),pp=m({name:`pipeline run`,description:`Run a pipeline workflow definition`,skipDefaultApiKeySetup:!0,usage:`bl pipeline run <file> [flags]`,options:[{flag:`--input <json>`,description:`Runtime input as inline JSON`},{flag:`--input-file <path>`,description:`Runtime input from a JSON file`},{flag:`--concurrency <n>`,description:`Max parallel steps (default: 1)`,type:`number`},{flag:`--events <format>`,description:`Emit lifecycle events: jsonl`},{flag:`--timeout <seconds>`,description:`Default step timeout in seconds`,type:`number`}],examples:[`bl pipeline run workflow.yaml --input '{"brief":"hello"}'`,`bl pipeline run workflow.json --input-file inputs.json --concurrency 3`,`bl pipeline run workflow.yaml --dry-run`,`bl pipeline run workflow.json --events jsonl`,`bl pipeline run workflow.yaml --output json`],async run(e,t){let n=(t._positional??[])[0];n||(process.stderr.write(`Error: pipeline file is required
|
|
308
|
-
Usage: bl pipeline run <file>
|
|
309
|
-
`),process.exit(2)),od();let r=t.events;r!==void 0&&r!==`jsonl`&&(process.stderr.write(`Error: unsupported --events format: ${r}. Supported: jsonl\n`),process.exit(2));let i=et(n),a=await sp(i),o=await lp(t),s=Ze(i);if(r===`jsonl`){for await(let e of kd(a,o,{concurrency:t.concurrency,basePath:s,dryRun:t.dryRun,timeoutSeconds:t.timeout}))process.stdout.write(JSON.stringify(e)+`
|
|
310
|
-
`);return}let c=await Od(a,o,{concurrency:t.concurrency,basePath:s,dryRun:t.dryRun,timeoutSeconds:t.timeout,onEvent:t.verbose?up:void 0});e.output===`json`?P(c,`json`):fp(c),c.status===`failed`&&(process.exitCode=1)}})})),hp,gp=M((()=>{I(),cd(),Dd(),cp(),hp=m({name:`pipeline validate`,description:`Validate a pipeline definition without executing`,skipDefaultApiKeySetup:!0,usage:`bl pipeline validate <file>`,options:[],examples:[`bl pipeline validate workflow.yaml`,`bl pipeline validate workflow.json --output json`],async run(e,t){let n=(t._positional??[])[0];n||(process.stderr.write(`Error: pipeline file is required
|
|
311
|
-
Usage: bl pipeline validate <file>
|
|
312
|
-
`),process.exit(2)),od();let r=await sp(et(n)),i=vd(r),a=i.length===0?yd(r):[];if(e.output===`json`)P({valid:i.length===0,issues:i,...a.length>0?{hints:a}:{}},`json`),i.length>0&&(process.exitCode=1);else if(i.length===0){process.stdout.write(`Pipeline definition is valid.
|
|
313
|
-
`);for(let e of a)process.stderr.write(` hint: ${e}\n`)}else{process.stderr.write(`Pipeline validation failed:
|
|
314
|
-
`);for(let e of i)process.stderr.write(` - ${e}\n`);process.exitCode=1}}})}));function _p(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}K`:String(e)}function vp(e,t){let n=t?new rt({level:0}):nt,r=[];r.push(n.cyan.bold(`Intent Analysis`)),e.taskSummary&&(r.push(``),r.push(e.taskSummary)),e.scenarioHints.length&&(r.push(``),r.push(`${n.dim(`Scenario`)} ${e.scenarioHints.join(` ยท `)}`));let i=e.inputModality.map(e=>wp[e]??e),a=e.outputModality.map(e=>wp[e]??e);if(i.length||a.length){r.push(``);let e=[];i.length&&e.push(`${n.dim(`Input`)} ${i.join(`, `)}`),a.length&&e.push(`${n.dim(`Output`)} ${a.join(`, `)}`),r.push(e.join(` `))}let o=e.requiredCapabilities.map(e=>Tp[e]??e);o.length&&r.push(`${n.dim(`Capabilities`)} ${o.join(`, `)}`);let s=Ep[e.budget]??e.budget,c=Dp[e.qualityPreference]??e.qualityPreference;r.push(``),r.push(`${n.dim(`Budget`)} ${s} ${n.dim(`Quality`)} ${c}`);let l=e.modelPreference;if(l&&l.mode!==`unconstrained`){r.push(``);let e=Op[l.mode]??l.mode,t=[n.dim(`Mode`)+` ${n.yellow(e)}`];l.targets?.length&&t.push(n.dim(`Targets`)+` ${l.targets.join(`, `)}`),l.excludes?.length&&t.push(n.dim(`Excludes`)+` ${l.excludes.join(`, `)}`),r.push(t.join(` `))}if(e.segments?.length){r.push(``),r.push(n.dim(`Pipeline`));for(let[t,i]of e.segments.entries()){let e=i.outputModality.map(e=>wp[e]??e).join(`, `);r.push(` ${n.dim(`${t+1}.`)} ${i.step}${e?n.dim(` โ ${e}`):``}`)}}return tt(r.join(`
|
|
315
|
-
`),{padding:{top:0,bottom:0,left:1,right:1},margin:{top:0,bottom:0,left:1,right:0},borderColor:`cyan`,borderStyle:`round`,dimBorder:!0})}function yp(e,t,n){let r=[n.green.bold,n.blue.bold,n.magenta.bold][t]??n.white.bold,i=kp[t]??`#${t+1}`,a=[];a.push(r(`โฌข #${t+1} โ ${i}`)),a.push(``),a.push(`${n.bold(e.name)} ${n.dim(`(${e.model})`)}`),a.push(``),a.push(`${n.cyan(`Why`)} ${e.reason}`),e.highlights.length&&(a.push(``),a.push(e.highlights.map(e=>n.bgGray.white(` ${e} `)).join(` `)));let o=[];e.contextWindow&&o.push(`Context ${_p(e.contextWindow)}`),e.maxOutputTokens&&o.push(`Max Output ${_p(e.maxOutputTokens)}`),o.length&&(a.push(``),a.push(n.dim(o.join(` ยท `))));let s=u(e.docUrl);return s&&(a.push(``),a.push(n.dim(`Docs ${s}`))),tt(a.join(`
|
|
316
|
-
`),{padding:{top:0,bottom:0,left:1,right:1},margin:{top:0,bottom:0,left:1,right:0},borderColor:`gray`,borderStyle:`round`,dimBorder:!0})}function bp(e,t){let n=t?new rt({level:0}):nt;return e.map((e,t)=>yp(e,t,n)).join(`
|
|
317
|
-
`)}function xp(e,t,n){let r=n?new rt({level:0}):nt,i=[];i.push(` ${r.yellow.bold(`โก Pipeline`)} ${e}`);for(let[e,{step:n,recommendations:a,warnings:o}]of t.entries()){if(i.push(``),i.push(r.bold(` โโโ Step ${e+1}: ${n} โโโ`)),o?.length)for(let e of o)i.push(` ${r.yellow(`โ `)} ${r.yellow(e)}`);i.push(``),i.push(a.map((e,t)=>yp(e,t,r)).join(`
|
|
318
|
-
`))}return i.join(`
|
|
319
|
-
`)}function Sp(e,t){return e.type===`pipeline`?xp(e.summary,e.steps,t):bp(e.recommendations,t)}function Cp(e){return e.type===`pipeline`?e.steps.length===0:e.recommendations.length===0}var wp,Tp,Ep,Dp,Op,kp,Ap,jp=M((()=>{I(),Xi(),U(),wp={Text:`Text`,Image:`Image`,Video:`Video`,Audio:`Audio`},Tp={TG:`Text Gen`,VU:`Vision`,IG:`Image Gen`,VG:`Video Gen`,TTS:`Text-to-Speech`,ASR:`Speech-to-Text`,Reasoning:`Reasoning`},Ep={low:`Cost-Effective`,medium:`Balanced`,high:`High Investment`},Dp={flagship:`Flagship`,balanced:`Balanced`,"cost-optimized":`Value`},Op={scoped:`Scoped`,comparison:`Comparison`,alternative:`Alternative`},kp=[`Best Pick`,`Runner-Up`,`Alternative`],Ap=m({name:`advisor recommend`,description:`Recommend the best models for your use case (intent analysis โ candidate recall โ LLM ranking)`,usage:`bl advisor recommend <prompt> [flags]`,options:[{flag:`--message <text>`,description:`Describe your requirements (alternative to positional prompt)`},{flag:`--dry-run`,description:`Show intent analysis and candidate list without LLM ranking`},{flag:`--output <format>`,description:`Output format: text (default in TTY), json, yaml`}],examples:[`bl advisor recommend --message "I need a visual-understanding chatbot"`,`bl advisor recommend --message "Build an Agent that auto-generates animations"`,`bl advisor recommend --message "Legal contract review, high precision required"`,`bl advisor recommend --message "Low-cost high-concurrency online customer service" --output json`,`bl advisor recommend --message "Long document summarization" --dry-run`,`bl advisor recommend # Interactive input`],async run(e,t){let n=t._positional??[],r=t.message||n.join(` `);if(!r.trim())if(D({nonInteractive:e.nonInteractive})){let e=await Yr({message:`Describe your requirement:`});e||(process.stderr.write(`Cancelled.
|
|
320
|
-
`),process.exit(1)),r=e}else H(`message`,`bl advisor recommend "your requirement"`);let i=h(e.output),a={onPrepareStart:()=>process.stderr.write(`Initializing model data...
|
|
321
|
-
`)};process.stderr.write(`Analyzing your request...
|
|
322
|
-
`);let[o,c]=await Promise.all([w(e,a),s(e,r)]);c.confidence===0?process.stderr.write(`Intent analysis timed out, using defaults...
|
|
323
|
-
`):process.stderr.write(`
|
|
324
|
-
`);let l=await fe(e,o,r,50,c);if(e.dryRun){P({userInput:r,intent:c,candidateCount:l.length,candidates:l.map(({model:e,score:t})=>({model:e.model,score:t})),top:3},i);return}let u=qi(`Recommending best models...`);u.start();let d=await ue(e,l,c,r,3);if(u.stop(),Cp(d)){F(`No suitable models found for this request.`);return}if(i!==`text`){P({intent:{taskSummary:c.taskSummary,scenarioHints:c.scenarioHints,complexity:c.complexity,inputModality:c.inputModality,outputModality:c.outputModality,requiredCapabilities:c.requiredCapabilities,budget:c.budget,qualityPreference:c.qualityPreference,modelPreference:c.modelPreference?.mode===`unconstrained`?void 0:c.modelPreference,segments:c.segments},result:d,candidates:l.length},i);return}F(vp(c,e.noColor)),F(``),F(Sp(d,e.noColor))}})}));function Mp(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function Np(e){let t=Mp(e,`data`);if(!t)return e;let n=Mp(t,`DataV2`);if(n){let e=Mp(n,`data`);return(e?Mp(e,`data`):void 0)??e??n}return Mp(t,`data`)??t}function Pp(e,t){let n=t?e=>e:e=>`\x1b[1m${e}\x1b[0m`,r=t?e=>e:e=>`\x1b[2m${e}\x1b[0m`,i=t?e=>e:e=>`\x1b[32m${e}\x1b[0m`,a=[`Name`,`Workspace ID`,`Default`],o=e.map(e=>[e.agentName,e.workspaceId,e.defaultAgent?`Yes`:`-`]),s=a.map((e,t)=>Math.max(_s(e),...o.map(e=>_s(e[t])))),c=a.map((e,t)=>n(W(e,s[t]))).join(` `),l=s.map(e=>r(`โ`.repeat(e))).join(`โโ`);process.stdout.write(c+`
|
|
325
|
-
`),process.stdout.write(l+`
|
|
326
|
-
`);for(let e of o){let t=e.map((e,t)=>t===2&&e===`Yes`?i(W(e,s[t])):W(e,s[t]));process.stdout.write(t.join(` `)+`
|
|
327
|
-
`)}process.stdout.write(r(`\nTotal: ${e.length}`)+`
|
|
328
|
-
`)}var Fp,Ip,Lp=M((()=>{I(),vs(),Fp=`zeldaEasy.bailian-dash-workspace.space.listWorkspaces`,Ip=m({name:`workspace list`,description:`List all workspaces`,skipDefaultApiKeySetup:!0,usage:`bl workspace list [flags]`,options:[{flag:`--list <n>`,description:`Limit number of results`},{flag:`--console-region <region>`,description:`Console region`},{flag:`--console-site <site>`,description:`Console site: domestic, international`},{flag:`--console-switch-agent <uid>`,description:`Switch agent UID`,type:`number`}],examples:[`bl workspace list`,`bl workspace list --list 5`,`bl workspace list --output json`],async run(e,t){let n=Number(t.list)||0,r=h(e.output),i=await he(e);if(e.dryRun){P({api:Fp,data:{}},r);return}let a=Np(await d(e,i.token,{api:Fp,data:{}})).data;if(!Array.isArray(a)||a.length===0){r===`json`?P([],r):process.stdout.write(`No workspace found.
|
|
329
|
-
`);return}let o=a;if(n>0&&(o=o.slice(0,n)),r===`json`){P(o.map(e=>({workspaceId:e.workspaceId,name:e.agentName,default:e.defaultAgent})),r);return}Pp(o,e.noColor)}})}));function Rp(e,t){if(!e)return 0;let n=e.count_limit_period||t;return n?Math.floor(e.count_limit*60/n):0}function zp(e,t){if(!e)return 0;let n=e.usage_limit_period||t;return n?Math.floor(e.usage_limit*60/n):0}function Bp(e){return e.toLocaleString(`en-US`)}function Vp(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function Hp(e){let t=Vp(e,`data`);if(!t)return e;let n=Vp(t,`DataV2`);if(n){let e=Vp(n,`data`);return(e?Vp(e,`data`):void 0)??e??n}return Vp(t,`data`)??t}async function Up(e,t,n){let r=[],i=1;for(;;){let a={pageNo:i,pageSize:50,group:!1,queryQpmInfo:!0,ignoreWorkspaceServiceSite:!0};n&&(a.supports={selfServiceLimitIncrease:!0});let o=Hp(await d(e,t,{api:Gp,data:{input:a}})),s=o.list??[],c=o.total??0;if(r.push(...s),r.length>=c||s.length===0)break;i++}return r}function Wp(e,t){let n=t?e=>e:e=>`\x1b[1m${e}\x1b[0m`,r=t?e=>e:e=>`\x1b[2m${e}\x1b[0m`,i=[`Model`,`Req/min`,`Token/min`,`Max TPM`],a=e.map(e=>{let t=e.qpmInfo,n=t?.[`model-default`],r=t?.[`user-spec`],i=Rp(n),a=zp(n),o=Rp(r,n?.count_limit_period)||i,s=zp(r,n?.usage_limit_period)||a,c=a*2;return[e.model,o>0?Bp(o):`-`,s>0?Bp(s):`-`,c>0?Bp(c):`-`]});if(a.length===0){process.stdout.write(`No models found.
|
|
330
|
-
`);return}let o=i.map((e,t)=>Math.max(_s(e),...a.map(e=>_s(e[t])))),s=i.map((e,t)=>n(W(e,o[t]))).join(` `),c=o.map(e=>r(`โ`.repeat(e))).join(`โโ`);process.stdout.write(s+`
|
|
331
|
-
`),process.stdout.write(c+`
|
|
332
|
-
`);for(let e of a)process.stdout.write(e.map((e,t)=>W(e,o[t])).join(` `)+`
|
|
333
|
-
`);process.stdout.write(r(`\nTotal: ${e.length} models`)+`
|
|
334
|
-
`)}var Gp,Kp,qp=M((()=>{I(),vs(),Gp=`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,Kp=m({name:`quota list`,description:`View model RPM/TPM rate limits`,skipDefaultApiKeySetup:!0,usage:`bl quota list [--model <model>] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s), comma-separated`},{flag:`--all`,description:`Show all models, not just self-service ones`},{flag:`--console-region <region>`,description:`Console region`},{flag:`--console-site <site>`,description:`Console site: domestic, international`},{flag:`--console-switch-agent <uid>`,description:`Switch agent UID`,type:`number`}],examples:[`bl quota list`,`bl quota list --model qwen3.6-plus`,`bl quota list --model qwen3.6-plus,qwen-turbo`,`bl quota list --all`,`bl quota list --output json`],async run(e,t){let n=t.model||void 0,r=!!t.all,i=h(e.output);if(e.dryRun){let e={pageNo:1,pageSize:50,group:!1,queryQpmInfo:!0,ignoreWorkspaceServiceSite:!0};r||(e.supports={selfServiceLimitIncrease:!0}),P({api:Gp,data:{input:e}},i);return}let a=await Up(e,(await he(e)).token,!r);if(n){let e=new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean));a=a.filter(t=>e.has(t.model)),a.length===0&&(process.stderr.write(`Error: no matching models found for "${n}".\n`),process.exit(1))}if(i===`json`){P(a.map(e=>{let t=e.qpmInfo,n=t?.[`model-default`],r=t?.[`user-spec`],i=Rp(n),a=zp(n),o=Rp(r,n?.count_limit_period)||i,s=zp(r,n?.usage_limit_period)||a,c=a*2;return{model:e.model,rpm:o>0?o:null,tpm:s>0?s:null,maxTPM:c>0?c:null}}),i);return}Wp(a,e.noColor)}})}));function Jp(e,t){if(!e)return 0;let n=e.usage_limit_period||t;return n?Math.floor(e.usage_limit*60/n):0}function Yp(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function Xp(e){let t=Yp(e,`data`);if(!t)return e;let n=Yp(t,`DataV2`);if(n){let e=Yp(n,`data`);return(e?Yp(e,`data`):void 0)??e??n}return Yp(t,`data`)??t}async function Zp(e,t,n){return(Xp(await d(e,t,{api:Qp,data:{input:{pageNo:1,pageSize:50,name:n,group:!1,queryQpmInfo:!0,ignoreWorkspaceServiceSite:!0,supports:{selfServiceLimitIncrease:!0}}}})).list??[]).find(e=>e.model===n&&e.qpmInfo)}var Qp,$p,em,tm=M((()=>{I(),Qp=`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,$p=`zeldaEasy.broadscope-platform.modelInstance.updateFoundationModelLimits`,em=m({name:`quota request`,description:`Request a temporary quota increase`,skipDefaultApiKeySetup:!0,usage:`bl quota request --model <model> --tpm <value> [flags]`,options:[{flag:`--model <model>`,description:`Model name (required)`,required:!0},{flag:`--tpm <value>`,description:`Target TPM value (required)`,required:!0},{flag:`--yes`,description:`Skip downgrade confirmation`},{flag:`--console-region <region>`,description:`Console region`},{flag:`--console-site <site>`,description:`Console site: domestic, international`},{flag:`--console-switch-agent <uid>`,description:`Switch agent UID`,type:`number`}],examples:[`bl quota request --model qwen-turbo --tpm 100000`,`bl quota request --model qwen3.6-plus --tpm 8000000 --yes`,`bl quota request --model qwen-turbo --tpm 100000 --output json`],async run(e,n){let r=n.model;r||(process.stderr.write(`Error: --model is required.
|
|
335
|
-
`),process.exit(1));let i=Number(n.tpm);(!i||i<=0)&&(process.stderr.write(`Error: --tpm must be a positive number.
|
|
336
|
-
`),process.exit(1));let a=!!n.yes||e.yes,o=h(e.output);if(e.dryRun){P({api:$p,data:{input:{model:r,limit:{usage_limit:i}}}},o);return}let s=await he(e),c=await Zp(e,s.token,r);c||(process.stderr.write(`Error: model "${r}" not found or does not support self-service quota increase.\n`),process.stderr.write("Hint: run `bl quota list` to view available models.\n"),process.exit(1));let l=c.qpmInfo[`model-default`],u=c.qpmInfo[`user-spec`],f=Jp(l),p=Jp(u,l?.usage_limit_period)||f,m=f*2;(i<f||i>m)&&(process.stderr.write(`Error: TPM value ${i.toLocaleString()} is out of range.\n Current: ${p.toLocaleString()}\n Range: ${f.toLocaleString()} ~ ${m.toLocaleString()}\n`),process.exit(1));let g={input:{model:r,limit:{usage_limit:i},originalQpmInfo:c.qpmInfo}},_=async n=>{n&&(g.input.confirmedDowngrade=!0);try{return await d(e,s.token,{api:$p,data:g})}catch(e){throw e instanceof t&&e.message.includes(`NotLogined`)&&(process.stderr.write("Error: session expired. Run `bl auth login --console` to re-authenticate.\n"),process.exit(1)),e}},v=await _(),y=Xp(v);if(y.needConfirm){let e=y.confirmCode;e===`Refresh_Required`&&(process.stderr.write(`Error: rate limit has been updated externally. Please retry.
|
|
337
|
-
`),process.exit(1)),e===`Downgrade`&&(a||(process.stderr.write(`Warning: target TPM (${i.toLocaleString()}) is lower than current (${p.toLocaleString()}).\nUse --yes to confirm downgrade.
|
|
338
|
-
`),process.exit(1)),v=await _(!0))}if(o===`json`){P(v,o);return}process.stdout.write(`Quota updated for "${r}": TPM ${p.toLocaleString()} โ ${i.toLocaleString()}\n`)}})}));function nm(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function rm(e){let t=nm(e,`data`);if(!t)return e;let n=nm(t,`DataV2`);if(n){let e=nm(n,`data`);return(e?nm(e,`data`):void 0)??e??n}return nm(t,`data`)??t}function im(e){if(!e)return`-`;try{let t=new Date(e);return isNaN(t.getTime())?e:`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)} ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}catch{return e}}function am(e){return e.toLocaleString(`en-US`)}function om(e,t,n){let r=t?e=>e:e=>`\x1b[1m${e}\x1b[0m`,i=t?e=>e:e=>`\x1b[2m${e}\x1b[0m`,a=[`Model`,`Token Limit`,`Applied At`],o=e.map(e=>[e.deployedModel,am(e.usageLimit),im(e.gmtCreate)]),s=a.map((e,t)=>Math.max(_s(e),...o.map(e=>_s(e[t])))),c=a.map((e,t)=>r(W(e,s[t]))).join(` `),l=s.map(e=>i(`โ`.repeat(e))).join(`โโ`);process.stdout.write(c+`
|
|
339
|
-
`),process.stdout.write(l+`
|
|
340
|
-
`);for(let e of o)process.stdout.write(e.map((e,t)=>W(e,s[t])).join(` `)+`
|
|
341
|
-
`);process.stdout.write(i(`\nTotal: ${n} records`)+`
|
|
342
|
-
`)}var sm,cm,lm=M((()=>{I(),vs(),sm=`zeldaEasy.broadscope-platform.modelInstance.listModelLimitApplications`,cm=m({name:`quota history`,description:`View quota change history`,skipDefaultApiKeySetup:!0,usage:`bl quota history [flags]`,options:[{flag:`--page <n>`,description:`Page number (default: 1)`},{flag:`--page-size <n>`,description:`Page size (default: 10)`},{flag:`--model <model>`,description:`Filter by model name`},{flag:`--console-region <region>`,description:`Console region`},{flag:`--console-site <site>`,description:`Console site: domestic, international`},{flag:`--console-switch-agent <uid>`,description:`Switch agent UID`,type:`number`}],examples:[`bl quota history`,`bl quota history --page 2`,`bl quota history --page-size 20`,`bl quota history --model qwen-turbo`,`bl quota history --output json`],async run(e,n){let r=Number(n.page)||1,i=Number(n.pageSize)||10,a=n.model||void 0,o=h(e.output),s={input:{pageNo:r,pageSize:i}};if(e.dryRun){P({api:sm,data:s},o);return}let c=await he(e),l;try{l=await d(e,c.token,{api:sm,data:s})}catch(e){throw e instanceof t&&e.message.includes(`NotLogined`)&&(process.stderr.write("Error: session expired. Run `bl auth login --console` to re-authenticate.\n"),process.exit(1)),e}let u=rm(l),f=u.records??[],p=u.items??f.length;if(a&&(f=f.filter(e=>e.deployedModel===a)),o===`json`){P({records:f.map(e=>({model:e.deployedModel,tokenLimit:e.usageLimit,appliedAt:im(e.gmtCreate)})),total:a?f.length:p},o);return}if(f.length===0){process.stdout.write(`No quota change history found.
|
|
343
|
-
`);return}om(f,e.noColor,a?f.length:p)}})}));function um(e,t){if(!e)return 0;let n=e.count_limit_period||t;return n?Math.floor(e.count_limit*60/n):0}function dm(e,t){if(!e)return 0;let n=e.usage_limit_period||t;return n?Math.floor(e.usage_limit*60/n):0}function fm(e){return e.toLocaleString(`en-US`)}function pm(e,t){if(t<=0)return`-`;let n=Math.round(e/t*100);return`${fm(e)}/${fm(t)} (${n}%)`}function mm(e,t){if(t<=0)return`-`;let n=e/t*100;return n>=100?`Rate Limited`:n>=80?`Near limit`:`Normal`}function hm(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function gm(e){let t=hm(e,`data`);if(!t)return e;let n=hm(t,`DataV2`);if(n){let e=hm(n,`data`);return(e?hm(e,`data`):void 0)??e??n}return hm(t,`data`)??t}async function _m(e,t){let n=[],r=1;for(;;){let i=gm(await d(e,t,{api:bm,data:{input:{pageNo:r,pageSize:50,group:!1,queryQpmInfo:!0,ignoreWorkspaceServiceSite:!0,supports:{selfServiceLimitIncrease:!0}}}})),a=i.list??[],o=i.total??0;if(n.push(...a),n.length>=o||a.length===0)break;r++}return n}async function vm(e,t,n,r){let i=Date.now(),a=i-r*60*1e3;try{let r=gm(await d(e,t,{api:xm,data:{reqDTO:{monitorType:`Advanced`,metricFilters:[{aggMethod:`sum_pm`,metricName:`model_total_amount`},{aggMethod:`sum_pm`,metricName:`model_call_count`}],labelFilters:{resourceId:n,resourceType:`model`},startTime:a,endTime:i}}})),o=r.data??r;if(!Array.isArray(o))return{rpm:0,tpm:0};let s=0,c=0;for(let e of o){if(e.aggMethod!==`sum_pm`||!e.points?.length)continue;let t=e.points[e.points.length-1].value??0;e.metricName===`model_call_count`&&(s=Math.round(t)),e.metricName===`model_total_amount`&&(c=Math.round(t))}return{rpm:s,tpm:c}}catch{return{rpm:-1,tpm:-1}}}function ym(e,t){let n=t?e=>e:e=>`\x1b[1m${e}\x1b[0m`,r=t?e=>e:e=>`\x1b[2m${e}\x1b[0m`,i=t?e=>e:e=>`\x1b[32m${e}\x1b[0m`,a=t?e=>e:e=>`\x1b[33m${e}\x1b[0m`,o=t?e=>e:e=>`\x1b[31m${e}\x1b[0m`,s=[`Model`,`RPM Usage/Limit`,`TPM Usage/Limit`,`Status`],c=e.map(e=>{let t=e.rpmUsage<0?`-`:pm(e.rpmUsage,e.rpmLimit),n=e.tpmUsage<0?`-`:pm(e.tpmUsage,e.tpmLimit),r=Math.max(e.rpmLimit>0?e.rpmUsage/e.rpmLimit*100:0,e.tpmLimit>0?e.tpmUsage/e.tpmLimit*100:0),i=e.rpmUsage<0?`-`:mm(Math.max(e.rpmUsage,e.tpmUsage),Math.max(e.rpmLimit,e.tpmLimit));return{cells:[e.model,t,n,i],maxPct:r}});if(c.length===0){process.stdout.write(`No models found.
|
|
344
|
-
`);return}let l=s.map((e,t)=>Math.max(_s(e),...c.map(e=>_s(e.cells[t])))),u=s.map((e,t)=>n(W(e,l[t]))).join(` `),d=l.map(e=>r(`โ`.repeat(e))).join(`โโ`);process.stdout.write(u+`
|
|
345
|
-
`),process.stdout.write(d+`
|
|
346
|
-
`);for(let e of c){let t=e.cells.map((e,t)=>{if(t===3){if(e===`Rate Limited`)return o(W(e,l[t]));if(e===`Near limit`)return a(W(e,l[t]));if(e===`Normal`)return i(W(e,l[t]))}return W(e,l[t])});process.stdout.write(t.join(` `)+`
|
|
347
|
-
`)}process.stdout.write(r(`\nTotal: ${e.length} models`)+`
|
|
348
|
-
`)}var bm,xm,Sm,Cm=M((()=>{I(),vs(),bm=`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,xm=`zeldaEasy.bailian-telemetry.monitor.getMonitorData`,Sm=m({name:`quota check`,description:`Check current usage against rate limits`,skipDefaultApiKeySetup:!0,usage:`bl quota check [--model <model>] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s), comma-separated`},{flag:`--period <minutes>`,description:`Query usage for the last N minutes (default: 2)`},{flag:`--console-region <region>`,description:`Console region`},{flag:`--console-site <site>`,description:`Console site: domestic, international`},{flag:`--console-switch-agent <uid>`,description:`Switch agent UID`,type:`number`}],examples:[`bl quota check`,`bl quota check --model qwen3.6-plus`,`bl quota check --period 5`,`bl quota check --model qwen3.6-plus,qwen-turbo`,`bl quota check --output json`],async run(e,t){let n=t.model||void 0,r=Number(t.period)||2;r<1&&(process.stderr.write(`Error: --period must be at least 1 minute.
|
|
349
|
-
`),process.exit(1));let i=r,a=h(e.output);if(e.dryRun){P({apis:[bm,xm],...g(e)},a);return}let o=await he(e),s=await _m(e,o.token);if(n){let e=new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean));s=s.filter(t=>e.has(t.model))}if(s=s.filter(e=>e.qpmInfo),s.length===0){process.stdout.write(`No models found.
|
|
350
|
-
`);return}let c=await Promise.all(s.map(t=>vm(e,o.token,t.model,i))),l=s.map((e,t)=>{let n=e.qpmInfo,r=n[`model-default`],i=n[`user-spec`],a=um(i,r?.count_limit_period)||um(r),o=dm(i,r?.usage_limit_period)||dm(r);return{model:e.model,rpmUsage:c[t].rpm,rpmLimit:a,tpmUsage:c[t].tpm,tpmLimit:o}});if(a===`json`){P(l,a);return}ym(l,e.noColor)}})})),wm=pt({commands:()=>Tm}),Tm,Em=M((()=>{_o(),yo(),So(),wo(),Eo(),Oo(),Ao(),Mo(),Po(),Io(),Ho(),qo(),Xo(),Qo(),es(),cs(),ds(),ps(),hs(),js(),Us(),cc(),mp(),gp(),jp(),Lp(),qp(),tm(),lm(),Cm(),Tm={"auth login":Si,"auth status":ji,"auth logout":Pi,"text chat":Li,omni:Gi,"image generate":ba,"image edit":Sa,"video generate":wa,"video edit":Ea,"video ref":Oa,"video task get":Aa,"video download":Ma,"vision describe":Ra,"app call":vo,"app list":xo,"memory add":Co,"memory search":To,"memory list":Do,"memory update":ko,"memory delete":jo,"memory profile create":No,"memory profile get":Fo,"knowledge retrieve":Vo,"mcp list":Yo,"mcp tools":Zo,"mcp call":Ko,"search web":$o,"speech synthesize":ss,"speech recognize":us,"file upload":fs,"console call":ms,"usage free":As,"usage freetier":Hs,"usage stats":sc,"pipeline run":pp,"pipeline validate":hp,"config show":Ba,"config set":Ga,"config export-schema":Ja,"advisor recommend":Ap,"workspace list":Ip,"quota list":Kp,"quota request":em,"quota history":cm,"quota check":Sm,update:go}}));Em();const Dm=new class{root={children:new Map};constructor(e){for(let[t,n]of Object.entries(e))this.register(t,n)}register(e,t){let n=e.split(` `),r=this.root;for(let e of n)r.children.has(e)||r.children.set(e,{children:new Map}),r=r.children.get(e);r.command=t}getAllCommands(){let e=[],t=n=>{n.command&&e.push(n.command);for(let e of n.children.values())t(e)};return t(this.root),e}isGroupPath(e){let t=this.root;for(let n of e){let e=t.children.get(n);if(!e)return!1;t=e}return!t.command&&t.children.size>0}resolve(e){let n=this.root,r=[];for(let t of e){let e=n.children.get(t);if(!e)break;n=e,r.push(t)}if(n.command)return{command:n.command,extra:e.slice(r.length)};if(r.length>0&&n.children.size===1){let[,t]=n.children.entries().next().value;if(t.command)return{command:t.command,extra:e.slice(r.length)}}if(r.length>0&&n.children.size>0){let a=Array.from(n.children.entries()).map(([e,t])=>{if(t.command)return` ${r.join(` `)} ${e} ${t.command.description}`;let n=Array.from(t.children.keys()).join(`, `);return` ${r.join(` `)} ${e} [${n}]`}).join(`
|
|
351
|
-
`);throw new t(`Unknown command: bl ${e.join(` `)}\n\nAvailable commands:\n${a}`,i.USAGE,`bl ${r.join(` `)} --help`)}throw new t(`Unknown command: bl ${e.join(` `)}`,i.USAGE,`bl --help`)}buildResourceLines(e,t){let n=[],r=(e,t)=>{for(let[i,a]of e.children){let e=t?`${t} ${i}`:i;a.command&&n.push({path:e,desc:a.command.description}),a.children.size>0&&r(a,e)}};r(this.root,``);let i=Math.max(...n.map(e=>e.path.length));return n.map(n=>` ${e(n.path.padEnd(i+2))} ${t(n.desc)}`).join(`
|
|
352
|
-
`)}buildGlobalFlagLines(e,t){let n=Math.max(...a.map(e=>e.flag.length));return a.map(r=>` ${e(r.flag.padEnd(n+2))} ${t(r.description)}`).join(`
|
|
353
|
-
`)}bold=(e,t)=>t.isTTY?`\x1b[1m${e}\x1b[0m`:e;accent=(e,t)=>t.isTTY?`\x1b[38;2;59;130;246m${e}\x1b[0m`:e;dim=(e,t)=>t.isTTY?`\x1b[2m${e}\x1b[0m`:e;printHelp(e,t=process.stdout){if(e.length===0){this.printRootHelp(t);return}let n=this.root;for(let r of e){let e=n.children.get(r);if(!e){this.printRootHelp(t);return}n=e}if(n.command){this.printCommandHelp(n.command,t);return}let r=e.join(` `);t.write(`\n${this.bold(`Usage:`,t)} bl ${r} <command> [flags]\n\n`),t.write(`${this.bold(`Commands:`,t)}\n`),this.printChildren(n,r,t),r===`pipeline`&&this.printPipelineQuickStart(t),t.write(`
|
|
354
|
-
`)}printPipelineQuickStart(e){let t=t=>this.bold(t,e),n=t=>this.dim(t,e);e.write(`
|
|
355
|
-
${t(`Minimal workflow.yaml:`)}
|
|
356
|
-
${n(` version: workflow/v1`)}
|
|
357
|
-
${n(` steps:`)}
|
|
358
|
-
${n(` - id: chat`)}
|
|
359
|
-
${n(` type: text/chat`)}
|
|
360
|
-
${n(` input:`)}
|
|
361
|
-
${n(` message: "Who are you?"`)}
|
|
362
|
-
${n(` system: "You are a concise assistant."`)}
|
|
363
|
-
|
|
364
|
-
${t(`Try it:`)}
|
|
365
|
-
${n(` bl pipeline validate workflow.yaml`)}
|
|
366
|
-
${n(` bl pipeline run workflow.yaml --dry-run --output json`)}
|
|
367
|
-
`)}printRootHelp(e){let t=[`โโโโโโโ โโโโโโ โโโโโโ โโโ โโโโโโ โโโโ โโโ`,`โโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโ`,`โโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โโโ`,`โโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโ`,`โโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโ โโโโโโ`,`โโโโโโโ โโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโ โโโโโ`];e.write(`
|
|
368
|
-
`);for(let n of t)e.isTTY?e.write(`[38;2;97;92;237m${n}[0m\n`):e.write(n+`
|
|
369
|
-
`);let n=t=>this.bold(t,e),r=t=>this.accent(t,e),i=t=>this.dim(t,e),a=this.buildResourceLines(r,i),o=this.buildGlobalFlagLines(r,i);e.write(`
|
|
370
|
-
${n(`Usage:`)} bl <resource> <command> [flags]
|
|
371
|
-
|
|
372
|
-
${n(`Commands:`)}
|
|
373
|
-
${a}
|
|
374
|
-
|
|
375
|
-
${n(`Global Flags:`)}
|
|
376
|
-
${o}
|
|
377
|
-
|
|
378
|
-
${n(`Getting Help:`)}
|
|
379
|
-
${i(`Add --help after any command to see its full list of options, defaults,`)}
|
|
380
|
-
${i(`and usage examples. For example:`)} bl text chat --help
|
|
381
|
-
`)}printCommandHelp(e,t){let n=e=>this.bold(e,t),r=e=>this.accent(e,t),i=e=>this.dim(e,t);if(t.write(`\n${e.description}\n`),e.usage&&t.write(`${n(`Usage:`)} ${e.usage}\n`),e.options&&e.options.length>0){let a=Math.max(...e.options.map(e=>e.flag.length));t.write(`\n${n(`Options:`)}\n`);for(let n of e.options)t.write(` ${r(n.flag.padEnd(a+2))} ${i(n.description)}\n`)}if(e.notes&&e.notes.length>0){t.write(`\n${n(`Notes:`)}\n`);for(let n of e.notes)t.write(` ${n}\n`)}if(e.examples&&e.examples.length>0){t.write(`\n${n(`Examples:`)}\n`);for(let n of e.examples)t.write(` ${i(n)}\n`)}t.write(`\n${i(`Global flags (--api-key, --output, --quiet, etc.) are always available.`)}\n`),t.write(`${i(`Run`)} bl --help ${i(`for the full list.`)}\n`)}printChildren(e,t,n){let r=[],i=(e,t)=>{for(let[n,a]of e.children)a.command&&r.push({fullName:`${t} ${n}`,description:a.command.description}),a.children.size>0&&i(a,`${t} ${n}`)};i(e,t);let a=Math.max(...r.map(e=>e.fullName.length));for(let{fullName:e,description:t}of r)n.write(` ${this.accent(e.padEnd(a),n)} ${this.dim(t,n)}\n`)}}(Tm);function Om(e,...t){for(let n of t){let t=e[n]?.trim();if(t)return t}}function km(e=process.env){return{httpProxy:Om(e,`http_proxy`,`HTTP_PROXY`),httpsProxy:Om(e,`https_proxy`,`HTTPS_PROXY`),noProxy:Om(e,`no_proxy`,`NO_PROXY`)}}function Am(){let{httpProxy:e,httpsProxy:n,noProxy:r}=km();if(!(!e&&!n))try{at(new it({httpProxy:e,httpsProxy:n,noProxy:r}))}catch(e){throw new t(`Invalid proxy configuration: ${e instanceof Error?e.message:String(e)}`,i.USAGE,`Check HTTP_PROXY / HTTPS_PROXY values, e.g. export HTTPS_PROXY=http://127.0.0.1:7890`,{cause:e})}}Ot();const jm=`If the DashScope host is wrong, check baseUrl (--base-url, bl config show, or DASHSCOPE_BASE_URL).`;function Mm(e){return e.padEnd(13)}function Nm(e){return e.split(`
|
|
382
|
-
`).map((e,t)=>t===0?e:` `.repeat(13)+e).join(`
|
|
383
|
-
`)}function Pm(e){return e.exitCode===i.AUTH?e.message===n||e.hint?.includes(`auth login --console`)?e.hint:[e.hint,``,`bl auth login --api-key <your-key>`,`bl auth status`,`Get API Key: ${Et}`].filter(e=>e!==void 0).join(`
|
|
384
|
-
`):e.hint}function Fm(e=process.argv.slice(2),t=process.env.DASHSCOPE_OUTPUT){for(let n=0;n<e.length;n++){let r=e[n];if(r===`--output`)return h(e[n+1]||t);if(r?.startsWith(`--output=`))return h(r.slice(9))}return h(t)}function Im(e){let n=e.cause,r=n?.code,a=n?.message,o=[];return r&&o.push(r),a&&a!==r&&o.push(a),new t(`Network request failed: ${o.length>0?o.join(`: `):`unknown cause`}`,i.NETWORK,Lm(r),{cause:e})}function Lm(e){switch(e){case`ENOTFOUND`:case`EAI_AGAIN`:return`DNS resolution failed. Check DNS / network. ${jm}`;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.
|
|
385
|
-
If you are behind a VPN or corporate proxy, route bl through it:
|
|
386
|
-
export HTTPS_PROXY=http://127.0.0.1:<proxy-port>`;case`ETIMEDOUT`:return`Connection timed out. Check your network. ${jm}`;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). ${jm}`}}function Rm(e){let n=e.code,r=`Check the file path and permissions.`;return n===`ENOENT`?r=`File or directory not found.`:n===`EACCES`||n===`EPERM`?r=`Permission denied โ check file or directory permissions.`:n===`ENOSPC`&&(r=`Disk full โ free up space and try again.`),new t(`File system error: ${e.message}`,i.GENERAL,r,{cause:e})}function zm(e){let t=e.cause,n=0;for(;t instanceof Error&&n<5;)process.stderr.write(`${Mm(`Caused by:`)}${t.message}\n`),t=t.cause,n++}function Bm(e){process.stderr.write(`\n${Mm(`Error:`)}${e.message}\n`);let t=Pm(e);t&&process.stderr.write(`${Mm(`Hint:`)}${Nm(t)}\n`);let n=e.api;if(n){if(n.httpStatus!==void 0){let e=n.apiCode?` (${n.apiCode})`:``;process.stderr.write(`${Mm(`Status:`)}HTTP ${n.httpStatus}${e}\n`)}else n.apiCode&&process.stderr.write(`${Mm(`Code:`)}${n.apiCode}\n`);n.requestId&&process.stderr.write(`${Mm(`Request ID:`)}${n.requestId}\n`)}zm(e),process.stderr.write(`${Mm(`Exit code:`)}${e.exitCode}\n`)}function Vm(e){if(e instanceof t&&(Fm()===`json`?process.stderr.write(JSON.stringify(e.toJSON(),null,2)+`
|
|
387
|
-
`):Bm(e),process.exit(e.exitCode)),e instanceof Error){if(e.name===`AbortError`||e.name===`TimeoutError`||e.message.includes(`timed out`))return Vm(new t(`Request timed out.`,i.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
|
|
388
|
-
${jm}\nRun: bl auth status โ to check credentials.`,{cause:e}));if(e instanceof TypeError&&e.message===`fetch failed`)return Vm(Im(e));let n=e.code;if(typeof n==`string`&&n.startsWith(`E`))return Vm(Rm(e));process.stderr.write(`\n${Mm(`Error:`)}${e.message}\n`),zm(e),process.env.DASHSCOPE_VERBOSE===`1`&&process.stderr.write(`${e.stack}\n`)}else process.stderr.write(`\n${Mm(`Error:`)}${String(e)}\n`);process.exit(i.GENERAL)}const Hm=`\x1B[0m`,Um=`\x1B[2m`;function Wm(e){return e.startsWith(ot())?e.replace(ot(),`~`):e}function Gm(e,t,n){if(e.quiet||!process.stderr.isTTY)return;let r=e.configPath?Wm(e.configPath):`~/.bailian/config.json`,i=n?`${n.source} ยท ${n.method}`:e.apiKey?`flag ยท api-key`:`config`,a=O(t);process.stderr.write(`[1m[38;2;43;82;255mBAILIAN${Hm} ${Um}${r}${Hm} ${Um}|${Hm} ${Um}Auth:${Hm} [38;2;236;72;153m${a}${Hm} ${Um}${i}${Hm}\n`)}Wo(),fo(),Nt(),Qa(),Bt();try{Am()}catch(e){Vm(e)}It((e,t)=>{Dm.printHelp(e,t)}),process.on(`SIGINT`,()=>{process.stderr.write(`
|
|
389
|
-
Interrupted. Exiting.
|
|
390
|
-
`),v(500).finally(()=>process.exit(130))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e});async function Km(){let e=process.argv.slice(2);e[0]===`--`&&(e=e.slice(1)),(e.includes(`--version`)||e.includes(`-v`))&&(process.stdout.write(`bl ${Za}\n`),process.exit(0));let t=St(e,a);if((e.includes(`--help`)||e.includes(`-h`))&&(Dm.printHelp(t,process.stderr),process.exit(0)),t.length===0){Dm.printHelp([],process.stderr);let t=ne(Ct(e,a));t.clientName=`bailian-cli`,t.clientVersion=Za,t.apiKey||t.fileApiKey||t.fileAccessToken||t.accessTokenEnv?jt():At(),process.exit(0)}Dm.isGroupPath(t)&&(Dm.printHelp(t,process.stderr),process.exit(0));let{command:n,extra:r}=Dm.resolve(t),i=Ct(e,[...a,...n.options??[]]);r.length>0&&(i._positional=r);let o=ne(i);if(o.clientName=`bailian-cli`,o.clientVersion=Za,!n.skipDefaultApiKeySetup){await Uo(o);try{let e=await A(o);Gm(o,e.token,e)}catch{}}let s=io(Za).catch(()=>{});Pt(t),t[0]===`auth`&&t[1]===`login`&&!i.console&&!String(i.apiKey??``).trim()&&!String(o.apiKey??``).trim()&&!process.env.DASHSCOPE_API_KEY?.trim()&&(Lt(process.stderr),process.exit(0)),await Ce(o,t,i,()=>n.execute(o,i)),await s;let c=t.length===1&&t[0]===`update`,l=ro();if(l&&!o.quiet&&!c){let e=process.stderr.isTTY,t=e?`\x1B[33m`:``,n=e?`\x1B[36m`:``,r=e?`\x1B[0m`:``;process.stderr.write(`\n ${t}Update available: ${Za} โ ${l}${r}\n`),process.stderr.write(` Run ${n}bl update${r} to upgrade\n\n`)}await v(1e3)}Km().catch(e=>{v(1e3).finally(()=>Vm(e))});export{};
|
|
3
|
+
import{createCli as e}from"bailian-cli-runtime";import{advisorRecommend as t,appCall as n,appList as r,authLogin as i,authLogout as a,authStatus as o,configSet as s,configShow as c,consoleCall as l,datasetDelete as u,datasetGet as d,datasetList as f,datasetUpload as p,datasetValidate as m,deployCreate as h,deployDelete as g,deployGet as _,deployList as v,deployModels as y,deployScale as b,deployUpdate as x,fileUpload as S,finetuneCancel as C,finetuneCapability as w,finetuneCheckpoints as T,finetuneCreate as E,finetuneDelete as D,finetuneExport as O,finetuneGet as k,finetuneList as A,finetuneLogs as j,finetuneWatch as M,imageEdit as N,imageGenerate as P,knowledgeRetrieve as F,mcpCall as I,mcpList as L,mcpTools as R,memoryAdd as z,memoryDelete as B,memoryList as V,memoryProfileCreate as H,memoryProfileGet as U,memorySearch as W,memoryUpdate as G,pipelineRun as K,pipelineValidate as q,quotaCheck as J,quotaHistory as Y,quotaList as X,quotaRequest as Z,searchWeb as Q,speechRecognize as $,speechSynthesize as ee,textChat as te,textOmni as ne,tokenPlanAddMember as re,tokenPlanAssignSeats as ie,tokenPlanCreateKey as ae,tokenPlanListSeats as oe,update as se,usageFree as ce,usageFreetier as le,usageStats as ue,videoDownload as de,videoEdit as fe,videoGenerate as pe,videoRef as me,videoTaskGet as he,visionDescribe as ge,workspaceList as _e}from"bailian-cli-commands";e({"auth login":i,"auth status":o,"auth logout":a,"text chat":te,omni:ne,"image generate":P,"image edit":N,"video generate":pe,"video edit":fe,"video ref":me,"video task get":he,"video download":de,"vision describe":ge,"config show":c,"config set":s,update:se,"app call":n,"app list":r,"memory add":z,"memory search":W,"memory list":V,"memory update":G,"memory delete":B,"memory profile create":H,"memory profile get":U,"knowledge retrieve":F,"mcp call":I,"mcp list":L,"mcp tools":R,"search web":Q,"speech synthesize":ee,"speech recognize":$,"file upload":S,"console call":l,"usage free":ce,"usage freetier":le,"usage stats":ue,"pipeline run":K,"pipeline validate":q,"advisor recommend":t,"workspace list":_e,"quota list":X,"quota request":Z,"quota history":Y,"quota check":J,"dataset upload":p,"dataset list":f,"dataset get":d,"dataset delete":u,"dataset validate":m,"finetune create":E,"finetune list":A,"finetune get":k,"finetune cancel":C,"finetune delete":D,"finetune logs":j,"finetune checkpoints":T,"finetune export":O,"finetune watch":M,"finetune capability":w,"deploy create":h,"deploy list":v,"deploy get":_,"deploy models":y,"deploy scale":b,"deploy update":x,"deploy delete":g,"token-plan list-seats":oe,"token-plan create-key":ae,"token-plan assign-seats":ie,"token-plan add-member":re},{binName:`bl`,version:`1.5.0`,clientName:`bailian-cli`,npmPackage:`bailian-cli`}).run();export{};
|