@fern-api/go-dynamic-snippets 0.0.18 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +32 -0
- package/dist/index.cjs.map +1 -0
- package/{esm/DynamicSnippetsGeneratorContext-D8VcLYKk.d.ts → dist/index.d.cts} +77 -2
- package/{cjs/DynamicSnippetsGeneratorContext-D8VcLYKk.d.cts → dist/index.d.ts} +77 -2
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/package.json +9 -10
- package/cjs/DynamicSnippetsGenerator.cjs +0 -37
- package/cjs/DynamicSnippetsGenerator.cjs.map +0 -1
- package/cjs/DynamicSnippetsGenerator.d.cts +0 -20
- package/cjs/EndpointSnippetGenerator.cjs +0 -37
- package/cjs/EndpointSnippetGenerator.cjs.map +0 -1
- package/cjs/EndpointSnippetGenerator.d.cts +0 -66
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs +0 -37
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs.map +0 -1
- package/cjs/context/DynamicSnippetsGeneratorContext.d.cts +0 -4
- package/cjs/context/DynamicTypeInstantiationMapper.cjs +0 -37
- package/cjs/context/DynamicTypeInstantiationMapper.cjs.map +0 -1
- package/cjs/context/DynamicTypeInstantiationMapper.d.cts +0 -4
- package/cjs/context/DynamicTypeMapper.cjs +0 -37
- package/cjs/context/DynamicTypeMapper.cjs.map +0 -1
- package/cjs/context/DynamicTypeMapper.d.cts +0 -4
- package/cjs/context/FilePropertyMapper.cjs +0 -37
- package/cjs/context/FilePropertyMapper.cjs.map +0 -1
- package/cjs/context/FilePropertyMapper.d.cts +0 -4
- package/cjs/index.cjs +0 -37
- package/cjs/index.cjs.map +0 -1
- package/cjs/index.d.cts +0 -6
- package/esm/DynamicSnippetsGenerator.d.ts +0 -20
- package/esm/DynamicSnippetsGenerator.js +0 -2
- package/esm/DynamicSnippetsGenerator.js.map +0 -1
- package/esm/EndpointSnippetGenerator.d.ts +0 -66
- package/esm/EndpointSnippetGenerator.js +0 -2
- package/esm/EndpointSnippetGenerator.js.map +0 -1
- package/esm/chunk-3Z2URLHB.js +0 -2
- package/esm/chunk-3Z2URLHB.js.map +0 -1
- package/esm/chunk-B2A7QNZM.js +0 -2
- package/esm/chunk-B2A7QNZM.js.map +0 -1
- package/esm/chunk-DVDVP26D.js +0 -2
- package/esm/chunk-DVDVP26D.js.map +0 -1
- package/esm/chunk-JHIUGKJ4.js +0 -37
- package/esm/chunk-JHIUGKJ4.js.map +0 -1
- package/esm/chunk-MYN2HZVH.js +0 -2
- package/esm/chunk-MYN2HZVH.js.map +0 -1
- package/esm/chunk-SVPRIX53.js +0 -2
- package/esm/chunk-SVPRIX53.js.map +0 -1
- package/esm/chunk-TXVHHFW3.js +0 -2
- package/esm/chunk-TXVHHFW3.js.map +0 -1
- package/esm/chunk-ZNTXZ3YV.js +0 -2
- package/esm/chunk-ZNTXZ3YV.js.map +0 -1
- package/esm/context/DynamicSnippetsGeneratorContext.d.ts +0 -4
- package/esm/context/DynamicSnippetsGeneratorContext.js +0 -2
- package/esm/context/DynamicSnippetsGeneratorContext.js.map +0 -1
- package/esm/context/DynamicTypeInstantiationMapper.d.ts +0 -4
- package/esm/context/DynamicTypeInstantiationMapper.js +0 -2
- package/esm/context/DynamicTypeInstantiationMapper.js.map +0 -1
- package/esm/context/DynamicTypeMapper.d.ts +0 -4
- package/esm/context/DynamicTypeMapper.js +0 -2
- package/esm/context/DynamicTypeMapper.js.map +0 -1
- package/esm/context/FilePropertyMapper.d.ts +0 -4
- package/esm/context/FilePropertyMapper.js +0 -2
- package/esm/context/FilePropertyMapper.js.map +0 -1
- package/esm/index.d.ts +0 -6
- package/esm/index.js +0 -2
- package/esm/index.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractDynamicSnippetsGeneratorContext, FernGeneratorExec } from '@fern-api/browser-compatible-base-generator';
|
|
1
|
+
import { AbstractDynamicSnippetsGeneratorContext, FernGeneratorExec, AbstractFormatter, Options, AbstractDynamicSnippetsGenerator, AbstractAstNode } from '@fern-api/browser-compatible-base-generator';
|
|
2
2
|
import { FernIr } from '@fern-api/dynamic-ir-sdk';
|
|
3
3
|
import { go, BaseGoCustomConfigSchema } from '@fern-api/go-ast';
|
|
4
4
|
|
|
@@ -95,6 +95,7 @@ declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGen
|
|
|
95
95
|
getMethodName(name: FernIr.Name): string;
|
|
96
96
|
getTestMethodName(endpoint: FernIr.dynamic.Endpoint): string;
|
|
97
97
|
getTypeName(name: FernIr.Name): string;
|
|
98
|
+
getFieldName(name: FernIr.Name): string;
|
|
98
99
|
getImportPath(fernFilepath: FernIr.dynamic.FernFilepath): string;
|
|
99
100
|
getImportPathForRequest(fernFilepath: FernIr.dynamic.FernFilepath): string;
|
|
100
101
|
getContextTypeReference(): go.TypeReference;
|
|
@@ -114,4 +115,78 @@ declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGen
|
|
|
114
115
|
static chainMethods(baseFunc: go.FuncInvocation, ...methods: Omit<go.MethodInvocation.Args, "on">[]): go.MethodInvocation;
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
|
|
118
|
+
declare class EndpointSnippetGenerator {
|
|
119
|
+
private context;
|
|
120
|
+
private formatter;
|
|
121
|
+
constructor({ context, formatter }: {
|
|
122
|
+
context: DynamicSnippetsGeneratorContext;
|
|
123
|
+
formatter?: AbstractFormatter;
|
|
124
|
+
});
|
|
125
|
+
generateSnippet({ endpoint, request, options }: {
|
|
126
|
+
endpoint: FernIr.dynamic.Endpoint;
|
|
127
|
+
request: FernIr.dynamic.EndpointSnippetRequest;
|
|
128
|
+
options?: Options;
|
|
129
|
+
}): Promise<string>;
|
|
130
|
+
generateSnippetSync({ endpoint, request, options }: {
|
|
131
|
+
endpoint: FernIr.dynamic.Endpoint;
|
|
132
|
+
request: FernIr.dynamic.EndpointSnippetRequest;
|
|
133
|
+
options?: Options;
|
|
134
|
+
}): string;
|
|
135
|
+
generateSnippetAst({ endpoint, request, options }: {
|
|
136
|
+
endpoint: FernIr.dynamic.Endpoint;
|
|
137
|
+
request: FernIr.dynamic.EndpointSnippetRequest;
|
|
138
|
+
options?: Options;
|
|
139
|
+
}): Promise<go.AstNode>;
|
|
140
|
+
private generateWiremockTest;
|
|
141
|
+
private buildCodeBlock;
|
|
142
|
+
private buildWiremockTestCodeBlock;
|
|
143
|
+
private constructClient;
|
|
144
|
+
private constructWiremockTestClient;
|
|
145
|
+
private writeMethodInvocation;
|
|
146
|
+
private callMethod;
|
|
147
|
+
private getConstructorArgs;
|
|
148
|
+
private getWiremockTestConstructorArgs;
|
|
149
|
+
private getConstructorAuthArg;
|
|
150
|
+
private addError;
|
|
151
|
+
private addWarning;
|
|
152
|
+
private getConstructorBasicAuthArg;
|
|
153
|
+
private getConstructorBaseUrlArg;
|
|
154
|
+
private getBaseUrlArg;
|
|
155
|
+
private getConstructorBearerAuthArg;
|
|
156
|
+
private getConstructorHeaderAuthArg;
|
|
157
|
+
private getConstructorOAuthAuthArg;
|
|
158
|
+
private getConstructorHeaderArgs;
|
|
159
|
+
private getConstructorHeaderArg;
|
|
160
|
+
private getMethodArgs;
|
|
161
|
+
private getMethodArgsForBodyRequest;
|
|
162
|
+
private getBodyRequestArg;
|
|
163
|
+
private getBytesBodyRequestArg;
|
|
164
|
+
private getMethodArgsForInlinedRequest;
|
|
165
|
+
private getFilePropertyInfo;
|
|
166
|
+
private getInlinedRequestArg;
|
|
167
|
+
private getInlinedRequestBodyStructFields;
|
|
168
|
+
private getFileUploadRequestBodyStructFields;
|
|
169
|
+
private getReferencedRequestBodyPropertyStructField;
|
|
170
|
+
private getReferencedRequestBodyPropertyTypeInstantiation;
|
|
171
|
+
private getInlinedRequestBodyPropertyStructFields;
|
|
172
|
+
private getPathParameters;
|
|
173
|
+
private getMethod;
|
|
174
|
+
private getRootClientFuncInvocation;
|
|
175
|
+
private buildWiremockTestSetup;
|
|
176
|
+
private callClientMethodAndAssert;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<DynamicSnippetsGeneratorContext, EndpointSnippetGenerator> {
|
|
180
|
+
private formatter;
|
|
181
|
+
constructor({ ir, config, formatter }: {
|
|
182
|
+
ir: FernIr.dynamic.DynamicIntermediateRepresentation;
|
|
183
|
+
config: FernGeneratorExec.GeneratorConfig;
|
|
184
|
+
formatter?: AbstractFormatter;
|
|
185
|
+
});
|
|
186
|
+
generate(request: FernIr.dynamic.EndpointSnippetRequest, options?: Options): Promise<FernIr.dynamic.EndpointSnippetResponse>;
|
|
187
|
+
generateSync(request: FernIr.dynamic.EndpointSnippetRequest, options?: Options): FernIr.dynamic.EndpointSnippetResponse;
|
|
188
|
+
generateSnippetAst(request: FernIr.dynamic.EndpointSnippetRequest): Promise<AbstractAstNode>;
|
|
189
|
+
protected createSnippetGenerator(context: DynamicSnippetsGeneratorContext): EndpointSnippetGenerator;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export { DynamicSnippetsGenerator };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractDynamicSnippetsGeneratorContext, FernGeneratorExec } from '@fern-api/browser-compatible-base-generator';
|
|
1
|
+
import { AbstractDynamicSnippetsGeneratorContext, FernGeneratorExec, AbstractFormatter, Options, AbstractDynamicSnippetsGenerator, AbstractAstNode } from '@fern-api/browser-compatible-base-generator';
|
|
2
2
|
import { FernIr } from '@fern-api/dynamic-ir-sdk';
|
|
3
3
|
import { go, BaseGoCustomConfigSchema } from '@fern-api/go-ast';
|
|
4
4
|
|
|
@@ -95,6 +95,7 @@ declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGen
|
|
|
95
95
|
getMethodName(name: FernIr.Name): string;
|
|
96
96
|
getTestMethodName(endpoint: FernIr.dynamic.Endpoint): string;
|
|
97
97
|
getTypeName(name: FernIr.Name): string;
|
|
98
|
+
getFieldName(name: FernIr.Name): string;
|
|
98
99
|
getImportPath(fernFilepath: FernIr.dynamic.FernFilepath): string;
|
|
99
100
|
getImportPathForRequest(fernFilepath: FernIr.dynamic.FernFilepath): string;
|
|
100
101
|
getContextTypeReference(): go.TypeReference;
|
|
@@ -114,4 +115,78 @@ declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGen
|
|
|
114
115
|
static chainMethods(baseFunc: go.FuncInvocation, ...methods: Omit<go.MethodInvocation.Args, "on">[]): go.MethodInvocation;
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
|
|
118
|
+
declare class EndpointSnippetGenerator {
|
|
119
|
+
private context;
|
|
120
|
+
private formatter;
|
|
121
|
+
constructor({ context, formatter }: {
|
|
122
|
+
context: DynamicSnippetsGeneratorContext;
|
|
123
|
+
formatter?: AbstractFormatter;
|
|
124
|
+
});
|
|
125
|
+
generateSnippet({ endpoint, request, options }: {
|
|
126
|
+
endpoint: FernIr.dynamic.Endpoint;
|
|
127
|
+
request: FernIr.dynamic.EndpointSnippetRequest;
|
|
128
|
+
options?: Options;
|
|
129
|
+
}): Promise<string>;
|
|
130
|
+
generateSnippetSync({ endpoint, request, options }: {
|
|
131
|
+
endpoint: FernIr.dynamic.Endpoint;
|
|
132
|
+
request: FernIr.dynamic.EndpointSnippetRequest;
|
|
133
|
+
options?: Options;
|
|
134
|
+
}): string;
|
|
135
|
+
generateSnippetAst({ endpoint, request, options }: {
|
|
136
|
+
endpoint: FernIr.dynamic.Endpoint;
|
|
137
|
+
request: FernIr.dynamic.EndpointSnippetRequest;
|
|
138
|
+
options?: Options;
|
|
139
|
+
}): Promise<go.AstNode>;
|
|
140
|
+
private generateWiremockTest;
|
|
141
|
+
private buildCodeBlock;
|
|
142
|
+
private buildWiremockTestCodeBlock;
|
|
143
|
+
private constructClient;
|
|
144
|
+
private constructWiremockTestClient;
|
|
145
|
+
private writeMethodInvocation;
|
|
146
|
+
private callMethod;
|
|
147
|
+
private getConstructorArgs;
|
|
148
|
+
private getWiremockTestConstructorArgs;
|
|
149
|
+
private getConstructorAuthArg;
|
|
150
|
+
private addError;
|
|
151
|
+
private addWarning;
|
|
152
|
+
private getConstructorBasicAuthArg;
|
|
153
|
+
private getConstructorBaseUrlArg;
|
|
154
|
+
private getBaseUrlArg;
|
|
155
|
+
private getConstructorBearerAuthArg;
|
|
156
|
+
private getConstructorHeaderAuthArg;
|
|
157
|
+
private getConstructorOAuthAuthArg;
|
|
158
|
+
private getConstructorHeaderArgs;
|
|
159
|
+
private getConstructorHeaderArg;
|
|
160
|
+
private getMethodArgs;
|
|
161
|
+
private getMethodArgsForBodyRequest;
|
|
162
|
+
private getBodyRequestArg;
|
|
163
|
+
private getBytesBodyRequestArg;
|
|
164
|
+
private getMethodArgsForInlinedRequest;
|
|
165
|
+
private getFilePropertyInfo;
|
|
166
|
+
private getInlinedRequestArg;
|
|
167
|
+
private getInlinedRequestBodyStructFields;
|
|
168
|
+
private getFileUploadRequestBodyStructFields;
|
|
169
|
+
private getReferencedRequestBodyPropertyStructField;
|
|
170
|
+
private getReferencedRequestBodyPropertyTypeInstantiation;
|
|
171
|
+
private getInlinedRequestBodyPropertyStructFields;
|
|
172
|
+
private getPathParameters;
|
|
173
|
+
private getMethod;
|
|
174
|
+
private getRootClientFuncInvocation;
|
|
175
|
+
private buildWiremockTestSetup;
|
|
176
|
+
private callClientMethodAndAssert;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<DynamicSnippetsGeneratorContext, EndpointSnippetGenerator> {
|
|
180
|
+
private formatter;
|
|
181
|
+
constructor({ ir, config, formatter }: {
|
|
182
|
+
ir: FernIr.dynamic.DynamicIntermediateRepresentation;
|
|
183
|
+
config: FernGeneratorExec.GeneratorConfig;
|
|
184
|
+
formatter?: AbstractFormatter;
|
|
185
|
+
});
|
|
186
|
+
generate(request: FernIr.dynamic.EndpointSnippetRequest, options?: Options): Promise<FernIr.dynamic.EndpointSnippetResponse>;
|
|
187
|
+
generateSync(request: FernIr.dynamic.EndpointSnippetRequest, options?: Options): FernIr.dynamic.EndpointSnippetResponse;
|
|
188
|
+
generateSnippetAst(request: FernIr.dynamic.EndpointSnippetRequest): Promise<AbstractAstNode>;
|
|
189
|
+
protected createSnippetGenerator(context: DynamicSnippetsGeneratorContext): EndpointSnippetGenerator;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export { DynamicSnippetsGenerator };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var Jt=Object.defineProperty;var Jr=(u,t,e)=>t in u?Jt(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e;var oe=(u,t)=>()=>(u&&(t=u(u=0)),t);var Xt=(u,t)=>{for(var e in t)Jt(u,e,{get:t[e],enumerable:!0})};var m=(u,t,e)=>Jr(u,typeof t!="symbol"?t+"":t,e);var y=oe(()=>{"use strict"});var b={};Xt(b,{_debugEnd:()=>Vn,_debugProcess:()=>On,_events:()=>rr,_eventsCount:()=>ir,_exiting:()=>Tn,_fatalExceptions:()=>_n,_getActiveHandles:()=>bn,_getActiveRequests:()=>Nn,_kill:()=>Rn,_linkedBinding:()=>vn,_maxListeners:()=>nr,_preload_modules:()=>Zn,_rawDebug:()=>gn,_startProfilerIdleNotifier:()=>Wn,_stopProfilerIdleNotifier:()=>qn,_tickCallback:()=>Dn,abort:()=>zn,addListener:()=>or,allowedNodeEnvironmentFlags:()=>Cn,arch:()=>nn,argv:()=>sn,argv0:()=>Qn,assert:()=>Un,binding:()=>ln,browser:()=>yn,chdir:()=>hn,config:()=>xn,cpuUsage:()=>it,cwd:()=>fn,debugPort:()=>Xn,default:()=>hr,dlopen:()=>En,domain:()=>In,emit:()=>pr,emitWarning:()=>pn,env:()=>on,execArgv:()=>an,execPath:()=>Jn,exit:()=>Pn,features:()=>Ln,hasUncaughtExceptionCaptureCallback:()=>$n,hrtime:()=>rt,kill:()=>Bn,listeners:()=>fr,memoryUsage:()=>kn,moduleLoadList:()=>wn,nextTick:()=>Zt,off:()=>ar,on:()=>ae,once:()=>sr,openStdin:()=>Sn,pid:()=>Yn,platform:()=>rn,ppid:()=>Kn,prependListener:()=>lr,prependOnceListener:()=>dr,reallyExit:()=>An,release:()=>mn,removeAllListeners:()=>ur,removeListener:()=>cr,resourceUsage:()=>Fn,setSourceMapsEnabled:()=>er,setUncaughtExceptionCaptureCallback:()=>Mn,stderr:()=>jn,stdin:()=>Hn,stdout:()=>Gn,title:()=>tn,umask:()=>dn,uptime:()=>tr,version:()=>cn,versions:()=>un});function xt(u){throw new Error("Node.js process "+u+" is not supported by JSPM core outside of Node.js")}function Xr(){!Ue||!ye||(Ue=!1,ye.length?se=ye.concat(se):nt=-1,se.length&&Qt())}function Qt(){if(!Ue){var u=setTimeout(Xr,0);Ue=!0;for(var t=se.length;t;){for(ye=se,se=[];++nt<t;)ye&&ye[nt].run();nt=-1,t=se.length}ye=null,Ue=!1,clearTimeout(u)}}function Zt(u){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];se.push(new en(u,t)),se.length===1&&!Ue&&setTimeout(Qt,0)}function en(u,t){this.fun=u,this.array=t}function H(){}function vn(u){xt("_linkedBinding")}function En(u){xt("dlopen")}function Nn(){return[]}function bn(){return[]}function Un(u,t){if(!u)throw new Error(t||"assertion error")}function $n(){return!1}function tr(){return fe.now()/1e3}function rt(u){var t=Math.floor((Date.now()-fe.now())*.001),e=fe.now()*.001,i=Math.floor(e)+t,a=Math.floor(e%1*1e9);return u&&(i=i-u[0],a=a-u[1],a<0&&(i--,a+=Tt)),[i,a]}function ae(){return hr}function fr(u){return[]}var se,Ue,ye,nt,tn,nn,rn,on,sn,an,cn,un,pn,ln,dn,fn,hn,mn,yn,gn,wn,In,Tn,xn,An,Rn,it,Fn,kn,Bn,Pn,Sn,Cn,Ln,_n,Mn,Dn,On,Vn,Wn,qn,Gn,jn,Hn,zn,Yn,Kn,Jn,Xn,Qn,Zn,er,fe,It,Tt,nr,rr,ir,or,sr,ar,cr,ur,pr,lr,dr,hr,mr=oe(()=>{"use strict";y();w();g();se=[],Ue=!1,nt=-1;en.prototype.run=function(){this.fun.apply(null,this.array)};tn="browser",nn="x64",rn="browser",on={PATH:"/usr/bin",LANG:typeof navigator<"u"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},sn=["/usr/bin/node"],an=[],cn="v16.8.0",un={},pn=function(u,t){console.warn((t?t+": ":"")+u)},ln=function(u){xt("binding")},dn=function(u){return 0},fn=function(){return"/"},hn=function(u){},mn={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};yn=!0,gn=H,wn=[];In={},Tn=!1,xn={};An=H,Rn=H,it=function(){return{}},Fn=it,kn=it,Bn=H,Pn=H,Sn=H,Cn={};Ln={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},_n=H,Mn=H;Dn=H,On=H,Vn=H,Wn=H,qn=H,Gn=void 0,jn=void 0,Hn=void 0,zn=H,Yn=2,Kn=1,Jn="/bin/usr/node",Xn=9229,Qn="node",Zn=[],er=H,fe={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};fe.now===void 0&&(It=Date.now(),fe.timing&&fe.timing.navigationStart&&(It=fe.timing.navigationStart),fe.now=()=>Date.now()-It);Tt=1e9;rt.bigint=function(u){var t=rt(u);return typeof BigInt>"u"?t[0]*Tt+t[1]:BigInt(t[0]*Tt)+BigInt(t[1])};nr=10,rr={},ir=0;or=ae,sr=ae,ar=ae,cr=ae,ur=ae,pr=H,lr=ae,dr=ae;hr={version:cn,versions:un,arch:nn,platform:rn,browser:yn,release:mn,_rawDebug:gn,moduleLoadList:wn,binding:ln,_linkedBinding:vn,_events:rr,_eventsCount:ir,_maxListeners:nr,on:ae,addListener:or,once:sr,off:ar,removeListener:cr,removeAllListeners:ur,emit:pr,prependListener:lr,prependOnceListener:dr,listeners:fr,domain:In,_exiting:Tn,config:xn,dlopen:En,uptime:tr,_getActiveRequests:Nn,_getActiveHandles:bn,reallyExit:An,_kill:Rn,cpuUsage:it,resourceUsage:Fn,memoryUsage:kn,kill:Bn,exit:Pn,openStdin:Sn,allowedNodeEnvironmentFlags:Cn,assert:Un,features:Ln,_fatalExceptions:_n,setUncaughtExceptionCaptureCallback:Mn,hasUncaughtExceptionCaptureCallback:$n,emitWarning:pn,nextTick:Zt,_tickCallback:Dn,_debugProcess:On,_debugEnd:Vn,_startProfilerIdleNotifier:Wn,_stopProfilerIdleNotifier:qn,stdout:Gn,stdin:Hn,stderr:jn,abort:zn,umask:dn,chdir:hn,cwd:fn,env:on,title:tn,argv:sn,execArgv:an,pid:Yn,ppid:Kn,execPath:Jn,debugPort:Xn,hrtime:rt,argv0:Qn,_preload_modules:Zn,setSourceMapsEnabled:er}});var g=oe(()=>{"use strict";mr()});function Qr(){if(yr)return De;yr=!0,De.byteLength=f,De.toByteArray=x,De.fromByteArray=F;for(var u=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,p=i.length;a<p;++a)u[a]=i[a],t[i.charCodeAt(a)]=a;t[45]=62,t[95]=63;function s(N){var k=N.length;if(k%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var S=N.indexOf("=");S===-1&&(S=k);var P=S===k?0:4-S%4;return[S,P]}function f(N){var k=s(N),S=k[0],P=k[1];return(S+P)*3/4-P}function I(N,k,S){return(k+S)*3/4-S}function x(N){var k,S=s(N),P=S[0],G=S[1],$=new e(I(N,P,G)),V=0,Q=G>0?P-4:P,Y;for(Y=0;Y<Q;Y+=4)k=t[N.charCodeAt(Y)]<<18|t[N.charCodeAt(Y+1)]<<12|t[N.charCodeAt(Y+2)]<<6|t[N.charCodeAt(Y+3)],$[V++]=k>>16&255,$[V++]=k>>8&255,$[V++]=k&255;return G===2&&(k=t[N.charCodeAt(Y)]<<2|t[N.charCodeAt(Y+1)]>>4,$[V++]=k&255),G===1&&(k=t[N.charCodeAt(Y)]<<10|t[N.charCodeAt(Y+1)]<<4|t[N.charCodeAt(Y+2)]>>2,$[V++]=k>>8&255,$[V++]=k&255),$}function E(N){return u[N>>18&63]+u[N>>12&63]+u[N>>6&63]+u[N&63]}function T(N,k,S){for(var P,G=[],$=k;$<S;$+=3)P=(N[$]<<16&16711680)+(N[$+1]<<8&65280)+(N[$+2]&255),G.push(E(P));return G.join("")}function F(N){for(var k,S=N.length,P=S%3,G=[],$=16383,V=0,Q=S-P;V<Q;V+=$)G.push(T(N,V,V+$>Q?Q:V+$));return P===1?(k=N[S-1],G.push(u[k>>2]+u[k<<4&63]+"==")):P===2&&(k=(N[S-2]<<8)+N[S-1],G.push(u[k>>10]+u[k>>4&63]+u[k<<2&63]+"=")),G.join("")}return De}function Zr(){if(gr)return ot;gr=!0;return ot.read=function(u,t,e,i,a){var p,s,f=a*8-i-1,I=(1<<f)-1,x=I>>1,E=-7,T=e?a-1:0,F=e?-1:1,N=u[t+T];for(T+=F,p=N&(1<<-E)-1,N>>=-E,E+=f;E>0;p=p*256+u[t+T],T+=F,E-=8);for(s=p&(1<<-E)-1,p>>=-E,E+=i;E>0;s=s*256+u[t+T],T+=F,E-=8);if(p===0)p=1-x;else{if(p===I)return s?NaN:(N?-1:1)*(1/0);s=s+Math.pow(2,i),p=p-x}return(N?-1:1)*s*Math.pow(2,p-i)},ot.write=function(u,t,e,i,a,p){var s,f,I,x=p*8-a-1,E=(1<<x)-1,T=E>>1,F=a===23?Math.pow(2,-24)-Math.pow(2,-77):0,N=i?0:p-1,k=i?1:-1,S=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(f=isNaN(t)?1:0,s=E):(s=Math.floor(Math.log(t)/Math.LN2),t*(I=Math.pow(2,-s))<1&&(s--,I*=2),s+T>=1?t+=F/I:t+=F*Math.pow(2,1-T),t*I>=2&&(s++,I/=2),s+T>=E?(f=0,s=E):s+T>=1?(f=(t*I-1)*Math.pow(2,a),s=s+T):(f=t*Math.pow(2,T-1)*Math.pow(2,a),s=0));a>=8;u[e+N]=f&255,N+=k,f/=256,a-=8);for(s=s<<a|f,x+=a;x>0;u[e+N]=s&255,N+=k,s/=256,x-=8);u[e+N-k]|=S*128},ot}function vr(){if(wr)return ge;wr=!0;let u=Qr(),t=Zr(),e=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ge.Buffer=s,ge.SlowBuffer=G,ge.INSPECT_MAX_BYTES=50;let i=2147483647;ge.kMaxLength=i,s.TYPED_ARRAY_SUPPORT=a(),!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function a(){try{let o=new Uint8Array(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,Uint8Array.prototype),Object.setPrototypeOf(o,n),o.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function p(o){if(o>i)throw new RangeError('The value "'+o+'" is invalid for option "size"');let n=new Uint8Array(o);return Object.setPrototypeOf(n,s.prototype),n}function s(o,n,r){if(typeof o=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return E(o)}return f(o,n,r)}s.poolSize=8192;function f(o,n,r){if(typeof o=="string")return T(o,n);if(ArrayBuffer.isView(o))return N(o);if(o==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o);if(te(o,ArrayBuffer)||o&&te(o.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(te(o,SharedArrayBuffer)||o&&te(o.buffer,SharedArrayBuffer)))return k(o,n,r);if(typeof o=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let c=o.valueOf&&o.valueOf();if(c!=null&&c!==o)return s.from(c,n,r);let l=S(o);if(l)return l;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof o[Symbol.toPrimitive]=="function")return s.from(o[Symbol.toPrimitive]("string"),n,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o)}s.from=function(o,n,r){return f(o,n,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function I(o){if(typeof o!="number")throw new TypeError('"size" argument must be of type number');if(o<0)throw new RangeError('The value "'+o+'" is invalid for option "size"')}function x(o,n,r){return I(o),o<=0?p(o):n!==void 0?typeof r=="string"?p(o).fill(n,r):p(o).fill(n):p(o)}s.alloc=function(o,n,r){return x(o,n,r)};function E(o){return I(o),p(o<0?0:P(o)|0)}s.allocUnsafe=function(o){return E(o)},s.allocUnsafeSlow=function(o){return E(o)};function T(o,n){if((typeof n!="string"||n==="")&&(n="utf8"),!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);let r=$(o,n)|0,c=p(r),l=c.write(o,n);return l!==r&&(c=c.slice(0,l)),c}function F(o){let n=o.length<0?0:P(o.length)|0,r=p(n);for(let c=0;c<n;c+=1)r[c]=o[c]&255;return r}function N(o){if(te(o,Uint8Array)){let n=new Uint8Array(o);return k(n.buffer,n.byteOffset,n.byteLength)}return F(o)}function k(o,n,r){if(n<0||o.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(o.byteLength<n+(r||0))throw new RangeError('"length" is outside of buffer bounds');let c;return n===void 0&&r===void 0?c=new Uint8Array(o):r===void 0?c=new Uint8Array(o,n):c=new Uint8Array(o,n,r),Object.setPrototypeOf(c,s.prototype),c}function S(o){if(s.isBuffer(o)){let n=P(o.length)|0,r=p(n);return r.length===0||o.copy(r,0,0,n),r}if(o.length!==void 0)return typeof o.length!="number"||vt(o.length)?p(0):F(o);if(o.type==="Buffer"&&Array.isArray(o.data))return F(o.data)}function P(o){if(o>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return o|0}function G(o){return+o!=o&&(o=0),s.alloc(+o)}s.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==s.prototype},s.compare=function(n,r){if(te(n,Uint8Array)&&(n=s.from(n,n.offset,n.byteLength)),te(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),!s.isBuffer(n)||!s.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===r)return 0;let c=n.length,l=r.length;for(let h=0,v=Math.min(c,l);h<v;++h)if(n[h]!==r[h]){c=n[h],l=r[h];break}return c<l?-1:l<c?1:0},s.isEncoding=function(n){switch(String(n).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(n,r){if(!Array.isArray(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return s.alloc(0);let c;if(r===void 0)for(r=0,c=0;c<n.length;++c)r+=n[c].length;let l=s.allocUnsafe(r),h=0;for(c=0;c<n.length;++c){let v=n[c];if(te(v,Uint8Array))h+v.length>l.length?(s.isBuffer(v)||(v=s.from(v)),v.copy(l,h)):Uint8Array.prototype.set.call(l,v,h);else if(s.isBuffer(v))v.copy(l,h);else throw new TypeError('"list" argument must be an Array of Buffers');h+=v.length}return l};function $(o,n){if(s.isBuffer(o))return o.length;if(ArrayBuffer.isView(o)||te(o,ArrayBuffer))return o.byteLength;if(typeof o!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof o);let r=o.length,c=arguments.length>2&&arguments[2]===!0;if(!c&&r===0)return 0;let l=!1;for(;;)switch(n){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return wt(o).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Kt(o).length;default:if(l)return c?-1:wt(o).length;n=(""+n).toLowerCase(),l=!0}}s.byteLength=$;function V(o,n,r){let c=!1;if((n===void 0||n<0)&&(n=0),n>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,n>>>=0,r<=n))return"";for(o||(o="utf8");;)switch(o){case"hex":return Vr(this,n,r);case"utf8":case"utf-8":return Ot(this,n,r);case"ascii":return Dr(this,n,r);case"latin1":case"binary":return Or(this,n,r);case"base64":return Mr(this,n,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Wr(this,n,r);default:if(c)throw new TypeError("Unknown encoding: "+o);o=(o+"").toLowerCase(),c=!0}}s.prototype._isBuffer=!0;function Q(o,n,r){let c=o[n];o[n]=o[r],o[r]=c}s.prototype.swap16=function(){let n=this.length;if(n%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<n;r+=2)Q(this,r,r+1);return this},s.prototype.swap32=function(){let n=this.length;if(n%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<n;r+=4)Q(this,r,r+3),Q(this,r+1,r+2);return this},s.prototype.swap64=function(){let n=this.length;if(n%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<n;r+=8)Q(this,r,r+7),Q(this,r+1,r+6),Q(this,r+2,r+5),Q(this,r+3,r+4);return this},s.prototype.toString=function(){let n=this.length;return n===0?"":arguments.length===0?Ot(this,0,n):V.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(n){if(!s.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:s.compare(this,n)===0},s.prototype.inspect=function(){let n="",r=ge.INSPECT_MAX_BYTES;return n=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(n+=" ... "),"<Buffer "+n+">"},e&&(s.prototype[e]=s.prototype.inspect),s.prototype.compare=function(n,r,c,l,h){if(te(n,Uint8Array)&&(n=s.from(n,n.offset,n.byteLength)),!s.isBuffer(n))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof n);if(r===void 0&&(r=0),c===void 0&&(c=n?n.length:0),l===void 0&&(l=0),h===void 0&&(h=this.length),r<0||c>n.length||l<0||h>this.length)throw new RangeError("out of range index");if(l>=h&&r>=c)return 0;if(l>=h)return-1;if(r>=c)return 1;if(r>>>=0,c>>>=0,l>>>=0,h>>>=0,this===n)return 0;let v=h-l,C=c-r,D=Math.min(v,C),M=this.slice(l,h),O=n.slice(r,c);for(let _=0;_<D;++_)if(M[_]!==O[_]){v=M[_],C=O[_];break}return v<C?-1:C<v?1:0};function Y(o,n,r,c,l){if(o.length===0)return-1;if(typeof r=="string"?(c=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,vt(r)&&(r=l?0:o.length-1),r<0&&(r=o.length+r),r>=o.length){if(l)return-1;r=o.length-1}else if(r<0)if(l)r=0;else return-1;if(typeof n=="string"&&(n=s.from(n,c)),s.isBuffer(n))return n.length===0?-1:Dt(o,n,r,c,l);if(typeof n=="number")return n=n&255,typeof Uint8Array.prototype.indexOf=="function"?l?Uint8Array.prototype.indexOf.call(o,n,r):Uint8Array.prototype.lastIndexOf.call(o,n,r):Dt(o,[n],r,c,l);throw new TypeError("val must be string, number or Buffer")}function Dt(o,n,r,c,l){let h=1,v=o.length,C=n.length;if(c!==void 0&&(c=String(c).toLowerCase(),c==="ucs2"||c==="ucs-2"||c==="utf16le"||c==="utf-16le")){if(o.length<2||n.length<2)return-1;h=2,v/=2,C/=2,r/=2}function D(O,_){return h===1?O[_]:O.readUInt16BE(_*h)}let M;if(l){let O=-1;for(M=r;M<v;M++)if(D(o,M)===D(n,O===-1?0:M-O)){if(O===-1&&(O=M),M-O+1===C)return O*h}else O!==-1&&(M-=M-O),O=-1}else for(r+C>v&&(r=v-C),M=r;M>=0;M--){let O=!0;for(let _=0;_<C;_++)if(D(o,M+_)!==D(n,_)){O=!1;break}if(O)return M}return-1}s.prototype.includes=function(n,r,c){return this.indexOf(n,r,c)!==-1},s.prototype.indexOf=function(n,r,c){return Y(this,n,r,c,!0)},s.prototype.lastIndexOf=function(n,r,c){return Y(this,n,r,c,!1)};function Sr(o,n,r,c){r=Number(r)||0;let l=o.length-r;c?(c=Number(c),c>l&&(c=l)):c=l;let h=n.length;c>h/2&&(c=h/2);let v;for(v=0;v<c;++v){let C=parseInt(n.substr(v*2,2),16);if(vt(C))return v;o[r+v]=C}return v}function Cr(o,n,r,c){return tt(wt(n,o.length-r),o,r,c)}function Ur(o,n,r,c){return tt(Hr(n),o,r,c)}function Lr(o,n,r,c){return tt(Kt(n),o,r,c)}function _r(o,n,r,c){return tt(zr(n,o.length-r),o,r,c)}s.prototype.write=function(n,r,c,l){if(r===void 0)l="utf8",c=this.length,r=0;else if(c===void 0&&typeof r=="string")l=r,c=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(c)?(c=c>>>0,l===void 0&&(l="utf8")):(l=c,c=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let h=this.length-r;if((c===void 0||c>h)&&(c=h),n.length>0&&(c<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");l||(l="utf8");let v=!1;for(;;)switch(l){case"hex":return Sr(this,n,r,c);case"utf8":case"utf-8":return Cr(this,n,r,c);case"ascii":case"latin1":case"binary":return Ur(this,n,r,c);case"base64":return Lr(this,n,r,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _r(this,n,r,c);default:if(v)throw new TypeError("Unknown encoding: "+l);l=(""+l).toLowerCase(),v=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Mr(o,n,r){return n===0&&r===o.length?u.fromByteArray(o):u.fromByteArray(o.slice(n,r))}function Ot(o,n,r){r=Math.min(o.length,r);let c=[],l=n;for(;l<r;){let h=o[l],v=null,C=h>239?4:h>223?3:h>191?2:1;if(l+C<=r){let D,M,O,_;switch(C){case 1:h<128&&(v=h);break;case 2:D=o[l+1],(D&192)===128&&(_=(h&31)<<6|D&63,_>127&&(v=_));break;case 3:D=o[l+1],M=o[l+2],(D&192)===128&&(M&192)===128&&(_=(h&15)<<12|(D&63)<<6|M&63,_>2047&&(_<55296||_>57343)&&(v=_));break;case 4:D=o[l+1],M=o[l+2],O=o[l+3],(D&192)===128&&(M&192)===128&&(O&192)===128&&(_=(h&15)<<18|(D&63)<<12|(M&63)<<6|O&63,_>65535&&_<1114112&&(v=_))}}v===null?(v=65533,C=1):v>65535&&(v-=65536,c.push(v>>>10&1023|55296),v=56320|v&1023),c.push(v),l+=C}return $r(c)}let Vt=4096;function $r(o){let n=o.length;if(n<=Vt)return String.fromCharCode.apply(String,o);let r="",c=0;for(;c<n;)r+=String.fromCharCode.apply(String,o.slice(c,c+=Vt));return r}function Dr(o,n,r){let c="";r=Math.min(o.length,r);for(let l=n;l<r;++l)c+=String.fromCharCode(o[l]&127);return c}function Or(o,n,r){let c="";r=Math.min(o.length,r);for(let l=n;l<r;++l)c+=String.fromCharCode(o[l]);return c}function Vr(o,n,r){let c=o.length;(!n||n<0)&&(n=0),(!r||r<0||r>c)&&(r=c);let l="";for(let h=n;h<r;++h)l+=Yr[o[h]];return l}function Wr(o,n,r){let c=o.slice(n,r),l="";for(let h=0;h<c.length-1;h+=2)l+=String.fromCharCode(c[h]+c[h+1]*256);return l}s.prototype.slice=function(n,r){let c=this.length;n=~~n,r=r===void 0?c:~~r,n<0?(n+=c,n<0&&(n=0)):n>c&&(n=c),r<0?(r+=c,r<0&&(r=0)):r>c&&(r=c),r<n&&(r=n);let l=this.subarray(n,r);return Object.setPrototypeOf(l,s.prototype),l};function W(o,n,r){if(o%1!==0||o<0)throw new RangeError("offset is not uint");if(o+n>r)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(n,r,c){n=n>>>0,r=r>>>0,c||W(n,r,this.length);let l=this[n],h=1,v=0;for(;++v<r&&(h*=256);)l+=this[n+v]*h;return l},s.prototype.readUintBE=s.prototype.readUIntBE=function(n,r,c){n=n>>>0,r=r>>>0,c||W(n,r,this.length);let l=this[n+--r],h=1;for(;r>0&&(h*=256);)l+=this[n+--r]*h;return l},s.prototype.readUint8=s.prototype.readUInt8=function(n,r){return n=n>>>0,r||W(n,1,this.length),this[n]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(n,r){return n=n>>>0,r||W(n,2,this.length),this[n]|this[n+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(n,r){return n=n>>>0,r||W(n,2,this.length),this[n]<<8|this[n+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(n,r){return n=n>>>0,r||W(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(n,r){return n=n>>>0,r||W(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},s.prototype.readBigUInt64LE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],c=this[n+7];(r===void 0||c===void 0)&&$e(n,this.length-8);let l=r+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24,h=this[++n]+this[++n]*2**8+this[++n]*2**16+c*2**24;return BigInt(l)+(BigInt(h)<<BigInt(32))}),s.prototype.readBigUInt64BE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],c=this[n+7];(r===void 0||c===void 0)&&$e(n,this.length-8);let l=r*2**24+this[++n]*2**16+this[++n]*2**8+this[++n],h=this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+c;return(BigInt(l)<<BigInt(32))+BigInt(h)}),s.prototype.readIntLE=function(n,r,c){n=n>>>0,r=r>>>0,c||W(n,r,this.length);let l=this[n],h=1,v=0;for(;++v<r&&(h*=256);)l+=this[n+v]*h;return h*=128,l>=h&&(l-=Math.pow(2,8*r)),l},s.prototype.readIntBE=function(n,r,c){n=n>>>0,r=r>>>0,c||W(n,r,this.length);let l=r,h=1,v=this[n+--l];for(;l>0&&(h*=256);)v+=this[n+--l]*h;return h*=128,v>=h&&(v-=Math.pow(2,8*r)),v},s.prototype.readInt8=function(n,r){return n=n>>>0,r||W(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},s.prototype.readInt16LE=function(n,r){n=n>>>0,r||W(n,2,this.length);let c=this[n]|this[n+1]<<8;return c&32768?c|4294901760:c},s.prototype.readInt16BE=function(n,r){n=n>>>0,r||W(n,2,this.length);let c=this[n+1]|this[n]<<8;return c&32768?c|4294901760:c},s.prototype.readInt32LE=function(n,r){return n=n>>>0,r||W(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},s.prototype.readInt32BE=function(n,r){return n=n>>>0,r||W(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},s.prototype.readBigInt64LE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],c=this[n+7];(r===void 0||c===void 0)&&$e(n,this.length-8);let l=this[n+4]+this[n+5]*2**8+this[n+6]*2**16+(c<<24);return(BigInt(l)<<BigInt(32))+BigInt(r+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24)}),s.prototype.readBigInt64BE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],c=this[n+7];(r===void 0||c===void 0)&&$e(n,this.length-8);let l=(r<<24)+this[++n]*2**16+this[++n]*2**8+this[++n];return(BigInt(l)<<BigInt(32))+BigInt(this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+c)}),s.prototype.readFloatLE=function(n,r){return n=n>>>0,r||W(n,4,this.length),t.read(this,n,!0,23,4)},s.prototype.readFloatBE=function(n,r){return n=n>>>0,r||W(n,4,this.length),t.read(this,n,!1,23,4)},s.prototype.readDoubleLE=function(n,r){return n=n>>>0,r||W(n,8,this.length),t.read(this,n,!0,52,8)},s.prototype.readDoubleBE=function(n,r){return n=n>>>0,r||W(n,8,this.length),t.read(this,n,!1,52,8)};function X(o,n,r,c,l,h){if(!s.isBuffer(o))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>l||n<h)throw new RangeError('"value" argument is out of bounds');if(r+c>o.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(n,r,c,l){if(n=+n,r=r>>>0,c=c>>>0,!l){let C=Math.pow(2,8*c)-1;X(this,n,r,c,C,0)}let h=1,v=0;for(this[r]=n&255;++v<c&&(h*=256);)this[r+v]=n/h&255;return r+c},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(n,r,c,l){if(n=+n,r=r>>>0,c=c>>>0,!l){let C=Math.pow(2,8*c)-1;X(this,n,r,c,C,0)}let h=c-1,v=1;for(this[r+h]=n&255;--h>=0&&(v*=256);)this[r+h]=n/v&255;return r+c},s.prototype.writeUint8=s.prototype.writeUInt8=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,1,255,0),this[r]=n&255,r+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,2,65535,0),this[r]=n&255,this[r+1]=n>>>8,r+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,2,65535,0),this[r]=n>>>8,this[r+1]=n&255,r+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,4,4294967295,0),this[r+3]=n>>>24,this[r+2]=n>>>16,this[r+1]=n>>>8,this[r]=n&255,r+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,4,4294967295,0),this[r]=n>>>24,this[r+1]=n>>>16,this[r+2]=n>>>8,this[r+3]=n&255,r+4};function Wt(o,n,r,c,l){Yt(n,c,l,o,r,7);let h=Number(n&BigInt(4294967295));o[r++]=h,h=h>>8,o[r++]=h,h=h>>8,o[r++]=h,h=h>>8,o[r++]=h;let v=Number(n>>BigInt(32)&BigInt(4294967295));return o[r++]=v,v=v>>8,o[r++]=v,v=v>>8,o[r++]=v,v=v>>8,o[r++]=v,r}function qt(o,n,r,c,l){Yt(n,c,l,o,r,7);let h=Number(n&BigInt(4294967295));o[r+7]=h,h=h>>8,o[r+6]=h,h=h>>8,o[r+5]=h,h=h>>8,o[r+4]=h;let v=Number(n>>BigInt(32)&BigInt(4294967295));return o[r+3]=v,v=v>>8,o[r+2]=v,v=v>>8,o[r+1]=v,v=v>>8,o[r]=v,r+8}s.prototype.writeBigUInt64LE=de(function(n,r=0){return Wt(this,n,r,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=de(function(n,r=0){return qt(this,n,r,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(n,r,c,l){if(n=+n,r=r>>>0,!l){let D=Math.pow(2,8*c-1);X(this,n,r,c,D-1,-D)}let h=0,v=1,C=0;for(this[r]=n&255;++h<c&&(v*=256);)n<0&&C===0&&this[r+h-1]!==0&&(C=1),this[r+h]=(n/v>>0)-C&255;return r+c},s.prototype.writeIntBE=function(n,r,c,l){if(n=+n,r=r>>>0,!l){let D=Math.pow(2,8*c-1);X(this,n,r,c,D-1,-D)}let h=c-1,v=1,C=0;for(this[r+h]=n&255;--h>=0&&(v*=256);)n<0&&C===0&&this[r+h+1]!==0&&(C=1),this[r+h]=(n/v>>0)-C&255;return r+c},s.prototype.writeInt8=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,1,127,-128),n<0&&(n=255+n+1),this[r]=n&255,r+1},s.prototype.writeInt16LE=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,2,32767,-32768),this[r]=n&255,this[r+1]=n>>>8,r+2},s.prototype.writeInt16BE=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,2,32767,-32768),this[r]=n>>>8,this[r+1]=n&255,r+2},s.prototype.writeInt32LE=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,4,2147483647,-2147483648),this[r]=n&255,this[r+1]=n>>>8,this[r+2]=n>>>16,this[r+3]=n>>>24,r+4},s.prototype.writeInt32BE=function(n,r,c){return n=+n,r=r>>>0,c||X(this,n,r,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),this[r]=n>>>24,this[r+1]=n>>>16,this[r+2]=n>>>8,this[r+3]=n&255,r+4},s.prototype.writeBigInt64LE=de(function(n,r=0){return Wt(this,n,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=de(function(n,r=0){return qt(this,n,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Gt(o,n,r,c,l,h){if(r+c>o.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function jt(o,n,r,c,l){return n=+n,r=r>>>0,l||Gt(o,n,r,4),t.write(o,n,r,c,23,4),r+4}s.prototype.writeFloatLE=function(n,r,c){return jt(this,n,r,!0,c)},s.prototype.writeFloatBE=function(n,r,c){return jt(this,n,r,!1,c)};function Ht(o,n,r,c,l){return n=+n,r=r>>>0,l||Gt(o,n,r,8),t.write(o,n,r,c,52,8),r+8}s.prototype.writeDoubleLE=function(n,r,c){return Ht(this,n,r,!0,c)},s.prototype.writeDoubleBE=function(n,r,c){return Ht(this,n,r,!1,c)},s.prototype.copy=function(n,r,c,l){if(!s.isBuffer(n))throw new TypeError("argument should be a Buffer");if(c||(c=0),!l&&l!==0&&(l=this.length),r>=n.length&&(r=n.length),r||(r=0),l>0&&l<c&&(l=c),l===c||n.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(c<0||c>=this.length)throw new RangeError("Index out of range");if(l<0)throw new RangeError("sourceEnd out of bounds");l>this.length&&(l=this.length),n.length-r<l-c&&(l=n.length-r+c);let h=l-c;return this===n&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,c,l):Uint8Array.prototype.set.call(n,this.subarray(c,l),r),h},s.prototype.fill=function(n,r,c,l){if(typeof n=="string"){if(typeof r=="string"?(l=r,r=0,c=this.length):typeof c=="string"&&(l=c,c=this.length),l!==void 0&&typeof l!="string")throw new TypeError("encoding must be a string");if(typeof l=="string"&&!s.isEncoding(l))throw new TypeError("Unknown encoding: "+l);if(n.length===1){let v=n.charCodeAt(0);(l==="utf8"&&v<128||l==="latin1")&&(n=v)}}else typeof n=="number"?n=n&255:typeof n=="boolean"&&(n=Number(n));if(r<0||this.length<r||this.length<c)throw new RangeError("Out of range index");if(c<=r)return this;r=r>>>0,c=c===void 0?this.length:c>>>0,n||(n=0);let h;if(typeof n=="number")for(h=r;h<c;++h)this[h]=n;else{let v=s.isBuffer(n)?n:s.from(n,l),C=v.length;if(C===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(h=0;h<c-r;++h)this[h+r]=v[h%C]}return this};let Se={};function gt(o,n,r){Se[o]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:n.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${o}]`,this.stack,delete this.name}get code(){return o}set code(l){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:l,writable:!0})}toString(){return`${this.name} [${o}]: ${this.message}`}}}gt("ERR_BUFFER_OUT_OF_BOUNDS",function(o){return o?`${o} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),gt("ERR_INVALID_ARG_TYPE",function(o,n){return`The "${o}" argument must be of type number. Received type ${typeof n}`},TypeError),gt("ERR_OUT_OF_RANGE",function(o,n,r){let c=`The value of "${o}" is out of range.`,l=r;return Number.isInteger(r)&&Math.abs(r)>2**32?l=zt(String(r)):typeof r=="bigint"&&(l=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(l=zt(l)),l+="n"),c+=` It must be ${n}. Received ${l}`,c},RangeError);function zt(o){let n="",r=o.length,c=o[0]==="-"?1:0;for(;r>=c+4;r-=3)n=`_${o.slice(r-3,r)}${n}`;return`${o.slice(0,r)}${n}`}function qr(o,n,r){Ce(n,"offset"),(o[n]===void 0||o[n+r]===void 0)&&$e(n,o.length-(r+1))}function Yt(o,n,r,c,l,h){if(o>r||o<n){let v=typeof n=="bigint"?"n":"",C;throw n===0||n===BigInt(0)?C=`>= 0${v} and < 2${v} ** ${(h+1)*8}${v}`:C=`>= -(2${v} ** ${(h+1)*8-1}${v}) and < 2 ** ${(h+1)*8-1}${v}`,new Se.ERR_OUT_OF_RANGE("value",C,o)}qr(c,l,h)}function Ce(o,n){if(typeof o!="number")throw new Se.ERR_INVALID_ARG_TYPE(n,"number",o)}function $e(o,n,r){throw Math.floor(o)!==o?(Ce(o,r),new Se.ERR_OUT_OF_RANGE("offset","an integer",o)):n<0?new Se.ERR_BUFFER_OUT_OF_BOUNDS:new Se.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${n}`,o)}let Gr=/[^+/0-9A-Za-z-_]/g;function jr(o){if(o=o.split("=")[0],o=o.trim().replace(Gr,""),o.length<2)return"";for(;o.length%4!==0;)o=o+"=";return o}function wt(o,n){n=n||1/0;let r,c=o.length,l=null,h=[];for(let v=0;v<c;++v){if(r=o.charCodeAt(v),r>55295&&r<57344){if(!l){if(r>56319){(n-=3)>-1&&h.push(239,191,189);continue}else if(v+1===c){(n-=3)>-1&&h.push(239,191,189);continue}l=r;continue}if(r<56320){(n-=3)>-1&&h.push(239,191,189),l=r;continue}r=(l-55296<<10|r-56320)+65536}else l&&(n-=3)>-1&&h.push(239,191,189);if(l=null,r<128){if((n-=1)<0)break;h.push(r)}else if(r<2048){if((n-=2)<0)break;h.push(r>>6|192,r&63|128)}else if(r<65536){if((n-=3)<0)break;h.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((n-=4)<0)break;h.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return h}function Hr(o){let n=[];for(let r=0;r<o.length;++r)n.push(o.charCodeAt(r)&255);return n}function zr(o,n){let r,c,l,h=[];for(let v=0;v<o.length&&!((n-=2)<0);++v)r=o.charCodeAt(v),c=r>>8,l=r%256,h.push(l),h.push(c);return h}function Kt(o){return u.toByteArray(jr(o))}function tt(o,n,r,c){let l;for(l=0;l<c&&!(l+r>=n.length||l>=o.length);++l)n[l+r]=o[l];return l}function te(o,n){return o instanceof n||o!=null&&o.constructor!=null&&o.constructor.name!=null&&o.constructor.name===n.name}function vt(o){return o!==o}let Yr=(function(){let o="0123456789abcdef",n=new Array(256);for(let r=0;r<16;++r){let c=r*16;for(let l=0;l<16;++l)n[c+l]=o[r]+o[l]}return n})();function de(o){return typeof BigInt>"u"?Kr:o}function Kr(){throw new Error("BigInt not supported")}return ge}var De,yr,ot,gr,ge,wr,Ir=oe(()=>{"use strict";y();w();g();De={},yr=!1;ot={},gr=!1;ge={},wr=!1});var we,A,gs,ws,Tr=oe(()=>{"use strict";y();w();g();Ir();we=vr();we.Buffer;we.SlowBuffer;we.INSPECT_MAX_BYTES;we.kMaxLength;A=we.Buffer,gs=we.INSPECT_MAX_BYTES,ws=we.kMaxLength});var w=oe(()=>{"use strict";Tr()});function kt(u){throw new Error("Node.js process "+u+" is not supported by JSPM core outside of Node.js")}function oi(){!Le||!Te||(Le=!1,Te.length?ce=Te.concat(ce):ut=-1,ce.length&&Nr())}function Nr(){if(!Le){var u=setTimeout(oi,0);Le=!0;for(var t=ce.length;t;){for(Te=ce,ce=[];++ut<t;)Te&&Te[ut].run();ut=-1,t=ce.length}Te=null,Le=!1,clearTimeout(u)}}function si(u){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];ce.push(new br(u,t)),ce.length===1&&!Le&&setTimeout(Nr,0)}function br(u,t){this.fun=u,this.array=t}function z(){}function Ei(u){kt("_linkedBinding")}function Ri(u){kt("dlopen")}function Fi(){return[]}function ki(){return[]}function $i(u,t){if(!u)throw new Error(t||"assertion error")}function Wi(){return!1}function oo(){return he.now()/1e3}function Ft(u){var t=Math.floor((Date.now()-he.now())*.001),e=he.now()*.001,i=Math.floor(e)+t,a=Math.floor(e%1*1e9);return u&&(i=i-u[0],a=a-u[1],a<0&&(i--,a+=Rt)),[i,a]}function me(){return Pt}function wo(u){return[]}var ce,Le,Te,ut,ai,ci,ui,pi,li,di,fi,hi,mi,yi,gi,wi,vi,Ii,Ti,xi,Ni,bi,Ai,Bi,Pi,Bt,Si,Ci,Ui,Li,_i,Mi,Di,Oi,Vi,qi,Gi,ji,Hi,zi,Yi,Ki,Ji,Xi,Qi,Zi,eo,to,no,ro,io,he,At,Rt,so,ao,co,uo,po,lo,fo,ho,mo,yo,go,Pt,St=oe(()=>{"use strict";y();w();g();ce=[],Le=!1,ut=-1;br.prototype.run=function(){this.fun.apply(null,this.array)};ai="browser",ci="x64",ui="browser",pi={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},li=["/usr/bin/node"],di=[],fi="v16.8.0",hi={},mi=function(u,t){console.warn((t?t+": ":"")+u)},yi=function(u){kt("binding")},gi=function(u){return 0},wi=function(){return"/"},vi=function(u){},Ii={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};Ti=z,xi=[];Ni={},bi=!1,Ai={};Bi=z,Pi=z,Bt=function(){return{}},Si=Bt,Ci=Bt,Ui=z,Li=z,_i=z,Mi={};Di={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},Oi=z,Vi=z;qi=z,Gi=z,ji=z,Hi=z,zi=z,Yi=void 0,Ki=void 0,Ji=void 0,Xi=z,Qi=2,Zi=1,eo="/bin/usr/node",to=9229,no="node",ro=[],io=z,he={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};he.now===void 0&&(At=Date.now(),he.timing&&he.timing.navigationStart&&(At=he.timing.navigationStart),he.now=()=>Date.now()-At);Rt=1e9;Ft.bigint=function(u){var t=Ft(u);return typeof BigInt>"u"?t[0]*Rt+t[1]:BigInt(t[0]*Rt)+BigInt(t[1])};so=10,ao={},co=0;uo=me,po=me,lo=me,fo=me,ho=me,mo=z,yo=me,go=me;Pt={version:fi,versions:hi,arch:ci,platform:ui,release:Ii,_rawDebug:Ti,moduleLoadList:xi,binding:yi,_linkedBinding:Ei,_events:ao,_eventsCount:co,_maxListeners:so,on:me,addListener:uo,once:po,off:lo,removeListener:fo,removeAllListeners:ho,emit:mo,prependListener:yo,prependOnceListener:go,listeners:wo,domain:Ni,_exiting:bi,config:Ai,dlopen:Ri,uptime:oo,_getActiveRequests:Fi,_getActiveHandles:ki,reallyExit:Bi,_kill:Pi,cpuUsage:Bt,resourceUsage:Si,memoryUsage:Ci,kill:Ui,exit:Li,openStdin:_i,allowedNodeEnvironmentFlags:Mi,assert:$i,features:Di,_fatalExceptions:Oi,setUncaughtExceptionCaptureCallback:Vi,hasUncaughtExceptionCaptureCallback:Wi,emitWarning:mi,nextTick:si,_tickCallback:qi,_debugProcess:Gi,_debugEnd:ji,_startProfilerIdleNotifier:Hi,_stopProfilerIdleNotifier:zi,stdout:Yi,stdin:Ji,stderr:Ki,abort:Xi,umask:gi,chdir:vi,cwd:wi,env:pi,title:ai,argv:li,execArgv:di,pid:Qi,ppid:Zi,execPath:eo,debugPort:to,hrtime:Ft,argv0:no,_preload_modules:ro,setSourceMapsEnabled:io}});function vo(){if(Ar)return Ct;Ar=!0;var u=Pt;function t(p){if(typeof p!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(p))}function e(p,s){for(var f="",I=0,x=-1,E=0,T,F=0;F<=p.length;++F){if(F<p.length)T=p.charCodeAt(F);else{if(T===47)break;T=47}if(T===47){if(!(x===F-1||E===1))if(x!==F-1&&E===2){if(f.length<2||I!==2||f.charCodeAt(f.length-1)!==46||f.charCodeAt(f.length-2)!==46){if(f.length>2){var N=f.lastIndexOf("/");if(N!==f.length-1){N===-1?(f="",I=0):(f=f.slice(0,N),I=f.length-1-f.lastIndexOf("/")),x=F,E=0;continue}}else if(f.length===2||f.length===1){f="",I=0,x=F,E=0;continue}}s&&(f.length>0?f+="/..":f="..",I=2)}else f.length>0?f+="/"+p.slice(x+1,F):f=p.slice(x+1,F),I=F-x-1;x=F,E=0}else T===46&&E!==-1?++E:E=-1}return f}function i(p,s){var f=s.dir||s.root,I=s.base||(s.name||"")+(s.ext||"");return f?f===s.root?f+I:f+p+I:I}var a={resolve:function(){for(var s="",f=!1,I,x=arguments.length-1;x>=-1&&!f;x--){var E;x>=0?E=arguments[x]:(I===void 0&&(I=u.cwd()),E=I),t(E),E.length!==0&&(s=E+"/"+s,f=E.charCodeAt(0)===47)}return s=e(s,!f),f?s.length>0?"/"+s:"/":s.length>0?s:"."},normalize:function(s){if(t(s),s.length===0)return".";var f=s.charCodeAt(0)===47,I=s.charCodeAt(s.length-1)===47;return s=e(s,!f),s.length===0&&!f&&(s="."),s.length>0&&I&&(s+="/"),f?"/"+s:s},isAbsolute:function(s){return t(s),s.length>0&&s.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var s,f=0;f<arguments.length;++f){var I=arguments[f];t(I),I.length>0&&(s===void 0?s=I:s+="/"+I)}return s===void 0?".":a.normalize(s)},relative:function(s,f){if(t(s),t(f),s===f||(s=a.resolve(s),f=a.resolve(f),s===f))return"";for(var I=1;I<s.length&&s.charCodeAt(I)===47;++I);for(var x=s.length,E=x-I,T=1;T<f.length&&f.charCodeAt(T)===47;++T);for(var F=f.length,N=F-T,k=E<N?E:N,S=-1,P=0;P<=k;++P){if(P===k){if(N>k){if(f.charCodeAt(T+P)===47)return f.slice(T+P+1);if(P===0)return f.slice(T+P)}else E>k&&(s.charCodeAt(I+P)===47?S=P:P===0&&(S=0));break}var G=s.charCodeAt(I+P),$=f.charCodeAt(T+P);if(G!==$)break;G===47&&(S=P)}var V="";for(P=I+S+1;P<=x;++P)(P===x||s.charCodeAt(P)===47)&&(V.length===0?V+="..":V+="/..");return V.length>0?V+f.slice(T+S):(T+=S,f.charCodeAt(T)===47&&++T,f.slice(T))},_makeLong:function(s){return s},dirname:function(s){if(t(s),s.length===0)return".";for(var f=s.charCodeAt(0),I=f===47,x=-1,E=!0,T=s.length-1;T>=1;--T)if(f=s.charCodeAt(T),f===47){if(!E){x=T;break}}else E=!1;return x===-1?I?"/":".":I&&x===1?"//":s.slice(0,x)},basename:function(s,f){if(f!==void 0&&typeof f!="string")throw new TypeError('"ext" argument must be a string');t(s);var I=0,x=-1,E=!0,T;if(f!==void 0&&f.length>0&&f.length<=s.length){if(f.length===s.length&&f===s)return"";var F=f.length-1,N=-1;for(T=s.length-1;T>=0;--T){var k=s.charCodeAt(T);if(k===47){if(!E){I=T+1;break}}else N===-1&&(E=!1,N=T+1),F>=0&&(k===f.charCodeAt(F)?--F===-1&&(x=T):(F=-1,x=N))}return I===x?x=N:x===-1&&(x=s.length),s.slice(I,x)}else{for(T=s.length-1;T>=0;--T)if(s.charCodeAt(T)===47){if(!E){I=T+1;break}}else x===-1&&(E=!1,x=T+1);return x===-1?"":s.slice(I,x)}},extname:function(s){t(s);for(var f=-1,I=0,x=-1,E=!0,T=0,F=s.length-1;F>=0;--F){var N=s.charCodeAt(F);if(N===47){if(!E){I=F+1;break}continue}x===-1&&(E=!1,x=F+1),N===46?f===-1?f=F:T!==1&&(T=1):f!==-1&&(T=-1)}return f===-1||x===-1||T===0||T===1&&f===x-1&&f===I+1?"":s.slice(f,x)},format:function(s){if(s===null||typeof s!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof s);return i("/",s)},parse:function(s){t(s);var f={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return f;var I=s.charCodeAt(0),x=I===47,E;x?(f.root="/",E=1):E=0;for(var T=-1,F=0,N=-1,k=!0,S=s.length-1,P=0;S>=E;--S){if(I=s.charCodeAt(S),I===47){if(!k){F=S+1;break}continue}N===-1&&(k=!1,N=S+1),I===46?T===-1?T=S:P!==1&&(P=1):T!==-1&&(P=-1)}return T===-1||N===-1||P===0||P===1&&T===N-1&&T===F+1?N!==-1&&(F===0&&x?f.base=f.name=s.slice(1,N):f.base=f.name=s.slice(F,N)):(F===0&&x?(f.name=s.slice(1,T),f.base=s.slice(1,N)):(f.name=s.slice(F,T),f.base=s.slice(F,N)),f.ext=s.slice(T,N)),F>0?f.dir=s.slice(0,F-1):x&&(f.dir="/"),f},sep:"/",delimiter:":",win32:null,posix:null};return a.posix=a,Ct=a,Ct}var Ct,Ar,q,Rr=oe(()=>{"use strict";y();w();g();St();Ct={},Ar=!1;q=vo()});var uu,pu,lu,du,fu,hu,mu,yu,gu,wu,vu,Iu,Tu,xu,Eu,Fr=oe(()=>{"use strict";y();w();g();Rr();St();uu=q._makeLong,pu=q.basename,lu=q.delimiter,du=q.dirname,fu=q.extname,hu=q.format,mu=q.isAbsolute,yu=q.join,gu=q.normalize,wu=q.parse,vu=q.posix,Iu=q.relative,Tu=q.resolve,xu=q.sep,Eu=q.win32});y();w();g();y();w();g();y();w();g();y();w();g();function U(u){throw new Error("Unexpected value: "+JSON.stringify(u))}y();w();g();function Oe(u){return Object.keys(u)}y();w();g();y();w();g();y();w();g();var Ve=b.env.FERN_STACK_TRACK?.toLowerCase()??"",ne=Ve!==""&&Ve!=="0"&&Ve!=="false",Et=["single","multiline","box"].includes(Ve)?Ve:"single";ne&&(Error.stackTraceLimit=50);var ei=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),ti=new Set(["stacktrace"]);function at({maxFrames:u=50,skip:t=0,filterPaths:e=[],filterFunctions:i=[],stopOn:a=[],filterNode:p=!0,filterJs:s=!0,formatFilename:f=I=>I}={}){if(!ne)return[];i=[...i,...ei],e=[...e,...ti],a=[...a,"runInteractiveTask"];let I=!1;return(new Error().stack??"").split(`
|
|
2
|
+
`).map(x=>{let E=x.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(E&&E.length===5){let[,T,F,N,k]=E;if(!T||!F||!N||!k)return;if(I||a.some(S=>T?.includes(S))){I=!0;return}switch(T){case"Object.<anonymous>":T="";break;case"Object.object":case"Object.alias":case"Object.union":case"Object.enum":case"Object.undiscriminatedUnion":T=`${T.substring(T.indexOf(".")+1)}()=> { ... }`;break}return{fn:T,path:f(F),position:`${N}:${k}`}}}).filter(x=>x&&!i.some(E=>x.fn.includes(E))&&!(p&&x.path?.startsWith("node:"))&&!(s&&x.path?.endsWith(".js"))&&!e.some(E=>x.path.includes(E))).slice(t,t+u)}var st=class{constructor({maxFrames:t=50,skip:e=0,filterPaths:i=[],filterFunctions:a=[],stopOn:p=[],filterNode:s=!0,filterJs:f=!0,multiline:I=!1,formatFilename:x=E=>E}={}){m(this,"maxFrames");m(this,"skip");m(this,"filterPaths");m(this,"filterFunctions");m(this,"stopOn");m(this,"filterNode");m(this,"filterJs");m(this,"multiline");m(this,"formatFilename");m(this,"tracking",new WeakMap);this.maxFrames=t,this.skip=e,this.filterPaths=i,this.filterFunctions=a,this.stopOn=p,this.filterNode=s,this.filterJs=f,this.multiline=I,this.formatFilename=x}tag(t){let e=this.tracking.get(t)||new Set;at({maxFrames:this.maxFrames,skip:this.skip,filterPaths:this.filterPaths,filterFunctions:this.filterFunctions,stopOn:this.stopOn,filterNode:this.filterNode,filterJs:this.filterJs,formatFilename:this.formatFilename}).forEach(i=>e.add(i)),this.tracking.set(t,e)}trace(t){if(!ne)return"";let e=this.tracking.get(t);return e?[...e].map(i=>`${this.multiline?`
|
|
3
|
+
`:""}${i.fn} - ${i.path}:${i.position}`).join(""):""}frames(t){let e=this.tracking.get(t);return e?[...e]:[]}free(t){this.tracking.delete(t)}clear(){this.tracking=new WeakMap}},Nt;function xr({maxFrames:u=50,skip:t=0,filterPaths:e=[],filterFunctions:i=[],stopOn:a=[],filterNode:p=!0,filterJs:s=!0,multiline:f=!1,formatFilename:I=x=>x}={}){ne&&(Nt??(Nt=new st({maxFrames:u,skip:t,filterPaths:e,filterFunctions:i,stopOn:a,filterNode:p,filterJs:s,multiline:f,formatFilename:I})))}function Er(u){Nt?.tag(u)}function bt(u){return Nt?.frames(u)??[]}var ve=class{constructor(){Er(this)}};y();w();g();var ct=class{formatMultiple(t){return Promise.all(t.map(e=>this.format(e)))}formatMultipleSync(t){return t.map(e=>this.formatSync(e))}},We=class extends ct{async format(t){return t}formatSync(t){return t}};y();w();g();y();w();g();y();w();g();var Z=class extends ve{constructor(e){super();m(this,"value");this.value=e}write(e){typeof this.value=="string"?e.write(this.value):typeof this.value=="function"?this.value(e):this.value.write(e)}};var ni=4;xr({skip:0,maxFrames:15,filterFunctions:["Abstract"]});var qe=class{constructor(){m(this,"lineBuffer",[]);m(this,"indentLevel",0);m(this,"hasWrittenAnything",!1);m(this,"lastCharacterIsSemicolon",!1);m(this,"lastCharacterIsNewline",!1);m(this,"nodeStackFrames",[])}get buffer(){return ne&&this.nodeStackFrames.length>0&&this.writeInternal(`
|
|
4
|
+
`),this.lineBuffer.join(`
|
|
5
|
+
`)+(this.lastCharacterIsNewline?`
|
|
6
|
+
`:"")}write(...t){for(let e of t)if(e!=null)if(typeof e=="string"){let i=e.length>0&&e.endsWith(`
|
|
7
|
+
`),a=i?e.substring(0,e.length-1):e,p=this.getIndentString(),s=a.replaceAll(`
|
|
8
|
+
`,`
|
|
9
|
+
${p}`);this.isAtStartOfLine()&&(s=p+s),i&&(s+=`
|
|
10
|
+
`),this.writeInternal(s)}else this.writeNode(e)}writeStatement(...t){this.write(...t),this.write(";"),this.writeNewLineIfLastLineNot()}writeNoIndent(t){let e=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=e}writeNode(t){ne&&this.nodeStackFrames.push(...bt(t)),t.write(this),ne&&Et!=="single"&&this.writeInternal(`
|
|
11
|
+
`)}writeNodeOrString(t){if(typeof t=="string"){this.write(t);return}this.writeNode(t)}writeNodeStatement(t){this.writeNode(t),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new Z(t).write(this),t.endsWith(";")||this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(t,e){new Z(t).write(this),this.write(" (",e,")"),this.pushScope()}controlFlowWithoutStatement(t){new Z(t).write(this),this.pushScope()}endControlFlow(){this.popScope()}contiguousControlFlow(t,e){this.dedent(),this.write("} "),new Z(t).write(this),this.write(" (",e,")"),this.pushScope()}alternativeControlFlow(t){this.dedent(),this.write("} "),new Z(t).write(this),this.pushScope()}pushScope(){this.writeLine("{"),this.indent()}popScope(t=!0){this.dedent(),this.writeNewLineIfLastLineNot(),t?this.writeLine("}"):this.write("}")}writeLine(...t){this.write(...t.length===0?[""]:t),this.writeNewLineIfLastLineNot()}newLine(){this.writeInternal(`
|
|
12
|
+
`)}writeSemicolonIfLastCharacterIsNot(){this.lastCharacterIsSemicolon||this.writeInternal(";")}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
|
|
13
|
+
`)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:t,delimiter:e,writeFunction:i}){if(t.length>0){let a=t[0];a!=null&&i(a);for(let p=1;p<t.length;p++){this.write(e);let s=t[p];s!=null&&i(s)}}}toString(){return this.buffer}writeInternal(t){if(t.length===0)return;let e=!this.lastCharacterIsNewline;this.hasWrittenAnything=!0,this.lastCharacterIsNewline=t.endsWith(`
|
|
14
|
+
`),this.lastCharacterIsSemicolon=t.endsWith(";");let i=t.split(`
|
|
15
|
+
`),a=ne&&!this.shouldSkipTracking(i)&&this.lastCharacterIsNewline;e&&(this.lastLine=`${this.lastLine}${i.shift()||""}`),this.lastCharacterIsNewline&&i.pop(),this.lineBuffer.push(...i),a&&this.appendTrackingComment()}set lastLine(t){this.lineBuffer.length>0?this.lineBuffer[this.lineBuffer.length-1]=t:this.lineBuffer.push(t)}get lastLine(){return this.lineBuffer[this.lineBuffer.length-1]||""}shouldSkipTracking(t){return!1}formatStack(t,e=""){return t.map(i=>`${e?`(${e}) `:""} ${i.fn} - ${i.path} : ${i.position}`)}filterStack(t){return t.filter(e=>!e.fn.startsWith(`${this.constructor.name}.`))}appendTrackingComment(){let t=[...this.formatStack(this.filterStack(at({maxFrames:15,skip:3}))),...this.formatStack(this.filterStack(this.nodeStackFrames),"node")];switch(this.nodeStackFrames.length=0,Et){case"single":return this.singleLineTrackingComment(t);case"multiline":return this.multiLineTrackingComment(t);case"box":return this.boxTrackingComment(t)}}singleLineTrackingComment(t){this.lastLine=`${this.lastLine} // ${t.join(" ")}`}multiLineTrackingComment(t){this.lineBuffer.push(...t.map(e=>` // ${e}`))}boxTrackingComment(t){this.lineBuffer.push("/*",...t.map(e=>` ${e}`),"*/")}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*this.getTabSize())}getTabSize(){return ni}};y();w();g();y();w();g();y();w();g();var Ge=class{constructor(){m(this,"reporter");m(this,"snippet");m(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:t,snippet:e}){this.shouldUpdate({snippet:e,reporter:t.errors})&&(this.reporter=t.errors.clone(),this.snippet=e)}getResponseOrThrow({endpoint:t}){if(this.snippet!=null&&this.reporter!=null)return{snippet:this.snippet,errors:this.reporter.toDynamicSnippetErrors()};throw this.err??new Error(`Failed to generate snippet for endpoint "${t.method} ${t.path}"`)}shouldUpdate({snippet:t,reporter:e}){return this.reporter==null||this.reporter.size()>0&&e.size()===0?!0:t.length>(this.snippet?.length??0)}};var je=class{constructor(t){m(this,"context");this.context=t}async generate(t,e={}){let i=this.context.resolveEndpointLocationOrThrow(t.endpoint);if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let a=new Ge;for(let p of i){let s=this.context.clone(),f=this.createSnippetGenerator(s);try{let I=await f.generateSnippet({endpoint:p,request:t,options:e});if(s.errors.empty())return{snippet:I,errors:void 0};a.update({context:s,snippet:I})}catch(I){a.err==null&&(a.err=I)}}return a.getResponseOrThrow({endpoint:t.endpoint})}async generateSnippetAst(t,e={}){let i=this.context.resolveEndpointLocationOrThrow(t.endpoint);if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let a;for(let p of i){let s=this.context.clone(),f=this.createSnippetGenerator(s);try{return await f.generateSnippetAst({endpoint:p,request:t,options:e})}catch(I){a=I}}throw a??new Error(`Failed to generate snippet AST for endpoint: ${t.endpoint.method} ${t.endpoint.path}`)}generateSync(t,e={}){let i=this.context.resolveEndpointLocationOrThrow(t.endpoint);if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let a=new Ge;for(let p of i){let s=this.context.clone(),f=this.createSnippetGenerator(s);try{let I=f.generateSnippetSync({endpoint:p,request:t,options:e});if(s.errors.empty())return{snippet:I,errors:void 0};a.update({context:s,snippet:I})}catch(I){a.err==null&&(a.err=I)}}return a.getResponseOrThrow({endpoint:t.endpoint})}};y();w();g();y();w();g();y();w();g();var He=class{constructor(){m(this,"REFERENCE_REGEX",/^(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/)}validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let i=t.match(this.REFERENCE_REGEX);if(!(i==null||i[1]==null||i[2]==null))return{method:i[1],path:i[2]}}};y();w();g();var L={Critical:"CRITICAL",Warning:"WARNING"},ze=class u{constructor(){m(this,"errors");m(this,"path");this.errors=[],this.path=[]}add(t){this.errors.push({...t,path:[...this.path]})}scope(t){this.path.push(t)}unscope(){this.path.pop()}getBySeverity(t){return this.errors.filter(e=>e.severity===t)}empty(){return this.errors.length===0}size(){return this.errors.length}clone(){let t=new u;return t.errors=[...this.errors],t.path=[...this.path],t}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(t=>({severity:t.severity,path:t.path!=null?this.pathToStringArray(t.path):void 0,message:t.message}))}pathToStringArray(t){let e=[];for(let i of t){if(typeof i=="string"){e.push(i);continue}e[e.length-1]+=`[${i.index}]`}return e}};var Ye=class{constructor({ir:t,config:e,options:i={}}){m(this,"config");m(this,"options");m(this,"errors");m(this,"_ir");m(this,"httpEndpointReferenceParser");this._ir=t,this.config=e,this.options=i,this.errors=new ze,this.httpEndpointReferenceParser=new He}associateQueryParametersByWireValue({parameters:t,values:e}){let i=[];for(let[a,p]of Object.entries(e)){this.errors.scope(a);try{let s=t.find(I=>I.name.wireValue===a);if(s==null)throw this.newParameterNotRecognizedError(a);let f=this.isListTypeReference(s.typeReference)&&!Array.isArray(p)?[p]:p;i.push({name:s.name,typeReference:s.typeReference,value:f})}finally{this.errors.unscope()}}return i}associateByWireValueOrDefault({parameters:t,values:e}){let i=[];for(let a of t){this.errors.scope(a.name.wireValue);try{let p=e[a.name.wireValue];if(p==null)if(a.typeReference.type==="primitive"&&a.typeReference.value==="STRING")p=`<${a.name.wireValue}>`;else{this.errors.add({severity:L.Critical,message:this.newParameterNotRecognizedError(a.name.wireValue).message});continue}i.push({name:a.name,typeReference:a.typeReference,value:p})}finally{this.errors.unscope()}}return i}associateByWireValue({parameters:t,values:e,ignoreMissingParameters:i}){let a=[];for(let[p,s]of Object.entries(e)){this.errors.scope(p);try{let f=t.find(I=>I.name.wireValue===p);if(f==null){if(i)continue;this.errors.add({severity:L.Critical,message:this.newParameterNotRecognizedError(p).message});continue}a.push({name:f.name,typeReference:f.typeReference,value:s})}finally{this.errors.unscope()}}return a}getExampleObjectProperties({parameters:t,snippetObject:e}){let i=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},a=[];for(let p of t){let s=i[p.name.wireValue];s==null?p.typeReference.type==="nullable"&&a.push({name:p.name,typeReference:p.typeReference,value:null}):a.push({name:p.name,typeReference:p.typeReference,value:s})}return a}getSingleFileValue({property:t,record:e}){let i=e[t.wireValue];if(i!=null){if(typeof i!="string"){this.errors.add({severity:L.Critical,message:`Expected file value to be a string, got ${typeof i}`});return}return i}}getFileArrayValues({property:t,record:e}){let i=e[t.wireValue];if(i==null)return;if(!Array.isArray(i)){this.errors.add({severity:L.Critical,message:`Expected file array value to be an array of strings, got ${typeof i}`});return}let a=[];for(let p of i){if(typeof p!="string"){this.errors.add({severity:L.Critical,message:`Expected file array value to be an array of strings, got ${typeof p}`});return}a.push(p)}return a}getRecord(t){if(typeof t!="object"||Array.isArray(t)){this.errors.add({severity:L.Critical,message:`Expected object with key, value pairs but got: ${Array.isArray(t)?"array":typeof t}`});return}return t??{}}resolveNamedType({typeId:t}){let e=this._ir.types[t];if(e==null){this.errors.add({severity:L.Critical,message:`Type identified by "${t}" could not be found`});return}return e}resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e}){let i=this.getRecord(e);if(i==null)return;let a=t.discriminant.wireValue,p=i[a];if(p==null){this.errors.add({severity:L.Critical,message:this.newParameterNotRecognizedError(a).message});return}if(typeof p!="string"){this.errors.add({severity:L.Critical,message:`Expected discriminant value to be a string but got: ${typeof p}`});return}let s=t.types[p];if(s==null){this.errors.add({severity:L.Critical,message:`No type found for discriminant value "${p}"`});return}let{[a]:f,...I}=i;return{singleDiscriminatedUnionType:s,discriminantValue:s.discriminantValue,value:I}}resolveEndpointOrThrow(t){let e=this.httpEndpointReferenceParser.tryParse(t);if(e==null)throw new Error(`Failed to parse endpoint reference "${t}"`);return this.resolveEndpointLocationOrThrow(e)}resolveEndpointLocation(t){let e=[];for(let i of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:i,parsedEndpoint:t})&&e.push(i);return e}resolveEndpointLocationOrThrow(t){let e=this.resolveEndpointLocation(t);if(e.length===0)throw new Error(`Failed to find endpoint identified by "${t.method} ${t.path}"`);return e}needsRequestParameter({request:t,inlinePathParameters:e,inlineFileProperties:i}){return this.includePathParametersInWrappedRequest({request:t,inlinePathParameters:e})||t.queryParameters!=null&&t.queryParameters.length>0||t.headers!=null&&t.headers.length>0?!0:t.body!=null?this.includeRequestBodyInWrappedRequest({body:t.body,inlineFileProperties:i}):!t.metadata?.onlyPathParameters}includePathParametersInWrappedRequest({request:t,inlinePathParameters:e}){return e&&(t.metadata?.includePathParameters??!1)}isFileUploadRequestBody(t){switch(t.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:U(t)}}resolveEnvironmentName(t){if(this._ir.environments==null)return;let e=this._ir.environments.environments;switch(e.type){case"singleBaseUrl":{let i=e.environments.find(a=>a.id===t);return i?.name}case"multipleBaseUrls":{let i=e.environments.find(a=>a.id===t);return i?.name}default:U(e)}}isSingleEnvironmentID(t){return typeof t=="string"}isMultiEnvironmentValues(t){return typeof t=="object"}validateMultiEnvironmentUrlValues(t){if(this._ir.environments==null)return this.errors.add({severity:L.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;let e=this._ir.environments.environments;switch(e.type){case"singleBaseUrl":return this.errors.add({severity:L.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let i=e.environments[0];if(i==null)return this.errors.add({severity:L.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let a=new Set(Oe(i.urls));for(let p of Oe(t))a.has(p)&&a.delete(p);return a.size>0?(this.errors.add({severity:L.Critical,message:`The provided environments are invalid; got: [${Object.keys(t).join(", ")}], expected: [${Oe(i.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:t}){if(typeof t!="number"){this.errors.add({severity:L.Critical,message:this.newTypeMismatchError({expected:"number",value:t}).message});return}return t}getValueAsBoolean({value:t}){if(typeof t!="boolean"){this.errors.add({severity:L.Critical,message:this.newTypeMismatchError({expected:"boolean",value:t}).message});return}return t}getValueAsString({value:t}){if(typeof t!="string"){this.errors.add({severity:L.Critical,message:this.newTypeMismatchError({expected:"string",value:t}).message});return}return t}isOptional(t){switch(t.type){case"nullable":return this.isOptional(t.value);case"optional":return!0;case"named":{let e=this.resolveNamedType({typeId:t.value});return e==null?!1:e.type==="alias"?this.isNullable(e.typeReference):!1}}return!1}isNullable(t){switch(t.type){case"nullable":return!0;case"optional":return this.isNullable(t.value);case"named":{let e=this.resolveNamedType({typeId:t.value});return e==null?!1:e.type==="alias"?this.isNullable(e.typeReference):!1}}return!1}newAuthMismatchError({auth:t,values:e}){return new Error(`Expected auth type ${t.type}, got ${e.type}`)}newParameterNotRecognizedError(t){return new Error(`"${t}" is not a recognized parameter for this endpoint`)}newTypeMismatchError({expected:t,value:e}){return new Error(`Expected ${t}, got ${typeof e}`)}includeRequestBodyInWrappedRequest({body:t,inlineFileProperties:e}){switch(t.type){case"properties":case"referenced":return!0;case"fileUpload":return this.includeFileUploadBodyInWrappedRequest({fileUpload:t,inlineFileProperties:e});default:U(t)}}includeFileUploadBodyInWrappedRequest({fileUpload:t,inlineFileProperties:e}){return this.fileUploadHasBodyProperties({fileUpload:t})||e&&this.fileUploadHasFileProperties({fileUpload:t})}fileUploadHasBodyProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!1;case"bodyProperty":return!0;default:U(e)}})}fileUploadHasFileProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:U(e)}})}isListTypeReference(t){return t.type==="optional"?this.isListTypeReference(t.value):t.type==="list"||t.type==="set"}parsedEndpointMatches({endpoint:t,parsedEndpoint:e}){return t.location.method===e.method&&t.location.path===e.path}};y();w();g();var re={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};y();w();g();y();w();g();function Ke(u,t){let e=u.split("/").pop()??u;return t?.stripExtension?e.split(".")[0]??e:e}y();w();g();y();w();g();y();w();g();y();w();g();var ri=/[^0-9a-zA-Z_]/g,ii=["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],Ie=class extends qe{constructor({packageName:e,rootImportPath:i,importPath:a,customConfig:p,formatter:s}){super();m(this,"packageName");m(this,"rootImportPath");m(this,"importPath");m(this,"customConfig");m(this,"formatter");m(this,"imports",{});this.packageName=e,this.rootImportPath=i,this.importPath=a,this.customConfig=p,this.formatter=s??new We}addImport(e){let i=this.imports[e];if(i!=null)return i;if(e===this.rootImportPath&&this.customConfig.packageName!=null)return this.imports[e]=this.customConfig.packageName,this.customConfig.packageName;let a=new Set(Object.values(this.imports)),p=e.split("/");for(let f=1;f<=p.length;f++){let I=p.slice(-f),x=this.getValidAlias(I.join(""));if(!a.has(x))return this.imports[e]=x,x}let s=this.getValidAlias(Ke(e));for(;a.has(s);)s="_"+s;return this.imports[e]=s,s}isValidAlias(e){return!ii.includes(e)}getValidAlias(e){let i=e.split("-");if(i[0]==null)return e;let a=i.map(p=>p.replace(ri,"")).join("");return this.isValidAlias(a)?a:"_"+a}};var Je=class extends Ie{constructor({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:p}){super({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:p})}async toStringAsync(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.format(t)}catch(e){throw new Error(`Failed to format Go file: ${e}
|
|
16
|
+
${t}`)}return t}toString(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.formatSync(t)}catch(e){throw new Error(`Failed to format Go file: ${e}
|
|
17
|
+
${t}`)}return t}getContent(){let t=`package ${this.packageName}
|
|
18
|
+
|
|
19
|
+
`,e=this.stringifyImports();return e.length>0?`${t}${e}
|
|
20
|
+
|
|
21
|
+
${this.buffer}`:t+this.buffer}stringifyImports(){let t=Object.entries(this.imports).filter(([e,i])=>e!==this.importPath).map(([e,i])=>` ${i} "${e}"`).join(`
|
|
22
|
+
`);return t?`import (
|
|
23
|
+
${t}
|
|
24
|
+
)`:""}};var d={};Xt(d,{Alias:()=>xe,AstNode:()=>B,CodeBlock:()=>ie,Enum:()=>Ee,Field:()=>Ne,File:()=>be,Func:()=>Ae,FuncInvocation:()=>ee,IoReaderTypeReference:()=>Ut,Method:()=>le,MethodInvocation:()=>pe,MultiNode:()=>Xe,Parameter:()=>Re,Pointer:()=>Fe,Selector:()=>ke,Struct:()=>Be,TimeTypeReference:()=>pt,Type:()=>Ze,TypeDeclaration:()=>Pe,TypeInstantiation:()=>K,TypeReference:()=>J,UuidTypeReference:()=>lt,Writer:()=>Ie,alias:()=>Po,codeblock:()=>So,enum_:()=>Co,field:()=>Uo,file:()=>Lo,func:()=>_o,identifier:()=>Mo,invokeFunc:()=>$o,invokeMethod:()=>Do,method:()=>Oo,parameter:()=>Vo,pointer:()=>Wo,selector:()=>qo,struct:()=>Go,switch_:()=>jo,typeDeclaration:()=>Ho,typeReference:()=>zo});y();w();g();y();w();g();y();w();g();y();w();g();y();w();g();var B=class extends ve{async toStringAsync({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:p}){let s=new Je({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:p});return this.write(s),s.toStringAsync()}toString({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:p}){let s=new Je({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:p});return this.write(s),s.toString()}};var j=class extends B{constructor({docs:e}={}){super();m(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
|
|
25
|
+
`).forEach(i=>{e.writeLine(`// ${i}`)})}};var xe=class extends B{constructor({name:e,type:i,docs:a}){super();m(this,"name");m(this,"type");m(this,"docs");this.name=e,this.type=i,this.docs=a}write(e){e.writeNode(new j({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" = "),e.writeNode(this.type)}};y();w();g();var ie=class extends B{constructor(e){super();m(this,"arg");this.arg=e}write(e){return new Z(this.arg).write(e)}};y();w();g();y();w();g();var ue=class extends B{constructor(e){super();m(this,"name");this.name=e}write(e){e.write(this.name)}};y();w();g();y();w();g();y();w();g();function _e({writer:u,arguments_:t,multiline:e=!0}){let i=t.map(a=>a instanceof K&&K.isNop(a)?K.nil():a);if(i.length===0){u.write("()");return}if(e){Io({writer:u,arguments_:i});return}To({writer:u,arguments_:i})}function Io({writer:u,arguments_:t}){u.writeLine("("),u.indent();for(let e of t)e.write(u),u.writeLine(",");u.dedent(),u.write(")")}function To({writer:u,arguments_:t}){u.write("("),t.forEach((e,i)=>{i>0&&u.write(", "),e.write(u)}),u.write(")")}var ee=class extends B{constructor({func:e,arguments_:i,multiline:a=!0}){super();m(this,"func");m(this,"arguments_");m(this,"multiline");this.func=e,this.arguments_=i,this.multiline=a}write(e){e.writeNode(this.func),_e({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};y();w();g();y();w();g();function kr({writer:u,generics:t}){t.length!==0&&(u.write("["),t.forEach((e,i)=>{i>0&&u.write(", "),e!=null&&u.writeNode(e)}),u.write("]"))}var J=class extends B{constructor({name:e,importPath:i,generics:a}){super();m(this,"name");m(this,"importPath");m(this,"generics");this.name=e,this.importPath=i,this.generics=a}write(e){if(this.importPath==null||e.importPath===this.importPath){e.write(this.name);return}let i=e.addImport(this.importPath);e.write(`${i}.${this.name}`),this.generics!=null&&kr({writer:e,generics:this.generics})}};y();w();g();var pe=class extends B{constructor({method:e,arguments_:i,on:a,multiline:p}){super();m(this,"on");m(this,"method");m(this,"arguments_");m(this,"multiline");this.on=a,this.method=e,this.arguments_=i,this.multiline=p}write(e){this.on.write(e),e.write("."),e.write(this.method),_e({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};var xo=new Set(["bool","date","dateTime","float64","int","int64","string","uuid"]),Br=new Set(["any","bytes","map","slice"]),K=class u extends B{constructor(e){super();m(this,"internalType");this.internalType=e}write(e){switch(this.internalType.type){case"any":this.writeAny({writer:e,value:this.internalType.value});break;case"bool":e.write(this.internalType.value.toString());break;case"bytes":e.write(`[]byte("${this.internalType.value}")`);break;case"date":case"dateTime":e.writeNode(bo({writer:e,type:this.internalType}));break;case"enum":e.writeNode(this.internalType.typeReference);break;case"float64":e.write(this.internalType.value.toString());break;case"int":case"int64":e.write(this.internalType.value.toString());break;case"map":this.writeMap({writer:e,map:this.internalType});break;case"nil":e.write("nil");break;case"nop":break;case"optional":this.writeOptional({writer:e,type:this.internalType.value});break;case"reference":e.writeNode(this.internalType.value);break;case"slice":this.writeSlice({writer:e,slice:this.internalType});break;case"string":e.write(this.internalType.value.includes('"')||this.internalType.value.includes(`
|
|
26
|
+
`)?`\`${this.internalType.value}\``:`"${this.internalType.value}"`);break;case"struct":this.writeStruct({writer:e,struct:this.internalType});break;case"uuid":e.writeNode(Ao({value:this.internalType.value}));break;default:U(this.internalType)}}static any(e){return new this({type:"any",value:e})}static bool(e){return new this({type:"bool",value:e})}static bytes(e){return new this({type:"bytes",value:e})}static date(e){return new this({type:"date",value:e})}static dateTime(e){return new this({type:"dateTime",value:e})}static enum(e){return new this({type:"enum",typeReference:e})}static float64(e){return new this({type:"float64",value:e})}static int(e){return new this({type:"int",value:e})}static int64(e){return new this({type:"int64",value:e})}static map({keyType:e,valueType:i,entries:a}){return new this({type:"map",keyType:e,valueType:i,entries:a})}static nil(){return new this({type:"nil"})}static nop(){return new this({type:"nop"})}static optional(e){return this.isAlreadyOptional(e)?e:new this({type:"optional",value:e})}static reference(e){return new this({type:"reference",value:e})}static slice({valueType:e,values:i}){return new this({type:"slice",valueType:e,values:i})}static string(e){return new this({type:"string",value:e})}static struct({typeReference:e,fields:i}){return new this({type:"struct",typeReference:e,fields:i})}static structPointer({typeReference:e,fields:i,generics:a}){return new this({type:"optional",value:new this({type:"struct",typeReference:e,fields:i,generics:a})})}static uuid(e){return new this({type:"uuid",value:e})}static isNop(e){return e.internalType.type==="optional"?this.isNop(e.internalType.value):e.internalType.type==="nop"}writeAny({writer:e,value:i}){switch(typeof i){case"boolean":e.write(i.toString());return;case"string":e.write(i.includes('"')?`\`${i}\``:`"${i}"`);return;case"number":e.write(i.toString());return;case"object":if(i==null){e.write("nil");return}if(Array.isArray(i)){this.writeAnyArray({writer:e,value:i});return}this.writeAnyObject({writer:e,value:i});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof i}`)}}writeAnyArray({writer:e,value:i}){if(e.write("[]any"),i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let a of i)e.writeNode(u.any(a)),e.writeLine(",");e.dedent(),e.write("}")}writeAnyObject({writer:e,value:i}){e.write("map[string]any");let a=Object.entries(i);if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let[p,s]of a)e.write(`"${p}": `),e.writeNode(u.any(s)),e.writeLine(",");e.dedent(),e.write("}")}writeMap({writer:e,map:i}){e.write("map["),e.writeNode(i.keyType),e.write("]"),e.writeNode(i.valueType);let a=Ro({entries:i.entries});if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let p of a)p.key.write(e),e.write(": "),p.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeOptional({writer:e,type:i}){if(xo.has(i.internalType.type)){e.writeNode(Eo({writer:e,type:i}));return}if(Br.has(i.internalType.type)){i.write(e);return}if(i.internalType.type==="enum"){e.writeNode(new pe({on:i.internalType.typeReference,method:"Ptr",arguments_:[]}));return}e.write("&"),i.write(e)}static isAlreadyOptional(e){return e.internalType.type==="optional"||Br.has(e.internalType.type)}writeSlice({writer:e,slice:i}){e.write("[]"),e.writeNode(i.valueType);let a=ko({values:i.values});if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let p of a)p.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeStruct({writer:e,struct:i}){e.writeNode(i.typeReference),i.generics!=null&&(e.write("["),i.generics.forEach((p,s)=>{s>0&&e.write(", "),e.writeNode(p)}),e.write("]"));let a=Fo({fields:i.fields});if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let p of a)e.write(`${p.name}: `),p.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}};function Eo({writer:u,type:t}){return new ee({func:new J({name:No({type:t}),importPath:u.rootImportPath}),arguments_:[t]})}function No({type:u}){switch(u.internalType.type){case"bool":return"Bool";case"date":case"dateTime":return"Time";case"float64":return"Float64";case"int":return"Int";case"int64":return"Int64";case"string":return"String";case"uuid":return"UUID";default:return""}}function bo({writer:u,type:t}){let e=t.type==="date"?"MustParseDate":"MustParseDateTime";return new ee({func:new J({name:e,importPath:u.rootImportPath}),arguments_:[new ie(`"${t.value}"`)]})}function Ao({value:u}){return new ee({func:new J({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new ie(`"${u}"`)]})}function Ro({entries:u}){return u.filter(t=>!K.isNop(t.key)&&!K.isNop(t.value))}function Fo({fields:u}){return u.filter(t=>!K.isNop(t.value))}function ko({values:u}){return u.filter(t=>!K.isNop(t))}var Ee=class u extends B{constructor({name:e,docs:i}){super();m(this,"name");m(this,"docs");m(this,"members",[]);m(this,"methods",[]);m(this,"constructor_");this.name=e,this.docs=i}addConstructor(e){this.constructor_=e}addMember(e){this.members.push(e)}addMethod(e){this.methods.push(e)}write(e){this.writeType({writer:e}),this.writeMembers({writer:e}),this.writeConstructor({writer:e}),this.writeMethods({writer:e})}writeType({writer:e}){e.writeNode(new j({docs:this.docs})),e.writeLine(`type ${this.name} string`)}writeMembers({writer:e}){if(this.members.length!==0){e.newLine(),e.writeLine("const ("),e.indent();for(let i of this.members)e.writeNode(new j({docs:i.docs})),e.writeNode(u.getMemberIdentifier({name:this.name,member:i})),e.write(" = "),e.writeNode(K.string(i.value)),e.newLine();e.dedent(),e.write(")")}}writeConstructor({writer:e}){this.constructor_!=null&&(e.newLine(),e.writeNode(this.constructor_))}writeMethods({writer:e}){e.newLine();for(let i of this.methods)e.newLine(),e.writeNode(i),e.newLine()}static getMemberIdentifier({name:e,member:i}){return new ue(`${e}${i.name}`)}};y();w();g();var Ne=class extends B{constructor({name:e,type:i,docs:a,tags:p}){super();m(this,"name");m(this,"type");m(this,"docs");m(this,"tags",[]);this.name=e,this.type=i,this.docs=a,this.tags=p??[]}addTags(...e){this.tags.push(...e)}write(e){e.writeNode(new j({docs:this.docs})),e.write(`${this.name} `),this.type.write(e),this.writeTags({writer:e})}writeTags({writer:e}){this.tags.length!==0&&(e.write(" `"),this.tags.forEach((i,a)=>{a>0&&e.write(" "),e.write(`${i.name}:"${i.value}"`)}),e.write("`"))}};y();w();g();var be=class extends B{constructor({nodes:e}={nodes:[]}){super();m(this,"nodes");this.nodes=e??[]}add(...e){this.nodes.push(...e)}write(e){for(let i of this.nodes)i.write(e)}};y();w();g();y();w();g();var le=class extends B{constructor({name:e,parameters:i,return_:a,body:p,docs:s,typeReference:f,multiline:I,receiver:x,pointerReceiver:E}){super();m(this,"parameters");m(this,"return_");m(this,"name");m(this,"body");m(this,"docs");m(this,"typeReference");m(this,"multiline");m(this,"receiver");m(this,"pointerReceiver");this.name=e,this.parameters=i,this.return_=a,this.body=p,this.docs=s,this.typeReference=f,this.multiline=I,this.receiver=x,this.pointerReceiver=E}write(e){e.writeNode(new j({docs:this.docs})),e.write("func"),this.typeReference!=null&&this.writeReceiver({writer:e,typeReference:this.typeReference,receiver:this.receiver}),this.name!=null&&e.write(` ${this.name}`),_e({writer:e,arguments_:this.parameters,multiline:this.multiline}),this.return_!=null&&(e.write(" "),this.return_.length>1&&e.write("("),this.return_.forEach((i,a)=>{a>0&&e.write(", "),e.writeNode(i)}),this.return_.length>1&&e.write(")")),e.writeLine("{"),e.indent(),this.body?.write(e),e.dedent(),e.writeNewLineIfLastLineNot(),e.write("}")}writeReceiver({writer:e,typeReference:i,receiver:a}){e.write(` (${this.getReceiverName({typeReference:i,receiver:a})} `),this.pointerReceiver&&e.write("*"),i.write(e),e.write(")")}getReceiverName({typeReference:e,receiver:i}){return i??e.name.charAt(0).toLowerCase()}};var Ae=class extends B{constructor({name:e,parameters:i,return_:a,body:p,docs:s,multiline:f}){super();m(this,"func");this.func=new le({name:e,parameters:i,return_:a,body:p,docs:s,multiline:f})}get parameters(){return this.func.parameters}get return_(){return this.func.return_}get name(){return this.func.name}get body(){return this.func.body}get docs(){return this.func.docs}write(e){e.writeNode(this.func)}};y();w();g();var Xe=class extends B{constructor({nodes:e}){super();m(this,"nodes");this.nodes=e}write(e){for(let i of this.nodes)e.newLine(),i.write(e),e.newLine()}};y();w();g();var Re=class extends B{constructor({name:e,type:i,docs:a}){super();m(this,"name");m(this,"type");m(this,"docs");this.name=e,this.type=i,this.docs=a}write(e){e.writeNode(new j({docs:this.docs})),e.write(`${this.name} `),this.type.write(e)}};y();w();g();var Fe=class extends B{constructor({node:e}){super();m(this,"node");this.node=e}write(e){e.write("*"),this.node.write(e)}};y();w();g();var ke=class extends B{constructor({on:e,selector:i}){super();m(this,"on");m(this,"selector");this.on=e,this.selector=i}write(e){e.writeNode(this.on),e.write("."),e.writeNode(this.selector)}};y();w();g();var Be=class extends B{constructor({name:e,embeds:i,fields:a,docs:p}){super();m(this,"name");m(this,"embeds",[]);m(this,"fields",[]);m(this,"docs");m(this,"methods",[]);m(this,"constructor_");this.name=e,this.docs=p,this.embeds=i??[],this.fields=a??[]}addConstructor(e){this.constructor_=e}addField(...e){this.fields.push(...e)}addMethod(...e){this.methods.push(...e)}write(e){this.writeType({writer:e}),this.constructor_!=null&&(e.newLine(),e.newLine(),this.writeConstructor({writer:e,constructor:this.constructor_})),this.writeMethods({writer:e})}writeType({writer:e}){if(e.writeNode(new j({docs:this.docs})),this.name!=null?e.write(`type ${this.name} struct {`):e.write("struct{"),this.embeds.length===0&&this.fields.length===0){e.writeLine("}");return}e.newLine(),e.indent();for(let p of this.embeds)e.writeNode(p),e.newLine();let i=this.fields.filter(p=>this.isExported(p));for(let p of i)e.writeNode(p),e.newLine();let a=this.fields.filter(p=>!this.isExported(p));i.length>0&&a.length>0&&e.newLine();for(let p of a)e.writeNode(p),e.newLine();e.dedent(),e.write("}")}writeConstructor({writer:e,constructor:i}){i.name!=null?e.write(`func ${i.name}(`):e.write(`func New${this.name}(`),i.parameters.forEach((a,p)=>{p>0&&e.write(", "),e.writeNode(a)}),e.write(`) *${this.name} {`),e.newLine(),e.indent(),e.writeNode(i.body),e.writeNewLineIfLastLineNot(),e.dedent(),e.writeLine("}")}writeMethods({writer:e}){if(this.methods.length!==0){e.writeNewLineIfLastLineNot();for(let i of this.methods)e.newLine(),e.writeNode(i),e.newLine()}}isExported(e){let i=e.name.charAt(0);return i===i.toUpperCase()}};y();w();g();var Qe=class extends B{constructor({on:e,cases:i,default:a}){super();m(this,"on");m(this,"cases");m(this,"default");this.on=e,this.cases=i,this.default=a}write(e){let i=this.cases;this.default!=null&&i.push({on:new ue("default"),body:this.default}),e.write("switch "),e.writeNode(this.on),e.writeLine("{"),e.indent();for(let a of i)e.write("case "),e.writeNode(a.on),e.writeLine(":"),e.indent(),e.writeNode(a.body),e.dedent(),e.writeNewLineIfLastLineNot();e.dedent(),e.write("}")}};y();w();g();var Bo=new Set(["any","bytes","map","slice"]),Ze=class u extends B{constructor(e){super();m(this,"internalType");this.internalType=e}write(e,{comment:i}={}){switch(this.internalType.type){case"any":e.write("any");break;case"bool":e.write("bool");break;case"bytes":e.write("[]byte");break;case"date":case"dateTime":e.writeNode(pt);break;case"error":e.write("error");break;case"float64":e.write("float64");break;case"int":e.write("int");break;case"int64":e.write("int64");break;case"map":{e.write("map["),this.internalType.keyType.write(e),e.write("]"),this.internalType.valueType.write(e);break}case"optional":{e.write("*"),this.internalType.value.write(e);break}case"reference":e.writeNode(this.internalType.value);break;case"slice":e.write("[]"),this.internalType.value.write(e);break;case"string":e.write("string");break;case"uuid":e.writeNode(lt);break;case"variadic":e.write("..."),this.internalType.value.write(e);break;default:U(this.internalType)}}isOptional(){return this.internalType.type==="optional"}isIterable(){return this.internalType.type==="slice"||this.internalType.type==="variadic"}iterableElement(){if(this.internalType.type==="slice"||this.internalType.type==="variadic")return this.internalType.value}underlying(){return this.internalType.type==="optional"?this.internalType.value:this}static any(){return new this({type:"any"})}static bool(){return new this({type:"bool"})}static bytes(){return new this({type:"bytes"})}static date(){return new this({type:"date"})}static dateTime(){return new this({type:"dateTime"})}static dereference(e){return e.internalType.type==="optional"?e.internalType.value:e}static error(){return new this({type:"error"})}static float64(){return new this({type:"float64"})}static int(){return new this({type:"int"})}static int64(){return new this({type:"int64"})}static map(e,i){return new this({type:"map",keyType:e,valueType:i})}static optional(e){return this.isAlreadyOptional(e)?e:new this({type:"optional",value:e})}static pointer(e){return u.optional(e)}static reference(e){return new this({type:"reference",value:e})}static slice(e){return new this({type:"slice",value:e})}static string(){return new this({type:"string"})}static uuid(){return new this({type:"uuid"})}static variadic(e){return this.isAlreadyVariadic(e)?e:new this({type:"variadic",value:e})}static isAlreadyOptional(e){return e.internalType.type==="optional"||Bo.has(e.internalType.type)}static isAlreadyVariadic(e){return e.internalType.type==="variadic"}},pt=new J({importPath:"time",name:"Time"}),lt=new J({importPath:"github.com/google/uuid",name:"UUID"}),Ut=new J({importPath:"io",name:"Reader"});y();w();g();var Pe=class extends B{constructor({name:e,type:i,docs:a}){super();m(this,"name");m(this,"type");m(this,"docs");this.name=e,this.type=i,this.docs=a}write(e){e.writeNode(new j({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" "),e.writeNode(this.type)}};function Po(u){return new xe(u)}function So(u){return new ie(u)}function Co(u){return new Ee(u)}function Uo(u){return new Ne(u)}function Lo(u={}){return new be(u)}function _o(u){return new Ae(u)}function Mo(u){return new ue(u)}function $o(u){return new ee(u)}function Do(u){return new pe(u)}function Oo(u){return new le(u)}function Vo(u){return new Re(u)}function Wo(u){return new Fe(u)}function qo(u){return new ke(u)}function Go(u={}){return new Be(u)}function jo(u){return new Qe(u)}function Ho(u){return new Pe(u)}function zo(u){return new J(u)}y();w();g();var Yo=new Set(["string"]);function Lt(u){if(u==="")return"Underscore";let t=u;for(;t.startsWith("_");)t=t.slice(1);if(t==="")return"Underscore";if(t.length>0&&/^\d/.test(t))return"Field"+t;let e=t,i=t[0];return t.length>0&&i!=null&&i!==i.toUpperCase()&&(e=i.toUpperCase()+t.slice(1)),Yo.has(e.toLowerCase())?"Field"+e:e}y();w();g();Fr();var Ko="sdk";function _t({config:u,customConfig:t}){let e=Xo({config:u}),i=Jo({config:u,customConfig:t});return e!=null?Zo({importPath:i,majorVersion:e}):i}function Jo({config:u,customConfig:t,isModulePath:e=!1}){let i=t?.importPath??t?.module?.path??(u.output.mode.type==="github"?es(u.output.mode.repoUrl,"https://"):Ko);return e?i:q.join(i,t?.packagePath??"")}function Xo({config:u}){let t=Qo({config:u});if(!(t==null||t==="v0"||t==="v1"))return`${t}`}function Qo({config:u}){let t=ts(u);if(t==null)return;let e=t.split(".");if(e[0]==null)return;let i=e[0];return i.startsWith("v")?i:`v${i}`}function Zo({importPath:u,majorVersion:t}){return Ke(u)===t?u:`${u}/${t}`}function es(u,t){return u.startsWith(t)?u.slice(t.length):u}function ts(u){let t=u?.output?.mode;if(t!=null)return t.type==="github"||t.type==="publish"?t.version:void 0}y();w();g();var dt=class{constructor({context:t}){m(this,"context");this.context=t}convert(t){if(t.value===null&&!this.context.isNullable(t.typeReference)&&this.context.errors.add({severity:L.Critical,message:"Expected non-null value, but got null"}),t.value==null)return d.TypeInstantiation.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return d.TypeInstantiation.nop();case"map":return this.convertMap({map:t.typeReference,value:t.value});case"named":{let e=this.context.resolveNamedType({typeId:t.typeReference.value});return e==null?d.TypeInstantiation.nop():this.convertNamed({named:e,value:t.value,as:t.as})}case"nullable":{let e=t.typeReference.value;if(e.type==="named"){let i=this.context.resolveNamedType({typeId:e.value});if(i?.type==="alias"&&["list","set","map"].includes(i.typeReference.type)){let a=this.convert({typeReference:i.typeReference,value:t.value,as:t.as}),p=this.context.getTypeName(i.declaration.name),s=this.context.getImportPath(i.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:a,aliasName:p,aliasImportPath:s})}}return d.TypeInstantiation.optional(this.convert({typeReference:e,value:t.value,as:t.as}))}case"optional":{let e=t.typeReference.value;if(e.type==="named"){let i=this.context.resolveNamedType({typeId:e.value});if(i?.type==="alias"&&["list","set","map"].includes(i.typeReference.type)){let a=this.convert({typeReference:i.typeReference,value:t.value,as:t.as}),p=this.context.getTypeName(i.declaration.name),s=this.context.getImportPath(i.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:a,aliasName:p,aliasImportPath:s})}}return d.TypeInstantiation.optional(this.convert({typeReference:e,value:t.value,as:t.as}))}case"primitive":return this.convertPrimitive({primitive:t.typeReference.value,value:t.value,as:t.as});case"set":return this.convertList({list:t.typeReference.value,value:t.value});case"unknown":return this.convertUnknown({value:t.value});default:U(t.typeReference)}}convertToPointerIfPossible(t){let e=this.convert(t);switch(t.typeReference.type){case"named":return this.context.resolveNamedType({typeId:t.typeReference.value})?.type==="enum"?d.TypeInstantiation.reference(d.invokeMethod({on:e,method:"Ptr",arguments_:[]})):e;default:return e}}convertList({list:t,value:e}){return Array.isArray(e)?d.TypeInstantiation.slice({valueType:this.context.dynamicTypeMapper.convert({typeReference:t}),values:e.map((i,a)=>{this.context.errors.scope({index:a});try{return this.convert({typeReference:t,value:i})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:L.Critical,message:`Expected array but got: ${typeof e}`}),d.TypeInstantiation.nop())}convertMap({map:t,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:L.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),d.TypeInstantiation.nop()):d.TypeInstantiation.map({keyType:this.context.dynamicTypeMapper.convert({typeReference:t.key}),valueType:this.context.dynamicTypeMapper.convert({typeReference:t.value}),entries:Object.entries(e).map(([i,a])=>{this.context.errors.scope(i);try{return{key:this.convert({typeReference:t.key,value:i,as:"key"}),value:this.convert({typeReference:t.value,value:a})}}finally{this.context.errors.unscope()}})})}convertNamed({named:t,value:e,as:i}){switch(t.type){case"alias":return this.convertAlias({aliasType:t,value:e,as:i});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:t,value:e});case"enum":return this.convertEnum({enum_:t,value:e});case"object":return this.convertObject({object_:t,value:e});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e});default:U(t)}}convertAlias({aliasType:t,value:e,as:i}){switch(t.typeReference.type){case"literal":return d.TypeInstantiation.reference(d.invokeFunc({func:d.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),arguments_:[this.convertLiteralValue(t.typeReference.value)]}));default:return this.convert({typeReference:t.typeReference,value:e,as:i})}}reconstructAliasCollectionLiteral({collectionLiteral:t,aliasName:e,aliasImportPath:i}){let a=t.internalType;return a.type==="slice"?d.TypeInstantiation.reference(d.codeblock(p=>{p.write("&"),p.writeNode(d.typeReference({name:e,importPath:i}));let s=a.values;if(s.length===0){p.write("{}");return}p.writeLine("{"),p.indent();for(let f of s)p.writeNode(f),p.writeLine(",");p.dedent(),p.write("}")})):a.type==="map"?d.TypeInstantiation.reference(d.codeblock(p=>{p.write("&"),p.writeNode(d.typeReference({name:e,importPath:i}));let s=a.entries;if(s.length===0){p.write("{}");return}p.writeLine("{"),p.indent();for(let f of s)p.writeNode(f.key),p.write(": "),p.writeNode(f.value),p.writeLine(",");p.dedent(),p.write("}")})):d.TypeInstantiation.reference(d.codeblock(p=>{p.write("&"),p.writeNode(t)}))}convertLiteralValue(t){switch(t.type){case"boolean":return d.TypeInstantiation.bool(t.value);case"string":return d.TypeInstantiation.string(t.value);default:U(t)}}convertDiscriminatedUnion({discriminatedUnion:t,value:e}){let i=this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),a=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e});if(a==null)return d.TypeInstantiation.nop();let p=a.singleDiscriminatedUnionType,s=this.getBaseFields({discriminatedUnionTypeInstance:a,singleDiscriminatedUnionType:p});switch(p.type){case"samePropertiesAsObject":{let f=this.context.resolveNamedType({typeId:p.typeId});return f==null?d.TypeInstantiation.nop():d.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(p.discriminantValue.name),value:this.convertNamed({named:f,value:a.value})},...s]})}case"singleProperty":{let f=this.context.getRecord(a.value);if(f==null)return d.TypeInstantiation.nop();try{return this.context.errors.scope(p.discriminantValue.wireValue),d.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(p.discriminantValue.name),value:this.convert({typeReference:p.typeReference,value:f[p.discriminantValue.wireValue]})},...s]})}finally{this.context.errors.unscope()}}case"noProperties":return d.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(a.discriminantValue.name),value:d.TypeInstantiation.string(p.discriminantValue.wireValue)},...s]});default:U(p)}}getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e}){return this.context.associateByWireValue({parameters:e.properties??[],values:this.context.getRecord(t.value)??{},ignoreMissingParameters:!0}).map(a=>{this.context.errors.scope(a.name.wireValue);try{return{name:this.context.getFieldName(a.name.name),value:this.convert(a)}}finally{this.context.errors.unscope()}})}convertObject({object_:t,value:e}){let i=this.context.associateByWireValue({parameters:t.properties,values:this.context.getRecord(e)??{}});return d.TypeInstantiation.structPointer({typeReference:d.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),fields:i.map(a=>{this.context.errors.scope(a.name.wireValue);try{return{name:this.context.getFieldName(a.name.name),value:this.convert(a)}}finally{this.context.errors.unscope()}})})}convertEnum({enum_:t,value:e}){let i=this.getEnumValueName({enum_:t,value:e});return i==null?d.TypeInstantiation.nop():d.TypeInstantiation.enum(d.typeReference({name:i,importPath:this.context.getImportPath(t.declaration.fernFilepath)}))}getEnumValueName({enum_:t,value:e}){if(typeof e!="string"){this.context.errors.add({severity:L.Critical,message:`Expected enum value string, got: ${typeof e}`});return}let i=t.values.find(a=>a.wireValue===e);if(i==null){this.context.errors.add({severity:L.Critical,message:`An enum value named "${e}" does not exist in this context`});return}return`${this.context.getTypeName(t.declaration.name)}${this.context.getTypeName(i.name)}`}convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e}){let i=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e});if(i==null)return d.TypeInstantiation.nop();let a=this.getUndiscriminatedUnionFieldName({typeReference:i.valueTypeReference});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.structPointer({typeReference:this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),fields:[{name:a,value:i.typeInstantiation}]})}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e}){for(let i of t.types)try{let a=this.convert({typeReference:i,value:e});return{valueTypeReference:i,typeInstantiation:a}}catch{continue}this.context.errors.add({severity:L.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof e}" value`})}getUndiscriminatedUnionFieldName({typeReference:t}){switch(t.type){case"list":return this.getUndiscriminatedUnionFieldNameForList({list:t});case"literal":return this.getUndiscriminatedUnionFieldNameForLiteral({literal:t.value});case"map":return this.getUndiscriminatedUnionFieldNameForMap({map:t});case"named":{let e=this.context.resolveNamedType({typeId:t.value});return e==null?void 0:this.context.getTypeName(e.declaration.name)}case"optional":return this.getUndiscriminatedUnionFieldNameForOptional({typeReference:t});case"nullable":return this.getUndiscriminatedUnionFieldNameForOptional({typeReference:t});case"primitive":return this.getUndiscriminatedUnionFieldNameForPrimitive({primitive:t.value});case"set":return this.getUndiscriminatedUnionFieldNameForSet({set:t});case"unknown":return"Unknown";default:U(t)}}getUndiscriminatedUnionFieldNameForList({list:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t});if(e!=null)return`${e}List`}getUndiscriminatedUnionFieldNameForMap({map:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t.key});if(e==null)return;let i=this.getUndiscriminatedUnionFieldName({typeReference:t.value});if(i!=null)return`${e}${i}Map`}getUndiscriminatedUnionFieldNameForOptional({typeReference:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t});if(e!=null)return`${e}Optional`}getUndiscriminatedUnionFieldNameForSet({set:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t});if(e!=null)return`${e}Set`}getUndiscriminatedUnionFieldNameForLiteral({literal:t}){switch(t.type){case"boolean":return t.value?"TrueLiteral":"FalseLiteral";case"string":return`${t.value}StringLiteral`;default:U(t)}}getUndiscriminatedUnionFieldNameForPrimitive({primitive:t}){switch(t){case"INTEGER":case"UINT":return"Integer";case"LONG":case"UINT_64":return"Long";case"FLOAT":case"DOUBLE":return"Double";case"BOOLEAN":return"Boolean";case"BIG_INTEGER":case"STRING":return"String";case"UUID":return"Uuid";case"DATE":return"Date";case"DATE_TIME":return"DateTime";case"BASE_64":return"Base64";default:U(t)}}convertUnknown({value:t}){return d.TypeInstantiation.any(t)}convertPrimitive({primitive:t,value:e,as:i}){switch(t){case"INTEGER":case"UINT":{let a=this.getValueAsNumber({value:e,as:i});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.int(a)}case"LONG":case"UINT_64":{let a=this.getValueAsNumber({value:e,as:i});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.int64(a)}case"FLOAT":case"DOUBLE":{let a=this.getValueAsNumber({value:e,as:i});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.float64(a)}case"BOOLEAN":{let a=this.getValueAsBoolean({value:e,as:i});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.bool(a)}case"STRING":{let a=this.context.getValueAsString({value:e});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.string(a)}case"DATE":{let a=this.context.getValueAsString({value:e});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.date(a)}case"DATE_TIME":{let a=this.context.getValueAsString({value:e});if(a==null)return d.TypeInstantiation.nop();let p=this.normalizeDateTimeString(a);return d.TypeInstantiation.dateTime(p)}case"UUID":{let a=this.context.getValueAsString({value:e});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.uuid(a)}case"BASE_64":{let a=this.context.getValueAsString({value:e});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.bytes(a)}case"BIG_INTEGER":{let a=this.context.getValueAsString({value:e});return a==null?d.TypeInstantiation.nop():d.TypeInstantiation.string(a)}default:U(t)}}getValueAsNumber({value:t,as:e}){let i=e==="key"&&typeof t=="string"?Number(t):t;return this.context.getValueAsNumber({value:i})}getValueAsBoolean({value:t,as:e}){let i=e==="key"?typeof t=="string"?t==="true":t==="false"?!1:t:t;return this.context.getValueAsBoolean({value:i})}normalizeDateTimeString(t){return/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t}T00:00:00Z`:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(t)?`${t}Z`:t}};y();w();g();var ft=class{constructor({context:t}){m(this,"context");this.context=t}convert(t){switch(t.typeReference.type){case"list":return d.Type.slice(this.convert({typeReference:t.typeReference.value}));case"literal":return this.convertLiteral({literal:t.typeReference.value});case"map":return d.Type.map(this.convert({typeReference:t.typeReference.key}),this.convert({typeReference:t.typeReference.value}));case"named":{let e=this.context.resolveNamedType({typeId:t.typeReference.value});return e==null?this.convertUnknown():this.convertNamed({named:e})}case"optional":return d.Type.optional(this.convert({typeReference:t.typeReference.value}));case"nullable":return d.Type.optional(this.convert({typeReference:t.typeReference.value}));case"primitive":return this.convertPrimitive({primitive:t.typeReference.value});case"set":return d.Type.slice(this.convert({typeReference:t.typeReference}));case"unknown":return this.convertUnknown();default:U(t.typeReference)}}convertLiteral({literal:t}){switch(t.type){case"boolean":return d.Type.bool();case"string":return d.Type.string()}}convertNamed({named:t}){let e=d.Type.reference(d.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}));switch(t.type){case"alias":case"enum":return e;case"discriminatedUnion":case"object":case"undiscriminatedUnion":return d.Type.pointer(e);default:U(t)}}convertUnknown(){return d.Type.any()}convertPrimitive({primitive:t}){switch(t){case"INTEGER":return d.Type.int();case"UINT":return d.Type.int();case"LONG":return d.Type.int64();case"UINT_64":return d.Type.int64();case"FLOAT":return d.Type.float64();case"DOUBLE":return d.Type.float64();case"BOOLEAN":return d.Type.bool();case"STRING":return d.Type.string();case"DATE":return d.Type.date();case"DATE_TIME":return d.Type.dateTime();case"UUID":return d.Type.uuid();case"BASE_64":return d.Type.bytes();case"BIG_INTEGER":return d.Type.string();default:U(t)}}};y();w();g();var ht=class{constructor({context:t}){m(this,"context");this.context=t}getFilePropertyInfo({body:t,value:e}){let i={fileFields:[],bodyPropertyFields:[]},a=this.context.getRecord(e)??{};for(let p of t.properties)switch(p.type){case"file":i.fileFields.push({name:this.context.getFieldName(p.name),value:this.getSingleFileProperty({property:p,record:a})});break;case"fileArray":i.fileFields.push({name:this.context.getFieldName(p.name),value:this.getArrayFileProperty({property:p,record:a})});break;case"bodyProperty":i.bodyPropertyFields.push({name:this.context.getFieldName(p.name.name),value:this.getBodyProperty({property:p,record:a})});break;default:U(p)}return i}getSingleFileProperty({property:t,record:e}){let i=this.context.getSingleFileValue({property:t,record:e})||"";return d.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(i))}getArrayFileProperty({property:t,record:e}){let i=this.context.getFileArrayValues({property:t,record:e});return i==null?d.TypeInstantiation.nop():d.TypeInstantiation.slice({valueType:d.Type.reference(this.context.getIoReaderTypeReference()),values:i.map(a=>d.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(a)))})}getBodyProperty({property:t,record:e}){let i=e[t.name.wireValue];return i==null?d.TypeInstantiation.nop():this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:i})}};var mt=class u extends Ye{constructor({ir:e,config:i}){super({ir:e,config:i});m(this,"ir");m(this,"customConfig");m(this,"dynamicTypeMapper");m(this,"dynamicTypeInstantiationMapper");m(this,"filePropertyMapper");m(this,"rootImportPath");this.ir=e,this.customConfig=i.customConfig!=null?i.customConfig:void 0,this.dynamicTypeMapper=new ft({context:this}),this.dynamicTypeInstantiationMapper=new dt({context:this}),this.filePropertyMapper=new ht({context:this}),this.rootImportPath=_t({config:i,customConfig:this.customConfig})}clone(){return new u({ir:this.ir,config:this.config})}isOptional(e){switch(e.type){case"optional":case"map":return!0;case"nullable":case"list":case"set":return this.isOptional(e.value);case"named":case"literal":case"primitive":case"unknown":return!1;default:U(e)}}getMethodName(e){return e.pascalCase.unsafeName}getTestMethodName(e){return e.declaration.fernFilepath.allParts.map(i=>i.pascalCase.unsafeName).join("")+e.declaration.name.pascalCase.unsafeName}getTypeName(e){return e.pascalCase.unsafeName}getFieldName(e){return Lt(e.pascalCase.unsafeName)}getImportPath(e){let i=e.packagePath.map(a=>a.pascalCase.unsafeName.toLowerCase());return[this.rootImportPath,...i].join("/")}getImportPathForRequest(e){return this.customConfig?.exportAllRequestsAtRoot?this.rootImportPath:this.getImportPath(e)}getContextTypeReference(){return d.typeReference({name:"Context",importPath:"context"})}getContextTodoFunctionInvocation(){return d.invokeFunc({func:d.typeReference({name:"TODO",importPath:"context"}),arguments_:[]})}getIoReaderTypeReference(){return d.typeReference({name:"Reader",importPath:"io"})}getTestingTypeReference(){return d.typeReference({name:"T",importPath:"testing"})}getNewStringsReaderFunctionInvocation(e){return d.invokeFunc({func:d.typeReference({name:"NewReader",importPath:"strings"}),arguments_:[d.TypeInstantiation.string(e)]})}getClientConstructorName(){return this.customConfig?.clientConstructorName!=null?this.customConfig.clientConstructorName:this.customConfig?.exportedClientName!=null?`New${this.customConfig.exportedClientName}`:`New${this.getClientName()}`}getClientName(){return this.customConfig?.clientName!=null?this.customConfig.clientName:"Client"}getClientImportPath(){return`${this.rootImportPath}/client`}getOptionImportPath(){return`${this.rootImportPath}/option`}getGoTypeReferenceFromDeclaration({declaration:e}){return d.typeReference({name:e.name.pascalCase.unsafeName,importPath:this.getImportPath(e.fernFilepath)})}getEnvironmentTypeReferenceFromID(e){let i=this.resolveEnvironmentName(e);if(i!=null)return this.getEnvironmentTypeReference(i)}getEnvironmentTypeReference(e){return d.typeReference({name:`Environments.${this.getTypeName(e)}`,importPath:this.rootImportPath})}static chainMethods(e,...i){if(i.length===0)throw new Error("Must have methods to chain");let a=e;for(let p of i)a=d.invokeMethod({on:a,method:p.method,arguments_:p.arguments_,multiline:p.multiline});return a}};y();w();g();var Pr="example",Mt="fern",ns="do",et="client",Me=d.TypeInstantiation,rs="WireMockBaseURL",is="WireMockClient",yt=class{constructor({context:t,formatter:e}){m(this,"context");m(this,"formatter");this.context=t,this.formatter=e}async generateSnippet({endpoint:t,request:e,options:i}){return i?.config?.outputWiremockTests??!1?this.generateWiremockTest({endpoint:t,snippet:e}):await this.buildCodeBlock({endpoint:t,snippet:e}).toStringAsync({packageName:Pr,importPath:Mt,rootImportPath:this.context.rootImportPath,customConfig:this.context.customConfig??{},formatter:this.formatter})}generateSnippetSync({endpoint:t,request:e,options:i}){return i?.config?.outputWiremockTests??!1?this.generateWiremockTest({endpoint:t,snippet:e}):this.buildCodeBlock({endpoint:t,snippet:e}).toString({packageName:Pr,importPath:Mt,rootImportPath:this.context.rootImportPath,customConfig:this.context.customConfig??{},formatter:this.formatter})}async generateSnippetAst({endpoint:t,request:e,options:i}){throw new Error("Unsupported")}generateWiremockTest({endpoint:t,snippet:e}){return this.buildWiremockTestCodeBlock({endpoint:t,snippet:e}).toString({packageName:"wiremock",importPath:Mt,rootImportPath:this.context.rootImportPath,customConfig:this.context.customConfig??{},formatter:this.formatter})}buildCodeBlock({endpoint:t,snippet:e}){return d.codeblock(i=>{i.writeNode(d.func({name:ns,parameters:[],return_:[],body:d.codeblock(a=>{a.writeNode(this.constructClient({endpoint:t,snippet:e})),a.writeLine(),a.writeNode(this.callMethod({endpoint:t,snippet:e}))})})),i.writeNewLineIfLastLineNot()})}buildWiremockTestCodeBlock({endpoint:t,snippet:e}){return d.codeblock(i=>{i.writeNode(d.func({name:"Test"+this.context.getTestMethodName(t)+"WithWireMock",parameters:[d.parameter({name:"t",type:d.Type.pointer(d.Type.reference(this.context.getTestingTypeReference()))})],return_:[],body:d.codeblock(a=>{for(let p of this.buildWiremockTestSetup({endpoint:t}))a.writeNode(p),a.writeLine();a.writeLine(),a.writeNode(this.constructWiremockTestClient({endpoint:t,snippet:e})),a.writeLine(),a.writeNode(this.callClientMethodAndAssert({endpoint:t,snippet:e}))})})),i.writeNewLineIfLastLineNot()})}constructClient({endpoint:t,snippet:e}){return d.codeblock(i=>{i.write(`${et} := `),i.writeNode(this.getRootClientFuncInvocation(this.getConstructorArgs({endpoint:t,snippet:e})))})}constructWiremockTestClient({endpoint:t,snippet:e}){return d.codeblock(i=>{i.write(`${et} := `),i.writeNode(this.getRootClientFuncInvocation(this.getWiremockTestConstructorArgs()))})}writeMethodInvocation({writer:t,endpoint:e,snippet:i}){let{otherArgs:a,requestArg:p}=this.getMethodArgs({endpoint:e,snippet:i});if(p!=null)if(p instanceof d.TypeInstantiation&&d.TypeInstantiation.isNop(p))t.writeNode(d.invokeMethod({on:d.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...a,d.codeblock("nil")]}));else{t.write("request := "),t.writeNode(p),t.writeLine();let s=d.codeblock("request");t.writeNode(d.invokeMethod({on:d.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...a,s]}))}else t.writeNode(d.invokeMethod({on:d.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...a]}))}callMethod({endpoint:t,snippet:e}){return d.codeblock(i=>{this.writeMethodInvocation({writer:i,endpoint:t,snippet:e})})}getConstructorArgs({endpoint:t,snippet:e}){let i=[],a=this.getConstructorBaseUrlArg({baseUrl:e.baseURL,environment:e.environment});return a!=null&&i.push(a),t.auth!=null&&(e.auth!=null?i.push(this.getConstructorAuthArg({auth:t.auth,values:e.auth})):this.context.errors.add({severity:L.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(re.Headers),this.context.ir.headers!=null&&e.headers!=null&&i.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:e.headers})),this.context.errors.unscope(),i}getWiremockTestConstructorArgs(){return[d.codeblock(t=>{t.writeNode(d.invokeFunc({func:d.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[d.codeblock(rs)]}))})]}getConstructorAuthArg({auth:t,values:e}){if(e.type!==t.type)return this.addError(this.context.newAuthMismatchError({auth:t,values:e}).message),Me.nop();switch(t.type){case"basic":return e.type==="basic"?this.getConstructorBasicAuthArg({auth:t,values:e}):Me.nop();case"bearer":return e.type==="bearer"?this.getConstructorBearerAuthArg({auth:t,values:e}):Me.nop();case"header":return e.type==="header"?this.getConstructorHeaderAuthArg({auth:t,values:e}):Me.nop();case"oauth":return e.type==="oauth"?this.getConstructorOAuthAuthArg({values:e}):Me.nop();case"inferred":return this.addWarning("The Go SDK Generator does not support Inferred auth scheme yet"),Me.nop();default:U(t)}}addError(t){this.context.errors.add({severity:L.Critical,message:t})}addWarning(t){this.context.errors.add({severity:L.Warning,message:t})}getConstructorBasicAuthArg({auth:t,values:e}){return d.codeblock(i=>{i.writeNode(d.invokeFunc({func:d.typeReference({name:"WithBasicAuth",importPath:this.context.getOptionImportPath()}),arguments_:[d.TypeInstantiation.string(e.username),d.TypeInstantiation.string(e.password)]}))})}getConstructorBaseUrlArg({baseUrl:t,environment:e}){let i=this.getBaseUrlArg({baseUrl:t,environment:e});if(i!=null)return d.codeblock(a=>{a.writeNode(d.invokeFunc({func:d.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[i]}))})}getBaseUrlArg({baseUrl:t,environment:e}){if(t!=null&&e!=null){this.context.errors.add({severity:L.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(t!=null)return d.TypeInstantiation.string(t);if(e!=null){if(this.context.isSingleEnvironmentID(e)){let i=this.context.getEnvironmentTypeReferenceFromID(e);if(i==null){this.context.errors.add({severity:L.Warning,message:`Environment ${JSON.stringify(e)} was not found`});return}return d.TypeInstantiation.reference(i)}this.context.isMultiEnvironmentValues(e)&&this.context.errors.add({severity:L.Warning,message:"The Go SDK doesn't support a multi-environment client option yet; use the baseUrl option instead"})}}getConstructorBearerAuthArg({auth:t,values:e}){return d.codeblock(i=>{i.writeNode(d.invokeFunc({func:d.typeReference({name:`With${t.token.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[d.TypeInstantiation.string(e.token)]}))})}getConstructorHeaderAuthArg({auth:t,values:e}){return d.codeblock(i=>{i.writeNode(d.invokeFunc({func:d.typeReference({name:`With${t.header.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.header.typeReference,value:e.value})]}))})}getConstructorOAuthAuthArg({values:t}){return d.codeblock(e=>{e.writeNode(d.invokeFunc({func:d.typeReference({name:"WithClientCredentials",importPath:this.context.getOptionImportPath()}),arguments_:[d.TypeInstantiation.string(t.clientId),d.TypeInstantiation.string(t.clientSecret)]}))})}getConstructorHeaderArgs({headers:t,values:e}){let i=[];for(let a of t){let p=this.getConstructorHeaderArg({header:a,value:e.value});p!=null&&i.push(p)}return i}getConstructorHeaderArg({header:t,value:e}){let i=this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:e});if(!d.TypeInstantiation.isNop(i))return d.codeblock(a=>{a.writeNode(d.invokeFunc({func:d.typeReference({name:`With${t.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[i]}))})}getMethodArgs({endpoint:t,snippet:e}){switch(t.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:t.request,snippet:e});case"body":return this.getMethodArgsForBodyRequest({request:t.request,snippet:e});default:U(t.request)}}getMethodArgsForBodyRequest({request:t,snippet:e}){let i=[];this.context.errors.scope(re.PathParameters);let a=[...this.context.ir.pathParameters??[],...t.pathParameters??[]];a.length>0&&i.push(...this.getPathParameters({namedParameters:a,snippet:e}).map(s=>s.value)),this.context.errors.unscope(),this.context.errors.scope(re.RequestBody);let p=t.body!=null?this.getBodyRequestArg({body:t.body,value:e.requestBody}):void 0;return this.context.errors.unscope(),{otherArgs:i,requestArg:p}}getBodyRequestArg({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e});default:U(t)}}getBytesBodyRequestArg({value:t}){return typeof t!="string"?(this.context.errors.add({severity:L.Critical,message:`Expected bytes value to be a string, got ${typeof t}`}),d.TypeInstantiation.nop()):d.TypeInstantiation.bytes(t)}getMethodArgsForInlinedRequest({request:t,snippet:e}){let i=[],{inlinePathParameters:a,inlineFileProperties:p}={inlinePathParameters:this.context.customConfig?.inlinePathParameters??!0,inlineFileProperties:this.context.customConfig?.inlineFileProperties??!0};this.context.errors.scope(re.PathParameters);let s=[],f=[...this.context.ir.pathParameters??[],...t.pathParameters??[]];f.length>0&&s.push(...this.getPathParameters({namedParameters:f,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(re.RequestBody);let I=this.getFilePropertyInfo({request:t,snippet:e});this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:a})||i.push(...s.map(E=>E.value)),p||i.push(...I.fileFields.map(E=>E.value));let x=this.context.needsRequestParameter({request:t,inlinePathParameters:a,inlineFileProperties:p})?this.getInlinedRequestArg({request:t,snippet:e,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:a})?s:[],filePropertyInfo:I}):void 0;return{otherArgs:i,requestArg:x}}getFilePropertyInfo({request:t,snippet:e}){return t.body==null||!this.context.isFileUploadRequestBody(t.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:t.body,value:e.requestBody})}getInlinedRequestArg({request:t,snippet:e,pathParameterFields:i,filePropertyInfo:a}){this.context.errors.scope(re.QueryParameters);let s=this.context.associateQueryParametersByWireValue({parameters:t.queryParameters??[],values:e.queryParameters??{}}).map(E=>({name:E.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(E)}));this.context.errors.unscope(),this.context.errors.scope(re.Headers);let I=this.context.associateByWireValue({parameters:t.headers??[],values:e.headers??{}}).map(E=>({name:E.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(E)}));this.context.errors.unscope(),this.context.errors.scope(re.RequestBody);let x=t.body!=null?this.getInlinedRequestBodyStructFields({body:t.body,value:e.requestBody,filePropertyInfo:a}):[];return this.context.errors.unscope(),d.TypeInstantiation.structPointer({typeReference:d.typeReference({name:this.context.getMethodName(t.declaration.name),importPath:this.context.getImportPathForRequest(t.declaration.fernFilepath)}),fields:[...i,...s,...I,...x]})}getInlinedRequestBodyStructFields({body:t,value:e,filePropertyInfo:i}){switch(t.type){case"properties":return this.getInlinedRequestBodyPropertyStructFields({parameters:t.value,value:e});case"referenced":return[this.getReferencedRequestBodyPropertyStructField({body:t,value:e})];case"fileUpload":return this.getFileUploadRequestBodyStructFields({filePropertyInfo:i});default:U(t)}}getFileUploadRequestBodyStructFields({filePropertyInfo:t}){return this.context.customConfig?.inlineFileProperties?[...t.fileFields,...t.bodyPropertyFields]:t.bodyPropertyFields}getReferencedRequestBodyPropertyStructField({body:t,value:e}){return{name:this.context.getTypeName(t.bodyKey),value:this.getReferencedRequestBodyPropertyTypeInstantiation({body:t.bodyType,value:e})}}getReferencedRequestBodyPropertyTypeInstantiation({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e});default:U(t)}}getInlinedRequestBodyPropertyStructFields({parameters:t,value:e}){let i=[],a=this.context.associateByWireValue({parameters:t,values:this.context.getRecord(e)??{}});for(let p of a)i.push({name:this.context.getTypeName(p.name.name),value:this.context.dynamicTypeInstantiationMapper.convert(p)});return i}getPathParameters({namedParameters:t,snippet:e}){let i=[],a=this.context.associateByWireValue({parameters:t,values:e.pathParameters??{}});for(let p of a)i.push({name:this.context.getTypeName(p.name.name),value:this.context.dynamicTypeInstantiationMapper.convertToPointerIfPossible(p)});return i}getMethod({endpoint:t}){return t.declaration.fernFilepath.allParts.length>0?`${t.declaration.fernFilepath.allParts.map(e=>this.context.getMethodName(e)).join(".")}.${this.context.getMethodName(t.declaration.name)}`:this.context.getMethodName(t.declaration.name)}getRootClientFuncInvocation(t){return d.invokeFunc({func:d.typeReference({name:this.context.getClientConstructorName(),importPath:this.context.getClientImportPath()}),arguments_:t})}buildWiremockTestSetup({endpoint:t,errorCase:e}){let i="stub";return[]}callClientMethodAndAssert({endpoint:t,snippet:e}){return d.codeblock(i=>{this.writeMethodInvocation({writer:i,endpoint:t,snippet:e}),i.writeLine(),i.writeLine(),i.write("ok, countErr := "),i.writeNode(d.invokeMethod({on:d.codeblock(is),method:"Verify",arguments_:[d.invokeMethod({on:d.codeblock("stub"),method:"Request",arguments_:[],multiline:!1}),d.codeblock("1")],multiline:!1})),i.writeLine(),i.writeNode(d.invokeFunc({func:d.typeReference({name:"NoError",importPath:"github.com/stretchr/testify/require"}),arguments_:[d.codeblock("t"),d.codeblock("countErr"),d.TypeInstantiation.string("Failed to verify WireMock request was matched")],multiline:!1})),i.writeLine(),i.writeNode(d.invokeFunc({func:d.typeReference({name:"True",importPath:"github.com/stretchr/testify/require"}),arguments_:[d.codeblock("t"),d.codeblock("ok"),d.TypeInstantiation.string("WireMock request was not matched")],multiline:!1})),i.writeLine()})}};var $t=class extends je{constructor({ir:e,config:i,formatter:a}){super(new mt({ir:e,config:i}));m(this,"formatter");this.formatter=a}async generate(e,i){return super.generate(e,i)}generateSync(e,i){return super.generateSync(e,i)}async generateSnippetAst(e){return super.generateSnippetAst(e)}createSnippetGenerator(e){return new yt({context:e,formatter:this.formatter})}};export{$t as DynamicSnippetsGenerator};
|
|
27
|
+
/*! Bundled license information:
|
|
28
|
+
|
|
29
|
+
@jspm/core/nodelibs/browser/chunk-DtuTasat.js:
|
|
30
|
+
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
31
|
+
*/
|
|
32
|
+
//# sourceMappingURL=index.js.map
|