@fern-api/go-dynamic-snippets 1.57.0 → 1.57.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var Xt=Object.defineProperty;var Xn=(p,t,e)=>t in p?Xt(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e;var oe=(p,t,e)=>()=>{if(e)throw e[0];try{return p&&(t=p(p=0)),t}catch(i){throw e=[i],i}};var Qt=(p,t)=>{for(var e in t)Xt(p,e,{get:t[e],enumerable:!0})};var m=(p,t,e)=>Xn(p,typeof t!="symbol"?t+"":t,e);var y=oe(()=>{"use strict"});var N={};Qt(N,{_debugEnd:()=>Vr,_debugProcess:()=>Dr,_events:()=>nn,_eventsCount:()=>on,_exiting:()=>Tr,_fatalExceptions:()=>_r,_getActiveHandles:()=>Nr,_getActiveRequests:()=>Er,_kill:()=>Rr,_linkedBinding:()=>wr,_maxListeners:()=>rn,_preload_modules:()=>Zr,_rawDebug:()=>gr,_startProfilerIdleNotifier:()=>Wr,_stopProfilerIdleNotifier:()=>Gr,_tickCallback:()=>Or,abort:()=>zr,addListener:()=>sn,allowedNodeEnvironmentFlags:()=>Cr,arch:()=>nr,argv:()=>sr,argv0:()=>Qr,assert:()=>Ur,binding:()=>lr,browser:()=>yr,chdir:()=>hr,config:()=>xr,cpuUsage:()=>it,cwd:()=>fr,debugPort:()=>Xr,default:()=>mn,dlopen:()=>br,domain:()=>Ir,emit:()=>ln,emitWarning:()=>pr,env:()=>or,execArgv:()=>ar,execPath:()=>Jr,exit:()=>Br,features:()=>Lr,hasUncaughtExceptionCaptureCallback:()=>$r,hrtime:()=>nt,kill:()=>kr,listeners:()=>hn,memoryUsage:()=>Pr,moduleLoadList:()=>vr,nextTick:()=>er,off:()=>cn,on:()=>ae,once:()=>an,openStdin:()=>Sr,pid:()=>Yr,platform:()=>ir,ppid:()=>Kr,prependListener:()=>dn,prependOnceListener:()=>fn,reallyExit:()=>Ar,release:()=>mr,removeAllListeners:()=>pn,removeListener:()=>un,resourceUsage:()=>Fr,setSourceMapsEnabled:()=>en,setUncaughtExceptionCaptureCallback:()=>Mr,stderr:()=>jr,stdin:()=>Hr,stdout:()=>qr,title:()=>rr,umask:()=>dr,uptime:()=>tn,version:()=>cr,versions:()=>ur});function xt(p){throw new Error("Node.js process "+p+" is not supported by JSPM core outside of Node.js")}function Qn(){!Ue||!ye||(Ue=!1,ye.length?se=ye.concat(se):rt=-1,se.length&&Zt())}function Zt(){if(!Ue){var p=setTimeout(Qn,0);Ue=!0;for(var t=se.length;t;){for(ye=se,se=[];++rt<t;)ye&&ye[rt].run();rt=-1,t=se.length}ye=null,Ue=!1,clearTimeout(p)}}function er(p){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 tr(p,t)),se.length===1&&!Ue&&setTimeout(Zt,0)}function tr(p,t){this.fun=p,this.array=t}function H(){}function wr(p){xt("_linkedBinding")}function br(p){xt("dlopen")}function Er(){return[]}function Nr(){return[]}function Ur(p,t){if(!p)throw new Error(t||"assertion error")}function $r(){return!1}function tn(){return fe.now()/1e3}function nt(p){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 p&&(i=i-p[0],a=a-p[1],a<0&&(i--,a+=Tt)),[i,a]}function ae(){return mn}function hn(p){return[]}var se,Ue,ye,rt,rr,nr,ir,or,sr,ar,cr,ur,pr,lr,dr,fr,hr,mr,yr,gr,vr,Ir,Tr,xr,Ar,Rr,it,Fr,Pr,kr,Br,Sr,Cr,Lr,_r,Mr,Or,Dr,Vr,Wr,Gr,qr,jr,Hr,zr,Yr,Kr,Jr,Xr,Qr,Zr,en,fe,It,Tt,rn,nn,on,sn,an,cn,un,pn,ln,dn,fn,mn,yn=oe(()=>{"use strict";y();v();g();se=[],Ue=!1,rt=-1;tr.prototype.run=function(){this.fun.apply(null,this.array)};rr="browser",nr="x64",ir="browser",or={PATH:"/usr/bin",LANG:typeof navigator<"u"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},sr=["/usr/bin/node"],ar=[],cr="v16.8.0",ur={},pr=function(p,t){console.warn((t?t+": ":"")+p)},lr=function(p){xt("binding")},dr=function(p){return 0},fr=function(){return"/"},hr=function(p){},mr={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};yr=!0,gr=H,vr=[];Ir={},Tr=!1,xr={};Ar=H,Rr=H,it=function(){return{}},Fr=it,Pr=it,kr=H,Br=H,Sr=H,Cr={};Lr={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},_r=H,Mr=H;Or=H,Dr=H,Vr=H,Wr=H,Gr=H,qr=void 0,jr=void 0,Hr=void 0,zr=H,Yr=2,Kr=1,Jr="/bin/usr/node",Xr=9229,Qr="node",Zr=[],en=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;nt.bigint=function(p){var t=nt(p);return typeof BigInt>"u"?t[0]*Tt+t[1]:BigInt(t[0]*Tt)+BigInt(t[1])};rn=10,nn={},on=0;sn=ae,an=ae,cn=ae,un=ae,pn=ae,ln=H,dn=ae,fn=ae;mn={version:cr,versions:ur,arch:nr,platform:ir,browser:yr,release:mr,_rawDebug:gr,moduleLoadList:vr,binding:lr,_linkedBinding:wr,_events:nn,_eventsCount:on,_maxListeners:rn,on:ae,addListener:sn,once:an,off:cn,removeListener:un,removeAllListeners:pn,emit:ln,prependListener:dn,prependOnceListener:fn,listeners:hn,domain:Ir,_exiting:Tr,config:xr,dlopen:br,uptime:tn,_getActiveRequests:Er,_getActiveHandles:Nr,reallyExit:Ar,_kill:Rr,cpuUsage:it,resourceUsage:Fr,memoryUsage:Pr,kill:kr,exit:Br,openStdin:Sr,allowedNodeEnvironmentFlags:Cr,assert:Ur,features:Lr,_fatalExceptions:_r,setUncaughtExceptionCaptureCallback:Mr,hasUncaughtExceptionCaptureCallback:$r,emitWarning:pr,nextTick:er,_tickCallback:Or,_debugProcess:Dr,_debugEnd:Vr,_startProfilerIdleNotifier:Wr,_stopProfilerIdleNotifier:Gr,stdout:qr,stdin:Hr,stderr:jr,abort:zr,umask:dr,chdir:hr,cwd:fr,env:or,title:rr,argv:sr,execArgv:ar,pid:Yr,ppid:Kr,execPath:Jr,debugPort:Xr,hrtime:nt,argv0:Qr,_preload_modules:Zr,setSourceMapsEnabled:en}});var g=oe(()=>{"use strict";yn()});function Zn(){if(gn)return $e;gn=!0,$e.byteLength=f,$e.toByteArray=T,$e.fromByteArray=P;for(var p=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=i.length;a<c;++a)p[a]=i[a],t[i.charCodeAt(a)]=a;t[45]=62,t[95]=63;function o(E){var F=E.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var S=E.indexOf("=");S===-1&&(S=F);var B=S===F?0:4-S%4;return[S,B]}function f(E){var F=o(E),S=F[0],B=F[1];return(S+B)*3/4-B}function w(E,F,S){return(F+S)*3/4-S}function T(E){var F,S=o(E),B=S[0],q=S[1],$=new e(w(E,B,q)),V=0,Q=q>0?B-4:B,Y;for(Y=0;Y<Q;Y+=4)F=t[E.charCodeAt(Y)]<<18|t[E.charCodeAt(Y+1)]<<12|t[E.charCodeAt(Y+2)]<<6|t[E.charCodeAt(Y+3)],$[V++]=F>>16&255,$[V++]=F>>8&255,$[V++]=F&255;return q===2&&(F=t[E.charCodeAt(Y)]<<2|t[E.charCodeAt(Y+1)]>>4,$[V++]=F&255),q===1&&(F=t[E.charCodeAt(Y)]<<10|t[E.charCodeAt(Y+1)]<<4|t[E.charCodeAt(Y+2)]>>2,$[V++]=F>>8&255,$[V++]=F&255),$}function b(E){return p[E>>18&63]+p[E>>12&63]+p[E>>6&63]+p[E&63]}function x(E,F,S){for(var B,q=[],$=F;$<S;$+=3)B=(E[$]<<16&16711680)+(E[$+1]<<8&65280)+(E[$+2]&255),q.push(b(B));return q.join("")}function P(E){for(var F,S=E.length,B=S%3,q=[],$=16383,V=0,Q=S-B;V<Q;V+=$)q.push(x(E,V,V+$>Q?Q:V+$));return B===1?(F=E[S-1],q.push(p[F>>2]+p[F<<4&63]+"==")):B===2&&(F=(E[S-2]<<8)+E[S-1],q.push(p[F>>10]+p[F>>4&63]+p[F<<2&63]+"=")),q.join("")}return $e}function ei(){if(vn)return ot;vn=!0;return ot.read=function(p,t,e,i,a){var c,o,f=a*8-i-1,w=(1<<f)-1,T=w>>1,b=-7,x=e?a-1:0,P=e?-1:1,E=p[t+x];for(x+=P,c=E&(1<<-b)-1,E>>=-b,b+=f;b>0;c=c*256+p[t+x],x+=P,b-=8);for(o=c&(1<<-b)-1,c>>=-b,b+=i;b>0;o=o*256+p[t+x],x+=P,b-=8);if(c===0)c=1-T;else{if(c===w)return o?NaN:(E?-1:1)*(1/0);o=o+Math.pow(2,i),c=c-T}return(E?-1:1)*o*Math.pow(2,c-i)},ot.write=function(p,t,e,i,a,c){var o,f,w,T=c*8-a-1,b=(1<<T)-1,x=b>>1,P=a===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=i?0:c-1,F=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,o=b):(o=Math.floor(Math.log(t)/Math.LN2),t*(w=Math.pow(2,-o))<1&&(o--,w*=2),o+x>=1?t+=P/w:t+=P*Math.pow(2,1-x),t*w>=2&&(o++,w/=2),o+x>=b?(f=0,o=b):o+x>=1?(f=(t*w-1)*Math.pow(2,a),o=o+x):(f=t*Math.pow(2,x-1)*Math.pow(2,a),o=0));a>=8;p[e+E]=f&255,E+=F,f/=256,a-=8);for(o=o<<a|f,T+=a;T>0;p[e+E]=o&255,E+=F,o/=256,T-=8);p[e+E-F]|=S*128},ot}function In(){if(wn)return ge;wn=!0;let p=Zn(),t=ei(),e=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ge.Buffer=o,ge.SlowBuffer=q,ge.INSPECT_MAX_BYTES=50;let i=2147483647;ge.kMaxLength=i,o.TYPED_ARRAY_SUPPORT=a(),!o.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 s=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(s,r),s.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function c(s){if(s>i)throw new RangeError('The value "'+s+'" is invalid for option "size"');let r=new Uint8Array(s);return Object.setPrototypeOf(r,o.prototype),r}function o(s,r,n){if(typeof s=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(s)}return f(s,r,n)}o.poolSize=8192;function f(s,r,n){if(typeof s=="string")return x(s,r);if(ArrayBuffer.isView(s))return E(s);if(s==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof s);if(te(s,ArrayBuffer)||s&&te(s.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(te(s,SharedArrayBuffer)||s&&te(s.buffer,SharedArrayBuffer)))return F(s,r,n);if(typeof s=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let u=s.valueOf&&s.valueOf();if(u!=null&&u!==s)return o.from(u,r,n);let d=S(s);if(d)return d;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof s[Symbol.toPrimitive]=="function")return o.from(s[Symbol.toPrimitive]("string"),r,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof s)}o.from=function(s,r,n){return f(s,r,n)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function w(s){if(typeof s!="number")throw new TypeError('"size" argument must be of type number');if(s<0)throw new RangeError('The value "'+s+'" is invalid for option "size"')}function T(s,r,n){return w(s),s<=0?c(s):r!==void 0?typeof n=="string"?c(s).fill(r,n):c(s).fill(r):c(s)}o.alloc=function(s,r,n){return T(s,r,n)};function b(s){return w(s),c(s<0?0:B(s)|0)}o.allocUnsafe=function(s){return b(s)},o.allocUnsafeSlow=function(s){return b(s)};function x(s,r){if((typeof r!="string"||r==="")&&(r="utf8"),!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let n=$(s,r)|0,u=c(n),d=u.write(s,r);return d!==n&&(u=u.slice(0,d)),u}function P(s){let r=s.length<0?0:B(s.length)|0,n=c(r);for(let u=0;u<r;u+=1)n[u]=s[u]&255;return n}function E(s){if(te(s,Uint8Array)){let r=new Uint8Array(s);return F(r.buffer,r.byteOffset,r.byteLength)}return P(s)}function F(s,r,n){if(r<0||s.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(s.byteLength<r+(n||0))throw new RangeError('"length" is outside of buffer bounds');let u;return r===void 0&&n===void 0?u=new Uint8Array(s):n===void 0?u=new Uint8Array(s,r):u=new Uint8Array(s,r,n),Object.setPrototypeOf(u,o.prototype),u}function S(s){if(o.isBuffer(s)){let r=B(s.length)|0,n=c(r);return n.length===0||s.copy(n,0,0,r),n}if(s.length!==void 0)return typeof s.length!="number"||wt(s.length)?c(0):P(s);if(s.type==="Buffer"&&Array.isArray(s.data))return P(s.data)}function B(s){if(s>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return s|0}function q(s){return+s!=s&&(s=0),o.alloc(+s)}o.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==o.prototype},o.compare=function(r,n){if(te(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),te(n,Uint8Array)&&(n=o.from(n,n.offset,n.byteLength)),!o.isBuffer(r)||!o.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===n)return 0;let u=r.length,d=n.length;for(let h=0,I=Math.min(u,d);h<I;++h)if(r[h]!==n[h]){u=r[h],d=n[h];break}return u<d?-1:d<u?1:0},o.isEncoding=function(r){switch(String(r).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}},o.concat=function(r,n){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return o.alloc(0);let u;if(n===void 0)for(n=0,u=0;u<r.length;++u)n+=r[u].length;let d=o.allocUnsafe(n),h=0;for(u=0;u<r.length;++u){let I=r[u];if(te(I,Uint8Array))h+I.length>d.length?(o.isBuffer(I)||(I=o.from(I)),I.copy(d,h)):Uint8Array.prototype.set.call(d,I,h);else if(o.isBuffer(I))I.copy(d,h);else throw new TypeError('"list" argument must be an Array of Buffers');h+=I.length}return d};function $(s,r){if(o.isBuffer(s))return s.length;if(ArrayBuffer.isView(s)||te(s,ArrayBuffer))return s.byteLength;if(typeof s!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof s);let n=s.length,u=arguments.length>2&&arguments[2]===!0;if(!u&&n===0)return 0;let d=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return vt(s).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return Jt(s).length;default:if(d)return u?-1:vt(s).length;r=(""+r).toLowerCase(),d=!0}}o.byteLength=$;function V(s,r,n){let u=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,r>>>=0,n<=r))return"";for(s||(s="utf8");;)switch(s){case"hex":return Wn(this,r,n);case"utf8":case"utf-8":return Vt(this,r,n);case"ascii":return Dn(this,r,n);case"latin1":case"binary":return Vn(this,r,n);case"base64":return $n(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Gn(this,r,n);default:if(u)throw new TypeError("Unknown encoding: "+s);s=(s+"").toLowerCase(),u=!0}}o.prototype._isBuffer=!0;function Q(s,r,n){let u=s[r];s[r]=s[n],s[n]=u}o.prototype.swap16=function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<r;n+=2)Q(this,n,n+1);return this},o.prototype.swap32=function(){let r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<r;n+=4)Q(this,n,n+3),Q(this,n+1,n+2);return this},o.prototype.swap64=function(){let r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<r;n+=8)Q(this,n,n+7),Q(this,n+1,n+6),Q(this,n+2,n+5),Q(this,n+3,n+4);return this},o.prototype.toString=function(){let r=this.length;return r===0?"":arguments.length===0?Vt(this,0,r):V.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(r){if(!o.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:o.compare(this,r)===0},o.prototype.inspect=function(){let r="",n=ge.INSPECT_MAX_BYTES;return r=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(r+=" ... "),"<Buffer "+r+">"},e&&(o.prototype[e]=o.prototype.inspect),o.prototype.compare=function(r,n,u,d,h){if(te(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),!o.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(n===void 0&&(n=0),u===void 0&&(u=r?r.length:0),d===void 0&&(d=0),h===void 0&&(h=this.length),n<0||u>r.length||d<0||h>this.length)throw new RangeError("out of range index");if(d>=h&&n>=u)return 0;if(d>=h)return-1;if(n>=u)return 1;if(n>>>=0,u>>>=0,d>>>=0,h>>>=0,this===r)return 0;let I=h-d,U=u-n,O=Math.min(I,U),M=this.slice(d,h),D=r.slice(n,u);for(let _=0;_<O;++_)if(M[_]!==D[_]){I=M[_],U=D[_];break}return I<U?-1:U<I?1:0};function Y(s,r,n,u,d){if(s.length===0)return-1;if(typeof n=="string"?(u=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,wt(n)&&(n=d?0:s.length-1),n<0&&(n=s.length+n),n>=s.length){if(d)return-1;n=s.length-1}else if(n<0)if(d)n=0;else return-1;if(typeof r=="string"&&(r=o.from(r,u)),o.isBuffer(r))return r.length===0?-1:Dt(s,r,n,u,d);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?d?Uint8Array.prototype.indexOf.call(s,r,n):Uint8Array.prototype.lastIndexOf.call(s,r,n):Dt(s,[r],n,u,d);throw new TypeError("val must be string, number or Buffer")}function Dt(s,r,n,u,d){let h=1,I=s.length,U=r.length;if(u!==void 0&&(u=String(u).toLowerCase(),u==="ucs2"||u==="ucs-2"||u==="utf16le"||u==="utf-16le")){if(s.length<2||r.length<2)return-1;h=2,I/=2,U/=2,n/=2}function O(D,_){return h===1?D[_]:D.readUInt16BE(_*h)}let M;if(d){let D=-1;for(M=n;M<I;M++)if(O(s,M)===O(r,D===-1?0:M-D)){if(D===-1&&(D=M),M-D+1===U)return D*h}else D!==-1&&(M-=M-D),D=-1}else for(n+U>I&&(n=I-U),M=n;M>=0;M--){let D=!0;for(let _=0;_<U;_++)if(O(s,M+_)!==O(r,_)){D=!1;break}if(D)return M}return-1}o.prototype.includes=function(r,n,u){return this.indexOf(r,n,u)!==-1},o.prototype.indexOf=function(r,n,u){return Y(this,r,n,u,!0)},o.prototype.lastIndexOf=function(r,n,u){return Y(this,r,n,u,!1)};function Cn(s,r,n,u){n=Number(n)||0;let d=s.length-n;u?(u=Number(u),u>d&&(u=d)):u=d;let h=r.length;u>h/2&&(u=h/2);let I;for(I=0;I<u;++I){let U=parseInt(r.substr(I*2,2),16);if(wt(U))return I;s[n+I]=U}return I}function Un(s,r,n,u){return tt(vt(r,s.length-n),s,n,u)}function Ln(s,r,n,u){return tt(zn(r),s,n,u)}function _n(s,r,n,u){return tt(Jt(r),s,n,u)}function Mn(s,r,n,u){return tt(Yn(r,s.length-n),s,n,u)}o.prototype.write=function(r,n,u,d){if(n===void 0)d="utf8",u=this.length,n=0;else if(u===void 0&&typeof n=="string")d=n,u=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(u)?(u=u>>>0,d===void 0&&(d="utf8")):(d=u,u=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let h=this.length-n;if((u===void 0||u>h)&&(u=h),r.length>0&&(u<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");d||(d="utf8");let I=!1;for(;;)switch(d){case"hex":return Cn(this,r,n,u);case"utf8":case"utf-8":return Un(this,r,n,u);case"ascii":case"latin1":case"binary":return Ln(this,r,n,u);case"base64":return _n(this,r,n,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Mn(this,r,n,u);default:if(I)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),I=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function $n(s,r,n){return r===0&&n===s.length?p.fromByteArray(s):p.fromByteArray(s.slice(r,n))}function Vt(s,r,n){n=Math.min(s.length,n);let u=[],d=r;for(;d<n;){let h=s[d],I=null,U=h>239?4:h>223?3:h>191?2:1;if(d+U<=n){let O,M,D,_;switch(U){case 1:h<128&&(I=h);break;case 2:O=s[d+1],(O&192)===128&&(_=(h&31)<<6|O&63,_>127&&(I=_));break;case 3:O=s[d+1],M=s[d+2],(O&192)===128&&(M&192)===128&&(_=(h&15)<<12|(O&63)<<6|M&63,_>2047&&(_<55296||_>57343)&&(I=_));break;case 4:O=s[d+1],M=s[d+2],D=s[d+3],(O&192)===128&&(M&192)===128&&(D&192)===128&&(_=(h&15)<<18|(O&63)<<12|(M&63)<<6|D&63,_>65535&&_<1114112&&(I=_))}}I===null?(I=65533,U=1):I>65535&&(I-=65536,u.push(I>>>10&1023|55296),I=56320|I&1023),u.push(I),d+=U}return On(u)}let Wt=4096;function On(s){let r=s.length;if(r<=Wt)return String.fromCharCode.apply(String,s);let n="",u=0;for(;u<r;)n+=String.fromCharCode.apply(String,s.slice(u,u+=Wt));return n}function Dn(s,r,n){let u="";n=Math.min(s.length,n);for(let d=r;d<n;++d)u+=String.fromCharCode(s[d]&127);return u}function Vn(s,r,n){let u="";n=Math.min(s.length,n);for(let d=r;d<n;++d)u+=String.fromCharCode(s[d]);return u}function Wn(s,r,n){let u=s.length;(!r||r<0)&&(r=0),(!n||n<0||n>u)&&(n=u);let d="";for(let h=r;h<n;++h)d+=Kn[s[h]];return d}function Gn(s,r,n){let u=s.slice(r,n),d="";for(let h=0;h<u.length-1;h+=2)d+=String.fromCharCode(u[h]+u[h+1]*256);return d}o.prototype.slice=function(r,n){let u=this.length;r=~~r,n=n===void 0?u:~~n,r<0?(r+=u,r<0&&(r=0)):r>u&&(r=u),n<0?(n+=u,n<0&&(n=0)):n>u&&(n=u),n<r&&(n=r);let d=this.subarray(r,n);return Object.setPrototypeOf(d,o.prototype),d};function G(s,r,n){if(s%1!==0||s<0)throw new RangeError("offset is not uint");if(s+r>n)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(r,n,u){r=r>>>0,n=n>>>0,u||G(r,n,this.length);let d=this[r],h=1,I=0;for(;++I<n&&(h*=256);)d+=this[r+I]*h;return d},o.prototype.readUintBE=o.prototype.readUIntBE=function(r,n,u){r=r>>>0,n=n>>>0,u||G(r,n,this.length);let d=this[r+--n],h=1;for(;n>0&&(h*=256);)d+=this[r+--n]*h;return d},o.prototype.readUint8=o.prototype.readUInt8=function(r,n){return r=r>>>0,n||G(r,1,this.length),this[r]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(r,n){return r=r>>>0,n||G(r,2,this.length),this[r]|this[r+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(r,n){return r=r>>>0,n||G(r,2,this.length),this[r]<<8|this[r+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(r,n){return r=r>>>0,n||G(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(r,n){return r=r>>>0,n||G(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},o.prototype.readBigUInt64LE=de(function(r){r=r>>>0,Ce(r,"offset");let n=this[r],u=this[r+7];(n===void 0||u===void 0)&&Me(r,this.length-8);let d=n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,h=this[++r]+this[++r]*2**8+this[++r]*2**16+u*2**24;return BigInt(d)+(BigInt(h)<<BigInt(32))}),o.prototype.readBigUInt64BE=de(function(r){r=r>>>0,Ce(r,"offset");let n=this[r],u=this[r+7];(n===void 0||u===void 0)&&Me(r,this.length-8);let d=n*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],h=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+u;return(BigInt(d)<<BigInt(32))+BigInt(h)}),o.prototype.readIntLE=function(r,n,u){r=r>>>0,n=n>>>0,u||G(r,n,this.length);let d=this[r],h=1,I=0;for(;++I<n&&(h*=256);)d+=this[r+I]*h;return h*=128,d>=h&&(d-=Math.pow(2,8*n)),d},o.prototype.readIntBE=function(r,n,u){r=r>>>0,n=n>>>0,u||G(r,n,this.length);let d=n,h=1,I=this[r+--d];for(;d>0&&(h*=256);)I+=this[r+--d]*h;return h*=128,I>=h&&(I-=Math.pow(2,8*n)),I},o.prototype.readInt8=function(r,n){return r=r>>>0,n||G(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},o.prototype.readInt16LE=function(r,n){r=r>>>0,n||G(r,2,this.length);let u=this[r]|this[r+1]<<8;return u&32768?u|4294901760:u},o.prototype.readInt16BE=function(r,n){r=r>>>0,n||G(r,2,this.length);let u=this[r+1]|this[r]<<8;return u&32768?u|4294901760:u},o.prototype.readInt32LE=function(r,n){return r=r>>>0,n||G(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},o.prototype.readInt32BE=function(r,n){return r=r>>>0,n||G(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},o.prototype.readBigInt64LE=de(function(r){r=r>>>0,Ce(r,"offset");let n=this[r],u=this[r+7];(n===void 0||u===void 0)&&Me(r,this.length-8);let d=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(u<<24);return(BigInt(d)<<BigInt(32))+BigInt(n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),o.prototype.readBigInt64BE=de(function(r){r=r>>>0,Ce(r,"offset");let n=this[r],u=this[r+7];(n===void 0||u===void 0)&&Me(r,this.length-8);let d=(n<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(d)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+u)}),o.prototype.readFloatLE=function(r,n){return r=r>>>0,n||G(r,4,this.length),t.read(this,r,!0,23,4)},o.prototype.readFloatBE=function(r,n){return r=r>>>0,n||G(r,4,this.length),t.read(this,r,!1,23,4)},o.prototype.readDoubleLE=function(r,n){return r=r>>>0,n||G(r,8,this.length),t.read(this,r,!0,52,8)},o.prototype.readDoubleBE=function(r,n){return r=r>>>0,n||G(r,8,this.length),t.read(this,r,!1,52,8)};function X(s,r,n,u,d,h){if(!o.isBuffer(s))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>d||r<h)throw new RangeError('"value" argument is out of bounds');if(n+u>s.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(r,n,u,d){if(r=+r,n=n>>>0,u=u>>>0,!d){let U=Math.pow(2,8*u)-1;X(this,r,n,u,U,0)}let h=1,I=0;for(this[n]=r&255;++I<u&&(h*=256);)this[n+I]=r/h&255;return n+u},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(r,n,u,d){if(r=+r,n=n>>>0,u=u>>>0,!d){let U=Math.pow(2,8*u)-1;X(this,r,n,u,U,0)}let h=u-1,I=1;for(this[n+h]=r&255;--h>=0&&(I*=256);)this[n+h]=r/I&255;return n+u},o.prototype.writeUint8=o.prototype.writeUInt8=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,1,255,0),this[n]=r&255,n+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,2,65535,0),this[n]=r&255,this[n+1]=r>>>8,n+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,2,65535,0),this[n]=r>>>8,this[n+1]=r&255,n+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,4,4294967295,0),this[n+3]=r>>>24,this[n+2]=r>>>16,this[n+1]=r>>>8,this[n]=r&255,n+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,4,4294967295,0),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4};function Gt(s,r,n,u,d){Kt(r,u,d,s,n,7);let h=Number(r&BigInt(4294967295));s[n++]=h,h=h>>8,s[n++]=h,h=h>>8,s[n++]=h,h=h>>8,s[n++]=h;let I=Number(r>>BigInt(32)&BigInt(4294967295));return s[n++]=I,I=I>>8,s[n++]=I,I=I>>8,s[n++]=I,I=I>>8,s[n++]=I,n}function qt(s,r,n,u,d){Kt(r,u,d,s,n,7);let h=Number(r&BigInt(4294967295));s[n+7]=h,h=h>>8,s[n+6]=h,h=h>>8,s[n+5]=h,h=h>>8,s[n+4]=h;let I=Number(r>>BigInt(32)&BigInt(4294967295));return s[n+3]=I,I=I>>8,s[n+2]=I,I=I>>8,s[n+1]=I,I=I>>8,s[n]=I,n+8}o.prototype.writeBigUInt64LE=de(function(r,n=0){return Gt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=de(function(r,n=0){return qt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(r,n,u,d){if(r=+r,n=n>>>0,!d){let O=Math.pow(2,8*u-1);X(this,r,n,u,O-1,-O)}let h=0,I=1,U=0;for(this[n]=r&255;++h<u&&(I*=256);)r<0&&U===0&&this[n+h-1]!==0&&(U=1),this[n+h]=(r/I>>0)-U&255;return n+u},o.prototype.writeIntBE=function(r,n,u,d){if(r=+r,n=n>>>0,!d){let O=Math.pow(2,8*u-1);X(this,r,n,u,O-1,-O)}let h=u-1,I=1,U=0;for(this[n+h]=r&255;--h>=0&&(I*=256);)r<0&&U===0&&this[n+h+1]!==0&&(U=1),this[n+h]=(r/I>>0)-U&255;return n+u},o.prototype.writeInt8=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,1,127,-128),r<0&&(r=255+r+1),this[n]=r&255,n+1},o.prototype.writeInt16LE=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,2,32767,-32768),this[n]=r&255,this[n+1]=r>>>8,n+2},o.prototype.writeInt16BE=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,2,32767,-32768),this[n]=r>>>8,this[n+1]=r&255,n+2},o.prototype.writeInt32LE=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,4,2147483647,-2147483648),this[n]=r&255,this[n+1]=r>>>8,this[n+2]=r>>>16,this[n+3]=r>>>24,n+4},o.prototype.writeInt32BE=function(r,n,u){return r=+r,n=n>>>0,u||X(this,r,n,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4},o.prototype.writeBigInt64LE=de(function(r,n=0){return Gt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=de(function(r,n=0){return qt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function jt(s,r,n,u,d,h){if(n+u>s.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Ht(s,r,n,u,d){return r=+r,n=n>>>0,d||jt(s,r,n,4),t.write(s,r,n,u,23,4),n+4}o.prototype.writeFloatLE=function(r,n,u){return Ht(this,r,n,!0,u)},o.prototype.writeFloatBE=function(r,n,u){return Ht(this,r,n,!1,u)};function zt(s,r,n,u,d){return r=+r,n=n>>>0,d||jt(s,r,n,8),t.write(s,r,n,u,52,8),n+8}o.prototype.writeDoubleLE=function(r,n,u){return zt(this,r,n,!0,u)},o.prototype.writeDoubleBE=function(r,n,u){return zt(this,r,n,!1,u)},o.prototype.copy=function(r,n,u,d){if(!o.isBuffer(r))throw new TypeError("argument should be a Buffer");if(u||(u=0),!d&&d!==0&&(d=this.length),n>=r.length&&(n=r.length),n||(n=0),d>0&&d<u&&(d=u),d===u||r.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(u<0||u>=this.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),r.length-n<d-u&&(d=r.length-n+u);let h=d-u;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,u,d):Uint8Array.prototype.set.call(r,this.subarray(u,d),n),h},o.prototype.fill=function(r,n,u,d){if(typeof r=="string"){if(typeof n=="string"?(d=n,n=0,u=this.length):typeof u=="string"&&(d=u,u=this.length),d!==void 0&&typeof d!="string")throw new TypeError("encoding must be a string");if(typeof d=="string"&&!o.isEncoding(d))throw new TypeError("Unknown encoding: "+d);if(r.length===1){let I=r.charCodeAt(0);(d==="utf8"&&I<128||d==="latin1")&&(r=I)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(n<0||this.length<n||this.length<u)throw new RangeError("Out of range index");if(u<=n)return this;n=n>>>0,u=u===void 0?this.length:u>>>0,r||(r=0);let h;if(typeof r=="number")for(h=n;h<u;++h)this[h]=r;else{let I=o.isBuffer(r)?r:o.from(r,d),U=I.length;if(U===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(h=0;h<u-n;++h)this[h+n]=I[h%U]}return this};let Se={};function gt(s,r,n){Se[s]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${s}]`,this.stack,delete this.name}get code(){return s}set code(d){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:d,writable:!0})}toString(){return`${this.name} [${s}]: ${this.message}`}}}gt("ERR_BUFFER_OUT_OF_BOUNDS",function(s){return s?`${s} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),gt("ERR_INVALID_ARG_TYPE",function(s,r){return`The "${s}" argument must be of type number. Received type ${typeof r}`},TypeError),gt("ERR_OUT_OF_RANGE",function(s,r,n){let u=`The value of "${s}" is out of range.`,d=n;return Number.isInteger(n)&&Math.abs(n)>2**32?d=Yt(String(n)):typeof n=="bigint"&&(d=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(d=Yt(d)),d+="n"),u+=` It must be ${r}. Received ${d}`,u},RangeError);function Yt(s){let r="",n=s.length,u=s[0]==="-"?1:0;for(;n>=u+4;n-=3)r=`_${s.slice(n-3,n)}${r}`;return`${s.slice(0,n)}${r}`}function qn(s,r,n){Ce(r,"offset"),(s[r]===void 0||s[r+n]===void 0)&&Me(r,s.length-(n+1))}function Kt(s,r,n,u,d,h){if(s>n||s<r){let I=typeof r=="bigint"?"n":"",U;throw r===0||r===BigInt(0)?U=`>= 0${I} and < 2${I} ** ${(h+1)*8}${I}`:U=`>= -(2${I} ** ${(h+1)*8-1}${I}) and < 2 ** ${(h+1)*8-1}${I}`,new Se.ERR_OUT_OF_RANGE("value",U,s)}qn(u,d,h)}function Ce(s,r){if(typeof s!="number")throw new Se.ERR_INVALID_ARG_TYPE(r,"number",s)}function Me(s,r,n){throw Math.floor(s)!==s?(Ce(s,n),new Se.ERR_OUT_OF_RANGE("offset","an integer",s)):r<0?new Se.ERR_BUFFER_OUT_OF_BOUNDS:new Se.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,s)}let jn=/[^+/0-9A-Za-z-_]/g;function Hn(s){if(s=s.split("=")[0],s=s.trim().replace(jn,""),s.length<2)return"";for(;s.length%4!==0;)s=s+"=";return s}function vt(s,r){r=r||1/0;let n,u=s.length,d=null,h=[];for(let I=0;I<u;++I){if(n=s.charCodeAt(I),n>55295&&n<57344){if(!d){if(n>56319){(r-=3)>-1&&h.push(239,191,189);continue}else if(I+1===u){(r-=3)>-1&&h.push(239,191,189);continue}d=n;continue}if(n<56320){(r-=3)>-1&&h.push(239,191,189),d=n;continue}n=(d-55296<<10|n-56320)+65536}else d&&(r-=3)>-1&&h.push(239,191,189);if(d=null,n<128){if((r-=1)<0)break;h.push(n)}else if(n<2048){if((r-=2)<0)break;h.push(n>>6|192,n&63|128)}else if(n<65536){if((r-=3)<0)break;h.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((r-=4)<0)break;h.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return h}function zn(s){let r=[];for(let n=0;n<s.length;++n)r.push(s.charCodeAt(n)&255);return r}function Yn(s,r){let n,u,d,h=[];for(let I=0;I<s.length&&!((r-=2)<0);++I)n=s.charCodeAt(I),u=n>>8,d=n%256,h.push(d),h.push(u);return h}function Jt(s){return p.toByteArray(Hn(s))}function tt(s,r,n,u){let d;for(d=0;d<u&&!(d+n>=r.length||d>=s.length);++d)r[d+n]=s[d];return d}function te(s,r){return s instanceof r||s!=null&&s.constructor!=null&&s.constructor.name!=null&&s.constructor.name===r.name}function wt(s){return s!==s}let Kn=(function(){let s="0123456789abcdef",r=new Array(256);for(let n=0;n<16;++n){let u=n*16;for(let d=0;d<16;++d)r[u+d]=s[n]+s[d]}return r})();function de(s){return typeof BigInt>"u"?Jn:s}function Jn(){throw new Error("BigInt not supported")}return ge}var $e,gn,ot,vn,ge,wn,Tn=oe(()=>{"use strict";y();v();g();$e={},gn=!1;ot={},vn=!1;ge={},wn=!1});var ve,A,vs,ws,xn=oe(()=>{"use strict";y();v();g();Tn();ve=In();ve.Buffer;ve.SlowBuffer;ve.INSPECT_MAX_BYTES;ve.kMaxLength;A=ve.Buffer,vs=ve.INSPECT_MAX_BYTES,ws=ve.kMaxLength});var v=oe(()=>{"use strict";xn()});function Pt(p){throw new Error("Node.js process "+p+" is not supported by JSPM core outside of Node.js")}function ni(){!Le||!Ie||(Le=!1,Ie.length?ce=Ie.concat(ce):ut=-1,ce.length&&Nn())}function Nn(){if(!Le){var p=setTimeout(ni,0);Le=!0;for(var t=ce.length;t;){for(Ie=ce,ce=[];++ut<t;)Ie&&Ie[ut].run();ut=-1,t=ce.length}Ie=null,Le=!1,clearTimeout(p)}}function ii(p){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 An(p,t)),ce.length===1&&!Le&&setTimeout(Nn,0)}function An(p,t){this.fun=p,this.array=t}function z(){}function Ti(p){Pt("_linkedBinding")}function Ni(p){Pt("dlopen")}function Ai(){return[]}function Ri(){return[]}function _i(p,t){if(!p)throw new Error(t||"assertion error")}function Di(){return!1}function no(){return he.now()/1e3}function Ft(p){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 p&&(i=i-p[0],a=a-p[1],a<0&&(i--,a+=Rt)),[i,a]}function me(){return Bt}function yo(p){return[]}var ce,Le,Ie,ut,oi,si,ai,ci,ui,pi,li,di,fi,hi,mi,yi,gi,vi,wi,Ii,xi,bi,Ei,Fi,Pi,kt,ki,Bi,Si,Ci,Ui,Li,Mi,$i,Oi,Vi,Wi,Gi,qi,ji,Hi,zi,Yi,Ki,Ji,Xi,Qi,Zi,eo,to,ro,he,At,Rt,io,oo,so,ao,co,uo,po,lo,fo,ho,mo,Bt,St=oe(()=>{"use strict";y();v();g();ce=[],Le=!1,ut=-1;An.prototype.run=function(){this.fun.apply(null,this.array)};oi="browser",si="x64",ai="browser",ci={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},ui=["/usr/bin/node"],pi=[],li="v16.8.0",di={},fi=function(p,t){console.warn((t?t+": ":"")+p)},hi=function(p){Pt("binding")},mi=function(p){return 0},yi=function(){return"/"},gi=function(p){},vi={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};wi=z,Ii=[];xi={},bi=!1,Ei={};Fi=z,Pi=z,kt=function(){return{}},ki=kt,Bi=kt,Si=z,Ci=z,Ui=z,Li={};Mi={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},$i=z,Oi=z;Vi=z,Wi=z,Gi=z,qi=z,ji=z,Hi=void 0,zi=void 0,Yi=void 0,Ki=z,Ji=2,Xi=1,Qi="/bin/usr/node",Zi=9229,eo="node",to=[],ro=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(p){var t=Ft(p);return typeof BigInt>"u"?t[0]*Rt+t[1]:BigInt(t[0]*Rt)+BigInt(t[1])};io=10,oo={},so=0;ao=me,co=me,uo=me,po=me,lo=me,fo=z,ho=me,mo=me;Bt={version:li,versions:di,arch:si,platform:ai,release:vi,_rawDebug:wi,moduleLoadList:Ii,binding:hi,_linkedBinding:Ti,_events:oo,_eventsCount:so,_maxListeners:io,on:me,addListener:ao,once:co,off:uo,removeListener:po,removeAllListeners:lo,emit:fo,prependListener:ho,prependOnceListener:mo,listeners:yo,domain:xi,_exiting:bi,config:Ei,dlopen:Ni,uptime:no,_getActiveRequests:Ai,_getActiveHandles:Ri,reallyExit:Fi,_kill:Pi,cpuUsage:kt,resourceUsage:ki,memoryUsage:Bi,kill:Si,exit:Ci,openStdin:Ui,allowedNodeEnvironmentFlags:Li,assert:_i,features:Mi,_fatalExceptions:$i,setUncaughtExceptionCaptureCallback:Oi,hasUncaughtExceptionCaptureCallback:Di,emitWarning:fi,nextTick:ii,_tickCallback:Vi,_debugProcess:Wi,_debugEnd:Gi,_startProfilerIdleNotifier:qi,_stopProfilerIdleNotifier:ji,stdout:Hi,stdin:Yi,stderr:zi,abort:Ki,umask:mi,chdir:gi,cwd:yi,env:ci,title:oi,argv:ui,execArgv:pi,pid:Ji,ppid:Xi,execPath:Qi,debugPort:Zi,hrtime:Ft,argv0:eo,_preload_modules:to,setSourceMapsEnabled:ro}});function go(){if(Rn)return Ct;Rn=!0;var p=Bt;function t(c){if(typeof c!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(c))}function e(c,o){for(var f="",w=0,T=-1,b=0,x,P=0;P<=c.length;++P){if(P<c.length)x=c.charCodeAt(P);else{if(x===47)break;x=47}if(x===47){if(!(T===P-1||b===1))if(T!==P-1&&b===2){if(f.length<2||w!==2||f.charCodeAt(f.length-1)!==46||f.charCodeAt(f.length-2)!==46){if(f.length>2){var E=f.lastIndexOf("/");if(E!==f.length-1){E===-1?(f="",w=0):(f=f.slice(0,E),w=f.length-1-f.lastIndexOf("/")),T=P,b=0;continue}}else if(f.length===2||f.length===1){f="",w=0,T=P,b=0;continue}}o&&(f.length>0?f+="/..":f="..",w=2)}else f.length>0?f+="/"+c.slice(T+1,P):f=c.slice(T+1,P),w=P-T-1;T=P,b=0}else x===46&&b!==-1?++b:b=-1}return f}function i(c,o){var f=o.dir||o.root,w=o.base||(o.name||"")+(o.ext||"");return f?f===o.root?f+w:f+c+w:w}var a={resolve:function(){for(var o="",f=!1,w,T=arguments.length-1;T>=-1&&!f;T--){var b;T>=0?b=arguments[T]:(w===void 0&&(w=p.cwd()),b=w),t(b),b.length!==0&&(o=b+"/"+o,f=b.charCodeAt(0)===47)}return o=e(o,!f),f?o.length>0?"/"+o:"/":o.length>0?o:"."},normalize:function(o){if(t(o),o.length===0)return".";var f=o.charCodeAt(0)===47,w=o.charCodeAt(o.length-1)===47;return o=e(o,!f),o.length===0&&!f&&(o="."),o.length>0&&w&&(o+="/"),f?"/"+o:o},isAbsolute:function(o){return t(o),o.length>0&&o.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var o,f=0;f<arguments.length;++f){var w=arguments[f];t(w),w.length>0&&(o===void 0?o=w:o+="/"+w)}return o===void 0?".":a.normalize(o)},relative:function(o,f){if(t(o),t(f),o===f||(o=a.resolve(o),f=a.resolve(f),o===f))return"";for(var w=1;w<o.length&&o.charCodeAt(w)===47;++w);for(var T=o.length,b=T-w,x=1;x<f.length&&f.charCodeAt(x)===47;++x);for(var P=f.length,E=P-x,F=b<E?b:E,S=-1,B=0;B<=F;++B){if(B===F){if(E>F){if(f.charCodeAt(x+B)===47)return f.slice(x+B+1);if(B===0)return f.slice(x+B)}else b>F&&(o.charCodeAt(w+B)===47?S=B:B===0&&(S=0));break}var q=o.charCodeAt(w+B),$=f.charCodeAt(x+B);if(q!==$)break;q===47&&(S=B)}var V="";for(B=w+S+1;B<=T;++B)(B===T||o.charCodeAt(B)===47)&&(V.length===0?V+="..":V+="/..");return V.length>0?V+f.slice(x+S):(x+=S,f.charCodeAt(x)===47&&++x,f.slice(x))},_makeLong:function(o){return o},dirname:function(o){if(t(o),o.length===0)return".";for(var f=o.charCodeAt(0),w=f===47,T=-1,b=!0,x=o.length-1;x>=1;--x)if(f=o.charCodeAt(x),f===47){if(!b){T=x;break}}else b=!1;return T===-1?w?"/":".":w&&T===1?"//":o.slice(0,T)},basename:function(o,f){if(f!==void 0&&typeof f!="string")throw new TypeError('"ext" argument must be a string');t(o);var w=0,T=-1,b=!0,x;if(f!==void 0&&f.length>0&&f.length<=o.length){if(f.length===o.length&&f===o)return"";var P=f.length-1,E=-1;for(x=o.length-1;x>=0;--x){var F=o.charCodeAt(x);if(F===47){if(!b){w=x+1;break}}else E===-1&&(b=!1,E=x+1),P>=0&&(F===f.charCodeAt(P)?--P===-1&&(T=x):(P=-1,T=E))}return w===T?T=E:T===-1&&(T=o.length),o.slice(w,T)}else{for(x=o.length-1;x>=0;--x)if(o.charCodeAt(x)===47){if(!b){w=x+1;break}}else T===-1&&(b=!1,T=x+1);return T===-1?"":o.slice(w,T)}},extname:function(o){t(o);for(var f=-1,w=0,T=-1,b=!0,x=0,P=o.length-1;P>=0;--P){var E=o.charCodeAt(P);if(E===47){if(!b){w=P+1;break}continue}T===-1&&(b=!1,T=P+1),E===46?f===-1?f=P:x!==1&&(x=1):f!==-1&&(x=-1)}return f===-1||T===-1||x===0||x===1&&f===T-1&&f===w+1?"":o.slice(f,T)},format:function(o){if(o===null||typeof o!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof o);return i("/",o)},parse:function(o){t(o);var f={root:"",dir:"",base:"",ext:"",name:""};if(o.length===0)return f;var w=o.charCodeAt(0),T=w===47,b;T?(f.root="/",b=1):b=0;for(var x=-1,P=0,E=-1,F=!0,S=o.length-1,B=0;S>=b;--S){if(w=o.charCodeAt(S),w===47){if(!F){P=S+1;break}continue}E===-1&&(F=!1,E=S+1),w===46?x===-1?x=S:B!==1&&(B=1):x!==-1&&(B=-1)}return x===-1||E===-1||B===0||B===1&&x===E-1&&x===P+1?E!==-1&&(P===0&&T?f.base=f.name=o.slice(1,E):f.base=f.name=o.slice(P,E)):(P===0&&T?(f.name=o.slice(1,x),f.base=o.slice(1,E)):(f.name=o.slice(P,x),f.base=o.slice(P,E)),f.ext=o.slice(x,E)),P>0?f.dir=o.slice(0,P-1):T&&(f.dir="/"),f},sep:"/",delimiter:":",win32:null,posix:null};return a.posix=a,Ct=a,Ct}var Ct,Rn,W,Fn=oe(()=>{"use strict";y();v();g();St();Ct={},Rn=!1;W=go()});var mu,yu,gu,vu,wu,Iu,Tu,xu,bu,Eu,Nu,Au,Ru,Fu,Pu,Pn=oe(()=>{"use strict";y();v();g();Fn();St();mu=W._makeLong,yu=W.basename,gu=W.delimiter,vu=W.dirname,wu=W.extname,Iu=W.format,Tu=W.isAbsolute,xu=W.join,bu=W.normalize,Eu=W.parse,Nu=W.posix,Au=W.relative,Ru=W.resolve,Fu=W.sep,Pu=W.win32});y();v();g();y();v();g();y();v();g();y();v();g();function C(p){throw new Error("Unexpected value: "+JSON.stringify(p))}y();v();g();function Oe(p){return Object.keys(p)}y();v();g();y();v();g();y();v();g();var De=N.env.FERN_STACK_TRACK?.toLowerCase()??"",re=De!==""&&De!=="0"&&De!=="false",bt=["single","multiline","box"].includes(De)?De:"single";re&&(Error.stackTraceLimit=50);var ti=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),ri=new Set(["stacktrace"]);function at({maxFrames:p=50,skip:t=0,filterPaths:e=[],filterFunctions:i=[],stopOn:a=[],filterNode:c=!0,filterJs:o=!0,formatFilename:f=w=>w}={}){if(!re)return[];i=[...i,...ti],e=[...e,...ri],a=[...a,"runInteractiveTask"];let w=!1;return(new Error().stack??"").split(`
|
|
2
|
-
`).map(T=>{let b=T.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(b&&b.length===5){let[,x,P,E,F]=b;if(!x||!P||!E||!F)return;if(w||a.some(
|
|
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}},Et;function
|
|
1
|
+
var Xt=Object.defineProperty;var Xr=(p,t,e)=>t in p?Xt(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e;var oe=(p,t,e)=>()=>{if(e)throw e[0];try{return p&&(t=p(p=0)),t}catch(i){throw e=[i],i}};var Qt=(p,t)=>{for(var e in t)Xt(p,e,{get:t[e],enumerable:!0})};var m=(p,t,e)=>Xr(p,typeof t!="symbol"?t+"":t,e);var y=oe(()=>{"use strict"});var N={};Qt(N,{_debugEnd:()=>Wn,_debugProcess:()=>Vn,_events:()=>ir,_eventsCount:()=>or,_exiting:()=>xn,_fatalExceptions:()=>Mn,_getActiveHandles:()=>An,_getActiveRequests:()=>Nn,_kill:()=>Fn,_linkedBinding:()=>In,_maxListeners:()=>rr,_preload_modules:()=>er,_rawDebug:()=>vn,_startProfilerIdleNotifier:()=>Gn,_stopProfilerIdleNotifier:()=>qn,_tickCallback:()=>Dn,abort:()=>Yn,addListener:()=>sr,allowedNodeEnvironmentFlags:()=>Un,arch:()=>rn,argv:()=>an,argv0:()=>Zn,assert:()=>Ln,binding:()=>dn,browser:()=>gn,chdir:()=>mn,config:()=>bn,cpuUsage:()=>it,cwd:()=>hn,debugPort:()=>Qn,default:()=>mr,dlopen:()=>En,domain:()=>Tn,emit:()=>lr,emitWarning:()=>ln,env:()=>sn,execArgv:()=>cn,execPath:()=>Xn,exit:()=>Bn,features:()=>_n,hasUncaughtExceptionCaptureCallback:()=>On,hrtime:()=>rt,kill:()=>Sn,listeners:()=>hr,memoryUsage:()=>kn,moduleLoadList:()=>wn,nextTick:()=>en,off:()=>cr,on:()=>ae,once:()=>ar,openStdin:()=>Cn,pid:()=>Kn,platform:()=>on,ppid:()=>Jn,prependListener:()=>dr,prependOnceListener:()=>fr,reallyExit:()=>Rn,release:()=>yn,removeAllListeners:()=>pr,removeListener:()=>ur,resourceUsage:()=>Pn,setSourceMapsEnabled:()=>tr,setUncaughtExceptionCaptureCallback:()=>$n,stderr:()=>Hn,stdin:()=>zn,stdout:()=>jn,title:()=>nn,umask:()=>fn,uptime:()=>nr,version:()=>un,versions:()=>pn});function xt(p){throw new Error("Node.js process "+p+" is not supported by JSPM core outside of Node.js")}function Qr(){!Ue||!ye||(Ue=!1,ye.length?se=ye.concat(se):nt=-1,se.length&&Zt())}function Zt(){if(!Ue){var p=setTimeout(Qr,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(p)}}function en(p){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 tn(p,t)),se.length===1&&!Ue&&setTimeout(Zt,0)}function tn(p,t){this.fun=p,this.array=t}function H(){}function In(p){xt("_linkedBinding")}function En(p){xt("dlopen")}function Nn(){return[]}function An(){return[]}function Ln(p,t){if(!p)throw new Error(t||"assertion error")}function On(){return!1}function nr(){return fe.now()/1e3}function rt(p){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 p&&(i=i-p[0],a=a-p[1],a<0&&(i--,a+=Tt)),[i,a]}function ae(){return mr}function hr(p){return[]}var se,Ue,ye,nt,nn,rn,on,sn,an,cn,un,pn,ln,dn,fn,hn,mn,yn,gn,vn,wn,Tn,xn,bn,Rn,Fn,it,Pn,kn,Sn,Bn,Cn,Un,_n,Mn,$n,Dn,Vn,Wn,Gn,qn,jn,Hn,zn,Yn,Kn,Jn,Xn,Qn,Zn,er,tr,fe,It,Tt,rr,ir,or,sr,ar,cr,ur,pr,lr,dr,fr,mr,yr=oe(()=>{"use strict";y();v();g();se=[],Ue=!1,nt=-1;tn.prototype.run=function(){this.fun.apply(null,this.array)};nn="browser",rn="x64",on="browser",sn={PATH:"/usr/bin",LANG:typeof navigator<"u"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},an=["/usr/bin/node"],cn=[],un="v16.8.0",pn={},ln=function(p,t){console.warn((t?t+": ":"")+p)},dn=function(p){xt("binding")},fn=function(p){return 0},hn=function(){return"/"},mn=function(p){},yn={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};gn=!0,vn=H,wn=[];Tn={},xn=!1,bn={};Rn=H,Fn=H,it=function(){return{}},Pn=it,kn=it,Sn=H,Bn=H,Cn=H,Un={};_n={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},Mn=H,$n=H;Dn=H,Vn=H,Wn=H,Gn=H,qn=H,jn=void 0,Hn=void 0,zn=void 0,Yn=H,Kn=2,Jn=1,Xn="/bin/usr/node",Qn=9229,Zn="node",er=[],tr=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(p){var t=rt(p);return typeof BigInt>"u"?t[0]*Tt+t[1]:BigInt(t[0]*Tt)+BigInt(t[1])};rr=10,ir={},or=0;sr=ae,ar=ae,cr=ae,ur=ae,pr=ae,lr=H,dr=ae,fr=ae;mr={version:un,versions:pn,arch:rn,platform:on,browser:gn,release:yn,_rawDebug:vn,moduleLoadList:wn,binding:dn,_linkedBinding:In,_events:ir,_eventsCount:or,_maxListeners:rr,on:ae,addListener:sr,once:ar,off:cr,removeListener:ur,removeAllListeners:pr,emit:lr,prependListener:dr,prependOnceListener:fr,listeners:hr,domain:Tn,_exiting:xn,config:bn,dlopen:En,uptime:nr,_getActiveRequests:Nn,_getActiveHandles:An,reallyExit:Rn,_kill:Fn,cpuUsage:it,resourceUsage:Pn,memoryUsage:kn,kill:Sn,exit:Bn,openStdin:Cn,allowedNodeEnvironmentFlags:Un,assert:Ln,features:_n,_fatalExceptions:Mn,setUncaughtExceptionCaptureCallback:$n,hasUncaughtExceptionCaptureCallback:On,emitWarning:ln,nextTick:en,_tickCallback:Dn,_debugProcess:Vn,_debugEnd:Wn,_startProfilerIdleNotifier:Gn,_stopProfilerIdleNotifier:qn,stdout:jn,stdin:zn,stderr:Hn,abort:Yn,umask:fn,chdir:mn,cwd:hn,env:sn,title:nn,argv:an,execArgv:cn,pid:Kn,ppid:Jn,execPath:Xn,debugPort:Qn,hrtime:rt,argv0:Zn,_preload_modules:er,setSourceMapsEnabled:tr}});var g=oe(()=>{"use strict";yr()});function Zr(){if(gr)return $e;gr=!0,$e.byteLength=f,$e.toByteArray=T,$e.fromByteArray=P;for(var p=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=i.length;a<c;++a)p[a]=i[a],t[i.charCodeAt(a)]=a;t[45]=62,t[95]=63;function o(E){var F=E.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var B=E.indexOf("=");B===-1&&(B=F);var S=B===F?0:4-B%4;return[B,S]}function f(E){var F=o(E),B=F[0],S=F[1];return(B+S)*3/4-S}function w(E,F,B){return(F+B)*3/4-B}function T(E){var F,B=o(E),S=B[0],q=B[1],$=new e(w(E,S,q)),V=0,Q=q>0?S-4:S,Y;for(Y=0;Y<Q;Y+=4)F=t[E.charCodeAt(Y)]<<18|t[E.charCodeAt(Y+1)]<<12|t[E.charCodeAt(Y+2)]<<6|t[E.charCodeAt(Y+3)],$[V++]=F>>16&255,$[V++]=F>>8&255,$[V++]=F&255;return q===2&&(F=t[E.charCodeAt(Y)]<<2|t[E.charCodeAt(Y+1)]>>4,$[V++]=F&255),q===1&&(F=t[E.charCodeAt(Y)]<<10|t[E.charCodeAt(Y+1)]<<4|t[E.charCodeAt(Y+2)]>>2,$[V++]=F>>8&255,$[V++]=F&255),$}function b(E){return p[E>>18&63]+p[E>>12&63]+p[E>>6&63]+p[E&63]}function x(E,F,B){for(var S,q=[],$=F;$<B;$+=3)S=(E[$]<<16&16711680)+(E[$+1]<<8&65280)+(E[$+2]&255),q.push(b(S));return q.join("")}function P(E){for(var F,B=E.length,S=B%3,q=[],$=16383,V=0,Q=B-S;V<Q;V+=$)q.push(x(E,V,V+$>Q?Q:V+$));return S===1?(F=E[B-1],q.push(p[F>>2]+p[F<<4&63]+"==")):S===2&&(F=(E[B-2]<<8)+E[B-1],q.push(p[F>>10]+p[F>>4&63]+p[F<<2&63]+"=")),q.join("")}return $e}function ei(){if(vr)return ot;vr=!0;return ot.read=function(p,t,e,i,a){var c,o,f=a*8-i-1,w=(1<<f)-1,T=w>>1,b=-7,x=e?a-1:0,P=e?-1:1,E=p[t+x];for(x+=P,c=E&(1<<-b)-1,E>>=-b,b+=f;b>0;c=c*256+p[t+x],x+=P,b-=8);for(o=c&(1<<-b)-1,c>>=-b,b+=i;b>0;o=o*256+p[t+x],x+=P,b-=8);if(c===0)c=1-T;else{if(c===w)return o?NaN:(E?-1:1)*(1/0);o=o+Math.pow(2,i),c=c-T}return(E?-1:1)*o*Math.pow(2,c-i)},ot.write=function(p,t,e,i,a,c){var o,f,w,T=c*8-a-1,b=(1<<T)-1,x=b>>1,P=a===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=i?0:c-1,F=i?1:-1,B=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(f=isNaN(t)?1:0,o=b):(o=Math.floor(Math.log(t)/Math.LN2),t*(w=Math.pow(2,-o))<1&&(o--,w*=2),o+x>=1?t+=P/w:t+=P*Math.pow(2,1-x),t*w>=2&&(o++,w/=2),o+x>=b?(f=0,o=b):o+x>=1?(f=(t*w-1)*Math.pow(2,a),o=o+x):(f=t*Math.pow(2,x-1)*Math.pow(2,a),o=0));a>=8;p[e+E]=f&255,E+=F,f/=256,a-=8);for(o=o<<a|f,T+=a;T>0;p[e+E]=o&255,E+=F,o/=256,T-=8);p[e+E-F]|=B*128},ot}function Ir(){if(wr)return ge;wr=!0;let p=Zr(),t=ei(),e=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ge.Buffer=o,ge.SlowBuffer=q,ge.INSPECT_MAX_BYTES=50;let i=2147483647;ge.kMaxLength=i,o.TYPED_ARRAY_SUPPORT=a(),!o.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 s=new Uint8Array(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,Uint8Array.prototype),Object.setPrototypeOf(s,n),s.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function c(s){if(s>i)throw new RangeError('The value "'+s+'" is invalid for option "size"');let n=new Uint8Array(s);return Object.setPrototypeOf(n,o.prototype),n}function o(s,n,r){if(typeof s=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(s)}return f(s,n,r)}o.poolSize=8192;function f(s,n,r){if(typeof s=="string")return x(s,n);if(ArrayBuffer.isView(s))return E(s);if(s==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof s);if(te(s,ArrayBuffer)||s&&te(s.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(te(s,SharedArrayBuffer)||s&&te(s.buffer,SharedArrayBuffer)))return F(s,n,r);if(typeof s=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let u=s.valueOf&&s.valueOf();if(u!=null&&u!==s)return o.from(u,n,r);let d=B(s);if(d)return d;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof s[Symbol.toPrimitive]=="function")return o.from(s[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 s)}o.from=function(s,n,r){return f(s,n,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function w(s){if(typeof s!="number")throw new TypeError('"size" argument must be of type number');if(s<0)throw new RangeError('The value "'+s+'" is invalid for option "size"')}function T(s,n,r){return w(s),s<=0?c(s):n!==void 0?typeof r=="string"?c(s).fill(n,r):c(s).fill(n):c(s)}o.alloc=function(s,n,r){return T(s,n,r)};function b(s){return w(s),c(s<0?0:S(s)|0)}o.allocUnsafe=function(s){return b(s)},o.allocUnsafeSlow=function(s){return b(s)};function x(s,n){if((typeof n!="string"||n==="")&&(n="utf8"),!o.isEncoding(n))throw new TypeError("Unknown encoding: "+n);let r=$(s,n)|0,u=c(r),d=u.write(s,n);return d!==r&&(u=u.slice(0,d)),u}function P(s){let n=s.length<0?0:S(s.length)|0,r=c(n);for(let u=0;u<n;u+=1)r[u]=s[u]&255;return r}function E(s){if(te(s,Uint8Array)){let n=new Uint8Array(s);return F(n.buffer,n.byteOffset,n.byteLength)}return P(s)}function F(s,n,r){if(n<0||s.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(s.byteLength<n+(r||0))throw new RangeError('"length" is outside of buffer bounds');let u;return n===void 0&&r===void 0?u=new Uint8Array(s):r===void 0?u=new Uint8Array(s,n):u=new Uint8Array(s,n,r),Object.setPrototypeOf(u,o.prototype),u}function B(s){if(o.isBuffer(s)){let n=S(s.length)|0,r=c(n);return r.length===0||s.copy(r,0,0,n),r}if(s.length!==void 0)return typeof s.length!="number"||wt(s.length)?c(0):P(s);if(s.type==="Buffer"&&Array.isArray(s.data))return P(s.data)}function S(s){if(s>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return s|0}function q(s){return+s!=s&&(s=0),o.alloc(+s)}o.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==o.prototype},o.compare=function(n,r){if(te(n,Uint8Array)&&(n=o.from(n,n.offset,n.byteLength)),te(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),!o.isBuffer(n)||!o.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===r)return 0;let u=n.length,d=r.length;for(let h=0,I=Math.min(u,d);h<I;++h)if(n[h]!==r[h]){u=n[h],d=r[h];break}return u<d?-1:d<u?1:0},o.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}},o.concat=function(n,r){if(!Array.isArray(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return o.alloc(0);let u;if(r===void 0)for(r=0,u=0;u<n.length;++u)r+=n[u].length;let d=o.allocUnsafe(r),h=0;for(u=0;u<n.length;++u){let I=n[u];if(te(I,Uint8Array))h+I.length>d.length?(o.isBuffer(I)||(I=o.from(I)),I.copy(d,h)):Uint8Array.prototype.set.call(d,I,h);else if(o.isBuffer(I))I.copy(d,h);else throw new TypeError('"list" argument must be an Array of Buffers');h+=I.length}return d};function $(s,n){if(o.isBuffer(s))return s.length;if(ArrayBuffer.isView(s)||te(s,ArrayBuffer))return s.byteLength;if(typeof s!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof s);let r=s.length,u=arguments.length>2&&arguments[2]===!0;if(!u&&r===0)return 0;let d=!1;for(;;)switch(n){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return vt(s).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Jt(s).length;default:if(d)return u?-1:vt(s).length;n=(""+n).toLowerCase(),d=!0}}o.byteLength=$;function V(s,n,r){let u=!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(s||(s="utf8");;)switch(s){case"hex":return Wr(this,n,r);case"utf8":case"utf-8":return Vt(this,n,r);case"ascii":return Dr(this,n,r);case"latin1":case"binary":return Vr(this,n,r);case"base64":return $r(this,n,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Gr(this,n,r);default:if(u)throw new TypeError("Unknown encoding: "+s);s=(s+"").toLowerCase(),u=!0}}o.prototype._isBuffer=!0;function Q(s,n,r){let u=s[n];s[n]=s[r],s[r]=u}o.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},o.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},o.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},o.prototype.toString=function(){let n=this.length;return n===0?"":arguments.length===0?Vt(this,0,n):V.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(n){if(!o.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:o.compare(this,n)===0},o.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&&(o.prototype[e]=o.prototype.inspect),o.prototype.compare=function(n,r,u,d,h){if(te(n,Uint8Array)&&(n=o.from(n,n.offset,n.byteLength)),!o.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),u===void 0&&(u=n?n.length:0),d===void 0&&(d=0),h===void 0&&(h=this.length),r<0||u>n.length||d<0||h>this.length)throw new RangeError("out of range index");if(d>=h&&r>=u)return 0;if(d>=h)return-1;if(r>=u)return 1;if(r>>>=0,u>>>=0,d>>>=0,h>>>=0,this===n)return 0;let I=h-d,U=u-r,O=Math.min(I,U),M=this.slice(d,h),D=n.slice(r,u);for(let _=0;_<O;++_)if(M[_]!==D[_]){I=M[_],U=D[_];break}return I<U?-1:U<I?1:0};function Y(s,n,r,u,d){if(s.length===0)return-1;if(typeof r=="string"?(u=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,wt(r)&&(r=d?0:s.length-1),r<0&&(r=s.length+r),r>=s.length){if(d)return-1;r=s.length-1}else if(r<0)if(d)r=0;else return-1;if(typeof n=="string"&&(n=o.from(n,u)),o.isBuffer(n))return n.length===0?-1:Dt(s,n,r,u,d);if(typeof n=="number")return n=n&255,typeof Uint8Array.prototype.indexOf=="function"?d?Uint8Array.prototype.indexOf.call(s,n,r):Uint8Array.prototype.lastIndexOf.call(s,n,r):Dt(s,[n],r,u,d);throw new TypeError("val must be string, number or Buffer")}function Dt(s,n,r,u,d){let h=1,I=s.length,U=n.length;if(u!==void 0&&(u=String(u).toLowerCase(),u==="ucs2"||u==="ucs-2"||u==="utf16le"||u==="utf-16le")){if(s.length<2||n.length<2)return-1;h=2,I/=2,U/=2,r/=2}function O(D,_){return h===1?D[_]:D.readUInt16BE(_*h)}let M;if(d){let D=-1;for(M=r;M<I;M++)if(O(s,M)===O(n,D===-1?0:M-D)){if(D===-1&&(D=M),M-D+1===U)return D*h}else D!==-1&&(M-=M-D),D=-1}else for(r+U>I&&(r=I-U),M=r;M>=0;M--){let D=!0;for(let _=0;_<U;_++)if(O(s,M+_)!==O(n,_)){D=!1;break}if(D)return M}return-1}o.prototype.includes=function(n,r,u){return this.indexOf(n,r,u)!==-1},o.prototype.indexOf=function(n,r,u){return Y(this,n,r,u,!0)},o.prototype.lastIndexOf=function(n,r,u){return Y(this,n,r,u,!1)};function Cr(s,n,r,u){r=Number(r)||0;let d=s.length-r;u?(u=Number(u),u>d&&(u=d)):u=d;let h=n.length;u>h/2&&(u=h/2);let I;for(I=0;I<u;++I){let U=parseInt(n.substr(I*2,2),16);if(wt(U))return I;s[r+I]=U}return I}function Ur(s,n,r,u){return tt(vt(n,s.length-r),s,r,u)}function Lr(s,n,r,u){return tt(zr(n),s,r,u)}function _r(s,n,r,u){return tt(Jt(n),s,r,u)}function Mr(s,n,r,u){return tt(Yr(n,s.length-r),s,r,u)}o.prototype.write=function(n,r,u,d){if(r===void 0)d="utf8",u=this.length,r=0;else if(u===void 0&&typeof r=="string")d=r,u=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(u)?(u=u>>>0,d===void 0&&(d="utf8")):(d=u,u=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let h=this.length-r;if((u===void 0||u>h)&&(u=h),n.length>0&&(u<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");d||(d="utf8");let I=!1;for(;;)switch(d){case"hex":return Cr(this,n,r,u);case"utf8":case"utf-8":return Ur(this,n,r,u);case"ascii":case"latin1":case"binary":return Lr(this,n,r,u);case"base64":return _r(this,n,r,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Mr(this,n,r,u);default:if(I)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),I=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function $r(s,n,r){return n===0&&r===s.length?p.fromByteArray(s):p.fromByteArray(s.slice(n,r))}function Vt(s,n,r){r=Math.min(s.length,r);let u=[],d=n;for(;d<r;){let h=s[d],I=null,U=h>239?4:h>223?3:h>191?2:1;if(d+U<=r){let O,M,D,_;switch(U){case 1:h<128&&(I=h);break;case 2:O=s[d+1],(O&192)===128&&(_=(h&31)<<6|O&63,_>127&&(I=_));break;case 3:O=s[d+1],M=s[d+2],(O&192)===128&&(M&192)===128&&(_=(h&15)<<12|(O&63)<<6|M&63,_>2047&&(_<55296||_>57343)&&(I=_));break;case 4:O=s[d+1],M=s[d+2],D=s[d+3],(O&192)===128&&(M&192)===128&&(D&192)===128&&(_=(h&15)<<18|(O&63)<<12|(M&63)<<6|D&63,_>65535&&_<1114112&&(I=_))}}I===null?(I=65533,U=1):I>65535&&(I-=65536,u.push(I>>>10&1023|55296),I=56320|I&1023),u.push(I),d+=U}return Or(u)}let Wt=4096;function Or(s){let n=s.length;if(n<=Wt)return String.fromCharCode.apply(String,s);let r="",u=0;for(;u<n;)r+=String.fromCharCode.apply(String,s.slice(u,u+=Wt));return r}function Dr(s,n,r){let u="";r=Math.min(s.length,r);for(let d=n;d<r;++d)u+=String.fromCharCode(s[d]&127);return u}function Vr(s,n,r){let u="";r=Math.min(s.length,r);for(let d=n;d<r;++d)u+=String.fromCharCode(s[d]);return u}function Wr(s,n,r){let u=s.length;(!n||n<0)&&(n=0),(!r||r<0||r>u)&&(r=u);let d="";for(let h=n;h<r;++h)d+=Kr[s[h]];return d}function Gr(s,n,r){let u=s.slice(n,r),d="";for(let h=0;h<u.length-1;h+=2)d+=String.fromCharCode(u[h]+u[h+1]*256);return d}o.prototype.slice=function(n,r){let u=this.length;n=~~n,r=r===void 0?u:~~r,n<0?(n+=u,n<0&&(n=0)):n>u&&(n=u),r<0?(r+=u,r<0&&(r=0)):r>u&&(r=u),r<n&&(r=n);let d=this.subarray(n,r);return Object.setPrototypeOf(d,o.prototype),d};function G(s,n,r){if(s%1!==0||s<0)throw new RangeError("offset is not uint");if(s+n>r)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(n,r,u){n=n>>>0,r=r>>>0,u||G(n,r,this.length);let d=this[n],h=1,I=0;for(;++I<r&&(h*=256);)d+=this[n+I]*h;return d},o.prototype.readUintBE=o.prototype.readUIntBE=function(n,r,u){n=n>>>0,r=r>>>0,u||G(n,r,this.length);let d=this[n+--r],h=1;for(;r>0&&(h*=256);)d+=this[n+--r]*h;return d},o.prototype.readUint8=o.prototype.readUInt8=function(n,r){return n=n>>>0,r||G(n,1,this.length),this[n]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(n,r){return n=n>>>0,r||G(n,2,this.length),this[n]|this[n+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(n,r){return n=n>>>0,r||G(n,2,this.length),this[n]<<8|this[n+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(n,r){return n=n>>>0,r||G(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(n,r){return n=n>>>0,r||G(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},o.prototype.readBigUInt64LE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],u=this[n+7];(r===void 0||u===void 0)&&Me(n,this.length-8);let d=r+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24,h=this[++n]+this[++n]*2**8+this[++n]*2**16+u*2**24;return BigInt(d)+(BigInt(h)<<BigInt(32))}),o.prototype.readBigUInt64BE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],u=this[n+7];(r===void 0||u===void 0)&&Me(n,this.length-8);let d=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+u;return(BigInt(d)<<BigInt(32))+BigInt(h)}),o.prototype.readIntLE=function(n,r,u){n=n>>>0,r=r>>>0,u||G(n,r,this.length);let d=this[n],h=1,I=0;for(;++I<r&&(h*=256);)d+=this[n+I]*h;return h*=128,d>=h&&(d-=Math.pow(2,8*r)),d},o.prototype.readIntBE=function(n,r,u){n=n>>>0,r=r>>>0,u||G(n,r,this.length);let d=r,h=1,I=this[n+--d];for(;d>0&&(h*=256);)I+=this[n+--d]*h;return h*=128,I>=h&&(I-=Math.pow(2,8*r)),I},o.prototype.readInt8=function(n,r){return n=n>>>0,r||G(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},o.prototype.readInt16LE=function(n,r){n=n>>>0,r||G(n,2,this.length);let u=this[n]|this[n+1]<<8;return u&32768?u|4294901760:u},o.prototype.readInt16BE=function(n,r){n=n>>>0,r||G(n,2,this.length);let u=this[n+1]|this[n]<<8;return u&32768?u|4294901760:u},o.prototype.readInt32LE=function(n,r){return n=n>>>0,r||G(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},o.prototype.readInt32BE=function(n,r){return n=n>>>0,r||G(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},o.prototype.readBigInt64LE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],u=this[n+7];(r===void 0||u===void 0)&&Me(n,this.length-8);let d=this[n+4]+this[n+5]*2**8+this[n+6]*2**16+(u<<24);return(BigInt(d)<<BigInt(32))+BigInt(r+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24)}),o.prototype.readBigInt64BE=de(function(n){n=n>>>0,Ce(n,"offset");let r=this[n],u=this[n+7];(r===void 0||u===void 0)&&Me(n,this.length-8);let d=(r<<24)+this[++n]*2**16+this[++n]*2**8+this[++n];return(BigInt(d)<<BigInt(32))+BigInt(this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+u)}),o.prototype.readFloatLE=function(n,r){return n=n>>>0,r||G(n,4,this.length),t.read(this,n,!0,23,4)},o.prototype.readFloatBE=function(n,r){return n=n>>>0,r||G(n,4,this.length),t.read(this,n,!1,23,4)},o.prototype.readDoubleLE=function(n,r){return n=n>>>0,r||G(n,8,this.length),t.read(this,n,!0,52,8)},o.prototype.readDoubleBE=function(n,r){return n=n>>>0,r||G(n,8,this.length),t.read(this,n,!1,52,8)};function X(s,n,r,u,d,h){if(!o.isBuffer(s))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>d||n<h)throw new RangeError('"value" argument is out of bounds');if(r+u>s.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(n,r,u,d){if(n=+n,r=r>>>0,u=u>>>0,!d){let U=Math.pow(2,8*u)-1;X(this,n,r,u,U,0)}let h=1,I=0;for(this[r]=n&255;++I<u&&(h*=256);)this[r+I]=n/h&255;return r+u},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(n,r,u,d){if(n=+n,r=r>>>0,u=u>>>0,!d){let U=Math.pow(2,8*u)-1;X(this,n,r,u,U,0)}let h=u-1,I=1;for(this[r+h]=n&255;--h>=0&&(I*=256);)this[r+h]=n/I&255;return r+u},o.prototype.writeUint8=o.prototype.writeUInt8=function(n,r,u){return n=+n,r=r>>>0,u||X(this,n,r,1,255,0),this[r]=n&255,r+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(n,r,u){return n=+n,r=r>>>0,u||X(this,n,r,2,65535,0),this[r]=n&255,this[r+1]=n>>>8,r+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(n,r,u){return n=+n,r=r>>>0,u||X(this,n,r,2,65535,0),this[r]=n>>>8,this[r+1]=n&255,r+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(n,r,u){return n=+n,r=r>>>0,u||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},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(n,r,u){return n=+n,r=r>>>0,u||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 Gt(s,n,r,u,d){Kt(n,u,d,s,r,7);let h=Number(n&BigInt(4294967295));s[r++]=h,h=h>>8,s[r++]=h,h=h>>8,s[r++]=h,h=h>>8,s[r++]=h;let I=Number(n>>BigInt(32)&BigInt(4294967295));return s[r++]=I,I=I>>8,s[r++]=I,I=I>>8,s[r++]=I,I=I>>8,s[r++]=I,r}function qt(s,n,r,u,d){Kt(n,u,d,s,r,7);let h=Number(n&BigInt(4294967295));s[r+7]=h,h=h>>8,s[r+6]=h,h=h>>8,s[r+5]=h,h=h>>8,s[r+4]=h;let I=Number(n>>BigInt(32)&BigInt(4294967295));return s[r+3]=I,I=I>>8,s[r+2]=I,I=I>>8,s[r+1]=I,I=I>>8,s[r]=I,r+8}o.prototype.writeBigUInt64LE=de(function(n,r=0){return Gt(this,n,r,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=de(function(n,r=0){return qt(this,n,r,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(n,r,u,d){if(n=+n,r=r>>>0,!d){let O=Math.pow(2,8*u-1);X(this,n,r,u,O-1,-O)}let h=0,I=1,U=0;for(this[r]=n&255;++h<u&&(I*=256);)n<0&&U===0&&this[r+h-1]!==0&&(U=1),this[r+h]=(n/I>>0)-U&255;return r+u},o.prototype.writeIntBE=function(n,r,u,d){if(n=+n,r=r>>>0,!d){let O=Math.pow(2,8*u-1);X(this,n,r,u,O-1,-O)}let h=u-1,I=1,U=0;for(this[r+h]=n&255;--h>=0&&(I*=256);)n<0&&U===0&&this[r+h+1]!==0&&(U=1),this[r+h]=(n/I>>0)-U&255;return r+u},o.prototype.writeInt8=function(n,r,u){return n=+n,r=r>>>0,u||X(this,n,r,1,127,-128),n<0&&(n=255+n+1),this[r]=n&255,r+1},o.prototype.writeInt16LE=function(n,r,u){return n=+n,r=r>>>0,u||X(this,n,r,2,32767,-32768),this[r]=n&255,this[r+1]=n>>>8,r+2},o.prototype.writeInt16BE=function(n,r,u){return n=+n,r=r>>>0,u||X(this,n,r,2,32767,-32768),this[r]=n>>>8,this[r+1]=n&255,r+2},o.prototype.writeInt32LE=function(n,r,u){return n=+n,r=r>>>0,u||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},o.prototype.writeInt32BE=function(n,r,u){return n=+n,r=r>>>0,u||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},o.prototype.writeBigInt64LE=de(function(n,r=0){return Gt(this,n,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=de(function(n,r=0){return qt(this,n,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function jt(s,n,r,u,d,h){if(r+u>s.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ht(s,n,r,u,d){return n=+n,r=r>>>0,d||jt(s,n,r,4),t.write(s,n,r,u,23,4),r+4}o.prototype.writeFloatLE=function(n,r,u){return Ht(this,n,r,!0,u)},o.prototype.writeFloatBE=function(n,r,u){return Ht(this,n,r,!1,u)};function zt(s,n,r,u,d){return n=+n,r=r>>>0,d||jt(s,n,r,8),t.write(s,n,r,u,52,8),r+8}o.prototype.writeDoubleLE=function(n,r,u){return zt(this,n,r,!0,u)},o.prototype.writeDoubleBE=function(n,r,u){return zt(this,n,r,!1,u)},o.prototype.copy=function(n,r,u,d){if(!o.isBuffer(n))throw new TypeError("argument should be a Buffer");if(u||(u=0),!d&&d!==0&&(d=this.length),r>=n.length&&(r=n.length),r||(r=0),d>0&&d<u&&(d=u),d===u||n.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(u<0||u>=this.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),n.length-r<d-u&&(d=n.length-r+u);let h=d-u;return this===n&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,u,d):Uint8Array.prototype.set.call(n,this.subarray(u,d),r),h},o.prototype.fill=function(n,r,u,d){if(typeof n=="string"){if(typeof r=="string"?(d=r,r=0,u=this.length):typeof u=="string"&&(d=u,u=this.length),d!==void 0&&typeof d!="string")throw new TypeError("encoding must be a string");if(typeof d=="string"&&!o.isEncoding(d))throw new TypeError("Unknown encoding: "+d);if(n.length===1){let I=n.charCodeAt(0);(d==="utf8"&&I<128||d==="latin1")&&(n=I)}}else typeof n=="number"?n=n&255:typeof n=="boolean"&&(n=Number(n));if(r<0||this.length<r||this.length<u)throw new RangeError("Out of range index");if(u<=r)return this;r=r>>>0,u=u===void 0?this.length:u>>>0,n||(n=0);let h;if(typeof n=="number")for(h=r;h<u;++h)this[h]=n;else{let I=o.isBuffer(n)?n:o.from(n,d),U=I.length;if(U===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(h=0;h<u-r;++h)this[h+r]=I[h%U]}return this};let Be={};function gt(s,n,r){Be[s]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:n.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${s}]`,this.stack,delete this.name}get code(){return s}set code(d){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:d,writable:!0})}toString(){return`${this.name} [${s}]: ${this.message}`}}}gt("ERR_BUFFER_OUT_OF_BOUNDS",function(s){return s?`${s} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),gt("ERR_INVALID_ARG_TYPE",function(s,n){return`The "${s}" argument must be of type number. Received type ${typeof n}`},TypeError),gt("ERR_OUT_OF_RANGE",function(s,n,r){let u=`The value of "${s}" is out of range.`,d=r;return Number.isInteger(r)&&Math.abs(r)>2**32?d=Yt(String(r)):typeof r=="bigint"&&(d=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(d=Yt(d)),d+="n"),u+=` It must be ${n}. Received ${d}`,u},RangeError);function Yt(s){let n="",r=s.length,u=s[0]==="-"?1:0;for(;r>=u+4;r-=3)n=`_${s.slice(r-3,r)}${n}`;return`${s.slice(0,r)}${n}`}function qr(s,n,r){Ce(n,"offset"),(s[n]===void 0||s[n+r]===void 0)&&Me(n,s.length-(r+1))}function Kt(s,n,r,u,d,h){if(s>r||s<n){let I=typeof n=="bigint"?"n":"",U;throw n===0||n===BigInt(0)?U=`>= 0${I} and < 2${I} ** ${(h+1)*8}${I}`:U=`>= -(2${I} ** ${(h+1)*8-1}${I}) and < 2 ** ${(h+1)*8-1}${I}`,new Be.ERR_OUT_OF_RANGE("value",U,s)}qr(u,d,h)}function Ce(s,n){if(typeof s!="number")throw new Be.ERR_INVALID_ARG_TYPE(n,"number",s)}function Me(s,n,r){throw Math.floor(s)!==s?(Ce(s,r),new Be.ERR_OUT_OF_RANGE("offset","an integer",s)):n<0?new Be.ERR_BUFFER_OUT_OF_BOUNDS:new Be.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${n}`,s)}let jr=/[^+/0-9A-Za-z-_]/g;function Hr(s){if(s=s.split("=")[0],s=s.trim().replace(jr,""),s.length<2)return"";for(;s.length%4!==0;)s=s+"=";return s}function vt(s,n){n=n||1/0;let r,u=s.length,d=null,h=[];for(let I=0;I<u;++I){if(r=s.charCodeAt(I),r>55295&&r<57344){if(!d){if(r>56319){(n-=3)>-1&&h.push(239,191,189);continue}else if(I+1===u){(n-=3)>-1&&h.push(239,191,189);continue}d=r;continue}if(r<56320){(n-=3)>-1&&h.push(239,191,189),d=r;continue}r=(d-55296<<10|r-56320)+65536}else d&&(n-=3)>-1&&h.push(239,191,189);if(d=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 zr(s){let n=[];for(let r=0;r<s.length;++r)n.push(s.charCodeAt(r)&255);return n}function Yr(s,n){let r,u,d,h=[];for(let I=0;I<s.length&&!((n-=2)<0);++I)r=s.charCodeAt(I),u=r>>8,d=r%256,h.push(d),h.push(u);return h}function Jt(s){return p.toByteArray(Hr(s))}function tt(s,n,r,u){let d;for(d=0;d<u&&!(d+r>=n.length||d>=s.length);++d)n[d+r]=s[d];return d}function te(s,n){return s instanceof n||s!=null&&s.constructor!=null&&s.constructor.name!=null&&s.constructor.name===n.name}function wt(s){return s!==s}let Kr=(function(){let s="0123456789abcdef",n=new Array(256);for(let r=0;r<16;++r){let u=r*16;for(let d=0;d<16;++d)n[u+d]=s[r]+s[d]}return n})();function de(s){return typeof BigInt>"u"?Jr:s}function Jr(){throw new Error("BigInt not supported")}return ge}var $e,gr,ot,vr,ge,wr,Tr=oe(()=>{"use strict";y();v();g();$e={},gr=!1;ot={},vr=!1;ge={},wr=!1});var ve,A,vs,ws,xr=oe(()=>{"use strict";y();v();g();Tr();ve=Ir();ve.Buffer;ve.SlowBuffer;ve.INSPECT_MAX_BYTES;ve.kMaxLength;A=ve.Buffer,vs=ve.INSPECT_MAX_BYTES,ws=ve.kMaxLength});var v=oe(()=>{"use strict";xr()});function Pt(p){throw new Error("Node.js process "+p+" is not supported by JSPM core outside of Node.js")}function ri(){!Le||!Ie||(Le=!1,Ie.length?ce=Ie.concat(ce):ut=-1,ce.length&&Nr())}function Nr(){if(!Le){var p=setTimeout(ri,0);Le=!0;for(var t=ce.length;t;){for(Ie=ce,ce=[];++ut<t;)Ie&&Ie[ut].run();ut=-1,t=ce.length}Ie=null,Le=!1,clearTimeout(p)}}function ii(p){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 Ar(p,t)),ce.length===1&&!Le&&setTimeout(Nr,0)}function Ar(p,t){this.fun=p,this.array=t}function z(){}function Ti(p){Pt("_linkedBinding")}function Ni(p){Pt("dlopen")}function Ai(){return[]}function Ri(){return[]}function _i(p,t){if(!p)throw new Error(t||"assertion error")}function Di(){return!1}function ro(){return he.now()/1e3}function Ft(p){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 p&&(i=i-p[0],a=a-p[1],a<0&&(i--,a+=Rt)),[i,a]}function me(){return St}function yo(p){return[]}var ce,Le,Ie,ut,oi,si,ai,ci,ui,pi,li,di,fi,hi,mi,yi,gi,vi,wi,Ii,xi,bi,Ei,Fi,Pi,kt,ki,Si,Bi,Ci,Ui,Li,Mi,$i,Oi,Vi,Wi,Gi,qi,ji,Hi,zi,Yi,Ki,Ji,Xi,Qi,Zi,eo,to,no,he,At,Rt,io,oo,so,ao,co,uo,po,lo,fo,ho,mo,St,Bt=oe(()=>{"use strict";y();v();g();ce=[],Le=!1,ut=-1;Ar.prototype.run=function(){this.fun.apply(null,this.array)};oi="browser",si="x64",ai="browser",ci={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},ui=["/usr/bin/node"],pi=[],li="v16.8.0",di={},fi=function(p,t){console.warn((t?t+": ":"")+p)},hi=function(p){Pt("binding")},mi=function(p){return 0},yi=function(){return"/"},gi=function(p){},vi={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};wi=z,Ii=[];xi={},bi=!1,Ei={};Fi=z,Pi=z,kt=function(){return{}},ki=kt,Si=kt,Bi=z,Ci=z,Ui=z,Li={};Mi={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},$i=z,Oi=z;Vi=z,Wi=z,Gi=z,qi=z,ji=z,Hi=void 0,zi=void 0,Yi=void 0,Ki=z,Ji=2,Xi=1,Qi="/bin/usr/node",Zi=9229,eo="node",to=[],no=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(p){var t=Ft(p);return typeof BigInt>"u"?t[0]*Rt+t[1]:BigInt(t[0]*Rt)+BigInt(t[1])};io=10,oo={},so=0;ao=me,co=me,uo=me,po=me,lo=me,fo=z,ho=me,mo=me;St={version:li,versions:di,arch:si,platform:ai,release:vi,_rawDebug:wi,moduleLoadList:Ii,binding:hi,_linkedBinding:Ti,_events:oo,_eventsCount:so,_maxListeners:io,on:me,addListener:ao,once:co,off:uo,removeListener:po,removeAllListeners:lo,emit:fo,prependListener:ho,prependOnceListener:mo,listeners:yo,domain:xi,_exiting:bi,config:Ei,dlopen:Ni,uptime:ro,_getActiveRequests:Ai,_getActiveHandles:Ri,reallyExit:Fi,_kill:Pi,cpuUsage:kt,resourceUsage:ki,memoryUsage:Si,kill:Bi,exit:Ci,openStdin:Ui,allowedNodeEnvironmentFlags:Li,assert:_i,features:Mi,_fatalExceptions:$i,setUncaughtExceptionCaptureCallback:Oi,hasUncaughtExceptionCaptureCallback:Di,emitWarning:fi,nextTick:ii,_tickCallback:Vi,_debugProcess:Wi,_debugEnd:Gi,_startProfilerIdleNotifier:qi,_stopProfilerIdleNotifier:ji,stdout:Hi,stdin:Yi,stderr:zi,abort:Ki,umask:mi,chdir:gi,cwd:yi,env:ci,title:oi,argv:ui,execArgv:pi,pid:Ji,ppid:Xi,execPath:Qi,debugPort:Zi,hrtime:Ft,argv0:eo,_preload_modules:to,setSourceMapsEnabled:no}});function go(){if(Rr)return Ct;Rr=!0;var p=St;function t(c){if(typeof c!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(c))}function e(c,o){for(var f="",w=0,T=-1,b=0,x,P=0;P<=c.length;++P){if(P<c.length)x=c.charCodeAt(P);else{if(x===47)break;x=47}if(x===47){if(!(T===P-1||b===1))if(T!==P-1&&b===2){if(f.length<2||w!==2||f.charCodeAt(f.length-1)!==46||f.charCodeAt(f.length-2)!==46){if(f.length>2){var E=f.lastIndexOf("/");if(E!==f.length-1){E===-1?(f="",w=0):(f=f.slice(0,E),w=f.length-1-f.lastIndexOf("/")),T=P,b=0;continue}}else if(f.length===2||f.length===1){f="",w=0,T=P,b=0;continue}}o&&(f.length>0?f+="/..":f="..",w=2)}else f.length>0?f+="/"+c.slice(T+1,P):f=c.slice(T+1,P),w=P-T-1;T=P,b=0}else x===46&&b!==-1?++b:b=-1}return f}function i(c,o){var f=o.dir||o.root,w=o.base||(o.name||"")+(o.ext||"");return f?f===o.root?f+w:f+c+w:w}var a={resolve:function(){for(var o="",f=!1,w,T=arguments.length-1;T>=-1&&!f;T--){var b;T>=0?b=arguments[T]:(w===void 0&&(w=p.cwd()),b=w),t(b),b.length!==0&&(o=b+"/"+o,f=b.charCodeAt(0)===47)}return o=e(o,!f),f?o.length>0?"/"+o:"/":o.length>0?o:"."},normalize:function(o){if(t(o),o.length===0)return".";var f=o.charCodeAt(0)===47,w=o.charCodeAt(o.length-1)===47;return o=e(o,!f),o.length===0&&!f&&(o="."),o.length>0&&w&&(o+="/"),f?"/"+o:o},isAbsolute:function(o){return t(o),o.length>0&&o.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var o,f=0;f<arguments.length;++f){var w=arguments[f];t(w),w.length>0&&(o===void 0?o=w:o+="/"+w)}return o===void 0?".":a.normalize(o)},relative:function(o,f){if(t(o),t(f),o===f||(o=a.resolve(o),f=a.resolve(f),o===f))return"";for(var w=1;w<o.length&&o.charCodeAt(w)===47;++w);for(var T=o.length,b=T-w,x=1;x<f.length&&f.charCodeAt(x)===47;++x);for(var P=f.length,E=P-x,F=b<E?b:E,B=-1,S=0;S<=F;++S){if(S===F){if(E>F){if(f.charCodeAt(x+S)===47)return f.slice(x+S+1);if(S===0)return f.slice(x+S)}else b>F&&(o.charCodeAt(w+S)===47?B=S:S===0&&(B=0));break}var q=o.charCodeAt(w+S),$=f.charCodeAt(x+S);if(q!==$)break;q===47&&(B=S)}var V="";for(S=w+B+1;S<=T;++S)(S===T||o.charCodeAt(S)===47)&&(V.length===0?V+="..":V+="/..");return V.length>0?V+f.slice(x+B):(x+=B,f.charCodeAt(x)===47&&++x,f.slice(x))},_makeLong:function(o){return o},dirname:function(o){if(t(o),o.length===0)return".";for(var f=o.charCodeAt(0),w=f===47,T=-1,b=!0,x=o.length-1;x>=1;--x)if(f=o.charCodeAt(x),f===47){if(!b){T=x;break}}else b=!1;return T===-1?w?"/":".":w&&T===1?"//":o.slice(0,T)},basename:function(o,f){if(f!==void 0&&typeof f!="string")throw new TypeError('"ext" argument must be a string');t(o);var w=0,T=-1,b=!0,x;if(f!==void 0&&f.length>0&&f.length<=o.length){if(f.length===o.length&&f===o)return"";var P=f.length-1,E=-1;for(x=o.length-1;x>=0;--x){var F=o.charCodeAt(x);if(F===47){if(!b){w=x+1;break}}else E===-1&&(b=!1,E=x+1),P>=0&&(F===f.charCodeAt(P)?--P===-1&&(T=x):(P=-1,T=E))}return w===T?T=E:T===-1&&(T=o.length),o.slice(w,T)}else{for(x=o.length-1;x>=0;--x)if(o.charCodeAt(x)===47){if(!b){w=x+1;break}}else T===-1&&(b=!1,T=x+1);return T===-1?"":o.slice(w,T)}},extname:function(o){t(o);for(var f=-1,w=0,T=-1,b=!0,x=0,P=o.length-1;P>=0;--P){var E=o.charCodeAt(P);if(E===47){if(!b){w=P+1;break}continue}T===-1&&(b=!1,T=P+1),E===46?f===-1?f=P:x!==1&&(x=1):f!==-1&&(x=-1)}return f===-1||T===-1||x===0||x===1&&f===T-1&&f===w+1?"":o.slice(f,T)},format:function(o){if(o===null||typeof o!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof o);return i("/",o)},parse:function(o){t(o);var f={root:"",dir:"",base:"",ext:"",name:""};if(o.length===0)return f;var w=o.charCodeAt(0),T=w===47,b;T?(f.root="/",b=1):b=0;for(var x=-1,P=0,E=-1,F=!0,B=o.length-1,S=0;B>=b;--B){if(w=o.charCodeAt(B),w===47){if(!F){P=B+1;break}continue}E===-1&&(F=!1,E=B+1),w===46?x===-1?x=B:S!==1&&(S=1):x!==-1&&(S=-1)}return x===-1||E===-1||S===0||S===1&&x===E-1&&x===P+1?E!==-1&&(P===0&&T?f.base=f.name=o.slice(1,E):f.base=f.name=o.slice(P,E)):(P===0&&T?(f.name=o.slice(1,x),f.base=o.slice(1,E)):(f.name=o.slice(P,x),f.base=o.slice(P,E)),f.ext=o.slice(x,E)),P>0?f.dir=o.slice(0,P-1):T&&(f.dir="/"),f},sep:"/",delimiter:":",win32:null,posix:null};return a.posix=a,Ct=a,Ct}var Ct,Rr,W,Fr=oe(()=>{"use strict";y();v();g();Bt();Ct={},Rr=!1;W=go()});var mu,yu,gu,vu,wu,Iu,Tu,xu,bu,Eu,Nu,Au,Ru,Fu,Pu,Pr=oe(()=>{"use strict";y();v();g();Fr();Bt();mu=W._makeLong,yu=W.basename,gu=W.delimiter,vu=W.dirname,wu=W.extname,Iu=W.format,Tu=W.isAbsolute,xu=W.join,bu=W.normalize,Eu=W.parse,Nu=W.posix,Au=W.relative,Ru=W.resolve,Fu=W.sep,Pu=W.win32});y();v();g();y();v();g();y();v();g();y();v();g();function C(p){throw new Error("Unexpected value: "+JSON.stringify(p))}y();v();g();function Oe(p){return Object.keys(p)}y();v();g();y();v();g();y();v();g();var De=N.env.FERN_STACK_TRACK?.toLowerCase()??"",ne=De!==""&&De!=="0"&&De!=="false",bt=["single","multiline","box"].includes(De)?De:"single";ne&&(Error.stackTraceLimit=50);var ti=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),ni=new Set(["stacktrace"]);function at({maxFrames:p=50,skip:t=0,filterPaths:e=[],filterFunctions:i=[],stopOn:a=[],filterNode:c=!0,filterJs:o=!0,formatFilename:f=w=>w}={}){if(!ne)return[];i=[...i,...ti],e=[...e,...ni],a=[...a,"runInteractiveTask"];let w=!1;return(new Error().stack??"").split(`
|
|
2
|
+
`).map(T=>{let b=T.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(b&&b.length===5){let[,x,P,E,F]=b;if(!x||!P||!E||!F)return;if(w||a.some(B=>x?.includes(B))){w=!0;return}switch(x){case"Object.<anonymous>":x="";break;case"Object.object":case"Object.alias":case"Object.union":case"Object.enum":case"Object.undiscriminatedUnion":x=`${x.substring(x.indexOf(".")+1)}()=> { ... }`;break}return{fn:x,path:f(P),position:`${E}:${F}`}}}).filter(T=>T&&!i.some(b=>T.fn.includes(b))&&!(c&&T.path?.startsWith("node:"))&&!(o&&T.path?.endsWith(".js"))&&!e.some(b=>T.path.includes(b))).slice(t,t+p)}var st=class{constructor({maxFrames:t=50,skip:e=0,filterPaths:i=[],filterFunctions:a=[],stopOn:c=[],filterNode:o=!0,filterJs:f=!0,multiline:w=!1,formatFilename:T=b=>b}={}){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=c,this.filterNode=o,this.filterJs=f,this.multiline=w,this.formatFilename=T}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}},Et;function br({maxFrames:p=50,skip:t=0,filterPaths:e=[],filterFunctions:i=[],stopOn:a=[],filterNode:c=!0,filterJs:o=!0,multiline:f=!1,formatFilename:w=T=>T}={}){ne&&(Et??(Et=new st({maxFrames:p,skip:t,filterPaths:e,filterFunctions:i,stopOn:a,filterNode:c,filterJs:o,multiline:f,formatFilename:w})))}function Er(p){Et?.tag(p)}function Nt(p){return Et?.frames(p)??[]}var we=class{constructor(){Er(this)}};y();v();g();var ct=class{formatMultiple(t){return Promise.all(t.map(e=>this.format(e)))}formatMultipleSync(t){return t.map(e=>this.formatSync(e))}dispose(){}},Ve=class extends ct{async format(t){return t}formatSync(t){return t}};y();v();g();y();v();g();y();v();g();function Ut(p){return p.output.mode._visit({publish:t=>t.version,downloadFiles:()=>{},github:t=>t.version,_other:()=>{throw new Error("Unrecognized output mode.")}})}y();v();g();var Z=class extends we{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 vo=4;br({skip:0,maxFrames:15,filterFunctions:["Abstract"]});var We=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
4
|
`),this.lineBuffer.join(`
|
|
5
5
|
`)+(this.lastCharacterIsNewline?`
|
|
6
6
|
`:"")}write(...t){for(let e of t)if(e!=null)if(typeof e=="string"){let i=e.length>0&&e.endsWith(`
|
|
7
7
|
`),a=i?e.substring(0,e.length-1):e,c=this.getIndentString(),o=a.replaceAll(`
|
|
8
8
|
`,`
|
|
9
9
|
${c}`);this.isAtStartOfLine()&&(o=c+o),i&&(o+=`
|
|
10
|
-
`),this.writeInternal(o)}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){
|
|
10
|
+
`),this.writeInternal(o)}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(...Nt(t)),t.write(this),ne&&bt!=="single"&&this.writeInternal(`
|
|
11
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
12
|
`)}writeSemicolonIfLastCharacterIsNot(){this.lastCharacterIsSemicolon||this.writeInternal(";")}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
|
|
13
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 c=1;c<t.length;c++){this.write(e);let o=t[c];o!=null&&i(o)}}}toString(){return this.buffer}writeInternal(t){if(t.length===0)return;let e=!this.lastCharacterIsNewline;this.hasWrittenAnything=!0,this.lastCharacterIsNewline=t.endsWith(`
|
|
14
14
|
`),this.lastCharacterIsSemicolon=t.endsWith(";");let i=t.split(`
|
|
15
|
-
`),a=re&&!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,bt){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 vo}};y();v();g();y();v();g();y();v();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 qe=class{constructor(t){m(this,"context");this.context=t}async generate(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let a=new Ge;for(let c of i){let o=this.context.clone(),f=this.createSnippetGenerator(o);try{let w=await f.generateSnippet({endpoint:c,request:t,options:e});if(o.errors.empty())return{snippet:w,errors:void 0};a.update({context:o,snippet:w})}catch(w){a.err==null&&(a.err=w)}}return a.getResponseOrThrow({endpoint:t.endpoint})}async generateSnippetAst(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let a;for(let c of i){let o=this.context.clone(),f=this.createSnippetGenerator(o);try{return await f.generateSnippetAst({endpoint:c,request:t,options:e})}catch(w){a=w}}throw a??new Error(`Failed to generate snippet AST for endpoint: ${t.endpoint.method} ${t.endpoint.path}`)}generateSync(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let a=new Ge;for(let c of i){let o=this.context.clone(),f=this.createSnippetGenerator(o);try{let w=f.generateSnippetSync({endpoint:c,request:t,options:e});if(o.errors.empty())return{snippet:w,errors:void 0};a.update({context:o,snippet:w})}catch(w){a.err==null&&(a.err=w)}}return a.getResponseOrThrow({endpoint:t.endpoint})}resolveEndpoints({request:t,options:e}){if(e.endpointId!=null){let i=this.context.resolveEndpointById(e.endpointId);if(i==null)throw new Error(`No endpoint found with ID "${e.endpointId}"`);return[i]}return this.context.resolveEndpointLocationOrThrow(t.endpoint)}};y();v();g();y();v();g();y();v();g();var je=class{constructor(){m(this,"REFERENCE_REGEX",/^(?:(\w+)::)?(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[2]==null||i[3]==null))return{namespace:i[1],method:i[2],path:i[3]}}};y();v();g();var L={Critical:"CRITICAL",Warning:"WARNING"},He=class p{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}truncate(t){this.errors.length=t}clone(){let t=new p;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 ze=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 He,this.httpEndpointReferenceParser=new je}associateQueryParametersByWireValue({parameters:t,values:e}){let i=[];for(let[a,c]of Object.entries(e))if(c!==void 0){this.errors.scope(a);try{let o=t.find(w=>w.name.wireValue===a);if(o==null)throw this.newParameterNotRecognizedError(a);let f=this.isListTypeReference(o.typeReference)&&!Array.isArray(c)?[c]:c;i.push({name:o.name,typeReference:o.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 c=e[a.name.wireValue];if(c==null)if(a.typeReference.type==="primitive"&&a.typeReference.value==="STRING")c=`<${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:c})}finally{this.errors.unscope()}}return i}associateByWireValue({parameters:t,values:e,ignoreMissingParameters:i}){let a=[],c=new Set;for(let o of t){let f=o.name.wireValue,w=e[f];if(w!==void 0){c.add(f),this.errors.scope(f);try{a.push({name:o.name,typeReference:o.typeReference,value:w})}finally{this.errors.unscope()}}}if(!i){for(let[o,f]of Object.entries(e))if(!(f===void 0||c.has(o))){this.errors.scope(o);try{this.errors.add({severity:L.Critical,message:this.newParameterNotRecognizedError(o).message})}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 c of t){let o=i[c.name.wireValue];o==null?c.typeReference.type==="nullable"&&a.push({name:c.name,typeReference:c.typeReference,value:null}):a.push({name:c.name,typeReference:c.typeReference,value:o})}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 c of i){if(typeof c!="string"){this.errors.add({severity:L.Critical,message:`Expected file array value to be an array of strings, got ${typeof c}`});return}a.push(c)}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,c=i[a];if(c==null){this.errors.add({severity:L.Critical,message:this.newParameterNotRecognizedError(a).message});return}if(typeof c!="string"){this.errors.add({severity:L.Critical,message:`Expected discriminant value to be a string but got: ${typeof c}`});return}let o=t.types[c];if(o==null){this.errors.add({severity:L.Critical,message:`No type found for discriminant value "${c}"`});return}let{[a]:f,...w}=i;return{singleDiscriminatedUnionType:o,discriminantValue:o.discriminantValue,value:w}}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}resolveEndpointById(t){return this._ir.endpoints[t]}resolveEndpointByIdOrThrow(t){let e=this.resolveEndpointById(t);if(e==null)throw new Error(`Failed to find endpoint with ID "${t}"`);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:C(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:C(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 c of Oe(t))a.has(c)&&a.delete(c);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:C(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:C(e)}})}fileUploadHasFileProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:C(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();v();g();var ne={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};y();v();g();y();v();g();function Ye(p,t){let e=p.split("/").pop()??p;return t?.stripExtension?e.split(".")[0]??e:e}y();v();g();y();v();g();y();v();g();y();v();g();var wo=/[^0-9a-zA-Z_]/g,Io=["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"],Te=class extends We{constructor({packageName:e,rootImportPath:i,importPath:a,customConfig:c,formatter:o}){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=c,this.formatter=o??new Ve}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)),c=e.split("/");for(let f=1;f<=c.length;f++){let w=c.slice(-f),T=this.getValidAlias(w.join(""));if(!a.has(T))return this.imports[e]=T,T}let o=this.getValidAlias(Ye(e));for(;a.has(o);)o="_"+o;return this.imports[e]=o,o}isValidAlias(e){return!Io.includes(e)}getValidAlias(e){let i=e.split("-");if(i[0]==null)return e;let a=i.map(c=>c.replace(wo,"")).join("");return this.isValidAlias(a)?a:"_"+a}};var Ke=class extends Te{constructor({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:c}){super({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:c})}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}
|
|
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,bt){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 vo}};y();v();g();y();v();g();y();v();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 qe=class{constructor(t){m(this,"context");this.context=t}async generate(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let a=new Ge;for(let c of i){let o=this.context.clone(),f=this.createSnippetGenerator(o);try{let w=await f.generateSnippet({endpoint:c,request:t,options:e});if(o.errors.empty())return{snippet:w,errors:void 0};a.update({context:o,snippet:w})}catch(w){a.err==null&&(a.err=w)}}return a.getResponseOrThrow({endpoint:t.endpoint})}async generateSnippetAst(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let a;for(let c of i){let o=this.context.clone(),f=this.createSnippetGenerator(o);try{return await f.generateSnippetAst({endpoint:c,request:t,options:e})}catch(w){a=w}}throw a??new Error(`Failed to generate snippet AST for endpoint: ${t.endpoint.method} ${t.endpoint.path}`)}generateSync(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let a=new Ge;for(let c of i){let o=this.context.clone(),f=this.createSnippetGenerator(o);try{let w=f.generateSnippetSync({endpoint:c,request:t,options:e});if(o.errors.empty())return{snippet:w,errors:void 0};a.update({context:o,snippet:w})}catch(w){a.err==null&&(a.err=w)}}return a.getResponseOrThrow({endpoint:t.endpoint})}resolveEndpoints({request:t,options:e}){if(e.endpointId!=null){let i=this.context.resolveEndpointById(e.endpointId);if(i==null)throw new Error(`No endpoint found with ID "${e.endpointId}"`);return[i]}return this.context.resolveEndpointLocationOrThrow(t.endpoint)}};y();v();g();y();v();g();y();v();g();var je=class{constructor(){m(this,"REFERENCE_REGEX",/^(?:(\w+)::)?(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[2]==null||i[3]==null))return{namespace:i[1],method:i[2],path:i[3]}}};y();v();g();var L={Critical:"CRITICAL",Warning:"WARNING"},He=class p{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}truncate(t){this.errors.length=t}clone(){let t=new p;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 ze=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 He,this.httpEndpointReferenceParser=new je}associateQueryParametersByWireValue({parameters:t,values:e}){let i=[];for(let[a,c]of Object.entries(e))if(c!==void 0){this.errors.scope(a);try{let o=t.find(w=>w.name.wireValue===a);if(o==null)throw this.newParameterNotRecognizedError(a);let f=this.isListTypeReference(o.typeReference)&&!Array.isArray(c)?[c]:c;i.push({name:o.name,typeReference:o.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 c=e[a.name.wireValue];if(c==null)if(a.typeReference.type==="primitive"&&a.typeReference.value==="STRING")c=`<${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:c})}finally{this.errors.unscope()}}return i}associateByWireValue({parameters:t,values:e,ignoreMissingParameters:i}){let a=[],c=new Set;for(let o of t){let f=o.name.wireValue,w=e[f];if(w!==void 0){c.add(f),this.errors.scope(f);try{a.push({name:o.name,typeReference:o.typeReference,value:w})}finally{this.errors.unscope()}}}if(!i){for(let[o,f]of Object.entries(e))if(!(f===void 0||c.has(o))){this.errors.scope(o);try{this.errors.add({severity:L.Critical,message:this.newParameterNotRecognizedError(o).message})}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 c of t){let o=i[c.name.wireValue];o==null?c.typeReference.type==="nullable"&&a.push({name:c.name,typeReference:c.typeReference,value:null}):a.push({name:c.name,typeReference:c.typeReference,value:o})}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 c of i){if(typeof c!="string"){this.errors.add({severity:L.Critical,message:`Expected file array value to be an array of strings, got ${typeof c}`});return}a.push(c)}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,c=i[a];if(c==null){this.errors.add({severity:L.Critical,message:this.newParameterNotRecognizedError(a).message});return}if(typeof c!="string"){this.errors.add({severity:L.Critical,message:`Expected discriminant value to be a string but got: ${typeof c}`});return}let o=t.types[c];if(o==null){this.errors.add({severity:L.Critical,message:`No type found for discriminant value "${c}"`});return}let{[a]:f,...w}=i;return{singleDiscriminatedUnionType:o,discriminantValue:o.discriminantValue,value:w}}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}resolveEndpointById(t){return this._ir.endpoints[t]}resolveEndpointByIdOrThrow(t){let e=this.resolveEndpointById(t);if(e==null)throw new Error(`Failed to find endpoint with ID "${t}"`);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:C(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:C(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 c of Oe(t))a.has(c)&&a.delete(c);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:C(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:C(e)}})}fileUploadHasFileProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:C(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();v();g();var re={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};y();v();g();y();v();g();function Ye(p,t){let e=p.split("/").pop()??p;return t?.stripExtension?e.split(".")[0]??e:e}y();v();g();y();v();g();y();v();g();y();v();g();var wo=/[^0-9a-zA-Z_]/g,Io=["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"],Te=class extends We{constructor({packageName:e,rootImportPath:i,importPath:a,customConfig:c,formatter:o}){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=c,this.formatter=o??new Ve}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)),c=e.split("/");for(let f=1;f<=c.length;f++){let w=c.slice(-f),T=this.getValidAlias(w.join(""));if(!a.has(T))return this.imports[e]=T,T}let o=this.getValidAlias(Ye(e));for(;a.has(o);)o="_"+o;return this.imports[e]=o,o}isValidAlias(e){return!Io.includes(e)}getValidAlias(e){let i=e.split("-");if(i[0]==null)return e;let a=i.map(c=>c.replace(wo,"")).join("");return this.isValidAlias(a)?a:"_"+a}};var Ke=class extends Te{constructor({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:c}){super({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:c})}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
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
17
|
${t}`)}return t}getContent(){let t=`package ${this.packageName}
|
|
18
18
|
|
|
@@ -24,10 +24,10 @@ ${this.buffer}`:t+this.buffer}stringifyImports(){let t=Object.entries(this.impor
|
|
|
24
24
|
${o.join(`
|
|
25
25
|
|
|
26
26
|
`)}
|
|
27
|
-
)`}};var l={};Qt(l,{Alias:()=>xe,AstNode:()=>k,CodeBlock:()=>ie,Enum:()=>be,Field:()=>Ee,File:()=>Ne,Func:()=>Ae,FuncInvocation:()=>ee,IoReaderTypeReference:()=>Lt,Method:()=>le,MethodInvocation:()=>pe,MultiNode:()=>Xe,Parameter:()=>Re,Pointer:()=>Fe,Selector:()=>Pe,Struct:()=>ke,TimeTypeReference:()=>pt,Type:()=>Ze,TypeDeclaration:()=>
|
|
28
|
-
`).forEach(i=>{e.writeLine(`// ${i}`)})}};var xe=class extends k{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();v();g();var ie=class extends k{constructor(e){super();m(this,"arg");this.arg=e}write(e){return new Z(this.arg).write(e)}};y();v();g();y();v();g();var ue=class extends k{constructor(e){super();m(this,"name");this.name=e}write(e){e.write(this.name)}};y();v();g();y();v();g();y();v();g();function _e({writer:p,arguments_:t,multiline:e=!0}){let i=t.map(a=>a instanceof K&&K.isNop(a)?K.nil():a);if(i.length===0){p.write("()");return}if(e){To({writer:p,arguments_:i});return}xo({writer:p,arguments_:i})}function To({writer:p,arguments_:t}){p.writeLine("("),p.indent();for(let e of t)e.write(p),p.writeLine(",");p.dedent(),p.write(")")}function xo({writer:p,arguments_:t}){p.write("("),t.forEach((e,i)=>{i>0&&p.write(", "),e.write(p)}),p.write(")")}var ee=class extends k{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();v();g();y();v();g();function
|
|
27
|
+
)`}};var l={};Qt(l,{Alias:()=>xe,AstNode:()=>k,CodeBlock:()=>ie,Enum:()=>be,Field:()=>Ee,File:()=>Ne,Func:()=>Ae,FuncInvocation:()=>ee,IoReaderTypeReference:()=>Lt,Method:()=>le,MethodInvocation:()=>pe,MultiNode:()=>Xe,Parameter:()=>Re,Pointer:()=>Fe,Selector:()=>Pe,Struct:()=>ke,TimeTypeReference:()=>pt,Type:()=>Ze,TypeDeclaration:()=>Se,TypeInstantiation:()=>K,TypeReference:()=>J,UuidTypeReference:()=>lt,Writer:()=>Te,alias:()=>Bo,codeblock:()=>Co,enum_:()=>Uo,field:()=>Lo,file:()=>_o,func:()=>Mo,identifier:()=>$o,invokeFunc:()=>Oo,invokeMethod:()=>Do,method:()=>Vo,parameter:()=>Wo,pointer:()=>Go,selector:()=>qo,struct:()=>jo,switch_:()=>Ho,typeDeclaration:()=>zo,typeReference:()=>Yo});y();v();g();y();v();g();y();v();g();y();v();g();y();v();g();var k=class extends we{async toStringAsync({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:c}){let o=new Ke({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:c});return this.write(o),o.toStringAsync()}toString({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:c}){let o=new Ke({packageName:t,rootImportPath:e,importPath:i,customConfig:a,formatter:c});return this.write(o),o.toString()}};var j=class extends k{constructor({docs:e}={}){super();m(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
|
|
28
|
+
`).forEach(i=>{e.writeLine(`// ${i}`)})}};var xe=class extends k{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();v();g();var ie=class extends k{constructor(e){super();m(this,"arg");this.arg=e}write(e){return new Z(this.arg).write(e)}};y();v();g();y();v();g();var ue=class extends k{constructor(e){super();m(this,"name");this.name=e}write(e){e.write(this.name)}};y();v();g();y();v();g();y();v();g();function _e({writer:p,arguments_:t,multiline:e=!0}){let i=t.map(a=>a instanceof K&&K.isNop(a)?K.nil():a);if(i.length===0){p.write("()");return}if(e){To({writer:p,arguments_:i});return}xo({writer:p,arguments_:i})}function To({writer:p,arguments_:t}){p.writeLine("("),p.indent();for(let e of t)e.write(p),p.writeLine(",");p.dedent(),p.write(")")}function xo({writer:p,arguments_:t}){p.write("("),t.forEach((e,i)=>{i>0&&p.write(", "),e.write(p)}),p.write(")")}var ee=class extends k{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();v();g();y();v();g();function kr({writer:p,generics:t}){t.length!==0&&(p.write("["),t.forEach((e,i)=>{i>0&&p.write(", "),e!=null&&p.writeNode(e)}),p.write("]"))}var J=class extends k{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();v();g();var pe=class extends k{constructor({method:e,arguments_:i,on:a,multiline:c}){super();m(this,"on");m(this,"method");m(this,"arguments_");m(this,"multiline");this.on=a,this.method=e,this.arguments_=i,this.multiline=c}write(e){this.on.write(e),e.write("."),e.write(this.method),_e({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};var bo=new Set(["bool","bytes","date","dateTime","float64","int","int64","string","uuid"]),Sr=new Set(["any","map","slice"]),K=class p extends k{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(Ao({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":e.write(this.internalType.value.toString());break;case"int64":e.write(`int64(${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("`")?`"${Je(this.internalType.value)}"`:this.internalType.value.includes('"')||this.internalType.value.includes(`
|
|
29
29
|
`)?`\`${this.internalType.value}\``:`"${Je(this.internalType.value)}"`);break;case"struct":this.writeStruct({writer:e,struct:this.internalType});break;case"uuid":e.writeNode(Ro({value:this.internalType.value}));break;default:C(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("`")?`"${Je(i)}"`:i.includes('"')||i.includes(`
|
|
30
|
-
`)?`\`${i}\``:`"${Je(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(p.any(a)),e.writeLine(",");e.dedent(),e.write("}")}writeAnyObject({writer:e,value:i}){e.write("map[string]any");let a=Object.entries(i).sort(([c],[o])=>c<o?-1:c>o?1:0);if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let[c,o]of a)e.write(`"${Je(c)}": `),e.writeNode(p.any(o)),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=Fo({entries:i.entries});if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let c of a)c.key.write(e),e.write(": "),c.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeOptional({writer:e,type:i}){if(bo.has(i.internalType.type)){e.writeNode(Eo({writer:e,type:i}));return}if(Bn.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"||Bn.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 c of a)c.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((c,o)=>{o>0&&e.write(", "),e.writeNode(c)}),e.write("]"));let a=Po({fields:i.fields});if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let c of a)e.write(`${c.name}: `),c.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}};function Eo({writer:p,type:t}){return new ee({func:new J({name:No({type:t}),importPath:p.rootImportPath}),arguments_:[t]})}function No({type:p}){switch(p.internalType.type){case"bool":return"Bool";case"bytes":return"Bytes";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 Ao({writer:p,type:t}){let e=t.type==="date"?"MustParseDate":"MustParseDateTime";return new ee({func:new J({name:e,importPath:p.rootImportPath}),arguments_:[new ie(`"${t.value}"`)]})}function Ro({value:p}){return new ee({func:new J({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new ie(`"${p}"`)]})}function Je(p){return p.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function Fo({entries:p}){return p.filter(t=>!K.isNop(t.key)&&!K.isNop(t.value))}function Po({fields:p}){return p.filter(t=>!K.isNop(t.value))}function ko({values:p}){return p.filter(t=>!K.isNop(t))}var be=class p extends k{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(p.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();v();g();var Ee=class extends k{constructor({name:e,type:i,docs:a,tags:c}){super();m(this,"name");m(this,"type");m(this,"docs");m(this,"tags",[]);this.name=e,this.type=i,this.docs=a,this.tags=c??[]}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();v();g();var Ne=class extends k{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();v();g();y();v();g();var le=class extends k{constructor({name:e,parameters:i,return_:a,body:c,docs:o,typeReference:f,multiline:w,receiver:T,pointerReceiver:b}){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=c,this.docs=o,this.typeReference=f,this.multiline=w,this.receiver=T,this.pointerReceiver=b}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 k{constructor({name:e,parameters:i,return_:a,body:c,docs:o,multiline:f}){super();m(this,"func");this.func=new le({name:e,parameters:i,return_:a,body:c,docs:o,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();v();g();var Xe=class extends k{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();v();g();var Re=class extends k{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();v();g();var Fe=class extends k{constructor({node:e}){super();m(this,"node");this.node=e}write(e){e.write("*"),this.node.write(e)}};y();v();g();var Pe=class extends k{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();v();g();var ke=class extends k{constructor({name:e,embeds:i,fields:a,docs:c}){super();m(this,"name");m(this,"embeds",[]);m(this,"fields",[]);m(this,"docs");m(this,"methods",[]);m(this,"constructor_");this.name=e,this.docs=c,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 c of this.embeds)e.writeNode(c),e.newLine();let i=this.fields.filter(c=>this.isExported(c));for(let c of i)e.writeNode(c),e.newLine();let a=this.fields.filter(c=>!this.isExported(c));i.length>0&&a.length>0&&e.newLine();for(let c of a)e.writeNode(c),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,c)=>{c>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();v();g();var Qe=class extends k{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();v();g();var Bo=new Set(["any","bytes","map","slice"]),Ze=class p extends k{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:C(this.internalType)}}isOptional(){return this.internalType.type==="optional"}isNilable(){return this.internalType.type==="optional"||Bo.has(this.internalType.type)}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 p.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.isNilable()}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"}),Lt=new J({importPath:"io",name:"Reader"});y();v();g();var Be=class extends k{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 So(p){return new xe(p)}function Co(p){return new ie(p)}function Uo(p){return new be(p)}function Lo(p){return new Ee(p)}function _o(p={}){return new Ne(p)}function Mo(p){return new Ae(p)}function $o(p){return new ue(p)}function Oo(p){return new ee(p)}function Do(p){return new pe(p)}function Vo(p){return new le(p)}function Wo(p){return new Re(p)}function Go(p){return new Fe(p)}function qo(p){return new Pe(p)}function jo(p={}){return new ke(p)}function Ho(p){return new Qe(p)}function zo(p){return new Be(p)}function Yo(p){return new J(p)}y();v();g();var Ko=new Set(["string"]);function _t(p){if(p==="")return"Underscore";let t=p;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)),Ko.has(e.toLowerCase())?"Field"+e:e}y();v();g();Pn();var Jo="sdk";function Mt({config:p,customConfig:t}){let e=Qo({config:p}),i=Xo({config:p,customConfig:t,isModulePath:!0}),a=e!=null?es({importPath:i,majorVersion:e}):i,c=t?.packagePath??"";return c?W.join(a,c):a}function Xo({config:p,customConfig:t,isModulePath:e=!1}){let i=t?.importPath??t?.module?.path??(p.output.mode.type==="github"?ts(p.output.mode.repoUrl,"https://"):Jo);return e?i:W.join(i,t?.packagePath??"")}function Qo({config:p}){let t=Zo({config:p});if(!(t==null||t==="v0"||t==="v1"))return`${t}`}function Zo({config:p}){let t=rs(p);if(t==null||t==="")return;let e=t.split(".");if(e[0]==null||e[0]===""||e[0]==="v")return;let i=e[0];return i.startsWith("v")?i:`v${i}`}function es({importPath:p,majorVersion:t}){return Ye(p)===t?p:`${p}/${t}`}function ts(p,t){return p.startsWith(t)?p.slice(t.length):p}function rs(p){let t=p?.output?.mode;if(t!=null)return t.type==="github"||t.type==="publish"?t.version:void 0}y();v();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 l.TypeInstantiation.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return l.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?l.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}),c=this.context.getTypeName(i.declaration.name),o=this.context.getImportPath(i.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:a,aliasName:c,aliasImportPath:o})}if(i?.type==="alias"&&i.typeReference.type==="literal")return this.convertLiteralToOptionalPrimitive(i.typeReference.value)}return e.type==="literal"?this.convertLiteralToOptionalPrimitive(e.value):l.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}),c=this.context.getTypeName(i.declaration.name),o=this.context.getImportPath(i.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:a,aliasName:c,aliasImportPath:o})}if(i?.type==="alias"&&i.typeReference.type==="literal")return this.convertLiteralToOptionalPrimitive(i.typeReference.value)}return e.type==="literal"?this.convertLiteralToOptionalPrimitive(e.value):l.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:C(t.typeReference)}}convertToPointerIfPossible(t){let e=this.convert(t);return t.typeReference.type==="named"&&this.context.resolveNamedType({typeId:t.typeReference.value})?.type==="enum"?l.TypeInstantiation.reference(l.invokeMethod({on:e,method:"Ptr",arguments_:[]})):e}convertList({list:t,value:e}){return Array.isArray(e)?l.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}`}),l.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}`}),l.TypeInstantiation.nop()):l.TypeInstantiation.map({keyType:this.context.dynamicTypeMapper.convert({typeReference:t.key}),valueType:this.context.dynamicTypeMapper.convert({typeReference:t.value}),entries:Object.entries(e).sort(([i],[a])=>i<a?-1:i>a?1:0).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:C(t)}}convertAlias({aliasType:t,value:e,as:i}){return t.typeReference.type==="literal"?l.TypeInstantiation.reference(l.invokeFunc({func:l.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),arguments_:[this.convertLiteralValue(t.typeReference.value)]})):this.convert({typeReference:t.typeReference,value:e,as:i})}reconstructAliasCollectionLiteral({collectionLiteral:t,aliasName:e,aliasImportPath:i}){let a=t.internalType;return a.type==="slice"?l.TypeInstantiation.reference(l.codeblock(c=>{c.write("&"),c.writeNode(l.typeReference({name:e,importPath:i}));let o=a.values;if(o.length===0){c.write("{}");return}c.writeLine("{"),c.indent();for(let f of o)c.writeNode(f),c.writeLine(",");c.dedent(),c.write("}")})):a.type==="map"?l.TypeInstantiation.reference(l.codeblock(c=>{c.write("&"),c.writeNode(l.typeReference({name:e,importPath:i}));let o=a.entries;if(o.length===0){c.write("{}");return}c.writeLine("{"),c.indent();for(let f of o)c.writeNode(f.key),c.write(": "),c.writeNode(f.value),c.writeLine(",");c.dedent(),c.write("}")})):l.TypeInstantiation.reference(l.codeblock(c=>{c.write("&"),c.writeNode(t)}))}convertLiteral(t){return this.convertLiteralValue(t)}convertLiteralValue(t){switch(t.type){case"boolean":return l.TypeInstantiation.bool(t.value);case"string":return l.TypeInstantiation.string(t.value);default:C(t)}}convertLiteralToOptionalPrimitive(t){switch(t.type){case"boolean":return l.TypeInstantiation.optional(l.TypeInstantiation.bool(t.value));case"string":return l.TypeInstantiation.optional(l.TypeInstantiation.string(t.value));default:C(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 l.TypeInstantiation.nop();let c=a.singleDiscriminatedUnionType,o=this.getBaseFields({discriminatedUnionTypeInstance:a,singleDiscriminatedUnionType:c,excludeWireValues:this.getDedupedBasePropertyWireValues(t)});switch(c.type){case"samePropertiesAsObject":{let f=this.context.resolveNamedType({typeId:c.typeId});return f==null?l.TypeInstantiation.nop():l.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(c.discriminantValue.name),value:this.convertNamed({named:f,value:a.value})},...o]})}case"singleProperty":{let f=this.context.getRecord(a.value);if(f==null)return l.TypeInstantiation.nop();try{return this.context.errors.scope(c.discriminantValue.wireValue),l.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(c.discriminantValue.name),value:this.convert({typeReference:c.typeReference,value:f[c.discriminantValue.wireValue]})},...o]})}finally{this.context.errors.unscope()}}case"noProperties":return l.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(a.discriminantValue.name),value:l.TypeInstantiation.string(c.discriminantValue.wireValue)},...o]});default:C(c)}}getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e,excludeWireValues:i}){return this.context.associateByWireValue({parameters:e.properties??[],values:this.context.getRecord(t.value)??{},ignoreMissingParameters:!0}).filter(c=>!(i?.has(c.name.wireValue)??!1)).map(c=>{this.context.errors.scope(c.name.wireValue);try{return{name:this.context.getFieldName(c.name.name),value:this.convert(c)}}finally{this.context.errors.unscope()}})}getDedupedBasePropertyWireValues(t){if(!this.context.customConfig?.dedupeUnionBaseProperties)return new Set;let e=Object.values(t.types);if(e.length===0||!e.every(o=>o.type==="samePropertiesAsObject"))return new Set;let i=e[0]?.properties??[];if(i.length===0)return new Set;let a=new Set((t.inheritedBaseProperties??[]).map(o=>o.wireValue)),c=this.context.errors.size();try{let o=e.map(T=>this.getObjectExportedProperties(T.typeId)),f=T=>o.every(b=>{let x=b.get(T);return x!=null&&x.typeReference.type!=="literal"}),w=new Set;for(let T of i){if(T.typeReference.type==="literal")continue;let b=this.context.getFieldName(T.name.name);if(a.has(T.name.wireValue)){f(b)&&w.add(T.name.wireValue);continue}let x=this.getGoGetterTypeString(T.typeReference);o.every(E=>{let F=E.get(b);return F!=null&&F.typeReference.type!=="literal"&&this.getGoGetterTypeString(F.typeReference)===x})&&w.add(T.name.wireValue)}return w}finally{this.context.errors.truncate(c)}}getObjectExportedProperties(t){let e=new Map,i=new Set,a=c=>{if(i.has(c))return;i.add(c);let o=this.context.resolveNamedType({typeId:c});if(o?.type==="object"){for(let f of o.extends??[])a(f);for(let f of o.properties)e.set(this.context.getFieldName(f.name.name),f)}};return a(t),e}getGoGetterTypeString(t){let e=t;if(this.context.customConfig?.gettersPassByValue)for(;e.type==="optional"||e.type==="nullable";)e=e.value;return this.context.dynamicTypeMapper.convert({typeReference:e}).toString({packageName:"example",importPath:"fern",rootImportPath:this.context.rootImportPath,customConfig:this.context.customConfig??{}})}convertObject({object_:t,value:e}){let i=this.context.associateByWireValue({parameters:t.properties,values:this.context.getRecord(e)??{}});return l.TypeInstantiation.structPointer({typeReference:l.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?l.TypeInstantiation.nop():l.TypeInstantiation.enum(l.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 l.TypeInstantiation.nop();let a=this.getUndiscriminatedUnionFieldName({typeReference:i.valueTypeReference});return a==null?l.TypeInstantiation.nop():l.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){let a=this.context.errors.size();try{let c=this.convert({typeReference:i,value:e});if(l.TypeInstantiation.isNop(c)||this.context.errors.size()>a){this.context.errors.truncate(a);continue}return{valueTypeReference:i,typeInstantiation:c}}catch{this.context.errors.truncate(a);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:C(t)}}getUndiscriminatedUnionFieldNameForList({list:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t.value});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.value});if(e!=null)return`${e}Optional`}getUndiscriminatedUnionFieldNameForSet({set:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t.value});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:C(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":case"DATE_TIME_RFC_2822":return"DateTime";case"BASE_64":return"Base64";default:C(t)}}convertUnknown({value:t}){return l.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?l.TypeInstantiation.nop():l.TypeInstantiation.int(a)}case"LONG":case"UINT_64":{let a=this.getValueAsNumber({value:e,as:i});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.int64(a)}case"FLOAT":case"DOUBLE":{let a=this.getValueAsNumber({value:e,as:i});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.float64(a)}case"BOOLEAN":{let a=this.getValueAsBoolean({value:e,as:i});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.bool(a)}case"STRING":{let a=this.context.getValueAsString({value:e});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.string(a)}case"DATE":{let a=this.context.getValueAsString({value:e});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.date(a)}case"DATE_TIME":case"DATE_TIME_RFC_2822":{let a=this.context.getValueAsString({value:e});if(a==null)return l.TypeInstantiation.nop();let c=this.normalizeDateTimeString(a);return l.TypeInstantiation.dateTime(c)}case"UUID":{let a=this.context.getValueAsString({value:e});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.uuid(a)}case"BASE_64":{let a=this.context.getValueAsString({value:e});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.bytes(a)}case"BIG_INTEGER":{let a=this.context.getValueAsString({value:e});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.string(a)}default:C(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();v();g();var ft=class{constructor({context:t}){m(this,"context");this.context=t}convert(t){switch(t.typeReference.type){case"list":return l.Type.slice(this.convert({typeReference:t.typeReference.value}));case"literal":return this.convertLiteral({literal:t.typeReference.value});case"map":return l.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 this.convertOptionalOrNullable(t.typeReference.value);case"nullable":return this.convertOptionalOrNullable(t.typeReference.value);case"primitive":return this.convertPrimitive({primitive:t.typeReference.value});case"set":return l.Type.slice(this.convert({typeReference:t.typeReference}));case"unknown":return this.convertUnknown();default:C(t.typeReference)}}convertOptionalOrNullable(t){return this.isPointerAliasReference(t)?this.convert({typeReference:t}):l.Type.optional(this.convert({typeReference:t}))}isPointerAliasReference(t){if(t.type==="named")return this.isAliasToPointerType(t.value);if(t.type==="optional"||t.type==="nullable"){let e=t.value;if(e.type==="named")return this.isAliasToPointerType(e.value)}return!1}isAliasToPointerType(t){let e=new Set,i=t;for(;;){if(e.has(i))return!1;e.add(i);let a=this.context.resolveNamedType({typeId:i});if(a==null||a.type!=="alias")return!1;let c=a.typeReference;if(c.type==="optional"||c.type==="nullable")return!0;if(c.type==="named"){i=c.value;continue}return!1}}convertLiteral({literal:t}){switch(t.type){case"boolean":return l.Type.bool();case"string":return l.Type.string()}}convertNamed({named:t}){let e=l.Type.reference(l.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 l.Type.pointer(e);default:C(t)}}convertUnknown(){return l.Type.any()}convertPrimitive({primitive:t}){switch(t){case"INTEGER":return l.Type.int();case"UINT":return l.Type.int();case"LONG":return l.Type.int64();case"UINT_64":return l.Type.int64();case"FLOAT":return l.Type.float64();case"DOUBLE":return l.Type.float64();case"BOOLEAN":return l.Type.bool();case"STRING":return l.Type.string();case"DATE":return l.Type.date();case"DATE_TIME":case"DATE_TIME_RFC_2822":return l.Type.dateTime();case"UUID":return l.Type.uuid();case"BASE_64":return l.Type.bytes();case"BIG_INTEGER":return l.Type.string();default:C(t)}}};y();v();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 c of t.properties)switch(c.type){case"file":i.fileFields.push({name:this.context.getFieldName(c.name),value:this.getSingleFileProperty({property:c,record:a})});break;case"fileArray":i.fileFields.push({name:this.context.getFieldName(c.name),value:this.getArrayFileProperty({property:c,record:a})});break;case"bodyProperty":i.bodyPropertyFields.push({name:this.context.getFieldName(c.name.name),value:this.getBodyProperty({property:c,record:a})});break;default:C(c)}return i}getSingleFileProperty({property:t,record:e}){let i=this.context.getSingleFileValue({property:t,record:e})||"";return l.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(i))}getArrayFileProperty({property:t,record:e}){let i=this.context.getFileArrayValues({property:t,record:e});return i==null?l.TypeInstantiation.nop():l.TypeInstantiation.slice({valueType:l.Type.reference(this.context.getIoReaderTypeReference()),values:i.map(a=>l.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(a)))})}getBodyProperty({property:t,record:e}){let i=e[t.name.wireValue];return i==null?l.TypeInstantiation.nop():this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:i})}};var mt=class p extends ze{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;let a=this.buildEffectiveConfig({ir:e,config:i});this.customConfig=a.customConfig!=null?a.customConfig:void 0,this.dynamicTypeMapper=new ft({context:this}),this.dynamicTypeInstantiationMapper=new dt({context:this}),this.filePropertyMapper=new ht({context:this}),this.rootImportPath=Mt({config:a,customConfig:this.customConfig})}clone(){return new p({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:C(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 _t(e.pascalCase.unsafeName)}getImportPath(e){let i=e.packagePath.map(a=>a.camelCase.safeName.toLowerCase());return[this.rootImportPath,...i].join("/")}getImportPathForRequest(e){return this.customConfig?.exportAllRequestsAtRoot?this.rootImportPath:this.getImportPath(e)}getContextTypeReference(){return l.typeReference({name:"Context",importPath:"context"})}getContextTodoFunctionInvocation(){return l.invokeFunc({func:l.typeReference({name:"TODO",importPath:"context"}),arguments_:[]})}getIoReaderTypeReference(){return l.typeReference({name:"Reader",importPath:"io"})}getTestingTypeReference(){return l.typeReference({name:"T",importPath:"testing"})}getNewStringsReaderFunctionInvocation(e){return l.invokeFunc({func:l.typeReference({name:"NewReader",importPath:"strings"}),arguments_:[l.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 l.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 l.typeReference({name:`Environments.${this.getTypeName(e)}`,importPath:this.rootImportPath})}buildEffectiveConfig({ir:e,config:i}){let a=e.generatorConfig;if(a==null||a.outputConfig.type!=="publish")return i;let c=a.outputConfig.value;if(c.type!=="go")return i;let o=Ut(i);return{...i,customConfig:a.customConfig??i.customConfig,output:{...i.output,mode:{type:"github",version:o??c.version,repoUrl:c.repoUrl}}}}static chainMethods(e,...i){if(i.length===0)throw new Error("Must have methods to chain");let a=e;for(let c of i)a=l.invokeMethod({on:a,method:c.method,arguments_:c.arguments_,multiline:c.multiline});return a}};y();v();g();var Sn="example",$t="fern",ns="do",et="client",yh=l.TypeInstantiation,is="WireMockBaseURL",os="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:Sn,importPath:$t,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:Sn,importPath:$t,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:$t,rootImportPath:this.context.rootImportPath,customConfig:this.context.customConfig??{},formatter:this.formatter})}buildCodeBlock({endpoint:t,snippet:e}){return l.codeblock(i=>{i.writeNode(l.func({name:ns,parameters:[],return_:[],body:l.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 l.codeblock(i=>{i.writeNode(l.func({name:"Test"+this.context.getTestMethodName(t)+"WithWireMock",parameters:[l.parameter({name:"t",type:l.Type.pointer(l.Type.reference(this.context.getTestingTypeReference()))})],return_:[],body:l.codeblock(a=>{for(let c of this.buildWiremockTestSetup({endpoint:t}))a.writeNode(c),a.writeLine();a.writeLine(),a.writeNode(this.constructWiremockTestClient({endpoint:t,snippet:e})),a.writeLine(),a.writeNode(this.callClientMethodAndAssert({endpoint:t,snippet:e,includeTestIdHeader:!0}))})})),i.writeNewLineIfLastLineNot()})}constructClient({endpoint:t,snippet:e}){return l.codeblock(i=>{i.write(`${et} := `),i.writeNode(this.getRootClientFuncInvocation(this.getConstructorArgs({endpoint:t,snippet:e})))})}constructWiremockTestClient({endpoint:t,snippet:e}){return l.codeblock(i=>{i.write(`${et} := `),i.writeNode(this.getRootClientFuncInvocation(this.getWiremockTestConstructorArgs()))})}writeMethodInvocation({writer:t,endpoint:e,snippet:i,includeTestIdHeader:a}){let{otherArgs:c,requestArg:o}=this.getMethodArgs({endpoint:e,snippet:i}),f=a?[l.codeblock(w=>{w.writeNode(l.invokeFunc({func:l.typeReference({name:"WithHTTPHeader",importPath:this.context.getOptionImportPath()}),arguments_:[l.codeblock('http.Header{"X-Test-Id": []string{"TEST-ID-PLACEHOLDER"}}')]}))})]:[];if(o!=null)if(o instanceof l.TypeInstantiation&&l.TypeInstantiation.isNop(o))t.writeNode(l.invokeMethod({on:l.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...c,l.codeblock("nil"),...f]}));else{t.write("request := "),t.writeNode(o),t.writeLine();let w=l.codeblock("request");t.writeNode(l.invokeMethod({on:l.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...c,w,...f]}))}else t.writeNode(l.invokeMethod({on:l.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...c,...f]}))}callMethod({endpoint:t,snippet:e}){return l.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.getConstructorAuthArgs({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(ne.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[l.codeblock(t=>{t.writeNode(l.invokeFunc({func:l.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[l.codeblock(is)]}))})]}getConstructorAuthArgs({auth:t,values:e}){if(e.type!==t.type)return this.addError(this.context.newAuthMismatchError({auth:t,values:e}).message),[];switch(t.type){case"basic":return e.type==="basic"?this.getConstructorBasicAuthArgs({auth:t,values:e}):[];case"bearer":return e.type==="bearer"?[this.getConstructorBearerAuthArg({auth:t,values:e})]:[];case"header":return e.type==="header"?[this.getConstructorHeaderAuthArg({auth:t,values:e})]:[];case"oauth":return e.type==="oauth"?[this.getConstructorOAuthAuthArg({values:e})]:[];case"inferred":return e.type==="inferred"?this.getConstructorInferredAuthArgs({auth:t,values:e}):[];default:C(t)}}addError(t){this.context.errors.add({severity:L.Critical,message:t})}addWarning(t){this.context.errors.add({severity:L.Warning,message:t})}getConstructorBasicAuthArgs({auth:t,values:e}){let i=t,a=!!i.usernameOmit,c=!!i.passwordOmit;if(a&&c)return[];let o=[];return a||o.push(l.TypeInstantiation.string(e.username)),c||o.push(l.TypeInstantiation.string(e.password)),[l.codeblock(f=>{f.writeNode(l.invokeFunc({func:l.typeReference({name:"WithBasicAuth",importPath:this.context.getOptionImportPath()}),arguments_:o}))})]}getConstructorBaseUrlArg({baseUrl:t,environment:e}){let i=this.getBaseUrlArg({baseUrl:t,environment:e});if(i!=null)return l.codeblock(a=>{a.writeNode(l.invokeFunc({func:l.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 l.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 l.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 l.codeblock(i=>{i.writeNode(l.invokeFunc({func:l.typeReference({name:`With${t.token.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[l.TypeInstantiation.string(e.token)]}))})}getConstructorHeaderAuthArg({auth:t,values:e}){return l.codeblock(i=>{i.writeNode(l.invokeFunc({func:l.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 l.codeblock(e=>{e.writeNode(l.invokeFunc({func:l.typeReference({name:"WithClientCredentials",importPath:this.context.getOptionImportPath()}),arguments_:[l.TypeInstantiation.string(t.clientId),l.TypeInstantiation.string(t.clientSecret)]}))})}getConstructorInferredAuthArgs({auth:t,values:e}){let i=t.parameters;if(i==null||i.length===0)return[];let a=[];for(let c of i){if(this.isInferredAuthConstructorParamSkipped(c.typeReference))continue;let o=c.name.wireValue,f=e.values?.[o]??c.name.name.originalName,w=this.context.dynamicTypeInstantiationMapper.convert({typeReference:this.getInferredAuthConstructorTypeReference(c.typeReference),value:f});l.TypeInstantiation.isNop(w)||a.push(l.codeblock(T=>{T.writeNode(l.invokeFunc({func:l.typeReference({name:`With${c.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[w]}))}))}return a}isInferredAuthConstructorParamSkipped(t,e=new Set){switch(t.type){case"optional":case"literal":return!0;case"named":{if(e.has(t.value))return!1;e.add(t.value);let i=this.context.resolveNamedType({typeId:t.value});return i?.type==="alias"&&this.isInferredAuthConstructorParamSkipped(i.typeReference,e)}case"list":case"map":case"nullable":case"primitive":case"set":case"unknown":return!1;default:C(t)}}getInferredAuthConstructorTypeReference(t,e=new Set){switch(t.type){case"nullable":return this.getInferredAuthConstructorTypeReference(t.value,e);case"named":{if(e.has(t.value))return t;e.add(t.value);let i=this.context.resolveNamedType({typeId:t.value});return i?.type==="alias"&&i.typeReference.type==="nullable"?this.getInferredAuthConstructorTypeReference(i.typeReference,e):t}case"list":case"literal":case"map":case"optional":case"primitive":case"set":case"unknown":return t;default:C(t)}}getConstructorHeaderArgs({headers:t,values:e}){let i=[];for(let a of t){let c=e[a.name.wireValue],o=this.getConstructorHeaderArg({header:a,value:c});o!=null&&i.push(o)}return i}getConstructorHeaderArg({header:t,value:e}){let i=this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:e});if(!l.TypeInstantiation.isNop(i))return l.codeblock(a=>{a.writeNode(l.invokeFunc({func:l.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:C(t.request)}}getMethodArgsForBodyRequest({request:t,snippet:e}){let i=[];this.context.errors.scope(ne.PathParameters);let a=[...this.context.ir.pathParameters??[],...t.pathParameters??[]];a.length>0&&i.push(...this.getPathParameters({namedParameters:a,snippet:e,asPointer:!0}).map(o=>o.value)),this.context.errors.unscope(),this.context.errors.scope(ne.RequestBody);let c=t.body!=null?this.callOmitsRequestBody({request:t,snippet:e})?l.TypeInstantiation.nop():this.getBodyRequestArg({body:t.body,value:e.requestBody}):void 0;return this.context.errors.unscope(),{otherArgs:i,requestArg:c}}getBodyRequestArg({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convertToPointerIfPossible({typeReference:t.value,value:e});default:C(t)}}getBytesBodyRequestArg({value:t}){let e=typeof t=="string"?t:"";return this.context.customConfig?.useReaderForBytesRequest??!0?l.TypeInstantiation.reference(l.invokeFunc({func:l.typeReference({name:"NewReader",importPath:"bytes"}),arguments_:[l.TypeInstantiation.bytes(e)]})):l.TypeInstantiation.bytes(e)}getMethodArgsForInlinedRequest({request:t,snippet:e}){let i=[],{inlinePathParameters:a,inlineFileProperties:c}={inlinePathParameters:this.context.customConfig?.inlinePathParameters??!0,inlineFileProperties:this.context.customConfig?.inlineFileProperties??!0},o=this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:a});this.context.errors.scope(ne.PathParameters);let f=[],w=[...this.context.ir.pathParameters??[],...t.pathParameters??[]];w.length>0&&f.push(...this.getPathParameters({namedParameters:w,snippet:e,asPointer:!o})),this.context.errors.unscope(),this.context.errors.scope(ne.RequestBody);let T=this.getFilePropertyInfo({request:t,snippet:e});this.context.errors.unscope(),o||i.push(...f.map(x=>x.value)),c||i.push(...T.fileFields.map(x=>x.value));let b=this.context.needsRequestParameter({request:t,inlinePathParameters:a,inlineFileProperties:c})?this.getInlinedRequestArg({request:t,snippet:e,pathParameterFields:o?f:[],filePropertyInfo:T}):void 0;return{otherArgs:i,requestArg:b}}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(ne.QueryParameters);let o=this.context.associateQueryParametersByWireValue({parameters:t.queryParameters??[],values:e.queryParameters??{}}).map(b=>({name:b.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(b)}));this.context.errors.unscope(),this.context.errors.scope(ne.Headers);let w=this.context.associateByWireValue({parameters:t.headers??[],values:e.headers??{}}).map(b=>({name:b.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(b)}));this.context.errors.unscope(),this.context.errors.scope(ne.RequestBody);let T=t.body!=null?this.getInlinedRequestBodyStructFields({body:t.body,value:e.requestBody,filePropertyInfo:a}):[];return this.context.errors.unscope(),l.TypeInstantiation.structPointer({typeReference:l.typeReference({name:this.context.getMethodName(t.declaration.name),importPath:this.context.getImportPathForRequest(t.declaration.fernFilepath)}),fields:[...i,...o,...w,...T]})}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:C(t)}}callOmitsRequestBody({request:t,snippet:e}){if(this.context.customConfig?.respectOptionalRequestBody!==!0||t.bodyRequired!==!1||t.body==null||!this.bodyParameterIsNilable({body:t.body}))return!1;let i=e.requestBody;return i==null||typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).length===0}bodyParameterIsNilable({body:t}){switch(t.type){case"bytes":return!0;case"typeReference":return this.context.dynamicTypeMapper.convert({typeReference:t.value}).isNilable();default:C(t)}}getFileUploadRequestBodyStructFields({filePropertyInfo:t}){return this.context.customConfig?.inlineFileProperties??!0?[...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 l.TypeInstantiation.bytes(typeof e=="string"?e:"");case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e});default:C(t)}}getInlinedRequestBodyPropertyStructFields({parameters:t,value:e}){let i=[],a=this.context.associateByWireValue({parameters:t,values:this.context.getRecord(e)??{}});for(let c of a)i.push({name:this.context.getFieldName(c.name.name),value:this.context.dynamicTypeInstantiationMapper.convert(c)});return i}getPathParameters({namedParameters:t,snippet:e,asPointer:i}){let a=[],c=this.context.associateByWireValueOrDefault({parameters:t,values:e.pathParameters??{}});for(let o of c){let f=o.typeReference.type==="literal"?this.context.dynamicTypeInstantiationMapper.convertLiteral(o.typeReference.value):i?this.context.dynamicTypeInstantiationMapper.convertToPointerIfPossible(o):this.context.dynamicTypeInstantiationMapper.convert(o);a.push({name:this.context.getTypeName(o.name.name),value:f})}return a}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 l.invokeFunc({func:l.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,includeTestIdHeader:i}){return l.codeblock(a=>{this.writeMethodInvocation({writer:a,endpoint:t,snippet:e,includeTestIdHeader:!0}),a.writeLine(),a.writeLine(),a.write("ok, countErr := "),a.writeNode(l.invokeMethod({on:l.codeblock(os),method:"Verify",arguments_:[l.invokeMethod({on:l.codeblock("stub"),method:"Request",arguments_:[],multiline:!1}),l.codeblock("1")],multiline:!1})),a.writeLine(),a.writeNode(l.invokeFunc({func:l.typeReference({name:"NoError",importPath:"github.com/stretchr/testify/require"}),arguments_:[l.codeblock("t"),l.codeblock("countErr"),l.TypeInstantiation.string("Failed to verify WireMock request was matched")],multiline:!1})),a.writeLine(),a.writeNode(l.invokeFunc({func:l.typeReference({name:"True",importPath:"github.com/stretchr/testify/require"}),arguments_:[l.codeblock("t"),l.codeblock("ok"),l.TypeInstantiation.string("WireMock request was not matched")],multiline:!1})),a.writeLine()})}};var Ot=class extends qe{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{Ot as DynamicSnippetsGenerator};
|
|
30
|
+
`)?`\`${i}\``:`"${Je(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(p.any(a)),e.writeLine(",");e.dedent(),e.write("}")}writeAnyObject({writer:e,value:i}){e.write("map[string]any");let a=Object.entries(i).sort(([c],[o])=>c<o?-1:c>o?1:0);if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let[c,o]of a)e.write(`"${Je(c)}": `),e.writeNode(p.any(o)),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=Fo({entries:i.entries});if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let c of a)c.key.write(e),e.write(": "),c.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeOptional({writer:e,type:i}){if(bo.has(i.internalType.type)){e.writeNode(Eo({writer:e,type:i}));return}if(Sr.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"||Sr.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 c of a)c.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((c,o)=>{o>0&&e.write(", "),e.writeNode(c)}),e.write("]"));let a=Po({fields:i.fields});if(a.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let c of a)e.write(`${c.name}: `),c.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}};function Eo({writer:p,type:t}){return new ee({func:new J({name:No({type:t}),importPath:p.rootImportPath}),arguments_:[t]})}function No({type:p}){switch(p.internalType.type){case"bool":return"Bool";case"bytes":return"Bytes";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 Ao({writer:p,type:t}){let e=t.type==="date"?"MustParseDate":"MustParseDateTime";return new ee({func:new J({name:e,importPath:p.rootImportPath}),arguments_:[new ie(`"${t.value}"`)]})}function Ro({value:p}){return new ee({func:new J({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new ie(`"${p}"`)]})}function Je(p){return p.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function Fo({entries:p}){return p.filter(t=>!K.isNop(t.key)&&!K.isNop(t.value))}function Po({fields:p}){return p.filter(t=>!K.isNop(t.value))}function ko({values:p}){return p.filter(t=>!K.isNop(t))}var be=class p extends k{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(p.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();v();g();var Ee=class extends k{constructor({name:e,type:i,docs:a,tags:c}){super();m(this,"name");m(this,"type");m(this,"docs");m(this,"tags",[]);this.name=e,this.type=i,this.docs=a,this.tags=c??[]}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();v();g();var Ne=class extends k{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();v();g();y();v();g();var le=class extends k{constructor({name:e,parameters:i,return_:a,body:c,docs:o,typeReference:f,multiline:w,receiver:T,pointerReceiver:b}){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=c,this.docs=o,this.typeReference=f,this.multiline=w,this.receiver=T,this.pointerReceiver=b}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 k{constructor({name:e,parameters:i,return_:a,body:c,docs:o,multiline:f}){super();m(this,"func");this.func=new le({name:e,parameters:i,return_:a,body:c,docs:o,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();v();g();var Xe=class extends k{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();v();g();var Re=class extends k{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();v();g();var Fe=class extends k{constructor({node:e}){super();m(this,"node");this.node=e}write(e){e.write("*"),this.node.write(e)}};y();v();g();var Pe=class extends k{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();v();g();var ke=class extends k{constructor({name:e,embeds:i,fields:a,docs:c}){super();m(this,"name");m(this,"embeds",[]);m(this,"fields",[]);m(this,"docs");m(this,"methods",[]);m(this,"constructor_");this.name=e,this.docs=c,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 c of this.embeds)e.writeNode(c),e.newLine();let i=this.fields.filter(c=>this.isExported(c));for(let c of i)e.writeNode(c),e.newLine();let a=this.fields.filter(c=>!this.isExported(c));i.length>0&&a.length>0&&e.newLine();for(let c of a)e.writeNode(c),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,c)=>{c>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();v();g();var Qe=class extends k{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();v();g();var So=new Set(["any","bytes","map","slice"]),Ze=class p extends k{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:C(this.internalType)}}isOptional(){return this.internalType.type==="optional"}isNilable(){return this.internalType.type==="optional"||So.has(this.internalType.type)}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 p.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.isNilable()}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"}),Lt=new J({importPath:"io",name:"Reader"});y();v();g();var Se=class extends k{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 Bo(p){return new xe(p)}function Co(p){return new ie(p)}function Uo(p){return new be(p)}function Lo(p){return new Ee(p)}function _o(p={}){return new Ne(p)}function Mo(p){return new Ae(p)}function $o(p){return new ue(p)}function Oo(p){return new ee(p)}function Do(p){return new pe(p)}function Vo(p){return new le(p)}function Wo(p){return new Re(p)}function Go(p){return new Fe(p)}function qo(p){return new Pe(p)}function jo(p={}){return new ke(p)}function Ho(p){return new Qe(p)}function zo(p){return new Se(p)}function Yo(p){return new J(p)}y();v();g();var Ko=new Set(["string"]);function _t(p){if(p==="")return"Underscore";let t=p;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)),Ko.has(e.toLowerCase())?"Field"+e:e}y();v();g();Pr();var Jo="sdk";function Mt({config:p,customConfig:t}){let e=Qo({config:p}),i=Xo({config:p,customConfig:t,isModulePath:!0}),a=e!=null?es({importPath:i,majorVersion:e}):i,c=t?.packagePath??"";return c?W.join(a,c):a}function Xo({config:p,customConfig:t,isModulePath:e=!1}){let i=t?.importPath??t?.module?.path??(p.output.mode.type==="github"?ts(p.output.mode.repoUrl,"https://"):Jo);return e?i:W.join(i,t?.packagePath??"")}function Qo({config:p}){let t=Zo({config:p});if(!(t==null||t==="v0"||t==="v1"))return`${t}`}function Zo({config:p}){let t=ns(p);if(t==null||t==="")return;let e=t.split(".");if(e[0]==null||e[0]===""||e[0]==="v")return;let i=e[0];return i.startsWith("v")?i:`v${i}`}function es({importPath:p,majorVersion:t}){return Ye(p)===t?p:`${p}/${t}`}function ts(p,t){return p.startsWith(t)?p.slice(t.length):p}function ns(p){let t=p?.output?.mode;if(t!=null)return t.type==="github"||t.type==="publish"?t.version:void 0}y();v();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 l.TypeInstantiation.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return l.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?l.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}),c=this.context.getTypeName(i.declaration.name),o=this.context.getImportPath(i.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:a,aliasName:c,aliasImportPath:o})}if(i?.type==="alias"&&i.typeReference.type==="literal")return this.convertLiteralToOptionalPrimitive(i.typeReference.value)}return e.type==="literal"?this.convertLiteralToOptionalPrimitive(e.value):l.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}),c=this.context.getTypeName(i.declaration.name),o=this.context.getImportPath(i.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:a,aliasName:c,aliasImportPath:o})}if(i?.type==="alias"&&i.typeReference.type==="literal")return this.convertLiteralToOptionalPrimitive(i.typeReference.value)}return e.type==="literal"?this.convertLiteralToOptionalPrimitive(e.value):l.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:C(t.typeReference)}}convertToPointerIfPossible(t){let e=this.convert(t);return t.typeReference.type==="named"&&this.context.resolveNamedType({typeId:t.typeReference.value})?.type==="enum"?l.TypeInstantiation.reference(l.invokeMethod({on:e,method:"Ptr",arguments_:[]})):e}convertList({list:t,value:e}){return Array.isArray(e)?l.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}`}),l.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}`}),l.TypeInstantiation.nop()):l.TypeInstantiation.map({keyType:this.context.dynamicTypeMapper.convert({typeReference:t.key}),valueType:this.context.dynamicTypeMapper.convert({typeReference:t.value}),entries:Object.entries(e).sort(([i],[a])=>i<a?-1:i>a?1:0).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:C(t)}}convertAlias({aliasType:t,value:e,as:i}){return t.typeReference.type==="literal"?l.TypeInstantiation.reference(l.invokeFunc({func:l.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),arguments_:[this.convertLiteralValue(t.typeReference.value)]})):this.convert({typeReference:t.typeReference,value:e,as:i})}reconstructAliasCollectionLiteral({collectionLiteral:t,aliasName:e,aliasImportPath:i}){let a=t.internalType;return a.type==="slice"?l.TypeInstantiation.reference(l.codeblock(c=>{c.write("&"),c.writeNode(l.typeReference({name:e,importPath:i}));let o=a.values;if(o.length===0){c.write("{}");return}c.writeLine("{"),c.indent();for(let f of o)c.writeNode(f),c.writeLine(",");c.dedent(),c.write("}")})):a.type==="map"?l.TypeInstantiation.reference(l.codeblock(c=>{c.write("&"),c.writeNode(l.typeReference({name:e,importPath:i}));let o=a.entries;if(o.length===0){c.write("{}");return}c.writeLine("{"),c.indent();for(let f of o)c.writeNode(f.key),c.write(": "),c.writeNode(f.value),c.writeLine(",");c.dedent(),c.write("}")})):l.TypeInstantiation.reference(l.codeblock(c=>{c.write("&"),c.writeNode(t)}))}convertLiteral(t){return this.convertLiteralValue(t)}convertLiteralValue(t){switch(t.type){case"boolean":return l.TypeInstantiation.bool(t.value);case"string":return l.TypeInstantiation.string(t.value);default:C(t)}}convertLiteralToOptionalPrimitive(t){switch(t.type){case"boolean":return l.TypeInstantiation.optional(l.TypeInstantiation.bool(t.value));case"string":return l.TypeInstantiation.optional(l.TypeInstantiation.string(t.value));default:C(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 l.TypeInstantiation.nop();let c=a.singleDiscriminatedUnionType,o=this.getBaseFields({discriminatedUnionTypeInstance:a,singleDiscriminatedUnionType:c,excludeWireValues:this.getDedupedBasePropertyWireValues(t)});switch(c.type){case"samePropertiesAsObject":{let f=this.context.resolveNamedType({typeId:c.typeId});return f==null?l.TypeInstantiation.nop():l.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(c.discriminantValue.name),value:this.convertNamed({named:f,value:a.value})},...o]})}case"singleProperty":{let f=this.context.getRecord(a.value);if(f==null)return l.TypeInstantiation.nop();try{return this.context.errors.scope(c.discriminantValue.wireValue),l.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(c.discriminantValue.name),value:this.convert({typeReference:c.typeReference,value:f[c.discriminantValue.wireValue]})},...o]})}finally{this.context.errors.unscope()}}case"noProperties":return l.TypeInstantiation.structPointer({typeReference:i,fields:[{name:this.context.getFieldName(a.discriminantValue.name),value:l.TypeInstantiation.string(c.discriminantValue.wireValue)},...o]});default:C(c)}}getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e,excludeWireValues:i}){return this.context.associateByWireValue({parameters:e.properties??[],values:this.context.getRecord(t.value)??{},ignoreMissingParameters:!0}).filter(c=>!(i?.has(c.name.wireValue)??!1)).map(c=>{this.context.errors.scope(c.name.wireValue);try{return{name:this.context.getFieldName(c.name.name),value:this.convert(c)}}finally{this.context.errors.unscope()}})}getDedupedBasePropertyWireValues(t){if(!this.context.customConfig?.dedupeUnionBaseProperties)return new Set;let e=Object.values(t.types);if(e.length===0||!e.every(o=>o.type==="samePropertiesAsObject"))return new Set;let i=e[0]?.properties??[];if(i.length===0)return new Set;let a=new Set((t.inheritedBaseProperties??[]).map(o=>o.wireValue)),c=this.context.errors.size();try{let o=e.map(T=>this.getObjectExportedProperties(T.typeId)),f=T=>o.every(b=>{let x=b.get(T);return x!=null&&x.typeReference.type!=="literal"}),w=new Set;for(let T of i){if(T.typeReference.type==="literal")continue;let b=this.context.getFieldName(T.name.name);if(a.has(T.name.wireValue)){f(b)&&w.add(T.name.wireValue);continue}let x=this.getGoGetterTypeString(T.typeReference);o.every(E=>{let F=E.get(b);return F!=null&&F.typeReference.type!=="literal"&&this.getGoGetterTypeString(F.typeReference)===x})&&w.add(T.name.wireValue)}return w}finally{this.context.errors.truncate(c)}}getObjectExportedProperties(t){let e=new Map,i=new Set,a=c=>{if(i.has(c))return;i.add(c);let o=this.context.resolveNamedType({typeId:c});if(o?.type==="object"){for(let f of o.extends??[])a(f);for(let f of o.properties)e.set(this.context.getFieldName(f.name.name),f)}};return a(t),e}getGoGetterTypeString(t){let e=t;if(this.context.customConfig?.gettersPassByValue)for(;e.type==="optional"||e.type==="nullable";)e=e.value;return this.context.dynamicTypeMapper.convert({typeReference:e}).toString({packageName:"example",importPath:"fern",rootImportPath:this.context.rootImportPath,customConfig:this.context.customConfig??{}})}convertObject({object_:t,value:e}){let i=this.context.associateByWireValue({parameters:t.properties,values:this.context.getRecord(e)??{}});return l.TypeInstantiation.structPointer({typeReference:l.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?l.TypeInstantiation.nop():l.TypeInstantiation.enum(l.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 l.TypeInstantiation.nop();let a=this.getUndiscriminatedUnionFieldName({typeReference:i.valueTypeReference});return a==null?l.TypeInstantiation.nop():l.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){let a=this.context.errors.size();try{let c=this.convert({typeReference:i,value:e});if(l.TypeInstantiation.isNop(c)||this.context.errors.size()>a){this.context.errors.truncate(a);continue}return{valueTypeReference:i,typeInstantiation:c}}catch{this.context.errors.truncate(a);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:C(t)}}getUndiscriminatedUnionFieldNameForList({list:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t.value});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.value});if(e!=null)return`${e}Optional`}getUndiscriminatedUnionFieldNameForSet({set:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t.value});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:C(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":case"DATE_TIME_RFC_2822":return"DateTime";case"BASE_64":return"Base64";default:C(t)}}convertUnknown({value:t}){return l.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?l.TypeInstantiation.nop():l.TypeInstantiation.int(a)}case"LONG":case"UINT_64":{let a=this.getValueAsNumber({value:e,as:i});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.int64(a)}case"FLOAT":case"DOUBLE":{let a=this.getValueAsNumber({value:e,as:i});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.float64(a)}case"BOOLEAN":{let a=this.getValueAsBoolean({value:e,as:i});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.bool(a)}case"STRING":{let a=this.context.getValueAsString({value:e});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.string(a)}case"DATE":{let a=this.context.getValueAsString({value:e});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.date(a)}case"DATE_TIME":case"DATE_TIME_RFC_2822":{let a=this.context.getValueAsString({value:e});if(a==null)return l.TypeInstantiation.nop();let c=this.normalizeDateTimeString(a);return l.TypeInstantiation.dateTime(c)}case"UUID":{let a=this.context.getValueAsString({value:e});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.uuid(a)}case"BASE_64":{let a=this.context.getValueAsString({value:e});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.bytes(a)}case"BIG_INTEGER":{let a=this.context.getValueAsString({value:e});return a==null?l.TypeInstantiation.nop():l.TypeInstantiation.string(a)}default:C(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();v();g();var ft=class{constructor({context:t}){m(this,"context");this.context=t}convert(t){switch(t.typeReference.type){case"list":return l.Type.slice(this.convert({typeReference:t.typeReference.value}));case"literal":return this.convertLiteral({literal:t.typeReference.value});case"map":return l.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 this.convertOptionalOrNullable(t.typeReference.value);case"nullable":return this.convertOptionalOrNullable(t.typeReference.value);case"primitive":return this.convertPrimitive({primitive:t.typeReference.value});case"set":return l.Type.slice(this.convert({typeReference:t.typeReference}));case"unknown":return this.convertUnknown();default:C(t.typeReference)}}convertOptionalOrNullable(t){return this.isPointerAliasReference(t)?this.convert({typeReference:t}):l.Type.optional(this.convert({typeReference:t}))}isPointerAliasReference(t){if(t.type==="named")return this.isAliasToPointerType(t.value);if(t.type==="optional"||t.type==="nullable"){let e=t.value;if(e.type==="named")return this.isAliasToPointerType(e.value)}return!1}isAliasToPointerType(t){let e=new Set,i=t;for(;;){if(e.has(i))return!1;e.add(i);let a=this.context.resolveNamedType({typeId:i});if(a==null||a.type!=="alias")return!1;let c=a.typeReference;if(c.type==="optional"||c.type==="nullable")return!0;if(c.type==="named"){i=c.value;continue}return!1}}convertLiteral({literal:t}){switch(t.type){case"boolean":return l.Type.bool();case"string":return l.Type.string()}}convertNamed({named:t}){let e=l.Type.reference(l.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 l.Type.pointer(e);default:C(t)}}convertUnknown(){return l.Type.any()}convertPrimitive({primitive:t}){switch(t){case"INTEGER":return l.Type.int();case"UINT":return l.Type.int();case"LONG":return l.Type.int64();case"UINT_64":return l.Type.int64();case"FLOAT":return l.Type.float64();case"DOUBLE":return l.Type.float64();case"BOOLEAN":return l.Type.bool();case"STRING":return l.Type.string();case"DATE":return l.Type.date();case"DATE_TIME":case"DATE_TIME_RFC_2822":return l.Type.dateTime();case"UUID":return l.Type.uuid();case"BASE_64":return l.Type.bytes();case"BIG_INTEGER":return l.Type.string();default:C(t)}}};y();v();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 c of t.properties)switch(c.type){case"file":i.fileFields.push({name:this.context.getFieldName(c.name),value:this.getSingleFileProperty({property:c,record:a})});break;case"fileArray":i.fileFields.push({name:this.context.getFieldName(c.name),value:this.getArrayFileProperty({property:c,record:a})});break;case"bodyProperty":i.bodyPropertyFields.push({name:this.context.getFieldName(c.name.name),value:this.getBodyProperty({property:c,record:a})});break;default:C(c)}return i}getSingleFileProperty({property:t,record:e}){let i=this.context.getSingleFileValue({property:t,record:e})||"";return l.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(i))}getArrayFileProperty({property:t,record:e}){let i=this.context.getFileArrayValues({property:t,record:e});return i==null?l.TypeInstantiation.nop():l.TypeInstantiation.slice({valueType:l.Type.reference(this.context.getIoReaderTypeReference()),values:i.map(a=>l.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(a)))})}getBodyProperty({property:t,record:e}){let i=e[t.name.wireValue];return i==null?l.TypeInstantiation.nop():this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:i})}};var mt=class p extends ze{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;let a=this.buildEffectiveConfig({ir:e,config:i});this.customConfig=a.customConfig!=null?a.customConfig:void 0,this.dynamicTypeMapper=new ft({context:this}),this.dynamicTypeInstantiationMapper=new dt({context:this}),this.filePropertyMapper=new ht({context:this}),this.rootImportPath=Mt({config:a,customConfig:this.customConfig})}clone(){return new p({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:C(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 _t(e.pascalCase.unsafeName)}getImportPath(e){let i=e.packagePath.map(a=>a.camelCase.safeName.toLowerCase());return[this.rootImportPath,...i].join("/")}getImportPathForRequest(e){return this.customConfig?.exportAllRequestsAtRoot?this.rootImportPath:this.getImportPath(e)}getContextTypeReference(){return l.typeReference({name:"Context",importPath:"context"})}getContextTodoFunctionInvocation(){return l.invokeFunc({func:l.typeReference({name:"TODO",importPath:"context"}),arguments_:[]})}getIoReaderTypeReference(){return l.typeReference({name:"Reader",importPath:"io"})}getTestingTypeReference(){return l.typeReference({name:"T",importPath:"testing"})}getNewStringsReaderFunctionInvocation(e){return l.invokeFunc({func:l.typeReference({name:"NewReader",importPath:"strings"}),arguments_:[l.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 l.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 l.typeReference({name:`Environments.${this.getTypeName(e)}`,importPath:this.rootImportPath})}buildEffectiveConfig({ir:e,config:i}){let a=e.generatorConfig;if(a==null||a.outputConfig.type!=="publish")return i;let c=a.outputConfig.value;if(c.type!=="go")return i;let o=Ut(i);return{...i,customConfig:a.customConfig??i.customConfig,output:{...i.output,mode:{type:"github",version:o??c.version,repoUrl:c.repoUrl}}}}static chainMethods(e,...i){if(i.length===0)throw new Error("Must have methods to chain");let a=e;for(let c of i)a=l.invokeMethod({on:a,method:c.method,arguments_:c.arguments_,multiline:c.multiline});return a}};y();v();g();var Br="example",$t="fern",rs="do",et="client",yh=l.TypeInstantiation,is="WireMockBaseURL",os="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:Br,importPath:$t,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:Br,importPath:$t,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:$t,rootImportPath:this.context.rootImportPath,customConfig:this.context.customConfig??{},formatter:this.formatter})}buildCodeBlock({endpoint:t,snippet:e}){return l.codeblock(i=>{i.writeNode(l.func({name:rs,parameters:[],return_:[],body:l.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 l.codeblock(i=>{i.writeNode(l.func({name:"Test"+this.context.getTestMethodName(t)+"WithWireMock",parameters:[l.parameter({name:"t",type:l.Type.pointer(l.Type.reference(this.context.getTestingTypeReference()))})],return_:[],body:l.codeblock(a=>{for(let c of this.buildWiremockTestSetup({endpoint:t}))a.writeNode(c),a.writeLine();a.writeLine(),a.writeNode(this.constructWiremockTestClient({endpoint:t,snippet:e})),a.writeLine(),a.writeNode(this.callClientMethodAndAssert({endpoint:t,snippet:e,includeTestIdHeader:!0}))})})),i.writeNewLineIfLastLineNot()})}constructClient({endpoint:t,snippet:e}){return l.codeblock(i=>{i.write(`${et} := `),i.writeNode(this.getRootClientFuncInvocation(this.getConstructorArgs({endpoint:t,snippet:e})))})}constructWiremockTestClient({endpoint:t,snippet:e}){return l.codeblock(i=>{i.write(`${et} := `),i.writeNode(this.getRootClientFuncInvocation(this.getWiremockTestConstructorArgs()))})}writeMethodInvocation({writer:t,endpoint:e,snippet:i,includeTestIdHeader:a}){let{otherArgs:c,requestArg:o}=this.getMethodArgs({endpoint:e,snippet:i}),f=a?[l.codeblock(w=>{w.writeNode(l.invokeFunc({func:l.typeReference({name:"WithHTTPHeader",importPath:this.context.getOptionImportPath()}),arguments_:[l.codeblock('http.Header{"X-Test-Id": []string{"TEST-ID-PLACEHOLDER"}}')]}))})]:[];if(o!=null)if(o instanceof l.TypeInstantiation&&l.TypeInstantiation.isNop(o))t.writeNode(l.invokeMethod({on:l.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...c,l.codeblock("nil"),...f]}));else{t.write("request := "),t.writeNode(o),t.writeLine();let w=l.codeblock("request");t.writeNode(l.invokeMethod({on:l.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...c,w,...f]}))}else t.writeNode(l.invokeMethod({on:l.codeblock(et),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...c,...f]}))}callMethod({endpoint:t,snippet:e}){return l.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.getConstructorAuthArgs({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[l.codeblock(t=>{t.writeNode(l.invokeFunc({func:l.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[l.codeblock(is)]}))})]}getConstructorAuthArgs({auth:t,values:e}){if(e.type!==t.type)return this.addError(this.context.newAuthMismatchError({auth:t,values:e}).message),[];switch(t.type){case"basic":return e.type==="basic"?this.getConstructorBasicAuthArgs({auth:t,values:e}):[];case"bearer":return e.type==="bearer"?[this.getConstructorBearerAuthArg({auth:t,values:e})]:[];case"header":return e.type==="header"?[this.getConstructorHeaderAuthArg({auth:t,values:e})]:[];case"oauth":return e.type==="oauth"?[this.getConstructorOAuthAuthArg({values:e})]:[];case"inferred":return e.type==="inferred"?this.getConstructorInferredAuthArgs({auth:t,values:e}):[];default:C(t)}}addError(t){this.context.errors.add({severity:L.Critical,message:t})}addWarning(t){this.context.errors.add({severity:L.Warning,message:t})}getConstructorBasicAuthArgs({auth:t,values:e}){let i=t,a=!!i.usernameOmit,c=!!i.passwordOmit;if(a&&c)return[];let o=[];return a||o.push(l.TypeInstantiation.string(e.username)),c||o.push(l.TypeInstantiation.string(e.password)),[l.codeblock(f=>{f.writeNode(l.invokeFunc({func:l.typeReference({name:"WithBasicAuth",importPath:this.context.getOptionImportPath()}),arguments_:o}))})]}getConstructorBaseUrlArg({baseUrl:t,environment:e}){let i=this.getBaseUrlArg({baseUrl:t,environment:e});if(i!=null)return l.codeblock(a=>{a.writeNode(l.invokeFunc({func:l.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 l.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 l.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 l.codeblock(i=>{i.writeNode(l.invokeFunc({func:l.typeReference({name:`With${t.token.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[l.TypeInstantiation.string(e.token)]}))})}getConstructorHeaderAuthArg({auth:t,values:e}){return l.codeblock(i=>{i.writeNode(l.invokeFunc({func:l.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 l.codeblock(e=>{e.writeNode(l.invokeFunc({func:l.typeReference({name:"WithClientCredentials",importPath:this.context.getOptionImportPath()}),arguments_:[l.TypeInstantiation.string(t.clientId),l.TypeInstantiation.string(t.clientSecret)]}))})}getConstructorInferredAuthArgs({auth:t,values:e}){let i=t.parameters;if(i==null||i.length===0)return[];let a=[];for(let c of i){if(this.isInferredAuthConstructorParamSkipped(c.typeReference))continue;let o=c.name.wireValue,f=e.values?.[o]??c.name.name.originalName,w=this.context.dynamicTypeInstantiationMapper.convert({typeReference:this.getInferredAuthConstructorTypeReference(c.typeReference),value:f});l.TypeInstantiation.isNop(w)||a.push(l.codeblock(T=>{T.writeNode(l.invokeFunc({func:l.typeReference({name:`With${c.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[w]}))}))}return a}isInferredAuthConstructorParamSkipped(t,e=new Set){switch(t.type){case"optional":case"literal":return!0;case"named":{if(e.has(t.value))return!1;e.add(t.value);let i=this.context.resolveNamedType({typeId:t.value});return i?.type==="alias"&&this.isInferredAuthConstructorParamSkipped(i.typeReference,e)}case"list":case"map":case"nullable":case"primitive":case"set":case"unknown":return!1;default:C(t)}}getInferredAuthConstructorTypeReference(t,e=new Set){switch(t.type){case"nullable":return this.getInferredAuthConstructorTypeReference(t.value,e);case"named":{if(e.has(t.value))return t;e.add(t.value);let i=this.context.resolveNamedType({typeId:t.value});return i?.type==="alias"&&i.typeReference.type==="nullable"?this.getInferredAuthConstructorTypeReference(i.typeReference,e):t}case"list":case"literal":case"map":case"optional":case"primitive":case"set":case"unknown":return t;default:C(t)}}getConstructorHeaderArgs({headers:t,values:e}){let i=[];for(let a of t){let c=e[a.name.wireValue],o=this.getConstructorHeaderArg({header:a,value:c});o!=null&&i.push(o)}return i}getConstructorHeaderArg({header:t,value:e}){let i=this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:e});if(!l.TypeInstantiation.isNop(i))return l.codeblock(a=>{a.writeNode(l.invokeFunc({func:l.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:C(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,asPointer:!0}).map(o=>o.value)),this.context.errors.unscope(),this.context.errors.scope(re.RequestBody);let c=t.body!=null?this.callOmitsRequestBody({request:t,snippet:e})?l.TypeInstantiation.nop():this.getBodyRequestArg({body:t.body,value:e.requestBody}):void 0;return this.context.errors.unscope(),{otherArgs:i,requestArg:c}}getBodyRequestArg({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convertToPointerIfPossible({typeReference:t.value,value:e});default:C(t)}}getBytesBodyRequestArg({value:t}){let e=typeof t=="string"?t:"";return this.context.customConfig?.useReaderForBytesRequest??!0?l.TypeInstantiation.reference(l.invokeFunc({func:l.typeReference({name:"NewReader",importPath:"bytes"}),arguments_:[l.TypeInstantiation.bytes(e)]})):l.TypeInstantiation.bytes(e)}getMethodArgsForInlinedRequest({request:t,snippet:e}){let i=[],{inlinePathParameters:a,inlineFileProperties:c}={inlinePathParameters:this.context.customConfig?.inlinePathParameters??!0,inlineFileProperties:this.context.customConfig?.inlineFileProperties??!0},o=this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:a});this.context.errors.scope(re.PathParameters);let f=[],w=[...this.context.ir.pathParameters??[],...t.pathParameters??[]];w.length>0&&f.push(...this.getPathParameters({namedParameters:w,snippet:e,asPointer:!o})),this.context.errors.unscope(),this.context.errors.scope(re.RequestBody);let T=this.getFilePropertyInfo({request:t,snippet:e});this.context.errors.unscope(),o||i.push(...f.map(x=>x.value)),c||i.push(...T.fileFields.map(x=>x.value));let b=this.context.needsRequestParameter({request:t,inlinePathParameters:a,inlineFileProperties:c})?this.getInlinedRequestArg({request:t,snippet:e,pathParameterFields:o?f:[],filePropertyInfo:T}):void 0;return{otherArgs:i,requestArg:b}}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 o=this.context.associateQueryParametersByWireValue({parameters:t.queryParameters??[],values:e.queryParameters??{}}).map(b=>({name:b.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(b)}));this.context.errors.unscope(),this.context.errors.scope(re.Headers);let w=this.context.associateByWireValue({parameters:t.headers??[],values:e.headers??{}}).map(b=>({name:b.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(b)}));this.context.errors.unscope(),this.context.errors.scope(re.RequestBody);let T=t.body!=null?this.getInlinedRequestBodyStructFields({body:t.body,value:e.requestBody,filePropertyInfo:a}):[];return this.context.errors.unscope(),l.TypeInstantiation.structPointer({typeReference:l.typeReference({name:this.context.getMethodName(t.declaration.name),importPath:this.context.getImportPathForRequest(t.declaration.fernFilepath)}),fields:[...i,...o,...w,...T]})}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:C(t)}}callOmitsRequestBody({request:t,snippet:e}){if(this.context.customConfig?.respectOptionalRequestBody!==!0||t.bodyRequired!==!1||t.body==null||!this.bodyParameterIsNilable({body:t.body}))return!1;let i=e.requestBody;return i==null||typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).length===0}bodyParameterIsNilable({body:t}){switch(t.type){case"bytes":return!0;case"typeReference":return this.context.dynamicTypeMapper.convert({typeReference:t.value}).isNilable();default:C(t)}}getFileUploadRequestBodyStructFields({filePropertyInfo:t}){return this.context.customConfig?.inlineFileProperties??!0?[...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 l.TypeInstantiation.bytes(typeof e=="string"?e:"");case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e});default:C(t)}}getInlinedRequestBodyPropertyStructFields({parameters:t,value:e}){let i=[],a=this.context.associateByWireValue({parameters:t,values:this.context.getRecord(e)??{}});for(let c of a)i.push({name:this.context.getFieldName(c.name.name),value:this.context.dynamicTypeInstantiationMapper.convert(c)});return i}getPathParameters({namedParameters:t,snippet:e,asPointer:i}){let a=[],c=this.context.associateByWireValueOrDefault({parameters:t,values:e.pathParameters??{}});for(let o of c){let f=o.typeReference.type==="literal"?this.context.dynamicTypeInstantiationMapper.convertLiteral(o.typeReference.value):i?this.context.dynamicTypeInstantiationMapper.convertToPointerIfPossible(o):this.context.dynamicTypeInstantiationMapper.convert(o);a.push({name:this.context.getTypeName(o.name.name),value:f})}return a}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 l.invokeFunc({func:l.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,includeTestIdHeader:i}){return l.codeblock(a=>{this.writeMethodInvocation({writer:a,endpoint:t,snippet:e,includeTestIdHeader:!0}),a.writeLine(),a.writeLine(),a.write("ok, countErr := "),a.writeNode(l.invokeMethod({on:l.codeblock(os),method:"Verify",arguments_:[l.invokeMethod({on:l.codeblock("stub"),method:"Request",arguments_:[],multiline:!1}),l.codeblock("1")],multiline:!1})),a.writeLine(),a.writeNode(l.invokeFunc({func:l.typeReference({name:"NoError",importPath:"github.com/stretchr/testify/require"}),arguments_:[l.codeblock("t"),l.codeblock("countErr"),l.TypeInstantiation.string("Failed to verify WireMock request was matched")],multiline:!1})),a.writeLine(),a.writeNode(l.invokeFunc({func:l.typeReference({name:"True",importPath:"github.com/stretchr/testify/require"}),arguments_:[l.codeblock("t"),l.codeblock("ok"),l.TypeInstantiation.string("WireMock request was not matched")],multiline:!1})),a.writeLine()})}};var Ot=class extends qe{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{Ot as DynamicSnippetsGenerator};
|
|
31
31
|
/*! Bundled license information:
|
|
32
32
|
|
|
33
33
|
@jspm/core/nodelibs/browser/chunk-DtuTasat.js:
|