micro-contracts 0.17.7 → 0.17.8

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.
@@ -213,7 +213,7 @@ Expecting `+k.join(", ")+", got '"+(this.terminals_[S]||S)+"'":j="Parse error on
213
213
  return undefined
214
214
  }
215
215
  `.trim()},blockValue:function(t){var r=this.aliasable("container.hooks.blockHelperMissing"),i=[this.contextName(0)];this.setupHelperArgs(t,0,i);var n=this.popStack();i.splice(1,0,n),this.push(this.source.functionCall(r,"call",i))},ambiguousBlockValue:function(){var t=this.aliasable("container.hooks.blockHelperMissing"),r=[this.contextName(0)];this.setupHelperArgs("",0,r,!0),this.flushInline();var i=this.topStack();r.splice(1,0,i),this.pushSource(["if (!",this.lastHelper,") { ",i," = ",this.source.functionCall(t,"call",r),"}"])},appendContent:function(t){this.pendingContent?t=this.pendingContent+t:this.pendingLocation=this.source.currentLocation,this.pendingContent=t},append:function(){if(this.isInline())this.replaceStack(function(r){return[" != null ? ",r,' : ""']}),this.pushSource(this.appendToBuffer(this.popStack()));else{var t=this.popStack();this.pushSource(["if (",t," != null) { ",this.appendToBuffer(t,void 0,!0)," }"]),this.environment.isSimple&&this.pushSource(["else { ",this.appendToBuffer("''",void 0,!0)," }"])}},appendEscaped:function(){this.pushSource(this.appendToBuffer([this.aliasable("container.escapeExpression"),"(",this.popStack(),")"]))},getContext:function(t){this.lastContext=t},pushContext:function(){this.pushStackLiteral(this.contextName(this.lastContext))},lookupOnContext:function(t,r,i,n){var a=0;!n&&this.options.compat&&!this.lastContext?this.push(this.depthedLookup(t[a++])):this.pushContext(),this.resolvePath("context",t,a,r,i)},lookupBlockParam:function(t,r){this.useBlockParams=!0,this.push(["blockParams[",t[0],"][",t[1],"]"]),this.resolvePath("context",r,1)},lookupData:function(t,r,i){t?this.pushStackLiteral("container.data(data, "+t+")"):this.pushStackLiteral("data"),this.resolvePath("data",r,0,!0,i)},resolvePath:function(t,r,i,n,a){var o=this;if(this.options.strict||this.options.assumeObjects){this.push(l4e(this.options.strict&&a,this,r,i,t));return}for(var s=r.length,u=function(c){o.replaceStack(function(d){var p=o.nameLookup(d,r[c],t);return n?[" && ",p]:[" != null ? ",p," : ",d]})},l=i;l<s;l++)u(l)},resolvePossibleLambda:function(){this.push([this.aliasable("container.lambda"),"(",this.popStack(),", ",this.contextName(0),")"])},pushStringParam:function(t,r){this.pushContext(),this.pushString(r),r!=="SubExpression"&&(typeof t=="string"?this.pushString(t):this.pushStackLiteral(t))},emptyHash:function(t){this.trackIds&&this.push("{}"),this.stringParams&&(this.push("{}"),this.push("{}")),this.pushStackLiteral(t?"undefined":"{}")},pushHash:function(){this.hash&&this.hashes.push(this.hash),this.hash={values:{},types:[],contexts:[],ids:[]}},popHash:function(){var t=this.hash;this.hash=this.hashes.pop(),this.trackIds&&this.push(this.objectLiteral(t.ids)),this.stringParams&&(this.push(this.objectLiteral(t.contexts)),this.push(this.objectLiteral(t.types))),this.push(this.objectLiteral(t.values))},pushString:function(t){this.pushStackLiteral(this.quotedString(t))},pushLiteral:function(t){this.pushStackLiteral(t)},pushProgram:function(t){t!=null?this.pushStackLiteral(this.programExpression(t)):this.pushStackLiteral(null)},registerDecorator:function(t,r){var i=this.nameLookup("decorators",r,"decorator"),n=this.setupHelperArgs(r,t);this.decorators.push(["var decorator = ",i,";"]),this.decorators.push(['if (typeof decorator !== "function") { throw new Error(',this.quotedString('Missing decorator: "'+r+'"'),"); }"]),this.decorators.push(["fn = ",this.decorators.functionCall("decorator","",["fn","props","container",n])," || fn;"])},invokeHelper:function(t,r,i){var n=this.popStack(),a=this.setupHelper(t,r),o=[];i&&o.push(a.name),o.push(n),this.options.strict||o.push(this.aliasable("container.hooks.helperMissing"));var s=["(",this.itemsSeparatedBy(o,"||"),")"],u=this.source.functionCall(s,"call",a.callParams);this.push(u)},itemsSeparatedBy:function(t,r){var i=[];i.push(t[0]);for(var n=1;n<t.length;n++)i.push(r,t[n]);return i},invokeKnownHelper:function(t,r){var i=this.setupHelper(t,r);this.push(this.source.functionCall(i.name,"call",i.callParams))},invokeAmbiguous:function(t,r){this.useRegister("helper");var i=this.popStack();this.emptyHash();var n=this.setupHelper(0,t,r),a=this.lastHelper=this.nameLookup("helpers",t,"helper"),o=["(","(helper = ",a," || ",i,")"];this.options.strict||(o[0]="(helper = ",o.push(" != null ? helper : ",this.aliasable("container.hooks.helperMissing"))),this.push(["(",o,n.paramsInit?["),(",n.paramsInit]:[],"),","(typeof helper === ",this.aliasable('"function"')," ? ",this.source.functionCall("helper","call",n.callParams)," : helper))"])},invokePartial:function(t,r,i){var n=[],a=this.setupParams(r,1,n);t&&(r=this.popStack(),delete a.name),i&&(a.indent=JSON.stringify(i)),a.helpers="helpers",a.partials="partials",a.decorators="container.decorators",t?n.unshift(r):n.unshift(this.nameLookup("partials",r,"partial")),this.options.compat&&(a.depths="depths"),a=this.objectLiteral(a),n.push(a),this.push(this.source.functionCall("container.invokePartial","",n))},assignToHash:function(t){var r=this.popStack(),i=void 0,n=void 0,a=void 0;this.trackIds&&(a=this.popStack()),this.stringParams&&(n=this.popStack(),i=this.popStack());var o=this.hash;i&&(o.contexts[t]=i),n&&(o.types[t]=n),a&&(o.ids[t]=a),o.values[t]=r},pushId:function(t,r,i){t==="BlockParam"?this.pushStackLiteral("blockParams["+r[0]+"].path["+r[1]+"]"+(i?" + "+JSON.stringify("."+i):"")):t==="PathExpression"?this.pushString(r):t==="SubExpression"?this.pushStackLiteral("true"):this.pushStackLiteral("null")},compiler:Tc,compileChildren:function(t,r){for(var i=t.children,n=void 0,a=void 0,o=0,s=i.length;o<s;o++){n=i[o],a=new this.compiler;var u=this.matchExistingProgram(n);if(u==null){var l=this.context.programs.push("")-1;n.index=l,n.name="program"+l,this.context.programs[l]=a.compile(n,r,this.context,!this.precompile),this.context.decorators[l]=a.decorators,this.context.environments[l]=n,this.useDepths=this.useDepths||a.useDepths,this.useBlockParams=this.useBlockParams||a.useBlockParams,n.useDepths=this.useDepths,n.useBlockParams=this.useBlockParams}else n.index=u.index,n.name="program"+u.index,this.useDepths=this.useDepths||u.useDepths,this.useBlockParams=this.useBlockParams||u.useBlockParams}},matchExistingProgram:function(t){for(var r=0,i=this.context.environments.length;r<i;r++){var n=this.context.environments[r];if(n&&n.equals(t))return n}},programExpression:function(t){var r=this.environment.children[t],i=[r.index,"data",r.blockParams];return(this.useBlockParams||this.useDepths)&&i.push("blockParams"),this.useDepths&&i.push("depths"),"container.program("+i.join(", ")+")"},useRegister:function(t){this.registers[t]||(this.registers[t]=!0,this.registers.list.push(t))},push:function(t){return t instanceof jc||(t=this.source.wrap(t)),this.inlineStack.push(t),t},pushStackLiteral:function(t){this.push(new jc(t))},pushSource:function(t){this.pendingContent&&(this.source.push(this.appendToBuffer(this.source.quotedString(this.pendingContent),this.pendingLocation)),this.pendingContent=void 0),t&&this.source.push(t)},replaceStack:function(t){var r=["("],i=void 0,n=void 0,a=void 0;if(!this.isInline())throw new Jb.default("replaceStack on non-inline");var o=this.popStack(!0);if(o instanceof jc)i=[o.value],r=["(",i],a=!0;else{n=!0;var s=this.incrStack();r=["((",this.push(s)," = ",o,")"],i=this.topStack()}var u=t.call(this,i);a||this.popStack(),n&&this.stackSlot--,this.push(r.concat(u,")"))},incrStack:function(){return this.stackSlot++,this.stackSlot>this.stackVars.length&&this.stackVars.push("stack"+this.stackSlot),this.topStackName()},topStackName:function(){return"stack"+this.stackSlot},flushInline:function(){var t=this.inlineStack;this.inlineStack=[];for(var r=0,i=t.length;r<i;r++){var n=t[r];if(n instanceof jc)this.compileStack.push(n);else{var a=this.incrStack();this.pushSource([a," = ",n,";"]),this.compileStack.push(a)}}},isInline:function(){return this.inlineStack.length},popStack:function(t){var r=this.isInline(),i=(r?this.inlineStack:this.compileStack).pop();if(!t&&i instanceof jc)return i.value;if(!r){if(!this.stackSlot)throw new Jb.default("Invalid stack pop");this.stackSlot--}return i},topStack:function(){var t=this.isInline()?this.inlineStack:this.compileStack,r=t[t.length-1];return r instanceof jc?r.value:r},contextName:function(t){return this.useDepths&&t?"depths["+t+"]":"depth"+t},quotedString:function(t){return this.source.quotedString(t)},objectLiteral:function(t){return this.source.objectLiteral(t)},aliasable:function(t){var r=this.aliases[t];return r?(r.referenceCount++,r):(r=this.aliases[t]=this.source.wrap(t),r.aliasable=!0,r.referenceCount=1,r)},setupHelper:function(t,r,i){var n=[],a=this.setupHelperArgs(r,t,n,i),o=this.nameLookup("helpers",r,"helper"),s=this.aliasable(this.contextName(0)+" != null ? "+this.contextName(0)+" : (container.nullContext || {})");return{params:n,paramsInit:a,name:o,callParams:[s].concat(n)}},setupParams:function(t,r,i){var n={},a=[],o=[],s=[],u=!i,l=void 0;u&&(i=[]),n.name=this.quotedString(t),n.hash=this.popStack(),this.trackIds&&(n.hashIds=this.popStack()),this.stringParams&&(n.hashTypes=this.popStack(),n.hashContexts=this.popStack());var c=this.popStack(),d=this.popStack();(d||c)&&(n.fn=d||"container.noop",n.inverse=c||"container.noop");for(var p=r;p--;)l=this.popStack(),i[p]=l,this.trackIds&&(s[p]=this.popStack()),this.stringParams&&(o[p]=this.popStack(),a[p]=this.popStack());return u&&(n.args=this.source.generateArray(i)),this.trackIds&&(n.ids=this.source.generateArray(s)),this.stringParams&&(n.types=this.source.generateArray(o),n.contexts=this.source.generateArray(a)),this.options.data&&(n.data="data"),this.useBlockParams&&(n.blockParams="blockParams"),n},setupHelperArgs:function(t,r,i,n){var a=this.setupParams(t,r,i);return a.loc=JSON.stringify(this.source.currentLocation),a=this.objectLiteral(a),n?(this.useRegister("options"),i.push("options"),["options=",a]):i?(i.push(a),""):a}};(function(){for(var e="break else new var case finally return void catch for switch while continue function this with default if throw delete in try do instanceof typeof abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws const goto private transient debugger implements protected volatile double import public let yield await null true false".split(" "),t=Tc.RESERVED_WORDS={},r=0,i=e.length;r<i;r++)t[e[r]]=!0})();Tc.isValidJavaScriptVariableName=function(e){return!Tc.RESERVED_WORDS[e]&&/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(e)};function l4e(e,t,r,i,n){var a=t.popStack(),o=r.length;e&&o--;for(var s=i;s<o;s++)a=t.nameLookup(a,r[s],n);return e?[t.aliasable("container.strict"),"(",a,", ",t.quotedString(r[o]),", ",JSON.stringify(t.source.currentLocation)," )"]:a}Dg.default=Tc;WR.exports=Dg.default});var YR=He((Og,JR)=>{"use strict";Og.__esModule=!0;function Sf(e){return e&&e.__esModule?e:{default:e}}var c4e=QN(),d4e=Sf(c4e),p4e=xb(),f4e=Sf(p4e),Yb=dR(),Xb=hR(),m4e=KR(),h4e=Sf(m4e),g4e=bg(),v4e=Sf(g4e),y4e=wb(),_4e=Sf(y4e),b4e=d4e.default.create;function HR(){var e=b4e();return e.compile=function(t,r){return Xb.compile(t,r,e)},e.precompile=function(t,r){return Xb.precompile(t,r,e)},e.AST=f4e.default,e.Compiler=Xb.Compiler,e.JavaScriptCompiler=h4e.default,e.Parser=Yb.parser,e.parse=Yb.parse,e.parseWithoutProcessing=Yb.parseWithoutProcessing,e}var Nc=HR();Nc.create=HR;_4e.default(Nc);Nc.Visitor=v4e.default;Nc.default=Nc;Og.default=Nc;JR.exports=Og.default});var XR=He(Pg=>{"use strict";Pg.__esModule=!0;Pg.print=$4e;Pg.PrintVisitor=tn;function w4e(e){return e&&e.__esModule?e:{default:e}}var S4e=bg(),E4e=w4e(S4e);function $4e(e){return new tn().accept(e)}function tn(){this.padding=0}tn.prototype=new E4e.default;tn.prototype.pad=function(e){for(var t="",r=0,i=this.padding;r<i;r++)t+=" ";return t+=e+`
216
- `,t};tn.prototype.Program=function(e){var t="",r=e.body,i=void 0,n=void 0;if(e.blockParams){var a="BLOCK PARAMS: [";for(i=0,n=e.blockParams.length;i<n;i++)a+=" "+e.blockParams[i];a+=" ]",t+=this.pad(a)}for(i=0,n=r.length;i<n;i++)t+=this.accept(r[i]);return this.padding--,t};tn.prototype.MustacheStatement=function(e){return this.pad("{{ "+this.SubExpression(e)+" }}")};tn.prototype.Decorator=function(e){return this.pad("{{ DIRECTIVE "+this.SubExpression(e)+" }}")};tn.prototype.BlockStatement=tn.prototype.DecoratorBlock=function(e){var t="";return t+=this.pad((e.type==="DecoratorBlock"?"DIRECTIVE ":"")+"BLOCK:"),this.padding++,t+=this.pad(this.SubExpression(e)),e.program&&(t+=this.pad("PROGRAM:"),this.padding++,t+=this.accept(e.program),this.padding--),e.inverse&&(e.program&&this.padding++,t+=this.pad("{{^}}"),this.padding++,t+=this.accept(e.inverse),this.padding--,e.program&&this.padding--),this.padding--,t};tn.prototype.PartialStatement=function(e){var t="PARTIAL:"+e.name.original;return e.params[0]&&(t+=" "+this.accept(e.params[0])),e.hash&&(t+=" "+this.accept(e.hash)),this.pad("{{> "+t+" }}")};tn.prototype.PartialBlockStatement=function(e){var t="PARTIAL BLOCK:"+e.name.original;return e.params[0]&&(t+=" "+this.accept(e.params[0])),e.hash&&(t+=" "+this.accept(e.hash)),t+=" "+this.pad("PROGRAM:"),this.padding++,t+=this.accept(e.program),this.padding--,this.pad("{{> "+t+" }}")};tn.prototype.ContentStatement=function(e){return this.pad("CONTENT[ '"+e.value+"' ]")};tn.prototype.CommentStatement=function(e){return this.pad("{{! '"+e.value+"' }}")};tn.prototype.SubExpression=function(e){for(var t=e.params,r=[],i=void 0,n=0,a=t.length;n<a;n++)r.push(this.accept(t[n]));return t="["+r.join(", ")+"]",i=e.hash?" "+this.accept(e.hash):"",this.accept(e.path)+" "+t+i};tn.prototype.PathExpression=function(e){var t=e.parts.join("/");return(e.data?"@":"")+"PATH:"+t};tn.prototype.StringLiteral=function(e){return'"'+e.value+'"'};tn.prototype.NumberLiteral=function(e){return"NUMBER{"+e.value+"}"};tn.prototype.BooleanLiteral=function(e){return"BOOLEAN{"+e.value+"}"};tn.prototype.UndefinedLiteral=function(){return"UNDEFINED"};tn.prototype.NullLiteral=function(){return"NULL"};tn.prototype.Hash=function(e){for(var t=e.pairs,r=[],i=0,n=t.length;i<n;i++)r.push(this.accept(t[i]));return"HASH{"+r.join(", ")+"}"};tn.prototype.HashPair=function(e){return e.key+"="+this.accept(e.value)}});var Qb=He((UBe,tB)=>{var Ig=YR().default,eB=XR();Ig.PrintVisitor=eB.PrintVisitor;Ig.print=eB.print;tB.exports=Ig;function QR(e,t){var r=pi("fs"),i=r.readFileSync(t,"utf8");e.exports=Ig.compile(i)}typeof pi<"u"&&pi.extensions&&(pi.extensions[".handlebars"]=QR,pi.extensions[".hbs"]=QR)});function rs(e,t={}){let r=[],i=[];for(let[a,o]of Object.entries(e.paths))for(let s of["get","post","put","patch","delete"]){let u=o[s];if(!u)continue;let l=`${s.toUpperCase()} ${a}`;if(t.screen||(u["x-micro-contracts-service"]||i.push({type:"warning",code:"MISSING_X_SERVICE",message:"Missing x-micro-contracts-service extension",path:a,location:l}),u["x-micro-contracts-method"]||i.push({type:"warning",code:"MISSING_X_METHOD",message:"Missing x-micro-contracts-method extension",path:a,location:l})),u["x-screen-id"]&&(u["x-screen-const"]||r.push({type:"error",code:"SCREEN_MISSING_CONST",message:"Operation has x-screen-id but missing x-screen-const",path:a,location:l}),u["x-screen-name"]||r.push({type:"error",code:"SCREEN_MISSING_NAME",message:"Operation has x-screen-id but missing x-screen-name",path:a,location:l}),u.operationId||r.push({type:"error",code:"SCREEN_MISSING_OPERATION_ID",message:"Screen operation requires operationId",path:a,location:l})),u["x-events"]){i.push({type:"warning",code:"SCREEN_DEPRECATED_X_EVENTS",message:"x-events (flat list) is deprecated. Use inline x-event instead.",path:a,location:l});let c=u["x-events"];if(!Array.isArray(c))r.push({type:"error",code:"SCREEN_INVALID_EVENTS",message:"x-events must be an array",path:a,location:l});else for(let d=0;d<c.length;d++){let p=c[d];(!p.name||!p.type)&&r.push({type:"error",code:"SCREEN_INVALID_EVENT",message:`x-events[${d}] must have name and type`,path:a,location:l})}}if(u["x-events"]&&u["x-event"]!=null&&r.push({type:"error",code:"SCREEN_CONFLICTING_EVENT_DEFS",message:"x-events and x-event cannot coexist on the same operation",path:a,location:l}),u["x-event"]!=null&&t9(u["x-event"],a,l,r),s==="get"){let c=u.responses?.["200"];if(c&&!Kt(c)){let d=c.links;if(d)for(let[p,f]of Object.entries(d))f["x-event"]!=null&&t9(f["x-event"],`${a}.responses.200.links.${p}`,l,r)}if(u["x-interactions"]){let d=u["x-interactions"];if(!Array.isArray(d))r.push({type:"error",code:"SCREEN_INVALID_INTERACTIONS",message:"x-interactions must be an array",path:a,location:l});else for(let p=0;p<d.length;p++)d[p].name||r.push({type:"error",code:"SCREEN_INVALID_INTERACTION",message:`x-interactions[${p}] must have a name`,path:a,location:l}),d[p]["x-event"]!=null&&t9(d[p]["x-event"],`${a}.x-interactions[${p}]`,l,r)}}if(u["x-micro-contracts-published"]===!0){let c=j4e(a,s,u,e);r.push(...c);let d=T4e(a,s,u,e);i.push(...d)}}if(e.components?.schemas)for(let[a,o]of Object.entries(e.components.schemas)){if(Kt(o))continue;let s=N4e(a,o);i.push(...s)}let n=r.length===0&&(!t.strict||i.length===0);return{errors:r,warnings:i,valid:n}}function j4e(e,t,r,i){let n=[],a=`${t.toUpperCase()} ${e}`;if(r.requestBody&&!Kt(r.requestBody)){let o=r.requestBody.content?.["application/json"];if(o?.schema&&il(o.schema,i)){let s=Kt(o.schema)?Or(o.schema.$ref):"inline schema";n.push({type:"error",code:"PUBLIC_ENDPOINT_PRIVATE_REQUEST",message:`Public endpoint references request schema "${s}" with x-private properties`,path:e,location:a})}}for(let[o,s]of Object.entries(r.responses)){if(!o.startsWith("2"))continue;let u=Kt(s)?i.components?.responses?.[Or(s.$ref)]:s;if(u?.content?.["application/json"]?.schema){let l=u.content["application/json"].schema;if(il(l,i)){let c=Kt(l)?Or(l.$ref):"inline schema";n.push({type:"error",code:"PUBLIC_ENDPOINT_PRIVATE_RESPONSE",message:`Public endpoint references response schema "${c}" with x-private properties`,path:e,location:a})}}}return n}function T4e(e,t,r,i){let n=[],a=`${t.toUpperCase()} ${e}`,o=new Set;if(r.requestBody&&!Kt(r.requestBody)){let s=r.requestBody.content?.["application/json"];s?.schema&&ru(s.schema,i,o)}for(let s of Object.values(r.responses)){let u=Kt(s)?i.components?.responses?.[Or(s.$ref)]:s;u?.content?.["application/json"]?.schema&&ru(u.content["application/json"].schema,i,o)}for(let s of o){let u=i.components?.schemas?.[s];!u||Kt(u)||(u.allOf||u.oneOf||u.anyOf)&&n.push({type:"warning",code:"PUBLIC_ENDPOINT_COMPOSITION",message:`Public endpoint uses schema "${s}" with allOf/oneOf/anyOf (may complicate compatibility)`,path:e,location:a})}return n}function N4e(e,t){let r=[];if(!t.properties||!t.required)return r;for(let i of t.required){let n=t.properties[i];n&&!Kt(n)&&n["x-private"]&&r.push({type:"warning",code:"PRIVATE_IN_REQUIRED",message:`Schema "${e}" has x-private property "${i}" in required array (cannot be used in public endpoints)`,location:`components/schemas/${e}`})}return r}function t9(e,t,r,i){if(typeof e=="string")return;if(typeof e!="object"||e===null){i.push({type:"error",code:"SCREEN_INVALID_X_EVENT",message:"x-event must be a string, object with {name}, or {$ref}",path:t,location:r});return}let n=e;!n.$ref&&!n.name&&i.push({type:"error",code:"SCREEN_INVALID_X_EVENT",message:"x-event object must have either $ref or name",path:t,location:r})}function dl(e){let t=[];if(e.errors.length>0){t.push("Errors:");for(let r of e.errors)t.push(` \u274C [${r.code}] ${r.message}`),r.location&&t.push(` at ${r.location}`);t.push("")}if(e.warnings.length>0){t.push("Warnings:");for(let r of e.warnings)t.push(` \u26A0\uFE0F [${r.code}] ${r.message}`),r.location&&t.push(` at ${r.location}`);t.push("")}return e.valid?t.push("\u2705 Lint passed"):t.push(`\u274C Lint failed with ${e.errors.length} error(s)`),t.join(`
216
+ `,t};tn.prototype.Program=function(e){var t="",r=e.body,i=void 0,n=void 0;if(e.blockParams){var a="BLOCK PARAMS: [";for(i=0,n=e.blockParams.length;i<n;i++)a+=" "+e.blockParams[i];a+=" ]",t+=this.pad(a)}for(i=0,n=r.length;i<n;i++)t+=this.accept(r[i]);return this.padding--,t};tn.prototype.MustacheStatement=function(e){return this.pad("{{ "+this.SubExpression(e)+" }}")};tn.prototype.Decorator=function(e){return this.pad("{{ DIRECTIVE "+this.SubExpression(e)+" }}")};tn.prototype.BlockStatement=tn.prototype.DecoratorBlock=function(e){var t="";return t+=this.pad((e.type==="DecoratorBlock"?"DIRECTIVE ":"")+"BLOCK:"),this.padding++,t+=this.pad(this.SubExpression(e)),e.program&&(t+=this.pad("PROGRAM:"),this.padding++,t+=this.accept(e.program),this.padding--),e.inverse&&(e.program&&this.padding++,t+=this.pad("{{^}}"),this.padding++,t+=this.accept(e.inverse),this.padding--,e.program&&this.padding--),this.padding--,t};tn.prototype.PartialStatement=function(e){var t="PARTIAL:"+e.name.original;return e.params[0]&&(t+=" "+this.accept(e.params[0])),e.hash&&(t+=" "+this.accept(e.hash)),this.pad("{{> "+t+" }}")};tn.prototype.PartialBlockStatement=function(e){var t="PARTIAL BLOCK:"+e.name.original;return e.params[0]&&(t+=" "+this.accept(e.params[0])),e.hash&&(t+=" "+this.accept(e.hash)),t+=" "+this.pad("PROGRAM:"),this.padding++,t+=this.accept(e.program),this.padding--,this.pad("{{> "+t+" }}")};tn.prototype.ContentStatement=function(e){return this.pad("CONTENT[ '"+e.value+"' ]")};tn.prototype.CommentStatement=function(e){return this.pad("{{! '"+e.value+"' }}")};tn.prototype.SubExpression=function(e){for(var t=e.params,r=[],i=void 0,n=0,a=t.length;n<a;n++)r.push(this.accept(t[n]));return t="["+r.join(", ")+"]",i=e.hash?" "+this.accept(e.hash):"",this.accept(e.path)+" "+t+i};tn.prototype.PathExpression=function(e){var t=e.parts.join("/");return(e.data?"@":"")+"PATH:"+t};tn.prototype.StringLiteral=function(e){return'"'+e.value+'"'};tn.prototype.NumberLiteral=function(e){return"NUMBER{"+e.value+"}"};tn.prototype.BooleanLiteral=function(e){return"BOOLEAN{"+e.value+"}"};tn.prototype.UndefinedLiteral=function(){return"UNDEFINED"};tn.prototype.NullLiteral=function(){return"NULL"};tn.prototype.Hash=function(e){for(var t=e.pairs,r=[],i=0,n=t.length;i<n;i++)r.push(this.accept(t[i]));return"HASH{"+r.join(", ")+"}"};tn.prototype.HashPair=function(e){return e.key+"="+this.accept(e.value)}});var Qb=He((qBe,tB)=>{var Ig=YR().default,eB=XR();Ig.PrintVisitor=eB.PrintVisitor;Ig.print=eB.print;tB.exports=Ig;function QR(e,t){var r=pi("fs"),i=r.readFileSync(t,"utf8");e.exports=Ig.compile(i)}typeof pi<"u"&&pi.extensions&&(pi.extensions[".handlebars"]=QR,pi.extensions[".hbs"]=QR)});function rs(e,t={}){let r=[],i=[];for(let[a,o]of Object.entries(e.paths))for(let s of["get","post","put","patch","delete"]){let u=o[s];if(!u)continue;let l=`${s.toUpperCase()} ${a}`;if(t.screen||(u["x-micro-contracts-service"]||i.push({type:"warning",code:"MISSING_X_SERVICE",message:"Missing x-micro-contracts-service extension",path:a,location:l}),u["x-micro-contracts-method"]||i.push({type:"warning",code:"MISSING_X_METHOD",message:"Missing x-micro-contracts-method extension",path:a,location:l})),u["x-screen-id"]&&(u["x-screen-const"]||r.push({type:"error",code:"SCREEN_MISSING_CONST",message:"Operation has x-screen-id but missing x-screen-const",path:a,location:l}),u["x-screen-name"]||r.push({type:"error",code:"SCREEN_MISSING_NAME",message:"Operation has x-screen-id but missing x-screen-name",path:a,location:l}),u.operationId||r.push({type:"error",code:"SCREEN_MISSING_OPERATION_ID",message:"Screen operation requires operationId",path:a,location:l})),u["x-events"]){i.push({type:"warning",code:"SCREEN_DEPRECATED_X_EVENTS",message:"x-events (flat list) is deprecated. Use inline x-event instead.",path:a,location:l});let c=u["x-events"];if(!Array.isArray(c))r.push({type:"error",code:"SCREEN_INVALID_EVENTS",message:"x-events must be an array",path:a,location:l});else for(let d=0;d<c.length;d++){let p=c[d];(!p.name||!p.type)&&r.push({type:"error",code:"SCREEN_INVALID_EVENT",message:`x-events[${d}] must have name and type`,path:a,location:l})}}if(u["x-events"]&&u["x-event"]!=null&&r.push({type:"error",code:"SCREEN_CONFLICTING_EVENT_DEFS",message:"x-events and x-event cannot coexist on the same operation",path:a,location:l}),u["x-event"]!=null&&t9(u["x-event"],a,l,r),s==="get"){let c=u.responses?.["200"];if(c&&!Kt(c)){let d=c.links;if(d)for(let[p,f]of Object.entries(d))f["x-event"]!=null&&t9(f["x-event"],`${a}.responses.200.links.${p}`,l,r)}if(u["x-interactions"]){let d=u["x-interactions"];if(!Array.isArray(d))r.push({type:"error",code:"SCREEN_INVALID_INTERACTIONS",message:"x-interactions must be an array",path:a,location:l});else for(let p=0;p<d.length;p++)d[p].name||r.push({type:"error",code:"SCREEN_INVALID_INTERACTION",message:`x-interactions[${p}] must have a name`,path:a,location:l}),d[p]["x-event"]!=null&&t9(d[p]["x-event"],`${a}.x-interactions[${p}]`,l,r)}}if(u["x-micro-contracts-published"]===!0){let c=j4e(a,s,u,e);r.push(...c);let d=T4e(a,s,u,e);i.push(...d)}}if(e.components?.schemas)for(let[a,o]of Object.entries(e.components.schemas)){if(Kt(o))continue;let s=N4e(a,o);i.push(...s)}let n=r.length===0&&(!t.strict||i.length===0);return{errors:r,warnings:i,valid:n}}function j4e(e,t,r,i){let n=[],a=`${t.toUpperCase()} ${e}`;if(r.requestBody&&!Kt(r.requestBody)){let o=r.requestBody.content?.["application/json"];if(o?.schema&&il(o.schema,i)){let s=Kt(o.schema)?Or(o.schema.$ref):"inline schema";n.push({type:"error",code:"PUBLIC_ENDPOINT_PRIVATE_REQUEST",message:`Public endpoint references request schema "${s}" with x-private properties`,path:e,location:a})}}for(let[o,s]of Object.entries(r.responses)){if(!o.startsWith("2"))continue;let u=Kt(s)?i.components?.responses?.[Or(s.$ref)]:s;if(u?.content?.["application/json"]?.schema){let l=u.content["application/json"].schema;if(il(l,i)){let c=Kt(l)?Or(l.$ref):"inline schema";n.push({type:"error",code:"PUBLIC_ENDPOINT_PRIVATE_RESPONSE",message:`Public endpoint references response schema "${c}" with x-private properties`,path:e,location:a})}}}return n}function T4e(e,t,r,i){let n=[],a=`${t.toUpperCase()} ${e}`,o=new Set;if(r.requestBody&&!Kt(r.requestBody)){let s=r.requestBody.content?.["application/json"];s?.schema&&ru(s.schema,i,o)}for(let s of Object.values(r.responses)){let u=Kt(s)?i.components?.responses?.[Or(s.$ref)]:s;u?.content?.["application/json"]?.schema&&ru(u.content["application/json"].schema,i,o)}for(let s of o){let u=i.components?.schemas?.[s];!u||Kt(u)||(u.allOf||u.oneOf||u.anyOf)&&n.push({type:"warning",code:"PUBLIC_ENDPOINT_COMPOSITION",message:`Public endpoint uses schema "${s}" with allOf/oneOf/anyOf (may complicate compatibility)`,path:e,location:a})}return n}function N4e(e,t){let r=[];if(!t.properties||!t.required)return r;for(let i of t.required){let n=t.properties[i];n&&!Kt(n)&&n["x-private"]&&r.push({type:"warning",code:"PRIVATE_IN_REQUIRED",message:`Schema "${e}" has x-private property "${i}" in required array (cannot be used in public endpoints)`,location:`components/schemas/${e}`})}return r}function t9(e,t,r,i){if(typeof e=="string")return;if(typeof e!="object"||e===null){i.push({type:"error",code:"SCREEN_INVALID_X_EVENT",message:"x-event must be a string, object with {name}, or {$ref}",path:t,location:r});return}let n=e;!n.$ref&&!n.name&&i.push({type:"error",code:"SCREEN_INVALID_X_EVENT",message:"x-event object must have either $ref or name",path:t,location:r})}function dl(e){let t=[];if(e.errors.length>0){t.push("Errors:");for(let r of e.errors)t.push(` \u274C [${r.code}] ${r.message}`),r.location&&t.push(` at ${r.location}`);t.push("")}if(e.warnings.length>0){t.push("Warnings:");for(let r of e.warnings)t.push(` \u26A0\uFE0F [${r.code}] ${r.message}`),r.location&&t.push(` at ${r.location}`);t.push("")}return e.valid?t.push("\u2705 Lint passed"):t.push(`\u274C Lint failed with ${e.errors.length} error(s)`),t.join(`
217
217
  `)}var jg=Xe(()=>{"use strict";Ii()});import Lg from"fs";import Af from"path";function l9(e){let t=e||process.cwd(),r=["micro-contracts.guardrails.yaml","micro-contracts.guardrails.yml","guardrails.yaml","guardrails.yml"],i=Af.resolve(t),n=Af.parse(i).root;for(;i!==n;){for(let a of r){let o=Af.join(i,a);if(Lg.existsSync(o))return o}i=Af.dirname(i)}return null}function zg(e){return Ni(e).config}function Ni(e){let t=e||l9();if(!t||!Lg.existsSync(t))return{config:Rc,baseDir:process.cwd(),configPath:null};let r=Lg.readFileSync(t,"utf-8"),i=Ya.load(r);if(typeof i!="object"||i===null)throw new Error(`Invalid guardrails config: ${t}`);return{config:{allowed:i.allowed??Rc.allowed,protected:i.protected??Rc.protected,generated:i.generated??Rc.generated,checks:i.checks},baseDir:Af.dirname(t),configPath:t}}function c9(){return`# AI-Driven Development Guardrails Configuration
218
218
  #
219
219
  # This file defines which files can be modified in normal development PRs.
@@ -283,7 +283,7 @@ generated:
283
283
  `).filter(Boolean),a=[...i,...n];return{valid:a.length===0,changedFiles:a}}catch(t){return{valid:!1,changedFiles:[],error:t instanceof Error?t.message:String(t)}}}async function Zg(e){let t=Date.now(),r=e.generatedDir||"packages/";try{let i=g9(r);if(i.error)return{name:"drift",status:"fail",duration:Date.now()-t,message:`Git error: ${i.error}`};if(i.valid)return{name:"drift",status:"pass",duration:Date.now()-t,message:`No uncommitted changes in ${r}`};let n=i.changedFiles.map(a=>` - ${a}`);return{name:"drift",status:"fail",duration:Date.now()-t,message:`${i.changedFiles.length} file(s) have uncommitted changes`,details:n}}catch(i){return{name:"drift",status:"fail",duration:Date.now()-t,message:i instanceof Error?i.message:String(i)}}}function _B(e){let t=[];if(e.error)return t.push(`\u274C Drift check failed: ${e.error}`),t.join(`
284
284
  `);if(e.valid)t.push("\u2705 No drift detected - generated files match committed state");else{t.push(`\u274C Generated code differs from committed code:
285
285
  `);for(let r of e.changedFiles)t.push(` - ${r}`);t.push("\n\u{1F4A1} Run `micro-contracts generate` to regenerate artifacts."),t.push("\u{1F4A1} Then commit the changes or verify they are expected.")}return t.join(`
286
- `)}var v9=Xe(()=>{"use strict"});var $B=He((WFe,EB)=>{"use strict";EB.exports=wB;function wB(e,t,r){e instanceof RegExp&&(e=bB(e,r)),t instanceof RegExp&&(t=bB(t,r));var i=SB(e,t,r);return i&&{start:i[0],end:i[1],pre:r.slice(0,i[0]),body:r.slice(i[0]+e.length,i[1]),post:r.slice(i[1]+t.length)}}function bB(e,t){var r=t.match(e);return r?r[0]:null}wB.range=SB;function SB(e,t,r){var i,n,a,o,s,u=r.indexOf(e),l=r.indexOf(t,u+1),c=u;if(u>=0&&l>0){if(e===t)return[u,l];for(i=[],a=r.length;c>=0&&!s;)c==u?(i.push(c),u=r.indexOf(e,c+1)):i.length==1?s=[i.pop(),l]:(n=i.pop(),n<a&&(a=n,o=l),l=r.indexOf(t,c+1)),c=u<l&&u>=0?u:l;i.length&&(s=[a,o])}return s}});var IB=He((KFe,PB)=>{var xB=$B();PB.exports=Dye;var kB="\0SLASH"+Math.random()+"\0",AB="\0OPEN"+Math.random()+"\0",_9="\0CLOSE"+Math.random()+"\0",CB="\0COMMA"+Math.random()+"\0",DB="\0PERIOD"+Math.random()+"\0";function y9(e){return parseInt(e,10)==e?parseInt(e,10):e.charCodeAt(0)}function Aye(e){return e.split("\\\\").join(kB).split("\\{").join(AB).split("\\}").join(_9).split("\\,").join(CB).split("\\.").join(DB)}function Cye(e){return e.split(kB).join("\\").split(AB).join("{").split(_9).join("}").split(CB).join(",").split(DB).join(".")}function OB(e){if(!e)return[""];var t=[],r=xB("{","}",e);if(!r)return e.split(",");var i=r.pre,n=r.body,a=r.post,o=i.split(",");o[o.length-1]+="{"+n+"}";var s=OB(a);return a.length&&(o[o.length-1]+=s.shift(),o.push.apply(o,s)),t.push.apply(t,o),t}function Dye(e,t){if(!e)return[];t=t||{};var r=t.max==null?1/0:t.max;return e.substr(0,2)==="{}"&&(e="\\{\\}"+e.substr(2)),Of(Aye(e),r,!0).map(Cye)}function Oye(e){return"{"+e+"}"}function Pye(e){return/^-?0\d/.test(e)}function Iye(e,t){return e<=t}function jye(e,t){return e>=t}function Of(e,t,r){var i=[],n=xB("{","}",e);if(!n)return[e];var a=n.pre,o=n.post.length?Of(n.post,t,!1):[""];if(/\$$/.test(n.pre))for(var s=0;s<o.length&&s<t;s++){var u=a+"{"+n.body+"}"+o[s];i.push(u)}else{var l=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),d=l||c,p=n.body.indexOf(",")>=0;if(!d&&!p)return n.post.match(/,(?!,).*\}/)?(e=n.pre+"{"+n.body+_9+n.post,Of(e,t,!0)):[e];var f;if(d)f=n.body.split(/\.\./);else if(f=OB(n.body),f.length===1&&(f=Of(f[0],t,!1).map(Oye),f.length===1))return o.map(function($){return n.pre+f[0]+$});var m;if(d){var h=y9(f[0]),g=y9(f[1]),y=Math.max(f[0].length,f[1].length),_=f.length==3?Math.max(Math.abs(y9(f[2])),1):1,w=Iye,S=g<h;S&&(_*=-1,w=jye);var C=f.some(Pye);m=[];for(var D=h;w(D,g)&&m.length<t;D+=_){var E;if(c)E=String.fromCharCode(D),E==="\\"&&(E="");else if(E=String(D),C){var A=y-E.length;if(A>0){var P=new Array(A+1).join("0");D<0?E="-"+P+E.slice(1):E=P+E}}m.push(E)}}else{m=[];for(var O=0;O<f.length;O++)m.push.apply(m,Of(f[O],t,!1))}for(var O=0;O<m.length;O++)for(var s=0;s<o.length&&i.length<t;s++){var u=a+m[O]+o[s];(!r||d||u)&&i.push(u)}}return i}});var Pf,jB=Xe(()=>{Pf=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")}});var Tye,If,Nye,TB,NB,RB=Xe(()=>{Tye={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},If=e=>e.replace(/[[\]\\-]/g,"\\$&"),Nye=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),TB=e=>e.join(""),NB=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let i=[],n=[],a=r+1,o=!1,s=!1,u=!1,l=!1,c=r,d="";e:for(;a<e.length;){let h=e.charAt(a);if((h==="!"||h==="^")&&a===r+1){l=!0,a++;continue}if(h==="]"&&o&&!u){c=a+1;break}if(o=!0,h==="\\"&&!u){u=!0,a++;continue}if(h==="["&&!u){for(let[g,[y,_,w]]of Object.entries(Tye))if(e.startsWith(g,a)){if(d)return["$.",!1,e.length-r,!0];a+=g.length,w?n.push(y):i.push(y),s=s||_;continue e}}if(u=!1,d){h>d?i.push(If(d)+"-"+If(h)):h===d&&i.push(If(h)),d="",a++;continue}if(e.startsWith("-]",a+1)){i.push(If(h+"-")),a+=2;continue}if(e.startsWith("-",a+1)){d=h,a+=2;continue}i.push(If(h)),a++}if(c<a)return["",!1,0,!1];if(!i.length&&!n.length)return["$.",!1,e.length-r,!0];if(n.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!l){let h=i[0].length===2?i[0].slice(-1):i[0];return[Nye(h),!1,c-r,!1]}let p="["+(l?"^":"")+TB(i)+"]",f="["+(l?"":"^")+TB(n)+"]";return[i.length&&n.length?"("+p+"|"+f+")":i.length?p:f,s,c-r,!0]}});var Qa,Gg=Xe(()=>{Qa=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")});var Ri,Rye,b9,BB,Bye,Fye,Mye,FB,Lye,Wg,zye,Uye,qye,Vye,w9,MB,LB,fl,S9=Xe(()=>{RB();Gg();Rye=new Set(["!","?","+","*","@"]),b9=e=>Rye.has(e),BB=e=>b9(e.type),Bye=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Fye=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Mye=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),FB=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Lye="(?!(?:^|/)\\.\\.?(?:$|/))",Wg="(?!\\.)",zye=new Set(["[","."]),Uye=new Set(["..","."]),qye=new Set("().*{}+?[]^$\\!"),Vye=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),w9="[^/]",MB=w9+"*?",LB=w9+"+?",fl=class{type;#t;#r;#n=!1;#e=[];#i;#h;#l;#c=!1;#u;#s;#a=!1;constructor(t,r,i={}){this.type=t,t&&(this.#r=!0),this.#i=r,this.#t=this.#i?this.#i.#t:this,this.#u=this.#t===this?i:this.#t.#u,this.#l=this.#t===this?[]:this.#t.#l,t==="!"&&!this.#t.#c&&this.#l.push(this),this.#h=this.#i?this.#i.#e.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let t of this.#e)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#s!==void 0?this.#s:this.type?this.#s=this.type+"("+this.#e.map(t=>String(t)).join("|")+")":this.#s=this.#e.map(t=>String(t)).join("")}#b(){if(this!==this.#t)throw new Error("should only call on root");if(this.#c)return this;this.toString(),this.#c=!0;let t;for(;t=this.#l.pop();){if(t.type!=="!")continue;let r=t,i=r.#i;for(;i;){for(let n=r.#h+1;!i.type&&n<i.#e.length;n++)for(let a of t.#e){if(typeof a=="string")throw new Error("string part in extglob AST??");a.copyIn(i.#e[n])}r=i,i=r.#i}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof Ri&&r.#i===this))throw new Error("invalid part: "+r);this.#e.push(r)}}toJSON(){let t=this.type===null?this.#e.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#e.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#c&&this.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#i?.isStart())return!1;if(this.#h===0)return!0;let t=this.#i;for(let r=0;r<this.#h;r++){let i=t.#e[r];if(!(i instanceof Ri&&i.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#e.length:0;return this.#h===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new Ri(this.type,t);for(let i of this.#e)r.copyIn(i);return r}static#g(t,r,i,n,a){let o=n.maxExtglobRecursion??2,s=!1,u=!1,l=-1,c=!1;if(r.type===null){let h=i,g="";for(;h<t.length;){let y=t.charAt(h++);if(s||y==="\\"){s=!s,g+=y;continue}if(u){h===l+1?(y==="^"||y==="!")&&(c=!0):y==="]"&&!(h===l+2&&c)&&(u=!1),g+=y;continue}else if(y==="["){u=!0,l=h,c=!1,g+=y;continue}if(!n.noext&&b9(y)&&t.charAt(h)==="("&&a<=o){r.push(g),g="";let w=new Ri(y,r);h=Ri.#g(t,w,h,n,a+1),r.push(w);continue}g+=y}return r.push(g),h}let d=i+1,p=new Ri(null,r),f=[],m="";for(;d<t.length;){let h=t.charAt(d++);if(s||h==="\\"){s=!s,m+=h;continue}if(u){d===l+1?(h==="^"||h==="!")&&(c=!0):h==="]"&&!(d===l+2&&c)&&(u=!1),m+=h;continue}else if(h==="["){u=!0,l=d,c=!1,m+=h;continue}if(b9(h)&&t.charAt(d)==="("&&(a<=o||r&&r.#w(h))){let y=r&&r.#w(h)?0:1;p.push(m),m="";let _=new Ri(h,p);p.push(_),d=Ri.#g(t,_,d,n,a+y);continue}if(h==="|"){p.push(m),m="",f.push(p),p=new Ri(null,r);continue}if(h===")")return m===""&&r.#e.length===0&&(r.#a=!0),p.push(m),m="",r.push(...f,p),d;m+=h}return r.type=null,r.#r=void 0,r.#e=[t.substring(i-1)],d}#y(t){return this.#f(t,Fye)}#f(t,r=Bye){if(!t||typeof t!="object"||t.type!==null||t.#e.length!==1||this.type===null)return!1;let i=t.#e[0];return!i||typeof i!="object"||i.type===null?!1:this.#w(i.type,r)}#w(t,r=Mye){return!!r.get(this.type)?.includes(t)}#m(t,r){let i=t.#e[0],n=new Ri(null,i,this.options);n.#e.push(""),i.push(n),this.#S(t,r)}#S(t,r){let i=t.#e[0];this.#e.splice(r,1,...i.#e);for(let n of i.#e)typeof n=="object"&&(n.#i=this);this.#s=void 0}#x(t){return!!FB.get(this.type)?.has(t)}#_(t){if(!t||typeof t!="object"||t.type!==null||t.#e.length!==1||this.type===null||this.#e.length!==1)return!1;let r=t.#e[0];return!r||typeof r!="object"||r.type===null?!1:this.#x(r.type)}#E(t){let r=FB.get(this.type),i=t.#e[0],n=r?.get(i.type);if(!n)return!1;this.#e=i.#e;for(let a of this.#e)typeof a=="object"&&(a.#i=this);this.type=n,this.#s=void 0,this.#a=!1}#v(){if(BB(this)){let t=0,r=!1;do{r=!0;for(let i=0;i<this.#e.length;i++){let n=this.#e[i];typeof n=="object"&&(n.#v(),this.#f(n)?(r=!1,this.#S(n,i)):this.#y(n)?(r=!1,this.#m(n,i)):this.#_(n)&&(r=!1,this.#E(n)))}}while(!r&&++t<10)}else for(let t of this.#e)typeof t=="object"&&t.#v();this.#s=void 0}static fromGlob(t,r={}){let i=new Ri(null,void 0,r);return Ri.#g(t,i,0,r,0),i}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let t=this.toString(),[r,i,n,a]=this.toRegExpSource();if(!(n||this.#r||this.#u.nocase&&!this.#u.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let s=(this.#u.nocase?"i":"")+(a?"u":"");return Object.assign(new RegExp(`^${r}$`,s),{_src:r,_glob:t})}get options(){return this.#u}toRegExpSource(t){let r=t??!!this.#u.dot;if(this.#t===this&&(this.#v(),this.#b()),!BB(this)){let u=this.isStart()&&this.isEnd(),l=this.#e.map(f=>{let[m,h,g,y]=typeof f=="string"?Ri.#k(f,this.#r,u):f.toRegExpSource(t);return this.#r=this.#r||g,this.#n=this.#n||y,m}).join(""),c="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&Uye.has(this.#e[0]))){let m=zye,h=r&&m.has(l.charAt(0))||l.startsWith("\\.")&&m.has(l.charAt(2))||l.startsWith("\\.\\.")&&m.has(l.charAt(4)),g=!r&&!t&&m.has(l.charAt(0));c=h?Lye:g?Wg:""}let d="";return this.isEnd()&&this.#t.#c&&this.#i?.type==="!"&&(d="(?:$|\\/)"),[c+l+d,Qa(l),this.#r=!!this.#r,this.#n]}let i=this.type==="*"||this.type==="+",n=this.type==="!"?"(?:(?!(?:":"(?:",a=this.#p(r);if(this.isStart()&&this.isEnd()&&!a&&this.type!=="!"){let u=this.toString(),l=this;return l.#e=[u],l.type=null,l.#r=void 0,[u,Qa(this.toString()),!1,!1]}let o=!i||t||r||!Wg?"":this.#p(!0);o===a&&(o=""),o&&(a=`(?:${a})(?:${o})*?`);let s="";if(this.type==="!"&&this.#a)s=(this.isStart()&&!r?Wg:"")+LB;else{let u=this.type==="!"?"))"+(this.isStart()&&!r&&!t?Wg:"")+MB+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;s=n+a+u}return[s,Qa(a),this.#r=!!this.#r,this.#n]}#p(t){return this.#e.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[i,n,a,o]=r.toRegExpSource(t);return this.#n=this.#n||o,i}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#k(t,r,i=!1){let n=!1,a="",o=!1,s=!1;for(let u=0;u<t.length;u++){let l=t.charAt(u);if(n){n=!1,a+=(qye.has(l)?"\\":"")+l,s=!1;continue}if(l==="\\"){u===t.length-1?a+="\\\\":n=!0;continue}if(l==="["){let[c,d,p,f]=NB(t,u);if(p){a+=c,o=o||d,u+=p-1,r=r||f,s=!1;continue}}if(l==="*"){if(s)continue;s=!0,a+=i&&/^[*]+$/.test(t)?LB:MB,r=!0;continue}else s=!1;if(l==="?"){a+=w9,r=!0;continue}a+=Vye(l)}return[a,Qa(t),!!r,o]}};Ri=fl});var Fc,E9=Xe(()=>{Fc=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&")});var qB,hi,Zye,Gye,Wye,Kye,Hye,Jye,Yye,Xye,Qye,e2e,t2e,r2e,n2e,i2e,a2e,o2e,s2e,u2e,VB,ZB,GB,zB,l2e,cn,c2e,d2e,p2e,f2e,m2e,Da,h2e,WB,g2e,v2e,UB,y2e,aa,au=Xe(()=>{qB=Hu(IB(),1);jB();S9();E9();Gg();S9();E9();Gg();hi=(e,t,r={})=>(Pf(t),!r.nocomment&&t.charAt(0)==="#"?!1:new aa(t,r).match(e)),Zye=/^\*+([^+@!?\*\[\(]*)$/,Gye=e=>t=>!t.startsWith(".")&&t.endsWith(e),Wye=e=>t=>t.endsWith(e),Kye=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Hye=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Jye=/^\*+\.\*+$/,Yye=e=>!e.startsWith(".")&&e.includes("."),Xye=e=>e!=="."&&e!==".."&&e.includes("."),Qye=/^\.\*+$/,e2e=e=>e!=="."&&e!==".."&&e.startsWith("."),t2e=/^\*+$/,r2e=e=>e.length!==0&&!e.startsWith("."),n2e=e=>e.length!==0&&e!=="."&&e!=="..",i2e=/^\?+([^+@!?\*\[\(]*)?$/,a2e=([e,t=""])=>{let r=VB([e]);return t?(t=t.toLowerCase(),i=>r(i)&&i.toLowerCase().endsWith(t)):r},o2e=([e,t=""])=>{let r=ZB([e]);return t?(t=t.toLowerCase(),i=>r(i)&&i.toLowerCase().endsWith(t)):r},s2e=([e,t=""])=>{let r=ZB([e]);return t?i=>r(i)&&i.endsWith(t):r},u2e=([e,t=""])=>{let r=VB([e]);return t?i=>r(i)&&i.endsWith(t):r},VB=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},ZB=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},GB=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",zB={win32:{sep:"\\"},posix:{sep:"/"}},l2e=GB==="win32"?zB.win32.sep:zB.posix.sep;hi.sep=l2e;cn=Symbol("globstar **");hi.GLOBSTAR=cn;c2e="[^/]",d2e=c2e+"*?",p2e="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",f2e="(?:(?!(?:\\/|^)\\.).)*?",m2e=(e,t={})=>r=>hi(r,e,t);hi.filter=m2e;Da=(e,t={})=>Object.assign({},e,t),h2e=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return hi;let t=hi;return Object.assign((i,n,a={})=>t(i,n,Da(e,a)),{Minimatch:class extends t.Minimatch{constructor(n,a={}){super(n,Da(e,a))}static defaults(n){return t.defaults(Da(e,n)).Minimatch}},AST:class extends t.AST{constructor(n,a,o={}){super(n,a,Da(e,o))}static fromGlob(n,a={}){return t.AST.fromGlob(n,Da(e,a))}},unescape:(i,n={})=>t.unescape(i,Da(e,n)),escape:(i,n={})=>t.escape(i,Da(e,n)),filter:(i,n={})=>t.filter(i,Da(e,n)),defaults:i=>t.defaults(Da(e,i)),makeRe:(i,n={})=>t.makeRe(i,Da(e,n)),braceExpand:(i,n={})=>t.braceExpand(i,Da(e,n)),match:(i,n,a={})=>t.match(i,n,Da(e,a)),sep:t.sep,GLOBSTAR:cn})};hi.defaults=h2e;WB=(e,t={})=>(Pf(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:(0,qB.default)(e));hi.braceExpand=WB;g2e=(e,t={})=>new aa(e,t).makeRe();hi.makeRe=g2e;v2e=(e,t,r={})=>{let i=new aa(t,r);return e=e.filter(n=>i.match(n)),i.options.nonull&&!e.length&&e.push(t),e};hi.match=v2e;UB=/[?*]|[+@!]\(.*?\)|\[|\]/,y2e=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),aa=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){Pf(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||GB,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...a)=>console.error(...a)),this.debug(this.pattern,this.globSet);let i=this.globSet.map(a=>this.slashSplit(a));this.globParts=this.preprocess(i),this.debug(this.pattern,this.globParts);let n=this.globParts.map((a,o,s)=>{if(this.isWindows&&this.windowsNoMagicRoot){let u=a[0]===""&&a[1]===""&&(a[2]==="?"||!UB.test(a[2]))&&!UB.test(a[3]),l=/^[a-z]:/i.test(a[0]);if(u)return[...a.slice(0,4),...a.slice(4).map(c=>this.parse(c))];if(l)return[a[0],...a.slice(1).map(c=>this.parse(c))]}return a.map(u=>this.parse(u))});if(this.debug(this.pattern,n),this.set=n.filter(a=>a.indexOf(!1)===-1),this.isWindows)for(let a=0;a<this.set.length;a++){let o=this.set[a];o[0]===""&&o[1]===""&&this.globParts[a][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let i=0;i<t.length;i++)for(let n=0;n<t[i].length;n++)t[i][n]==="**"&&(t[i][n]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let i=-1;for(;(i=r.indexOf("**",i+1))!==-1;){let n=i;for(;r[n+1]==="**";)n++;n!==i&&r.splice(i,n-i)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((i,n)=>{let a=i[i.length-1];return n==="**"&&a==="**"?i:n===".."&&a&&a!==".."&&a!=="."&&a!=="**"?(i.pop(),i):(i.push(n),i)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let n=1;n<t.length-1;n++){let a=t[n];n===1&&a===""&&t[0]===""||(a==="."||a==="")&&(r=!0,t.splice(n,1),n--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let i=0;for(;(i=t.indexOf("..",i+1))!==-1;){let n=t[i-1];n&&n!=="."&&n!==".."&&n!=="**"&&(r=!0,t.splice(i-1,2),i-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let i of t){let n=-1;for(;(n=i.indexOf("**",n+1))!==-1;){let o=n;for(;i[o+1]==="**";)o++;o>n&&i.splice(n+1,o-n);let s=i[n+1],u=i[n+2],l=i[n+3];if(s!==".."||!u||u==="."||u===".."||!l||l==="."||l==="..")continue;r=!0,i.splice(n,1);let c=i.slice(0);c[n]="**",t.push(c),n--}if(!this.preserveMultipleSlashes){for(let o=1;o<i.length-1;o++){let s=i[o];o===1&&s===""&&i[0]===""||(s==="."||s==="")&&(r=!0,i.splice(o,1),o--)}i[0]==="."&&i.length===2&&(i[1]==="."||i[1]==="")&&(r=!0,i.pop())}let a=0;for(;(a=i.indexOf("..",a+1))!==-1;){let o=i[a-1];if(o&&o!=="."&&o!==".."&&o!=="**"){r=!0;let u=a===1&&i[a+1]==="**"?["."]:[];i.splice(a-1,2,...u),i.length===0&&i.push(""),a-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let i=r+1;i<t.length;i++){let n=this.partsMatch(t[r],t[i],!this.preserveMultipleSlashes);if(n){t[r]=[],t[i]=n;break}}return t.filter(r=>r.length)}partsMatch(t,r,i=!1){let n=0,a=0,o=[],s="";for(;n<t.length&&a<r.length;)if(t[n]===r[a])o.push(s==="b"?r[a]:t[n]),n++,a++;else if(i&&t[n]==="**"&&r[a]===t[n+1])o.push(t[n]),n++;else if(i&&r[a]==="**"&&t[n]===r[a+1])o.push(r[a]),a++;else if(t[n]==="*"&&r[a]&&(this.options.dot||!r[a].startsWith("."))&&r[a]!=="**"){if(s==="b")return!1;s="a",o.push(t[n]),n++,a++}else if(r[a]==="*"&&t[n]&&(this.options.dot||!t[n].startsWith("."))&&t[n]!=="**"){if(s==="a")return!1;s="b",o.push(r[a]),n++,a++}else return!1;return t.length===r.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,i=0;for(let n=0;n<t.length&&t.charAt(n)==="!";n++)r=!r,i++;i&&(this.pattern=t.slice(i)),this.negate=r}matchOne(t,r,i=!1){let n=0,a=0;if(this.isWindows){let s=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),u=!s&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),l=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),c=!l&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),d=u?3:s?0:void 0,p=c?3:l?0:void 0;if(typeof d=="number"&&typeof p=="number"){let[f,m]=[t[d],r[p]];f.toLowerCase()===m.toLowerCase()&&(r[p]=f,a=p,n=d)}}let{optimizationLevel:o=1}=this.options;return o>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(cn)?this.#t(t,r,i,n,a):this.#n(t,r,i,n,a)}#t(t,r,i,n,a){let o=r.indexOf(cn,a),s=r.lastIndexOf(cn),[u,l,c]=i?[r.slice(a,o),r.slice(o+1),[]]:[r.slice(a,o),r.slice(o+1,s),r.slice(s+1)];if(u.length){let _=t.slice(n,n+u.length);if(!this.#n(_,u,i,0,0))return!1;n+=u.length}let d=0;if(c.length){if(c.length+n>t.length)return!1;let _=t.length-c.length;if(this.#n(t,c,i,_,0))d=c.length;else{if(t[t.length-1]!==""||n+c.length===t.length||(_--,!this.#n(t,c,i,_,0)))return!1;d=c.length+1}}if(!l.length){let _=!!d;for(let w=n;w<t.length-d;w++){let S=String(t[w]);if(_=!0,S==="."||S===".."||!this.options.dot&&S.startsWith("."))return!1}return i||_}let p=[[[],0]],f=p[0],m=0,h=[0];for(let _ of l)_===cn?(h.push(m),f=[[],0],p.push(f)):(f[0].push(_),m++);let g=p.length-1,y=t.length-d;for(let _ of p)_[1]=y-(h[g--]+_[0].length);return!!this.#r(t,p,n,0,i,0,!!d)}#r(t,r,i,n,a,o,s){let u=r[n];if(!u){for(let d=i;d<t.length;d++){s=!0;let p=t[d];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1}return s}let[l,c]=u;for(;i<=c;){if(this.#n(t.slice(0,i+l.length),l,a,i,0)&&o<this.maxGlobstarRecursion){let f=this.#r(t,r,i+l.length,n+1,a,o+1,s);if(f!==!1)return f}let p=t[i];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1;i++}return a||null}#n(t,r,i,n,a){let o,s,u,l;for(o=n,s=a,l=t.length,u=r.length;o<l&&s<u;o++,s++){this.debug("matchOne loop");let c=r[s],d=t[o];if(this.debug(r,c,d),c===!1||c===cn)return!1;let p;if(typeof c=="string"?(p=d===c,this.debug("string match",c,d,p)):(p=c.test(d),this.debug("pattern match",c,d,p)),!p)return!1}if(o===l&&s===u)return!0;if(o===l)return i;if(s===u)return o===l-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return WB(this.pattern,this.options)}parse(t){Pf(t);let r=this.options;if(t==="**")return cn;if(t==="")return"";let i,n=null;(i=t.match(t2e))?n=r.dot?n2e:r2e:(i=t.match(Zye))?n=(r.nocase?r.dot?Hye:Kye:r.dot?Wye:Gye)(i[1]):(i=t.match(i2e))?n=(r.nocase?r.dot?o2e:a2e:r.dot?s2e:u2e)(i):(i=t.match(Jye))?n=r.dot?Xye:Yye:(i=t.match(Qye))&&(n=e2e);let a=fl.fromGlob(t,this.options).toMMPattern();return n&&typeof a=="object"&&Reflect.defineProperty(a,"test",{value:n}),a}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,i=r.noglobstar?d2e:r.dot?p2e:f2e,n=new Set(r.nocase?["i"]:[]),a=t.map(u=>{let l=u.map(c=>{if(c instanceof RegExp)for(let d of c.flags.split(""))n.add(d);return typeof c=="string"?y2e(c):c===cn?cn:c._src});return l.forEach((c,d)=>{let p=l[d+1],f=l[d-1];c!==cn||f===cn||(f===void 0?p!==void 0&&p!==cn?l[d+1]="(?:\\/|"+i+"\\/)?"+p:l[d]=i:p===void 0?l[d-1]=f+"(?:\\/|"+i+")?":p!==cn&&(l[d-1]=f+"(?:\\/|\\/"+i+"\\/)"+p,l[d+1]=cn))}),l.filter(c=>c!==cn).join("/")}).join("|"),[o,s]=t.length>1?["(?:",")"]:["",""];a="^"+o+a+s+"$",this.negate&&(a="^(?!"+a+").+$");try{this.regexp=new RegExp(a,[...n].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let i=this.options;this.isWindows&&(t=t.split("\\").join("/"));let n=this.slashSplit(t);this.debug(this.pattern,"split",n);let a=this.set;this.debug(this.pattern,"set",a);let o=n[n.length-1];if(!o)for(let s=n.length-2;!o&&s>=0;s--)o=n[s];for(let s=0;s<a.length;s++){let u=a[s],l=n;if(i.matchBase&&u.length===1&&(l=[o]),this.matchOne(l,u,r))return i.flipNegate?!0:!this.negate}return i.flipNegate?!1:this.negate}static defaults(t){return hi.defaults(t).Minimatch}};hi.AST=fl;hi.Minimatch=aa;hi.escape=Fc;hi.unescape=Qa});var Mc,HB,$9,JB,Kg,KB,_2e,ou,YB,Lc,x9,jf,XB=Xe(()=>{Mc=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,HB=new Set,$9=typeof process=="object"&&process?process:{},JB=(e,t,r,i)=>{typeof $9.emitWarning=="function"?$9.emitWarning(e,t,r,i):console.error(`[${r}] ${t}: ${e}`)},Kg=globalThis.AbortController,KB=globalThis.AbortSignal;if(typeof Kg>"u"){KB=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(i,n){this._onabort.push(n)}},Kg=class{constructor(){t()}signal=new KB;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=!0;for(let n of this.signal._onabort)n(i);this.signal.onabort?.(i)}}};let e=$9.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,JB("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}_2e=e=>!HB.has(e),ou=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),YB=e=>ou(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Lc:null:null,Lc=class extends Array{constructor(t){super(t),this.fill(0)}},x9=class e{heap;length;static#t=!1;static create(t){let r=YB(t);if(!r)return[];e.#t=!0;let i=new e(t,r);return e.#t=!1,i}constructor(t,r){if(!e.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},jf=class e{#t;#r;#n;#e;#i;#h;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#l;#c;#u;#s;#a;#b;#g;#y;#f;#w;#m;#S;#x;#_;#E;#v;#p;static unsafeExposeInternals(t){return{starts:t.#x,ttls:t.#_,sizes:t.#S,keyMap:t.#u,keyList:t.#s,valList:t.#a,next:t.#b,prev:t.#g,get head(){return t.#y},get tail(){return t.#f},free:t.#w,isBackgroundFetch:r=>t.#d(r),backgroundFetch:(r,i,n,a)=>t.#F(r,i,n,a),moveToTail:r=>t.#L(r),indexes:r=>t.#C(r),rindexes:r=>t.#D(r),isStale:r=>t.#$(r)}}get max(){return this.#t}get maxSize(){return this.#r}get calculatedSize(){return this.#c}get size(){return this.#l}get fetchMethod(){return this.#i}get memoMethod(){return this.#h}get dispose(){return this.#n}get disposeAfter(){return this.#e}constructor(t){let{max:r=0,ttl:i,ttlResolution:n=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:s,allowStale:u,dispose:l,disposeAfter:c,noDisposeOnSet:d,noUpdateTTL:p,maxSize:f=0,maxEntrySize:m=0,sizeCalculation:h,fetchMethod:g,memoMethod:y,noDeleteOnFetchRejection:_,noDeleteOnStaleGet:w,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:C,ignoreFetchAbort:D}=t;if(r!==0&&!ou(r))throw new TypeError("max option must be a nonnegative integer");let E=r?YB(r):Array;if(!E)throw new Error("invalid max value: "+r);if(this.#t=r,this.#r=f,this.maxEntrySize=m||this.#r,this.sizeCalculation=h,this.sizeCalculation){if(!this.#r&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(y!==void 0&&typeof y!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#h=y,g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#i=g,this.#v=!!g,this.#u=new Map,this.#s=new Array(r).fill(void 0),this.#a=new Array(r).fill(void 0),this.#b=new E(r),this.#g=new E(r),this.#y=0,this.#f=0,this.#w=x9.create(r),this.#l=0,this.#c=0,typeof l=="function"&&(this.#n=l),typeof c=="function"?(this.#e=c,this.#m=[]):(this.#e=void 0,this.#m=void 0),this.#E=!!this.#n,this.#p=!!this.#e,this.noDisposeOnSet=!!d,this.noUpdateTTL=!!p,this.noDeleteOnFetchRejection=!!_,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!C,this.ignoreFetchAbort=!!D,this.maxEntrySize!==0){if(this.#r!==0&&!ou(this.#r))throw new TypeError("maxSize must be a positive integer if specified");if(!ou(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#O()}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!w,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!s,this.ttlResolution=ou(n)||n===0?n:1,this.ttlAutopurge=!!a,this.ttl=i||0,this.ttl){if(!ou(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#k()}if(this.#t===0&&this.ttl===0&&this.#r===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#r){let A="LRU_CACHE_UNBOUNDED";_2e(A)&&(HB.add(A),JB("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",A,e))}}getRemainingTTL(t){return this.#u.has(t)?1/0:0}#k(){let t=new Lc(this.#t),r=new Lc(this.#t);this.#_=t,this.#x=r,this.#I=(a,o,s=Mc.now())=>{if(r[a]=o!==0?s:0,t[a]=o,o!==0&&this.ttlAutopurge){let u=setTimeout(()=>{this.#$(a)&&this.#P(this.#s[a],"expire")},o+1);u.unref&&u.unref()}},this.#A=a=>{r[a]=t[a]!==0?Mc.now():0},this.#o=(a,o)=>{if(t[o]){let s=t[o],u=r[o];if(!s||!u)return;a.ttl=s,a.start=u,a.now=i||n();let l=a.now-u;a.remainingTTL=s-l}};let i=0,n=()=>{let a=Mc.now();if(this.ttlResolution>0){i=a;let o=setTimeout(()=>i=0,this.ttlResolution);o.unref&&o.unref()}return a};this.getRemainingTTL=a=>{let o=this.#u.get(a);if(o===void 0)return 0;let s=t[o],u=r[o];if(!s||!u)return 1/0;let l=(i||n())-u;return s-l},this.#$=a=>{let o=r[a],s=t[a];return!!s&&!!o&&(i||n())-o>s}}#A=()=>{};#o=()=>{};#I=()=>{};#$=()=>!1;#O(){let t=new Lc(this.#t);this.#c=0,this.#S=t,this.#j=r=>{this.#c-=t[r],t[r]=0},this.#N=(r,i,n,a)=>{if(this.#d(i))return 0;if(!ou(n))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(n=a(i,r),!ou(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return n},this.#T=(r,i,n)=>{if(t[r]=i,this.#r){let a=this.#r-t[r];for(;this.#c>a;)this.#B(!0)}this.#c+=t[r],n&&(n.entrySize=i,n.totalCalculatedSize=this.#c)}}#j=t=>{};#T=(t,r,i)=>{};#N=(t,r,i,n)=>{if(i||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#C({allowStale:t=this.allowStale}={}){if(this.#l)for(let r=this.#f;!(!this.#R(r)||((t||!this.#$(r))&&(yield r),r===this.#y));)r=this.#g[r]}*#D({allowStale:t=this.allowStale}={}){if(this.#l)for(let r=this.#y;!(!this.#R(r)||((t||!this.#$(r))&&(yield r),r===this.#f));)r=this.#b[r]}#R(t){return t!==void 0&&this.#u.get(this.#s[t])===t}*entries(){for(let t of this.#C())this.#a[t]!==void 0&&this.#s[t]!==void 0&&!this.#d(this.#a[t])&&(yield[this.#s[t],this.#a[t]])}*rentries(){for(let t of this.#D())this.#a[t]!==void 0&&this.#s[t]!==void 0&&!this.#d(this.#a[t])&&(yield[this.#s[t],this.#a[t]])}*keys(){for(let t of this.#C()){let r=this.#s[t];r!==void 0&&!this.#d(this.#a[t])&&(yield r)}}*rkeys(){for(let t of this.#D()){let r=this.#s[t];r!==void 0&&!this.#d(this.#a[t])&&(yield r)}}*values(){for(let t of this.#C())this.#a[t]!==void 0&&!this.#d(this.#a[t])&&(yield this.#a[t])}*rvalues(){for(let t of this.#D())this.#a[t]!==void 0&&!this.#d(this.#a[t])&&(yield this.#a[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,r={}){for(let i of this.#C()){let n=this.#a[i],a=this.#d(n)?n.__staleWhileFetching:n;if(a!==void 0&&t(a,this.#s[i],this))return this.get(this.#s[i],r)}}forEach(t,r=this){for(let i of this.#C()){let n=this.#a[i],a=this.#d(n)?n.__staleWhileFetching:n;a!==void 0&&t.call(r,a,this.#s[i],this)}}rforEach(t,r=this){for(let i of this.#D()){let n=this.#a[i],a=this.#d(n)?n.__staleWhileFetching:n;a!==void 0&&t.call(r,a,this.#s[i],this)}}purgeStale(){let t=!1;for(let r of this.#D({allowStale:!0}))this.#$(r)&&(this.#P(this.#s[r],"expire"),t=!0);return t}info(t){let r=this.#u.get(t);if(r===void 0)return;let i=this.#a[r],n=this.#d(i)?i.__staleWhileFetching:i;if(n===void 0)return;let a={value:n};if(this.#_&&this.#x){let o=this.#_[r],s=this.#x[r];if(o&&s){let u=o-(Mc.now()-s);a.ttl=u,a.start=Date.now()}}return this.#S&&(a.size=this.#S[r]),a}dump(){let t=[];for(let r of this.#C({allowStale:!0})){let i=this.#s[r],n=this.#a[r],a=this.#d(n)?n.__staleWhileFetching:n;if(a===void 0||i===void 0)continue;let o={value:a};if(this.#_&&this.#x){o.ttl=this.#_[r];let s=Mc.now()-this.#x[r];o.start=Math.floor(Date.now()-s)}this.#S&&(o.size=this.#S[r]),t.unshift([i,o])}return t}load(t){this.clear();for(let[r,i]of t){if(i.start){let n=Date.now()-i.start;i.start=Mc.now()-n}this.set(r,i.value,i)}}set(t,r,i={}){if(r===void 0)return this.delete(t),this;let{ttl:n=this.ttl,start:a,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:u}=i,{noUpdateTTL:l=this.noUpdateTTL}=i,c=this.#N(t,r,i.size||0,s);if(this.maxEntrySize&&c>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=!0),this.#P(t,"set"),this;let d=this.#l===0?void 0:this.#u.get(t);if(d===void 0)d=this.#l===0?this.#f:this.#w.length!==0?this.#w.pop():this.#l===this.#t?this.#B(!1):this.#l,this.#s[d]=t,this.#a[d]=r,this.#u.set(t,d),this.#b[this.#f]=d,this.#g[d]=this.#f,this.#f=d,this.#l++,this.#T(d,c,u),u&&(u.set="add"),l=!1;else{this.#L(d);let p=this.#a[d];if(r!==p){if(this.#v&&this.#d(p)){p.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:f}=p;f!==void 0&&!o&&(this.#E&&this.#n?.(f,t,"set"),this.#p&&this.#m?.push([f,t,"set"]))}else o||(this.#E&&this.#n?.(p,t,"set"),this.#p&&this.#m?.push([p,t,"set"]));if(this.#j(d),this.#T(d,c,u),this.#a[d]=r,u){u.set="replace";let f=p&&this.#d(p)?p.__staleWhileFetching:p;f!==void 0&&(u.oldValue=f)}}else u&&(u.set="update")}if(n!==0&&!this.#_&&this.#k(),this.#_&&(l||this.#I(d,n,a),u&&this.#o(u,d)),!o&&this.#p&&this.#m){let p=this.#m,f;for(;f=p?.shift();)this.#e?.(...f)}return this}pop(){try{for(;this.#l;){let t=this.#a[this.#y];if(this.#B(!0),this.#d(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#p&&this.#m){let t=this.#m,r;for(;r=t?.shift();)this.#e?.(...r)}}}#B(t){let r=this.#y,i=this.#s[r],n=this.#a[r];return this.#v&&this.#d(n)?n.__abortController.abort(new Error("evicted")):(this.#E||this.#p)&&(this.#E&&this.#n?.(n,i,"evict"),this.#p&&this.#m?.push([n,i,"evict"])),this.#j(r),t&&(this.#s[r]=void 0,this.#a[r]=void 0,this.#w.push(r)),this.#l===1?(this.#y=this.#f=0,this.#w.length=0):this.#y=this.#b[r],this.#u.delete(i),this.#l--,r}has(t,r={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:n}=r,a=this.#u.get(t);if(a!==void 0){let o=this.#a[a];if(this.#d(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#$(a))n&&(n.has="stale",this.#o(n,a));else return i&&this.#A(a),n&&(n.has="hit",this.#o(n,a)),!0}else n&&(n.has="miss");return!1}peek(t,r={}){let{allowStale:i=this.allowStale}=r,n=this.#u.get(t);if(n===void 0||!i&&this.#$(n))return;let a=this.#a[n];return this.#d(a)?a.__staleWhileFetching:a}#F(t,r,i,n){let a=r===void 0?void 0:this.#a[r];if(this.#d(a))return a;let o=new Kg,{signal:s}=i;s?.addEventListener("abort",()=>o.abort(s.reason),{signal:o.signal});let u={signal:o.signal,options:i,context:n},l=(h,g=!1)=>{let{aborted:y}=o.signal,_=i.ignoreFetchAbort&&h!==void 0;if(i.status&&(y&&!g?(i.status.fetchAborted=!0,i.status.fetchError=o.signal.reason,_&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),y&&!_&&!g)return d(o.signal.reason);let w=f;return this.#a[r]===f&&(h===void 0?w.__staleWhileFetching?this.#a[r]=w.__staleWhileFetching:this.#P(t,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.set(t,h,u.options))),h},c=h=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=h),d(h)),d=h=>{let{aborted:g}=o.signal,y=g&&i.allowStaleOnFetchAbort,_=y||i.allowStaleOnFetchRejection,w=_||i.noDeleteOnFetchRejection,S=f;if(this.#a[r]===f&&(!w||S.__staleWhileFetching===void 0?this.#P(t,"fetch"):y||(this.#a[r]=S.__staleWhileFetching)),_)return i.status&&S.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),S.__staleWhileFetching;if(S.__returned===S)throw h},p=(h,g)=>{let y=this.#i?.(t,a,u);y&&y instanceof Promise&&y.then(_=>h(_===void 0?void 0:_),g),o.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(h(void 0),i.allowStaleOnFetchAbort&&(h=_=>l(_,!0)))})};i.status&&(i.status.fetchDispatched=!0);let f=new Promise(p).then(l,c),m=Object.assign(f,{__abortController:o,__staleWhileFetching:a,__returned:void 0});return r===void 0?(this.set(t,m,{...u.options,status:void 0}),r=this.#u.get(t)):this.#a[r]=m,m}#d(t){if(!this.#v)return!1;let r=t;return!!r&&r instanceof Promise&&r.hasOwnProperty("__staleWhileFetching")&&r.__abortController instanceof Kg}async fetch(t,r={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:u=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:d=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:p=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:m=this.allowStaleOnFetchAbort,context:h,forceRefresh:g=!1,status:y,signal:_}=r;if(!this.#v)return y&&(y.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:a,status:y});let w={allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:a,ttl:o,noDisposeOnSet:s,size:u,sizeCalculation:l,noUpdateTTL:c,noDeleteOnFetchRejection:d,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:m,ignoreFetchAbort:f,status:y,signal:_},S=this.#u.get(t);if(S===void 0){y&&(y.fetch="miss");let C=this.#F(t,S,w,h);return C.__returned=C}else{let C=this.#a[S];if(this.#d(C)){let O=i&&C.__staleWhileFetching!==void 0;return y&&(y.fetch="inflight",O&&(y.returnedStale=!0)),O?C.__staleWhileFetching:C.__returned=C}let D=this.#$(S);if(!g&&!D)return y&&(y.fetch="hit"),this.#L(S),n&&this.#A(S),y&&this.#o(y,S),C;let E=this.#F(t,S,w,h),P=E.__staleWhileFetching!==void 0&&i;return y&&(y.fetch=D?"stale":"refresh",P&&D&&(y.returnedStale=!0)),P?E.__staleWhileFetching:E.__returned=E}}async forceFetch(t,r={}){let i=await this.fetch(t,r);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,r={}){let i=this.#h;if(!i)throw new Error("no memoMethod provided to constructor");let{context:n,forceRefresh:a,...o}=r,s=this.get(t,o);if(!a&&s!==void 0)return s;let u=i(t,s,{options:o,context:n});return this.set(t,u,o),u}get(t,r={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:o}=r,s=this.#u.get(t);if(s!==void 0){let u=this.#a[s],l=this.#d(u);return o&&this.#o(o,s),this.#$(s)?(o&&(o.get="stale"),l?(o&&i&&u.__staleWhileFetching!==void 0&&(o.returnedStale=!0),i?u.__staleWhileFetching:void 0):(a||this.#P(t,"expire"),o&&i&&(o.returnedStale=!0),i?u:void 0)):(o&&(o.get="hit"),l?u.__staleWhileFetching:(this.#L(s),n&&this.#A(s),u))}else o&&(o.get="miss")}#M(t,r){this.#g[r]=t,this.#b[t]=r}#L(t){t!==this.#f&&(t===this.#y?this.#y=this.#b[t]:this.#M(this.#g[t],this.#b[t]),this.#M(this.#f,t),this.#f=t)}delete(t){return this.#P(t,"delete")}#P(t,r){let i=!1;if(this.#l!==0){let n=this.#u.get(t);if(n!==void 0)if(i=!0,this.#l===1)this.#z(r);else{this.#j(n);let a=this.#a[n];if(this.#d(a)?a.__abortController.abort(new Error("deleted")):(this.#E||this.#p)&&(this.#E&&this.#n?.(a,t,r),this.#p&&this.#m?.push([a,t,r])),this.#u.delete(t),this.#s[n]=void 0,this.#a[n]=void 0,n===this.#f)this.#f=this.#g[n];else if(n===this.#y)this.#y=this.#b[n];else{let o=this.#g[n];this.#b[o]=this.#b[n];let s=this.#b[n];this.#g[s]=this.#g[n]}this.#l--,this.#w.push(n)}}if(this.#p&&this.#m?.length){let n=this.#m,a;for(;a=n?.shift();)this.#e?.(...a)}return i}clear(){return this.#z("delete")}#z(t){for(let r of this.#D({allowStale:!0})){let i=this.#a[r];if(this.#d(i))i.__abortController.abort(new Error("deleted"));else{let n=this.#s[r];this.#E&&this.#n?.(i,n,t),this.#p&&this.#m?.push([i,n,t])}}if(this.#u.clear(),this.#a.fill(void 0),this.#s.fill(void 0),this.#_&&this.#x&&(this.#_.fill(0),this.#x.fill(0)),this.#S&&this.#S.fill(0),this.#y=0,this.#f=0,this.#w.length=0,this.#c=0,this.#l=0,this.#p&&this.#m){let r=this.#m,i;for(;i=r?.shift();)this.#e?.(...i)}}}});import{EventEmitter as I9}from"node:events";import nF from"node:stream";import{StringDecoder as b2e}from"node:string_decoder";var QB,w2e,S2e,E2e,os,ss,su,Hg,Tf,Jg,eF,Yg,tF,eo,zc,Dn,Nf,Uc,On,gi,Pn,k9,Xg,ei,dn,A9,C9,rF,D9,Eo,O9,Qg,Rf,ml,oa,Bf,$2e,x2e,k2e,A2e,ev,P9,C2e,D2e,uu,j9=Xe(()=>{QB=typeof process=="object"&&process?process:{stdout:null,stderr:null},w2e=e=>!!e&&typeof e=="object"&&(e instanceof uu||e instanceof nF||S2e(e)||E2e(e)),S2e=e=>!!e&&typeof e=="object"&&e instanceof I9&&typeof e.pipe=="function"&&e.pipe!==nF.Writable.prototype.pipe,E2e=e=>!!e&&typeof e=="object"&&e instanceof I9&&typeof e.write=="function"&&typeof e.end=="function",os=Symbol("EOF"),ss=Symbol("maybeEmitEnd"),su=Symbol("emittedEnd"),Hg=Symbol("emittingEnd"),Tf=Symbol("emittedError"),Jg=Symbol("closed"),eF=Symbol("read"),Yg=Symbol("flush"),tF=Symbol("flushChunk"),eo=Symbol("encoding"),zc=Symbol("decoder"),Dn=Symbol("flowing"),Nf=Symbol("paused"),Uc=Symbol("resume"),On=Symbol("buffer"),gi=Symbol("pipes"),Pn=Symbol("bufferLength"),k9=Symbol("bufferPush"),Xg=Symbol("bufferShift"),ei=Symbol("objectMode"),dn=Symbol("destroyed"),A9=Symbol("error"),C9=Symbol("emitData"),rF=Symbol("emitEnd"),D9=Symbol("emitEnd2"),Eo=Symbol("async"),O9=Symbol("abort"),Qg=Symbol("aborted"),Rf=Symbol("signal"),ml=Symbol("dataListeners"),oa=Symbol("discarded"),Bf=e=>Promise.resolve().then(e),$2e=e=>e(),x2e=e=>e==="end"||e==="finish"||e==="prefinish",k2e=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,A2e=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),ev=class{src;dest;opts;ondrain;constructor(t,r,i){this.src=t,this.dest=r,this.opts=i,this.ondrain=()=>t[Uc](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},P9=class extends ev{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,r,i){super(t,r,i),this.proxyErrors=n=>this.dest.emit("error",n),t.on("error",this.proxyErrors)}},C2e=e=>!!e.objectMode,D2e=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",uu=class extends I9{[Dn]=!1;[Nf]=!1;[gi]=[];[On]=[];[ei];[eo];[Eo];[zc];[os]=!1;[su]=!1;[Hg]=!1;[Jg]=!1;[Tf]=null;[Pn]=0;[dn]=!1;[Rf];[Qg]=!1;[ml]=0;[oa]=!1;writable=!0;readable=!0;constructor(...t){let r=t[0]||{};if(super(),r.objectMode&&typeof r.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");C2e(r)?(this[ei]=!0,this[eo]=null):D2e(r)?(this[eo]=r.encoding,this[ei]=!1):(this[ei]=!1,this[eo]=null),this[Eo]=!!r.async,this[zc]=this[eo]?new b2e(this[eo]):null,r&&r.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[On]}),r&&r.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[gi]});let{signal:i}=r;i&&(this[Rf]=i,i.aborted?this[O9]():i.addEventListener("abort",()=>this[O9]()))}get bufferLength(){return this[Pn]}get encoding(){return this[eo]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[ei]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Eo]}set async(t){this[Eo]=this[Eo]||!!t}[O9](){this[Qg]=!0,this.emit("abort",this[Rf]?.reason),this.destroy(this[Rf]?.reason)}get aborted(){return this[Qg]}set aborted(t){}write(t,r,i){if(this[Qg])return!1;if(this[os])throw new Error("write after end");if(this[dn])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof r=="function"&&(i=r,r="utf8"),r||(r="utf8");let n=this[Eo]?Bf:$2e;if(!this[ei]&&!Buffer.isBuffer(t)){if(A2e(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(k2e(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[ei]?(this[Dn]&&this[Pn]!==0&&this[Yg](!0),this[Dn]?this.emit("data",t):this[k9](t),this[Pn]!==0&&this.emit("readable"),i&&n(i),this[Dn]):t.length?(typeof t=="string"&&!(r===this[eo]&&!this[zc]?.lastNeed)&&(t=Buffer.from(t,r)),Buffer.isBuffer(t)&&this[eo]&&(t=this[zc].write(t)),this[Dn]&&this[Pn]!==0&&this[Yg](!0),this[Dn]?this.emit("data",t):this[k9](t),this[Pn]!==0&&this.emit("readable"),i&&n(i),this[Dn]):(this[Pn]!==0&&this.emit("readable"),i&&n(i),this[Dn])}read(t){if(this[dn])return null;if(this[oa]=!1,this[Pn]===0||t===0||t&&t>this[Pn])return this[ss](),null;this[ei]&&(t=null),this[On].length>1&&!this[ei]&&(this[On]=[this[eo]?this[On].join(""):Buffer.concat(this[On],this[Pn])]);let r=this[eF](t||null,this[On][0]);return this[ss](),r}[eF](t,r){if(this[ei])this[Xg]();else{let i=r;t===i.length||t===null?this[Xg]():typeof i=="string"?(this[On][0]=i.slice(t),r=i.slice(0,t),this[Pn]-=t):(this[On][0]=i.subarray(t),r=i.subarray(0,t),this[Pn]-=t)}return this.emit("data",r),!this[On].length&&!this[os]&&this.emit("drain"),r}end(t,r,i){return typeof t=="function"&&(i=t,t=void 0),typeof r=="function"&&(i=r,r="utf8"),t!==void 0&&this.write(t,r),i&&this.once("end",i),this[os]=!0,this.writable=!1,(this[Dn]||!this[Nf])&&this[ss](),this}[Uc](){this[dn]||(!this[ml]&&!this[gi].length&&(this[oa]=!0),this[Nf]=!1,this[Dn]=!0,this.emit("resume"),this[On].length?this[Yg]():this[os]?this[ss]():this.emit("drain"))}resume(){return this[Uc]()}pause(){this[Dn]=!1,this[Nf]=!0,this[oa]=!1}get destroyed(){return this[dn]}get flowing(){return this[Dn]}get paused(){return this[Nf]}[k9](t){this[ei]?this[Pn]+=1:this[Pn]+=t.length,this[On].push(t)}[Xg](){return this[ei]?this[Pn]-=1:this[Pn]-=this[On][0].length,this[On].shift()}[Yg](t=!1){do;while(this[tF](this[Xg]())&&this[On].length);!t&&!this[On].length&&!this[os]&&this.emit("drain")}[tF](t){return this.emit("data",t),this[Dn]}pipe(t,r){if(this[dn])return t;this[oa]=!1;let i=this[su];return r=r||{},t===QB.stdout||t===QB.stderr?r.end=!1:r.end=r.end!==!1,r.proxyErrors=!!r.proxyErrors,i?r.end&&t.end():(this[gi].push(r.proxyErrors?new P9(this,t,r):new ev(this,t,r)),this[Eo]?Bf(()=>this[Uc]()):this[Uc]()),t}unpipe(t){let r=this[gi].find(i=>i.dest===t);r&&(this[gi].length===1?(this[Dn]&&this[ml]===0&&(this[Dn]=!1),this[gi]=[]):this[gi].splice(this[gi].indexOf(r),1),r.unpipe())}addListener(t,r){return this.on(t,r)}on(t,r){let i=super.on(t,r);if(t==="data")this[oa]=!1,this[ml]++,!this[gi].length&&!this[Dn]&&this[Uc]();else if(t==="readable"&&this[Pn]!==0)super.emit("readable");else if(x2e(t)&&this[su])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Tf]){let n=r;this[Eo]?Bf(()=>n.call(this,this[Tf])):n.call(this,this[Tf])}return i}removeListener(t,r){return this.off(t,r)}off(t,r){let i=super.off(t,r);return t==="data"&&(this[ml]=this.listeners("data").length,this[ml]===0&&!this[oa]&&!this[gi].length&&(this[Dn]=!1)),i}removeAllListeners(t){let r=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[ml]=0,!this[oa]&&!this[gi].length&&(this[Dn]=!1)),r}get emittedEnd(){return this[su]}[ss](){!this[Hg]&&!this[su]&&!this[dn]&&this[On].length===0&&this[os]&&(this[Hg]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Jg]&&this.emit("close"),this[Hg]=!1)}emit(t,...r){let i=r[0];if(t!=="error"&&t!=="close"&&t!==dn&&this[dn])return!1;if(t==="data")return!this[ei]&&!i?!1:this[Eo]?(Bf(()=>this[C9](i)),!0):this[C9](i);if(t==="end")return this[rF]();if(t==="close"){if(this[Jg]=!0,!this[su]&&!this[dn])return!1;let a=super.emit("close");return this.removeAllListeners("close"),a}else if(t==="error"){this[Tf]=i,super.emit(A9,i);let a=!this[Rf]||this.listeners("error").length?super.emit("error",i):!1;return this[ss](),a}else if(t==="resume"){let a=super.emit("resume");return this[ss](),a}else if(t==="finish"||t==="prefinish"){let a=super.emit(t);return this.removeAllListeners(t),a}let n=super.emit(t,...r);return this[ss](),n}[C9](t){for(let i of this[gi])i.dest.write(t)===!1&&this.pause();let r=this[oa]?!1:super.emit("data",t);return this[ss](),r}[rF](){return this[su]?!1:(this[su]=!0,this.readable=!1,this[Eo]?(Bf(()=>this[D9]()),!0):this[D9]())}[D9](){if(this[zc]){let r=this[zc].end();if(r){for(let i of this[gi])i.dest.write(r);this[oa]||super.emit("data",r)}}for(let r of this[gi])r.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[ei]||(t.dataLength=0);let r=this.promise();return this.on("data",i=>{t.push(i),this[ei]||(t.dataLength+=i.length)}),await r,t}async concat(){if(this[ei])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[eo]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,r)=>{this.on(dn,()=>r(new Error("stream destroyed"))),this.on("error",i=>r(i)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[oa]=!1;let t=!1,r=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return r();let n=this.read();if(n!==null)return Promise.resolve({done:!1,value:n});if(this[os])return r();let a,o,s=d=>{this.off("data",u),this.off("end",l),this.off(dn,c),r(),o(d)},u=d=>{this.off("error",s),this.off("end",l),this.off(dn,c),this.pause(),a({value:d,done:!!this[os]})},l=()=>{this.off("error",s),this.off("data",u),this.off(dn,c),r(),a({done:!0,value:void 0})},c=()=>s(new Error("stream destroyed"));return new Promise((d,p)=>{o=p,a=d,this.once(dn,c),this.once("error",s),this.once("end",l),this.once("data",u)})},throw:r,return:r,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[oa]=!1;let t=!1,r=()=>(this.pause(),this.off(A9,r),this.off(dn,r),this.off("end",r),t=!0,{done:!0,value:void 0}),i=()=>{if(t)return r();let n=this.read();return n===null?r():{done:!1,value:n}};return this.once("end",r),this.once(A9,r),this.once(dn,r),{next:i,throw:r,return:r,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[dn])return t?this.emit("error",t):this.emit(dn),this;this[dn]=!0,this[oa]=!0,this[On].length=0,this[Pn]=0;let r=this;return typeof r.close=="function"&&!this[Jg]&&r.close(),t?this.emit("error",t):this.emit(dn),this}static get isStream(){return w2e}}});import{posix as O2e,win32 as R9}from"node:path";import{fileURLToPath as P2e}from"node:url";import{lstatSync as I2e,readdir as j2e,readdirSync as T2e,readlinkSync as N2e,realpathSync as R2e}from"fs";import*as B2e from"node:fs";import{lstat as M2e,readdir as L2e,readlink as z2e,realpath as U2e}from"node:fs/promises";var F2e,Mf,uF,lF,q2e,V2e,Pa,cF,dF,$o,pF,fF,hl,mF,Oa,Ff,T9,iF,Lf,to,tv,nv,aF,Z2e,N9,oF,zf,sF,rv,iv,B9,hF,ti,av,ov,sv,qc,Vc,Uf,xMe,gF,vF=Xe(()=>{XB();j9();F2e=R2e.native,Mf={lstatSync:I2e,readdir:j2e,readdirSync:T2e,readlinkSync:N2e,realpathSync:F2e,promises:{lstat:M2e,readdir:L2e,readlink:z2e,realpath:U2e}},uF=e=>!e||e===Mf||e===B2e?Mf:{...Mf,...e,promises:{...Mf.promises,...e.promises||{}}},lF=/^\\\\\?\\([a-z]:)\\?$/i,q2e=e=>e.replace(/\//g,"\\").replace(lF,"$1\\"),V2e=/[\\\/]/,Pa=0,cF=1,dF=2,$o=4,pF=6,fF=8,hl=10,mF=12,Oa=15,Ff=~Oa,T9=16,iF=32,Lf=64,to=128,tv=256,nv=512,aF=Lf|to|nv,Z2e=1023,N9=e=>e.isFile()?fF:e.isDirectory()?$o:e.isSymbolicLink()?hl:e.isCharacterDevice()?dF:e.isBlockDevice()?pF:e.isSocket()?mF:e.isFIFO()?cF:Pa,oF=new Map,zf=e=>{let t=oF.get(e);if(t)return t;let r=e.normalize("NFKD");return oF.set(e,r),r},sF=new Map,rv=e=>{let t=sF.get(e);if(t)return t;let r=zf(e.toLowerCase());return sF.set(e,r),r},iv=class extends jf{constructor(){super({max:256})}},B9=class extends jf{constructor(t=16*1024){super({maxSize:t,sizeCalculation:r=>r.length+1})}},hF=Symbol("PathScurry setAsCwd"),ti=class{name;root;roots;parent;nocase;isCWD=!1;#t;#r;get dev(){return this.#r}#n;get mode(){return this.#n}#e;get nlink(){return this.#e}#i;get uid(){return this.#i}#h;get gid(){return this.#h}#l;get rdev(){return this.#l}#c;get blksize(){return this.#c}#u;get ino(){return this.#u}#s;get size(){return this.#s}#a;get blocks(){return this.#a}#b;get atimeMs(){return this.#b}#g;get mtimeMs(){return this.#g}#y;get ctimeMs(){return this.#y}#f;get birthtimeMs(){return this.#f}#w;get atime(){return this.#w}#m;get mtime(){return this.#m}#S;get ctime(){return this.#S}#x;get birthtime(){return this.#x}#_;#E;#v;#p;#k;#A;#o;#I;#$;#O;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,r=Pa,i,n,a,o,s){this.name=t,this.#_=a?rv(t):zf(t),this.#o=r&Z2e,this.nocase=a,this.roots=n,this.root=i||this,this.#I=o,this.#v=s.fullpath,this.#k=s.relative,this.#A=s.relativePosix,this.parent=s.parent,this.parent?this.#t=this.parent.#t:this.#t=uF(s.fs)}depth(){return this.#E!==void 0?this.#E:this.parent?this.#E=this.parent.depth()+1:this.#E=0}childrenCache(){return this.#I}resolve(t){if(!t)return this;let r=this.getRootString(t),n=t.substring(r.length).split(this.splitSep);return r?this.getRoot(r).#j(n):this.#j(n)}#j(t){let r=this;for(let i of t)r=r.child(i);return r}children(){let t=this.#I.get(this);if(t)return t;let r=Object.assign([],{provisional:0});return this.#I.set(this,r),this.#o&=~T9,r}child(t,r){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let i=this.children(),n=this.nocase?rv(t):zf(t);for(let u of i)if(u.#_===n)return u;let a=this.parent?this.sep:"",o=this.#v?this.#v+a+t:void 0,s=this.newChild(t,Pa,{...r,parent:this,fullpath:o});return this.canReaddir()||(s.#o|=to),i.push(s),s}relative(){if(this.isCWD)return"";if(this.#k!==void 0)return this.#k;let t=this.name,r=this.parent;if(!r)return this.#k=this.name;let i=r.relative();return i+(!i||!r.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#A!==void 0)return this.#A;let t=this.name,r=this.parent;if(!r)return this.#A=this.fullpathPosix();let i=r.relativePosix();return i+(!i||!r.parent?"":"/")+t}fullpath(){if(this.#v!==void 0)return this.#v;let t=this.name,r=this.parent;if(!r)return this.#v=this.name;let n=r.fullpath()+(r.parent?this.sep:"")+t;return this.#v=n}fullpathPosix(){if(this.#p!==void 0)return this.#p;if(this.sep==="/")return this.#p=this.fullpath();if(!this.parent){let n=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(n)?this.#p=`//?/${n}`:this.#p=n}let t=this.parent,r=t.fullpathPosix(),i=r+(!r||!t.parent?"":"/")+this.name;return this.#p=i}isUnknown(){return(this.#o&Oa)===Pa}isType(t){return this[`is${t}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#o&Oa)===fF}isDirectory(){return(this.#o&Oa)===$o}isCharacterDevice(){return(this.#o&Oa)===dF}isBlockDevice(){return(this.#o&Oa)===pF}isFIFO(){return(this.#o&Oa)===cF}isSocket(){return(this.#o&Oa)===mF}isSymbolicLink(){return(this.#o&hl)===hl}lstatCached(){return this.#o&iF?this:void 0}readlinkCached(){return this.#$}realpathCached(){return this.#O}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#$)return!0;if(!this.parent)return!1;let t=this.#o&Oa;return!(t!==Pa&&t!==hl||this.#o&tv||this.#o&to)}calledReaddir(){return!!(this.#o&T9)}isENOENT(){return!!(this.#o&to)}isNamed(t){return this.nocase?this.#_===rv(t):this.#_===zf(t)}async readlink(){let t=this.#$;if(t)return t;if(this.canReadlink()&&this.parent)try{let r=await this.#t.promises.readlink(this.fullpath()),i=(await this.parent.realpath())?.resolve(r);if(i)return this.#$=i}catch(r){this.#d(r.code);return}}readlinkSync(){let t=this.#$;if(t)return t;if(this.canReadlink()&&this.parent)try{let r=this.#t.readlinkSync(this.fullpath()),i=this.parent.realpathSync()?.resolve(r);if(i)return this.#$=i}catch(r){this.#d(r.code);return}}#T(t){this.#o|=T9;for(let r=t.provisional;r<t.length;r++){let i=t[r];i&&i.#N()}}#N(){this.#o&to||(this.#o=(this.#o|to)&Ff,this.#C())}#C(){let t=this.children();t.provisional=0;for(let r of t)r.#N()}#D(){this.#o|=nv,this.#R()}#R(){if(this.#o&Lf)return;let t=this.#o;(t&Oa)===$o&&(t&=Ff),this.#o=t|Lf,this.#C()}#B(t=""){t==="ENOTDIR"||t==="EPERM"?this.#R():t==="ENOENT"?this.#N():this.children().provisional=0}#F(t=""){t==="ENOTDIR"?this.parent.#R():t==="ENOENT"&&this.#N()}#d(t=""){let r=this.#o;r|=tv,t==="ENOENT"&&(r|=to),(t==="EINVAL"||t==="UNKNOWN")&&(r&=Ff),this.#o=r,t==="ENOTDIR"&&this.parent&&this.parent.#R()}#M(t,r){return this.#P(t,r)||this.#L(t,r)}#L(t,r){let i=N9(t),n=this.newChild(t.name,i,{parent:this}),a=n.#o&Oa;return a!==$o&&a!==hl&&a!==Pa&&(n.#o|=Lf),r.unshift(n),r.provisional++,n}#P(t,r){for(let i=r.provisional;i<r.length;i++){let n=r[i];if((this.nocase?rv(t.name):zf(t.name))===n.#_)return this.#z(t,n,i,r)}}#z(t,r,i,n){let a=r.name;return r.#o=r.#o&Ff|N9(t),a!==t.name&&(r.name=t.name),i!==n.provisional&&(i===n.length-1?n.pop():n.splice(i,1),n.unshift(r)),n.provisional++,r}async lstat(){if((this.#o&to)===0)try{return this.#Z(await this.#t.promises.lstat(this.fullpath())),this}catch(t){this.#F(t.code)}}lstatSync(){if((this.#o&to)===0)try{return this.#Z(this.#t.lstatSync(this.fullpath())),this}catch(t){this.#F(t.code)}}#Z(t){let{atime:r,atimeMs:i,birthtime:n,birthtimeMs:a,blksize:o,blocks:s,ctime:u,ctimeMs:l,dev:c,gid:d,ino:p,mode:f,mtime:m,mtimeMs:h,nlink:g,rdev:y,size:_,uid:w}=t;this.#w=r,this.#b=i,this.#x=n,this.#f=a,this.#c=o,this.#a=s,this.#S=u,this.#y=l,this.#r=c,this.#h=d,this.#u=p,this.#n=f,this.#m=m,this.#g=h,this.#e=g,this.#l=y,this.#s=_,this.#i=w;let S=N9(t);this.#o=this.#o&Ff|S|iF,S!==Pa&&S!==$o&&S!==hl&&(this.#o|=Lf)}#q=[];#V=!1;#G(t){this.#V=!1;let r=this.#q.slice();this.#q.length=0,r.forEach(i=>i(null,t))}readdirCB(t,r=!1){if(!this.canReaddir()){r?t(null,[]):queueMicrotask(()=>t(null,[]));return}let i=this.children();if(this.calledReaddir()){let a=i.slice(0,i.provisional);r?t(null,a):queueMicrotask(()=>t(null,a));return}if(this.#q.push(t),this.#V)return;this.#V=!0;let n=this.fullpath();this.#t.readdir(n,{withFileTypes:!0},(a,o)=>{if(a)this.#B(a.code),i.provisional=0;else{for(let s of o)this.#M(s,i);this.#T(i)}this.#G(i.slice(0,i.provisional))})}#U;async readdir(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let r=this.fullpath();if(this.#U)await this.#U;else{let i=()=>{};this.#U=new Promise(n=>i=n);try{for(let n of await this.#t.promises.readdir(r,{withFileTypes:!0}))this.#M(n,t);this.#T(t)}catch(n){this.#B(n.code),t.provisional=0}this.#U=void 0,i()}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let r=this.fullpath();try{for(let i of this.#t.readdirSync(r,{withFileTypes:!0}))this.#M(i,t);this.#T(t)}catch(i){this.#B(i.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#o&aF)return!1;let t=Oa&this.#o;return t===Pa||t===$o||t===hl}shouldWalk(t,r){return(this.#o&$o)===$o&&!(this.#o&aF)&&!t.has(this)&&(!r||r(this))}async realpath(){if(this.#O)return this.#O;if(!((nv|tv|to)&this.#o))try{let t=await this.#t.promises.realpath(this.fullpath());return this.#O=this.resolve(t)}catch{this.#D()}}realpathSync(){if(this.#O)return this.#O;if(!((nv|tv|to)&this.#o))try{let t=this.#t.realpathSync(this.fullpath());return this.#O=this.resolve(t)}catch{this.#D()}}[hF](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let r=new Set([]),i=[],n=this;for(;n&&n.parent;)r.add(n),n.#k=i.join(this.sep),n.#A=i.join("/"),n=n.parent,i.push("..");for(n=t;n&&n.parent&&!r.has(n);)n.#k=void 0,n.#A=void 0,n=n.parent}},av=class e extends ti{sep="\\";splitSep=V2e;constructor(t,r=Pa,i,n,a,o,s){super(t,r,i,n,a,o,s)}newChild(t,r=Pa,i={}){return new e(t,r,this.root,this.roots,this.nocase,this.childrenCache(),i)}getRootString(t){return R9.parse(t).root}getRoot(t){if(t=q2e(t.toUpperCase()),t===this.root.name)return this.root;for(let[r,i]of Object.entries(this.roots))if(this.sameRoot(t,r))return this.roots[t]=i;return this.roots[t]=new qc(t,this).root}sameRoot(t,r=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(lF,"$1\\"),t===r}},ov=class e extends ti{splitSep="/";sep="/";constructor(t,r=Pa,i,n,a,o,s){super(t,r,i,n,a,o,s)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,r=Pa,i={}){return new e(t,r,this.root,this.roots,this.nocase,this.childrenCache(),i)}},sv=class{root;rootPath;roots;cwd;#t;#r;#n;nocase;#e;constructor(t=process.cwd(),r,i,{nocase:n,childrenCacheSize:a=16*1024,fs:o=Mf}={}){this.#e=uF(o),(t instanceof URL||t.startsWith("file://"))&&(t=P2e(t));let s=r.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(s),this.#t=new iv,this.#r=new iv,this.#n=new B9(a);let u=s.substring(this.rootPath.length).split(i);if(u.length===1&&!u[0]&&u.pop(),n===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=n,this.root=this.newRoot(this.#e),this.roots[this.rootPath]=this.root;let l=this.root,c=u.length-1,d=r.sep,p=this.rootPath,f=!1;for(let m of u){let h=c--;l=l.child(m,{relative:new Array(h).fill("..").join(d),relativePosix:new Array(h).fill("..").join("/"),fullpath:p+=(f?"":d)+m}),f=!0}this.cwd=l}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#n}resolve(...t){let r="";for(let a=t.length-1;a>=0;a--){let o=t[a];if(!(!o||o===".")&&(r=r?`${o}/${r}`:o,this.isAbsolute(o)))break}let i=this.#t.get(r);if(i!==void 0)return i;let n=this.cwd.resolve(r).fullpath();return this.#t.set(r,n),n}resolvePosix(...t){let r="";for(let a=t.length-1;a>=0;a--){let o=t[a];if(!(!o||o===".")&&(r=r?`${o}/${r}`:o,this.isAbsolute(o)))break}let i=this.#r.get(r);if(i!==void 0)return i;let n=this.cwd.resolve(r).fullpathPosix();return this.#r.set(r,n),n}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,r={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t,t=this.cwd);let{withFileTypes:i}=r;if(t.canReaddir()){let n=await t.readdir();return i?n:n.map(a=>a.name)}else return[]}readdirSync(t=this.cwd,r={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t,t=this.cwd);let{withFileTypes:i=!0}=r;return t.canReaddir()?i?t.readdirSync():t.readdirSync().map(n=>n.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t.withFileTypes,t=this.cwd);let i=await t.readlink();return r?i:i?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t.withFileTypes,t=this.cwd);let i=t.readlinkSync();return r?i:i?.fullpath()}async realpath(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t.withFileTypes,t=this.cwd);let i=await t.realpath();return r?i:i?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t.withFileTypes,t=this.cwd);let i=t.realpathSync();return r?i:i?.fullpath()}async walk(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t,t=this.cwd);let{withFileTypes:i=!0,follow:n=!1,filter:a,walkFilter:o}=r,s=[];(!a||a(t))&&s.push(i?t:t.fullpath());let u=new Set,l=(d,p)=>{u.add(d),d.readdirCB((f,m)=>{if(f)return p(f);let h=m.length;if(!h)return p();let g=()=>{--h===0&&p()};for(let y of m)(!a||a(y))&&s.push(i?y:y.fullpath()),n&&y.isSymbolicLink()?y.realpath().then(_=>_?.isUnknown()?_.lstat():_).then(_=>_?.shouldWalk(u,o)?l(_,g):g()):y.shouldWalk(u,o)?l(y,g):g()},!0)},c=t;return new Promise((d,p)=>{l(c,f=>{if(f)return p(f);d(s)})})}walkSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t,t=this.cwd);let{withFileTypes:i=!0,follow:n=!1,filter:a,walkFilter:o}=r,s=[];(!a||a(t))&&s.push(i?t:t.fullpath());let u=new Set([t]);for(let l of u){let c=l.readdirSync();for(let d of c){(!a||a(d))&&s.push(i?d:d.fullpath());let p=d;if(d.isSymbolicLink()){if(!(n&&(p=d.realpathSync())))continue;p.isUnknown()&&p.lstatSync()}p.shouldWalk(u,o)&&u.add(p)}}return s}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,r={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t,t=this.cwd),this.stream(t,r)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t,t=this.cwd);let{withFileTypes:i=!0,follow:n=!1,filter:a,walkFilter:o}=r;(!a||a(t))&&(yield i?t:t.fullpath());let s=new Set([t]);for(let u of s){let l=u.readdirSync();for(let c of l){(!a||a(c))&&(yield i?c:c.fullpath());let d=c;if(c.isSymbolicLink()){if(!(n&&(d=c.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(s,o)&&s.add(d)}}}stream(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t,t=this.cwd);let{withFileTypes:i=!0,follow:n=!1,filter:a,walkFilter:o}=r,s=new uu({objectMode:!0});(!a||a(t))&&s.write(i?t:t.fullpath());let u=new Set,l=[t],c=0,d=()=>{let p=!1;for(;!p;){let f=l.shift();if(!f){c===0&&s.end();return}c++,u.add(f);let m=(g,y,_=!1)=>{if(g)return s.emit("error",g);if(n&&!_){let w=[];for(let S of y)S.isSymbolicLink()&&w.push(S.realpath().then(C=>C?.isUnknown()?C.lstat():C));if(w.length){Promise.all(w).then(()=>m(null,y,!0));return}}for(let w of y)w&&(!a||a(w))&&(s.write(i?w:w.fullpath())||(p=!0));c--;for(let w of y){let S=w.realpathCached()||w;S.shouldWalk(u,o)&&l.push(S)}p&&!s.flowing?s.once("drain",d):h||d()},h=!0;f.readdirCB(m,!0),h=!1}};return d(),s}streamSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t,t=this.cwd);let{withFileTypes:i=!0,follow:n=!1,filter:a,walkFilter:o}=r,s=new uu({objectMode:!0}),u=new Set;(!a||a(t))&&s.write(i?t:t.fullpath());let l=[t],c=0,d=()=>{let p=!1;for(;!p;){let f=l.shift();if(!f){c===0&&s.end();return}c++,u.add(f);let m=f.readdirSync();for(let h of m)(!a||a(h))&&(s.write(i?h:h.fullpath())||(p=!0));c--;for(let h of m){let g=h;if(h.isSymbolicLink()){if(!(n&&(g=h.realpathSync())))continue;g.isUnknown()&&g.lstatSync()}g.shouldWalk(u,o)&&l.push(g)}}p&&!s.flowing&&s.once("drain",d)};return d(),s}chdir(t=this.cwd){let r=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[hF](r)}},qc=class extends sv{sep="\\";constructor(t=process.cwd(),r={}){let{nocase:i=!0}=r;super(t,R9,"\\",{...r,nocase:i}),this.nocase=i;for(let n=this.cwd;n;n=n.parent)n.nocase=this.nocase}parseRootPath(t){return R9.parse(t).root.toUpperCase()}newRoot(t){return new av(this.rootPath,$o,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},Vc=class extends sv{sep="/";constructor(t=process.cwd(),r={}){let{nocase:i=!1}=r;super(t,O2e,"/",{...r,nocase:i}),this.nocase=i}parseRootPath(t){return"/"}newRoot(t){return new ov(this.rootPath,$o,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},Uf=class extends Vc{constructor(t=process.cwd(),r={}){let{nocase:i=!0}=r;super(t,{...r,nocase:i})}},xMe=process.platform==="win32"?av:ov,gF=process.platform==="win32"?qc:process.platform==="darwin"?Uf:Vc});var G2e,W2e,Zc,F9=Xe(()=>{au();G2e=e=>e.length>=1,W2e=e=>e.length>=1,Zc=class e{#t;#r;#n;length;#e;#i;#h;#l;#c;#u;#s=!0;constructor(t,r,i,n){if(!G2e(t))throw new TypeError("empty pattern list");if(!W2e(r))throw new TypeError("empty glob list");if(r.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,i<0||i>=this.length)throw new TypeError("index out of range");if(this.#t=t,this.#r=r,this.#n=i,this.#e=n,this.#n===0){if(this.isUNC()){let[a,o,s,u,...l]=this.#t,[c,d,p,f,...m]=this.#r;l[0]===""&&(l.shift(),m.shift());let h=[a,o,s,u,""].join("/"),g=[c,d,p,f,""].join("/");this.#t=[h,...l],this.#r=[g,...m],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[a,...o]=this.#t,[s,...u]=this.#r;o[0]===""&&(o.shift(),u.shift());let l=a+"/",c=s+"/";this.#t=[l,...o],this.#r=[c,...u],this.length=this.#t.length}}}pattern(){return this.#t[this.#n]}isString(){return typeof this.#t[this.#n]=="string"}isGlobstar(){return this.#t[this.#n]===cn}isRegExp(){return this.#t[this.#n]instanceof RegExp}globString(){return this.#h=this.#h||(this.#n===0?this.isAbsolute()?this.#r[0]+this.#r.slice(1).join("/"):this.#r.join("/"):this.#r.slice(this.#n).join("/"))}hasMore(){return this.length>this.#n+1}rest(){return this.#i!==void 0?this.#i:this.hasMore()?(this.#i=new e(this.#t,this.#r,this.#n+1,this.#e),this.#i.#u=this.#u,this.#i.#c=this.#c,this.#i.#l=this.#l,this.#i):this.#i=null}isUNC(){let t=this.#t;return this.#c!==void 0?this.#c:this.#c=this.#e==="win32"&&this.#n===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#t;return this.#l!==void 0?this.#l:this.#l=this.#e==="win32"&&this.#n===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#t;return this.#u!==void 0?this.#u:this.#u=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#t[0];return typeof t=="string"&&this.isAbsolute()&&this.#n===0?t:""}checkFollowGlobstar(){return!(this.#n===0||!this.isGlobstar()||!this.#s)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#s?!1:(this.#s=!1,!0)}}});var K2e,Gc,M9=Xe(()=>{au();F9();K2e=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Gc=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(t,{nobrace:r,nocase:i,noext:n,noglobstar:a,platform:o=K2e}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:r,nocase:i,noext:n,noglobstar:a,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let s of t)this.add(s)}add(t){let r=new aa(t,this.mmopts);for(let i=0;i<r.set.length;i++){let n=r.set[i],a=r.globParts[i];if(!n||!a)throw new Error("invalid pattern object");for(;n[0]==="."&&a[0]===".";)n.shift(),a.shift();let o=new Zc(n,a,0,this.platform),s=new aa(o.globString(),this.mmopts),u=a[a.length-1]==="**",l=o.isAbsolute();l?this.absolute.push(s):this.relative.push(s),u&&(l?this.absoluteChildren.push(s):this.relativeChildren.push(s))}}ignored(t){let r=t.fullpath(),i=`${r}/`,n=t.relative()||".",a=`${n}/`;for(let o of this.relative)if(o.match(n)||o.match(a))return!0;for(let o of this.absolute)if(o.match(r)||o.match(i))return!0;return!1}childrenIgnored(t){let r=t.fullpath()+"/",i=(t.relative()||".")+"/";for(let n of this.relativeChildren)if(n.match(i))return!0;for(let n of this.absoluteChildren)if(n.match(r))return!0;return!1}}});var L9,z9,U9,qf,yF=Xe(()=>{au();L9=class e{store;constructor(t=new Map){this.store=t}copy(){return new e(new Map(this.store))}hasWalked(t,r){return this.store.get(t.fullpath())?.has(r.globString())}storeWalked(t,r){let i=t.fullpath(),n=this.store.get(i);n?n.add(r.globString()):this.store.set(i,new Set([r.globString()]))}},z9=class{store=new Map;add(t,r,i){let n=(r?2:0)|(i?1:0),a=this.store.get(t);this.store.set(t,a===void 0?n:n&a)}entries(){return[...this.store.entries()].map(([t,r])=>[t,!!(r&2),!!(r&1)])}},U9=class{store=new Map;add(t,r){if(!t.canReaddir())return;let i=this.store.get(t);i?i.find(n=>n.globString()===r.globString())||i.push(r):this.store.set(t,[r])}get(t){let r=this.store.get(t);if(!r)throw new Error("attempting to walk unknown path");return r}entries(){return this.keys().map(t=>[t,this.store.get(t)])}keys(){return[...this.store.keys()].filter(t=>t.canReaddir())}},qf=class e{hasWalkedCache;matches=new z9;subwalks=new U9;patterns;follow;dot;opts;constructor(t,r){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=r?r.copy():new L9}processPatterns(t,r){this.patterns=r;let i=r.map(n=>[t,n]);for(let[n,a]of i){this.hasWalkedCache.storeWalked(n,a);let o=a.root(),s=a.isAbsolute()&&this.opts.absolute!==!1;if(o){n=n.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let d=a.rest();if(d)a=d;else{this.matches.add(n,!0,!1);continue}}if(n.isENOENT())continue;let u,l,c=!1;for(;typeof(u=a.pattern())=="string"&&(l=a.rest());)n=n.resolve(u),a=l,c=!0;if(u=a.pattern(),l=a.rest(),c){if(this.hasWalkedCache.hasWalked(n,a))continue;this.hasWalkedCache.storeWalked(n,a)}if(typeof u=="string"){let d=u===".."||u===""||u===".";this.matches.add(n.resolve(u),s,d);continue}else if(u===cn){(!n.isSymbolicLink()||this.follow||a.checkFollowGlobstar())&&this.subwalks.add(n,a);let d=l?.pattern(),p=l?.rest();if(!l||(d===""||d===".")&&!p)this.matches.add(n,s,d===""||d===".");else if(d===".."){let f=n.parent||n;p?this.hasWalkedCache.hasWalked(f,p)||this.subwalks.add(f,p):this.matches.add(f,s,!0)}}else u instanceof RegExp&&this.subwalks.add(n,a)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new e(this.opts,this.hasWalkedCache)}filterEntries(t,r){let i=this.subwalks.get(t),n=this.child();for(let a of r)for(let o of i){let s=o.isAbsolute(),u=o.pattern(),l=o.rest();u===cn?n.testGlobstar(a,o,l,s):u instanceof RegExp?n.testRegExp(a,u,l,s):n.testString(a,u,l,s)}return n}testGlobstar(t,r,i,n){if((this.dot||!t.name.startsWith("."))&&(r.hasMore()||this.matches.add(t,n,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,r):t.isSymbolicLink()&&(i&&r.checkFollowGlobstar()?this.subwalks.add(t,i):r.markFollowGlobstar()&&this.subwalks.add(t,r)))),i){let a=i.pattern();if(typeof a=="string"&&a!==".."&&a!==""&&a!==".")this.testString(t,a,i.rest(),n);else if(a===".."){let o=t.parent||t;this.subwalks.add(o,i)}else a instanceof RegExp&&this.testRegExp(t,a,i.rest(),n)}}testRegExp(t,r,i,n){r.test(t.name)&&(i?this.subwalks.add(t,i):this.matches.add(t,n,!1))}testString(t,r,i,n){t.isNamed(r)&&(i?this.subwalks.add(t,i):this.matches.add(t,n,!1))}}});var H2e,uv,Vf,Zf,_F=Xe(()=>{j9();M9();yF();H2e=(e,t)=>typeof e=="string"?new Gc([e],t):Array.isArray(e)?new Gc(e,t):e,uv=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#t=[];#r;#n;signal;maxDepth;includeChildMatches;constructor(t,r,i){if(this.patterns=t,this.path=r,this.opts=i,this.#n=!i.posix&&i.platform==="win32"?"\\":"/",this.includeChildMatches=i.includeChildMatches!==!1,(i.ignore||!this.includeChildMatches)&&(this.#r=H2e(i.ignore??[],i),!this.includeChildMatches&&typeof this.#r.add!="function")){let n="cannot ignore child matches, ignore lacks add() method.";throw new Error(n)}this.maxDepth=i.maxDepth||1/0,i.signal&&(this.signal=i.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0}))}#e(t){return this.seen.has(t)||!!this.#r?.ignored?.(t)}#i(t){return!!this.#r?.childrenIgnored?.(t)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let t;for(;!this.paused&&(t=this.#t.shift());)t()}onResume(t){this.signal?.aborted||(this.paused?this.#t.push(t):t())}async matchCheck(t,r){if(r&&this.opts.nodir)return;let i;if(this.opts.realpath){if(i=t.realpathCached()||await t.realpath(),!i)return;t=i}let a=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&a?.isSymbolicLink()){let o=await a.realpath();o&&(o.isUnknown()||this.opts.stat)&&await o.lstat()}return this.matchCheckTest(a,r)}matchCheckTest(t,r){return t&&(this.maxDepth===1/0||t.depth()<=this.maxDepth)&&(!r||t.canReaddir())&&(!this.opts.nodir||!t.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!t.isSymbolicLink()||!t.realpathCached()?.isDirectory())&&!this.#e(t)?t:void 0}matchCheckSync(t,r){if(r&&this.opts.nodir)return;let i;if(this.opts.realpath){if(i=t.realpathCached()||t.realpathSync(),!i)return;t=i}let a=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&a?.isSymbolicLink()){let o=a.realpathSync();o&&(o?.isUnknown()||this.opts.stat)&&o.lstatSync()}return this.matchCheckTest(a,r)}matchFinish(t,r){if(this.#e(t))return;if(!this.includeChildMatches&&this.#r?.add){let a=`${t.relativePosix()}/**`;this.#r.add(a)}let i=this.opts.absolute===void 0?r:this.opts.absolute;this.seen.add(t);let n=this.opts.mark&&t.isDirectory()?this.#n:"";if(this.opts.withFileTypes)this.matchEmit(t);else if(i){let a=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(a+n)}else{let a=this.opts.posix?t.relativePosix():t.relative(),o=this.opts.dotRelative&&!a.startsWith(".."+this.#n)?"."+this.#n:"";this.matchEmit(a?o+a+n:"."+n)}}async match(t,r,i){let n=await this.matchCheck(t,i);n&&this.matchFinish(n,r)}matchSync(t,r,i){let n=this.matchCheckSync(t,i);n&&this.matchFinish(n,r)}walkCB(t,r,i){this.signal?.aborted&&i(),this.walkCB2(t,r,new qf(this.opts),i)}walkCB2(t,r,i,n){if(this.#i(t))return n();if(this.signal?.aborted&&n(),this.paused){this.onResume(()=>this.walkCB2(t,r,i,n));return}i.processPatterns(t,r);let a=1,o=()=>{--a===0&&n()};for(let[s,u,l]of i.matches.entries())this.#e(s)||(a++,this.match(s,u,l).then(()=>o()));for(let s of i.subwalkTargets()){if(this.maxDepth!==1/0&&s.depth()>=this.maxDepth)continue;a++;let u=s.readdirCached();s.calledReaddir()?this.walkCB3(s,u,i,o):s.readdirCB((l,c)=>this.walkCB3(s,c,i,o),!0)}o()}walkCB3(t,r,i,n){i=i.filterEntries(t,r);let a=1,o=()=>{--a===0&&n()};for(let[s,u,l]of i.matches.entries())this.#e(s)||(a++,this.match(s,u,l).then(()=>o()));for(let[s,u]of i.subwalks.entries())a++,this.walkCB2(s,u,i.child(),o);o()}walkCBSync(t,r,i){this.signal?.aborted&&i(),this.walkCB2Sync(t,r,new qf(this.opts),i)}walkCB2Sync(t,r,i,n){if(this.#i(t))return n();if(this.signal?.aborted&&n(),this.paused){this.onResume(()=>this.walkCB2Sync(t,r,i,n));return}i.processPatterns(t,r);let a=1,o=()=>{--a===0&&n()};for(let[s,u,l]of i.matches.entries())this.#e(s)||this.matchSync(s,u,l);for(let s of i.subwalkTargets()){if(this.maxDepth!==1/0&&s.depth()>=this.maxDepth)continue;a++;let u=s.readdirSync();this.walkCB3Sync(s,u,i,o)}o()}walkCB3Sync(t,r,i,n){i=i.filterEntries(t,r);let a=1,o=()=>{--a===0&&n()};for(let[s,u,l]of i.matches.entries())this.#e(s)||this.matchSync(s,u,l);for(let[s,u]of i.subwalks.entries())a++,this.walkCB2Sync(s,u,i.child(),o);o()}},Vf=class extends uv{matches=new Set;constructor(t,r,i){super(t,r,i)}matchEmit(t){this.matches.add(t)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,r)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?r(this.signal.reason):t(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},Zf=class extends uv{results;constructor(t,r,i){super(t,r,i),this.results=new uu({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(t){this.results.write(t),this.results.flowing||this.pause()}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end())}):this.walkCB(t,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}});import{fileURLToPath as J2e}from"node:url";var Y2e,ro,q9=Xe(()=>{au();vF();F9();_F();Y2e=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",ro=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(t,r){if(!r)throw new TypeError("glob options required");if(this.withFileTypes=!!r.withFileTypes,this.signal=r.signal,this.follow=!!r.follow,this.dot=!!r.dot,this.dotRelative=!!r.dotRelative,this.nodir=!!r.nodir,this.mark=!!r.mark,r.cwd?(r.cwd instanceof URL||r.cwd.startsWith("file://"))&&(r.cwd=J2e(r.cwd)):this.cwd="",this.cwd=r.cwd||"",this.root=r.root,this.magicalBraces=!!r.magicalBraces,this.nobrace=!!r.nobrace,this.noext=!!r.noext,this.realpath=!!r.realpath,this.absolute=r.absolute,this.includeChildMatches=r.includeChildMatches!==!1,this.noglobstar=!!r.noglobstar,this.matchBase=!!r.matchBase,this.maxDepth=typeof r.maxDepth=="number"?r.maxDepth:1/0,this.stat=!!r.stat,this.ignore=r.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof t=="string"&&(t=[t]),this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(t=t.map(u=>u.replace(/\\/g,"/"))),this.matchBase){if(r.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(u=>u.includes("/")?u:`./**/${u}`)}if(this.pattern=t,this.platform=r.platform||Y2e,this.opts={...r,platform:this.platform},r.scurry){if(this.scurry=r.scurry,r.nocase!==void 0&&r.nocase!==r.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let u=r.platform==="win32"?qc:r.platform==="darwin"?Uf:r.platform?Vc:gF;this.scurry=new u(this.cwd,{nocase:r.nocase,fs:r.fs})}this.nocase=this.scurry.nocase;let i=this.platform==="darwin"||this.platform==="win32",n={...r,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:i,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},a=this.pattern.map(u=>new aa(u,n)),[o,s]=a.reduce((u,l)=>(u[0].push(...l.set),u[1].push(...l.globParts),u),[[],[]]);this.patterns=o.map((u,l)=>{let c=s[l];if(!c)throw new Error("invalid pattern object");return new Zc(u,c,0,this.platform)})}async walk(){return[...await new Vf(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new Vf(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new Zf(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new Zf(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}});var V9,Z9=Xe(()=>{au();V9=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let r of e)if(new aa(r,t).hasMagic())return!0;return!1}});function lv(e,t={}){return new ro(e,t).streamSync()}function wF(e,t={}){return new ro(e,t).stream()}function SF(e,t={}){return new ro(e,t).walkSync()}async function bF(e,t={}){return new ro(e,t).walk()}function cv(e,t={}){return new ro(e,t).iterateSync()}function EF(e,t={}){return new ro(e,t).iterate()}var X2e,Q2e,e6e,t6e,r6e,lu,dv=Xe(()=>{au();q9();Z9();au();q9();Z9();M9();X2e=lv,Q2e=Object.assign(wF,{sync:lv}),e6e=cv,t6e=Object.assign(EF,{sync:cv}),r6e=Object.assign(SF,{stream:lv,iterate:cv}),lu=Object.assign(bF,{glob:bF,globSync:SF,sync:r6e,globStream:wF,stream:Q2e,globStreamSync:lv,streamSync:X2e,globIterate:EF,iterate:t6e,globIterateSync:cv,iterateSync:e6e,Glob:ro,hasMagic:V9,escape:Fc,unescape:Qa});lu.glob=lu});import cu from"fs";import Wc from"path";import n6e from"crypto";function pv(e){let t=cu.readFileSync(e);return n6e.createHash("sha256").update(t).digest("hex")}async function fv(e,t=["**/*"]){let r=[];for(let i of t){let n=await lu(i,{cwd:e,nodir:!0,ignore:["**/node_modules/**","**/.git/**",Kc]});r.push(...n)}return[...new Set(r)].sort()}function a6e(e,t){let r=Object.keys(e).sort(),i=Object.keys(t).sort();if(r.length!==i.length||r.join(",")!==i.join(","))return!1;for(let n of r)if(e[n].sha256!==t[n].sha256)return!1;return!0}async function Hc(e,t={}){let{generatorVersion:r="1.0.0",inputHash:i,sourceMap:n=new Map,patterns:a=["**/*"]}=t,o=await fv(e,a),s={};for(let h of o){let g=Wc.join(e,h);if(!cu.existsSync(g)||cu.statSync(g).isDirectory())continue;let y={sha256:pv(g)},_=n.get(h);_&&(y.source=_),s[h]=y}let u=Jc(e),l=!u||!a6e(u.files,s),c=!u||u.generatorVersion!==r,d=i!==void 0&&(!u||u.inputHash!==i),p=l||c||d,f=p?new Date().toISOString():u?.updatedAt,m={version:i6e,generatorVersion:r,files:s};return i!==void 0&&(m.inputHash=i),f&&(m.updatedAt=f),{manifest:m,changed:p}}async function Gf(e,t){let r=Jc(e);if(!r)return{skip:!1,reason:"No manifest found"};if(!r.inputHash)return{skip:!1,reason:"Manifest has no inputHash (pre-cache version)"};if(r.inputHash!==t)return{skip:!1,reason:"Input files have changed"};let i=await mv(e);return i.valid?{skip:!0,reason:"Input and output hashes match"}:{skip:!1,reason:`${i.mismatches.length} generated file(s) have been modified`}}function gl(e,t){let r=Wc.join(t,Kc);return cu.writeFileSync(r,JSON.stringify(e,null,2)+`
286
+ `)}var v9=Xe(()=>{"use strict"});var $B=He((KFe,EB)=>{"use strict";EB.exports=wB;function wB(e,t,r){e instanceof RegExp&&(e=bB(e,r)),t instanceof RegExp&&(t=bB(t,r));var i=SB(e,t,r);return i&&{start:i[0],end:i[1],pre:r.slice(0,i[0]),body:r.slice(i[0]+e.length,i[1]),post:r.slice(i[1]+t.length)}}function bB(e,t){var r=t.match(e);return r?r[0]:null}wB.range=SB;function SB(e,t,r){var i,n,a,o,s,u=r.indexOf(e),l=r.indexOf(t,u+1),c=u;if(u>=0&&l>0){if(e===t)return[u,l];for(i=[],a=r.length;c>=0&&!s;)c==u?(i.push(c),u=r.indexOf(e,c+1)):i.length==1?s=[i.pop(),l]:(n=i.pop(),n<a&&(a=n,o=l),l=r.indexOf(t,c+1)),c=u<l&&u>=0?u:l;i.length&&(s=[a,o])}return s}});var IB=He((HFe,PB)=>{var xB=$B();PB.exports=Dye;var kB="\0SLASH"+Math.random()+"\0",AB="\0OPEN"+Math.random()+"\0",_9="\0CLOSE"+Math.random()+"\0",CB="\0COMMA"+Math.random()+"\0",DB="\0PERIOD"+Math.random()+"\0";function y9(e){return parseInt(e,10)==e?parseInt(e,10):e.charCodeAt(0)}function Aye(e){return e.split("\\\\").join(kB).split("\\{").join(AB).split("\\}").join(_9).split("\\,").join(CB).split("\\.").join(DB)}function Cye(e){return e.split(kB).join("\\").split(AB).join("{").split(_9).join("}").split(CB).join(",").split(DB).join(".")}function OB(e){if(!e)return[""];var t=[],r=xB("{","}",e);if(!r)return e.split(",");var i=r.pre,n=r.body,a=r.post,o=i.split(",");o[o.length-1]+="{"+n+"}";var s=OB(a);return a.length&&(o[o.length-1]+=s.shift(),o.push.apply(o,s)),t.push.apply(t,o),t}function Dye(e,t){if(!e)return[];t=t||{};var r=t.max==null?1/0:t.max;return e.substr(0,2)==="{}"&&(e="\\{\\}"+e.substr(2)),Of(Aye(e),r,!0).map(Cye)}function Oye(e){return"{"+e+"}"}function Pye(e){return/^-?0\d/.test(e)}function Iye(e,t){return e<=t}function jye(e,t){return e>=t}function Of(e,t,r){var i=[],n=xB("{","}",e);if(!n)return[e];var a=n.pre,o=n.post.length?Of(n.post,t,!1):[""];if(/\$$/.test(n.pre))for(var s=0;s<o.length&&s<t;s++){var u=a+"{"+n.body+"}"+o[s];i.push(u)}else{var l=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),d=l||c,p=n.body.indexOf(",")>=0;if(!d&&!p)return n.post.match(/,(?!,).*\}/)?(e=n.pre+"{"+n.body+_9+n.post,Of(e,t,!0)):[e];var f;if(d)f=n.body.split(/\.\./);else if(f=OB(n.body),f.length===1&&(f=Of(f[0],t,!1).map(Oye),f.length===1))return o.map(function($){return n.pre+f[0]+$});var m;if(d){var h=y9(f[0]),g=y9(f[1]),y=Math.max(f[0].length,f[1].length),_=f.length==3?Math.max(Math.abs(y9(f[2])),1):1,w=Iye,S=g<h;S&&(_*=-1,w=jye);var C=f.some(Pye);m=[];for(var D=h;w(D,g)&&m.length<t;D+=_){var E;if(c)E=String.fromCharCode(D),E==="\\"&&(E="");else if(E=String(D),C){var A=y-E.length;if(A>0){var P=new Array(A+1).join("0");D<0?E="-"+P+E.slice(1):E=P+E}}m.push(E)}}else{m=[];for(var O=0;O<f.length;O++)m.push.apply(m,Of(f[O],t,!1))}for(var O=0;O<m.length;O++)for(var s=0;s<o.length&&i.length<t;s++){var u=a+m[O]+o[s];(!r||d||u)&&i.push(u)}}return i}});var Pf,jB=Xe(()=>{Pf=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")}});var Tye,If,Nye,TB,NB,RB=Xe(()=>{Tye={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},If=e=>e.replace(/[[\]\\-]/g,"\\$&"),Nye=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),TB=e=>e.join(""),NB=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let i=[],n=[],a=r+1,o=!1,s=!1,u=!1,l=!1,c=r,d="";e:for(;a<e.length;){let h=e.charAt(a);if((h==="!"||h==="^")&&a===r+1){l=!0,a++;continue}if(h==="]"&&o&&!u){c=a+1;break}if(o=!0,h==="\\"&&!u){u=!0,a++;continue}if(h==="["&&!u){for(let[g,[y,_,w]]of Object.entries(Tye))if(e.startsWith(g,a)){if(d)return["$.",!1,e.length-r,!0];a+=g.length,w?n.push(y):i.push(y),s=s||_;continue e}}if(u=!1,d){h>d?i.push(If(d)+"-"+If(h)):h===d&&i.push(If(h)),d="",a++;continue}if(e.startsWith("-]",a+1)){i.push(If(h+"-")),a+=2;continue}if(e.startsWith("-",a+1)){d=h,a+=2;continue}i.push(If(h)),a++}if(c<a)return["",!1,0,!1];if(!i.length&&!n.length)return["$.",!1,e.length-r,!0];if(n.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!l){let h=i[0].length===2?i[0].slice(-1):i[0];return[Nye(h),!1,c-r,!1]}let p="["+(l?"^":"")+TB(i)+"]",f="["+(l?"":"^")+TB(n)+"]";return[i.length&&n.length?"("+p+"|"+f+")":i.length?p:f,s,c-r,!0]}});var Qa,Gg=Xe(()=>{Qa=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")});var Ri,Rye,b9,BB,Bye,Fye,Mye,FB,Lye,Wg,zye,Uye,qye,Vye,w9,MB,LB,fl,S9=Xe(()=>{RB();Gg();Rye=new Set(["!","?","+","*","@"]),b9=e=>Rye.has(e),BB=e=>b9(e.type),Bye=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Fye=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Mye=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),FB=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Lye="(?!(?:^|/)\\.\\.?(?:$|/))",Wg="(?!\\.)",zye=new Set(["[","."]),Uye=new Set(["..","."]),qye=new Set("().*{}+?[]^$\\!"),Vye=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),w9="[^/]",MB=w9+"*?",LB=w9+"+?",fl=class{type;#t;#r;#n=!1;#e=[];#i;#h;#l;#c=!1;#u;#s;#a=!1;constructor(t,r,i={}){this.type=t,t&&(this.#r=!0),this.#i=r,this.#t=this.#i?this.#i.#t:this,this.#u=this.#t===this?i:this.#t.#u,this.#l=this.#t===this?[]:this.#t.#l,t==="!"&&!this.#t.#c&&this.#l.push(this),this.#h=this.#i?this.#i.#e.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let t of this.#e)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#s!==void 0?this.#s:this.type?this.#s=this.type+"("+this.#e.map(t=>String(t)).join("|")+")":this.#s=this.#e.map(t=>String(t)).join("")}#b(){if(this!==this.#t)throw new Error("should only call on root");if(this.#c)return this;this.toString(),this.#c=!0;let t;for(;t=this.#l.pop();){if(t.type!=="!")continue;let r=t,i=r.#i;for(;i;){for(let n=r.#h+1;!i.type&&n<i.#e.length;n++)for(let a of t.#e){if(typeof a=="string")throw new Error("string part in extglob AST??");a.copyIn(i.#e[n])}r=i,i=r.#i}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof Ri&&r.#i===this))throw new Error("invalid part: "+r);this.#e.push(r)}}toJSON(){let t=this.type===null?this.#e.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#e.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#c&&this.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#i?.isStart())return!1;if(this.#h===0)return!0;let t=this.#i;for(let r=0;r<this.#h;r++){let i=t.#e[r];if(!(i instanceof Ri&&i.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#e.length:0;return this.#h===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new Ri(this.type,t);for(let i of this.#e)r.copyIn(i);return r}static#g(t,r,i,n,a){let o=n.maxExtglobRecursion??2,s=!1,u=!1,l=-1,c=!1;if(r.type===null){let h=i,g="";for(;h<t.length;){let y=t.charAt(h++);if(s||y==="\\"){s=!s,g+=y;continue}if(u){h===l+1?(y==="^"||y==="!")&&(c=!0):y==="]"&&!(h===l+2&&c)&&(u=!1),g+=y;continue}else if(y==="["){u=!0,l=h,c=!1,g+=y;continue}if(!n.noext&&b9(y)&&t.charAt(h)==="("&&a<=o){r.push(g),g="";let w=new Ri(y,r);h=Ri.#g(t,w,h,n,a+1),r.push(w);continue}g+=y}return r.push(g),h}let d=i+1,p=new Ri(null,r),f=[],m="";for(;d<t.length;){let h=t.charAt(d++);if(s||h==="\\"){s=!s,m+=h;continue}if(u){d===l+1?(h==="^"||h==="!")&&(c=!0):h==="]"&&!(d===l+2&&c)&&(u=!1),m+=h;continue}else if(h==="["){u=!0,l=d,c=!1,m+=h;continue}if(b9(h)&&t.charAt(d)==="("&&(a<=o||r&&r.#w(h))){let y=r&&r.#w(h)?0:1;p.push(m),m="";let _=new Ri(h,p);p.push(_),d=Ri.#g(t,_,d,n,a+y);continue}if(h==="|"){p.push(m),m="",f.push(p),p=new Ri(null,r);continue}if(h===")")return m===""&&r.#e.length===0&&(r.#a=!0),p.push(m),m="",r.push(...f,p),d;m+=h}return r.type=null,r.#r=void 0,r.#e=[t.substring(i-1)],d}#y(t){return this.#f(t,Fye)}#f(t,r=Bye){if(!t||typeof t!="object"||t.type!==null||t.#e.length!==1||this.type===null)return!1;let i=t.#e[0];return!i||typeof i!="object"||i.type===null?!1:this.#w(i.type,r)}#w(t,r=Mye){return!!r.get(this.type)?.includes(t)}#m(t,r){let i=t.#e[0],n=new Ri(null,i,this.options);n.#e.push(""),i.push(n),this.#S(t,r)}#S(t,r){let i=t.#e[0];this.#e.splice(r,1,...i.#e);for(let n of i.#e)typeof n=="object"&&(n.#i=this);this.#s=void 0}#x(t){return!!FB.get(this.type)?.has(t)}#_(t){if(!t||typeof t!="object"||t.type!==null||t.#e.length!==1||this.type===null||this.#e.length!==1)return!1;let r=t.#e[0];return!r||typeof r!="object"||r.type===null?!1:this.#x(r.type)}#E(t){let r=FB.get(this.type),i=t.#e[0],n=r?.get(i.type);if(!n)return!1;this.#e=i.#e;for(let a of this.#e)typeof a=="object"&&(a.#i=this);this.type=n,this.#s=void 0,this.#a=!1}#v(){if(BB(this)){let t=0,r=!1;do{r=!0;for(let i=0;i<this.#e.length;i++){let n=this.#e[i];typeof n=="object"&&(n.#v(),this.#f(n)?(r=!1,this.#S(n,i)):this.#y(n)?(r=!1,this.#m(n,i)):this.#_(n)&&(r=!1,this.#E(n)))}}while(!r&&++t<10)}else for(let t of this.#e)typeof t=="object"&&t.#v();this.#s=void 0}static fromGlob(t,r={}){let i=new Ri(null,void 0,r);return Ri.#g(t,i,0,r,0),i}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let t=this.toString(),[r,i,n,a]=this.toRegExpSource();if(!(n||this.#r||this.#u.nocase&&!this.#u.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let s=(this.#u.nocase?"i":"")+(a?"u":"");return Object.assign(new RegExp(`^${r}$`,s),{_src:r,_glob:t})}get options(){return this.#u}toRegExpSource(t){let r=t??!!this.#u.dot;if(this.#t===this&&(this.#v(),this.#b()),!BB(this)){let u=this.isStart()&&this.isEnd(),l=this.#e.map(f=>{let[m,h,g,y]=typeof f=="string"?Ri.#k(f,this.#r,u):f.toRegExpSource(t);return this.#r=this.#r||g,this.#n=this.#n||y,m}).join(""),c="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&Uye.has(this.#e[0]))){let m=zye,h=r&&m.has(l.charAt(0))||l.startsWith("\\.")&&m.has(l.charAt(2))||l.startsWith("\\.\\.")&&m.has(l.charAt(4)),g=!r&&!t&&m.has(l.charAt(0));c=h?Lye:g?Wg:""}let d="";return this.isEnd()&&this.#t.#c&&this.#i?.type==="!"&&(d="(?:$|\\/)"),[c+l+d,Qa(l),this.#r=!!this.#r,this.#n]}let i=this.type==="*"||this.type==="+",n=this.type==="!"?"(?:(?!(?:":"(?:",a=this.#p(r);if(this.isStart()&&this.isEnd()&&!a&&this.type!=="!"){let u=this.toString(),l=this;return l.#e=[u],l.type=null,l.#r=void 0,[u,Qa(this.toString()),!1,!1]}let o=!i||t||r||!Wg?"":this.#p(!0);o===a&&(o=""),o&&(a=`(?:${a})(?:${o})*?`);let s="";if(this.type==="!"&&this.#a)s=(this.isStart()&&!r?Wg:"")+LB;else{let u=this.type==="!"?"))"+(this.isStart()&&!r&&!t?Wg:"")+MB+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;s=n+a+u}return[s,Qa(a),this.#r=!!this.#r,this.#n]}#p(t){return this.#e.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[i,n,a,o]=r.toRegExpSource(t);return this.#n=this.#n||o,i}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#k(t,r,i=!1){let n=!1,a="",o=!1,s=!1;for(let u=0;u<t.length;u++){let l=t.charAt(u);if(n){n=!1,a+=(qye.has(l)?"\\":"")+l,s=!1;continue}if(l==="\\"){u===t.length-1?a+="\\\\":n=!0;continue}if(l==="["){let[c,d,p,f]=NB(t,u);if(p){a+=c,o=o||d,u+=p-1,r=r||f,s=!1;continue}}if(l==="*"){if(s)continue;s=!0,a+=i&&/^[*]+$/.test(t)?LB:MB,r=!0;continue}else s=!1;if(l==="?"){a+=w9,r=!0;continue}a+=Vye(l)}return[a,Qa(t),!!r,o]}};Ri=fl});var Fc,E9=Xe(()=>{Fc=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&")});var qB,hi,Zye,Gye,Wye,Kye,Hye,Jye,Yye,Xye,Qye,e2e,t2e,r2e,n2e,i2e,a2e,o2e,s2e,u2e,VB,ZB,GB,zB,l2e,cn,c2e,d2e,p2e,f2e,m2e,Da,h2e,WB,g2e,v2e,UB,y2e,aa,au=Xe(()=>{qB=Hu(IB(),1);jB();S9();E9();Gg();S9();E9();Gg();hi=(e,t,r={})=>(Pf(t),!r.nocomment&&t.charAt(0)==="#"?!1:new aa(t,r).match(e)),Zye=/^\*+([^+@!?\*\[\(]*)$/,Gye=e=>t=>!t.startsWith(".")&&t.endsWith(e),Wye=e=>t=>t.endsWith(e),Kye=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Hye=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Jye=/^\*+\.\*+$/,Yye=e=>!e.startsWith(".")&&e.includes("."),Xye=e=>e!=="."&&e!==".."&&e.includes("."),Qye=/^\.\*+$/,e2e=e=>e!=="."&&e!==".."&&e.startsWith("."),t2e=/^\*+$/,r2e=e=>e.length!==0&&!e.startsWith("."),n2e=e=>e.length!==0&&e!=="."&&e!=="..",i2e=/^\?+([^+@!?\*\[\(]*)?$/,a2e=([e,t=""])=>{let r=VB([e]);return t?(t=t.toLowerCase(),i=>r(i)&&i.toLowerCase().endsWith(t)):r},o2e=([e,t=""])=>{let r=ZB([e]);return t?(t=t.toLowerCase(),i=>r(i)&&i.toLowerCase().endsWith(t)):r},s2e=([e,t=""])=>{let r=ZB([e]);return t?i=>r(i)&&i.endsWith(t):r},u2e=([e,t=""])=>{let r=VB([e]);return t?i=>r(i)&&i.endsWith(t):r},VB=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},ZB=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},GB=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",zB={win32:{sep:"\\"},posix:{sep:"/"}},l2e=GB==="win32"?zB.win32.sep:zB.posix.sep;hi.sep=l2e;cn=Symbol("globstar **");hi.GLOBSTAR=cn;c2e="[^/]",d2e=c2e+"*?",p2e="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",f2e="(?:(?!(?:\\/|^)\\.).)*?",m2e=(e,t={})=>r=>hi(r,e,t);hi.filter=m2e;Da=(e,t={})=>Object.assign({},e,t),h2e=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return hi;let t=hi;return Object.assign((i,n,a={})=>t(i,n,Da(e,a)),{Minimatch:class extends t.Minimatch{constructor(n,a={}){super(n,Da(e,a))}static defaults(n){return t.defaults(Da(e,n)).Minimatch}},AST:class extends t.AST{constructor(n,a,o={}){super(n,a,Da(e,o))}static fromGlob(n,a={}){return t.AST.fromGlob(n,Da(e,a))}},unescape:(i,n={})=>t.unescape(i,Da(e,n)),escape:(i,n={})=>t.escape(i,Da(e,n)),filter:(i,n={})=>t.filter(i,Da(e,n)),defaults:i=>t.defaults(Da(e,i)),makeRe:(i,n={})=>t.makeRe(i,Da(e,n)),braceExpand:(i,n={})=>t.braceExpand(i,Da(e,n)),match:(i,n,a={})=>t.match(i,n,Da(e,a)),sep:t.sep,GLOBSTAR:cn})};hi.defaults=h2e;WB=(e,t={})=>(Pf(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:(0,qB.default)(e));hi.braceExpand=WB;g2e=(e,t={})=>new aa(e,t).makeRe();hi.makeRe=g2e;v2e=(e,t,r={})=>{let i=new aa(t,r);return e=e.filter(n=>i.match(n)),i.options.nonull&&!e.length&&e.push(t),e};hi.match=v2e;UB=/[?*]|[+@!]\(.*?\)|\[|\]/,y2e=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),aa=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){Pf(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||GB,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...a)=>console.error(...a)),this.debug(this.pattern,this.globSet);let i=this.globSet.map(a=>this.slashSplit(a));this.globParts=this.preprocess(i),this.debug(this.pattern,this.globParts);let n=this.globParts.map((a,o,s)=>{if(this.isWindows&&this.windowsNoMagicRoot){let u=a[0]===""&&a[1]===""&&(a[2]==="?"||!UB.test(a[2]))&&!UB.test(a[3]),l=/^[a-z]:/i.test(a[0]);if(u)return[...a.slice(0,4),...a.slice(4).map(c=>this.parse(c))];if(l)return[a[0],...a.slice(1).map(c=>this.parse(c))]}return a.map(u=>this.parse(u))});if(this.debug(this.pattern,n),this.set=n.filter(a=>a.indexOf(!1)===-1),this.isWindows)for(let a=0;a<this.set.length;a++){let o=this.set[a];o[0]===""&&o[1]===""&&this.globParts[a][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let i=0;i<t.length;i++)for(let n=0;n<t[i].length;n++)t[i][n]==="**"&&(t[i][n]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let i=-1;for(;(i=r.indexOf("**",i+1))!==-1;){let n=i;for(;r[n+1]==="**";)n++;n!==i&&r.splice(i,n-i)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((i,n)=>{let a=i[i.length-1];return n==="**"&&a==="**"?i:n===".."&&a&&a!==".."&&a!=="."&&a!=="**"?(i.pop(),i):(i.push(n),i)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let n=1;n<t.length-1;n++){let a=t[n];n===1&&a===""&&t[0]===""||(a==="."||a==="")&&(r=!0,t.splice(n,1),n--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let i=0;for(;(i=t.indexOf("..",i+1))!==-1;){let n=t[i-1];n&&n!=="."&&n!==".."&&n!=="**"&&(r=!0,t.splice(i-1,2),i-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let i of t){let n=-1;for(;(n=i.indexOf("**",n+1))!==-1;){let o=n;for(;i[o+1]==="**";)o++;o>n&&i.splice(n+1,o-n);let s=i[n+1],u=i[n+2],l=i[n+3];if(s!==".."||!u||u==="."||u===".."||!l||l==="."||l==="..")continue;r=!0,i.splice(n,1);let c=i.slice(0);c[n]="**",t.push(c),n--}if(!this.preserveMultipleSlashes){for(let o=1;o<i.length-1;o++){let s=i[o];o===1&&s===""&&i[0]===""||(s==="."||s==="")&&(r=!0,i.splice(o,1),o--)}i[0]==="."&&i.length===2&&(i[1]==="."||i[1]==="")&&(r=!0,i.pop())}let a=0;for(;(a=i.indexOf("..",a+1))!==-1;){let o=i[a-1];if(o&&o!=="."&&o!==".."&&o!=="**"){r=!0;let u=a===1&&i[a+1]==="**"?["."]:[];i.splice(a-1,2,...u),i.length===0&&i.push(""),a-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let i=r+1;i<t.length;i++){let n=this.partsMatch(t[r],t[i],!this.preserveMultipleSlashes);if(n){t[r]=[],t[i]=n;break}}return t.filter(r=>r.length)}partsMatch(t,r,i=!1){let n=0,a=0,o=[],s="";for(;n<t.length&&a<r.length;)if(t[n]===r[a])o.push(s==="b"?r[a]:t[n]),n++,a++;else if(i&&t[n]==="**"&&r[a]===t[n+1])o.push(t[n]),n++;else if(i&&r[a]==="**"&&t[n]===r[a+1])o.push(r[a]),a++;else if(t[n]==="*"&&r[a]&&(this.options.dot||!r[a].startsWith("."))&&r[a]!=="**"){if(s==="b")return!1;s="a",o.push(t[n]),n++,a++}else if(r[a]==="*"&&t[n]&&(this.options.dot||!t[n].startsWith("."))&&t[n]!=="**"){if(s==="a")return!1;s="b",o.push(r[a]),n++,a++}else return!1;return t.length===r.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,i=0;for(let n=0;n<t.length&&t.charAt(n)==="!";n++)r=!r,i++;i&&(this.pattern=t.slice(i)),this.negate=r}matchOne(t,r,i=!1){let n=0,a=0;if(this.isWindows){let s=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),u=!s&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),l=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),c=!l&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),d=u?3:s?0:void 0,p=c?3:l?0:void 0;if(typeof d=="number"&&typeof p=="number"){let[f,m]=[t[d],r[p]];f.toLowerCase()===m.toLowerCase()&&(r[p]=f,a=p,n=d)}}let{optimizationLevel:o=1}=this.options;return o>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(cn)?this.#t(t,r,i,n,a):this.#n(t,r,i,n,a)}#t(t,r,i,n,a){let o=r.indexOf(cn,a),s=r.lastIndexOf(cn),[u,l,c]=i?[r.slice(a,o),r.slice(o+1),[]]:[r.slice(a,o),r.slice(o+1,s),r.slice(s+1)];if(u.length){let _=t.slice(n,n+u.length);if(!this.#n(_,u,i,0,0))return!1;n+=u.length}let d=0;if(c.length){if(c.length+n>t.length)return!1;let _=t.length-c.length;if(this.#n(t,c,i,_,0))d=c.length;else{if(t[t.length-1]!==""||n+c.length===t.length||(_--,!this.#n(t,c,i,_,0)))return!1;d=c.length+1}}if(!l.length){let _=!!d;for(let w=n;w<t.length-d;w++){let S=String(t[w]);if(_=!0,S==="."||S===".."||!this.options.dot&&S.startsWith("."))return!1}return i||_}let p=[[[],0]],f=p[0],m=0,h=[0];for(let _ of l)_===cn?(h.push(m),f=[[],0],p.push(f)):(f[0].push(_),m++);let g=p.length-1,y=t.length-d;for(let _ of p)_[1]=y-(h[g--]+_[0].length);return!!this.#r(t,p,n,0,i,0,!!d)}#r(t,r,i,n,a,o,s){let u=r[n];if(!u){for(let d=i;d<t.length;d++){s=!0;let p=t[d];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1}return s}let[l,c]=u;for(;i<=c;){if(this.#n(t.slice(0,i+l.length),l,a,i,0)&&o<this.maxGlobstarRecursion){let f=this.#r(t,r,i+l.length,n+1,a,o+1,s);if(f!==!1)return f}let p=t[i];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1;i++}return a||null}#n(t,r,i,n,a){let o,s,u,l;for(o=n,s=a,l=t.length,u=r.length;o<l&&s<u;o++,s++){this.debug("matchOne loop");let c=r[s],d=t[o];if(this.debug(r,c,d),c===!1||c===cn)return!1;let p;if(typeof c=="string"?(p=d===c,this.debug("string match",c,d,p)):(p=c.test(d),this.debug("pattern match",c,d,p)),!p)return!1}if(o===l&&s===u)return!0;if(o===l)return i;if(s===u)return o===l-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return WB(this.pattern,this.options)}parse(t){Pf(t);let r=this.options;if(t==="**")return cn;if(t==="")return"";let i,n=null;(i=t.match(t2e))?n=r.dot?n2e:r2e:(i=t.match(Zye))?n=(r.nocase?r.dot?Hye:Kye:r.dot?Wye:Gye)(i[1]):(i=t.match(i2e))?n=(r.nocase?r.dot?o2e:a2e:r.dot?s2e:u2e)(i):(i=t.match(Jye))?n=r.dot?Xye:Yye:(i=t.match(Qye))&&(n=e2e);let a=fl.fromGlob(t,this.options).toMMPattern();return n&&typeof a=="object"&&Reflect.defineProperty(a,"test",{value:n}),a}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,i=r.noglobstar?d2e:r.dot?p2e:f2e,n=new Set(r.nocase?["i"]:[]),a=t.map(u=>{let l=u.map(c=>{if(c instanceof RegExp)for(let d of c.flags.split(""))n.add(d);return typeof c=="string"?y2e(c):c===cn?cn:c._src});return l.forEach((c,d)=>{let p=l[d+1],f=l[d-1];c!==cn||f===cn||(f===void 0?p!==void 0&&p!==cn?l[d+1]="(?:\\/|"+i+"\\/)?"+p:l[d]=i:p===void 0?l[d-1]=f+"(?:\\/|"+i+")?":p!==cn&&(l[d-1]=f+"(?:\\/|\\/"+i+"\\/)"+p,l[d+1]=cn))}),l.filter(c=>c!==cn).join("/")}).join("|"),[o,s]=t.length>1?["(?:",")"]:["",""];a="^"+o+a+s+"$",this.negate&&(a="^(?!"+a+").+$");try{this.regexp=new RegExp(a,[...n].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let i=this.options;this.isWindows&&(t=t.split("\\").join("/"));let n=this.slashSplit(t);this.debug(this.pattern,"split",n);let a=this.set;this.debug(this.pattern,"set",a);let o=n[n.length-1];if(!o)for(let s=n.length-2;!o&&s>=0;s--)o=n[s];for(let s=0;s<a.length;s++){let u=a[s],l=n;if(i.matchBase&&u.length===1&&(l=[o]),this.matchOne(l,u,r))return i.flipNegate?!0:!this.negate}return i.flipNegate?!1:this.negate}static defaults(t){return hi.defaults(t).Minimatch}};hi.AST=fl;hi.Minimatch=aa;hi.escape=Fc;hi.unescape=Qa});var Mc,HB,$9,JB,Kg,KB,_2e,ou,YB,Lc,x9,jf,XB=Xe(()=>{Mc=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,HB=new Set,$9=typeof process=="object"&&process?process:{},JB=(e,t,r,i)=>{typeof $9.emitWarning=="function"?$9.emitWarning(e,t,r,i):console.error(`[${r}] ${t}: ${e}`)},Kg=globalThis.AbortController,KB=globalThis.AbortSignal;if(typeof Kg>"u"){KB=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(i,n){this._onabort.push(n)}},Kg=class{constructor(){t()}signal=new KB;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=!0;for(let n of this.signal._onabort)n(i);this.signal.onabort?.(i)}}};let e=$9.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,JB("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}_2e=e=>!HB.has(e),ou=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),YB=e=>ou(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Lc:null:null,Lc=class extends Array{constructor(t){super(t),this.fill(0)}},x9=class e{heap;length;static#t=!1;static create(t){let r=YB(t);if(!r)return[];e.#t=!0;let i=new e(t,r);return e.#t=!1,i}constructor(t,r){if(!e.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},jf=class e{#t;#r;#n;#e;#i;#h;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#l;#c;#u;#s;#a;#b;#g;#y;#f;#w;#m;#S;#x;#_;#E;#v;#p;static unsafeExposeInternals(t){return{starts:t.#x,ttls:t.#_,sizes:t.#S,keyMap:t.#u,keyList:t.#s,valList:t.#a,next:t.#b,prev:t.#g,get head(){return t.#y},get tail(){return t.#f},free:t.#w,isBackgroundFetch:r=>t.#d(r),backgroundFetch:(r,i,n,a)=>t.#F(r,i,n,a),moveToTail:r=>t.#L(r),indexes:r=>t.#C(r),rindexes:r=>t.#D(r),isStale:r=>t.#$(r)}}get max(){return this.#t}get maxSize(){return this.#r}get calculatedSize(){return this.#c}get size(){return this.#l}get fetchMethod(){return this.#i}get memoMethod(){return this.#h}get dispose(){return this.#n}get disposeAfter(){return this.#e}constructor(t){let{max:r=0,ttl:i,ttlResolution:n=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:s,allowStale:u,dispose:l,disposeAfter:c,noDisposeOnSet:d,noUpdateTTL:p,maxSize:f=0,maxEntrySize:m=0,sizeCalculation:h,fetchMethod:g,memoMethod:y,noDeleteOnFetchRejection:_,noDeleteOnStaleGet:w,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:C,ignoreFetchAbort:D}=t;if(r!==0&&!ou(r))throw new TypeError("max option must be a nonnegative integer");let E=r?YB(r):Array;if(!E)throw new Error("invalid max value: "+r);if(this.#t=r,this.#r=f,this.maxEntrySize=m||this.#r,this.sizeCalculation=h,this.sizeCalculation){if(!this.#r&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(y!==void 0&&typeof y!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#h=y,g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#i=g,this.#v=!!g,this.#u=new Map,this.#s=new Array(r).fill(void 0),this.#a=new Array(r).fill(void 0),this.#b=new E(r),this.#g=new E(r),this.#y=0,this.#f=0,this.#w=x9.create(r),this.#l=0,this.#c=0,typeof l=="function"&&(this.#n=l),typeof c=="function"?(this.#e=c,this.#m=[]):(this.#e=void 0,this.#m=void 0),this.#E=!!this.#n,this.#p=!!this.#e,this.noDisposeOnSet=!!d,this.noUpdateTTL=!!p,this.noDeleteOnFetchRejection=!!_,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!C,this.ignoreFetchAbort=!!D,this.maxEntrySize!==0){if(this.#r!==0&&!ou(this.#r))throw new TypeError("maxSize must be a positive integer if specified");if(!ou(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#O()}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!w,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!s,this.ttlResolution=ou(n)||n===0?n:1,this.ttlAutopurge=!!a,this.ttl=i||0,this.ttl){if(!ou(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#k()}if(this.#t===0&&this.ttl===0&&this.#r===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#r){let A="LRU_CACHE_UNBOUNDED";_2e(A)&&(HB.add(A),JB("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",A,e))}}getRemainingTTL(t){return this.#u.has(t)?1/0:0}#k(){let t=new Lc(this.#t),r=new Lc(this.#t);this.#_=t,this.#x=r,this.#I=(a,o,s=Mc.now())=>{if(r[a]=o!==0?s:0,t[a]=o,o!==0&&this.ttlAutopurge){let u=setTimeout(()=>{this.#$(a)&&this.#P(this.#s[a],"expire")},o+1);u.unref&&u.unref()}},this.#A=a=>{r[a]=t[a]!==0?Mc.now():0},this.#o=(a,o)=>{if(t[o]){let s=t[o],u=r[o];if(!s||!u)return;a.ttl=s,a.start=u,a.now=i||n();let l=a.now-u;a.remainingTTL=s-l}};let i=0,n=()=>{let a=Mc.now();if(this.ttlResolution>0){i=a;let o=setTimeout(()=>i=0,this.ttlResolution);o.unref&&o.unref()}return a};this.getRemainingTTL=a=>{let o=this.#u.get(a);if(o===void 0)return 0;let s=t[o],u=r[o];if(!s||!u)return 1/0;let l=(i||n())-u;return s-l},this.#$=a=>{let o=r[a],s=t[a];return!!s&&!!o&&(i||n())-o>s}}#A=()=>{};#o=()=>{};#I=()=>{};#$=()=>!1;#O(){let t=new Lc(this.#t);this.#c=0,this.#S=t,this.#j=r=>{this.#c-=t[r],t[r]=0},this.#N=(r,i,n,a)=>{if(this.#d(i))return 0;if(!ou(n))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(n=a(i,r),!ou(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return n},this.#T=(r,i,n)=>{if(t[r]=i,this.#r){let a=this.#r-t[r];for(;this.#c>a;)this.#B(!0)}this.#c+=t[r],n&&(n.entrySize=i,n.totalCalculatedSize=this.#c)}}#j=t=>{};#T=(t,r,i)=>{};#N=(t,r,i,n)=>{if(i||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#C({allowStale:t=this.allowStale}={}){if(this.#l)for(let r=this.#f;!(!this.#R(r)||((t||!this.#$(r))&&(yield r),r===this.#y));)r=this.#g[r]}*#D({allowStale:t=this.allowStale}={}){if(this.#l)for(let r=this.#y;!(!this.#R(r)||((t||!this.#$(r))&&(yield r),r===this.#f));)r=this.#b[r]}#R(t){return t!==void 0&&this.#u.get(this.#s[t])===t}*entries(){for(let t of this.#C())this.#a[t]!==void 0&&this.#s[t]!==void 0&&!this.#d(this.#a[t])&&(yield[this.#s[t],this.#a[t]])}*rentries(){for(let t of this.#D())this.#a[t]!==void 0&&this.#s[t]!==void 0&&!this.#d(this.#a[t])&&(yield[this.#s[t],this.#a[t]])}*keys(){for(let t of this.#C()){let r=this.#s[t];r!==void 0&&!this.#d(this.#a[t])&&(yield r)}}*rkeys(){for(let t of this.#D()){let r=this.#s[t];r!==void 0&&!this.#d(this.#a[t])&&(yield r)}}*values(){for(let t of this.#C())this.#a[t]!==void 0&&!this.#d(this.#a[t])&&(yield this.#a[t])}*rvalues(){for(let t of this.#D())this.#a[t]!==void 0&&!this.#d(this.#a[t])&&(yield this.#a[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,r={}){for(let i of this.#C()){let n=this.#a[i],a=this.#d(n)?n.__staleWhileFetching:n;if(a!==void 0&&t(a,this.#s[i],this))return this.get(this.#s[i],r)}}forEach(t,r=this){for(let i of this.#C()){let n=this.#a[i],a=this.#d(n)?n.__staleWhileFetching:n;a!==void 0&&t.call(r,a,this.#s[i],this)}}rforEach(t,r=this){for(let i of this.#D()){let n=this.#a[i],a=this.#d(n)?n.__staleWhileFetching:n;a!==void 0&&t.call(r,a,this.#s[i],this)}}purgeStale(){let t=!1;for(let r of this.#D({allowStale:!0}))this.#$(r)&&(this.#P(this.#s[r],"expire"),t=!0);return t}info(t){let r=this.#u.get(t);if(r===void 0)return;let i=this.#a[r],n=this.#d(i)?i.__staleWhileFetching:i;if(n===void 0)return;let a={value:n};if(this.#_&&this.#x){let o=this.#_[r],s=this.#x[r];if(o&&s){let u=o-(Mc.now()-s);a.ttl=u,a.start=Date.now()}}return this.#S&&(a.size=this.#S[r]),a}dump(){let t=[];for(let r of this.#C({allowStale:!0})){let i=this.#s[r],n=this.#a[r],a=this.#d(n)?n.__staleWhileFetching:n;if(a===void 0||i===void 0)continue;let o={value:a};if(this.#_&&this.#x){o.ttl=this.#_[r];let s=Mc.now()-this.#x[r];o.start=Math.floor(Date.now()-s)}this.#S&&(o.size=this.#S[r]),t.unshift([i,o])}return t}load(t){this.clear();for(let[r,i]of t){if(i.start){let n=Date.now()-i.start;i.start=Mc.now()-n}this.set(r,i.value,i)}}set(t,r,i={}){if(r===void 0)return this.delete(t),this;let{ttl:n=this.ttl,start:a,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:u}=i,{noUpdateTTL:l=this.noUpdateTTL}=i,c=this.#N(t,r,i.size||0,s);if(this.maxEntrySize&&c>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=!0),this.#P(t,"set"),this;let d=this.#l===0?void 0:this.#u.get(t);if(d===void 0)d=this.#l===0?this.#f:this.#w.length!==0?this.#w.pop():this.#l===this.#t?this.#B(!1):this.#l,this.#s[d]=t,this.#a[d]=r,this.#u.set(t,d),this.#b[this.#f]=d,this.#g[d]=this.#f,this.#f=d,this.#l++,this.#T(d,c,u),u&&(u.set="add"),l=!1;else{this.#L(d);let p=this.#a[d];if(r!==p){if(this.#v&&this.#d(p)){p.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:f}=p;f!==void 0&&!o&&(this.#E&&this.#n?.(f,t,"set"),this.#p&&this.#m?.push([f,t,"set"]))}else o||(this.#E&&this.#n?.(p,t,"set"),this.#p&&this.#m?.push([p,t,"set"]));if(this.#j(d),this.#T(d,c,u),this.#a[d]=r,u){u.set="replace";let f=p&&this.#d(p)?p.__staleWhileFetching:p;f!==void 0&&(u.oldValue=f)}}else u&&(u.set="update")}if(n!==0&&!this.#_&&this.#k(),this.#_&&(l||this.#I(d,n,a),u&&this.#o(u,d)),!o&&this.#p&&this.#m){let p=this.#m,f;for(;f=p?.shift();)this.#e?.(...f)}return this}pop(){try{for(;this.#l;){let t=this.#a[this.#y];if(this.#B(!0),this.#d(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#p&&this.#m){let t=this.#m,r;for(;r=t?.shift();)this.#e?.(...r)}}}#B(t){let r=this.#y,i=this.#s[r],n=this.#a[r];return this.#v&&this.#d(n)?n.__abortController.abort(new Error("evicted")):(this.#E||this.#p)&&(this.#E&&this.#n?.(n,i,"evict"),this.#p&&this.#m?.push([n,i,"evict"])),this.#j(r),t&&(this.#s[r]=void 0,this.#a[r]=void 0,this.#w.push(r)),this.#l===1?(this.#y=this.#f=0,this.#w.length=0):this.#y=this.#b[r],this.#u.delete(i),this.#l--,r}has(t,r={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:n}=r,a=this.#u.get(t);if(a!==void 0){let o=this.#a[a];if(this.#d(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#$(a))n&&(n.has="stale",this.#o(n,a));else return i&&this.#A(a),n&&(n.has="hit",this.#o(n,a)),!0}else n&&(n.has="miss");return!1}peek(t,r={}){let{allowStale:i=this.allowStale}=r,n=this.#u.get(t);if(n===void 0||!i&&this.#$(n))return;let a=this.#a[n];return this.#d(a)?a.__staleWhileFetching:a}#F(t,r,i,n){let a=r===void 0?void 0:this.#a[r];if(this.#d(a))return a;let o=new Kg,{signal:s}=i;s?.addEventListener("abort",()=>o.abort(s.reason),{signal:o.signal});let u={signal:o.signal,options:i,context:n},l=(h,g=!1)=>{let{aborted:y}=o.signal,_=i.ignoreFetchAbort&&h!==void 0;if(i.status&&(y&&!g?(i.status.fetchAborted=!0,i.status.fetchError=o.signal.reason,_&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),y&&!_&&!g)return d(o.signal.reason);let w=f;return this.#a[r]===f&&(h===void 0?w.__staleWhileFetching?this.#a[r]=w.__staleWhileFetching:this.#P(t,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.set(t,h,u.options))),h},c=h=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=h),d(h)),d=h=>{let{aborted:g}=o.signal,y=g&&i.allowStaleOnFetchAbort,_=y||i.allowStaleOnFetchRejection,w=_||i.noDeleteOnFetchRejection,S=f;if(this.#a[r]===f&&(!w||S.__staleWhileFetching===void 0?this.#P(t,"fetch"):y||(this.#a[r]=S.__staleWhileFetching)),_)return i.status&&S.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),S.__staleWhileFetching;if(S.__returned===S)throw h},p=(h,g)=>{let y=this.#i?.(t,a,u);y&&y instanceof Promise&&y.then(_=>h(_===void 0?void 0:_),g),o.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(h(void 0),i.allowStaleOnFetchAbort&&(h=_=>l(_,!0)))})};i.status&&(i.status.fetchDispatched=!0);let f=new Promise(p).then(l,c),m=Object.assign(f,{__abortController:o,__staleWhileFetching:a,__returned:void 0});return r===void 0?(this.set(t,m,{...u.options,status:void 0}),r=this.#u.get(t)):this.#a[r]=m,m}#d(t){if(!this.#v)return!1;let r=t;return!!r&&r instanceof Promise&&r.hasOwnProperty("__staleWhileFetching")&&r.__abortController instanceof Kg}async fetch(t,r={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:u=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:d=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:p=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:m=this.allowStaleOnFetchAbort,context:h,forceRefresh:g=!1,status:y,signal:_}=r;if(!this.#v)return y&&(y.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:a,status:y});let w={allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:a,ttl:o,noDisposeOnSet:s,size:u,sizeCalculation:l,noUpdateTTL:c,noDeleteOnFetchRejection:d,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:m,ignoreFetchAbort:f,status:y,signal:_},S=this.#u.get(t);if(S===void 0){y&&(y.fetch="miss");let C=this.#F(t,S,w,h);return C.__returned=C}else{let C=this.#a[S];if(this.#d(C)){let O=i&&C.__staleWhileFetching!==void 0;return y&&(y.fetch="inflight",O&&(y.returnedStale=!0)),O?C.__staleWhileFetching:C.__returned=C}let D=this.#$(S);if(!g&&!D)return y&&(y.fetch="hit"),this.#L(S),n&&this.#A(S),y&&this.#o(y,S),C;let E=this.#F(t,S,w,h),P=E.__staleWhileFetching!==void 0&&i;return y&&(y.fetch=D?"stale":"refresh",P&&D&&(y.returnedStale=!0)),P?E.__staleWhileFetching:E.__returned=E}}async forceFetch(t,r={}){let i=await this.fetch(t,r);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,r={}){let i=this.#h;if(!i)throw new Error("no memoMethod provided to constructor");let{context:n,forceRefresh:a,...o}=r,s=this.get(t,o);if(!a&&s!==void 0)return s;let u=i(t,s,{options:o,context:n});return this.set(t,u,o),u}get(t,r={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:o}=r,s=this.#u.get(t);if(s!==void 0){let u=this.#a[s],l=this.#d(u);return o&&this.#o(o,s),this.#$(s)?(o&&(o.get="stale"),l?(o&&i&&u.__staleWhileFetching!==void 0&&(o.returnedStale=!0),i?u.__staleWhileFetching:void 0):(a||this.#P(t,"expire"),o&&i&&(o.returnedStale=!0),i?u:void 0)):(o&&(o.get="hit"),l?u.__staleWhileFetching:(this.#L(s),n&&this.#A(s),u))}else o&&(o.get="miss")}#M(t,r){this.#g[r]=t,this.#b[t]=r}#L(t){t!==this.#f&&(t===this.#y?this.#y=this.#b[t]:this.#M(this.#g[t],this.#b[t]),this.#M(this.#f,t),this.#f=t)}delete(t){return this.#P(t,"delete")}#P(t,r){let i=!1;if(this.#l!==0){let n=this.#u.get(t);if(n!==void 0)if(i=!0,this.#l===1)this.#z(r);else{this.#j(n);let a=this.#a[n];if(this.#d(a)?a.__abortController.abort(new Error("deleted")):(this.#E||this.#p)&&(this.#E&&this.#n?.(a,t,r),this.#p&&this.#m?.push([a,t,r])),this.#u.delete(t),this.#s[n]=void 0,this.#a[n]=void 0,n===this.#f)this.#f=this.#g[n];else if(n===this.#y)this.#y=this.#b[n];else{let o=this.#g[n];this.#b[o]=this.#b[n];let s=this.#b[n];this.#g[s]=this.#g[n]}this.#l--,this.#w.push(n)}}if(this.#p&&this.#m?.length){let n=this.#m,a;for(;a=n?.shift();)this.#e?.(...a)}return i}clear(){return this.#z("delete")}#z(t){for(let r of this.#D({allowStale:!0})){let i=this.#a[r];if(this.#d(i))i.__abortController.abort(new Error("deleted"));else{let n=this.#s[r];this.#E&&this.#n?.(i,n,t),this.#p&&this.#m?.push([i,n,t])}}if(this.#u.clear(),this.#a.fill(void 0),this.#s.fill(void 0),this.#_&&this.#x&&(this.#_.fill(0),this.#x.fill(0)),this.#S&&this.#S.fill(0),this.#y=0,this.#f=0,this.#w.length=0,this.#c=0,this.#l=0,this.#p&&this.#m){let r=this.#m,i;for(;i=r?.shift();)this.#e?.(...i)}}}});import{EventEmitter as I9}from"node:events";import nF from"node:stream";import{StringDecoder as b2e}from"node:string_decoder";var QB,w2e,S2e,E2e,os,ss,su,Hg,Tf,Jg,eF,Yg,tF,eo,zc,Dn,Nf,Uc,On,gi,Pn,k9,Xg,ei,dn,A9,C9,rF,D9,Eo,O9,Qg,Rf,ml,oa,Bf,$2e,x2e,k2e,A2e,ev,P9,C2e,D2e,uu,j9=Xe(()=>{QB=typeof process=="object"&&process?process:{stdout:null,stderr:null},w2e=e=>!!e&&typeof e=="object"&&(e instanceof uu||e instanceof nF||S2e(e)||E2e(e)),S2e=e=>!!e&&typeof e=="object"&&e instanceof I9&&typeof e.pipe=="function"&&e.pipe!==nF.Writable.prototype.pipe,E2e=e=>!!e&&typeof e=="object"&&e instanceof I9&&typeof e.write=="function"&&typeof e.end=="function",os=Symbol("EOF"),ss=Symbol("maybeEmitEnd"),su=Symbol("emittedEnd"),Hg=Symbol("emittingEnd"),Tf=Symbol("emittedError"),Jg=Symbol("closed"),eF=Symbol("read"),Yg=Symbol("flush"),tF=Symbol("flushChunk"),eo=Symbol("encoding"),zc=Symbol("decoder"),Dn=Symbol("flowing"),Nf=Symbol("paused"),Uc=Symbol("resume"),On=Symbol("buffer"),gi=Symbol("pipes"),Pn=Symbol("bufferLength"),k9=Symbol("bufferPush"),Xg=Symbol("bufferShift"),ei=Symbol("objectMode"),dn=Symbol("destroyed"),A9=Symbol("error"),C9=Symbol("emitData"),rF=Symbol("emitEnd"),D9=Symbol("emitEnd2"),Eo=Symbol("async"),O9=Symbol("abort"),Qg=Symbol("aborted"),Rf=Symbol("signal"),ml=Symbol("dataListeners"),oa=Symbol("discarded"),Bf=e=>Promise.resolve().then(e),$2e=e=>e(),x2e=e=>e==="end"||e==="finish"||e==="prefinish",k2e=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,A2e=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),ev=class{src;dest;opts;ondrain;constructor(t,r,i){this.src=t,this.dest=r,this.opts=i,this.ondrain=()=>t[Uc](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},P9=class extends ev{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,r,i){super(t,r,i),this.proxyErrors=n=>this.dest.emit("error",n),t.on("error",this.proxyErrors)}},C2e=e=>!!e.objectMode,D2e=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",uu=class extends I9{[Dn]=!1;[Nf]=!1;[gi]=[];[On]=[];[ei];[eo];[Eo];[zc];[os]=!1;[su]=!1;[Hg]=!1;[Jg]=!1;[Tf]=null;[Pn]=0;[dn]=!1;[Rf];[Qg]=!1;[ml]=0;[oa]=!1;writable=!0;readable=!0;constructor(...t){let r=t[0]||{};if(super(),r.objectMode&&typeof r.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");C2e(r)?(this[ei]=!0,this[eo]=null):D2e(r)?(this[eo]=r.encoding,this[ei]=!1):(this[ei]=!1,this[eo]=null),this[Eo]=!!r.async,this[zc]=this[eo]?new b2e(this[eo]):null,r&&r.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[On]}),r&&r.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[gi]});let{signal:i}=r;i&&(this[Rf]=i,i.aborted?this[O9]():i.addEventListener("abort",()=>this[O9]()))}get bufferLength(){return this[Pn]}get encoding(){return this[eo]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[ei]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Eo]}set async(t){this[Eo]=this[Eo]||!!t}[O9](){this[Qg]=!0,this.emit("abort",this[Rf]?.reason),this.destroy(this[Rf]?.reason)}get aborted(){return this[Qg]}set aborted(t){}write(t,r,i){if(this[Qg])return!1;if(this[os])throw new Error("write after end");if(this[dn])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof r=="function"&&(i=r,r="utf8"),r||(r="utf8");let n=this[Eo]?Bf:$2e;if(!this[ei]&&!Buffer.isBuffer(t)){if(A2e(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(k2e(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[ei]?(this[Dn]&&this[Pn]!==0&&this[Yg](!0),this[Dn]?this.emit("data",t):this[k9](t),this[Pn]!==0&&this.emit("readable"),i&&n(i),this[Dn]):t.length?(typeof t=="string"&&!(r===this[eo]&&!this[zc]?.lastNeed)&&(t=Buffer.from(t,r)),Buffer.isBuffer(t)&&this[eo]&&(t=this[zc].write(t)),this[Dn]&&this[Pn]!==0&&this[Yg](!0),this[Dn]?this.emit("data",t):this[k9](t),this[Pn]!==0&&this.emit("readable"),i&&n(i),this[Dn]):(this[Pn]!==0&&this.emit("readable"),i&&n(i),this[Dn])}read(t){if(this[dn])return null;if(this[oa]=!1,this[Pn]===0||t===0||t&&t>this[Pn])return this[ss](),null;this[ei]&&(t=null),this[On].length>1&&!this[ei]&&(this[On]=[this[eo]?this[On].join(""):Buffer.concat(this[On],this[Pn])]);let r=this[eF](t||null,this[On][0]);return this[ss](),r}[eF](t,r){if(this[ei])this[Xg]();else{let i=r;t===i.length||t===null?this[Xg]():typeof i=="string"?(this[On][0]=i.slice(t),r=i.slice(0,t),this[Pn]-=t):(this[On][0]=i.subarray(t),r=i.subarray(0,t),this[Pn]-=t)}return this.emit("data",r),!this[On].length&&!this[os]&&this.emit("drain"),r}end(t,r,i){return typeof t=="function"&&(i=t,t=void 0),typeof r=="function"&&(i=r,r="utf8"),t!==void 0&&this.write(t,r),i&&this.once("end",i),this[os]=!0,this.writable=!1,(this[Dn]||!this[Nf])&&this[ss](),this}[Uc](){this[dn]||(!this[ml]&&!this[gi].length&&(this[oa]=!0),this[Nf]=!1,this[Dn]=!0,this.emit("resume"),this[On].length?this[Yg]():this[os]?this[ss]():this.emit("drain"))}resume(){return this[Uc]()}pause(){this[Dn]=!1,this[Nf]=!0,this[oa]=!1}get destroyed(){return this[dn]}get flowing(){return this[Dn]}get paused(){return this[Nf]}[k9](t){this[ei]?this[Pn]+=1:this[Pn]+=t.length,this[On].push(t)}[Xg](){return this[ei]?this[Pn]-=1:this[Pn]-=this[On][0].length,this[On].shift()}[Yg](t=!1){do;while(this[tF](this[Xg]())&&this[On].length);!t&&!this[On].length&&!this[os]&&this.emit("drain")}[tF](t){return this.emit("data",t),this[Dn]}pipe(t,r){if(this[dn])return t;this[oa]=!1;let i=this[su];return r=r||{},t===QB.stdout||t===QB.stderr?r.end=!1:r.end=r.end!==!1,r.proxyErrors=!!r.proxyErrors,i?r.end&&t.end():(this[gi].push(r.proxyErrors?new P9(this,t,r):new ev(this,t,r)),this[Eo]?Bf(()=>this[Uc]()):this[Uc]()),t}unpipe(t){let r=this[gi].find(i=>i.dest===t);r&&(this[gi].length===1?(this[Dn]&&this[ml]===0&&(this[Dn]=!1),this[gi]=[]):this[gi].splice(this[gi].indexOf(r),1),r.unpipe())}addListener(t,r){return this.on(t,r)}on(t,r){let i=super.on(t,r);if(t==="data")this[oa]=!1,this[ml]++,!this[gi].length&&!this[Dn]&&this[Uc]();else if(t==="readable"&&this[Pn]!==0)super.emit("readable");else if(x2e(t)&&this[su])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Tf]){let n=r;this[Eo]?Bf(()=>n.call(this,this[Tf])):n.call(this,this[Tf])}return i}removeListener(t,r){return this.off(t,r)}off(t,r){let i=super.off(t,r);return t==="data"&&(this[ml]=this.listeners("data").length,this[ml]===0&&!this[oa]&&!this[gi].length&&(this[Dn]=!1)),i}removeAllListeners(t){let r=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[ml]=0,!this[oa]&&!this[gi].length&&(this[Dn]=!1)),r}get emittedEnd(){return this[su]}[ss](){!this[Hg]&&!this[su]&&!this[dn]&&this[On].length===0&&this[os]&&(this[Hg]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Jg]&&this.emit("close"),this[Hg]=!1)}emit(t,...r){let i=r[0];if(t!=="error"&&t!=="close"&&t!==dn&&this[dn])return!1;if(t==="data")return!this[ei]&&!i?!1:this[Eo]?(Bf(()=>this[C9](i)),!0):this[C9](i);if(t==="end")return this[rF]();if(t==="close"){if(this[Jg]=!0,!this[su]&&!this[dn])return!1;let a=super.emit("close");return this.removeAllListeners("close"),a}else if(t==="error"){this[Tf]=i,super.emit(A9,i);let a=!this[Rf]||this.listeners("error").length?super.emit("error",i):!1;return this[ss](),a}else if(t==="resume"){let a=super.emit("resume");return this[ss](),a}else if(t==="finish"||t==="prefinish"){let a=super.emit(t);return this.removeAllListeners(t),a}let n=super.emit(t,...r);return this[ss](),n}[C9](t){for(let i of this[gi])i.dest.write(t)===!1&&this.pause();let r=this[oa]?!1:super.emit("data",t);return this[ss](),r}[rF](){return this[su]?!1:(this[su]=!0,this.readable=!1,this[Eo]?(Bf(()=>this[D9]()),!0):this[D9]())}[D9](){if(this[zc]){let r=this[zc].end();if(r){for(let i of this[gi])i.dest.write(r);this[oa]||super.emit("data",r)}}for(let r of this[gi])r.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[ei]||(t.dataLength=0);let r=this.promise();return this.on("data",i=>{t.push(i),this[ei]||(t.dataLength+=i.length)}),await r,t}async concat(){if(this[ei])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[eo]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,r)=>{this.on(dn,()=>r(new Error("stream destroyed"))),this.on("error",i=>r(i)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[oa]=!1;let t=!1,r=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return r();let n=this.read();if(n!==null)return Promise.resolve({done:!1,value:n});if(this[os])return r();let a,o,s=d=>{this.off("data",u),this.off("end",l),this.off(dn,c),r(),o(d)},u=d=>{this.off("error",s),this.off("end",l),this.off(dn,c),this.pause(),a({value:d,done:!!this[os]})},l=()=>{this.off("error",s),this.off("data",u),this.off(dn,c),r(),a({done:!0,value:void 0})},c=()=>s(new Error("stream destroyed"));return new Promise((d,p)=>{o=p,a=d,this.once(dn,c),this.once("error",s),this.once("end",l),this.once("data",u)})},throw:r,return:r,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[oa]=!1;let t=!1,r=()=>(this.pause(),this.off(A9,r),this.off(dn,r),this.off("end",r),t=!0,{done:!0,value:void 0}),i=()=>{if(t)return r();let n=this.read();return n===null?r():{done:!1,value:n}};return this.once("end",r),this.once(A9,r),this.once(dn,r),{next:i,throw:r,return:r,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[dn])return t?this.emit("error",t):this.emit(dn),this;this[dn]=!0,this[oa]=!0,this[On].length=0,this[Pn]=0;let r=this;return typeof r.close=="function"&&!this[Jg]&&r.close(),t?this.emit("error",t):this.emit(dn),this}static get isStream(){return w2e}}});import{posix as O2e,win32 as R9}from"node:path";import{fileURLToPath as P2e}from"node:url";import{lstatSync as I2e,readdir as j2e,readdirSync as T2e,readlinkSync as N2e,realpathSync as R2e}from"fs";import*as B2e from"node:fs";import{lstat as M2e,readdir as L2e,readlink as z2e,realpath as U2e}from"node:fs/promises";var F2e,Mf,uF,lF,q2e,V2e,Pa,cF,dF,$o,pF,fF,hl,mF,Oa,Ff,T9,iF,Lf,to,tv,nv,aF,Z2e,N9,oF,zf,sF,rv,iv,B9,hF,ti,av,ov,sv,qc,Vc,Uf,kMe,gF,vF=Xe(()=>{XB();j9();F2e=R2e.native,Mf={lstatSync:I2e,readdir:j2e,readdirSync:T2e,readlinkSync:N2e,realpathSync:F2e,promises:{lstat:M2e,readdir:L2e,readlink:z2e,realpath:U2e}},uF=e=>!e||e===Mf||e===B2e?Mf:{...Mf,...e,promises:{...Mf.promises,...e.promises||{}}},lF=/^\\\\\?\\([a-z]:)\\?$/i,q2e=e=>e.replace(/\//g,"\\").replace(lF,"$1\\"),V2e=/[\\\/]/,Pa=0,cF=1,dF=2,$o=4,pF=6,fF=8,hl=10,mF=12,Oa=15,Ff=~Oa,T9=16,iF=32,Lf=64,to=128,tv=256,nv=512,aF=Lf|to|nv,Z2e=1023,N9=e=>e.isFile()?fF:e.isDirectory()?$o:e.isSymbolicLink()?hl:e.isCharacterDevice()?dF:e.isBlockDevice()?pF:e.isSocket()?mF:e.isFIFO()?cF:Pa,oF=new Map,zf=e=>{let t=oF.get(e);if(t)return t;let r=e.normalize("NFKD");return oF.set(e,r),r},sF=new Map,rv=e=>{let t=sF.get(e);if(t)return t;let r=zf(e.toLowerCase());return sF.set(e,r),r},iv=class extends jf{constructor(){super({max:256})}},B9=class extends jf{constructor(t=16*1024){super({maxSize:t,sizeCalculation:r=>r.length+1})}},hF=Symbol("PathScurry setAsCwd"),ti=class{name;root;roots;parent;nocase;isCWD=!1;#t;#r;get dev(){return this.#r}#n;get mode(){return this.#n}#e;get nlink(){return this.#e}#i;get uid(){return this.#i}#h;get gid(){return this.#h}#l;get rdev(){return this.#l}#c;get blksize(){return this.#c}#u;get ino(){return this.#u}#s;get size(){return this.#s}#a;get blocks(){return this.#a}#b;get atimeMs(){return this.#b}#g;get mtimeMs(){return this.#g}#y;get ctimeMs(){return this.#y}#f;get birthtimeMs(){return this.#f}#w;get atime(){return this.#w}#m;get mtime(){return this.#m}#S;get ctime(){return this.#S}#x;get birthtime(){return this.#x}#_;#E;#v;#p;#k;#A;#o;#I;#$;#O;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,r=Pa,i,n,a,o,s){this.name=t,this.#_=a?rv(t):zf(t),this.#o=r&Z2e,this.nocase=a,this.roots=n,this.root=i||this,this.#I=o,this.#v=s.fullpath,this.#k=s.relative,this.#A=s.relativePosix,this.parent=s.parent,this.parent?this.#t=this.parent.#t:this.#t=uF(s.fs)}depth(){return this.#E!==void 0?this.#E:this.parent?this.#E=this.parent.depth()+1:this.#E=0}childrenCache(){return this.#I}resolve(t){if(!t)return this;let r=this.getRootString(t),n=t.substring(r.length).split(this.splitSep);return r?this.getRoot(r).#j(n):this.#j(n)}#j(t){let r=this;for(let i of t)r=r.child(i);return r}children(){let t=this.#I.get(this);if(t)return t;let r=Object.assign([],{provisional:0});return this.#I.set(this,r),this.#o&=~T9,r}child(t,r){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let i=this.children(),n=this.nocase?rv(t):zf(t);for(let u of i)if(u.#_===n)return u;let a=this.parent?this.sep:"",o=this.#v?this.#v+a+t:void 0,s=this.newChild(t,Pa,{...r,parent:this,fullpath:o});return this.canReaddir()||(s.#o|=to),i.push(s),s}relative(){if(this.isCWD)return"";if(this.#k!==void 0)return this.#k;let t=this.name,r=this.parent;if(!r)return this.#k=this.name;let i=r.relative();return i+(!i||!r.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#A!==void 0)return this.#A;let t=this.name,r=this.parent;if(!r)return this.#A=this.fullpathPosix();let i=r.relativePosix();return i+(!i||!r.parent?"":"/")+t}fullpath(){if(this.#v!==void 0)return this.#v;let t=this.name,r=this.parent;if(!r)return this.#v=this.name;let n=r.fullpath()+(r.parent?this.sep:"")+t;return this.#v=n}fullpathPosix(){if(this.#p!==void 0)return this.#p;if(this.sep==="/")return this.#p=this.fullpath();if(!this.parent){let n=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(n)?this.#p=`//?/${n}`:this.#p=n}let t=this.parent,r=t.fullpathPosix(),i=r+(!r||!t.parent?"":"/")+this.name;return this.#p=i}isUnknown(){return(this.#o&Oa)===Pa}isType(t){return this[`is${t}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#o&Oa)===fF}isDirectory(){return(this.#o&Oa)===$o}isCharacterDevice(){return(this.#o&Oa)===dF}isBlockDevice(){return(this.#o&Oa)===pF}isFIFO(){return(this.#o&Oa)===cF}isSocket(){return(this.#o&Oa)===mF}isSymbolicLink(){return(this.#o&hl)===hl}lstatCached(){return this.#o&iF?this:void 0}readlinkCached(){return this.#$}realpathCached(){return this.#O}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#$)return!0;if(!this.parent)return!1;let t=this.#o&Oa;return!(t!==Pa&&t!==hl||this.#o&tv||this.#o&to)}calledReaddir(){return!!(this.#o&T9)}isENOENT(){return!!(this.#o&to)}isNamed(t){return this.nocase?this.#_===rv(t):this.#_===zf(t)}async readlink(){let t=this.#$;if(t)return t;if(this.canReadlink()&&this.parent)try{let r=await this.#t.promises.readlink(this.fullpath()),i=(await this.parent.realpath())?.resolve(r);if(i)return this.#$=i}catch(r){this.#d(r.code);return}}readlinkSync(){let t=this.#$;if(t)return t;if(this.canReadlink()&&this.parent)try{let r=this.#t.readlinkSync(this.fullpath()),i=this.parent.realpathSync()?.resolve(r);if(i)return this.#$=i}catch(r){this.#d(r.code);return}}#T(t){this.#o|=T9;for(let r=t.provisional;r<t.length;r++){let i=t[r];i&&i.#N()}}#N(){this.#o&to||(this.#o=(this.#o|to)&Ff,this.#C())}#C(){let t=this.children();t.provisional=0;for(let r of t)r.#N()}#D(){this.#o|=nv,this.#R()}#R(){if(this.#o&Lf)return;let t=this.#o;(t&Oa)===$o&&(t&=Ff),this.#o=t|Lf,this.#C()}#B(t=""){t==="ENOTDIR"||t==="EPERM"?this.#R():t==="ENOENT"?this.#N():this.children().provisional=0}#F(t=""){t==="ENOTDIR"?this.parent.#R():t==="ENOENT"&&this.#N()}#d(t=""){let r=this.#o;r|=tv,t==="ENOENT"&&(r|=to),(t==="EINVAL"||t==="UNKNOWN")&&(r&=Ff),this.#o=r,t==="ENOTDIR"&&this.parent&&this.parent.#R()}#M(t,r){return this.#P(t,r)||this.#L(t,r)}#L(t,r){let i=N9(t),n=this.newChild(t.name,i,{parent:this}),a=n.#o&Oa;return a!==$o&&a!==hl&&a!==Pa&&(n.#o|=Lf),r.unshift(n),r.provisional++,n}#P(t,r){for(let i=r.provisional;i<r.length;i++){let n=r[i];if((this.nocase?rv(t.name):zf(t.name))===n.#_)return this.#z(t,n,i,r)}}#z(t,r,i,n){let a=r.name;return r.#o=r.#o&Ff|N9(t),a!==t.name&&(r.name=t.name),i!==n.provisional&&(i===n.length-1?n.pop():n.splice(i,1),n.unshift(r)),n.provisional++,r}async lstat(){if((this.#o&to)===0)try{return this.#Z(await this.#t.promises.lstat(this.fullpath())),this}catch(t){this.#F(t.code)}}lstatSync(){if((this.#o&to)===0)try{return this.#Z(this.#t.lstatSync(this.fullpath())),this}catch(t){this.#F(t.code)}}#Z(t){let{atime:r,atimeMs:i,birthtime:n,birthtimeMs:a,blksize:o,blocks:s,ctime:u,ctimeMs:l,dev:c,gid:d,ino:p,mode:f,mtime:m,mtimeMs:h,nlink:g,rdev:y,size:_,uid:w}=t;this.#w=r,this.#b=i,this.#x=n,this.#f=a,this.#c=o,this.#a=s,this.#S=u,this.#y=l,this.#r=c,this.#h=d,this.#u=p,this.#n=f,this.#m=m,this.#g=h,this.#e=g,this.#l=y,this.#s=_,this.#i=w;let S=N9(t);this.#o=this.#o&Ff|S|iF,S!==Pa&&S!==$o&&S!==hl&&(this.#o|=Lf)}#q=[];#V=!1;#G(t){this.#V=!1;let r=this.#q.slice();this.#q.length=0,r.forEach(i=>i(null,t))}readdirCB(t,r=!1){if(!this.canReaddir()){r?t(null,[]):queueMicrotask(()=>t(null,[]));return}let i=this.children();if(this.calledReaddir()){let a=i.slice(0,i.provisional);r?t(null,a):queueMicrotask(()=>t(null,a));return}if(this.#q.push(t),this.#V)return;this.#V=!0;let n=this.fullpath();this.#t.readdir(n,{withFileTypes:!0},(a,o)=>{if(a)this.#B(a.code),i.provisional=0;else{for(let s of o)this.#M(s,i);this.#T(i)}this.#G(i.slice(0,i.provisional))})}#U;async readdir(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let r=this.fullpath();if(this.#U)await this.#U;else{let i=()=>{};this.#U=new Promise(n=>i=n);try{for(let n of await this.#t.promises.readdir(r,{withFileTypes:!0}))this.#M(n,t);this.#T(t)}catch(n){this.#B(n.code),t.provisional=0}this.#U=void 0,i()}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let r=this.fullpath();try{for(let i of this.#t.readdirSync(r,{withFileTypes:!0}))this.#M(i,t);this.#T(t)}catch(i){this.#B(i.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#o&aF)return!1;let t=Oa&this.#o;return t===Pa||t===$o||t===hl}shouldWalk(t,r){return(this.#o&$o)===$o&&!(this.#o&aF)&&!t.has(this)&&(!r||r(this))}async realpath(){if(this.#O)return this.#O;if(!((nv|tv|to)&this.#o))try{let t=await this.#t.promises.realpath(this.fullpath());return this.#O=this.resolve(t)}catch{this.#D()}}realpathSync(){if(this.#O)return this.#O;if(!((nv|tv|to)&this.#o))try{let t=this.#t.realpathSync(this.fullpath());return this.#O=this.resolve(t)}catch{this.#D()}}[hF](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let r=new Set([]),i=[],n=this;for(;n&&n.parent;)r.add(n),n.#k=i.join(this.sep),n.#A=i.join("/"),n=n.parent,i.push("..");for(n=t;n&&n.parent&&!r.has(n);)n.#k=void 0,n.#A=void 0,n=n.parent}},av=class e extends ti{sep="\\";splitSep=V2e;constructor(t,r=Pa,i,n,a,o,s){super(t,r,i,n,a,o,s)}newChild(t,r=Pa,i={}){return new e(t,r,this.root,this.roots,this.nocase,this.childrenCache(),i)}getRootString(t){return R9.parse(t).root}getRoot(t){if(t=q2e(t.toUpperCase()),t===this.root.name)return this.root;for(let[r,i]of Object.entries(this.roots))if(this.sameRoot(t,r))return this.roots[t]=i;return this.roots[t]=new qc(t,this).root}sameRoot(t,r=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(lF,"$1\\"),t===r}},ov=class e extends ti{splitSep="/";sep="/";constructor(t,r=Pa,i,n,a,o,s){super(t,r,i,n,a,o,s)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,r=Pa,i={}){return new e(t,r,this.root,this.roots,this.nocase,this.childrenCache(),i)}},sv=class{root;rootPath;roots;cwd;#t;#r;#n;nocase;#e;constructor(t=process.cwd(),r,i,{nocase:n,childrenCacheSize:a=16*1024,fs:o=Mf}={}){this.#e=uF(o),(t instanceof URL||t.startsWith("file://"))&&(t=P2e(t));let s=r.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(s),this.#t=new iv,this.#r=new iv,this.#n=new B9(a);let u=s.substring(this.rootPath.length).split(i);if(u.length===1&&!u[0]&&u.pop(),n===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=n,this.root=this.newRoot(this.#e),this.roots[this.rootPath]=this.root;let l=this.root,c=u.length-1,d=r.sep,p=this.rootPath,f=!1;for(let m of u){let h=c--;l=l.child(m,{relative:new Array(h).fill("..").join(d),relativePosix:new Array(h).fill("..").join("/"),fullpath:p+=(f?"":d)+m}),f=!0}this.cwd=l}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#n}resolve(...t){let r="";for(let a=t.length-1;a>=0;a--){let o=t[a];if(!(!o||o===".")&&(r=r?`${o}/${r}`:o,this.isAbsolute(o)))break}let i=this.#t.get(r);if(i!==void 0)return i;let n=this.cwd.resolve(r).fullpath();return this.#t.set(r,n),n}resolvePosix(...t){let r="";for(let a=t.length-1;a>=0;a--){let o=t[a];if(!(!o||o===".")&&(r=r?`${o}/${r}`:o,this.isAbsolute(o)))break}let i=this.#r.get(r);if(i!==void 0)return i;let n=this.cwd.resolve(r).fullpathPosix();return this.#r.set(r,n),n}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,r={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t,t=this.cwd);let{withFileTypes:i}=r;if(t.canReaddir()){let n=await t.readdir();return i?n:n.map(a=>a.name)}else return[]}readdirSync(t=this.cwd,r={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t,t=this.cwd);let{withFileTypes:i=!0}=r;return t.canReaddir()?i?t.readdirSync():t.readdirSync().map(n=>n.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t.withFileTypes,t=this.cwd);let i=await t.readlink();return r?i:i?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t.withFileTypes,t=this.cwd);let i=t.readlinkSync();return r?i:i?.fullpath()}async realpath(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t.withFileTypes,t=this.cwd);let i=await t.realpath();return r?i:i?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t.withFileTypes,t=this.cwd);let i=t.realpathSync();return r?i:i?.fullpath()}async walk(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t,t=this.cwd);let{withFileTypes:i=!0,follow:n=!1,filter:a,walkFilter:o}=r,s=[];(!a||a(t))&&s.push(i?t:t.fullpath());let u=new Set,l=(d,p)=>{u.add(d),d.readdirCB((f,m)=>{if(f)return p(f);let h=m.length;if(!h)return p();let g=()=>{--h===0&&p()};for(let y of m)(!a||a(y))&&s.push(i?y:y.fullpath()),n&&y.isSymbolicLink()?y.realpath().then(_=>_?.isUnknown()?_.lstat():_).then(_=>_?.shouldWalk(u,o)?l(_,g):g()):y.shouldWalk(u,o)?l(y,g):g()},!0)},c=t;return new Promise((d,p)=>{l(c,f=>{if(f)return p(f);d(s)})})}walkSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t,t=this.cwd);let{withFileTypes:i=!0,follow:n=!1,filter:a,walkFilter:o}=r,s=[];(!a||a(t))&&s.push(i?t:t.fullpath());let u=new Set([t]);for(let l of u){let c=l.readdirSync();for(let d of c){(!a||a(d))&&s.push(i?d:d.fullpath());let p=d;if(d.isSymbolicLink()){if(!(n&&(p=d.realpathSync())))continue;p.isUnknown()&&p.lstatSync()}p.shouldWalk(u,o)&&u.add(p)}}return s}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,r={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t,t=this.cwd),this.stream(t,r)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t,t=this.cwd);let{withFileTypes:i=!0,follow:n=!1,filter:a,walkFilter:o}=r;(!a||a(t))&&(yield i?t:t.fullpath());let s=new Set([t]);for(let u of s){let l=u.readdirSync();for(let c of l){(!a||a(c))&&(yield i?c:c.fullpath());let d=c;if(c.isSymbolicLink()){if(!(n&&(d=c.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(s,o)&&s.add(d)}}}stream(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t,t=this.cwd);let{withFileTypes:i=!0,follow:n=!1,filter:a,walkFilter:o}=r,s=new uu({objectMode:!0});(!a||a(t))&&s.write(i?t:t.fullpath());let u=new Set,l=[t],c=0,d=()=>{let p=!1;for(;!p;){let f=l.shift();if(!f){c===0&&s.end();return}c++,u.add(f);let m=(g,y,_=!1)=>{if(g)return s.emit("error",g);if(n&&!_){let w=[];for(let S of y)S.isSymbolicLink()&&w.push(S.realpath().then(C=>C?.isUnknown()?C.lstat():C));if(w.length){Promise.all(w).then(()=>m(null,y,!0));return}}for(let w of y)w&&(!a||a(w))&&(s.write(i?w:w.fullpath())||(p=!0));c--;for(let w of y){let S=w.realpathCached()||w;S.shouldWalk(u,o)&&l.push(S)}p&&!s.flowing?s.once("drain",d):h||d()},h=!0;f.readdirCB(m,!0),h=!1}};return d(),s}streamSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof ti||(r=t,t=this.cwd);let{withFileTypes:i=!0,follow:n=!1,filter:a,walkFilter:o}=r,s=new uu({objectMode:!0}),u=new Set;(!a||a(t))&&s.write(i?t:t.fullpath());let l=[t],c=0,d=()=>{let p=!1;for(;!p;){let f=l.shift();if(!f){c===0&&s.end();return}c++,u.add(f);let m=f.readdirSync();for(let h of m)(!a||a(h))&&(s.write(i?h:h.fullpath())||(p=!0));c--;for(let h of m){let g=h;if(h.isSymbolicLink()){if(!(n&&(g=h.realpathSync())))continue;g.isUnknown()&&g.lstatSync()}g.shouldWalk(u,o)&&l.push(g)}}p&&!s.flowing&&s.once("drain",d)};return d(),s}chdir(t=this.cwd){let r=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[hF](r)}},qc=class extends sv{sep="\\";constructor(t=process.cwd(),r={}){let{nocase:i=!0}=r;super(t,R9,"\\",{...r,nocase:i}),this.nocase=i;for(let n=this.cwd;n;n=n.parent)n.nocase=this.nocase}parseRootPath(t){return R9.parse(t).root.toUpperCase()}newRoot(t){return new av(this.rootPath,$o,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},Vc=class extends sv{sep="/";constructor(t=process.cwd(),r={}){let{nocase:i=!1}=r;super(t,O2e,"/",{...r,nocase:i}),this.nocase=i}parseRootPath(t){return"/"}newRoot(t){return new ov(this.rootPath,$o,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},Uf=class extends Vc{constructor(t=process.cwd(),r={}){let{nocase:i=!0}=r;super(t,{...r,nocase:i})}},kMe=process.platform==="win32"?av:ov,gF=process.platform==="win32"?qc:process.platform==="darwin"?Uf:Vc});var G2e,W2e,Zc,F9=Xe(()=>{au();G2e=e=>e.length>=1,W2e=e=>e.length>=1,Zc=class e{#t;#r;#n;length;#e;#i;#h;#l;#c;#u;#s=!0;constructor(t,r,i,n){if(!G2e(t))throw new TypeError("empty pattern list");if(!W2e(r))throw new TypeError("empty glob list");if(r.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,i<0||i>=this.length)throw new TypeError("index out of range");if(this.#t=t,this.#r=r,this.#n=i,this.#e=n,this.#n===0){if(this.isUNC()){let[a,o,s,u,...l]=this.#t,[c,d,p,f,...m]=this.#r;l[0]===""&&(l.shift(),m.shift());let h=[a,o,s,u,""].join("/"),g=[c,d,p,f,""].join("/");this.#t=[h,...l],this.#r=[g,...m],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[a,...o]=this.#t,[s,...u]=this.#r;o[0]===""&&(o.shift(),u.shift());let l=a+"/",c=s+"/";this.#t=[l,...o],this.#r=[c,...u],this.length=this.#t.length}}}pattern(){return this.#t[this.#n]}isString(){return typeof this.#t[this.#n]=="string"}isGlobstar(){return this.#t[this.#n]===cn}isRegExp(){return this.#t[this.#n]instanceof RegExp}globString(){return this.#h=this.#h||(this.#n===0?this.isAbsolute()?this.#r[0]+this.#r.slice(1).join("/"):this.#r.join("/"):this.#r.slice(this.#n).join("/"))}hasMore(){return this.length>this.#n+1}rest(){return this.#i!==void 0?this.#i:this.hasMore()?(this.#i=new e(this.#t,this.#r,this.#n+1,this.#e),this.#i.#u=this.#u,this.#i.#c=this.#c,this.#i.#l=this.#l,this.#i):this.#i=null}isUNC(){let t=this.#t;return this.#c!==void 0?this.#c:this.#c=this.#e==="win32"&&this.#n===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#t;return this.#l!==void 0?this.#l:this.#l=this.#e==="win32"&&this.#n===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#t;return this.#u!==void 0?this.#u:this.#u=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#t[0];return typeof t=="string"&&this.isAbsolute()&&this.#n===0?t:""}checkFollowGlobstar(){return!(this.#n===0||!this.isGlobstar()||!this.#s)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#s?!1:(this.#s=!1,!0)}}});var K2e,Gc,M9=Xe(()=>{au();F9();K2e=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Gc=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(t,{nobrace:r,nocase:i,noext:n,noglobstar:a,platform:o=K2e}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:r,nocase:i,noext:n,noglobstar:a,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let s of t)this.add(s)}add(t){let r=new aa(t,this.mmopts);for(let i=0;i<r.set.length;i++){let n=r.set[i],a=r.globParts[i];if(!n||!a)throw new Error("invalid pattern object");for(;n[0]==="."&&a[0]===".";)n.shift(),a.shift();let o=new Zc(n,a,0,this.platform),s=new aa(o.globString(),this.mmopts),u=a[a.length-1]==="**",l=o.isAbsolute();l?this.absolute.push(s):this.relative.push(s),u&&(l?this.absoluteChildren.push(s):this.relativeChildren.push(s))}}ignored(t){let r=t.fullpath(),i=`${r}/`,n=t.relative()||".",a=`${n}/`;for(let o of this.relative)if(o.match(n)||o.match(a))return!0;for(let o of this.absolute)if(o.match(r)||o.match(i))return!0;return!1}childrenIgnored(t){let r=t.fullpath()+"/",i=(t.relative()||".")+"/";for(let n of this.relativeChildren)if(n.match(i))return!0;for(let n of this.absoluteChildren)if(n.match(r))return!0;return!1}}});var L9,z9,U9,qf,yF=Xe(()=>{au();L9=class e{store;constructor(t=new Map){this.store=t}copy(){return new e(new Map(this.store))}hasWalked(t,r){return this.store.get(t.fullpath())?.has(r.globString())}storeWalked(t,r){let i=t.fullpath(),n=this.store.get(i);n?n.add(r.globString()):this.store.set(i,new Set([r.globString()]))}},z9=class{store=new Map;add(t,r,i){let n=(r?2:0)|(i?1:0),a=this.store.get(t);this.store.set(t,a===void 0?n:n&a)}entries(){return[...this.store.entries()].map(([t,r])=>[t,!!(r&2),!!(r&1)])}},U9=class{store=new Map;add(t,r){if(!t.canReaddir())return;let i=this.store.get(t);i?i.find(n=>n.globString()===r.globString())||i.push(r):this.store.set(t,[r])}get(t){let r=this.store.get(t);if(!r)throw new Error("attempting to walk unknown path");return r}entries(){return this.keys().map(t=>[t,this.store.get(t)])}keys(){return[...this.store.keys()].filter(t=>t.canReaddir())}},qf=class e{hasWalkedCache;matches=new z9;subwalks=new U9;patterns;follow;dot;opts;constructor(t,r){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=r?r.copy():new L9}processPatterns(t,r){this.patterns=r;let i=r.map(n=>[t,n]);for(let[n,a]of i){this.hasWalkedCache.storeWalked(n,a);let o=a.root(),s=a.isAbsolute()&&this.opts.absolute!==!1;if(o){n=n.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let d=a.rest();if(d)a=d;else{this.matches.add(n,!0,!1);continue}}if(n.isENOENT())continue;let u,l,c=!1;for(;typeof(u=a.pattern())=="string"&&(l=a.rest());)n=n.resolve(u),a=l,c=!0;if(u=a.pattern(),l=a.rest(),c){if(this.hasWalkedCache.hasWalked(n,a))continue;this.hasWalkedCache.storeWalked(n,a)}if(typeof u=="string"){let d=u===".."||u===""||u===".";this.matches.add(n.resolve(u),s,d);continue}else if(u===cn){(!n.isSymbolicLink()||this.follow||a.checkFollowGlobstar())&&this.subwalks.add(n,a);let d=l?.pattern(),p=l?.rest();if(!l||(d===""||d===".")&&!p)this.matches.add(n,s,d===""||d===".");else if(d===".."){let f=n.parent||n;p?this.hasWalkedCache.hasWalked(f,p)||this.subwalks.add(f,p):this.matches.add(f,s,!0)}}else u instanceof RegExp&&this.subwalks.add(n,a)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new e(this.opts,this.hasWalkedCache)}filterEntries(t,r){let i=this.subwalks.get(t),n=this.child();for(let a of r)for(let o of i){let s=o.isAbsolute(),u=o.pattern(),l=o.rest();u===cn?n.testGlobstar(a,o,l,s):u instanceof RegExp?n.testRegExp(a,u,l,s):n.testString(a,u,l,s)}return n}testGlobstar(t,r,i,n){if((this.dot||!t.name.startsWith("."))&&(r.hasMore()||this.matches.add(t,n,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,r):t.isSymbolicLink()&&(i&&r.checkFollowGlobstar()?this.subwalks.add(t,i):r.markFollowGlobstar()&&this.subwalks.add(t,r)))),i){let a=i.pattern();if(typeof a=="string"&&a!==".."&&a!==""&&a!==".")this.testString(t,a,i.rest(),n);else if(a===".."){let o=t.parent||t;this.subwalks.add(o,i)}else a instanceof RegExp&&this.testRegExp(t,a,i.rest(),n)}}testRegExp(t,r,i,n){r.test(t.name)&&(i?this.subwalks.add(t,i):this.matches.add(t,n,!1))}testString(t,r,i,n){t.isNamed(r)&&(i?this.subwalks.add(t,i):this.matches.add(t,n,!1))}}});var H2e,uv,Vf,Zf,_F=Xe(()=>{j9();M9();yF();H2e=(e,t)=>typeof e=="string"?new Gc([e],t):Array.isArray(e)?new Gc(e,t):e,uv=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#t=[];#r;#n;signal;maxDepth;includeChildMatches;constructor(t,r,i){if(this.patterns=t,this.path=r,this.opts=i,this.#n=!i.posix&&i.platform==="win32"?"\\":"/",this.includeChildMatches=i.includeChildMatches!==!1,(i.ignore||!this.includeChildMatches)&&(this.#r=H2e(i.ignore??[],i),!this.includeChildMatches&&typeof this.#r.add!="function")){let n="cannot ignore child matches, ignore lacks add() method.";throw new Error(n)}this.maxDepth=i.maxDepth||1/0,i.signal&&(this.signal=i.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0}))}#e(t){return this.seen.has(t)||!!this.#r?.ignored?.(t)}#i(t){return!!this.#r?.childrenIgnored?.(t)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let t;for(;!this.paused&&(t=this.#t.shift());)t()}onResume(t){this.signal?.aborted||(this.paused?this.#t.push(t):t())}async matchCheck(t,r){if(r&&this.opts.nodir)return;let i;if(this.opts.realpath){if(i=t.realpathCached()||await t.realpath(),!i)return;t=i}let a=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&a?.isSymbolicLink()){let o=await a.realpath();o&&(o.isUnknown()||this.opts.stat)&&await o.lstat()}return this.matchCheckTest(a,r)}matchCheckTest(t,r){return t&&(this.maxDepth===1/0||t.depth()<=this.maxDepth)&&(!r||t.canReaddir())&&(!this.opts.nodir||!t.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!t.isSymbolicLink()||!t.realpathCached()?.isDirectory())&&!this.#e(t)?t:void 0}matchCheckSync(t,r){if(r&&this.opts.nodir)return;let i;if(this.opts.realpath){if(i=t.realpathCached()||t.realpathSync(),!i)return;t=i}let a=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&a?.isSymbolicLink()){let o=a.realpathSync();o&&(o?.isUnknown()||this.opts.stat)&&o.lstatSync()}return this.matchCheckTest(a,r)}matchFinish(t,r){if(this.#e(t))return;if(!this.includeChildMatches&&this.#r?.add){let a=`${t.relativePosix()}/**`;this.#r.add(a)}let i=this.opts.absolute===void 0?r:this.opts.absolute;this.seen.add(t);let n=this.opts.mark&&t.isDirectory()?this.#n:"";if(this.opts.withFileTypes)this.matchEmit(t);else if(i){let a=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(a+n)}else{let a=this.opts.posix?t.relativePosix():t.relative(),o=this.opts.dotRelative&&!a.startsWith(".."+this.#n)?"."+this.#n:"";this.matchEmit(a?o+a+n:"."+n)}}async match(t,r,i){let n=await this.matchCheck(t,i);n&&this.matchFinish(n,r)}matchSync(t,r,i){let n=this.matchCheckSync(t,i);n&&this.matchFinish(n,r)}walkCB(t,r,i){this.signal?.aborted&&i(),this.walkCB2(t,r,new qf(this.opts),i)}walkCB2(t,r,i,n){if(this.#i(t))return n();if(this.signal?.aborted&&n(),this.paused){this.onResume(()=>this.walkCB2(t,r,i,n));return}i.processPatterns(t,r);let a=1,o=()=>{--a===0&&n()};for(let[s,u,l]of i.matches.entries())this.#e(s)||(a++,this.match(s,u,l).then(()=>o()));for(let s of i.subwalkTargets()){if(this.maxDepth!==1/0&&s.depth()>=this.maxDepth)continue;a++;let u=s.readdirCached();s.calledReaddir()?this.walkCB3(s,u,i,o):s.readdirCB((l,c)=>this.walkCB3(s,c,i,o),!0)}o()}walkCB3(t,r,i,n){i=i.filterEntries(t,r);let a=1,o=()=>{--a===0&&n()};for(let[s,u,l]of i.matches.entries())this.#e(s)||(a++,this.match(s,u,l).then(()=>o()));for(let[s,u]of i.subwalks.entries())a++,this.walkCB2(s,u,i.child(),o);o()}walkCBSync(t,r,i){this.signal?.aborted&&i(),this.walkCB2Sync(t,r,new qf(this.opts),i)}walkCB2Sync(t,r,i,n){if(this.#i(t))return n();if(this.signal?.aborted&&n(),this.paused){this.onResume(()=>this.walkCB2Sync(t,r,i,n));return}i.processPatterns(t,r);let a=1,o=()=>{--a===0&&n()};for(let[s,u,l]of i.matches.entries())this.#e(s)||this.matchSync(s,u,l);for(let s of i.subwalkTargets()){if(this.maxDepth!==1/0&&s.depth()>=this.maxDepth)continue;a++;let u=s.readdirSync();this.walkCB3Sync(s,u,i,o)}o()}walkCB3Sync(t,r,i,n){i=i.filterEntries(t,r);let a=1,o=()=>{--a===0&&n()};for(let[s,u,l]of i.matches.entries())this.#e(s)||this.matchSync(s,u,l);for(let[s,u]of i.subwalks.entries())a++,this.walkCB2Sync(s,u,i.child(),o);o()}},Vf=class extends uv{matches=new Set;constructor(t,r,i){super(t,r,i)}matchEmit(t){this.matches.add(t)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,r)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?r(this.signal.reason):t(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},Zf=class extends uv{results;constructor(t,r,i){super(t,r,i),this.results=new uu({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(t){this.results.write(t),this.results.flowing||this.pause()}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end())}):this.walkCB(t,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}});import{fileURLToPath as J2e}from"node:url";var Y2e,ro,q9=Xe(()=>{au();vF();F9();_F();Y2e=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",ro=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(t,r){if(!r)throw new TypeError("glob options required");if(this.withFileTypes=!!r.withFileTypes,this.signal=r.signal,this.follow=!!r.follow,this.dot=!!r.dot,this.dotRelative=!!r.dotRelative,this.nodir=!!r.nodir,this.mark=!!r.mark,r.cwd?(r.cwd instanceof URL||r.cwd.startsWith("file://"))&&(r.cwd=J2e(r.cwd)):this.cwd="",this.cwd=r.cwd||"",this.root=r.root,this.magicalBraces=!!r.magicalBraces,this.nobrace=!!r.nobrace,this.noext=!!r.noext,this.realpath=!!r.realpath,this.absolute=r.absolute,this.includeChildMatches=r.includeChildMatches!==!1,this.noglobstar=!!r.noglobstar,this.matchBase=!!r.matchBase,this.maxDepth=typeof r.maxDepth=="number"?r.maxDepth:1/0,this.stat=!!r.stat,this.ignore=r.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof t=="string"&&(t=[t]),this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(t=t.map(u=>u.replace(/\\/g,"/"))),this.matchBase){if(r.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(u=>u.includes("/")?u:`./**/${u}`)}if(this.pattern=t,this.platform=r.platform||Y2e,this.opts={...r,platform:this.platform},r.scurry){if(this.scurry=r.scurry,r.nocase!==void 0&&r.nocase!==r.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let u=r.platform==="win32"?qc:r.platform==="darwin"?Uf:r.platform?Vc:gF;this.scurry=new u(this.cwd,{nocase:r.nocase,fs:r.fs})}this.nocase=this.scurry.nocase;let i=this.platform==="darwin"||this.platform==="win32",n={...r,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:i,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},a=this.pattern.map(u=>new aa(u,n)),[o,s]=a.reduce((u,l)=>(u[0].push(...l.set),u[1].push(...l.globParts),u),[[],[]]);this.patterns=o.map((u,l)=>{let c=s[l];if(!c)throw new Error("invalid pattern object");return new Zc(u,c,0,this.platform)})}async walk(){return[...await new Vf(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new Vf(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new Zf(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new Zf(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}});var V9,Z9=Xe(()=>{au();V9=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let r of e)if(new aa(r,t).hasMagic())return!0;return!1}});function lv(e,t={}){return new ro(e,t).streamSync()}function wF(e,t={}){return new ro(e,t).stream()}function SF(e,t={}){return new ro(e,t).walkSync()}async function bF(e,t={}){return new ro(e,t).walk()}function cv(e,t={}){return new ro(e,t).iterateSync()}function EF(e,t={}){return new ro(e,t).iterate()}var X2e,Q2e,e6e,t6e,r6e,lu,dv=Xe(()=>{au();q9();Z9();au();q9();Z9();M9();X2e=lv,Q2e=Object.assign(wF,{sync:lv}),e6e=cv,t6e=Object.assign(EF,{sync:cv}),r6e=Object.assign(SF,{stream:lv,iterate:cv}),lu=Object.assign(bF,{glob:bF,globSync:SF,sync:r6e,globStream:wF,stream:Q2e,globStreamSync:lv,streamSync:X2e,globIterate:EF,iterate:t6e,globIterateSync:cv,iterateSync:e6e,Glob:ro,hasMagic:V9,escape:Fc,unescape:Qa});lu.glob=lu});import cu from"fs";import Wc from"path";import n6e from"crypto";function pv(e){let t=cu.readFileSync(e);return n6e.createHash("sha256").update(t).digest("hex")}async function fv(e,t=["**/*"]){let r=[];for(let i of t){let n=await lu(i,{cwd:e,nodir:!0,ignore:["**/node_modules/**","**/.git/**",Kc]});r.push(...n)}return[...new Set(r)].sort()}function a6e(e,t){let r=Object.keys(e).sort(),i=Object.keys(t).sort();if(r.length!==i.length||r.join(",")!==i.join(","))return!1;for(let n of r)if(e[n].sha256!==t[n].sha256)return!1;return!0}async function Hc(e,t={}){let{generatorVersion:r="1.0.0",inputHash:i,sourceMap:n=new Map,patterns:a=["**/*"]}=t,o=await fv(e,a),s={};for(let h of o){let g=Wc.join(e,h);if(!cu.existsSync(g)||cu.statSync(g).isDirectory())continue;let y={sha256:pv(g)},_=n.get(h);_&&(y.source=_),s[h]=y}let u=Jc(e),l=!u||!a6e(u.files,s),c=!u||u.generatorVersion!==r,d=i!==void 0&&(!u||u.inputHash!==i),p=l||c||d,f=p?new Date().toISOString():u?.updatedAt,m={version:i6e,generatorVersion:r,files:s};return i!==void 0&&(m.inputHash=i),f&&(m.updatedAt=f),{manifest:m,changed:p}}async function Gf(e,t){let r=Jc(e);if(!r)return{skip:!1,reason:"No manifest found"};if(!r.inputHash)return{skip:!1,reason:"Manifest has no inputHash (pre-cache version)"};if(r.inputHash!==t)return{skip:!1,reason:"Input files have changed"};let i=await mv(e);return i.valid?{skip:!0,reason:"Input and output hashes match"}:{skip:!1,reason:`${i.mismatches.length} generated file(s) have been modified`}}function gl(e,t){let r=Wc.join(t,Kc);return cu.writeFileSync(r,JSON.stringify(e,null,2)+`
287
287
  `),r}function Jc(e){let t=Wc.join(e,Kc);if(!cu.existsSync(t))return null;try{let r=cu.readFileSync(t,"utf-8");return JSON.parse(r)}catch{return null}}async function mv(e){let t=Jc(e);if(!t)return{valid:!1,mismatches:[{file:Kc,reason:"missing"}],manifestPath:Wc.join(e,Kc)};let r=[];for(let[a,o]of Object.entries(t.files)){let s=Wc.join(e,a);if(!cu.existsSync(s)){r.push({file:a,reason:"missing"});continue}let u=pv(s);u!==o.sha256&&r.push({file:a,reason:"hash-mismatch",expected:o.sha256.slice(0,16)+"...",actual:u.slice(0,16)+"..."})}let i=await fv(e),n=new Set(Object.keys(t.files));for(let a of i)n.has(a)||r.push({file:a,reason:"extra"});return{valid:r.length===0,mismatches:r,manifestPath:Wc.join(e,Kc)}}async function hv(e){let t=Date.now(),r=e.generatedDir||"packages/";try{if(!cu.existsSync(r))return{name:"manifest",status:"skip",duration:Date.now()-t,message:`Generated directory not found: ${r}`};let i=await mv(r);if(i.valid){let a=Jc(r),o=a?Object.keys(a.files).length:0;return{name:"manifest",status:"pass",duration:Date.now()-t,message:`All ${o} generated files match manifest`}}let n=i.mismatches.map(a=>a.reason==="missing"?` - ${a.file}: FILE MISSING`:a.reason==="hash-mismatch"?` - ${a.file}: HASH MISMATCH
288
288
  Expected: ${a.expected}
289
289
  Actual: ${a.actual}`:` - ${a.file}: EXTRA FILE (not in manifest)`);return{name:"manifest",status:"fail",duration:Date.now()-t,message:`${i.mismatches.length} file(s) failed integrity check`,details:n}}catch(i){return{name:"manifest",status:"fail",duration:Date.now()-t,message:i instanceof Error?i.message:String(i)}}}function $F(e){let t=[];if(e.valid)t.push("\u2705 All generated files match manifest");else{t.push(`\u274C Generated artifact integrity check failed:
@@ -887,7 +887,7 @@ or
887
887
  `);return{permission:"deny",user_message:l,agent_message:l}}return{}}function n(a){let o=a.file_path??"",s=a.content??"";if(!o)return{};let u=t({filePath:o,content:s}),l=r0(u);if(l.length>0){let c=l.map(d=>`[${d.guardrail_id}] ${d.message}`).join(`
888
888
  `);return{permission:"deny",user_message:c,agent_message:c}}return{}}return{beforeShellExecution:r,preToolUse:i,afterFileEdit:n,runChecks:t}}function yre(e){let t=e.commandRules.map(n=>({guardrail_id:n.guardrail_id,pattern:new RegExp(n.pattern),action:n.action,message:n.message})),r=e.fileRules,i=e.contentRules.map(n=>({guardrail_id:n.guardrail_id,pattern:new RegExp(n.pattern),action:n.action,message:n.message,file_glob:n.file_glob,exclude_glob:n.exclude_glob}));return OC({checkCommand(n){let a=[];for(let o of t){let s=!o.pattern.test(n);a.push({guardrail_id:o.guardrail_id,passed:s,action:o.action,message:s?"":o.message})}return a},checkFilePath(n){let a=[];for(let o of r){if(o.exclude_glob&&D6(o.exclude_glob,n))continue;let s=D6(o.pattern,n);a.push({guardrail_id:o.guardrail_id,passed:!s,action:o.action,message:s?o.message:""})}return a},checkContent(n,a){let o=[];for(let s of i){if(s.file_glob&&!D6(s.file_glob,n)||s.exclude_glob&&D6(s.exclude_glob,n))continue;let u=s.pattern.test(a);o.push({guardrail_id:s.guardrail_id,passed:!u,action:s.action,message:u?s.message:""})}return o}})}function _re(e){return{workflow(t){return new PC(e.adapter,t,e.registries)}}}function bTe(e){return typeof e=="object"&&e!==null&&typeof e.id=="string"}async function wTe(e){return bre(e)?(await vTe(e,{withFileTypes:!0})).filter(r=>r.isFile()&&_Te.some(i=>r.name.endsWith(i))&&!r.name.startsWith("_")&&!r.name.endsWith(".d.ts")&&!r.name.endsWith(".test.ts")&&!r.name.endsWith(".spec.ts")).map(r=>wre(e,r.name)):[]}async function Sre(e){let t=await import(new URL(`file://${e}`).href),r=0;for(let i of Object.values(t))if(bTe(i))try{ui.register(i),r++}catch{}return r}async function IC(e,t){let r={loaded:0,files:[],errors:[]};for(let i of e){let n=wre(t,i);if(!bre(n)){r.errors.push({file:i,error:`File not found: ${n}`});continue}try{let a=await Sre(n);r.loaded+=a,r.files.push(n)}catch(a){r.errors.push({file:i,error:a.message})}}return r}async function jC(e){let t={loaded:0,files:[],errors:[]},r=await wTe(e);for(let i of r)try{let n=await Sre(i);t.loaded+=n,t.files.push(i)}catch(n){t.errors.push({file:i,error:n.message})}return t}async function Ere(e){if(e.pluginPaths&&e.pluginPaths.length>0)return IC(e.pluginPaths,e.projectDir);let t=yTe(e.projectDir,"src","plugins");return jC(t)}function STe(e,t){let r=e;return typeof t.minLength=="number"&&(r=r.min(t.minLength)),typeof t.maxLength=="number"&&(r=r.max(t.maxLength)),typeof t.pattern=="string"&&(r=r.regex(new RegExp(t.pattern))),r}function fre(e,t,r){let i=e;return r&&(i=i.int()),typeof t.minimum=="number"&&(i=i.min(t.minimum)),typeof t.maximum=="number"&&(i=i.max(t.maximum)),i}function ETe(e,t){let r=e;return typeof t.minItems=="number"&&(r=r.min(t.minItems)),typeof t.maxItems=="number"&&(r=r.max(t.maxItems)),r}function op(e){if(!e||typeof e!="object")return Te.unknown();if(e.enum){let r=e.enum;return r.length===0?Te.unknown():Te.enum(r)}if(e.const!==void 0){let r=e.const;return typeof r=="string"||typeof r=="number"||typeof r=="boolean"?Te.literal(r):Te.unknown()}let t=e.type;if(t==="string")return STe(Te.string(),e);if(t==="integer")return fre(Te.number(),e,!0);if(t==="number")return fre(Te.number(),e,!1);if(t==="boolean")return Te.boolean();if(t==="array"){let r=e.items,i=r?op(r):Te.unknown();return ETe(Te.array(i),e)}if(t==="object"){let r=e.properties;if(!r)return Te.record(Te.string(),Te.unknown());let i=new Set(e.required??[]),n={};for(let[a,o]of Object.entries(r)){let s=op(o);n[a]=i.has(a)?s:s.optional()}return Te.object(n).passthrough()}if(e.allOf){let r=e.allOf.map(op);if(r.length===0)return Te.unknown();if(r.length===1)return r[0];let i=r[0];for(let n=1;n<r.length;n++){let a=r[n];i instanceof Te.ZodObject&&a instanceof Te.ZodObject&&(i=i.merge(a))}return i}return Te.unknown()}function $Te(e){let t={};for(let[r,i]of Object.entries(e)){let a=(i.mode??"read-only")==="read-write"?"read-write":"read-only";t[r]={id:r,role_name:i.role_name??r,purpose:i.purpose??"",mode:a,responsibilities:i.responsibilities??[],constraints:i.constraints??[],rules:i.rules??[]}}return t}function xTe(e){let t={};for(let[r,i]of Object.entries(e))t[r]={id:r,description:i.description??"",target_agent:i.target_agent??"",result_handoff:i.result_handoff??"",completion_criteria:i.completion_criteria??[],model_class:i.model_class};return t}function kTe(e){return e.type==="gate"?{type:"gate",gate_kind:e.gate_kind??"",description:e.description??"",depends_on:e.depends_on}:{type:"delegate",task:e.task??"",from_agent:e.from_agent??"",description:e.description??"",optional:e.optional??!1,max_retries:e.max_retries??0,max_follow_ups:e.max_follow_ups,depends_on:e.depends_on,retry:e.retry}}function ATe(e){let t={};for(let[r,i]of Object.entries(e)){let n=(i.steps??[]).map(kTe);t[r]={id:r,description:i.description??"",steps:n}}return t}function CTe(e){let t={};for(let[r,i]of Object.entries(e)){let n=i.schema;n&&(t[r]=op(n))}return t}function NC(e){let t=e._guardrailRules;if(t)return{commandRules:t.commandRules??[],fileRules:t.fileRules??[],contentRules:t.contentRules??[]}}function RC(e){let t=e.agents??{},r=e.tasks??{},i=e.workflow??{},n=e.handoff_types??{};return{agentRegistry:$Te(t),taskRegistry:xTe(r),workflowRegistry:ATe(i),handoffSchemas:CTe(n)}}function DTe(e,t){let r=[],i=e.workflow??{},n=e.tasks??{},a=e.handoff_types??{};if(t.workflows)for(let o of t.workflows)o in i||r.push(`workflow "${o}" is required by the CLI but not found in the resolved DSL`);if(t.tasks)for(let o of t.tasks){if(!(o in n)){r.push(`task "${o}" is required by the CLI but not found in the resolved DSL`);continue}let s=n[o],u=s.invocation_handoff,l=s.result_handoff;u&&!(u in a)&&r.push(`handoff_type "${u}" (invocation_handoff of task "${o}") not found`),l&&!(l in a)&&r.push(`handoff_type "${l}" (result_handoff of task "${o}") not found`)}if(t.workflows)for(let o of t.workflows){if(!(o in i))continue;let u=i[o].steps??[];for(let l of u){if(l.type!=="delegate")continue;let c=l.task;if(c&&c in n){let p=n[c].result_handoff;p&&!(p in a)&&r.push(`handoff_type "${p}" (result of task "${c}" in workflow "${o}") not found`)}}}if(r.length>0)throw new TC(r)}async function $re(e){let t;if(e.projectDslPath){let{resolve:n,mergeDsl:a,expandDefaults:o}=await Promise.resolve().then(()=>(cre(),lre)),s=await n(e.projectDslPath),u=a(e.embeddedDsl,s.data);t=o(u)}else t=e.embeddedDsl;e.requiredEntities&&DTe(t,e.requiredEntities);let r=RC(t),i=NC(t);return{registries:r,dsl:t,guardrailRules:i}}function RTe(e,t,r){if(t==="single")return e;let i=xre(e),n=NTe(e),a=TTe(e,n),o=new Date;if(t==="daily"){let c=o.toISOString().slice(0,10);return mre(i,`${a}-${c}${n}`)}let s=c=>String(c).padStart(2,"0"),u=`${o.getFullYear()}${s(o.getMonth()+1)}${s(o.getDate())}T${s(o.getHours())}${s(o.getMinutes())}${s(o.getSeconds())}`,l=r?`-${r}`:"";return mre(i,`${a}-${u}${l}${n}`)}function kre(e){let t=e.stderr??!1,r=null,i;if(e.file){let n=e.naming??"single";i=RTe(e.file,n,e.label),jTe(xre(i),{recursive:!0}),r=OTe(i,"a")}return!t&&r===null?{write(){},close(){}}:{write(n){t&&process.stderr.write(n),r!==null&&PTe(r,n)},close(){r!==null&&(ITe(r),r=null)},get filePath(){return i}}}var P6,wC,ui,PC,_Te,TC,Are,Cre=Xe(()=>{uy();P6=Hu(z1(),1);uy();wC=class{plugins=[];register(e){if(this.plugins.some(t=>t.id===e.id))throw new Error(`Plugin "${e.id}" is already registered`);this.plugins.push(e)}getAll(){return this.plugins}async runBeforeTask(e,t){let r=t;for(let i of this.plugins)!i.beforeTask||r===null||(r=await i.beforeTask(e,r));return r}async runAfterTask(e,t){let r=t;for(let i of this.plugins)i.afterTask&&(r=await i.afterTask(e,r));return r}applyContextEnhancers(e,t){let r=t;for(let i of this.plugins)i.contextEnhancer&&(r=i.contextEnhancer(e,r));return r}applyPromptBuilder(e){for(let t of this.plugins){if(!t.promptBuilder)continue;let r=t.promptBuilder(e);if(r!==null)return r}return null}applyPromptEnhancers(e,t,r){let i=t;for(let n of this.plugins)n.promptEnhancer&&(i=n.promptEnhancer(e,i,r));return i}evaluateCommandGuardrails(e){let t=[];for(let r of this.plugins)r.customGuardrails?.evaluateCommand&&t.push(...r.customGuardrails.evaluateCommand(e));return t}evaluateFilePathGuardrails(e){let t=[];for(let r of this.plugins)r.customGuardrails?.evaluateFilePath&&t.push(...r.customGuardrails.evaluateFilePath(e));return t}evaluateFileContentGuardrails(e,t){let r=[];for(let i of this.plugins)i.customGuardrails?.evaluateFileContent&&r.push(...i.customGuardrails.evaluateFileContent(e,t));return r}async runBeforeWorkflow(e,t){for(let r of this.plugins)r.beforeWorkflow&&await r.beforeWorkflow(e,t)}async runAfterWorkflow(e,t){for(let r of this.plugins)r.afterWorkflow&&await r.afterWorkflow(e,t)}},ui=new wC;PC=class{adapter;invocation;registries;constructor(e,t,r){this.adapter=e,this.invocation={workflow:t},this.registries=r}handoff(e){return this.invocation={...this.invocation,handoff:e},this}request(e){return this.invocation={...this.invocation,user_request:e},this}maxFollowUps(e){return this.invocation={...this.invocation,runtime:{...this.invocation.runtime,maxFollowUps:e}},this}maxRetries(e){return this.invocation={...this.invocation,runtime:{...this.invocation.runtime,maxRetries:e}},this}onStepComplete(e){return this.invocation={...this.invocation,hooks:{...this.invocation.hooks,onStepComplete:e}},this}onGate(e){return this.invocation={...this.invocation,hooks:{...this.invocation.hooks,onGate:e}},this}onOptionalStep(e){return this.invocation={...this.invocation,hooks:{...this.invocation.hooks,onOptionalStep:e}},this}progressOutput(e){return this.invocation={...this.invocation,progressOutput:e},this}async run(){return kC(this.adapter,this.invocation,this.registries)}},_Te=[".ts",".js",".mts",".mjs"];TC=class extends Error{missing;constructor(e){super(`Required entities missing after DSL merge:
889
889
  `+e.map(t=>` - ${t}`).join(`
890
- `)),this.name="DslValidationError",this.missing=e}};Are=class{data=new Map;async save(e,t){this.data.set(e.id,t)}async load(e){return this.data.get(e.id)??null}async delete(e){this.data.delete(e.id)}}});function Dre(e,t){let r=e.indexOf(":");if(r===-1)return{adapter:t,model:e||void 0};let i=e.slice(0,r)||t,n=e.slice(r+1)||void 0;return{adapter:i,model:n}}function Ore(e){let t=e.env??process.env;return{resolve(r){let i={adapter:e.fallbackAdapter,model:e.fallbackModel};if(!r)return i;let n=t[BTe[r]];if(n)return Dre(n,e.fallbackAdapter);let a=t[R6];if(a)return Dre(a,e.fallbackAdapter);let o=e.modelMapping?.[r];return o?{adapter:o.adapter,model:o.model}:i}}}var R6,BTe,Pre=Xe(()=>{R6="AGENT_RUNTIME_MODEL",BTe={fast:`${R6}_FAST`,standard:`${R6}_STANDARD`,thinking:`${R6}_THINKING`}});var Ire={};Ln(Ire,{DslValidationError:()=>TC,InMemoryStore:()=>Are,PluginRegistry:()=>wC,WorkflowBuilder:()=>PC,buildCandidateAgents:()=>SC,buildGateEvaluationPrompt:()=>AC,buildGuardrailRulesFromDsl:()=>NC,buildRegistriesFromDsl:()=>RC,buildRetryFollowUp:()=>$C,buildSplitTaskPrompt:()=>N6,buildTaskPrompt:()=>O6,createGuardrailHooks:()=>OC,createGuardrailHooksFromRules:()=>yre,createModelResolver:()=>Ore,createProgressSink:()=>kre,createRuntime:()=>_re,extractStructuredResult:()=>EC,getBlockingViolations:()=>r0,getWarnings:()=>DC,hasBlockingViolation:()=>vre,jsonSchemaToZod:()=>op,loadDslContext:()=>$re,loadPlugins:()=>Ere,loadPluginsFromDirectory:()=>jC,loadPluginsFromPaths:()=>IC,parseGateEvaluationResponse:()=>CC,pluginRegistry:()=>ui,renderAgentSystemPrompt:()=>I6,runTask:()=>xC,runWorkflow:()=>kC,zodSchemaToPromptDescription:()=>n0,zodSchemaToYamlExample:()=>T6});var jre=Xe(()=>{Cre();Pre()});var FTe,Tre,Nre=Xe(()=>{"use strict";FTe={id:"openapi-design-reviewer",role_name:"OpenAPI Design Reviewer",purpose:"Review OpenAPI specifications for design quality, module boundary alignment, and operational readiness in contract-first TypeScript web/API systems. Identifies semantic issues that static linting cannot detect by considering service decomposition, dependency graphs, overlay coverage, and public API surface exposure.",mode:"read-only",dispatch_only:!1,can_read_artifacts:["openapi-spec-input","config-source","overlay-definitions","lint-results-input","deps-graph-input","published-spec-input","guardrails-config-input","cli-contract-source"],can_write_artifacts:[],can_execute_tools:[],can_invoke_agents:[],can_return_handoffs:["openapi-audit-result","published-review-result","overlay-proposal-result","guardrails-audit-result"],responsibilities:["Evaluate path design and feature module boundary alignment using x-micro-contracts-service grouping","Detect request/response schema bloat and overly coupled resource models","Verify x-micro-contracts-service and operationId consistency within modules","Assess CRUD-heavy APIs vs use-case-oriented design and suggest improvements","Detect public API surface leakage of internal types via x-micro-contracts-non-exportable analysis","Evaluate backward compatibility risks in published API changes","Propose cross-cutting overlays for auth, tenancy, rate limiting, and audit logging patterns","Verify overlay proposals do not conflict with existing overlay definitions","Check guardrails.yaml drift detection and OpenAPI lint rule coverage","Use module dependency graph (deps command output) for cross-module analysis"],constraints:["Do not modify OpenAPI specs, overlays, config files, or any source artifacts","Do not claim an API design is sound without citing specific structural evidence","Prefer actionable recommendations over abstract design principles","Reference micro-contracts lint rules and extension names when findings overlap","Consider multi-module architecture when evaluating cross-cutting concerns","Output must conform to AgentAuditResult schema (summary, riskLevel, findings, recommendedActions, metadata)","Each finding must include a recommendation when severity is warning or above"],rules:[{id:"R-OAR-001",description:"Operations without x-micro-contracts-service are flagged as unclassified and may indicate missing module assignment",severity:"mandatory"},{id:"R-OAR-002",description:"Schemas referenced by published endpoints must not carry x-micro-contracts-non-exportable",severity:"mandatory"},{id:"R-OAR-003",description:"Overlay proposals must not conflict with existing overlay definitions in the shared overlays directory",severity:"mandatory"},{id:"R-OAR-004",description:"Response schemas with more than 20 top-level properties are flagged as potential bloat",severity:"recommended"},{id:"R-OAR-005",description:"Modules with more than 3 cross-module schema references are flagged for coupling review",severity:"recommended"},{id:"R-OAR-006",description:"Generated file patterns in guardrails.yaml must cover all output directories configured in modules",severity:"mandatory"}],escalation_criteria:[{condition:"OpenAPI specification cannot be parsed or is structurally invalid",action:"stop_and_report"},{condition:"Configuration file references missing modules or specs",action:"stop_and_report"}]},Tre={"openapi-design-reviewer":FTe}});var MTe,LTe,zTe,UTe,Rre,Bre=Xe(()=>{"use strict";MTe={id:"audit-openapi-design",description:"Audit OpenAPI specification design quality and module boundary alignment",target_agent:"openapi-design-reviewer",allowed_from_agents:["openapi-design-reviewer"],workflow:"openapi-audit",invocation_handoff:"openapi-audit-request",result_handoff:"openapi-audit-result",input_artifacts:["openapi-spec-input","config-source","overlay-definitions","lint-results-input","deps-graph-input"],responsibilities:["Evaluate all paths for module boundary alignment","Check operationId and x-micro-contracts-service consistency","Detect schema bloat and excessive coupling","Assess CRUD vs use-case-oriented design","Review overlay usage and cross-cutting concerns"],completion_criteria:["All paths and operations have been evaluated for design quality","Findings classified by category (design_quality, responsibility_boundary, api_bloat, dependency_coupling)","Module boundary alignment explicitly assessed","Recommendations reference specific paths and operations","Output conforms to AgentAuditResult schema"],optional:!1,model_class:"standard"},LTe={id:"audit-published-api",description:"Review published API surface for internal type leakage and compatibility",target_agent:"openapi-design-reviewer",allowed_from_agents:["openapi-design-reviewer"],workflow:"published-review",invocation_handoff:"openapi-audit-request",result_handoff:"published-review-result",input_artifacts:["openapi-spec-input","published-spec-input","config-source","deps-graph-input"],responsibilities:["Compare master spec against published spec for leakage","Identify schemas with x-micro-contracts-non-exportable that appear in published surface","Assess backward compatibility of published endpoint changes","Enumerate published endpoints with their operation details"],completion_criteria:["All published endpoints enumerated with operationId, path, method","Leaked internal types identified with referencing context","Backward compatibility risks assessed for each published endpoint","Output conforms to PublishedReviewResult schema (publishedEndpoints, leakedInternalTypes)"],optional:!1,model_class:"standard"},zTe={id:"propose-overlay-candidates",description:"Propose cross-cutting overlay candidates for the API specification",target_agent:"openapi-design-reviewer",allowed_from_agents:["openapi-design-reviewer"],workflow:"overlay-proposal",invocation_handoff:"openapi-audit-request",result_handoff:"overlay-proposal-result",input_artifacts:["openapi-spec-input","overlay-definitions","config-source"],responsibilities:["Identify endpoints needing cross-cutting concerns (auth, tenancy, rate limit, audit log)","Generate overlay candidates with endpoint, type, rationale, and suggested config","Verify proposals do not conflict with existing overlay definitions","Group candidates by overlay type for batch application"],completion_criteria:["Candidate overlays identified for endpoints lacking cross-cutting concerns","Each candidate includes endpoint, overlayType, rationale, and suggestedConfig","No conflicts with existing overlay definitions confirmed","Output conforms to OverlayProposalResult schema (overlayCandidates)"],optional:!1,model_class:"standard"},UTe={id:"audit-guardrails-coverage",description:"Audit guardrails.yaml for drift detection and lint rule coverage",target_agent:"openapi-design-reviewer",allowed_from_agents:["openapi-design-reviewer"],workflow:"guardrails-audit",invocation_handoff:"openapi-audit-request",result_handoff:"guardrails-audit-result",input_artifacts:["guardrails-config-input","config-source","openapi-spec-input"],responsibilities:["Verify generated file patterns cover all configured output directories","Check that drift detection covers all generated artifact types","Verify OpenAPI lint rules are configured for all spec files","Identify uncovered paths in guardrails configuration"],completion_criteria:["All configured output directories checked against guardrails generated patterns","Covered and uncovered paths explicitly listed","Lint rule coverage for each spec file assessed","Output conforms to GuardrailsAuditResult schema (coveredPaths, uncoveredPaths)"],optional:!1,model_class:"fast"},Rre={"audit-openapi-design":MTe,"audit-published-api":LTe,"propose-overlay-candidates":zTe,"audit-guardrails-coverage":UTe}});var Fre,Mre,Lre,zre,Ure,qre,Vre,Zre=Xe(()=>{"use strict";uy();Fre=Te.object({task_id:Te.string(),context:Te.string()}),Mre=Te.object({summary:Te.string(),riskLevel:Te.enum(["low","medium","high","critical"]),findings:Te.array(Te.object({id:Te.string().optional(),severity:Te.enum(["info","warning","error","critical"]),category:Te.string(),target:Te.string().optional(),location:Te.string().optional(),message:Te.string(),recommendation:Te.string().optional(),confidence:Te.number().min(0).max(1).optional(),evidence:Te.array(Te.object({kind:Te.enum(["file","command","schema","diff","stdout","stderr","text"]).optional(),target:Te.string().optional(),location:Te.string().optional(),excerpt:Te.string().optional()})).optional(),details:Te.record(Te.string(),Te.unknown()).optional()})),recommendedActions:Te.array(Te.object({kind:Te.enum(["run_command","edit_file","review","confirm","block","ignore"]),title:Te.string(),command:Te.string().optional(),target:Te.string().optional(),rationale:Te.string().optional()})).optional(),metadata:Te.object({tool:Te.string().optional(),command:Te.string().optional(),version:Te.string().optional(),generatedAt:Te.string().optional(),adapter:Te.string().optional(),model:Te.string().optional()}).optional()}),Lre=Te.object({summary:Te.string(),riskLevel:Te.enum(["low","medium","high","critical"]),findings:Te.array(Te.object({severity:Te.enum(["info","warning","error","critical"]),category:Te.string(),message:Te.string(),recommendation:Te.string().optional()})),publishedEndpoints:Te.array(Te.object({operationId:Te.string(),path:Te.string(),method:Te.string()})),leakedInternalTypes:Te.array(Te.object({schemaName:Te.string(),referencedBy:Te.string(),reason:Te.string()})),recommendedActions:Te.array(Te.object({kind:Te.enum(["run_command","edit_file","review","confirm","block","ignore"]),title:Te.string(),command:Te.string().optional(),target:Te.string().optional(),rationale:Te.string().optional()})).optional(),metadata:Te.object({tool:Te.string().optional(),command:Te.string().optional(),version:Te.string().optional(),generatedAt:Te.string().optional(),adapter:Te.string().optional(),model:Te.string().optional()}).optional()}),zre=Te.object({summary:Te.string(),riskLevel:Te.enum(["low","medium","high","critical"]),findings:Te.array(Te.object({severity:Te.enum(["info","warning","error","critical"]),category:Te.string(),message:Te.string(),recommendation:Te.string().optional()})),overlayCandidates:Te.array(Te.object({endpoint:Te.string(),overlayType:Te.enum(["auth","tenancy","rateLimit","auditLog","custom"]),rationale:Te.string(),suggestedConfig:Te.record(Te.string(),Te.unknown()).optional()})),recommendedActions:Te.array(Te.object({kind:Te.enum(["run_command","edit_file","review","confirm","block","ignore"]),title:Te.string(),command:Te.string().optional(),target:Te.string().optional(),rationale:Te.string().optional()})).optional(),metadata:Te.object({tool:Te.string().optional(),command:Te.string().optional(),version:Te.string().optional(),generatedAt:Te.string().optional(),adapter:Te.string().optional(),model:Te.string().optional()}).optional()}),Ure=Te.object({summary:Te.string(),riskLevel:Te.enum(["low","medium","high","critical"]),findings:Te.array(Te.object({severity:Te.enum(["info","warning","error","critical"]),category:Te.string(),message:Te.string(),recommendation:Te.string().optional()})),coveredPaths:Te.array(Te.string()),uncoveredPaths:Te.array(Te.string()),recommendedActions:Te.array(Te.object({kind:Te.enum(["run_command","edit_file","review","confirm","block","ignore"]),title:Te.string(),command:Te.string().optional(),target:Te.string().optional(),rationale:Te.string().optional()})).optional(),metadata:Te.object({tool:Te.string().optional(),command:Te.string().optional(),version:Te.string().optional(),generatedAt:Te.string().optional(),adapter:Te.string().optional(),model:Te.string().optional()}).optional()}),qre={"openapi-audit-request":Fre,"openapi-audit-result":Mre,"published-review-result":Lre,"overlay-proposal-result":zre,"guardrails-audit-result":Ure},Vre={openapiAuditRequest(e){return{type:"openapi-audit-request",version:1,payload:Fre.parse(e)}},openapiAuditResult(e){return{type:"openapi-audit-result",version:1,payload:Mre.parse(e)}},publishedReviewResult(e){return{type:"published-review-result",version:1,payload:Lre.parse(e)}},overlayProposalResult(e){return{type:"overlay-proposal-result",version:1,payload:zre.parse(e)}},guardrailsAuditResult(e){return{type:"guardrails-audit-result",version:1,payload:Ure.parse(e)}}}});var qTe,VTe,ZTe,GTe,Gre,Wre=Xe(()=>{"use strict";qTe={id:"openapi-audit",description:"Audit OpenAPI design quality and module boundary alignment",trigger:"cli-command",entry_conditions:["OpenAPI specification and config are available"],steps:[{type:"delegate",task:"audit-openapi-design",from_agent:"openapi-design-reviewer",description:"",optional:!1,max_retries:0}]},VTe={id:"published-review",description:"Review published API surface for internal leakage and compatibility",trigger:"cli-command",entry_conditions:["Both master and published specs are available"],steps:[{type:"delegate",task:"audit-published-api",from_agent:"openapi-design-reviewer",description:"",optional:!1,max_retries:0}]},ZTe={id:"overlay-proposal",description:"Propose cross-cutting overlay candidates",trigger:"cli-command",entry_conditions:["OpenAPI specification and existing overlays are available"],steps:[{type:"delegate",task:"propose-overlay-candidates",from_agent:"openapi-design-reviewer",description:"",optional:!1,max_retries:0}]},GTe={id:"guardrails-audit",description:"Audit guardrails configuration for drift and lint coverage",trigger:"cli-command",entry_conditions:["guardrails.yaml configuration exists"],steps:[{type:"delegate",task:"audit-guardrails-coverage",from_agent:"openapi-design-reviewer",description:"",optional:!1,max_retries:0}]},Gre={"openapi-audit":qTe,"published-review":VTe,"overlay-proposal":ZTe,"guardrails-audit":GTe}});var Kre={};Ln(Kre,{agentRegistry:()=>Tre,handoffSchemas:()=>qre,handoffs:()=>Vre,taskRegistry:()=>Rre,workflowRegistry:()=>Gre});var Hre=Xe(()=>{"use strict";Nre();Bre();Zre();Wre()});var qC=Hu(z1(),1);import Sr from"fs";import sn from"path";var eT=Hu(Qj(),1),{program:KRe,createCommand:HRe,createArgument:JRe,createOption:YRe,CommanderError:XRe,InvalidArgumentError:QRe,InvalidOptionArgumentError:eBe,Command:tT,Argument:tBe,Option:rBe,Help:nBe}=eT.default;var rT={low:0,medium:1,high:2,critical:3};function Qme(...e){let t="low";for(let r of e)rT[r]>rT[t]&&(t=r);return t}function U5(e,t,r){return e.schema?.type==="boolean"?t===!0:e.repeatable?r&&Array.isArray(t)&&t.length>0:r&&t!=null}function nT(e){let t=new Set,r=[],i=[],n=[],a=[],o,s;if(e.command_effects){let f=e.command_effects;if(a.push(f.risk_level??"low"),f.writes){t.add("file_write");for(let m of f.writes)i.push({kind:"semantic",target:m.target,description:m.description,overwrite:m.overwrite,destructive:m.destructive,...m.idempotent!==void 0?{idempotent:m.idempotent}:{},...m.idempotency_key?{idempotency_key:m.idempotency_key}:{},...m.idempotent_note?{idempotent_note:m.idempotent_note}:{},source:`command:${e.command_id}`})}if(f.reads)for(let m of f.reads)r.push({kind:"semantic",target:m.target,description:m.description,source:`command:${e.command_id}`});f.network&&(t.add("network"),typeof f.network=="object"&&n.push({...f.network.description?{description:f.network.description}:{},...f.network.domains?{domains:f.network.domains}:{},...f.network.idempotent!==void 0?{idempotent:f.network.idempotent}:{},...f.network.idempotency_key?{idempotency_key:f.network.idempotency_key}:{},...f.network.idempotent_note?{idempotent_note:f.network.idempotent_note}:{},source:`command:${e.command_id}`})),f.execution_mode&&(o=f.execution_mode),f.requires_confirmation!==void 0&&(s=f.requires_confirmation)}for(let[f,m]of Object.entries(e.options)){let{definition:h,value:g,specified:y}=m;if(U5(h,g,y)){if(h.file){let w=typeof g=="string"?g:void 0,S=h.file.mode;(S==="read"||S==="readWrite")&&r.push({kind:"option-file",option:f,path:w,source:`option:${f}`}),(S==="write"||S==="append"||S==="readWrite")&&(t.add("file_write"),i.push({kind:"option-file",option:f,path:w,mode:S,source:`option:${f}`}))}if(h.effects){let w=h.effects;if(a.push(w.risk_level??"low"),w.writes){t.add("file_write");for(let S of w.writes)i.push({kind:"semantic",target:S.target,description:S.description,overwrite:S.overwrite,destructive:S.destructive,...S.idempotent!==void 0?{idempotent:S.idempotent}:{},...S.idempotency_key?{idempotency_key:S.idempotency_key}:{},...S.idempotent_note?{idempotent_note:S.idempotent_note}:{},source:`option:${f}`})}if(w.reads)for(let S of w.reads)r.push({kind:"semantic",target:S.target,description:S.description,source:`option:${f}`});w.network&&(t.add("network"),typeof w.network=="object"&&n.push({...w.network.description?{description:w.network.description}:{},...w.network.domains?{domains:w.network.domains}:{},...w.network.idempotent!==void 0?{idempotent:w.network.idempotent}:{},...w.network.idempotency_key?{idempotency_key:w.network.idempotency_key}:{},...w.network.idempotent_note?{idempotent_note:w.network.idempotent_note}:{},source:`option:${f}`})),w.execution_mode&&!o&&(o=w.execution_mode),w.requires_confirmation!==void 0&&s===void 0&&(s=w.requires_confirmation)}}}let u=a.length>0?Qme(...a):"low",l=s??(u==="high"||u==="critical"),c;if(e.env){let f=[];for(let[m,h]of Object.entries(e.env))h.sensitive&&f.push(m);f.length>0&&(c=f)}let p=i.filter(f=>f.kind==="semantic").every(f=>f.idempotent===!0)&&n.every(f=>f.idempotent===!0);return{risk_level:u,requires_confirmation:l,idempotent:p,side_effects:[...t],reads:r,writes:i,...n.length>0?{network:n}:{},...o?{execution_mode:o}:{},...c?{requires_secrets:c}:{}}}var ehe={generate:{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"module",schema:{type:"string"}},{name:"contracts-only",schema:{type:"boolean",default:!1}},{name:"server-only",schema:{type:"boolean",default:!1}},{name:"frontend-only",schema:{type:"boolean",default:!1}},{name:"docs-only",schema:{type:"boolean",default:!1}},{name:"skip-lint",schema:{type:"boolean",default:!1}},{name:"manifest",schema:{type:"boolean",default:!0}},{name:"manifest-dir",schema:{type:"string",default:"packages/"}},{name:"force",schema:{type:"boolean",default:!1}},{name:"cache",schema:{type:"boolean",default:!0}}]},lint:{options:[{name:"strict",schema:{type:"boolean",default:!1}}]},init:{options:[{name:"dir",schema:{type:"string",default:"src"}},{name:"openapi",schema:{type:"string"},file:{mode:"read",exists:!0,media_type:"application/yaml",encoding:"utf-8"}},{name:"output",schema:{type:"string"}},{name:"skip-templates",schema:{type:"boolean",default:!1}},{name:"screens",schema:{type:"boolean",default:!1}}]},check:{options:[{name:"only",schema:{type:"string"}},{name:"skip",schema:{type:"string"}},{name:"gate",schema:{type:"string"}},{name:"verbose",schema:{type:"boolean",default:!1}},{name:"fix",schema:{type:"boolean",default:!1}},{name:"guardrails",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"generated-dir",schema:{type:"string",default:"packages/"}},{name:"changed-files",schema:{type:"string"},file:{mode:"read",exists:!0,media_type:"text/plain",encoding:"utf-8"}},{name:"list",schema:{type:"boolean",default:!1}},{name:"list-gates",schema:{type:"boolean",default:!1}}]},pipeline:{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"verbose",schema:{type:"boolean",default:!1}},{name:"skip",schema:{type:"string"}},{name:"continue-on-error",schema:{type:"boolean",default:!1}},{name:"guardrails",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"generated-dir",schema:{type:"string",default:"packages/"}},{name:"manifest",schema:{type:"boolean",default:!0}},{name:"skip-lint",schema:{type:"boolean",default:!1}},{name:"contracts-only",schema:{type:"boolean",default:!1}},{name:"server-only",schema:{type:"boolean",default:!1}},{name:"frontend-only",schema:{type:"boolean",default:!1}},{name:"docs-only",schema:{type:"boolean",default:!1}},{name:"force",schema:{type:"boolean",default:!1}},{name:"cache",schema:{type:"boolean",default:!0}}]},deps:{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"module",schema:{type:"string"}},{name:"graph",schema:{type:"boolean",default:!1}},{name:"impact",schema:{type:"string"}},{name:"who-depends-on",schema:{type:"string"}},{name:"validate",schema:{type:"boolean",default:!1}}]},insights:{options:[{name:"format",schema:{type:"string",default:"json"}},{name:"project-root",schema:{type:"string",default:"."}},{name:"config",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}}]},"guardrails-init":{options:[{name:"output",schema:{type:"string",default:"guardrails.yaml"}}]},manifest:{options:[{name:"dir",schema:{type:"string",default:"packages/"}},{name:"verify",schema:{type:"boolean",default:!1}},{name:"output",schema:{type:"string"}}]},"audit-openapi":{effects:{reads:["openapi-specs","config"],writes:[],network:{description:"LLM API calls when adapter is not mock",requires_secrets:[],idempotent:!0}},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"module",schema:{type:"string"}},{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"fail-on",schema:{type:"string",enum:["warning","error","critical"],default:"error"}},{name:"output",schema:{type:"string"},file:{mode:"write",media_type:"application/json",encoding:"utf-8"}},{name:"report-format",schema:{type:"string",enum:["json","text","yaml"],default:"text"}},{name:"log-file",schema:{type:"string"}}]},"review-published":{effects:{reads:["openapi-specs","config","generated-packages"],writes:[],network:{description:"LLM API calls when adapter is not mock",requires_secrets:[],idempotent:!0}},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"module",schema:{type:"string"}},{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"fail-on",schema:{type:"string",enum:["warning","error","critical"],default:"error"}},{name:"output",schema:{type:"string"},file:{mode:"write",media_type:"application/json",encoding:"utf-8"}},{name:"report-format",schema:{type:"string",enum:["json","text","yaml"],default:"text"}},{name:"log-file",schema:{type:"string"}}]},"propose-overlays":{effects:{reads:["openapi-specs","config"],writes:[],network:{description:"LLM API calls when adapter is not mock",requires_secrets:[],idempotent:!0}},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"module",schema:{type:"string"}},{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"fail-on",schema:{type:"string",enum:["warning","error","critical"],default:"error"}},{name:"output",schema:{type:"string"},file:{mode:"write",media_type:"application/json",encoding:"utf-8"}},{name:"report-format",schema:{type:"string",enum:["json","text","yaml"],default:"json"}},{name:"log-file",schema:{type:"string"}}]},"audit-guardrails":{effects:{reads:["guardrails-config","config"],writes:[],network:{description:"LLM API calls when adapter is not mock",requires_secrets:[],idempotent:!0}},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"guardrails",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"fail-on",schema:{type:"string",enum:["warning","error","critical"],default:"error"}},{name:"output",schema:{type:"string"},file:{mode:"write",media_type:"application/json",encoding:"utf-8"}},{name:"report-format",schema:{type:"string",enum:["json","text","yaml"],default:"text"}},{name:"log-file",schema:{type:"string"}}]}};function Oi(e,t){let r=ehe[e];if(!r)throw new Error(`Unknown command: ${e}`);let i=r,n={},a=[];for(let s of i.options??[]){let u=t[s.name],l=s.name in t&&u!==void 0;n[s.name]={value:u,specified:l,definition:s},U5(s,u,l)&&a.push(s.name)}let o=nT({command_id:e,command_effects:i.effects,options:n,env:i.env});return{command:e,active_options:a,policy:o}}var iT=`# yaml-language-server: $schema=./node_modules/cli-contracts/schemas/cli-contract.schema.json
890
+ `)),this.name="DslValidationError",this.missing=e}};Are=class{data=new Map;async save(e,t){this.data.set(e.id,t)}async load(e){return this.data.get(e.id)??null}async delete(e){this.data.delete(e.id)}}});function Dre(e,t){let r=e.indexOf(":");if(r===-1)return{adapter:t,model:e||void 0};let i=e.slice(0,r)||t,n=e.slice(r+1)||void 0;return{adapter:i,model:n}}function Ore(e){let t=e.env??process.env;return{resolve(r){let i={adapter:e.fallbackAdapter,model:e.fallbackModel};if(!r)return i;let n=t[BTe[r]];if(n)return Dre(n,e.fallbackAdapter);let a=t[R6];if(a)return Dre(a,e.fallbackAdapter);let o=e.modelMapping?.[r];return o?{adapter:o.adapter,model:o.model}:i}}}var R6,BTe,Pre=Xe(()=>{R6="AGENT_RUNTIME_MODEL",BTe={fast:`${R6}_FAST`,standard:`${R6}_STANDARD`,thinking:`${R6}_THINKING`}});var Ire={};Ln(Ire,{DslValidationError:()=>TC,InMemoryStore:()=>Are,PluginRegistry:()=>wC,WorkflowBuilder:()=>PC,buildCandidateAgents:()=>SC,buildGateEvaluationPrompt:()=>AC,buildGuardrailRulesFromDsl:()=>NC,buildRegistriesFromDsl:()=>RC,buildRetryFollowUp:()=>$C,buildSplitTaskPrompt:()=>N6,buildTaskPrompt:()=>O6,createGuardrailHooks:()=>OC,createGuardrailHooksFromRules:()=>yre,createModelResolver:()=>Ore,createProgressSink:()=>kre,createRuntime:()=>_re,extractStructuredResult:()=>EC,getBlockingViolations:()=>r0,getWarnings:()=>DC,hasBlockingViolation:()=>vre,jsonSchemaToZod:()=>op,loadDslContext:()=>$re,loadPlugins:()=>Ere,loadPluginsFromDirectory:()=>jC,loadPluginsFromPaths:()=>IC,parseGateEvaluationResponse:()=>CC,pluginRegistry:()=>ui,renderAgentSystemPrompt:()=>I6,runTask:()=>xC,runWorkflow:()=>kC,zodSchemaToPromptDescription:()=>n0,zodSchemaToYamlExample:()=>T6});var jre=Xe(()=>{Cre();Pre()});var FTe,Tre,Nre=Xe(()=>{"use strict";FTe={id:"openapi-design-reviewer",role_name:"OpenAPI Design Reviewer",purpose:"Review OpenAPI specifications for design quality, module boundary alignment, and operational readiness in contract-first TypeScript web/API systems. Identifies semantic issues that static linting cannot detect by considering service decomposition, dependency graphs, overlay coverage, and public API surface exposure.",mode:"read-only",dispatch_only:!1,can_read_artifacts:["openapi-spec-input","config-source","overlay-definitions","lint-results-input","deps-graph-input","published-spec-input","guardrails-config-input","cli-contract-source"],can_write_artifacts:[],can_execute_tools:[],can_invoke_agents:[],can_return_handoffs:["openapi-audit-result","published-review-result","overlay-proposal-result","guardrails-audit-result"],responsibilities:["Evaluate path design and feature module boundary alignment using x-micro-contracts-service grouping","Detect request/response schema bloat and overly coupled resource models","Verify x-micro-contracts-service and operationId consistency within modules","Assess CRUD-heavy APIs vs use-case-oriented design and suggest improvements","Detect public API surface leakage of internal types via x-micro-contracts-non-exportable analysis","Evaluate backward compatibility risks in published API changes","Propose cross-cutting overlays for auth, tenancy, rate limiting, and audit logging patterns","Verify overlay proposals do not conflict with existing overlay definitions","Check guardrails.yaml drift detection and OpenAPI lint rule coverage","Use module dependency graph (deps command output) for cross-module analysis"],constraints:["Do not modify OpenAPI specs, overlays, config files, or any source artifacts","Do not claim an API design is sound without citing specific structural evidence","Prefer actionable recommendations over abstract design principles","Reference micro-contracts lint rules and extension names when findings overlap","Consider multi-module architecture when evaluating cross-cutting concerns","Output must conform to AgentAuditResult schema (summary, riskLevel, findings, recommendedActions, metadata)","Each finding must include a recommendation when severity is warning or above"],rules:[{id:"R-OAR-001",description:"Operations without x-micro-contracts-service are flagged as unclassified and may indicate missing module assignment",severity:"mandatory"},{id:"R-OAR-002",description:"Schemas referenced by published endpoints must not carry x-micro-contracts-non-exportable",severity:"mandatory"},{id:"R-OAR-003",description:"Overlay proposals must not conflict with existing overlay definitions in the shared overlays directory",severity:"mandatory"},{id:"R-OAR-004",description:"Response schemas with more than 20 top-level properties are flagged as potential bloat",severity:"recommended"},{id:"R-OAR-005",description:"Modules with more than 3 cross-module schema references are flagged for coupling review",severity:"recommended"},{id:"R-OAR-006",description:"Generated file patterns in guardrails.yaml must cover all output directories configured in modules",severity:"mandatory"}],escalation_criteria:[{condition:"OpenAPI specification cannot be parsed or is structurally invalid",action:"stop_and_report"},{condition:"Configuration file references missing modules or specs",action:"stop_and_report"}]},Tre={"openapi-design-reviewer":FTe}});var MTe,LTe,zTe,UTe,Rre,Bre=Xe(()=>{"use strict";MTe={id:"audit-openapi-design",description:"Audit OpenAPI specification design quality and module boundary alignment",target_agent:"openapi-design-reviewer",allowed_from_agents:["openapi-design-reviewer"],workflow:"openapi-audit",invocation_handoff:"openapi-audit-request",result_handoff:"openapi-audit-result",input_artifacts:["openapi-spec-input","config-source","overlay-definitions","lint-results-input","deps-graph-input"],responsibilities:["Evaluate all paths for module boundary alignment","Check operationId and x-micro-contracts-service consistency","Detect schema bloat and excessive coupling","Assess CRUD vs use-case-oriented design","Review overlay usage and cross-cutting concerns"],completion_criteria:["All paths and operations have been evaluated for design quality","Findings classified by category (design_quality, responsibility_boundary, api_bloat, dependency_coupling)","Module boundary alignment explicitly assessed","Recommendations reference specific paths and operations","Output conforms to AgentAuditResult schema"],optional:!1,model_class:"standard"},LTe={id:"audit-published-api",description:"Review published API surface for internal type leakage and compatibility",target_agent:"openapi-design-reviewer",allowed_from_agents:["openapi-design-reviewer"],workflow:"published-review",invocation_handoff:"openapi-audit-request",result_handoff:"published-review-result",input_artifacts:["openapi-spec-input","published-spec-input","config-source","deps-graph-input"],responsibilities:["Compare master spec against published spec for leakage","Identify schemas with x-micro-contracts-non-exportable that appear in published surface","Assess backward compatibility of published endpoint changes","Enumerate published endpoints with their operation details"],completion_criteria:["All published endpoints enumerated with operationId, path, method","Leaked internal types identified with referencing context","Backward compatibility risks assessed for each published endpoint","Output conforms to PublishedReviewResult schema (publishedEndpoints, leakedInternalTypes)"],optional:!1,model_class:"standard"},zTe={id:"propose-overlay-candidates",description:"Propose cross-cutting overlay candidates for the API specification",target_agent:"openapi-design-reviewer",allowed_from_agents:["openapi-design-reviewer"],workflow:"overlay-proposal",invocation_handoff:"openapi-audit-request",result_handoff:"overlay-proposal-result",input_artifacts:["openapi-spec-input","overlay-definitions","config-source"],responsibilities:["Identify endpoints needing cross-cutting concerns (auth, tenancy, rate limit, audit log)","Generate overlay candidates with endpoint, type, rationale, and suggested config","Verify proposals do not conflict with existing overlay definitions","Group candidates by overlay type for batch application"],completion_criteria:["Candidate overlays identified for endpoints lacking cross-cutting concerns","Each candidate includes endpoint, overlayType, rationale, and suggestedConfig","No conflicts with existing overlay definitions confirmed","Output conforms to OverlayProposalResult schema (overlayCandidates)"],optional:!1,model_class:"standard"},UTe={id:"audit-guardrails-coverage",description:"Audit guardrails.yaml for drift detection and lint rule coverage",target_agent:"openapi-design-reviewer",allowed_from_agents:["openapi-design-reviewer"],workflow:"guardrails-audit",invocation_handoff:"openapi-audit-request",result_handoff:"guardrails-audit-result",input_artifacts:["guardrails-config-input","config-source","openapi-spec-input"],responsibilities:["Verify generated file patterns cover all configured output directories","Check that drift detection covers all generated artifact types","Verify OpenAPI lint rules are configured for all spec files","Identify uncovered paths in guardrails configuration"],completion_criteria:["All configured output directories checked against guardrails generated patterns","Covered and uncovered paths explicitly listed","Lint rule coverage for each spec file assessed","Output conforms to GuardrailsAuditResult schema (coveredPaths, uncoveredPaths)"],optional:!1,model_class:"fast"},Rre={"audit-openapi-design":MTe,"audit-published-api":LTe,"propose-overlay-candidates":zTe,"audit-guardrails-coverage":UTe}});var Fre,Mre,Lre,zre,Ure,qre,Vre,Zre=Xe(()=>{"use strict";uy();Fre=Te.object({task_id:Te.string(),context:Te.string()}),Mre=Te.object({summary:Te.string(),riskLevel:Te.enum(["low","medium","high","critical"]),findings:Te.array(Te.object({id:Te.string().optional(),severity:Te.enum(["info","warning","error","critical"]),category:Te.string(),target:Te.string().optional(),location:Te.string().optional(),message:Te.string(),recommendation:Te.string().optional(),confidence:Te.number().min(0).max(1).optional(),evidence:Te.array(Te.object({kind:Te.enum(["file","command","schema","diff","stdout","stderr","text"]).optional(),target:Te.string().optional(),location:Te.string().optional(),excerpt:Te.string().optional()})).optional(),details:Te.record(Te.string(),Te.unknown()).optional()})),recommendedActions:Te.array(Te.object({kind:Te.enum(["run_command","edit_file","review","confirm","block","ignore"]),title:Te.string(),command:Te.string().optional(),target:Te.string().optional(),rationale:Te.string().optional()})).optional(),metadata:Te.object({tool:Te.string().optional(),command:Te.string().optional(),version:Te.string().optional(),generatedAt:Te.string().optional(),adapter:Te.string().optional(),model:Te.string().optional()}).optional()}),Lre=Te.object({summary:Te.string(),riskLevel:Te.enum(["low","medium","high","critical"]),findings:Te.array(Te.object({severity:Te.enum(["info","warning","error","critical"]),category:Te.string(),message:Te.string(),recommendation:Te.string().optional()})),publishedEndpoints:Te.array(Te.object({operationId:Te.string(),path:Te.string(),method:Te.string()})),leakedInternalTypes:Te.array(Te.object({schemaName:Te.string(),referencedBy:Te.string(),reason:Te.string()})),recommendedActions:Te.array(Te.object({kind:Te.enum(["run_command","edit_file","review","confirm","block","ignore"]),title:Te.string(),command:Te.string().optional(),target:Te.string().optional(),rationale:Te.string().optional()})).optional(),metadata:Te.object({tool:Te.string().optional(),command:Te.string().optional(),version:Te.string().optional(),generatedAt:Te.string().optional(),adapter:Te.string().optional(),model:Te.string().optional()}).optional()}),zre=Te.object({summary:Te.string(),riskLevel:Te.enum(["low","medium","high","critical"]),findings:Te.array(Te.object({severity:Te.enum(["info","warning","error","critical"]),category:Te.string(),message:Te.string(),recommendation:Te.string().optional()})),overlayCandidates:Te.array(Te.object({endpoint:Te.string(),overlayType:Te.enum(["auth","tenancy","rateLimit","auditLog","custom"]),rationale:Te.string(),suggestedConfig:Te.record(Te.string(),Te.unknown()).optional()})),recommendedActions:Te.array(Te.object({kind:Te.enum(["run_command","edit_file","review","confirm","block","ignore"]),title:Te.string(),command:Te.string().optional(),target:Te.string().optional(),rationale:Te.string().optional()})).optional(),metadata:Te.object({tool:Te.string().optional(),command:Te.string().optional(),version:Te.string().optional(),generatedAt:Te.string().optional(),adapter:Te.string().optional(),model:Te.string().optional()}).optional()}),Ure=Te.object({summary:Te.string(),riskLevel:Te.enum(["low","medium","high","critical"]),findings:Te.array(Te.object({severity:Te.enum(["info","warning","error","critical"]),category:Te.string(),message:Te.string(),recommendation:Te.string().optional()})),coveredPaths:Te.array(Te.string()),uncoveredPaths:Te.array(Te.string()),recommendedActions:Te.array(Te.object({kind:Te.enum(["run_command","edit_file","review","confirm","block","ignore"]),title:Te.string(),command:Te.string().optional(),target:Te.string().optional(),rationale:Te.string().optional()})).optional(),metadata:Te.object({tool:Te.string().optional(),command:Te.string().optional(),version:Te.string().optional(),generatedAt:Te.string().optional(),adapter:Te.string().optional(),model:Te.string().optional()}).optional()}),qre={"openapi-audit-request":Fre,"openapi-audit-result":Mre,"published-review-result":Lre,"overlay-proposal-result":zre,"guardrails-audit-result":Ure},Vre={openapiAuditRequest(e){return{type:"openapi-audit-request",version:1,payload:Fre.parse(e)}},openapiAuditResult(e){return{type:"openapi-audit-result",version:1,payload:Mre.parse(e)}},publishedReviewResult(e){return{type:"published-review-result",version:1,payload:Lre.parse(e)}},overlayProposalResult(e){return{type:"overlay-proposal-result",version:1,payload:zre.parse(e)}},guardrailsAuditResult(e){return{type:"guardrails-audit-result",version:1,payload:Ure.parse(e)}}}});var qTe,VTe,ZTe,GTe,Gre,Wre=Xe(()=>{"use strict";qTe={id:"openapi-audit",description:"Audit OpenAPI design quality and module boundary alignment",trigger:"cli-command",entry_conditions:["OpenAPI specification and config are available"],steps:[{type:"delegate",task:"audit-openapi-design",from_agent:"openapi-design-reviewer",description:"",optional:!1,max_retries:0}]},VTe={id:"published-review",description:"Review published API surface for internal leakage and compatibility",trigger:"cli-command",entry_conditions:["Both master and published specs are available"],steps:[{type:"delegate",task:"audit-published-api",from_agent:"openapi-design-reviewer",description:"",optional:!1,max_retries:0}]},ZTe={id:"overlay-proposal",description:"Propose cross-cutting overlay candidates",trigger:"cli-command",entry_conditions:["OpenAPI specification and existing overlays are available"],steps:[{type:"delegate",task:"propose-overlay-candidates",from_agent:"openapi-design-reviewer",description:"",optional:!1,max_retries:0}]},GTe={id:"guardrails-audit",description:"Audit guardrails configuration for drift and lint coverage",trigger:"cli-command",entry_conditions:["guardrails.yaml configuration exists"],steps:[{type:"delegate",task:"audit-guardrails-coverage",from_agent:"openapi-design-reviewer",description:"",optional:!1,max_retries:0}]},Gre={"openapi-audit":qTe,"published-review":VTe,"overlay-proposal":ZTe,"guardrails-audit":GTe}});var Kre={};Ln(Kre,{agentRegistry:()=>Tre,handoffSchemas:()=>qre,handoffs:()=>Vre,taskRegistry:()=>Rre,workflowRegistry:()=>Gre});var Hre=Xe(()=>{"use strict";Nre();Bre();Zre();Wre()});var qC=Hu(z1(),1);import Sr from"fs";import sn from"path";var eT=Hu(Qj(),1),{program:HRe,createCommand:JRe,createArgument:YRe,createOption:XRe,CommanderError:QRe,InvalidArgumentError:eBe,InvalidOptionArgumentError:tBe,Command:tT,Argument:rBe,Option:nBe,Help:iBe}=eT.default;var rT={low:0,medium:1,high:2,critical:3};function Qme(...e){let t="low";for(let r of e)rT[r]>rT[t]&&(t=r);return t}function U5(e,t,r){return e.schema?.type==="boolean"?t===!0:e.repeatable?r&&Array.isArray(t)&&t.length>0:r&&t!=null}function nT(e){let t=new Set,r=[],i=[],n=[],a=[],o,s;if(e.command_effects){let f=e.command_effects;if(a.push(f.risk_level??"low"),f.writes){t.add("file_write");for(let m of f.writes)i.push({kind:"semantic",target:m.target,description:m.description,overwrite:m.overwrite,destructive:m.destructive,...m.idempotent!==void 0?{idempotent:m.idempotent}:{},...m.idempotency_key?{idempotency_key:m.idempotency_key}:{},...m.idempotent_note?{idempotent_note:m.idempotent_note}:{},source:`command:${e.command_id}`})}if(f.reads)for(let m of f.reads)r.push({kind:"semantic",target:m.target,description:m.description,source:`command:${e.command_id}`});f.network&&(t.add("network"),typeof f.network=="object"&&n.push({...f.network.description?{description:f.network.description}:{},...f.network.domains?{domains:f.network.domains}:{},...f.network.idempotent!==void 0?{idempotent:f.network.idempotent}:{},...f.network.idempotency_key?{idempotency_key:f.network.idempotency_key}:{},...f.network.idempotent_note?{idempotent_note:f.network.idempotent_note}:{},source:`command:${e.command_id}`})),f.execution_mode&&(o=f.execution_mode),f.requires_confirmation!==void 0&&(s=f.requires_confirmation)}for(let[f,m]of Object.entries(e.options)){let{definition:h,value:g,specified:y}=m;if(U5(h,g,y)){if(h.file){let w=typeof g=="string"?g:void 0,S=h.file.mode;(S==="read"||S==="readWrite")&&r.push({kind:"option-file",option:f,path:w,source:`option:${f}`}),(S==="write"||S==="append"||S==="readWrite")&&(t.add("file_write"),i.push({kind:"option-file",option:f,path:w,mode:S,source:`option:${f}`}))}if(h.effects){let w=h.effects;if(a.push(w.risk_level??"low"),w.writes){t.add("file_write");for(let S of w.writes)i.push({kind:"semantic",target:S.target,description:S.description,overwrite:S.overwrite,destructive:S.destructive,...S.idempotent!==void 0?{idempotent:S.idempotent}:{},...S.idempotency_key?{idempotency_key:S.idempotency_key}:{},...S.idempotent_note?{idempotent_note:S.idempotent_note}:{},source:`option:${f}`})}if(w.reads)for(let S of w.reads)r.push({kind:"semantic",target:S.target,description:S.description,source:`option:${f}`});w.network&&(t.add("network"),typeof w.network=="object"&&n.push({...w.network.description?{description:w.network.description}:{},...w.network.domains?{domains:w.network.domains}:{},...w.network.idempotent!==void 0?{idempotent:w.network.idempotent}:{},...w.network.idempotency_key?{idempotency_key:w.network.idempotency_key}:{},...w.network.idempotent_note?{idempotent_note:w.network.idempotent_note}:{},source:`option:${f}`})),w.execution_mode&&!o&&(o=w.execution_mode),w.requires_confirmation!==void 0&&s===void 0&&(s=w.requires_confirmation)}}}let u=a.length>0?Qme(...a):"low",l=s??(u==="high"||u==="critical"),c;if(e.env){let f=[];for(let[m,h]of Object.entries(e.env))h.sensitive&&f.push(m);f.length>0&&(c=f)}let p=i.filter(f=>f.kind==="semantic").every(f=>f.idempotent===!0)&&n.every(f=>f.idempotent===!0);return{risk_level:u,requires_confirmation:l,idempotent:p,side_effects:[...t],reads:r,writes:i,...n.length>0?{network:n}:{},...o?{execution_mode:o}:{},...c?{requires_secrets:c}:{}}}var ehe={generate:{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"module",schema:{type:"string"}},{name:"contracts-only",schema:{type:"boolean",default:!1}},{name:"server-only",schema:{type:"boolean",default:!1}},{name:"frontend-only",schema:{type:"boolean",default:!1}},{name:"docs-only",schema:{type:"boolean",default:!1}},{name:"skip-lint",schema:{type:"boolean",default:!1}},{name:"manifest",schema:{type:"boolean",default:!0}},{name:"manifest-dir",schema:{type:"string",default:"packages/"}},{name:"force",schema:{type:"boolean",default:!1}},{name:"cache",schema:{type:"boolean",default:!0}}]},lint:{options:[{name:"strict",schema:{type:"boolean",default:!1}}]},init:{options:[{name:"dir",schema:{type:"string",default:"src"}},{name:"openapi",schema:{type:"string"},file:{mode:"read",exists:!0,media_type:"application/yaml",encoding:"utf-8"}},{name:"output",schema:{type:"string"}},{name:"skip-templates",schema:{type:"boolean",default:!1}},{name:"screens",schema:{type:"boolean",default:!1}}]},check:{options:[{name:"only",schema:{type:"string"}},{name:"skip",schema:{type:"string"}},{name:"gate",schema:{type:"string"}},{name:"verbose",schema:{type:"boolean",default:!1}},{name:"fix",schema:{type:"boolean",default:!1}},{name:"guardrails",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"generated-dir",schema:{type:"string",default:"packages/"}},{name:"changed-files",schema:{type:"string"},file:{mode:"read",exists:!0,media_type:"text/plain",encoding:"utf-8"}},{name:"list",schema:{type:"boolean",default:!1}},{name:"list-gates",schema:{type:"boolean",default:!1}}]},pipeline:{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"verbose",schema:{type:"boolean",default:!1}},{name:"skip",schema:{type:"string"}},{name:"continue-on-error",schema:{type:"boolean",default:!1}},{name:"guardrails",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"generated-dir",schema:{type:"string",default:"packages/"}},{name:"manifest",schema:{type:"boolean",default:!0}},{name:"skip-lint",schema:{type:"boolean",default:!1}},{name:"contracts-only",schema:{type:"boolean",default:!1}},{name:"server-only",schema:{type:"boolean",default:!1}},{name:"frontend-only",schema:{type:"boolean",default:!1}},{name:"docs-only",schema:{type:"boolean",default:!1}},{name:"force",schema:{type:"boolean",default:!1}},{name:"cache",schema:{type:"boolean",default:!0}}]},deps:{options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"module",schema:{type:"string"}},{name:"graph",schema:{type:"boolean",default:!1}},{name:"impact",schema:{type:"string"}},{name:"who-depends-on",schema:{type:"string"}},{name:"validate",schema:{type:"boolean",default:!1}}]},insights:{options:[{name:"format",schema:{type:"string",default:"json"}},{name:"project-root",schema:{type:"string",default:"."}},{name:"config",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}}]},"guardrails-init":{options:[{name:"output",schema:{type:"string",default:"guardrails.yaml"}}]},manifest:{options:[{name:"dir",schema:{type:"string",default:"packages/"}},{name:"verify",schema:{type:"boolean",default:!1}},{name:"output",schema:{type:"string"}}]},"audit-openapi":{effects:{reads:["openapi-specs","config"],writes:[],network:{description:"LLM API calls when adapter is not mock",requires_secrets:[],idempotent:!0}},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"module",schema:{type:"string"}},{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"fail-on",schema:{type:"string",enum:["warning","error","critical"],default:"error"}},{name:"output",schema:{type:"string"},file:{mode:"write",media_type:"application/json",encoding:"utf-8"}},{name:"report-format",schema:{type:"string",enum:["json","text","yaml"],default:"text"}},{name:"log-file",schema:{type:"string"}}]},"review-published":{effects:{reads:["openapi-specs","config","generated-packages"],writes:[],network:{description:"LLM API calls when adapter is not mock",requires_secrets:[],idempotent:!0}},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"module",schema:{type:"string"}},{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"fail-on",schema:{type:"string",enum:["warning","error","critical"],default:"error"}},{name:"output",schema:{type:"string"},file:{mode:"write",media_type:"application/json",encoding:"utf-8"}},{name:"report-format",schema:{type:"string",enum:["json","text","yaml"],default:"text"}},{name:"log-file",schema:{type:"string"}}]},"propose-overlays":{effects:{reads:["openapi-specs","config"],writes:[],network:{description:"LLM API calls when adapter is not mock",requires_secrets:[],idempotent:!0}},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"module",schema:{type:"string"}},{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"fail-on",schema:{type:"string",enum:["warning","error","critical"],default:"error"}},{name:"output",schema:{type:"string"},file:{mode:"write",media_type:"application/json",encoding:"utf-8"}},{name:"report-format",schema:{type:"string",enum:["json","text","yaml"],default:"json"}},{name:"log-file",schema:{type:"string"}}]},"audit-guardrails":{effects:{reads:["guardrails-config","config"],writes:[],network:{description:"LLM API calls when adapter is not mock",requires_secrets:[],idempotent:!0}},options:[{name:"config",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"guardrails",schema:{type:"string"},file:{mode:"read",exists:!1,media_type:"application/yaml",encoding:"utf-8"}},{name:"adapter",schema:{type:"string",enum:["claude","openai","gemini","mock"]}},{name:"model",schema:{type:"string"}},{name:"fail-on",schema:{type:"string",enum:["warning","error","critical"],default:"error"}},{name:"output",schema:{type:"string"},file:{mode:"write",media_type:"application/json",encoding:"utf-8"}},{name:"report-format",schema:{type:"string",enum:["json","text","yaml"],default:"text"}},{name:"log-file",schema:{type:"string"}}]}};function Oi(e,t){let r=ehe[e];if(!r)throw new Error(`Unknown command: ${e}`);let i=r,n={},a=[];for(let s of i.options??[]){let u=t[s.name],l=s.name in t&&u!==void 0;n[s.name]={value:u,specified:l,definition:s},U5(s,u,l)&&a.push(s.name)}let o=nT({command_id:e,command_effects:i.effects,options:n,env:i.env});return{command:e,active_options:a,policy:o}}var iT=`# yaml-language-server: $schema=./node_modules/cli-contracts/schemas/cli-contract.schema.json
891
891
  cli_contracts: 0.1.0
892
892
 
893
893
  info:
@@ -4939,11 +4939,11 @@ export function use{{screenName}}Events() {
4939
4939
 
4940
4940
  {{/if}}
4941
4941
  {{/each}}
4942
- `;function mB(){return{"fastify-routes.hbs":_ye,"fetch-client.hbs":bye,"service-stubs.hbs":wye,"overlay-adapter.hbs":Sye,"overlay-stubs.hbs":Eye}}function hB(){return{"screen-navigation.hbs":$ye,"screen-events.hbs":xye}}_v();var BF=(e=0)=>t=>`\x1B[${t+e}m`,FF=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,MF=(e=0)=>(t,r,i)=>`\x1B[${38+e};2;${t};${r};${i}m`,Wr={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]}},RLe=Object.keys(Wr.modifier),g6e=Object.keys(Wr.color),v6e=Object.keys(Wr.bgColor),BLe=[...g6e,...v6e];function y6e(){let e=new Map;for(let[t,r]of Object.entries(Wr)){for(let[i,n]of Object.entries(r))Wr[i]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},r[i]=Wr[i],e.set(n[0],n[1]);Object.defineProperty(Wr,t,{value:r,enumerable:!1})}return Object.defineProperty(Wr,"codes",{value:e,enumerable:!1}),Wr.color.close="\x1B[39m",Wr.bgColor.close="\x1B[49m",Wr.color.ansi=BF(),Wr.color.ansi256=FF(),Wr.color.ansi16m=MF(),Wr.bgColor.ansi=BF(10),Wr.bgColor.ansi256=FF(10),Wr.bgColor.ansi16m=MF(10),Object.defineProperties(Wr,{rgbToAnsi256:{value(t,r,i){return t===r&&r===i?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[i]=r;i.length===3&&(i=[...i].map(a=>a+a).join(""));let n=Number.parseInt(i,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:t=>Wr.rgbToAnsi256(...Wr.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,i,n;if(t>=232)r=((t-232)*10+8)/255,i=r,n=r;else{t-=16;let s=t%36;r=Math.floor(t/36)/5,i=Math.floor(s/6)/5,n=s%6/5}let a=Math.max(r,i,n)*2;if(a===0)return 30;let o=30+(Math.round(n)<<2|Math.round(i)<<1|Math.round(r));return a===2&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(t,r,i)=>Wr.ansi256ToAnsi(Wr.rgbToAnsi256(t,r,i)),enumerable:!1},hexToAnsi:{value:t=>Wr.ansi256ToAnsi(Wr.hexToAnsi256(t)),enumerable:!1}}),Wr}var _6e=y6e(),no=_6e;import Q9 from"node:process";import b6e from"node:os";import LF from"node:tty";function Ia(e,t=globalThis.Deno?globalThis.Deno.args:Q9.argv){let r=e.startsWith("-")?"":e.length===1?"-":"--",i=t.indexOf(r+e),n=t.indexOf("--");return i!==-1&&(n===-1||i<n)}var{env:Kr}=Q9,bv;Ia("no-color")||Ia("no-colors")||Ia("color=false")||Ia("color=never")?bv=0:(Ia("color")||Ia("colors")||Ia("color=true")||Ia("color=always"))&&(bv=1);function w6e(){if("FORCE_COLOR"in Kr)return Kr.FORCE_COLOR==="true"?1:Kr.FORCE_COLOR==="false"?0:Kr.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(Kr.FORCE_COLOR,10),3)}function S6e(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function E6e(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let i=w6e();i!==void 0&&(bv=i);let n=r?bv:i;if(n===0)return 0;if(r){if(Ia("color=16m")||Ia("color=full")||Ia("color=truecolor"))return 3;if(Ia("color=256"))return 2}if("TF_BUILD"in Kr&&"AGENT_NAME"in Kr)return 1;if(e&&!t&&n===void 0)return 0;let a=n||0;if(Kr.TERM==="dumb")return a;if(Q9.platform==="win32"){let o=b6e.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in Kr)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(o=>o in Kr)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(o=>o in Kr)||Kr.CI_NAME==="codeship"?1:a;if("TEAMCITY_VERSION"in Kr)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Kr.TEAMCITY_VERSION)?1:0;if(Kr.COLORTERM==="truecolor"||Kr.TERM==="xterm-kitty"||Kr.TERM==="xterm-ghostty"||Kr.TERM==="wezterm")return 3;if("TERM_PROGRAM"in Kr){let o=Number.parseInt((Kr.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Kr.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Kr.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Kr.TERM)||"COLORTERM"in Kr?1:a}function zF(e,t={}){let r=E6e(e,{streamIsTTY:e&&e.isTTY,...t});return S6e(r)}var $6e={stdout:zF({isTTY:LF.isatty(1)}),stderr:zF({isTTY:LF.isatty(2)})},UF=$6e;function qF(e,t,r){let i=e.indexOf(t);if(i===-1)return e;let n=t.length,a=0,o="";do o+=e.slice(a,i)+t+r,a=i+n,i=e.indexOf(t,a);while(i!==-1);return o+=e.slice(a),o}function VF(e,t,r,i){let n=0,a="";do{let o=e[i-1]==="\r";a+=e.slice(n,o?i-1:i)+t+(o?`\r
4942
+ `;function mB(){return{"fastify-routes.hbs":_ye,"fetch-client.hbs":bye,"service-stubs.hbs":wye,"overlay-adapter.hbs":Sye,"overlay-stubs.hbs":Eye}}function hB(){return{"screen-navigation.hbs":$ye,"screen-events.hbs":xye}}_v();var BF=(e=0)=>t=>`\x1B[${t+e}m`,FF=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,MF=(e=0)=>(t,r,i)=>`\x1B[${38+e};2;${t};${r};${i}m`,Wr={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]}},BLe=Object.keys(Wr.modifier),g6e=Object.keys(Wr.color),v6e=Object.keys(Wr.bgColor),FLe=[...g6e,...v6e];function y6e(){let e=new Map;for(let[t,r]of Object.entries(Wr)){for(let[i,n]of Object.entries(r))Wr[i]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},r[i]=Wr[i],e.set(n[0],n[1]);Object.defineProperty(Wr,t,{value:r,enumerable:!1})}return Object.defineProperty(Wr,"codes",{value:e,enumerable:!1}),Wr.color.close="\x1B[39m",Wr.bgColor.close="\x1B[49m",Wr.color.ansi=BF(),Wr.color.ansi256=FF(),Wr.color.ansi16m=MF(),Wr.bgColor.ansi=BF(10),Wr.bgColor.ansi256=FF(10),Wr.bgColor.ansi16m=MF(10),Object.defineProperties(Wr,{rgbToAnsi256:{value(t,r,i){return t===r&&r===i?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[i]=r;i.length===3&&(i=[...i].map(a=>a+a).join(""));let n=Number.parseInt(i,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:t=>Wr.rgbToAnsi256(...Wr.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,i,n;if(t>=232)r=((t-232)*10+8)/255,i=r,n=r;else{t-=16;let s=t%36;r=Math.floor(t/36)/5,i=Math.floor(s/6)/5,n=s%6/5}let a=Math.max(r,i,n)*2;if(a===0)return 30;let o=30+(Math.round(n)<<2|Math.round(i)<<1|Math.round(r));return a===2&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(t,r,i)=>Wr.ansi256ToAnsi(Wr.rgbToAnsi256(t,r,i)),enumerable:!1},hexToAnsi:{value:t=>Wr.ansi256ToAnsi(Wr.hexToAnsi256(t)),enumerable:!1}}),Wr}var _6e=y6e(),no=_6e;import Q9 from"node:process";import b6e from"node:os";import LF from"node:tty";function Ia(e,t=globalThis.Deno?globalThis.Deno.args:Q9.argv){let r=e.startsWith("-")?"":e.length===1?"-":"--",i=t.indexOf(r+e),n=t.indexOf("--");return i!==-1&&(n===-1||i<n)}var{env:Kr}=Q9,bv;Ia("no-color")||Ia("no-colors")||Ia("color=false")||Ia("color=never")?bv=0:(Ia("color")||Ia("colors")||Ia("color=true")||Ia("color=always"))&&(bv=1);function w6e(){if("FORCE_COLOR"in Kr)return Kr.FORCE_COLOR==="true"?1:Kr.FORCE_COLOR==="false"?0:Kr.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(Kr.FORCE_COLOR,10),3)}function S6e(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function E6e(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let i=w6e();i!==void 0&&(bv=i);let n=r?bv:i;if(n===0)return 0;if(r){if(Ia("color=16m")||Ia("color=full")||Ia("color=truecolor"))return 3;if(Ia("color=256"))return 2}if("TF_BUILD"in Kr&&"AGENT_NAME"in Kr)return 1;if(e&&!t&&n===void 0)return 0;let a=n||0;if(Kr.TERM==="dumb")return a;if(Q9.platform==="win32"){let o=b6e.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in Kr)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(o=>o in Kr)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(o=>o in Kr)||Kr.CI_NAME==="codeship"?1:a;if("TEAMCITY_VERSION"in Kr)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Kr.TEAMCITY_VERSION)?1:0;if(Kr.COLORTERM==="truecolor"||Kr.TERM==="xterm-kitty"||Kr.TERM==="xterm-ghostty"||Kr.TERM==="wezterm")return 3;if("TERM_PROGRAM"in Kr){let o=Number.parseInt((Kr.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Kr.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Kr.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Kr.TERM)||"COLORTERM"in Kr?1:a}function zF(e,t={}){let r=E6e(e,{streamIsTTY:e&&e.isTTY,...t});return S6e(r)}var $6e={stdout:zF({isTTY:LF.isatty(1)}),stderr:zF({isTTY:LF.isatty(2)})},UF=$6e;function qF(e,t,r){let i=e.indexOf(t);if(i===-1)return e;let n=t.length,a=0,o="";do o+=e.slice(a,i)+t+r,a=i+n,i=e.indexOf(t,a);while(i!==-1);return o+=e.slice(a),o}function VF(e,t,r,i){let n=0,a="";do{let o=e[i-1]==="\r";a+=e.slice(n,o?i-1:i)+t+(o?`\r
4943
4943
  `:`
4944
4944
  `)+r,n=i+1,i=e.indexOf(`
4945
4945
  `,n)}while(i!==-1);return a+=e.slice(n),a}var{stdout:ZF,stderr:GF}=UF,e8=Symbol("GENERATOR"),Qc=Symbol("STYLER"),Yf=Symbol("IS_EMPTY"),WF=["ansi","ansi","ansi256","ansi16m"],ed=Object.create(null),x6e=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let r=ZF?ZF.level:0;e.level=t.level===void 0?r:t.level};var k6e=e=>{let t=(...r)=>r.join(" ");return x6e(t,e),Object.setPrototypeOf(t,Xf.prototype),t};function Xf(e){return k6e(e)}Object.setPrototypeOf(Xf.prototype,Function.prototype);for(let[e,t]of Object.entries(no))ed[e]={get(){let r=wv(this,r8(t.open,t.close,this[Qc]),this[Yf]);return Object.defineProperty(this,e,{value:r}),r}};ed.visible={get(){let e=wv(this,this[Qc],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var t8=(e,t,r,...i)=>e==="rgb"?t==="ansi16m"?no[r].ansi16m(...i):t==="ansi256"?no[r].ansi256(no.rgbToAnsi256(...i)):no[r].ansi(no.rgbToAnsi(...i)):e==="hex"?t8("rgb",t,r,...no.hexToRgb(...i)):no[r][e](...i),A6e=["rgb","hex","ansi256"];for(let e of A6e){ed[e]={get(){let{level:r}=this;return function(...i){let n=r8(t8(e,WF[r],"color",...i),no.color.close,this[Qc]);return wv(this,n,this[Yf])}}};let t="bg"+e[0].toUpperCase()+e.slice(1);ed[t]={get(){let{level:r}=this;return function(...i){let n=r8(t8(e,WF[r],"bgColor",...i),no.bgColor.close,this[Qc]);return wv(this,n,this[Yf])}}}}var C6e=Object.defineProperties(()=>{},{...ed,level:{enumerable:!0,get(){return this[e8].level},set(e){this[e8].level=e}}}),r8=(e,t,r)=>{let i,n;return r===void 0?(i=e,n=t):(i=r.openAll+e,n=t+r.closeAll),{open:e,close:t,openAll:i,closeAll:n,parent:r}},wv=(e,t,r)=>{let i=(...n)=>D6e(i,n.length===1?""+n[0]:n.join(" "));return Object.setPrototypeOf(i,C6e),i[e8]=e,i[Qc]=t,i[Yf]=r,i},D6e=(e,t)=>{if(e.level<=0||!t)return e[Yf]?"":t;let r=e[Qc];if(r===void 0)return t;let{openAll:i,closeAll:n}=r;if(t.includes("\x1B"))for(;r!==void 0;)t=qF(t,r.close,r.open),r=r.parent;let a=t.indexOf(`
4946
- `);return a!==-1&&(t=VF(t,n,i,a)),i+t+n};Object.defineProperties(Xf.prototype,ed);var O6e=Xf(),WLe=Xf({level:GF?GF.level:0});var du=O6e;import In from"fs";import ri from"path";Ii();_v();function KF(){let e=["micro-contracts.config.yaml","micro-contracts.config.yml","api-framework.config.yaml","api-framework.config.yml"];for(let t of e){let r=ri.resolve(t);if(In.existsSync(r))return r}return null}function n8(e,t){let r=e?ri.resolve(e):KF();if(!r||!In.existsSync(r))throw Object.assign(new Error(`Config file not found: ${r??"micro-contracts.config.yaml"}`),{exitCode:3});let i=as(r);if(!bo(i))throw Object.assign(new Error("Config must be a multi-module config with modules defined."),{exitCode:3});let n=[];for(let[a,o]of Object.entries(i.modules)){if(t&&a!==t)continue;let s=ri.resolve(ri.dirname(r),o.openapi);if(!In.existsSync(s))continue;let u=is(s);n.push({name:a,spec:u,specPath:s})}return{config:i,configPath:r,modules:n}}function i8(e,t){let r=In.readFileSync(t,"utf-8"),i=24e3;return r.length>i?r.slice(0,i)+`
4946
+ `);return a!==-1&&(t=VF(t,n,i,a)),i+t+n};Object.defineProperties(Xf.prototype,ed);var O6e=Xf(),KLe=Xf({level:GF?GF.level:0});var du=O6e;import In from"fs";import ri from"path";Ii();_v();function KF(){let e=["micro-contracts.config.yaml","micro-contracts.config.yml","api-framework.config.yaml","api-framework.config.yml"];for(let t of e){let r=ri.resolve(t);if(In.existsSync(r))return r}return null}function n8(e,t){let r=e?ri.resolve(e):KF();if(!r||!In.existsSync(r))throw Object.assign(new Error(`Config file not found: ${r??"micro-contracts.config.yaml"}`),{exitCode:3});let i=as(r);if(!bo(i))throw Object.assign(new Error("Config must be a multi-module config with modules defined."),{exitCode:3});let n=[];for(let[a,o]of Object.entries(i.modules)){if(t&&a!==t)continue;let s=ri.resolve(ri.dirname(r),o.openapi);if(!In.existsSync(s))continue;let u=is(s);n.push({name:a,spec:u,specPath:s})}return{config:i,configPath:r,modules:n}}function i8(e,t){let r=In.readFileSync(t,"utf-8"),i=24e3;return r.length>i?r.slice(0,i)+`
4947
4947
  # (truncated)`:r}function HF(e,t){let r=[],i=ri.dirname(t),n=e.defaults?.overlays?.shared??[];for(let a of n){let o=ri.resolve(i,a);In.existsSync(o)&&r.push(`### ${a}
4948
4948
 
4949
4949
  \`\`\`yaml
@@ -5042,15 +5042,15 @@ ${YTe(e,(t+1)*2)}`:JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean")
5042
5042
  ${o}`:Array.isArray(a)&&a.length>0?`${r}${n}:
5043
5043
  ${o}`:`${r}${n}: ${o}`}).join(`
5044
5044
  `)}return String(e)}async function Qre(e){let t=await YF(e.config,e.module);if(e.showPrompt)return t;let r={adapter:e.adapter,model:e.model},i={failOn:e.failOn,logFile:e.logFile};try{let n=await Es(t,"audit-openapi-design",r,i),a=xs(n,e.reportFormat??"text");await ks(a,e.output);let o=$s(n,i);o!==0&&process.exit(o)}catch(n){let a=n.exitCode;throw(a===Ro||a===Bo)&&(console.error(du.red(n.message)),process.exit(a)),n}}async function ene(e){let t=await XF(e.config,e.module);if(e.showPrompt)return t;let r={adapter:e.adapter,model:e.model},i={failOn:e.failOn,logFile:e.logFile};try{let n=await Es(t,"audit-published-api",r,i),a=xs(n,e.reportFormat??"text");await ks(a,e.output);let o=$s(n,i);o!==0&&process.exit(o)}catch(n){let a=n.exitCode;throw(a===Ro||a===Bo)&&(console.error(du.red(n.message)),process.exit(a)),n}}async function tne(e){let t=await QF(e.config,e.module);if(e.showPrompt)return t;let r={adapter:e.adapter,model:e.model},i={failOn:e.failOn,logFile:e.logFile};try{let n=await Es(t,"propose-overlay-candidates",r,i),a=xs(n,e.reportFormat??"json");await ks(a,e.output);let o=$s(n,i);o!==0&&process.exit(o)}catch(n){let a=n.exitCode;throw(a===Ro||a===Bo)&&(console.error(du.red(n.message)),process.exit(a)),n}}async function rne(e){let t=await eM(e.config,e.guardrails);if(e.showPrompt)return t;let r={adapter:e.adapter,model:e.model},i={failOn:e.failOn,logFile:e.logFile};try{let n=await Es(t,"audit-guardrails-coverage",r,i),a=xs(n,e.reportFormat??"text");await ks(a,e.output);let o=$s(n,i);o!==0&&process.exit(o)}catch(n){let a=n.exitCode;throw(a===Ro||a===Bo)&&(console.error(du.red(n.message)),process.exit(a)),n}}import MC from"fs";import As from"path";import{createRequire as XTe}from"module";Ii();Ii();var QTe=XTe(import.meta.url),eNe=QTe("../../package.json"),une="micro-contracts",tNe="api_contract_declaration",nne=.9;function rNe(e){let t=["micro-contracts.config.yaml","micro-contracts.config.yml","api-framework.config.yaml","api-framework.config.yml"];for(let r of t){let i=As.join(e,r);if(MC.existsSync(i))return i}return null}function ine(e,t){let r=As.relative(e,t);return r.startsWith("..")?t:r.split(As.sep).join("/")}function FC(e){return e.raw}function B6(e,t,r){return`${e}/services/${t}ServiceApi.ts#${r}`}function nNe(e,t){let r=e.split(`
5045
- `);for(let i=0;i<r.length;i++)if(r[i].includes(t))return i+1}function ane(e,t,r,i,n){let a=i?nNe(r,i):void 0;return{kind:tNe,detail:e,filePath:t,...a!==void 0?{line:a}:{},...n!==void 0?{symbolId:n}:{}}}function iNe(e){let t=new Map,r=["get","post","put","patch","delete"];for(let i of Object.values(e.paths))for(let n of r){let a=i[n];if(!a?.operationId)continue;let o=a["x-micro-contracts-service"],s=a["x-micro-contracts-method"];typeof o=="string"&&typeof s=="string"&&t.set(a.operationId,{service:o,method:s})}return t}function one(e,t,r){return`${e}.${t}.${r}`}function sne(e,t,r){return`${e}\0${t}\0${r}`}function aNe(e,t){return{symbolId:B6(e,t.service,t.method),filePath:`${e}/services/${t.service}ServiceApi.ts`,startLine:1,endLine:1}}function zC(e,t={}){let r=As.resolve(e),i=t.configPath?As.resolve(t.configPath):rNe(r);if(!i)throw new Error("micro-contracts.config.yaml not found. Run from project root or pass --config.");let n=as(i);if(!bo(n))throw new Error("Insight provider requires multi-module config with modules.");let a=As.dirname(i),o=n.defaults??{},s=[],u=new Map;for(let[h,g]of Object.entries(n.modules)){let y=xc(h,g,o),_=As.resolve(a,y.openapi);if(!MC.existsSync(_))continue;let w=is(_),S=ine(r,_),C=ine(r,As.resolve(r,y.contractOutput));u.set(h,C),s.push({name:h,openapiRel:S,resolved:y,spec:w})}let l=[],c=new Set,d=new Map,p=h=>{d.has(h.name)||d.set(h.name,{domainId:h.name,filePaths:[h.openapiRel,h.resolved.contractOutput]})},f=h=>{let g=FC(h);if(d.has(g))return;let y=u.get(h.module);if(!y)return;let _=s.find(S=>S.name===h.module),w=_?[_.openapiRel,y]:[y];d.set(g,{domainId:g,filePaths:w,symbolIds:[B6(y,h.service,h.method)],symbols:[aNe(y,h)]})},m=(h,g,y,_,w)=>{let S=one(h,g,y);if(d.has(S))return;let C=B6(_,g,y);d.set(S,{domainId:S,filePaths:[w,_],symbolIds:[C],symbols:[{symbolId:C,filePath:`${_}/services/${g}ServiceApi.ts`,startLine:1,endLine:1}]})};for(let h of s){p(h);let g=MC.readFileSync(As.resolve(r,h.openapiRel),"utf-8"),y=uf(h.spec),_=u.get(h.name),w=iNe(h.spec);for(let S of y.moduleLevelDeps){let C=h.name,D=FC(S),E="api_dependency",A=sne(C,D,E);c.has(A)||(c.add(A),f(S),l.push({from:C,to:D,kind:E,propagation:"forward",weight:nne,evidence:[ane(`module declares dependency on ${S.raw}`,h.openapiRel,g,S.raw)]}))}for(let[S,C]of y.operationLevelDeps){let D=w.get(S);if(!D)continue;let E=one(h.name,D.service,D.method);m(h.name,D.service,D.method,_,h.openapiRel);for(let A of C){let P=FC(A),O="api_operation_dependency",$=sne(E,P,O);if(c.has($))continue;c.add($),f(A);let x=B6(_,D.service,D.method);l.push({from:E,to:P,kind:O,propagation:"forward",weight:nne,evidence:[ane(`operation ${E} declares dependency on ${A.raw}`,h.openapiRel,g,A.raw,x)]})}}}return{source:une,sourceVersion:eNe.version,generatedAt:new Date().toISOString(),edges:l,anchorMapping:[...d.values()]}}var LC=class{name=une;async provide(t){return zC(t.projectRoot)}},xWe=new LC;async function lne(e){let t=e.format??"json";if(t!=="json")throw new Error(`Unsupported --format: ${t}. Only "json" is supported.`);let r=e.projectRoot??process.cwd(),i=zC(r,{configPath:e.config});process.stdout.write(`${JSON.stringify(i)}
5046
- `)}var sp={version:"0.17.7"};function UC(){let e=["micro-contracts.config.yaml","micro-contracts.config.yml","api-framework.config.yaml","api-framework.config.yml"];for(let t of e){let r=sn.resolve(t);if(Sr.existsSync(r))return r}return null}var oNe={generate:async e=>{try{let t,r=e.config?sn.resolve(e.config):UC();r||(console.error("Error: No config file found."),console.error("Create micro-contracts.config.yaml or use --config <path>"),process.exit(1)),Sr.existsSync(r)||(console.error(`Config file not found: ${r}`),process.exit(1)),console.log(`Using config: ${r}`),t=as(r);let i=e.cache!==!1&&!e.force,n;if(bo(t)&&(n=Fg(t,r,sp.version),i)){let a=e.manifestDir||"packages/",o=await Gf(a,n);if(o.skip){console.log(`No input changes detected, skipping generation (${o.reason})`);return}}if(await u9(t,{contractsOnly:e.contractsOnly,serverOnly:e.serverOnly,frontendOnly:e.frontendOnly,docsOnly:e.docsOnly,skipLint:e.skipLint,modules:e.module}),e.manifest!==!1){let{config:a}=Ni();if(a?.generated&&a.generated.length>0){let o=e.manifestDir||"packages/";if(Sr.existsSync(o)){let s=e.cache!==!1?n:void 0,{manifest:u,changed:l}=await Hc(o,{generatorVersion:sp.version,inputHash:s}),c=Object.keys(u.files).length;if(l){let d=gl(u,o);console.log(`
5045
+ `);for(let i=0;i<r.length;i++)if(r[i].includes(t))return i+1}function ane(e,t,r,i,n){let a=i?nNe(r,i):void 0;return{kind:tNe,detail:e,filePath:t,...a!==void 0?{line:a}:{},...n!==void 0?{symbolId:n}:{}}}function iNe(e){let t=new Map,r=["get","post","put","patch","delete"];for(let i of Object.values(e.paths))for(let n of r){let a=i[n];if(!a?.operationId)continue;let o=a["x-micro-contracts-service"],s=a["x-micro-contracts-method"];typeof o=="string"&&typeof s=="string"&&t.set(a.operationId,{service:o,method:s})}return t}function one(e,t,r){return`${e}.${t}.${r}`}function sne(e,t,r){return`${e}\0${t}\0${r}`}function aNe(e,t){return{symbolId:B6(e,t.service,t.method),filePath:`${e}/services/${t.service}ServiceApi.ts`,startLine:1,endLine:1}}function zC(e,t={}){let r=As.resolve(e),i=t.configPath?As.resolve(t.configPath):rNe(r);if(!i)throw new Error("micro-contracts.config.yaml not found. Run from project root or pass --config.");let n=as(i);if(!bo(n))throw new Error("Insight provider requires multi-module config with modules.");let a=As.dirname(i),o=n.defaults??{},s=[],u=new Map;for(let[h,g]of Object.entries(n.modules)){let y=xc(h,g,o),_=As.resolve(a,y.openapi);if(!MC.existsSync(_))continue;let w=is(_),S=ine(r,_),C=ine(r,As.resolve(r,y.contractOutput));u.set(h,C),s.push({name:h,openapiRel:S,resolved:y,spec:w})}let l=[],c=new Set,d=new Map,p=h=>{d.has(h.name)||d.set(h.name,{domainId:h.name,filePaths:[h.openapiRel,h.resolved.contractOutput]})},f=h=>{let g=FC(h);if(d.has(g))return;let y=u.get(h.module);if(!y)return;let _=s.find(S=>S.name===h.module),w=_?[_.openapiRel,y]:[y];d.set(g,{domainId:g,filePaths:w,symbolIds:[B6(y,h.service,h.method)],symbols:[aNe(y,h)]})},m=(h,g,y,_,w)=>{let S=one(h,g,y);if(d.has(S))return;let C=B6(_,g,y);d.set(S,{domainId:S,filePaths:[w,_],symbolIds:[C],symbols:[{symbolId:C,filePath:`${_}/services/${g}ServiceApi.ts`,startLine:1,endLine:1}]})};for(let h of s){p(h);let g=MC.readFileSync(As.resolve(r,h.openapiRel),"utf-8"),y=uf(h.spec),_=u.get(h.name),w=iNe(h.spec);for(let S of y.moduleLevelDeps){let C=h.name,D=FC(S),E="api_dependency",A=sne(C,D,E);c.has(A)||(c.add(A),f(S),l.push({from:C,to:D,kind:E,propagation:"forward",weight:nne,evidence:[ane(`module declares dependency on ${S.raw}`,h.openapiRel,g,S.raw)]}))}for(let[S,C]of y.operationLevelDeps){let D=w.get(S);if(!D)continue;let E=one(h.name,D.service,D.method);m(h.name,D.service,D.method,_,h.openapiRel);for(let A of C){let P=FC(A),O="api_operation_dependency",$=sne(E,P,O);if(c.has($))continue;c.add($),f(A);let x=B6(_,D.service,D.method);l.push({from:E,to:P,kind:O,propagation:"forward",weight:nne,evidence:[ane(`operation ${E} declares dependency on ${A.raw}`,h.openapiRel,g,A.raw,x)]})}}}return{source:une,sourceVersion:eNe.version,generatedAt:new Date().toISOString(),edges:l,anchorMapping:[...d.values()]}}function oNe(e,t){let{changedFiles:r,artifactIds:i}=t;if(!r?.length&&!i?.length)return e;let n=new Set;if(r?.length){let u=new Set(r);for(let l of e.anchorMapping??[])l.filePaths.some(c=>u.has(c))&&n.add(l.domainId)}if(i?.length)for(let u of i)n.add(u);let a=e.edges.filter(u=>n.has(u.from)||n.has(u.to)),o=new Set;for(let u of a)o.add(u.from),o.add(u.to);let s=(e.anchorMapping??[]).filter(u=>o.has(u.domainId));return{...e,edges:a,anchorMapping:s.length>0?s:void 0}}var LC=class{name=une;async provide(t){let r=zC(t.projectRoot);return oNe(r,t)}},kWe=new LC;async function lne(e){let t=e.format??"json";if(t!=="json")throw new Error(`Unsupported --format: ${t}. Only "json" is supported.`);let r=e.projectRoot??process.cwd(),i=zC(r,{configPath:e.config});process.stdout.write(`${JSON.stringify(i)}
5046
+ `)}var sp={version:"0.17.8"};function UC(){let e=["micro-contracts.config.yaml","micro-contracts.config.yml","api-framework.config.yaml","api-framework.config.yml"];for(let t of e){let r=sn.resolve(t);if(Sr.existsSync(r))return r}return null}var sNe={generate:async e=>{try{let t,r=e.config?sn.resolve(e.config):UC();r||(console.error("Error: No config file found."),console.error("Create micro-contracts.config.yaml or use --config <path>"),process.exit(1)),Sr.existsSync(r)||(console.error(`Config file not found: ${r}`),process.exit(1)),console.log(`Using config: ${r}`),t=as(r);let i=e.cache!==!1&&!e.force,n;if(bo(t)&&(n=Fg(t,r,sp.version),i)){let a=e.manifestDir||"packages/",o=await Gf(a,n);if(o.skip){console.log(`No input changes detected, skipping generation (${o.reason})`);return}}if(await u9(t,{contractsOnly:e.contractsOnly,serverOnly:e.serverOnly,frontendOnly:e.frontendOnly,docsOnly:e.docsOnly,skipLint:e.skipLint,modules:e.module}),e.manifest!==!1){let{config:a}=Ni();if(a?.generated&&a.generated.length>0){let o=e.manifestDir||"packages/";if(Sr.existsSync(o)){let s=e.cache!==!1?n:void 0,{manifest:u,changed:l}=await Hc(o,{generatorVersion:sp.version,inputHash:s}),c=Object.keys(u.files).length;if(l){let d=gl(u,o);console.log(`
5047
5047
  Manifest updated: ${d} (${c} files)`)}else console.log(`
5048
5048
  Manifest unchanged (${c} files)`)}}}}catch(t){console.error("Generation failed:",t instanceof Error?t.message:t),process.exit(1)}},lint:async e=>{try{let t=sn.resolve(e);Sr.existsSync(t)||(console.error(`OpenAPI spec not found: ${t}`),process.exit(1)),console.log(`Linting: ${t}
5049
5049
  `);let r=is(t),i=rs(r,{strict:!1});console.log(dl(i)),i.valid||process.exit(1)}catch(t){console.error("Lint failed:",t instanceof Error?t.message:t),process.exit(1)}},init:async(e,t)=>{console.log(`Initializing module "${e}"${t.screens?" (screen spec)":""}...
5050
- `);let r=["spec","spec/default/templates","spec/_shared/openapi","spec/_shared/overlays",`spec/${e}/openapi`];for(let l of r)Sr.existsSync(l)||(Sr.mkdirSync(l,{recursive:!0}),console.log(`Created: ${l}/`));if(!t.skipTemplates){let l=mB();for(let[c,d]of Object.entries(l)){let p=sn.join("spec/default/templates",c);Sr.existsSync(p)||(Sr.writeFileSync(p,d),console.log(`Created: ${p}`))}if(t.screens){let c=hB();for(let[d,p]of Object.entries(c)){let f=sn.join("spec/default/templates",d);Sr.existsSync(f)||(Sr.writeFileSync(f,p),console.log(`Created: ${f}`))}}}let i="spec/_shared/openapi/problem-details.yaml";Sr.existsSync(i)||(Sr.writeFileSync(i,mNe()),console.log(`Created: ${i}`));let n="spec/spectral.yaml";if(Sr.existsSync(n)||(Sr.writeFileSync(n,hNe()),console.log(`Created: ${n}`)),t.screens){let l=`spec/${e}/openapi`;Sr.mkdirSync(l,{recursive:!0});let c=sn.join(l,`${e}.yaml`);Sr.existsSync(c)||(Sr.writeFileSync(c,gNe(e)),console.log(`Created: ${c}`))}let a=sn.resolve(t.dir??"src",e),o=[a,sn.join(a,"services"),sn.join(a,"models")];for(let l of o)Sr.existsSync(l)||(Sr.mkdirSync(l,{recursive:!0}),console.log(`Created: ${l}/`));let s=[[sn.join(a,"db.ts"),cNe()],[sn.join(a,"container.ts"),dNe(e)],[sn.join(a,"services","index.ts"),`// Export service classes
5050
+ `);let r=["spec","spec/default/templates","spec/_shared/openapi","spec/_shared/overlays",`spec/${e}/openapi`];for(let l of r)Sr.existsSync(l)||(Sr.mkdirSync(l,{recursive:!0}),console.log(`Created: ${l}/`));if(!t.skipTemplates){let l=mB();for(let[c,d]of Object.entries(l)){let p=sn.join("spec/default/templates",c);Sr.existsSync(p)||(Sr.writeFileSync(p,d),console.log(`Created: ${p}`))}if(t.screens){let c=hB();for(let[d,p]of Object.entries(c)){let f=sn.join("spec/default/templates",d);Sr.existsSync(f)||(Sr.writeFileSync(f,p),console.log(`Created: ${f}`))}}}let i="spec/_shared/openapi/problem-details.yaml";Sr.existsSync(i)||(Sr.writeFileSync(i,hNe()),console.log(`Created: ${i}`));let n="spec/spectral.yaml";if(Sr.existsSync(n)||(Sr.writeFileSync(n,gNe()),console.log(`Created: ${n}`)),t.screens){let l=`spec/${e}/openapi`;Sr.mkdirSync(l,{recursive:!0});let c=sn.join(l,`${e}.yaml`);Sr.existsSync(c)||(Sr.writeFileSync(c,vNe(e)),console.log(`Created: ${c}`))}let a=sn.resolve(t.dir??"src",e),o=[a,sn.join(a,"services"),sn.join(a,"models")];for(let l of o)Sr.existsSync(l)||(Sr.mkdirSync(l,{recursive:!0}),console.log(`Created: ${l}/`));let s=[[sn.join(a,"db.ts"),dNe()],[sn.join(a,"container.ts"),pNe(e)],[sn.join(a,"services","index.ts"),`// Export service classes
5051
5051
  `],[sn.join(a,"models","index.ts"),`// Export models
5052
- `]];for(let[l,c]of s)Sr.existsSync(l)||(Sr.writeFileSync(l,c),console.log(`Created: ${l}`));let u=sn.resolve("micro-contracts.config.yaml");if(!Sr.existsSync(u)){let l=t.screens?fNe(e):pNe(e);Sr.writeFileSync(u,l),console.log(`Created: ${u}`)}if(t.openapi){let l=sn.resolve(t.openapi);Sr.existsSync(l)||(console.error(`OpenAPI file not found: ${l}`),process.exit(1));let c=t.output?sn.resolve(t.output):sn.resolve(`spec/${e}/openapi/${e}.yaml`);Sr.mkdirSync(sn.dirname(c),{recursive:!0}),console.log(`
5053
- Processing OpenAPI: ${l}`);let d=sNe(l);Sr.writeFileSync(c,d.yaml),console.log(`Created: ${c}`),console.log(` - Added x-micro-contracts-service to ${d.stats.servicesAdded} operations`),console.log(` - Added x-micro-contracts-method to ${d.stats.methodsAdded} operations`),d.stats.services.length>0&&console.log(` - Detected services: ${d.stats.services.join(", ")}`)}console.log(`
5052
+ `]];for(let[l,c]of s)Sr.existsSync(l)||(Sr.writeFileSync(l,c),console.log(`Created: ${l}`));let u=sn.resolve("micro-contracts.config.yaml");if(!Sr.existsSync(u)){let l=t.screens?mNe(e):fNe(e);Sr.writeFileSync(u,l),console.log(`Created: ${u}`)}if(t.openapi){let l=sn.resolve(t.openapi);Sr.existsSync(l)||(console.error(`OpenAPI file not found: ${l}`),process.exit(1));let c=t.output?sn.resolve(t.output):sn.resolve(`spec/${e}/openapi/${e}.yaml`);Sr.mkdirSync(sn.dirname(c),{recursive:!0}),console.log(`
5053
+ Processing OpenAPI: ${l}`);let d=uNe(l);Sr.writeFileSync(c,d.yaml),console.log(`Created: ${c}`),console.log(` - Added x-micro-contracts-service to ${d.stats.servicesAdded} operations`),console.log(` - Added x-micro-contracts-method to ${d.stats.methodsAdded} operations`),d.stats.services.length>0&&console.log(` - Detected services: ${d.stats.services.join(", ")}`)}console.log(`
5054
5054
  Module "${e}" initialized!`),t.screens?(console.log(`
5055
5055
  Next steps:`),console.log(` 1. Edit spec/${e}/openapi/${e}.yaml with your screen definitions`),console.log(" 2. Define ViewModels in components/schemas"),console.log(" 3. Add navigation links and x-events"),console.log(" 4. Run: npx micro-contracts generate")):t.openapi?(console.log(`
5056
5056
  Next steps:`),console.log(` 1. Review the generated extensions in spec/${e}/openapi/${e}.yaml`),console.log(" 2. Run: npx micro-contracts generate")):(console.log(`
@@ -5061,8 +5061,8 @@ Available gates:
5061
5061
  Usage: micro-contracts check --gate 1,2,3`),console.log("");return}if(e.list){console.log(`
5062
5062
  Available checks:
5063
5063
  `);for(let a of vv({guardrailsPath:e.guardrails})){let o=a.gate!==void 0?`[G${a.gate}]`:" ";console.log(` ${o} ${a.name.padEnd(20)} - ${a.description}`)}console.log("");return}let t;e.gate&&(t=e.gate.split(",").map(a=>{let o=parseInt(a.trim(),10);if(o<1||o>5||isNaN(o))throw new Error(`Invalid gate number: ${a}. Must be 1-5.`);return o})),console.log(""),console.log("\u{1F50D} AI Guardrail Check Results"),console.log("\u2550".repeat(50)),console.log("");let r=process.stdout.isTTY!==!1,i={only:e.only?.split(",").map(a=>a.trim()),skip:e.skip?.split(",").map(a=>a.trim()),gates:t,verbose:e.verbose,fix:e.fix,guardrailsPath:e.guardrails,generatedDir:e.generatedDir,changedFilesPath:e.changedFiles,onCheckStart:r?a=>{process.stdout.isTTY&&process.stdout.write(Jf(a)+"\r")}:void 0,onCheckComplete:r?(a,o)=>{process.stdout.isTTY&&(process.stdout.clearLine?.(0),process.stdout.cursorTo?.(0)),console.log(Hf(a,o,e.verbose))}:void 0},n=await Yc(i);console.log(r?Xc(n,n.checks):yv(n,e.verbose,n.checks)),n.failed>0&&process.exit(1)}catch(t){console.error("Check failed:",t instanceof Error?t.message:t),process.exit(1)}},pipeline:async e=>{try{let t=Date.now(),r=e.verbose,i=!1,n=!1,a=0,o=!1,s=null,u=[];console.log(""),console.log("\u{1F680} Running AI Guardrails Pipeline"),console.log("\u2550".repeat(50)),console.log("");let l=e.skip?.split(",").map(C=>C.trim())||[],c=process.stdout.isTTY!==!1,d={verbose:r,skip:l,guardrailsPath:e.guardrails,generatedDir:e.generatedDir,onCheckStart:c?C=>{process.stdout.isTTY&&process.stdout.write(Jf(C)+"\r")}:void 0,onCheckComplete:c?(C,D)=>{process.stdout.isTTY&&(process.stdout.clearLine?.(0),process.stdout.cursorTo?.(0)),console.log(Hf(C,D,r))}:void 0};r&&(console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 Step 1: Pre-generation checks (Gate 1, 2) \u2502"),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log(""));let p=await Yc({...d,gates:[1,2]});u.push(...p.results),r&&console.log(Xc(p,p.checks)),p.failed>0&&(i=!0,e.continueOnError||(console.log(""),console.log("\u274C Gate 1,2 failed. Stopping pipeline."),console.log(" Use --continue-on-error to continue despite failures."),process.exit(1)),r&&console.log(`\u26A0\uFE0F Gate 1,2 had failures. Continuing due to --continue-on-error.
5064
- `));let f=!1;r&&(console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 Step 2: Generate contracts \u2502"),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log(""));let m=Date.now();c&&process.stdout.isTTY&&process.stdout.write(" \u22EF Generate running...\r");try{let C=e.config?sn.resolve(e.config):UC();if(!C)o=!0,a=Date.now()-m,c&&process.stdout.isTTY&&(process.stdout.clearLine?.(0),process.stdout.cursorTo?.(0)),console.log(" \u25CB Generate SKIP (no config file)");else{r&&console.log(` Using config: ${C}`);let D=as(C),E=e.cache!==!1&&!e.force,A;if(bo(D)&&(A=Fg(D,C,sp.version),E)){let P=e.generatedDir||"packages/",O=await Gf(P,A);O.skip&&(f=!0,o=!0,a=Date.now()-m,c&&process.stdout.isTTY&&(process.stdout.clearLine?.(0),process.stdout.cursorTo?.(0)),console.log(` \u25CB Generate SKIP (${O.reason})`))}if(!f){let P=console.log;r||(console.log=()=>{});try{if(await u9(D,{skipLint:e.skipLint,contractsOnly:e.contractsOnly,serverOnly:e.serverOnly,frontendOnly:e.frontendOnly,docsOnly:e.docsOnly}),e.manifest!==!1){let{config:O}=Ni(e.guardrails);if(O?.generated&&O.generated.length>0){let $=e.generatedDir||"packages/";if(Sr.existsSync($)){let x=e.cache!==!1?A:void 0,{manifest:N,changed:k}=await Hc($,{generatorVersion:sp.version,inputHash:x});if(r){let j=Object.keys(N.files).length;if(k){let B=gl(N,$);P(` Manifest updated: ${B} (${j} files)`)}else P(` Manifest unchanged (${j} files)`)}else k&&gl(N,$)}}}n=!0}finally{r||(console.log=P)}a=Date.now()-m,c&&process.stdout.isTTY&&(process.stdout.clearLine?.(0),process.stdout.cursorTo?.(0)),console.log(` \u2713 Generate PASS (${a}ms)`),r&&console.log("")}}}catch(C){a=Date.now()-m,i=!0,s=C instanceof Error?C.message:String(C),c&&process.stdout.isTTY&&(process.stdout.clearLine?.(0),process.stdout.cursorTo?.(0)),console.log(` \u2717 Generate FAIL (${a}ms)`),console.log(` ${s}`),e.continueOnError||(console.log(""),console.log("\u274C Generation failed. Stopping pipeline."),process.exit(1)),r&&console.log("\u26A0\uFE0F Continuing due to --continue-on-error.")}r&&(console.log(""),console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 Step 3: Post-generation checks (Gate 3, 4, 5) \u2502"),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log(""));let h=f?[...l,"drift","manifest"]:l,g=await Yc({...d,skip:h,gates:[3,4,5]});u.push(...g.results),r&&console.log(Xc(g,g.checks)),g.failed>0&&(i=!0);let y=Date.now()-t,_=p.passed+g.passed+(n?1:0),w=p.failed+g.failed+(s?1:0),S=p.skipped+g.skipped+(o?1:0);if(console.log(""),console.log("\u2501".repeat(50)),console.log("\u{1F4CA} Pipeline Summary"),console.log("\u2501".repeat(50)),console.log(""),console.log(` Total Passed: ${_}`),console.log(` Total Failed: ${w}`),S>0&&console.log(` Total Skipped: ${S}`),console.log(` Duration: ${y}ms`),console.log(""),i){console.log("\u274C Pipeline completed with failures.");let C=u.filter(D=>D.status==="fail"&&D.details&&D.details.length>0);if(C.length>0){console.log(""),console.log("\u{1F4CB} Failed Check Details:");for(let D of C){console.log(` \u25B6 ${D.name}`);for(let E of D.details)console.log(` ${E}`)}}process.exit(1)}else console.log("\u2705 Pipeline completed successfully!");console.log("")}catch(t){console.error("Pipeline failed:",t instanceof Error?t.message:t),process.exit(1)}},deps:async e=>{try{let t=e.config?sn.resolve(e.config):UC();t||(console.error("Error: No config file found."),process.exit(1));let r=as(t);r.modules||(console.error("Error: Config must have modules defined."),process.exit(1));let i=new Map;for(let[n,a]of Object.entries(r.modules)){if(e.module&&n!==e.module)continue;let o=sn.resolve(sn.dirname(t),a.openapi);if(!Sr.existsSync(o)){console.warn(`Warning: OpenAPI spec not found: ${o}`);continue}let u=is(o).info["x-micro-contracts-depend-on"]||[],l=a.dependsOn||[];i.set(n,{deps:u,openApiDeps:u,configDeps:l})}e.graph?vNe(i):e.impact?yNe(i,e.impact):e.whoDependsOn?_Ne(i,e.whoDependsOn):e.validate?bNe(i):wNe(i)}catch(t){console.error("Deps analysis failed:",t instanceof Error?t.message:t),process.exit(1)}},guardrailsInit:async e=>{try{let t=e.output??"guardrails.yaml";Sr.existsSync(t)&&(console.error(`File already exists: ${t}`),console.error("Use --output to specify a different path."),process.exit(1)),Ug(t),console.log(`Created: ${t}`),console.log(`
5065
- Next steps:`),console.log(" 1. Review and customize the guardrails configuration"),console.log(" 2. Run: micro-contracts check")}catch(t){console.error("Failed to create guardrails config:",t instanceof Error?t.message:t),process.exit(1)}},manifest:async e=>{try{let t=e.dir??"packages/";if(Sr.existsSync(t)||(console.error(`Directory not found: ${t}`),process.exit(1)),e.verify){let{verifyManifest:r,formatManifestResult:i}=await Promise.resolve().then(()=>(_v(),RF)),n=await r(t);console.log(i(n)),n.valid||process.exit(1)}else{console.log(`Generating manifest for: ${t}`);let{manifest:r,changed:i}=await Hc(t,{generatorVersion:sp.version}),n=Object.keys(r.files).length;if(i){let a=gl(r,t);console.log(`Manifest updated: ${a} (${n} files)`)}else console.log(`Manifest unchanged (${n} files)`)}}catch(t){console.error("Manifest operation failed:",t instanceof Error?t.message:t),process.exit(1)}},auditOpenapi:async e=>Qre({config:e.config,module:e.module,adapter:e.adapter,model:e.model,showPrompt:e.showPrompt,failOn:e.failOn,output:e.output,reportFormat:e.reportFormat,logFile:e.logFile}),reviewPublished:async e=>ene({config:e.config,module:e.module,adapter:e.adapter,model:e.model,showPrompt:e.showPrompt,failOn:e.failOn,output:e.output,reportFormat:e.reportFormat,logFile:e.logFile}),proposeOverlays:async e=>tne({config:e.config,module:e.module,adapter:e.adapter,model:e.model,showPrompt:e.showPrompt,failOn:e.failOn,output:e.output,reportFormat:e.reportFormat,logFile:e.logFile}),insights:async e=>{try{await lne({format:e.format,projectRoot:e.projectRoot,config:e.config})}catch(t){console.error("Insights failed:",t instanceof Error?t.message:t),process.exit(1)}},auditGuardrails:async e=>rne({config:e.config,guardrails:e.guardrails,adapter:e.adapter,model:e.model,showPrompt:e.showPrompt,failOn:e.failOn,output:e.output,reportFormat:e.reportFormat,logFile:e.logFile})};oT(oNe,sp.version).parse();function sNe(e){let t=Sr.readFileSync(e,"utf-8"),r=qC.default.parse(t),i={servicesAdded:0,methodsAdded:0,services:new Set},n=["get","post","put","patch","delete","head","options"];if(r.paths)for(let[o,s]of Object.entries(r.paths)){if(!s||typeof s!="object")continue;let u=uNe(o);for(let l of n){let c=s[l];if(!c||typeof c!="object")continue;let d=c;if(!d["x-micro-contracts-service"]&&u&&(d["x-micro-contracts-service"]=u,i.servicesAdded++,i.services.add(u)),!d["x-micro-contracts-method"]){let p=d.operationId?String(d.operationId):lNe(l,o);d["x-micro-contracts-method"]=p,i.methodsAdded++}}}return{yaml:qC.default.stringify(r,{indent:2}),stats:{...i,services:Array.from(i.services)}}}function uNe(e){let r=e.replace(/^\/api\//,"/").replace(/^\/v\d+\//,"/").split("/").filter(Boolean);if(r.length===0)return null;let i=r[0];if(i.startsWith("{"))return null;let a=i.replace(/-/g,"_").split("_").map(o=>o.charAt(0).toUpperCase()+o.slice(1).toLowerCase()).join("");return a.endsWith("s")&&!a.endsWith("ss")?a.slice(0,-1):a}function lNe(e,t){let r=t.replace(/^\/api\//,"/").replace(/^\/v\d+\//,"/").split("/").filter(Boolean),i=r.some(s=>s.startsWith("{")),a=r.filter(s=>!s.startsWith("{")).map(s=>s.replace(/-/g,"_").split("_").map(l=>l.charAt(0).toUpperCase()+l.slice(1).toLowerCase()).join("")).join(""),o=a.endsWith("s")&&!a.endsWith("ss")?a.slice(0,-1):a;switch(e.toLowerCase()){case"get":return i?`get${o}ById`:`get${a}`;case"post":return`create${o}`;case"put":return`update${o}`;case"patch":return`patch${o}`;case"delete":return`delete${o}`;default:return`${e.toLowerCase()}${a}`}}function cNe(){return`import pg from 'pg';
5064
+ `));let f=!1;r&&(console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 Step 2: Generate contracts \u2502"),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log(""));let m=Date.now();c&&process.stdout.isTTY&&process.stdout.write(" \u22EF Generate running...\r");try{let C=e.config?sn.resolve(e.config):UC();if(!C)o=!0,a=Date.now()-m,c&&process.stdout.isTTY&&(process.stdout.clearLine?.(0),process.stdout.cursorTo?.(0)),console.log(" \u25CB Generate SKIP (no config file)");else{r&&console.log(` Using config: ${C}`);let D=as(C),E=e.cache!==!1&&!e.force,A;if(bo(D)&&(A=Fg(D,C,sp.version),E)){let P=e.generatedDir||"packages/",O=await Gf(P,A);O.skip&&(f=!0,o=!0,a=Date.now()-m,c&&process.stdout.isTTY&&(process.stdout.clearLine?.(0),process.stdout.cursorTo?.(0)),console.log(` \u25CB Generate SKIP (${O.reason})`))}if(!f){let P=console.log;r||(console.log=()=>{});try{if(await u9(D,{skipLint:e.skipLint,contractsOnly:e.contractsOnly,serverOnly:e.serverOnly,frontendOnly:e.frontendOnly,docsOnly:e.docsOnly}),e.manifest!==!1){let{config:O}=Ni(e.guardrails);if(O?.generated&&O.generated.length>0){let $=e.generatedDir||"packages/";if(Sr.existsSync($)){let x=e.cache!==!1?A:void 0,{manifest:N,changed:k}=await Hc($,{generatorVersion:sp.version,inputHash:x});if(r){let j=Object.keys(N.files).length;if(k){let B=gl(N,$);P(` Manifest updated: ${B} (${j} files)`)}else P(` Manifest unchanged (${j} files)`)}else k&&gl(N,$)}}}n=!0}finally{r||(console.log=P)}a=Date.now()-m,c&&process.stdout.isTTY&&(process.stdout.clearLine?.(0),process.stdout.cursorTo?.(0)),console.log(` \u2713 Generate PASS (${a}ms)`),r&&console.log("")}}}catch(C){a=Date.now()-m,i=!0,s=C instanceof Error?C.message:String(C),c&&process.stdout.isTTY&&(process.stdout.clearLine?.(0),process.stdout.cursorTo?.(0)),console.log(` \u2717 Generate FAIL (${a}ms)`),console.log(` ${s}`),e.continueOnError||(console.log(""),console.log("\u274C Generation failed. Stopping pipeline."),process.exit(1)),r&&console.log("\u26A0\uFE0F Continuing due to --continue-on-error.")}r&&(console.log(""),console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 Step 3: Post-generation checks (Gate 3, 4, 5) \u2502"),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log(""));let h=f?[...l,"drift","manifest"]:l,g=await Yc({...d,skip:h,gates:[3,4,5]});u.push(...g.results),r&&console.log(Xc(g,g.checks)),g.failed>0&&(i=!0);let y=Date.now()-t,_=p.passed+g.passed+(n?1:0),w=p.failed+g.failed+(s?1:0),S=p.skipped+g.skipped+(o?1:0);if(console.log(""),console.log("\u2501".repeat(50)),console.log("\u{1F4CA} Pipeline Summary"),console.log("\u2501".repeat(50)),console.log(""),console.log(` Total Passed: ${_}`),console.log(` Total Failed: ${w}`),S>0&&console.log(` Total Skipped: ${S}`),console.log(` Duration: ${y}ms`),console.log(""),i){console.log("\u274C Pipeline completed with failures.");let C=u.filter(D=>D.status==="fail"&&D.details&&D.details.length>0);if(C.length>0){console.log(""),console.log("\u{1F4CB} Failed Check Details:");for(let D of C){console.log(` \u25B6 ${D.name}`);for(let E of D.details)console.log(` ${E}`)}}process.exit(1)}else console.log("\u2705 Pipeline completed successfully!");console.log("")}catch(t){console.error("Pipeline failed:",t instanceof Error?t.message:t),process.exit(1)}},deps:async e=>{try{let t=e.config?sn.resolve(e.config):UC();t||(console.error("Error: No config file found."),process.exit(1));let r=as(t);r.modules||(console.error("Error: Config must have modules defined."),process.exit(1));let i=new Map;for(let[n,a]of Object.entries(r.modules)){if(e.module&&n!==e.module)continue;let o=sn.resolve(sn.dirname(t),a.openapi);if(!Sr.existsSync(o)){console.warn(`Warning: OpenAPI spec not found: ${o}`);continue}let u=is(o).info["x-micro-contracts-depend-on"]||[],l=a.dependsOn||[];i.set(n,{deps:u,openApiDeps:u,configDeps:l})}e.graph?yNe(i):e.impact?_Ne(i,e.impact):e.whoDependsOn?bNe(i,e.whoDependsOn):e.validate?wNe(i):SNe(i)}catch(t){console.error("Deps analysis failed:",t instanceof Error?t.message:t),process.exit(1)}},guardrailsInit:async e=>{try{let t=e.output??"guardrails.yaml";Sr.existsSync(t)&&(console.error(`File already exists: ${t}`),console.error("Use --output to specify a different path."),process.exit(1)),Ug(t),console.log(`Created: ${t}`),console.log(`
5065
+ Next steps:`),console.log(" 1. Review and customize the guardrails configuration"),console.log(" 2. Run: micro-contracts check")}catch(t){console.error("Failed to create guardrails config:",t instanceof Error?t.message:t),process.exit(1)}},manifest:async e=>{try{let t=e.dir??"packages/";if(Sr.existsSync(t)||(console.error(`Directory not found: ${t}`),process.exit(1)),e.verify){let{verifyManifest:r,formatManifestResult:i}=await Promise.resolve().then(()=>(_v(),RF)),n=await r(t);console.log(i(n)),n.valid||process.exit(1)}else{console.log(`Generating manifest for: ${t}`);let{manifest:r,changed:i}=await Hc(t,{generatorVersion:sp.version}),n=Object.keys(r.files).length;if(i){let a=gl(r,t);console.log(`Manifest updated: ${a} (${n} files)`)}else console.log(`Manifest unchanged (${n} files)`)}}catch(t){console.error("Manifest operation failed:",t instanceof Error?t.message:t),process.exit(1)}},auditOpenapi:async e=>Qre({config:e.config,module:e.module,adapter:e.adapter,model:e.model,showPrompt:e.showPrompt,failOn:e.failOn,output:e.output,reportFormat:e.reportFormat,logFile:e.logFile}),reviewPublished:async e=>ene({config:e.config,module:e.module,adapter:e.adapter,model:e.model,showPrompt:e.showPrompt,failOn:e.failOn,output:e.output,reportFormat:e.reportFormat,logFile:e.logFile}),proposeOverlays:async e=>tne({config:e.config,module:e.module,adapter:e.adapter,model:e.model,showPrompt:e.showPrompt,failOn:e.failOn,output:e.output,reportFormat:e.reportFormat,logFile:e.logFile}),insights:async e=>{try{await lne({format:e.format,projectRoot:e.projectRoot,config:e.config})}catch(t){console.error("Insights failed:",t instanceof Error?t.message:t),process.exit(1)}},auditGuardrails:async e=>rne({config:e.config,guardrails:e.guardrails,adapter:e.adapter,model:e.model,showPrompt:e.showPrompt,failOn:e.failOn,output:e.output,reportFormat:e.reportFormat,logFile:e.logFile})};oT(sNe,sp.version).parse();function uNe(e){let t=Sr.readFileSync(e,"utf-8"),r=qC.default.parse(t),i={servicesAdded:0,methodsAdded:0,services:new Set},n=["get","post","put","patch","delete","head","options"];if(r.paths)for(let[o,s]of Object.entries(r.paths)){if(!s||typeof s!="object")continue;let u=lNe(o);for(let l of n){let c=s[l];if(!c||typeof c!="object")continue;let d=c;if(!d["x-micro-contracts-service"]&&u&&(d["x-micro-contracts-service"]=u,i.servicesAdded++,i.services.add(u)),!d["x-micro-contracts-method"]){let p=d.operationId?String(d.operationId):cNe(l,o);d["x-micro-contracts-method"]=p,i.methodsAdded++}}}return{yaml:qC.default.stringify(r,{indent:2}),stats:{...i,services:Array.from(i.services)}}}function lNe(e){let r=e.replace(/^\/api\//,"/").replace(/^\/v\d+\//,"/").split("/").filter(Boolean);if(r.length===0)return null;let i=r[0];if(i.startsWith("{"))return null;let a=i.replace(/-/g,"_").split("_").map(o=>o.charAt(0).toUpperCase()+o.slice(1).toLowerCase()).join("");return a.endsWith("s")&&!a.endsWith("ss")?a.slice(0,-1):a}function cNe(e,t){let r=t.replace(/^\/api\//,"/").replace(/^\/v\d+\//,"/").split("/").filter(Boolean),i=r.some(s=>s.startsWith("{")),a=r.filter(s=>!s.startsWith("{")).map(s=>s.replace(/-/g,"_").split("_").map(l=>l.charAt(0).toUpperCase()+l.slice(1).toLowerCase()).join("")).join(""),o=a.endsWith("s")&&!a.endsWith("ss")?a.slice(0,-1):a;switch(e.toLowerCase()){case"get":return i?`get${o}ById`:`get${a}`;case"post":return`create${o}`;case"put":return`update${o}`;case"patch":return`patch${o}`;case"delete":return`delete${o}`;default:return`${e.toLowerCase()}${a}`}}function dNe(){return`import pg from 'pg';
5066
5066
  import { DBModel, PostgresDriver } from 'litedbmodel';
5067
5067
 
5068
5068
  const { Pool } = pg;
@@ -5113,7 +5113,7 @@ export async function testConnection(): Promise<boolean> {
5113
5113
  return false;
5114
5114
  }
5115
5115
  }
5116
- `}function dNe(e){let t=e.charAt(0).toUpperCase()+e.slice(1);return`import { testConnection, closeDb } from './db.js';
5116
+ `}function pNe(e){let t=e.charAt(0).toUpperCase()+e.slice(1);return`import { testConnection, closeDb } from './db.js';
5117
5117
 
5118
5118
  export interface ${t}Services {
5119
5119
  // example: ExampleServiceApi;
@@ -5134,9 +5134,9 @@ export async function initialize${t}Module(): Promise<${t}ModuleContainer> {
5134
5134
  close: closeDb,
5135
5135
  };
5136
5136
  }
5137
- `}function pNe(e){return["# micro-contracts Configuration","","defaults:"," contract:"," output: packages/contract/{module}",""," contractPublic:"," output: packages/contract-published/{module}",""," outputs:"," server-routes:"," output: server/src/{module}/routes.generated.ts"," template: fastify-routes.hbs"," config:"," servicesPath: fastify.services.{module}",""," frontend-api:"," output: frontend/src/{module}/api.generated.ts"," template: fetch-client.hbs",""," shared-client:"," output: frontend/src/shared/{module}.api.generated.ts"," template: fetch-client.hbs"," condition: hasPublicEndpoints"," config:",' contractPackage: "@project/contract-published/{module}"',""," overlays:"," shared:"," - spec/_shared/overlays/middleware.overlay.yaml"," collision: error",""," docs:"," enabled: true","","modules:",` ${e}:`,` openapi: spec/${e}/openapi/${e}.yaml`,""].join(`
5138
- `)}function fNe(e){return["# micro-contracts Configuration (Screen Spec)","","defaults:"," contract:"," output: packages/contract/{module}",""," docs:"," enabled: false","","modules:",` ${e}:`,` openapi: spec/${e}/openapi/${e}.yaml`," screen: true"," outputs:"," screen-navigation:"," output: frontend/src/screens/navigation.generated.ts"," template: screen-navigation.hbs"," screen-events:"," output: frontend/src/screens/events.generated.ts"," template: screen-events.hbs",""].join(`
5139
- `)}function mNe(){return`# RFC 9457 Problem Details
5137
+ `}function fNe(e){return["# micro-contracts Configuration","","defaults:"," contract:"," output: packages/contract/{module}",""," contractPublic:"," output: packages/contract-published/{module}",""," outputs:"," server-routes:"," output: server/src/{module}/routes.generated.ts"," template: fastify-routes.hbs"," config:"," servicesPath: fastify.services.{module}",""," frontend-api:"," output: frontend/src/{module}/api.generated.ts"," template: fetch-client.hbs",""," shared-client:"," output: frontend/src/shared/{module}.api.generated.ts"," template: fetch-client.hbs"," condition: hasPublicEndpoints"," config:",' contractPackage: "@project/contract-published/{module}"',""," overlays:"," shared:"," - spec/_shared/overlays/middleware.overlay.yaml"," collision: error",""," docs:"," enabled: true","","modules:",` ${e}:`,` openapi: spec/${e}/openapi/${e}.yaml`,""].join(`
5138
+ `)}function mNe(e){return["# micro-contracts Configuration (Screen Spec)","","defaults:"," contract:"," output: packages/contract/{module}",""," docs:"," enabled: false","","modules:",` ${e}:`,` openapi: spec/${e}/openapi/${e}.yaml`," screen: true"," outputs:"," screen-navigation:"," output: frontend/src/screens/navigation.generated.ts"," template: screen-navigation.hbs"," screen-events:"," output: frontend/src/screens/events.generated.ts"," template: screen-events.hbs",""].join(`
5139
+ `)}function hNe(){return`# RFC 9457 Problem Details
5140
5140
  components:
5141
5141
  schemas:
5142
5142
  ProblemDetails:
@@ -5168,7 +5168,7 @@ components:
5168
5168
  type: string
5169
5169
  message:
5170
5170
  type: string
5171
- `}function hNe(){return`extends: ["spectral:oas"]
5171
+ `}function gNe(){return`extends: ["spectral:oas"]
5172
5172
 
5173
5173
  rules:
5174
5174
  operation-service:
@@ -5211,7 +5211,7 @@ rules:
5211
5211
  function: falsy
5212
5212
  - field: x-public
5213
5213
  function: falsy
5214
- `}function gNe(e){return`openapi: '3.1.0'
5214
+ `}function vNe(e){return`openapi: '3.1.0'
5215
5215
  info:
5216
5216
  title: ${e.charAt(0).toUpperCase()+e.slice(1)} Screen Specification
5217
5217
  version: '0.1.0'
@@ -5279,9 +5279,9 @@ components:
5279
5279
  theme:
5280
5280
  type: string
5281
5281
  enum: [light, dark]
5282
- `}function vNe(e){console.log("```mermaid"),console.log("graph LR");for(let[t,{deps:r}]of e){let i=new Set;for(let n of r){let a=n.split(".");a.length>=1&&i.add(a[0])}for(let n of i)console.log(` ${t} --> ${n}`)}console.log("```")}function yNe(e,t){console.log(`Impacted by changes to ${t}:
5283
- `);let r=[];for(let[i,{deps:n}]of e)n.includes(t)&&r.push(i);if(r.length===0)console.log(" No modules depend on this API.");else for(let i of r)console.log(` - ${i}`)}function _Ne(e,t){console.log(`Modules that depend on ${t}:
5284
- `);let r=[];for(let[i,{deps:n}]of e)n.some(a=>a.startsWith(t))&&r.push(i);if(r.length===0)console.log(" None found.");else for(let i of r)console.log(` - ${i}`)}function bNe(e){let t=!1;for(let[r,{openApiDeps:i,configDeps:n}]of e)for(let a of n)i.includes(a)||(console.error(`ERROR: ${r}.dependsOn includes '${a}'`),console.error(" but it's not declared in OpenAPI x-micro-contracts-depend-on"),t=!0);t?process.exit(1):console.log("\u2713 All dependencies are valid")}function wNe(e){console.log(`Module Dependencies:
5282
+ `}function yNe(e){console.log("```mermaid"),console.log("graph LR");for(let[t,{deps:r}]of e){let i=new Set;for(let n of r){let a=n.split(".");a.length>=1&&i.add(a[0])}for(let n of i)console.log(` ${t} --> ${n}`)}console.log("```")}function _Ne(e,t){console.log(`Impacted by changes to ${t}:
5283
+ `);let r=[];for(let[i,{deps:n}]of e)n.includes(t)&&r.push(i);if(r.length===0)console.log(" No modules depend on this API.");else for(let i of r)console.log(` - ${i}`)}function bNe(e,t){console.log(`Modules that depend on ${t}:
5284
+ `);let r=[];for(let[i,{deps:n}]of e)n.some(a=>a.startsWith(t))&&r.push(i);if(r.length===0)console.log(" None found.");else for(let i of r)console.log(` - ${i}`)}function wNe(e){let t=!1;for(let[r,{openApiDeps:i,configDeps:n}]of e)for(let a of n)i.includes(a)||(console.error(`ERROR: ${r}.dependsOn includes '${a}'`),console.error(" but it's not declared in OpenAPI x-micro-contracts-depend-on"),t=!0);t?process.exit(1):console.log("\u2713 All dependencies are valid")}function SNe(e){console.log(`Module Dependencies:
5285
5285
  `);for(let[t,{deps:r}]of e){if(console.log(`${t}:`),r.length===0)console.log(" (no dependencies)");else for(let i of r)console.log(` - ${i}`);console.log()}}
5286
5286
  /*! Bundled license information:
5287
5287