@fern-api/ruby-dynamic-snippets 0.0.1
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/cjs/DynamicSnippetsGenerator.cjs +26 -0
- package/cjs/DynamicSnippetsGenerator.d.cts +19 -0
- package/cjs/DynamicSnippetsGeneratorContext-BGmCyT7y.d.cts +52 -0
- package/cjs/EndpointSnippetGenerator.cjs +26 -0
- package/cjs/EndpointSnippetGenerator.d.cts +40 -0
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs +26 -0
- package/cjs/context/DynamicSnippetsGeneratorContext.d.cts +4 -0
- package/cjs/context/DynamicToLiteralMapper.cjs +26 -0
- package/cjs/context/DynamicToLiteralMapper.d.cts +4 -0
- package/cjs/index.cjs +38 -0
- package/cjs/index.d.cts +6 -0
- package/esm/DynamicSnippetsGenerator.d.ts +19 -0
- package/esm/DynamicSnippetsGenerator.js +1 -0
- package/esm/DynamicSnippetsGeneratorContext-BGmCyT7y.d.ts +52 -0
- package/esm/EndpointSnippetGenerator.d.ts +40 -0
- package/esm/EndpointSnippetGenerator.js +1 -0
- package/esm/chunk-2EUGHB6H.js +26 -0
- package/esm/chunk-5MYTC5XX.js +1 -0
- package/esm/chunk-JE27KH5P.js +1 -0
- package/esm/chunk-P72WBQKD.js +1 -0
- package/esm/chunk-T3CDT3YD.js +1 -0
- package/esm/context/DynamicSnippetsGeneratorContext.d.ts +4 -0
- package/esm/context/DynamicSnippetsGeneratorContext.js +1 -0
- package/esm/context/DynamicToLiteralMapper.d.ts +4 -0
- package/esm/context/DynamicToLiteralMapper.js +1 -0
- package/esm/index.d.ts +6 -0
- package/esm/index.js +13 -0
- package/package.json +27 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";var de=Object.defineProperty,yt=Object.defineProperties,wt=Object.getOwnPropertyDescriptor,gt=Object.getOwnPropertyDescriptors,xt=Object.getOwnPropertyNames,me=Object.getOwnPropertySymbols;var ke=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable;var Le=(n,t,e)=>t in n?de(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,$e=(n,t)=>{for(var e in t||(t={}))ke.call(t,e)&&Le(n,e,t[e]);if(me)for(var e of me(t))De.call(t,e)&&Le(n,e,t[e]);return n},Ve=(n,t)=>yt(n,gt(t));var Ye=n=>typeof n=="symbol"?n:n+"",Oe=(n,t)=>{var e={};for(var r in n)ke.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&me)for(var r of me(n))t.indexOf(r)<0&&De.call(n,r)&&(e[r]=n[r]);return e};var Pe=(n,t)=>()=>(n&&(t=n(n=0)),t);var qe=(n,t)=>{for(var e in t)de(n,e,{get:t[e],enumerable:!0})},vt=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of xt(t))!ke.call(n,i)&&i!==e&&de(n,i,{get:()=>t[i],enumerable:!(r=wt(t,i))||r.enumerable});return n};var At=n=>vt(de({},"__esModule",{value:!0}),n);var u=(n,t,e)=>Le(n,typeof t!="symbol"?t+"":t,e);function We(){throw new Error("setTimeout has not been defined")}function ze(){throw new Error("clearTimeout has not been defined")}function He(n){if(B===setTimeout)return setTimeout(n,0);if((B===We||!B)&&setTimeout)return B=setTimeout,setTimeout(n,0);try{return B(n,0)}catch(t){try{return B.call(null,n,0)}catch(e){return B.call(this,n,0)}}}function Tt(n){if(F===clearTimeout)return clearTimeout(n);if((F===ze||!F)&&clearTimeout)return F=clearTimeout,clearTimeout(n);try{return F(n)}catch(t){try{return F.call(null,n)}catch(e){return F.call(this,n)}}}function Et(){!X||!M||(X=!1,M.length?k=M.concat(k):ye=-1,k.length&&Ke())}function Ke(){if(!X){var n=He(Et);X=!0;for(var t=k.length;t;){for(M=k,k=[];++ye<t;)M&&M[ye].run();ye=-1,t=k.length}M=null,X=!1,Tt(n)}}function Rt(n){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];k.push(new je(n,t)),k.length===1&&!X&&He(Ke)}function je(n,t){this.fun=n,this.array=t}function _(){}function Yt(n){throw new Error("process.binding is not supported")}function Ot(){return"/"}function qt(n){throw new Error("process.chdir is not supported")}function Gt(){return 0}function zt(n){var t=Wt.call(j)*.001,e=Math.floor(t),r=Math.floor(t%1*1e9);return n&&(e=e-n[0],r=r-n[1],r<0&&(e--,r+=1e9)),[e,r]}function Kt(){var n=new Date,t=n-Ht;return t/1e3}var B,F,k,X,M,ye,bt,It,Ct,Nt,St,Lt,kt,Pt,Bt,Ft,Mt,_t,Ut,Dt,$t,Vt,j,Wt,Ht,m,Ge,c=Pe(()=>{"use strict";B=We,F=ze;typeof globalThis.setTimeout=="function"&&(B=setTimeout);typeof globalThis.clearTimeout=="function"&&(F=clearTimeout);k=[],X=!1,ye=-1;je.prototype.run=function(){this.fun.apply(null,this.array)};bt="browser",It="browser",Ct=!0,Nt={},St=[],Lt="",kt={},Pt={},Bt={};Ft=_,Mt=_,_t=_,Ut=_,Dt=_,$t=_,Vt=_;j=globalThis.performance||{},Wt=j.now||j.mozNow||j.msNow||j.oNow||j.webkitNow||function(){return new Date().getTime()};Ht=new Date;m={nextTick:Rt,title:bt,browser:Ct,env:Nt,argv:St,version:Lt,versions:kt,on:Ft,addListener:Mt,once:_t,off:Ut,removeListener:Dt,removeAllListeners:$t,emit:Vt,binding:Yt,cwd:Ot,chdir:qt,umask:Gt,hrtime:zt,platform:It,release:Pt,config:Bt,uptime:Kt},Ge={};Object.keys(Ge).forEach(n=>{let t=n.split("."),e=m;for(let r=0;r<t.length;r++){let i=t[r];r===t.length-1?e[i]=Ge[n]:e=e[i]||(e[i]={})}})});function Ze(){Fe=!0;for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=n.length;t<e;++t)S[t]=n[t],b[n.charCodeAt(t)]=t;b[45]=62,b[95]=63}function Xt(n){Fe||Ze();var t,e,r,i,o,s,p=n.length;if(p%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o=n[p-2]==="="?2:n[p-1]==="="?1:0,s=new jt(p*3/4-o),r=o>0?p-4:p;var h=0;for(t=0,e=0;t<r;t+=4,e+=3)i=b[n.charCodeAt(t)]<<18|b[n.charCodeAt(t+1)]<<12|b[n.charCodeAt(t+2)]<<6|b[n.charCodeAt(t+3)],s[h++]=i>>16&255,s[h++]=i>>8&255,s[h++]=i&255;return o===2?(i=b[n.charCodeAt(t)]<<2|b[n.charCodeAt(t+1)]>>4,s[h++]=i&255):o===1&&(i=b[n.charCodeAt(t)]<<10|b[n.charCodeAt(t+1)]<<4|b[n.charCodeAt(t+2)]>>2,s[h++]=i>>8&255,s[h++]=i&255),s}function Jt(n){return S[n>>18&63]+S[n>>12&63]+S[n>>6&63]+S[n&63]}function Qt(n,t,e){for(var r,i=[],o=t;o<e;o+=3)r=(n[o]<<16)+(n[o+1]<<8)+n[o+2],i.push(Jt(r));return i.join("")}function Xe(n){Fe||Ze();for(var t,e=n.length,r=e%3,i="",o=[],s=16383,p=0,h=e-r;p<h;p+=s)o.push(Qt(n,p,p+s>h?h:p+s));return r===1?(t=n[e-1],i+=S[t>>2],i+=S[t<<4&63],i+="=="):r===2&&(t=(n[e-2]<<8)+n[e-1],i+=S[t>>10],i+=S[t>>4&63],i+=S[t<<2&63],i+="="),o.push(i),o.join("")}function we(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function P(n,t){if(we()<t)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(n=new Uint8Array(t),n.__proto__=a.prototype):(n===null&&(n=new a(t)),n.length=t),n}function a(n,t,e){if(!a.TYPED_ARRAY_SUPPORT&&!(this instanceof a))return new a(n,t,e);if(typeof n=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return Me(this,n)}return et(this,n,t,e)}function et(n,t,e,r){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer!="undefined"&&t instanceof ArrayBuffer?tr(n,t,e,r):typeof t=="string"?er(n,t,e):rr(n,t)}function tt(n){if(typeof n!="number")throw new TypeError('"size" argument must be a number');if(n<0)throw new RangeError('"size" argument must not be negative')}function Zt(n,t,e,r){return tt(t),t<=0?P(n,t):e!==void 0?typeof r=="string"?P(n,t).fill(e,r):P(n,t).fill(e):P(n,t)}function Me(n,t){if(tt(t),n=P(n,t<0?0:_e(t)|0),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)n[e]=0;return n}function er(n,t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!a.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var r=rt(t,e)|0;n=P(n,r);var i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Be(n,t){var e=t.length<0?0:_e(t.length)|0;n=P(n,e);for(var r=0;r<e;r+=1)n[r]=t[r]&255;return n}function tr(n,t,e,r){if(t.byteLength,e<0||t.byteLength<e)throw new RangeError("'offset' is out of bounds");if(t.byteLength<e+(r||0))throw new RangeError("'length' is out of bounds");return e===void 0&&r===void 0?t=new Uint8Array(t):r===void 0?t=new Uint8Array(t,e):t=new Uint8Array(t,e,r),a.TYPED_ARRAY_SUPPORT?(n=t,n.__proto__=a.prototype):n=Be(n,t),n}function rr(n,t){if(L(t)){var e=_e(t.length)|0;return n=P(n,e),n.length===0||t.copy(n,0,0,e),n}if(t){if(typeof ArrayBuffer!="undefined"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||Ar(t.length)?P(n,0):Be(n,t);if(t.type==="Buffer"&&Array.isArray(t.data))return Be(n,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function _e(n){if(n>=we())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+we().toString(16)+" bytes");return n|0}function L(n){return!!(n!=null&&n._isBuffer)}function rt(n,t){if(L(n))return n.length;if(typeof ArrayBuffer!="undefined"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(n)||n instanceof ArrayBuffer))return n.byteLength;typeof n!="string"&&(n=""+n);var e=n.length;if(e===0)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return ge(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return ct(n).length;default:if(r)return ge(n).length;t=(""+t).toLowerCase(),r=!0}}function nr(n,t,e){var r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(n||(n="utf8");;)switch(n){case"hex":return hr(this,t,e);case"utf8":case"utf-8":return ot(this,t,e);case"ascii":return pr(this,t,e);case"latin1":case"binary":return fr(this,t,e);case"base64":return cr(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mr(this,t,e);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),r=!0}}function U(n,t,e){var r=n[t];n[t]=n[e],n[e]=r}function nt(n,t,e,r,i){if(n.length===0)return-1;if(typeof e=="string"?(r=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(i)return-1;e=n.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,r)),L(t))return t.length===0?-1:Je(n,t,e,r,i);if(typeof t=="number")return t=t&255,a.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):Je(n,[t],e,r,i);throw new TypeError("val must be string, number or Buffer")}function Je(n,t,e,r,i){var o=1,s=n.length,p=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(n.length<2||t.length<2)return-1;o=2,s/=2,p/=2,e/=2}function h(R,K){return o===1?R[K]:R.readUInt16BE(K*o)}var d;if(i){var w=-1;for(d=e;d<s;d++)if(h(n,d)===h(t,w===-1?0:d-w)){if(w===-1&&(w=d),d-w+1===p)return w*o}else w!==-1&&(d-=d-w),w=-1}else for(e+p>s&&(e=s-p),d=e;d>=0;d--){for(var y=!0,I=0;I<p;I++)if(h(n,d+I)!==h(t,I)){y=!1;break}if(y)return d}return-1}function ir(n,t,e,r){e=Number(e)||0;var i=n.length-e;r?(r=Number(r),r>i&&(r=i)):r=i;var o=t.length;if(o%2!==0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var p=parseInt(t.substr(s*2,2),16);if(isNaN(p))return s;n[e+s]=p}return s}function or(n,t,e,r){return Ae(ge(t,n.length-e),n,e,r)}function it(n,t,e,r){return Ae(xr(t),n,e,r)}function sr(n,t,e,r){return it(n,t,e,r)}function ar(n,t,e,r){return Ae(ct(t),n,e,r)}function ur(n,t,e,r){return Ae(vr(t,n.length-e),n,e,r)}function cr(n,t,e){return t===0&&e===n.length?Xe(n):Xe(n.slice(t,e))}function ot(n,t,e){e=Math.min(n.length,e);for(var r=[],i=t;i<e;){var o=n[i],s=null,p=o>239?4:o>223?3:o>191?2:1;if(i+p<=e){var h,d,w,y;switch(p){case 1:o<128&&(s=o);break;case 2:h=n[i+1],(h&192)===128&&(y=(o&31)<<6|h&63,y>127&&(s=y));break;case 3:h=n[i+1],d=n[i+2],(h&192)===128&&(d&192)===128&&(y=(o&15)<<12|(h&63)<<6|d&63,y>2047&&(y<55296||y>57343)&&(s=y));break;case 4:h=n[i+1],d=n[i+2],w=n[i+3],(h&192)===128&&(d&192)===128&&(w&192)===128&&(y=(o&15)<<18|(h&63)<<12|(d&63)<<6|w&63,y>65535&&y<1114112&&(s=y))}}s===null?(s=65533,p=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),i+=p}return lr(r)}function lr(n){var t=n.length;if(t<=Qe)return String.fromCharCode.apply(String,n);for(var e="",r=0;r<t;)e+=String.fromCharCode.apply(String,n.slice(r,r+=Qe));return e}function pr(n,t,e){var r="";e=Math.min(n.length,e);for(var i=t;i<e;++i)r+=String.fromCharCode(n[i]&127);return r}function fr(n,t,e){var r="";e=Math.min(n.length,e);for(var i=t;i<e;++i)r+=String.fromCharCode(n[i]);return r}function hr(n,t,e){var r=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>r)&&(e=r);for(var i="",o=t;o<e;++o)i+=gr(n[o]);return i}function mr(n,t,e){for(var r=n.slice(t,e),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+r[o+1]*256);return i}function A(n,t,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>e)throw new RangeError("Trying to access beyond buffer length")}function E(n,t,e,r,i,o){if(!L(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(e+r>n.length)throw new RangeError("Index out of range")}function xe(n,t,e,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(n.length-e,2);i<o;++i)n[e+i]=(t&255<<8*(r?i:1-i))>>>(r?i:1-i)*8}function ve(n,t,e,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(n.length-e,4);i<o;++i)n[e+i]=t>>>(r?i:3-i)*8&255}function st(n,t,e,r,i,o){if(e+r>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function at(n,t,e,r,i){return i||st(n,t,e,4,34028234663852886e22,-34028234663852886e22),pt(n,t,e,r,23,4),e+4}function ut(n,t,e,r,i){return i||st(n,t,e,8,17976931348623157e292,-17976931348623157e292),pt(n,t,e,r,52,8),e+8}function yr(n){if(n=wr(n).replace(dr,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function wr(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")}function gr(n){return n<16?"0"+n.toString(16):n.toString(16)}function ge(n,t){t=t||1/0;for(var e,r=n.length,i=null,o=[],s=0;s<r;++s){if(e=n.charCodeAt(s),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&o.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;o.push(e)}else if(e<2048){if((t-=2)<0)break;o.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;o.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return o}function xr(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function vr(n,t){for(var e,r,i,o=[],s=0;s<n.length&&!((t-=2)<0);++s)e=n.charCodeAt(s),r=e>>8,i=e%256,o.push(i),o.push(r);return o}function ct(n){return Xt(yr(n))}function Ae(n,t,e,r){for(var i=0;i<r&&!(i+e>=t.length||i>=n.length);++i)t[i+e]=n[i];return i}function Ar(n){return n!==n}function Tr(n){return n!=null&&(!!n._isBuffer||lt(n)||Er(n))}function lt(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function Er(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&<(n.slice(0,0))}function Te(n,t,e,r,i){var o,s,p=i*8-r-1,h=(1<<p)-1,d=h>>1,w=-7,y=e?i-1:0,I=e?-1:1,R=n[t+y];for(y+=I,o=R&(1<<-w)-1,R>>=-w,w+=p;w>0;o=o*256+n[t+y],y+=I,w-=8);for(s=o&(1<<-w)-1,o>>=-w,w+=r;w>0;s=s*256+n[t+y],y+=I,w-=8);if(o===0)o=1-d;else{if(o===h)return s?NaN:(R?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-d}return(R?-1:1)*s*Math.pow(2,o-r)}function pt(n,t,e,r,i,o){var s,p,h,d=o*8-i-1,w=(1<<d)-1,y=w>>1,I=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,R=r?0:o-1,K=r?1:-1,dt=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(p=isNaN(t)?1:0,s=w):(s=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-s))<1&&(s--,h*=2),s+y>=1?t+=I/h:t+=I*Math.pow(2,1-y),t*h>=2&&(s++,h/=2),s+y>=w?(p=0,s=w):s+y>=1?(p=(t*h-1)*Math.pow(2,i),s=s+y):(p=t*Math.pow(2,y-1)*Math.pow(2,i),s=0));i>=8;n[e+R]=p&255,R+=K,p/=256,i-=8);for(s=s<<i|p,d+=i;d>0;n[e+R]=s&255,R+=K,s/=256,d-=8);n[e+R-K]|=dt*128}var S,b,jt,Fe,Qe,dr,ft=Pe(()=>{"use strict";c();l();S=[],b=[],jt=typeof Uint8Array!="undefined"?Uint8Array:Array,Fe=!1;a.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;a.poolSize=8192;a._augment=function(n){return n.__proto__=a.prototype,n};a.from=function(n,t,e){return et(null,n,t,e)};a.kMaxLength=we();a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&a[Symbol.species]);a.alloc=function(n,t,e){return Zt(null,n,t,e)};a.allocUnsafe=function(n){return Me(null,n)};a.allocUnsafeSlow=function(n){return Me(null,n)};a.isBuffer=Tr;a.compare=function(t,e){if(!L(t)||!L(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,i=e.length,o=0,s=Math.min(r,i);o<s;++o)if(t[o]!==e[o]){r=t[o],i=e[o];break}return r<i?-1:i<r?1:0};a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var r;if(e===void 0)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var i=a.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(!L(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i};a.byteLength=rt;a.prototype._isBuffer=!0;a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)U(this,e,e+1);return this};a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)U(this,e,e+3),U(this,e+1,e+2);return this};a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)U(this,e,e+7),U(this,e+1,e+6),U(this,e+2,e+5),U(this,e+3,e+4);return this};a.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?ot(this,0,t):nr.apply(this,arguments)};a.prototype.equals=function(t){if(!L(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0};a.prototype.compare=function(t,e,r,i,o){if(!L(t))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),r===void 0&&(r=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),e<0||r>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&e>=r)return 0;if(i>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,i>>>=0,o>>>=0,this===t)return 0;for(var s=o-i,p=r-e,h=Math.min(s,p),d=this.slice(i,o),w=t.slice(e,r),y=0;y<h;++y)if(d[y]!==w[y]){s=d[y],p=w[y];break}return s<p?-1:p<s?1:0};a.prototype.includes=function(t,e,r){return this.indexOf(t,e,r)!==-1};a.prototype.indexOf=function(t,e,r){return nt(this,t,e,r,!0)};a.prototype.lastIndexOf=function(t,e,r){return nt(this,t,e,r,!1)};a.prototype.write=function(t,e,r,i){if(e===void 0)i="utf8",r=this.length,e=0;else if(r===void 0&&typeof e=="string")i=e,r=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(r)?(r=r|0,i===void 0&&(i="utf8")):(i=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var o=this.length-e;if((r===void 0||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return ir(this,t,e,r);case"utf8":case"utf-8":return or(this,t,e,r);case"ascii":return it(this,t,e,r);case"latin1":case"binary":return sr(this,t,e,r);case"base64":return ar(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ur(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};Qe=4096;a.prototype.slice=function(t,e){var r=this.length;t=~~t,e=e===void 0?r:~~e,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),e<t&&(e=t);var i;if(a.TYPED_ARRAY_SUPPORT)i=this.subarray(t,e),i.__proto__=a.prototype;else{var o=e-t;i=new a(o,void 0);for(var s=0;s<o;++s)i[s]=this[s+t]}return i};a.prototype.readUIntLE=function(t,e,r){t=t|0,e=e|0,r||A(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return i};a.prototype.readUIntBE=function(t,e,r){t=t|0,e=e|0,r||A(t,e,this.length);for(var i=this[t+--e],o=1;e>0&&(o*=256);)i+=this[t+--e]*o;return i};a.prototype.readUInt8=function(t,e){return e||A(t,1,this.length),this[t]};a.prototype.readUInt16LE=function(t,e){return e||A(t,2,this.length),this[t]|this[t+1]<<8};a.prototype.readUInt16BE=function(t,e){return e||A(t,2,this.length),this[t]<<8|this[t+1]};a.prototype.readUInt32LE=function(t,e){return e||A(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};a.prototype.readUInt32BE=function(t,e){return e||A(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};a.prototype.readIntLE=function(t,e,r){t=t|0,e=e|0,r||A(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i};a.prototype.readIntBE=function(t,e,r){t=t|0,e=e|0,r||A(t,e,this.length);for(var i=e,o=1,s=this[t+--i];i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*e)),s};a.prototype.readInt8=function(t,e){return e||A(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};a.prototype.readInt16LE=function(t,e){e||A(t,2,this.length);var r=this[t]|this[t+1]<<8;return r&32768?r|4294901760:r};a.prototype.readInt16BE=function(t,e){e||A(t,2,this.length);var r=this[t+1]|this[t]<<8;return r&32768?r|4294901760:r};a.prototype.readInt32LE=function(t,e){return e||A(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};a.prototype.readInt32BE=function(t,e){return e||A(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};a.prototype.readFloatLE=function(t,e){return e||A(t,4,this.length),Te(this,t,!0,23,4)};a.prototype.readFloatBE=function(t,e){return e||A(t,4,this.length),Te(this,t,!1,23,4)};a.prototype.readDoubleLE=function(t,e){return e||A(t,8,this.length),Te(this,t,!0,52,8)};a.prototype.readDoubleBE=function(t,e){return e||A(t,8,this.length),Te(this,t,!1,52,8)};a.prototype.writeUIntLE=function(t,e,r,i){if(t=+t,e=e|0,r=r|0,!i){var o=Math.pow(2,8*r)-1;E(this,t,e,r,o,0)}var s=1,p=0;for(this[e]=t&255;++p<r&&(s*=256);)this[e+p]=t/s&255;return e+r};a.prototype.writeUIntBE=function(t,e,r,i){if(t=+t,e=e|0,r=r|0,!i){var o=Math.pow(2,8*r)-1;E(this,t,e,r,o,0)}var s=r-1,p=1;for(this[e+s]=t&255;--s>=0&&(p*=256);)this[e+s]=t/p&255;return e+r};a.prototype.writeUInt8=function(t,e,r){return t=+t,e=e|0,r||E(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t&255,e+1};a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=e|0,r||E(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):xe(this,t,e,!0),e+2};a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=e|0,r||E(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):xe(this,t,e,!1),e+2};a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=e|0,r||E(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255):ve(this,t,e,!0),e+4};a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=e|0,r||E(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):ve(this,t,e,!1),e+4};a.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*r-1);E(this,t,e,r,o-1,-o)}var s=0,p=1,h=0;for(this[e]=t&255;++s<r&&(p*=256);)t<0&&h===0&&this[e+s-1]!==0&&(h=1),this[e+s]=(t/p>>0)-h&255;return e+r};a.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*r-1);E(this,t,e,r,o-1,-o)}var s=r-1,p=1,h=0;for(this[e+s]=t&255;--s>=0&&(p*=256);)t<0&&h===0&&this[e+s+1]!==0&&(h=1),this[e+s]=(t/p>>0)-h&255;return e+r};a.prototype.writeInt8=function(t,e,r){return t=+t,e=e|0,r||E(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=t&255,e+1};a.prototype.writeInt16LE=function(t,e,r){return t=+t,e=e|0,r||E(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):xe(this,t,e,!0),e+2};a.prototype.writeInt16BE=function(t,e,r){return t=+t,e=e|0,r||E(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):xe(this,t,e,!1),e+2};a.prototype.writeInt32LE=function(t,e,r){return t=+t,e=e|0,r||E(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):ve(this,t,e,!0),e+4};a.prototype.writeInt32BE=function(t,e,r){return t=+t,e=e|0,r||E(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):ve(this,t,e,!1),e+4};a.prototype.writeFloatLE=function(t,e,r){return at(this,t,e,!0,r)};a.prototype.writeFloatBE=function(t,e,r){return at(this,t,e,!1,r)};a.prototype.writeDoubleLE=function(t,e,r){return ut(this,t,e,!0,r)};a.prototype.writeDoubleBE=function(t,e,r){return ut(this,t,e,!1,r)};a.prototype.copy=function(t,e,r,i){if(r||(r=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===r||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);var o=i-r,s;if(this===t&&r<e&&e<i)for(s=o-1;s>=0;--s)t[s+e]=this[s+r];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(s=0;s<o;++s)t[s+e]=this[s+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o};a.prototype.fill=function(t,e,r,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,r=this.length):typeof r=="string"&&(i=r,r=this.length),t.length===1){var o=t.charCodeAt(0);o<256&&(t=o)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!a.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof t=="number"&&(t=t&255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;e=e>>>0,r=r===void 0?this.length:r>>>0,t||(t=0);var s;if(typeof t=="number")for(s=e;s<r;++s)this[s]=t;else{var p=L(t)?t:ge(new a(t,i).toString()),h=p.length;for(s=0;s<r-e;++s)this[s+e]=p[s%h]}return this};dr=/[^+\/0-9A-Za-z-_]/g});var l=Pe(()=>{"use strict";ft()});var Ur={};qe(Ur,{DynamicSnippetsGenerator:()=>Ue});module.exports=At(Ur);c();l();c();l();c();l();function v(n){throw new Error("Unexpected value: "+JSON.stringify(n))}c();l();function Z(n){return Object.keys(n)}c();l();c();l();var D=class{};c();l();c();l();var C=class extends D{constructor(e){super();u(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 Rr=4,ee=class{constructor(){u(this,"buffer","");u(this,"indentLevel",0);u(this,"hasWrittenAnything",!1);u(this,"lastCharacterIsSemicolon",!1);u(this,"lastCharacterIsNewline",!1)}write(t){let e=t.length>0&&t.endsWith(`
|
|
2
|
+
`),r=e?t.substring(0,t.length-1):t,i=this.getIndentString(),o=r.replaceAll(`
|
|
3
|
+
`,`
|
|
4
|
+
${i}`);this.isAtStartOfLine()&&(o=i+o),e&&(o+=`
|
|
5
|
+
`),this.writeInternal(o)}writeNoIndent(t){let e=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=e}writeNode(t){t.write(this)}writeNodeOrString(t){if(typeof t=="string"){this.write(t);return}this.writeNode(t)}writeNodeStatement(t){t.write(this),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new C(t).write(this),this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(t,e){new C(t).write(this),this.write(" ("),this.writeNode(e),this.write(") {"),this.writeNewLineIfLastLineNot(),this.indent()}controlFlowWithoutStatement(t){new C(t).write(this),this.write(" {"),this.writeNewLineIfLastLineNot(),this.indent()}endControlFlow(){this.dedent(),this.writeLine("}")}contiguousControlFlow(t,e){this.dedent(),this.write("} "),new C(t).write(this),this.write(" ("),this.writeNode(e),this.write(") {"),this.writeNewLineIfLastLineNot(),this.indent()}alternativeControlFlow(t){this.dedent(),this.write("} "),new C(t).write(this),this.write(" {"),this.writeNewLineIfLastLineNot(),this.indent()}writeLine(t=""){this.write(t),this.writeNewLineIfLastLineNot()}newLine(){this.writeInternal(`
|
|
6
|
+
`)}writeSemicolonIfLastCharacterIsNot(){this.lastCharacterIsSemicolon||this.writeInternal(";")}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
|
|
7
|
+
`)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:t,delimiter:e,writeFunction:r}){if(t.length>0){let i=t[0];i!=null&&r(i);for(let o=1;o<t.length;o++){this.write(e);let s=t[o];s!=null&&r(s)}}}toString(){return this.buffer}writeInternal(t){return t.length>0&&(this.hasWrittenAnything=!0,this.lastCharacterIsNewline=t.endsWith(`
|
|
8
|
+
`),this.lastCharacterIsSemicolon=t.endsWith(";")),this.buffer+=t}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*Rr)}};c();l();var Ee=class{formatMultiple(t){return Promise.all(t.map(e=>this.format(e)))}formatMultipleSync(t){return t.map(e=>this.formatSync(e))}},te=class extends Ee{async format(t){return t}formatSync(t){return t}};c();l();c();l();c();l();var re=class{constructor(){u(this,"reporter");u(this,"snippet");u(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}){var e;if(this.snippet!=null&&this.reporter!=null)return{snippet:this.snippet,errors:this.reporter.toDynamicSnippetErrors()};throw(e=this.err)!=null?e:new Error(`Failed to generate snippet for endpoint "${t.method} ${t.path}"`)}shouldUpdate({snippet:t,reporter:e}){var r,i;return this.reporter==null||this.reporter.size()>0&&e.size()===0?!0:t.length>((i=(r=this.snippet)==null?void 0:r.length)!=null?i:0)}};var ne=class{constructor(t){u(this,"context");this.context=t}async generate(t,e={}){let r=this.context.resolveEndpointLocationOrThrow(t.endpoint);if(r.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let i=new re;for(let o of r){let s=this.context.clone(),p=this.createSnippetGenerator(s);try{let h=await p.generateSnippet({endpoint:o,request:t,options:e});if(s.errors.empty())return{snippet:h,errors:void 0};i.update({context:s,snippet:h})}catch(h){i.err==null&&(i.err=h)}}return i.getResponseOrThrow({endpoint:t.endpoint})}generateSync(t,e={}){let r=this.context.resolveEndpointLocationOrThrow(t.endpoint);if(r.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let i=new re;for(let o of r){let s=this.context.clone(),p=this.createSnippetGenerator(s);try{let h=p.generateSnippetSync({endpoint:o,request:t,options:e});if(s.errors.empty())return{snippet:h,errors:void 0};i.update({context:s,snippet:h})}catch(h){i.err==null&&(i.err=h)}}return i.getResponseOrThrow({endpoint:t.endpoint})}};c();l();c();l();c();l();var ie=class{constructor(){u(this,"REFERENCE_REGEX",/^(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/)}validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let r=t.match(this.REFERENCE_REGEX);if(!(r==null||r[1]==null||r[2]==null))return{method:r[1],path:r[2]}}};c();l();var x={Critical:"CRITICAL",Warning:"WARNING"},oe=class n{constructor(){u(this,"errors");u(this,"path");this.errors=[],this.path=[]}add(t){this.errors.push(Ve($e({},t),{path:[...this.path]}))}scope(t){this.path.push(t)}unscope(){this.path.pop()}getBySeverity(t){return this.errors.filter(e=>e.severity===t)}empty(){return this.errors.length===0}size(){return this.errors.length}clone(){let t=new n;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 r of t){if(typeof r=="string"){e.push(r);continue}e[e.length-1]+=`[${r.index}]`}return e}};var se=class{constructor({ir:t,config:e,options:r={}}){u(this,"config");u(this,"options");u(this,"errors");u(this,"_ir");u(this,"httpEndpointReferenceParser");this._ir=t,this.config=e,this.options=r,this.errors=new oe,this.httpEndpointReferenceParser=new ie}associateQueryParametersByWireValue({parameters:t,values:e}){let r=[];for(let[i,o]of Object.entries(e)){this.errors.scope(i);try{let s=t.find(h=>h.name.wireValue===i);if(s==null)throw this.newParameterNotRecognizedError(i);let p=this.isListTypeReference(s.typeReference)&&!Array.isArray(o)?[o]:o;r.push({name:s.name,typeReference:s.typeReference,value:p})}finally{this.errors.unscope()}}return r}associateByWireValue({parameters:t,values:e,ignoreMissingParameters:r}){let i=[];for(let[o,s]of Object.entries(e)){this.errors.scope(o);try{let p=t.find(h=>h.name.wireValue===o);if(p==null){if(r)continue;this.errors.add({severity:x.Critical,message:this.newParameterNotRecognizedError(o).message});continue}i.push({name:p.name,typeReference:p.typeReference,value:s})}finally{this.errors.unscope()}}return i}getSingleFileValue({property:t,record:e}){let r=e[t.wireValue];if(r!=null){if(typeof r!="string"){this.errors.add({severity:x.Critical,message:`Expected file value to be a string, got ${typeof r}`});return}return r}}getFileArrayValues({property:t,record:e}){let r=e[t.wireValue];if(r==null)return;if(!Array.isArray(r)){this.errors.add({severity:x.Critical,message:`Expected file array value to be an array of strings, got ${typeof r}`});return}let i=[];for(let o of r){if(typeof o!="string"){this.errors.add({severity:x.Critical,message:`Expected file array value to be an array of strings, got ${typeof o}`});return}i.push(o)}return i}getRecord(t){if(typeof t!="object"||Array.isArray(t)){this.errors.add({severity:x.Critical,message:`Expected object with key, value pairs but got: ${Array.isArray(t)?"array":typeof t}`});return}return t==null?{}:t}resolveNamedType({typeId:t}){let e=this._ir.types[t];if(e==null){this.errors.add({severity:x.Critical,message:`Type identified by "${t}" could not be found`});return}return e}resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e}){let r=this.getRecord(e);if(r==null)return;let i=t.discriminant.wireValue,o=r[i];if(o==null){this.errors.add({severity:x.Critical,message:this.newParameterNotRecognizedError(i).message});return}if(typeof o!="string"){this.errors.add({severity:x.Critical,message:`Expected discriminant value to be a string but got: ${typeof o}`});return}let s=t.types[o];if(s==null){this.errors.add({severity:x.Critical,message:`No type found for discriminant value "${o}"`});return}let d=r,{[i]:p}=d,h=Oe(d,[Ye(i)]);return{singleDiscriminatedUnionType:s,discriminantValue:s.discriminantValue,value:h}}resolveEndpointOrThrow(t){let e=this.httpEndpointReferenceParser.tryParse(t);if(e==null)throw new Error(`Failed to parse endpoint reference "${t}"`);return this.resolveEndpointLocationOrThrow(e)}resolveEndpointLocationOrThrow(t){let e=[];for(let r of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:r,parsedEndpoint:t})&&e.push(r);if(e.length===0)throw new Error(`Failed to find endpoint identified by "${t.method} ${t.path}"`);return e}needsRequestParameter({request:t,inlinePathParameters:e,inlineFileProperties:r}){var 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:r}):!((i=t.metadata)!=null&&i.onlyPathParameters)}includePathParametersInWrappedRequest({request:t,inlinePathParameters:e}){var r,i;return e&&((i=(r=t.metadata)==null?void 0:r.includePathParameters)!=null?i:!1)}isFileUploadRequestBody(t){switch(t.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:v(t)}}resolveEnvironmentName(t){if(this._ir.environments==null)return;let e=this._ir.environments.environments;switch(e.type){case"singleBaseUrl":{let r=e.environments.find(i=>i.id===t);return r==null?void 0:r.name}case"multipleBaseUrls":{let r=e.environments.find(i=>i.id===t);return r==null?void 0:r.name}default:v(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:x.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:x.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let r=e.environments[0];if(r==null)return this.errors.add({severity:x.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let i=new Set(Z(r.urls));for(let o of Z(t))i.has(o)&&i.delete(o);return i.size>0?(this.errors.add({severity:x.Critical,message:`The provided environments are invalid; got: [${Object.keys(t).join(", ")}], expected: [${Z(r.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:t}){if(typeof t!="number"){this.errors.add({severity:x.Critical,message:this.newTypeMismatchError({expected:"number",value:t}).message});return}return t}getValueAsBoolean({value:t}){if(typeof t!="boolean"){this.errors.add({severity:x.Critical,message:this.newTypeMismatchError({expected:"boolean",value:t}).message});return}return t}getValueAsString({value:t}){if(typeof t!="string"){this.errors.add({severity:x.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:v(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:v(e)}})}fileUploadHasFileProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:v(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();l();c();l();var f={};qe(f,{AstNode:()=>g,ClassInstantiation:()=>Y,ClassReference:()=>O,CodeBlock:()=>q,KeywordArgument:()=>G,Method:()=>W,MethodInvocation:()=>z,Parameter:()=>T,TypeLiteral:()=>fe,TypeParameter:()=>H,classReference:()=>Pr,class_:()=>Cr,codeblock:()=>br,comment:()=>Lr,instantiateClass:()=>Br,invokeMethod:()=>Mr,keywordArgument:()=>Fr,method:()=>Sr,module:()=>Nr,parameters:()=>Ir,positionalArgument:()=>_r,typeParameter:()=>kr});c();l();c();l();c();l();c();l();c();l();c();l();c();l();var Re=class extends ee{constructor({customConfig:e,formatter:r}){super();u(this,"customConfig");u(this,"formatter");u(this,"requires",new Set);this.customConfig=e,this.formatter=r!=null?r:new te}addRequire(e){this.requires.add(e)}};var J=class extends Re{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}
|
|
9
|
+
${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}
|
|
10
|
+
${t}`)}return t}getContent(){let t=this.stringifyRequires();return t.length>0?`${t}
|
|
11
|
+
|
|
12
|
+
${this.buffer}`:this.buffer}stringifyRequires(){return Array.from(this.requires).map(t=>`require "${t}"`).join(`
|
|
13
|
+
`)}};var g=class extends D{async toStringAsync({customConfig:t,formatter:e}){let r=new J({customConfig:t,formatter:e});return this.write(r),r.toStringAsync()}toString({customConfig:t,formatter:e}){let r=new J({customConfig:t,formatter:e});return this.write(r),r.toString()}typeDefinitionToString({customConfig:t,formatter:e}){let r=new J({customConfig:t,formatter:e});return this.writeTypeDefinition(r),r.toString()}writeTypeDefinition(t){}};var N=class extends g{constructor({docs:e}){super();u(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
|
|
14
|
+
`).forEach(r=>{e.writeLine(`# ${r}`)})}};c();l();var $=class n extends g{constructor({name:e,namespace:r,typeParameters:i,docstring:o,statements:s}){super();u(this,"name");u(this,"namespace");u(this,"typeParameters");u(this,"docstring");u(this,"statements");this.name=e,this.namespace=r!=null?r:new Set,this.typeParameters=i!=null?i:[],this.docstring=o,this.statements=s!=null?s:[],this.populateChildNamespaces()}write(e){this.docstring&&new N({docs:this.docstring}).write(e),e.write(`module ${this.name}`),this.statements.length?(e.newLine(),e.indent(),this.statements.forEach((r,i)=>{r.write(e),i<this.statements.length-1&&e.newLine()}),e.dedent(),e.write("end")):e.write("; end"),e.newLine()}writeTypeDefinition(e){e.write(`module ${this.name}`),this.typeParameters.length&&(e.write("["),e.delimit({nodes:this.typeParameters,delimiter:", ",writeFunction:r=>r.writeTypeDefinition(e)}),e.write("]")),e.newLine(),this.statements.length&&(e.indent(),this.statements.forEach(r=>{r.writeTypeDefinition(e),e.newLine()}),e.dedent()),e.write("end")}populateChildNamespaces(){this.statements.filter(e=>e instanceof n||e instanceof V).forEach(e=>{e.namespace=new Set([...this.namespace,this]),e.populateChildNamespaces()})}get fullyQualifiedNamespace(){return[...this.namespace,this].map(e=>e.name).join("::")}};var V=class extends ${constructor({name:e,superclass:r,typeParameters:i,docstring:o,statements:s}){super({name:e,docstring:o,typeParameters:i});u(this,"superclass");u(this,"statements");this.superclass=r,this.statements=s!=null?s:[]}write(e){this.docstring&&new N({docs:this.docstring}).write(e),e.write(`class ${this.name}`),this.superclass&&e.write(` < ${this.superclass.name}`),this.statements.length?(e.newLine(),e.indent(),this.statements.forEach((r,i)=>{r.write(e),i<this.statements.length-1&&e.newLine()}),e.dedent(),e.write("end")):e.write("; end"),e.newLine()}writeTypeDefinition(e){e.write(`class ${this.name}`),this.typeParameters.length&&(e.write("["),e.delimit({nodes:this.typeParameters,delimiter:", ",writeFunction:r=>r.writeTypeDefinition(e)}),e.write("]")),this.superclass&&e.write(` < ${this.superclass.name}`),e.newLine(),this.statements.length&&(e.indent(),this.statements.forEach(r=>{r.writeTypeDefinition(e),e.newLine()}),e.dedent()),e.write("end")}};c();l();var Y=class extends g{constructor({classReference:e,arguments_:r}){super();u(this,"classReference");u(this,"arguments_");this.classReference=e,this.arguments_=r}write(e){e.writeNode(this.classReference),e.write("."),e.write("new"),e.write("("),this.arguments_.length>1?(e.indent(),e.newLine(),this.arguments_.forEach((r,i)=>{i>0&&(e.write(","),e.newLine()),r.write(e)}),e.newLine(),e.dedent()):this.arguments_.forEach((r,i)=>{i>0&&e.write(", "),r.write(e)}),e.write(")")}};c();l();var O=class extends g{constructor({name:e,modules:r,fullyQualified:i}){super();u(this,"name");u(this,"modules");u(this,"fullyQualified");this.name=e,this.modules=r!=null?r:[],this.fullyQualified=i!=null?i:!1}write(e){if(this.fullyQualified||this.modules.length>0){let r=[...this.modules,this.name].join("::");e.write(r);return}e.write(this.name)}};c();l();var q=class extends g{constructor(e){super();u(this,"arg");this.arg=e}write(e){return new C(this.arg).write(e)}};c();l();var G=class extends g{constructor({name:e,value:r}){super();u(this,"name");u(this,"value");this.name=e,this.value=r}write(e){e.write(`${this.name}: `),this.value.write(e)}};c();l();c();l();c();l();var Q=class n extends g{constructor(e){super();u(this,"internalType");this.internalType=e}write(e){}writeTypeDefinition(e){if(this.internalType)switch(this.internalType.type){case"self":e.write("self");break;case"class":e.write("class");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:r=>r.writeTypeDefinition(e)});break;case"intersection":e.delimit({nodes:this.internalType.elems,delimiter:" & ",writeFunction:r=>r.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:r=>r.write(e)}),e.write("]");break;case"generic":e.write(`${this.internalType.baseKlass}[`),e.delimit({nodes:this.internalType.parameters,delimiter:", ",writeFunction:r=>r.writeTypeDefinition(e)}),e.write("]");break;default:v(this.internalType)}else e.write("untyped")}static untyped(){return new this(void 0)}static self(){return new this({type:"self"})}static class_(){return new this({type:"class"})}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,r){return new this({type:"hash",keyType:e,valueType:r})}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,r){return new this({type:"generic",baseKlass:e,parameters:r})}static nilable(e){return n.union([e,n.nil()])}nilable(){return n.nilable(this)}};var T=class extends g{constructor({name:e,type:r,optional:i}){super();u(this,"name");u(this,"type");u(this,"optional");this.name=e,this.type=r!=null?r:Q.untyped(),this.optional=i!=null?i:!1}};var ae=class extends T{constructor({name:e,type:r,initializer:i,optional:o}){super({name:e,type:r,optional:o});u(this,"initializer");this.initializer=i}write(e){e.write(`${this.name}:`),this.initializer&&e.write(` ${this.initializer.write(e)}`)}writeTypeDefinition(e){this.optional&&e.write("?"),e.write(`${this.name}: `),this.type.writeTypeDefinition(e)}};c();l();var ue=class extends T{constructor(){super(...arguments);u(this,"initializer")}write(e){e.write(`**${this.name}`)}writeTypeDefinition(e){e.write("**"),this.type.writeTypeDefinition(e)}};c();l();var be={Instance:"instance",Class_:"class"},ht={Public:"public",Private:"private",Protected:"protected"},W=class extends g{constructor({name:e,docstring:r,kind:i,visibility:o,parameters:s,returnType:p}){var h,d;super();u(this,"name");u(this,"docstring");u(this,"kind");u(this,"positionalParameters");u(this,"keywordParameters");u(this,"positionalSplatParameter");u(this,"keywordSplatParameter");u(this,"yieldParameter");u(this,"visibility");u(this,"statements",[]);u(this,"returnType");this.name=e,this.docstring=r,this.kind=i!=null?i:be.Instance,this.visibility=o!=null?o:ht.Public,this.positionalParameters=(h=s==null?void 0:s.positional)!=null?h:[],this.keywordParameters=(d=s==null?void 0:s.keyword)!=null?d:[],this.positionalSplatParameter=s==null?void 0:s.positionalSplat,this.keywordSplatParameter=s==null?void 0:s.keywordSplat,this.yieldParameter=s==null?void 0:s.yield,this.returnType=p!=null?p:Q.untyped()}write(e){switch(this.docstring&&new N({docs:this.docstring}).write(e),this.visibility!==ht.Public&&(e.write(this.visibility),this.kind===be.Class_&&e.write("_class_method"),e.write(" ")),this.kind){case be.Instance:e.write(`def ${this.name}`);break;case be.Class_:e.write(`def self.${this.name}`);break}this.parameters.length&&(e.write("("),e.delimit({nodes:this.parameters,delimiter:", ",writeFunction:r=>r.write(e)}),e.write(")")),this.statements.length?(e.newLine(),e.indent(),this.statements.forEach((r,i)=>{r.write(e),i<this.statements.length-1&&e.newLine()}),e.dedent(),e.write("end")):e.write("; end"),e.newLine()}writeTypeDefinition(e){e.write(`def ${this.name}: (`),this.parameters.forEach((r,i)=>{r.writeTypeDefinition(e),i<this.parameters.length-1&&e.write(", ")}),e.write(") -> "),this.returnType.writeTypeDefinition(e)}get parameters(){return[...this.positionalParameters,...this.keywordParameters,this.positionalSplatParameter,this.keywordSplatParameter,this.yieldParameter].flatMap(e=>e!==void 0?e:[])}};c();l();var z=class extends g{constructor({on:e,method:r,arguments_:i}){super();u(this,"on");u(this,"method");u(this,"arguments_");this.on=e,this.method=r,this.arguments_=i}write(e){this.on.write(e),e.write("."),e.write(this.method),e.write("("),this.arguments_.length>1?(e.indent(),e.newLine(),this.arguments_.forEach((r,i)=>{i>0&&(e.write(","),e.newLine()),r.write(e)}),e.newLine(),e.dedent()):this.arguments_.forEach((r,i)=>{i>0&&e.write(", "),r.write(e)}),e.write(")")}};c();l();var ce=class extends g{constructor({value:e}){super();u(this,"value");this.value=e}write(e){this.value.write(e)}};c();l();var le=class extends T{constructor({name:e,type:r,optional:i,initializer:o}){super({name:e,type:r,optional:i});u(this,"initializer");this.initializer=o}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();l();var pe=class extends T{write(t){t.write(`*${this.name}`)}writeTypeDefinition(t){t.write("*"),this.type.writeTypeDefinition(t)}};c();l();var fe=class n extends g{constructor(e){super();u(this,"internalType");this.internalType=e}static string(e){return new this({type:"str",value:e})}static integer(e){return new this({type:"int",value:e})}static float(e){return new this({type:"float",value:e})}static boolean(e){return new this({type:"bool",value:e})}static hash(e){return new this({type:"hash",entries:e})}static set(e){return new this({type:"set",values:e})}static list(e){return new this({type:"list",values:e})}static nop(){return new this({type:"nop"})}static nil(){return new this({type:"nil"})}static isNop(e){return e instanceof n&&e.internalType.type==="nop"}static isNil(e){return e instanceof n&&e.internalType.type==="nil"}write(e){switch(this.internalType.type){case"str":{this.internalType.value.includes("'")?e.write(`"${this.internalType.value.replaceAll('"','\\"')}"`):e.write(`'${this.internalType.value}'`);break}case"int":{e.write(this.internalType.value.toString());break}case"float":{e.write(this.internalType.value.toString());break}case"bool":{e.write(this.internalType.value?"true":"false");break}case"hash":{let r=this.internalType.entries.filter(i=>!n.isNop(i.key)&&!n.isNop(i.value));if(r.length===0){e.write("{}");break}e.write(`{
|
|
15
|
+
`),r.forEach((i,o)=>{o>0&&e.writeLine(","),e.indent();let s=!1;if(i.key instanceof n&&i.key.internalType.type==="str"){let p=i.key.internalType.value;/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(p)&&(e.write(`${p}:`),s=!0)}s||(i.key.write(e),e.write(":")),i.value.write(e),e.dedent()}),e.write(`
|
|
16
|
+
}`);break}case"set":{let r=this.internalType.values.filter(i=>!n.isNop(i));if(r.length===0){e.write("Set.new([])");break}e.write("Set.new(["),r.forEach((i,o)=>{o>0&&e.write(", "),i.write(e)}),e.write("])");break}case"list":{let r=this.internalType.values.filter(i=>!n.isNop(i));if(r.length===0){e.write("[]");break}e.write("["),r.forEach((i,o)=>{o>0&&e.write(", "),i.write(e)}),e.write("]");break}case"nop":break;case"nil":e.write("nil");break;default:v(this.internalType)}}};c();l();var Ie;(function(n){n[n.Invariant=0]="Invariant",n.Covariant="out",n.Contravariant="in"})(Ie||(Ie={}));var H=class extends g{constructor({name:e,unchecked:r,bound:i,variance:o,defaultType:s}){super();u(this,"name");u(this,"unchecked");u(this,"bound");u(this,"variance");u(this,"defaultType");this.name=e,this.unchecked=r!=null?r:!1,this.bound=i,this.variance=o!=null?o:Ie.Invariant,this.defaultType=s}write(e){}writeTypeDefinition(e){this.unchecked&&e.write("unchecked "),this.variance!=Ie.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();l();var he=class extends T{constructor(){super(...arguments);u(this,"initializer")}write(e){e.write(`&${this.name}`)}};function br(n){return new q(n)}var Ir={positional(n){return new le(n)},keyword(n){return new ae(n)},positionalSplat(n){return new pe(n)},keywordSplat(n){return new ue(n)},yield(n){return new he(n)}};function Cr(n){return new V(n)}function Nr(n){return new $(n)}function Sr(n){return new W(n)}function Lr(n){return new N(n)}function kr(n){return new H(n)}function Pr(n){return new O(n)}function Br(n){return new Y(n)}function Fr(n){return new G(n)}function Mr(n){return new z(n)}function _r(n){return new ce(n)}var mt="client",Ce=class{constructor({context:t,formatter:e}){u(this,"context");u(this,"formatter");this.context=t,this.formatter=e}async generateSnippet({endpoint:t,request:e}){var i;return await this.buildCodeBlock({endpoint:t,snippet:e}).toStringAsync({customConfig:(i=this.context.customConfig)!=null?i:{},formatter:this.formatter})}generateSnippetSync({endpoint:t,request:e}){var i;return this.buildCodeBlock({endpoint:t,snippet:e}).toString({customConfig:(i=this.context.customConfig)!=null?i:{},formatter:this.formatter})}buildCodeBlock({endpoint:t,snippet:e}){return f.codeblock(r=>{r.writeNodeStatement(this.constructClient({endpoint:t,snippet:e})),r.newLine(),r.writeNodeStatement(this.callMethod({endpoint:t,snippet:e}))})}constructClient({endpoint:t,snippet:e}){return f.codeblock(r=>{r.addRequire(this.context.getRootModuleName());let i=this.context.getRootClientClassReference(),o=this.getRootClientBuilderArgs({endpoint:t,snippet:e});r.write(`${mt} = `),r.writeNode(f.instantiateClass({classReference:i,arguments_:o}))})}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[f.keywordArgument({name:"base_url",value:f.TypeLiteral.string(t)})];if(e!=null){if(this.context.isSingleEnvironmentID(e)){let r=this.context.getEnvironmentTypeReferenceFromID(e);return r==null?(this.context.errors.add({severity:"CRITICAL",message:`Environment ID ${e} not found`}),[]):[f.keywordArgument({name:"environment",value:r})]}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}){switch(t.type){case"basic":return e.type!=="basic"?(this.context.errors.add({severity:"CRITICAL",message:this.context.newAuthMismatchError({auth:t,values:e}).message}),[]):this.getRootClientBasicAuthArgs({auth:t,values:e});case"bearer":return e.type!=="bearer"?(this.context.errors.add({severity:"CRITICAL",message:this.context.newAuthMismatchError({auth:t,values:e}).message}),[]):this.getRootClientBearerAuthArgs({auth:t,values:e});case"header":return e.type!=="header"?(this.context.errors.add({severity:"CRITICAL",message:this.context.newAuthMismatchError({auth:t,values:e}).message}),[]):this.getRootClientHeaderAuthArgs({auth:t,values:e});case"oauth":return e.type!=="oauth"?(this.context.errors.add({severity:"CRITICAL",message:this.context.newAuthMismatchError({auth:t,values:e}).message}),[]):this.getRootClientOAuthArgs({auth:t,values:e});default:return[]}}getRootClientBasicAuthArgs({auth:t,values:e}){return[f.keywordArgument({name:t.username.snakeCase.safeName,value:f.TypeLiteral.string(e.username)}),f.keywordArgument({name:t.password.snakeCase.safeName,value:f.TypeLiteral.string(e.password)})]}getRootClientBearerAuthArgs({auth:t,values:e}){return[f.keywordArgument({name:t.token.snakeCase.safeName,value:f.TypeLiteral.string(e.token)})]}getRootClientHeaderAuthArgs({auth:t,values:e}){return[f.keywordArgument({name:t.header.name.name.snakeCase.safeName,value:f.TypeLiteral.string(e.value)})]}getRootClientOAuthArgs({auth:t,values:e}){return[f.keywordArgument({name:t.clientId.snakeCase.safeName,value:f.TypeLiteral.string(e.clientId)}),f.keywordArgument({name:t.clientSecret.snakeCase.safeName,value:f.TypeLiteral.string(e.clientSecret)})]}getRootClientHeaderArgs({headers:t,values:e}){let r=[];for(let i of t){let o=e[i.name.name.originalName];o!=null&&typeof o=="string"&&r.push(f.keywordArgument({name:i.name.name.snakeCase.safeName,value:f.TypeLiteral.string(o)}))}return r}getRootClientBuilderArgs({endpoint:t,snippet:e}){let r=[];t.auth!=null&&(e.auth!=null?r.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 i=this.getRootClientBaseUrlArg({baseUrl:e.baseURL,environment:e.environment});return i.length>0&&r.push(...i),this.context.errors.scope("Headers"),this.context.ir.headers!=null&&e.headers!=null&&r.push(...this.getRootClientHeaderArgs({headers:this.context.ir.headers,values:e.headers})),this.context.errors.unscope(),r}callMethod({endpoint:t,snippet:e}){return f.invokeMethod({on:f.codeblock(mt),method:this.getMethod({endpoint:t}),arguments_:this.getMethodArgs({endpoint:t,snippet:e})})}getMethodArgs({endpoint:t,snippet:e}){switch(t.request.type){case"inlined":return[this.getMethodArgsForInlinedRequest({request:t.request,snippet:e})];case"body":return this.getMethodArgsForBodyRequest({request:t.request,snippet:e});default:v(t.request)}}getMethodArgsForInlinedRequest({request:t,snippet:e}){let r=[];if(r.push(...this.getNamedParameterArgs({kind:"PathParameters",namedParameters:t.pathParameters,values:e.pathParameters})),r.push(...this.getNamedParameterArgs({kind:"QueryParameters",namedParameters:t.queryParameters,values:e.queryParameters})),r.push(...this.getNamedParameterArgs({kind:"Headers",namedParameters:t.headers,values:e.headers})),t.body!=null)switch(t.body.type){case"properties":r.push(...this.getMethodArgsForPropertiesRequest({request:t.body,snippet:e}));break;case"referenced":case"fileUpload":break;default:v(t.body)}return f.TypeLiteral.hash(r.map(i=>({key:f.TypeLiteral.string(i.name),value:i.value})))}getNamedParameterArgs({kind:t,namedParameters:e,values:r}){let i=[];if(this.context.errors.scope(t),e!=null){let o=this.context.associateByWireValue({parameters:e,values:r!=null?r:{},ignoreMissingParameters:!0});for(let s of o)i.push(f.keywordArgument({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)}))}return this.context.errors.unscope(),i}getMethodArgsForPropertiesRequest({request:t,snippet:e}){var o;let r=[],i=this.context.associateByWireValue({parameters:t.value,values:(o=this.context.getRecord(e.requestBody))!=null?o:{}});for(let s of i)r.push(f.keywordArgument({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)}));return r}getMethodArgsForBodyRequest({request:t,snippet:e}){if(t.body==null)return[];switch(t.body.type){case"bytes":return this.context.errors.add({severity:"CRITICAL",message:"Multi-environment values are not supported in Ruby snippets yet"}),[];case"typeReference":return[f.positionalArgument({value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t.body.value,value:this.context.getRecord(e.requestBody)})})];default:v(t.body)}}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)}};c();l();c();l();var Ne=class{constructor({context:t}){u(this,"context");this.context=t}convert(t){if(t.value===null)return this.context.isNullable(t.typeReference)?f.TypeLiteral.nil():(this.context.errors.add({severity:x.Critical,message:"Expected non-null value, but got null"}),f.TypeLiteral.nop());if(t.value===void 0)return f.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?f.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 f.TypeLiteral.nop();default:v(t.typeReference)}}convertLiteral({literalType:t,value:e}){switch(t.type){case"boolean":{let r=this.context.getValueAsBoolean({value:e});return r==null?f.TypeLiteral.nop():f.TypeLiteral.boolean(r)}case"string":{let r=this.context.getValueAsString({value:e});return r==null?f.TypeLiteral.nop():f.TypeLiteral.string(r)}default:v(t)}}convertList({list:t,value:e}){return Array.isArray(e)?f.TypeLiteral.list(e.map((r,i)=>{this.context.errors.scope({index:i});try{return this.convert({typeReference:t,value:r})}finally{this.context.errors.unscope()}})):(this.context.errors.add({severity:x.Critical,message:`Expected array but got: ${typeof e}`}),f.TypeLiteral.nop())}convertSet({set:t,value:e}){return Array.isArray(e)?f.TypeLiteral.set(e.map((r,i)=>{this.context.errors.scope({index:i});try{return this.convert({typeReference:t,value:r})}finally{this.context.errors.unscope()}})):(this.context.errors.add({severity:x.Critical,message:`Expected array but got: ${typeof e}`}),f.TypeLiteral.nop())}convertMap({map:t,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:x.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),f.TypeLiteral.nop()):f.TypeLiteral.hash(Object.entries(e).map(([r,i])=>{this.context.errors.scope(r);try{return{key:this.convert({typeReference:t.key,value:r,as:"key"}),value:this.convert({typeReference:t.value,value:i})}}finally{this.context.errors.unscope()}}))}convertNamed({named:t,value:e,as:r}){switch(t.type){case"alias":return this.convert({typeReference:t.typeReference,value:e,as:r});case"discriminatedUnion":return f.TypeLiteral.nop();case"object":return this.convertObject({object:t,value:e});case"enum":return f.TypeLiteral.nop();case"undiscriminatedUnion":return f.TypeLiteral.nop();default:v(t)}}convertPrimitive({primitive:t,value:e,as:r}){switch(t){case"INTEGER":case"LONG":case"UINT":case"UINT_64":{let i=this.getValueAsNumber({value:e,as:r});return i==null?f.TypeLiteral.nop():f.TypeLiteral.integer(i)}case"FLOAT":case"DOUBLE":{let i=this.getValueAsNumber({value:e});return i==null?f.TypeLiteral.nop():f.TypeLiteral.float(i)}case"BOOLEAN":{let i=this.getValueAsBoolean({value:e,as:r});return i==null?f.TypeLiteral.nop():f.TypeLiteral.boolean(i)}case"BASE_64":case"BIG_INTEGER":case"STRING":{let i=this.context.getValueAsString({value:e});return i==null?f.TypeLiteral.nop():f.TypeLiteral.string(i)}case"UUID":{let i=this.context.getValueAsString({value:e});return i==null?f.TypeLiteral.nop():f.TypeLiteral.string(i)}case"DATE":{let i=this.context.getValueAsString({value:e});return i==null?f.TypeLiteral.nop():f.TypeLiteral.string(i)}case"DATE_TIME":{let i=this.context.getValueAsString({value:e});return i==null?f.TypeLiteral.nop():f.TypeLiteral.string(i)}default:v(t)}}convertObject({object:t,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:x.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),f.TypeLiteral.nop()):f.TypeLiteral.hash(Object.entries(e).map(([r,i])=>{var h;this.context.errors.scope(r);let o=t.properties.find(d=>d.name.wireValue===r),s=(h=o==null?void 0:o.typeReference)!=null?h:{type:"unknown"},p={key:f.TypeLiteral.string(r),value:this.convert({typeReference:s,value:i})};return this.context.errors.unscope(),p}))}getValueAsNumber({value:t,as:e}){let r=e==="key"&&typeof t=="string"?Number(t):t;return this.context.getValueAsNumber({value:r})}getValueAsBoolean({value:t,as:e}){let r=e==="key"?typeof t=="string"?t==="true":!!t:t;return this.context.getValueAsBoolean({value:r})}};var Se=class n extends se{constructor({ir:e,config:r}){super({ir:e,config:r});u(this,"ir");u(this,"customConfig");u(this,"dynamicTypeLiteralMapper");this.ir=e,this.customConfig=r.customConfig!=null?r.customConfig:void 0,this.dynamicTypeLiteralMapper=new Ne({context:this})}clone(){return new n({ir:this.ir,config:this.config})}getRootClientClassReference(){return f.classReference({name:this.getRootClientClassName(),modules:[this.getRootModuleName()]})}getRootClientClassName(){return"Client"}getRootModuleName(){var e,r;return(r=(e=this.customConfig)==null?void 0:e.clientModuleName)!=null?r:this.config.organization}isSingleEnvironmentID(e){return typeof e=="string"}isMultiEnvironmentValues(e){return typeof e=="object"}getEnvironmentTypeReferenceFromID(e){let r=this.resolveEnvironmentName(e);if(r!=null)return f.codeblock(i=>{i.writeNode(this.getEnvironmentClassReference()),i.write("::"),i.write(this.getEnumName(r))})}getEnvironmentClassReference(){return f.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.camelCase.safeName)}getName(e){return e}};var Ue=class extends ne{constructor({ir:e,config:r,formatter:i}){super(new Se({ir:e,config:r}));u(this,"formatter");this.formatter=i}async generate(e){return super.generate(e)}generateSync(e){return super.generateSync(e)}createSnippetGenerator(e){return new Ce({context:e,formatter:this.formatter})}};0&&(module.exports={DynamicSnippetsGenerator});
|
|
17
|
+
/*! Bundled license information:
|
|
18
|
+
|
|
19
|
+
@esbuild-plugins/node-globals-polyfill/Buffer.js:
|
|
20
|
+
(*!
|
|
21
|
+
* The buffer module from node.js, for the browser.
|
|
22
|
+
*
|
|
23
|
+
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
24
|
+
* @license MIT
|
|
25
|
+
*)
|
|
26
|
+
*/
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AbstractDynamicSnippetsGenerator, FernGeneratorExec, AbstractFormatter } from '@fern-api/browser-compatible-base-generator';
|
|
2
|
+
import { FernIr } from '@fern-api/dynamic-ir-sdk';
|
|
3
|
+
import { EndpointSnippetGenerator } from './EndpointSnippetGenerator.cjs';
|
|
4
|
+
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-BGmCyT7y.cjs';
|
|
5
|
+
import '@fern-api/ruby-ast';
|
|
6
|
+
|
|
7
|
+
declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<DynamicSnippetsGeneratorContext, EndpointSnippetGenerator> {
|
|
8
|
+
private formatter;
|
|
9
|
+
constructor({ ir, config, formatter }: {
|
|
10
|
+
ir: FernIr.dynamic.DynamicIntermediateRepresentation;
|
|
11
|
+
config: FernGeneratorExec.GeneratorConfig;
|
|
12
|
+
formatter?: AbstractFormatter;
|
|
13
|
+
});
|
|
14
|
+
generate(request: FernIr.dynamic.EndpointSnippetRequest): Promise<FernIr.dynamic.EndpointSnippetResponse>;
|
|
15
|
+
generateSync(request: FernIr.dynamic.EndpointSnippetRequest): FernIr.dynamic.EndpointSnippetResponse;
|
|
16
|
+
protected createSnippetGenerator(context: DynamicSnippetsGeneratorContext): EndpointSnippetGenerator;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { DynamicSnippetsGenerator };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { AbstractDynamicSnippetsGeneratorContext, FernGeneratorExec } from '@fern-api/browser-compatible-base-generator';
|
|
2
|
+
import { FernIr } from '@fern-api/dynamic-ir-sdk';
|
|
3
|
+
import { ruby, BaseRubyCustomConfigSchema } from '@fern-api/ruby-ast';
|
|
4
|
+
|
|
5
|
+
declare namespace DynamicTypeLiteralMapper {
|
|
6
|
+
interface Args {
|
|
7
|
+
typeReference: FernIr.dynamic.TypeReference;
|
|
8
|
+
value: unknown;
|
|
9
|
+
as?: ConvertedAs;
|
|
10
|
+
}
|
|
11
|
+
type ConvertedAs = "key";
|
|
12
|
+
}
|
|
13
|
+
declare class DynamicTypeLiteralMapper {
|
|
14
|
+
private context;
|
|
15
|
+
constructor({ context }: {
|
|
16
|
+
context: DynamicSnippetsGeneratorContext;
|
|
17
|
+
});
|
|
18
|
+
convert(args: DynamicTypeLiteralMapper.Args): ruby.AstNode;
|
|
19
|
+
private convertLiteral;
|
|
20
|
+
private convertList;
|
|
21
|
+
private convertSet;
|
|
22
|
+
private convertMap;
|
|
23
|
+
private convertNamed;
|
|
24
|
+
private convertPrimitive;
|
|
25
|
+
private convertObject;
|
|
26
|
+
private getValueAsNumber;
|
|
27
|
+
private getValueAsBoolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGeneratorContext {
|
|
31
|
+
ir: FernIr.dynamic.DynamicIntermediateRepresentation;
|
|
32
|
+
customConfig: BaseRubyCustomConfigSchema | undefined;
|
|
33
|
+
dynamicTypeLiteralMapper: DynamicTypeLiteralMapper;
|
|
34
|
+
constructor({ ir, config }: {
|
|
35
|
+
ir: FernIr.dynamic.DynamicIntermediateRepresentation;
|
|
36
|
+
config: FernGeneratorExec.GeneratorConfig;
|
|
37
|
+
});
|
|
38
|
+
clone(): DynamicSnippetsGeneratorContext;
|
|
39
|
+
getRootClientClassReference(): ruby.ClassReference;
|
|
40
|
+
getRootClientClassName(): string;
|
|
41
|
+
getRootModuleName(): string;
|
|
42
|
+
isSingleEnvironmentID(environment: FernIr.dynamic.EnvironmentValues): environment is FernIr.EnvironmentId;
|
|
43
|
+
isMultiEnvironmentValues(environment: FernIr.dynamic.EnvironmentValues): environment is FernIr.dynamic.MultipleEnvironmentUrlValues;
|
|
44
|
+
getEnvironmentTypeReferenceFromID(environmentID: string): ruby.AstNode | undefined;
|
|
45
|
+
getEnvironmentClassReference(): ruby.AstNode;
|
|
46
|
+
getEnumName(name: FernIr.Name): string;
|
|
47
|
+
getMethodName(name: FernIr.Name): string;
|
|
48
|
+
getPropertyName(name: FernIr.Name): string;
|
|
49
|
+
private getName;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { DynamicSnippetsGeneratorContext as D, DynamicTypeLiteralMapper as a };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";var ae=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var et=Object.prototype.hasOwnProperty;var tt=(r,t,e)=>t in r?ae(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var ge=(r,t)=>()=>(r&&(t=r(r=0)),t);var Re=(r,t)=>{for(var e in t)ae(r,e,{get:t[e],enumerable:!0})},rt=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of je(t))!et.call(r,n)&&n!==e&&ae(r,n,{get:()=>t[n],enumerable:!(i=Xe(t,n))||i.enumerable});return r};var it=r=>rt(ae({},"__esModule",{value:!0}),r);var u=(r,t,e)=>tt(r,typeof t!="symbol"?t+"":t,e);function be(){throw new Error("setTimeout has not been defined")}function Ce(){throw new Error("clearTimeout has not been defined")}function Ne(r){if(B===setTimeout)return setTimeout(r,0);if((B===be||!B)&&setTimeout)return B=setTimeout,setTimeout(r,0);try{return B(r,0)}catch(t){try{return B.call(null,r,0)}catch(e){return B.call(this,r,0)}}}function nt(r){if(L===clearTimeout)return clearTimeout(r);if((L===Ce||!L)&&clearTimeout)return L=clearTimeout,clearTimeout(r);try{return L(r)}catch(t){try{return L.call(null,r)}catch(e){return L.call(this,r)}}}function ot(){!J||!_||(J=!1,_.length?N=_.concat(N):ue=-1,N.length&&Se())}function Se(){if(!J){var r=Ne(ot);J=!0;for(var t=N.length;t;){for(_=N,N=[];++ue<t;)_&&_[ue].run();ue=-1,t=N.length}_=null,J=!1,nt(r)}}function st(r){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];N.push(new Pe(r,t)),N.length===1&&!J&&Ne(Se)}function Pe(r,t){this.fun=r,this.array=t}function M(){}function Et(r){throw new Error("process.binding is not supported")}function It(){return"/"}function Rt(r){throw new Error("process.chdir is not supported")}function kt(){return 0}function Ct(r){var t=bt.call(G)*.001,e=Math.floor(t),i=Math.floor(t%1*1e9);return r&&(e=e-r[0],i=i-r[1],i<0&&(e--,i+=1e9)),[e,i]}function St(){var r=new Date,t=r-Nt;return t/1e3}var B,L,N,J,_,ue,at,ut,ht,ft,ct,lt,pt,mt,dt,wt,yt,xt,gt,At,Tt,vt,G,bt,Nt,d,ke,h=ge(()=>{"use strict";B=be,L=Ce;typeof globalThis.setTimeout=="function"&&(B=setTimeout);typeof globalThis.clearTimeout=="function"&&(L=clearTimeout);N=[],J=!1,ue=-1;Pe.prototype.run=function(){this.fun.apply(null,this.array)};at="browser",ut="browser",ht=!0,ft={},ct=[],lt="",pt={},mt={},dt={};wt=M,yt=M,xt=M,gt=M,At=M,Tt=M,vt=M;G=globalThis.performance||{},bt=G.now||G.mozNow||G.msNow||G.oNow||G.webkitNow||function(){return new Date().getTime()};Nt=new Date;d={nextTick:st,title:at,browser:ht,env:ft,argv:ct,version:lt,versions:pt,on:wt,addListener:yt,once:xt,off:gt,removeListener:At,removeAllListeners:Tt,emit:vt,binding:Et,cwd:It,chdir:Rt,umask:kt,hrtime:Ct,platform:ut,release:mt,config:dt,uptime:St},ke={};Object.keys(ke).forEach(r=>{let t=r.split("."),e=d;for(let i=0;i<t.length;i++){let n=t[i];i===t.length-1?e[n]=ke[r]:e=e[n]||(e[n]={})}})});function Me(){Te=!0;for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=r.length;t<e;++t)b[t]=r[t],E[r.charCodeAt(t)]=t;E[45]=62,E[95]=63}function Bt(r){Te||Me();var t,e,i,n,o,s,c=r.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o=r[c-2]==="="?2:r[c-1]==="="?1:0,s=new Pt(c*3/4-o),i=o>0?c-4:c;var l=0;for(t=0,e=0;t<i;t+=4,e+=3)n=E[r.charCodeAt(t)]<<18|E[r.charCodeAt(t+1)]<<12|E[r.charCodeAt(t+2)]<<6|E[r.charCodeAt(t+3)],s[l++]=n>>16&255,s[l++]=n>>8&255,s[l++]=n&255;return o===2?(n=E[r.charCodeAt(t)]<<2|E[r.charCodeAt(t+1)]>>4,s[l++]=n&255):o===1&&(n=E[r.charCodeAt(t)]<<10|E[r.charCodeAt(t+1)]<<4|E[r.charCodeAt(t+2)]>>2,s[l++]=n>>8&255,s[l++]=n&255),s}function Lt(r){return b[r>>18&63]+b[r>>12&63]+b[r>>6&63]+b[r&63]}function _t(r,t,e){for(var i,n=[],o=t;o<e;o+=3)i=(r[o]<<16)+(r[o+1]<<8)+r[o+2],n.push(Lt(i));return n.join("")}function Be(r){Te||Me();for(var t,e=r.length,i=e%3,n="",o=[],s=16383,c=0,l=e-i;c<l;c+=s)o.push(_t(r,c,c+s>l?l:c+s));return i===1?(t=r[e-1],n+=b[t>>2],n+=b[t<<4&63],n+="=="):i===2&&(t=(r[e-2]<<8)+r[e-1],n+=b[t>>10],n+=b[t>>4&63],n+=b[t<<2&63],n+="="),o.push(n),o.join("")}function he(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function S(r,t){if(he()<t)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(r=new Uint8Array(t),r.__proto__=a.prototype):(r===null&&(r=new a(t)),r.length=t),r}function a(r,t,e){if(!a.TYPED_ARRAY_SUPPORT&&!(this instanceof a))return new a(r,t,e);if(typeof r=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return ve(this,r)}return Ue(this,r,t,e)}function Ue(r,t,e,i){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer!="undefined"&&t instanceof ArrayBuffer?Ft(r,t,e,i):typeof t=="string"?Ut(r,t,e):Dt(r,t)}function Fe(r){if(typeof r!="number")throw new TypeError('"size" argument must be a number');if(r<0)throw new RangeError('"size" argument must not be negative')}function Mt(r,t,e,i){return Fe(t),t<=0?S(r,t):e!==void 0?typeof i=="string"?S(r,t).fill(e,i):S(r,t).fill(e):S(r,t)}function ve(r,t){if(Fe(t),r=S(r,t<0?0:Ee(t)|0),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)r[e]=0;return r}function Ut(r,t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!a.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var i=De(t,e)|0;r=S(r,i);var n=r.write(t,e);return n!==i&&(r=r.slice(0,n)),r}function Ae(r,t){var e=t.length<0?0:Ee(t.length)|0;r=S(r,e);for(var i=0;i<e;i+=1)r[i]=t[i]&255;return r}function Ft(r,t,e,i){if(t.byteLength,e<0||t.byteLength<e)throw new RangeError("'offset' is out of bounds");if(t.byteLength<e+(i||0))throw new RangeError("'length' is out of bounds");return e===void 0&&i===void 0?t=new Uint8Array(t):i===void 0?t=new Uint8Array(t,e):t=new Uint8Array(t,e,i),a.TYPED_ARRAY_SUPPORT?(r=t,r.__proto__=a.prototype):r=Ae(r,t),r}function Dt(r,t){if(C(t)){var e=Ee(t.length)|0;return r=S(r,e),r.length===0||t.copy(r,0,0,e),r}if(t){if(typeof ArrayBuffer!="undefined"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||ir(t.length)?S(r,0):Ae(r,t);if(t.type==="Buffer"&&Array.isArray(t.data))return Ae(r,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Ee(r){if(r>=he())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+he().toString(16)+" bytes");return r|0}function C(r){return!!(r!=null&&r._isBuffer)}function De(r,t){if(C(r))return r.length;if(typeof ArrayBuffer!="undefined"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(r)||r instanceof ArrayBuffer))return r.byteLength;typeof r!="string"&&(r=""+r);var e=r.length;if(e===0)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return fe(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Ve(r).length;default:if(i)return fe(r).length;t=(""+t).toLowerCase(),i=!0}}function Yt(r,t,e){var i=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return Jt(this,t,e);case"utf8":case"utf-8":return qe(this,t,e);case"ascii":return Ht(this,t,e);case"latin1":case"binary":return Gt(this,t,e);case"base64":return Vt(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Qt(this,t,e);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0}}function U(r,t,e){var i=r[t];r[t]=r[e],r[e]=i}function Ye(r,t,e,i,n){if(r.length===0)return-1;if(typeof e=="string"?(i=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=n?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(n)return-1;e=r.length-1}else if(e<0)if(n)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,i)),C(t))return t.length===0?-1:Le(r,t,e,i,n);if(typeof t=="number")return t=t&255,a.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):Le(r,[t],e,i,n);throw new TypeError("val must be string, number or Buffer")}function Le(r,t,e,i,n){var o=1,s=r.length,c=t.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||t.length<2)return-1;o=2,s/=2,c/=2,e/=2}function l(v,H){return o===1?v[H]:v.readUInt16BE(H*o)}var m;if(n){var w=-1;for(m=e;m<s;m++)if(l(r,m)===l(t,w===-1?0:m-w)){if(w===-1&&(w=m),m-w+1===c)return w*o}else w!==-1&&(m-=m-w),w=-1}else for(e+c>s&&(e=s-c),m=e;m>=0;m--){for(var p=!0,I=0;I<c;I++)if(l(r,m+I)!==l(t,I)){p=!1;break}if(p)return m}return-1}function $t(r,t,e,i){e=Number(e)||0;var n=r.length-e;i?(i=Number(i),i>n&&(i=n)):i=n;var o=t.length;if(o%2!==0)throw new TypeError("Invalid hex string");i>o/2&&(i=o/2);for(var s=0;s<i;++s){var c=parseInt(t.substr(s*2,2),16);if(isNaN(c))return s;r[e+s]=c}return s}function qt(r,t,e,i){return pe(fe(t,r.length-e),r,e,i)}function $e(r,t,e,i){return pe(tr(t),r,e,i)}function Wt(r,t,e,i){return $e(r,t,e,i)}function Kt(r,t,e,i){return pe(Ve(t),r,e,i)}function Ot(r,t,e,i){return pe(rr(t,r.length-e),r,e,i)}function Vt(r,t,e){return t===0&&e===r.length?Be(r):Be(r.slice(t,e))}function qe(r,t,e){e=Math.min(r.length,e);for(var i=[],n=t;n<e;){var o=r[n],s=null,c=o>239?4:o>223?3:o>191?2:1;if(n+c<=e){var l,m,w,p;switch(c){case 1:o<128&&(s=o);break;case 2:l=r[n+1],(l&192)===128&&(p=(o&31)<<6|l&63,p>127&&(s=p));break;case 3:l=r[n+1],m=r[n+2],(l&192)===128&&(m&192)===128&&(p=(o&15)<<12|(l&63)<<6|m&63,p>2047&&(p<55296||p>57343)&&(s=p));break;case 4:l=r[n+1],m=r[n+2],w=r[n+3],(l&192)===128&&(m&192)===128&&(w&192)===128&&(p=(o&15)<<18|(l&63)<<12|(m&63)<<6|w&63,p>65535&&p<1114112&&(s=p))}}s===null?(s=65533,c=1):s>65535&&(s-=65536,i.push(s>>>10&1023|55296),s=56320|s&1023),i.push(s),n+=c}return zt(i)}function zt(r){var t=r.length;if(t<=_e)return String.fromCharCode.apply(String,r);for(var e="",i=0;i<t;)e+=String.fromCharCode.apply(String,r.slice(i,i+=_e));return e}function Ht(r,t,e){var i="";e=Math.min(r.length,e);for(var n=t;n<e;++n)i+=String.fromCharCode(r[n]&127);return i}function Gt(r,t,e){var i="";e=Math.min(r.length,e);for(var n=t;n<e;++n)i+=String.fromCharCode(r[n]);return i}function Jt(r,t,e){var i=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>i)&&(e=i);for(var n="",o=t;o<e;++o)n+=er(r[o]);return n}function Qt(r,t,e){for(var i=r.slice(t,e),n="",o=0;o<i.length;o+=2)n+=String.fromCharCode(i[o]+i[o+1]*256);return n}function g(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}function T(r,t,e,i,n,o){if(!C(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<o)throw new RangeError('"value" argument is out of bounds');if(e+i>r.length)throw new RangeError("Index out of range")}function ce(r,t,e,i){t<0&&(t=65535+t+1);for(var n=0,o=Math.min(r.length-e,2);n<o;++n)r[e+n]=(t&255<<8*(i?n:1-n))>>>(i?n:1-n)*8}function le(r,t,e,i){t<0&&(t=4294967295+t+1);for(var n=0,o=Math.min(r.length-e,4);n<o;++n)r[e+n]=t>>>(i?n:3-n)*8&255}function We(r,t,e,i,n,o){if(e+i>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Ke(r,t,e,i,n){return n||We(r,t,e,4,34028234663852886e22,-34028234663852886e22),He(r,t,e,i,23,4),e+4}function Oe(r,t,e,i,n){return n||We(r,t,e,8,17976931348623157e292,-17976931348623157e292),He(r,t,e,i,52,8),e+8}function Xt(r){if(r=jt(r).replace(Zt,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function jt(r){return r.trim?r.trim():r.replace(/^\s+|\s+$/g,"")}function er(r){return r<16?"0"+r.toString(16):r.toString(16)}function fe(r,t){t=t||1/0;for(var e,i=r.length,n=null,o=[],s=0;s<i;++s){if(e=r.charCodeAt(s),e>55295&&e<57344){if(!n){if(e>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===i){(t-=3)>-1&&o.push(239,191,189);continue}n=e;continue}if(e<56320){(t-=3)>-1&&o.push(239,191,189),n=e;continue}e=(n-55296<<10|e-56320)+65536}else n&&(t-=3)>-1&&o.push(239,191,189);if(n=null,e<128){if((t-=1)<0)break;o.push(e)}else if(e<2048){if((t-=2)<0)break;o.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;o.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return o}function tr(r){for(var t=[],e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function rr(r,t){for(var e,i,n,o=[],s=0;s<r.length&&!((t-=2)<0);++s)e=r.charCodeAt(s),i=e>>8,n=e%256,o.push(n),o.push(i);return o}function Ve(r){return Bt(Xt(r))}function pe(r,t,e,i){for(var n=0;n<i&&!(n+e>=t.length||n>=r.length);++n)t[n+e]=r[n];return n}function ir(r){return r!==r}function nr(r){return r!=null&&(!!r._isBuffer||ze(r)||or(r))}function ze(r){return!!r.constructor&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function or(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&ze(r.slice(0,0))}function me(r,t,e,i,n){var o,s,c=n*8-i-1,l=(1<<c)-1,m=l>>1,w=-7,p=e?n-1:0,I=e?-1:1,v=r[t+p];for(p+=I,o=v&(1<<-w)-1,v>>=-w,w+=c;w>0;o=o*256+r[t+p],p+=I,w-=8);for(s=o&(1<<-w)-1,o>>=-w,w+=i;w>0;s=s*256+r[t+p],p+=I,w-=8);if(o===0)o=1-m;else{if(o===l)return s?NaN:(v?-1:1)*(1/0);s=s+Math.pow(2,i),o=o-m}return(v?-1:1)*s*Math.pow(2,o-i)}function He(r,t,e,i,n,o){var s,c,l,m=o*8-n-1,w=(1<<m)-1,p=w>>1,I=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,v=i?0:o-1,H=i?1:-1,Ze=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,s=w):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+p>=1?t+=I/l:t+=I*Math.pow(2,1-p),t*l>=2&&(s++,l/=2),s+p>=w?(c=0,s=w):s+p>=1?(c=(t*l-1)*Math.pow(2,n),s=s+p):(c=t*Math.pow(2,p-1)*Math.pow(2,n),s=0));n>=8;r[e+v]=c&255,v+=H,c/=256,n-=8);for(s=s<<n|c,m+=n;m>0;r[e+v]=s&255,v+=H,s/=256,m-=8);r[e+v-H]|=Ze*128}var b,E,Pt,Te,_e,Zt,Ge=ge(()=>{"use strict";h();f();b=[],E=[],Pt=typeof Uint8Array!="undefined"?Uint8Array:Array,Te=!1;a.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;a.poolSize=8192;a._augment=function(r){return r.__proto__=a.prototype,r};a.from=function(r,t,e){return Ue(null,r,t,e)};a.kMaxLength=he();a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&a[Symbol.species]);a.alloc=function(r,t,e){return Mt(null,r,t,e)};a.allocUnsafe=function(r){return ve(null,r)};a.allocUnsafeSlow=function(r){return ve(null,r)};a.isBuffer=nr;a.compare=function(t,e){if(!C(t)||!C(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var i=t.length,n=e.length,o=0,s=Math.min(i,n);o<s;++o)if(t[o]!==e[o]){i=t[o],n=e[o];break}return i<n?-1:n<i?1:0};a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var i;if(e===void 0)for(e=0,i=0;i<t.length;++i)e+=t[i].length;var n=a.allocUnsafe(e),o=0;for(i=0;i<t.length;++i){var s=t[i];if(!C(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o),o+=s.length}return n};a.byteLength=De;a.prototype._isBuffer=!0;a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)U(this,e,e+1);return this};a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)U(this,e,e+3),U(this,e+1,e+2);return this};a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)U(this,e,e+7),U(this,e+1,e+6),U(this,e+2,e+5),U(this,e+3,e+4);return this};a.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?qe(this,0,t):Yt.apply(this,arguments)};a.prototype.equals=function(t){if(!C(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0};a.prototype.compare=function(t,e,i,n,o){if(!C(t))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),i===void 0&&(i=t?t.length:0),n===void 0&&(n=0),o===void 0&&(o=this.length),e<0||i>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=i)return 0;if(n>=o)return-1;if(e>=i)return 1;if(e>>>=0,i>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var s=o-n,c=i-e,l=Math.min(s,c),m=this.slice(n,o),w=t.slice(e,i),p=0;p<l;++p)if(m[p]!==w[p]){s=m[p],c=w[p];break}return s<c?-1:c<s?1:0};a.prototype.includes=function(t,e,i){return this.indexOf(t,e,i)!==-1};a.prototype.indexOf=function(t,e,i){return Ye(this,t,e,i,!0)};a.prototype.lastIndexOf=function(t,e,i){return Ye(this,t,e,i,!1)};a.prototype.write=function(t,e,i,n){if(e===void 0)n="utf8",i=this.length,e=0;else if(i===void 0&&typeof e=="string")n=e,i=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(i)?(i=i|0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var o=this.length-e;if((i===void 0||i>o)&&(i=o),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return $t(this,t,e,i);case"utf8":case"utf-8":return qt(this,t,e,i);case"ascii":return $e(this,t,e,i);case"latin1":case"binary":return Wt(this,t,e,i);case"base64":return Kt(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ot(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}};a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};_e=4096;a.prototype.slice=function(t,e){var i=this.length;t=~~t,e=e===void 0?i:~~e,t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),e<t&&(e=t);var n;if(a.TYPED_ARRAY_SUPPORT)n=this.subarray(t,e),n.__proto__=a.prototype;else{var o=e-t;n=new a(o,void 0);for(var s=0;s<o;++s)n[s]=this[s+t]}return n};a.prototype.readUIntLE=function(t,e,i){t=t|0,e=e|0,i||g(t,e,this.length);for(var n=this[t],o=1,s=0;++s<e&&(o*=256);)n+=this[t+s]*o;return n};a.prototype.readUIntBE=function(t,e,i){t=t|0,e=e|0,i||g(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n};a.prototype.readUInt8=function(t,e){return e||g(t,1,this.length),this[t]};a.prototype.readUInt16LE=function(t,e){return e||g(t,2,this.length),this[t]|this[t+1]<<8};a.prototype.readUInt16BE=function(t,e){return e||g(t,2,this.length),this[t]<<8|this[t+1]};a.prototype.readUInt32LE=function(t,e){return e||g(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};a.prototype.readUInt32BE=function(t,e){return e||g(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};a.prototype.readIntLE=function(t,e,i){t=t|0,e=e|0,i||g(t,e,this.length);for(var n=this[t],o=1,s=0;++s<e&&(o*=256);)n+=this[t+s]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*e)),n};a.prototype.readIntBE=function(t,e,i){t=t|0,e=e|0,i||g(t,e,this.length);for(var n=e,o=1,s=this[t+--n];n>0&&(o*=256);)s+=this[t+--n]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*e)),s};a.prototype.readInt8=function(t,e){return e||g(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};a.prototype.readInt16LE=function(t,e){e||g(t,2,this.length);var i=this[t]|this[t+1]<<8;return i&32768?i|4294901760:i};a.prototype.readInt16BE=function(t,e){e||g(t,2,this.length);var i=this[t+1]|this[t]<<8;return i&32768?i|4294901760:i};a.prototype.readInt32LE=function(t,e){return e||g(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};a.prototype.readInt32BE=function(t,e){return e||g(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};a.prototype.readFloatLE=function(t,e){return e||g(t,4,this.length),me(this,t,!0,23,4)};a.prototype.readFloatBE=function(t,e){return e||g(t,4,this.length),me(this,t,!1,23,4)};a.prototype.readDoubleLE=function(t,e){return e||g(t,8,this.length),me(this,t,!0,52,8)};a.prototype.readDoubleBE=function(t,e){return e||g(t,8,this.length),me(this,t,!1,52,8)};a.prototype.writeUIntLE=function(t,e,i,n){if(t=+t,e=e|0,i=i|0,!n){var o=Math.pow(2,8*i)-1;T(this,t,e,i,o,0)}var s=1,c=0;for(this[e]=t&255;++c<i&&(s*=256);)this[e+c]=t/s&255;return e+i};a.prototype.writeUIntBE=function(t,e,i,n){if(t=+t,e=e|0,i=i|0,!n){var o=Math.pow(2,8*i)-1;T(this,t,e,i,o,0)}var s=i-1,c=1;for(this[e+s]=t&255;--s>=0&&(c*=256);)this[e+s]=t/c&255;return e+i};a.prototype.writeUInt8=function(t,e,i){return t=+t,e=e|0,i||T(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t&255,e+1};a.prototype.writeUInt16LE=function(t,e,i){return t=+t,e=e|0,i||T(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):ce(this,t,e,!0),e+2};a.prototype.writeUInt16BE=function(t,e,i){return t=+t,e=e|0,i||T(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):ce(this,t,e,!1),e+2};a.prototype.writeUInt32LE=function(t,e,i){return t=+t,e=e|0,i||T(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255):le(this,t,e,!0),e+4};a.prototype.writeUInt32BE=function(t,e,i){return t=+t,e=e|0,i||T(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):le(this,t,e,!1),e+4};a.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e=e|0,!n){var o=Math.pow(2,8*i-1);T(this,t,e,i,o-1,-o)}var s=0,c=1,l=0;for(this[e]=t&255;++s<i&&(c*=256);)t<0&&l===0&&this[e+s-1]!==0&&(l=1),this[e+s]=(t/c>>0)-l&255;return e+i};a.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e=e|0,!n){var o=Math.pow(2,8*i-1);T(this,t,e,i,o-1,-o)}var s=i-1,c=1,l=0;for(this[e+s]=t&255;--s>=0&&(c*=256);)t<0&&l===0&&this[e+s+1]!==0&&(l=1),this[e+s]=(t/c>>0)-l&255;return e+i};a.prototype.writeInt8=function(t,e,i){return t=+t,e=e|0,i||T(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=t&255,e+1};a.prototype.writeInt16LE=function(t,e,i){return t=+t,e=e|0,i||T(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):ce(this,t,e,!0),e+2};a.prototype.writeInt16BE=function(t,e,i){return t=+t,e=e|0,i||T(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):ce(this,t,e,!1),e+2};a.prototype.writeInt32LE=function(t,e,i){return t=+t,e=e|0,i||T(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):le(this,t,e,!0),e+4};a.prototype.writeInt32BE=function(t,e,i){return t=+t,e=e|0,i||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):le(this,t,e,!1),e+4};a.prototype.writeFloatLE=function(t,e,i){return Ke(this,t,e,!0,i)};a.prototype.writeFloatBE=function(t,e,i){return Ke(this,t,e,!1,i)};a.prototype.writeDoubleLE=function(t,e,i){return Oe(this,t,e,!0,i)};a.prototype.writeDoubleBE=function(t,e,i){return Oe(this,t,e,!1,i)};a.prototype.copy=function(t,e,i,n){if(i||(i=0),!n&&n!==0&&(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<i&&(n=i),n===i||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-i&&(n=t.length-e+i);var o=n-i,s;if(this===t&&i<e&&e<n)for(s=o-1;s>=0;--s)t[s+e]=this[s+i];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(s=0;s<o;++s)t[s+e]=this[s+i];else Uint8Array.prototype.set.call(t,this.subarray(i,i+o),e);return o};a.prototype.fill=function(t,e,i,n){if(typeof t=="string"){if(typeof e=="string"?(n=e,e=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),t.length===1){var o=t.charCodeAt(0);o<256&&(t=o)}if(n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else typeof t=="number"&&(t=t&255);if(e<0||this.length<e||this.length<i)throw new RangeError("Out of range index");if(i<=e)return this;e=e>>>0,i=i===void 0?this.length:i>>>0,t||(t=0);var s;if(typeof t=="number")for(s=e;s<i;++s)this[s]=t;else{var c=C(t)?t:fe(new a(t,n).toString()),l=c.length;for(s=0;s<i-e;++s)this[s+e]=c[s%l]}return this};Zt=/[^+\/0-9A-Za-z-_]/g});var f=ge(()=>{"use strict";Ge()});var gr={};Re(gr,{EndpointSnippetGenerator:()=>Ie});module.exports=it(gr);h();f();h();f();h();f();function P(r){throw new Error("Unexpected value: "+JSON.stringify(r))}h();f();h();f();h();f();var F=class{};h();f();h();f();var R=class extends F{constructor(e){super();u(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 sr=4,X=class{constructor(){u(this,"buffer","");u(this,"indentLevel",0);u(this,"hasWrittenAnything",!1);u(this,"lastCharacterIsSemicolon",!1);u(this,"lastCharacterIsNewline",!1)}write(t){let e=t.length>0&&t.endsWith(`
|
|
2
|
+
`),i=e?t.substring(0,t.length-1):t,n=this.getIndentString(),o=i.replaceAll(`
|
|
3
|
+
`,`
|
|
4
|
+
${n}`);this.isAtStartOfLine()&&(o=n+o),e&&(o+=`
|
|
5
|
+
`),this.writeInternal(o)}writeNoIndent(t){let e=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=e}writeNode(t){t.write(this)}writeNodeOrString(t){if(typeof t=="string"){this.write(t);return}this.writeNode(t)}writeNodeStatement(t){t.write(this),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new R(t).write(this),this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(t,e){new R(t).write(this),this.write(" ("),this.writeNode(e),this.write(") {"),this.writeNewLineIfLastLineNot(),this.indent()}controlFlowWithoutStatement(t){new R(t).write(this),this.write(" {"),this.writeNewLineIfLastLineNot(),this.indent()}endControlFlow(){this.dedent(),this.writeLine("}")}contiguousControlFlow(t,e){this.dedent(),this.write("} "),new R(t).write(this),this.write(" ("),this.writeNode(e),this.write(") {"),this.writeNewLineIfLastLineNot(),this.indent()}alternativeControlFlow(t){this.dedent(),this.write("} "),new R(t).write(this),this.write(" {"),this.writeNewLineIfLastLineNot(),this.indent()}writeLine(t=""){this.write(t),this.writeNewLineIfLastLineNot()}newLine(){this.writeInternal(`
|
|
6
|
+
`)}writeSemicolonIfLastCharacterIsNot(){this.lastCharacterIsSemicolon||this.writeInternal(";")}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
|
|
7
|
+
`)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:t,delimiter:e,writeFunction:i}){if(t.length>0){let n=t[0];n!=null&&i(n);for(let o=1;o<t.length;o++){this.write(e);let s=t[o];s!=null&&i(s)}}}toString(){return this.buffer}writeInternal(t){return t.length>0&&(this.hasWrittenAnything=!0,this.lastCharacterIsNewline=t.endsWith(`
|
|
8
|
+
`),this.lastCharacterIsSemicolon=t.endsWith(";")),this.buffer+=t}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*sr)}};h();f();var de=class{formatMultiple(t){return Promise.all(t.map(e=>this.format(e)))}formatMultipleSync(t){return t.map(e=>this.formatSync(e))}},j=class extends de{async format(t){return t}formatSync(t){return t}};var y={};Re(y,{AstNode:()=>x,ClassInstantiation:()=>$,ClassReference:()=>q,CodeBlock:()=>W,KeywordArgument:()=>K,Method:()=>O,MethodInvocation:()=>V,Parameter:()=>A,TypeLiteral:()=>oe,TypeParameter:()=>z,classReference:()=>mr,class_:()=>hr,codeblock:()=>ar,comment:()=>lr,instantiateClass:()=>dr,invokeMethod:()=>yr,keywordArgument:()=>wr,method:()=>cr,module:()=>fr,parameters:()=>ur,positionalArgument:()=>xr,typeParameter:()=>pr});h();f();h();f();h();f();h();f();h();f();h();f();h();f();var we=class extends X{constructor({customConfig:e,formatter:i}){super();u(this,"customConfig");u(this,"formatter");u(this,"requires",new Set);this.customConfig=e,this.formatter=i!=null?i:new j}addRequire(e){this.requires.add(e)}};var Q=class extends we{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}
|
|
9
|
+
${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}
|
|
10
|
+
${t}`)}return t}getContent(){let t=this.stringifyRequires();return t.length>0?`${t}
|
|
11
|
+
|
|
12
|
+
${this.buffer}`:this.buffer}stringifyRequires(){return Array.from(this.requires).map(t=>`require "${t}"`).join(`
|
|
13
|
+
`)}};var x=class extends F{async toStringAsync({customConfig:t,formatter:e}){let i=new Q({customConfig:t,formatter:e});return this.write(i),i.toStringAsync()}toString({customConfig:t,formatter:e}){let i=new Q({customConfig:t,formatter:e});return this.write(i),i.toString()}typeDefinitionToString({customConfig:t,formatter:e}){let i=new Q({customConfig:t,formatter:e});return this.writeTypeDefinition(i),i.toString()}writeTypeDefinition(t){}};var k=class extends x{constructor({docs:e}){super();u(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
|
|
14
|
+
`).forEach(i=>{e.writeLine(`# ${i}`)})}};h();f();var D=class r extends x{constructor({name:e,namespace:i,typeParameters:n,docstring:o,statements:s}){super();u(this,"name");u(this,"namespace");u(this,"typeParameters");u(this,"docstring");u(this,"statements");this.name=e,this.namespace=i!=null?i:new Set,this.typeParameters=n!=null?n:[],this.docstring=o,this.statements=s!=null?s:[],this.populateChildNamespaces()}write(e){this.docstring&&new k({docs:this.docstring}).write(e),e.write(`module ${this.name}`),this.statements.length?(e.newLine(),e.indent(),this.statements.forEach((i,n)=>{i.write(e),n<this.statements.length-1&&e.newLine()}),e.dedent(),e.write("end")):e.write("; end"),e.newLine()}writeTypeDefinition(e){e.write(`module ${this.name}`),this.typeParameters.length&&(e.write("["),e.delimit({nodes:this.typeParameters,delimiter:", ",writeFunction:i=>i.writeTypeDefinition(e)}),e.write("]")),e.newLine(),this.statements.length&&(e.indent(),this.statements.forEach(i=>{i.writeTypeDefinition(e),e.newLine()}),e.dedent()),e.write("end")}populateChildNamespaces(){this.statements.filter(e=>e instanceof r||e instanceof Y).forEach(e=>{e.namespace=new Set([...this.namespace,this]),e.populateChildNamespaces()})}get fullyQualifiedNamespace(){return[...this.namespace,this].map(e=>e.name).join("::")}};var Y=class extends D{constructor({name:e,superclass:i,typeParameters:n,docstring:o,statements:s}){super({name:e,docstring:o,typeParameters:n});u(this,"superclass");u(this,"statements");this.superclass=i,this.statements=s!=null?s:[]}write(e){this.docstring&&new k({docs:this.docstring}).write(e),e.write(`class ${this.name}`),this.superclass&&e.write(` < ${this.superclass.name}`),this.statements.length?(e.newLine(),e.indent(),this.statements.forEach((i,n)=>{i.write(e),n<this.statements.length-1&&e.newLine()}),e.dedent(),e.write("end")):e.write("; end"),e.newLine()}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.name}`),e.newLine(),this.statements.length&&(e.indent(),this.statements.forEach(i=>{i.writeTypeDefinition(e),e.newLine()}),e.dedent()),e.write("end")}};h();f();var $=class extends x{constructor({classReference:e,arguments_:i}){super();u(this,"classReference");u(this,"arguments_");this.classReference=e,this.arguments_=i}write(e){e.writeNode(this.classReference),e.write("."),e.write("new"),e.write("("),this.arguments_.length>1?(e.indent(),e.newLine(),this.arguments_.forEach((i,n)=>{n>0&&(e.write(","),e.newLine()),i.write(e)}),e.newLine(),e.dedent()):this.arguments_.forEach((i,n)=>{n>0&&e.write(", "),i.write(e)}),e.write(")")}};h();f();var q=class extends x{constructor({name:e,modules:i,fullyQualified:n}){super();u(this,"name");u(this,"modules");u(this,"fullyQualified");this.name=e,this.modules=i!=null?i:[],this.fullyQualified=n!=null?n:!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)}};h();f();var W=class extends x{constructor(e){super();u(this,"arg");this.arg=e}write(e){return new R(this.arg).write(e)}};h();f();var K=class extends x{constructor({name:e,value:i}){super();u(this,"name");u(this,"value");this.name=e,this.value=i}write(e){e.write(`${this.name}: `),this.value.write(e)}};h();f();h();f();h();f();var Z=class r extends x{constructor(e){super();u(this,"internalType");this.internalType=e}write(e){}writeTypeDefinition(e){if(this.internalType)switch(this.internalType.type){case"self":e.write("self");break;case"class":e.write("class");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:P(this.internalType)}else e.write("untyped")}static untyped(){return new this(void 0)}static self(){return new this({type:"self"})}static class_(){return new this({type:"class"})}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 r.union([e,r.nil()])}nilable(){return r.nilable(this)}};var A=class extends x{constructor({name:e,type:i,optional:n}){super();u(this,"name");u(this,"type");u(this,"optional");this.name=e,this.type=i!=null?i:Z.untyped(),this.optional=n!=null?n:!1}};var ee=class extends A{constructor({name:e,type:i,initializer:n,optional:o}){super({name:e,type:i,optional:o});u(this,"initializer");this.initializer=n}write(e){e.write(`${this.name}:`),this.initializer&&e.write(` ${this.initializer.write(e)}`)}writeTypeDefinition(e){this.optional&&e.write("?"),e.write(`${this.name}: `),this.type.writeTypeDefinition(e)}};h();f();var te=class extends A{constructor(){super(...arguments);u(this,"initializer")}write(e){e.write(`**${this.name}`)}writeTypeDefinition(e){e.write("**"),this.type.writeTypeDefinition(e)}};h();f();var ye={Instance:"instance",Class_:"class"},Je={Public:"public",Private:"private",Protected:"protected"},O=class extends x{constructor({name:e,docstring:i,kind:n,visibility:o,parameters:s,returnType:c}){var l,m;super();u(this,"name");u(this,"docstring");u(this,"kind");u(this,"positionalParameters");u(this,"keywordParameters");u(this,"positionalSplatParameter");u(this,"keywordSplatParameter");u(this,"yieldParameter");u(this,"visibility");u(this,"statements",[]);u(this,"returnType");this.name=e,this.docstring=i,this.kind=n!=null?n:ye.Instance,this.visibility=o!=null?o:Je.Public,this.positionalParameters=(l=s==null?void 0:s.positional)!=null?l:[],this.keywordParameters=(m=s==null?void 0:s.keyword)!=null?m:[],this.positionalSplatParameter=s==null?void 0:s.positionalSplat,this.keywordSplatParameter=s==null?void 0:s.keywordSplat,this.yieldParameter=s==null?void 0:s.yield,this.returnType=c!=null?c:Z.untyped()}write(e){switch(this.docstring&&new k({docs:this.docstring}).write(e),this.visibility!==Je.Public&&(e.write(this.visibility),this.kind===ye.Class_&&e.write("_class_method"),e.write(" ")),this.kind){case ye.Instance:e.write(`def ${this.name}`);break;case ye.Class_:e.write(`def self.${this.name}`);break}this.parameters.length&&(e.write("("),e.delimit({nodes:this.parameters,delimiter:", ",writeFunction:i=>i.write(e)}),e.write(")")),this.statements.length?(e.newLine(),e.indent(),this.statements.forEach((i,n)=>{i.write(e),n<this.statements.length-1&&e.newLine()}),e.dedent(),e.write("end")):e.write("; end"),e.newLine()}writeTypeDefinition(e){e.write(`def ${this.name}: (`),this.parameters.forEach((i,n)=>{i.writeTypeDefinition(e),n<this.parameters.length-1&&e.write(", ")}),e.write(") -> "),this.returnType.writeTypeDefinition(e)}get parameters(){return[...this.positionalParameters,...this.keywordParameters,this.positionalSplatParameter,this.keywordSplatParameter,this.yieldParameter].flatMap(e=>e!==void 0?e:[])}};h();f();var V=class extends x{constructor({on:e,method:i,arguments_:n}){super();u(this,"on");u(this,"method");u(this,"arguments_");this.on=e,this.method=i,this.arguments_=n}write(e){this.on.write(e),e.write("."),e.write(this.method),e.write("("),this.arguments_.length>1?(e.indent(),e.newLine(),this.arguments_.forEach((i,n)=>{n>0&&(e.write(","),e.newLine()),i.write(e)}),e.newLine(),e.dedent()):this.arguments_.forEach((i,n)=>{n>0&&e.write(", "),i.write(e)}),e.write(")")}};h();f();var re=class extends x{constructor({value:e}){super();u(this,"value");this.value=e}write(e){this.value.write(e)}};h();f();var ie=class extends A{constructor({name:e,type:i,optional:n,initializer:o}){super({name:e,type:i,optional:n});u(this,"initializer");this.initializer=o}write(e){e.write(this.name),this.initializer&&e.write(` = ${this.initializer.write(e)}`)}writeTypeDefinition(e){this.optional&&e.write("?"),this.type.writeTypeDefinition(e)}};h();f();var ne=class extends A{write(t){t.write(`*${this.name}`)}writeTypeDefinition(t){t.write("*"),this.type.writeTypeDefinition(t)}};h();f();var oe=class r extends x{constructor(e){super();u(this,"internalType");this.internalType=e}static string(e){return new this({type:"str",value:e})}static integer(e){return new this({type:"int",value:e})}static float(e){return new this({type:"float",value:e})}static boolean(e){return new this({type:"bool",value:e})}static hash(e){return new this({type:"hash",entries:e})}static set(e){return new this({type:"set",values:e})}static list(e){return new this({type:"list",values:e})}static nop(){return new this({type:"nop"})}static nil(){return new this({type:"nil"})}static isNop(e){return e instanceof r&&e.internalType.type==="nop"}static isNil(e){return e instanceof r&&e.internalType.type==="nil"}write(e){switch(this.internalType.type){case"str":{this.internalType.value.includes("'")?e.write(`"${this.internalType.value.replaceAll('"','\\"')}"`):e.write(`'${this.internalType.value}'`);break}case"int":{e.write(this.internalType.value.toString());break}case"float":{e.write(this.internalType.value.toString());break}case"bool":{e.write(this.internalType.value?"true":"false");break}case"hash":{let i=this.internalType.entries.filter(n=>!r.isNop(n.key)&&!r.isNop(n.value));if(i.length===0){e.write("{}");break}e.write(`{
|
|
15
|
+
`),i.forEach((n,o)=>{o>0&&e.writeLine(","),e.indent();let s=!1;if(n.key instanceof r&&n.key.internalType.type==="str"){let c=n.key.internalType.value;/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(c)&&(e.write(`${c}:`),s=!0)}s||(n.key.write(e),e.write(":")),n.value.write(e),e.dedent()}),e.write(`
|
|
16
|
+
}`);break}case"set":{let i=this.internalType.values.filter(n=>!r.isNop(n));if(i.length===0){e.write("Set.new([])");break}e.write("Set.new(["),i.forEach((n,o)=>{o>0&&e.write(", "),n.write(e)}),e.write("])");break}case"list":{let i=this.internalType.values.filter(n=>!r.isNop(n));if(i.length===0){e.write("[]");break}e.write("["),i.forEach((n,o)=>{o>0&&e.write(", "),n.write(e)}),e.write("]");break}case"nop":break;case"nil":e.write("nil");break;default:P(this.internalType)}}};h();f();var xe;(function(r){r[r.Invariant=0]="Invariant",r.Covariant="out",r.Contravariant="in"})(xe||(xe={}));var z=class extends x{constructor({name:e,unchecked:i,bound:n,variance:o,defaultType:s}){super();u(this,"name");u(this,"unchecked");u(this,"bound");u(this,"variance");u(this,"defaultType");this.name=e,this.unchecked=i!=null?i:!1,this.bound=n,this.variance=o!=null?o:xe.Invariant,this.defaultType=s}write(e){}writeTypeDefinition(e){this.unchecked&&e.write("unchecked "),this.variance!=xe.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))}};h();f();var se=class extends A{constructor(){super(...arguments);u(this,"initializer")}write(e){e.write(`&${this.name}`)}};function ar(r){return new W(r)}var ur={positional(r){return new ie(r)},keyword(r){return new ee(r)},positionalSplat(r){return new ne(r)},keywordSplat(r){return new te(r)},yield(r){return new se(r)}};function hr(r){return new Y(r)}function fr(r){return new D(r)}function cr(r){return new O(r)}function lr(r){return new k(r)}function pr(r){return new z(r)}function mr(r){return new q(r)}function dr(r){return new $(r)}function wr(r){return new K(r)}function yr(r){return new V(r)}function xr(r){return new re(r)}var Qe="client",Ie=class{constructor({context:t,formatter:e}){u(this,"context");u(this,"formatter");this.context=t,this.formatter=e}async generateSnippet({endpoint:t,request:e}){var n;return await this.buildCodeBlock({endpoint:t,snippet:e}).toStringAsync({customConfig:(n=this.context.customConfig)!=null?n:{},formatter:this.formatter})}generateSnippetSync({endpoint:t,request:e}){var n;return this.buildCodeBlock({endpoint:t,snippet:e}).toString({customConfig:(n=this.context.customConfig)!=null?n:{},formatter:this.formatter})}buildCodeBlock({endpoint:t,snippet:e}){return y.codeblock(i=>{i.writeNodeStatement(this.constructClient({endpoint:t,snippet:e})),i.newLine(),i.writeNodeStatement(this.callMethod({endpoint:t,snippet:e}))})}constructClient({endpoint:t,snippet:e}){return y.codeblock(i=>{i.addRequire(this.context.getRootModuleName());let n=this.context.getRootClientClassReference(),o=this.getRootClientBuilderArgs({endpoint:t,snippet:e});i.write(`${Qe} = `),i.writeNode(y.instantiateClass({classReference:n,arguments_:o}))})}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[y.keywordArgument({name:"base_url",value:y.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`}),[]):[y.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}){switch(t.type){case"basic":return e.type!=="basic"?(this.context.errors.add({severity:"CRITICAL",message:this.context.newAuthMismatchError({auth:t,values:e}).message}),[]):this.getRootClientBasicAuthArgs({auth:t,values:e});case"bearer":return e.type!=="bearer"?(this.context.errors.add({severity:"CRITICAL",message:this.context.newAuthMismatchError({auth:t,values:e}).message}),[]):this.getRootClientBearerAuthArgs({auth:t,values:e});case"header":return e.type!=="header"?(this.context.errors.add({severity:"CRITICAL",message:this.context.newAuthMismatchError({auth:t,values:e}).message}),[]):this.getRootClientHeaderAuthArgs({auth:t,values:e});case"oauth":return e.type!=="oauth"?(this.context.errors.add({severity:"CRITICAL",message:this.context.newAuthMismatchError({auth:t,values:e}).message}),[]):this.getRootClientOAuthArgs({auth:t,values:e});default:return[]}}getRootClientBasicAuthArgs({auth:t,values:e}){return[y.keywordArgument({name:t.username.snakeCase.safeName,value:y.TypeLiteral.string(e.username)}),y.keywordArgument({name:t.password.snakeCase.safeName,value:y.TypeLiteral.string(e.password)})]}getRootClientBearerAuthArgs({auth:t,values:e}){return[y.keywordArgument({name:t.token.snakeCase.safeName,value:y.TypeLiteral.string(e.token)})]}getRootClientHeaderAuthArgs({auth:t,values:e}){return[y.keywordArgument({name:t.header.name.name.snakeCase.safeName,value:y.TypeLiteral.string(e.value)})]}getRootClientOAuthArgs({auth:t,values:e}){return[y.keywordArgument({name:t.clientId.snakeCase.safeName,value:y.TypeLiteral.string(e.clientId)}),y.keywordArgument({name:t.clientSecret.snakeCase.safeName,value:y.TypeLiteral.string(e.clientSecret)})]}getRootClientHeaderArgs({headers:t,values:e}){let i=[];for(let n of t){let o=e[n.name.name.originalName];o!=null&&typeof o=="string"&&i.push(y.keywordArgument({name:n.name.name.snakeCase.safeName,value:y.TypeLiteral.string(o)}))}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 n=this.getRootClientBaseUrlArg({baseUrl:e.baseURL,environment:e.environment});return n.length>0&&i.push(...n),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}){return y.invokeMethod({on:y.codeblock(Qe),method:this.getMethod({endpoint:t}),arguments_:this.getMethodArgs({endpoint:t,snippet:e})})}getMethodArgs({endpoint:t,snippet:e}){switch(t.request.type){case"inlined":return[this.getMethodArgsForInlinedRequest({request:t.request,snippet:e})];case"body":return this.getMethodArgsForBodyRequest({request:t.request,snippet:e});default:P(t.request)}}getMethodArgsForInlinedRequest({request:t,snippet:e}){let i=[];if(i.push(...this.getNamedParameterArgs({kind:"PathParameters",namedParameters:t.pathParameters,values:e.pathParameters})),i.push(...this.getNamedParameterArgs({kind:"QueryParameters",namedParameters:t.queryParameters,values:e.queryParameters})),i.push(...this.getNamedParameterArgs({kind:"Headers",namedParameters:t.headers,values:e.headers})),t.body!=null)switch(t.body.type){case"properties":i.push(...this.getMethodArgsForPropertiesRequest({request:t.body,snippet:e}));break;case"referenced":case"fileUpload":break;default:P(t.body)}return y.TypeLiteral.hash(i.map(n=>({key:y.TypeLiteral.string(n.name),value:n.value})))}getNamedParameterArgs({kind:t,namedParameters:e,values:i}){let n=[];if(this.context.errors.scope(t),e!=null){let o=this.context.associateByWireValue({parameters:e,values:i!=null?i:{},ignoreMissingParameters:!0});for(let s of o)n.push(y.keywordArgument({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)}))}return this.context.errors.unscope(),n}getMethodArgsForPropertiesRequest({request:t,snippet:e}){var o;let i=[],n=this.context.associateByWireValue({parameters:t.value,values:(o=this.context.getRecord(e.requestBody))!=null?o:{}});for(let s of n)i.push(y.keywordArgument({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)}));return i}getMethodArgsForBodyRequest({request:t,snippet:e}){if(t.body==null)return[];switch(t.body.type){case"bytes":return this.context.errors.add({severity:"CRITICAL",message:"Multi-environment values are not supported in Ruby snippets yet"}),[];case"typeReference":return[y.positionalArgument({value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t.body.value,value:this.context.getRecord(e.requestBody)})})];default:P(t.body)}}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)}};0&&(module.exports={EndpointSnippetGenerator});
|
|
17
|
+
/*! Bundled license information:
|
|
18
|
+
|
|
19
|
+
@esbuild-plugins/node-globals-polyfill/Buffer.js:
|
|
20
|
+
(*!
|
|
21
|
+
* The buffer module from node.js, for the browser.
|
|
22
|
+
*
|
|
23
|
+
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
24
|
+
* @license MIT
|
|
25
|
+
*)
|
|
26
|
+
*/
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { AbstractFormatter } from '@fern-api/browser-compatible-base-generator';
|
|
2
|
+
import { FernIr } from '@fern-api/dynamic-ir-sdk';
|
|
3
|
+
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-BGmCyT7y.cjs';
|
|
4
|
+
import '@fern-api/ruby-ast';
|
|
5
|
+
|
|
6
|
+
declare class EndpointSnippetGenerator {
|
|
7
|
+
private context;
|
|
8
|
+
private formatter;
|
|
9
|
+
constructor({ context, formatter }: {
|
|
10
|
+
context: DynamicSnippetsGeneratorContext;
|
|
11
|
+
formatter?: AbstractFormatter;
|
|
12
|
+
});
|
|
13
|
+
generateSnippet({ endpoint, request }: {
|
|
14
|
+
endpoint: FernIr.dynamic.Endpoint;
|
|
15
|
+
request: FernIr.dynamic.EndpointSnippetRequest;
|
|
16
|
+
}): Promise<string>;
|
|
17
|
+
generateSnippetSync({ endpoint, request }: {
|
|
18
|
+
endpoint: FernIr.dynamic.Endpoint;
|
|
19
|
+
request: FernIr.dynamic.EndpointSnippetRequest;
|
|
20
|
+
}): string;
|
|
21
|
+
private buildCodeBlock;
|
|
22
|
+
private constructClient;
|
|
23
|
+
private getRootClientBaseUrlArg;
|
|
24
|
+
private getRootClientAuthArgs;
|
|
25
|
+
private getRootClientBasicAuthArgs;
|
|
26
|
+
private getRootClientBearerAuthArgs;
|
|
27
|
+
private getRootClientHeaderAuthArgs;
|
|
28
|
+
private getRootClientOAuthArgs;
|
|
29
|
+
private getRootClientHeaderArgs;
|
|
30
|
+
private getRootClientBuilderArgs;
|
|
31
|
+
private callMethod;
|
|
32
|
+
private getMethodArgs;
|
|
33
|
+
private getMethodArgsForInlinedRequest;
|
|
34
|
+
private getNamedParameterArgs;
|
|
35
|
+
private getMethodArgsForPropertiesRequest;
|
|
36
|
+
private getMethodArgsForBodyRequest;
|
|
37
|
+
private getMethod;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { EndpointSnippetGenerator };
|