@fern-api/go-dynamic-snippets 0.0.17 → 0.0.18

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.
@@ -1,7 +1,7 @@
1
1
  import { AbstractFormatter, Options } from '@fern-api/browser-compatible-base-generator';
2
2
  import { FernIr } from '@fern-api/dynamic-ir-sdk';
3
+ import { go } from '@fern-api/go-ast';
3
4
  import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-D8VcLYKk.cjs';
4
- import '@fern-api/go-ast';
5
5
 
6
6
  declare class EndpointSnippetGenerator {
7
7
  private context;
@@ -20,6 +20,11 @@ declare class EndpointSnippetGenerator {
20
20
  request: FernIr.dynamic.EndpointSnippetRequest;
21
21
  options?: Options;
22
22
  }): string;
23
+ generateSnippetAst({ endpoint, request, options }: {
24
+ endpoint: FernIr.dynamic.Endpoint;
25
+ request: FernIr.dynamic.EndpointSnippetRequest;
26
+ options?: Options;
27
+ }): Promise<go.AstNode>;
23
28
  private generateWiremockTest;
24
29
  private buildCodeBlock;
25
30
  private buildWiremockTestCodeBlock;
package/cjs/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";var be=Object.defineProperty,Kt=Object.defineProperties,Jt=Object.getOwnPropertyDescriptor,Xt=Object.getOwnPropertyDescriptors,Qt=Object.getOwnPropertyNames,Fe=Object.getOwnPropertySymbols;var Ke=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable;var ze=(n,t,e)=>t in n?be(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ut=(n,t)=>{for(var e in t||(t={}))Ke.call(t,e)&&ze(n,e,t[e]);if(Fe)for(var e of Fe(t))ct.call(t,e)&&ze(n,e,t[e]);return n},pt=(n,t)=>Kt(n,Xt(t));var lt=n=>typeof n=="symbol"?n:n+"",ft=(n,t)=>{var e={};for(var r in n)Ke.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&Fe)for(var r of Fe(n))t.indexOf(r)<0&&ct.call(n,r)&&(e[r]=n[r]);return e};var Pe=(n,t)=>()=>(n&&(t=n(n=0)),t);var ht=(n,t)=>{for(var e in t)be(n,e,{get:t[e],enumerable:!0})},Zt=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Qt(t))!Ke.call(n,i)&&i!==e&&be(n,i,{get:()=>t[i],enumerable:!(r=Jt(t,i))||r.enumerable});return n};var er=n=>Zt(be({},"__esModule",{value:!0}),n);var u=(n,t,e)=>ze(n,typeof t!="symbol"?t+"":t,e);function mt(){throw new Error("setTimeout has not been defined")}function yt(){throw new Error("clearTimeout has not been defined")}function gt(n){if(q===setTimeout)return setTimeout(n,0);if((q===mt||!q)&&setTimeout)return q=setTimeout,setTimeout(n,0);try{return q(n,0)}catch(t){try{return q.call(null,n,0)}catch(e){return q.call(this,n,0)}}}function tr(n){if(G===clearTimeout)return clearTimeout(n);if((G===yt||!G)&&clearTimeout)return G=clearTimeout,clearTimeout(n);try{return G(n)}catch(t){try{return G.call(null,n)}catch(e){return G.call(this,n)}}}function rr(){!ce||!j||(ce=!1,j.length?M=j.concat(M):ke=-1,M.length&&xt())}function xt(){if(!ce){var n=gt(rr);ce=!0;for(var t=M.length;t;){for(j=M,M=[];++ke<t;)j&&j[ke].run();ke=-1,t=M.length}j=null,ce=!1,tr(n)}}function nr(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];M.push(new wt(n,t)),M.length===1&&!ce&&gt(xt)}function wt(n,t){this.fun=n,this.array=t}function H(){}function vr(n){throw new Error("process.binding is not supported")}function Tr(){return"/"}function Ir(n){throw new Error("process.chdir is not supported")}function Rr(){return 0}function Ar(n){var t=Nr.call(ae)*.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 Fr(){var n=new Date,t=n-Er;return t/1e3}var q,G,M,ce,j,ke,ir,or,sr,ar,cr,ur,pr,lr,fr,hr,dr,mr,yr,gr,xr,wr,ae,Nr,Er,d,dt,p=Pe(()=>{"use strict";q=mt,G=yt;typeof globalThis.setTimeout=="function"&&(q=setTimeout);typeof globalThis.clearTimeout=="function"&&(G=clearTimeout);M=[],ce=!1,ke=-1;wt.prototype.run=function(){this.fun.apply(null,this.array)};ir="browser",or="browser",sr=!0,ar={},cr=[],ur="",pr={},lr={},fr={};hr=H,dr=H,mr=H,yr=H,gr=H,xr=H,wr=H;ae=globalThis.performance||{},Nr=ae.now||ae.mozNow||ae.msNow||ae.oNow||ae.webkitNow||function(){return new Date().getTime()};Er=new Date;d={nextTick:nr,title:ir,browser:sr,env:ar,argv:cr,version:ur,versions:pr,on:hr,addListener:dr,once:mr,off:yr,removeListener:gr,removeAllListeners:xr,emit:wr,binding:vr,cwd:Tr,chdir:Ir,umask:Rr,hrtime:Ar,platform:or,release:lr,config:fr,uptime:Fr},dt={};Object.keys(dt).forEach(n=>{let t=n.split("."),e=d;for(let r=0;r<t.length;r++){let i=t[r];r===t.length-1?e[i]=dt[n]:e=e[i]||(e[i]={})}})});function Rt(){Xe=!0;for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=n.length;t<e;++t)C[t]=n[t],P[n.charCodeAt(t)]=t;P[45]=62,P[95]=63}function Pr(n){Xe||Rt();var t,e,r,i,o,s,f=n.length;if(f%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o=n[f-2]==="="?2:n[f-1]==="="?1:0,s=new br(f*3/4-o),r=o>0?f-4:f;var h=0;for(t=0,e=0;t<r;t+=4,e+=3)i=P[n.charCodeAt(t)]<<18|P[n.charCodeAt(t+1)]<<12|P[n.charCodeAt(t+2)]<<6|P[n.charCodeAt(t+3)],s[h++]=i>>16&255,s[h++]=i>>8&255,s[h++]=i&255;return o===2?(i=P[n.charCodeAt(t)]<<2|P[n.charCodeAt(t+1)]>>4,s[h++]=i&255):o===1&&(i=P[n.charCodeAt(t)]<<10|P[n.charCodeAt(t+1)]<<4|P[n.charCodeAt(t+2)]>>2,s[h++]=i>>8&255,s[h++]=i&255),s}function kr(n){return C[n>>18&63]+C[n>>12&63]+C[n>>6&63]+C[n&63]}function Sr(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(kr(r));return i.join("")}function vt(n){Xe||Rt();for(var t,e=n.length,r=e%3,i="",o=[],s=16383,f=0,h=e-r;f<h;f+=s)o.push(Sr(n,f,f+s>h?h:f+s));return r===1?(t=n[e-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):r===2&&(t=(n[e-2]<<8)+n[e-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Se(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function D(n,t){if(Se()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(n=new Uint8Array(t),n.__proto__=c.prototype):(n===null&&(n=new c(t)),n.length=t),n}function c(n,t,e){if(!c.TYPED_ARRAY_SUPPORT&&!(this instanceof c))return new c(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 Qe(this,n)}return Nt(this,n,t,e)}function Nt(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?Br(n,t,e,r):typeof t=="string"?Ur(n,t,e):Lr(n,t)}function At(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 Cr(n,t,e,r){return At(t),t<=0?D(n,t):e!==void 0?typeof r=="string"?D(n,t).fill(e,r):D(n,t).fill(e):D(n,t)}function Qe(n,t){if(At(t),n=D(n,t<0?0:Ze(t)|0),!c.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)n[e]=0;return n}function Ur(n,t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!c.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var r=Et(t,e)|0;n=D(n,r);var i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Je(n,t){var e=t.length<0?0:Ze(t.length)|0;n=D(n,e);for(var r=0;r<e;r+=1)n[r]=t[r]&255;return n}function Br(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),c.TYPED_ARRAY_SUPPORT?(n=t,n.__proto__=c.prototype):n=Je(n,t),n}function Lr(n,t){if(U(t)){var e=Ze(t.length)|0;return n=D(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"||en(t.length)?D(n,0):Je(n,t);if(t.type==="Buffer"&&Array.isArray(t.data))return Je(n,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Ze(n){if(n>=Se())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Se().toString(16)+" bytes");return n|0}function U(n){return!!(n!=null&&n._isBuffer)}function Et(n,t){if(U(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 Ce(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Ut(n).length;default:if(r)return Ce(n).length;t=(""+t).toLowerCase(),r=!0}}function _r(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 jr(this,t,e);case"utf8":case"utf-8":return Pt(this,t,e);case"ascii":return Gr(this,t,e);case"latin1":case"binary":return Yr(this,t,e);case"base64":return Wr(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Hr(this,t,e);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),r=!0}}function z(n,t,e){var r=n[t];n[t]=n[e],n[e]=r}function Ft(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=c.from(t,r)),U(t))return t.length===0?-1:Tt(n,t,e,r,i);if(typeof t=="number")return t=t&255,c.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):Tt(n,[t],e,r,i);throw new TypeError("val must be string, number or Buffer")}function Tt(n,t,e,r,i){var o=1,s=n.length,f=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,f/=2,e/=2}function h(I,R){return o===1?I[R]:I.readUInt16BE(R*o)}var m;if(i){var y=-1;for(m=e;m<s;m++)if(h(n,m)===h(t,y===-1?0:m-y)){if(y===-1&&(y=m),m-y+1===f)return y*o}else y!==-1&&(m-=m-y),y=-1}else for(e+f>s&&(e=s-f),m=e;m>=0;m--){for(var g=!0,T=0;T<f;T++)if(h(n,m+T)!==h(t,T)){g=!1;break}if(g)return m}return-1}function Mr(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 f=parseInt(t.substr(s*2,2),16);if(isNaN(f))return s;n[e+s]=f}return s}function Dr(n,t,e,r){return Le(Ce(t,n.length-e),n,e,r)}function bt(n,t,e,r){return Le(Qr(t),n,e,r)}function $r(n,t,e,r){return bt(n,t,e,r)}function Or(n,t,e,r){return Le(Ut(t),n,e,r)}function Vr(n,t,e,r){return Le(Zr(t,n.length-e),n,e,r)}function Wr(n,t,e){return t===0&&e===n.length?vt(n):vt(n.slice(t,e))}function Pt(n,t,e){e=Math.min(n.length,e);for(var r=[],i=t;i<e;){var o=n[i],s=null,f=o>239?4:o>223?3:o>191?2:1;if(i+f<=e){var h,m,y,g;switch(f){case 1:o<128&&(s=o);break;case 2:h=n[i+1],(h&192)===128&&(g=(o&31)<<6|h&63,g>127&&(s=g));break;case 3:h=n[i+1],m=n[i+2],(h&192)===128&&(m&192)===128&&(g=(o&15)<<12|(h&63)<<6|m&63,g>2047&&(g<55296||g>57343)&&(s=g));break;case 4:h=n[i+1],m=n[i+2],y=n[i+3],(h&192)===128&&(m&192)===128&&(y&192)===128&&(g=(o&15)<<18|(h&63)<<12|(m&63)<<6|y&63,g>65535&&g<1114112&&(s=g))}}s===null?(s=65533,f=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),i+=f}return qr(r)}function qr(n){var t=n.length;if(t<=It)return String.fromCharCode.apply(String,n);for(var e="",r=0;r<t;)e+=String.fromCharCode.apply(String,n.slice(r,r+=It));return e}function Gr(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 Yr(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 jr(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+=Xr(n[o]);return i}function Hr(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 N(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 b(n,t,e,r,i,o){if(!U(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 Ue(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 Be(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 kt(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 St(n,t,e,r,i){return i||kt(n,t,e,4,34028234663852886e22,-34028234663852886e22),Lt(n,t,e,r,23,4),e+4}function Ct(n,t,e,r,i){return i||kt(n,t,e,8,17976931348623157e292,-17976931348623157e292),Lt(n,t,e,r,52,8),e+8}function Kr(n){if(n=Jr(n).replace(zr,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function Jr(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")}function Xr(n){return n<16?"0"+n.toString(16):n.toString(16)}function Ce(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 Qr(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function Zr(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 Ut(n){return Pr(Kr(n))}function Le(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 en(n){return n!==n}function tn(n){return n!=null&&(!!n._isBuffer||Bt(n)||rn(n))}function Bt(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function rn(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&Bt(n.slice(0,0))}function _e(n,t,e,r,i){var o,s,f=i*8-r-1,h=(1<<f)-1,m=h>>1,y=-7,g=e?i-1:0,T=e?-1:1,I=n[t+g];for(g+=T,o=I&(1<<-y)-1,I>>=-y,y+=f;y>0;o=o*256+n[t+g],g+=T,y-=8);for(s=o&(1<<-y)-1,o>>=-y,y+=r;y>0;s=s*256+n[t+g],g+=T,y-=8);if(o===0)o=1-m;else{if(o===h)return s?NaN:(I?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-m}return(I?-1:1)*s*Math.pow(2,o-r)}function Lt(n,t,e,r,i,o){var s,f,h,m=o*8-i-1,y=(1<<m)-1,g=y>>1,T=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=r?0:o-1,R=r?1:-1,Y=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(f=isNaN(t)?1:0,s=y):(s=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-s))<1&&(s--,h*=2),s+g>=1?t+=T/h:t+=T*Math.pow(2,1-g),t*h>=2&&(s++,h/=2),s+g>=y?(f=0,s=y):s+g>=1?(f=(t*h-1)*Math.pow(2,i),s=s+g):(f=t*Math.pow(2,g-1)*Math.pow(2,i),s=0));i>=8;n[e+I]=f&255,I+=R,f/=256,i-=8);for(s=s<<i|f,m+=i;m>0;n[e+I]=s&255,I+=R,s/=256,m-=8);n[e+I-R]|=Y*128}var C,P,br,Xe,It,zr,_t=Pe(()=>{"use strict";p();l();C=[],P=[],br=typeof Uint8Array!="undefined"?Uint8Array:Array,Xe=!1;c.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;c.poolSize=8192;c._augment=function(n){return n.__proto__=c.prototype,n};c.from=function(n,t,e){return Nt(null,n,t,e)};c.kMaxLength=Se();c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&c[Symbol.species]);c.alloc=function(n,t,e){return Cr(null,n,t,e)};c.allocUnsafe=function(n){return Qe(null,n)};c.allocUnsafeSlow=function(n){return Qe(null,n)};c.isBuffer=tn;c.compare=function(t,e){if(!U(t)||!U(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};c.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}};c.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return c.alloc(0);var r;if(e===void 0)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var i=c.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(!U(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i};c.byteLength=Et;c.prototype._isBuffer=!0;c.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)z(this,e,e+1);return this};c.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)z(this,e,e+3),z(this,e+1,e+2);return this};c.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)z(this,e,e+7),z(this,e+1,e+6),z(this,e+2,e+5),z(this,e+3,e+4);return this};c.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?Pt(this,0,t):_r.apply(this,arguments)};c.prototype.equals=function(t){if(!U(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:c.compare(this,t)===0};c.prototype.compare=function(t,e,r,i,o){if(!U(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,f=r-e,h=Math.min(s,f),m=this.slice(i,o),y=t.slice(e,r),g=0;g<h;++g)if(m[g]!==y[g]){s=m[g],f=y[g];break}return s<f?-1:f<s?1:0};c.prototype.includes=function(t,e,r){return this.indexOf(t,e,r)!==-1};c.prototype.indexOf=function(t,e,r){return Ft(this,t,e,r,!0)};c.prototype.lastIndexOf=function(t,e,r){return Ft(this,t,e,r,!1)};c.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 Mr(this,t,e,r);case"utf8":case"utf-8":return Dr(this,t,e,r);case"ascii":return bt(this,t,e,r);case"latin1":case"binary":return $r(this,t,e,r);case"base64":return Or(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Vr(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};It=4096;c.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(c.TYPED_ARRAY_SUPPORT)i=this.subarray(t,e),i.__proto__=c.prototype;else{var o=e-t;i=new c(o,void 0);for(var s=0;s<o;++s)i[s]=this[s+t]}return i};c.prototype.readUIntLE=function(t,e,r){t=t|0,e=e|0,r||N(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return i};c.prototype.readUIntBE=function(t,e,r){t=t|0,e=e|0,r||N(t,e,this.length);for(var i=this[t+--e],o=1;e>0&&(o*=256);)i+=this[t+--e]*o;return i};c.prototype.readUInt8=function(t,e){return e||N(t,1,this.length),this[t]};c.prototype.readUInt16LE=function(t,e){return e||N(t,2,this.length),this[t]|this[t+1]<<8};c.prototype.readUInt16BE=function(t,e){return e||N(t,2,this.length),this[t]<<8|this[t+1]};c.prototype.readUInt32LE=function(t,e){return e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};c.prototype.readUInt32BE=function(t,e){return e||N(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};c.prototype.readIntLE=function(t,e,r){t=t|0,e=e|0,r||N(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};c.prototype.readIntBE=function(t,e,r){t=t|0,e=e|0,r||N(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};c.prototype.readInt8=function(t,e){return e||N(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};c.prototype.readInt16LE=function(t,e){e||N(t,2,this.length);var r=this[t]|this[t+1]<<8;return r&32768?r|4294901760:r};c.prototype.readInt16BE=function(t,e){e||N(t,2,this.length);var r=this[t+1]|this[t]<<8;return r&32768?r|4294901760:r};c.prototype.readInt32LE=function(t,e){return e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};c.prototype.readInt32BE=function(t,e){return e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};c.prototype.readFloatLE=function(t,e){return e||N(t,4,this.length),_e(this,t,!0,23,4)};c.prototype.readFloatBE=function(t,e){return e||N(t,4,this.length),_e(this,t,!1,23,4)};c.prototype.readDoubleLE=function(t,e){return e||N(t,8,this.length),_e(this,t,!0,52,8)};c.prototype.readDoubleBE=function(t,e){return e||N(t,8,this.length),_e(this,t,!1,52,8)};c.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;b(this,t,e,r,o,0)}var s=1,f=0;for(this[e]=t&255;++f<r&&(s*=256);)this[e+f]=t/s&255;return e+r};c.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;b(this,t,e,r,o,0)}var s=r-1,f=1;for(this[e+s]=t&255;--s>=0&&(f*=256);)this[e+s]=t/f&255;return e+r};c.prototype.writeUInt8=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t&255,e+1};c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):Ue(this,t,e,!0),e+2};c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):Ue(this,t,e,!1),e+2};c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255):Be(this,t,e,!0),e+4};c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):Be(this,t,e,!1),e+4};c.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*r-1);b(this,t,e,r,o-1,-o)}var s=0,f=1,h=0;for(this[e]=t&255;++s<r&&(f*=256);)t<0&&h===0&&this[e+s-1]!==0&&(h=1),this[e+s]=(t/f>>0)-h&255;return e+r};c.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*r-1);b(this,t,e,r,o-1,-o)}var s=r-1,f=1,h=0;for(this[e+s]=t&255;--s>=0&&(f*=256);)t<0&&h===0&&this[e+s+1]!==0&&(h=1),this[e+s]=(t/f>>0)-h&255;return e+r};c.prototype.writeInt8=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=t&255,e+1};c.prototype.writeInt16LE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):Ue(this,t,e,!0),e+2};c.prototype.writeInt16BE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):Ue(this,t,e,!1),e+2};c.prototype.writeInt32LE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):Be(this,t,e,!0),e+4};c.prototype.writeInt32BE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):Be(this,t,e,!1),e+4};c.prototype.writeFloatLE=function(t,e,r){return St(this,t,e,!0,r)};c.prototype.writeFloatBE=function(t,e,r){return St(this,t,e,!1,r)};c.prototype.writeDoubleLE=function(t,e,r){return Ct(this,t,e,!0,r)};c.prototype.writeDoubleBE=function(t,e,r){return Ct(this,t,e,!1,r)};c.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||!c.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};c.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"&&!c.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 f=U(t)?t:Ce(new c(t,i).toString()),h=f.length;for(s=0;s<r-e;++s)this[s+e]=f[s%h]}return this};zr=/[^+\/0-9A-Za-z-_]/g});var l=Pe(()=>{"use strict";_t()});function Vt(n,t){for(var e=0,r=n.length-1;r>=0;r--){var i=n[r];i==="."?n.splice(r,1):i===".."?(n.splice(r,1),e++):e&&(n.splice(r,1),e--)}if(t)for(;e--;e)n.unshift("..");return n}function rt(){for(var n="",t=!1,e=arguments.length-1;e>=-1&&!t;e--){var r=e>=0?arguments[e]:"/";if(typeof r!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!r)continue;n=r+"/"+n,t=r.charAt(0)==="/"}return n=Vt(it(n.split("/"),function(i){return!!i}),!t).join("/"),(t?"/":"")+n||"."}function Wt(n){var t=qt(n),e=gn(n,-1)==="/";return n=Vt(it(n.split("/"),function(r){return!!r}),!t).join("/"),!n&&!t&&(n="."),n&&e&&(n+="/"),(t?"/":"")+n}function qt(n){return n.charAt(0)==="/"}function pn(){var n=Array.prototype.slice.call(arguments,0);return Wt(it(n,function(t,e){if(typeof t!="string")throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function ln(n,t){n=rt(n).substr(1),t=rt(t).substr(1);function e(m){for(var y=0;y<m.length&&m[y]==="";y++);for(var g=m.length-1;g>=0&&m[g]==="";g--);return y>g?[]:m.slice(y,g-y+1)}for(var r=e(n.split("/")),i=e(t.split("/")),o=Math.min(r.length,i.length),s=o,f=0;f<o;f++)if(r[f]!==i[f]){s=f;break}for(var h=[],f=s;f<r.length;f++)h.push("..");return h=h.concat(i.slice(s)),h.join("/")}function dn(n){var t=nt(n),e=t[0],r=t[1];return!e&&!r?".":(r&&(r=r.substr(0,r.length-1)),e+r)}function mn(n,t){var e=nt(n)[2];return t&&e.substr(-1*t.length)===t&&(e=e.substr(0,e.length-t.length)),e}function yn(n){return nt(n)[3]}function it(n,t){if(n.filter)return n.filter(t);for(var e=[],r=0;r<n.length;r++)t(n[r],r,n)&&e.push(n[r]);return e}var un,nt,fn,hn,Gt,gn,Yt=Pe(()=>{"use strict";p();l();un=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,nt=function(n){return un.exec(n).slice(1)};fn="/",hn=":";Gt={extname:yn,basename:mn,dirname:dn,sep:fn,delimiter:hn,relative:ln,join:pn,isAbsolute:qt,normalize:Wt,resolve:rt};gn="ab".substr(-1)==="b"?function(n,t,e){return n.substr(t,e)}:function(n,t,e){return t<0&&(t=n.length+t),n.substr(t,e)}});var ri={};ht(ri,{DynamicSnippetsGenerator:()=>He});module.exports=er(ri);p();l();p();l();p();l();p();l();function w(n){throw new Error("Unexpected value: "+JSON.stringify(n))}p();l();function fe(n){return Object.keys(n)}p();l();p();l();p();l();var Mt,Dt,he=(Dt=(Mt=d.env.FERN_STACK_TRACK)==null?void 0:Mt.toLowerCase())!=null?Dt:"",B=he!==""&&he!=="0"&&he!=="false",et=["single","multiline","box"].includes(he)?he:"single";B&&(Error.stackTraceLimit=50);var nn=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),on=new Set(["stacktrace"]);function De({maxFrames:n=50,skip:t=0,filterPaths:e=[],filterFunctions:r=[],stopOn:i=[],filterNode:o=!0,filterJs:s=!0,formatFilename:f=h=>h}={}){var m;if(!B)return[];r=[...r,...nn],e=[...e,...on],i=[...i,"runInteractiveTask"];let h=!1;return((m=new Error().stack)!=null?m:"").split(`
2
- `).map(y=>{let g=y.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(g&&g.length===5){let[,T,I,R,Y]=g;if(!T||!I||!R||!Y)return;if(h||i.some(le=>T==null?void 0:T.includes(le))){h=!0;return}switch(T){case"Object.<anonymous>":T="";break;case"Object.object":case"Object.alias":case"Object.union":case"Object.enum":case"Object.undiscriminatedUnion":T=`${T.substring(T.indexOf(".")+1)}()=> { ... }`;break}return{fn:T,path:f(I),position:`${R}:${Y}`}}}).filter(y=>{var g,T;return y&&!r.some(I=>y.fn.includes(I))&&!(o&&((g=y.path)!=null&&g.startsWith("node:")))&&!(s&&((T=y.path)!=null&&T.endsWith(".js")))&&!e.some(I=>y.path.includes(I))}).slice(t,t+n)}var Me=class{constructor({maxFrames:t=50,skip:e=0,filterPaths:r=[],filterFunctions:i=[],stopOn:o=[],filterNode:s=!0,filterJs:f=!0,multiline:h=!1,formatFilename:m=y=>y}={}){u(this,"maxFrames");u(this,"skip");u(this,"filterPaths");u(this,"filterFunctions");u(this,"stopOn");u(this,"filterNode");u(this,"filterJs");u(this,"multiline");u(this,"formatFilename");u(this,"tracking",new WeakMap);this.maxFrames=t,this.skip=e,this.filterPaths=r,this.filterFunctions=i,this.stopOn=o,this.filterNode=s,this.filterJs=f,this.multiline=h,this.formatFilename=m}tag(t){let e=this.tracking.get(t)||new Set;De({maxFrames:this.maxFrames,skip:this.skip,filterPaths:this.filterPaths,filterFunctions:this.filterFunctions,stopOn:this.stopOn,filterNode:this.filterNode,filterJs:this.filterJs,formatFilename:this.formatFilename}).forEach(r=>e.add(r)),this.tracking.set(t,e)}trace(t){if(!B)return"";let e=this.tracking.get(t);return e?[...e].map(r=>`${this.multiline?`
3
- `:""}${r.fn} - ${r.path}:${r.position}`).join(""):""}frames(t){let e=this.tracking.get(t);return e?[...e]:[]}free(t){this.tracking.delete(t)}clear(){this.tracking=new WeakMap}},$;function $t({maxFrames:n=50,skip:t=0,filterPaths:e=[],filterFunctions:r=[],stopOn:i=[],filterNode:o=!0,filterJs:s=!0,multiline:f=!1,formatFilename:h=m=>m}={}){B&&($!=null||($=new Me({maxFrames:n,skip:t,filterPaths:e,filterFunctions:r,stopOn:i,filterNode:o,filterJs:s,multiline:f,formatFilename:h})))}function Ot(n){$==null||$.tag(n)}function tt(n){var t;return(t=$==null?void 0:$.frames(n))!=null?t:[]}var K=class{constructor(){Ot(this)}};p();l();var $e=class{formatMultiple(t){return Promise.all(t.map(e=>this.format(e)))}formatMultipleSync(t){return t.map(e=>this.formatSync(e))}},de=class extends $e{async format(t){return t}formatSync(t){return t}};p();l();p();l();p();l();var k=class extends K{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 sn=4;$t({skip:0,maxFrames:15,filterFunctions:["Abstract"]});var me=class{constructor(){u(this,"lineBuffer",[]);u(this,"indentLevel",0);u(this,"hasWrittenAnything",!1);u(this,"lastCharacterIsSemicolon",!1);u(this,"lastCharacterIsNewline",!1);u(this,"nodeStackFrames",[])}get buffer(){return B&&this.nodeStackFrames.length>0&&this.writeInternal(`
1
+ "use strict";var be=Object.defineProperty,Kt=Object.defineProperties,Jt=Object.getOwnPropertyDescriptor,Xt=Object.getOwnPropertyDescriptors,Qt=Object.getOwnPropertyNames,Fe=Object.getOwnPropertySymbols;var Ke=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable;var ze=(n,t,e)=>t in n?be(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ut=(n,t)=>{for(var e in t||(t={}))Ke.call(t,e)&&ze(n,e,t[e]);if(Fe)for(var e of Fe(t))ct.call(t,e)&&ze(n,e,t[e]);return n},pt=(n,t)=>Kt(n,Xt(t));var lt=n=>typeof n=="symbol"?n:n+"",ft=(n,t)=>{var e={};for(var r in n)Ke.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&Fe)for(var r of Fe(n))t.indexOf(r)<0&&ct.call(n,r)&&(e[r]=n[r]);return e};var Pe=(n,t)=>()=>(n&&(t=n(n=0)),t);var ht=(n,t)=>{for(var e in t)be(n,e,{get:t[e],enumerable:!0})},Zt=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Qt(t))!Ke.call(n,i)&&i!==e&&be(n,i,{get:()=>t[i],enumerable:!(r=Jt(t,i))||r.enumerable});return n};var er=n=>Zt(be({},"__esModule",{value:!0}),n);var u=(n,t,e)=>ze(n,typeof t!="symbol"?t+"":t,e);function mt(){throw new Error("setTimeout has not been defined")}function yt(){throw new Error("clearTimeout has not been defined")}function gt(n){if(q===setTimeout)return setTimeout(n,0);if((q===mt||!q)&&setTimeout)return q=setTimeout,setTimeout(n,0);try{return q(n,0)}catch(t){try{return q.call(null,n,0)}catch(e){return q.call(this,n,0)}}}function tr(n){if(G===clearTimeout)return clearTimeout(n);if((G===yt||!G)&&clearTimeout)return G=clearTimeout,clearTimeout(n);try{return G(n)}catch(t){try{return G.call(null,n)}catch(e){return G.call(this,n)}}}function rr(){!ce||!j||(ce=!1,j.length?M=j.concat(M):ke=-1,M.length&&wt())}function wt(){if(!ce){var n=gt(rr);ce=!0;for(var t=M.length;t;){for(j=M,M=[];++ke<t;)j&&j[ke].run();ke=-1,t=M.length}j=null,ce=!1,tr(n)}}function nr(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];M.push(new xt(n,t)),M.length===1&&!ce&&gt(wt)}function xt(n,t){this.fun=n,this.array=t}function H(){}function vr(n){throw new Error("process.binding is not supported")}function Tr(){return"/"}function Ir(n){throw new Error("process.chdir is not supported")}function Rr(){return 0}function Ar(n){var t=Nr.call(ae)*.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 Fr(){var n=new Date,t=n-Er;return t/1e3}var q,G,M,ce,j,ke,ir,or,sr,ar,cr,ur,pr,lr,fr,hr,dr,mr,yr,gr,wr,xr,ae,Nr,Er,d,dt,l=Pe(()=>{"use strict";q=mt,G=yt;typeof globalThis.setTimeout=="function"&&(q=setTimeout);typeof globalThis.clearTimeout=="function"&&(G=clearTimeout);M=[],ce=!1,ke=-1;xt.prototype.run=function(){this.fun.apply(null,this.array)};ir="browser",or="browser",sr=!0,ar={},cr=[],ur="",pr={},lr={},fr={};hr=H,dr=H,mr=H,yr=H,gr=H,wr=H,xr=H;ae=globalThis.performance||{},Nr=ae.now||ae.mozNow||ae.msNow||ae.oNow||ae.webkitNow||function(){return new Date().getTime()};Er=new Date;d={nextTick:nr,title:ir,browser:sr,env:ar,argv:cr,version:ur,versions:pr,on:hr,addListener:dr,once:mr,off:yr,removeListener:gr,removeAllListeners:wr,emit:xr,binding:vr,cwd:Tr,chdir:Ir,umask:Rr,hrtime:Ar,platform:or,release:lr,config:fr,uptime:Fr},dt={};Object.keys(dt).forEach(n=>{let t=n.split("."),e=d;for(let r=0;r<t.length;r++){let i=t[r];r===t.length-1?e[i]=dt[n]:e=e[i]||(e[i]={})}})});function Rt(){Xe=!0;for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=n.length;t<e;++t)C[t]=n[t],P[n.charCodeAt(t)]=t;P[45]=62,P[95]=63}function Pr(n){Xe||Rt();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 br(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=P[n.charCodeAt(t)]<<18|P[n.charCodeAt(t+1)]<<12|P[n.charCodeAt(t+2)]<<6|P[n.charCodeAt(t+3)],s[h++]=i>>16&255,s[h++]=i>>8&255,s[h++]=i&255;return o===2?(i=P[n.charCodeAt(t)]<<2|P[n.charCodeAt(t+1)]>>4,s[h++]=i&255):o===1&&(i=P[n.charCodeAt(t)]<<10|P[n.charCodeAt(t+1)]<<4|P[n.charCodeAt(t+2)]>>2,s[h++]=i>>8&255,s[h++]=i&255),s}function kr(n){return C[n>>18&63]+C[n>>12&63]+C[n>>6&63]+C[n&63]}function Sr(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(kr(r));return i.join("")}function vt(n){Xe||Rt();for(var t,e=n.length,r=e%3,i="",o=[],s=16383,p=0,h=e-r;p<h;p+=s)o.push(Sr(n,p,p+s>h?h:p+s));return r===1?(t=n[e-1],i+=C[t>>2],i+=C[t<<4&63],i+="=="):r===2&&(t=(n[e-2]<<8)+n[e-1],i+=C[t>>10],i+=C[t>>4&63],i+=C[t<<2&63],i+="="),o.push(i),o.join("")}function Se(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function D(n,t){if(Se()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(n=new Uint8Array(t),n.__proto__=c.prototype):(n===null&&(n=new c(t)),n.length=t),n}function c(n,t,e){if(!c.TYPED_ARRAY_SUPPORT&&!(this instanceof c))return new c(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 Qe(this,n)}return Nt(this,n,t,e)}function Nt(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?Br(n,t,e,r):typeof t=="string"?Ur(n,t,e):Lr(n,t)}function At(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 Cr(n,t,e,r){return At(t),t<=0?D(n,t):e!==void 0?typeof r=="string"?D(n,t).fill(e,r):D(n,t).fill(e):D(n,t)}function Qe(n,t){if(At(t),n=D(n,t<0?0:Ze(t)|0),!c.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)n[e]=0;return n}function Ur(n,t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!c.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var r=Et(t,e)|0;n=D(n,r);var i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Je(n,t){var e=t.length<0?0:Ze(t.length)|0;n=D(n,e);for(var r=0;r<e;r+=1)n[r]=t[r]&255;return n}function Br(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),c.TYPED_ARRAY_SUPPORT?(n=t,n.__proto__=c.prototype):n=Je(n,t),n}function Lr(n,t){if(U(t)){var e=Ze(t.length)|0;return n=D(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"||en(t.length)?D(n,0):Je(n,t);if(t.type==="Buffer"&&Array.isArray(t.data))return Je(n,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Ze(n){if(n>=Se())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Se().toString(16)+" bytes");return n|0}function U(n){return!!(n!=null&&n._isBuffer)}function Et(n,t){if(U(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 Ce(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Ut(n).length;default:if(r)return Ce(n).length;t=(""+t).toLowerCase(),r=!0}}function _r(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 jr(this,t,e);case"utf8":case"utf-8":return Pt(this,t,e);case"ascii":return Gr(this,t,e);case"latin1":case"binary":return Yr(this,t,e);case"base64":return Wr(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Hr(this,t,e);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),r=!0}}function z(n,t,e){var r=n[t];n[t]=n[e],n[e]=r}function Ft(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=c.from(t,r)),U(t))return t.length===0?-1:Tt(n,t,e,r,i);if(typeof t=="number")return t=t&255,c.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):Tt(n,[t],e,r,i);throw new TypeError("val must be string, number or Buffer")}function Tt(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(I,R){return o===1?I[R]:I.readUInt16BE(R*o)}var m;if(i){var y=-1;for(m=e;m<s;m++)if(h(n,m)===h(t,y===-1?0:m-y)){if(y===-1&&(y=m),m-y+1===p)return y*o}else y!==-1&&(m-=m-y),y=-1}else for(e+p>s&&(e=s-p),m=e;m>=0;m--){for(var g=!0,T=0;T<p;T++)if(h(n,m+T)!==h(t,T)){g=!1;break}if(g)return m}return-1}function Mr(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 Dr(n,t,e,r){return Le(Ce(t,n.length-e),n,e,r)}function bt(n,t,e,r){return Le(Qr(t),n,e,r)}function $r(n,t,e,r){return bt(n,t,e,r)}function Or(n,t,e,r){return Le(Ut(t),n,e,r)}function Vr(n,t,e,r){return Le(Zr(t,n.length-e),n,e,r)}function Wr(n,t,e){return t===0&&e===n.length?vt(n):vt(n.slice(t,e))}function Pt(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,m,y,g;switch(p){case 1:o<128&&(s=o);break;case 2:h=n[i+1],(h&192)===128&&(g=(o&31)<<6|h&63,g>127&&(s=g));break;case 3:h=n[i+1],m=n[i+2],(h&192)===128&&(m&192)===128&&(g=(o&15)<<12|(h&63)<<6|m&63,g>2047&&(g<55296||g>57343)&&(s=g));break;case 4:h=n[i+1],m=n[i+2],y=n[i+3],(h&192)===128&&(m&192)===128&&(y&192)===128&&(g=(o&15)<<18|(h&63)<<12|(m&63)<<6|y&63,g>65535&&g<1114112&&(s=g))}}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 qr(r)}function qr(n){var t=n.length;if(t<=It)return String.fromCharCode.apply(String,n);for(var e="",r=0;r<t;)e+=String.fromCharCode.apply(String,n.slice(r,r+=It));return e}function Gr(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 Yr(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 jr(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+=Xr(n[o]);return i}function Hr(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 N(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 b(n,t,e,r,i,o){if(!U(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 Ue(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 Be(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 kt(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 St(n,t,e,r,i){return i||kt(n,t,e,4,34028234663852886e22,-34028234663852886e22),Lt(n,t,e,r,23,4),e+4}function Ct(n,t,e,r,i){return i||kt(n,t,e,8,17976931348623157e292,-17976931348623157e292),Lt(n,t,e,r,52,8),e+8}function Kr(n){if(n=Jr(n).replace(zr,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function Jr(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")}function Xr(n){return n<16?"0"+n.toString(16):n.toString(16)}function Ce(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 Qr(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function Zr(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 Ut(n){return Pr(Kr(n))}function Le(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 en(n){return n!==n}function tn(n){return n!=null&&(!!n._isBuffer||Bt(n)||rn(n))}function Bt(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function rn(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&Bt(n.slice(0,0))}function _e(n,t,e,r,i){var o,s,p=i*8-r-1,h=(1<<p)-1,m=h>>1,y=-7,g=e?i-1:0,T=e?-1:1,I=n[t+g];for(g+=T,o=I&(1<<-y)-1,I>>=-y,y+=p;y>0;o=o*256+n[t+g],g+=T,y-=8);for(s=o&(1<<-y)-1,o>>=-y,y+=r;y>0;s=s*256+n[t+g],g+=T,y-=8);if(o===0)o=1-m;else{if(o===h)return s?NaN:(I?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-m}return(I?-1:1)*s*Math.pow(2,o-r)}function Lt(n,t,e,r,i,o){var s,p,h,m=o*8-i-1,y=(1<<m)-1,g=y>>1,T=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=r?0:o-1,R=r?1:-1,Y=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=y):(s=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-s))<1&&(s--,h*=2),s+g>=1?t+=T/h:t+=T*Math.pow(2,1-g),t*h>=2&&(s++,h/=2),s+g>=y?(p=0,s=y):s+g>=1?(p=(t*h-1)*Math.pow(2,i),s=s+g):(p=t*Math.pow(2,g-1)*Math.pow(2,i),s=0));i>=8;n[e+I]=p&255,I+=R,p/=256,i-=8);for(s=s<<i|p,m+=i;m>0;n[e+I]=s&255,I+=R,s/=256,m-=8);n[e+I-R]|=Y*128}var C,P,br,Xe,It,zr,_t=Pe(()=>{"use strict";l();f();C=[],P=[],br=typeof Uint8Array!="undefined"?Uint8Array:Array,Xe=!1;c.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;c.poolSize=8192;c._augment=function(n){return n.__proto__=c.prototype,n};c.from=function(n,t,e){return Nt(null,n,t,e)};c.kMaxLength=Se();c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&c[Symbol.species]);c.alloc=function(n,t,e){return Cr(null,n,t,e)};c.allocUnsafe=function(n){return Qe(null,n)};c.allocUnsafeSlow=function(n){return Qe(null,n)};c.isBuffer=tn;c.compare=function(t,e){if(!U(t)||!U(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};c.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}};c.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return c.alloc(0);var r;if(e===void 0)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var i=c.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(!U(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i};c.byteLength=Et;c.prototype._isBuffer=!0;c.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)z(this,e,e+1);return this};c.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)z(this,e,e+3),z(this,e+1,e+2);return this};c.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)z(this,e,e+7),z(this,e+1,e+6),z(this,e+2,e+5),z(this,e+3,e+4);return this};c.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?Pt(this,0,t):_r.apply(this,arguments)};c.prototype.equals=function(t){if(!U(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:c.compare(this,t)===0};c.prototype.compare=function(t,e,r,i,o){if(!U(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),m=this.slice(i,o),y=t.slice(e,r),g=0;g<h;++g)if(m[g]!==y[g]){s=m[g],p=y[g];break}return s<p?-1:p<s?1:0};c.prototype.includes=function(t,e,r){return this.indexOf(t,e,r)!==-1};c.prototype.indexOf=function(t,e,r){return Ft(this,t,e,r,!0)};c.prototype.lastIndexOf=function(t,e,r){return Ft(this,t,e,r,!1)};c.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 Mr(this,t,e,r);case"utf8":case"utf-8":return Dr(this,t,e,r);case"ascii":return bt(this,t,e,r);case"latin1":case"binary":return $r(this,t,e,r);case"base64":return Or(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Vr(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};It=4096;c.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(c.TYPED_ARRAY_SUPPORT)i=this.subarray(t,e),i.__proto__=c.prototype;else{var o=e-t;i=new c(o,void 0);for(var s=0;s<o;++s)i[s]=this[s+t]}return i};c.prototype.readUIntLE=function(t,e,r){t=t|0,e=e|0,r||N(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return i};c.prototype.readUIntBE=function(t,e,r){t=t|0,e=e|0,r||N(t,e,this.length);for(var i=this[t+--e],o=1;e>0&&(o*=256);)i+=this[t+--e]*o;return i};c.prototype.readUInt8=function(t,e){return e||N(t,1,this.length),this[t]};c.prototype.readUInt16LE=function(t,e){return e||N(t,2,this.length),this[t]|this[t+1]<<8};c.prototype.readUInt16BE=function(t,e){return e||N(t,2,this.length),this[t]<<8|this[t+1]};c.prototype.readUInt32LE=function(t,e){return e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};c.prototype.readUInt32BE=function(t,e){return e||N(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};c.prototype.readIntLE=function(t,e,r){t=t|0,e=e|0,r||N(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};c.prototype.readIntBE=function(t,e,r){t=t|0,e=e|0,r||N(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};c.prototype.readInt8=function(t,e){return e||N(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};c.prototype.readInt16LE=function(t,e){e||N(t,2,this.length);var r=this[t]|this[t+1]<<8;return r&32768?r|4294901760:r};c.prototype.readInt16BE=function(t,e){e||N(t,2,this.length);var r=this[t+1]|this[t]<<8;return r&32768?r|4294901760:r};c.prototype.readInt32LE=function(t,e){return e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};c.prototype.readInt32BE=function(t,e){return e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};c.prototype.readFloatLE=function(t,e){return e||N(t,4,this.length),_e(this,t,!0,23,4)};c.prototype.readFloatBE=function(t,e){return e||N(t,4,this.length),_e(this,t,!1,23,4)};c.prototype.readDoubleLE=function(t,e){return e||N(t,8,this.length),_e(this,t,!0,52,8)};c.prototype.readDoubleBE=function(t,e){return e||N(t,8,this.length),_e(this,t,!1,52,8)};c.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;b(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};c.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;b(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};c.prototype.writeUInt8=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t&255,e+1};c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):Ue(this,t,e,!0),e+2};c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):Ue(this,t,e,!1),e+2};c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255):Be(this,t,e,!0),e+4};c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):Be(this,t,e,!1),e+4};c.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*r-1);b(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};c.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*r-1);b(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};c.prototype.writeInt8=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=t&255,e+1};c.prototype.writeInt16LE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):Ue(this,t,e,!0),e+2};c.prototype.writeInt16BE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):Ue(this,t,e,!1),e+2};c.prototype.writeInt32LE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):Be(this,t,e,!0),e+4};c.prototype.writeInt32BE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):Be(this,t,e,!1),e+4};c.prototype.writeFloatLE=function(t,e,r){return St(this,t,e,!0,r)};c.prototype.writeFloatBE=function(t,e,r){return St(this,t,e,!1,r)};c.prototype.writeDoubleLE=function(t,e,r){return Ct(this,t,e,!0,r)};c.prototype.writeDoubleBE=function(t,e,r){return Ct(this,t,e,!1,r)};c.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||!c.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};c.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"&&!c.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=U(t)?t:Ce(new c(t,i).toString()),h=p.length;for(s=0;s<r-e;++s)this[s+e]=p[s%h]}return this};zr=/[^+\/0-9A-Za-z-_]/g});var f=Pe(()=>{"use strict";_t()});function Vt(n,t){for(var e=0,r=n.length-1;r>=0;r--){var i=n[r];i==="."?n.splice(r,1):i===".."?(n.splice(r,1),e++):e&&(n.splice(r,1),e--)}if(t)for(;e--;e)n.unshift("..");return n}function rt(){for(var n="",t=!1,e=arguments.length-1;e>=-1&&!t;e--){var r=e>=0?arguments[e]:"/";if(typeof r!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!r)continue;n=r+"/"+n,t=r.charAt(0)==="/"}return n=Vt(it(n.split("/"),function(i){return!!i}),!t).join("/"),(t?"/":"")+n||"."}function Wt(n){var t=qt(n),e=gn(n,-1)==="/";return n=Vt(it(n.split("/"),function(r){return!!r}),!t).join("/"),!n&&!t&&(n="."),n&&e&&(n+="/"),(t?"/":"")+n}function qt(n){return n.charAt(0)==="/"}function pn(){var n=Array.prototype.slice.call(arguments,0);return Wt(it(n,function(t,e){if(typeof t!="string")throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function ln(n,t){n=rt(n).substr(1),t=rt(t).substr(1);function e(m){for(var y=0;y<m.length&&m[y]==="";y++);for(var g=m.length-1;g>=0&&m[g]==="";g--);return y>g?[]:m.slice(y,g-y+1)}for(var r=e(n.split("/")),i=e(t.split("/")),o=Math.min(r.length,i.length),s=o,p=0;p<o;p++)if(r[p]!==i[p]){s=p;break}for(var h=[],p=s;p<r.length;p++)h.push("..");return h=h.concat(i.slice(s)),h.join("/")}function dn(n){var t=nt(n),e=t[0],r=t[1];return!e&&!r?".":(r&&(r=r.substr(0,r.length-1)),e+r)}function mn(n,t){var e=nt(n)[2];return t&&e.substr(-1*t.length)===t&&(e=e.substr(0,e.length-t.length)),e}function yn(n){return nt(n)[3]}function it(n,t){if(n.filter)return n.filter(t);for(var e=[],r=0;r<n.length;r++)t(n[r],r,n)&&e.push(n[r]);return e}var un,nt,fn,hn,Gt,gn,Yt=Pe(()=>{"use strict";l();f();un=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,nt=function(n){return un.exec(n).slice(1)};fn="/",hn=":";Gt={extname:yn,basename:mn,dirname:dn,sep:fn,delimiter:hn,relative:ln,join:pn,isAbsolute:qt,normalize:Wt,resolve:rt};gn="ab".substr(-1)==="b"?function(n,t,e){return n.substr(t,e)}:function(n,t,e){return t<0&&(t=n.length+t),n.substr(t,e)}});var ri={};ht(ri,{DynamicSnippetsGenerator:()=>He});module.exports=er(ri);l();f();l();f();l();f();l();f();function x(n){throw new Error("Unexpected value: "+JSON.stringify(n))}l();f();function fe(n){return Object.keys(n)}l();f();l();f();l();f();var Mt,Dt,he=(Dt=(Mt=d.env.FERN_STACK_TRACK)==null?void 0:Mt.toLowerCase())!=null?Dt:"",B=he!==""&&he!=="0"&&he!=="false",et=["single","multiline","box"].includes(he)?he:"single";B&&(Error.stackTraceLimit=50);var nn=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),on=new Set(["stacktrace"]);function De({maxFrames:n=50,skip:t=0,filterPaths:e=[],filterFunctions:r=[],stopOn:i=[],filterNode:o=!0,filterJs:s=!0,formatFilename:p=h=>h}={}){var m;if(!B)return[];r=[...r,...nn],e=[...e,...on],i=[...i,"runInteractiveTask"];let h=!1;return((m=new Error().stack)!=null?m:"").split(`
2
+ `).map(y=>{let g=y.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(g&&g.length===5){let[,T,I,R,Y]=g;if(!T||!I||!R||!Y)return;if(h||i.some(le=>T==null?void 0:T.includes(le))){h=!0;return}switch(T){case"Object.<anonymous>":T="";break;case"Object.object":case"Object.alias":case"Object.union":case"Object.enum":case"Object.undiscriminatedUnion":T=`${T.substring(T.indexOf(".")+1)}()=> { ... }`;break}return{fn:T,path:p(I),position:`${R}:${Y}`}}}).filter(y=>{var g,T;return y&&!r.some(I=>y.fn.includes(I))&&!(o&&((g=y.path)!=null&&g.startsWith("node:")))&&!(s&&((T=y.path)!=null&&T.endsWith(".js")))&&!e.some(I=>y.path.includes(I))}).slice(t,t+n)}var Me=class{constructor({maxFrames:t=50,skip:e=0,filterPaths:r=[],filterFunctions:i=[],stopOn:o=[],filterNode:s=!0,filterJs:p=!0,multiline:h=!1,formatFilename:m=y=>y}={}){u(this,"maxFrames");u(this,"skip");u(this,"filterPaths");u(this,"filterFunctions");u(this,"stopOn");u(this,"filterNode");u(this,"filterJs");u(this,"multiline");u(this,"formatFilename");u(this,"tracking",new WeakMap);this.maxFrames=t,this.skip=e,this.filterPaths=r,this.filterFunctions=i,this.stopOn=o,this.filterNode=s,this.filterJs=p,this.multiline=h,this.formatFilename=m}tag(t){let e=this.tracking.get(t)||new Set;De({maxFrames:this.maxFrames,skip:this.skip,filterPaths:this.filterPaths,filterFunctions:this.filterFunctions,stopOn:this.stopOn,filterNode:this.filterNode,filterJs:this.filterJs,formatFilename:this.formatFilename}).forEach(r=>e.add(r)),this.tracking.set(t,e)}trace(t){if(!B)return"";let e=this.tracking.get(t);return e?[...e].map(r=>`${this.multiline?`
3
+ `:""}${r.fn} - ${r.path}:${r.position}`).join(""):""}frames(t){let e=this.tracking.get(t);return e?[...e]:[]}free(t){this.tracking.delete(t)}clear(){this.tracking=new WeakMap}},$;function $t({maxFrames:n=50,skip:t=0,filterPaths:e=[],filterFunctions:r=[],stopOn:i=[],filterNode:o=!0,filterJs:s=!0,multiline:p=!1,formatFilename:h=m=>m}={}){B&&($!=null||($=new Me({maxFrames:n,skip:t,filterPaths:e,filterFunctions:r,stopOn:i,filterNode:o,filterJs:s,multiline:p,formatFilename:h})))}function Ot(n){$==null||$.tag(n)}function tt(n){var t;return(t=$==null?void 0:$.frames(n))!=null?t:[]}var K=class{constructor(){Ot(this)}};l();f();var $e=class{formatMultiple(t){return Promise.all(t.map(e=>this.format(e)))}formatMultipleSync(t){return t.map(e=>this.formatSync(e))}},de=class extends $e{async format(t){return t}formatSync(t){return t}};l();f();l();f();l();f();var k=class extends K{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 sn=4;$t({skip:0,maxFrames:15,filterFunctions:["Abstract"]});var me=class{constructor(){u(this,"lineBuffer",[]);u(this,"indentLevel",0);u(this,"hasWrittenAnything",!1);u(this,"lastCharacterIsSemicolon",!1);u(this,"lastCharacterIsNewline",!1);u(this,"nodeStackFrames",[])}get buffer(){return B&&this.nodeStackFrames.length>0&&this.writeInternal(`
4
4
  `),this.lineBuffer.join(`
5
5
  `)+(this.lastCharacterIsNewline?`
6
6
  `:"")}write(...t){for(let e of t)if(e!=null)if(typeof e=="string"){let r=e.length>0&&e.endsWith(`
@@ -12,7 +12,7 @@ ${o}`);this.isAtStartOfLine()&&(s=o+s),r&&(s+=`
12
12
  `)}writeSemicolonIfLastCharacterIsNot(){this.lastCharacterIsSemicolon||this.writeInternal(";")}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
13
13
  `)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:t,delimiter:e,writeFunction: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){if(t.length===0)return;let e=!this.lastCharacterIsNewline;this.hasWrittenAnything=!0,this.lastCharacterIsNewline=t.endsWith(`
14
14
  `),this.lastCharacterIsSemicolon=t.endsWith(";");let r=t.split(`
15
- `),i=B&&!this.shouldSkipTracking(r)&&this.lastCharacterIsNewline;e&&(this.lastLine=`${this.lastLine}${r.shift()||""}`),this.lastCharacterIsNewline&&r.pop(),this.lineBuffer.push(...r),i&&this.appendTrackingComment()}set lastLine(t){this.lineBuffer.length>0?this.lineBuffer[this.lineBuffer.length-1]=t:this.lineBuffer.push(t)}get lastLine(){return this.lineBuffer[this.lineBuffer.length-1]||""}shouldSkipTracking(t){return!1}formatStack(t,e=""){return t.map(r=>`${e?`(${e}) `:""} ${r.fn} - ${r.path} : ${r.position}`)}filterStack(t){return t.filter(e=>!e.fn.startsWith(`${this.constructor.name}.`))}appendTrackingComment(){let t=[...this.formatStack(this.filterStack(De({maxFrames:15,skip:3}))),...this.formatStack(this.filterStack(this.nodeStackFrames),"node")];switch(this.nodeStackFrames.length=0,et){case"single":return this.singleLineTrackingComment(t);case"multiline":return this.multiLineTrackingComment(t);case"box":return this.boxTrackingComment(t)}}singleLineTrackingComment(t){this.lastLine=`${this.lastLine} // ${t.join(" ")}`}multiLineTrackingComment(t){this.lineBuffer.push(...t.map(e=>` // ${e}`))}boxTrackingComment(t){this.lineBuffer.push("/*",...t.map(e=>` ${e}`),"*/")}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*this.getTabSize())}getTabSize(){return sn}};p();l();p();l();p();l();var ye=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 ge=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 ye;for(let o of r){let s=this.context.clone(),f=this.createSnippetGenerator(s);try{let h=await f.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 ye;for(let o of r){let s=this.context.clone(),f=this.createSnippetGenerator(s);try{let h=f.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})}};p();l();p();l();p();l();var xe=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]}}};p();l();var v={Critical:"CRITICAL",Warning:"WARNING"},we=class n{constructor(){u(this,"errors");u(this,"path");this.errors=[],this.path=[]}add(t){this.errors.push(pt(ut({},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 ve=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 we,this.httpEndpointReferenceParser=new xe}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 f=this.isListTypeReference(s.typeReference)&&!Array.isArray(o)?[o]:o;r.push({name:s.name,typeReference:s.typeReference,value:f})}finally{this.errors.unscope()}}return r}associateByWireValueOrDefault({parameters:t,values:e}){let r=[];for(let i of t){this.errors.scope(i.name.wireValue);try{let o=e[i.name.wireValue];if(o==null)if(i.typeReference.type==="primitive"&&i.typeReference.value==="STRING")o=`<${i.name.wireValue}>`;else{this.errors.add({severity:v.Critical,message:this.newParameterNotRecognizedError(i.name.wireValue).message});continue}r.push({name:i.name,typeReference:i.typeReference,value:o})}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 f=t.find(h=>h.name.wireValue===o);if(f==null){if(r)continue;this.errors.add({severity:v.Critical,message:this.newParameterNotRecognizedError(o).message});continue}i.push({name:f.name,typeReference:f.typeReference,value:s})}finally{this.errors.unscope()}}return i}getExampleObjectProperties({parameters:t,snippetObject:e}){let r=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},i=[];for(let o of t){let s=r[o.name.wireValue];s==null?o.typeReference.type==="nullable"&&i.push({name:o.name,typeReference:o.typeReference,value:null}):i.push({name:o.name,typeReference:o.typeReference,value:s})}return i}getSingleFileValue({property:t,record:e}){let r=e[t.wireValue];if(r!=null){if(typeof r!="string"){this.errors.add({severity:v.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:v.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:v.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:v.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:v.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:v.Critical,message:this.newParameterNotRecognizedError(i).message});return}if(typeof o!="string"){this.errors.add({severity:v.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:v.Critical,message:`No type found for discriminant value "${o}"`});return}let m=r,{[i]:f}=m,h=ft(m,[lt(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)}resolveEndpointLocation(t){let e=[];for(let r of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:r,parsedEndpoint:t})&&e.push(r);return e}resolveEndpointLocationOrThrow(t){let e=this.resolveEndpointLocation(t);if(e.length===0)throw new Error(`Failed to find endpoint identified by "${t.method} ${t.path}"`);return e}needsRequestParameter({request:t,inlinePathParameters:e,inlineFileProperties: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:w(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:w(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:v.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:v.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:v.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let i=new Set(fe(r.urls));for(let o of fe(t))i.has(o)&&i.delete(o);return i.size>0?(this.errors.add({severity:v.Critical,message:`The provided environments are invalid; got: [${Object.keys(t).join(", ")}], expected: [${fe(r.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:t}){if(typeof t!="number"){this.errors.add({severity:v.Critical,message:this.newTypeMismatchError({expected:"number",value:t}).message});return}return t}getValueAsBoolean({value:t}){if(typeof t!="boolean"){this.errors.add({severity:v.Critical,message:this.newTypeMismatchError({expected:"boolean",value:t}).message});return}return t}getValueAsString({value:t}){if(typeof t!="string"){this.errors.add({severity:v.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:w(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:w(e)}})}fileUploadHasFileProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:w(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}};p();l();var L={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};p();l();p();l();function Te(n,t){var r,i;let e=(r=n.split("/").pop())!=null?r:n;return t!=null&&t.stripExtension&&(i=e.split(".")[0])!=null?i:e}p();l();p();l();p();l();p();l();var an=/[^0-9a-zA-Z_]/g,cn=["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],J=class extends me{constructor({packageName:e,rootImportPath:r,importPath:i,customConfig:o,formatter:s}){super();u(this,"packageName");u(this,"rootImportPath");u(this,"importPath");u(this,"customConfig");u(this,"formatter");u(this,"imports",{});this.packageName=e,this.rootImportPath=r,this.importPath=i,this.customConfig=o,this.formatter=s!=null?s:new de}addImport(e){let r=this.imports[e];if(r!=null)return r;if(e===this.rootImportPath&&this.customConfig.packageName!=null)return this.imports[e]=this.customConfig.packageName,this.customConfig.packageName;let i=new Set(Object.values(this.imports)),o=e.split("/");for(let f=1;f<=o.length;f++){let h=o.slice(-f),m=this.getValidAlias(h.join(""));if(!i.has(m))return this.imports[e]=m,m}let s=this.getValidAlias(Te(e));for(;i.has(s);)s="_"+s;return this.imports[e]=s,s}isValidAlias(e){return!cn.includes(e)}getValidAlias(e){let r=e.split("-");if(r[0]==null)return e;let i=r.map(o=>o.replace(an,"")).join("");return this.isValidAlias(i)?i:"_"+i}};var Ie=class extends J{constructor({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o}){super({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o})}async toStringAsync(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.format(t)}catch(e){throw new Error(`Failed to format Go file: ${e}
15
+ `),i=B&&!this.shouldSkipTracking(r)&&this.lastCharacterIsNewline;e&&(this.lastLine=`${this.lastLine}${r.shift()||""}`),this.lastCharacterIsNewline&&r.pop(),this.lineBuffer.push(...r),i&&this.appendTrackingComment()}set lastLine(t){this.lineBuffer.length>0?this.lineBuffer[this.lineBuffer.length-1]=t:this.lineBuffer.push(t)}get lastLine(){return this.lineBuffer[this.lineBuffer.length-1]||""}shouldSkipTracking(t){return!1}formatStack(t,e=""){return t.map(r=>`${e?`(${e}) `:""} ${r.fn} - ${r.path} : ${r.position}`)}filterStack(t){return t.filter(e=>!e.fn.startsWith(`${this.constructor.name}.`))}appendTrackingComment(){let t=[...this.formatStack(this.filterStack(De({maxFrames:15,skip:3}))),...this.formatStack(this.filterStack(this.nodeStackFrames),"node")];switch(this.nodeStackFrames.length=0,et){case"single":return this.singleLineTrackingComment(t);case"multiline":return this.multiLineTrackingComment(t);case"box":return this.boxTrackingComment(t)}}singleLineTrackingComment(t){this.lastLine=`${this.lastLine} // ${t.join(" ")}`}multiLineTrackingComment(t){this.lineBuffer.push(...t.map(e=>` // ${e}`))}boxTrackingComment(t){this.lineBuffer.push("/*",...t.map(e=>` ${e}`),"*/")}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*this.getTabSize())}getTabSize(){return sn}};l();f();l();f();l();f();var ye=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 ge=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 ye;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})}async generateSnippetAst(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;for(let o of r){let s=this.context.clone(),p=this.createSnippetGenerator(s);try{return await p.generateSnippetAst({endpoint:o,request:t,options:e})}catch(h){i=h}}throw i!=null?i:new Error(`Failed to generate snippet AST for endpoint: ${t.endpoint.method} ${t.endpoint.path}`)}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 ye;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})}};l();f();l();f();l();f();var we=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]}}};l();f();var v={Critical:"CRITICAL",Warning:"WARNING"},xe=class n{constructor(){u(this,"errors");u(this,"path");this.errors=[],this.path=[]}add(t){this.errors.push(pt(ut({},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 ve=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 xe,this.httpEndpointReferenceParser=new we}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}associateByWireValueOrDefault({parameters:t,values:e}){let r=[];for(let i of t){this.errors.scope(i.name.wireValue);try{let o=e[i.name.wireValue];if(o==null)if(i.typeReference.type==="primitive"&&i.typeReference.value==="STRING")o=`<${i.name.wireValue}>`;else{this.errors.add({severity:v.Critical,message:this.newParameterNotRecognizedError(i.name.wireValue).message});continue}r.push({name:i.name,typeReference:i.typeReference,value:o})}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:v.Critical,message:this.newParameterNotRecognizedError(o).message});continue}i.push({name:p.name,typeReference:p.typeReference,value:s})}finally{this.errors.unscope()}}return i}getExampleObjectProperties({parameters:t,snippetObject:e}){let r=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},i=[];for(let o of t){let s=r[o.name.wireValue];s==null?o.typeReference.type==="nullable"&&i.push({name:o.name,typeReference:o.typeReference,value:null}):i.push({name:o.name,typeReference:o.typeReference,value:s})}return i}getSingleFileValue({property:t,record:e}){let r=e[t.wireValue];if(r!=null){if(typeof r!="string"){this.errors.add({severity:v.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:v.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:v.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:v.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:v.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:v.Critical,message:this.newParameterNotRecognizedError(i).message});return}if(typeof o!="string"){this.errors.add({severity:v.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:v.Critical,message:`No type found for discriminant value "${o}"`});return}let m=r,{[i]:p}=m,h=ft(m,[lt(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)}resolveEndpointLocation(t){let e=[];for(let r of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:r,parsedEndpoint:t})&&e.push(r);return e}resolveEndpointLocationOrThrow(t){let e=this.resolveEndpointLocation(t);if(e.length===0)throw new Error(`Failed to find endpoint identified by "${t.method} ${t.path}"`);return e}needsRequestParameter({request:t,inlinePathParameters:e,inlineFileProperties: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:x(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:x(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:v.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:v.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:v.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let i=new Set(fe(r.urls));for(let o of fe(t))i.has(o)&&i.delete(o);return i.size>0?(this.errors.add({severity:v.Critical,message:`The provided environments are invalid; got: [${Object.keys(t).join(", ")}], expected: [${fe(r.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:t}){if(typeof t!="number"){this.errors.add({severity:v.Critical,message:this.newTypeMismatchError({expected:"number",value:t}).message});return}return t}getValueAsBoolean({value:t}){if(typeof t!="boolean"){this.errors.add({severity:v.Critical,message:this.newTypeMismatchError({expected:"boolean",value:t}).message});return}return t}getValueAsString({value:t}){if(typeof t!="string"){this.errors.add({severity:v.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:x(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:x(e)}})}fileUploadHasFileProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:x(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}};l();f();var L={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};l();f();l();f();function Te(n,t){var r,i;let e=(r=n.split("/").pop())!=null?r:n;return t!=null&&t.stripExtension&&(i=e.split(".")[0])!=null?i:e}l();f();l();f();l();f();l();f();var an=/[^0-9a-zA-Z_]/g,cn=["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],J=class extends me{constructor({packageName:e,rootImportPath:r,importPath:i,customConfig:o,formatter:s}){super();u(this,"packageName");u(this,"rootImportPath");u(this,"importPath");u(this,"customConfig");u(this,"formatter");u(this,"imports",{});this.packageName=e,this.rootImportPath=r,this.importPath=i,this.customConfig=o,this.formatter=s!=null?s:new de}addImport(e){let r=this.imports[e];if(r!=null)return r;if(e===this.rootImportPath&&this.customConfig.packageName!=null)return this.imports[e]=this.customConfig.packageName,this.customConfig.packageName;let i=new Set(Object.values(this.imports)),o=e.split("/");for(let p=1;p<=o.length;p++){let h=o.slice(-p),m=this.getValidAlias(h.join(""));if(!i.has(m))return this.imports[e]=m,m}let s=this.getValidAlias(Te(e));for(;i.has(s);)s="_"+s;return this.imports[e]=s,s}isValidAlias(e){return!cn.includes(e)}getValidAlias(e){let r=e.split("-");if(r[0]==null)return e;let i=r.map(o=>o.replace(an,"")).join("");return this.isValidAlias(i)?i:"_"+i}};var Ie=class extends J{constructor({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o}){super({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o})}async toStringAsync(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.format(t)}catch(e){throw new Error(`Failed to format Go file: ${e}
16
16
  ${t}`)}return t}toString(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.formatSync(t)}catch(e){throw new Error(`Failed to format Go file: ${e}
17
17
  ${t}`)}return t}getContent(){let t=`package ${this.packageName}
18
18
 
@@ -21,9 +21,9 @@ ${t}`)}return t}getContent(){let t=`package ${this.packageName}
21
21
  ${this.buffer}`:t+this.buffer}stringifyImports(){let t=Object.entries(this.imports).filter(([e,r])=>e!==this.importPath).map(([e,r])=>` ${r} "${e}"`).join(`
22
22
  `);return t?`import (
23
23
  ${t}
24
- )`:""}};var a={};ht(a,{Alias:()=>X,AstNode:()=>x,CodeBlock:()=>_,Enum:()=>Q,Field:()=>Z,File:()=>ee,Func:()=>te,FuncInvocation:()=>S,IoReaderTypeReference:()=>ot,Method:()=>W,MethodInvocation:()=>V,MultiNode:()=>Re,Parameter:()=>re,Pointer:()=>ne,Selector:()=>ie,Struct:()=>oe,TimeTypeReference:()=>Oe,Type:()=>Ae,TypeDeclaration:()=>se,TypeInstantiation:()=>E,TypeReference:()=>F,UuidTypeReference:()=>Ve,Writer:()=>J,alias:()=>Pn,codeblock:()=>kn,enum_:()=>Sn,field:()=>Cn,file:()=>Un,func:()=>Bn,identifier:()=>Ln,invokeFunc:()=>_n,invokeMethod:()=>Mn,method:()=>Dn,parameter:()=>$n,pointer:()=>On,selector:()=>Vn,struct:()=>Wn,switch_:()=>qn,typeDeclaration:()=>Gn,typeReference:()=>Yn});p();l();p();l();p();l();p();l();p();l();var x=class extends K{async toStringAsync({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o}){let s=new Ie({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o});return this.write(s),s.toStringAsync()}toString({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o}){let s=new Ie({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o});return this.write(s),s.toString()}};var A=class extends x{constructor({docs:e}={}){super();u(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
25
- `).forEach(r=>{e.writeLine(`// ${r}`)})}};var X=class extends x{constructor({name:e,type:r,docs:i}){super();u(this,"name");u(this,"type");u(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new A({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" = "),e.writeNode(this.type)}};p();l();var _=class extends x{constructor(e){super();u(this,"arg");this.arg=e}write(e){return new k(this.arg).write(e)}};p();l();p();l();var O=class extends x{constructor(e){super();u(this,"name");this.name=e}write(e){e.write(this.name)}};p();l();p();l();p();l();function ue({writer:n,arguments_:t,multiline:e=!0}){let r=t.map(i=>i instanceof E&&E.isNop(i)?E.nil():i);if(r.length===0){n.write("()");return}if(e){xn({writer:n,arguments_:r});return}wn({writer:n,arguments_:r})}function xn({writer:n,arguments_:t}){n.writeLine("("),n.indent();for(let e of t)e.write(n),n.writeLine(",");n.dedent(),n.write(")")}function wn({writer:n,arguments_:t}){n.write("("),t.forEach((e,r)=>{r>0&&n.write(", "),e.write(n)}),n.write(")")}var S=class extends x{constructor({func:e,arguments_:r,multiline:i=!0}){super();u(this,"func");u(this,"arguments_");u(this,"multiline");this.func=e,this.arguments_=r,this.multiline=i}write(e){e.writeNode(this.func),ue({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};p();l();p();l();function jt({writer:n,generics:t}){t.length!==0&&(n.write("["),t.forEach((e,r)=>{r>0&&n.write(", "),e!=null&&n.writeNode(e)}),n.write("]"))}var F=class extends x{constructor({name:e,importPath:r,generics:i}){super();u(this,"name");u(this,"importPath");u(this,"generics");this.name=e,this.importPath=r,this.generics=i}write(e){if(this.importPath==null||e.importPath===this.importPath){e.write(this.name);return}let r=e.addImport(this.importPath);e.write(`${r}.${this.name}`),this.generics!=null&&jt({writer:e,generics:this.generics})}};p();l();var V=class extends x{constructor({method:e,arguments_:r,on:i,multiline:o}){super();u(this,"on");u(this,"method");u(this,"arguments_");u(this,"multiline");this.on=i,this.method=e,this.arguments_=r,this.multiline=o}write(e){this.on.write(e),e.write("."),e.write(this.method),ue({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};var vn=new Set(["bool","date","dateTime","float64","int","int64","string","uuid"]),Ht=new Set(["any","bytes","map","slice"]),E=class n extends x{constructor(e){super();u(this,"internalType");this.internalType=e}write(e){switch(this.internalType.type){case"any":this.writeAny({writer:e,value:this.internalType.value});break;case"bool":e.write(this.internalType.value.toString());break;case"bytes":e.write(`[]byte("${this.internalType.value}")`);break;case"date":case"dateTime":e.writeNode(Rn({writer:e,type:this.internalType}));break;case"enum":e.writeNode(this.internalType.typeReference);break;case"float64":e.write(this.internalType.value.toString());break;case"int":case"int64":e.write(this.internalType.value.toString());break;case"map":this.writeMap({writer:e,map:this.internalType});break;case"nil":e.write("nil");break;case"nop":break;case"optional":this.writeOptional({writer:e,type:this.internalType.value});break;case"reference":e.writeNode(this.internalType.value);break;case"slice":this.writeSlice({writer:e,slice:this.internalType});break;case"string":e.write(this.internalType.value.includes('"')||this.internalType.value.includes(`
26
- `)?`\`${this.internalType.value}\``:`"${this.internalType.value}"`);break;case"struct":this.writeStruct({writer:e,struct:this.internalType});break;case"uuid":e.writeNode(Nn({value:this.internalType.value}));break;default:w(this.internalType)}}static any(e){return new this({type:"any",value:e})}static bool(e){return new this({type:"bool",value:e})}static bytes(e){return new this({type:"bytes",value:e})}static date(e){return new this({type:"date",value:e})}static dateTime(e){return new this({type:"dateTime",value:e})}static enum(e){return new this({type:"enum",typeReference:e})}static float64(e){return new this({type:"float64",value:e})}static int(e){return new this({type:"int",value:e})}static int64(e){return new this({type:"int64",value:e})}static map({keyType:e,valueType:r,entries:i}){return new this({type:"map",keyType:e,valueType:r,entries:i})}static nil(){return new this({type:"nil"})}static nop(){return new this({type:"nop"})}static optional(e){return this.isAlreadyOptional(e)?e:new this({type:"optional",value:e})}static reference(e){return new this({type:"reference",value:e})}static slice({valueType:e,values:r}){return new this({type:"slice",valueType:e,values:r})}static string(e){return new this({type:"string",value:e})}static struct({typeReference:e,fields:r}){return new this({type:"struct",typeReference:e,fields:r})}static structPointer({typeReference:e,fields:r,generics:i}){return new this({type:"optional",value:new this({type:"struct",typeReference:e,fields:r,generics:i})})}static uuid(e){return new this({type:"uuid",value:e})}static isNop(e){return e.internalType.type==="optional"?this.isNop(e.internalType.value):e.internalType.type==="nop"}writeAny({writer:e,value:r}){switch(typeof r){case"boolean":e.write(r.toString());return;case"string":e.write(r.includes('"')?`\`${r}\``:`"${r}"`);return;case"number":e.write(r.toString());return;case"object":if(r==null){e.write("nil");return}if(Array.isArray(r)){this.writeAnyArray({writer:e,value:r});return}this.writeAnyObject({writer:e,value:r});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof r}`)}}writeAnyArray({writer:e,value:r}){if(e.write("[]any"),r.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let i of r)e.writeNode(n.any(i)),e.writeLine(",");e.dedent(),e.write("}")}writeAnyObject({writer:e,value:r}){e.write("map[string]any");let i=Object.entries(r);if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let[o,s]of i)e.write(`"${o}": `),e.writeNode(n.any(s)),e.writeLine(",");e.dedent(),e.write("}")}writeMap({writer:e,map:r}){e.write("map["),e.writeNode(r.keyType),e.write("]"),e.writeNode(r.valueType);let i=An({entries:r.entries});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)o.key.write(e),e.write(": "),o.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeOptional({writer:e,type:r}){if(vn.has(r.internalType.type)){e.writeNode(Tn({writer:e,type:r}));return}if(Ht.has(r.internalType.type)){r.write(e);return}if(r.internalType.type==="enum"){e.writeNode(new V({on:r.internalType.typeReference,method:"Ptr",arguments_:[]}));return}e.write("&"),r.write(e)}static isAlreadyOptional(e){return e.internalType.type==="optional"||Ht.has(e.internalType.type)}writeSlice({writer:e,slice:r}){e.write("[]"),e.writeNode(r.valueType);let i=Fn({values:r.values});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)o.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeStruct({writer:e,struct:r}){e.writeNode(r.typeReference),r.generics!=null&&(e.write("["),r.generics.forEach((o,s)=>{s>0&&e.write(", "),e.writeNode(o)}),e.write("]"));let i=En({fields:r.fields});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)e.write(`${o.name}: `),o.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}};function Tn({writer:n,type:t}){return new S({func:new F({name:In({type:t}),importPath:n.rootImportPath}),arguments_:[t]})}function In({type:n}){switch(n.internalType.type){case"bool":return"Bool";case"date":case"dateTime":return"Time";case"float64":return"Float64";case"int":return"Int";case"int64":return"Int64";case"string":return"String";case"uuid":return"UUID";default:return""}}function Rn({writer:n,type:t}){let e=t.type==="date"?"MustParseDate":"MustParseDateTime";return new S({func:new F({name:e,importPath:n.rootImportPath}),arguments_:[new _(`"${t.value}"`)]})}function Nn({value:n}){return new S({func:new F({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new _(`"${n}"`)]})}function An({entries:n}){return n.filter(t=>!E.isNop(t.key)&&!E.isNop(t.value))}function En({fields:n}){return n.filter(t=>!E.isNop(t.value))}function Fn({values:n}){return n.filter(t=>!E.isNop(t))}var Q=class n extends x{constructor({name:e,docs:r}){super();u(this,"name");u(this,"docs");u(this,"members",[]);u(this,"methods",[]);u(this,"constructor_");this.name=e,this.docs=r}addConstructor(e){this.constructor_=e}addMember(e){this.members.push(e)}addMethod(e){this.methods.push(e)}write(e){this.writeType({writer:e}),this.writeMembers({writer:e}),this.writeConstructor({writer:e}),this.writeMethods({writer:e})}writeType({writer:e}){e.writeNode(new A({docs:this.docs})),e.writeLine(`type ${this.name} string`)}writeMembers({writer:e}){if(this.members.length!==0){e.newLine(),e.writeLine("const ("),e.indent();for(let r of this.members)e.writeNode(new A({docs:r.docs})),e.writeNode(n.getMemberIdentifier({name:this.name,member:r})),e.write(" = "),e.writeNode(E.string(r.value)),e.newLine();e.dedent(),e.write(")")}}writeConstructor({writer:e}){this.constructor_!=null&&(e.newLine(),e.writeNode(this.constructor_))}writeMethods({writer:e}){e.newLine();for(let r of this.methods)e.newLine(),e.writeNode(r),e.newLine()}static getMemberIdentifier({name:e,member:r}){return new O(`${e}${r.name}`)}};p();l();var Z=class extends x{constructor({name:e,type:r,docs:i,tags:o}){super();u(this,"name");u(this,"type");u(this,"docs");u(this,"tags",[]);this.name=e,this.type=r,this.docs=i,this.tags=o!=null?o:[]}addTags(...e){this.tags.push(...e)}write(e){e.writeNode(new A({docs:this.docs})),e.write(`${this.name} `),this.type.write(e),this.writeTags({writer:e})}writeTags({writer:e}){this.tags.length!==0&&(e.write(" `"),this.tags.forEach((r,i)=>{i>0&&e.write(" "),e.write(`${r.name}:"${r.value}"`)}),e.write("`"))}};p();l();var ee=class extends x{constructor({nodes:e}={nodes:[]}){super();u(this,"nodes");this.nodes=e!=null?e:[]}add(...e){this.nodes.push(...e)}write(e){for(let r of this.nodes)r.write(e)}};p();l();p();l();var W=class extends x{constructor({name:e,parameters:r,return_:i,body:o,docs:s,typeReference:f,multiline:h,receiver:m,pointerReceiver:y}){super();u(this,"parameters");u(this,"return_");u(this,"name");u(this,"body");u(this,"docs");u(this,"typeReference");u(this,"multiline");u(this,"receiver");u(this,"pointerReceiver");this.name=e,this.parameters=r,this.return_=i,this.body=o,this.docs=s,this.typeReference=f,this.multiline=h,this.receiver=m,this.pointerReceiver=y}write(e){var r;e.writeNode(new A({docs:this.docs})),e.write("func"),this.typeReference!=null&&this.writeReceiver({writer:e,typeReference:this.typeReference,receiver:this.receiver}),this.name!=null&&e.write(` ${this.name}`),ue({writer:e,arguments_:this.parameters,multiline:this.multiline}),this.return_!=null&&(e.write(" "),this.return_.length>1&&e.write("("),this.return_.forEach((i,o)=>{o>0&&e.write(", "),e.writeNode(i)}),this.return_.length>1&&e.write(")")),e.writeLine("{"),e.indent(),(r=this.body)==null||r.write(e),e.dedent(),e.writeNewLineIfLastLineNot(),e.write("}")}writeReceiver({writer:e,typeReference:r,receiver:i}){e.write(` (${this.getReceiverName({typeReference:r,receiver:i})} `),this.pointerReceiver&&e.write("*"),r.write(e),e.write(")")}getReceiverName({typeReference:e,receiver:r}){return r!=null?r:e.name.charAt(0).toLowerCase()}};var te=class extends x{constructor({name:e,parameters:r,return_:i,body:o,docs:s,multiline:f}){super();u(this,"func");this.func=new W({name:e,parameters:r,return_:i,body:o,docs:s,multiline:f})}get parameters(){return this.func.parameters}get return_(){return this.func.return_}get name(){return this.func.name}get body(){return this.func.body}get docs(){return this.func.docs}write(e){e.writeNode(this.func)}};p();l();var Re=class extends x{constructor({nodes:e}){super();u(this,"nodes");this.nodes=e}write(e){for(let r of this.nodes)e.newLine(),r.write(e),e.newLine()}};p();l();var re=class extends x{constructor({name:e,type:r,docs:i}){super();u(this,"name");u(this,"type");u(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new A({docs:this.docs})),e.write(`${this.name} `),this.type.write(e)}};p();l();var ne=class extends x{constructor({node:e}){super();u(this,"node");this.node=e}write(e){e.write("*"),this.node.write(e)}};p();l();var ie=class extends x{constructor({on:e,selector:r}){super();u(this,"on");u(this,"selector");this.on=e,this.selector=r}write(e){e.writeNode(this.on),e.write("."),e.writeNode(this.selector)}};p();l();var oe=class extends x{constructor({name:e,embeds:r,fields:i,docs:o}){super();u(this,"name");u(this,"embeds",[]);u(this,"fields",[]);u(this,"docs");u(this,"methods",[]);u(this,"constructor_");this.name=e,this.docs=o,this.embeds=r!=null?r:[],this.fields=i!=null?i:[]}addConstructor(e){this.constructor_=e}addField(...e){this.fields.push(...e)}addMethod(...e){this.methods.push(...e)}write(e){this.writeType({writer:e}),this.constructor_!=null&&(e.newLine(),e.newLine(),this.writeConstructor({writer:e,constructor:this.constructor_})),this.writeMethods({writer:e})}writeType({writer:e}){if(e.writeNode(new A({docs:this.docs})),this.name!=null?e.write(`type ${this.name} struct {`):e.write("struct{"),this.embeds.length===0&&this.fields.length===0){e.writeLine("}");return}e.newLine(),e.indent();for(let o of this.embeds)e.writeNode(o),e.newLine();let r=this.fields.filter(o=>this.isExported(o));for(let o of r)e.writeNode(o),e.newLine();let i=this.fields.filter(o=>!this.isExported(o));r.length>0&&i.length>0&&e.newLine();for(let o of i)e.writeNode(o),e.newLine();e.dedent(),e.write("}")}writeConstructor({writer:e,constructor:r}){r.name!=null?e.write(`func ${r.name}(`):e.write(`func New${this.name}(`),r.parameters.forEach((i,o)=>{o>0&&e.write(", "),e.writeNode(i)}),e.write(`) *${this.name} {`),e.newLine(),e.indent(),e.writeNode(r.body),e.writeNewLineIfLastLineNot(),e.dedent(),e.writeLine("}")}writeMethods({writer:e}){if(this.methods.length!==0){e.writeNewLineIfLastLineNot();for(let r of this.methods)e.newLine(),e.writeNode(r),e.newLine()}}isExported(e){let r=e.name.charAt(0);return r===r.toUpperCase()}};p();l();var Ne=class extends x{constructor({on:e,cases:r,default:i}){super();u(this,"on");u(this,"cases");u(this,"default");this.on=e,this.cases=r,this.default=i}write(e){let r=this.cases;this.default!=null&&r.push({on:new O("default"),body:this.default}),e.write("switch "),e.writeNode(this.on),e.writeLine("{"),e.indent();for(let i of r)e.write("case "),e.writeNode(i.on),e.writeLine(":"),e.indent(),e.writeNode(i.body),e.dedent(),e.writeNewLineIfLastLineNot();e.dedent(),e.write("}")}};p();l();var bn=new Set(["any","bytes","map","slice"]),Ae=class n extends x{constructor(e){super();u(this,"internalType");this.internalType=e}write(e,{comment:r}={}){switch(this.internalType.type){case"any":e.write("any");break;case"bool":e.write("bool");break;case"bytes":e.write("[]byte");break;case"date":case"dateTime":e.writeNode(Oe);break;case"error":e.write("error");break;case"float64":e.write("float64");break;case"int":e.write("int");break;case"int64":e.write("int64");break;case"map":{e.write("map["),this.internalType.keyType.write(e),e.write("]"),this.internalType.valueType.write(e);break}case"optional":{e.write("*"),this.internalType.value.write(e);break}case"reference":e.writeNode(this.internalType.value);break;case"slice":e.write("[]"),this.internalType.value.write(e);break;case"string":e.write("string");break;case"uuid":e.writeNode(Ve);break;case"variadic":e.write("..."),this.internalType.value.write(e);break;default:w(this.internalType)}}isOptional(){return this.internalType.type==="optional"}isIterable(){return this.internalType.type==="slice"||this.internalType.type==="variadic"}iterableElement(){if(this.internalType.type==="slice"||this.internalType.type==="variadic")return this.internalType.value}underlying(){return this.internalType.type==="optional"?this.internalType.value:this}static any(){return new this({type:"any"})}static bool(){return new this({type:"bool"})}static bytes(){return new this({type:"bytes"})}static date(){return new this({type:"date"})}static dateTime(){return new this({type:"dateTime"})}static dereference(e){return e.internalType.type==="optional"?e.internalType.value:e}static error(){return new this({type:"error"})}static float64(){return new this({type:"float64"})}static int(){return new this({type:"int"})}static int64(){return new this({type:"int64"})}static map(e,r){return new this({type:"map",keyType:e,valueType:r})}static optional(e){return this.isAlreadyOptional(e)?e:new this({type:"optional",value:e})}static pointer(e){return n.optional(e)}static reference(e){return new this({type:"reference",value:e})}static slice(e){return new this({type:"slice",value:e})}static string(){return new this({type:"string"})}static uuid(){return new this({type:"uuid"})}static variadic(e){return this.isAlreadyVariadic(e)?e:new this({type:"variadic",value:e})}static isAlreadyOptional(e){return e.internalType.type==="optional"||bn.has(e.internalType.type)}static isAlreadyVariadic(e){return e.internalType.type==="variadic"}},Oe=new F({importPath:"time",name:"Time"}),Ve=new F({importPath:"github.com/google/uuid",name:"UUID"}),ot=new F({importPath:"io",name:"Reader"});p();l();var se=class extends x{constructor({name:e,type:r,docs:i}){super();u(this,"name");u(this,"type");u(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new A({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" "),e.writeNode(this.type)}};function Pn(n){return new X(n)}function kn(n){return new _(n)}function Sn(n){return new Q(n)}function Cn(n){return new Z(n)}function Un(n={}){return new ee(n)}function Bn(n){return new te(n)}function Ln(n){return new O(n)}function _n(n){return new S(n)}function Mn(n){return new V(n)}function Dn(n){return new W(n)}function $n(n){return new re(n)}function On(n){return new ne(n)}function Vn(n){return new ie(n)}function Wn(n={}){return new oe(n)}function qn(n){return new Ne(n)}function Gn(n){return new se(n)}function Yn(n){return new F(n)}p();l();Yt();var jn="sdk";function st({config:n,customConfig:t}){let e=zn({config:n}),r=Hn({config:n,customConfig:t});return e!=null?Jn({importPath:r,majorVersion:e}):r}function Hn({config:n,customConfig:t,isModulePath:e=!1}){var i,o,s,f;let r=(s=(o=t==null?void 0:t.importPath)!=null?o:(i=t==null?void 0:t.module)==null?void 0:i.path)!=null?s:n.output.mode.type==="github"?Xn(n.output.mode.repoUrl,"https://"):jn;return e?r:Gt.join(r,(f=t==null?void 0:t.packagePath)!=null?f:"")}function zn({config:n}){let t=Kn({config:n});if(!(t==null||t==="v0"||t==="v1"))return`${t}`}function Kn({config:n}){let t=Qn(n);if(t==null)return;let e=t.split(".");if(e[0]==null)return;let r=e[0];return r.startsWith("v")?r:`v${r}`}function Jn({importPath:n,majorVersion:t}){return Te(n)===t?n:`${n}/${t}`}function Xn(n,t){return n.startsWith(t)?n.slice(t.length):n}function Qn(n){var e;let t=(e=n==null?void 0:n.output)==null?void 0:e.mode;if(t!=null)return t.type==="github"||t.type==="publish"?t.version:void 0}p();l();var We=class{constructor({context:t}){u(this,"context");this.context=t}convert(t){if(t.value===null&&!this.context.isNullable(t.typeReference)&&this.context.errors.add({severity:v.Critical,message:"Expected non-null value, but got null"}),t.value==null)return a.TypeInstantiation.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return a.TypeInstantiation.nop();case"map":return this.convertMap({map:t.typeReference,value:t.value});case"named":{let e=this.context.resolveNamedType({typeId:t.typeReference.value});return e==null?a.TypeInstantiation.nop():this.convertNamed({named:e,value:t.value,as:t.as})}case"nullable":{let e=t.typeReference.value;if(e.type==="named"){let r=this.context.resolveNamedType({typeId:e.value});if((r==null?void 0:r.type)==="alias"&&["list","set","map"].includes(r.typeReference.type)){let i=this.convert({typeReference:r.typeReference,value:t.value,as:t.as}),o=this.context.getTypeName(r.declaration.name),s=this.context.getImportPath(r.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:i,aliasName:o,aliasImportPath:s})}}return a.TypeInstantiation.optional(this.convert({typeReference:e,value:t.value,as:t.as}))}case"optional":{let e=t.typeReference.value;if(e.type==="named"){let r=this.context.resolveNamedType({typeId:e.value});if((r==null?void 0:r.type)==="alias"&&["list","set","map"].includes(r.typeReference.type)){let i=this.convert({typeReference:r.typeReference,value:t.value,as:t.as}),o=this.context.getTypeName(r.declaration.name),s=this.context.getImportPath(r.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:i,aliasName:o,aliasImportPath:s})}}return a.TypeInstantiation.optional(this.convert({typeReference:e,value:t.value,as:t.as}))}case"primitive":return this.convertPrimitive({primitive:t.typeReference.value,value:t.value,as:t.as});case"set":return this.convertList({list:t.typeReference.value,value:t.value});case"unknown":return this.convertUnknown({value:t.value});default:w(t.typeReference)}}convertToPointerIfPossible(t){let e=this.convert(t);switch(t.typeReference.type){case"named":{let r=this.context.resolveNamedType({typeId:t.typeReference.value});return(r==null?void 0:r.type)==="enum"?a.TypeInstantiation.reference(a.invokeMethod({on:e,method:"Ptr",arguments_:[]})):e}default:return e}}convertList({list:t,value:e}){return Array.isArray(e)?a.TypeInstantiation.slice({valueType:this.context.dynamicTypeMapper.convert({typeReference:t}),values: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:v.Critical,message:`Expected array but got: ${typeof e}`}),a.TypeInstantiation.nop())}convertMap({map:t,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:v.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),a.TypeInstantiation.nop()):a.TypeInstantiation.map({keyType:this.context.dynamicTypeMapper.convert({typeReference:t.key}),valueType:this.context.dynamicTypeMapper.convert({typeReference:t.value}),entries: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.convertAlias({aliasType:t,value:e,as:r});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:t,value:e});case"enum":return this.convertEnum({enum_:t,value:e});case"object":return this.convertObject({object_:t,value:e});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e});default:w(t)}}convertAlias({aliasType:t,value:e,as:r}){switch(t.typeReference.type){case"literal":return a.TypeInstantiation.reference(a.invokeFunc({func:a.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),arguments_:[this.convertLiteralValue(t.typeReference.value)]}));default:return this.convert({typeReference:t.typeReference,value:e,as:r})}}reconstructAliasCollectionLiteral({collectionLiteral:t,aliasName:e,aliasImportPath:r}){let i=t.internalType;return i.type==="slice"?a.TypeInstantiation.reference(a.codeblock(o=>{o.write("&"),o.writeNode(a.typeReference({name:e,importPath:r}));let s=i.values;if(s.length===0){o.write("{}");return}o.writeLine("{"),o.indent();for(let f of s)o.writeNode(f),o.writeLine(",");o.dedent(),o.write("}")})):i.type==="map"?a.TypeInstantiation.reference(a.codeblock(o=>{o.write("&"),o.writeNode(a.typeReference({name:e,importPath:r}));let s=i.entries;if(s.length===0){o.write("{}");return}o.writeLine("{"),o.indent();for(let f of s)o.writeNode(f.key),o.write(": "),o.writeNode(f.value),o.writeLine(",");o.dedent(),o.write("}")})):a.TypeInstantiation.reference(a.codeblock(o=>{o.write("&"),o.writeNode(t)}))}convertLiteralValue(t){switch(t.type){case"boolean":return a.TypeInstantiation.bool(t.value);case"string":return a.TypeInstantiation.string(t.value);default:w(t)}}convertDiscriminatedUnion({discriminatedUnion:t,value:e}){let r=this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),i=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e});if(i==null)return a.TypeInstantiation.nop();let o=i.singleDiscriminatedUnionType,s=this.getBaseFields({discriminatedUnionTypeInstance:i,singleDiscriminatedUnionType:o});switch(o.type){case"samePropertiesAsObject":{let f=this.context.resolveNamedType({typeId:o.typeId});return f==null?a.TypeInstantiation.nop():a.TypeInstantiation.structPointer({typeReference:r,fields:[{name:this.context.getTypeName(o.discriminantValue.name),value:this.convertNamed({named:f,value:i.value})},...s]})}case"singleProperty":{let f=this.context.getRecord(i.value);if(f==null)return a.TypeInstantiation.nop();try{return this.context.errors.scope(o.discriminantValue.wireValue),a.TypeInstantiation.structPointer({typeReference:r,fields:[{name:this.context.getTypeName(o.discriminantValue.name),value:this.convert({typeReference:o.typeReference,value:f[o.discriminantValue.wireValue]})},...s]})}finally{this.context.errors.unscope()}}case"noProperties":return a.TypeInstantiation.structPointer({typeReference:r,fields:[{name:this.context.getTypeName(i.discriminantValue.name),value:a.TypeInstantiation.string(o.discriminantValue.wireValue)},...s]});default:w(o)}}getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e}){var i,o;return this.context.associateByWireValue({parameters:(i=e.properties)!=null?i:[],values:(o=this.context.getRecord(t.value))!=null?o:{},ignoreMissingParameters:!0}).map(s=>{this.context.errors.scope(s.name.wireValue);try{return{name:this.context.getTypeName(s.name.name),value:this.convert(s)}}finally{this.context.errors.unscope()}})}convertObject({object_:t,value:e}){var i;let r=this.context.associateByWireValue({parameters:t.properties,values:(i=this.context.getRecord(e))!=null?i:{}});return a.TypeInstantiation.structPointer({typeReference:a.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),fields:r.map(o=>{this.context.errors.scope(o.name.wireValue);try{return{name:this.context.getTypeName(o.name.name),value:this.convert(o)}}finally{this.context.errors.unscope()}})})}convertEnum({enum_:t,value:e}){let r=this.getEnumValueName({enum_:t,value:e});return r==null?a.TypeInstantiation.nop():a.TypeInstantiation.enum(a.typeReference({name:r,importPath:this.context.getImportPath(t.declaration.fernFilepath)}))}getEnumValueName({enum_:t,value:e}){if(typeof e!="string"){this.context.errors.add({severity:v.Critical,message:`Expected enum value string, got: ${typeof e}`});return}let r=t.values.find(i=>i.wireValue===e);if(r==null){this.context.errors.add({severity:v.Critical,message:`An enum value named "${e}" does not exist in this context`});return}return`${this.context.getTypeName(t.declaration.name)}${this.context.getTypeName(r.name)}`}convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e}){let r=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e});if(r==null)return a.TypeInstantiation.nop();let i=this.getUndiscriminatedUnionFieldName({typeReference:r.valueTypeReference});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.structPointer({typeReference:this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),fields:[{name:i,value:r.typeInstantiation}]})}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e}){for(let r of t.types)try{let i=this.convert({typeReference:r,value:e});return{valueTypeReference:r,typeInstantiation:i}}catch(i){continue}this.context.errors.add({severity:v.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof e}" value`})}getUndiscriminatedUnionFieldName({typeReference:t}){switch(t.type){case"list":return this.getUndiscriminatedUnionFieldNameForList({list:t});case"literal":return this.getUndiscriminatedUnionFieldNameForLiteral({literal:t.value});case"map":return this.getUndiscriminatedUnionFieldNameForMap({map:t});case"named":{let e=this.context.resolveNamedType({typeId:t.value});return e==null?void 0:this.context.getTypeName(e.declaration.name)}case"optional":return this.getUndiscriminatedUnionFieldNameForOptional({typeReference:t});case"nullable":return this.getUndiscriminatedUnionFieldNameForOptional({typeReference:t});case"primitive":return this.getUndiscriminatedUnionFieldNameForPrimitive({primitive:t.value});case"set":return this.getUndiscriminatedUnionFieldNameForSet({set:t});case"unknown":return"Unknown";default:w(t)}}getUndiscriminatedUnionFieldNameForList({list:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t});if(e!=null)return`${e}List`}getUndiscriminatedUnionFieldNameForMap({map:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t.key});if(e==null)return;let r=this.getUndiscriminatedUnionFieldName({typeReference:t.value});if(r!=null)return`${e}${r}Map`}getUndiscriminatedUnionFieldNameForOptional({typeReference:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t});if(e!=null)return`${e}Optional`}getUndiscriminatedUnionFieldNameForSet({set:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t});if(e!=null)return`${e}Set`}getUndiscriminatedUnionFieldNameForLiteral({literal:t}){switch(t.type){case"boolean":return t.value?"TrueLiteral":"FalseLiteral";case"string":return`${t.value}StringLiteral`;default:w(t)}}getUndiscriminatedUnionFieldNameForPrimitive({primitive:t}){switch(t){case"INTEGER":case"UINT":return"Integer";case"LONG":case"UINT_64":return"Long";case"FLOAT":case"DOUBLE":return"Double";case"BOOLEAN":return"Boolean";case"BIG_INTEGER":case"STRING":return"String";case"UUID":return"Uuid";case"DATE":return"Date";case"DATE_TIME":return"DateTime";case"BASE_64":return"Base64";default:w(t)}}convertUnknown({value:t}){return a.TypeInstantiation.any(t)}convertPrimitive({primitive:t,value:e,as:r}){switch(t){case"INTEGER":case"UINT":{let i=this.getValueAsNumber({value:e,as:r});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.int(i)}case"LONG":case"UINT_64":{let i=this.getValueAsNumber({value:e,as:r});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.int64(i)}case"FLOAT":case"DOUBLE":{let i=this.getValueAsNumber({value:e,as:r});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.float64(i)}case"BOOLEAN":{let i=this.getValueAsBoolean({value:e,as:r});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.bool(i)}case"STRING":{let i=this.context.getValueAsString({value:e});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.string(i)}case"DATE":{let i=this.context.getValueAsString({value:e});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.date(i)}case"DATE_TIME":{let i=this.context.getValueAsString({value:e});if(i==null)return a.TypeInstantiation.nop();let o=this.normalizeDateTimeString(i);return a.TypeInstantiation.dateTime(o)}case"UUID":{let i=this.context.getValueAsString({value:e});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.uuid(i)}case"BASE_64":{let i=this.context.getValueAsString({value:e});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.bytes(i)}case"BIG_INTEGER":{let i=this.context.getValueAsString({value:e});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.string(i)}default:w(t)}}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==="false"?!1:t:t;return this.context.getValueAsBoolean({value:r})}normalizeDateTimeString(t){return/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t}T00:00:00Z`:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(t)?`${t}Z`:t}};p();l();var qe=class{constructor({context:t}){u(this,"context");this.context=t}convert(t){switch(t.typeReference.type){case"list":return a.Type.slice(this.convert({typeReference:t.typeReference.value}));case"literal":return this.convertLiteral({literal:t.typeReference.value});case"map":return a.Type.map(this.convert({typeReference:t.typeReference.key}),this.convert({typeReference:t.typeReference.value}));case"named":{let e=this.context.resolveNamedType({typeId:t.typeReference.value});return e==null?this.convertUnknown():this.convertNamed({named:e})}case"optional":return a.Type.optional(this.convert({typeReference:t.typeReference.value}));case"nullable":return a.Type.optional(this.convert({typeReference:t.typeReference.value}));case"primitive":return this.convertPrimitive({primitive:t.typeReference.value});case"set":return a.Type.slice(this.convert({typeReference:t.typeReference}));case"unknown":return this.convertUnknown();default:w(t.typeReference)}}convertLiteral({literal:t}){switch(t.type){case"boolean":return a.Type.bool();case"string":return a.Type.string()}}convertNamed({named:t}){let e=a.Type.reference(a.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}));switch(t.type){case"alias":case"enum":return e;case"discriminatedUnion":case"object":case"undiscriminatedUnion":return a.Type.pointer(e);default:w(t)}}convertUnknown(){return a.Type.any()}convertPrimitive({primitive:t}){switch(t){case"INTEGER":return a.Type.int();case"UINT":return a.Type.int();case"LONG":return a.Type.int64();case"UINT_64":return a.Type.int64();case"FLOAT":return a.Type.float64();case"DOUBLE":return a.Type.float64();case"BOOLEAN":return a.Type.bool();case"STRING":return a.Type.string();case"DATE":return a.Type.date();case"DATE_TIME":return a.Type.dateTime();case"UUID":return a.Type.uuid();case"BASE_64":return a.Type.bytes();case"BIG_INTEGER":return a.Type.string();default:w(t)}}};p();l();var Ge=class{constructor({context:t}){u(this,"context");this.context=t}getFilePropertyInfo({body:t,value:e}){var o;let r={fileFields:[],bodyPropertyFields:[]},i=(o=this.context.getRecord(e))!=null?o:{};for(let s of t.properties)switch(s.type){case"file":r.fileFields.push({name:this.context.getTypeName(s.name),value:this.getSingleFileProperty({property:s,record:i})});break;case"fileArray":r.fileFields.push({name:this.context.getTypeName(s.name),value:this.getArrayFileProperty({property:s,record:i})});break;case"bodyProperty":r.bodyPropertyFields.push({name:this.context.getTypeName(s.name.name),value:this.getBodyProperty({property:s,record:i})});break;default:w(s)}return r}getSingleFileProperty({property:t,record:e}){let r=this.context.getSingleFileValue({property:t,record:e})||"";return a.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(r))}getArrayFileProperty({property:t,record:e}){let r=this.context.getFileArrayValues({property:t,record:e});return r==null?a.TypeInstantiation.nop():a.TypeInstantiation.slice({valueType:a.Type.reference(this.context.getIoReaderTypeReference()),values:r.map(i=>a.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(i)))})}getBodyProperty({property:t,record:e}){let r=e[t.name.wireValue];return r==null?a.TypeInstantiation.nop():this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:r})}};var Ye=class n extends ve{constructor({ir:e,config:r}){super({ir:e,config:r});u(this,"ir");u(this,"customConfig");u(this,"dynamicTypeMapper");u(this,"dynamicTypeInstantiationMapper");u(this,"filePropertyMapper");u(this,"rootImportPath");this.ir=e,this.customConfig=r.customConfig!=null?r.customConfig:void 0,this.dynamicTypeMapper=new qe({context:this}),this.dynamicTypeInstantiationMapper=new We({context:this}),this.filePropertyMapper=new Ge({context:this}),this.rootImportPath=st({config:r,customConfig:this.customConfig})}clone(){return new n({ir:this.ir,config:this.config})}isOptional(e){switch(e.type){case"optional":case"map":return!0;case"nullable":case"list":case"set":return this.isOptional(e.value);case"named":case"literal":case"primitive":case"unknown":return!1;default:w(e)}}getMethodName(e){return e.pascalCase.unsafeName}getTestMethodName(e){return e.declaration.fernFilepath.allParts.map(r=>r.pascalCase.unsafeName).join("")+e.declaration.name.pascalCase.unsafeName}getTypeName(e){return e.pascalCase.unsafeName}getImportPath(e){let r=e.packagePath.map(i=>i.pascalCase.unsafeName.toLowerCase());return[this.rootImportPath,...r].join("/")}getImportPathForRequest(e){var r;return(r=this.customConfig)!=null&&r.exportAllRequestsAtRoot?this.rootImportPath:this.getImportPath(e)}getContextTypeReference(){return a.typeReference({name:"Context",importPath:"context"})}getContextTodoFunctionInvocation(){return a.invokeFunc({func:a.typeReference({name:"TODO",importPath:"context"}),arguments_:[]})}getIoReaderTypeReference(){return a.typeReference({name:"Reader",importPath:"io"})}getTestingTypeReference(){return a.typeReference({name:"T",importPath:"testing"})}getNewStringsReaderFunctionInvocation(e){return a.invokeFunc({func:a.typeReference({name:"NewReader",importPath:"strings"}),arguments_:[a.TypeInstantiation.string(e)]})}getClientConstructorName(){var e,r;return((e=this.customConfig)==null?void 0:e.clientConstructorName)!=null?this.customConfig.clientConstructorName:((r=this.customConfig)==null?void 0:r.exportedClientName)!=null?`New${this.customConfig.exportedClientName}`:`New${this.getClientName()}`}getClientName(){var e;return((e=this.customConfig)==null?void 0:e.clientName)!=null?this.customConfig.clientName:"Client"}getClientImportPath(){return`${this.rootImportPath}/client`}getOptionImportPath(){return`${this.rootImportPath}/option`}getGoTypeReferenceFromDeclaration({declaration:e}){return a.typeReference({name:e.name.pascalCase.unsafeName,importPath:this.getImportPath(e.fernFilepath)})}getEnvironmentTypeReferenceFromID(e){let r=this.resolveEnvironmentName(e);if(r!=null)return this.getEnvironmentTypeReference(r)}getEnvironmentTypeReference(e){return a.typeReference({name:`Environments.${this.getTypeName(e)}`,importPath:this.rootImportPath})}static chainMethods(e,...r){if(r.length===0)throw new Error("Must have methods to chain");let i=e;for(let o of r)i=a.invokeMethod({on:i,method:o.method,arguments_:o.arguments_,multiline:o.multiline});return i}};p();l();var zt="example",at="fern",Zn="do",Ee="client",pe=a.TypeInstantiation,ei="WireMockBaseURL",ti="WireMockClient",je=class{constructor({context:t,formatter:e}){u(this,"context");u(this,"formatter");this.context=t,this.formatter=e}async generateSnippet({endpoint:t,request:e,options:r}){var s,f,h;return((f=(s=r==null?void 0:r.config)==null?void 0:s.outputWiremockTests)!=null?f:!1)?this.generateWiremockTest({endpoint:t,snippet:e}):await this.buildCodeBlock({endpoint:t,snippet:e}).toStringAsync({packageName:zt,importPath:at,rootImportPath:this.context.rootImportPath,customConfig:(h=this.context.customConfig)!=null?h:{},formatter:this.formatter})}generateSnippetSync({endpoint:t,request:e,options:r}){var s,f,h;return((f=(s=r==null?void 0:r.config)==null?void 0:s.outputWiremockTests)!=null?f:!1)?this.generateWiremockTest({endpoint:t,snippet:e}):this.buildCodeBlock({endpoint:t,snippet:e}).toString({packageName:zt,importPath:at,rootImportPath:this.context.rootImportPath,customConfig:(h=this.context.customConfig)!=null?h:{},formatter:this.formatter})}generateWiremockTest({endpoint:t,snippet:e}){var i;return this.buildWiremockTestCodeBlock({endpoint:t,snippet:e}).toString({packageName:"wiremock",importPath:at,rootImportPath:this.context.rootImportPath,customConfig:(i=this.context.customConfig)!=null?i:{},formatter:this.formatter})}buildCodeBlock({endpoint:t,snippet:e}){return a.codeblock(r=>{r.writeNode(a.func({name:Zn,parameters:[],return_:[],body:a.codeblock(i=>{i.writeNode(this.constructClient({endpoint:t,snippet:e})),i.writeLine(),i.writeNode(this.callMethod({endpoint:t,snippet:e}))})})),r.writeNewLineIfLastLineNot()})}buildWiremockTestCodeBlock({endpoint:t,snippet:e}){return a.codeblock(r=>{r.writeNode(a.func({name:"Test"+this.context.getTestMethodName(t)+"WithWireMock",parameters:[a.parameter({name:"t",type:a.Type.pointer(a.Type.reference(this.context.getTestingTypeReference()))})],return_:[],body:a.codeblock(i=>{for(let o of this.buildWiremockTestSetup({endpoint:t}))i.writeNode(o),i.writeLine();i.writeLine(),i.writeNode(this.constructWiremockTestClient({endpoint:t,snippet:e})),i.writeLine(),i.writeNode(this.callClientMethodAndAssert({endpoint:t,snippet:e}))})})),r.writeNewLineIfLastLineNot()})}constructClient({endpoint:t,snippet:e}){return a.codeblock(r=>{r.write(`${Ee} := `),r.writeNode(this.getRootClientFuncInvocation(this.getConstructorArgs({endpoint:t,snippet:e})))})}constructWiremockTestClient({endpoint:t,snippet:e}){return a.codeblock(r=>{r.write(`${Ee} := `),r.writeNode(this.getRootClientFuncInvocation(this.getWiremockTestConstructorArgs()))})}writeMethodInvocation({writer:t,endpoint:e,snippet:r}){let{otherArgs:i,requestArg:o}=this.getMethodArgs({endpoint:e,snippet:r});if(o!=null)if(o instanceof a.TypeInstantiation&&a.TypeInstantiation.isNop(o))t.writeNode(a.invokeMethod({on:a.codeblock(Ee),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...i,a.codeblock("nil")]}));else{t.write("request := "),t.writeNode(o),t.writeLine();let s=a.codeblock("request");t.writeNode(a.invokeMethod({on:a.codeblock(Ee),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...i,s]}))}else t.writeNode(a.invokeMethod({on:a.codeblock(Ee),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...i]}))}callMethod({endpoint:t,snippet:e}){return a.codeblock(r=>{this.writeMethodInvocation({writer:r,endpoint:t,snippet:e})})}getConstructorArgs({endpoint:t,snippet:e}){let r=[],i=this.getConstructorBaseUrlArg({baseUrl:e.baseURL,environment:e.environment});return i!=null&&r.push(i),t.auth!=null&&(e.auth!=null?r.push(this.getConstructorAuthArg({auth:t.auth,values:e.auth})):this.context.errors.add({severity:v.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(L.Headers),this.context.ir.headers!=null&&e.headers!=null&&r.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:e.headers})),this.context.errors.unscope(),r}getWiremockTestConstructorArgs(){return[a.codeblock(t=>{t.writeNode(a.invokeFunc({func:a.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[a.codeblock(ei)]}))})]}getConstructorAuthArg({auth:t,values:e}){if(e.type!==t.type)return this.addError(this.context.newAuthMismatchError({auth:t,values:e}).message),pe.nop();switch(t.type){case"basic":return e.type==="basic"?this.getConstructorBasicAuthArg({auth:t,values:e}):pe.nop();case"bearer":return e.type==="bearer"?this.getConstructorBearerAuthArg({auth:t,values:e}):pe.nop();case"header":return e.type==="header"?this.getConstructorHeaderAuthArg({auth:t,values:e}):pe.nop();case"oauth":return this.addWarning("The Go SDK doesn't support OAuth client credentials yet"),pe.nop();case"inferred":return this.addWarning("The Go SDK Generator does not support Inferred auth scheme yet"),pe.nop();default:w(t)}}addError(t){this.context.errors.add({severity:v.Critical,message:t})}addWarning(t){this.context.errors.add({severity:v.Warning,message:t})}getConstructorBasicAuthArg({auth:t,values:e}){return a.codeblock(r=>{r.writeNode(a.invokeFunc({func:a.typeReference({name:"WithBasicAuth",importPath:this.context.getOptionImportPath()}),arguments_:[a.TypeInstantiation.string(e.username),a.TypeInstantiation.string(e.password)]}))})}getConstructorBaseUrlArg({baseUrl:t,environment:e}){let r=this.getBaseUrlArg({baseUrl:t,environment:e});if(r!=null)return a.codeblock(i=>{i.writeNode(a.invokeFunc({func:a.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[r]}))})}getBaseUrlArg({baseUrl:t,environment:e}){if(t!=null&&e!=null){this.context.errors.add({severity:v.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(t!=null)return a.TypeInstantiation.string(t);if(e!=null){if(this.context.isSingleEnvironmentID(e)){let r=this.context.getEnvironmentTypeReferenceFromID(e);if(r==null){this.context.errors.add({severity:v.Warning,message:`Environment ${JSON.stringify(e)} was not found`});return}return a.TypeInstantiation.reference(r)}this.context.isMultiEnvironmentValues(e)&&this.context.errors.add({severity:v.Warning,message:"The Go SDK doesn't support a multi-environment client option yet; use the baseUrl option instead"})}}getConstructorBearerAuthArg({auth:t,values:e}){return a.codeblock(r=>{r.writeNode(a.invokeFunc({func:a.typeReference({name:`With${t.token.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[a.TypeInstantiation.string(e.token)]}))})}getConstructorHeaderAuthArg({auth:t,values:e}){return a.codeblock(r=>{r.writeNode(a.invokeFunc({func:a.typeReference({name:`With${t.header.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.header.typeReference,value:e.value})]}))})}getConstructorHeaderArgs({headers:t,values:e}){let r=[];for(let i of t){let o=this.getConstructorHeaderArg({header:i,value:e.value});o!=null&&r.push(o)}return r}getConstructorHeaderArg({header:t,value:e}){let r=this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:e});if(!a.TypeInstantiation.isNop(r))return a.codeblock(i=>{i.writeNode(a.invokeFunc({func:a.typeReference({name:`With${t.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[r]}))})}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:w(t.request)}}getMethodArgsForBodyRequest({request:t,snippet:e}){var s,f;let r=[];this.context.errors.scope(L.PathParameters);let i=[...(s=this.context.ir.pathParameters)!=null?s:[],...(f=t.pathParameters)!=null?f:[]];i.length>0&&r.push(...this.getPathParameters({namedParameters:i,snippet:e}).map(h=>h.value)),this.context.errors.unscope(),this.context.errors.scope(L.RequestBody);let o=t.body!=null?this.getBodyRequestArg({body:t.body,value:e.requestBody}):void 0;return this.context.errors.unscope(),{otherArgs:r,requestArg:o}}getBodyRequestArg({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e});default:w(t)}}getBytesBodyRequestArg({value:t}){return typeof t!="string"?(this.context.errors.add({severity:v.Critical,message:`Expected bytes value to be a string, got ${typeof t}`}),a.TypeInstantiation.nop()):a.TypeInstantiation.bytes(t)}getMethodArgsForInlinedRequest({request:t,snippet:e}){var y,g,T,I,R,Y;let r=[],{inlinePathParameters:i,inlineFileProperties:o}={inlinePathParameters:(g=(y=this.context.customConfig)==null?void 0:y.inlinePathParameters)!=null?g:!0,inlineFileProperties:(I=(T=this.context.customConfig)==null?void 0:T.inlineFileProperties)!=null?I:!0};this.context.errors.scope(L.PathParameters);let s=[],f=[...(R=this.context.ir.pathParameters)!=null?R:[],...(Y=t.pathParameters)!=null?Y:[]];f.length>0&&s.push(...this.getPathParameters({namedParameters:f,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(L.RequestBody);let h=this.getFilePropertyInfo({request:t,snippet:e});this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:i})||r.push(...s.map(le=>le.value)),o||r.push(...h.fileFields.map(le=>le.value));let m=this.context.needsRequestParameter({request:t,inlinePathParameters:i,inlineFileProperties:o})?this.getInlinedRequestArg({request:t,snippet:e,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:i})?s:[],filePropertyInfo:h}):void 0;return{otherArgs:r,requestArg:m}}getFilePropertyInfo({request:t,snippet:e}){return t.body==null||!this.context.isFileUploadRequestBody(t.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:t.body,value:e.requestBody})}getInlinedRequestArg({request:t,snippet:e,pathParameterFields:r,filePropertyInfo:i}){var y,g,T,I;this.context.errors.scope(L.QueryParameters);let s=this.context.associateQueryParametersByWireValue({parameters:(y=t.queryParameters)!=null?y:[],values:(g=e.queryParameters)!=null?g:{}}).map(R=>({name:R.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(R)}));this.context.errors.unscope(),this.context.errors.scope(L.Headers);let h=this.context.associateByWireValue({parameters:(T=t.headers)!=null?T:[],values:(I=e.headers)!=null?I:{}}).map(R=>({name:R.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(R)}));this.context.errors.unscope(),this.context.errors.scope(L.RequestBody);let m=t.body!=null?this.getInlinedRequestBodyStructFields({body:t.body,value:e.requestBody,filePropertyInfo:i}):[];return this.context.errors.unscope(),a.TypeInstantiation.structPointer({typeReference:a.typeReference({name:this.context.getMethodName(t.declaration.name),importPath:this.context.getImportPathForRequest(t.declaration.fernFilepath)}),fields:[...r,...s,...h,...m]})}getInlinedRequestBodyStructFields({body:t,value:e,filePropertyInfo:r}){switch(t.type){case"properties":return this.getInlinedRequestBodyPropertyStructFields({parameters:t.value,value:e});case"referenced":return[this.getReferencedRequestBodyPropertyStructField({body:t,value:e})];case"fileUpload":return this.getFileUploadRequestBodyStructFields({filePropertyInfo:r});default:w(t)}}getFileUploadRequestBodyStructFields({filePropertyInfo:t}){var e;return(e=this.context.customConfig)!=null&&e.inlineFileProperties?[...t.fileFields,...t.bodyPropertyFields]:t.bodyPropertyFields}getReferencedRequestBodyPropertyStructField({body:t,value:e}){return{name:this.context.getTypeName(t.bodyKey),value:this.getReferencedRequestBodyPropertyTypeInstantiation({body:t.bodyType,value:e})}}getReferencedRequestBodyPropertyTypeInstantiation({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e});default:w(t)}}getInlinedRequestBodyPropertyStructFields({parameters:t,value:e}){var o;let r=[],i=this.context.associateByWireValue({parameters:t,values:(o=this.context.getRecord(e))!=null?o:{}});for(let s of i)r.push({name:this.context.getTypeName(s.name.name),value:this.context.dynamicTypeInstantiationMapper.convert(s)});return r}getPathParameters({namedParameters:t,snippet:e}){var o;let r=[],i=this.context.associateByWireValue({parameters:t,values:(o=e.pathParameters)!=null?o:{}});for(let s of i)r.push({name:this.context.getTypeName(s.name.name),value:this.context.dynamicTypeInstantiationMapper.convertToPointerIfPossible(s)});return r}getMethod({endpoint:t}){return t.declaration.fernFilepath.allParts.length>0?`${t.declaration.fernFilepath.allParts.map(e=>this.context.getMethodName(e)).join(".")}.${this.context.getMethodName(t.declaration.name)}`:this.context.getMethodName(t.declaration.name)}getRootClientFuncInvocation(t){return a.invokeFunc({func:a.typeReference({name:this.context.getClientConstructorName(),importPath:this.context.getClientImportPath()}),arguments_:t})}buildWiremockTestSetup({endpoint:t,errorCase:e}){let r="stub";return[]}callClientMethodAndAssert({endpoint:t,snippet:e}){return a.codeblock(r=>{this.writeMethodInvocation({writer:r,endpoint:t,snippet:e}),r.writeLine(),r.writeLine(),r.write("ok, countErr := "),r.writeNode(a.invokeMethod({on:a.codeblock(ti),method:"Verify",arguments_:[a.invokeMethod({on:a.codeblock("stub"),method:"Request",arguments_:[],multiline:!1}),a.codeblock("1")],multiline:!1})),r.writeLine(),r.writeNode(a.invokeFunc({func:a.typeReference({name:"NoError",importPath:"github.com/stretchr/testify/require"}),arguments_:[a.codeblock("t"),a.codeblock("countErr"),a.TypeInstantiation.string("Failed to verify WireMock request was matched")],multiline:!1})),r.writeLine(),r.writeNode(a.invokeFunc({func:a.typeReference({name:"True",importPath:"github.com/stretchr/testify/require"}),arguments_:[a.codeblock("t"),a.codeblock("ok"),a.TypeInstantiation.string("WireMock request was not matched")],multiline:!1})),r.writeLine()})}};var He=class extends ge{constructor({ir:e,config:r,formatter:i}){super(new Ye({ir:e,config:r}));u(this,"formatter");this.formatter=i}async generate(e,r){return super.generate(e,r)}generateSync(e,r){return super.generateSync(e,r)}createSnippetGenerator(e){return new je({context:e,formatter:this.formatter})}};0&&(module.exports={DynamicSnippetsGenerator});
24
+ )`:""}};var a={};ht(a,{Alias:()=>X,AstNode:()=>w,CodeBlock:()=>_,Enum:()=>Q,Field:()=>Z,File:()=>ee,Func:()=>te,FuncInvocation:()=>S,IoReaderTypeReference:()=>ot,Method:()=>W,MethodInvocation:()=>V,MultiNode:()=>Re,Parameter:()=>re,Pointer:()=>ne,Selector:()=>ie,Struct:()=>oe,TimeTypeReference:()=>Oe,Type:()=>Ae,TypeDeclaration:()=>se,TypeInstantiation:()=>E,TypeReference:()=>F,UuidTypeReference:()=>Ve,Writer:()=>J,alias:()=>Pn,codeblock:()=>kn,enum_:()=>Sn,field:()=>Cn,file:()=>Un,func:()=>Bn,identifier:()=>Ln,invokeFunc:()=>_n,invokeMethod:()=>Mn,method:()=>Dn,parameter:()=>$n,pointer:()=>On,selector:()=>Vn,struct:()=>Wn,switch_:()=>qn,typeDeclaration:()=>Gn,typeReference:()=>Yn});l();f();l();f();l();f();l();f();l();f();var w=class extends K{async toStringAsync({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o}){let s=new Ie({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o});return this.write(s),s.toStringAsync()}toString({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o}){let s=new Ie({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o});return this.write(s),s.toString()}};var A=class extends w{constructor({docs:e}={}){super();u(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
25
+ `).forEach(r=>{e.writeLine(`// ${r}`)})}};var X=class extends w{constructor({name:e,type:r,docs:i}){super();u(this,"name");u(this,"type");u(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new A({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" = "),e.writeNode(this.type)}};l();f();var _=class extends w{constructor(e){super();u(this,"arg");this.arg=e}write(e){return new k(this.arg).write(e)}};l();f();l();f();var O=class extends w{constructor(e){super();u(this,"name");this.name=e}write(e){e.write(this.name)}};l();f();l();f();l();f();function ue({writer:n,arguments_:t,multiline:e=!0}){let r=t.map(i=>i instanceof E&&E.isNop(i)?E.nil():i);if(r.length===0){n.write("()");return}if(e){wn({writer:n,arguments_:r});return}xn({writer:n,arguments_:r})}function wn({writer:n,arguments_:t}){n.writeLine("("),n.indent();for(let e of t)e.write(n),n.writeLine(",");n.dedent(),n.write(")")}function xn({writer:n,arguments_:t}){n.write("("),t.forEach((e,r)=>{r>0&&n.write(", "),e.write(n)}),n.write(")")}var S=class extends w{constructor({func:e,arguments_:r,multiline:i=!0}){super();u(this,"func");u(this,"arguments_");u(this,"multiline");this.func=e,this.arguments_=r,this.multiline=i}write(e){e.writeNode(this.func),ue({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};l();f();l();f();function jt({writer:n,generics:t}){t.length!==0&&(n.write("["),t.forEach((e,r)=>{r>0&&n.write(", "),e!=null&&n.writeNode(e)}),n.write("]"))}var F=class extends w{constructor({name:e,importPath:r,generics:i}){super();u(this,"name");u(this,"importPath");u(this,"generics");this.name=e,this.importPath=r,this.generics=i}write(e){if(this.importPath==null||e.importPath===this.importPath){e.write(this.name);return}let r=e.addImport(this.importPath);e.write(`${r}.${this.name}`),this.generics!=null&&jt({writer:e,generics:this.generics})}};l();f();var V=class extends w{constructor({method:e,arguments_:r,on:i,multiline:o}){super();u(this,"on");u(this,"method");u(this,"arguments_");u(this,"multiline");this.on=i,this.method=e,this.arguments_=r,this.multiline=o}write(e){this.on.write(e),e.write("."),e.write(this.method),ue({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};var vn=new Set(["bool","date","dateTime","float64","int","int64","string","uuid"]),Ht=new Set(["any","bytes","map","slice"]),E=class n extends w{constructor(e){super();u(this,"internalType");this.internalType=e}write(e){switch(this.internalType.type){case"any":this.writeAny({writer:e,value:this.internalType.value});break;case"bool":e.write(this.internalType.value.toString());break;case"bytes":e.write(`[]byte("${this.internalType.value}")`);break;case"date":case"dateTime":e.writeNode(Rn({writer:e,type:this.internalType}));break;case"enum":e.writeNode(this.internalType.typeReference);break;case"float64":e.write(this.internalType.value.toString());break;case"int":case"int64":e.write(this.internalType.value.toString());break;case"map":this.writeMap({writer:e,map:this.internalType});break;case"nil":e.write("nil");break;case"nop":break;case"optional":this.writeOptional({writer:e,type:this.internalType.value});break;case"reference":e.writeNode(this.internalType.value);break;case"slice":this.writeSlice({writer:e,slice:this.internalType});break;case"string":e.write(this.internalType.value.includes('"')||this.internalType.value.includes(`
26
+ `)?`\`${this.internalType.value}\``:`"${this.internalType.value}"`);break;case"struct":this.writeStruct({writer:e,struct:this.internalType});break;case"uuid":e.writeNode(Nn({value:this.internalType.value}));break;default:x(this.internalType)}}static any(e){return new this({type:"any",value:e})}static bool(e){return new this({type:"bool",value:e})}static bytes(e){return new this({type:"bytes",value:e})}static date(e){return new this({type:"date",value:e})}static dateTime(e){return new this({type:"dateTime",value:e})}static enum(e){return new this({type:"enum",typeReference:e})}static float64(e){return new this({type:"float64",value:e})}static int(e){return new this({type:"int",value:e})}static int64(e){return new this({type:"int64",value:e})}static map({keyType:e,valueType:r,entries:i}){return new this({type:"map",keyType:e,valueType:r,entries:i})}static nil(){return new this({type:"nil"})}static nop(){return new this({type:"nop"})}static optional(e){return this.isAlreadyOptional(e)?e:new this({type:"optional",value:e})}static reference(e){return new this({type:"reference",value:e})}static slice({valueType:e,values:r}){return new this({type:"slice",valueType:e,values:r})}static string(e){return new this({type:"string",value:e})}static struct({typeReference:e,fields:r}){return new this({type:"struct",typeReference:e,fields:r})}static structPointer({typeReference:e,fields:r,generics:i}){return new this({type:"optional",value:new this({type:"struct",typeReference:e,fields:r,generics:i})})}static uuid(e){return new this({type:"uuid",value:e})}static isNop(e){return e.internalType.type==="optional"?this.isNop(e.internalType.value):e.internalType.type==="nop"}writeAny({writer:e,value:r}){switch(typeof r){case"boolean":e.write(r.toString());return;case"string":e.write(r.includes('"')?`\`${r}\``:`"${r}"`);return;case"number":e.write(r.toString());return;case"object":if(r==null){e.write("nil");return}if(Array.isArray(r)){this.writeAnyArray({writer:e,value:r});return}this.writeAnyObject({writer:e,value:r});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof r}`)}}writeAnyArray({writer:e,value:r}){if(e.write("[]any"),r.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let i of r)e.writeNode(n.any(i)),e.writeLine(",");e.dedent(),e.write("}")}writeAnyObject({writer:e,value:r}){e.write("map[string]any");let i=Object.entries(r);if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let[o,s]of i)e.write(`"${o}": `),e.writeNode(n.any(s)),e.writeLine(",");e.dedent(),e.write("}")}writeMap({writer:e,map:r}){e.write("map["),e.writeNode(r.keyType),e.write("]"),e.writeNode(r.valueType);let i=An({entries:r.entries});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)o.key.write(e),e.write(": "),o.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeOptional({writer:e,type:r}){if(vn.has(r.internalType.type)){e.writeNode(Tn({writer:e,type:r}));return}if(Ht.has(r.internalType.type)){r.write(e);return}if(r.internalType.type==="enum"){e.writeNode(new V({on:r.internalType.typeReference,method:"Ptr",arguments_:[]}));return}e.write("&"),r.write(e)}static isAlreadyOptional(e){return e.internalType.type==="optional"||Ht.has(e.internalType.type)}writeSlice({writer:e,slice:r}){e.write("[]"),e.writeNode(r.valueType);let i=Fn({values:r.values});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)o.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeStruct({writer:e,struct:r}){e.writeNode(r.typeReference),r.generics!=null&&(e.write("["),r.generics.forEach((o,s)=>{s>0&&e.write(", "),e.writeNode(o)}),e.write("]"));let i=En({fields:r.fields});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)e.write(`${o.name}: `),o.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}};function Tn({writer:n,type:t}){return new S({func:new F({name:In({type:t}),importPath:n.rootImportPath}),arguments_:[t]})}function In({type:n}){switch(n.internalType.type){case"bool":return"Bool";case"date":case"dateTime":return"Time";case"float64":return"Float64";case"int":return"Int";case"int64":return"Int64";case"string":return"String";case"uuid":return"UUID";default:return""}}function Rn({writer:n,type:t}){let e=t.type==="date"?"MustParseDate":"MustParseDateTime";return new S({func:new F({name:e,importPath:n.rootImportPath}),arguments_:[new _(`"${t.value}"`)]})}function Nn({value:n}){return new S({func:new F({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new _(`"${n}"`)]})}function An({entries:n}){return n.filter(t=>!E.isNop(t.key)&&!E.isNop(t.value))}function En({fields:n}){return n.filter(t=>!E.isNop(t.value))}function Fn({values:n}){return n.filter(t=>!E.isNop(t))}var Q=class n extends w{constructor({name:e,docs:r}){super();u(this,"name");u(this,"docs");u(this,"members",[]);u(this,"methods",[]);u(this,"constructor_");this.name=e,this.docs=r}addConstructor(e){this.constructor_=e}addMember(e){this.members.push(e)}addMethod(e){this.methods.push(e)}write(e){this.writeType({writer:e}),this.writeMembers({writer:e}),this.writeConstructor({writer:e}),this.writeMethods({writer:e})}writeType({writer:e}){e.writeNode(new A({docs:this.docs})),e.writeLine(`type ${this.name} string`)}writeMembers({writer:e}){if(this.members.length!==0){e.newLine(),e.writeLine("const ("),e.indent();for(let r of this.members)e.writeNode(new A({docs:r.docs})),e.writeNode(n.getMemberIdentifier({name:this.name,member:r})),e.write(" = "),e.writeNode(E.string(r.value)),e.newLine();e.dedent(),e.write(")")}}writeConstructor({writer:e}){this.constructor_!=null&&(e.newLine(),e.writeNode(this.constructor_))}writeMethods({writer:e}){e.newLine();for(let r of this.methods)e.newLine(),e.writeNode(r),e.newLine()}static getMemberIdentifier({name:e,member:r}){return new O(`${e}${r.name}`)}};l();f();var Z=class extends w{constructor({name:e,type:r,docs:i,tags:o}){super();u(this,"name");u(this,"type");u(this,"docs");u(this,"tags",[]);this.name=e,this.type=r,this.docs=i,this.tags=o!=null?o:[]}addTags(...e){this.tags.push(...e)}write(e){e.writeNode(new A({docs:this.docs})),e.write(`${this.name} `),this.type.write(e),this.writeTags({writer:e})}writeTags({writer:e}){this.tags.length!==0&&(e.write(" `"),this.tags.forEach((r,i)=>{i>0&&e.write(" "),e.write(`${r.name}:"${r.value}"`)}),e.write("`"))}};l();f();var ee=class extends w{constructor({nodes:e}={nodes:[]}){super();u(this,"nodes");this.nodes=e!=null?e:[]}add(...e){this.nodes.push(...e)}write(e){for(let r of this.nodes)r.write(e)}};l();f();l();f();var W=class extends w{constructor({name:e,parameters:r,return_:i,body:o,docs:s,typeReference:p,multiline:h,receiver:m,pointerReceiver:y}){super();u(this,"parameters");u(this,"return_");u(this,"name");u(this,"body");u(this,"docs");u(this,"typeReference");u(this,"multiline");u(this,"receiver");u(this,"pointerReceiver");this.name=e,this.parameters=r,this.return_=i,this.body=o,this.docs=s,this.typeReference=p,this.multiline=h,this.receiver=m,this.pointerReceiver=y}write(e){var r;e.writeNode(new A({docs:this.docs})),e.write("func"),this.typeReference!=null&&this.writeReceiver({writer:e,typeReference:this.typeReference,receiver:this.receiver}),this.name!=null&&e.write(` ${this.name}`),ue({writer:e,arguments_:this.parameters,multiline:this.multiline}),this.return_!=null&&(e.write(" "),this.return_.length>1&&e.write("("),this.return_.forEach((i,o)=>{o>0&&e.write(", "),e.writeNode(i)}),this.return_.length>1&&e.write(")")),e.writeLine("{"),e.indent(),(r=this.body)==null||r.write(e),e.dedent(),e.writeNewLineIfLastLineNot(),e.write("}")}writeReceiver({writer:e,typeReference:r,receiver:i}){e.write(` (${this.getReceiverName({typeReference:r,receiver:i})} `),this.pointerReceiver&&e.write("*"),r.write(e),e.write(")")}getReceiverName({typeReference:e,receiver:r}){return r!=null?r:e.name.charAt(0).toLowerCase()}};var te=class extends w{constructor({name:e,parameters:r,return_:i,body:o,docs:s,multiline:p}){super();u(this,"func");this.func=new W({name:e,parameters:r,return_:i,body:o,docs:s,multiline:p})}get parameters(){return this.func.parameters}get return_(){return this.func.return_}get name(){return this.func.name}get body(){return this.func.body}get docs(){return this.func.docs}write(e){e.writeNode(this.func)}};l();f();var Re=class extends w{constructor({nodes:e}){super();u(this,"nodes");this.nodes=e}write(e){for(let r of this.nodes)e.newLine(),r.write(e),e.newLine()}};l();f();var re=class extends w{constructor({name:e,type:r,docs:i}){super();u(this,"name");u(this,"type");u(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new A({docs:this.docs})),e.write(`${this.name} `),this.type.write(e)}};l();f();var ne=class extends w{constructor({node:e}){super();u(this,"node");this.node=e}write(e){e.write("*"),this.node.write(e)}};l();f();var ie=class extends w{constructor({on:e,selector:r}){super();u(this,"on");u(this,"selector");this.on=e,this.selector=r}write(e){e.writeNode(this.on),e.write("."),e.writeNode(this.selector)}};l();f();var oe=class extends w{constructor({name:e,embeds:r,fields:i,docs:o}){super();u(this,"name");u(this,"embeds",[]);u(this,"fields",[]);u(this,"docs");u(this,"methods",[]);u(this,"constructor_");this.name=e,this.docs=o,this.embeds=r!=null?r:[],this.fields=i!=null?i:[]}addConstructor(e){this.constructor_=e}addField(...e){this.fields.push(...e)}addMethod(...e){this.methods.push(...e)}write(e){this.writeType({writer:e}),this.constructor_!=null&&(e.newLine(),e.newLine(),this.writeConstructor({writer:e,constructor:this.constructor_})),this.writeMethods({writer:e})}writeType({writer:e}){if(e.writeNode(new A({docs:this.docs})),this.name!=null?e.write(`type ${this.name} struct {`):e.write("struct{"),this.embeds.length===0&&this.fields.length===0){e.writeLine("}");return}e.newLine(),e.indent();for(let o of this.embeds)e.writeNode(o),e.newLine();let r=this.fields.filter(o=>this.isExported(o));for(let o of r)e.writeNode(o),e.newLine();let i=this.fields.filter(o=>!this.isExported(o));r.length>0&&i.length>0&&e.newLine();for(let o of i)e.writeNode(o),e.newLine();e.dedent(),e.write("}")}writeConstructor({writer:e,constructor:r}){r.name!=null?e.write(`func ${r.name}(`):e.write(`func New${this.name}(`),r.parameters.forEach((i,o)=>{o>0&&e.write(", "),e.writeNode(i)}),e.write(`) *${this.name} {`),e.newLine(),e.indent(),e.writeNode(r.body),e.writeNewLineIfLastLineNot(),e.dedent(),e.writeLine("}")}writeMethods({writer:e}){if(this.methods.length!==0){e.writeNewLineIfLastLineNot();for(let r of this.methods)e.newLine(),e.writeNode(r),e.newLine()}}isExported(e){let r=e.name.charAt(0);return r===r.toUpperCase()}};l();f();var Ne=class extends w{constructor({on:e,cases:r,default:i}){super();u(this,"on");u(this,"cases");u(this,"default");this.on=e,this.cases=r,this.default=i}write(e){let r=this.cases;this.default!=null&&r.push({on:new O("default"),body:this.default}),e.write("switch "),e.writeNode(this.on),e.writeLine("{"),e.indent();for(let i of r)e.write("case "),e.writeNode(i.on),e.writeLine(":"),e.indent(),e.writeNode(i.body),e.dedent(),e.writeNewLineIfLastLineNot();e.dedent(),e.write("}")}};l();f();var bn=new Set(["any","bytes","map","slice"]),Ae=class n extends w{constructor(e){super();u(this,"internalType");this.internalType=e}write(e,{comment:r}={}){switch(this.internalType.type){case"any":e.write("any");break;case"bool":e.write("bool");break;case"bytes":e.write("[]byte");break;case"date":case"dateTime":e.writeNode(Oe);break;case"error":e.write("error");break;case"float64":e.write("float64");break;case"int":e.write("int");break;case"int64":e.write("int64");break;case"map":{e.write("map["),this.internalType.keyType.write(e),e.write("]"),this.internalType.valueType.write(e);break}case"optional":{e.write("*"),this.internalType.value.write(e);break}case"reference":e.writeNode(this.internalType.value);break;case"slice":e.write("[]"),this.internalType.value.write(e);break;case"string":e.write("string");break;case"uuid":e.writeNode(Ve);break;case"variadic":e.write("..."),this.internalType.value.write(e);break;default:x(this.internalType)}}isOptional(){return this.internalType.type==="optional"}isIterable(){return this.internalType.type==="slice"||this.internalType.type==="variadic"}iterableElement(){if(this.internalType.type==="slice"||this.internalType.type==="variadic")return this.internalType.value}underlying(){return this.internalType.type==="optional"?this.internalType.value:this}static any(){return new this({type:"any"})}static bool(){return new this({type:"bool"})}static bytes(){return new this({type:"bytes"})}static date(){return new this({type:"date"})}static dateTime(){return new this({type:"dateTime"})}static dereference(e){return e.internalType.type==="optional"?e.internalType.value:e}static error(){return new this({type:"error"})}static float64(){return new this({type:"float64"})}static int(){return new this({type:"int"})}static int64(){return new this({type:"int64"})}static map(e,r){return new this({type:"map",keyType:e,valueType:r})}static optional(e){return this.isAlreadyOptional(e)?e:new this({type:"optional",value:e})}static pointer(e){return n.optional(e)}static reference(e){return new this({type:"reference",value:e})}static slice(e){return new this({type:"slice",value:e})}static string(){return new this({type:"string"})}static uuid(){return new this({type:"uuid"})}static variadic(e){return this.isAlreadyVariadic(e)?e:new this({type:"variadic",value:e})}static isAlreadyOptional(e){return e.internalType.type==="optional"||bn.has(e.internalType.type)}static isAlreadyVariadic(e){return e.internalType.type==="variadic"}},Oe=new F({importPath:"time",name:"Time"}),Ve=new F({importPath:"github.com/google/uuid",name:"UUID"}),ot=new F({importPath:"io",name:"Reader"});l();f();var se=class extends w{constructor({name:e,type:r,docs:i}){super();u(this,"name");u(this,"type");u(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new A({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" "),e.writeNode(this.type)}};function Pn(n){return new X(n)}function kn(n){return new _(n)}function Sn(n){return new Q(n)}function Cn(n){return new Z(n)}function Un(n={}){return new ee(n)}function Bn(n){return new te(n)}function Ln(n){return new O(n)}function _n(n){return new S(n)}function Mn(n){return new V(n)}function Dn(n){return new W(n)}function $n(n){return new re(n)}function On(n){return new ne(n)}function Vn(n){return new ie(n)}function Wn(n={}){return new oe(n)}function qn(n){return new Ne(n)}function Gn(n){return new se(n)}function Yn(n){return new F(n)}l();f();Yt();var jn="sdk";function st({config:n,customConfig:t}){let e=zn({config:n}),r=Hn({config:n,customConfig:t});return e!=null?Jn({importPath:r,majorVersion:e}):r}function Hn({config:n,customConfig:t,isModulePath:e=!1}){var i,o,s,p;let r=(s=(o=t==null?void 0:t.importPath)!=null?o:(i=t==null?void 0:t.module)==null?void 0:i.path)!=null?s:n.output.mode.type==="github"?Xn(n.output.mode.repoUrl,"https://"):jn;return e?r:Gt.join(r,(p=t==null?void 0:t.packagePath)!=null?p:"")}function zn({config:n}){let t=Kn({config:n});if(!(t==null||t==="v0"||t==="v1"))return`${t}`}function Kn({config:n}){let t=Qn(n);if(t==null)return;let e=t.split(".");if(e[0]==null)return;let r=e[0];return r.startsWith("v")?r:`v${r}`}function Jn({importPath:n,majorVersion:t}){return Te(n)===t?n:`${n}/${t}`}function Xn(n,t){return n.startsWith(t)?n.slice(t.length):n}function Qn(n){var e;let t=(e=n==null?void 0:n.output)==null?void 0:e.mode;if(t!=null)return t.type==="github"||t.type==="publish"?t.version:void 0}l();f();var We=class{constructor({context:t}){u(this,"context");this.context=t}convert(t){if(t.value===null&&!this.context.isNullable(t.typeReference)&&this.context.errors.add({severity:v.Critical,message:"Expected non-null value, but got null"}),t.value==null)return a.TypeInstantiation.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return a.TypeInstantiation.nop();case"map":return this.convertMap({map:t.typeReference,value:t.value});case"named":{let e=this.context.resolveNamedType({typeId:t.typeReference.value});return e==null?a.TypeInstantiation.nop():this.convertNamed({named:e,value:t.value,as:t.as})}case"nullable":{let e=t.typeReference.value;if(e.type==="named"){let r=this.context.resolveNamedType({typeId:e.value});if((r==null?void 0:r.type)==="alias"&&["list","set","map"].includes(r.typeReference.type)){let i=this.convert({typeReference:r.typeReference,value:t.value,as:t.as}),o=this.context.getTypeName(r.declaration.name),s=this.context.getImportPath(r.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:i,aliasName:o,aliasImportPath:s})}}return a.TypeInstantiation.optional(this.convert({typeReference:e,value:t.value,as:t.as}))}case"optional":{let e=t.typeReference.value;if(e.type==="named"){let r=this.context.resolveNamedType({typeId:e.value});if((r==null?void 0:r.type)==="alias"&&["list","set","map"].includes(r.typeReference.type)){let i=this.convert({typeReference:r.typeReference,value:t.value,as:t.as}),o=this.context.getTypeName(r.declaration.name),s=this.context.getImportPath(r.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:i,aliasName:o,aliasImportPath:s})}}return a.TypeInstantiation.optional(this.convert({typeReference:e,value:t.value,as:t.as}))}case"primitive":return this.convertPrimitive({primitive:t.typeReference.value,value:t.value,as:t.as});case"set":return this.convertList({list:t.typeReference.value,value:t.value});case"unknown":return this.convertUnknown({value:t.value});default:x(t.typeReference)}}convertToPointerIfPossible(t){let e=this.convert(t);switch(t.typeReference.type){case"named":{let r=this.context.resolveNamedType({typeId:t.typeReference.value});return(r==null?void 0:r.type)==="enum"?a.TypeInstantiation.reference(a.invokeMethod({on:e,method:"Ptr",arguments_:[]})):e}default:return e}}convertList({list:t,value:e}){return Array.isArray(e)?a.TypeInstantiation.slice({valueType:this.context.dynamicTypeMapper.convert({typeReference:t}),values: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:v.Critical,message:`Expected array but got: ${typeof e}`}),a.TypeInstantiation.nop())}convertMap({map:t,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:v.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),a.TypeInstantiation.nop()):a.TypeInstantiation.map({keyType:this.context.dynamicTypeMapper.convert({typeReference:t.key}),valueType:this.context.dynamicTypeMapper.convert({typeReference:t.value}),entries: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.convertAlias({aliasType:t,value:e,as:r});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:t,value:e});case"enum":return this.convertEnum({enum_:t,value:e});case"object":return this.convertObject({object_:t,value:e});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e});default:x(t)}}convertAlias({aliasType:t,value:e,as:r}){switch(t.typeReference.type){case"literal":return a.TypeInstantiation.reference(a.invokeFunc({func:a.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),arguments_:[this.convertLiteralValue(t.typeReference.value)]}));default:return this.convert({typeReference:t.typeReference,value:e,as:r})}}reconstructAliasCollectionLiteral({collectionLiteral:t,aliasName:e,aliasImportPath:r}){let i=t.internalType;return i.type==="slice"?a.TypeInstantiation.reference(a.codeblock(o=>{o.write("&"),o.writeNode(a.typeReference({name:e,importPath:r}));let s=i.values;if(s.length===0){o.write("{}");return}o.writeLine("{"),o.indent();for(let p of s)o.writeNode(p),o.writeLine(",");o.dedent(),o.write("}")})):i.type==="map"?a.TypeInstantiation.reference(a.codeblock(o=>{o.write("&"),o.writeNode(a.typeReference({name:e,importPath:r}));let s=i.entries;if(s.length===0){o.write("{}");return}o.writeLine("{"),o.indent();for(let p of s)o.writeNode(p.key),o.write(": "),o.writeNode(p.value),o.writeLine(",");o.dedent(),o.write("}")})):a.TypeInstantiation.reference(a.codeblock(o=>{o.write("&"),o.writeNode(t)}))}convertLiteralValue(t){switch(t.type){case"boolean":return a.TypeInstantiation.bool(t.value);case"string":return a.TypeInstantiation.string(t.value);default:x(t)}}convertDiscriminatedUnion({discriminatedUnion:t,value:e}){let r=this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),i=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e});if(i==null)return a.TypeInstantiation.nop();let o=i.singleDiscriminatedUnionType,s=this.getBaseFields({discriminatedUnionTypeInstance:i,singleDiscriminatedUnionType:o});switch(o.type){case"samePropertiesAsObject":{let p=this.context.resolveNamedType({typeId:o.typeId});return p==null?a.TypeInstantiation.nop():a.TypeInstantiation.structPointer({typeReference:r,fields:[{name:this.context.getTypeName(o.discriminantValue.name),value:this.convertNamed({named:p,value:i.value})},...s]})}case"singleProperty":{let p=this.context.getRecord(i.value);if(p==null)return a.TypeInstantiation.nop();try{return this.context.errors.scope(o.discriminantValue.wireValue),a.TypeInstantiation.structPointer({typeReference:r,fields:[{name:this.context.getTypeName(o.discriminantValue.name),value:this.convert({typeReference:o.typeReference,value:p[o.discriminantValue.wireValue]})},...s]})}finally{this.context.errors.unscope()}}case"noProperties":return a.TypeInstantiation.structPointer({typeReference:r,fields:[{name:this.context.getTypeName(i.discriminantValue.name),value:a.TypeInstantiation.string(o.discriminantValue.wireValue)},...s]});default:x(o)}}getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e}){var i,o;return this.context.associateByWireValue({parameters:(i=e.properties)!=null?i:[],values:(o=this.context.getRecord(t.value))!=null?o:{},ignoreMissingParameters:!0}).map(s=>{this.context.errors.scope(s.name.wireValue);try{return{name:this.context.getTypeName(s.name.name),value:this.convert(s)}}finally{this.context.errors.unscope()}})}convertObject({object_:t,value:e}){var i;let r=this.context.associateByWireValue({parameters:t.properties,values:(i=this.context.getRecord(e))!=null?i:{}});return a.TypeInstantiation.structPointer({typeReference:a.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),fields:r.map(o=>{this.context.errors.scope(o.name.wireValue);try{return{name:this.context.getTypeName(o.name.name),value:this.convert(o)}}finally{this.context.errors.unscope()}})})}convertEnum({enum_:t,value:e}){let r=this.getEnumValueName({enum_:t,value:e});return r==null?a.TypeInstantiation.nop():a.TypeInstantiation.enum(a.typeReference({name:r,importPath:this.context.getImportPath(t.declaration.fernFilepath)}))}getEnumValueName({enum_:t,value:e}){if(typeof e!="string"){this.context.errors.add({severity:v.Critical,message:`Expected enum value string, got: ${typeof e}`});return}let r=t.values.find(i=>i.wireValue===e);if(r==null){this.context.errors.add({severity:v.Critical,message:`An enum value named "${e}" does not exist in this context`});return}return`${this.context.getTypeName(t.declaration.name)}${this.context.getTypeName(r.name)}`}convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e}){let r=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e});if(r==null)return a.TypeInstantiation.nop();let i=this.getUndiscriminatedUnionFieldName({typeReference:r.valueTypeReference});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.structPointer({typeReference:this.context.getGoTypeReferenceFromDeclaration({declaration:t.declaration}),fields:[{name:i,value:r.typeInstantiation}]})}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e}){for(let r of t.types)try{let i=this.convert({typeReference:r,value:e});return{valueTypeReference:r,typeInstantiation:i}}catch(i){continue}this.context.errors.add({severity:v.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof e}" value`})}getUndiscriminatedUnionFieldName({typeReference:t}){switch(t.type){case"list":return this.getUndiscriminatedUnionFieldNameForList({list:t});case"literal":return this.getUndiscriminatedUnionFieldNameForLiteral({literal:t.value});case"map":return this.getUndiscriminatedUnionFieldNameForMap({map:t});case"named":{let e=this.context.resolveNamedType({typeId:t.value});return e==null?void 0:this.context.getTypeName(e.declaration.name)}case"optional":return this.getUndiscriminatedUnionFieldNameForOptional({typeReference:t});case"nullable":return this.getUndiscriminatedUnionFieldNameForOptional({typeReference:t});case"primitive":return this.getUndiscriminatedUnionFieldNameForPrimitive({primitive:t.value});case"set":return this.getUndiscriminatedUnionFieldNameForSet({set:t});case"unknown":return"Unknown";default:x(t)}}getUndiscriminatedUnionFieldNameForList({list:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t});if(e!=null)return`${e}List`}getUndiscriminatedUnionFieldNameForMap({map:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t.key});if(e==null)return;let r=this.getUndiscriminatedUnionFieldName({typeReference:t.value});if(r!=null)return`${e}${r}Map`}getUndiscriminatedUnionFieldNameForOptional({typeReference:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t});if(e!=null)return`${e}Optional`}getUndiscriminatedUnionFieldNameForSet({set:t}){let e=this.getUndiscriminatedUnionFieldName({typeReference:t});if(e!=null)return`${e}Set`}getUndiscriminatedUnionFieldNameForLiteral({literal:t}){switch(t.type){case"boolean":return t.value?"TrueLiteral":"FalseLiteral";case"string":return`${t.value}StringLiteral`;default:x(t)}}getUndiscriminatedUnionFieldNameForPrimitive({primitive:t}){switch(t){case"INTEGER":case"UINT":return"Integer";case"LONG":case"UINT_64":return"Long";case"FLOAT":case"DOUBLE":return"Double";case"BOOLEAN":return"Boolean";case"BIG_INTEGER":case"STRING":return"String";case"UUID":return"Uuid";case"DATE":return"Date";case"DATE_TIME":return"DateTime";case"BASE_64":return"Base64";default:x(t)}}convertUnknown({value:t}){return a.TypeInstantiation.any(t)}convertPrimitive({primitive:t,value:e,as:r}){switch(t){case"INTEGER":case"UINT":{let i=this.getValueAsNumber({value:e,as:r});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.int(i)}case"LONG":case"UINT_64":{let i=this.getValueAsNumber({value:e,as:r});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.int64(i)}case"FLOAT":case"DOUBLE":{let i=this.getValueAsNumber({value:e,as:r});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.float64(i)}case"BOOLEAN":{let i=this.getValueAsBoolean({value:e,as:r});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.bool(i)}case"STRING":{let i=this.context.getValueAsString({value:e});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.string(i)}case"DATE":{let i=this.context.getValueAsString({value:e});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.date(i)}case"DATE_TIME":{let i=this.context.getValueAsString({value:e});if(i==null)return a.TypeInstantiation.nop();let o=this.normalizeDateTimeString(i);return a.TypeInstantiation.dateTime(o)}case"UUID":{let i=this.context.getValueAsString({value:e});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.uuid(i)}case"BASE_64":{let i=this.context.getValueAsString({value:e});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.bytes(i)}case"BIG_INTEGER":{let i=this.context.getValueAsString({value:e});return i==null?a.TypeInstantiation.nop():a.TypeInstantiation.string(i)}default:x(t)}}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==="false"?!1:t:t;return this.context.getValueAsBoolean({value:r})}normalizeDateTimeString(t){return/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t}T00:00:00Z`:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(t)?`${t}Z`:t}};l();f();var qe=class{constructor({context:t}){u(this,"context");this.context=t}convert(t){switch(t.typeReference.type){case"list":return a.Type.slice(this.convert({typeReference:t.typeReference.value}));case"literal":return this.convertLiteral({literal:t.typeReference.value});case"map":return a.Type.map(this.convert({typeReference:t.typeReference.key}),this.convert({typeReference:t.typeReference.value}));case"named":{let e=this.context.resolveNamedType({typeId:t.typeReference.value});return e==null?this.convertUnknown():this.convertNamed({named:e})}case"optional":return a.Type.optional(this.convert({typeReference:t.typeReference.value}));case"nullable":return a.Type.optional(this.convert({typeReference:t.typeReference.value}));case"primitive":return this.convertPrimitive({primitive:t.typeReference.value});case"set":return a.Type.slice(this.convert({typeReference:t.typeReference}));case"unknown":return this.convertUnknown();default:x(t.typeReference)}}convertLiteral({literal:t}){switch(t.type){case"boolean":return a.Type.bool();case"string":return a.Type.string()}}convertNamed({named:t}){let e=a.Type.reference(a.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}));switch(t.type){case"alias":case"enum":return e;case"discriminatedUnion":case"object":case"undiscriminatedUnion":return a.Type.pointer(e);default:x(t)}}convertUnknown(){return a.Type.any()}convertPrimitive({primitive:t}){switch(t){case"INTEGER":return a.Type.int();case"UINT":return a.Type.int();case"LONG":return a.Type.int64();case"UINT_64":return a.Type.int64();case"FLOAT":return a.Type.float64();case"DOUBLE":return a.Type.float64();case"BOOLEAN":return a.Type.bool();case"STRING":return a.Type.string();case"DATE":return a.Type.date();case"DATE_TIME":return a.Type.dateTime();case"UUID":return a.Type.uuid();case"BASE_64":return a.Type.bytes();case"BIG_INTEGER":return a.Type.string();default:x(t)}}};l();f();var Ge=class{constructor({context:t}){u(this,"context");this.context=t}getFilePropertyInfo({body:t,value:e}){var o;let r={fileFields:[],bodyPropertyFields:[]},i=(o=this.context.getRecord(e))!=null?o:{};for(let s of t.properties)switch(s.type){case"file":r.fileFields.push({name:this.context.getTypeName(s.name),value:this.getSingleFileProperty({property:s,record:i})});break;case"fileArray":r.fileFields.push({name:this.context.getTypeName(s.name),value:this.getArrayFileProperty({property:s,record:i})});break;case"bodyProperty":r.bodyPropertyFields.push({name:this.context.getTypeName(s.name.name),value:this.getBodyProperty({property:s,record:i})});break;default:x(s)}return r}getSingleFileProperty({property:t,record:e}){let r=this.context.getSingleFileValue({property:t,record:e})||"";return a.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(r))}getArrayFileProperty({property:t,record:e}){let r=this.context.getFileArrayValues({property:t,record:e});return r==null?a.TypeInstantiation.nop():a.TypeInstantiation.slice({valueType:a.Type.reference(this.context.getIoReaderTypeReference()),values:r.map(i=>a.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(i)))})}getBodyProperty({property:t,record:e}){let r=e[t.name.wireValue];return r==null?a.TypeInstantiation.nop():this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:r})}};var Ye=class n extends ve{constructor({ir:e,config:r}){super({ir:e,config:r});u(this,"ir");u(this,"customConfig");u(this,"dynamicTypeMapper");u(this,"dynamicTypeInstantiationMapper");u(this,"filePropertyMapper");u(this,"rootImportPath");this.ir=e,this.customConfig=r.customConfig!=null?r.customConfig:void 0,this.dynamicTypeMapper=new qe({context:this}),this.dynamicTypeInstantiationMapper=new We({context:this}),this.filePropertyMapper=new Ge({context:this}),this.rootImportPath=st({config:r,customConfig:this.customConfig})}clone(){return new n({ir:this.ir,config:this.config})}isOptional(e){switch(e.type){case"optional":case"map":return!0;case"nullable":case"list":case"set":return this.isOptional(e.value);case"named":case"literal":case"primitive":case"unknown":return!1;default:x(e)}}getMethodName(e){return e.pascalCase.unsafeName}getTestMethodName(e){return e.declaration.fernFilepath.allParts.map(r=>r.pascalCase.unsafeName).join("")+e.declaration.name.pascalCase.unsafeName}getTypeName(e){return e.pascalCase.unsafeName}getImportPath(e){let r=e.packagePath.map(i=>i.pascalCase.unsafeName.toLowerCase());return[this.rootImportPath,...r].join("/")}getImportPathForRequest(e){var r;return(r=this.customConfig)!=null&&r.exportAllRequestsAtRoot?this.rootImportPath:this.getImportPath(e)}getContextTypeReference(){return a.typeReference({name:"Context",importPath:"context"})}getContextTodoFunctionInvocation(){return a.invokeFunc({func:a.typeReference({name:"TODO",importPath:"context"}),arguments_:[]})}getIoReaderTypeReference(){return a.typeReference({name:"Reader",importPath:"io"})}getTestingTypeReference(){return a.typeReference({name:"T",importPath:"testing"})}getNewStringsReaderFunctionInvocation(e){return a.invokeFunc({func:a.typeReference({name:"NewReader",importPath:"strings"}),arguments_:[a.TypeInstantiation.string(e)]})}getClientConstructorName(){var e,r;return((e=this.customConfig)==null?void 0:e.clientConstructorName)!=null?this.customConfig.clientConstructorName:((r=this.customConfig)==null?void 0:r.exportedClientName)!=null?`New${this.customConfig.exportedClientName}`:`New${this.getClientName()}`}getClientName(){var e;return((e=this.customConfig)==null?void 0:e.clientName)!=null?this.customConfig.clientName:"Client"}getClientImportPath(){return`${this.rootImportPath}/client`}getOptionImportPath(){return`${this.rootImportPath}/option`}getGoTypeReferenceFromDeclaration({declaration:e}){return a.typeReference({name:e.name.pascalCase.unsafeName,importPath:this.getImportPath(e.fernFilepath)})}getEnvironmentTypeReferenceFromID(e){let r=this.resolveEnvironmentName(e);if(r!=null)return this.getEnvironmentTypeReference(r)}getEnvironmentTypeReference(e){return a.typeReference({name:`Environments.${this.getTypeName(e)}`,importPath:this.rootImportPath})}static chainMethods(e,...r){if(r.length===0)throw new Error("Must have methods to chain");let i=e;for(let o of r)i=a.invokeMethod({on:i,method:o.method,arguments_:o.arguments_,multiline:o.multiline});return i}};l();f();var zt="example",at="fern",Zn="do",Ee="client",pe=a.TypeInstantiation,ei="WireMockBaseURL",ti="WireMockClient",je=class{constructor({context:t,formatter:e}){u(this,"context");u(this,"formatter");this.context=t,this.formatter=e}async generateSnippet({endpoint:t,request:e,options:r}){var s,p,h;return((p=(s=r==null?void 0:r.config)==null?void 0:s.outputWiremockTests)!=null?p:!1)?this.generateWiremockTest({endpoint:t,snippet:e}):await this.buildCodeBlock({endpoint:t,snippet:e}).toStringAsync({packageName:zt,importPath:at,rootImportPath:this.context.rootImportPath,customConfig:(h=this.context.customConfig)!=null?h:{},formatter:this.formatter})}generateSnippetSync({endpoint:t,request:e,options:r}){var s,p,h;return((p=(s=r==null?void 0:r.config)==null?void 0:s.outputWiremockTests)!=null?p:!1)?this.generateWiremockTest({endpoint:t,snippet:e}):this.buildCodeBlock({endpoint:t,snippet:e}).toString({packageName:zt,importPath:at,rootImportPath:this.context.rootImportPath,customConfig:(h=this.context.customConfig)!=null?h:{},formatter:this.formatter})}async generateSnippetAst({endpoint:t,request:e,options:r}){throw new Error("Unsupported")}generateWiremockTest({endpoint:t,snippet:e}){var i;return this.buildWiremockTestCodeBlock({endpoint:t,snippet:e}).toString({packageName:"wiremock",importPath:at,rootImportPath:this.context.rootImportPath,customConfig:(i=this.context.customConfig)!=null?i:{},formatter:this.formatter})}buildCodeBlock({endpoint:t,snippet:e}){return a.codeblock(r=>{r.writeNode(a.func({name:Zn,parameters:[],return_:[],body:a.codeblock(i=>{i.writeNode(this.constructClient({endpoint:t,snippet:e})),i.writeLine(),i.writeNode(this.callMethod({endpoint:t,snippet:e}))})})),r.writeNewLineIfLastLineNot()})}buildWiremockTestCodeBlock({endpoint:t,snippet:e}){return a.codeblock(r=>{r.writeNode(a.func({name:"Test"+this.context.getTestMethodName(t)+"WithWireMock",parameters:[a.parameter({name:"t",type:a.Type.pointer(a.Type.reference(this.context.getTestingTypeReference()))})],return_:[],body:a.codeblock(i=>{for(let o of this.buildWiremockTestSetup({endpoint:t}))i.writeNode(o),i.writeLine();i.writeLine(),i.writeNode(this.constructWiremockTestClient({endpoint:t,snippet:e})),i.writeLine(),i.writeNode(this.callClientMethodAndAssert({endpoint:t,snippet:e}))})})),r.writeNewLineIfLastLineNot()})}constructClient({endpoint:t,snippet:e}){return a.codeblock(r=>{r.write(`${Ee} := `),r.writeNode(this.getRootClientFuncInvocation(this.getConstructorArgs({endpoint:t,snippet:e})))})}constructWiremockTestClient({endpoint:t,snippet:e}){return a.codeblock(r=>{r.write(`${Ee} := `),r.writeNode(this.getRootClientFuncInvocation(this.getWiremockTestConstructorArgs()))})}writeMethodInvocation({writer:t,endpoint:e,snippet:r}){let{otherArgs:i,requestArg:o}=this.getMethodArgs({endpoint:e,snippet:r});if(o!=null)if(o instanceof a.TypeInstantiation&&a.TypeInstantiation.isNop(o))t.writeNode(a.invokeMethod({on:a.codeblock(Ee),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...i,a.codeblock("nil")]}));else{t.write("request := "),t.writeNode(o),t.writeLine();let s=a.codeblock("request");t.writeNode(a.invokeMethod({on:a.codeblock(Ee),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...i,s]}))}else t.writeNode(a.invokeMethod({on:a.codeblock(Ee),method:this.getMethod({endpoint:e}),arguments_:[this.context.getContextTodoFunctionInvocation(),...i]}))}callMethod({endpoint:t,snippet:e}){return a.codeblock(r=>{this.writeMethodInvocation({writer:r,endpoint:t,snippet:e})})}getConstructorArgs({endpoint:t,snippet:e}){let r=[],i=this.getConstructorBaseUrlArg({baseUrl:e.baseURL,environment:e.environment});return i!=null&&r.push(i),t.auth!=null&&(e.auth!=null?r.push(this.getConstructorAuthArg({auth:t.auth,values:e.auth})):this.context.errors.add({severity:v.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(L.Headers),this.context.ir.headers!=null&&e.headers!=null&&r.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:e.headers})),this.context.errors.unscope(),r}getWiremockTestConstructorArgs(){return[a.codeblock(t=>{t.writeNode(a.invokeFunc({func:a.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[a.codeblock(ei)]}))})]}getConstructorAuthArg({auth:t,values:e}){if(e.type!==t.type)return this.addError(this.context.newAuthMismatchError({auth:t,values:e}).message),pe.nop();switch(t.type){case"basic":return e.type==="basic"?this.getConstructorBasicAuthArg({auth:t,values:e}):pe.nop();case"bearer":return e.type==="bearer"?this.getConstructorBearerAuthArg({auth:t,values:e}):pe.nop();case"header":return e.type==="header"?this.getConstructorHeaderAuthArg({auth:t,values:e}):pe.nop();case"oauth":return this.addWarning("The Go SDK doesn't support OAuth client credentials yet"),pe.nop();case"inferred":return this.addWarning("The Go SDK Generator does not support Inferred auth scheme yet"),pe.nop();default:x(t)}}addError(t){this.context.errors.add({severity:v.Critical,message:t})}addWarning(t){this.context.errors.add({severity:v.Warning,message:t})}getConstructorBasicAuthArg({auth:t,values:e}){return a.codeblock(r=>{r.writeNode(a.invokeFunc({func:a.typeReference({name:"WithBasicAuth",importPath:this.context.getOptionImportPath()}),arguments_:[a.TypeInstantiation.string(e.username),a.TypeInstantiation.string(e.password)]}))})}getConstructorBaseUrlArg({baseUrl:t,environment:e}){let r=this.getBaseUrlArg({baseUrl:t,environment:e});if(r!=null)return a.codeblock(i=>{i.writeNode(a.invokeFunc({func:a.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[r]}))})}getBaseUrlArg({baseUrl:t,environment:e}){if(t!=null&&e!=null){this.context.errors.add({severity:v.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(t!=null)return a.TypeInstantiation.string(t);if(e!=null){if(this.context.isSingleEnvironmentID(e)){let r=this.context.getEnvironmentTypeReferenceFromID(e);if(r==null){this.context.errors.add({severity:v.Warning,message:`Environment ${JSON.stringify(e)} was not found`});return}return a.TypeInstantiation.reference(r)}this.context.isMultiEnvironmentValues(e)&&this.context.errors.add({severity:v.Warning,message:"The Go SDK doesn't support a multi-environment client option yet; use the baseUrl option instead"})}}getConstructorBearerAuthArg({auth:t,values:e}){return a.codeblock(r=>{r.writeNode(a.invokeFunc({func:a.typeReference({name:`With${t.token.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[a.TypeInstantiation.string(e.token)]}))})}getConstructorHeaderAuthArg({auth:t,values:e}){return a.codeblock(r=>{r.writeNode(a.invokeFunc({func:a.typeReference({name:`With${t.header.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.header.typeReference,value:e.value})]}))})}getConstructorHeaderArgs({headers:t,values:e}){let r=[];for(let i of t){let o=this.getConstructorHeaderArg({header:i,value:e.value});o!=null&&r.push(o)}return r}getConstructorHeaderArg({header:t,value:e}){let r=this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:e});if(!a.TypeInstantiation.isNop(r))return a.codeblock(i=>{i.writeNode(a.invokeFunc({func:a.typeReference({name:`With${t.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[r]}))})}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:x(t.request)}}getMethodArgsForBodyRequest({request:t,snippet:e}){var s,p;let r=[];this.context.errors.scope(L.PathParameters);let i=[...(s=this.context.ir.pathParameters)!=null?s:[],...(p=t.pathParameters)!=null?p:[]];i.length>0&&r.push(...this.getPathParameters({namedParameters:i,snippet:e}).map(h=>h.value)),this.context.errors.unscope(),this.context.errors.scope(L.RequestBody);let o=t.body!=null?this.getBodyRequestArg({body:t.body,value:e.requestBody}):void 0;return this.context.errors.unscope(),{otherArgs:r,requestArg:o}}getBodyRequestArg({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e});default:x(t)}}getBytesBodyRequestArg({value:t}){return typeof t!="string"?(this.context.errors.add({severity:v.Critical,message:`Expected bytes value to be a string, got ${typeof t}`}),a.TypeInstantiation.nop()):a.TypeInstantiation.bytes(t)}getMethodArgsForInlinedRequest({request:t,snippet:e}){var y,g,T,I,R,Y;let r=[],{inlinePathParameters:i,inlineFileProperties:o}={inlinePathParameters:(g=(y=this.context.customConfig)==null?void 0:y.inlinePathParameters)!=null?g:!0,inlineFileProperties:(I=(T=this.context.customConfig)==null?void 0:T.inlineFileProperties)!=null?I:!0};this.context.errors.scope(L.PathParameters);let s=[],p=[...(R=this.context.ir.pathParameters)!=null?R:[],...(Y=t.pathParameters)!=null?Y:[]];p.length>0&&s.push(...this.getPathParameters({namedParameters:p,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(L.RequestBody);let h=this.getFilePropertyInfo({request:t,snippet:e});this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:i})||r.push(...s.map(le=>le.value)),o||r.push(...h.fileFields.map(le=>le.value));let m=this.context.needsRequestParameter({request:t,inlinePathParameters:i,inlineFileProperties:o})?this.getInlinedRequestArg({request:t,snippet:e,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:i})?s:[],filePropertyInfo:h}):void 0;return{otherArgs:r,requestArg:m}}getFilePropertyInfo({request:t,snippet:e}){return t.body==null||!this.context.isFileUploadRequestBody(t.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:t.body,value:e.requestBody})}getInlinedRequestArg({request:t,snippet:e,pathParameterFields:r,filePropertyInfo:i}){var y,g,T,I;this.context.errors.scope(L.QueryParameters);let s=this.context.associateQueryParametersByWireValue({parameters:(y=t.queryParameters)!=null?y:[],values:(g=e.queryParameters)!=null?g:{}}).map(R=>({name:R.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(R)}));this.context.errors.unscope(),this.context.errors.scope(L.Headers);let h=this.context.associateByWireValue({parameters:(T=t.headers)!=null?T:[],values:(I=e.headers)!=null?I:{}}).map(R=>({name:R.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(R)}));this.context.errors.unscope(),this.context.errors.scope(L.RequestBody);let m=t.body!=null?this.getInlinedRequestBodyStructFields({body:t.body,value:e.requestBody,filePropertyInfo:i}):[];return this.context.errors.unscope(),a.TypeInstantiation.structPointer({typeReference:a.typeReference({name:this.context.getMethodName(t.declaration.name),importPath:this.context.getImportPathForRequest(t.declaration.fernFilepath)}),fields:[...r,...s,...h,...m]})}getInlinedRequestBodyStructFields({body:t,value:e,filePropertyInfo:r}){switch(t.type){case"properties":return this.getInlinedRequestBodyPropertyStructFields({parameters:t.value,value:e});case"referenced":return[this.getReferencedRequestBodyPropertyStructField({body:t,value:e})];case"fileUpload":return this.getFileUploadRequestBodyStructFields({filePropertyInfo:r});default:x(t)}}getFileUploadRequestBodyStructFields({filePropertyInfo:t}){var e;return(e=this.context.customConfig)!=null&&e.inlineFileProperties?[...t.fileFields,...t.bodyPropertyFields]:t.bodyPropertyFields}getReferencedRequestBodyPropertyStructField({body:t,value:e}){return{name:this.context.getTypeName(t.bodyKey),value:this.getReferencedRequestBodyPropertyTypeInstantiation({body:t.bodyType,value:e})}}getReferencedRequestBodyPropertyTypeInstantiation({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.value,value:e});default:x(t)}}getInlinedRequestBodyPropertyStructFields({parameters:t,value:e}){var o;let r=[],i=this.context.associateByWireValue({parameters:t,values:(o=this.context.getRecord(e))!=null?o:{}});for(let s of i)r.push({name:this.context.getTypeName(s.name.name),value:this.context.dynamicTypeInstantiationMapper.convert(s)});return r}getPathParameters({namedParameters:t,snippet:e}){var o;let r=[],i=this.context.associateByWireValue({parameters:t,values:(o=e.pathParameters)!=null?o:{}});for(let s of i)r.push({name:this.context.getTypeName(s.name.name),value:this.context.dynamicTypeInstantiationMapper.convertToPointerIfPossible(s)});return r}getMethod({endpoint:t}){return t.declaration.fernFilepath.allParts.length>0?`${t.declaration.fernFilepath.allParts.map(e=>this.context.getMethodName(e)).join(".")}.${this.context.getMethodName(t.declaration.name)}`:this.context.getMethodName(t.declaration.name)}getRootClientFuncInvocation(t){return a.invokeFunc({func:a.typeReference({name:this.context.getClientConstructorName(),importPath:this.context.getClientImportPath()}),arguments_:t})}buildWiremockTestSetup({endpoint:t,errorCase:e}){let r="stub";return[]}callClientMethodAndAssert({endpoint:t,snippet:e}){return a.codeblock(r=>{this.writeMethodInvocation({writer:r,endpoint:t,snippet:e}),r.writeLine(),r.writeLine(),r.write("ok, countErr := "),r.writeNode(a.invokeMethod({on:a.codeblock(ti),method:"Verify",arguments_:[a.invokeMethod({on:a.codeblock("stub"),method:"Request",arguments_:[],multiline:!1}),a.codeblock("1")],multiline:!1})),r.writeLine(),r.writeNode(a.invokeFunc({func:a.typeReference({name:"NoError",importPath:"github.com/stretchr/testify/require"}),arguments_:[a.codeblock("t"),a.codeblock("countErr"),a.TypeInstantiation.string("Failed to verify WireMock request was matched")],multiline:!1})),r.writeLine(),r.writeNode(a.invokeFunc({func:a.typeReference({name:"True",importPath:"github.com/stretchr/testify/require"}),arguments_:[a.codeblock("t"),a.codeblock("ok"),a.TypeInstantiation.string("WireMock request was not matched")],multiline:!1})),r.writeLine()})}};var He=class extends ge{constructor({ir:e,config:r,formatter:i}){super(new Ye({ir:e,config:r}));u(this,"formatter");this.formatter=i}async generate(e,r){return super.generate(e,r)}generateSync(e,r){return super.generateSync(e,r)}async generateSnippetAst(e){return super.generateSnippetAst(e)}createSnippetGenerator(e){return new je({context:e,formatter:this.formatter})}};0&&(module.exports={DynamicSnippetsGenerator});
27
27
  /*! Bundled license information:
28
28
 
29
29
  @esbuild-plugins/node-globals-polyfill/Buffer.js: