@prismatic-io/prism 7.6.5 → 7.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -64933,10 +64933,10 @@ ${t.data}
64933
64933
  comments: "Provide headers to the SOAP client",
64934
64934
  default: '{}'
64935
64935
  }`]}}`}]),o.addVariableStatement({declarationKind:jen.VariableDeclarationKind.Const,declarations:[{name:e.key,initializer:`action(${p.print()})`}],isExported:!0}),c.remove()},Neu=async(e,{actionFile:t,definitionDirectory:o})=>{t.addImportDeclaration({moduleSpecifier:`../${o}/index`,namedImports:e})},Peu=async(e,{actionFile:t})=>{t.addImportDeclaration({moduleSpecifier:"./inputs",namedImports:e})},sMi=async(e)=>{let{actionFile:t,inputsFile:o}=e,c=rMi(e),p=P9e(Object.entries(c).flatMap(([V,X])=>{return w7n(X,(d0)=>d0.getName()).map((d0)=>Seu(V,d0,e))}),({key:V})=>V),m=p.flatMap(({actionObject:V})=>V.inputs).filter(({shouldImport:V})=>V).flatMap(({properties:V})=>V),T=P9e(w7n(m,(V)=>V.propertyName.toLowerCase()),(V)=>V.propertyName);await oMi(e,T),o.organizeImports(),o.formatText(),await o.save();let P=p.map(({service:V})=>V),I=P9e(tje(P));await Neu(I,e);let L=T.map(({propertyName:V})=>V);await Peu(L,e);let z=p.map((V)=>weu(V,e));await Promise.all(z);let H=P9e(p.map(({key:V})=>V));t.addExportAssignment({isExportEquals:!1,expression:`{${H.join(`,
64936
- `)}}`}),t.organizeImports(),t.formatText(),await t.save()};var cMi=async({projectRoot:e,projectTemplateName:t,projectTemplatePath:o})=>{let c=iMi(e,t,o),{componentProject:p}=c;await sMi(c),p.getSourceFile(Xge.join(e,"src","index.test.ts"))?.delete(),p.getSourceFile(Xge.join(e,"src","actions.test.ts"))?.delete(),p.getSourceFile(Xge.join(e,"src","client.ts"))?.delete(),p.getSourceFile(Xge.join(e,"src","connections.ts"))?.delete(),p.getSourceFile(Xge.join(e,"src","dataSources.ts"))?.delete(),p.getSourceFile(Xge.join(e,"src","dataSources.test.ts"))?.delete(),p.getSourceFile(Xge.join(e,"src","triggers.ts"))?.delete(),p.getSourceFile(Xge.join(e,"src","triggers.test.ts"))?.delete(),await p.save()};var dmn={"@prismatic-io/eslint-config-spectral":"2.1.0","@types/jest":"29.5.14","copy-webpack-plugin":"13.0.0",eslint:"^8.57.1",jest:"29.7.0","ts-jest":"29.3.2","ts-loader":"9.5.2",typescript:"5.8.3",webpack:"5.99.5","webpack-cli":"6.0.1"};var uLi=H3(Izn(),1);var AMi=H3(mMi(),1);var nnn=(e)=>{if(typeof e!=="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var qeu={"[: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]},tnn=(e)=>e.replace(/[[\]\\-]/g,"\\$&"),Jeu=(e)=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),hMi=(e)=>e.join(""),xMi=(e,t)=>{let o=t;if(e.charAt(o)!=="[")throw new Error("not in a brace expression");let c=[],p=[],m=o+1,T=!1,P=!1,I=!1,L=!1,z=o,H="";e:while(m<e.length){let d0=e.charAt(m);if((d0==="!"||d0==="^")&&m===o+1){L=!0,m++;continue}if(d0==="]"&&T&&!I){z=m+1;break}if(T=!0,d0==="\\"){if(!I){I=!0,m++;continue}}if(d0==="["&&!I){for(let[D0,[N0,w0,W0]]of Object.entries(qeu))if(e.startsWith(D0,m)){if(H)return["$.",!1,e.length-o,!0];if(m+=D0.length,W0)p.push(N0);else c.push(N0);P=P||w0;continue e}}if(I=!1,H){if(d0>H)c.push(tnn(H)+"-"+tnn(d0));else if(d0===H)c.push(tnn(d0));H="",m++;continue}if(e.startsWith("-]",m+1)){c.push(tnn(d0+"-")),m+=2;continue}if(e.startsWith("-",m+1)){H=d0,m+=2;continue}c.push(tnn(d0)),m++}if(z<m)return["",!1,0,!1];if(!c.length&&!p.length)return["$.",!1,e.length-o,!0];if(p.length===0&&c.length===1&&/^\\?.$/.test(c[0])&&!L){let d0=c[0].length===2?c[0].slice(-1):c[0];return[Jeu(d0),!1,z-o,!1]}let V="["+(L?"^":"")+hMi(c)+"]",X="["+(L?"":"^")+hMi(p)+"]";return[c.length&&p.length?"("+V+"|"+X+")":c.length?V:X,P,z-o,!0]};var kj0=(e,{windowsPathsNoEscape:t=!1}={})=>{return t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var Keu=new Set(["!","?","+","*","@"]),DMi=(e)=>Keu.has(e),zeu="(?!(?:^|/)\\.\\.?(?:$|/))",pmn="(?!\\.)",Weu=new Set(["[","."]),Ueu=new Set(["..","."]),Qeu=new Set("().*{}+?[]^$\\!"),Yeu=(e)=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),qjn="[^/]",yMi=qjn+"*?",EMi=qjn+"+?";class kD0{type;#e;#n;#t=!1;#i=[];#r;#a;#o;#s=!1;#c;#u;#p=!1;constructor(e,t,o={}){if(this.type=e,e)this.#n=!0;if(this.#r=t,this.#e=this.#r?this.#r.#e:this,this.#c=this.#e===this?o:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e==="!"&&!this.#e.#s)this.#o.push(this);this.#a=this.#r?this.#r.#i.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(let e of this.#i){if(typeof e==="string")continue;if(e.type||e.hasMagic)return this.#n=!0}return this.#n}toString(){if(this.#u!==void 0)return this.#u;if(!this.type)return this.#u=this.#i.map((e)=>String(e)).join("");else return this.#u=this.type+"("+this.#i.map((e)=>String(e)).join("|")+")"}#y(){if(this!==this.#e)throw new Error("should only call on root");if(this.#s)return this;this.toString(),this.#s=!0;let e;while(e=this.#o.pop()){if(e.type!=="!")continue;let t=e,o=t.#r;while(o){for(let c=t.#a+1;!o.type&&c<o.#i.length;c++)for(let p of e.#i){if(typeof p==="string")throw new Error("string part in extglob AST??");p.copyIn(o.#i[c])}t=o,o=t.#r}}return this}push(...e){for(let t of e){if(t==="")continue;if(typeof t!=="string"&&!(t instanceof kD0&&t.#r===this))throw new Error("invalid part: "+t);this.#i.push(t)}}toJSON(){let e=this.type===null?this.#i.slice().map((t)=>typeof t==="string"?t:t.toJSON()):[this.type,...this.#i.map((t)=>t.toJSON())];if(this.isStart()&&!this.type)e.unshift([]);if(this.isEnd()&&(this===this.#e||this.#e.#s&&this.#r?.type==="!"))e.push({});return e}isStart(){if(this.#e===this)return!0;if(!this.#r?.isStart())return!1;if(this.#a===0)return!0;let e=this.#r;for(let t=0;t<this.#a;t++){let o=e.#i[t];if(!(o instanceof kD0&&o.type==="!"))return!1}return!0}isEnd(){if(this.#e===this)return!0;if(this.#r?.type==="!")return!0;if(!this.#r?.isEnd())return!1;if(!this.type)return this.#r?.isEnd();let e=this.#r?this.#r.#i.length:0;return this.#a===e-1}copyIn(e){if(typeof e==="string")this.push(e);else this.push(e.clone(this))}clone(e){let t=new kD0(this.type,e);for(let o of this.#i)t.copyIn(o);return t}static#m(e,t,o,c){let p=!1,m=!1,T=-1,P=!1;if(t.type===null){let V=o,X="";while(V<e.length){let f0=e.charAt(V++);if(p||f0==="\\"){p=!p,X+=f0;continue}if(m){if(V===T+1){if(f0==="^"||f0==="!")P=!0}else if(f0==="]"&&!(V===T+2&&P))m=!1;X+=f0;continue}else if(f0==="["){m=!0,T=V,P=!1,X+=f0;continue}if(!c.noext&&DMi(f0)&&e.charAt(V)==="("){t.push(X),X="";let d0=new kD0(f0,t);V=kD0.#m(e,d0,V,c),t.push(d0);continue}X+=f0}return t.push(X),V}let I=o+1,L=new kD0(null,t),z=[],H="";while(I<e.length){let V=e.charAt(I++);if(p||V==="\\"){p=!p,H+=V;continue}if(m){if(I===T+1){if(V==="^"||V==="!")P=!0}else if(V==="]"&&!(I===T+2&&P))m=!1;H+=V;continue}else if(V==="["){m=!0,T=I,P=!1,H+=V;continue}if(DMi(V)&&e.charAt(I)==="("){L.push(H),H="";let X=new kD0(V,L);L.push(X),I=kD0.#m(e,X,I,c);continue}if(V==="|"){L.push(H),H="",z.push(L),L=new kD0(null,t);continue}if(V===")"){if(H===""&&t.#i.length===0)t.#p=!0;return L.push(H),H="",t.push(...z,L),I}H+=V}return t.type=null,t.#n=void 0,t.#i=[e.substring(o-1)],I}static fromGlob(e,t={}){let o=new kD0(null,void 0,t);return kD0.#m(e,o,0,t),o}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,o,c,p]=this.toRegExpSource();if(!(c||this.#n||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return o;let T=(this.#c.nocase?"i":"")+(p?"u":"");return Object.assign(new RegExp(`^${t}$`,T),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(e){let t=e??!!this.#c.dot;if(this.#e===this)this.#y();if(!this.type){let P=this.isStart()&&this.isEnd(),I=this.#i.map((V)=>{let[X,f0,d0,D0]=typeof V==="string"?kD0.#D(V,this.#n,P):V.toRegExpSource(e);return this.#n=this.#n||d0,this.#t=this.#t||D0,X}).join(""),L="";if(this.isStart()){if(typeof this.#i[0]==="string"){if(!(this.#i.length===1&&Ueu.has(this.#i[0]))){let X=Weu,f0=t&&X.has(I.charAt(0))||I.startsWith("\\.")&&X.has(I.charAt(2))||I.startsWith("\\.\\.")&&X.has(I.charAt(4)),d0=!t&&!e&&X.has(I.charAt(0));L=f0?zeu:d0?pmn:""}}}let z="";if(this.isEnd()&&this.#e.#s&&this.#r?.type==="!")z="(?:$|\\/)";return[L+I+z,kj0(I),this.#n=!!this.#n,this.#t]}let o=this.type==="*"||this.type==="+",c=this.type==="!"?"(?:(?!(?:":"(?:",p=this.#_(t);if(this.isStart()&&this.isEnd()&&!p&&this.type!=="!"){let P=this.toString();return this.#i=[P],this.type=null,this.#n=void 0,[P,kj0(this.toString()),!1,!1]}let m=!o||e||t||!pmn?"":this.#_(!0);if(m===p)m="";if(m)p=`(?:${p})(?:${m})*?`;let T="";if(this.type==="!"&&this.#p)T=(this.isStart()&&!t?pmn:"")+EMi;else{let P=this.type==="!"?"))"+(this.isStart()&&!t&&!e?pmn:"")+yMi+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&m?")":this.type==="*"&&m?")?":`)${this.type}`;T=c+p+P}return[T,kj0(p),this.#n=!!this.#n,this.#t]}#_(e){return this.#i.map((t)=>{if(typeof t==="string")throw new Error("string type in extglob ast??");let[o,c,p,m]=t.toRegExpSource(e);return this.#t=this.#t||m,o}).filter((t)=>!(this.isStart()&&this.isEnd())||!!t).join("|")}static#D(e,t,o=!1){let c=!1,p="",m=!1;for(let T=0;T<e.length;T++){let P=e.charAt(T);if(c){c=!1,p+=(Qeu.has(P)?"\\":"")+P;continue}if(P==="\\"){if(T===e.length-1)p+="\\\\";else c=!0;continue}if(P==="["){let[I,L,z,H]=xMi(e,T);if(z){p+=I,m=m||L,T+=z-1,t=t||H;continue}}if(P==="*"){if(o&&e==="*")p+=EMi;else p+=yMi;t=!0;continue}if(P==="?"){p+=qjn,t=!0;continue}p+=Yeu(P)}return[p,kj0(e),!!t,m]}}var AQe=(e,{windowsPathsNoEscape:t=!1}={})=>{return t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&")};var BT0=(e,t,o={})=>{if(nnn(t),!o.nocomment&&t.charAt(0)==="#")return!1;return new bQ0(t,o).match(e)},$eu=/^\*+([^+@!?\*\[\(]*)$/,Zeu=(e)=>(t)=>!t.startsWith(".")&&t.endsWith(e),Veu=(e)=>(t)=>t.endsWith(e),Heu=(e)=>{return e=e.toLowerCase(),(t)=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)},Geu=(e)=>{return e=e.toLowerCase(),(t)=>t.toLowerCase().endsWith(e)},Xeu=/^\*+\.\*+$/,Reu=(e)=>!e.startsWith(".")&&e.includes("."),jeu=(e)=>e!=="."&&e!==".."&&e.includes("."),enu=/^\.\*+$/,nnu=(e)=>e!=="."&&e!==".."&&e.startsWith("."),tnu=/^\*+$/,inu=(e)=>e.length!==0&&!e.startsWith("."),rnu=(e)=>e.length!==0&&e!=="."&&e!=="..",anu=/^\?+([^+@!?\*\[\(]*)?$/,onu=([e,t=""])=>{let o=FMi([e]);if(!t)return o;return t=t.toLowerCase(),(c)=>o(c)&&c.toLowerCase().endsWith(t)},unu=([e,t=""])=>{let o=SMi([e]);if(!t)return o;return t=t.toLowerCase(),(c)=>o(c)&&c.toLowerCase().endsWith(t)},snu=([e,t=""])=>{let o=SMi([e]);return!t?o:(c)=>o(c)&&c.endsWith(t)},cnu=([e,t=""])=>{let o=FMi([e]);return!t?o:(c)=>o(c)&&c.endsWith(t)},FMi=([e])=>{let t=e.length;return(o)=>o.length===t&&!o.startsWith(".")},SMi=([e])=>{let t=e.length;return(o)=>o.length===t&&o!=="."&&o!==".."},wMi=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",CMi={win32:{sep:"\\"},posix:{sep:"/"}},fnu=wMi==="win32"?CMi.win32.sep:CMi.posix.sep;BT0.sep=fnu;var ID0=Symbol("globstar **");BT0.GLOBSTAR=ID0;var lnu="[^/]",_nu=lnu+"*?",dnu="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",pnu="(?:(?!(?:\\/|^)\\.).)*?",vnu=(e,t={})=>(o)=>BT0(o,e,t);BT0.filter=vnu;var PQ0=(e,t={})=>Object.assign({},e,t),gnu=(e)=>{if(!e||typeof e!=="object"||!Object.keys(e).length)return BT0;let t=BT0;return Object.assign((c,p,m={})=>t(c,p,PQ0(e,m)),{Minimatch:class c extends t.Minimatch{constructor(p,m={}){super(p,PQ0(e,m))}static defaults(p){return t.defaults(PQ0(e,p)).Minimatch}},AST:class c extends t.AST{constructor(p,m,T={}){super(p,m,PQ0(e,T))}static fromGlob(p,m={}){return t.AST.fromGlob(p,PQ0(e,m))}},unescape:(c,p={})=>t.unescape(c,PQ0(e,p)),escape:(c,p={})=>t.escape(c,PQ0(e,p)),filter:(c,p={})=>t.filter(c,PQ0(e,p)),defaults:(c)=>t.defaults(PQ0(e,c)),makeRe:(c,p={})=>t.makeRe(c,PQ0(e,p)),braceExpand:(c,p={})=>t.braceExpand(c,PQ0(e,p)),match:(c,p,m={})=>t.match(c,p,PQ0(e,m)),sep:t.sep,GLOBSTAR:ID0})};BT0.defaults=gnu;var NMi=(e,t={})=>{if(nnn(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e))return[e];return AMi.default(e)};BT0.braceExpand=NMi;var mnu=(e,t={})=>new bQ0(e,t).makeRe();BT0.makeRe=mnu;var hnu=(e,t,o={})=>{let c=new bQ0(t,o);if(e=e.filter((p)=>c.match(p)),c.options.nonull&&!e.length)e.push(t);return e};BT0.match=hnu;var TMi=/[?*]|[+@!]\(.*?\)|\[|\]/,xnu=(e)=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class bQ0{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(e,t={}){if(nnn(e),t=t||{},this.options=t,this.pattern=e,this.platform=t.platform||wMi,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.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 e of this.set)for(let t of e)if(typeof t!=="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug)this.debug=(...p)=>console.error(...p);this.debug(this.pattern,this.globSet);let o=this.globSet.map((p)=>this.slashSplit(p));this.globParts=this.preprocess(o),this.debug(this.pattern,this.globParts);let c=this.globParts.map((p,m,T)=>{if(this.isWindows&&this.windowsNoMagicRoot){let P=p[0]===""&&p[1]===""&&(p[2]==="?"||!TMi.test(p[2]))&&!TMi.test(p[3]),I=/^[a-z]:/i.test(p[0]);if(P)return[...p.slice(0,4),...p.slice(4).map((L)=>this.parse(L))];else if(I)return[p[0],...p.slice(1).map((L)=>this.parse(L))]}return p.map((P)=>this.parse(P))});if(this.debug(this.pattern,c),this.set=c.filter((p)=>p.indexOf(!1)===-1),this.isWindows)for(let p=0;p<this.set.length;p++){let m=this.set[p];if(m[0]===""&&m[1]===""&&this.globParts[p][2]==="?"&&typeof m[3]==="string"&&/^[a-z]:$/i.test(m[3]))m[2]="?"}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar){for(let o=0;o<e.length;o++)for(let c=0;c<e[o].length;c++)if(e[o][c]==="**")e[o][c]="*"}let{optimizationLevel:t=1}=this.options;if(t>=2)e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e);else if(t>=1)e=this.levelOneOptimize(e);else e=this.adjascentGlobstarOptimize(e);return e}adjascentGlobstarOptimize(e){return e.map((t)=>{let o=-1;while((o=t.indexOf("**",o+1))!==-1){let c=o;while(t[c+1]==="**")c++;if(c!==o)t.splice(o,c-o)}return t})}levelOneOptimize(e){return e.map((t)=>{return t=t.reduce((o,c)=>{let p=o[o.length-1];if(c==="**"&&p==="**")return o;if(c===".."){if(p&&p!==".."&&p!=="."&&p!=="**")return o.pop(),o}return o.push(c),o},[]),t.length===0?[""]:t})}levelTwoFileOptimize(e){if(!Array.isArray(e))e=this.slashSplit(e);let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let c=1;c<e.length-1;c++){let p=e[c];if(c===1&&p===""&&e[0]==="")continue;if(p==="."||p==="")t=!0,e.splice(c,1),c--}if(e[0]==="."&&e.length===2&&(e[1]==="."||e[1]===""))t=!0,e.pop()}let o=0;while((o=e.indexOf("..",o+1))!==-1){let c=e[o-1];if(c&&c!=="."&&c!==".."&&c!=="**")t=!0,e.splice(o-1,2),o-=2}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let o of e){let c=-1;while((c=o.indexOf("**",c+1))!==-1){let m=c;while(o[m+1]==="**")m++;if(m>c)o.splice(c+1,m-c);let T=o[c+1],P=o[c+2],I=o[c+3];if(T!=="..")continue;if(!P||P==="."||P===".."||!I||I==="."||I==="..")continue;t=!0,o.splice(c,1);let L=o.slice(0);L[c]="**",e.push(L),c--}if(!this.preserveMultipleSlashes){for(let m=1;m<o.length-1;m++){let T=o[m];if(m===1&&T===""&&o[0]==="")continue;if(T==="."||T==="")t=!0,o.splice(m,1),m--}if(o[0]==="."&&o.length===2&&(o[1]==="."||o[1]===""))t=!0,o.pop()}let p=0;while((p=o.indexOf("..",p+1))!==-1){let m=o[p-1];if(m&&m!=="."&&m!==".."&&m!=="**"){t=!0;let P=p===1&&o[p+1]==="**"?["."]:[];if(o.splice(p-1,2,...P),o.length===0)o.push("");p-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let o=t+1;o<e.length;o++){let c=this.partsMatch(e[t],e[o],!this.preserveMultipleSlashes);if(c){e[t]=[],e[o]=c;break}}return e.filter((t)=>t.length)}partsMatch(e,t,o=!1){let c=0,p=0,m=[],T="";while(c<e.length&&p<t.length)if(e[c]===t[p])m.push(T==="b"?t[p]:e[c]),c++,p++;else if(o&&e[c]==="**"&&t[p]===e[c+1])m.push(e[c]),c++;else if(o&&t[p]==="**"&&e[c]===t[p+1])m.push(t[p]),p++;else if(e[c]==="*"&&t[p]&&(this.options.dot||!t[p].startsWith("."))&&t[p]!=="**"){if(T==="b")return!1;T="a",m.push(e[c]),c++,p++}else if(t[p]==="*"&&e[c]&&(this.options.dot||!e[c].startsWith("."))&&e[c]!=="**"){if(T==="a")return!1;T="b",m.push(t[p]),c++,p++}else return!1;return e.length===t.length&&m}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,o=0;for(let c=0;c<e.length&&e.charAt(c)==="!";c++)t=!t,o++;if(o)this.pattern=e.slice(o);this.negate=t}matchOne(e,t,o=!1){let c=this.options;if(this.isWindows){let f0=typeof e[0]==="string"&&/^[a-z]:$/i.test(e[0]),d0=!f0&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),D0=typeof t[0]==="string"&&/^[a-z]:$/i.test(t[0]),N0=!D0&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]==="string"&&/^[a-z]:$/i.test(t[3]),w0=d0?3:f0?0:void 0,W0=N0?3:D0?0:void 0;if(typeof w0==="number"&&typeof W0==="number"){let[Q0,fe]=[e[w0],t[W0]];if(Q0.toLowerCase()===fe.toLowerCase()){if(t[W0]=Q0,W0>w0)t=t.slice(W0);else if(w0>W0)e=e.slice(w0)}}}let{optimizationLevel:p=1}=this.options;if(p>=2)e=this.levelTwoFileOptimize(e);this.debug("matchOne",this,{file:e,pattern:t}),this.debug("matchOne",e.length,t.length);for(var m=0,T=0,P=e.length,I=t.length;m<P&&T<I;m++,T++){this.debug("matchOne loop");var L=t[T],z=e[m];if(this.debug(t,L,z),L===!1)return!1;if(L===ID0){this.debug("GLOBSTAR",[t,L,z]);var H=m,V=T+1;if(V===I){this.debug("** at the end");for(;m<P;m++)if(e[m]==="."||e[m]===".."||!c.dot&&e[m].charAt(0)===".")return!1;return!0}while(H<P){var X=e[H];if(this.debug(`
64936
+ `)}}`}),t.organizeImports(),t.formatText(),await t.save()};var cMi=async({projectRoot:e,projectTemplateName:t,projectTemplatePath:o})=>{let c=iMi(e,t,o),{componentProject:p}=c;await sMi(c),p.getSourceFile(Xge.join(e,"src","index.test.ts"))?.delete(),p.getSourceFile(Xge.join(e,"src","actions.test.ts"))?.delete(),p.getSourceFile(Xge.join(e,"src","client.ts"))?.delete(),p.getSourceFile(Xge.join(e,"src","connections.ts"))?.delete(),p.getSourceFile(Xge.join(e,"src","dataSources.ts"))?.delete(),p.getSourceFile(Xge.join(e,"src","dataSources.test.ts"))?.delete(),p.getSourceFile(Xge.join(e,"src","triggers.ts"))?.delete(),p.getSourceFile(Xge.join(e,"src","triggers.test.ts"))?.delete(),await p.save()};var dmn={"@prismatic-io/eslint-config-spectral":"2.1.0","@types/jest":"29.5.14","copy-webpack-plugin":"13.0.0","dotenv-webpack":"^8.1.1",eslint:"^8.57.1",jest:"29.7.0","ts-jest":"29.3.2","ts-loader":"9.5.2",typescript:"5.8.3",webpack:"5.99.5","webpack-cli":"6.0.1"};var uLi=H3(Izn(),1);var AMi=H3(mMi(),1);var nnn=(e)=>{if(typeof e!=="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var qeu={"[: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]},tnn=(e)=>e.replace(/[[\]\\-]/g,"\\$&"),Jeu=(e)=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),hMi=(e)=>e.join(""),xMi=(e,t)=>{let o=t;if(e.charAt(o)!=="[")throw new Error("not in a brace expression");let c=[],p=[],m=o+1,T=!1,P=!1,I=!1,L=!1,z=o,H="";e:while(m<e.length){let d0=e.charAt(m);if((d0==="!"||d0==="^")&&m===o+1){L=!0,m++;continue}if(d0==="]"&&T&&!I){z=m+1;break}if(T=!0,d0==="\\"){if(!I){I=!0,m++;continue}}if(d0==="["&&!I){for(let[D0,[N0,w0,W0]]of Object.entries(qeu))if(e.startsWith(D0,m)){if(H)return["$.",!1,e.length-o,!0];if(m+=D0.length,W0)p.push(N0);else c.push(N0);P=P||w0;continue e}}if(I=!1,H){if(d0>H)c.push(tnn(H)+"-"+tnn(d0));else if(d0===H)c.push(tnn(d0));H="",m++;continue}if(e.startsWith("-]",m+1)){c.push(tnn(d0+"-")),m+=2;continue}if(e.startsWith("-",m+1)){H=d0,m+=2;continue}c.push(tnn(d0)),m++}if(z<m)return["",!1,0,!1];if(!c.length&&!p.length)return["$.",!1,e.length-o,!0];if(p.length===0&&c.length===1&&/^\\?.$/.test(c[0])&&!L){let d0=c[0].length===2?c[0].slice(-1):c[0];return[Jeu(d0),!1,z-o,!1]}let V="["+(L?"^":"")+hMi(c)+"]",X="["+(L?"":"^")+hMi(p)+"]";return[c.length&&p.length?"("+V+"|"+X+")":c.length?V:X,P,z-o,!0]};var kj0=(e,{windowsPathsNoEscape:t=!1}={})=>{return t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var Keu=new Set(["!","?","+","*","@"]),DMi=(e)=>Keu.has(e),zeu="(?!(?:^|/)\\.\\.?(?:$|/))",pmn="(?!\\.)",Weu=new Set(["[","."]),Ueu=new Set(["..","."]),Qeu=new Set("().*{}+?[]^$\\!"),Yeu=(e)=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),qjn="[^/]",yMi=qjn+"*?",EMi=qjn+"+?";class kD0{type;#e;#n;#t=!1;#i=[];#r;#a;#o;#s=!1;#c;#u;#p=!1;constructor(e,t,o={}){if(this.type=e,e)this.#n=!0;if(this.#r=t,this.#e=this.#r?this.#r.#e:this,this.#c=this.#e===this?o:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e==="!"&&!this.#e.#s)this.#o.push(this);this.#a=this.#r?this.#r.#i.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(let e of this.#i){if(typeof e==="string")continue;if(e.type||e.hasMagic)return this.#n=!0}return this.#n}toString(){if(this.#u!==void 0)return this.#u;if(!this.type)return this.#u=this.#i.map((e)=>String(e)).join("");else return this.#u=this.type+"("+this.#i.map((e)=>String(e)).join("|")+")"}#y(){if(this!==this.#e)throw new Error("should only call on root");if(this.#s)return this;this.toString(),this.#s=!0;let e;while(e=this.#o.pop()){if(e.type!=="!")continue;let t=e,o=t.#r;while(o){for(let c=t.#a+1;!o.type&&c<o.#i.length;c++)for(let p of e.#i){if(typeof p==="string")throw new Error("string part in extglob AST??");p.copyIn(o.#i[c])}t=o,o=t.#r}}return this}push(...e){for(let t of e){if(t==="")continue;if(typeof t!=="string"&&!(t instanceof kD0&&t.#r===this))throw new Error("invalid part: "+t);this.#i.push(t)}}toJSON(){let e=this.type===null?this.#i.slice().map((t)=>typeof t==="string"?t:t.toJSON()):[this.type,...this.#i.map((t)=>t.toJSON())];if(this.isStart()&&!this.type)e.unshift([]);if(this.isEnd()&&(this===this.#e||this.#e.#s&&this.#r?.type==="!"))e.push({});return e}isStart(){if(this.#e===this)return!0;if(!this.#r?.isStart())return!1;if(this.#a===0)return!0;let e=this.#r;for(let t=0;t<this.#a;t++){let o=e.#i[t];if(!(o instanceof kD0&&o.type==="!"))return!1}return!0}isEnd(){if(this.#e===this)return!0;if(this.#r?.type==="!")return!0;if(!this.#r?.isEnd())return!1;if(!this.type)return this.#r?.isEnd();let e=this.#r?this.#r.#i.length:0;return this.#a===e-1}copyIn(e){if(typeof e==="string")this.push(e);else this.push(e.clone(this))}clone(e){let t=new kD0(this.type,e);for(let o of this.#i)t.copyIn(o);return t}static#m(e,t,o,c){let p=!1,m=!1,T=-1,P=!1;if(t.type===null){let V=o,X="";while(V<e.length){let f0=e.charAt(V++);if(p||f0==="\\"){p=!p,X+=f0;continue}if(m){if(V===T+1){if(f0==="^"||f0==="!")P=!0}else if(f0==="]"&&!(V===T+2&&P))m=!1;X+=f0;continue}else if(f0==="["){m=!0,T=V,P=!1,X+=f0;continue}if(!c.noext&&DMi(f0)&&e.charAt(V)==="("){t.push(X),X="";let d0=new kD0(f0,t);V=kD0.#m(e,d0,V,c),t.push(d0);continue}X+=f0}return t.push(X),V}let I=o+1,L=new kD0(null,t),z=[],H="";while(I<e.length){let V=e.charAt(I++);if(p||V==="\\"){p=!p,H+=V;continue}if(m){if(I===T+1){if(V==="^"||V==="!")P=!0}else if(V==="]"&&!(I===T+2&&P))m=!1;H+=V;continue}else if(V==="["){m=!0,T=I,P=!1,H+=V;continue}if(DMi(V)&&e.charAt(I)==="("){L.push(H),H="";let X=new kD0(V,L);L.push(X),I=kD0.#m(e,X,I,c);continue}if(V==="|"){L.push(H),H="",z.push(L),L=new kD0(null,t);continue}if(V===")"){if(H===""&&t.#i.length===0)t.#p=!0;return L.push(H),H="",t.push(...z,L),I}H+=V}return t.type=null,t.#n=void 0,t.#i=[e.substring(o-1)],I}static fromGlob(e,t={}){let o=new kD0(null,void 0,t);return kD0.#m(e,o,0,t),o}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,o,c,p]=this.toRegExpSource();if(!(c||this.#n||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return o;let T=(this.#c.nocase?"i":"")+(p?"u":"");return Object.assign(new RegExp(`^${t}$`,T),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(e){let t=e??!!this.#c.dot;if(this.#e===this)this.#y();if(!this.type){let P=this.isStart()&&this.isEnd(),I=this.#i.map((V)=>{let[X,f0,d0,D0]=typeof V==="string"?kD0.#D(V,this.#n,P):V.toRegExpSource(e);return this.#n=this.#n||d0,this.#t=this.#t||D0,X}).join(""),L="";if(this.isStart()){if(typeof this.#i[0]==="string"){if(!(this.#i.length===1&&Ueu.has(this.#i[0]))){let X=Weu,f0=t&&X.has(I.charAt(0))||I.startsWith("\\.")&&X.has(I.charAt(2))||I.startsWith("\\.\\.")&&X.has(I.charAt(4)),d0=!t&&!e&&X.has(I.charAt(0));L=f0?zeu:d0?pmn:""}}}let z="";if(this.isEnd()&&this.#e.#s&&this.#r?.type==="!")z="(?:$|\\/)";return[L+I+z,kj0(I),this.#n=!!this.#n,this.#t]}let o=this.type==="*"||this.type==="+",c=this.type==="!"?"(?:(?!(?:":"(?:",p=this.#_(t);if(this.isStart()&&this.isEnd()&&!p&&this.type!=="!"){let P=this.toString();return this.#i=[P],this.type=null,this.#n=void 0,[P,kj0(this.toString()),!1,!1]}let m=!o||e||t||!pmn?"":this.#_(!0);if(m===p)m="";if(m)p=`(?:${p})(?:${m})*?`;let T="";if(this.type==="!"&&this.#p)T=(this.isStart()&&!t?pmn:"")+EMi;else{let P=this.type==="!"?"))"+(this.isStart()&&!t&&!e?pmn:"")+yMi+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&m?")":this.type==="*"&&m?")?":`)${this.type}`;T=c+p+P}return[T,kj0(p),this.#n=!!this.#n,this.#t]}#_(e){return this.#i.map((t)=>{if(typeof t==="string")throw new Error("string type in extglob ast??");let[o,c,p,m]=t.toRegExpSource(e);return this.#t=this.#t||m,o}).filter((t)=>!(this.isStart()&&this.isEnd())||!!t).join("|")}static#D(e,t,o=!1){let c=!1,p="",m=!1;for(let T=0;T<e.length;T++){let P=e.charAt(T);if(c){c=!1,p+=(Qeu.has(P)?"\\":"")+P;continue}if(P==="\\"){if(T===e.length-1)p+="\\\\";else c=!0;continue}if(P==="["){let[I,L,z,H]=xMi(e,T);if(z){p+=I,m=m||L,T+=z-1,t=t||H;continue}}if(P==="*"){if(o&&e==="*")p+=EMi;else p+=yMi;t=!0;continue}if(P==="?"){p+=qjn,t=!0;continue}p+=Yeu(P)}return[p,kj0(e),!!t,m]}}var AQe=(e,{windowsPathsNoEscape:t=!1}={})=>{return t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&")};var BT0=(e,t,o={})=>{if(nnn(t),!o.nocomment&&t.charAt(0)==="#")return!1;return new bQ0(t,o).match(e)},$eu=/^\*+([^+@!?\*\[\(]*)$/,Zeu=(e)=>(t)=>!t.startsWith(".")&&t.endsWith(e),Veu=(e)=>(t)=>t.endsWith(e),Heu=(e)=>{return e=e.toLowerCase(),(t)=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)},Geu=(e)=>{return e=e.toLowerCase(),(t)=>t.toLowerCase().endsWith(e)},Xeu=/^\*+\.\*+$/,Reu=(e)=>!e.startsWith(".")&&e.includes("."),jeu=(e)=>e!=="."&&e!==".."&&e.includes("."),enu=/^\.\*+$/,nnu=(e)=>e!=="."&&e!==".."&&e.startsWith("."),tnu=/^\*+$/,inu=(e)=>e.length!==0&&!e.startsWith("."),rnu=(e)=>e.length!==0&&e!=="."&&e!=="..",anu=/^\?+([^+@!?\*\[\(]*)?$/,onu=([e,t=""])=>{let o=FMi([e]);if(!t)return o;return t=t.toLowerCase(),(c)=>o(c)&&c.toLowerCase().endsWith(t)},unu=([e,t=""])=>{let o=SMi([e]);if(!t)return o;return t=t.toLowerCase(),(c)=>o(c)&&c.toLowerCase().endsWith(t)},snu=([e,t=""])=>{let o=SMi([e]);return!t?o:(c)=>o(c)&&c.endsWith(t)},cnu=([e,t=""])=>{let o=FMi([e]);return!t?o:(c)=>o(c)&&c.endsWith(t)},FMi=([e])=>{let t=e.length;return(o)=>o.length===t&&!o.startsWith(".")},SMi=([e])=>{let t=e.length;return(o)=>o.length===t&&o!=="."&&o!==".."},wMi=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",CMi={win32:{sep:"\\"},posix:{sep:"/"}},fnu=wMi==="win32"?CMi.win32.sep:CMi.posix.sep;BT0.sep=fnu;var ID0=Symbol("globstar **");BT0.GLOBSTAR=ID0;var lnu="[^/]",_nu=lnu+"*?",dnu="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",pnu="(?:(?!(?:\\/|^)\\.).)*?",vnu=(e,t={})=>(o)=>BT0(o,e,t);BT0.filter=vnu;var PQ0=(e,t={})=>Object.assign({},e,t),gnu=(e)=>{if(!e||typeof e!=="object"||!Object.keys(e).length)return BT0;let t=BT0;return Object.assign((c,p,m={})=>t(c,p,PQ0(e,m)),{Minimatch:class c extends t.Minimatch{constructor(p,m={}){super(p,PQ0(e,m))}static defaults(p){return t.defaults(PQ0(e,p)).Minimatch}},AST:class c extends t.AST{constructor(p,m,T={}){super(p,m,PQ0(e,T))}static fromGlob(p,m={}){return t.AST.fromGlob(p,PQ0(e,m))}},unescape:(c,p={})=>t.unescape(c,PQ0(e,p)),escape:(c,p={})=>t.escape(c,PQ0(e,p)),filter:(c,p={})=>t.filter(c,PQ0(e,p)),defaults:(c)=>t.defaults(PQ0(e,c)),makeRe:(c,p={})=>t.makeRe(c,PQ0(e,p)),braceExpand:(c,p={})=>t.braceExpand(c,PQ0(e,p)),match:(c,p,m={})=>t.match(c,p,PQ0(e,m)),sep:t.sep,GLOBSTAR:ID0})};BT0.defaults=gnu;var NMi=(e,t={})=>{if(nnn(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e))return[e];return AMi.default(e)};BT0.braceExpand=NMi;var mnu=(e,t={})=>new bQ0(e,t).makeRe();BT0.makeRe=mnu;var hnu=(e,t,o={})=>{let c=new bQ0(t,o);if(e=e.filter((p)=>c.match(p)),c.options.nonull&&!e.length)e.push(t);return e};BT0.match=hnu;var TMi=/[?*]|[+@!]\(.*?\)|\[|\]/,xnu=(e)=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class bQ0{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(e,t={}){if(nnn(e),t=t||{},this.options=t,this.pattern=e,this.platform=t.platform||wMi,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.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 e of this.set)for(let t of e)if(typeof t!=="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug)this.debug=(...p)=>console.error(...p);this.debug(this.pattern,this.globSet);let o=this.globSet.map((p)=>this.slashSplit(p));this.globParts=this.preprocess(o),this.debug(this.pattern,this.globParts);let c=this.globParts.map((p,m,T)=>{if(this.isWindows&&this.windowsNoMagicRoot){let P=p[0]===""&&p[1]===""&&(p[2]==="?"||!TMi.test(p[2]))&&!TMi.test(p[3]),I=/^[a-z]:/i.test(p[0]);if(P)return[...p.slice(0,4),...p.slice(4).map((L)=>this.parse(L))];else if(I)return[p[0],...p.slice(1).map((L)=>this.parse(L))]}return p.map((P)=>this.parse(P))});if(this.debug(this.pattern,c),this.set=c.filter((p)=>p.indexOf(!1)===-1),this.isWindows)for(let p=0;p<this.set.length;p++){let m=this.set[p];if(m[0]===""&&m[1]===""&&this.globParts[p][2]==="?"&&typeof m[3]==="string"&&/^[a-z]:$/i.test(m[3]))m[2]="?"}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar){for(let o=0;o<e.length;o++)for(let c=0;c<e[o].length;c++)if(e[o][c]==="**")e[o][c]="*"}let{optimizationLevel:t=1}=this.options;if(t>=2)e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e);else if(t>=1)e=this.levelOneOptimize(e);else e=this.adjascentGlobstarOptimize(e);return e}adjascentGlobstarOptimize(e){return e.map((t)=>{let o=-1;while((o=t.indexOf("**",o+1))!==-1){let c=o;while(t[c+1]==="**")c++;if(c!==o)t.splice(o,c-o)}return t})}levelOneOptimize(e){return e.map((t)=>{return t=t.reduce((o,c)=>{let p=o[o.length-1];if(c==="**"&&p==="**")return o;if(c===".."){if(p&&p!==".."&&p!=="."&&p!=="**")return o.pop(),o}return o.push(c),o},[]),t.length===0?[""]:t})}levelTwoFileOptimize(e){if(!Array.isArray(e))e=this.slashSplit(e);let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let c=1;c<e.length-1;c++){let p=e[c];if(c===1&&p===""&&e[0]==="")continue;if(p==="."||p==="")t=!0,e.splice(c,1),c--}if(e[0]==="."&&e.length===2&&(e[1]==="."||e[1]===""))t=!0,e.pop()}let o=0;while((o=e.indexOf("..",o+1))!==-1){let c=e[o-1];if(c&&c!=="."&&c!==".."&&c!=="**")t=!0,e.splice(o-1,2),o-=2}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let o of e){let c=-1;while((c=o.indexOf("**",c+1))!==-1){let m=c;while(o[m+1]==="**")m++;if(m>c)o.splice(c+1,m-c);let T=o[c+1],P=o[c+2],I=o[c+3];if(T!=="..")continue;if(!P||P==="."||P===".."||!I||I==="."||I==="..")continue;t=!0,o.splice(c,1);let L=o.slice(0);L[c]="**",e.push(L),c--}if(!this.preserveMultipleSlashes){for(let m=1;m<o.length-1;m++){let T=o[m];if(m===1&&T===""&&o[0]==="")continue;if(T==="."||T==="")t=!0,o.splice(m,1),m--}if(o[0]==="."&&o.length===2&&(o[1]==="."||o[1]===""))t=!0,o.pop()}let p=0;while((p=o.indexOf("..",p+1))!==-1){let m=o[p-1];if(m&&m!=="."&&m!==".."&&m!=="**"){t=!0;let P=p===1&&o[p+1]==="**"?["."]:[];if(o.splice(p-1,2,...P),o.length===0)o.push("");p-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let o=t+1;o<e.length;o++){let c=this.partsMatch(e[t],e[o],!this.preserveMultipleSlashes);if(c){e[t]=[],e[o]=c;break}}return e.filter((t)=>t.length)}partsMatch(e,t,o=!1){let c=0,p=0,m=[],T="";while(c<e.length&&p<t.length)if(e[c]===t[p])m.push(T==="b"?t[p]:e[c]),c++,p++;else if(o&&e[c]==="**"&&t[p]===e[c+1])m.push(e[c]),c++;else if(o&&t[p]==="**"&&e[c]===t[p+1])m.push(t[p]),p++;else if(e[c]==="*"&&t[p]&&(this.options.dot||!t[p].startsWith("."))&&t[p]!=="**"){if(T==="b")return!1;T="a",m.push(e[c]),c++,p++}else if(t[p]==="*"&&e[c]&&(this.options.dot||!e[c].startsWith("."))&&e[c]!=="**"){if(T==="a")return!1;T="b",m.push(t[p]),c++,p++}else return!1;return e.length===t.length&&m}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,o=0;for(let c=0;c<e.length&&e.charAt(c)==="!";c++)t=!t,o++;if(o)this.pattern=e.slice(o);this.negate=t}matchOne(e,t,o=!1){let c=this.options;if(this.isWindows){let f0=typeof e[0]==="string"&&/^[a-z]:$/i.test(e[0]),d0=!f0&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),D0=typeof t[0]==="string"&&/^[a-z]:$/i.test(t[0]),N0=!D0&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]==="string"&&/^[a-z]:$/i.test(t[3]),w0=d0?3:f0?0:void 0,W0=N0?3:D0?0:void 0;if(typeof w0==="number"&&typeof W0==="number"){let[Q0,fe]=[e[w0],t[W0]];if(Q0.toLowerCase()===fe.toLowerCase()){if(t[W0]=Q0,W0>w0)t=t.slice(W0);else if(w0>W0)e=e.slice(w0)}}}let{optimizationLevel:p=1}=this.options;if(p>=2)e=this.levelTwoFileOptimize(e);this.debug("matchOne",this,{file:e,pattern:t}),this.debug("matchOne",e.length,t.length);for(var m=0,T=0,P=e.length,I=t.length;m<P&&T<I;m++,T++){this.debug("matchOne loop");var L=t[T],z=e[m];if(this.debug(t,L,z),L===!1)return!1;if(L===ID0){this.debug("GLOBSTAR",[t,L,z]);var H=m,V=T+1;if(V===I){this.debug("** at the end");for(;m<P;m++)if(e[m]==="."||e[m]===".."||!c.dot&&e[m].charAt(0)===".")return!1;return!0}while(H<P){var X=e[H];if(this.debug(`
64937
64937
  globstar while`,e,H,t,V,X),this.matchOne(e.slice(H),t.slice(V),o))return this.debug("globstar found match!",H,P,X),!0;else{if(X==="."||X===".."||!c.dot&&X.charAt(0)==="."){this.debug("dot detected!",e,H,t,V);break}this.debug("globstar swallow a segment, and continue"),H++}}if(o){if(this.debug(`
64938
64938
  >>> no match, partial?`,e,H,t,V),H===P)return!0}return!1}let f0;if(typeof L==="string")f0=z===L,this.debug("string match",L,z,f0);else f0=L.test(z),this.debug("pattern match",L,z,f0);if(!f0)return!1}if(m===P&&T===I)return!0;else if(m===P)return o;else if(T===I)return m===P-1&&e[m]==="";else throw new Error("wtf?")}braceExpand(){return NMi(this.pattern,this.options)}parse(e){nnn(e);let t=this.options;if(e==="**")return ID0;if(e==="")return"";let o,c=null;if(o=e.match(tnu))c=t.dot?rnu:inu;else if(o=e.match($eu))c=(t.nocase?t.dot?Geu:Heu:t.dot?Veu:Zeu)(o[1]);else if(o=e.match(anu))c=(t.nocase?t.dot?unu:onu:t.dot?snu:cnu)(o);else if(o=e.match(Xeu))c=t.dot?jeu:Reu;else if(o=e.match(enu))c=nnu;let p=kD0.fromGlob(e,this.options).toMMPattern();if(c&&typeof p==="object")Reflect.defineProperty(p,"test",{value:c});return p}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,o=t.noglobstar?_nu:t.dot?dnu:pnu,c=new Set(t.nocase?["i"]:[]),p=e.map((P)=>{let I=P.map((L)=>{if(L instanceof RegExp)for(let z of L.flags.split(""))c.add(z);return typeof L==="string"?xnu(L):L===ID0?ID0:L._src});return I.forEach((L,z)=>{let H=I[z+1],V=I[z-1];if(L!==ID0||V===ID0)return;if(V===void 0)if(H!==void 0&&H!==ID0)I[z+1]="(?:\\/|"+o+"\\/)?"+H;else I[z]=o;else if(H===void 0)I[z-1]=V+"(?:\\/|"+o+")?";else if(H!==ID0)I[z-1]=V+"(?:\\/|\\/"+o+"\\/)"+H,I[z+1]=ID0}),I.filter((L)=>L!==ID0).join("/")}).join("|"),[m,T]=e.length>1?["(?:",")"]:["",""];if(p="^"+m+p+T+"$",this.negate)p="^(?!"+p+").+$";try{this.regexp=new RegExp(p,[...c].join(""))}catch(P){this.regexp=!1}return this.regexp}slashSplit(e){if(this.preserveMultipleSlashes)return e.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(e))return["",...e.split(/\/+/)];else return e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&t)return!0;let o=this.options;if(this.isWindows)e=e.split("\\").join("/");let c=this.slashSplit(e);this.debug(this.pattern,"split",c);let p=this.set;this.debug(this.pattern,"set",p);let m=c[c.length-1];if(!m)for(let T=c.length-2;!m&&T>=0;T--)m=c[T];for(let T=0;T<p.length;T++){let P=p[T],I=c;if(o.matchBase&&P.length===1)I=[m];if(this.matchOne(I,P,t)){if(o.flipNegate)return!0;return!this.negate}}if(o.flipNegate)return!1;return this.negate}static defaults(e){return BT0.defaults(e).Minimatch}}BT0.AST=kD0;BT0.Minimatch=bQ0;BT0.escape=AQe;BT0.unescape=kj0;import{fileURLToPath as Xnu}from"node:url";var FQe=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,bMi=new Set,Jjn=typeof process==="object"&&!!process?process:{},OMi=(e,t,o,c)=>{typeof Jjn.emitWarning==="function"?Jjn.emitWarning(e,t,o,c):console.error(`[${o}] ${t}: ${e}`)},vmn=globalThis.AbortController,PMi=globalThis.AbortSignal;if(typeof vmn==="undefined"){PMi=class o{onabort;_onabort=[];reason;aborted=!1;addEventListener(c,p){this._onabort.push(p)}},vmn=class o{constructor(){t()}signal=new PMi;abort(c){if(this.signal.aborted)return;this.signal.reason=c,this.signal.aborted=!0;for(let p of this.signal._onabort)p(c);this.signal.onabort?.(c)}};let e=Jjn.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{if(!e)return;e=!1,OMi("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)}}var Dnu=(e)=>!bMi.has(e),bFs=Symbol("type"),dCe=(e)=>e&&e===Math.floor(e)&&e>0&&isFinite(e),kMi=(e)=>!dCe(e)?null:e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?inn:null;class inn extends Array{constructor(e){super(e);this.fill(0)}}class SQe{heap;length;static#e=!1;static create(e){let t=kMi(e);if(!t)return[];SQe.#e=!0;let o=new SQe(e,t);return SQe.#e=!1,o}constructor(e,t){if(!SQe.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class rnn{#e;#n;#t;#i;#r;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#o;#s;#c;#u;#p;#y;#m;#_;#D;#d;#h;#E;#A;#v;#F;#l;static unsafeExposeInternals(e){return{starts:e.#E,ttls:e.#A,sizes:e.#h,keyMap:e.#s,keyList:e.#c,valList:e.#u,next:e.#p,prev:e.#y,get head(){return e.#m},get tail(){return e.#_},free:e.#D,isBackgroundFetch:(t)=>e.#x(t),backgroundFetch:(t,o,c,p)=>e.#I(t,o,c,p),moveToTail:(t)=>e.#k(t),indexes:(t)=>e.#P(t),rindexes:(t)=>e.#b(t),isStale:(t)=>e.#T(t)}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#o}get size(){return this.#a}get fetchMethod(){return this.#r}get dispose(){return this.#t}get disposeAfter(){return this.#i}constructor(e){let{max:t=0,ttl:o,ttlResolution:c=1,ttlAutopurge:p,updateAgeOnGet:m,updateAgeOnHas:T,allowStale:P,dispose:I,disposeAfter:L,noDisposeOnSet:z,noUpdateTTL:H,maxSize:V=0,maxEntrySize:X=0,sizeCalculation:f0,fetchMethod:d0,noDeleteOnFetchRejection:D0,noDeleteOnStaleGet:N0,allowStaleOnFetchRejection:w0,allowStaleOnFetchAbort:W0,ignoreFetchAbort:Q0}=e;if(t!==0&&!dCe(t))throw new TypeError("max option must be a nonnegative integer");let fe=t?kMi(t):Array;if(!fe)throw new Error("invalid max value: "+t);if(this.#e=t,this.#n=V,this.maxEntrySize=X||this.#n,this.sizeCalculation=f0,this.sizeCalculation){if(!this.#n&&!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(d0!==void 0&&typeof d0!=="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#r=d0,this.#F=!!d0,this.#s=new Map,this.#c=new Array(t).fill(void 0),this.#u=new Array(t).fill(void 0),this.#p=new fe(t),this.#y=new fe(t),this.#m=0,this.#_=0,this.#D=SQe.create(t),this.#a=0,this.#o=0,typeof I==="function")this.#t=I;if(typeof L==="function")this.#i=L,this.#d=[];else this.#i=void 0,this.#d=void 0;if(this.#v=!!this.#t,this.#l=!!this.#i,this.noDisposeOnSet=!!z,this.noUpdateTTL=!!H,this.noDeleteOnFetchRejection=!!D0,this.allowStaleOnFetchRejection=!!w0,this.allowStaleOnFetchAbort=!!W0,this.ignoreFetchAbort=!!Q0,this.maxEntrySize!==0){if(this.#n!==0){if(!dCe(this.#n))throw new TypeError("maxSize must be a positive integer if specified")}if(!dCe(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#N()}if(this.allowStale=!!P,this.noDeleteOnStaleGet=!!N0,this.updateAgeOnGet=!!m,this.updateAgeOnHas=!!T,this.ttlResolution=dCe(c)||c===0?c:1,this.ttlAutopurge=!!p,this.ttl=o||0,this.ttl){if(!dCe(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#g()}if(this.#e===0&&this.ttl===0&&this.#n===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){if(Dnu("LRU_CACHE_UNBOUNDED"))bMi.add("LRU_CACHE_UNBOUNDED"),OMi("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",rnn)}}getRemainingTTL(e){return this.#s.has(e)?1/0:0}#g(){let e=new inn(this.#e),t=new inn(this.#e);this.#A=e,this.#E=t,this.#f=(p,m,T=FQe.now())=>{if(t[p]=m!==0?T:0,e[p]=m,m!==0&&this.ttlAutopurge){let P=setTimeout(()=>{if(this.#T(p))this.delete(this.#c[p])},m+1);if(P.unref)P.unref()}},this.#w=(p)=>{t[p]=e[p]!==0?FQe.now():0},this.#S=(p,m)=>{if(e[m]){let T=e[m],P=t[m];if(!T||!P)return;p.ttl=T,p.start=P,p.now=o||c();let I=p.now-P;p.remainingTTL=T-I}};let o=0,c=()=>{let p=FQe.now();if(this.ttlResolution>0){o=p;let m=setTimeout(()=>o=0,this.ttlResolution);if(m.unref)m.unref()}return p};this.getRemainingTTL=(p)=>{let m=this.#s.get(p);if(m===void 0)return 0;let T=e[m],P=t[m];if(!T||!P)return 1/0;let I=(o||c())-P;return T-I},this.#T=(p)=>{let m=t[p],T=e[p];return!!T&&!!m&&(o||c())-m>T}}#w=()=>{};#S=()=>{};#f=()=>{};#T=()=>!1;#N(){let e=new inn(this.#e);this.#o=0,this.#h=e,this.#C=(t)=>{this.#o-=e[t],e[t]=0},this.#M=(t,o,c,p)=>{if(this.#x(o))return 0;if(!dCe(c))if(p){if(typeof p!=="function")throw new TypeError("sizeCalculation must be a function");if(c=p(o,t),!dCe(c))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 c},this.#B=(t,o,c)=>{if(e[t]=o,this.#n){let p=this.#n-e[t];while(this.#o>p)this.#O(!0)}if(this.#o+=e[t],c)c.entrySize=o,c.totalCalculatedSize=this.#o}}#C=(e)=>{};#B=(e,t,o)=>{};#M=(e,t,o,c)=>{if(o||c)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#P({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#_;;){if(!this.#L(t))break;if(e||!this.#T(t))yield t;if(t===this.#m)break;else t=this.#y[t]}}*#b({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#m;;){if(!this.#L(t))break;if(e||!this.#T(t))yield t;if(t===this.#_)break;else t=this.#p[t]}}#L(e){return e!==void 0&&this.#s.get(this.#c[e])===e}*entries(){for(let e of this.#P())if(this.#u[e]!==void 0&&this.#c[e]!==void 0&&!this.#x(this.#u[e]))yield[this.#c[e],this.#u[e]]}*rentries(){for(let e of this.#b())if(this.#u[e]!==void 0&&this.#c[e]!==void 0&&!this.#x(this.#u[e]))yield[this.#c[e],this.#u[e]]}*keys(){for(let e of this.#P()){let t=this.#c[e];if(t!==void 0&&!this.#x(this.#u[e]))yield t}}*rkeys(){for(let e of this.#b()){let t=this.#c[e];if(t!==void 0&&!this.#x(this.#u[e]))yield t}}*values(){for(let e of this.#P())if(this.#u[e]!==void 0&&!this.#x(this.#u[e]))yield this.#u[e]}*rvalues(){for(let e of this.#b())if(this.#u[e]!==void 0&&!this.#x(this.#u[e]))yield this.#u[e]}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let o of this.#P()){let c=this.#u[o],p=this.#x(c)?c.__staleWhileFetching:c;if(p===void 0)continue;if(e(p,this.#c[o],this))return this.get(this.#c[o],t)}}forEach(e,t=this){for(let o of this.#P()){let c=this.#u[o],p=this.#x(c)?c.__staleWhileFetching:c;if(p===void 0)continue;e.call(t,p,this.#c[o],this)}}rforEach(e,t=this){for(let o of this.#b()){let c=this.#u[o],p=this.#x(c)?c.__staleWhileFetching:c;if(p===void 0)continue;e.call(t,p,this.#c[o],this)}}purgeStale(){let e=!1;for(let t of this.#b({allowStale:!0}))if(this.#T(t))this.delete(this.#c[t]),e=!0;return e}info(e){let t=this.#s.get(e);if(t===void 0)return;let o=this.#u[t],c=this.#x(o)?o.__staleWhileFetching:o;if(c===void 0)return;let p={value:c};if(this.#A&&this.#E){let m=this.#A[t],T=this.#E[t];if(m&&T){let P=m-(FQe.now()-T);p.ttl=P,p.start=Date.now()}}if(this.#h)p.size=this.#h[t];return p}dump(){let e=[];for(let t of this.#P({allowStale:!0})){let o=this.#c[t],c=this.#u[t],p=this.#x(c)?c.__staleWhileFetching:c;if(p===void 0||o===void 0)continue;let m={value:p};if(this.#A&&this.#E){m.ttl=this.#A[t];let T=FQe.now()-this.#E[t];m.start=Math.floor(Date.now()-T)}if(this.#h)m.size=this.#h[t];e.unshift([o,m])}return e}load(e){this.clear();for(let[t,o]of e){if(o.start){let c=Date.now()-o.start;o.start=FQe.now()-c}this.set(t,o.value,o)}}set(e,t,o={}){if(t===void 0)return this.delete(e),this;let{ttl:c=this.ttl,start:p,noDisposeOnSet:m=this.noDisposeOnSet,sizeCalculation:T=this.sizeCalculation,status:P}=o,{noUpdateTTL:I=this.noUpdateTTL}=o,L=this.#M(e,t,o.size||0,T);if(this.maxEntrySize&&L>this.maxEntrySize){if(P)P.set="miss",P.maxEntrySizeExceeded=!0;return this.delete(e),this}let z=this.#a===0?void 0:this.#s.get(e);if(z===void 0){if(z=this.#a===0?this.#_:this.#D.length!==0?this.#D.pop():this.#a===this.#e?this.#O(!1):this.#a,this.#c[z]=e,this.#u[z]=t,this.#s.set(e,z),this.#p[this.#_]=z,this.#y[z]=this.#_,this.#_=z,this.#a++,this.#B(z,L,P),P)P.set="add";I=!1}else{this.#k(z);let H=this.#u[z];if(t!==H){if(this.#F&&this.#x(H)){H.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:V}=H;if(V!==void 0&&!m){if(this.#v)this.#t?.(V,e,"set");if(this.#l)this.#d?.push([V,e,"set"])}}else if(!m){if(this.#v)this.#t?.(H,e,"set");if(this.#l)this.#d?.push([H,e,"set"])}if(this.#C(z),this.#B(z,L,P),this.#u[z]=t,P){P.set="replace";let V=H&&this.#x(H)?H.__staleWhileFetching:H;if(V!==void 0)P.oldValue=V}}else if(P)P.set="update"}if(c!==0&&!this.#A)this.#g();if(this.#A){if(!I)this.#f(z,c,p);if(P)this.#S(P,z)}if(!m&&this.#l&&this.#d){let H=this.#d,V;while(V=H?.shift())this.#i?.(...V)}return this}pop(){try{while(this.#a){let e=this.#u[this.#m];if(this.#O(!0),this.#x(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#l&&this.#d){let e=this.#d,t;while(t=e?.shift())this.#i?.(...t)}}}#O(e){let t=this.#m,o=this.#c[t],c=this.#u[t];if(this.#F&&this.#x(c))c.__abortController.abort(new Error("evicted"));else if(this.#v||this.#l){if(this.#v)this.#t?.(c,o,"evict");if(this.#l)this.#d?.push([c,o,"evict"])}if(this.#C(t),e)this.#c[t]=void 0,this.#u[t]=void 0,this.#D.push(t);if(this.#a===1)this.#m=this.#_=0,this.#D.length=0;else this.#m=this.#p[t];return this.#s.delete(o),this.#a--,t}has(e,t={}){let{updateAgeOnHas:o=this.updateAgeOnHas,status:c}=t,p=this.#s.get(e);if(p!==void 0){let m=this.#u[p];if(this.#x(m)&&m.__staleWhileFetching===void 0)return!1;if(!this.#T(p)){if(o)this.#w(p);if(c)c.has="hit",this.#S(c,p);return!0}else if(c)c.has="stale",this.#S(c,p)}else if(c)c.has="miss";return!1}peek(e,t={}){let{allowStale:o=this.allowStale}=t,c=this.#s.get(e);if(c===void 0||!o&&this.#T(c))return;let p=this.#u[c];return this.#x(p)?p.__staleWhileFetching:p}#I(e,t,o,c){let p=t===void 0?void 0:this.#u[t];if(this.#x(p))return p;let m=new vmn,{signal:T}=o;T?.addEventListener("abort",()=>m.abort(T.reason),{signal:m.signal});let P={signal:m.signal,options:o,context:c},I=(f0,d0=!1)=>{let{aborted:D0}=m.signal,N0=o.ignoreFetchAbort&&f0!==void 0;if(o.status)if(D0&&!d0){if(o.status.fetchAborted=!0,o.status.fetchError=m.signal.reason,N0)o.status.fetchAbortIgnored=!0}else o.status.fetchResolved=!0;if(D0&&!N0&&!d0)return z(m.signal.reason);let w0=V;if(this.#u[t]===V)if(f0===void 0)if(w0.__staleWhileFetching)this.#u[t]=w0.__staleWhileFetching;else this.delete(e);else{if(o.status)o.status.fetchUpdated=!0;this.set(e,f0,P.options)}return f0},L=(f0)=>{if(o.status)o.status.fetchRejected=!0,o.status.fetchError=f0;return z(f0)},z=(f0)=>{let{aborted:d0}=m.signal,D0=d0&&o.allowStaleOnFetchAbort,N0=D0||o.allowStaleOnFetchRejection,w0=N0||o.noDeleteOnFetchRejection,W0=V;if(this.#u[t]===V){if(!w0||W0.__staleWhileFetching===void 0)this.delete(e);else if(!D0)this.#u[t]=W0.__staleWhileFetching}if(N0){if(o.status&&W0.__staleWhileFetching!==void 0)o.status.returnedStale=!0;return W0.__staleWhileFetching}else if(W0.__returned===W0)throw f0},H=(f0,d0)=>{let D0=this.#r?.(e,p,P);if(D0&&D0 instanceof Promise)D0.then((N0)=>f0(N0===void 0?void 0:N0),d0);m.signal.addEventListener("abort",()=>{if(!o.ignoreFetchAbort||o.allowStaleOnFetchAbort){if(f0(void 0),o.allowStaleOnFetchAbort)f0=(N0)=>I(N0,!0)}})};if(o.status)o.status.fetchDispatched=!0;let V=new Promise(H).then(I,L),X=Object.assign(V,{__abortController:m,__staleWhileFetching:p,__returned:void 0});if(t===void 0)this.set(e,X,{...P.options,status:void 0}),t=this.#s.get(e);else this.#u[t]=X;return X}#x(e){if(!this.#F)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof vmn}async fetch(e,t={}){let{allowStale:o=this.allowStale,updateAgeOnGet:c=this.updateAgeOnGet,noDeleteOnStaleGet:p=this.noDeleteOnStaleGet,ttl:m=this.ttl,noDisposeOnSet:T=this.noDisposeOnSet,size:P=0,sizeCalculation:I=this.sizeCalculation,noUpdateTTL:L=this.noUpdateTTL,noDeleteOnFetchRejection:z=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:H=this.allowStaleOnFetchRejection,ignoreFetchAbort:V=this.ignoreFetchAbort,allowStaleOnFetchAbort:X=this.allowStaleOnFetchAbort,context:f0,forceRefresh:d0=!1,status:D0,signal:N0}=t;if(!this.#F){if(D0)D0.fetch="get";return this.get(e,{allowStale:o,updateAgeOnGet:c,noDeleteOnStaleGet:p,status:D0})}let w0={allowStale:o,updateAgeOnGet:c,noDeleteOnStaleGet:p,ttl:m,noDisposeOnSet:T,size:P,sizeCalculation:I,noUpdateTTL:L,noDeleteOnFetchRejection:z,allowStaleOnFetchRejection:H,allowStaleOnFetchAbort:X,ignoreFetchAbort:V,status:D0,signal:N0},W0=this.#s.get(e);if(W0===void 0){if(D0)D0.fetch="miss";let Q0=this.#I(e,W0,w0,f0);return Q0.__returned=Q0}else{let Q0=this.#u[W0];if(this.#x(Q0)){let he=o&&Q0.__staleWhileFetching!==void 0;if(D0){if(D0.fetch="inflight",he)D0.returnedStale=!0}return he?Q0.__staleWhileFetching:Q0.__returned=Q0}let fe=this.#T(W0);if(!d0&&!fe){if(D0)D0.fetch="hit";if(this.#k(W0),c)this.#w(W0);if(D0)this.#S(D0,W0);return Q0}let nn=this.#I(e,W0,w0,f0),Ee=nn.__staleWhileFetching!==void 0&&o;if(D0){if(D0.fetch=fe?"stale":"refresh",Ee&&fe)D0.returnedStale=!0}return Ee?nn.__staleWhileFetching:nn.__returned=nn}}get(e,t={}){let{allowStale:o=this.allowStale,updateAgeOnGet:c=this.updateAgeOnGet,noDeleteOnStaleGet:p=this.noDeleteOnStaleGet,status:m}=t,T=this.#s.get(e);if(T!==void 0){let P=this.#u[T],I=this.#x(P);if(m)this.#S(m,T);if(this.#T(T)){if(m)m.get="stale";if(!I){if(!p)this.delete(e);if(m&&o)m.returnedStale=!0;return o?P:void 0}else{if(m&&o&&P.__staleWhileFetching!==void 0)m.returnedStale=!0;return o?P.__staleWhileFetching:void 0}}else{if(m)m.get="hit";if(I)return P.__staleWhileFetching;if(this.#k(T),c)this.#w(T);return P}}else if(m)m.get="miss"}#q(e,t){this.#y[t]=e,this.#p[e]=t}#k(e){if(e!==this.#_){if(e===this.#m)this.#m=this.#p[e];else this.#q(this.#y[e],this.#p[e]);this.#q(this.#_,e),this.#_=e}}delete(e){let t=!1;if(this.#a!==0){let o=this.#s.get(e);if(o!==void 0)if(t=!0,this.#a===1)this.clear();else{this.#C(o);let c=this.#u[o];if(this.#x(c))c.__abortController.abort(new Error("deleted"));else if(this.#v||this.#l){if(this.#v)this.#t?.(c,e,"delete");if(this.#l)this.#d?.push([c,e,"delete"])}if(this.#s.delete(e),this.#c[o]=void 0,this.#u[o]=void 0,o===this.#_)this.#_=this.#y[o];else if(o===this.#m)this.#m=this.#p[o];else{let p=this.#y[o];this.#p[p]=this.#p[o];let m=this.#p[o];this.#y[m]=this.#y[o]}this.#a--,this.#D.push(o)}}if(this.#l&&this.#d?.length){let o=this.#d,c;while(c=o?.shift())this.#i?.(...c)}return t}clear(){for(let e of this.#b({allowStale:!0})){let t=this.#u[e];if(this.#x(t))t.__abortController.abort(new Error("deleted"));else{let o=this.#c[e];if(this.#v)this.#t?.(t,o,"delete");if(this.#l)this.#d?.push([t,o,"delete"])}}if(this.#s.clear(),this.#u.fill(void 0),this.#c.fill(void 0),this.#A&&this.#E)this.#A.fill(0),this.#E.fill(0);if(this.#h)this.#h.fill(0);if(this.#m=0,this.#_=0,this.#D.length=0,this.#o=0,this.#a=0,this.#l&&this.#d){let e=this.#d,t;while(t=e?.shift())this.#i?.(...t)}}}import{posix as bnu,win32 as Hjn}from"node:path";import{fileURLToPath as Onu}from"node:url";import{lstatSync as knu,readdir as Inu,readdirSync as Bnu,readlinkSync as Mnu,realpathSync as Lnu}from"fs";import*as qnu from"node:fs";import{lstat as Knu,readdir as znu,readlink as Wnu,realpath as Unu}from"node:fs/promises";import{EventEmitter as Yjn}from"node:events";import qMi from"node:stream";import{StringDecoder as ynu}from"node:string_decoder";var IMi=typeof process==="object"&&process?process:{stdout:null,stderr:null},Enu=(e)=>!!e&&typeof e==="object"&&(e instanceof wLe||e instanceof qMi||Cnu(e)||Tnu(e)),Cnu=(e)=>!!e&&typeof e==="object"&&e instanceof Yjn&&typeof e.pipe==="function"&&e.pipe!==qMi.Writable.prototype.pipe,Tnu=(e)=>!!e&&typeof e==="object"&&e instanceof Yjn&&typeof e.write==="function"&&typeof e.end==="function",Rge=Symbol("EOF"),jge=Symbol("maybeEmitEnd"),pCe=Symbol("emittedEnd"),gmn=Symbol("emittingEnd"),ann=Symbol("emittedError"),mmn=Symbol("closed"),BMi=Symbol("read"),hmn=Symbol("flush"),MMi=Symbol("flushChunk"),Ij0=Symbol("encoding"),wQe=Symbol("decoder"),X40=Symbol("flowing"),onn=Symbol("paused"),NQe=Symbol("resume"),R40=Symbol("buffer"),MT0=Symbol("pipes"),j40=Symbol("bufferLength"),Kjn=Symbol("bufferPush"),xmn=Symbol("bufferShift"),p80=Symbol("objectMode"),b_0=Symbol("destroyed"),zjn=Symbol("error"),Wjn=Symbol("emitData"),LMi=Symbol("emitEnd"),Ujn=Symbol("emitEnd2"),Sse=Symbol("async"),Qjn=Symbol("abort"),Dmn=Symbol("aborted"),unn=Symbol("signal"),SLe=Symbol("dataListeners"),HM0=Symbol("discarded"),snn=(e)=>Promise.resolve().then(e),Anu=(e)=>e(),Fnu=(e)=>e==="end"||e==="finish"||e==="prefinish",Snu=(e)=>e instanceof ArrayBuffer||!!e&&typeof e==="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,wnu=(e)=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e);class $jn{src;dest;opts;ondrain;constructor(e,t,o){this.src=e,this.dest=t,this.opts=o,this.ondrain=()=>e[NQe](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class JMi extends $jn{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,o){super(e,t,o);this.proxyErrors=(c)=>t.emit("error",c),e.on("error",this.proxyErrors)}}var Nnu=(e)=>!!e.objectMode,Pnu=(e)=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer";class wLe extends Yjn{[X40]=!1;[onn]=!1;[MT0]=[];[R40]=[];[p80];[Ij0];[Sse];[wQe];[Rge]=!1;[pCe]=!1;[gmn]=!1;[mmn]=!1;[ann]=null;[j40]=0;[b_0]=!1;[unn];[Dmn]=!1;[SLe]=0;[HM0]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};super();if(t.objectMode&&typeof t.encoding==="string")throw new TypeError("Encoding and objectMode may not be used together");if(Nnu(t))this[p80]=!0,this[Ij0]=null;else if(Pnu(t))this[Ij0]=t.encoding,this[p80]=!1;else this[p80]=!1,this[Ij0]=null;if(this[Sse]=!!t.async,this[wQe]=this[Ij0]?new ynu(this[Ij0]):null,t&&t.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[R40]});if(t&&t.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[MT0]});let{signal:o}=t;if(o)if(this[unn]=o,o.aborted)this[Qjn]();else o.addEventListener("abort",()=>this[Qjn]())}get bufferLength(){return this[j40]}get encoding(){return this[Ij0]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[p80]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get["async"](){return this[Sse]}set["async"](e){this[Sse]=this[Sse]||!!e}[Qjn](){this[Dmn]=!0,this.emit("abort",this[unn]?.reason),this.destroy(this[unn]?.reason)}get aborted(){return this[Dmn]}set aborted(e){}write(e,t,o){if(this[Dmn])return!1;if(this[Rge])throw new Error("write after end");if(this[b_0])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof t==="function")o=t,t="utf8";if(!t)t="utf8";let c=this[Sse]?snn:Anu;if(!this[p80]&&!Buffer.isBuffer(e)){if(wnu(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(Snu(e))e=Buffer.from(e);else if(typeof e!=="string")throw new Error("Non-contiguous data written to non-objectMode stream")}if(this[p80]){if(this[X40]&&this[j40]!==0)this[hmn](!0);if(this[X40])this.emit("data",e);else this[Kjn](e);if(this[j40]!==0)this.emit("readable");if(o)c(o);return this[X40]}if(!e.length){if(this[j40]!==0)this.emit("readable");if(o)c(o);return this[X40]}if(typeof e==="string"&&!(t===this[Ij0]&&!this[wQe]?.lastNeed))e=Buffer.from(e,t);if(Buffer.isBuffer(e)&&this[Ij0])e=this[wQe].write(e);if(this[X40]&&this[j40]!==0)this[hmn](!0);if(this[X40])this.emit("data",e);else this[Kjn](e);if(this[j40]!==0)this.emit("readable");if(o)c(o);return this[X40]}read(e){if(this[b_0])return null;if(this[HM0]=!1,this[j40]===0||e===0||e&&e>this[j40])return this[jge](),null;if(this[p80])e=null;if(this[R40].length>1&&!this[p80])this[R40]=[this[Ij0]?this[R40].join(""):Buffer.concat(this[R40],this[j40])];let t=this[BMi](e||null,this[R40][0]);return this[jge](),t}[BMi](e,t){if(this[p80])this[xmn]();else{let o=t;if(e===o.length||e===null)this[xmn]();else if(typeof o==="string")this[R40][0]=o.slice(e),t=o.slice(0,e),this[j40]-=e;else this[R40][0]=o.subarray(e),t=o.subarray(0,e),this[j40]-=e}if(this.emit("data",t),!this[R40].length&&!this[Rge])this.emit("drain");return t}end(e,t,o){if(typeof e==="function")o=e,e=void 0;if(typeof t==="function")o=t,t="utf8";if(e!==void 0)this.write(e,t);if(o)this.once("end",o);if(this[Rge]=!0,this.writable=!1,this[X40]||!this[onn])this[jge]();return this}[NQe](){if(this[b_0])return;if(!this[SLe]&&!this[MT0].length)this[HM0]=!0;if(this[onn]=!1,this[X40]=!0,this.emit("resume"),this[R40].length)this[hmn]();else if(this[Rge])this[jge]();else this.emit("drain")}resume(){return this[NQe]()}pause(){this[X40]=!1,this[onn]=!0,this[HM0]=!1}get destroyed(){return this[b_0]}get flowing(){return this[X40]}get paused(){return this[onn]}[Kjn](e){if(this[p80])this[j40]+=1;else this[j40]+=e.length;this[R40].push(e)}[xmn](){if(this[p80])this[j40]-=1;else this[j40]-=this[R40][0].length;return this[R40].shift()}[hmn](e=!1){do;while(this[MMi](this[xmn]())&&this[R40].length);if(!e&&!this[R40].length&&!this[Rge])this.emit("drain")}[MMi](e){return this.emit("data",e),this[X40]}pipe(e,t){if(this[b_0])return e;this[HM0]=!1;let o=this[pCe];if(t=t||{},e===IMi.stdout||e===IMi.stderr)t.end=!1;else t.end=t.end!==!1;if(t.proxyErrors=!!t.proxyErrors,o){if(t.end)e.end()}else if(this[MT0].push(!t.proxyErrors?new $jn(this,e,t):new JMi(this,e,t)),this[Sse])snn(()=>this[NQe]());else this[NQe]();return e}unpipe(e){let t=this[MT0].find((o)=>o.dest===e);if(t){if(this[MT0].length===1){if(this[X40]&&this[SLe]===0)this[X40]=!1;this[MT0]=[]}else this[MT0].splice(this[MT0].indexOf(t),1);t.unpipe()}}addListener(e,t){return this.on(e,t)}on(e,t){let o=super.on(e,t);if(e==="data"){if(this[HM0]=!1,this[SLe]++,!this[MT0].length&&!this[X40])this[NQe]()}else if(e==="readable"&&this[j40]!==0)super.emit("readable");else if(Fnu(e)&&this[pCe])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[ann]){let c=t;if(this[Sse])snn(()=>c.call(this,this[ann]));else c.call(this,this[ann])}return o}removeListener(e,t){return this.off(e,t)}off(e,t){let o=super.off(e,t);if(e==="data"){if(this[SLe]=this.listeners("data").length,this[SLe]===0&&!this[HM0]&&!this[MT0].length)this[X40]=!1}return o}removeAllListeners(e){let t=super.removeAllListeners(e);if(e==="data"||e===void 0){if(this[SLe]=0,!this[HM0]&&!this[MT0].length)this[X40]=!1}return t}get emittedEnd(){return this[pCe]}[jge](){if(!this[gmn]&&!this[pCe]&&!this[b_0]&&this[R40].length===0&&this[Rge]){if(this[gmn]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[mmn])this.emit("close");this[gmn]=!1}}emit(e,...t){let o=t[0];if(e!=="error"&&e!=="close"&&e!==b_0&&this[b_0])return!1;else if(e==="data")return!this[p80]&&!o?!1:this[Sse]?(snn(()=>this[Wjn](o)),!0):this[Wjn](o);else if(e==="end")return this[LMi]();else if(e==="close"){if(this[mmn]=!0,!this[pCe]&&!this[b_0])return!1;let p=super.emit("close");return this.removeAllListeners("close"),p}else if(e==="error"){this[ann]=o,super.emit(zjn,o);let p=!this[unn]||this.listeners("error").length?super.emit("error",o):!1;return this[jge](),p}else if(e==="resume"){let p=super.emit("resume");return this[jge](),p}else if(e==="finish"||e==="prefinish"){let p=super.emit(e);return this.removeAllListeners(e),p}let c=super.emit(e,...t);return this[jge](),c}[Wjn](e){for(let o of this[MT0])if(o.dest.write(e)===!1)this.pause();let t=this[HM0]?!1:super.emit("data",e);return this[jge](),t}[LMi](){if(this[pCe])return!1;return this[pCe]=!0,this.readable=!1,this[Sse]?(snn(()=>this[Ujn]()),!0):this[Ujn]()}[Ujn](){if(this[wQe]){let t=this[wQe].end();if(t){for(let o of this[MT0])o.dest.write(t);if(!this[HM0])super.emit("data",t)}}for(let t of this[MT0])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});if(!this[p80])e.dataLength=0;let t=this.promise();return this.on("data",(o)=>{if(e.push(o),!this[p80])e.dataLength+=o.length}),await t,e}async concat(){if(this[p80])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Ij0]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(b_0,()=>t(new Error("stream destroyed"))),this.on("error",(o)=>t(o)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[HM0]=!1;let e=!1,t=async()=>{return this.pause(),e=!0,{value:void 0,done:!0}};return{next:()=>{if(e)return t();let c=this.read();if(c!==null)return Promise.resolve({done:!1,value:c});if(this[Rge])return t();let p,m,T=(z)=>{this.off("data",P),this.off("end",I),this.off(b_0,L),t(),m(z)},P=(z)=>{this.off("error",T),this.off("end",I),this.off(b_0,L),this.pause(),p({value:z,done:!!this[Rge]})},I=()=>{this.off("error",T),this.off("data",P),this.off(b_0,L),t(),p({done:!0,value:void 0})},L=()=>T(new Error("stream destroyed"));return new Promise((z,H)=>{m=H,p=z,this.once(b_0,L),this.once("error",T),this.once("end",I),this.once("data",P)})},throw:t,return:t,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[HM0]=!1;let e=!1,t=()=>{return this.pause(),this.off(zjn,t),this.off(b_0,t),this.off("end",t),e=!0,{done:!0,value:void 0}},o=()=>{if(e)return t();let c=this.read();return c===null?t():{done:!1,value:c}};return this.once("end",t),this.once(zjn,t),this.once(b_0,t),{next:o,throw:t,return:t,[Symbol.iterator](){return this}}}destroy(e){if(this[b_0]){if(e)this.emit("error",e);else this.emit(b_0);return this}this[b_0]=!0,this[HM0]=!0,this[R40].length=0,this[j40]=0;let t=this;if(typeof t.close==="function"&&!this[mmn])t.close();if(e)this.emit("error",e);else this.emit(b_0);return this}static get isStream(){return Enu}}var Jnu=Lnu.native,fnn={lstatSync:knu,readdir:Inu,readdirSync:Bnu,readlinkSync:Mnu,realpathSync:Jnu,promises:{lstat:Knu,readdir:znu,readlink:Wnu,realpath:Unu}},QMi=(e)=>!e||e===fnn||e===qnu?fnn:{...fnn,...e,promises:{...fnn.promises,...e.promises||{}}},YMi=/^\\\\\?\\([a-z]:)\\?$/i,Qnu=(e)=>e.replace(/\//g,"\\").replace(YMi,"$1\\"),Ynu=/[\\\/]/,kQ0=0,$Mi=1,ZMi=2,wse=4,VMi=6,HMi=8,NLe=10,GMi=12,OQ0=15,cnn=~OQ0,Zjn=16,KMi=32,lnn=64,Bj0=128,ymn=256,Cmn=512,zMi=lnn|Bj0|Cmn,$nu=1023,Vjn=(e)=>e.isFile()?HMi:e.isDirectory()?wse:e.isSymbolicLink()?NLe:e.isCharacterDevice()?ZMi:e.isBlockDevice()?VMi:e.isSocket()?GMi:e.isFIFO()?$Mi:kQ0,WMi=new Map,_nn=(e)=>{let t=WMi.get(e);if(t)return t;let o=e.normalize("NFKD");return WMi.set(e,o),o},UMi=new Map,Emn=(e)=>{let t=UMi.get(e);if(t)return t;let o=_nn(e.toLowerCase());return UMi.set(e,o),o};class Gjn extends rnn{constructor(){super({max:256})}}class XMi extends rnn{constructor(e=16384){super({maxSize:e,sizeCalculation:(t)=>t.length+1})}}var RMi=Symbol("PathScurry setAsCwd");class LT0{name;root;roots;parent;nocase;isCWD=!1;#e;#n;get dev(){return this.#n}#t;get mode(){return this.#t}#i;get nlink(){return this.#i}#r;get uid(){return this.#r}#a;get gid(){return this.#a}#o;get rdev(){return this.#o}#s;get blksize(){return this.#s}#c;get ino(){return this.#c}#u;get size(){return this.#u}#p;get blocks(){return this.#p}#y;get atimeMs(){return this.#y}#m;get mtimeMs(){return this.#m}#_;get ctimeMs(){return this.#_}#D;get birthtimeMs(){return this.#D}#d;get atime(){return this.#d}#h;get mtime(){return this.#h}#E;get ctime(){return this.#E}#A;get birthtime(){return this.#A}#v;#F;#l;#g;#w;#S;#f;#T;#N;#C;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=kQ0,o,c,p,m,T){if(this.name=e,this.#v=p?Emn(e):_nn(e),this.#f=t&$nu,this.nocase=p,this.roots=c,this.root=o||this,this.#T=m,this.#l=T.fullpath,this.#w=T.relative,this.#S=T.relativePosix,this.parent=T.parent,this.parent)this.#e=this.parent.#e;else this.#e=QMi(T.fs)}depth(){if(this.#F!==void 0)return this.#F;if(!this.parent)return this.#F=0;return this.#F=this.parent.depth()+1}childrenCache(){return this.#T}resolve(e){if(!e)return this;let t=this.getRootString(e),c=e.substring(t.length).split(this.splitSep);return t?this.getRoot(t).#B(c):this.#B(c)}#B(e){let t=this;for(let o of e)t=t.child(o);return t}children(){let e=this.#T.get(this);if(e)return e;let t=Object.assign([],{provisional:0});return this.#T.set(this,t),this.#f&=~Zjn,t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let o=this.children(),c=this.nocase?Emn(e):_nn(e);for(let P of o)if(P.#v===c)return P;let p=this.parent?this.sep:"",m=this.#l?this.#l+p+e:void 0,T=this.newChild(e,kQ0,{...t,parent:this,fullpath:m});if(!this.canReaddir())T.#f|=Bj0;return o.push(T),T}relative(){if(this.isCWD)return"";if(this.#w!==void 0)return this.#w;let e=this.name,t=this.parent;if(!t)return this.#w=this.name;let o=t.relative();return o+(!o||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#S!==void 0)return this.#S;let e=this.name,t=this.parent;if(!t)return this.#S=this.fullpathPosix();let o=t.relativePosix();return o+(!o||!t.parent?"":"/")+e}fullpath(){if(this.#l!==void 0)return this.#l;let e=this.name,t=this.parent;if(!t)return this.#l=this.name;let c=t.fullpath()+(!t.parent?"":this.sep)+e;return this.#l=c}fullpathPosix(){if(this.#g!==void 0)return this.#g;if(this.sep==="/")return this.#g=this.fullpath();if(!this.parent){let c=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(c))return this.#g=`//?/${c}`;else return this.#g=c}let e=this.parent,t=e.fullpathPosix(),o=t+(!t||!e.parent?"":"/")+this.name;return this.#g=o}isUnknown(){return(this.#f&OQ0)===kQ0}isType(e){return this[`is${e}`]()}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.#f&OQ0)===HMi}isDirectory(){return(this.#f&OQ0)===wse}isCharacterDevice(){return(this.#f&OQ0)===ZMi}isBlockDevice(){return(this.#f&OQ0)===VMi}isFIFO(){return(this.#f&OQ0)===$Mi}isSocket(){return(this.#f&OQ0)===GMi}isSymbolicLink(){return(this.#f&NLe)===NLe}lstatCached(){return this.#f&KMi?this:void 0}readlinkCached(){return this.#N}realpathCached(){return this.#C}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#N)return!0;if(!this.parent)return!1;let e=this.#f&OQ0;return!(e!==kQ0&&e!==NLe||this.#f&ymn||this.#f&Bj0)}calledReaddir(){return!!(this.#f&Zjn)}isENOENT(){return!!(this.#f&Bj0)}isNamed(e){return!this.nocase?this.#v===_nn(e):this.#v===Emn(e)}async readlink(){let e=this.#N;if(e)return e;if(!this.canReadlink())return;if(!this.parent)return;try{let t=await this.#e.promises.readlink(this.fullpath()),o=(await this.parent.realpath())?.resolve(t);if(o)return this.#N=o}catch(t){this.#q(t.code);return}}readlinkSync(){let e=this.#N;if(e)return e;if(!this.canReadlink())return;if(!this.parent)return;try{let t=this.#e.readlinkSync(this.fullpath()),o=this.parent.realpathSync()?.resolve(t);if(o)return this.#N=o}catch(t){this.#q(t.code);return}}#M(e){this.#f|=Zjn;for(let t=e.provisional;t<e.length;t++){let o=e[t];if(o)o.#P()}}#P(){if(this.#f&Bj0)return;this.#f=(this.#f|Bj0)&cnn,this.#b()}#b(){let e=this.children();e.provisional=0;for(let t of e)t.#P()}#L(){this.#f|=Cmn,this.#O()}#O(){if(this.#f&lnn)return;let e=this.#f;if((e&OQ0)===wse)e&=cnn;this.#f=e|lnn,this.#b()}#I(e=""){if(e==="ENOTDIR"||e==="EPERM")this.#O();else if(e==="ENOENT")this.#P();else this.children().provisional=0}#x(e=""){if(e==="ENOTDIR")this.parent.#O();else if(e==="ENOENT")this.#P()}#q(e=""){let t=this.#f;if(t|=ymn,e==="ENOENT")t|=Bj0;if(e==="EINVAL"||e==="UNKNOWN")t&=cnn;if(this.#f=t,e==="ENOTDIR"&&this.parent)this.parent.#O()}#k(e,t){return this.#Q(e,t)||this.#U(e,t)}#U(e,t){let o=Vjn(e),c=this.newChild(e.name,o,{parent:this}),p=c.#f&OQ0;if(p!==wse&&p!==NLe&&p!==kQ0)c.#f|=lnn;return t.unshift(c),t.provisional++,c}#Q(e,t){for(let o=t.provisional;o<t.length;o++){let c=t[o];if((this.nocase?Emn(e.name):_nn(e.name))!==c.#v)continue;return this.#Y(e,c,o,t)}}#Y(e,t,o,c){let p=t.name;if(t.#f=t.#f&cnn|Vjn(e),p!==e.name)t.name=e.name;if(o!==c.provisional){if(o===c.length-1)c.pop();else c.splice(o,1);c.unshift(t)}return c.provisional++,t}async lstat(){if((this.#f&Bj0)===0)try{return this.#W(await this.#e.promises.lstat(this.fullpath())),this}catch(e){this.#x(e.code)}}lstatSync(){if((this.#f&Bj0)===0)try{return this.#W(this.#e.lstatSync(this.fullpath())),this}catch(e){this.#x(e.code)}}#W(e){let{atime:t,atimeMs:o,birthtime:c,birthtimeMs:p,blksize:m,blocks:T,ctime:P,ctimeMs:I,dev:L,gid:z,ino:H,mode:V,mtime:X,mtimeMs:f0,nlink:d0,rdev:D0,size:N0,uid:w0}=e;this.#d=t,this.#y=o,this.#A=c,this.#D=p,this.#s=m,this.#p=T,this.#E=P,this.#_=I,this.#n=L,this.#a=z,this.#c=H,this.#t=V,this.#h=X,this.#m=f0,this.#i=d0,this.#o=D0,this.#u=N0,this.#r=w0;let W0=Vjn(e);if(this.#f=this.#f&cnn|W0|KMi,W0!==kQ0&&W0!==wse&&W0!==NLe)this.#f|=lnn}#K=[];#z=!1;#$(e){this.#z=!1;let t=this.#K.slice();this.#K.length=0,t.forEach((o)=>o(null,e))}readdirCB(e,t=!1){if(!this.canReaddir()){if(t)e(null,[]);else queueMicrotask(()=>e(null,[]));return}let o=this.children();if(this.calledReaddir()){let p=o.slice(0,o.provisional);if(t)e(null,p);else queueMicrotask(()=>e(null,p));return}if(this.#K.push(e),this.#z)return;this.#z=!0;let c=this.fullpath();this.#e.readdir(c,{withFileTypes:!0},(p,m)=>{if(p)this.#I(p.code),o.provisional=0;else{for(let T of m)this.#k(T,o);this.#M(o)}this.#$(o.slice(0,o.provisional));return})}#J;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(this.#J)await this.#J;else{let o=()=>{};this.#J=new Promise((c)=>o=c);try{for(let c of await this.#e.promises.readdir(t,{withFileTypes:!0}))this.#k(c,e);this.#M(e)}catch(c){this.#I(c.code),e.provisional=0}this.#J=void 0,o()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();try{for(let o of this.#e.readdirSync(t,{withFileTypes:!0}))this.#k(o,e);this.#M(e)}catch(o){this.#I(o.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#f&zMi)return!1;let e=OQ0&this.#f;if(!(e===kQ0||e===wse||e===NLe))return!1;return!0}shouldWalk(e,t){return(this.#f&wse)===wse&&!(this.#f&zMi)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#C)return this.#C;if((Cmn|ymn|Bj0)&this.#f)return;try{let e=await this.#e.promises.realpath(this.fullpath());return this.#C=this.resolve(e)}catch(e){this.#L()}}realpathSync(){if(this.#C)return this.#C;if((Cmn|ymn|Bj0)&this.#f)return;try{let e=this.#e.realpathSync(this.fullpath());return this.#C=this.resolve(e)}catch(e){this.#L()}}[RMi](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let t=new Set([]),o=[],c=this;while(c&&c.parent)t.add(c),c.#w=o.join(this.sep),c.#S=o.join("/"),c=c.parent,o.push("..");c=e;while(c&&c.parent&&!t.has(c))c.#w=void 0,c.#S=void 0,c=c.parent}}class Tmn extends LT0{sep="\\";splitSep=Ynu;constructor(e,t=kQ0,o,c,p,m,T){super(e,t,o,c,p,m,T)}newChild(e,t=kQ0,o={}){return new Tmn(e,t,this.root,this.roots,this.nocase,this.childrenCache(),o)}getRootString(e){return Hjn.parse(e).root}getRoot(e){if(e=Qnu(e.toUpperCase()),e===this.root.name)return this.root;for(let[t,o]of Object.entries(this.roots))if(this.sameRoot(e,t))return this.roots[e]=o;return this.roots[e]=new dnn(e,this).root}sameRoot(e,t=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(YMi,"$1\\"),e===t}}class Amn extends LT0{splitSep="/";sep="/";constructor(e,t=kQ0,o,c,p,m,T){super(e,t,o,c,p,m,T)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,t=kQ0,o={}){return new Amn(e,t,this.root,this.roots,this.nocase,this.childrenCache(),o)}}class Xjn{root;rootPath;roots;cwd;#e;#n;#t;nocase;#i;constructor(e=process.cwd(),t,o,{nocase:c,childrenCacheSize:p=16384,fs:m=fnn}={}){if(this.#i=QMi(m),e instanceof URL||e.startsWith("file://"))e=Onu(e);let T=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(T),this.#e=new Gjn,this.#n=new Gjn,this.#t=new XMi(p);let P=T.substring(this.rootPath.length).split(o);if(P.length===1&&!P[0])P.pop();if(c===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=c,this.root=this.newRoot(this.#i),this.roots[this.rootPath]=this.root;let I=this.root,L=P.length-1,z=t.sep,H=this.rootPath,V=!1;for(let X of P){let f0=L--;I=I.child(X,{relative:new Array(f0).fill("..").join(z),relativePosix:new Array(f0).fill("..").join("/"),fullpath:H+=(V?"":z)+X}),V=!0}this.cwd=I}depth(e=this.cwd){if(typeof e==="string")e=this.cwd.resolve(e);return e.depth()}childrenCache(){return this.#t}resolve(...e){let t="";for(let p=e.length-1;p>=0;p--){let m=e[p];if(!m||m===".")continue;if(t=t?`${m}/${t}`:m,this.isAbsolute(m))break}let o=this.#e.get(t);if(o!==void 0)return o;let c=this.cwd.resolve(t).fullpath();return this.#e.set(t,c),c}resolvePosix(...e){let t="";for(let p=e.length-1;p>=0;p--){let m=e[p];if(!m||m===".")continue;if(t=t?`${m}/${t}`:m,this.isAbsolute(m))break}let o=this.#n.get(t);if(o!==void 0)return o;let c=this.cwd.resolve(t).fullpathPosix();return this.#n.set(t,c),c}relative(e=this.cwd){if(typeof e==="string")e=this.cwd.resolve(e);return e.relative()}relativePosix(e=this.cwd){if(typeof e==="string")e=this.cwd.resolve(e);return e.relativePosix()}basename(e=this.cwd){if(typeof e==="string")e=this.cwd.resolve(e);return e.name}dirname(e=this.cwd){if(typeof e==="string")e=this.cwd.resolve(e);return(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:!0}){if(typeof e==="string")e=this.cwd.resolve(e);else if(!(e instanceof LT0))t=e,e=this.cwd;let{withFileTypes:o}=t;if(!e.canReaddir())return[];else{let c=await e.readdir();return o?c:c.map((p)=>p.name)}}readdirSync(e=this.cwd,t={withFileTypes:!0}){if(typeof e==="string")e=this.cwd.resolve(e);else if(!(e instanceof LT0))t=e,e=this.cwd;let{withFileTypes:o=!0}=t;if(!e.canReaddir())return[];else if(o)return e.readdirSync();else return e.readdirSync().map((c)=>c.name)}async lstat(e=this.cwd){if(typeof e==="string")e=this.cwd.resolve(e);return e.lstat()}lstatSync(e=this.cwd){if(typeof e==="string")e=this.cwd.resolve(e);return e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){if(typeof e==="string")e=this.cwd.resolve(e);else if(!(e instanceof LT0))t=e.withFileTypes,e=this.cwd;let o=await e.readlink();return t?o:o?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){if(typeof e==="string")e=this.cwd.resolve(e);else if(!(e instanceof LT0))t=e.withFileTypes,e=this.cwd;let o=e.readlinkSync();return t?o:o?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){if(typeof e==="string")e=this.cwd.resolve(e);else if(!(e instanceof LT0))t=e.withFileTypes,e=this.cwd;let o=await e.realpath();return t?o:o?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){if(typeof e==="string")e=this.cwd.resolve(e);else if(!(e instanceof LT0))t=e.withFileTypes,e=this.cwd;let o=e.realpathSync();return t?o:o?.fullpath()}async walk(e=this.cwd,t={}){if(typeof e==="string")e=this.cwd.resolve(e);else if(!(e instanceof LT0))t=e,e=this.cwd;let{withFileTypes:o=!0,follow:c=!1,filter:p,walkFilter:m}=t,T=[];if(!p||p(e))T.push(o?e:e.fullpath());let P=new Set,I=(z,H)=>{P.add(z),z.readdirCB((V,X)=>{if(V)return H(V);let f0=X.length;if(!f0)return H();let d0=()=>{if(--f0===0)H()};for(let D0 of X){if(!p||p(D0))T.push(o?D0:D0.fullpath());if(c&&D0.isSymbolicLink())D0.realpath().then((N0)=>N0?.isUnknown()?N0.lstat():N0).then((N0)=>N0?.shouldWalk(P,m)?I(N0,d0):d0());else if(D0.shouldWalk(P,m))I(D0,d0);else d0()}},!0)},L=e;return new Promise((z,H)=>{I(L,(V)=>{if(V)return H(V);z(T)})})}walkSync(e=this.cwd,t={}){if(typeof e==="string")e=this.cwd.resolve(e);else if(!(e instanceof LT0))t=e,e=this.cwd;let{withFileTypes:o=!0,follow:c=!1,filter:p,walkFilter:m}=t,T=[];if(!p||p(e))T.push(o?e:e.fullpath());let P=new Set([e]);for(let I of P){let L=I.readdirSync();for(let z of L){if(!p||p(z))T.push(o?z:z.fullpath());let H=z;if(z.isSymbolicLink()){if(!(c&&(H=z.realpathSync())))continue;if(H.isUnknown())H.lstatSync()}if(H.shouldWalk(P,m))P.add(H)}}return T}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){if(typeof e==="string")e=this.cwd.resolve(e);else if(!(e instanceof LT0))t=e,e=this.cwd;return this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){if(typeof e==="string")e=this.cwd.resolve(e);else if(!(e instanceof LT0))t=e,e=this.cwd;let{withFileTypes:o=!0,follow:c=!1,filter:p,walkFilter:m}=t;if(!p||p(e))yield o?e:e.fullpath();let T=new Set([e]);for(let P of T){let I=P.readdirSync();for(let L of I){if(!p||p(L))yield o?L:L.fullpath();let z=L;if(L.isSymbolicLink()){if(!(c&&(z=L.realpathSync())))continue;if(z.isUnknown())z.lstatSync()}if(z.shouldWalk(T,m))T.add(z)}}}stream(e=this.cwd,t={}){if(typeof e==="string")e=this.cwd.resolve(e);else if(!(e instanceof LT0))t=e,e=this.cwd;let{withFileTypes:o=!0,follow:c=!1,filter:p,walkFilter:m}=t,T=new wLe({objectMode:!0});if(!p||p(e))T.write(o?e:e.fullpath());let P=new Set,I=[e],L=0,z=()=>{let H=!1;while(!H){let V=I.shift();if(!V){if(L===0)T.end();return}L++,P.add(V);let X=(d0,D0,N0=!1)=>{if(d0)return T.emit("error",d0);if(c&&!N0){let w0=[];for(let W0 of D0)if(W0.isSymbolicLink())w0.push(W0.realpath().then((Q0)=>Q0?.isUnknown()?Q0.lstat():Q0));if(w0.length){Promise.all(w0).then(()=>X(null,D0,!0));return}}for(let w0 of D0)if(w0&&(!p||p(w0))){if(!T.write(o?w0:w0.fullpath()))H=!0}L--;for(let w0 of D0){let W0=w0.realpathCached()||w0;if(W0.shouldWalk(P,m))I.push(W0)}if(H&&!T.flowing)T.once("drain",z);else if(!f0)z()},f0=!0;V.readdirCB(X,!0),f0=!1}};return z(),T}streamSync(e=this.cwd,t={}){if(typeof e==="string")e=this.cwd.resolve(e);else if(!(e instanceof LT0))t=e,e=this.cwd;let{withFileTypes:o=!0,follow:c=!1,filter:p,walkFilter:m}=t,T=new wLe({objectMode:!0}),P=new Set;if(!p||p(e))T.write(o?e:e.fullpath());let I=[e],L=0,z=()=>{let H=!1;while(!H){let V=I.shift();if(!V){if(L===0)T.end();return}L++,P.add(V);let X=V.readdirSync();for(let f0 of X)if(!p||p(f0)){if(!T.write(o?f0:f0.fullpath()))H=!0}L--;for(let f0 of X){let d0=f0;if(f0.isSymbolicLink()){if(!(c&&(d0=f0.realpathSync())))continue;if(d0.isUnknown())d0.lstatSync()}if(d0.shouldWalk(P,m))I.push(d0)}}if(H&&!T.flowing)T.once("drain",z)};return z(),T}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e==="string"?this.cwd.resolve(e):e,this.cwd[RMi](t)}}class dnn extends Xjn{sep="\\";constructor(e=process.cwd(),t={}){let{nocase:o=!0}=t;super(e,Hjn,"\\",{...t,nocase:o});this.nocase=o;for(let c=this.cwd;c;c=c.parent)c.nocase=this.nocase}parseRootPath(e){return Hjn.parse(e).root.toUpperCase()}newRoot(e){return new Tmn(this.rootPath,wse,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}}class pnn extends Xjn{sep="/";constructor(e=process.cwd(),t={}){let{nocase:o=!1}=t;super(e,bnu,"/",{...t,nocase:o});this.nocase=o}parseRootPath(e){return"/"}newRoot(e){return new Amn(this.rootPath,wse,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}}class Fmn extends pnn{constructor(e=process.cwd(),t={}){let{nocase:o=!0}=t;super(e,{...t,nocase:o})}}var UFs=process.platform==="win32"?Tmn:Amn,jMi=process.platform==="win32"?dnn:process.platform==="darwin"?Fmn:pnn;var Znu=(e)=>e.length>=1,Vnu=(e)=>e.length>=1;class PQe{#e;#n;#t;length;#i;#r;#a;#o;#s;#c;#u=!0;constructor(e,t,o,c){if(!Znu(e))throw new TypeError("empty pattern list");if(!Vnu(t))throw new TypeError("empty glob list");if(t.length!==e.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=e.length,o<0||o>=this.length)throw new TypeError("index out of range");if(this.#e=e,this.#n=t,this.#t=o,this.#i=c,this.#t===0){if(this.isUNC()){let[p,m,T,P,...I]=this.#e,[L,z,H,V,...X]=this.#n;if(I[0]==="")I.shift(),X.shift();let f0=[p,m,T,P,""].join("/"),d0=[L,z,H,V,""].join("/");this.#e=[f0,...I],this.#n=[d0,...X],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[p,...m]=this.#e,[T,...P]=this.#n;if(m[0]==="")m.shift(),P.shift();let I=p+"/",L=T+"/";this.#e=[I,...m],this.#n=[L,...P],this.length=this.#e.length}}}pattern(){return this.#e[this.#t]}isString(){return typeof this.#e[this.#t]==="string"}isGlobstar(){return this.#e[this.#t]===ID0}isRegExp(){return this.#e[this.#t]instanceof RegExp}globString(){return this.#a=this.#a||(this.#t===0?this.isAbsolute()?this.#n[0]+this.#n.slice(1).join("/"):this.#n.join("/"):this.#n.slice(this.#t).join("/"))}hasMore(){return this.length>this.#t+1}rest(){if(this.#r!==void 0)return this.#r;if(!this.hasMore())return this.#r=null;return this.#r=new PQe(this.#e,this.#n,this.#t+1,this.#i),this.#r.#c=this.#c,this.#r.#s=this.#s,this.#r.#o=this.#o,this.#r}isUNC(){let e=this.#e;return this.#s!==void 0?this.#s:this.#s=this.#i==="win32"&&this.#t===0&&e[0]===""&&e[1]===""&&typeof e[2]==="string"&&!!e[2]&&typeof e[3]==="string"&&!!e[3]}isDrive(){let e=this.#e;return this.#o!==void 0?this.#o:this.#o=this.#i==="win32"&&this.#t===0&&this.length>1&&typeof e[0]==="string"&&/^[a-z]:$/i.test(e[0])}isAbsolute(){let e=this.#e;return this.#c!==void 0?this.#c:this.#c=e[0]===""&&e.length>1||this.isDrive()||this.isUNC()}root(){let e=this.#e[0];return typeof e==="string"&&this.isAbsolute()&&this.#t===0?e:""}checkFollowGlobstar(){return!(this.#t===0||!this.isGlobstar()||!this.#u)}markFollowGlobstar(){if(this.#t===0||!this.isGlobstar()||!this.#u)return!1;return this.#u=!1,!0}}var Hnu=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class vnn{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:o,noext:c,noglobstar:p,platform:m=Hnu}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=m,this.mmopts={dot:!0,nobrace:t,nocase:o,noext:c,noglobstar:p,optimizationLevel:2,platform:m,nocomment:!0,nonegate:!0};for(let T of e)this.add(T)}add(e){let t=new bQ0(e,this.mmopts);for(let o=0;o<t.set.length;o++){let c=t.set[o],p=t.globParts[o];if(!c||!p)throw new Error("invalid pattern object");while(c[0]==="."&&p[0]===".")c.shift(),p.shift();let m=new PQe(c,p,0,this.platform),T=new bQ0(m.globString(),this.mmopts),P=p[p.length-1]==="**",I=m.isAbsolute();if(I)this.absolute.push(T);else this.relative.push(T);if(P)if(I)this.absoluteChildren.push(T);else this.relativeChildren.push(T)}}ignored(e){let t=e.fullpath(),o=`${t}/`,c=e.relative()||".",p=`${c}/`;for(let m of this.relative)if(m.match(c)||m.match(p))return!0;for(let m of this.absolute)if(m.match(t)||m.match(o))return!0;return!1}childrenIgnored(e){let t=e.fullpath()+"/",o=(e.relative()||".")+"/";for(let c of this.relativeChildren)if(c.match(o))return!0;for(let c of this.absoluteChildren)if(c.match(t))return!0;return!1}}class Rjn{store;constructor(e=new Map){this.store=e}copy(){return new Rjn(new Map(this.store))}hasWalked(e,t){return this.store.get(e.fullpath())?.has(t.globString())}storeWalked(e,t){let o=e.fullpath(),c=this.store.get(o);if(c)c.add(t.globString());else this.store.set(o,new Set([t.globString()]))}}class eLi{store=new Map;add(e,t,o){let c=(t?2:0)|(o?1:0),p=this.store.get(e);this.store.set(e,p===void 0?c:c&p)}entries(){return[...this.store.entries()].map(([e,t])=>[e,!!(t&2),!!(t&1)])}}class nLi{store=new Map;add(e,t){if(!e.canReaddir())return;let o=this.store.get(e);if(o){if(!o.find((c)=>c.globString()===t.globString()))o.push(t)}else this.store.set(e,[t])}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map((e)=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter((e)=>e.canReaddir())}}class gnn{hasWalkedCache;matches=new eLi;subwalks=new nLi;patterns;follow;dot;opts;constructor(e,t){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=t?t.copy():new Rjn}processPatterns(e,t){this.patterns=t;let o=t.map((c)=>[e,c]);for(let[c,p]of o){this.hasWalkedCache.storeWalked(c,p);let m=p.root(),T=p.isAbsolute()&&this.opts.absolute!==!1;if(m){c=c.resolve(m==="/"&&this.opts.root!==void 0?this.opts.root:m);let z=p.rest();if(!z){this.matches.add(c,!0,!1);continue}else p=z}if(c.isENOENT())continue;let P,I,L=!1;while(typeof(P=p.pattern())==="string"&&(I=p.rest()))c=c.resolve(P),p=I,L=!0;if(P=p.pattern(),I=p.rest(),L){if(this.hasWalkedCache.hasWalked(c,p))continue;this.hasWalkedCache.storeWalked(c,p)}if(typeof P==="string"){let z=P===".."||P===""||P===".";this.matches.add(c.resolve(P),T,z);continue}else if(P===ID0){if(!c.isSymbolicLink()||this.follow||p.checkFollowGlobstar())this.subwalks.add(c,p);let z=I?.pattern(),H=I?.rest();if(!I||(z===""||z===".")&&!H)this.matches.add(c,T,z===""||z===".");else if(z===".."){let V=c.parent||c;if(!H)this.matches.add(V,T,!0);else if(!this.hasWalkedCache.hasWalked(V,H))this.subwalks.add(V,H)}}else if(P instanceof RegExp)this.subwalks.add(c,p)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new gnn(this.opts,this.hasWalkedCache)}filterEntries(e,t){let o=this.subwalks.get(e),c=this.child();for(let p of t)for(let m of o){let T=m.isAbsolute(),P=m.pattern(),I=m.rest();if(P===ID0)c.testGlobstar(p,m,I,T);else if(P instanceof RegExp)c.testRegExp(p,P,I,T);else c.testString(p,P,I,T)}return c}testGlobstar(e,t,o,c){if(this.dot||!e.name.startsWith(".")){if(!t.hasMore())this.matches.add(e,c,!1);if(e.canReaddir()){if(this.follow||!e.isSymbolicLink())this.subwalks.add(e,t);else if(e.isSymbolicLink()){if(o&&t.checkFollowGlobstar())this.subwalks.add(e,o);else if(t.markFollowGlobstar())this.subwalks.add(e,t)}}}if(o){let p=o.pattern();if(typeof p==="string"&&p!==".."&&p!==""&&p!==".")this.testString(e,p,o.rest(),c);else if(p===".."){let m=e.parent||e;this.subwalks.add(m,o)}else if(p instanceof RegExp)this.testRegExp(e,p,o.rest(),c)}}testRegExp(e,t,o,c){if(!t.test(e.name))return;if(!o)this.matches.add(e,c,!1);else this.subwalks.add(e,o)}testString(e,t,o,c){if(!e.isNamed(t))return;if(!o)this.matches.add(e,c,!1);else this.subwalks.add(e,o)}}var Gnu=(e,t)=>typeof e==="string"?new vnn([e],t):Array.isArray(e)?new vnn(e,t):e;class jjn{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#n;#t;signal;maxDepth;includeChildMatches;constructor(e,t,o){if(this.patterns=e,this.path=t,this.opts=o,this.#t=!o.posix&&o.platform==="win32"?"\\":"/",this.includeChildMatches=o.includeChildMatches!==!1,o.ignore||!this.includeChildMatches){if(this.#n=Gnu(o.ignore??[],o),!this.includeChildMatches&&typeof this.#n.add!=="function")throw new Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=o.maxDepth||1/0,o.signal)this.signal=o.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0})}#i(e){return this.seen.has(e)||!!this.#n?.ignored?.(e)}#r(e){return!!this.#n?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e=void 0;while(!this.paused&&(e=this.#e.shift()))e()}onResume(e){if(this.signal?.aborted)return;if(!this.paused)e();else this.#e.push(e)}async matchCheck(e,t){if(t&&this.opts.nodir)return;let o;if(this.opts.realpath){if(o=e.realpathCached()||await e.realpath(),!o)return;e=o}let p=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&p?.isSymbolicLink()){let m=await p.realpath();if(m&&(m.isUnknown()||this.opts.stat))await m.lstat()}return this.matchCheckTest(p,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#i(e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let o;if(this.opts.realpath){if(o=e.realpathCached()||e.realpathSync(),!o)return;e=o}let p=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&p?.isSymbolicLink()){let m=p.realpathSync();if(m&&(m?.isUnknown()||this.opts.stat))m.lstatSync()}return this.matchCheckTest(p,t)}matchFinish(e,t){if(this.#i(e))return;if(!this.includeChildMatches&&this.#n?.add){let p=`${e.relativePosix()}/**`;this.#n.add(p)}let o=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let c=this.opts.mark&&e.isDirectory()?this.#t:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(o){let p=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(p+c)}else{let p=this.opts.posix?e.relativePosix():e.relative(),m=this.opts.dotRelative&&!p.startsWith(".."+this.#t)?"."+this.#t:"";this.matchEmit(!p?"."+c:m+p+c)}}async match(e,t,o){let c=await this.matchCheck(e,o);if(c)this.matchFinish(c,t)}matchSync(e,t,o){let c=this.matchCheckSync(e,o);if(c)this.matchFinish(c,t)}walkCB(e,t,o){if(this.signal?.aborted)o();this.walkCB2(e,t,new gnn(this.opts),o)}walkCB2(e,t,o,c){if(this.#r(e))return c();if(this.signal?.aborted)c();if(this.paused){this.onResume(()=>this.walkCB2(e,t,o,c));return}o.processPatterns(e,t);let p=1,m=()=>{if(--p===0)c()};for(let[T,P,I]of o.matches.entries()){if(this.#i(T))continue;p++,this.match(T,P,I).then(()=>m())}for(let T of o.subwalkTargets()){if(this.maxDepth!==1/0&&T.depth()>=this.maxDepth)continue;p++;let P=T.readdirCached();if(T.calledReaddir())this.walkCB3(T,P,o,m);else T.readdirCB((I,L)=>this.walkCB3(T,L,o,m),!0)}m()}walkCB3(e,t,o,c){o=o.filterEntries(e,t);let p=1,m=()=>{if(--p===0)c()};for(let[T,P,I]of o.matches.entries()){if(this.#i(T))continue;p++,this.match(T,P,I).then(()=>m())}for(let[T,P]of o.subwalks.entries())p++,this.walkCB2(T,P,o.child(),m);m()}walkCBSync(e,t,o){if(this.signal?.aborted)o();this.walkCB2Sync(e,t,new gnn(this.opts),o)}walkCB2Sync(e,t,o,c){if(this.#r(e))return c();if(this.signal?.aborted)c();if(this.paused){this.onResume(()=>this.walkCB2Sync(e,t,o,c));return}o.processPatterns(e,t);let p=1,m=()=>{if(--p===0)c()};for(let[T,P,I]of o.matches.entries()){if(this.#i(T))continue;this.matchSync(T,P,I)}for(let T of o.subwalkTargets()){if(this.maxDepth!==1/0&&T.depth()>=this.maxDepth)continue;p++;let P=T.readdirSync();this.walkCB3Sync(T,P,o,m)}m()}walkCB3Sync(e,t,o,c){o=o.filterEntries(e,t);let p=1,m=()=>{if(--p===0)c()};for(let[T,P,I]of o.matches.entries()){if(this.#i(T))continue;this.matchSync(T,P,I)}for(let[T,P]of o.subwalks.entries())p++,this.walkCB2Sync(T,P,o.child(),m);m()}}class Smn extends jjn{matches=new Set;constructor(e,t,o){super(e,t,o)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise((e,t)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)t(this.signal.reason);else e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class wmn extends jjn{results;constructor(e,t,o){super(e,t,o);this.results=new wLe({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(e){if(this.results.write(e),!this.results.flowing)this.pause()}stream(){let e=this.path;if(e.isUnknown())e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())});else this.walkCB(e,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var Rnu=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class Nse{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(e,t){if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,!t.cwd)this.cwd="";else if(t.cwd instanceof URL||t.cwd.startsWith("file://"))t.cwd=Xnu(t.cwd);if(this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==!1,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth==="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e==="string")e=[e];if(this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape)e=e.map((P)=>P.replace(/\\/g,"/"));if(this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map((P)=>P.includes("/")?P:`./**/${P}`)}if(this.pattern=e,this.platform=t.platform||Rnu,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let P=t.platform==="win32"?dnn:t.platform==="darwin"?Fmn:t.platform?pnn:jMi;this.scurry=new P(this.cwd,{nocase:t.nocase,fs:t.fs})}this.nocase=this.scurry.nocase;let o=this.platform==="darwin"||this.platform==="win32",c={...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:o,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},p=this.pattern.map((P)=>new bQ0(P,c)),[m,T]=p.reduce((P,I)=>{return P[0].push(...I.set),P[1].push(...I.globParts),P},[[],[]]);this.patterns=m.map((P,I)=>{let L=T[I];if(!L)throw new Error("invalid pattern object");return new PQe(P,L,0,this.platform)})}async walk(){return[...await new Smn(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 Smn(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 wmn(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 wmn(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 e0t=(e,t={})=>{if(!Array.isArray(e))e=[e];for(let o of e)if(new bQ0(o,t).hasMagic())return!0;return!1};function Pmn(e,t={}){return new Nse(e,t).streamSync()}function iLi(e,t={}){return new Nse(e,t).stream()}function rLi(e,t={}){return new Nse(e,t).walkSync()}async function tLi(e,t={}){return new Nse(e,t).walk()}function bmn(e,t={}){return new Nse(e,t).iterateSync()}function aLi(e,t={}){return new Nse(e,t).iterate()}var jnu=Pmn,etu=Object.assign(iLi,{sync:Pmn}),ntu=bmn,ttu=Object.assign(aLi,{sync:bmn}),itu=Object.assign(rLi,{stream:Pmn,iterate:bmn}),Nmn=Object.assign(tLi,{glob:tLi,globSync:rLi,sync:itu,globStream:iLi,stream:etu,globStreamSync:Pmn,streamSync:jnu,globIterate:aLi,iterate:ttu,globIterateSync:bmn,iterateSync:ntu,Glob:Nse,hasMagic:e0t,escape:AQe,unescape:kj0});Nmn.glob=Nmn;import{promises as oLi}from"fs";import*as PLe from"path";var bQe=/^[a-zA-Z0-9][a-zA-Z0-9-_]*[a-zA-Z0-9]$/,Omn=async(e)=>{return await Nmn("**/*.ts",{ignore:["**/node_modules/**"],cwd:PLe.dirname(e)})},kmn=async(e,t)=>{await Promise.all(t.map(async(o)=>{let c=await uLi.default.format(await oLi.readFile(PLe.resolve(PLe.dirname(e),o),"utf-8"),{parser:"typescript"});await oLi.writeFile(PLe.resolve(PLe.dirname(e),o),c)}))};var rqe=H3(YT(),1);var Ert=H3(DKn(),1);import yrt,{extname as qNu}from"path";var zxn=H3(VYi(),1);var l$i=H3(yKn(),1),_$i=H3(f$i(),1),Fvu={default:"defaultValue",public:"isPublic",protected:"isProtected",private:"isPrivate",interface:"anInterface",context:"ctx",data:"aData",case:"aCase"},Rj0=(e)=>Fvu[e]??MW(e.replace(/^([0-9])(.+)?$/,(t,o,c="")=>`${_$i.toWords(o)}${c}`)),MD0=(e)=>Object.entries(e??{}).reduce((t,[o,c])=>{if(typeof c==="undefined")return t;return{...t,[o]:c}},{}),NCe=(e)=>{if(!e)return"";let t=l$i.default(e),[o]=t.split(`
64939
- `).filter((p)=>p.trim()!==""),[c]=o.split(/[.!?]/g);return Mse(c)},Mse=(e)=>{if(!e)return"";return`${e}`.replace(/\s+/g," ").trim().replace(/"/g,"\\\"")};var PCe={string:{type:"string",cleanFn:"toString",cleanReturnType:"string",allowOptional:!0},integer:{type:"string",cleanFn:"toNumber",cleanReturnType:"number",allowOptional:!0},number:{type:"string",cleanFn:"toNumber",cleanReturnType:"number",allowOptional:!0},boolean:{type:"boolean",cleanFn:"toBool",cleanReturnType:"boolean",allowOptional:!1}},d$i=(e)=>{if(e?.type==="boolean")return;let t="items"in e&&e.items&&"enum"in e.items?e.items.enum:void 0;if(e?.enum||t)return(e?.enum||t||[]).map((o)=>({label:TN0(o),value:o}));if(e?.allOf?.[0]&&!("$ref"in e?.allOf?.[0]))return(e?.allOf?.[0]?.enum??[]).map((o)=>({label:TN0(o),value:o}));return},Int=(e,t)=>{if("$ref"in e)throw new Error("$ref nodes are not supported.");let o=e.schema?.type,{type:c,cleanFn:p,cleanReturnType:m,allowOptional:T}=PCe[o]??PCe.string,P=e.required||!T,I=P?`(value): ${m} => util.types.${p}(value)`:`(value): ${m} | undefined => value !== undefined && value !== null ? util.types.${p}(value) : undefined`,{name:L}=e,z=t.has(Rj0(L))?Rj0(`other ${L}`):Rj0(L);return t.add(z),MD0({upstreamKey:L,key:z,label:TN0(L),type:c,required:P,comments:e.description,default:e.schema?.default,example:e.schema?.example,model:d$i(e.schema),clean:I})},Svu=(e)=>{return N9e(e.properties??{},...(e.allOf??[]).map((t)=>t.properties))},wvu=(e,t)=>{let o=new Set(e.required??[]),c=Svu(e);return Object.entries(c).filter(([,p])=>!p.readOnly).map(([p,m])=>{let T=m?.type,P;if(T==="array")P=Nvu(m);else P=PCe[T]??PCe.string;let{type:I,cleanFn:L,cleanReturnType:z,allowOptional:H,collection:V}=P,X=o.has(p)||!H,f0;if(T==="array")f0=`(values) => ((values as unknown[]) || []).map((value) => util.types.${L}(value))`;else f0=X?`(value): ${z} => util.types.${L}(value)`:`(value): ${z} | undefined => value !== undefined && value !== null ? util.types.${L}(value) : undefined`;let d0=t.has(Rj0(p))?Rj0(`other ${p}`):Rj0(p);return t.add(d0),MD0({upstreamKey:p,key:d0,label:TN0(p),type:I,collection:V,required:X,comments:m.description,default:m.default,example:m.example,model:d$i(m),clean:f0})})},p$i=(e,t=[])=>{if(typeof e.requestBody!=="undefined"&&"$ref"in e.requestBody)throw new Error("All refs should be resolved before computing Inputs.");let o=new Set(["connection"]),c=Object.values([...t,...e.parameters??[]].reduce((L,z)=>{if("$ref"in z)return L;return{...L,[z.name]:z}},{})),p=(c??[]).filter((L)=>L.in==="header").map((L)=>Int(L,o)),m=(c??[]).filter((L)=>L.in==="path").map((L)=>Int(L,o)),T=(c??[]).filter((L)=>L.in==="query").map((L)=>Int(L,o)),P=e.requestBody?.content?.["application/json"]?.schema;if(typeof P!=="undefined"&&"$ref"in P)throw new Error("All refs should be resolved before computing Inputs.");let I=P===void 0?[]:wvu(P,o);return{headerInputs:p,pathInputs:m,queryInputs:T,bodyInputs:I,payloadContentType:"application/json"}},Nvu=(e)=>{let{items:t}=e;if("type"in t)if(t.type==="object")return{type:"code",language:"json",cleanFn:"toObject"};else{let o=t.type;return{type:o,collection:"valuelist",required:"minimum"in t&&t.minimum,cleanFn:o in PCe?PCe[o].cleanFn:PCe.string.cleanFn}}else return PCe.string};var v$i=(e)=>{let o=(e.startsWith("/")?e.split("/")[1]||"root":e).replace(/^(\d)/,"a$1");return MW(o)};var Pvu=(e,t,o,c,p,m)=>{let T=[...o,...c,...p,...m].map(({key:V})=>V).join(", "),P=o.map(({key:V,upstreamKey:X})=>V===X?V:`"${X}": ${V}`).join(", "),I=c.reduce((V,{key:X,upstreamKey:f0})=>V.replace(`{${f0}}`,`{${X}}`),e).replace(/{([^}]+)}/g,(V,X)=>`\${${X}}`),L=p.map(({key:V,upstreamKey:X})=>V===X?V:`"${X}": ${V}`).join(", "),z=m.map(({key:V,upstreamKey:X})=>V===X?V:`"${X}": ${V}`),H=!Mue(L)||!Mue(P);return(V)=>V.writeLine(`async (context, { connection, ${T} }) => {`).blankLineIfLastNot().writeLine("const client = createClient(connection);").write("const {data} = await client.").write(t).write("(`").write(I).write("`").conditionalWrite(["post","put","patch"].includes(t),()=>`, { ${z} }`).conditionalWrite(H,()=>", { ").conditionalWrite(!Mue(L),()=>`params: { ${L} }`).conditionalWrite(!Mue(L)&&!Mue(P),()=>", ").conditionalWrite(!Mue(P),()=>`headers: { ${P} }`).conditionalWrite(H,()=>" } ").write(");").writeLine("return {data};").writeLine("}")},bvu=(e,t,o,c=[])=>{let p=Rj0(o.operationId||`${t} ${e}`),{headerInputs:m,pathInputs:T,queryInputs:P,bodyInputs:I}=p$i(o,c),L=v$i(o.tags?.[0]??e),z=[...m,...T,...P,...I].reduce((V,X)=>({...V,[MW(X.key)]:X}),{});return MD0({key:p,groupTag:L,display:{label:TN0(p),description:o.summary??o.description??"TODO: Description"},inputs:{connection:{label:"Connection",type:"connection",required:!0},...z},perform:Pvu(e,t,m,T,P,I)})},Ovu=new Set(["get","put","post","delete","options","head","patch","trace"]),g$i=(e,t)=>{let o=t.parameters;return Object.entries(t).filter(([c])=>Ovu.has(c)).map(([c,p])=>bvu(e,c,p,o))};var hrt=H3(Kxn(),1),Mer=(e,t)=>{if("$ref"in t)throw new Error("$ref nodes are not supported.");if(t.type==="apiKey"||t.type==="http"&&t.scheme==="bearer")return[MD0({orderPriority:50,key:MW(e),display:{label:TN0(e),description:NCe(t.description)},inputs:{apiKey:{label:TN0(t.type==="apiKey"?t.name:"Token"),type:"password",required:!0}}})];if(t.type==="http"&&t.scheme==="basic")return[MD0({orderPriority:1000,key:MW(e),display:{label:TN0(e),description:NCe(t.description)},inputs:{username:{label:"Username",type:"string",required:!0},password:{label:"Password",type:"password",required:!0}}})];if(t.type==="oauth2"){if("authorizationCode"in t.flows){let o=t.flows.authorizationCode,c=o?.scopes&&Object.keys(o.scopes).length>0;return[MD0({orderPriority:0,key:MW(e),display:{label:"OAuth 2.0",description:""},oauth2Type:hrt.OAuth2Type.AuthorizationCode,inputs:{authorizeUrl:MD0({label:"Authorization URL",type:"string",required:!0,shown:!o?.authorizationUrl,default:o?.authorizationUrl,comments:"Authorization URL"}),tokenUrl:MD0({label:"Token URL",type:"string",required:!0,shown:!o?.tokenUrl,default:o?.tokenUrl,comments:"Token URL"}),scopes:MD0({label:"Scopes",type:"string",required:!0,shown:c,default:c?void 0:"",comments:"Space-delimited scopes"}),clientId:{label:"Client ID",type:"string",required:!0,shown:!0,comments:"Client identifier"},clientSecret:{label:"Client Secret",type:"password",required:!0,shown:!0,comments:"Client secret"}}})]}if("clientCredentials"in t.flows){let o=t.flows.clientCredentials,c=o?.scopes&&Object.keys(o.scopes).length>0;return[MD0({orderPriority:10,key:MW(e),display:{label:"OAuth 2.0 Client Credentials",description:""},oauth2Type:hrt.OAuth2Type.ClientCredentials,inputs:{tokenUrl:MD0({label:"Token URL",type:"string",required:!0,shown:!o?.tokenUrl,default:o?.tokenUrl,comments:"Token URL"}),scopes:MD0({label:"Scopes",type:"string",required:!0,shown:c,default:c?void 0:"",comments:"Space-delimited scopes"}),clientId:{label:"Client ID",type:"string",required:!0,shown:!0,comments:"Client identifier"},clientSecret:{label:"Client Secret",type:"password",required:!0,shown:!0,comments:"Client secret"}}})]}throw new Error("Did not find supported OAuth 2.0 flow.")}throw new Error(`Security scheme '${t.type}' not supported.`)};var ANu=(e)=>{if("basePath"in e)return e?.basePath;if("servers"in e)return e?.servers?.[0]?.url;return},FNu=(e)=>{return MD0({display:{label:e.info.title,description:e.info.description??`Generated component for ${e.info.title} ${e.info.version}`,iconPath:"icon.png"}})},Ler=async(e)=>{let t=await zxn.dereference.bind(zxn.default)(e),o=FNu(t),c=Object.entries(t.paths??{}).reduce((T,[P,I])=>[...T,...g$i(P,I)],[]),p="components"in t?Object.entries(t.components?.securitySchemes??{}).reduce((T,[P,I])=>[...T,...Mer(P,I)],[]):[],m=ANu(t);if(!m)throw new Error("Failed to identify base path of API.");return{baseUrl:m,component:o,actions:c,connections:p}};var Itn=H3(_Ce(),1);import SYe from"path";var xrt=H3(Kxn(),1);var FYe=H3(_Ce(),1);import SNu from"path";var wNu=(e,t,{label:o,type:c,comments:p,default:m,example:T,placeholder:P,shown:I,required:L})=>e.writeLine(`${t}: {`).writeLine(`label: "${o}",`).writeLine(`type: "${c}",`).conditionalWriteLine(L!==void 0,`required: ${L},`).conditionalWriteLine(I!==void 0,`shown: ${I},`).conditionalWriteLine(P!==void 0,`placeholder: "${P}",`).conditionalWriteLine(m!==void 0,`default: "${m}",`).conditionalWriteLine(T!==void 0,`example: "${T}",`).conditionalWriteLine(p!==void 0,`comments: "${Mse(p)}",`).writeLine("},"),NNu=({key:e,display:t,oauth2Type:o,inputs:c})=>{let{label:p,description:m,icons:T}=t,P=o===void 0?"connection":"oauth2Connection";return{kind:FYe.StructureKind.VariableDeclaration,name:e,leadingTrivia:(I)=>I.blankLine(),trailingTrivia:(I)=>I.blankLine(),initializer:(I)=>I.writeLine(`${P}({`).writeLine(`key: "${e}",`).write("display: ").block(()=>{I.writeLine(`label: "${p}",`).writeLine(`description: "${Mse(m)}",`).write("icons: ").block(()=>{I.conditionalWriteLine(T?.avatarPath!==void 0,`avatarPath: "${T?.avatarPath}",`).conditionalWriteLine(T?.oauth2ConnectionIconPath!==void 0,`oauth2ConnectionIconPath: "${T?.oauth2ConnectionIconPath}",`)})}).writeLine(",").conditionalWriteLine(o!==void 0,()=>{if(o===xrt.OAuth2Type.AuthorizationCode)return"oauth2Type: OAuth2Type.AuthorizationCode,";if(o===xrt.OAuth2Type.ClientCredentials)return"oauth2Type: OAuth2Type.ClientCredentials,";throw new Error(`Unexpected OAuth2Type: ${o}`)}).write("inputs: ").block(()=>Object.entries(c).forEach(([L,z])=>wNu(I,L,z))).writeLine("})")}},qer=(e,t)=>{let o=e.createSourceFile(SNu.join("src","connections.ts"),void 0,{scriptKind:FYe.ScriptKind.TS}),c=[];if(t.some(({oauth2Type:I})=>I===void 0))c.push("connection");if(t.some(({oauth2Type:I})=>I!==void 0))c.push("oauth2Connection","OAuth2Type");o.addImportDeclaration({moduleSpecifier:"@prismatic-io/spectral",namedImports:c});for(let I of t)I.key=Rj0(I.key);let T=P9e(t,({orderPriority:I})=>I).map(({key:I})=>I),P=t.map(NNu);return o.addVariableStatements(P.map((I)=>({declarationKind:FYe.VariableDeclarationKind.Const,declarations:[I],isExported:!0}))),o.addExportAssignment({isExportEquals:!1,expression:(I)=>I.write("[").write(T.join(", ")).write("]")}),o};import Drt from"path";var ZCe=H3(_Ce(),1);var PNu=(e,t,{label:o,type:c,collection:p,comments:m,clean:T,default:P,example:I,placeholder:L,required:z,model:H})=>e.writeLine(`${t}: input({`).writeLine(`label: "${o}",`).writeLine(`type: "${c}",`).conditionalWriteLine(z!==void 0,`required: ${z},`).conditionalWriteLine(L!==void 0,`placeholder: "${L}",`).conditionalWriteLine(P!==void 0,`default: "${P}",`).conditionalWriteLine(p!==void 0,`collection: "${p}",`).conditionalWriteLine(H!==void 0&&H.length>0,()=>{return`model: [${(H??[]).map(({label:X,value:f0})=>`{label: "${X}", value: "${f0}"}`).join(", ")}],`}).conditionalWriteLine(I!==void 0,`example: "${Mse(I)}",`).conditionalWriteLine(T!==void 0,()=>`clean: ${typeof T==="string"?T:T(e)},`).conditionalWriteLine(m!==void 0,()=>`comments: "${NCe(`${m}`)}",`).writeLine("}),"),bNu=({key:e,display:{label:t,description:o},examplePayload:c,inputs:p,perform:m})=>{let T=MW(e);return{kind:ZCe.StructureKind.VariableDeclaration,name:T,leadingTrivia:(P)=>P.blankLine(),trailingTrivia:(P)=>P.blankLine(),initializer:(P)=>{if(P.writeLine("action({").write("display: ").block(()=>{P.writeLine(`label: "${t}",`).writeLine(`description: "${NCe(`${o}`)}",`)}).write(",").write("perform: "),typeof m==="string")P.write(m);else m(P);return P.write(",").write("inputs: ").block(()=>Object.entries(p).forEach(([I,L])=>PNu(P,I,L))).write(",").conditionalWriteLine(c!==void 0,`examplePayload: ${c},`).writeLine("})"),P}}},ONu=(e,t,o)=>{let c=e.createSourceFile(Drt.join("src","actions",`${t}.ts`),void 0,{scriptKind:ZCe.ScriptKind.TS});c.addImportDeclarations([{moduleSpecifier:"@prismatic-io/spectral",namedImports:["action","input","util"]},{moduleSpecifier:"../client",namedImports:["createClient"]}]);let p=o.map(bNu);c.addVariableStatements(p.map((T)=>({declarationKind:ZCe.VariableDeclarationKind.Const,declarations:[T],isExported:!1})));let m=p.map(({name:T})=>T);return c.addExportAssignment({isExportEquals:!1,expression:(T)=>T.block(()=>m.forEach((P)=>T.writeLine(`${P},`)))}),c},kNu=(e,t)=>{let o=e.createSourceFile(Drt.join("src","actions","index.ts"),void 0,{scriptKind:ZCe.ScriptKind.TS});return o.addImportDeclarations([{moduleSpecifier:"@prismatic-io/spectral/dist/clients/http",namedImports:["buildRawRequestAction"]},{moduleSpecifier:"../client",namedImports:["baseUrl"]},...t.map((c)=>({kind:ZCe.StructureKind.ImportDeclaration,moduleSpecifier:`./${c}`,defaultImport:c}))]),o.addExportAssignment({isExportEquals:!1,expression:(c)=>c.block(()=>{t.forEach((p)=>c.writeLine(`...${p},`)),c.writeLine("rawRequest: buildRawRequestAction(baseUrl),")})}),o},Jer=(e,t)=>{e.createDirectory(Drt.join("src","actions"));let o=IBn(t,({groupTag:m})=>m),c=Object.entries(o).map(([m,T])=>ONu(e,m,T)),p=kNu(e,Object.keys(o));return[...c,p]};var INu=(e,t,o,{display:{label:c,description:p,iconPath:m}})=>{let T=e.createSourceFile(SYe.join("src","index.ts"),void 0,{scriptKind:Itn.ScriptKind.TS});return T.addImportDeclarations([{moduleSpecifier:"@prismatic-io/spectral",namedImports:["component"]},{moduleSpecifier:"@prismatic-io/spectral/dist/clients/http",namedImports:["handleErrors"]},{moduleSpecifier:"./actions",defaultImport:"actions"},{moduleSpecifier:"./connections",defaultImport:"connections"}]),T.addExportAssignment({isExportEquals:!1,expression:(P)=>P.writeLine("component({").writeLine(`key: "${t}",`).conditionalWriteLine(o,"public: true,").conditionalWriteLine(o,`documentationUrl: "https://prismatic.io/docs/components/${t}/",`).writeLine("display: {").writeLine(`label: "${c}",`).writeLine(`description: "${NCe(p)}",`).conditionalWriteLine(o,'category: "Application Connectors",').writeLine(`iconPath: "${m}",`).writeLine("},").writeLine("hooks: { error: handleErrors },").writeLine("actions,").writeLine("connections,").writeLine("})")}),T},BNu=(e,t,o,[{key:c,inputs:p}])=>{let T=BBn(o,({orderPriority:I})=>I)?.key;return e.createSourceFile(SYe.join("src","component.test.ts"),(I)=>I.writeLine('import { testing } from "@prismatic-io/spectral";').conditionalWriteLine(Boolean(T),`import { ${T} } from "./connections";`).writeLine('import component from ".";').blankLine().writeLine(`describe("${t}", () => {`).writeLine("const harness = testing.createHarness(component);").conditionalWriteLine(Boolean(T),`const connection = harness.connectionValue(${T});`).blankLine().writeLine('it("should invoke action", async () => {').writeLine(`const result = await harness.action("${c}", `).block(()=>{I.conditionalWriteLine(Boolean(T),"connection,"),Object.entries(p).forEach(([L,z])=>{let H=`${z.default}`??null;I.conditionalWriteLine(L!=="connection",`${L}: ${H},`)})}).writeLine(");").writeLine("expect(result?.data).toBeDefined();").writeLine("});").writeLine("});"))},MNu=(e,t,o)=>{return e.createSourceFile(SYe.join("src","client.ts"),(p)=>p.writeLine('import { Connection, ConnectionError, util } from "@prismatic-io/spectral";').writeLine('import { HttpClient, createClient as createHttpClient } from "@prismatic-io/spectral/dist/clients/http";').writeLine(`import { ${o.map(({key:m})=>m).join(", ")} } from "./connections";`).blankLine().writeLine(`export const baseUrl = "${t}";`).blankLine().writeLine("const toAuthorizationHeaders = (connection: Connection): { Authorization: string } => {").writeLine("const accessToken = util.types.toString(connection.token?.access_token);").writeLine("if (accessToken) {").writeLine("return { Authorization: `Bearer ${accessToken}` };").writeLine("}").blankLine().writeLine("const apiKey = util.types.toString(connection.fields?.apiKey);").writeLine("if (apiKey) {").writeLine("return { Authorization: `Bearer ${apiKey}` };").writeLine("}").blankLine().writeLine("const username = util.types.toString(connection.fields?.username);").writeLine("const password = util.types.toString(connection.fields?.password);").writeLine("if (username && password) {").writeLine('const encoded = Buffer.from(`${username}:${password}`).toString("base64");').writeLine("return { Authorization: `Basic ${encoded}` };").writeLine("}").blankLine().writeLine("throw new Error(").writeLine("`Failed to guess at authorization parameters for Connection: ${connection.key}`").writeLine(");").writeLine("};").blankLine().writeLine("export const createClient = async (connection: Connection): Promise<HttpClient> => {").writeLine(`if (![${o.map(({key:m})=>`${m}.key`).join(", ")}].includes(connection.key)) {`).writeLine("throw new ConnectionError(connection, `Received unexpected connection type: ${connection.key}`);").writeLine("}").blankLine().writeLine("const client = createHttpClient({").writeLine("baseUrl,").writeLine("headers: {").writeLine("...toAuthorizationHeaders(connection),").writeLine('Accept: "application/json",').writeLine("},").writeLine('responseType: "json",').writeLine("});").writeLine("return client;").writeLine("};"),{scriptKind:Itn.ScriptKind.TS})},LNu=(e,t,o)=>{e.createDirectory("documentation");let c=e.createSourceFile(SYe.join("documentation","description.mdx"),(m)=>m.writeLine(t.display.description));if(o.length>0)e.createDirectory(SYe.join("documentation","connections"));let p=o.map((m)=>e.createSourceFile(SYe.join("documentation","connections",`${m.key}.mdx`),(T)=>T.blankLine()));return[c,...p]},Ker=async(e,t,{baseUrl:o,component:c,actions:p,connections:m})=>{let T=new Itn.Project;if(T.createDirectory("src"),qer(T,m),Jer(T,p),MNu(T,o,m),INu(T,e,t,c),BNu(T,e,m,p),t)LNu(T,c,m);return await T.save(),T};class wYe extends rqe.Command{static hidden=!0;static description="Initialize a new Component from a format";static flags={name:rqe.Flags.string({char:"n",description:"Name of the component",required:!0}),icon:rqe.Flags.string({char:"i",description:"Path to png icon for the component"}),openapi:rqe.Flags.string({char:"o",description:"Path to OpenAPI file for the component",required:!0}),public:rqe.Flags.boolean({hidden:!0})};async run(){let{flags:{name:e,icon:t,openapi:o,public:c=!1}}=await this.parse(wYe),p=MW(e),m=["tsconfig.json","webpack.config.js","jest.config.js",yrt.join("assets","icon.png")];await Promise.all(m.map((P)=>EEe(yrt.join("formats",P.endsWith("icon.png")?P:`${P}.ejs`),P)));let T=await Ler(o);if(await Ker(p,c,T),await Ert.copy(o,`${p}-openapi-spec${qNu(o)}`),t)await Ert.copy(t,yrt.join("assets","icon.png"));this.log(`
64939
+ `).filter((p)=>p.trim()!==""),[c]=o.split(/[.!?]/g);return Mse(c)},Mse=(e)=>{if(!e)return"";return`${e}`.replace(/\s+/g," ").trim().replace(/"/g,"\\\"")};var PCe={string:{type:"string",cleanFn:"toString",cleanReturnType:"string",allowOptional:!0},integer:{type:"string",cleanFn:"toNumber",cleanReturnType:"number",allowOptional:!0},number:{type:"string",cleanFn:"toNumber",cleanReturnType:"number",allowOptional:!0},boolean:{type:"boolean",cleanFn:"toBool",cleanReturnType:"boolean",allowOptional:!1}},d$i=(e)=>{if(e?.type==="boolean")return;let t="items"in e&&e.items&&"enum"in e.items?e.items.enum:void 0;if(e?.enum||t)return(e?.enum||t||[]).map((o)=>({label:TN0(o),value:o}));if(e?.allOf?.[0]&&!("$ref"in e?.allOf?.[0]))return(e?.allOf?.[0]?.enum??[]).map((o)=>({label:TN0(o),value:o}));return},Int=(e,t)=>{if("$ref"in e)throw new Error("$ref nodes are not supported.");let o=e.schema?.type,{type:c,cleanFn:p,cleanReturnType:m,allowOptional:T}=PCe[o]??PCe.string,P=e.required||!T,I=P?`(value): ${m} => util.types.${p}(value)`:`(value): ${m} | undefined => value !== undefined && value !== null ? util.types.${p}(value) : undefined`,{name:L}=e,z=t.has(Rj0(L))?Rj0(`other ${L}`):Rj0(L);return t.add(z),MD0({upstreamKey:L,key:z,label:TN0(L),type:c,required:P,comments:e.description,default:e.schema?.default,example:e.schema?.example,model:d$i(e.schema),clean:I})},Svu=(e)=>{return N9e(e.properties??{},...(e.allOf??[]).map((t)=>t.properties))},wvu=(e,t)=>{let o=new Set(e.required??[]),c=Svu(e);return Object.entries(c).filter(([,p])=>!p.readOnly).map(([p,m])=>{let T=m?.type,P;if(T==="array")P=Nvu(m);else P=PCe[T]??PCe.string;let{type:I,cleanFn:L,cleanReturnType:z,allowOptional:H,collection:V}=P,X=o.has(p)||!H,f0;if(T==="array")f0=`(values) => ((values as unknown[]) || []).map((value) => util.types.${L}(value))`;else f0=X?`(value): ${z} => util.types.${L}(value)`:`(value): ${z} | undefined => value !== undefined && value !== null ? util.types.${L}(value) : undefined`;let d0=t.has(Rj0(p))?Rj0(`other ${p}`):Rj0(p);return t.add(d0),MD0({upstreamKey:p,key:d0,label:TN0(p),type:I,collection:V,required:X,comments:m.description,default:m.default,example:m.example,model:d$i(m),clean:f0})})},p$i=(e,t=[])=>{if(typeof e.requestBody!=="undefined"&&"$ref"in e.requestBody)throw new Error("All refs should be resolved before computing Inputs.");let o=new Set(["connection"]),c=Object.values([...t,...e.parameters??[]].reduce((L,z)=>{if("$ref"in z)return L;return{...L,[z.name]:z}},{})),p=(c??[]).filter((L)=>L.in==="header").map((L)=>Int(L,o)),m=(c??[]).filter((L)=>L.in==="path").map((L)=>Int(L,o)),T=(c??[]).filter((L)=>L.in==="query").map((L)=>Int(L,o)),P=e.requestBody?.content?.["application/json"]?.schema;if(typeof P!=="undefined"&&"$ref"in P)throw new Error("All refs should be resolved before computing Inputs.");let I=P===void 0?[]:wvu(P,o);return{headerInputs:p,pathInputs:m,queryInputs:T,bodyInputs:I,payloadContentType:"application/json"}},Nvu=(e)=>{let{items:t}=e;if("type"in t)if(t.type==="object")return{type:"code",language:"json",cleanFn:"toObject"};else{let o=t.type;return{type:o,collection:"valuelist",required:"minimum"in t&&t.minimum,cleanFn:o in PCe?PCe[o].cleanFn:PCe.string.cleanFn}}else return PCe.string};var v$i=(e)=>{let o=(e.startsWith("/")?e.split("/")[1]||"root":e).replace(/^(\d)/,"a$1");return MW(o)};var Pvu=(e,t,o,c,p,m)=>{let T=[...o,...c,...p,...m].map(({key:V})=>V).join(", "),P=o.map(({key:V,upstreamKey:X})=>V===X?V:`"${X}": ${V}`).join(", "),I=c.reduce((V,{key:X,upstreamKey:f0})=>V.replace(`{${f0}}`,`{${X}}`),e).replace(/{([^}]+)}/g,(V,X)=>`\${${X}}`),L=p.map(({key:V,upstreamKey:X})=>V===X?V:`"${X}": ${V}`).join(", "),z=m.map(({key:V,upstreamKey:X})=>V===X?V:`"${X}": ${V}`),H=!Mue(L)||!Mue(P);return(V)=>V.writeLine(`async (context, { connection, ${T} }) => {`).blankLineIfLastNot().writeLine("const client = await createClient(connection);").write("const {data} = await client.").write(t).write("(`").write(I).write("`").conditionalWrite(["post","put","patch"].includes(t),()=>`, { ${z} }`).conditionalWrite(H,()=>", { ").conditionalWrite(!Mue(L),()=>`params: { ${L} }`).conditionalWrite(!Mue(L)&&!Mue(P),()=>", ").conditionalWrite(!Mue(P),()=>`headers: { ${P} }`).conditionalWrite(H,()=>" } ").write(");").writeLine("return {data};").writeLine("}")},bvu=(e,t,o,c=[])=>{let p=Rj0(o.operationId||`${t} ${e}`),{headerInputs:m,pathInputs:T,queryInputs:P,bodyInputs:I}=p$i(o,c),L=v$i(o.tags?.[0]??e),z=[...m,...T,...P,...I].reduce((V,X)=>({...V,[MW(X.key)]:X}),{});return MD0({key:p,groupTag:L,display:{label:TN0(p),description:o.summary??o.description??"TODO: Description"},inputs:{connection:{label:"Connection",type:"connection",required:!0},...z},perform:Pvu(e,t,m,T,P,I)})},Ovu=new Set(["get","put","post","delete","options","head","patch","trace"]),g$i=(e,t)=>{let o=t.parameters;return Object.entries(t).filter(([c])=>Ovu.has(c)).map(([c,p])=>bvu(e,c,p,o))};var hrt=H3(Kxn(),1),Mer=(e,t)=>{if("$ref"in t)throw new Error("$ref nodes are not supported.");if(t.type==="apiKey"||t.type==="http"&&t.scheme==="bearer")return[MD0({orderPriority:50,key:MW(e),display:{label:TN0(e),description:NCe(t.description)},inputs:{apiKey:{label:TN0(t.type==="apiKey"?t.name:"Token"),type:"password",required:!0}}})];if(t.type==="http"&&t.scheme==="basic")return[MD0({orderPriority:1000,key:MW(e),display:{label:TN0(e),description:NCe(t.description)},inputs:{username:{label:"Username",type:"string",required:!0},password:{label:"Password",type:"password",required:!0}}})];if(t.type==="oauth2"){if("authorizationCode"in t.flows){let o=t.flows.authorizationCode,c=o?.scopes&&Object.keys(o.scopes).length>0;return[MD0({orderPriority:0,key:MW(e),display:{label:"OAuth 2.0",description:""},oauth2Type:hrt.OAuth2Type.AuthorizationCode,inputs:{authorizeUrl:MD0({label:"Authorization URL",type:"string",required:!0,shown:!o?.authorizationUrl,default:o?.authorizationUrl,comments:"Authorization URL"}),tokenUrl:MD0({label:"Token URL",type:"string",required:!0,shown:!o?.tokenUrl,default:o?.tokenUrl,comments:"Token URL"}),scopes:MD0({label:"Scopes",type:"string",required:!0,shown:c,default:c?void 0:"",comments:"Space-delimited scopes"}),clientId:{label:"Client ID",type:"string",required:!0,shown:!0,comments:"Client identifier"},clientSecret:{label:"Client Secret",type:"password",required:!0,shown:!0,comments:"Client secret"}}})]}if("clientCredentials"in t.flows){let o=t.flows.clientCredentials,c=o?.scopes&&Object.keys(o.scopes).length>0;return[MD0({orderPriority:10,key:MW(e),display:{label:"OAuth 2.0 Client Credentials",description:""},oauth2Type:hrt.OAuth2Type.ClientCredentials,inputs:{tokenUrl:MD0({label:"Token URL",type:"string",required:!0,shown:!o?.tokenUrl,default:o?.tokenUrl,comments:"Token URL"}),scopes:MD0({label:"Scopes",type:"string",required:!0,shown:c,default:c?void 0:"",comments:"Space-delimited scopes"}),clientId:{label:"Client ID",type:"string",required:!0,shown:!0,comments:"Client identifier"},clientSecret:{label:"Client Secret",type:"password",required:!0,shown:!0,comments:"Client secret"}}})]}throw new Error("Did not find supported OAuth 2.0 flow.")}throw new Error(`Security scheme '${t.type}' not supported.`)};var ANu=(e)=>{if("basePath"in e)return e?.basePath;if("servers"in e)return e?.servers?.[0]?.url;return},FNu=(e)=>{return MD0({display:{label:e.info.title,description:e.info.description??`Generated component for ${e.info.title} ${e.info.version}`,iconPath:"icon.png"}})},Ler=async(e)=>{let t=await zxn.dereference.bind(zxn.default)(e),o=FNu(t),c=Object.entries(t.paths??{}).reduce((T,[P,I])=>[...T,...g$i(P,I)],[]),p="components"in t?Object.entries(t.components?.securitySchemes??{}).reduce((T,[P,I])=>[...T,...Mer(P,I)],[]):[],m=ANu(t);if(!m)throw new Error("Failed to identify base path of API.");return{baseUrl:m,component:o,actions:c,connections:p}};var Itn=H3(_Ce(),1);import SYe from"path";var xrt=H3(Kxn(),1);var FYe=H3(_Ce(),1);import SNu from"path";var wNu=(e,t,{label:o,type:c,comments:p,default:m,example:T,placeholder:P,shown:I,required:L})=>e.writeLine(`${t}: {`).writeLine(`label: "${o}",`).writeLine(`type: "${c}",`).conditionalWriteLine(L!==void 0,`required: ${L},`).conditionalWriteLine(I!==void 0,`shown: ${I},`).conditionalWriteLine(P!==void 0,`placeholder: "${P}",`).conditionalWriteLine(m!==void 0,`default: "${m}",`).conditionalWriteLine(T!==void 0,`example: "${T}",`).conditionalWriteLine(p!==void 0,`comments: "${Mse(p)}",`).writeLine("},"),NNu=({key:e,display:t,oauth2Type:o,inputs:c})=>{let{label:p,description:m,icons:T}=t,P=o===void 0?"connection":"oauth2Connection";return{kind:FYe.StructureKind.VariableDeclaration,name:e,leadingTrivia:(I)=>I.blankLine(),trailingTrivia:(I)=>I.blankLine(),initializer:(I)=>I.writeLine(`${P}({`).writeLine(`key: "${e}",`).write("display: ").block(()=>{I.writeLine(`label: "${p}",`).writeLine(`description: "${Mse(m)}",`).write("icons: ").block(()=>{I.conditionalWriteLine(T?.avatarPath!==void 0,`avatarPath: "${T?.avatarPath}",`).conditionalWriteLine(T?.oauth2ConnectionIconPath!==void 0,`oauth2ConnectionIconPath: "${T?.oauth2ConnectionIconPath}",`)})}).writeLine(",").conditionalWriteLine(o!==void 0,()=>{if(o===xrt.OAuth2Type.AuthorizationCode)return"oauth2Type: OAuth2Type.AuthorizationCode,";if(o===xrt.OAuth2Type.ClientCredentials)return"oauth2Type: OAuth2Type.ClientCredentials,";throw new Error(`Unexpected OAuth2Type: ${o}`)}).write("inputs: ").block(()=>Object.entries(c).forEach(([L,z])=>wNu(I,L,z))).writeLine("})")}},qer=(e,t)=>{let o=e.createSourceFile(SNu.join("src","connections.ts"),void 0,{scriptKind:FYe.ScriptKind.TS}),c=[];if(t.some(({oauth2Type:I})=>I===void 0))c.push("connection");if(t.some(({oauth2Type:I})=>I!==void 0))c.push("oauth2Connection","OAuth2Type");o.addImportDeclaration({moduleSpecifier:"@prismatic-io/spectral",namedImports:c});for(let I of t)I.key=Rj0(I.key);let T=P9e(t,({orderPriority:I})=>I).map(({key:I})=>I),P=t.map(NNu);return o.addVariableStatements(P.map((I)=>({declarationKind:FYe.VariableDeclarationKind.Const,declarations:[I],isExported:!0}))),o.addExportAssignment({isExportEquals:!1,expression:(I)=>I.write("[").write(T.join(", ")).write("]")}),o};import Drt from"path";var ZCe=H3(_Ce(),1);var PNu=(e,t,{label:o,type:c,collection:p,comments:m,clean:T,default:P,example:I,placeholder:L,required:z,model:H})=>e.writeLine(`${t}: input({`).writeLine(`label: "${o}",`).writeLine(`type: "${c}",`).conditionalWriteLine(z!==void 0,`required: ${z},`).conditionalWriteLine(L!==void 0,`placeholder: "${L}",`).conditionalWriteLine(P!==void 0,`default: "${P}",`).conditionalWriteLine(p!==void 0,`collection: "${p}",`).conditionalWriteLine(H!==void 0&&H.length>0,()=>{return`model: [${(H??[]).map(({label:X,value:f0})=>`{label: "${X}", value: "${f0}"}`).join(", ")}],`}).conditionalWriteLine(I!==void 0,`example: "${Mse(I)}",`).conditionalWriteLine(T!==void 0,()=>`clean: ${typeof T==="string"?T:T(e)},`).conditionalWriteLine(m!==void 0,()=>`comments: "${NCe(`${m}`)}",`).writeLine("}),"),bNu=({key:e,display:{label:t,description:o},examplePayload:c,inputs:p,perform:m})=>{let T=MW(e);return{kind:ZCe.StructureKind.VariableDeclaration,name:T,leadingTrivia:(P)=>P.blankLine(),trailingTrivia:(P)=>P.blankLine(),initializer:(P)=>{if(P.writeLine("action({").write("display: ").block(()=>{P.writeLine(`label: "${t}",`).writeLine(`description: "${NCe(`${o}`)}",`)}).write(",").write("perform: "),typeof m==="string")P.write(m);else m(P);return P.write(",").write("inputs: ").block(()=>Object.entries(p).forEach(([I,L])=>PNu(P,I,L))).write(",").conditionalWriteLine(c!==void 0,`examplePayload: ${c},`).writeLine("})"),P}}},ONu=(e,t,o)=>{let c=e.createSourceFile(Drt.join("src","actions",`${t}.ts`),void 0,{scriptKind:ZCe.ScriptKind.TS});c.addImportDeclarations([{moduleSpecifier:"@prismatic-io/spectral",namedImports:["action","input","util"]},{moduleSpecifier:"../client",namedImports:["createClient"]}]);let p=o.map(bNu);c.addVariableStatements(p.map((T)=>({declarationKind:ZCe.VariableDeclarationKind.Const,declarations:[T],isExported:!1})));let m=p.map(({name:T})=>T);return c.addExportAssignment({isExportEquals:!1,expression:(T)=>T.block(()=>m.forEach((P)=>T.writeLine(`${P},`)))}),c},kNu=(e,t)=>{let o=e.createSourceFile(Drt.join("src","actions","index.ts"),void 0,{scriptKind:ZCe.ScriptKind.TS});return o.addImportDeclarations([{moduleSpecifier:"@prismatic-io/spectral/dist/clients/http",namedImports:["buildRawRequestAction"]},{moduleSpecifier:"../client",namedImports:["baseUrl"]},...t.map((c)=>({kind:ZCe.StructureKind.ImportDeclaration,moduleSpecifier:`./${c}`,defaultImport:c}))]),o.addExportAssignment({isExportEquals:!1,expression:(c)=>c.block(()=>{t.forEach((p)=>c.writeLine(`...${p},`)),c.writeLine("rawRequest: buildRawRequestAction(baseUrl),")})}),o},Jer=(e,t)=>{e.createDirectory(Drt.join("src","actions"));let o=IBn(t,({groupTag:m})=>m),c=Object.entries(o).map(([m,T])=>ONu(e,m,T)),p=kNu(e,Object.keys(o));return[...c,p]};var INu=(e,t,o,{display:{label:c,description:p,iconPath:m}})=>{let T=e.createSourceFile(SYe.join("src","index.ts"),void 0,{scriptKind:Itn.ScriptKind.TS});return T.addImportDeclarations([{moduleSpecifier:"@prismatic-io/spectral",namedImports:["component"]},{moduleSpecifier:"@prismatic-io/spectral/dist/clients/http",namedImports:["handleErrors"]},{moduleSpecifier:"./actions",defaultImport:"actions"},{moduleSpecifier:"./connections",defaultImport:"connections"}]),T.addExportAssignment({isExportEquals:!1,expression:(P)=>P.writeLine("component({").writeLine(`key: "${t}",`).conditionalWriteLine(o,"public: true,").conditionalWriteLine(o,`documentationUrl: "https://prismatic.io/docs/components/${t}/",`).writeLine("display: {").writeLine(`label: "${c}",`).writeLine(`description: "${NCe(p)}",`).conditionalWriteLine(o,'category: "Application Connectors",').writeLine(`iconPath: "${m}",`).writeLine("},").writeLine("hooks: { error: handleErrors },").writeLine("actions,").writeLine("connections,").writeLine("})")}),T},BNu=(e,t,o,[{key:c,inputs:p}])=>{let T=BBn(o,({orderPriority:I})=>I)?.key;return e.createSourceFile(SYe.join("src","component.test.ts"),(I)=>I.writeLine('import { testing } from "@prismatic-io/spectral";').conditionalWriteLine(Boolean(T),`import { ${T} } from "./connections";`).writeLine('import component from ".";').blankLine().writeLine(`describe("${t}", () => {`).writeLine("const harness = testing.createHarness(component);").conditionalWriteLine(Boolean(T),`const connection = harness.connectionValue(${T});`).blankLine().writeLine('it("should invoke action", async () => {').writeLine(`const result = await harness.action("${c}", `).block(()=>{I.conditionalWriteLine(Boolean(T),"connection,"),Object.entries(p).forEach(([L,z])=>{let H=`${z.default}`??null;I.conditionalWriteLine(L!=="connection",`${L}: ${H},`)})}).writeLine(");").writeLine("expect(result?.data).toBeDefined();").writeLine("});").writeLine("});"))},MNu=(e,t,o)=>{return e.createSourceFile(SYe.join("src","client.ts"),(p)=>p.writeLine('import { Connection, ConnectionError, util } from "@prismatic-io/spectral";').writeLine('import { HttpClient, createClient as createHttpClient } from "@prismatic-io/spectral/dist/clients/http";').writeLine(`import { ${o.map(({key:m})=>m).join(", ")} } from "./connections";`).blankLine().writeLine(`export const baseUrl = "${t}";`).blankLine().writeLine("const toAuthorizationHeaders = (connection: Connection): { Authorization: string } => {").writeLine("const accessToken = util.types.toString(connection.token?.access_token);").writeLine("if (accessToken) {").writeLine("return { Authorization: `Bearer ${accessToken}` };").writeLine("}").blankLine().writeLine("const apiKey = util.types.toString(connection.fields?.apiKey);").writeLine("if (apiKey) {").writeLine("return { Authorization: `Bearer ${apiKey}` };").writeLine("}").blankLine().writeLine("const username = util.types.toString(connection.fields?.username);").writeLine("const password = util.types.toString(connection.fields?.password);").writeLine("if (username && password) {").writeLine('const encoded = Buffer.from(`${username}:${password}`).toString("base64");').writeLine("return { Authorization: `Basic ${encoded}` };").writeLine("}").blankLine().writeLine("throw new Error(").writeLine("`Failed to guess at authorization parameters for Connection: ${connection.key}`").writeLine(");").writeLine("};").blankLine().writeLine("export const createClient = async (connection: Connection): Promise<HttpClient> => {").writeLine(`if (![${o.map(({key:m})=>`${m}.key`).join(", ")}].includes(connection.key)) {`).writeLine("throw new ConnectionError(connection, `Received unexpected connection type: ${connection.key}`);").writeLine("}").blankLine().writeLine("const client = createHttpClient({").writeLine("baseUrl,").writeLine("headers: {").writeLine("...toAuthorizationHeaders(connection),").writeLine('Accept: "application/json",').writeLine("},").writeLine('responseType: "json",').writeLine("});").writeLine("return client;").writeLine("};"),{scriptKind:Itn.ScriptKind.TS})},LNu=(e,t,o)=>{e.createDirectory("documentation");let c=e.createSourceFile(SYe.join("documentation","description.mdx"),(m)=>m.writeLine(t.display.description));if(o.length>0)e.createDirectory(SYe.join("documentation","connections"));let p=o.map((m)=>e.createSourceFile(SYe.join("documentation","connections",`${m.key}.mdx`),(T)=>T.blankLine()));return[c,...p]},Ker=async(e,t,{baseUrl:o,component:c,actions:p,connections:m})=>{let T=new Itn.Project;if(T.createDirectory("src"),qer(T,m),Jer(T,p),MNu(T,o,m),INu(T,e,t,c),BNu(T,e,m,p),t)LNu(T,c,m);return await T.save(),T};class wYe extends rqe.Command{static hidden=!0;static description="Initialize a new Component from a format";static flags={name:rqe.Flags.string({char:"n",description:"Name of the component",required:!0}),icon:rqe.Flags.string({char:"i",description:"Path to png icon for the component"}),openapi:rqe.Flags.string({char:"o",description:"Path to OpenAPI file for the component",required:!0}),public:rqe.Flags.boolean({hidden:!0})};async run(){let{flags:{name:e,icon:t,openapi:o,public:c=!1}}=await this.parse(wYe),p=MW(e),m=["tsconfig.json","webpack.config.js","jest.config.js",yrt.join("assets","icon.png")];await Promise.all(m.map((P)=>EEe(yrt.join("formats",P.endsWith("icon.png")?P:`${P}.ejs`),P)));let T=await Ler(o);if(await Ker(p,c,T),await Ert.copy(o,`${p}-openapi-spec${qNu(o)}`),t)await Ert.copy(t,yrt.join("assets","icon.png"));this.log(`
64940
64940
  "${e}" is ready for development.
64941
64941
  To install dependencies, run either "npm install" or "yarn install"
64942
64942
  To test the component, run "npm run test" or "yarn test"
@@ -1,5 +1,6 @@
1
1
  const path = require("path");
2
2
  const CopyPlugin = require("copy-webpack-plugin");
3
+ const Dotenv = require("dotenv-webpack");
3
4
 
4
5
  module.exports = {
5
6
  mode: "production",
@@ -8,6 +9,7 @@ module.exports = {
8
9
  new CopyPlugin({
9
10
  patterns: [{ from: "assets", to: path.resolve(__dirname, "dist") }],
10
11
  }),
12
+ new Dotenv(),
11
13
  ],
12
14
  module: {
13
15
  rules: [
@@ -5655,5 +5655,5 @@
5655
5655
  "enableJsonFlag": false
5656
5656
  }
5657
5657
  },
5658
- "version": "7.6.5"
5658
+ "version": "7.6.6"
5659
5659
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/prism",
3
- "version": "7.6.5",
3
+ "version": "7.6.6",
4
4
  "description": "Build, deploy, and support integrations in Prismatic from the comfort of your command line",
5
5
  "keywords": ["prismatic", "cli"],
6
6
  "homepage": "https://prismatic.io",