@fern-api/ruby-dynamic-snippets 1.30.1 → 1.31.0

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