@fern-api/ruby-dynamic-snippets 1.0.0-rc76 → 1.0.0-rc78
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 +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
var Lt=Object.defineProperty;var ei=(l,r,e)=>r in l?Lt(l,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[r]=e;var Te=(l,r)=>()=>(l&&(r=l(l=0)),r);var Ct=(l,r)=>{for(var e in r)Lt(l,e,{get:r[e],enumerable:!0})};var y=(l,r,e)=>ei(l,typeof r!="symbol"?r+"":r,e);var c=Te(()=>{"use strict"});var b={};Ct(b,{_debugEnd:()=>vr,_debugProcess:()=>br,_events:()=>$r,_eventsCount:()=>Dr,_exiting:()=>tr,_fatalExceptions:()=>yr,_getActiveHandles:()=>or,_getActiveRequests:()=>ir,_kill:()=>ar,_linkedBinding:()=>Zt,_maxListeners:()=>Mr,_preload_modules:()=>Fr,_rawDebug:()=>Xt,_startProfilerIdleNotifier:()=>Ar,_stopProfilerIdleNotifier:()=>Tr,_tickCallback:()=>wr,abort:()=>Rr,addListener:()=>Or,allowedNodeEnvironmentFlags:()=>dr,arch:()=>$t,argv:()=>_t,argv0:()=>Cr,assert:()=>mr,binding:()=>Gt,browser:()=>Jt,chdir:()=>Ht,config:()=>rr,cpuUsage:()=>ze,cwd:()=>zt,debugPort:()=>Lr,default:()=>Hr,dlopen:()=>nr,domain:()=>er,emit:()=>Wr,emitWarning:()=>Wt,env:()=>Ot,execArgv:()=>jt,execPath:()=>Nr,exit:()=>fr,features:()=>hr,hasUncaughtExceptionCaptureCallback:()=>xr,hrtime:()=>Ke,kill:()=>pr,listeners:()=>zr,memoryUsage:()=>lr,moduleLoadList:()=>Qt,nextTick:()=>Pt,off:()=>jr,on:()=>te,once:()=>_r,openStdin:()=>cr,pid:()=>Br,platform:()=>Dt,ppid:()=>Sr,prependListener:()=>Gr,prependOnceListener:()=>Kr,reallyExit:()=>sr,release:()=>Yt,removeAllListeners:()=>qr,removeListener:()=>Vr,resourceUsage:()=>ur,setSourceMapsEnabled:()=>Pr,setUncaughtExceptionCaptureCallback:()=>gr,stderr:()=>Ir,stdin:()=>kr,stdout:()=>Er,title:()=>Mt,umask:()=>Kt,uptime:()=>Ur,version:()=>Vt,versions:()=>qt});function ct(l){throw new Error("Node.js process "+l+" is not supported by JSPM core outside of Node.js")}function ti(){!Ee||!fe||(Ee=!1,fe.length?ee=fe.concat(ee):Ge=-1,ee.length&&Ft())}function Ft(){if(!Ee){var l=setTimeout(ti,0);Ee=!0;for(var r=ee.length;r;){for(fe=ee,ee=[];++Ge<r;)fe&&fe[Ge].run();Ge=-1,r=ee.length}fe=null,Ee=!1,clearTimeout(l)}}function Pt(l){var r=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)r[e-1]=arguments[e];ee.push(new Ut(l,r)),ee.length===1&&!Ee&&setTimeout(Ft,0)}function Ut(l,r){this.fun=l,this.array=r}function V(){}function Zt(l){ct("_linkedBinding")}function nr(l){ct("dlopen")}function ir(){return[]}function or(){return[]}function mr(l,r){if(!l)throw new Error(r||"assertion error")}function xr(){return!1}function Ur(){return pe.now()/1e3}function Ke(l){var r=Math.floor((Date.now()-pe.now())*.001),e=pe.now()*.001,i=Math.floor(e)+r,s=Math.floor(e%1*1e9);return l&&(i=i-l[0],s=s-l[1],s<0&&(i--,s+=ft)),[i,s]}function te(){return Hr}function zr(l){return[]}var ee,Ee,fe,Ge,Mt,$t,Dt,Ot,_t,jt,Vt,qt,Wt,Gt,Kt,zt,Ht,Yt,Jt,Xt,Qt,er,tr,rr,sr,ar,ze,ur,lr,pr,fr,cr,dr,hr,yr,gr,wr,br,vr,Ar,Tr,Er,Ir,kr,Rr,Br,Sr,Nr,Lr,Cr,Fr,Pr,pe,pt,ft,Mr,$r,Dr,Or,_r,jr,Vr,qr,Wr,Gr,Kr,Hr,Yr=Te(()=>{"use strict";c();m();d();ee=[],Ee=!1,Ge=-1;Ut.prototype.run=function(){this.fun.apply(null,this.array)};Mt="browser",$t="x64",Dt="browser",Ot={PATH:"/usr/bin",LANG:typeof navigator<"u"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},_t=["/usr/bin/node"],jt=[],Vt="v16.8.0",qt={},Wt=function(l,r){console.warn((r?r+": ":"")+l)},Gt=function(l){ct("binding")},Kt=function(l){return 0},zt=function(){return"/"},Ht=function(l){},Yt={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};Jt=!0,Xt=V,Qt=[];er={},tr=!1,rr={};sr=V,ar=V,ze=function(){return{}},ur=ze,lr=ze,pr=V,fr=V,cr=V,dr={};hr={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},yr=V,gr=V;wr=V,br=V,vr=V,Ar=V,Tr=V,Er=void 0,Ir=void 0,kr=void 0,Rr=V,Br=2,Sr=1,Nr="/bin/usr/node",Lr=9229,Cr="node",Fr=[],Pr=V,pe={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};pe.now===void 0&&(pt=Date.now(),pe.timing&&pe.timing.navigationStart&&(pt=pe.timing.navigationStart),pe.now=()=>Date.now()-pt);ft=1e9;Ke.bigint=function(l){var r=Ke(l);return typeof BigInt>"u"?r[0]*ft+r[1]:BigInt(r[0]*ft)+BigInt(r[1])};Mr=10,$r={},Dr=0;Or=te,_r=te,jr=te,Vr=te,qr=te,Wr=V,Gr=te,Kr=te;Hr={version:Vt,versions:qt,arch:$t,platform:Dt,browser:Jt,release:Yt,_rawDebug:Xt,moduleLoadList:Qt,binding:Gt,_linkedBinding:Zt,_events:$r,_eventsCount:Dr,_maxListeners:Mr,on:te,addListener:Or,once:_r,off:jr,removeListener:Vr,removeAllListeners:qr,emit:Wr,prependListener:Gr,prependOnceListener:Kr,listeners:zr,domain:er,_exiting:tr,config:rr,dlopen:nr,uptime:Ur,_getActiveRequests:ir,_getActiveHandles:or,reallyExit:sr,_kill:ar,cpuUsage:ze,resourceUsage:ur,memoryUsage:lr,kill:pr,exit:fr,openStdin:cr,allowedNodeEnvironmentFlags:dr,assert:mr,features:hr,_fatalExceptions:yr,setUncaughtExceptionCaptureCallback:gr,hasUncaughtExceptionCaptureCallback:xr,emitWarning:Wt,nextTick:Pt,_tickCallback:wr,_debugProcess:br,_debugEnd:vr,_startProfilerIdleNotifier:Ar,_stopProfilerIdleNotifier:Tr,stdout:Er,stdin:kr,stderr:Ir,abort:Rr,umask:Kt,chdir:Ht,cwd:zt,env:Ot,title:Mt,argv:_t,execArgv:jt,pid:Br,ppid:Sr,execPath:Nr,debugPort:Lr,hrtime:Ke,argv0:Cr,_preload_modules:Fr,setSourceMapsEnabled:Pr}});var d=Te(()=>{"use strict";Yr()});function ri(){if(Jr)return Re;Jr=!0,Re.byteLength=T,Re.toByteArray=k,Re.fromByteArray=D;for(var l=[],r=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,f=i.length;s<f;++s)l[s]=i[s],r[i.charCodeAt(s)]=s;r[45]=62,r[95]=63;function u(E){var I=E.length;if(I%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var F=E.indexOf("=");F===-1&&(F=I);var _=F===I?0:4-F%4;return[F,_]}function T(E){var I=u(E),F=I[0],_=I[1];return(F+_)*3/4-_}function w(E,I,F){return(I+F)*3/4-F}function k(E){var I,F=u(E),_=F[0],G=F[1],O=new e(w(E,_,G)),K=0,H=G>0?_-4:_,q;for(q=0;q<H;q+=4)I=r[E.charCodeAt(q)]<<18|r[E.charCodeAt(q+1)]<<12|r[E.charCodeAt(q+2)]<<6|r[E.charCodeAt(q+3)],O[K++]=I>>16&255,O[K++]=I>>8&255,O[K++]=I&255;return G===2&&(I=r[E.charCodeAt(q)]<<2|r[E.charCodeAt(q+1)]>>4,O[K++]=I&255),G===1&&(I=r[E.charCodeAt(q)]<<10|r[E.charCodeAt(q+1)]<<4|r[E.charCodeAt(q+2)]>>2,O[K++]=I>>8&255,O[K++]=I&255),O}function R(E){return l[E>>18&63]+l[E>>12&63]+l[E>>6&63]+l[E&63]}function C(E,I,F){for(var _,G=[],O=I;O<F;O+=3)_=(E[O]<<16&16711680)+(E[O+1]<<8&65280)+(E[O+2]&255),G.push(R(_));return G.join("")}function D(E){for(var I,F=E.length,_=F%3,G=[],O=16383,K=0,H=F-_;K<H;K+=O)G.push(C(E,K,K+O>H?H:K+O));return _===1?(I=E[F-1],G.push(l[I>>2]+l[I<<4&63]+"==")):_===2&&(I=(E[F-2]<<8)+E[F-1],G.push(l[I>>10]+l[I>>4&63]+l[I<<2&63]+"=")),G.join("")}return Re}function ni(){if(Xr)return He;Xr=!0;return He.read=function(l,r,e,i,s){var f,u,T=s*8-i-1,w=(1<<T)-1,k=w>>1,R=-7,C=e?s-1:0,D=e?-1:1,E=l[r+C];for(C+=D,f=E&(1<<-R)-1,E>>=-R,R+=T;R>0;f=f*256+l[r+C],C+=D,R-=8);for(u=f&(1<<-R)-1,f>>=-R,R+=i;R>0;u=u*256+l[r+C],C+=D,R-=8);if(f===0)f=1-k;else{if(f===w)return u?NaN:(E?-1:1)*(1/0);u=u+Math.pow(2,i),f=f-k}return(E?-1:1)*u*Math.pow(2,f-i)},He.write=function(l,r,e,i,s,f){var u,T,w,k=f*8-s-1,R=(1<<k)-1,C=R>>1,D=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=i?0:f-1,I=i?1:-1,F=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(T=isNaN(r)?1:0,u=R):(u=Math.floor(Math.log(r)/Math.LN2),r*(w=Math.pow(2,-u))<1&&(u--,w*=2),u+C>=1?r+=D/w:r+=D*Math.pow(2,1-C),r*w>=2&&(u++,w/=2),u+C>=R?(T=0,u=R):u+C>=1?(T=(r*w-1)*Math.pow(2,s),u=u+C):(T=r*Math.pow(2,C-1)*Math.pow(2,s),u=0));s>=8;l[e+E]=T&255,E+=I,T/=256,s-=8);for(u=u<<s|T,k+=s;k>0;l[e+E]=u&255,E+=I,u/=256,k-=8);l[e+E-I]|=F*128},He}function Zr(){if(Qr)return ce;Qr=!0;let l=ri(),r=ni(),e=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ce.Buffer=u,ce.SlowBuffer=G,ce.INSPECT_MAX_BYTES=50;let i=2147483647;ce.kMaxLength=i,u.TYPED_ARRAY_SUPPORT=s(),!u.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 s(){try{let o=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(o,t),o.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function f(o){if(o>i)throw new RangeError('The value "'+o+'" is invalid for option "size"');let t=new Uint8Array(o);return Object.setPrototypeOf(t,u.prototype),t}function u(o,t,n){if(typeof o=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return R(o)}return T(o,t,n)}u.poolSize=8192;function T(o,t,n){if(typeof o=="string")return C(o,t);if(ArrayBuffer.isView(o))return E(o);if(o==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o);if(Q(o,ArrayBuffer)||o&&Q(o.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Q(o,SharedArrayBuffer)||o&&Q(o.buffer,SharedArrayBuffer)))return I(o,t,n);if(typeof o=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let a=o.valueOf&&o.valueOf();if(a!=null&&a!==o)return u.from(a,t,n);let p=F(o);if(p)return p;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof o[Symbol.toPrimitive]=="function")return u.from(o[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o)}u.from=function(o,t,n){return T(o,t,n)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function w(o){if(typeof o!="number")throw new TypeError('"size" argument must be of type number');if(o<0)throw new RangeError('The value "'+o+'" is invalid for option "size"')}function k(o,t,n){return w(o),o<=0?f(o):t!==void 0?typeof n=="string"?f(o).fill(t,n):f(o).fill(t):f(o)}u.alloc=function(o,t,n){return k(o,t,n)};function R(o){return w(o),f(o<0?0:_(o)|0)}u.allocUnsafe=function(o){return R(o)},u.allocUnsafeSlow=function(o){return R(o)};function C(o,t){if((typeof t!="string"||t==="")&&(t="utf8"),!u.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let n=O(o,t)|0,a=f(n),p=a.write(o,t);return p!==n&&(a=a.slice(0,p)),a}function D(o){let t=o.length<0?0:_(o.length)|0,n=f(t);for(let a=0;a<t;a+=1)n[a]=o[a]&255;return n}function E(o){if(Q(o,Uint8Array)){let t=new Uint8Array(o);return I(t.buffer,t.byteOffset,t.byteLength)}return D(o)}function I(o,t,n){if(t<0||o.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(o.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');let a;return t===void 0&&n===void 0?a=new Uint8Array(o):n===void 0?a=new Uint8Array(o,t):a=new Uint8Array(o,t,n),Object.setPrototypeOf(a,u.prototype),a}function F(o){if(u.isBuffer(o)){let t=_(o.length)|0,n=f(t);return n.length===0||o.copy(n,0,0,t),n}if(o.length!==void 0)return typeof o.length!="number"||lt(o.length)?f(0):D(o);if(o.type==="Buffer"&&Array.isArray(o.data))return D(o.data)}function _(o){if(o>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return o|0}function G(o){return+o!=o&&(o=0),u.alloc(+o)}u.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==u.prototype},u.compare=function(t,n){if(Q(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),Q(n,Uint8Array)&&(n=u.from(n,n.offset,n.byteLength)),!u.isBuffer(t)||!u.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===n)return 0;let a=t.length,p=n.length;for(let h=0,g=Math.min(a,p);h<g;++h)if(t[h]!==n[h]){a=t[h],p=n[h];break}return a<p?-1:p<a?1:0},u.isEncoding=function(t){switch(String(t).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}},u.concat=function(t,n){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return u.alloc(0);let a;if(n===void 0)for(n=0,a=0;a<t.length;++a)n+=t[a].length;let p=u.allocUnsafe(n),h=0;for(a=0;a<t.length;++a){let g=t[a];if(Q(g,Uint8Array))h+g.length>p.length?(u.isBuffer(g)||(g=u.from(g)),g.copy(p,h)):Uint8Array.prototype.set.call(p,g,h);else if(u.isBuffer(g))g.copy(p,h);else throw new TypeError('"list" argument must be an Array of Buffers');h+=g.length}return p};function O(o,t){if(u.isBuffer(o))return o.length;if(ArrayBuffer.isView(o)||Q(o,ArrayBuffer))return o.byteLength;if(typeof o!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof o);let n=o.length,a=arguments.length>2&&arguments[2]===!0;if(!a&&n===0)return 0;let p=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return ut(o).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return Nt(o).length;default:if(p)return a?-1:ut(o).length;t=(""+t).toLowerCase(),p=!0}}u.byteLength=O;function K(o,t,n){let a=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return"";for(o||(o="utf8");;)switch(o){case"hex":return Gn(this,t,n);case"utf8":case"utf-8":return vt(this,t,n);case"ascii":return qn(this,t,n);case"latin1":case"binary":return Wn(this,t,n);case"base64":return jn(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Kn(this,t,n);default:if(a)throw new TypeError("Unknown encoding: "+o);o=(o+"").toLowerCase(),a=!0}}u.prototype._isBuffer=!0;function H(o,t,n){let a=o[t];o[t]=o[n],o[n]=a}u.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<t;n+=2)H(this,n,n+1);return this},u.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<t;n+=4)H(this,n,n+3),H(this,n+1,n+2);return this},u.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<t;n+=8)H(this,n,n+7),H(this,n+1,n+6),H(this,n+2,n+5),H(this,n+3,n+4);return this},u.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?vt(this,0,t):K.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:u.compare(this,t)===0},u.prototype.inspect=function(){let t="",n=ce.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},e&&(u.prototype[e]=u.prototype.inspect),u.prototype.compare=function(t,n,a,p,h){if(Q(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(n===void 0&&(n=0),a===void 0&&(a=t?t.length:0),p===void 0&&(p=0),h===void 0&&(h=this.length),n<0||a>t.length||p<0||h>this.length)throw new RangeError("out of range index");if(p>=h&&n>=a)return 0;if(p>=h)return-1;if(n>=a)return 1;if(n>>>=0,a>>>=0,p>>>=0,h>>>=0,this===t)return 0;let g=h-p,B=a-n,M=Math.min(g,B),U=this.slice(p,h),$=t.slice(n,a);for(let P=0;P<M;++P)if(U[P]!==$[P]){g=U[P],B=$[P];break}return g<B?-1:B<g?1:0};function q(o,t,n,a,p){if(o.length===0)return-1;if(typeof n=="string"?(a=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,lt(n)&&(n=p?0:o.length-1),n<0&&(n=o.length+n),n>=o.length){if(p)return-1;n=o.length-1}else if(n<0)if(p)n=0;else return-1;if(typeof t=="string"&&(t=u.from(t,a)),u.isBuffer(t))return t.length===0?-1:bt(o,t,n,a,p);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?p?Uint8Array.prototype.indexOf.call(o,t,n):Uint8Array.prototype.lastIndexOf.call(o,t,n):bt(o,[t],n,a,p);throw new TypeError("val must be string, number or Buffer")}function bt(o,t,n,a,p){let h=1,g=o.length,B=t.length;if(a!==void 0&&(a=String(a).toLowerCase(),a==="ucs2"||a==="ucs-2"||a==="utf16le"||a==="utf-16le")){if(o.length<2||t.length<2)return-1;h=2,g/=2,B/=2,n/=2}function M($,P){return h===1?$[P]:$.readUInt16BE(P*h)}let U;if(p){let $=-1;for(U=n;U<g;U++)if(M(o,U)===M(t,$===-1?0:U-$)){if($===-1&&($=U),U-$+1===B)return $*h}else $!==-1&&(U-=U-$),$=-1}else for(n+B>g&&(n=g-B),U=n;U>=0;U--){let $=!0;for(let P=0;P<B;P++)if(M(o,U+P)!==M(t,P)){$=!1;break}if($)return U}return-1}u.prototype.includes=function(t,n,a){return this.indexOf(t,n,a)!==-1},u.prototype.indexOf=function(t,n,a){return q(this,t,n,a,!0)},u.prototype.lastIndexOf=function(t,n,a){return q(this,t,n,a,!1)};function Mn(o,t,n,a){n=Number(n)||0;let p=o.length-n;a?(a=Number(a),a>p&&(a=p)):a=p;let h=t.length;a>h/2&&(a=h/2);let g;for(g=0;g<a;++g){let B=parseInt(t.substr(g*2,2),16);if(lt(B))return g;o[n+g]=B}return g}function $n(o,t,n,a){return We(ut(t,o.length-n),o,n,a)}function Dn(o,t,n,a){return We(Jn(t),o,n,a)}function On(o,t,n,a){return We(Nt(t),o,n,a)}function _n(o,t,n,a){return We(Xn(t,o.length-n),o,n,a)}u.prototype.write=function(t,n,a,p){if(n===void 0)p="utf8",a=this.length,n=0;else if(a===void 0&&typeof n=="string")p=n,a=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(a)?(a=a>>>0,p===void 0&&(p="utf8")):(p=a,a=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let h=this.length-n;if((a===void 0||a>h)&&(a=h),t.length>0&&(a<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");p||(p="utf8");let g=!1;for(;;)switch(p){case"hex":return Mn(this,t,n,a);case"utf8":case"utf-8":return $n(this,t,n,a);case"ascii":case"latin1":case"binary":return Dn(this,t,n,a);case"base64":return On(this,t,n,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _n(this,t,n,a);default:if(g)throw new TypeError("Unknown encoding: "+p);p=(""+p).toLowerCase(),g=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jn(o,t,n){return t===0&&n===o.length?l.fromByteArray(o):l.fromByteArray(o.slice(t,n))}function vt(o,t,n){n=Math.min(o.length,n);let a=[],p=t;for(;p<n;){let h=o[p],g=null,B=h>239?4:h>223?3:h>191?2:1;if(p+B<=n){let M,U,$,P;switch(B){case 1:h<128&&(g=h);break;case 2:M=o[p+1],(M&192)===128&&(P=(h&31)<<6|M&63,P>127&&(g=P));break;case 3:M=o[p+1],U=o[p+2],(M&192)===128&&(U&192)===128&&(P=(h&15)<<12|(M&63)<<6|U&63,P>2047&&(P<55296||P>57343)&&(g=P));break;case 4:M=o[p+1],U=o[p+2],$=o[p+3],(M&192)===128&&(U&192)===128&&($&192)===128&&(P=(h&15)<<18|(M&63)<<12|(U&63)<<6|$&63,P>65535&&P<1114112&&(g=P))}}g===null?(g=65533,B=1):g>65535&&(g-=65536,a.push(g>>>10&1023|55296),g=56320|g&1023),a.push(g),p+=B}return Vn(a)}let At=4096;function Vn(o){let t=o.length;if(t<=At)return String.fromCharCode.apply(String,o);let n="",a=0;for(;a<t;)n+=String.fromCharCode.apply(String,o.slice(a,a+=At));return n}function qn(o,t,n){let a="";n=Math.min(o.length,n);for(let p=t;p<n;++p)a+=String.fromCharCode(o[p]&127);return a}function Wn(o,t,n){let a="";n=Math.min(o.length,n);for(let p=t;p<n;++p)a+=String.fromCharCode(o[p]);return a}function Gn(o,t,n){let a=o.length;(!t||t<0)&&(t=0),(!n||n<0||n>a)&&(n=a);let p="";for(let h=t;h<n;++h)p+=Qn[o[h]];return p}function Kn(o,t,n){let a=o.slice(t,n),p="";for(let h=0;h<a.length-1;h+=2)p+=String.fromCharCode(a[h]+a[h+1]*256);return p}u.prototype.slice=function(t,n){let a=this.length;t=~~t,n=n===void 0?a:~~n,t<0?(t+=a,t<0&&(t=0)):t>a&&(t=a),n<0?(n+=a,n<0&&(n=0)):n>a&&(n=a),n<t&&(n=t);let p=this.subarray(t,n);return Object.setPrototypeOf(p,u.prototype),p};function j(o,t,n){if(o%1!==0||o<0)throw new RangeError("offset is not uint");if(o+t>n)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(t,n,a){t=t>>>0,n=n>>>0,a||j(t,n,this.length);let p=this[t],h=1,g=0;for(;++g<n&&(h*=256);)p+=this[t+g]*h;return p},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,n,a){t=t>>>0,n=n>>>0,a||j(t,n,this.length);let p=this[t+--n],h=1;for(;n>0&&(h*=256);)p+=this[t+--n]*h;return p},u.prototype.readUint8=u.prototype.readUInt8=function(t,n){return t=t>>>0,n||j(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,n){return t=t>>>0,n||j(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,n){return t=t>>>0,n||j(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,n){return t=t>>>0,n||j(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,n){return t=t>>>0,n||j(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=le(function(t){t=t>>>0,Ae(t,"offset");let n=this[t],a=this[t+7];(n===void 0||a===void 0)&&ke(t,this.length-8);let p=n+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,h=this[++t]+this[++t]*2**8+this[++t]*2**16+a*2**24;return BigInt(p)+(BigInt(h)<<BigInt(32))}),u.prototype.readBigUInt64BE=le(function(t){t=t>>>0,Ae(t,"offset");let n=this[t],a=this[t+7];(n===void 0||a===void 0)&&ke(t,this.length-8);let p=n*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],h=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+a;return(BigInt(p)<<BigInt(32))+BigInt(h)}),u.prototype.readIntLE=function(t,n,a){t=t>>>0,n=n>>>0,a||j(t,n,this.length);let p=this[t],h=1,g=0;for(;++g<n&&(h*=256);)p+=this[t+g]*h;return h*=128,p>=h&&(p-=Math.pow(2,8*n)),p},u.prototype.readIntBE=function(t,n,a){t=t>>>0,n=n>>>0,a||j(t,n,this.length);let p=n,h=1,g=this[t+--p];for(;p>0&&(h*=256);)g+=this[t+--p]*h;return h*=128,g>=h&&(g-=Math.pow(2,8*n)),g},u.prototype.readInt8=function(t,n){return t=t>>>0,n||j(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},u.prototype.readInt16LE=function(t,n){t=t>>>0,n||j(t,2,this.length);let a=this[t]|this[t+1]<<8;return a&32768?a|4294901760:a},u.prototype.readInt16BE=function(t,n){t=t>>>0,n||j(t,2,this.length);let a=this[t+1]|this[t]<<8;return a&32768?a|4294901760:a},u.prototype.readInt32LE=function(t,n){return t=t>>>0,n||j(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,n){return t=t>>>0,n||j(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=le(function(t){t=t>>>0,Ae(t,"offset");let n=this[t],a=this[t+7];(n===void 0||a===void 0)&&ke(t,this.length-8);let p=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(a<<24);return(BigInt(p)<<BigInt(32))+BigInt(n+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)}),u.prototype.readBigInt64BE=le(function(t){t=t>>>0,Ae(t,"offset");let n=this[t],a=this[t+7];(n===void 0||a===void 0)&&ke(t,this.length-8);let p=(n<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(p)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+a)}),u.prototype.readFloatLE=function(t,n){return t=t>>>0,n||j(t,4,this.length),r.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,n){return t=t>>>0,n||j(t,4,this.length),r.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,n){return t=t>>>0,n||j(t,8,this.length),r.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,n){return t=t>>>0,n||j(t,8,this.length),r.read(this,t,!1,52,8)};function z(o,t,n,a,p,h){if(!u.isBuffer(o))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>p||t<h)throw new RangeError('"value" argument is out of bounds');if(n+a>o.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,n,a,p){if(t=+t,n=n>>>0,a=a>>>0,!p){let B=Math.pow(2,8*a)-1;z(this,t,n,a,B,0)}let h=1,g=0;for(this[n]=t&255;++g<a&&(h*=256);)this[n+g]=t/h&255;return n+a},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,n,a,p){if(t=+t,n=n>>>0,a=a>>>0,!p){let B=Math.pow(2,8*a)-1;z(this,t,n,a,B,0)}let h=a-1,g=1;for(this[n+h]=t&255;--h>=0&&(g*=256);)this[n+h]=t/g&255;return n+a},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,n,a){return t=+t,n=n>>>0,a||z(this,t,n,1,255,0),this[n]=t&255,n+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,n,a){return t=+t,n=n>>>0,a||z(this,t,n,2,65535,0),this[n]=t&255,this[n+1]=t>>>8,n+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,n,a){return t=+t,n=n>>>0,a||z(this,t,n,2,65535,0),this[n]=t>>>8,this[n+1]=t&255,n+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,n,a){return t=+t,n=n>>>0,a||z(this,t,n,4,4294967295,0),this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=t&255,n+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,n,a){return t=+t,n=n>>>0,a||z(this,t,n,4,4294967295,0),this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255,n+4};function Tt(o,t,n,a,p){St(t,a,p,o,n,7);let h=Number(t&BigInt(4294967295));o[n++]=h,h=h>>8,o[n++]=h,h=h>>8,o[n++]=h,h=h>>8,o[n++]=h;let g=Number(t>>BigInt(32)&BigInt(4294967295));return o[n++]=g,g=g>>8,o[n++]=g,g=g>>8,o[n++]=g,g=g>>8,o[n++]=g,n}function Et(o,t,n,a,p){St(t,a,p,o,n,7);let h=Number(t&BigInt(4294967295));o[n+7]=h,h=h>>8,o[n+6]=h,h=h>>8,o[n+5]=h,h=h>>8,o[n+4]=h;let g=Number(t>>BigInt(32)&BigInt(4294967295));return o[n+3]=g,g=g>>8,o[n+2]=g,g=g>>8,o[n+1]=g,g=g>>8,o[n]=g,n+8}u.prototype.writeBigUInt64LE=le(function(t,n=0){return Tt(this,t,n,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=le(function(t,n=0){return Et(this,t,n,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(t,n,a,p){if(t=+t,n=n>>>0,!p){let M=Math.pow(2,8*a-1);z(this,t,n,a,M-1,-M)}let h=0,g=1,B=0;for(this[n]=t&255;++h<a&&(g*=256);)t<0&&B===0&&this[n+h-1]!==0&&(B=1),this[n+h]=(t/g>>0)-B&255;return n+a},u.prototype.writeIntBE=function(t,n,a,p){if(t=+t,n=n>>>0,!p){let M=Math.pow(2,8*a-1);z(this,t,n,a,M-1,-M)}let h=a-1,g=1,B=0;for(this[n+h]=t&255;--h>=0&&(g*=256);)t<0&&B===0&&this[n+h+1]!==0&&(B=1),this[n+h]=(t/g>>0)-B&255;return n+a},u.prototype.writeInt8=function(t,n,a){return t=+t,n=n>>>0,a||z(this,t,n,1,127,-128),t<0&&(t=255+t+1),this[n]=t&255,n+1},u.prototype.writeInt16LE=function(t,n,a){return t=+t,n=n>>>0,a||z(this,t,n,2,32767,-32768),this[n]=t&255,this[n+1]=t>>>8,n+2},u.prototype.writeInt16BE=function(t,n,a){return t=+t,n=n>>>0,a||z(this,t,n,2,32767,-32768),this[n]=t>>>8,this[n+1]=t&255,n+2},u.prototype.writeInt32LE=function(t,n,a){return t=+t,n=n>>>0,a||z(this,t,n,4,2147483647,-2147483648),this[n]=t&255,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24,n+4},u.prototype.writeInt32BE=function(t,n,a){return t=+t,n=n>>>0,a||z(this,t,n,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255,n+4},u.prototype.writeBigInt64LE=le(function(t,n=0){return Tt(this,t,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=le(function(t,n=0){return Et(this,t,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function It(o,t,n,a,p,h){if(n+a>o.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function kt(o,t,n,a,p){return t=+t,n=n>>>0,p||It(o,t,n,4),r.write(o,t,n,a,23,4),n+4}u.prototype.writeFloatLE=function(t,n,a){return kt(this,t,n,!0,a)},u.prototype.writeFloatBE=function(t,n,a){return kt(this,t,n,!1,a)};function Rt(o,t,n,a,p){return t=+t,n=n>>>0,p||It(o,t,n,8),r.write(o,t,n,a,52,8),n+8}u.prototype.writeDoubleLE=function(t,n,a){return Rt(this,t,n,!0,a)},u.prototype.writeDoubleBE=function(t,n,a){return Rt(this,t,n,!1,a)},u.prototype.copy=function(t,n,a,p){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(a||(a=0),!p&&p!==0&&(p=this.length),n>=t.length&&(n=t.length),n||(n=0),p>0&&p<a&&(p=a),p===a||t.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(a<0||a>=this.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("sourceEnd out of bounds");p>this.length&&(p=this.length),t.length-n<p-a&&(p=t.length-n+a);let h=p-a;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,a,p):Uint8Array.prototype.set.call(t,this.subarray(a,p),n),h},u.prototype.fill=function(t,n,a,p){if(typeof t=="string"){if(typeof n=="string"?(p=n,n=0,a=this.length):typeof a=="string"&&(p=a,a=this.length),p!==void 0&&typeof p!="string")throw new TypeError("encoding must be a string");if(typeof p=="string"&&!u.isEncoding(p))throw new TypeError("Unknown encoding: "+p);if(t.length===1){let g=t.charCodeAt(0);(p==="utf8"&&g<128||p==="latin1")&&(t=g)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(n<0||this.length<n||this.length<a)throw new RangeError("Out of range index");if(a<=n)return this;n=n>>>0,a=a===void 0?this.length:a>>>0,t||(t=0);let h;if(typeof t=="number")for(h=n;h<a;++h)this[h]=t;else{let g=u.isBuffer(t)?t:u.from(t,p),B=g.length;if(B===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(h=0;h<a-n;++h)this[h+n]=g[h%B]}return this};let ve={};function at(o,t,n){ve[o]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${o}]`,this.stack,delete this.name}get code(){return o}set code(p){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:p,writable:!0})}toString(){return`${this.name} [${o}]: ${this.message}`}}}at("ERR_BUFFER_OUT_OF_BOUNDS",function(o){return o?`${o} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),at("ERR_INVALID_ARG_TYPE",function(o,t){return`The "${o}" argument must be of type number. Received type ${typeof t}`},TypeError),at("ERR_OUT_OF_RANGE",function(o,t,n){let a=`The value of "${o}" is out of range.`,p=n;return Number.isInteger(n)&&Math.abs(n)>2**32?p=Bt(String(n)):typeof n=="bigint"&&(p=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(p=Bt(p)),p+="n"),a+=` It must be ${t}. Received ${p}`,a},RangeError);function Bt(o){let t="",n=o.length,a=o[0]==="-"?1:0;for(;n>=a+4;n-=3)t=`_${o.slice(n-3,n)}${t}`;return`${o.slice(0,n)}${t}`}function zn(o,t,n){Ae(t,"offset"),(o[t]===void 0||o[t+n]===void 0)&&ke(t,o.length-(n+1))}function St(o,t,n,a,p,h){if(o>n||o<t){let g=typeof t=="bigint"?"n":"",B;throw t===0||t===BigInt(0)?B=`>= 0${g} and < 2${g} ** ${(h+1)*8}${g}`:B=`>= -(2${g} ** ${(h+1)*8-1}${g}) and < 2 ** ${(h+1)*8-1}${g}`,new ve.ERR_OUT_OF_RANGE("value",B,o)}zn(a,p,h)}function Ae(o,t){if(typeof o!="number")throw new ve.ERR_INVALID_ARG_TYPE(t,"number",o)}function ke(o,t,n){throw Math.floor(o)!==o?(Ae(o,n),new ve.ERR_OUT_OF_RANGE("offset","an integer",o)):t<0?new ve.ERR_BUFFER_OUT_OF_BOUNDS:new ve.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${t}`,o)}let Hn=/[^+/0-9A-Za-z-_]/g;function Yn(o){if(o=o.split("=")[0],o=o.trim().replace(Hn,""),o.length<2)return"";for(;o.length%4!==0;)o=o+"=";return o}function ut(o,t){t=t||1/0;let n,a=o.length,p=null,h=[];for(let g=0;g<a;++g){if(n=o.charCodeAt(g),n>55295&&n<57344){if(!p){if(n>56319){(t-=3)>-1&&h.push(239,191,189);continue}else if(g+1===a){(t-=3)>-1&&h.push(239,191,189);continue}p=n;continue}if(n<56320){(t-=3)>-1&&h.push(239,191,189),p=n;continue}n=(p-55296<<10|n-56320)+65536}else p&&(t-=3)>-1&&h.push(239,191,189);if(p=null,n<128){if((t-=1)<0)break;h.push(n)}else if(n<2048){if((t-=2)<0)break;h.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;h.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=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 Jn(o){let t=[];for(let n=0;n<o.length;++n)t.push(o.charCodeAt(n)&255);return t}function Xn(o,t){let n,a,p,h=[];for(let g=0;g<o.length&&!((t-=2)<0);++g)n=o.charCodeAt(g),a=n>>8,p=n%256,h.push(p),h.push(a);return h}function Nt(o){return l.toByteArray(Yn(o))}function We(o,t,n,a){let p;for(p=0;p<a&&!(p+n>=t.length||p>=o.length);++p)t[p+n]=o[p];return p}function Q(o,t){return o instanceof t||o!=null&&o.constructor!=null&&o.constructor.name!=null&&o.constructor.name===t.name}function lt(o){return o!==o}let Qn=(function(){let o="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){let a=n*16;for(let p=0;p<16;++p)t[a+p]=o[n]+o[p]}return t})();function le(o){return typeof BigInt>"u"?Zn:o}function Zn(){throw new Error("BigInt not supported")}return ce}var Re,Jr,He,Xr,ce,Qr,en=Te(()=>{"use strict";c();m();d();Re={},Jr=!1;He={},Xr=!1;ce={},Qr=!1});var de,v,Mo,$o,tn=Te(()=>{"use strict";c();m();d();en();de=Zr();de.Buffer;de.SlowBuffer;de.INSPECT_MAX_BYTES;de.kMaxLength;v=de.Buffer,Mo=de.INSPECT_MAX_BYTES,$o=de.kMaxLength});var m=Te(()=>{"use strict";tn()});c();m();d();c();m();d();c();m();d();c();m();d();function L(l){throw new Error("Unexpected value: "+JSON.stringify(l))}c();m();d();c();m();d();c();m();d();c();m();d();c();m();d();c();m();d();var ii=typeof global=="object"&&global&&global.Object===Object&&global,rn=ii;var oi=typeof self=="object"&&self&&self.Object===Object&&self,si=rn||oi||Function("return this")(),nn=si;var ai=nn.Symbol,re=ai;c();m();d();var on=Object.prototype,ui=on.hasOwnProperty,li=on.toString,Be=re?re.toStringTag:void 0;function pi(l){var r=ui.call(l,Be),e=l[Be];try{l[Be]=void 0;var i=!0}catch{}var s=li.call(l);return i&&(r?l[Be]=e:delete l[Be]),s}var sn=pi;c();m();d();var fi=Object.prototype,ci=fi.toString;function di(l){return ci.call(l)}var an=di;var mi="[object Null]",hi="[object Undefined]",un=re?re.toStringTag:void 0;function yi(l){return l==null?l===void 0?hi:mi:un&&un in Object(l)?sn(l):an(l)}var ln=yi;c();m();d();function gi(l){return l!=null&&typeof l=="object"}var pn=gi;var xi="[object Symbol]";function wi(l){return typeof l=="symbol"||pn(l)&&ln(l)==xi}var fn=wi;c();m();d();c();m();d();function bi(l,r){for(var e=-1,i=l==null?0:l.length,s=Array(i);++e<i;)s[e]=r(l[e],e,l);return s}var cn=bi;c();m();d();var vi=Array.isArray,dn=vi;var Ai=1/0,mn=re?re.prototype:void 0,hn=mn?mn.toString:void 0;function yn(l){if(typeof l=="string")return l;if(dn(l))return cn(l,yn)+"";if(fn(l))return hn?hn.call(l):"";var r=l+"";return r=="0"&&1/l==-Ai?"-0":r}var gn=yn;c();m();d();function Ti(l){return l==null?"":gn(l)}var xn=Ti;c();m();d();c();m();d();c();m();d();c();m();d();function Ei(l,r,e){var i=-1,s=l.length;r<0&&(r=-r>s?0:s+r),e=e>s?s:e,e<0&&(e+=s),s=r>e?0:e-r>>>0,r>>>=0;for(var f=Array(s);++i<s;)f[i]=l[i+r];return f}var wn=Ei;function Ii(l,r,e){var i=l.length;return e=e===void 0?i:e,!r&&e>=i?l:wn(l,r,e)}var bn=Ii;c();m();d();var ki="\\ud800-\\udfff",Ri="\\u0300-\\u036f",Bi="\\ufe20-\\ufe2f",Si="\\u20d0-\\u20ff",Ni=Ri+Bi+Si,Li="\\ufe0e\\ufe0f",Ci="\\u200d",Fi=RegExp("["+Ci+ki+Ni+Li+"]");function Pi(l){return Fi.test(l)}var Ye=Pi;c();m();d();c();m();d();function Ui(l){return l.split("")}var vn=Ui;c();m();d();var An="\\ud800-\\udfff",Mi="\\u0300-\\u036f",$i="\\ufe20-\\ufe2f",Di="\\u20d0-\\u20ff",Oi=Mi+$i+Di,_i="\\ufe0e\\ufe0f",ji="["+An+"]",dt="["+Oi+"]",mt="\\ud83c[\\udffb-\\udfff]",Vi="(?:"+dt+"|"+mt+")",Tn="[^"+An+"]",En="(?:\\ud83c[\\udde6-\\uddff]){2}",In="[\\ud800-\\udbff][\\udc00-\\udfff]",qi="\\u200d",kn=Vi+"?",Rn="["+_i+"]?",Wi="(?:"+qi+"(?:"+[Tn,En,In].join("|")+")"+Rn+kn+")*",Gi=Rn+kn+Wi,Ki="(?:"+[Tn+dt+"?",dt,En,In,ji].join("|")+")",zi=RegExp(mt+"(?="+mt+")|"+Ki+Gi,"g");function Hi(l){return l.match(zi)||[]}var Bn=Hi;function Yi(l){return Ye(l)?Bn(l):vn(l)}var Sn=Yi;function Ji(l){return function(r){r=xn(r);var e=Ye(r)?Sn(r):void 0,i=e?e[0]:r.charAt(0),s=e?bn(e,1).join(""):r.slice(1);return i[l]()+s}}var Nn=Ji;var Xi=Nn("toUpperCase"),ht=Xi;c();m();d();function Se(l){return Object.keys(l)}c();m();d();c();m();d();c();m();d();var Ne=b.env.FERN_STACK_TRACK?.toLowerCase()??"",Z=Ne!==""&&Ne!=="0"&&Ne!=="false",yt=["single","multiline","box"].includes(Ne)?Ne:"single";Z&&(Error.stackTraceLimit=50);var Qi=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),Zi=new Set(["stacktrace"]);function Xe({maxFrames:l=50,skip:r=0,filterPaths:e=[],filterFunctions:i=[],stopOn:s=[],filterNode:f=!0,filterJs:u=!0,formatFilename:T=w=>w}={}){if(!Z)return[];i=[...i,...Qi],e=[...e,...Zi],s=[...s,"runInteractiveTask"];let w=!1;return(new Error().stack??"").split(`
|
|
2
|
-
`).map(k=>{let R=k.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(R&&R.length===5){let[,C,D,E,I]=R;if(!C||!D||!E||!I)return;if(w||s.some(F=>C?.includes(F))){w=!0;return}switch(C){case"Object.<anonymous>":C="";break;case"Object.object":case"Object.alias":case"Object.union":case"Object.enum":case"Object.undiscriminatedUnion":C=`${C.substring(C.indexOf(".")+1)}()=> { ... }`;break}return{fn:C,path:T(D),position:`${E}:${I}`}}}).filter(k=>k&&!i.some(R=>k.fn.includes(R))&&!(f&&k.path?.startsWith("node:"))&&!(u&&k.path?.endsWith(".js"))&&!e.some(R=>k.path.includes(R))).slice(
|
|
3
|
-
`:""}${i.fn} - ${i.path}:${i.position}`).join(""):""}frames(
|
|
1
|
+
var Lt=Object.defineProperty;var ei=(l,t,e)=>t in l?Lt(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e;var Te=(l,t)=>()=>(l&&(t=l(l=0)),t);var Ct=(l,t)=>{for(var e in t)Lt(l,e,{get:t[e],enumerable:!0})};var y=(l,t,e)=>ei(l,typeof t!="symbol"?t+"":t,e);var c=Te(()=>{"use strict"});var b={};Ct(b,{_debugEnd:()=>vr,_debugProcess:()=>br,_events:()=>$r,_eventsCount:()=>Dr,_exiting:()=>tr,_fatalExceptions:()=>yr,_getActiveHandles:()=>or,_getActiveRequests:()=>ir,_kill:()=>ar,_linkedBinding:()=>Zt,_maxListeners:()=>Mr,_preload_modules:()=>Fr,_rawDebug:()=>Xt,_startProfilerIdleNotifier:()=>Ar,_stopProfilerIdleNotifier:()=>Tr,_tickCallback:()=>wr,abort:()=>Rr,addListener:()=>Or,allowedNodeEnvironmentFlags:()=>dr,arch:()=>$t,argv:()=>_t,argv0:()=>Cr,assert:()=>mr,binding:()=>Gt,browser:()=>Jt,chdir:()=>Ht,config:()=>rr,cpuUsage:()=>ze,cwd:()=>zt,debugPort:()=>Lr,default:()=>Hr,dlopen:()=>nr,domain:()=>er,emit:()=>Wr,emitWarning:()=>Wt,env:()=>Ot,execArgv:()=>jt,execPath:()=>Nr,exit:()=>fr,features:()=>hr,hasUncaughtExceptionCaptureCallback:()=>xr,hrtime:()=>Ke,kill:()=>pr,listeners:()=>zr,memoryUsage:()=>lr,moduleLoadList:()=>Qt,nextTick:()=>Pt,off:()=>jr,on:()=>te,once:()=>_r,openStdin:()=>cr,pid:()=>Br,platform:()=>Dt,ppid:()=>Sr,prependListener:()=>Gr,prependOnceListener:()=>Kr,reallyExit:()=>sr,release:()=>Yt,removeAllListeners:()=>qr,removeListener:()=>Vr,resourceUsage:()=>ur,setSourceMapsEnabled:()=>Pr,setUncaughtExceptionCaptureCallback:()=>gr,stderr:()=>Ir,stdin:()=>kr,stdout:()=>Er,title:()=>Mt,umask:()=>Kt,uptime:()=>Ur,version:()=>Vt,versions:()=>qt});function ct(l){throw new Error("Node.js process "+l+" is not supported by JSPM core outside of Node.js")}function ti(){!Ee||!fe||(Ee=!1,fe.length?ee=fe.concat(ee):Ge=-1,ee.length&&Ft())}function Ft(){if(!Ee){var l=setTimeout(ti,0);Ee=!0;for(var t=ee.length;t;){for(fe=ee,ee=[];++Ge<t;)fe&&fe[Ge].run();Ge=-1,t=ee.length}fe=null,Ee=!1,clearTimeout(l)}}function Pt(l){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];ee.push(new Ut(l,t)),ee.length===1&&!Ee&&setTimeout(Ft,0)}function Ut(l,t){this.fun=l,this.array=t}function V(){}function Zt(l){ct("_linkedBinding")}function nr(l){ct("dlopen")}function ir(){return[]}function or(){return[]}function mr(l,t){if(!l)throw new Error(t||"assertion error")}function xr(){return!1}function Ur(){return pe.now()/1e3}function Ke(l){var t=Math.floor((Date.now()-pe.now())*.001),e=pe.now()*.001,i=Math.floor(e)+t,s=Math.floor(e%1*1e9);return l&&(i=i-l[0],s=s-l[1],s<0&&(i--,s+=ft)),[i,s]}function te(){return Hr}function zr(l){return[]}var ee,Ee,fe,Ge,Mt,$t,Dt,Ot,_t,jt,Vt,qt,Wt,Gt,Kt,zt,Ht,Yt,Jt,Xt,Qt,er,tr,rr,sr,ar,ze,ur,lr,pr,fr,cr,dr,hr,yr,gr,wr,br,vr,Ar,Tr,Er,Ir,kr,Rr,Br,Sr,Nr,Lr,Cr,Fr,Pr,pe,pt,ft,Mr,$r,Dr,Or,_r,jr,Vr,qr,Wr,Gr,Kr,Hr,Yr=Te(()=>{"use strict";c();m();d();ee=[],Ee=!1,Ge=-1;Ut.prototype.run=function(){this.fun.apply(null,this.array)};Mt="browser",$t="x64",Dt="browser",Ot={PATH:"/usr/bin",LANG:typeof navigator<"u"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},_t=["/usr/bin/node"],jt=[],Vt="v16.8.0",qt={},Wt=function(l,t){console.warn((t?t+": ":"")+l)},Gt=function(l){ct("binding")},Kt=function(l){return 0},zt=function(){return"/"},Ht=function(l){},Yt={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};Jt=!0,Xt=V,Qt=[];er={},tr=!1,rr={};sr=V,ar=V,ze=function(){return{}},ur=ze,lr=ze,pr=V,fr=V,cr=V,dr={};hr={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},yr=V,gr=V;wr=V,br=V,vr=V,Ar=V,Tr=V,Er=void 0,Ir=void 0,kr=void 0,Rr=V,Br=2,Sr=1,Nr="/bin/usr/node",Lr=9229,Cr="node",Fr=[],Pr=V,pe={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};pe.now===void 0&&(pt=Date.now(),pe.timing&&pe.timing.navigationStart&&(pt=pe.timing.navigationStart),pe.now=()=>Date.now()-pt);ft=1e9;Ke.bigint=function(l){var t=Ke(l);return typeof BigInt>"u"?t[0]*ft+t[1]:BigInt(t[0]*ft)+BigInt(t[1])};Mr=10,$r={},Dr=0;Or=te,_r=te,jr=te,Vr=te,qr=te,Wr=V,Gr=te,Kr=te;Hr={version:Vt,versions:qt,arch:$t,platform:Dt,browser:Jt,release:Yt,_rawDebug:Xt,moduleLoadList:Qt,binding:Gt,_linkedBinding:Zt,_events:$r,_eventsCount:Dr,_maxListeners:Mr,on:te,addListener:Or,once:_r,off:jr,removeListener:Vr,removeAllListeners:qr,emit:Wr,prependListener:Gr,prependOnceListener:Kr,listeners:zr,domain:er,_exiting:tr,config:rr,dlopen:nr,uptime:Ur,_getActiveRequests:ir,_getActiveHandles:or,reallyExit:sr,_kill:ar,cpuUsage:ze,resourceUsage:ur,memoryUsage:lr,kill:pr,exit:fr,openStdin:cr,allowedNodeEnvironmentFlags:dr,assert:mr,features:hr,_fatalExceptions:yr,setUncaughtExceptionCaptureCallback:gr,hasUncaughtExceptionCaptureCallback:xr,emitWarning:Wt,nextTick:Pt,_tickCallback:wr,_debugProcess:br,_debugEnd:vr,_startProfilerIdleNotifier:Ar,_stopProfilerIdleNotifier:Tr,stdout:Er,stdin:kr,stderr:Ir,abort:Rr,umask:Kt,chdir:Ht,cwd:zt,env:Ot,title:Mt,argv:_t,execArgv:jt,pid:Br,ppid:Sr,execPath:Nr,debugPort:Lr,hrtime:Ke,argv0:Cr,_preload_modules:Fr,setSourceMapsEnabled:Pr}});var d=Te(()=>{"use strict";Yr()});function ri(){if(Jr)return Re;Jr=!0,Re.byteLength=T,Re.toByteArray=k,Re.fromByteArray=D;for(var l=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,f=i.length;s<f;++s)l[s]=i[s],t[i.charCodeAt(s)]=s;t[45]=62,t[95]=63;function u(E){var I=E.length;if(I%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var F=E.indexOf("=");F===-1&&(F=I);var _=F===I?0:4-F%4;return[F,_]}function T(E){var I=u(E),F=I[0],_=I[1];return(F+_)*3/4-_}function w(E,I,F){return(I+F)*3/4-F}function k(E){var I,F=u(E),_=F[0],G=F[1],O=new e(w(E,_,G)),K=0,H=G>0?_-4:_,q;for(q=0;q<H;q+=4)I=t[E.charCodeAt(q)]<<18|t[E.charCodeAt(q+1)]<<12|t[E.charCodeAt(q+2)]<<6|t[E.charCodeAt(q+3)],O[K++]=I>>16&255,O[K++]=I>>8&255,O[K++]=I&255;return G===2&&(I=t[E.charCodeAt(q)]<<2|t[E.charCodeAt(q+1)]>>4,O[K++]=I&255),G===1&&(I=t[E.charCodeAt(q)]<<10|t[E.charCodeAt(q+1)]<<4|t[E.charCodeAt(q+2)]>>2,O[K++]=I>>8&255,O[K++]=I&255),O}function R(E){return l[E>>18&63]+l[E>>12&63]+l[E>>6&63]+l[E&63]}function C(E,I,F){for(var _,G=[],O=I;O<F;O+=3)_=(E[O]<<16&16711680)+(E[O+1]<<8&65280)+(E[O+2]&255),G.push(R(_));return G.join("")}function D(E){for(var I,F=E.length,_=F%3,G=[],O=16383,K=0,H=F-_;K<H;K+=O)G.push(C(E,K,K+O>H?H:K+O));return _===1?(I=E[F-1],G.push(l[I>>2]+l[I<<4&63]+"==")):_===2&&(I=(E[F-2]<<8)+E[F-1],G.push(l[I>>10]+l[I>>4&63]+l[I<<2&63]+"=")),G.join("")}return Re}function ni(){if(Xr)return He;Xr=!0;return He.read=function(l,t,e,i,s){var f,u,T=s*8-i-1,w=(1<<T)-1,k=w>>1,R=-7,C=e?s-1:0,D=e?-1:1,E=l[t+C];for(C+=D,f=E&(1<<-R)-1,E>>=-R,R+=T;R>0;f=f*256+l[t+C],C+=D,R-=8);for(u=f&(1<<-R)-1,f>>=-R,R+=i;R>0;u=u*256+l[t+C],C+=D,R-=8);if(f===0)f=1-k;else{if(f===w)return u?NaN:(E?-1:1)*(1/0);u=u+Math.pow(2,i),f=f-k}return(E?-1:1)*u*Math.pow(2,f-i)},He.write=function(l,t,e,i,s,f){var u,T,w,k=f*8-s-1,R=(1<<k)-1,C=R>>1,D=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=i?0:f-1,I=i?1:-1,F=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(T=isNaN(t)?1:0,u=R):(u=Math.floor(Math.log(t)/Math.LN2),t*(w=Math.pow(2,-u))<1&&(u--,w*=2),u+C>=1?t+=D/w:t+=D*Math.pow(2,1-C),t*w>=2&&(u++,w/=2),u+C>=R?(T=0,u=R):u+C>=1?(T=(t*w-1)*Math.pow(2,s),u=u+C):(T=t*Math.pow(2,C-1)*Math.pow(2,s),u=0));s>=8;l[e+E]=T&255,E+=I,T/=256,s-=8);for(u=u<<s|T,k+=s;k>0;l[e+E]=u&255,E+=I,u/=256,k-=8);l[e+E-I]|=F*128},He}function Zr(){if(Qr)return ce;Qr=!0;let l=ri(),t=ni(),e=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ce.Buffer=u,ce.SlowBuffer=G,ce.INSPECT_MAX_BYTES=50;let i=2147483647;ce.kMaxLength=i,u.TYPED_ARRAY_SUPPORT=s(),!u.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 s(){try{let o=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(o,r),o.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function f(o){if(o>i)throw new RangeError('The value "'+o+'" is invalid for option "size"');let r=new Uint8Array(o);return Object.setPrototypeOf(r,u.prototype),r}function u(o,r,n){if(typeof o=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return R(o)}return T(o,r,n)}u.poolSize=8192;function T(o,r,n){if(typeof o=="string")return C(o,r);if(ArrayBuffer.isView(o))return E(o);if(o==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o);if(Q(o,ArrayBuffer)||o&&Q(o.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Q(o,SharedArrayBuffer)||o&&Q(o.buffer,SharedArrayBuffer)))return I(o,r,n);if(typeof o=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let a=o.valueOf&&o.valueOf();if(a!=null&&a!==o)return u.from(a,r,n);let p=F(o);if(p)return p;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof o[Symbol.toPrimitive]=="function")return u.from(o[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 o)}u.from=function(o,r,n){return T(o,r,n)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function w(o){if(typeof o!="number")throw new TypeError('"size" argument must be of type number');if(o<0)throw new RangeError('The value "'+o+'" is invalid for option "size"')}function k(o,r,n){return w(o),o<=0?f(o):r!==void 0?typeof n=="string"?f(o).fill(r,n):f(o).fill(r):f(o)}u.alloc=function(o,r,n){return k(o,r,n)};function R(o){return w(o),f(o<0?0:_(o)|0)}u.allocUnsafe=function(o){return R(o)},u.allocUnsafeSlow=function(o){return R(o)};function C(o,r){if((typeof r!="string"||r==="")&&(r="utf8"),!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let n=O(o,r)|0,a=f(n),p=a.write(o,r);return p!==n&&(a=a.slice(0,p)),a}function D(o){let r=o.length<0?0:_(o.length)|0,n=f(r);for(let a=0;a<r;a+=1)n[a]=o[a]&255;return n}function E(o){if(Q(o,Uint8Array)){let r=new Uint8Array(o);return I(r.buffer,r.byteOffset,r.byteLength)}return D(o)}function I(o,r,n){if(r<0||o.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(o.byteLength<r+(n||0))throw new RangeError('"length" is outside of buffer bounds');let a;return r===void 0&&n===void 0?a=new Uint8Array(o):n===void 0?a=new Uint8Array(o,r):a=new Uint8Array(o,r,n),Object.setPrototypeOf(a,u.prototype),a}function F(o){if(u.isBuffer(o)){let r=_(o.length)|0,n=f(r);return n.length===0||o.copy(n,0,0,r),n}if(o.length!==void 0)return typeof o.length!="number"||lt(o.length)?f(0):D(o);if(o.type==="Buffer"&&Array.isArray(o.data))return D(o.data)}function _(o){if(o>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return o|0}function G(o){return+o!=o&&(o=0),u.alloc(+o)}u.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==u.prototype},u.compare=function(r,n){if(Q(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),Q(n,Uint8Array)&&(n=u.from(n,n.offset,n.byteLength)),!u.isBuffer(r)||!u.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===n)return 0;let a=r.length,p=n.length;for(let h=0,g=Math.min(a,p);h<g;++h)if(r[h]!==n[h]){a=r[h],p=n[h];break}return a<p?-1:p<a?1:0},u.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}},u.concat=function(r,n){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return u.alloc(0);let a;if(n===void 0)for(n=0,a=0;a<r.length;++a)n+=r[a].length;let p=u.allocUnsafe(n),h=0;for(a=0;a<r.length;++a){let g=r[a];if(Q(g,Uint8Array))h+g.length>p.length?(u.isBuffer(g)||(g=u.from(g)),g.copy(p,h)):Uint8Array.prototype.set.call(p,g,h);else if(u.isBuffer(g))g.copy(p,h);else throw new TypeError('"list" argument must be an Array of Buffers');h+=g.length}return p};function O(o,r){if(u.isBuffer(o))return o.length;if(ArrayBuffer.isView(o)||Q(o,ArrayBuffer))return o.byteLength;if(typeof o!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof o);let n=o.length,a=arguments.length>2&&arguments[2]===!0;if(!a&&n===0)return 0;let p=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return ut(o).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return Nt(o).length;default:if(p)return a?-1:ut(o).length;r=(""+r).toLowerCase(),p=!0}}u.byteLength=O;function K(o,r,n){let a=!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(o||(o="utf8");;)switch(o){case"hex":return Gn(this,r,n);case"utf8":case"utf-8":return vt(this,r,n);case"ascii":return qn(this,r,n);case"latin1":case"binary":return Wn(this,r,n);case"base64":return jn(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Kn(this,r,n);default:if(a)throw new TypeError("Unknown encoding: "+o);o=(o+"").toLowerCase(),a=!0}}u.prototype._isBuffer=!0;function H(o,r,n){let a=o[r];o[r]=o[n],o[n]=a}u.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)H(this,n,n+1);return this},u.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)H(this,n,n+3),H(this,n+1,n+2);return this},u.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)H(this,n,n+7),H(this,n+1,n+6),H(this,n+2,n+5),H(this,n+3,n+4);return this},u.prototype.toString=function(){let r=this.length;return r===0?"":arguments.length===0?vt(this,0,r):K.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(r){if(!u.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:u.compare(this,r)===0},u.prototype.inspect=function(){let r="",n=ce.INSPECT_MAX_BYTES;return r=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(r+=" ... "),"<Buffer "+r+">"},e&&(u.prototype[e]=u.prototype.inspect),u.prototype.compare=function(r,n,a,p,h){if(Q(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),!u.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),a===void 0&&(a=r?r.length:0),p===void 0&&(p=0),h===void 0&&(h=this.length),n<0||a>r.length||p<0||h>this.length)throw new RangeError("out of range index");if(p>=h&&n>=a)return 0;if(p>=h)return-1;if(n>=a)return 1;if(n>>>=0,a>>>=0,p>>>=0,h>>>=0,this===r)return 0;let g=h-p,B=a-n,M=Math.min(g,B),U=this.slice(p,h),$=r.slice(n,a);for(let P=0;P<M;++P)if(U[P]!==$[P]){g=U[P],B=$[P];break}return g<B?-1:B<g?1:0};function q(o,r,n,a,p){if(o.length===0)return-1;if(typeof n=="string"?(a=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,lt(n)&&(n=p?0:o.length-1),n<0&&(n=o.length+n),n>=o.length){if(p)return-1;n=o.length-1}else if(n<0)if(p)n=0;else return-1;if(typeof r=="string"&&(r=u.from(r,a)),u.isBuffer(r))return r.length===0?-1:bt(o,r,n,a,p);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?p?Uint8Array.prototype.indexOf.call(o,r,n):Uint8Array.prototype.lastIndexOf.call(o,r,n):bt(o,[r],n,a,p);throw new TypeError("val must be string, number or Buffer")}function bt(o,r,n,a,p){let h=1,g=o.length,B=r.length;if(a!==void 0&&(a=String(a).toLowerCase(),a==="ucs2"||a==="ucs-2"||a==="utf16le"||a==="utf-16le")){if(o.length<2||r.length<2)return-1;h=2,g/=2,B/=2,n/=2}function M($,P){return h===1?$[P]:$.readUInt16BE(P*h)}let U;if(p){let $=-1;for(U=n;U<g;U++)if(M(o,U)===M(r,$===-1?0:U-$)){if($===-1&&($=U),U-$+1===B)return $*h}else $!==-1&&(U-=U-$),$=-1}else for(n+B>g&&(n=g-B),U=n;U>=0;U--){let $=!0;for(let P=0;P<B;P++)if(M(o,U+P)!==M(r,P)){$=!1;break}if($)return U}return-1}u.prototype.includes=function(r,n,a){return this.indexOf(r,n,a)!==-1},u.prototype.indexOf=function(r,n,a){return q(this,r,n,a,!0)},u.prototype.lastIndexOf=function(r,n,a){return q(this,r,n,a,!1)};function Mn(o,r,n,a){n=Number(n)||0;let p=o.length-n;a?(a=Number(a),a>p&&(a=p)):a=p;let h=r.length;a>h/2&&(a=h/2);let g;for(g=0;g<a;++g){let B=parseInt(r.substr(g*2,2),16);if(lt(B))return g;o[n+g]=B}return g}function $n(o,r,n,a){return We(ut(r,o.length-n),o,n,a)}function Dn(o,r,n,a){return We(Jn(r),o,n,a)}function On(o,r,n,a){return We(Nt(r),o,n,a)}function _n(o,r,n,a){return We(Xn(r,o.length-n),o,n,a)}u.prototype.write=function(r,n,a,p){if(n===void 0)p="utf8",a=this.length,n=0;else if(a===void 0&&typeof n=="string")p=n,a=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(a)?(a=a>>>0,p===void 0&&(p="utf8")):(p=a,a=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let h=this.length-n;if((a===void 0||a>h)&&(a=h),r.length>0&&(a<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");p||(p="utf8");let g=!1;for(;;)switch(p){case"hex":return Mn(this,r,n,a);case"utf8":case"utf-8":return $n(this,r,n,a);case"ascii":case"latin1":case"binary":return Dn(this,r,n,a);case"base64":return On(this,r,n,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _n(this,r,n,a);default:if(g)throw new TypeError("Unknown encoding: "+p);p=(""+p).toLowerCase(),g=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jn(o,r,n){return r===0&&n===o.length?l.fromByteArray(o):l.fromByteArray(o.slice(r,n))}function vt(o,r,n){n=Math.min(o.length,n);let a=[],p=r;for(;p<n;){let h=o[p],g=null,B=h>239?4:h>223?3:h>191?2:1;if(p+B<=n){let M,U,$,P;switch(B){case 1:h<128&&(g=h);break;case 2:M=o[p+1],(M&192)===128&&(P=(h&31)<<6|M&63,P>127&&(g=P));break;case 3:M=o[p+1],U=o[p+2],(M&192)===128&&(U&192)===128&&(P=(h&15)<<12|(M&63)<<6|U&63,P>2047&&(P<55296||P>57343)&&(g=P));break;case 4:M=o[p+1],U=o[p+2],$=o[p+3],(M&192)===128&&(U&192)===128&&($&192)===128&&(P=(h&15)<<18|(M&63)<<12|(U&63)<<6|$&63,P>65535&&P<1114112&&(g=P))}}g===null?(g=65533,B=1):g>65535&&(g-=65536,a.push(g>>>10&1023|55296),g=56320|g&1023),a.push(g),p+=B}return Vn(a)}let At=4096;function Vn(o){let r=o.length;if(r<=At)return String.fromCharCode.apply(String,o);let n="",a=0;for(;a<r;)n+=String.fromCharCode.apply(String,o.slice(a,a+=At));return n}function qn(o,r,n){let a="";n=Math.min(o.length,n);for(let p=r;p<n;++p)a+=String.fromCharCode(o[p]&127);return a}function Wn(o,r,n){let a="";n=Math.min(o.length,n);for(let p=r;p<n;++p)a+=String.fromCharCode(o[p]);return a}function Gn(o,r,n){let a=o.length;(!r||r<0)&&(r=0),(!n||n<0||n>a)&&(n=a);let p="";for(let h=r;h<n;++h)p+=Qn[o[h]];return p}function Kn(o,r,n){let a=o.slice(r,n),p="";for(let h=0;h<a.length-1;h+=2)p+=String.fromCharCode(a[h]+a[h+1]*256);return p}u.prototype.slice=function(r,n){let a=this.length;r=~~r,n=n===void 0?a:~~n,r<0?(r+=a,r<0&&(r=0)):r>a&&(r=a),n<0?(n+=a,n<0&&(n=0)):n>a&&(n=a),n<r&&(n=r);let p=this.subarray(r,n);return Object.setPrototypeOf(p,u.prototype),p};function j(o,r,n){if(o%1!==0||o<0)throw new RangeError("offset is not uint");if(o+r>n)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(r,n,a){r=r>>>0,n=n>>>0,a||j(r,n,this.length);let p=this[r],h=1,g=0;for(;++g<n&&(h*=256);)p+=this[r+g]*h;return p},u.prototype.readUintBE=u.prototype.readUIntBE=function(r,n,a){r=r>>>0,n=n>>>0,a||j(r,n,this.length);let p=this[r+--n],h=1;for(;n>0&&(h*=256);)p+=this[r+--n]*h;return p},u.prototype.readUint8=u.prototype.readUInt8=function(r,n){return r=r>>>0,n||j(r,1,this.length),this[r]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(r,n){return r=r>>>0,n||j(r,2,this.length),this[r]|this[r+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(r,n){return r=r>>>0,n||j(r,2,this.length),this[r]<<8|this[r+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(r,n){return r=r>>>0,n||j(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(r,n){return r=r>>>0,n||j(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},u.prototype.readBigUInt64LE=le(function(r){r=r>>>0,Ae(r,"offset");let n=this[r],a=this[r+7];(n===void 0||a===void 0)&&ke(r,this.length-8);let p=n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,h=this[++r]+this[++r]*2**8+this[++r]*2**16+a*2**24;return BigInt(p)+(BigInt(h)<<BigInt(32))}),u.prototype.readBigUInt64BE=le(function(r){r=r>>>0,Ae(r,"offset");let n=this[r],a=this[r+7];(n===void 0||a===void 0)&&ke(r,this.length-8);let p=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+a;return(BigInt(p)<<BigInt(32))+BigInt(h)}),u.prototype.readIntLE=function(r,n,a){r=r>>>0,n=n>>>0,a||j(r,n,this.length);let p=this[r],h=1,g=0;for(;++g<n&&(h*=256);)p+=this[r+g]*h;return h*=128,p>=h&&(p-=Math.pow(2,8*n)),p},u.prototype.readIntBE=function(r,n,a){r=r>>>0,n=n>>>0,a||j(r,n,this.length);let p=n,h=1,g=this[r+--p];for(;p>0&&(h*=256);)g+=this[r+--p]*h;return h*=128,g>=h&&(g-=Math.pow(2,8*n)),g},u.prototype.readInt8=function(r,n){return r=r>>>0,n||j(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},u.prototype.readInt16LE=function(r,n){r=r>>>0,n||j(r,2,this.length);let a=this[r]|this[r+1]<<8;return a&32768?a|4294901760:a},u.prototype.readInt16BE=function(r,n){r=r>>>0,n||j(r,2,this.length);let a=this[r+1]|this[r]<<8;return a&32768?a|4294901760:a},u.prototype.readInt32LE=function(r,n){return r=r>>>0,n||j(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},u.prototype.readInt32BE=function(r,n){return r=r>>>0,n||j(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},u.prototype.readBigInt64LE=le(function(r){r=r>>>0,Ae(r,"offset");let n=this[r],a=this[r+7];(n===void 0||a===void 0)&&ke(r,this.length-8);let p=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(a<<24);return(BigInt(p)<<BigInt(32))+BigInt(n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),u.prototype.readBigInt64BE=le(function(r){r=r>>>0,Ae(r,"offset");let n=this[r],a=this[r+7];(n===void 0||a===void 0)&&ke(r,this.length-8);let p=(n<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(p)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+a)}),u.prototype.readFloatLE=function(r,n){return r=r>>>0,n||j(r,4,this.length),t.read(this,r,!0,23,4)},u.prototype.readFloatBE=function(r,n){return r=r>>>0,n||j(r,4,this.length),t.read(this,r,!1,23,4)},u.prototype.readDoubleLE=function(r,n){return r=r>>>0,n||j(r,8,this.length),t.read(this,r,!0,52,8)},u.prototype.readDoubleBE=function(r,n){return r=r>>>0,n||j(r,8,this.length),t.read(this,r,!1,52,8)};function z(o,r,n,a,p,h){if(!u.isBuffer(o))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>p||r<h)throw new RangeError('"value" argument is out of bounds');if(n+a>o.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(r,n,a,p){if(r=+r,n=n>>>0,a=a>>>0,!p){let B=Math.pow(2,8*a)-1;z(this,r,n,a,B,0)}let h=1,g=0;for(this[n]=r&255;++g<a&&(h*=256);)this[n+g]=r/h&255;return n+a},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(r,n,a,p){if(r=+r,n=n>>>0,a=a>>>0,!p){let B=Math.pow(2,8*a)-1;z(this,r,n,a,B,0)}let h=a-1,g=1;for(this[n+h]=r&255;--h>=0&&(g*=256);)this[n+h]=r/g&255;return n+a},u.prototype.writeUint8=u.prototype.writeUInt8=function(r,n,a){return r=+r,n=n>>>0,a||z(this,r,n,1,255,0),this[n]=r&255,n+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(r,n,a){return r=+r,n=n>>>0,a||z(this,r,n,2,65535,0),this[n]=r&255,this[n+1]=r>>>8,n+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(r,n,a){return r=+r,n=n>>>0,a||z(this,r,n,2,65535,0),this[n]=r>>>8,this[n+1]=r&255,n+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(r,n,a){return r=+r,n=n>>>0,a||z(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},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(r,n,a){return r=+r,n=n>>>0,a||z(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 Tt(o,r,n,a,p){St(r,a,p,o,n,7);let h=Number(r&BigInt(4294967295));o[n++]=h,h=h>>8,o[n++]=h,h=h>>8,o[n++]=h,h=h>>8,o[n++]=h;let g=Number(r>>BigInt(32)&BigInt(4294967295));return o[n++]=g,g=g>>8,o[n++]=g,g=g>>8,o[n++]=g,g=g>>8,o[n++]=g,n}function Et(o,r,n,a,p){St(r,a,p,o,n,7);let h=Number(r&BigInt(4294967295));o[n+7]=h,h=h>>8,o[n+6]=h,h=h>>8,o[n+5]=h,h=h>>8,o[n+4]=h;let g=Number(r>>BigInt(32)&BigInt(4294967295));return o[n+3]=g,g=g>>8,o[n+2]=g,g=g>>8,o[n+1]=g,g=g>>8,o[n]=g,n+8}u.prototype.writeBigUInt64LE=le(function(r,n=0){return Tt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=le(function(r,n=0){return Et(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(r,n,a,p){if(r=+r,n=n>>>0,!p){let M=Math.pow(2,8*a-1);z(this,r,n,a,M-1,-M)}let h=0,g=1,B=0;for(this[n]=r&255;++h<a&&(g*=256);)r<0&&B===0&&this[n+h-1]!==0&&(B=1),this[n+h]=(r/g>>0)-B&255;return n+a},u.prototype.writeIntBE=function(r,n,a,p){if(r=+r,n=n>>>0,!p){let M=Math.pow(2,8*a-1);z(this,r,n,a,M-1,-M)}let h=a-1,g=1,B=0;for(this[n+h]=r&255;--h>=0&&(g*=256);)r<0&&B===0&&this[n+h+1]!==0&&(B=1),this[n+h]=(r/g>>0)-B&255;return n+a},u.prototype.writeInt8=function(r,n,a){return r=+r,n=n>>>0,a||z(this,r,n,1,127,-128),r<0&&(r=255+r+1),this[n]=r&255,n+1},u.prototype.writeInt16LE=function(r,n,a){return r=+r,n=n>>>0,a||z(this,r,n,2,32767,-32768),this[n]=r&255,this[n+1]=r>>>8,n+2},u.prototype.writeInt16BE=function(r,n,a){return r=+r,n=n>>>0,a||z(this,r,n,2,32767,-32768),this[n]=r>>>8,this[n+1]=r&255,n+2},u.prototype.writeInt32LE=function(r,n,a){return r=+r,n=n>>>0,a||z(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},u.prototype.writeInt32BE=function(r,n,a){return r=+r,n=n>>>0,a||z(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},u.prototype.writeBigInt64LE=le(function(r,n=0){return Tt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=le(function(r,n=0){return Et(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function It(o,r,n,a,p,h){if(n+a>o.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function kt(o,r,n,a,p){return r=+r,n=n>>>0,p||It(o,r,n,4),t.write(o,r,n,a,23,4),n+4}u.prototype.writeFloatLE=function(r,n,a){return kt(this,r,n,!0,a)},u.prototype.writeFloatBE=function(r,n,a){return kt(this,r,n,!1,a)};function Rt(o,r,n,a,p){return r=+r,n=n>>>0,p||It(o,r,n,8),t.write(o,r,n,a,52,8),n+8}u.prototype.writeDoubleLE=function(r,n,a){return Rt(this,r,n,!0,a)},u.prototype.writeDoubleBE=function(r,n,a){return Rt(this,r,n,!1,a)},u.prototype.copy=function(r,n,a,p){if(!u.isBuffer(r))throw new TypeError("argument should be a Buffer");if(a||(a=0),!p&&p!==0&&(p=this.length),n>=r.length&&(n=r.length),n||(n=0),p>0&&p<a&&(p=a),p===a||r.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(a<0||a>=this.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("sourceEnd out of bounds");p>this.length&&(p=this.length),r.length-n<p-a&&(p=r.length-n+a);let h=p-a;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,a,p):Uint8Array.prototype.set.call(r,this.subarray(a,p),n),h},u.prototype.fill=function(r,n,a,p){if(typeof r=="string"){if(typeof n=="string"?(p=n,n=0,a=this.length):typeof a=="string"&&(p=a,a=this.length),p!==void 0&&typeof p!="string")throw new TypeError("encoding must be a string");if(typeof p=="string"&&!u.isEncoding(p))throw new TypeError("Unknown encoding: "+p);if(r.length===1){let g=r.charCodeAt(0);(p==="utf8"&&g<128||p==="latin1")&&(r=g)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(n<0||this.length<n||this.length<a)throw new RangeError("Out of range index");if(a<=n)return this;n=n>>>0,a=a===void 0?this.length:a>>>0,r||(r=0);let h;if(typeof r=="number")for(h=n;h<a;++h)this[h]=r;else{let g=u.isBuffer(r)?r:u.from(r,p),B=g.length;if(B===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(h=0;h<a-n;++h)this[h+n]=g[h%B]}return this};let ve={};function at(o,r,n){ve[o]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${o}]`,this.stack,delete this.name}get code(){return o}set code(p){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:p,writable:!0})}toString(){return`${this.name} [${o}]: ${this.message}`}}}at("ERR_BUFFER_OUT_OF_BOUNDS",function(o){return o?`${o} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),at("ERR_INVALID_ARG_TYPE",function(o,r){return`The "${o}" argument must be of type number. Received type ${typeof r}`},TypeError),at("ERR_OUT_OF_RANGE",function(o,r,n){let a=`The value of "${o}" is out of range.`,p=n;return Number.isInteger(n)&&Math.abs(n)>2**32?p=Bt(String(n)):typeof n=="bigint"&&(p=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(p=Bt(p)),p+="n"),a+=` It must be ${r}. Received ${p}`,a},RangeError);function Bt(o){let r="",n=o.length,a=o[0]==="-"?1:0;for(;n>=a+4;n-=3)r=`_${o.slice(n-3,n)}${r}`;return`${o.slice(0,n)}${r}`}function zn(o,r,n){Ae(r,"offset"),(o[r]===void 0||o[r+n]===void 0)&&ke(r,o.length-(n+1))}function St(o,r,n,a,p,h){if(o>n||o<r){let g=typeof r=="bigint"?"n":"",B;throw r===0||r===BigInt(0)?B=`>= 0${g} and < 2${g} ** ${(h+1)*8}${g}`:B=`>= -(2${g} ** ${(h+1)*8-1}${g}) and < 2 ** ${(h+1)*8-1}${g}`,new ve.ERR_OUT_OF_RANGE("value",B,o)}zn(a,p,h)}function Ae(o,r){if(typeof o!="number")throw new ve.ERR_INVALID_ARG_TYPE(r,"number",o)}function ke(o,r,n){throw Math.floor(o)!==o?(Ae(o,n),new ve.ERR_OUT_OF_RANGE("offset","an integer",o)):r<0?new ve.ERR_BUFFER_OUT_OF_BOUNDS:new ve.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,o)}let Hn=/[^+/0-9A-Za-z-_]/g;function Yn(o){if(o=o.split("=")[0],o=o.trim().replace(Hn,""),o.length<2)return"";for(;o.length%4!==0;)o=o+"=";return o}function ut(o,r){r=r||1/0;let n,a=o.length,p=null,h=[];for(let g=0;g<a;++g){if(n=o.charCodeAt(g),n>55295&&n<57344){if(!p){if(n>56319){(r-=3)>-1&&h.push(239,191,189);continue}else if(g+1===a){(r-=3)>-1&&h.push(239,191,189);continue}p=n;continue}if(n<56320){(r-=3)>-1&&h.push(239,191,189),p=n;continue}n=(p-55296<<10|n-56320)+65536}else p&&(r-=3)>-1&&h.push(239,191,189);if(p=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 Jn(o){let r=[];for(let n=0;n<o.length;++n)r.push(o.charCodeAt(n)&255);return r}function Xn(o,r){let n,a,p,h=[];for(let g=0;g<o.length&&!((r-=2)<0);++g)n=o.charCodeAt(g),a=n>>8,p=n%256,h.push(p),h.push(a);return h}function Nt(o){return l.toByteArray(Yn(o))}function We(o,r,n,a){let p;for(p=0;p<a&&!(p+n>=r.length||p>=o.length);++p)r[p+n]=o[p];return p}function Q(o,r){return o instanceof r||o!=null&&o.constructor!=null&&o.constructor.name!=null&&o.constructor.name===r.name}function lt(o){return o!==o}let Qn=(function(){let o="0123456789abcdef",r=new Array(256);for(let n=0;n<16;++n){let a=n*16;for(let p=0;p<16;++p)r[a+p]=o[n]+o[p]}return r})();function le(o){return typeof BigInt>"u"?Zn:o}function Zn(){throw new Error("BigInt not supported")}return ce}var Re,Jr,He,Xr,ce,Qr,en=Te(()=>{"use strict";c();m();d();Re={},Jr=!1;He={},Xr=!1;ce={},Qr=!1});var de,v,Mo,$o,tn=Te(()=>{"use strict";c();m();d();en();de=Zr();de.Buffer;de.SlowBuffer;de.INSPECT_MAX_BYTES;de.kMaxLength;v=de.Buffer,Mo=de.INSPECT_MAX_BYTES,$o=de.kMaxLength});var m=Te(()=>{"use strict";tn()});c();m();d();c();m();d();c();m();d();c();m();d();c();m();d();c();m();d();c();m();d();c();m();d();c();m();d();var ii=typeof global=="object"&&global&&global.Object===Object&&global,rn=ii;var oi=typeof self=="object"&&self&&self.Object===Object&&self,si=rn||oi||Function("return this")(),nn=si;var ai=nn.Symbol,re=ai;c();m();d();var on=Object.prototype,ui=on.hasOwnProperty,li=on.toString,Be=re?re.toStringTag:void 0;function pi(l){var t=ui.call(l,Be),e=l[Be];try{l[Be]=void 0;var i=!0}catch{}var s=li.call(l);return i&&(t?l[Be]=e:delete l[Be]),s}var sn=pi;c();m();d();var fi=Object.prototype,ci=fi.toString;function di(l){return ci.call(l)}var an=di;var mi="[object Null]",hi="[object Undefined]",un=re?re.toStringTag:void 0;function yi(l){return l==null?l===void 0?hi:mi:un&&un in Object(l)?sn(l):an(l)}var ln=yi;c();m();d();function gi(l){return l!=null&&typeof l=="object"}var pn=gi;var xi="[object Symbol]";function wi(l){return typeof l=="symbol"||pn(l)&&ln(l)==xi}var fn=wi;c();m();d();c();m();d();function bi(l,t){for(var e=-1,i=l==null?0:l.length,s=Array(i);++e<i;)s[e]=t(l[e],e,l);return s}var cn=bi;c();m();d();var vi=Array.isArray,dn=vi;var Ai=1/0,mn=re?re.prototype:void 0,hn=mn?mn.toString:void 0;function yn(l){if(typeof l=="string")return l;if(dn(l))return cn(l,yn)+"";if(fn(l))return hn?hn.call(l):"";var t=l+"";return t=="0"&&1/l==-Ai?"-0":t}var gn=yn;c();m();d();function Ti(l){return l==null?"":gn(l)}var xn=Ti;c();m();d();c();m();d();c();m();d();c();m();d();function Ei(l,t,e){var i=-1,s=l.length;t<0&&(t=-t>s?0:s+t),e=e>s?s:e,e<0&&(e+=s),s=t>e?0:e-t>>>0,t>>>=0;for(var f=Array(s);++i<s;)f[i]=l[i+t];return f}var wn=Ei;function Ii(l,t,e){var i=l.length;return e=e===void 0?i:e,!t&&e>=i?l:wn(l,t,e)}var bn=Ii;c();m();d();var ki="\\ud800-\\udfff",Ri="\\u0300-\\u036f",Bi="\\ufe20-\\ufe2f",Si="\\u20d0-\\u20ff",Ni=Ri+Bi+Si,Li="\\ufe0e\\ufe0f",Ci="\\u200d",Fi=RegExp("["+Ci+ki+Ni+Li+"]");function Pi(l){return Fi.test(l)}var Ye=Pi;c();m();d();c();m();d();function Ui(l){return l.split("")}var vn=Ui;c();m();d();var An="\\ud800-\\udfff",Mi="\\u0300-\\u036f",$i="\\ufe20-\\ufe2f",Di="\\u20d0-\\u20ff",Oi=Mi+$i+Di,_i="\\ufe0e\\ufe0f",ji="["+An+"]",dt="["+Oi+"]",mt="\\ud83c[\\udffb-\\udfff]",Vi="(?:"+dt+"|"+mt+")",Tn="[^"+An+"]",En="(?:\\ud83c[\\udde6-\\uddff]){2}",In="[\\ud800-\\udbff][\\udc00-\\udfff]",qi="\\u200d",kn=Vi+"?",Rn="["+_i+"]?",Wi="(?:"+qi+"(?:"+[Tn,En,In].join("|")+")"+Rn+kn+")*",Gi=Rn+kn+Wi,Ki="(?:"+[Tn+dt+"?",dt,En,In,ji].join("|")+")",zi=RegExp(mt+"(?="+mt+")|"+Ki+Gi,"g");function Hi(l){return l.match(zi)||[]}var Bn=Hi;function Yi(l){return Ye(l)?Bn(l):vn(l)}var Sn=Yi;function Ji(l){return function(t){t=xn(t);var e=Ye(t)?Sn(t):void 0,i=e?e[0]:t.charAt(0),s=e?bn(e,1).join(""):t.slice(1);return i[l]()+s}}var Nn=Ji;var Xi=Nn("toUpperCase"),ht=Xi;c();m();d();function L(l){throw new Error("Unexpected value: "+JSON.stringify(l))}c();m();d();function Se(l){return Object.keys(l)}c();m();d();c();m();d();c();m();d();var Ne=b.env.FERN_STACK_TRACK?.toLowerCase()??"",Z=Ne!==""&&Ne!=="0"&&Ne!=="false",yt=["single","multiline","box"].includes(Ne)?Ne:"single";Z&&(Error.stackTraceLimit=50);var Qi=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),Zi=new Set(["stacktrace"]);function Xe({maxFrames:l=50,skip:t=0,filterPaths:e=[],filterFunctions:i=[],stopOn:s=[],filterNode:f=!0,filterJs:u=!0,formatFilename:T=w=>w}={}){if(!Z)return[];i=[...i,...Qi],e=[...e,...Zi],s=[...s,"runInteractiveTask"];let w=!1;return(new Error().stack??"").split(`
|
|
2
|
+
`).map(k=>{let R=k.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(R&&R.length===5){let[,C,D,E,I]=R;if(!C||!D||!E||!I)return;if(w||s.some(F=>C?.includes(F))){w=!0;return}switch(C){case"Object.<anonymous>":C="";break;case"Object.object":case"Object.alias":case"Object.union":case"Object.enum":case"Object.undiscriminatedUnion":C=`${C.substring(C.indexOf(".")+1)}()=> { ... }`;break}return{fn:C,path:T(D),position:`${E}:${I}`}}}).filter(k=>k&&!i.some(R=>k.fn.includes(R))&&!(f&&k.path?.startsWith("node:"))&&!(u&&k.path?.endsWith(".js"))&&!e.some(R=>k.path.includes(R))).slice(t,t+l)}var Je=class{constructor({maxFrames:t=50,skip:e=0,filterPaths:i=[],filterFunctions:s=[],stopOn:f=[],filterNode:u=!0,filterJs:T=!0,multiline:w=!1,formatFilename:k=R=>R}={}){y(this,"maxFrames");y(this,"skip");y(this,"filterPaths");y(this,"filterFunctions");y(this,"stopOn");y(this,"filterNode");y(this,"filterJs");y(this,"multiline");y(this,"formatFilename");y(this,"tracking",new WeakMap);this.maxFrames=t,this.skip=e,this.filterPaths=i,this.filterFunctions=s,this.stopOn=f,this.filterNode=u,this.filterJs=T,this.multiline=w,this.formatFilename=k}tag(t){let e=this.tracking.get(t)||new Set;Xe({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(!Z)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}},gt;function Ln({maxFrames:l=50,skip:t=0,filterPaths:e=[],filterFunctions:i=[],stopOn:s=[],filterNode:f=!0,filterJs:u=!0,multiline:T=!1,formatFilename:w=k=>k}={}){Z&&(gt??(gt=new Je({maxFrames:l,skip:t,filterPaths:e,filterFunctions:i,stopOn:s,filterNode:f,filterJs:u,multiline:T,formatFilename:w})))}function Cn(l){gt?.tag(l)}function xt(l){return gt?.frames(l)??[]}var me=class{constructor(){Cn(this)}};c();m();d();var Qe=class{formatMultiple(t){return Promise.all(t.map(e=>this.format(e)))}formatMultipleSync(t){return t.map(e=>this.formatSync(e))}},Le=class extends Qe{async format(t){return t}formatSync(t){return t}};c();m();d();c();m();d();c();m();d();var J=class extends me{constructor(e){super();y(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 eo=4;Ln({skip:0,maxFrames:15,filterFunctions:["Abstract"]});var Ce=class{constructor(){y(this,"lineBuffer",[]);y(this,"indentLevel",0);y(this,"hasWrittenAnything",!1);y(this,"lastCharacterIsSemicolon",!1);y(this,"lastCharacterIsNewline",!1);y(this,"nodeStackFrames",[])}get buffer(){return Z&&this.nodeStackFrames.length>0&&this.writeInternal(`
|
|
4
4
|
`),this.lineBuffer.join(`
|
|
5
5
|
`)+(this.lastCharacterIsNewline?`
|
|
6
|
-
`:"")}write(...
|
|
6
|
+
`:"")}write(...t){for(let e of t)if(e!=null)if(typeof e=="string"){let i=e.length>0&&e.endsWith(`
|
|
7
7
|
`),s=i?e.substring(0,e.length-1):e,f=this.getIndentString(),u=s.replaceAll(`
|
|
8
8
|
`,`
|
|
9
9
|
${f}`);this.isAtStartOfLine()&&(u=f+u),i&&(u+=`
|
|
10
|
-
`),this.writeInternal(u)}else this.writeNode(e)}writeStatement(...
|
|
11
|
-
`)}writeNodeOrString(
|
|
10
|
+
`),this.writeInternal(u)}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){Z&&this.nodeStackFrames.push(...xt(t)),t.write(this),Z&&yt!=="single"&&this.writeInternal(`
|
|
11
|
+
`)}writeNodeOrString(t){if(typeof t=="string"){this.write(t);return}this.writeNode(t)}writeNodeStatement(t){this.writeNode(t),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new J(t).write(this),t.endsWith(";")||this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(t,e){new J(t).write(this),this.write(" (",e,")"),this.pushScope()}controlFlowWithoutStatement(t){new J(t).write(this),this.pushScope()}endControlFlow(){this.popScope()}contiguousControlFlow(t,e){this.dedent(),this.write("} "),new J(t).write(this),this.write(" (",e,")"),this.pushScope()}alternativeControlFlow(t){this.dedent(),this.write("} "),new J(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
|
-
`)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:
|
|
14
|
-
`),this.lastCharacterIsSemicolon=
|
|
15
|
-
`),s=Z&&!this.shouldSkipTracking(i)&&this.lastCharacterIsNewline;e&&(this.lastLine=`${this.lastLine}${i.shift()||""}`),this.lastCharacterIsNewline&&i.pop(),this.lineBuffer.push(...i),s&&this.appendTrackingComment()}set lastLine(r){this.lineBuffer.length>0?this.lineBuffer[this.lineBuffer.length-1]=r:this.lineBuffer.push(r)}get lastLine(){return this.lineBuffer[this.lineBuffer.length-1]||""}shouldSkipTracking(r){return!1}formatStack(r,e=""){return r.map(i=>`${e?`(${e}) `:""} ${i.fn} - ${i.path} : ${i.position}`)}filterStack(r){return r.filter(e=>!e.fn.startsWith(`${this.constructor.name}.`))}appendTrackingComment(){let r=[...this.formatStack(this.filterStack(Xe({maxFrames:15,skip:3}))),...this.formatStack(this.filterStack(this.nodeStackFrames),"node")];switch(this.nodeStackFrames.length=0,yt){case"single":return this.singleLineTrackingComment(r);case"multiline":return this.multiLineTrackingComment(r);case"box":return this.boxTrackingComment(r)}}singleLineTrackingComment(r){this.lastLine=`${this.lastLine} // ${r.join(" ")}`}multiLineTrackingComment(r){this.lineBuffer.push(...r.map(e=>` // ${e}`))}boxTrackingComment(r){this.lineBuffer.push("/*",...r.map(e=>` ${e}`),"*/")}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*this.getTabSize())}getTabSize(){return eo}};c();m();d();c();m();d();c();m();d();var Fe=class{constructor(){y(this,"reporter");y(this,"snippet");y(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:r,snippet:e}){this.shouldUpdate({snippet:e,reporter:r.errors})&&(this.reporter=r.errors.clone(),this.snippet=e)}getResponseOrThrow({endpoint:r}){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 "${r.method} ${r.path}"`)}shouldUpdate({snippet:r,reporter:e}){return this.reporter==null||this.reporter.size()>0&&e.size()===0?!0:r.length>(this.snippet?.length??0)}};var Pe=class{constructor(r){y(this,"context");this.context=r}async generate(r,e={}){let i=this.context.resolveEndpointLocationOrThrow(r.endpoint);if(i.length===0)throw new Error(`No endpoints found that match "${r.endpoint.method} ${r.endpoint.path}"`);let s=new Fe;for(let f of i){let u=this.context.clone(),T=this.createSnippetGenerator(u);try{let w=await T.generateSnippet({endpoint:f,request:r,options:e});if(u.errors.empty())return{snippet:w,errors:void 0};s.update({context:u,snippet:w})}catch(w){s.err==null&&(s.err=w)}}return s.getResponseOrThrow({endpoint:r.endpoint})}async generateSnippetAst(r,e={}){let i=this.context.resolveEndpointLocationOrThrow(r.endpoint);if(i.length===0)throw new Error(`No endpoints found that match "${r.endpoint.method} ${r.endpoint.path}"`);let s;for(let f of i){let u=this.context.clone(),T=this.createSnippetGenerator(u);try{return await T.generateSnippetAst({endpoint:f,request:r,options:e})}catch(w){s=w}}throw s??new Error(`Failed to generate snippet AST for endpoint: ${r.endpoint.method} ${r.endpoint.path}`)}generateSync(r,e={}){let i=this.context.resolveEndpointLocationOrThrow(r.endpoint);if(i.length===0)throw new Error(`No endpoints found that match "${r.endpoint.method} ${r.endpoint.path}"`);let s=new Fe;for(let f of i){let u=this.context.clone(),T=this.createSnippetGenerator(u);try{let w=T.generateSnippetSync({endpoint:f,request:r,options:e});if(u.errors.empty())return{snippet:w,errors:void 0};s.update({context:u,snippet:w})}catch(w){s.err==null&&(s.err=w)}}return s.getResponseOrThrow({endpoint:r.endpoint})}};c();m();d();c();m();d();c();m();d();var Ue=class{constructor(){y(this,"REFERENCE_REGEX",/^(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/)}validate(r){return this.REFERENCE_REGEX.test(r)?{type:"valid"}:{type:"invalid"}}tryParse(r){if(this.validate(r).type==="invalid")return;let i=r.match(this.REFERENCE_REGEX);if(!(i==null||i[1]==null||i[2]==null))return{method:i[1],path:i[2]}}};c();m();d();var N={Critical:"CRITICAL",Warning:"WARNING"},Me=class l{constructor(){y(this,"errors");y(this,"path");this.errors=[],this.path=[]}add(r){this.errors.push({...r,path:[...this.path]})}scope(r){this.path.push(r)}unscope(){this.path.pop()}getBySeverity(r){return this.errors.filter(e=>e.severity===r)}empty(){return this.errors.length===0}size(){return this.errors.length}clone(){let r=new l;return r.errors=[...this.errors],r.path=[...this.path],r}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(r=>({severity:r.severity,path:r.path!=null?this.pathToStringArray(r.path):void 0,message:r.message}))}pathToStringArray(r){let e=[];for(let i of r){if(typeof i=="string"){e.push(i);continue}e[e.length-1]+=`[${i.index}]`}return e}};var $e=class{constructor({ir:r,config:e,options:i={}}){y(this,"config");y(this,"options");y(this,"errors");y(this,"_ir");y(this,"httpEndpointReferenceParser");this._ir=r,this.config=e,this.options=i,this.errors=new Me,this.httpEndpointReferenceParser=new Ue}associateQueryParametersByWireValue({parameters:r,values:e}){let i=[];for(let[s,f]of Object.entries(e)){this.errors.scope(s);try{let u=r.find(w=>w.name.wireValue===s);if(u==null)throw this.newParameterNotRecognizedError(s);let T=this.isListTypeReference(u.typeReference)&&!Array.isArray(f)?[f]:f;i.push({name:u.name,typeReference:u.typeReference,value:T})}finally{this.errors.unscope()}}return i}associateByWireValueOrDefault({parameters:r,values:e}){let i=[];for(let s of r){this.errors.scope(s.name.wireValue);try{let f=e[s.name.wireValue];if(f==null)if(s.typeReference.type==="primitive"&&s.typeReference.value==="STRING")f=`<${s.name.wireValue}>`;else{this.errors.add({severity:N.Critical,message:this.newParameterNotRecognizedError(s.name.wireValue).message});continue}i.push({name:s.name,typeReference:s.typeReference,value:f})}finally{this.errors.unscope()}}return i}associateByWireValue({parameters:r,values:e,ignoreMissingParameters:i}){let s=[];for(let[f,u]of Object.entries(e)){this.errors.scope(f);try{let T=r.find(w=>w.name.wireValue===f);if(T==null){if(i)continue;this.errors.add({severity:N.Critical,message:this.newParameterNotRecognizedError(f).message});continue}s.push({name:T.name,typeReference:T.typeReference,value:u})}finally{this.errors.unscope()}}return s}getExampleObjectProperties({parameters:r,snippetObject:e}){let i=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},s=[];for(let f of r){let u=i[f.name.wireValue];u==null?f.typeReference.type==="nullable"&&s.push({name:f.name,typeReference:f.typeReference,value:null}):s.push({name:f.name,typeReference:f.typeReference,value:u})}return s}getSingleFileValue({property:r,record:e}){let i=e[r.wireValue];if(i!=null){if(typeof i!="string"){this.errors.add({severity:N.Critical,message:`Expected file value to be a string, got ${typeof i}`});return}return i}}getFileArrayValues({property:r,record:e}){let i=e[r.wireValue];if(i==null)return;if(!Array.isArray(i)){this.errors.add({severity:N.Critical,message:`Expected file array value to be an array of strings, got ${typeof i}`});return}let s=[];for(let f of i){if(typeof f!="string"){this.errors.add({severity:N.Critical,message:`Expected file array value to be an array of strings, got ${typeof f}`});return}s.push(f)}return s}getRecord(r){if(typeof r!="object"||Array.isArray(r)){this.errors.add({severity:N.Critical,message:`Expected object with key, value pairs but got: ${Array.isArray(r)?"array":typeof r}`});return}return r??{}}resolveNamedType({typeId:r}){let e=this._ir.types[r];if(e==null){this.errors.add({severity:N.Critical,message:`Type identified by "${r}" could not be found`});return}return e}resolveDiscriminatedUnionTypeInstance({discriminatedUnion:r,value:e}){let i=this.getRecord(e);if(i==null)return;let s=r.discriminant.wireValue,f=i[s];if(f==null){this.errors.add({severity:N.Critical,message:this.newParameterNotRecognizedError(s).message});return}if(typeof f!="string"){this.errors.add({severity:N.Critical,message:`Expected discriminant value to be a string but got: ${typeof f}`});return}let u=r.types[f];if(u==null){this.errors.add({severity:N.Critical,message:`No type found for discriminant value "${f}"`});return}let{[s]:T,...w}=i;return{singleDiscriminatedUnionType:u,discriminantValue:u.discriminantValue,value:w}}resolveEndpointOrThrow(r){let e=this.httpEndpointReferenceParser.tryParse(r);if(e==null)throw new Error(`Failed to parse endpoint reference "${r}"`);return this.resolveEndpointLocationOrThrow(e)}resolveEndpointLocation(r){let e=[];for(let i of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:i,parsedEndpoint:r})&&e.push(i);return e}resolveEndpointLocationOrThrow(r){let e=this.resolveEndpointLocation(r);if(e.length===0)throw new Error(`Failed to find endpoint identified by "${r.method} ${r.path}"`);return e}needsRequestParameter({request:r,inlinePathParameters:e,inlineFileProperties:i}){return this.includePathParametersInWrappedRequest({request:r,inlinePathParameters:e})||r.queryParameters!=null&&r.queryParameters.length>0||r.headers!=null&&r.headers.length>0?!0:r.body!=null?this.includeRequestBodyInWrappedRequest({body:r.body,inlineFileProperties:i}):!r.metadata?.onlyPathParameters}includePathParametersInWrappedRequest({request:r,inlinePathParameters:e}){return e&&(r.metadata?.includePathParameters??!1)}isFileUploadRequestBody(r){switch(r.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:L(r)}}resolveEnvironmentName(r){if(this._ir.environments==null)return;let e=this._ir.environments.environments;switch(e.type){case"singleBaseUrl":{let i=e.environments.find(s=>s.id===r);return i?.name}case"multipleBaseUrls":{let i=e.environments.find(s=>s.id===r);return i?.name}default:L(e)}}isSingleEnvironmentID(r){return typeof r=="string"}isMultiEnvironmentValues(r){return typeof r=="object"}validateMultiEnvironmentUrlValues(r){if(this._ir.environments==null)return this.errors.add({severity:N.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:N.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:N.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let s=new Set(Se(i.urls));for(let f of Se(r))s.has(f)&&s.delete(f);return s.size>0?(this.errors.add({severity:N.Critical,message:`The provided environments are invalid; got: [${Object.keys(r).join(", ")}], expected: [${Se(i.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:r}){if(typeof r!="number"){this.errors.add({severity:N.Critical,message:this.newTypeMismatchError({expected:"number",value:r}).message});return}return r}getValueAsBoolean({value:r}){if(typeof r!="boolean"){this.errors.add({severity:N.Critical,message:this.newTypeMismatchError({expected:"boolean",value:r}).message});return}return r}getValueAsString({value:r}){if(typeof r!="string"){this.errors.add({severity:N.Critical,message:this.newTypeMismatchError({expected:"string",value:r}).message});return}return r}isOptional(r){switch(r.type){case"nullable":return this.isOptional(r.value);case"optional":return!0;case"named":{let e=this.resolveNamedType({typeId:r.value});return e==null?!1:e.type==="alias"?this.isNullable(e.typeReference):!1}}return!1}isNullable(r){switch(r.type){case"nullable":return!0;case"optional":return this.isNullable(r.value);case"named":{let e=this.resolveNamedType({typeId:r.value});return e==null?!1:e.type==="alias"?this.isNullable(e.typeReference):!1}}return!1}newAuthMismatchError({auth:r,values:e}){return new Error(`Expected auth type ${r.type}, got ${e.type}`)}newParameterNotRecognizedError(r){return new Error(`"${r}" is not a recognized parameter for this endpoint`)}newTypeMismatchError({expected:r,value:e}){return new Error(`Expected ${r}, got ${typeof e}`)}includeRequestBodyInWrappedRequest({body:r,inlineFileProperties:e}){switch(r.type){case"properties":case"referenced":return!0;case"fileUpload":return this.includeFileUploadBodyInWrappedRequest({fileUpload:r,inlineFileProperties:e});default:L(r)}}includeFileUploadBodyInWrappedRequest({fileUpload:r,inlineFileProperties:e}){return this.fileUploadHasBodyProperties({fileUpload:r})||e&&this.fileUploadHasFileProperties({fileUpload:r})}fileUploadHasBodyProperties({fileUpload:r}){return r.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!1;case"bodyProperty":return!0;default:L(e)}})}fileUploadHasFileProperties({fileUpload:r}){return r.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:L(e)}})}isListTypeReference(r){return r.type==="optional"?this.isListTypeReference(r.value):r.type==="list"||r.type==="set"}parsedEndpointMatches({endpoint:r,parsedEndpoint:e}){return r.location.method===e.method&&r.location.path===e.path}};c();m();d();c();m();d();c();m();d();c();m();d();var to=2,Y=class extends Ce{constructor({customConfig:e,formatter:i}){super();y(this,"customConfig");y(this,"formatter");y(this,"requires",new Set);y(this,"_indentLevel",0);this.customConfig=e,this.formatter=i??new Le}addRequire(e){this.requires.add(e)}get currentIndentLevel(){return this._indentLevel}indent(){this._indentLevel++,super.indent()}dedent(){this._indentLevel--,super.dedent()}getTabSize(){return to}};var Ie=class extends Y{constructor({customConfig:r,formatter:e}){super({customConfig:r,formatter:e})}async toStringAsync(){let r=this.getContent();if(this.formatter!=null)try{return this.formatter.format(r)}catch(e){throw new Error(`Failed to format Ruby file: ${e}
|
|
16
|
-
${
|
|
17
|
-
${
|
|
13
|
+
`)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:t,delimiter:e,writeFunction:i}){if(t.length>0){let s=t[0];s!=null&&i(s);for(let f=1;f<t.length;f++){this.write(e);let u=t[f];u!=null&&i(u)}}}toString(){return this.buffer}writeInternal(t){if(t.length===0)return;let e=!this.lastCharacterIsNewline;this.hasWrittenAnything=!0,this.lastCharacterIsNewline=t.endsWith(`
|
|
14
|
+
`),this.lastCharacterIsSemicolon=t.endsWith(";");let i=t.split(`
|
|
15
|
+
`),s=Z&&!this.shouldSkipTracking(i)&&this.lastCharacterIsNewline;e&&(this.lastLine=`${this.lastLine}${i.shift()||""}`),this.lastCharacterIsNewline&&i.pop(),this.lineBuffer.push(...i),s&&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(Xe({maxFrames:15,skip:3}))),...this.formatStack(this.filterStack(this.nodeStackFrames),"node")];switch(this.nodeStackFrames.length=0,yt){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 eo}};c();m();d();c();m();d();c();m();d();var Fe=class{constructor(){y(this,"reporter");y(this,"snippet");y(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 Pe=class{constructor(t){y(this,"context");this.context=t}async generate(t,e={}){let i=this.context.resolveEndpointLocationOrThrow(t.endpoint);if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let s=new Fe;for(let f of i){let u=this.context.clone(),T=this.createSnippetGenerator(u);try{let w=await T.generateSnippet({endpoint:f,request:t,options:e});if(u.errors.empty())return{snippet:w,errors:void 0};s.update({context:u,snippet:w})}catch(w){s.err==null&&(s.err=w)}}return s.getResponseOrThrow({endpoint:t.endpoint})}async generateSnippetAst(t,e={}){let i=this.context.resolveEndpointLocationOrThrow(t.endpoint);if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let s;for(let f of i){let u=this.context.clone(),T=this.createSnippetGenerator(u);try{return await T.generateSnippetAst({endpoint:f,request:t,options:e})}catch(w){s=w}}throw s??new Error(`Failed to generate snippet AST for endpoint: ${t.endpoint.method} ${t.endpoint.path}`)}generateSync(t,e={}){let i=this.context.resolveEndpointLocationOrThrow(t.endpoint);if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let s=new Fe;for(let f of i){let u=this.context.clone(),T=this.createSnippetGenerator(u);try{let w=T.generateSnippetSync({endpoint:f,request:t,options:e});if(u.errors.empty())return{snippet:w,errors:void 0};s.update({context:u,snippet:w})}catch(w){s.err==null&&(s.err=w)}}return s.getResponseOrThrow({endpoint:t.endpoint})}};c();m();d();c();m();d();c();m();d();var Ue=class{constructor(){y(this,"REFERENCE_REGEX",/^(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/)}validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let i=t.match(this.REFERENCE_REGEX);if(!(i==null||i[1]==null||i[2]==null))return{method:i[1],path:i[2]}}};c();m();d();var N={Critical:"CRITICAL",Warning:"WARNING"},Me=class l{constructor(){y(this,"errors");y(this,"path");this.errors=[],this.path=[]}add(t){this.errors.push({...t,path:[...this.path]})}scope(t){this.path.push(t)}unscope(){this.path.pop()}getBySeverity(t){return this.errors.filter(e=>e.severity===t)}empty(){return this.errors.length===0}size(){return this.errors.length}clone(){let t=new l;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 $e=class{constructor({ir:t,config:e,options:i={}}){y(this,"config");y(this,"options");y(this,"errors");y(this,"_ir");y(this,"httpEndpointReferenceParser");this._ir=t,this.config=e,this.options=i,this.errors=new Me,this.httpEndpointReferenceParser=new Ue}associateQueryParametersByWireValue({parameters:t,values:e}){let i=[];for(let[s,f]of Object.entries(e))if(f!==void 0){this.errors.scope(s);try{let u=t.find(w=>w.name.wireValue===s);if(u==null)throw this.newParameterNotRecognizedError(s);let T=this.isListTypeReference(u.typeReference)&&!Array.isArray(f)?[f]:f;i.push({name:u.name,typeReference:u.typeReference,value:T})}finally{this.errors.unscope()}}return i}associateByWireValueOrDefault({parameters:t,values:e}){let i=[];for(let s of t){this.errors.scope(s.name.wireValue);try{let f=e[s.name.wireValue];if(f==null)if(s.typeReference.type==="primitive"&&s.typeReference.value==="STRING")f=`<${s.name.wireValue}>`;else{this.errors.add({severity:N.Critical,message:this.newParameterNotRecognizedError(s.name.wireValue).message});continue}i.push({name:s.name,typeReference:s.typeReference,value:f})}finally{this.errors.unscope()}}return i}associateByWireValue({parameters:t,values:e,ignoreMissingParameters:i}){let s=[];for(let[f,u]of Object.entries(e))if(u!==void 0){this.errors.scope(f);try{let T=t.find(w=>w.name.wireValue===f);if(T==null){if(i)continue;this.errors.add({severity:N.Critical,message:this.newParameterNotRecognizedError(f).message});continue}s.push({name:T.name,typeReference:T.typeReference,value:u})}finally{this.errors.unscope()}}return s}getExampleObjectProperties({parameters:t,snippetObject:e}){let i=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},s=[];for(let f of t){let u=i[f.name.wireValue];u==null?f.typeReference.type==="nullable"&&s.push({name:f.name,typeReference:f.typeReference,value:null}):s.push({name:f.name,typeReference:f.typeReference,value:u})}return s}getSingleFileValue({property:t,record:e}){let i=e[t.wireValue];if(i!=null){if(typeof i!="string"){this.errors.add({severity:N.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:N.Critical,message:`Expected file array value to be an array of strings, got ${typeof i}`});return}let s=[];for(let f of i){if(typeof f!="string"){this.errors.add({severity:N.Critical,message:`Expected file array value to be an array of strings, got ${typeof f}`});return}s.push(f)}return s}getRecord(t){if(typeof t!="object"||Array.isArray(t)){this.errors.add({severity:N.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:N.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 s=t.discriminant.wireValue,f=i[s];if(f==null){this.errors.add({severity:N.Critical,message:this.newParameterNotRecognizedError(s).message});return}if(typeof f!="string"){this.errors.add({severity:N.Critical,message:`Expected discriminant value to be a string but got: ${typeof f}`});return}let u=t.types[f];if(u==null){this.errors.add({severity:N.Critical,message:`No type found for discriminant value "${f}"`});return}let{[s]:T,...w}=i;return{singleDiscriminatedUnionType:u,discriminantValue:u.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:L(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(s=>s.id===t);return i?.name}case"multipleBaseUrls":{let i=e.environments.find(s=>s.id===t);return i?.name}default:L(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:N.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:N.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:N.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let s=new Set(Se(i.urls));for(let f of Se(t))s.has(f)&&s.delete(f);return s.size>0?(this.errors.add({severity:N.Critical,message:`The provided environments are invalid; got: [${Object.keys(t).join(", ")}], expected: [${Se(i.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:t}){if(typeof t!="number"){this.errors.add({severity:N.Critical,message:this.newTypeMismatchError({expected:"number",value:t}).message});return}return t}getValueAsBoolean({value:t}){if(typeof t!="boolean"){this.errors.add({severity:N.Critical,message:this.newTypeMismatchError({expected:"boolean",value:t}).message});return}return t}getValueAsString({value:t}){if(typeof t!="string"){this.errors.add({severity:N.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:L(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:L(e)}})}fileUploadHasFileProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:L(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}};c();m();d();c();m();d();c();m();d();c();m();d();var to=2,Y=class extends Ce{constructor({customConfig:e,formatter:i}){super();y(this,"customConfig");y(this,"formatter");y(this,"requires",new Set);y(this,"_indentLevel",0);this.customConfig=e,this.formatter=i??new Le}addRequire(e){this.requires.add(e)}get currentIndentLevel(){return this._indentLevel}indent(){this._indentLevel++,super.indent()}dedent(){this._indentLevel--,super.dedent()}getTabSize(){return to}};var Ie=class extends Y{constructor({customConfig:t,formatter:e}){super({customConfig:t,formatter:e})}async toStringAsync(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.format(t)}catch(e){throw new Error(`Failed to format Ruby file: ${e}
|
|
16
|
+
${t}`)}return t}toString(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.formatSync(t)}catch(e){throw new Error(`Failed to format Ruby file: ${e}
|
|
17
|
+
${t}`)}return t}getContent(){let t=this.stringifyRequires();return t.length>0?`${t}
|
|
18
18
|
|
|
19
|
-
${this.buffer}`:this.buffer}stringifyRequires(){return Array.from(this.requires).map(
|
|
20
|
-
`)}};var x={};Ct(x,{AstNode:()=>S,ClassInstantiation:()=>he,ClassReference:()=>ne,Class_:()=>ue,CodeBlock:()=>ye,KeywordArgument:()=>ge,KeywordParameter:()=>xe,Method:()=>se,MethodInvocation:()=>we,MethodKind:()=>oe,Module_:()=>ae,Parameter:()=>W,Type:()=>ie,TypeLiteral:()=>Ve,TypeParameter:()=>be,Writer:()=>Y,begin:()=>bo,classReference:()=>mo,class_:()=>uo,codeblock:()=>nt,comment:()=>fo,falseValue:()=>oo,ifElse:()=>wo,instantiateClass:()=>ho,invokeMethod:()=>go,keywordArgument:()=>yo,method:()=>po,module:()=>lo,nilValue:()=>so,parameters:()=>ao,positionalArgument:()=>xo,raise:()=>vo,trueValue:()=>io,typeParameter:()=>co,wrapInModules:()=>Ao});c();m();d();c();m();d();c();m();d();c();m();d();c();m();d();var S=class extends me{async toStringAsync({customConfig:
|
|
21
|
-
`).forEach(i=>{this.wrapLine(i,e).forEach(f=>{e.writeLine(`# ${f}`)})})}wrapLine(e,i){let s=i.currentIndentLevel*2,f=ro-s-no;if(e.length<=f)return[e];if(f<20)return[e];let u=e.split(/(\s+)/),T=[],w="";for(let k of u){if(k===""||w===""&&/^\s+$/.test(k))continue;let R=w+k;R.length<=f?w=R:(w.trim()!==""&&T.push(w.trimEnd()),w=k.trimStart(),w.length>f&&(T.push(w),w=""))}return w.trim()!==""&&T.push(w.trimEnd()),T.length===0?[e]:T}};c();m();d();c();m();d();c();m();d();var ne=class extends S{constructor({name:e,modules:i,fullyQualified:s}){super();y(this,"name");y(this,"modules");y(this,"fullyQualified");this.name=e,this.modules=i??[],this.fullyQualified=s??!1}write(e){if(this.fullyQualified||this.modules.length>0){let i=[...this.modules,this.name].join("::");e.write(i);return}e.write(this.name)}};var ie=class l extends S{constructor(e){super();y(this,"internalType");this.internalType=e}write(e){if(this.internalType)switch(this.internalType?.type){case"integer":e.write("Integer");return;case"string":e.write("String");return;case"class":e.writeNode(this.internalType.reference);return;case"instance":break;case"boolean":e.write("Internal::Types::Boolean");return;case"nil":break;case"top":break;case"bot":break;case"void":break;case"boolish":break;case"union":if(this.internalType.elems.length===2&&this.internalType.elems[1]?.internalType?.type==="nil"){let i=this.internalType.elems[0];i?.write(e)}break;case"intersection":break;case"array":e.write("Internal::Types::Array["),this.internalType.elem.write(e),e.write("]");return;case"hash":e.write("Internal::Types::Hash["),this.internalType.keyType.write(e),e.write(", "),this.internalType.valueType.write(e),e.write("]");return;case"object":e.write("Object");break;case"singleton":break;case"generic":break;case"self":break;case"tuple":break;default:L(this.internalType)}}writeTypeDefinition(e){if(this.internalType)switch(this.internalType.type){case"self":e.write("self");break;case"class":e.write(this.internalType.reference.toString(e));break;case"instance":e.write("instance");break;case"boolean":e.write("bool");break;case"nil":e.write("nil");break;case"top":e.write("top");break;case"bot":e.write("bot");break;case"void":e.write("void");break;case"boolish":e.write("boolish");break;case"string":e.write("String");break;case"integer":e.write("Integer");break;case"union":e.delimit({nodes:this.internalType.elems,delimiter:" | ",writeFunction:i=>i.writeTypeDefinition(e)});break;case"intersection":e.delimit({nodes:this.internalType.elems,delimiter:" & ",writeFunction:i=>i.writeTypeDefinition(e)});break;case"array":e.write("Array["),this.internalType.elem.writeTypeDefinition(e),e.write("]");break;case"hash":e.write("Hash["),this.internalType.keyType.writeTypeDefinition(e),e.write(", "),this.internalType.valueType.writeTypeDefinition(e),e.write("]");break;case"object":e.write(this.internalType.klass);break;case"singleton":e.write("singleton("),e.write(this.internalType.klass),e.write(")");break;case"tuple":e.write("["),e.delimit({nodes:this.internalType.elems,delimiter:", ",writeFunction:i=>i.write(e)}),e.write("]");break;case"generic":e.write(`${this.internalType.baseKlass}[`),e.delimit({nodes:this.internalType.parameters,delimiter:", ",writeFunction:i=>i.writeTypeDefinition(e)}),e.write("]");break;default:L(this.internalType)}else e.write("untyped")}static untyped(){return new this(void 0)}static self(){return new this({type:"self"})}static class_(e){return new this({type:"class",reference:new ne({name:e.name,modules:e.modules,fullyQualified:!0})})}static instance(){return new this({type:"instance"})}static boolean(){return new this({type:"boolean"})}static nil(){return new this({type:"nil"})}static top(){return new this({type:"top"})}static bot(){return new this({type:"bot"})}static void(){return new this({type:"void"})}static boolish(){return new this({type:"boolish"})}static string(){return new this({type:"string"})}static integer(){return new this({type:"integer"})}static union(e){return new this({type:"union",elems:e})}static intersection(e){return new this({type:"intersection",elems:e})}static array(e){return new this({type:"array",elem:e})}static hash(e,i){return new this({type:"hash",keyType:e,valueType:i})}static object(e){return new this({type:"object",klass:e})}static singleton(e){return new this({type:"singleton",klass:e})}static tuple(e){return new this({type:"tuple",elems:e})}static generic(e,i){return new this({type:"generic",baseKlass:e,parameters:i})}static nilable(e){return l.union([e,l.nil()])}nilable(){return l.nilable(this)}};var oe={Instance:"instance",Class_:"class"},Fn={Public:"public",Private:"private",Protected:"protected"},se=class extends S{constructor({name:e,docstring:i,kind:s,visibility:f,parameters:u,returnType:T,statements:w,splatOptionDocs:k}){super();y(this,"name");y(this,"docstring");y(this,"kind");y(this,"positionalParameters");y(this,"keywordParameters");y(this,"positionalSplatParameter");y(this,"keywordSplatParameter");y(this,"yieldParameter");y(this,"visibility");y(this,"statements");y(this,"returnType");y(this,"splatOptionDocs");this.name=e,this.docstring=i,this.kind=s??oe.Instance,this.visibility=f??Fn.Public,this.positionalParameters=u?.positional??[],this.keywordParameters=u?.keyword??[],this.positionalSplatParameter=u?.positionalSplat,this.keywordSplatParameter=u?.keywordSplat,this.yieldParameter=u?.yield,this.returnType=T??ie.untyped(),this.statements=w??[],this.splatOptionDocs=k??[]}addStatement(e){this.statements.push(e)}write(e){this.docstring&&new X({docs:this.docstring}).write(e);let i=this.positionalParameters.length>0||this.keywordParameters.length>0||this.keywordSplatParameter!=null;this.docstring&&i&&e.writeLine("#");for(let s of this.positionalParameters){e.write(`# @option ${s.name} [`);let f=new Y({customConfig:e.customConfig});s.type.writeTypeDefinition(f),e.write(this.normalizeForYard(f.toString())),e.write("]"),e.newLine()}for(let s of this.keywordParameters){e.write(`# @param ${s.name} [`);let f=new Y({customConfig:e.customConfig});s.type.writeTypeDefinition(f),e.write(this.normalizeForYard(f.toString())),e.write("]"),s.docs&&e.write(` ${s.docs}`),e.newLine()}if(this.keywordSplatParameter!=null){e.write(`# @param ${this.keywordSplatParameter.name} [`);let s=new Y({customConfig:e.customConfig});this.keywordSplatParameter.type.writeTypeDefinition(s),e.write(this.normalizeForYard(s.toString())),e.write("]"),this.keywordSplatParameter.docs&&e.write(` ${this.keywordSplatParameter.docs}`),e.newLine()}for(let s of this.splatOptionDocs)e.writeLine(`# ${s}`);if(this.returnType!=null){(i||this.docstring)&&e.writeLine("#"),e.write("# @return [");let s=new Y({customConfig:e.customConfig});this.returnType.writeTypeDefinition(s),e.write(this.normalizeForYard(s.toString())),e.write("]"),e.newLine()}switch(this.visibility!==Fn.Public&&(e.write(this.visibility),this.kind===oe.Class_&&e.write("_class_method"),e.write(" ")),this.kind){case oe.Instance:e.write(`def ${this.name}`);break;case oe.Class_:e.write(`def self.${this.name}`);break}this.parameters.length&&(e.write("("),e.delimit({nodes:this.parameters,delimiter:", ",writeFunction:s=>s.write(e)}),e.write(")")),this.statements.length?(e.newLine(),e.indent(),this.statements.forEach((s,f)=>{s.write(e),f<this.statements.length-1&&e.newLine()}),e.writeNewLineIfLastLineNot(),e.dedent(),e.write("end")):e.write("; end"),e.newLine()}writeTypeDefinition(e){e.write(`def ${this.name}: (`),this.parameters.forEach((i,s)=>{i.writeTypeDefinition(e),s<this.parameters.length-1&&e.write(", ")}),e.write(") -> "),this.returnType.writeTypeDefinition(e)}normalizeForYard(e){let i=e.replace(/\s*\|\s*/g,", ");return i=i.replace(/\bbool\b/g,"Boolean"),i=i.replace(/(^|,\s*)nil(?:,\s*nil)+(?=,|\]|$)/g,"$1nil"),i=i.replace(/Hash\[untyped,\s*untyped\]/g,"Hash"),i}get parameters(){return[...this.positionalParameters,...this.keywordParameters,this.positionalSplatParameter,this.keywordSplatParameter,this.yieldParameter].flatMap(e=>e!==void 0?e:[])}};c();m();d();var ae=class l extends S{constructor({name:e,namespace:i,typeParameters:s,docstring:f,statements:u}){super();y(this,"name");y(this,"namespace");y(this,"typeParameters");y(this,"docstring");y(this,"statements");this.name=e,this.namespace=i??new Set,this.typeParameters=s??[],this.docstring=f,this.statements=u??[],this.populateChildNamespaces()}addStatement(e){this.statements.push(e)}write(e){this.docstring&&new X({docs:this.docstring}).write(e),e.write(`module ${this.name}`),this.statements.length?(e.newLine(),e.indent(),this.statements.forEach((i,s)=>{i.write(e),s<this.statements.length-1&&e.newLine()}),e.dedent(),e.write("end")):e.write("; end"),e.newLine()}writeTypeDefinition(e){e.write(`module ${this.name}`),this.typeParameters.length&&(e.write("["),e.delimit({nodes:this.typeParameters,delimiter:", ",writeFunction:i=>i.writeTypeDefinition(e)}),e.write("]")),e.newLine(),this.statements.length&&(e.indent(),this.statements.forEach(i=>{i.writeTypeDefinition(e),e.newLine()}),e.dedent()),e.write("end")}populateChildNamespaces(){this.statements.filter(e=>e instanceof l||e instanceof ue).forEach(e=>{e.namespace=new Set([...this.namespace,this]),e.populateChildNamespaces()})}get fullyQualifiedNamespace(){return[...this.namespace,this].map(e=>e.name).join("::")}};var ue=class extends ae{constructor({name:e,superclass:i,typeParameters:s,docstring:f,statements:u}){super({name:e,docstring:f,typeParameters:s});y(this,"superclass");y(this,"statements");y(this,"methods",[]);this.superclass=i,this.statements=u??[]}addStatement(e){this.statements.push(e)}addStatements(e){this.statements.push(...e)}addInstanceMethod(e,i,s){let f=new se({name:e,kind:oe.Instance,returnType:i,statements:s});this.addMethod(f)}addMethod(e){this.methods.push(e)}addMethods(e){e.forEach(i=>this.addMethod(i))}write(e){if(this.docstring&&new X({docs:this.docstring}).write(e),e.write(`class ${this.name}`),this.superclass&&(e.write(" < "),this.superclass.write(e)),!this.hasBody()){e.writeLine("; end");return}this.statements.length&&(e.newLine(),e.indent(),this.statements.forEach((i,s)=>{i.write(e),e.newLine()}),e.dedent()),this.methods.length&&(e.newLine(),e.indent(),this.methods.forEach(i=>{i.write(e)}),e.dedent()),e.writeLine("end")}hasBody(){return this.statements.length>0||this.methods.length>0}writeTypeDefinition(e){e.write(`class ${this.name}`),this.typeParameters.length&&(e.write("["),e.delimit({nodes:this.typeParameters,delimiter:", ",writeFunction:i=>i.writeTypeDefinition(e)}),e.write("]")),this.superclass&&(e.write(" < "),this.superclass.write(e)),e.newLine(),this.statements.length&&(e.indent(),this.statements.forEach(i=>{i.writeTypeDefinition(e),e.newLine()}),e.dedent()),e.write("end")}};c();m();d();var he=class extends S{constructor({classReference:e,arguments_:i}){super();y(this,"classReference");y(this,"arguments_");this.classReference=e,this.arguments_=i}write(e){e.writeNode(this.classReference),e.write("."),e.write("new"),e.write("("),this.arguments_.length>1?(e.indent(),e.newLine(),this.arguments_.forEach((i,s)=>{s>0&&(e.write(","),e.newLine()),i.write(e)}),e.newLine(),e.dedent()):this.arguments_.forEach((i,s)=>{s>0&&e.write(", "),i.write(e)}),e.write(")")}};c();m();d();var ye=class extends S{constructor(e){super();y(this,"arg");this.arg=e}write(e){return new J(this.arg).write(e)}};c();m();d();var ge=class extends S{constructor({name:e,value:i}){super();y(this,"name");y(this,"value");this.name=e,this.value=i}write(e){e.write(`${this.name}: `),this.value.write(e)}};c();m();d();c();m();d();var W=class extends S{constructor({name:e,type:i,optional:s,docs:f}){super();y(this,"name");y(this,"type");y(this,"optional");y(this,"docs");this.name=e,this.type=i??ie.untyped(),this.optional=s??!1,this.docs=f}};var xe=class extends W{constructor({name:e,type:i,initializer:s,optional:f}){super({name:e,type:i,optional:f});y(this,"initializer");this.initializer=s}write(e){e.write(`${this.name}:`),this.initializer&&(e.write(" "),e.writeNode(this.initializer))}writeTypeDefinition(e){this.optional&&e.write("?"),e.write(`${this.name}: `),this.type.writeTypeDefinition(e)}};c();m();d();var De=class extends W{constructor(){super(...arguments);y(this,"initializer")}write(e){e.write(`**${this.name}`)}writeTypeDefinition(e){e.write("**"),this.type.writeTypeDefinition(e)}};c();m();d();var we=class extends S{constructor({on:e,method:i,arguments_:s,keywordArguments:f,block:u}){super();y(this,"on");y(this,"method");y(this,"arguments_");y(this,"keywordArguments");y(this,"block");this.on=e,this.method=i,this.arguments_=s,this.keywordArguments=f,this.block=u}write(e){this.on.write(e),e.write("."),e.write(this.method),e.write("(");let i=[];for(let s of this.arguments_)i.push({kind:"positional",node:s});for(let s of this.keywordArguments||[])i.push({kind:"keyword",arg:s});if(i.length>1?(e.indent(),e.newLine(),i.forEach((s,f)=>{f>0&&(e.write(","),e.newLine()),Pn(e,s)}),e.newLine(),e.dedent()):i.forEach((s,f)=>{f>0&&e.write(", "),Pn(e,s)}),e.write(")"),this.block){let[s,f]=this.block;e.write(" do"),s.length>0&&(e.write(" |"),s.forEach((u,T)=>{T>0&&e.write(", "),e.write(u)}),e.write("|")),e.newLine(),e.indent();for(let u of f)u.write(e),e.writeNewLineIfLastLineNot();e.dedent(),e.write("end")}}};function Pn(l,r){switch(r.kind){case"positional":r.node.write(l);break;case"keyword":r.arg.write(l);break;default:L(r)}}c();m();d();var Oe=class extends S{constructor({value:e}){super();y(this,"value");this.value=e}write(e){this.value.write(e)}};c();m();d();var _e=class extends W{constructor({name:e,type:i,optional:s,initializer:f}){super({name:e,type:i,optional:s});y(this,"initializer");this.initializer=f}write(e){e.write(this.name),this.initializer&&e.write(` = ${this.initializer.write(e)}`)}writeTypeDefinition(e){this.optional&&e.write("?"),this.type.writeTypeDefinition(e)}};c();m();d();var je=class extends W{write(r){r.write(`*${this.name}`)}writeTypeDefinition(r){r.write("*"),this.type.writeTypeDefinition(r)}};c();m();d();var Ve=class l extends S{constructor(e){super();y(this,"internalType");this.internalType=e}static string(e){return new this({type:"str",value:e})}static integer(e){return new this({type:"int",value:e})}static float(e){return new this({type:"float",value:e})}static boolean(e){return new this({type:"bool",value:e})}static hash(e){return new this({type:"hash",entries:e})}static set(e){return new this({type:"set",values:e})}static list(e){return new this({type:"list",values:e})}static nop(){return new this({type:"nop"})}static nil(){return new this({type:"nil"})}static isNop(e){return e instanceof l&&e.internalType.type==="nop"}static isNil(e){return e instanceof l&&e.internalType.type==="nil"}write(e){switch(this.internalType.type){case"str":{this.internalType.value.includes("'")||this.internalType.value.includes("#")?e.write(`"${this.internalType.value.replaceAll('"','\\"')}"`):e.write(`'${this.internalType.value}'`);break}case"int":{e.write(this.internalType.value.toString());break}case"float":{e.write(this.internalType.value.toString());break}case"bool":{e.write(this.internalType.value?"true":"false");break}case"hash":{let i=this.internalType.entries.filter(s=>!l.isNop(s.key)&&!l.isNop(s.value));if(i.length===0){e.write("{}");break}e.write(`{
|
|
19
|
+
${this.buffer}`:this.buffer}stringifyRequires(){return Array.from(this.requires).map(t=>`require "${t}"`).join(`
|
|
20
|
+
`)}};var x={};Ct(x,{AstNode:()=>S,ClassInstantiation:()=>he,ClassReference:()=>ne,Class_:()=>ue,CodeBlock:()=>ye,KeywordArgument:()=>ge,KeywordParameter:()=>xe,Method:()=>se,MethodInvocation:()=>we,MethodKind:()=>oe,Module_:()=>ae,Parameter:()=>W,Type:()=>ie,TypeLiteral:()=>Ve,TypeParameter:()=>be,Writer:()=>Y,begin:()=>bo,classReference:()=>mo,class_:()=>uo,codeblock:()=>nt,comment:()=>fo,falseValue:()=>oo,ifElse:()=>wo,instantiateClass:()=>ho,invokeMethod:()=>go,keywordArgument:()=>yo,method:()=>po,module:()=>lo,nilValue:()=>so,parameters:()=>ao,positionalArgument:()=>xo,raise:()=>vo,trueValue:()=>io,typeParameter:()=>co,wrapInModules:()=>Ao});c();m();d();c();m();d();c();m();d();c();m();d();c();m();d();var S=class extends me{async toStringAsync({customConfig:t,formatter:e}={}){let i=new Ie({customConfig:t??{},formatter:e});return this.write(i),i.toStringAsync()}toString({customConfig:t,formatter:e}={}){let i=new Ie({customConfig:t??{},formatter:e});return this.write(i),i.toString()}typeDefinitionToString({customConfig:t,formatter:e}={}){let i=new Ie({customConfig:t??{},formatter:e});return this.writeTypeDefinition(i),i.toString()}writeTypeDefinition(t){}};var ro=120,no=2,X=class extends S{constructor({docs:e}){super();y(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
|
|
21
|
+
`).forEach(i=>{this.wrapLine(i,e).forEach(f=>{e.writeLine(`# ${f}`)})})}wrapLine(e,i){let s=i.currentIndentLevel*2,f=ro-s-no;if(e.length<=f)return[e];if(f<20)return[e];let u=e.split(/(\s+)/),T=[],w="";for(let k of u){if(k===""||w===""&&/^\s+$/.test(k))continue;let R=w+k;R.length<=f?w=R:(w.trim()!==""&&T.push(w.trimEnd()),w=k.trimStart(),w.length>f&&(T.push(w),w=""))}return w.trim()!==""&&T.push(w.trimEnd()),T.length===0?[e]:T}};c();m();d();c();m();d();c();m();d();var ne=class extends S{constructor({name:e,modules:i,fullyQualified:s}){super();y(this,"name");y(this,"modules");y(this,"fullyQualified");this.name=e,this.modules=i??[],this.fullyQualified=s??!1}write(e){if(this.fullyQualified||this.modules.length>0){let i=[...this.modules,this.name].join("::");e.write(i);return}e.write(this.name)}};var ie=class l extends S{constructor(e){super();y(this,"internalType");this.internalType=e}write(e){if(this.internalType)switch(this.internalType?.type){case"integer":e.write("Integer");return;case"string":e.write("String");return;case"class":e.writeNode(this.internalType.reference);return;case"instance":break;case"boolean":e.write("Internal::Types::Boolean");return;case"nil":break;case"top":break;case"bot":break;case"void":break;case"boolish":break;case"union":if(this.internalType.elems.length===2&&this.internalType.elems[1]?.internalType?.type==="nil"){let i=this.internalType.elems[0];i?.write(e)}break;case"intersection":break;case"array":e.write("Internal::Types::Array["),this.internalType.elem.write(e),e.write("]");return;case"hash":e.write("Internal::Types::Hash["),this.internalType.keyType.write(e),e.write(", "),this.internalType.valueType.write(e),e.write("]");return;case"object":e.write("Object");break;case"singleton":break;case"generic":break;case"self":break;case"tuple":break;default:L(this.internalType)}}writeTypeDefinition(e){if(this.internalType)switch(this.internalType.type){case"self":e.write("self");break;case"class":e.write(this.internalType.reference.toString(e));break;case"instance":e.write("instance");break;case"boolean":e.write("bool");break;case"nil":e.write("nil");break;case"top":e.write("top");break;case"bot":e.write("bot");break;case"void":e.write("void");break;case"boolish":e.write("boolish");break;case"string":e.write("String");break;case"integer":e.write("Integer");break;case"union":e.delimit({nodes:this.internalType.elems,delimiter:" | ",writeFunction:i=>i.writeTypeDefinition(e)});break;case"intersection":e.delimit({nodes:this.internalType.elems,delimiter:" & ",writeFunction:i=>i.writeTypeDefinition(e)});break;case"array":e.write("Array["),this.internalType.elem.writeTypeDefinition(e),e.write("]");break;case"hash":e.write("Hash["),this.internalType.keyType.writeTypeDefinition(e),e.write(", "),this.internalType.valueType.writeTypeDefinition(e),e.write("]");break;case"object":e.write(this.internalType.klass);break;case"singleton":e.write("singleton("),e.write(this.internalType.klass),e.write(")");break;case"tuple":e.write("["),e.delimit({nodes:this.internalType.elems,delimiter:", ",writeFunction:i=>i.write(e)}),e.write("]");break;case"generic":e.write(`${this.internalType.baseKlass}[`),e.delimit({nodes:this.internalType.parameters,delimiter:", ",writeFunction:i=>i.writeTypeDefinition(e)}),e.write("]");break;default:L(this.internalType)}else e.write("untyped")}static untyped(){return new this(void 0)}static self(){return new this({type:"self"})}static class_(e){return new this({type:"class",reference:new ne({name:e.name,modules:e.modules,fullyQualified:!0})})}static instance(){return new this({type:"instance"})}static boolean(){return new this({type:"boolean"})}static nil(){return new this({type:"nil"})}static top(){return new this({type:"top"})}static bot(){return new this({type:"bot"})}static void(){return new this({type:"void"})}static boolish(){return new this({type:"boolish"})}static string(){return new this({type:"string"})}static integer(){return new this({type:"integer"})}static union(e){return new this({type:"union",elems:e})}static intersection(e){return new this({type:"intersection",elems:e})}static array(e){return new this({type:"array",elem:e})}static hash(e,i){return new this({type:"hash",keyType:e,valueType:i})}static object(e){return new this({type:"object",klass:e})}static singleton(e){return new this({type:"singleton",klass:e})}static tuple(e){return new this({type:"tuple",elems:e})}static generic(e,i){return new this({type:"generic",baseKlass:e,parameters:i})}static nilable(e){return l.union([e,l.nil()])}nilable(){return l.nilable(this)}};var oe={Instance:"instance",Class_:"class"},Fn={Public:"public",Private:"private",Protected:"protected"},se=class extends S{constructor({name:e,docstring:i,kind:s,visibility:f,parameters:u,returnType:T,statements:w,splatOptionDocs:k}){super();y(this,"name");y(this,"docstring");y(this,"kind");y(this,"positionalParameters");y(this,"keywordParameters");y(this,"positionalSplatParameter");y(this,"keywordSplatParameter");y(this,"yieldParameter");y(this,"visibility");y(this,"statements");y(this,"returnType");y(this,"splatOptionDocs");this.name=e,this.docstring=i,this.kind=s??oe.Instance,this.visibility=f??Fn.Public,this.positionalParameters=u?.positional??[],this.keywordParameters=u?.keyword??[],this.positionalSplatParameter=u?.positionalSplat,this.keywordSplatParameter=u?.keywordSplat,this.yieldParameter=u?.yield,this.returnType=T??ie.untyped(),this.statements=w??[],this.splatOptionDocs=k??[]}addStatement(e){this.statements.push(e)}write(e){this.docstring&&new X({docs:this.docstring}).write(e);let i=this.positionalParameters.length>0||this.keywordParameters.length>0||this.keywordSplatParameter!=null;this.docstring&&i&&e.writeLine("#");for(let s of this.positionalParameters){e.write(`# @option ${s.name} [`);let f=new Y({customConfig:e.customConfig});s.type.writeTypeDefinition(f),e.write(this.normalizeForYard(f.toString())),e.write("]"),e.newLine()}for(let s of this.keywordParameters){e.write(`# @param ${s.name} [`);let f=new Y({customConfig:e.customConfig});s.type.writeTypeDefinition(f),e.write(this.normalizeForYard(f.toString())),e.write("]"),s.docs&&e.write(` ${s.docs}`),e.newLine()}if(this.keywordSplatParameter!=null){e.write(`# @param ${this.keywordSplatParameter.name} [`);let s=new Y({customConfig:e.customConfig});this.keywordSplatParameter.type.writeTypeDefinition(s),e.write(this.normalizeForYard(s.toString())),e.write("]"),this.keywordSplatParameter.docs&&e.write(` ${this.keywordSplatParameter.docs}`),e.newLine()}for(let s of this.splatOptionDocs)e.writeLine(`# ${s}`);if(this.returnType!=null){(i||this.docstring)&&e.writeLine("#"),e.write("# @return [");let s=new Y({customConfig:e.customConfig});this.returnType.writeTypeDefinition(s),e.write(this.normalizeForYard(s.toString())),e.write("]"),e.newLine()}switch(this.visibility!==Fn.Public&&(e.write(this.visibility),this.kind===oe.Class_&&e.write("_class_method"),e.write(" ")),this.kind){case oe.Instance:e.write(`def ${this.name}`);break;case oe.Class_:e.write(`def self.${this.name}`);break}this.parameters.length&&(e.write("("),e.delimit({nodes:this.parameters,delimiter:", ",writeFunction:s=>s.write(e)}),e.write(")")),this.statements.length?(e.newLine(),e.indent(),this.statements.forEach((s,f)=>{s.write(e),f<this.statements.length-1&&e.newLine()}),e.writeNewLineIfLastLineNot(),e.dedent(),e.write("end")):e.write("; end"),e.newLine()}writeTypeDefinition(e){e.write(`def ${this.name}: (`),this.parameters.forEach((i,s)=>{i.writeTypeDefinition(e),s<this.parameters.length-1&&e.write(", ")}),e.write(") -> "),this.returnType.writeTypeDefinition(e)}normalizeForYard(e){let i=e.replace(/\s*\|\s*/g,", ");return i=i.replace(/\bbool\b/g,"Boolean"),i=i.replace(/(^|,\s*)nil(?:,\s*nil)+(?=,|\]|$)/g,"$1nil"),i=i.replace(/Hash\[untyped,\s*untyped\]/g,"Hash"),i}get parameters(){return[...this.positionalParameters,...this.keywordParameters,this.positionalSplatParameter,this.keywordSplatParameter,this.yieldParameter].flatMap(e=>e!==void 0?e:[])}};c();m();d();var ae=class l extends S{constructor({name:e,namespace:i,typeParameters:s,docstring:f,statements:u}){super();y(this,"name");y(this,"namespace");y(this,"typeParameters");y(this,"docstring");y(this,"statements");this.name=e,this.namespace=i??new Set,this.typeParameters=s??[],this.docstring=f,this.statements=u??[],this.populateChildNamespaces()}addStatement(e){this.statements.push(e)}write(e){this.docstring&&new X({docs:this.docstring}).write(e),e.write(`module ${this.name}`),this.statements.length?(e.newLine(),e.indent(),this.statements.forEach((i,s)=>{i.write(e),s<this.statements.length-1&&e.newLine()}),e.dedent(),e.write("end")):e.write("; end"),e.newLine()}writeTypeDefinition(e){e.write(`module ${this.name}`),this.typeParameters.length&&(e.write("["),e.delimit({nodes:this.typeParameters,delimiter:", ",writeFunction:i=>i.writeTypeDefinition(e)}),e.write("]")),e.newLine(),this.statements.length&&(e.indent(),this.statements.forEach(i=>{i.writeTypeDefinition(e),e.newLine()}),e.dedent()),e.write("end")}populateChildNamespaces(){this.statements.filter(e=>e instanceof l||e instanceof ue).forEach(e=>{e.namespace=new Set([...this.namespace,this]),e.populateChildNamespaces()})}get fullyQualifiedNamespace(){return[...this.namespace,this].map(e=>e.name).join("::")}};var ue=class extends ae{constructor({name:e,superclass:i,typeParameters:s,docstring:f,statements:u}){super({name:e,docstring:f,typeParameters:s});y(this,"superclass");y(this,"statements");y(this,"methods",[]);this.superclass=i,this.statements=u??[]}addStatement(e){this.statements.push(e)}addStatements(e){this.statements.push(...e)}addInstanceMethod(e,i,s){let f=new se({name:e,kind:oe.Instance,returnType:i,statements:s});this.addMethod(f)}addMethod(e){this.methods.push(e)}addMethods(e){e.forEach(i=>this.addMethod(i))}write(e){if(this.docstring&&new X({docs:this.docstring}).write(e),e.write(`class ${this.name}`),this.superclass&&(e.write(" < "),this.superclass.write(e)),!this.hasBody()){e.writeLine("; end");return}this.statements.length&&(e.newLine(),e.indent(),this.statements.forEach((i,s)=>{i.write(e),e.newLine()}),e.dedent()),this.methods.length&&(e.newLine(),e.indent(),this.methods.forEach(i=>{i.write(e)}),e.dedent()),e.writeLine("end")}hasBody(){return this.statements.length>0||this.methods.length>0}writeTypeDefinition(e){e.write(`class ${this.name}`),this.typeParameters.length&&(e.write("["),e.delimit({nodes:this.typeParameters,delimiter:", ",writeFunction:i=>i.writeTypeDefinition(e)}),e.write("]")),this.superclass&&(e.write(" < "),this.superclass.write(e)),e.newLine(),this.statements.length&&(e.indent(),this.statements.forEach(i=>{i.writeTypeDefinition(e),e.newLine()}),e.dedent()),e.write("end")}};c();m();d();var he=class extends S{constructor({classReference:e,arguments_:i}){super();y(this,"classReference");y(this,"arguments_");this.classReference=e,this.arguments_=i}write(e){e.writeNode(this.classReference),e.write("."),e.write("new"),e.write("("),this.arguments_.length>1?(e.indent(),e.newLine(),this.arguments_.forEach((i,s)=>{s>0&&(e.write(","),e.newLine()),i.write(e)}),e.newLine(),e.dedent()):this.arguments_.forEach((i,s)=>{s>0&&e.write(", "),i.write(e)}),e.write(")")}};c();m();d();var ye=class extends S{constructor(e){super();y(this,"arg");this.arg=e}write(e){return new J(this.arg).write(e)}};c();m();d();var ge=class extends S{constructor({name:e,value:i}){super();y(this,"name");y(this,"value");this.name=e,this.value=i}write(e){e.write(`${this.name}: `),this.value.write(e)}};c();m();d();c();m();d();var W=class extends S{constructor({name:e,type:i,optional:s,docs:f}){super();y(this,"name");y(this,"type");y(this,"optional");y(this,"docs");this.name=e,this.type=i??ie.untyped(),this.optional=s??!1,this.docs=f}};var xe=class extends W{constructor({name:e,type:i,initializer:s,optional:f}){super({name:e,type:i,optional:f});y(this,"initializer");this.initializer=s}write(e){e.write(`${this.name}:`),this.initializer&&(e.write(" "),e.writeNode(this.initializer))}writeTypeDefinition(e){this.optional&&e.write("?"),e.write(`${this.name}: `),this.type.writeTypeDefinition(e)}};c();m();d();var De=class extends W{constructor(){super(...arguments);y(this,"initializer")}write(e){e.write(`**${this.name}`)}writeTypeDefinition(e){e.write("**"),this.type.writeTypeDefinition(e)}};c();m();d();var we=class extends S{constructor({on:e,method:i,arguments_:s,keywordArguments:f,block:u}){super();y(this,"on");y(this,"method");y(this,"arguments_");y(this,"keywordArguments");y(this,"block");this.on=e,this.method=i,this.arguments_=s,this.keywordArguments=f,this.block=u}write(e){this.on.write(e),e.write("."),e.write(this.method),e.write("(");let i=[];for(let s of this.arguments_)i.push({kind:"positional",node:s});for(let s of this.keywordArguments||[])i.push({kind:"keyword",arg:s});if(i.length>1?(e.indent(),e.newLine(),i.forEach((s,f)=>{f>0&&(e.write(","),e.newLine()),Pn(e,s)}),e.newLine(),e.dedent()):i.forEach((s,f)=>{f>0&&e.write(", "),Pn(e,s)}),e.write(")"),this.block){let[s,f]=this.block;e.write(" do"),s.length>0&&(e.write(" |"),s.forEach((u,T)=>{T>0&&e.write(", "),e.write(u)}),e.write("|")),e.newLine(),e.indent();for(let u of f)u.write(e),e.writeNewLineIfLastLineNot();e.dedent(),e.write("end")}}};function Pn(l,t){switch(t.kind){case"positional":t.node.write(l);break;case"keyword":t.arg.write(l);break;default:L(t)}}c();m();d();var Oe=class extends S{constructor({value:e}){super();y(this,"value");this.value=e}write(e){this.value.write(e)}};c();m();d();var _e=class extends W{constructor({name:e,type:i,optional:s,initializer:f}){super({name:e,type:i,optional:s});y(this,"initializer");this.initializer=f}write(e){e.write(this.name),this.initializer&&e.write(` = ${this.initializer.write(e)}`)}writeTypeDefinition(e){this.optional&&e.write("?"),this.type.writeTypeDefinition(e)}};c();m();d();var je=class extends W{write(t){t.write(`*${this.name}`)}writeTypeDefinition(t){t.write("*"),this.type.writeTypeDefinition(t)}};c();m();d();var Ve=class l extends S{constructor(e){super();y(this,"internalType");this.internalType=e}static string(e){return new this({type:"str",value:e})}static integer(e){return new this({type:"int",value:e})}static float(e){return new this({type:"float",value:e})}static boolean(e){return new this({type:"bool",value:e})}static hash(e){return new this({type:"hash",entries:e})}static set(e){return new this({type:"set",values:e})}static list(e){return new this({type:"list",values:e})}static nop(){return new this({type:"nop"})}static nil(){return new this({type:"nil"})}static isNop(e){return e instanceof l&&e.internalType.type==="nop"}static isNil(e){return e instanceof l&&e.internalType.type==="nil"}write(e){switch(this.internalType.type){case"str":{this.internalType.value.includes("'")||this.internalType.value.includes("#")?e.write(`"${this.internalType.value.replaceAll('"','\\"')}"`):e.write(`'${this.internalType.value}'`);break}case"int":{e.write(this.internalType.value.toString());break}case"float":{e.write(this.internalType.value.toString());break}case"bool":{e.write(this.internalType.value?"true":"false");break}case"hash":{let i=this.internalType.entries.filter(s=>!l.isNop(s.key)&&!l.isNop(s.value));if(i.length===0){e.write("{}");break}e.write(`{
|
|
22
22
|
`),i.forEach((s,f)=>{f>0&&e.writeLine(","),e.indent();let u=!1;if(s.key instanceof l&&s.key.internalType.type==="str"){let T=s.key.internalType.value;/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(T)&&(e.write(`${T}:`),u=!0)}u||(s.key.write(e),e.write(" =>")),e.write(" "),s.value.write(e),e.dedent()}),e.write(`
|
|
23
|
-
}`);break}case"set":{let i=this.internalType.values.filter(s=>!l.isNop(s));if(i.length===0){e.write("Set.new([])");break}e.write("Set.new(["),i.forEach((s,f)=>{f>0&&e.write(", "),s.write(e)}),e.write("])");break}case"list":{let i=this.internalType.values.filter(s=>!l.isNop(s));if(i.length===0){e.write("[]");break}e.write("["),i.forEach((s,f)=>{f>0&&e.write(", "),s.write(e)}),e.write("]");break}case"nop":break;case"nil":e.write("nil");break;default:L(this.internalType)}}};c();m();d();var Ze;(function(l){l[l.Invariant=0]="Invariant",l.Covariant="out",l.Contravariant="in"})(Ze||(Ze={}));var be=class extends S{constructor({name:e,unchecked:i,bound:s,variance:f,defaultType:u}){super();y(this,"name");y(this,"unchecked");y(this,"bound");y(this,"variance");y(this,"defaultType");this.name=e,this.unchecked=i??!1,this.bound=s,this.variance=f??Ze.Invariant,this.defaultType=u}write(e){}writeTypeDefinition(e){this.unchecked&&e.write("unchecked "),this.variance!=Ze.Invariant&&e.write(`${this.variance} `),e.write(this.name),this.bound&&(e.write(" < "),this.bound.writeTypeDefinition(e)),this.defaultType&&(e.write(" = "),this.defaultType.writeTypeDefinition(e))}};c();m();d();var qe=class extends W{constructor(){super(...arguments);y(this,"initializer")}write(e){e.write(`&${this.name}`)}};c();m();d();var et=class extends S{constructor({body:e,rescues:i}){super();y(this,"body");y(this,"rescues");this.body=e,this.rescues=i}write(e){e.write("begin"),e.writeLine(),this.body&&(e.indent(),this.body.write(e),e.writeNewLineIfLastLineNot(),e.dedent());for(let{errorClass:i,errorVariable:s,body:f}of this.rescues)e.write("rescue"),i&&(e.write(" "),i.write(e)),s&&(e.write(" => "),e.write(s)),e.writeLine(),f&&(e.indent(),f.write(e),e.writeNewLineIfLastLineNot(),e.dedent());e.write("end")}};c();m();d();var tt=class extends S{constructor({if:e,elseIf:i,elseBody:s}){super();y(this,"ifBranch");y(this,"elseIfs");y(this,"elseBody");this.ifBranch=e,this.elseIfs=i??[],this.elseBody=s?Array.isArray(s)?s:[s]:void 0}write(e){e.write("if "),this.ifBranch.condition.write(e),e.writeLine(),e.indent();for(let i of this.ifBranch.thenBody)i.write(e),e.writeNewLineIfLastLineNot();e.dedent();for(let i of this.elseIfs){e.write("elsif "),i.condition.write(e),e.writeLine(),e.indent();for(let s of i.thenBody)s.write(e),e.writeNewLineIfLastLineNot();e.dedent()}if(this.elseBody&&this.elseBody.length>0){e.writeLine("else"),e.indent();for(let i of this.elseBody)i.write(e),e.writeNewLineIfLastLineNot();e.dedent()}e.write("end"),e.writeNewLineIfLastLineNot()}};c();m();d();var rt=class extends S{constructor({errorClass:e,message:i}){super();y(this,"errorClass");y(this,"message");this.errorClass=e,this.message=i}write(e){e.write("raise"),this.errorClass&&(e.write(" "),this.errorClass.write(e)),this.message&&(this.errorClass&&e.write(", "),this.message.write(e))}};function nt(l){return new ye(l)}function io(){return nt("true")}function oo(){return nt("false")}function so(){return nt("nil")}var ao={positional(l){return new _e(l)},keyword(l){return new xe(l)},positionalSplat(l){return new je(l)},keywordSplat(l){return new De(l)},yield(l){return new qe(l)}};function uo(l){return new ue(l)}function lo(l){return new ae(l)}function po(l){return new se(l)}function fo(l){return new X(l)}function co(l){return new be(l)}function mo(l){return new ne(l)}function ho(l){return new he(l)}function yo(l){return new ge(l)}function go(l){return new we(l)}function xo(l){return new Oe(l)}function wo(l){return new tt(l)}function bo(l){return new et(l)}function vo(l){return new rt(l)}function Ao(l,r){let e=l;for(let i of r.toReversed())i.addStatement(e),e=i;return e}c();m();d();var it=class l{constructor({context:r}){y(this,"context");this.context=r}convert(r){if(r.value===null)return this.context.isNullable(r.typeReference)?x.TypeLiteral.nil():(this.context.errors.add({severity:N.Critical,message:"Expected non-null value, but got null"}),x.TypeLiteral.nop());if(r.value===void 0)return x.TypeLiteral.nop();switch(r.typeReference.type){case"list":return this.convertList({list:r.typeReference.value,value:r.value});case"literal":return this.convertLiteral({literalType:r.typeReference.value,value:r.value});case"map":return this.convertMap({map:r.typeReference,value:r.value});case"named":{let e=this.context.resolveNamedType({typeId:r.typeReference.value});return e==null?x.TypeLiteral.nop():this.convertNamed({named:e,value:r.value,as:r.as})}case"optional":return this.convert({typeReference:r.typeReference.value,value:r.value,as:r.as});case"nullable":return this.convert({typeReference:r.typeReference.value,value:r.value,as:r.as});case"primitive":return this.convertPrimitive({primitive:r.typeReference.value,value:r.value,as:r.as});case"set":return this.convertSet({set:r.typeReference.value,value:r.value});case"unknown":return x.TypeLiteral.nop();default:L(r.typeReference)}}convertLiteral({literalType:r,value:e}){switch(r.type){case"boolean":{let i=this.context.getValueAsBoolean({value:e});return i==null?x.TypeLiteral.nop():x.TypeLiteral.boolean(i)}case"string":{let i=this.context.getValueAsString({value:e});return i==null?x.TypeLiteral.nop():x.TypeLiteral.string(i)}default:L(r)}}convertList({list:r,value:e}){return Array.isArray(e)?x.TypeLiteral.list(e.map((i,s)=>{this.context.errors.scope({index:s});try{return this.convert({typeReference:r,value:i})}finally{this.context.errors.unscope()}})):(this.context.errors.add({severity:N.Critical,message:`Expected array but got: ${typeof e}`}),x.TypeLiteral.nop())}convertSet({set:r,value:e}){return Array.isArray(e)?x.TypeLiteral.set(e.map((i,s)=>{this.context.errors.scope({index:s});try{return this.convert({typeReference:r,value:i})}finally{this.context.errors.unscope()}})):(this.context.errors.add({severity:N.Critical,message:`Expected array but got: ${typeof e}`}),x.TypeLiteral.nop())}convertMap({map:r,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:N.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),x.TypeLiteral.nop()):x.TypeLiteral.hash(Object.entries(e).map(([i,s])=>{this.context.errors.scope(i);try{return{key:this.convert({typeReference:r.key,value:i,as:"key"}),value:this.convert({typeReference:r.value,value:s})}}finally{this.context.errors.unscope()}}))}convertNamed({named:r,value:e,as:i}){switch(r.type){case"alias":return this.convert({typeReference:r.typeReference,value:e,as:i});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:r,value:e});case"object":return this.convertObject({object:r,value:e});case"enum":return this.convertEnum({enum_:r,value:e});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:r,value:e});default:L(r)}}convertDiscriminatedUnion({discriminatedUnion:r,value:e}){let i=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:r,value:e});if(i==null)return x.TypeLiteral.nop();let s=i.singleDiscriminatedUnionType,f=this.convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:i,unionVariant:s});return f==null?x.TypeLiteral.nop():x.TypeLiteral.hash(f)}convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:r,unionVariant:e}){switch(e.type){case"samePropertiesAsObject":{let i=this.context.resolveNamedType({typeId:e.typeId});if(i==null)return;let s=this.convertNamed({named:i,value:r.value});return this.extractHashEntries(s)}case"singleProperty":try{this.context.errors.scope(e.discriminantValue.wireValue);let i=this.context.getRecord(r.value);return i==null?[{key:x.TypeLiteral.string(this.context.getPropertyName(e.discriminantValue.name)),value:this.convert({typeReference:e.typeReference,value:r.value})}]:[{key:x.TypeLiteral.string(this.context.getPropertyName(e.discriminantValue.name)),value:this.convert({typeReference:e.typeReference,value:i[e.discriminantValue.wireValue]})}]}finally{this.context.errors.unscope()}case"noProperties":return[];default:L(e)}}extractHashEntries(r){r instanceof x.TypeLiteral}convertEnum({enum_:r,value:e}){let i=this.getEnumValueName({enum_:r,value:e});return i==null?x.TypeLiteral.nop():x.TypeLiteral.string(i)}getEnumValueName({enum_:r,value:e}){if(typeof e!="string"){this.context.errors.add({severity:N.Critical,message:`Expected enum value string, got: ${typeof e}`});return}let i=r.values.find(s=>s.wireValue===e);if(i==null){this.context.errors.add({severity:N.Critical,message:`An enum value named "${e}" does not exist in this context`});return}return i.wireValue}convertUndiscriminatedUnion({undiscriminatedUnion:r,value:e}){let i=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:r,value:e});return i??x.TypeLiteral.nop()}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:r,value:e}){for(let i of r.types){let s=this.context.clone(),u=new l({context:s}).convert({typeReference:i,value:e});if(s.errors.empty())return u}this.context.errors.add({severity:N.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof e}" value`})}convertPrimitive({primitive:r,value:e,as:i}){switch(r){case"INTEGER":case"LONG":case"UINT":case"UINT_64":{let s=this.getValueAsNumber({value:e,as:i});return s==null?x.TypeLiteral.nop():x.TypeLiteral.integer(s)}case"FLOAT":case"DOUBLE":{let s=this.getValueAsNumber({value:e});return s==null?x.TypeLiteral.nop():x.TypeLiteral.float(s)}case"BOOLEAN":{let s=this.getValueAsBoolean({value:e,as:i});return s==null?x.TypeLiteral.nop():x.TypeLiteral.boolean(s)}case"BASE_64":case"BIG_INTEGER":case"STRING":{let s=this.context.getValueAsString({value:e});return s==null?x.TypeLiteral.nop():x.TypeLiteral.string(s)}case"UUID":{let s=this.context.getValueAsString({value:e});return s==null?x.TypeLiteral.nop():x.TypeLiteral.string(s)}case"DATE":{let s=this.context.getValueAsString({value:e});return s==null?x.TypeLiteral.nop():x.TypeLiteral.string(s)}case"DATE_TIME":{let s=this.context.getValueAsString({value:e});return s==null?x.TypeLiteral.nop():x.TypeLiteral.string(s)}default:L(r)}}convertObject({object:r,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:N.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),x.TypeLiteral.nop()):x.TypeLiteral.hash(Object.entries(e).map(([i,s])=>{this.context.errors.scope(i);let f=r.properties.find(k=>k.name.wireValue===i),u=f?.typeReference??{type:"unknown"},T=f?.name.name.snakeCase.safeName??i,w={key:x.TypeLiteral.string(T),value:this.convert({typeReference:u,value:s})};return this.context.errors.unscope(),w}))}getValueAsNumber({value:r,as:e}){let i=e==="key"&&typeof r=="string"?Number(r):r;return this.context.getValueAsNumber({value:i})}getValueAsBoolean({value:r,as:e}){let i=e==="key"?typeof r=="string"?r==="true":!!r:r;return this.context.getValueAsBoolean({value:i})}};var ot=class l extends $e{constructor({ir:e,config:i}){super({ir:e,config:i});y(this,"ir");y(this,"customConfig");y(this,"dynamicTypeLiteralMapper");this.ir=e,this.customConfig=i.customConfig!=null?i.customConfig:void 0,this.dynamicTypeLiteralMapper=new it({context:this})}clone(){return new l({ir:this.ir,config:this.config})}getRootClientClassReference(){return x.classReference({name:this.getRootClientClassName(),modules:[this.getRootModuleName()]})}getRootClientClassName(){return"Client"}getRootModuleName(){return ht(this.customConfig?.module??this.customConfig?.clientModuleName??this.config.organization)}isSingleEnvironmentID(e){return typeof e=="string"}isMultiEnvironmentValues(e){return typeof e=="object"}getEnvironmentTypeReferenceFromID(e){let i=this.resolveEnvironmentName(e);if(i!=null)return x.codeblock(s=>{s.writeNode(this.getEnvironmentClassReference()),s.write("::"),s.write(this.getEnumName(i))})}getEnvironmentClassReference(){return x.classReference({name:"Environment",modules:[this.getRootModuleName()]})}getEnumName(e){return this.getName(e.screamingSnakeCase.safeName)}getMethodName(e){return this.getName(e.snakeCase.safeName)}getPropertyName(e){return this.getName(e.snakeCase.safeName)}getName(e){return e}};c();m();d();var Un="client",To="@client",st=class{constructor({context:r,formatter:e}){y(this,"context");y(this,"formatter");this.context=r,this.formatter=e}async generateSnippet({endpoint:r,request:e}){return await this.buildCodeBlock({endpoint:r,snippet:e}).toStringAsync({customConfig:this.context.customConfig??{},formatter:this.formatter})}generateSnippetSync({endpoint:r,request:e}){return this.buildCodeBlock({endpoint:r,snippet:e}).toString({customConfig:this.context.customConfig??{},formatter:this.formatter})}async generateSnippetAst({endpoint:r,request:e,options:i}){return i?.skipClientInstantiation?this.buildCodeBlockWithoutClient({endpoint:r,snippet:e}):this.buildCodeBlock({endpoint:r,snippet:e})}buildCodeBlock({endpoint:r,snippet:e}){return x.codeblock(i=>{i.writeNodeStatement(this.constructClient({endpoint:r,snippet:e})),i.newLine(),i.writeNodeStatement(this.callMethod({endpoint:r,snippet:e}))})}buildCodeBlockWithoutClient({endpoint:r,snippet:e}){return x.codeblock(i=>{i.writeNodeStatement(this.callMethodOnExistingClient({endpoint:r,snippet:e}))})}constructClient({endpoint:r,snippet:e}){return x.codeblock(i=>{i.addRequire(this.context.getRootModuleName().toLowerCase());let s=this.context.getRootClientClassReference(),f=this.getRootClientBuilderArgs({endpoint:r,snippet:e});i.write(`${Un} = `),i.writeNode(x.instantiateClass({classReference:s,arguments_:f}))})}getRootClientBaseUrlArg({baseUrl:r,environment:e}){if(r!=null&&e!=null)return this.context.errors.add({severity:"CRITICAL",message:"Cannot specify both baseUrl and environment options"}),[];if(r!=null)return[x.keywordArgument({name:"base_url",value:x.TypeLiteral.string(r)})];if(e!=null){if(this.context.isSingleEnvironmentID(e)){let i=this.context.getEnvironmentTypeReferenceFromID(e);return i==null?(this.context.errors.add({severity:"CRITICAL",message:`Environment ID ${e} not found`}),[]):[x.keywordArgument({name:"environment",value:i})]}if(this.context.isMultiEnvironmentValues(e))return this.context.errors.add({severity:"CRITICAL",message:"Multi-environment values are not supported in Ruby snippets yet"}),[]}return[]}getRootClientAuthArgs({auth:r,values:e}){if(e.type!==r.type)return this.addError(this.context.newAuthMismatchError({auth:r,values:e}).message),[];switch(r.type){case"basic":return e.type==="basic"?this.getRootClientBasicAuthArgs({auth:r,values:e}):[];case"bearer":return e.type==="bearer"?this.getRootClientBearerAuthArgs({auth:r,values:e}):[];case"header":return e.type==="header"?this.getRootClientHeaderAuthArgs({auth:r,values:e}):[];case"oauth":return e.type==="oauth"?this.getRootClientOAuthArgs({auth:r,values:e}):[];case"inferred":return[];default:L(r)}}addError(r){this.context.errors.add({severity:N.Critical,message:r})}addWarning(r){this.context.errors.add({severity:N.Warning,message:r})}getRootClientBasicAuthArgs({auth:r,values:e}){return[x.keywordArgument({name:r.username.snakeCase.safeName,value:x.TypeLiteral.string(e.username)}),x.keywordArgument({name:r.password.snakeCase.safeName,value:x.TypeLiteral.string(e.password)})]}getRootClientBearerAuthArgs({auth:r,values:e}){return[x.keywordArgument({name:r.token.snakeCase.safeName,value:x.TypeLiteral.string(e.token)})]}getRootClientHeaderAuthArgs({auth:r,values:e}){return[x.keywordArgument({name:r.header.name.name.snakeCase.safeName,value:x.TypeLiteral.string(e.value)})]}getRootClientOAuthArgs({auth:r,values:e}){return[x.keywordArgument({name:r.clientId.snakeCase.safeName,value:x.TypeLiteral.string(e.clientId)}),x.keywordArgument({name:r.clientSecret.snakeCase.safeName,value:x.TypeLiteral.string(e.clientSecret)})]}getRootClientHeaderArgs({headers:r,values:e}){let i=[];for(let s of r){let f=e[s.name.name.originalName];f!=null&&typeof f=="string"&&i.push(x.keywordArgument({name:s.name.name.snakeCase.safeName,value:x.TypeLiteral.string(f)}))}return i}getRootClientBuilderArgs({endpoint:r,snippet:e}){let i=[];r.auth!=null&&(e.auth!=null?i.push(...this.getRootClientAuthArgs({auth:r.auth,values:e.auth})):this.context.errors.add({severity:"WARNING",message:`Auth with ${r.auth.type} configuration is required for this endpoint`}));let s=this.getRootClientBaseUrlArg({baseUrl:e.baseURL,environment:e.environment});return s.length>0&&i.push(...s),this.context.errors.scope("Headers"),this.context.ir.headers!=null&&e.headers!=null&&i.push(...this.getRootClientHeaderArgs({headers:this.context.ir.headers,values:e.headers})),this.context.errors.unscope(),i}callMethod({endpoint:r,snippet:e}){let i={on:x.codeblock(Un),method:this.getMethod({endpoint:r}),arguments_:[]};switch(r.request.type){case"inlined":i.keywordArguments=this.getMethodArgsForInlinedRequest({request:r.request,snippet:e});break;case"body":i.keywordArguments=this.getMethodArgsForBodyRequest({request:r.request,snippet:e});break;default:L(r.request)}let s=this.getRequestOptions({endpoint:r,snippet:e});return s!=null&&(i.keywordArguments=i.keywordArguments??[],i.keywordArguments.push(s)),x.invokeMethod(i)}callMethodOnExistingClient({endpoint:r,snippet:e}){let i={on:x.codeblock(To),method:this.getMethod({endpoint:r}),arguments_:[]};switch(r.request.type){case"inlined":i.keywordArguments=this.getMethodArgsForInlinedRequest({request:r.request,snippet:e});break;case"body":i.keywordArguments=this.getMethodArgsForBodyRequest({request:r.request,snippet:e});break;default:L(r.request)}let s=this.getRequestOptions({endpoint:r,snippet:e});return s!=null&&(i.keywordArguments=i.keywordArguments??[],i.keywordArguments.push(s)),x.invokeMethod(i)}getRequestOptions({endpoint:r,snippet:e}){let i=e.headers??{},s=Object.entries(i);if(s.length===0)return;let f=new Set;if(this.context.ir.headers!=null)for(let w of this.context.ir.headers)f.add(w.name.wireValue.toLowerCase());if(r.request.type==="inlined"&&r.request.headers!=null)for(let w of r.request.headers)f.add(w.name.wireValue.toLowerCase());let u=s.filter(([w])=>!f.has(w.toLowerCase()));if(u.length===0)return;let T=u.map(([w,k])=>({key:x.TypeLiteral.string(w),value:x.TypeLiteral.string(String(k))}));return x.keywordArgument({name:"request_options",value:x.TypeLiteral.hash([{key:x.TypeLiteral.string("additional_headers"),value:x.TypeLiteral.hash(T)}])})}getMethodArgsForInlinedRequest({request:r,snippet:e}){let i=[];if(i.push(...this.getNamedParameterArgs({kind:"PathParameters",namedParameters:r.pathParameters,values:e.pathParameters})),i.push(...this.getNamedParameterArgs({kind:"QueryParameters",namedParameters:r.queryParameters,values:e.queryParameters})),i.push(...this.getNamedParameterArgs({kind:"Headers",namedParameters:r.headers,values:e.headers})),r.body!=null&&e.requestBody!=null)switch(r.body.type){case"properties":i.push(...this.getMethodArgsForPropertiesRequest({request:r.body,snippet:e}));break;case"referenced":{let s=r.body.bodyType;if(s.type==="typeReference"){let f=s.value;if(f.type==="named"){let u=this.context.resolveNamedType({typeId:f.value});if(u!=null&&u.type==="object"){let T=this.context.getRecord(e.requestBody);if(T!=null){let w=this.getBodyFieldsAsKeywordArgs({namedType:u,bodyRecord:T});i.push(...w)}}else if(u!=null){let T=this.getBodyArgsForNonObjectType({namedType:u,typeRef:f,bodyValue:e.requestBody});i.push(...T)}}else{let u=this.context.dynamicTypeLiteralMapper.convert({typeReference:f,value:e.requestBody});x.TypeLiteral.isNop(u)||i.push(x.keywordArgument({name:r.body.bodyKey.snakeCase.safeName,value:u}))}}break}case"fileUpload":break;default:L(r.body)}return i}getNamedParameterArgs({kind:r,namedParameters:e,values:i}){let s=[];if(this.context.errors.scope(r),e!=null){let f=this.context.associateByWireValue({parameters:e,values:i??{},ignoreMissingParameters:!0});for(let u of f){let T=this.context.dynamicTypeLiteralMapper.convert(u);x.TypeLiteral.isNop(T)||s.push(x.keywordArgument({name:this.context.getPropertyName(u.name.name),value:T}))}}return this.context.errors.unscope(),s}getMethodArgsForPropertiesRequest({request:r,snippet:e}){let i=[],s=this.context.associateByWireValue({parameters:r.value,values:this.context.getRecord(e.requestBody)??{}});for(let f of s){let u=this.context.dynamicTypeLiteralMapper.convert(f);x.TypeLiteral.isNop(u)||i.push(x.keywordArgument({name:this.context.getPropertyName(f.name.name),value:u}))}return i}getMethodArgsForBodyRequest({request:r,snippet:e}){let i=[];if(i.push(...this.getNamedParameterArgs({kind:"PathParameters",namedParameters:r.pathParameters,values:e.pathParameters})),r.body!=null&&e.requestBody!=null)switch(r.body.type){case"bytes":this.context.errors.add({severity:"CRITICAL",message:"Bytes request body is not supported in Ruby snippets yet"});break;case"typeReference":{let s=r.body.value;if(s.type==="named"){let f=this.context.resolveNamedType({typeId:s.value});if(f!=null&&f.type==="object"){let u=this.context.getRecord(e.requestBody);if(u!=null){let T=this.getBodyFieldsAsKeywordArgs({namedType:f,bodyRecord:u});i.push(...T)}}else if(f!=null){let u=this.getBodyArgsForNonObjectType({namedType:f,typeRef:s,bodyValue:e.requestBody});i.push(...u)}}else{let f=this.context.dynamicTypeLiteralMapper.convert({typeReference:s,value:e.requestBody});x.TypeLiteral.isNop(f)||i.push(x.keywordArgument({name:"request",value:f}))}break}default:L(r.body)}return i}getBodyArgsForNonObjectType({namedType:r,typeRef:e,bodyValue:i}){let s=[];switch(r.type){case"undiscriminatedUnion":{let f=this.context.getRecord(i);if(f!=null){for(let T of r.types)if(T.type==="named"){let w=this.context.resolveNamedType({typeId:T.value});if(w!=null&&w.type==="object"){let k=new Set(w.properties.map(D=>D.name.wireValue)),R=Object.keys(f);if(R.every(D=>k.has(D))&&R.length>0){let D=this.getBodyFieldsAsKeywordArgs({namedType:w,bodyRecord:f});return s.push(...D),s}}}}let u=this.context.dynamicTypeLiteralMapper.convert({typeReference:e,value:i});x.TypeLiteral.isNop(u)||s.push(x.keywordArgument({name:"request",value:u}));break}case"alias":{let f=r.typeReference;if(f.type==="named"){let T=this.context.resolveNamedType({typeId:f.value});if(T!=null&&T.type==="object"){let w=this.context.getRecord(i);if(w!=null){let k=this.getBodyFieldsAsKeywordArgs({namedType:T,bodyRecord:w});return s.push(...k),s}}}let u=this.context.dynamicTypeLiteralMapper.convert({typeReference:e,value:i});x.TypeLiteral.isNop(u)||s.push(x.keywordArgument({name:"request",value:u}));break}case"discriminatedUnion":case"enum":{let f=this.context.dynamicTypeLiteralMapper.convert({typeReference:e,value:i});x.TypeLiteral.isNop(f)||s.push(x.keywordArgument({name:"request",value:f}));break}case"object":break;default:L(r)}return s}getBodyFieldsAsKeywordArgs({namedType:r,bodyRecord:e}){let i=[];switch(r.type){case"object":{for(let s of r.properties){let f=s.name.wireValue,u=e[f];if(u!==void 0){this.context.errors.scope(f);let T=this.context.dynamicTypeLiteralMapper.convert({typeReference:s.typeReference,value:u});this.context.errors.unscope(),x.TypeLiteral.isNop(T)||i.push(x.keywordArgument({name:this.context.getPropertyName(s.name.name),value:T}))}}break}case"alias":case"discriminatedUnion":case"undiscriminatedUnion":case"enum":break;default:L(r)}return i}getMethod({endpoint:r}){return r.declaration.fernFilepath.allParts.length>0?`${r.declaration.fernFilepath.allParts.map(e=>`${this.context.getMethodName(e)}`).join(".")}.${this.context.getMethodName(r.declaration.name)}`:this.context.getMethodName(r.declaration.name)}};var wt=class extends Pe{constructor({ir:e,config:i,formatter:s}){super(new ot({ir:e,config:i}));y(this,"formatter");this.formatter=s}async generate(e){return super.generate(e)}generateSync(e){return super.generateSync(e)}async generateSnippetAst(e,i){return super.generateSnippetAst(e,i)}createSnippetGenerator(e){return new st({context:e,formatter:this.formatter})}};export{wt as DynamicSnippetsGenerator};
|
|
23
|
+
}`);break}case"set":{let i=this.internalType.values.filter(s=>!l.isNop(s));if(i.length===0){e.write("Set.new([])");break}e.write("Set.new(["),i.forEach((s,f)=>{f>0&&e.write(", "),s.write(e)}),e.write("])");break}case"list":{let i=this.internalType.values.filter(s=>!l.isNop(s));if(i.length===0){e.write("[]");break}e.write("["),i.forEach((s,f)=>{f>0&&e.write(", "),s.write(e)}),e.write("]");break}case"nop":break;case"nil":e.write("nil");break;default:L(this.internalType)}}};c();m();d();var Ze;(function(l){l[l.Invariant=0]="Invariant",l.Covariant="out",l.Contravariant="in"})(Ze||(Ze={}));var be=class extends S{constructor({name:e,unchecked:i,bound:s,variance:f,defaultType:u}){super();y(this,"name");y(this,"unchecked");y(this,"bound");y(this,"variance");y(this,"defaultType");this.name=e,this.unchecked=i??!1,this.bound=s,this.variance=f??Ze.Invariant,this.defaultType=u}write(e){}writeTypeDefinition(e){this.unchecked&&e.write("unchecked "),this.variance!=Ze.Invariant&&e.write(`${this.variance} `),e.write(this.name),this.bound&&(e.write(" < "),this.bound.writeTypeDefinition(e)),this.defaultType&&(e.write(" = "),this.defaultType.writeTypeDefinition(e))}};c();m();d();var qe=class extends W{constructor(){super(...arguments);y(this,"initializer")}write(e){e.write(`&${this.name}`)}};c();m();d();var et=class extends S{constructor({body:e,rescues:i}){super();y(this,"body");y(this,"rescues");this.body=e,this.rescues=i}write(e){e.write("begin"),e.writeLine(),this.body&&(e.indent(),this.body.write(e),e.writeNewLineIfLastLineNot(),e.dedent());for(let{errorClass:i,errorVariable:s,body:f}of this.rescues)e.write("rescue"),i&&(e.write(" "),i.write(e)),s&&(e.write(" => "),e.write(s)),e.writeLine(),f&&(e.indent(),f.write(e),e.writeNewLineIfLastLineNot(),e.dedent());e.write("end")}};c();m();d();var tt=class extends S{constructor({if:e,elseIf:i,elseBody:s}){super();y(this,"ifBranch");y(this,"elseIfs");y(this,"elseBody");this.ifBranch=e,this.elseIfs=i??[],this.elseBody=s?Array.isArray(s)?s:[s]:void 0}write(e){e.write("if "),this.ifBranch.condition.write(e),e.writeLine(),e.indent();for(let i of this.ifBranch.thenBody)i.write(e),e.writeNewLineIfLastLineNot();e.dedent();for(let i of this.elseIfs){e.write("elsif "),i.condition.write(e),e.writeLine(),e.indent();for(let s of i.thenBody)s.write(e),e.writeNewLineIfLastLineNot();e.dedent()}if(this.elseBody&&this.elseBody.length>0){e.writeLine("else"),e.indent();for(let i of this.elseBody)i.write(e),e.writeNewLineIfLastLineNot();e.dedent()}e.write("end"),e.writeNewLineIfLastLineNot()}};c();m();d();var rt=class extends S{constructor({errorClass:e,message:i}){super();y(this,"errorClass");y(this,"message");this.errorClass=e,this.message=i}write(e){e.write("raise"),this.errorClass&&(e.write(" "),this.errorClass.write(e)),this.message&&(this.errorClass&&e.write(", "),this.message.write(e))}};function nt(l){return new ye(l)}function io(){return nt("true")}function oo(){return nt("false")}function so(){return nt("nil")}var ao={positional(l){return new _e(l)},keyword(l){return new xe(l)},positionalSplat(l){return new je(l)},keywordSplat(l){return new De(l)},yield(l){return new qe(l)}};function uo(l){return new ue(l)}function lo(l){return new ae(l)}function po(l){return new se(l)}function fo(l){return new X(l)}function co(l){return new be(l)}function mo(l){return new ne(l)}function ho(l){return new he(l)}function yo(l){return new ge(l)}function go(l){return new we(l)}function xo(l){return new Oe(l)}function wo(l){return new tt(l)}function bo(l){return new et(l)}function vo(l){return new rt(l)}function Ao(l,t){let e=l;for(let i of t.toReversed())i.addStatement(e),e=i;return e}c();m();d();var it=class l{constructor({context:t}){y(this,"context");this.context=t}convert(t){if(t.value===null)return this.context.isNullable(t.typeReference)?x.TypeLiteral.nil():(this.context.errors.add({severity:N.Critical,message:"Expected non-null value, but got null"}),x.TypeLiteral.nop());if(t.value===void 0)return x.TypeLiteral.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return this.convertLiteral({literalType:t.typeReference.value,value:t.value});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?x.TypeLiteral.nop():this.convertNamed({named:e,value:t.value,as:t.as})}case"optional":return this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as});case"nullable":return this.convert({typeReference:t.typeReference.value,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.convertSet({set:t.typeReference.value,value:t.value});case"unknown":return x.TypeLiteral.nop();default:L(t.typeReference)}}convertLiteral({literalType:t,value:e}){switch(t.type){case"boolean":{let i=this.context.getValueAsBoolean({value:e});return i==null?x.TypeLiteral.nop():x.TypeLiteral.boolean(i)}case"string":{let i=this.context.getValueAsString({value:e});return i==null?x.TypeLiteral.nop():x.TypeLiteral.string(i)}default:L(t)}}convertList({list:t,value:e}){return Array.isArray(e)?x.TypeLiteral.list(e.map((i,s)=>{this.context.errors.scope({index:s});try{return this.convert({typeReference:t,value:i})}finally{this.context.errors.unscope()}})):(this.context.errors.add({severity:N.Critical,message:`Expected array but got: ${typeof e}`}),x.TypeLiteral.nop())}convertSet({set:t,value:e}){return Array.isArray(e)?x.TypeLiteral.set(e.map((i,s)=>{this.context.errors.scope({index:s});try{return this.convert({typeReference:t,value:i})}finally{this.context.errors.unscope()}})):(this.context.errors.add({severity:N.Critical,message:`Expected array but got: ${typeof e}`}),x.TypeLiteral.nop())}convertMap({map:t,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:N.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),x.TypeLiteral.nop()):x.TypeLiteral.hash(Object.entries(e).map(([i,s])=>{this.context.errors.scope(i);try{return{key:this.convert({typeReference:t.key,value:i,as:"key"}),value:this.convert({typeReference:t.value,value:s})}}finally{this.context.errors.unscope()}}))}convertNamed({named:t,value:e,as:i}){switch(t.type){case"alias":return this.convert({typeReference:t.typeReference,value:e,as:i});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:t,value:e});case"object":return this.convertObject({object:t,value:e});case"enum":return this.convertEnum({enum_:t,value:e});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e});default:L(t)}}convertDiscriminatedUnion({discriminatedUnion:t,value:e}){let i=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e});if(i==null)return x.TypeLiteral.nop();let s=i.singleDiscriminatedUnionType,f=this.convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:i,unionVariant:s});return f==null?x.TypeLiteral.nop():x.TypeLiteral.hash(f)}convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:t,unionVariant:e}){switch(e.type){case"samePropertiesAsObject":{let i=this.context.resolveNamedType({typeId:e.typeId});if(i==null)return;let s=this.convertNamed({named:i,value:t.value});return this.extractHashEntries(s)}case"singleProperty":try{this.context.errors.scope(e.discriminantValue.wireValue);let i=this.context.getRecord(t.value);return i==null?[{key:x.TypeLiteral.string(this.context.getPropertyName(e.discriminantValue.name)),value:this.convert({typeReference:e.typeReference,value:t.value})}]:[{key:x.TypeLiteral.string(this.context.getPropertyName(e.discriminantValue.name)),value:this.convert({typeReference:e.typeReference,value:i[e.discriminantValue.wireValue]})}]}finally{this.context.errors.unscope()}case"noProperties":return[];default:L(e)}}extractHashEntries(t){t instanceof x.TypeLiteral}convertEnum({enum_:t,value:e}){let i=this.getEnumValueName({enum_:t,value:e});return i==null?x.TypeLiteral.nop():x.TypeLiteral.string(i)}getEnumValueName({enum_:t,value:e}){if(typeof e!="string"){this.context.errors.add({severity:N.Critical,message:`Expected enum value string, got: ${typeof e}`});return}let i=t.values.find(s=>s.wireValue===e);if(i==null){this.context.errors.add({severity:N.Critical,message:`An enum value named "${e}" does not exist in this context`});return}return i.wireValue}convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e}){let i=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e});return i??x.TypeLiteral.nop()}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e}){for(let i of t.types){let s=this.context.clone(),u=new l({context:s}).convert({typeReference:i,value:e});if(s.errors.empty())return u}this.context.errors.add({severity:N.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof e}" value`})}convertPrimitive({primitive:t,value:e,as:i}){switch(t){case"INTEGER":case"LONG":case"UINT":case"UINT_64":{let s=this.getValueAsNumber({value:e,as:i});return s==null?x.TypeLiteral.nop():x.TypeLiteral.integer(s)}case"FLOAT":case"DOUBLE":{let s=this.getValueAsNumber({value:e});return s==null?x.TypeLiteral.nop():x.TypeLiteral.float(s)}case"BOOLEAN":{let s=this.getValueAsBoolean({value:e,as:i});return s==null?x.TypeLiteral.nop():x.TypeLiteral.boolean(s)}case"BASE_64":case"BIG_INTEGER":case"STRING":{let s=this.context.getValueAsString({value:e});return s==null?x.TypeLiteral.nop():x.TypeLiteral.string(s)}case"UUID":{let s=this.context.getValueAsString({value:e});return s==null?x.TypeLiteral.nop():x.TypeLiteral.string(s)}case"DATE":{let s=this.context.getValueAsString({value:e});return s==null?x.TypeLiteral.nop():x.TypeLiteral.string(s)}case"DATE_TIME":{let s=this.context.getValueAsString({value:e});return s==null?x.TypeLiteral.nop():x.TypeLiteral.string(s)}default:L(t)}}convertObject({object:t,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:N.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),x.TypeLiteral.nop()):x.TypeLiteral.hash(Object.entries(e).map(([i,s])=>{this.context.errors.scope(i);let f=t.properties.find(k=>k.name.wireValue===i),u=f?.typeReference??{type:"unknown"},T=f?.name.name.snakeCase.safeName??i,w={key:x.TypeLiteral.string(T),value:this.convert({typeReference:u,value:s})};return this.context.errors.unscope(),w}))}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:t;return this.context.getValueAsBoolean({value:i})}};var ot=class l extends $e{constructor({ir:e,config:i}){super({ir:e,config:i});y(this,"ir");y(this,"customConfig");y(this,"dynamicTypeLiteralMapper");this.ir=e,this.customConfig=i.customConfig!=null?i.customConfig:void 0,this.dynamicTypeLiteralMapper=new it({context:this})}clone(){return new l({ir:this.ir,config:this.config})}getRootClientClassReference(){return x.classReference({name:this.getRootClientClassName(),modules:[this.getRootModuleName()]})}getRootClientClassName(){return"Client"}getRootModuleName(){return ht(this.customConfig?.module??this.customConfig?.clientModuleName??this.config.organization)}isSingleEnvironmentID(e){return typeof e=="string"}isMultiEnvironmentValues(e){return typeof e=="object"}getEnvironmentTypeReferenceFromID(e){let i=this.resolveEnvironmentName(e);if(i!=null)return x.codeblock(s=>{s.writeNode(this.getEnvironmentClassReference()),s.write("::"),s.write(this.getEnumName(i))})}getEnvironmentClassReference(){return x.classReference({name:"Environment",modules:[this.getRootModuleName()]})}getEnumName(e){return this.getName(e.screamingSnakeCase.safeName)}getMethodName(e){return this.getName(e.snakeCase.safeName)}getPropertyName(e){return this.getName(e.snakeCase.safeName)}getName(e){return e}};c();m();d();var Un="client",To="@client",st=class{constructor({context:t,formatter:e}){y(this,"context");y(this,"formatter");this.context=t,this.formatter=e}async generateSnippet({endpoint:t,request:e}){return await this.buildCodeBlock({endpoint:t,snippet:e}).toStringAsync({customConfig:this.context.customConfig??{},formatter:this.formatter})}generateSnippetSync({endpoint:t,request:e}){return this.buildCodeBlock({endpoint:t,snippet:e}).toString({customConfig:this.context.customConfig??{},formatter:this.formatter})}async generateSnippetAst({endpoint:t,request:e,options:i}){return i?.skipClientInstantiation?this.buildCodeBlockWithoutClient({endpoint:t,snippet:e}):this.buildCodeBlock({endpoint:t,snippet:e})}buildCodeBlock({endpoint:t,snippet:e}){return x.codeblock(i=>{i.writeNodeStatement(this.constructClient({endpoint:t,snippet:e})),i.newLine(),i.writeNodeStatement(this.callMethod({endpoint:t,snippet:e}))})}buildCodeBlockWithoutClient({endpoint:t,snippet:e}){return x.codeblock(i=>{i.writeNodeStatement(this.callMethodOnExistingClient({endpoint:t,snippet:e}))})}constructClient({endpoint:t,snippet:e}){return x.codeblock(i=>{i.addRequire(this.context.getRootModuleName().toLowerCase());let s=this.context.getRootClientClassReference(),f=this.getRootClientBuilderArgs({endpoint:t,snippet:e});i.write(`${Un} = `),i.writeNode(x.instantiateClass({classReference:s,arguments_:f}))})}getRootClientBaseUrlArg({baseUrl:t,environment:e}){if(t!=null&&e!=null)return this.context.errors.add({severity:"CRITICAL",message:"Cannot specify both baseUrl and environment options"}),[];if(t!=null)return[x.keywordArgument({name:"base_url",value:x.TypeLiteral.string(t)})];if(e!=null){if(this.context.isSingleEnvironmentID(e)){let i=this.context.getEnvironmentTypeReferenceFromID(e);return i==null?(this.context.errors.add({severity:"CRITICAL",message:`Environment ID ${e} not found`}),[]):[x.keywordArgument({name:"environment",value:i})]}if(this.context.isMultiEnvironmentValues(e))return this.context.errors.add({severity:"CRITICAL",message:"Multi-environment values are not supported in Ruby snippets yet"}),[]}return[]}getRootClientAuthArgs({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.getRootClientBasicAuthArgs({auth:t,values:e}):[];case"bearer":return e.type==="bearer"?this.getRootClientBearerAuthArgs({auth:t,values:e}):[];case"header":return e.type==="header"?this.getRootClientHeaderAuthArgs({auth:t,values:e}):[];case"oauth":return e.type==="oauth"?this.getRootClientOAuthArgs({auth:t,values:e}):[];case"inferred":return[];default:L(t)}}addError(t){this.context.errors.add({severity:N.Critical,message:t})}addWarning(t){this.context.errors.add({severity:N.Warning,message:t})}getRootClientBasicAuthArgs({auth:t,values:e}){return[x.keywordArgument({name:t.username.snakeCase.safeName,value:x.TypeLiteral.string(e.username)}),x.keywordArgument({name:t.password.snakeCase.safeName,value:x.TypeLiteral.string(e.password)})]}getRootClientBearerAuthArgs({auth:t,values:e}){return[x.keywordArgument({name:t.token.snakeCase.safeName,value:x.TypeLiteral.string(e.token)})]}getRootClientHeaderAuthArgs({auth:t,values:e}){return[x.keywordArgument({name:t.header.name.name.snakeCase.safeName,value:x.TypeLiteral.string(e.value)})]}getRootClientOAuthArgs({auth:t,values:e}){return[x.keywordArgument({name:t.clientId.snakeCase.safeName,value:x.TypeLiteral.string(e.clientId)}),x.keywordArgument({name:t.clientSecret.snakeCase.safeName,value:x.TypeLiteral.string(e.clientSecret)})]}getRootClientHeaderArgs({headers:t,values:e}){let i=[];for(let s of t){let f=e[s.name.name.originalName];f!=null&&typeof f=="string"&&i.push(x.keywordArgument({name:s.name.name.snakeCase.safeName,value:x.TypeLiteral.string(f)}))}return i}getRootClientBuilderArgs({endpoint:t,snippet:e}){let i=[];t.auth!=null&&(e.auth!=null?i.push(...this.getRootClientAuthArgs({auth:t.auth,values:e.auth})):this.context.errors.add({severity:"WARNING",message:`Auth with ${t.auth.type} configuration is required for this endpoint`}));let s=this.getRootClientBaseUrlArg({baseUrl:e.baseURL,environment:e.environment});return s.length>0&&i.push(...s),this.context.errors.scope("Headers"),this.context.ir.headers!=null&&e.headers!=null&&i.push(...this.getRootClientHeaderArgs({headers:this.context.ir.headers,values:e.headers})),this.context.errors.unscope(),i}callMethod({endpoint:t,snippet:e}){let i={on:x.codeblock(Un),method:this.getMethod({endpoint:t}),arguments_:[]};switch(t.request.type){case"inlined":i.keywordArguments=this.getMethodArgsForInlinedRequest({request:t.request,snippet:e});break;case"body":i.keywordArguments=this.getMethodArgsForBodyRequest({request:t.request,snippet:e});break;default:L(t.request)}let s=this.getRequestOptions({endpoint:t,snippet:e});return s!=null&&(i.keywordArguments=i.keywordArguments??[],i.keywordArguments.push(s)),x.invokeMethod(i)}callMethodOnExistingClient({endpoint:t,snippet:e}){let i={on:x.codeblock(To),method:this.getMethod({endpoint:t}),arguments_:[]};switch(t.request.type){case"inlined":i.keywordArguments=this.getMethodArgsForInlinedRequest({request:t.request,snippet:e});break;case"body":i.keywordArguments=this.getMethodArgsForBodyRequest({request:t.request,snippet:e});break;default:L(t.request)}let s=this.getRequestOptions({endpoint:t,snippet:e});return s!=null&&(i.keywordArguments=i.keywordArguments??[],i.keywordArguments.push(s)),x.invokeMethod(i)}getRequestOptions({endpoint:t,snippet:e}){let i=e.headers??{},s=Object.entries(i);if(s.length===0)return;let f=new Set;if(this.context.ir.headers!=null)for(let w of this.context.ir.headers)f.add(w.name.wireValue.toLowerCase());if(t.request.type==="inlined"&&t.request.headers!=null)for(let w of t.request.headers)f.add(w.name.wireValue.toLowerCase());let u=s.filter(([w])=>!f.has(w.toLowerCase()));if(u.length===0)return;let T=u.map(([w,k])=>({key:x.TypeLiteral.string(w),value:x.TypeLiteral.string(String(k))}));return x.keywordArgument({name:"request_options",value:x.TypeLiteral.hash([{key:x.TypeLiteral.string("additional_headers"),value:x.TypeLiteral.hash(T)}])})}getMethodArgsForInlinedRequest({request:t,snippet:e}){let i=[];if(i.push(...this.getNamedParameterArgs({kind:"PathParameters",namedParameters:t.pathParameters,values:e.pathParameters})),i.push(...this.getNamedParameterArgs({kind:"QueryParameters",namedParameters:t.queryParameters,values:e.queryParameters})),i.push(...this.getNamedParameterArgs({kind:"Headers",namedParameters:t.headers,values:e.headers})),t.body!=null&&e.requestBody!=null)switch(t.body.type){case"properties":i.push(...this.getMethodArgsForPropertiesRequest({request:t.body,snippet:e}));break;case"referenced":{let s=t.body.bodyType;if(s.type==="typeReference"){let f=s.value;if(f.type==="named"){let u=this.context.resolveNamedType({typeId:f.value});if(u!=null&&u.type==="object"){let T=this.context.getRecord(e.requestBody);if(T!=null){let w=this.getBodyFieldsAsKeywordArgs({namedType:u,bodyRecord:T});i.push(...w)}}else if(u!=null){let T=this.getBodyArgsForNonObjectType({namedType:u,typeRef:f,bodyValue:e.requestBody});i.push(...T)}}else{let u=this.context.dynamicTypeLiteralMapper.convert({typeReference:f,value:e.requestBody});x.TypeLiteral.isNop(u)||i.push(x.keywordArgument({name:t.body.bodyKey.snakeCase.safeName,value:u}))}}break}case"fileUpload":break;default:L(t.body)}return i}getNamedParameterArgs({kind:t,namedParameters:e,values:i}){let s=[];if(this.context.errors.scope(t),e!=null){let f=this.context.associateByWireValue({parameters:e,values:i??{},ignoreMissingParameters:!0});for(let u of f){let T=this.context.dynamicTypeLiteralMapper.convert(u);x.TypeLiteral.isNop(T)||s.push(x.keywordArgument({name:this.context.getPropertyName(u.name.name),value:T}))}}return this.context.errors.unscope(),s}getMethodArgsForPropertiesRequest({request:t,snippet:e}){let i=[],s=this.context.associateByWireValue({parameters:t.value,values:this.context.getRecord(e.requestBody)??{}});for(let f of s){let u=this.context.dynamicTypeLiteralMapper.convert(f);x.TypeLiteral.isNop(u)||i.push(x.keywordArgument({name:this.context.getPropertyName(f.name.name),value:u}))}return i}getMethodArgsForBodyRequest({request:t,snippet:e}){let i=[];if(i.push(...this.getNamedParameterArgs({kind:"PathParameters",namedParameters:t.pathParameters,values:e.pathParameters})),t.body!=null&&e.requestBody!=null)switch(t.body.type){case"bytes":this.context.errors.add({severity:"CRITICAL",message:"Bytes request body is not supported in Ruby snippets yet"});break;case"typeReference":{let s=t.body.value;if(s.type==="named"){let f=this.context.resolveNamedType({typeId:s.value});if(f!=null&&f.type==="object"){let u=this.context.getRecord(e.requestBody);if(u!=null){let T=this.getBodyFieldsAsKeywordArgs({namedType:f,bodyRecord:u});i.push(...T)}}else if(f!=null){let u=this.getBodyArgsForNonObjectType({namedType:f,typeRef:s,bodyValue:e.requestBody});i.push(...u)}}else{let f=this.context.dynamicTypeLiteralMapper.convert({typeReference:s,value:e.requestBody});x.TypeLiteral.isNop(f)||i.push(x.keywordArgument({name:"request",value:f}))}break}default:L(t.body)}return i}getBodyArgsForNonObjectType({namedType:t,typeRef:e,bodyValue:i}){let s=[];switch(t.type){case"undiscriminatedUnion":{let f=this.context.getRecord(i);if(f!=null){for(let T of t.types)if(T.type==="named"){let w=this.context.resolveNamedType({typeId:T.value});if(w!=null&&w.type==="object"){let k=new Set(w.properties.map(D=>D.name.wireValue)),R=Object.keys(f);if(R.every(D=>k.has(D))&&R.length>0){let D=this.getBodyFieldsAsKeywordArgs({namedType:w,bodyRecord:f});return s.push(...D),s}}}}let u=this.context.dynamicTypeLiteralMapper.convert({typeReference:e,value:i});x.TypeLiteral.isNop(u)||s.push(x.keywordArgument({name:"request",value:u}));break}case"alias":{let f=t.typeReference;if(f.type==="named"){let T=this.context.resolveNamedType({typeId:f.value});if(T!=null&&T.type==="object"){let w=this.context.getRecord(i);if(w!=null){let k=this.getBodyFieldsAsKeywordArgs({namedType:T,bodyRecord:w});return s.push(...k),s}}}let u=this.context.dynamicTypeLiteralMapper.convert({typeReference:e,value:i});x.TypeLiteral.isNop(u)||s.push(x.keywordArgument({name:"request",value:u}));break}case"discriminatedUnion":case"enum":{let f=this.context.dynamicTypeLiteralMapper.convert({typeReference:e,value:i});x.TypeLiteral.isNop(f)||s.push(x.keywordArgument({name:"request",value:f}));break}case"object":break;default:L(t)}return s}getBodyFieldsAsKeywordArgs({namedType:t,bodyRecord:e}){let i=[];switch(t.type){case"object":{for(let s of t.properties){let f=s.name.wireValue,u=e[f];if(u!==void 0){this.context.errors.scope(f);let T=this.context.dynamicTypeLiteralMapper.convert({typeReference:s.typeReference,value:u});this.context.errors.unscope(),x.TypeLiteral.isNop(T)||i.push(x.keywordArgument({name:this.context.getPropertyName(s.name.name),value:T}))}}break}case"alias":case"discriminatedUnion":case"undiscriminatedUnion":case"enum":break;default:L(t)}return i}getMethod({endpoint:t}){return t.declaration.fernFilepath.allParts.length>0?`${t.declaration.fernFilepath.allParts.map(e=>`${this.context.getMethodName(e)}`).join(".")}.${this.context.getMethodName(t.declaration.name)}`:this.context.getMethodName(t.declaration.name)}};var wt=class extends Pe{constructor({ir:e,config:i,formatter:s}){super(new ot({ir:e,config:i}));y(this,"formatter");this.formatter=s}async generate(e){return super.generate(e)}generateSync(e){return super.generateSync(e)}async generateSnippetAst(e,i){return super.generateSnippetAst(e,i)}createSnippetGenerator(e){return new st({context:e,formatter:this.formatter})}};export{wt as DynamicSnippetsGenerator};
|
|
24
24
|
/*! Bundled license information:
|
|
25
25
|
|
|
26
26
|
@jspm/core/nodelibs/browser/chunk-DtuTasat.js:
|