@fern-api/go-dynamic-snippets 0.0.17 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/DynamicSnippetsGenerator.cjs +6 -6
- package/cjs/DynamicSnippetsGenerator.cjs.map +1 -1
- package/cjs/DynamicSnippetsGenerator.d.cts +3 -2
- package/cjs/{DynamicSnippetsGeneratorContext-D8VcLYKk.d.cts → DynamicSnippetsGeneratorContext-X0Mtg6YW.d.cts} +1 -0
- package/cjs/EndpointSnippetGenerator.cjs +4 -4
- package/cjs/EndpointSnippetGenerator.cjs.map +1 -1
- package/cjs/EndpointSnippetGenerator.d.cts +7 -2
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs +8 -8
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs.map +1 -1
- package/cjs/context/DynamicSnippetsGeneratorContext.d.cts +1 -1
- package/cjs/context/DynamicTypeInstantiationMapper.cjs +1 -1
- package/cjs/context/DynamicTypeInstantiationMapper.cjs.map +1 -1
- package/cjs/context/DynamicTypeInstantiationMapper.d.cts +1 -1
- package/cjs/context/DynamicTypeMapper.cjs +4 -4
- package/cjs/context/DynamicTypeMapper.cjs.map +1 -1
- package/cjs/context/DynamicTypeMapper.d.cts +1 -1
- package/cjs/context/FilePropertyMapper.cjs +7 -7
- package/cjs/context/FilePropertyMapper.cjs.map +1 -1
- package/cjs/context/FilePropertyMapper.d.cts +1 -1
- package/cjs/index.cjs +6 -6
- package/cjs/index.cjs.map +1 -1
- package/cjs/index.d.cts +1 -1
- package/esm/DynamicSnippetsGenerator.d.ts +3 -2
- package/esm/DynamicSnippetsGenerator.js +1 -1
- package/esm/{DynamicSnippetsGeneratorContext-D8VcLYKk.d.ts → DynamicSnippetsGeneratorContext-X0Mtg6YW.d.ts} +1 -0
- package/esm/EndpointSnippetGenerator.d.ts +7 -2
- package/esm/EndpointSnippetGenerator.js +1 -1
- package/esm/{chunk-ZNTXZ3YV.js → chunk-5X6DU53C.js} +2 -2
- package/esm/chunk-EUHLPBOB.js +2 -0
- package/esm/chunk-EUHLPBOB.js.map +1 -0
- package/esm/chunk-FVPD7ODP.js +2 -0
- package/esm/chunk-FVPD7ODP.js.map +1 -0
- package/esm/chunk-KGXOPYBU.js +2 -0
- package/esm/chunk-KGXOPYBU.js.map +1 -0
- package/esm/chunk-NY6N4HP7.js +2 -0
- package/esm/chunk-NY6N4HP7.js.map +1 -0
- package/esm/chunk-S5R5YTLQ.js +2 -0
- package/esm/chunk-S5R5YTLQ.js.map +1 -0
- package/esm/chunk-T2DJJZPN.js +2 -0
- package/esm/chunk-T2DJJZPN.js.map +1 -0
- package/esm/{chunk-JHIUGKJ4.js → chunk-VY2BNRW5.js} +9 -9
- package/esm/chunk-VY2BNRW5.js.map +1 -0
- package/esm/context/DynamicSnippetsGeneratorContext.d.ts +1 -1
- package/esm/context/DynamicSnippetsGeneratorContext.js +1 -1
- package/esm/context/DynamicTypeInstantiationMapper.d.ts +1 -1
- package/esm/context/DynamicTypeInstantiationMapper.js +1 -1
- package/esm/context/DynamicTypeMapper.d.ts +1 -1
- package/esm/context/DynamicTypeMapper.js +1 -1
- package/esm/context/FilePropertyMapper.d.ts +1 -1
- package/esm/context/FilePropertyMapper.js +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/package.json +1 -1
- package/esm/chunk-ADZ6FCNI.js +0 -2
- package/esm/chunk-ADZ6FCNI.js.map +0 -1
- package/esm/chunk-FTDA4363.js +0 -2
- package/esm/chunk-FTDA4363.js.map +0 -1
- package/esm/chunk-GDQPUUAY.js +0 -2
- package/esm/chunk-GDQPUUAY.js.map +0 -1
- package/esm/chunk-JHIUGKJ4.js.map +0 -1
- package/esm/chunk-PZ73VBNX.js +0 -2
- package/esm/chunk-PZ73VBNX.js.map +0 -1
- package/esm/chunk-SVPRIX53.js +0 -2
- package/esm/chunk-SVPRIX53.js.map +0 -1
- package/esm/chunk-VTPICU2V.js +0 -2
- package/esm/chunk-VTPICU2V.js.map +0 -1
- /package/esm/{chunk-ZNTXZ3YV.js.map → chunk-5X6DU53C.js.map} +0 -0
|
@@ -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 {
|
|
4
|
-
import '
|
|
3
|
+
import { go } from '@fern-api/go-ast';
|
|
4
|
+
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-X0Mtg6YW.cjs';
|
|
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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var Ie=Object.defineProperty,Vt=Object.defineProperties,Ot=Object.getOwnPropertyDescriptor,Gt=Object.getOwnPropertyDescriptors,Yt=Object.getOwnPropertyNames,Te=Object.getOwnPropertySymbols;var Ve=Object.prototype.hasOwnProperty,Qe=Object.prototype.propertyIsEnumerable;var $e=(n,t,e)=>t in n?Ie(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,et=(n,t)=>{for(var e in t||(t={}))Ve.call(t,e)&&$e(n,e,t[e]);if(Te)for(var e of Te(t))Qe.call(t,e)&&$e(n,e,t[e]);return n},tt=(n,t)=>Vt(n,Gt(t));var rt=n=>typeof n=="symbol"?n:n+"",nt=(n,t)=>{var e={};for(var r in n)Ve.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&Te)for(var r of Te(n))t.indexOf(r)<0&&Qe.call(n,r)&&(e[r]=n[r]);return e};var Re=(n,t)=>()=>(n&&(t=n(n=0)),t);var it=(n,t)=>{for(var e in t)Ie(n,e,{get:t[e],enumerable:!0})},jt=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Yt(t))!Ve.call(n,i)&&i!==e&&Ie(n,i,{get:()=>t[i],enumerable:!(r=Ot(t,i))||r.enumerable});return n};var Wt=n=>jt(Ie({},"__esModule",{value:!0}),n);var c=(n,t,e)=>$e(n,typeof t!="symbol"?t+"":t,e);function st(){throw new Error("setTimeout has not been defined")}function at(){throw new Error("clearTimeout has not been defined")}function ct(n){if(G===setTimeout)return setTimeout(n,0);if((G===st||!G)&&setTimeout)return G=setTimeout,setTimeout(n,0);try{return G(n,0)}catch(t){try{return G.call(null,n,0)}catch(e){return G.call(this,n,0)}}}function zt(n){if(Y===clearTimeout)return clearTimeout(n);if((Y===at||!Y)&&clearTimeout)return Y=clearTimeout,clearTimeout(n);try{return Y(n)}catch(t){try{return Y.call(null,n)}catch(e){return Y.call(this,n)}}}function Ht(){!se||!j||(se=!1,j.length?B=j.concat(B):Ne=-1,B.length&&ut())}function ut(){if(!se){var n=ct(Ht);se=!0;for(var t=B.length;t;){for(j=B,B=[];++Ne<t;)j&&j[Ne].run();Ne=-1,t=B.length}j=null,se=!1,zt(n)}}function qt(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];B.push(new pt(n,t)),B.length===1&&!se&&ct(ut)}function pt(n,t){this.fun=n,this.array=t}function W(){}function lr(n){throw new Error("process.binding is not supported")}function fr(){return"/"}function hr(n){throw new Error("process.chdir is not supported")}function mr(){return 0}function yr(n){var t=dr.call(oe)*.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 wr(){var n=new Date,t=n-gr;return t/1e3}var G,Y,B,se,j,Ne,Jt,Xt,Kt,Zt,Qt,er,tr,rr,nr,ir,or,sr,ar,cr,ur,pr,oe,dr,gr,m,ot,p=Re(()=>{"use strict";G=st,Y=at;typeof globalThis.setTimeout=="function"&&(G=setTimeout);typeof globalThis.clearTimeout=="function"&&(Y=clearTimeout);B=[],se=!1,Ne=-1;pt.prototype.run=function(){this.fun.apply(null,this.array)};Jt="browser",Xt="browser",Kt=!0,Zt={},Qt=[],er="",tr={},rr={},nr={};ir=W,or=W,sr=W,ar=W,cr=W,ur=W,pr=W;oe=globalThis.performance||{},dr=oe.now||oe.mozNow||oe.msNow||oe.oNow||oe.webkitNow||function(){return new Date().getTime()};gr=new Date;m={nextTick:qt,title:Jt,browser:Kt,env:Zt,argv:Qt,version:er,versions:tr,on:ir,addListener:or,once:sr,off:ar,removeListener:cr,removeAllListeners:ur,emit:pr,binding:lr,cwd:fr,chdir:hr,umask:mr,hrtime:yr,platform:Xt,release:rr,config:nr,uptime:wr},ot={};Object.keys(ot).forEach(n=>{let t=n.split("."),e=m;for(let r=0;r<t.length;r++){let i=t[r];r===t.length-1?e[i]=ot[n]:e=e[i]||(e[i]={})}})});function mt(){Ge=!0;for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=n.length;t<e;++t)k[t]=n[t],F[n.charCodeAt(t)]=t;F[45]=62,F[95]=63}function vr(n){Ge||mt();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 xr(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=F[n.charCodeAt(t)]<<18|F[n.charCodeAt(t+1)]<<12|F[n.charCodeAt(t+2)]<<6|F[n.charCodeAt(t+3)],s[h++]=i>>16&255,s[h++]=i>>8&255,s[h++]=i&255;return o===2?(i=F[n.charCodeAt(t)]<<2|F[n.charCodeAt(t+1)]>>4,s[h++]=i&255):o===1&&(i=F[n.charCodeAt(t)]<<10|F[n.charCodeAt(t+1)]<<4|F[n.charCodeAt(t+2)]>>2,s[h++]=i>>8&255,s[h++]=i&255),s}function Tr(n){return k[n>>18&63]+k[n>>12&63]+k[n>>6&63]+k[n&63]}function Ir(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(Tr(r));return i.join("")}function lt(n){Ge||mt();for(var t,e=n.length,r=e%3,i="",o=[],s=16383,f=0,h=e-r;f<h;f+=s)o.push(Ir(n,f,f+s>h?h:f+s));return r===1?(t=n[e-1],i+=k[t>>2],i+=k[t<<4&63],i+="=="):r===2&&(t=(n[e-2]<<8)+n[e-1],i+=k[t>>10],i+=k[t>>4&63],i+=k[t<<2&63],i+="="),o.push(i),o.join("")}function Ee(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function M(n,t){if(Ee()<t)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(n=new Uint8Array(t),n.__proto__=a.prototype):(n===null&&(n=new a(t)),n.length=t),n}function a(n,t,e){if(!a.TYPED_ARRAY_SUPPORT&&!(this instanceof a))return new a(n,t,e);if(typeof n=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return Ye(this,n)}return dt(this,n,t,e)}function dt(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?Er(n,t,e,r):typeof t=="string"?Nr(n,t,e):Ar(n,t)}function yt(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 Rr(n,t,e,r){return yt(t),t<=0?M(n,t):e!==void 0?typeof r=="string"?M(n,t).fill(e,r):M(n,t).fill(e):M(n,t)}function Ye(n,t){if(yt(t),n=M(n,t<0?0:je(t)|0),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)n[e]=0;return n}function Nr(n,t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!a.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var r=gt(t,e)|0;n=M(n,r);var i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Oe(n,t){var e=t.length<0?0:je(t.length)|0;n=M(n,e);for(var r=0;r<e;r+=1)n[r]=t[r]&255;return n}function Er(n,t,e,r){if(t.byteLength,e<0||t.byteLength<e)throw new RangeError("'offset' is out of bounds");if(t.byteLength<e+(r||0))throw new RangeError("'length' is out of bounds");return e===void 0&&r===void 0?t=new Uint8Array(t):r===void 0?t=new Uint8Array(t,e):t=new Uint8Array(t,e,r),a.TYPED_ARRAY_SUPPORT?(n=t,n.__proto__=a.prototype):n=Oe(n,t),n}function Ar(n,t){if(U(t)){var e=je(t.length)|0;return n=M(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"||Wr(t.length)?M(n,0):Oe(n,t);if(t.type==="Buffer"&&Array.isArray(t.data))return Oe(n,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function je(n){if(n>=Ee())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ee().toString(16)+" bytes");return n|0}function U(n){return!!(n!=null&&n._isBuffer)}function gt(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 Ae(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Nt(n).length;default:if(r)return Ae(n).length;t=(""+t).toLowerCase(),r=!0}}function br(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 Mr(this,t,e);case"utf8":case"utf-8":return vt(this,t,e);case"ascii":return _r(this,t,e);case"latin1":case"binary":return Br(this,t,e);case"base64":return Lr(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Dr(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 wt(n,t,e,r,i){if(n.length===0)return-1;if(typeof e=="string"?(r=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(i)return-1;e=n.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,r)),U(t))return t.length===0?-1:ft(n,t,e,r,i);if(typeof t=="number")return t=t&255,a.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):ft(n,[t],e,r,i);throw new TypeError("val must be string, number or Buffer")}function ft(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,_){return o===1?I[_]:I.readUInt16BE(_*o)}var d;if(i){var y=-1;for(d=e;d<s;d++)if(h(n,d)===h(t,y===-1?0:d-y)){if(y===-1&&(y=d),d-y+1===f)return y*o}else y!==-1&&(d-=d-y),y=-1}else for(e+f>s&&(e=s-f),d=e;d>=0;d--){for(var g=!0,T=0;T<f;T++)if(h(n,d+T)!==h(t,T)){g=!1;break}if(g)return d}return-1}function Fr(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 Pr(n,t,e,r){return Pe(Ae(t,n.length-e),n,e,r)}function xt(n,t,e,r){return Pe(Yr(t),n,e,r)}function Sr(n,t,e,r){return xt(n,t,e,r)}function kr(n,t,e,r){return Pe(Nt(t),n,e,r)}function Ur(n,t,e,r){return Pe(jr(t,n.length-e),n,e,r)}function Lr(n,t,e){return t===0&&e===n.length?lt(n):lt(n.slice(t,e))}function vt(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,d,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],d=n[i+2],(h&192)===128&&(d&192)===128&&(g=(o&15)<<12|(h&63)<<6|d&63,g>2047&&(g<55296||g>57343)&&(s=g));break;case 4:h=n[i+1],d=n[i+2],y=n[i+3],(h&192)===128&&(d&192)===128&&(y&192)===128&&(g=(o&15)<<18|(h&63)<<12|(d&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 Cr(r)}function Cr(n){var t=n.length;if(t<=ht)return String.fromCharCode.apply(String,n);for(var e="",r=0;r<t;)e+=String.fromCharCode.apply(String,n.slice(r,r+=ht));return e}function _r(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 Br(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 Mr(n,t,e){var r=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>r)&&(e=r);for(var i="",o=t;o<e;++o)i+=Gr(n[o]);return i}function Dr(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 R(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 be(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 Fe(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 Tt(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 It(n,t,e,r,i){return i||Tt(n,t,e,4,34028234663852886e22,-34028234663852886e22),At(n,t,e,r,23,4),e+4}function Rt(n,t,e,r,i){return i||Tt(n,t,e,8,17976931348623157e292,-17976931348623157e292),At(n,t,e,r,52,8),e+8}function Vr(n){if(n=Or(n).replace($r,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function Or(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")}function Gr(n){return n<16?"0"+n.toString(16):n.toString(16)}function Ae(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 Yr(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function jr(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 Nt(n){return vr(Vr(n))}function Pe(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 Wr(n){return n!==n}function zr(n){return n!=null&&(!!n._isBuffer||Et(n)||Hr(n))}function Et(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function Hr(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&Et(n.slice(0,0))}function Se(n,t,e,r,i){var o,s,f=i*8-r-1,h=(1<<f)-1,d=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-d;else{if(o===h)return s?NaN:(I?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-d}return(I?-1:1)*s*Math.pow(2,o-r)}function At(n,t,e,r,i,o){var s,f,h,d=o*8-i-1,y=(1<<d)-1,g=y>>1,T=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=r?0:o-1,_=r?1:-1,ve=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+=_,f/=256,i-=8);for(s=s<<i|f,d+=i;d>0;n[e+I]=s&255,I+=_,s/=256,d-=8);n[e+I-_]|=ve*128}var k,F,xr,Ge,ht,$r,bt=Re(()=>{"use strict";p();l();k=[],F=[],xr=typeof Uint8Array!="undefined"?Uint8Array:Array,Ge=!1;a.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;a.poolSize=8192;a._augment=function(n){return n.__proto__=a.prototype,n};a.from=function(n,t,e){return dt(null,n,t,e)};a.kMaxLength=Ee();a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&a[Symbol.species]);a.alloc=function(n,t,e){return Rr(null,n,t,e)};a.allocUnsafe=function(n){return Ye(null,n)};a.allocUnsafeSlow=function(n){return Ye(null,n)};a.isBuffer=zr;a.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};a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var r;if(e===void 0)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var i=a.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(!U(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i};a.byteLength=gt;a.prototype._isBuffer=!0;a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)z(this,e,e+1);return this};a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)z(this,e,e+3),z(this,e+1,e+2);return this};a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)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};a.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?vt(this,0,t):br.apply(this,arguments)};a.prototype.equals=function(t){if(!U(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0};a.prototype.compare=function(t,e,r,i,o){if(!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),d=this.slice(i,o),y=t.slice(e,r),g=0;g<h;++g)if(d[g]!==y[g]){s=d[g],f=y[g];break}return s<f?-1:f<s?1:0};a.prototype.includes=function(t,e,r){return this.indexOf(t,e,r)!==-1};a.prototype.indexOf=function(t,e,r){return wt(this,t,e,r,!0)};a.prototype.lastIndexOf=function(t,e,r){return wt(this,t,e,r,!1)};a.prototype.write=function(t,e,r,i){if(e===void 0)i="utf8",r=this.length,e=0;else if(r===void 0&&typeof e=="string")i=e,r=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(r)?(r=r|0,i===void 0&&(i="utf8")):(i=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var o=this.length-e;if((r===void 0||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return Fr(this,t,e,r);case"utf8":case"utf-8":return Pr(this,t,e,r);case"ascii":return xt(this,t,e,r);case"latin1":case"binary":return Sr(this,t,e,r);case"base64":return kr(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ur(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};ht=4096;a.prototype.slice=function(t,e){var r=this.length;t=~~t,e=e===void 0?r:~~e,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),e<t&&(e=t);var i;if(a.TYPED_ARRAY_SUPPORT)i=this.subarray(t,e),i.__proto__=a.prototype;else{var o=e-t;i=new a(o,void 0);for(var s=0;s<o;++s)i[s]=this[s+t]}return i};a.prototype.readUIntLE=function(t,e,r){t=t|0,e=e|0,r||R(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return i};a.prototype.readUIntBE=function(t,e,r){t=t|0,e=e|0,r||R(t,e,this.length);for(var i=this[t+--e],o=1;e>0&&(o*=256);)i+=this[t+--e]*o;return i};a.prototype.readUInt8=function(t,e){return e||R(t,1,this.length),this[t]};a.prototype.readUInt16LE=function(t,e){return e||R(t,2,this.length),this[t]|this[t+1]<<8};a.prototype.readUInt16BE=function(t,e){return e||R(t,2,this.length),this[t]<<8|this[t+1]};a.prototype.readUInt32LE=function(t,e){return e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};a.prototype.readUInt32BE=function(t,e){return e||R(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};a.prototype.readIntLE=function(t,e,r){t=t|0,e=e|0,r||R(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i};a.prototype.readIntBE=function(t,e,r){t=t|0,e=e|0,r||R(t,e,this.length);for(var i=e,o=1,s=this[t+--i];i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*e)),s};a.prototype.readInt8=function(t,e){return e||R(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};a.prototype.readInt16LE=function(t,e){e||R(t,2,this.length);var r=this[t]|this[t+1]<<8;return r&32768?r|4294901760:r};a.prototype.readInt16BE=function(t,e){e||R(t,2,this.length);var r=this[t+1]|this[t]<<8;return r&32768?r|4294901760:r};a.prototype.readInt32LE=function(t,e){return e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};a.prototype.readInt32BE=function(t,e){return e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};a.prototype.readFloatLE=function(t,e){return e||R(t,4,this.length),Se(this,t,!0,23,4)};a.prototype.readFloatBE=function(t,e){return e||R(t,4,this.length),Se(this,t,!1,23,4)};a.prototype.readDoubleLE=function(t,e){return e||R(t,8,this.length),Se(this,t,!0,52,8)};a.prototype.readDoubleBE=function(t,e){return e||R(t,8,this.length),Se(this,t,!1,52,8)};a.prototype.writeUIntLE=function(t,e,r,i){if(t=+t,e=e|0,r=r|0,!i){var o=Math.pow(2,8*r)-1;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};a.prototype.writeUIntBE=function(t,e,r,i){if(t=+t,e=e|0,r=r|0,!i){var o=Math.pow(2,8*r)-1;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};a.prototype.writeUInt8=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t&255,e+1};a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):be(this,t,e,!0),e+2};a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):be(this,t,e,!1),e+2};a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255):Fe(this,t,e,!0),e+4};a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):Fe(this,t,e,!1),e+4};a.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*r-1);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};a.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};a.prototype.writeInt8=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=t&255,e+1};a.prototype.writeInt16LE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):be(this,t,e,!0),e+2};a.prototype.writeInt16BE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):be(this,t,e,!1),e+2};a.prototype.writeInt32LE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):Fe(this,t,e,!0),e+4};a.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),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):Fe(this,t,e,!1),e+4};a.prototype.writeFloatLE=function(t,e,r){return It(this,t,e,!0,r)};a.prototype.writeFloatBE=function(t,e,r){return It(this,t,e,!1,r)};a.prototype.writeDoubleLE=function(t,e,r){return Rt(this,t,e,!0,r)};a.prototype.writeDoubleBE=function(t,e,r){return Rt(this,t,e,!1,r)};a.prototype.copy=function(t,e,r,i){if(r||(r=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===r||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);var o=i-r,s;if(this===t&&r<e&&e<i)for(s=o-1;s>=0;--s)t[s+e]=this[s+r];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(s=0;s<o;++s)t[s+e]=this[s+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o};a.prototype.fill=function(t,e,r,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,r=this.length):typeof r=="string"&&(i=r,r=this.length),t.length===1){var o=t.charCodeAt(0);o<256&&(t=o)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!a.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof t=="number"&&(t=t&255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;e=e>>>0,r=r===void 0?this.length:r>>>0,t||(t=0);var s;if(typeof t=="number")for(s=e;s<r;++s)this[s]=t;else{var f=U(t)?t:Ae(new a(t,i).toString()),h=f.length;for(s=0;s<r-e;++s)this[s+e]=f[s%h]}return this};$r=/[^+\/0-9A-Za-z-_]/g});var l=Re(()=>{"use strict";bt()});function Ut(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 He(){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=Ut(Je(n.split("/"),function(i){return!!i}),!t).join("/"),(t?"/":"")+n||"."}function Lt(n){var t=Ct(n),e=cn(n,-1)==="/";return n=Ut(Je(n.split("/"),function(r){return!!r}),!t).join("/"),!n&&!t&&(n="."),n&&e&&(n+="/"),(t?"/":"")+n}function Ct(n){return n.charAt(0)==="/"}function en(){var n=Array.prototype.slice.call(arguments,0);return Lt(Je(n,function(t,e){if(typeof t!="string")throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function tn(n,t){n=He(n).substr(1),t=He(t).substr(1);function e(d){for(var y=0;y<d.length&&d[y]==="";y++);for(var g=d.length-1;g>=0&&d[g]==="";g--);return y>g?[]:d.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 on(n){var t=qe(n),e=t[0],r=t[1];return!e&&!r?".":(r&&(r=r.substr(0,r.length-1)),e+r)}function sn(n,t){var e=qe(n)[2];return t&&e.substr(-1*t.length)===t&&(e=e.substr(0,e.length-t.length)),e}function an(n){return qe(n)[3]}function Je(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 Qr,qe,rn,nn,_t,cn,Bt=Re(()=>{"use strict";p();l();Qr=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,qe=function(n){return Qr.exec(n).slice(1)};rn="/",nn=":";_t={extname:an,basename:sn,dirname:on,sep:rn,delimiter:nn,relative:tn,join:en,isAbsolute:Ct,normalize:Lt,resolve:He};cn="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 jn={};it(jn,{DynamicSnippetsGeneratorContext:()=>Ze});module.exports=Wt(jn);p();l();p();l();p();l();function x(n){throw new Error("Unexpected value: "+JSON.stringify(n))}p();l();function ce(n){return Object.keys(n)}p();l();p();l();p();l();var Ft,Pt,ue=(Pt=(Ft=m.env.FERN_STACK_TRACK)==null?void 0:Ft.toLowerCase())!=null?Pt:"",L=ue!==""&&ue!=="0"&&ue!=="false",We=["single","multiline","box"].includes(ue)?ue:"single";L&&(Error.stackTraceLimit=50);var qr=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),Jr=new Set(["stacktrace"]);function Ue({maxFrames:n=50,skip:t=0,filterPaths:e=[],filterFunctions:r=[],stopOn:i=[],filterNode:o=!0,filterJs:s=!0,formatFilename:f=h=>h}={}){var d;if(!L)return[];r=[...r,...qr],e=[...e,...Jr],i=[...i,"runInteractiveTask"];let h=!1;return((d=new Error().stack)!=null?d:"").split(`
|
|
2
|
-
`).map(y=>{let g=y.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(g&&g.length===5){let[,T,I,_,ve]=g;if(!T||!I||!_||!ve)return;if(h||i.some(
|
|
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}},D;function
|
|
1
|
+
"use strict";var Ie=Object.defineProperty,Ot=Object.defineProperties,Gt=Object.getOwnPropertyDescriptor,Yt=Object.getOwnPropertyDescriptors,jt=Object.getOwnPropertyNames,Te=Object.getOwnPropertySymbols;var Ve=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable;var $e=(n,t,e)=>t in n?Ie(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,tt=(n,t)=>{for(var e in t||(t={}))Ve.call(t,e)&&$e(n,e,t[e]);if(Te)for(var e of Te(t))et.call(t,e)&&$e(n,e,t[e]);return n},rt=(n,t)=>Ot(n,Yt(t));var nt=n=>typeof n=="symbol"?n:n+"",it=(n,t)=>{var e={};for(var r in n)Ve.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&Te)for(var r of Te(n))t.indexOf(r)<0&&et.call(n,r)&&(e[r]=n[r]);return e};var Re=(n,t)=>()=>(n&&(t=n(n=0)),t);var ot=(n,t)=>{for(var e in t)Ie(n,e,{get:t[e],enumerable:!0})},Wt=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of jt(t))!Ve.call(n,i)&&i!==e&&Ie(n,i,{get:()=>t[i],enumerable:!(r=Gt(t,i))||r.enumerable});return n};var zt=n=>Wt(Ie({},"__esModule",{value:!0}),n);var c=(n,t,e)=>$e(n,typeof t!="symbol"?t+"":t,e);function at(){throw new Error("setTimeout has not been defined")}function ct(){throw new Error("clearTimeout has not been defined")}function ut(n){if(G===setTimeout)return setTimeout(n,0);if((G===at||!G)&&setTimeout)return G=setTimeout,setTimeout(n,0);try{return G(n,0)}catch(t){try{return G.call(null,n,0)}catch(e){return G.call(this,n,0)}}}function Ht(n){if(Y===clearTimeout)return clearTimeout(n);if((Y===ct||!Y)&&clearTimeout)return Y=clearTimeout,clearTimeout(n);try{return Y(n)}catch(t){try{return Y.call(null,n)}catch(e){return Y.call(this,n)}}}function qt(){!se||!j||(se=!1,j.length?B=j.concat(B):Ne=-1,B.length&&pt())}function pt(){if(!se){var n=ut(qt);se=!0;for(var t=B.length;t;){for(j=B,B=[];++Ne<t;)j&&j[Ne].run();Ne=-1,t=B.length}j=null,se=!1,Ht(n)}}function Jt(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];B.push(new lt(n,t)),B.length===1&&!se&&ut(pt)}function lt(n,t){this.fun=n,this.array=t}function W(){}function fr(n){throw new Error("process.binding is not supported")}function hr(){return"/"}function mr(n){throw new Error("process.chdir is not supported")}function dr(){return 0}function gr(n){var t=yr.call(oe)*.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 xr(){var n=new Date,t=n-wr;return t/1e3}var G,Y,B,se,j,Ne,Xt,Kt,Zt,Qt,er,tr,rr,nr,ir,or,sr,ar,cr,ur,pr,lr,oe,yr,wr,m,st,u=Re(()=>{"use strict";G=at,Y=ct;typeof globalThis.setTimeout=="function"&&(G=setTimeout);typeof globalThis.clearTimeout=="function"&&(Y=clearTimeout);B=[],se=!1,Ne=-1;lt.prototype.run=function(){this.fun.apply(null,this.array)};Xt="browser",Kt="browser",Zt=!0,Qt={},er=[],tr="",rr={},nr={},ir={};or=W,sr=W,ar=W,cr=W,ur=W,pr=W,lr=W;oe=globalThis.performance||{},yr=oe.now||oe.mozNow||oe.msNow||oe.oNow||oe.webkitNow||function(){return new Date().getTime()};wr=new Date;m={nextTick:Jt,title:Xt,browser:Zt,env:Qt,argv:er,version:tr,versions:rr,on:or,addListener:sr,once:ar,off:cr,removeListener:ur,removeAllListeners:pr,emit:lr,binding:fr,cwd:hr,chdir:mr,umask:dr,hrtime:gr,platform:Kt,release:nr,config:ir,uptime:xr},st={};Object.keys(st).forEach(n=>{let t=n.split("."),e=m;for(let r=0;r<t.length;r++){let i=t[r];r===t.length-1?e[i]=st[n]:e=e[i]||(e[i]={})}})});function dt(){Ge=!0;for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=n.length;t<e;++t)k[t]=n[t],F[n.charCodeAt(t)]=t;F[45]=62,F[95]=63}function Tr(n){Ge||dt();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 vr(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=F[n.charCodeAt(t)]<<18|F[n.charCodeAt(t+1)]<<12|F[n.charCodeAt(t+2)]<<6|F[n.charCodeAt(t+3)],s[h++]=i>>16&255,s[h++]=i>>8&255,s[h++]=i&255;return o===2?(i=F[n.charCodeAt(t)]<<2|F[n.charCodeAt(t+1)]>>4,s[h++]=i&255):o===1&&(i=F[n.charCodeAt(t)]<<10|F[n.charCodeAt(t+1)]<<4|F[n.charCodeAt(t+2)]>>2,s[h++]=i>>8&255,s[h++]=i&255),s}function Ir(n){return k[n>>18&63]+k[n>>12&63]+k[n>>6&63]+k[n&63]}function Rr(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(Ir(r));return i.join("")}function ft(n){Ge||dt();for(var t,e=n.length,r=e%3,i="",o=[],s=16383,f=0,h=e-r;f<h;f+=s)o.push(Rr(n,f,f+s>h?h:f+s));return r===1?(t=n[e-1],i+=k[t>>2],i+=k[t<<4&63],i+="=="):r===2&&(t=(n[e-2]<<8)+n[e-1],i+=k[t>>10],i+=k[t>>4&63],i+=k[t<<2&63],i+="="),o.push(i),o.join("")}function Ee(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function M(n,t){if(Ee()<t)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(n=new Uint8Array(t),n.__proto__=a.prototype):(n===null&&(n=new a(t)),n.length=t),n}function a(n,t,e){if(!a.TYPED_ARRAY_SUPPORT&&!(this instanceof a))return new a(n,t,e);if(typeof n=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return Ye(this,n)}return yt(this,n,t,e)}function yt(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?Ar(n,t,e,r):typeof t=="string"?Er(n,t,e):br(n,t)}function gt(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 Nr(n,t,e,r){return gt(t),t<=0?M(n,t):e!==void 0?typeof r=="string"?M(n,t).fill(e,r):M(n,t).fill(e):M(n,t)}function Ye(n,t){if(gt(t),n=M(n,t<0?0:je(t)|0),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)n[e]=0;return n}function Er(n,t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!a.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var r=wt(t,e)|0;n=M(n,r);var i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Oe(n,t){var e=t.length<0?0:je(t.length)|0;n=M(n,e);for(var r=0;r<e;r+=1)n[r]=t[r]&255;return n}function Ar(n,t,e,r){if(t.byteLength,e<0||t.byteLength<e)throw new RangeError("'offset' is out of bounds");if(t.byteLength<e+(r||0))throw new RangeError("'length' is out of bounds");return e===void 0&&r===void 0?t=new Uint8Array(t):r===void 0?t=new Uint8Array(t,e):t=new Uint8Array(t,e,r),a.TYPED_ARRAY_SUPPORT?(n=t,n.__proto__=a.prototype):n=Oe(n,t),n}function br(n,t){if(U(t)){var e=je(t.length)|0;return n=M(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"||zr(t.length)?M(n,0):Oe(n,t);if(t.type==="Buffer"&&Array.isArray(t.data))return Oe(n,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function je(n){if(n>=Ee())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ee().toString(16)+" bytes");return n|0}function U(n){return!!(n!=null&&n._isBuffer)}function wt(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 Ae(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Et(n).length;default:if(r)return Ae(n).length;t=(""+t).toLowerCase(),r=!0}}function Fr(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 Dr(this,t,e);case"utf8":case"utf-8":return Tt(this,t,e);case"ascii":return Br(this,t,e);case"latin1":case"binary":return Mr(this,t,e);case"base64":return Cr(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $r(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 xt(n,t,e,r,i){if(n.length===0)return-1;if(typeof e=="string"?(r=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(i)return-1;e=n.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,r)),U(t))return t.length===0?-1:ht(n,t,e,r,i);if(typeof t=="number")return t=t&255,a.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):ht(n,[t],e,r,i);throw new TypeError("val must be string, number or Buffer")}function ht(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,_){return o===1?I[_]:I.readUInt16BE(_*o)}var d;if(i){var y=-1;for(d=e;d<s;d++)if(h(n,d)===h(t,y===-1?0:d-y)){if(y===-1&&(y=d),d-y+1===f)return y*o}else y!==-1&&(d-=d-y),y=-1}else for(e+f>s&&(e=s-f),d=e;d>=0;d--){for(var g=!0,T=0;T<f;T++)if(h(n,d+T)!==h(t,T)){g=!1;break}if(g)return d}return-1}function Sr(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 Pr(n,t,e,r){return Se(Ae(t,n.length-e),n,e,r)}function vt(n,t,e,r){return Se(jr(t),n,e,r)}function kr(n,t,e,r){return vt(n,t,e,r)}function Ur(n,t,e,r){return Se(Et(t),n,e,r)}function Lr(n,t,e,r){return Se(Wr(t,n.length-e),n,e,r)}function Cr(n,t,e){return t===0&&e===n.length?ft(n):ft(n.slice(t,e))}function Tt(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,d,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],d=n[i+2],(h&192)===128&&(d&192)===128&&(g=(o&15)<<12|(h&63)<<6|d&63,g>2047&&(g<55296||g>57343)&&(s=g));break;case 4:h=n[i+1],d=n[i+2],y=n[i+3],(h&192)===128&&(d&192)===128&&(y&192)===128&&(g=(o&15)<<18|(h&63)<<12|(d&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 _r(r)}function _r(n){var t=n.length;if(t<=mt)return String.fromCharCode.apply(String,n);for(var e="",r=0;r<t;)e+=String.fromCharCode.apply(String,n.slice(r,r+=mt));return e}function Br(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 Mr(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 Dr(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+=Yr(n[o]);return i}function $r(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 R(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 be(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 Fe(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 It(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 Rt(n,t,e,r,i){return i||It(n,t,e,4,34028234663852886e22,-34028234663852886e22),bt(n,t,e,r,23,4),e+4}function Nt(n,t,e,r,i){return i||It(n,t,e,8,17976931348623157e292,-17976931348623157e292),bt(n,t,e,r,52,8),e+8}function Or(n){if(n=Gr(n).replace(Vr,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function Gr(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")}function Yr(n){return n<16?"0"+n.toString(16):n.toString(16)}function Ae(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 jr(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function Wr(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 Et(n){return Tr(Or(n))}function Se(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 zr(n){return n!==n}function Hr(n){return n!=null&&(!!n._isBuffer||At(n)||qr(n))}function At(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function qr(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&At(n.slice(0,0))}function Pe(n,t,e,r,i){var o,s,f=i*8-r-1,h=(1<<f)-1,d=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-d;else{if(o===h)return s?NaN:(I?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-d}return(I?-1:1)*s*Math.pow(2,o-r)}function bt(n,t,e,r,i,o){var s,f,h,d=o*8-i-1,y=(1<<d)-1,g=y>>1,T=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=r?0:o-1,_=r?1:-1,ve=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+=_,f/=256,i-=8);for(s=s<<i|f,d+=i;d>0;n[e+I]=s&255,I+=_,s/=256,d-=8);n[e+I-_]|=ve*128}var k,F,vr,Ge,mt,Vr,Ft=Re(()=>{"use strict";u();p();k=[],F=[],vr=typeof Uint8Array!="undefined"?Uint8Array:Array,Ge=!1;a.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;a.poolSize=8192;a._augment=function(n){return n.__proto__=a.prototype,n};a.from=function(n,t,e){return yt(null,n,t,e)};a.kMaxLength=Ee();a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&a[Symbol.species]);a.alloc=function(n,t,e){return Nr(null,n,t,e)};a.allocUnsafe=function(n){return Ye(null,n)};a.allocUnsafeSlow=function(n){return Ye(null,n)};a.isBuffer=Hr;a.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};a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var r;if(e===void 0)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var i=a.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(!U(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i};a.byteLength=wt;a.prototype._isBuffer=!0;a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)z(this,e,e+1);return this};a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)z(this,e,e+3),z(this,e+1,e+2);return this};a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)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};a.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?Tt(this,0,t):Fr.apply(this,arguments)};a.prototype.equals=function(t){if(!U(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0};a.prototype.compare=function(t,e,r,i,o){if(!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),d=this.slice(i,o),y=t.slice(e,r),g=0;g<h;++g)if(d[g]!==y[g]){s=d[g],f=y[g];break}return s<f?-1:f<s?1:0};a.prototype.includes=function(t,e,r){return this.indexOf(t,e,r)!==-1};a.prototype.indexOf=function(t,e,r){return xt(this,t,e,r,!0)};a.prototype.lastIndexOf=function(t,e,r){return xt(this,t,e,r,!1)};a.prototype.write=function(t,e,r,i){if(e===void 0)i="utf8",r=this.length,e=0;else if(r===void 0&&typeof e=="string")i=e,r=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(r)?(r=r|0,i===void 0&&(i="utf8")):(i=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var o=this.length-e;if((r===void 0||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return Sr(this,t,e,r);case"utf8":case"utf-8":return Pr(this,t,e,r);case"ascii":return vt(this,t,e,r);case"latin1":case"binary":return kr(this,t,e,r);case"base64":return Ur(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Lr(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};mt=4096;a.prototype.slice=function(t,e){var r=this.length;t=~~t,e=e===void 0?r:~~e,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),e<t&&(e=t);var i;if(a.TYPED_ARRAY_SUPPORT)i=this.subarray(t,e),i.__proto__=a.prototype;else{var o=e-t;i=new a(o,void 0);for(var s=0;s<o;++s)i[s]=this[s+t]}return i};a.prototype.readUIntLE=function(t,e,r){t=t|0,e=e|0,r||R(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return i};a.prototype.readUIntBE=function(t,e,r){t=t|0,e=e|0,r||R(t,e,this.length);for(var i=this[t+--e],o=1;e>0&&(o*=256);)i+=this[t+--e]*o;return i};a.prototype.readUInt8=function(t,e){return e||R(t,1,this.length),this[t]};a.prototype.readUInt16LE=function(t,e){return e||R(t,2,this.length),this[t]|this[t+1]<<8};a.prototype.readUInt16BE=function(t,e){return e||R(t,2,this.length),this[t]<<8|this[t+1]};a.prototype.readUInt32LE=function(t,e){return e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};a.prototype.readUInt32BE=function(t,e){return e||R(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};a.prototype.readIntLE=function(t,e,r){t=t|0,e=e|0,r||R(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i};a.prototype.readIntBE=function(t,e,r){t=t|0,e=e|0,r||R(t,e,this.length);for(var i=e,o=1,s=this[t+--i];i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*e)),s};a.prototype.readInt8=function(t,e){return e||R(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};a.prototype.readInt16LE=function(t,e){e||R(t,2,this.length);var r=this[t]|this[t+1]<<8;return r&32768?r|4294901760:r};a.prototype.readInt16BE=function(t,e){e||R(t,2,this.length);var r=this[t+1]|this[t]<<8;return r&32768?r|4294901760:r};a.prototype.readInt32LE=function(t,e){return e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};a.prototype.readInt32BE=function(t,e){return e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};a.prototype.readFloatLE=function(t,e){return e||R(t,4,this.length),Pe(this,t,!0,23,4)};a.prototype.readFloatBE=function(t,e){return e||R(t,4,this.length),Pe(this,t,!1,23,4)};a.prototype.readDoubleLE=function(t,e){return e||R(t,8,this.length),Pe(this,t,!0,52,8)};a.prototype.readDoubleBE=function(t,e){return e||R(t,8,this.length),Pe(this,t,!1,52,8)};a.prototype.writeUIntLE=function(t,e,r,i){if(t=+t,e=e|0,r=r|0,!i){var o=Math.pow(2,8*r)-1;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};a.prototype.writeUIntBE=function(t,e,r,i){if(t=+t,e=e|0,r=r|0,!i){var o=Math.pow(2,8*r)-1;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};a.prototype.writeUInt8=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t&255,e+1};a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):be(this,t,e,!0),e+2};a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):be(this,t,e,!1),e+2};a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255):Fe(this,t,e,!0),e+4};a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):Fe(this,t,e,!1),e+4};a.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*r-1);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};a.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};a.prototype.writeInt8=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=t&255,e+1};a.prototype.writeInt16LE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):be(this,t,e,!0),e+2};a.prototype.writeInt16BE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):be(this,t,e,!1),e+2};a.prototype.writeInt32LE=function(t,e,r){return t=+t,e=e|0,r||b(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):Fe(this,t,e,!0),e+4};a.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),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):Fe(this,t,e,!1),e+4};a.prototype.writeFloatLE=function(t,e,r){return Rt(this,t,e,!0,r)};a.prototype.writeFloatBE=function(t,e,r){return Rt(this,t,e,!1,r)};a.prototype.writeDoubleLE=function(t,e,r){return Nt(this,t,e,!0,r)};a.prototype.writeDoubleBE=function(t,e,r){return Nt(this,t,e,!1,r)};a.prototype.copy=function(t,e,r,i){if(r||(r=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===r||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);var o=i-r,s;if(this===t&&r<e&&e<i)for(s=o-1;s>=0;--s)t[s+e]=this[s+r];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(s=0;s<o;++s)t[s+e]=this[s+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o};a.prototype.fill=function(t,e,r,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,r=this.length):typeof r=="string"&&(i=r,r=this.length),t.length===1){var o=t.charCodeAt(0);o<256&&(t=o)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!a.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof t=="number"&&(t=t&255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;e=e>>>0,r=r===void 0?this.length:r>>>0,t||(t=0);var s;if(typeof t=="number")for(s=e;s<r;++s)this[s]=t;else{var f=U(t)?t:Ae(new a(t,i).toString()),h=f.length;for(s=0;s<r-e;++s)this[s+e]=f[s%h]}return this};Vr=/[^+\/0-9A-Za-z-_]/g});var p=Re(()=>{"use strict";Ft()});function Lt(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 He(){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=Lt(Je(n.split("/"),function(i){return!!i}),!t).join("/"),(t?"/":"")+n||"."}function Ct(n){var t=_t(n),e=un(n,-1)==="/";return n=Lt(Je(n.split("/"),function(r){return!!r}),!t).join("/"),!n&&!t&&(n="."),n&&e&&(n+="/"),(t?"/":"")+n}function _t(n){return n.charAt(0)==="/"}function tn(){var n=Array.prototype.slice.call(arguments,0);return Ct(Je(n,function(t,e){if(typeof t!="string")throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function rn(n,t){n=He(n).substr(1),t=He(t).substr(1);function e(d){for(var y=0;y<d.length&&d[y]==="";y++);for(var g=d.length-1;g>=0&&d[g]==="";g--);return y>g?[]:d.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 sn(n){var t=qe(n),e=t[0],r=t[1];return!e&&!r?".":(r&&(r=r.substr(0,r.length-1)),e+r)}function an(n,t){var e=qe(n)[2];return t&&e.substr(-1*t.length)===t&&(e=e.substr(0,e.length-t.length)),e}function cn(n){return qe(n)[3]}function Je(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 en,qe,nn,on,Bt,un,Mt=Re(()=>{"use strict";u();p();en=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,qe=function(n){return en.exec(n).slice(1)};nn="/",on=":";Bt={extname:cn,basename:an,dirname:sn,sep:nn,delimiter:on,relative:rn,join:tn,isAbsolute:_t,normalize:Ct,resolve:He};un="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 zn={};ot(zn,{DynamicSnippetsGeneratorContext:()=>Qe});module.exports=zt(zn);u();p();u();p();u();p();function x(n){throw new Error("Unexpected value: "+JSON.stringify(n))}u();p();function ce(n){return Object.keys(n)}u();p();u();p();u();p();var St,Pt,ue=(Pt=(St=m.env.FERN_STACK_TRACK)==null?void 0:St.toLowerCase())!=null?Pt:"",L=ue!==""&&ue!=="0"&&ue!=="false",We=["single","multiline","box"].includes(ue)?ue:"single";L&&(Error.stackTraceLimit=50);var Jr=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),Xr=new Set(["stacktrace"]);function Ue({maxFrames:n=50,skip:t=0,filterPaths:e=[],filterFunctions:r=[],stopOn:i=[],filterNode:o=!0,filterJs:s=!0,formatFilename:f=h=>h}={}){var d;if(!L)return[];r=[...r,...Jr],e=[...e,...Xr],i=[...i,"runInteractiveTask"];let h=!1;return((d=new Error().stack)!=null?d:"").split(`
|
|
2
|
+
`).map(y=>{let g=y.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(g&&g.length===5){let[,T,I,_,ve]=g;if(!T||!I||!_||!ve)return;if(h||i.some(Vt=>T==null?void 0:T.includes(Vt))){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:`${_}:${ve}`}}}).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 ke=class{constructor({maxFrames:t=50,skip:e=0,filterPaths:r=[],filterFunctions:i=[],stopOn:o=[],filterNode:s=!0,filterJs:f=!0,multiline:h=!1,formatFilename:d=y=>y}={}){c(this,"maxFrames");c(this,"skip");c(this,"filterPaths");c(this,"filterFunctions");c(this,"stopOn");c(this,"filterNode");c(this,"filterJs");c(this,"multiline");c(this,"formatFilename");c(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=d}tag(t){let e=this.tracking.get(t)||new Set;Ue({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(!L)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}},D;function kt({maxFrames:n=50,skip:t=0,filterPaths:e=[],filterFunctions:r=[],stopOn:i=[],filterNode:o=!0,filterJs:s=!0,multiline:f=!1,formatFilename:h=d=>d}={}){L&&(D!=null||(D=new ke({maxFrames:n,skip:t,filterPaths:e,filterFunctions:r,stopOn:i,filterNode:o,filterJs:s,multiline:f,formatFilename:h})))}function Ut(n){D==null||D.tag(n)}function ze(n){var t;return(t=D==null?void 0:D.frames(n))!=null?t:[]}var H=class{constructor(){Ut(this)}};u();p();var Le=class{formatMultiple(t){return Promise.all(t.map(e=>this.format(e)))}formatMultipleSync(t){return t.map(e=>this.formatSync(e))}},pe=class extends Le{async format(t){return t}formatSync(t){return t}};u();p();u();p();u();p();var S=class extends H{constructor(e){super();c(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 Kr=4;kt({skip:0,maxFrames:15,filterFunctions:["Abstract"]});var le=class{constructor(){c(this,"lineBuffer",[]);c(this,"indentLevel",0);c(this,"hasWrittenAnything",!1);c(this,"lastCharacterIsSemicolon",!1);c(this,"lastCharacterIsNewline",!1);c(this,"nodeStackFrames",[])}get buffer(){return L&&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(`
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
`,`
|
|
9
9
|
${o}`);this.isAtStartOfLine()&&(s=o+s),r&&(s+=`
|
|
10
10
|
`),this.writeInternal(s)}else this.writeNode(e)}writeStatement(...t){this.write(...t),this.write(";"),this.writeNewLineIfLastLineNot()}writeNoIndent(t){let e=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=e}writeNode(t){L&&this.nodeStackFrames.push(...ze(t)),t.write(this),L&&We!=="single"&&this.writeInternal(`
|
|
11
|
-
`)}writeNodeOrString(t){if(typeof t=="string"){this.write(t);return}this.writeNode(t)}writeNodeStatement(t){this.writeNode(t),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new
|
|
11
|
+
`)}writeNodeOrString(t){if(typeof t=="string"){this.write(t);return}this.writeNode(t)}writeNodeStatement(t){this.writeNode(t),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new S(t).write(this),t.endsWith(";")||this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(t,e){new S(t).write(this),this.write(" (",e,")"),this.pushScope()}controlFlowWithoutStatement(t){new S(t).write(this),this.pushScope()}endControlFlow(){this.popScope()}contiguousControlFlow(t,e){this.dedent(),this.write("} "),new S(t).write(this),this.write(" (",e,")"),this.pushScope()}alternativeControlFlow(t){this.dedent(),this.write("} "),new S(t).write(this),this.pushScope()}pushScope(){this.writeLine("{"),this.indent()}popScope(t=!0){this.dedent(),this.writeNewLineIfLastLineNot(),t?this.writeLine("}"):this.write("}")}writeLine(...t){this.write(...t.length===0?[""]:t),this.writeNewLineIfLastLineNot()}newLine(){this.writeInternal(`
|
|
12
12
|
`)}writeSemicolonIfLastCharacterIsNot(){this.lastCharacterIsSemicolon||this.writeInternal(";")}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
|
|
13
13
|
`)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:t,delimiter:e,writeFunction: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=L&&!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(Ue({maxFrames:15,skip:3}))),...this.formatStack(this.filterStack(this.nodeStackFrames),"node")];switch(this.nodeStackFrames.length=0,We){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 Xr}};p();l();p();l();p();l();p();l();var fe=class{constructor(){c(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"},he=class n{constructor(){c(this,"errors");c(this,"path");this.errors=[],this.path=[]}add(t){this.errors.push(tt(et({},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 me=class{constructor({ir:t,config:e,options:r={}}){c(this,"config");c(this,"options");c(this,"errors");c(this,"_ir");c(this,"httpEndpointReferenceParser");this._ir=t,this.config=e,this.options=r,this.errors=new he,this.httpEndpointReferenceParser=new fe}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 d=r,{[i]:f}=d,h=nt(d,[rt(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(ce(r.urls));for(let o of ce(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: [${ce(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}};p();l();p();l();function de(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();var Kr=/[^0-9a-zA-Z_]/g,Zr=["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"],q=class extends le{constructor({packageName:e,rootImportPath:r,importPath:i,customConfig:o,formatter:s}){super();c(this,"packageName");c(this,"rootImportPath");c(this,"importPath");c(this,"customConfig");c(this,"formatter");c(this,"imports",{});this.packageName=e,this.rootImportPath=r,this.importPath=i,this.customConfig=o,this.formatter=s!=null?s:new pe}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),d=this.getValidAlias(h.join(""));if(!i.has(d))return this.imports[e]=d,d}let s=this.getValidAlias(de(e));for(;i.has(s);)s="_"+s;return this.imports[e]=s,s}isValidAlias(e){return!Zr.includes(e)}getValidAlias(e){let r=e.split("-");if(r[0]==null)return e;let i=r.map(o=>o.replace(Kr,"")).join("");return this.isValidAlias(i)?i:"_"+i}};var ye=class extends q{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=L&&!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(Ue({maxFrames:15,skip:3}))),...this.formatStack(this.filterStack(this.nodeStackFrames),"node")];switch(this.nodeStackFrames.length=0,We){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 Kr}};u();p();u();p();u();p();u();p();var fe=class{constructor(){c(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]}}};u();p();var v={Critical:"CRITICAL",Warning:"WARNING"},he=class n{constructor(){c(this,"errors");c(this,"path");this.errors=[],this.path=[]}add(t){this.errors.push(rt(tt({},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 me=class{constructor({ir:t,config:e,options:r={}}){c(this,"config");c(this,"options");c(this,"errors");c(this,"_ir");c(this,"httpEndpointReferenceParser");this._ir=t,this.config=e,this.options=r,this.errors=new he,this.httpEndpointReferenceParser=new fe}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 d=r,{[i]:f}=d,h=it(d,[nt(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(ce(r.urls));for(let o of ce(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: [${ce(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}};u();p();u();p();function de(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}u();p();u();p();u();p();var Zr=/[^0-9a-zA-Z_]/g,Qr=["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"],q=class extends le{constructor({packageName:e,rootImportPath:r,importPath:i,customConfig:o,formatter:s}){super();c(this,"packageName");c(this,"rootImportPath");c(this,"importPath");c(this,"customConfig");c(this,"formatter");c(this,"imports",{});this.packageName=e,this.rootImportPath=r,this.importPath=i,this.customConfig=o,this.formatter=s!=null?s:new pe}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),d=this.getValidAlias(h.join(""));if(!i.has(d))return this.imports[e]=d,d}let s=this.getValidAlias(de(e));for(;i.has(s);)s="_"+s;return this.imports[e]=s,s}isValidAlias(e){return!Qr.includes(e)}getValidAlias(e){let r=e.split("-");if(r[0]==null)return e;let i=r.map(o=>o.replace(Zr,"")).join("");return this.isValidAlias(i)?i:"_"+i}};var ye=class extends q{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
|
|
25
|
-
`).forEach(r=>{e.writeLine(`// ${r}`)})}};var J=class extends w{constructor({name:e,type:r,docs:i}){super();c(this,"name");c(this,"type");c(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new N({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" = "),e.writeNode(this.type)}};
|
|
26
|
-
`)?`\`${this.internalType.value}\``:`"${this.internalType.value}"`);break;case"struct":this.writeStruct({writer:e,struct:this.internalType});break;case"uuid":e.writeNode(dn({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=yn({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(ln.has(r.internalType.type)){e.writeNode(fn({writer:e,type:r}));return}if(Dt.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"||Dt.has(e.internalType.type)}writeSlice({writer:e,slice:r}){e.write("[]"),e.writeNode(r.valueType);let i=wn({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=gn({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 fn({writer:n,type:t}){return new S({func:new A({name:hn({type:t}),importPath:n.rootImportPath}),arguments_:[t]})}function hn({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 mn({writer:n,type:t}){let e=t.type==="date"?"MustParseDate":"MustParseDateTime";return new S({func:new A({name:e,importPath:n.rootImportPath}),arguments_:[new C(`"${t.value}"`)]})}function dn({value:n}){return new S({func:new A({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new C(`"${n}"`)]})}function yn({entries:n}){return n.filter(t=>!E.isNop(t.key)&&!E.isNop(t.value))}function gn({fields:n}){return n.filter(t=>!E.isNop(t.value))}function wn({values:n}){return n.filter(t=>!E.isNop(t))}var X=class n extends w{constructor({name:e,docs:r}){super();c(this,"name");c(this,"docs");c(this,"members",[]);c(this,"methods",[]);c(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 N({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 N({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 $(`${e}${r.name}`)}};p();l();var K=class extends w{constructor({name:e,type:r,docs:i,tags:o}){super();c(this,"name");c(this,"type");c(this,"docs");c(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 N({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 Z=class extends w{constructor({nodes:e}={nodes:[]}){super();c(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 O=class extends w{constructor({name:e,parameters:r,return_:i,body:o,docs:s,typeReference:f,multiline:h,receiver:d,pointerReceiver:y}){super();c(this,"parameters");c(this,"return_");c(this,"name");c(this,"body");c(this,"docs");c(this,"typeReference");c(this,"multiline");c(this,"receiver");c(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=d,this.pointerReceiver=y}write(e){var r;e.writeNode(new N({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}`),ae({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 Q=class extends w{constructor({name:e,parameters:r,return_:i,body:o,docs:s,multiline:f}){super();c(this,"func");this.func=new O({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 ge=class extends w{constructor({nodes:e}){super();c(this,"nodes");this.nodes=e}write(e){for(let r of this.nodes)e.newLine(),r.write(e),e.newLine()}};p();l();var ee=class extends w{constructor({name:e,type:r,docs:i}){super();c(this,"name");c(this,"type");c(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new N({docs:this.docs})),e.write(`${this.name} `),this.type.write(e)}};p();l();var te=class extends w{constructor({node:e}){super();c(this,"node");this.node=e}write(e){e.write("*"),this.node.write(e)}};p();l();var re=class extends w{constructor({on:e,selector:r}){super();c(this,"on");c(this,"selector");this.on=e,this.selector=r}write(e){e.writeNode(this.on),e.write("."),e.writeNode(this.selector)}};p();l();var ne=class extends w{constructor({name:e,embeds:r,fields:i,docs:o}){super();c(this,"name");c(this,"embeds",[]);c(this,"fields",[]);c(this,"docs");c(this,"methods",[]);c(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 N({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 we=class extends w{constructor({on:e,cases:r,default:i}){super();c(this,"on");c(this,"cases");c(this,"default");this.on=e,this.cases=r,this.default=i}write(e){let r=this.cases;this.default!=null&&r.push({on:new $("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 xn=new Set(["any","bytes","map","slice"]),xe=class n extends w{constructor(e){super();c(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(Ce);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(_e);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"||xn.has(e.internalType.type)}static isAlreadyVariadic(e){return e.internalType.type==="variadic"}},Ce=new A({importPath:"time",name:"Time"}),_e=new A({importPath:"github.com/google/uuid",name:"UUID"}),Xe=new A({importPath:"io",name:"Reader"});p();l();var ie=class extends w{constructor({name:e,type:r,docs:i}){super();c(this,"name");c(this,"type");c(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new N({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" "),e.writeNode(this.type)}};function vn(n){return new J(n)}function Tn(n){return new C(n)}function In(n){return new X(n)}function Rn(n){return new K(n)}function Nn(n={}){return new Z(n)}function En(n){return new Q(n)}function An(n){return new $(n)}function bn(n){return new S(n)}function Fn(n){return new V(n)}function Pn(n){return new O(n)}function Sn(n){return new ee(n)}function kn(n){return new te(n)}function Un(n){return new re(n)}function Ln(n={}){return new ne(n)}function Cn(n){return new we(n)}function _n(n){return new ie(n)}function Bn(n){return new A(n)}p();l();Bt();var Mn="sdk";function Ke({config:n,customConfig:t}){let e=$n({config:n}),r=Dn({config:n,customConfig:t});return e!=null?On({importPath:r,majorVersion:e}):r}function Dn({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"?Gn(n.output.mode.repoUrl,"https://"):Mn;return e?r:_t.join(r,(f=t==null?void 0:t.packagePath)!=null?f:"")}function $n({config:n}){let t=Vn({config:n});if(!(t==null||t==="v0"||t==="v1"))return`${t}`}function Vn({config:n}){let t=Yn(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 On({importPath:n,majorVersion:t}){return de(n)===t?n:`${n}/${t}`}function Gn(n,t){return n.startsWith(t)?n.slice(t.length):n}function Yn(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 Be=class{constructor({context:t}){c(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 u.TypeInstantiation.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return u.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?u.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 u.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 u.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"?u.TypeInstantiation.reference(u.invokeMethod({on:e,method:"Ptr",arguments_:[]})):e}default:return e}}convertList({list:t,value:e}){return Array.isArray(e)?u.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}`}),u.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}`}),u.TypeInstantiation.nop()):u.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 u.TypeInstantiation.reference(u.invokeFunc({func:u.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"?u.TypeInstantiation.reference(u.codeblock(o=>{o.write("&"),o.writeNode(u.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"?u.TypeInstantiation.reference(u.codeblock(o=>{o.write("&"),o.writeNode(u.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("}")})):u.TypeInstantiation.reference(u.codeblock(o=>{o.write("&"),o.writeNode(t)}))}convertLiteralValue(t){switch(t.type){case"boolean":return u.TypeInstantiation.bool(t.value);case"string":return u.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 u.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?u.TypeInstantiation.nop():u.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 u.TypeInstantiation.nop();try{return this.context.errors.scope(o.discriminantValue.wireValue),u.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 u.TypeInstantiation.structPointer({typeReference:r,fields:[{name:this.context.getTypeName(i.discriminantValue.name),value:u.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 u.TypeInstantiation.structPointer({typeReference:u.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?u.TypeInstantiation.nop():u.TypeInstantiation.enum(u.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 u.TypeInstantiation.nop();let i=this.getUndiscriminatedUnionFieldName({typeReference:r.valueTypeReference});return i==null?u.TypeInstantiation.nop():u.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 u.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?u.TypeInstantiation.nop():u.TypeInstantiation.int(i)}case"LONG":case"UINT_64":{let i=this.getValueAsNumber({value:e,as:r});return i==null?u.TypeInstantiation.nop():u.TypeInstantiation.int64(i)}case"FLOAT":case"DOUBLE":{let i=this.getValueAsNumber({value:e,as:r});return i==null?u.TypeInstantiation.nop():u.TypeInstantiation.float64(i)}case"BOOLEAN":{let i=this.getValueAsBoolean({value:e,as:r});return i==null?u.TypeInstantiation.nop():u.TypeInstantiation.bool(i)}case"STRING":{let i=this.context.getValueAsString({value:e});return i==null?u.TypeInstantiation.nop():u.TypeInstantiation.string(i)}case"DATE":{let i=this.context.getValueAsString({value:e});return i==null?u.TypeInstantiation.nop():u.TypeInstantiation.date(i)}case"DATE_TIME":{let i=this.context.getValueAsString({value:e});if(i==null)return u.TypeInstantiation.nop();let o=this.normalizeDateTimeString(i);return u.TypeInstantiation.dateTime(o)}case"UUID":{let i=this.context.getValueAsString({value:e});return i==null?u.TypeInstantiation.nop():u.TypeInstantiation.uuid(i)}case"BASE_64":{let i=this.context.getValueAsString({value:e});return i==null?u.TypeInstantiation.nop():u.TypeInstantiation.bytes(i)}case"BIG_INTEGER":{let i=this.context.getValueAsString({value:e});return i==null?u.TypeInstantiation.nop():u.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}};p();l();var Me=class{constructor({context:t}){c(this,"context");this.context=t}convert(t){switch(t.typeReference.type){case"list":return u.Type.slice(this.convert({typeReference:t.typeReference.value}));case"literal":return this.convertLiteral({literal:t.typeReference.value});case"map":return u.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 u.Type.optional(this.convert({typeReference:t.typeReference.value}));case"nullable":return u.Type.optional(this.convert({typeReference:t.typeReference.value}));case"primitive":return this.convertPrimitive({primitive:t.typeReference.value});case"set":return u.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 u.Type.bool();case"string":return u.Type.string()}}convertNamed({named:t}){let e=u.Type.reference(u.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 u.Type.pointer(e);default:x(t)}}convertUnknown(){return u.Type.any()}convertPrimitive({primitive:t}){switch(t){case"INTEGER":return u.Type.int();case"UINT":return u.Type.int();case"LONG":return u.Type.int64();case"UINT_64":return u.Type.int64();case"FLOAT":return u.Type.float64();case"DOUBLE":return u.Type.float64();case"BOOLEAN":return u.Type.bool();case"STRING":return u.Type.string();case"DATE":return u.Type.date();case"DATE_TIME":return u.Type.dateTime();case"UUID":return u.Type.uuid();case"BASE_64":return u.Type.bytes();case"BIG_INTEGER":return u.Type.string();default:x(t)}}};p();l();var De=class{constructor({context:t}){c(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 u.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(r))}getArrayFileProperty({property:t,record:e}){let r=this.context.getFileArrayValues({property:t,record:e});return r==null?u.TypeInstantiation.nop():u.TypeInstantiation.slice({valueType:u.Type.reference(this.context.getIoReaderTypeReference()),values:r.map(i=>u.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(i)))})}getBodyProperty({property:t,record:e}){let r=e[t.name.wireValue];return r==null?u.TypeInstantiation.nop():this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:r})}};var Ze=class n extends me{constructor({ir:e,config:r}){super({ir:e,config:r});c(this,"ir");c(this,"customConfig");c(this,"dynamicTypeMapper");c(this,"dynamicTypeInstantiationMapper");c(this,"filePropertyMapper");c(this,"rootImportPath");this.ir=e,this.customConfig=r.customConfig!=null?r.customConfig:void 0,this.dynamicTypeMapper=new Me({context:this}),this.dynamicTypeInstantiationMapper=new Be({context:this}),this.filePropertyMapper=new De({context:this}),this.rootImportPath=Ke({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 u.typeReference({name:"Context",importPath:"context"})}getContextTodoFunctionInvocation(){return u.invokeFunc({func:u.typeReference({name:"TODO",importPath:"context"}),arguments_:[]})}getIoReaderTypeReference(){return u.typeReference({name:"Reader",importPath:"io"})}getTestingTypeReference(){return u.typeReference({name:"T",importPath:"testing"})}getNewStringsReaderFunctionInvocation(e){return u.invokeFunc({func:u.typeReference({name:"NewReader",importPath:"strings"}),arguments_:[u.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 u.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 u.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=u.invokeMethod({on:i,method:o.method,arguments_:o.arguments_,multiline:o.multiline});return i}};0&&(module.exports={DynamicSnippetsGeneratorContext});
|
|
24
|
+
)`:""}};var l={};ot(l,{Alias:()=>J,AstNode:()=>w,CodeBlock:()=>C,Enum:()=>X,Field:()=>K,File:()=>Z,Func:()=>Q,FuncInvocation:()=>P,IoReaderTypeReference:()=>Xe,Method:()=>O,MethodInvocation:()=>V,MultiNode:()=>ge,Parameter:()=>ee,Pointer:()=>te,Selector:()=>re,Struct:()=>ne,TimeTypeReference:()=>Ce,Type:()=>xe,TypeDeclaration:()=>ie,TypeInstantiation:()=>E,TypeReference:()=>A,UuidTypeReference:()=>_e,Writer:()=>q,alias:()=>Tn,codeblock:()=>In,enum_:()=>Rn,field:()=>Nn,file:()=>En,func:()=>An,identifier:()=>bn,invokeFunc:()=>Fn,invokeMethod:()=>Sn,method:()=>Pn,parameter:()=>kn,pointer:()=>Un,selector:()=>Ln,struct:()=>Cn,switch_:()=>_n,typeDeclaration:()=>Bn,typeReference:()=>Mn});u();p();u();p();u();p();u();p();u();p();var w=class extends H{async toStringAsync({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o}){let s=new ye({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 ye({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o});return this.write(s),s.toString()}};var N=class extends w{constructor({docs:e}={}){super();c(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
|
|
25
|
+
`).forEach(r=>{e.writeLine(`// ${r}`)})}};var J=class extends w{constructor({name:e,type:r,docs:i}){super();c(this,"name");c(this,"type");c(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new N({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" = "),e.writeNode(this.type)}};u();p();var C=class extends w{constructor(e){super();c(this,"arg");this.arg=e}write(e){return new S(this.arg).write(e)}};u();p();u();p();var $=class extends w{constructor(e){super();c(this,"name");this.name=e}write(e){e.write(this.name)}};u();p();u();p();u();p();function ae({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){pn({writer:n,arguments_:r});return}ln({writer:n,arguments_:r})}function pn({writer:n,arguments_:t}){n.writeLine("("),n.indent();for(let e of t)e.write(n),n.writeLine(",");n.dedent(),n.write(")")}function ln({writer:n,arguments_:t}){n.write("("),t.forEach((e,r)=>{r>0&&n.write(", "),e.write(n)}),n.write(")")}var P=class extends w{constructor({func:e,arguments_:r,multiline:i=!0}){super();c(this,"func");c(this,"arguments_");c(this,"multiline");this.func=e,this.arguments_=r,this.multiline=i}write(e){e.writeNode(this.func),ae({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};u();p();u();p();function Dt({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 A=class extends w{constructor({name:e,importPath:r,generics:i}){super();c(this,"name");c(this,"importPath");c(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&&Dt({writer:e,generics:this.generics})}};u();p();var V=class extends w{constructor({method:e,arguments_:r,on:i,multiline:o}){super();c(this,"on");c(this,"method");c(this,"arguments_");c(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),ae({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};var fn=new Set(["bool","date","dateTime","float64","int","int64","string","uuid"]),$t=new Set(["any","bytes","map","slice"]),E=class n extends w{constructor(e){super();c(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(dn({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(yn({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=gn({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(fn.has(r.internalType.type)){e.writeNode(hn({writer:e,type:r}));return}if($t.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"||$t.has(e.internalType.type)}writeSlice({writer:e,slice:r}){e.write("[]"),e.writeNode(r.valueType);let i=xn({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=wn({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 hn({writer:n,type:t}){return new P({func:new A({name:mn({type:t}),importPath:n.rootImportPath}),arguments_:[t]})}function mn({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 dn({writer:n,type:t}){let e=t.type==="date"?"MustParseDate":"MustParseDateTime";return new P({func:new A({name:e,importPath:n.rootImportPath}),arguments_:[new C(`"${t.value}"`)]})}function yn({value:n}){return new P({func:new A({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new C(`"${n}"`)]})}function gn({entries:n}){return n.filter(t=>!E.isNop(t.key)&&!E.isNop(t.value))}function wn({fields:n}){return n.filter(t=>!E.isNop(t.value))}function xn({values:n}){return n.filter(t=>!E.isNop(t))}var X=class n extends w{constructor({name:e,docs:r}){super();c(this,"name");c(this,"docs");c(this,"members",[]);c(this,"methods",[]);c(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 N({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 N({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 $(`${e}${r.name}`)}};u();p();var K=class extends w{constructor({name:e,type:r,docs:i,tags:o}){super();c(this,"name");c(this,"type");c(this,"docs");c(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 N({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("`"))}};u();p();var Z=class extends w{constructor({nodes:e}={nodes:[]}){super();c(this,"nodes");this.nodes=e!=null?e:[]}add(...e){this.nodes.push(...e)}write(e){for(let r of this.nodes)r.write(e)}};u();p();u();p();var O=class extends w{constructor({name:e,parameters:r,return_:i,body:o,docs:s,typeReference:f,multiline:h,receiver:d,pointerReceiver:y}){super();c(this,"parameters");c(this,"return_");c(this,"name");c(this,"body");c(this,"docs");c(this,"typeReference");c(this,"multiline");c(this,"receiver");c(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=d,this.pointerReceiver=y}write(e){var r;e.writeNode(new N({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}`),ae({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 Q=class extends w{constructor({name:e,parameters:r,return_:i,body:o,docs:s,multiline:f}){super();c(this,"func");this.func=new O({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)}};u();p();var ge=class extends w{constructor({nodes:e}){super();c(this,"nodes");this.nodes=e}write(e){for(let r of this.nodes)e.newLine(),r.write(e),e.newLine()}};u();p();var ee=class extends w{constructor({name:e,type:r,docs:i}){super();c(this,"name");c(this,"type");c(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new N({docs:this.docs})),e.write(`${this.name} `),this.type.write(e)}};u();p();var te=class extends w{constructor({node:e}){super();c(this,"node");this.node=e}write(e){e.write("*"),this.node.write(e)}};u();p();var re=class extends w{constructor({on:e,selector:r}){super();c(this,"on");c(this,"selector");this.on=e,this.selector=r}write(e){e.writeNode(this.on),e.write("."),e.writeNode(this.selector)}};u();p();var ne=class extends w{constructor({name:e,embeds:r,fields:i,docs:o}){super();c(this,"name");c(this,"embeds",[]);c(this,"fields",[]);c(this,"docs");c(this,"methods",[]);c(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 N({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()}};u();p();var we=class extends w{constructor({on:e,cases:r,default:i}){super();c(this,"on");c(this,"cases");c(this,"default");this.on=e,this.cases=r,this.default=i}write(e){let r=this.cases;this.default!=null&&r.push({on:new $("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("}")}};u();p();var vn=new Set(["any","bytes","map","slice"]),xe=class n extends w{constructor(e){super();c(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(Ce);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(_e);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"||vn.has(e.internalType.type)}static isAlreadyVariadic(e){return e.internalType.type==="variadic"}},Ce=new A({importPath:"time",name:"Time"}),_e=new A({importPath:"github.com/google/uuid",name:"UUID"}),Xe=new A({importPath:"io",name:"Reader"});u();p();var ie=class extends w{constructor({name:e,type:r,docs:i}){super();c(this,"name");c(this,"type");c(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){e.writeNode(new N({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" "),e.writeNode(this.type)}};function Tn(n){return new J(n)}function In(n){return new C(n)}function Rn(n){return new X(n)}function Nn(n){return new K(n)}function En(n={}){return new Z(n)}function An(n){return new Q(n)}function bn(n){return new $(n)}function Fn(n){return new P(n)}function Sn(n){return new V(n)}function Pn(n){return new O(n)}function kn(n){return new ee(n)}function Un(n){return new te(n)}function Ln(n){return new re(n)}function Cn(n={}){return new ne(n)}function _n(n){return new we(n)}function Bn(n){return new ie(n)}function Mn(n){return new A(n)}u();p();var Dn=new Set(["string"]);function Ke(n){if(n==="")return"Underscore";let t=n;for(;t.startsWith("_");)t=t.slice(1);if(t==="")return"Underscore";if(t.length>0&&/^\d/.test(t))return"Field"+t;let e=t,r=t[0];return t.length>0&&r!=null&&r!==r.toUpperCase()&&(e=r.toUpperCase()+t.slice(1)),Dn.has(e.toLowerCase())?"Field"+e:e}u();p();Mt();var $n="sdk";function Ze({config:n,customConfig:t}){let e=On({config:n}),r=Vn({config:n,customConfig:t});return e!=null?Yn({importPath:r,majorVersion:e}):r}function Vn({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"?jn(n.output.mode.repoUrl,"https://"):$n;return e?r:Bt.join(r,(f=t==null?void 0:t.packagePath)!=null?f:"")}function On({config:n}){let t=Gn({config:n});if(!(t==null||t==="v0"||t==="v1"))return`${t}`}function Gn({config:n}){let t=Wn(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 Yn({importPath:n,majorVersion:t}){return de(n)===t?n:`${n}/${t}`}function jn(n,t){return n.startsWith(t)?n.slice(t.length):n}function Wn(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}u();p();var Be=class{constructor({context:t}){c(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 l.TypeInstantiation.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return l.TypeInstantiation.nop();case"map":return this.convertMap({map:t.typeReference,value:t.value});case"named":{let e=this.context.resolveNamedType({typeId:t.typeReference.value});return e==null?l.TypeInstantiation.nop():this.convertNamed({named:e,value:t.value,as:t.as})}case"nullable":{let e=t.typeReference.value;if(e.type==="named"){let 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 l.TypeInstantiation.optional(this.convert({typeReference:e,value:t.value,as:t.as}))}case"optional":{let e=t.typeReference.value;if(e.type==="named"){let 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 l.TypeInstantiation.optional(this.convert({typeReference:e,value:t.value,as:t.as}))}case"primitive":return this.convertPrimitive({primitive:t.typeReference.value,value:t.value,as:t.as});case"set":return this.convertList({list:t.typeReference.value,value:t.value});case"unknown":return this.convertUnknown({value:t.value});default: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"?l.TypeInstantiation.reference(l.invokeMethod({on:e,method:"Ptr",arguments_:[]})):e}default:return e}}convertList({list:t,value:e}){return Array.isArray(e)?l.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}`}),l.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}`}),l.TypeInstantiation.nop()):l.TypeInstantiation.map({keyType:this.context.dynamicTypeMapper.convert({typeReference:t.key}),valueType:this.context.dynamicTypeMapper.convert({typeReference:t.value}),entries:Object.entries(e).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 l.TypeInstantiation.reference(l.invokeFunc({func:l.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}),arguments_:[this.convertLiteralValue(t.typeReference.value)]}));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"?l.TypeInstantiation.reference(l.codeblock(o=>{o.write("&"),o.writeNode(l.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"?l.TypeInstantiation.reference(l.codeblock(o=>{o.write("&"),o.writeNode(l.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("}")})):l.TypeInstantiation.reference(l.codeblock(o=>{o.write("&"),o.writeNode(t)}))}convertLiteralValue(t){switch(t.type){case"boolean":return l.TypeInstantiation.bool(t.value);case"string":return l.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 l.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?l.TypeInstantiation.nop():l.TypeInstantiation.structPointer({typeReference:r,fields:[{name:this.context.getFieldName(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 l.TypeInstantiation.nop();try{return this.context.errors.scope(o.discriminantValue.wireValue),l.TypeInstantiation.structPointer({typeReference:r,fields:[{name:this.context.getFieldName(o.discriminantValue.name),value:this.convert({typeReference:o.typeReference,value:f[o.discriminantValue.wireValue]})},...s]})}finally{this.context.errors.unscope()}}case"noProperties":return l.TypeInstantiation.structPointer({typeReference:r,fields:[{name:this.context.getFieldName(i.discriminantValue.name),value:l.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.getFieldName(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 l.TypeInstantiation.structPointer({typeReference:l.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.getFieldName(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?l.TypeInstantiation.nop():l.TypeInstantiation.enum(l.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 l.TypeInstantiation.nop();let i=this.getUndiscriminatedUnionFieldName({typeReference:r.valueTypeReference});return i==null?l.TypeInstantiation.nop():l.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 l.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?l.TypeInstantiation.nop():l.TypeInstantiation.int(i)}case"LONG":case"UINT_64":{let i=this.getValueAsNumber({value:e,as:r});return i==null?l.TypeInstantiation.nop():l.TypeInstantiation.int64(i)}case"FLOAT":case"DOUBLE":{let i=this.getValueAsNumber({value:e,as:r});return i==null?l.TypeInstantiation.nop():l.TypeInstantiation.float64(i)}case"BOOLEAN":{let i=this.getValueAsBoolean({value:e,as:r});return i==null?l.TypeInstantiation.nop():l.TypeInstantiation.bool(i)}case"STRING":{let i=this.context.getValueAsString({value:e});return i==null?l.TypeInstantiation.nop():l.TypeInstantiation.string(i)}case"DATE":{let i=this.context.getValueAsString({value:e});return i==null?l.TypeInstantiation.nop():l.TypeInstantiation.date(i)}case"DATE_TIME":{let i=this.context.getValueAsString({value:e});if(i==null)return l.TypeInstantiation.nop();let o=this.normalizeDateTimeString(i);return l.TypeInstantiation.dateTime(o)}case"UUID":{let i=this.context.getValueAsString({value:e});return i==null?l.TypeInstantiation.nop():l.TypeInstantiation.uuid(i)}case"BASE_64":{let i=this.context.getValueAsString({value:e});return i==null?l.TypeInstantiation.nop():l.TypeInstantiation.bytes(i)}case"BIG_INTEGER":{let i=this.context.getValueAsString({value:e});return i==null?l.TypeInstantiation.nop():l.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}};u();p();var Me=class{constructor({context:t}){c(this,"context");this.context=t}convert(t){switch(t.typeReference.type){case"list":return l.Type.slice(this.convert({typeReference:t.typeReference.value}));case"literal":return this.convertLiteral({literal:t.typeReference.value});case"map":return l.Type.map(this.convert({typeReference:t.typeReference.key}),this.convert({typeReference:t.typeReference.value}));case"named":{let e=this.context.resolveNamedType({typeId:t.typeReference.value});return e==null?this.convertUnknown():this.convertNamed({named:e})}case"optional":return l.Type.optional(this.convert({typeReference:t.typeReference.value}));case"nullable":return l.Type.optional(this.convert({typeReference:t.typeReference.value}));case"primitive":return this.convertPrimitive({primitive:t.typeReference.value});case"set":return l.Type.slice(this.convert({typeReference:t.typeReference}));case"unknown":return this.convertUnknown();default:x(t.typeReference)}}convertLiteral({literal:t}){switch(t.type){case"boolean":return l.Type.bool();case"string":return l.Type.string()}}convertNamed({named:t}){let e=l.Type.reference(l.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}));switch(t.type){case"alias":case"enum":return e;case"discriminatedUnion":case"object":case"undiscriminatedUnion":return l.Type.pointer(e);default:x(t)}}convertUnknown(){return l.Type.any()}convertPrimitive({primitive:t}){switch(t){case"INTEGER":return l.Type.int();case"UINT":return l.Type.int();case"LONG":return l.Type.int64();case"UINT_64":return l.Type.int64();case"FLOAT":return l.Type.float64();case"DOUBLE":return l.Type.float64();case"BOOLEAN":return l.Type.bool();case"STRING":return l.Type.string();case"DATE":return l.Type.date();case"DATE_TIME":return l.Type.dateTime();case"UUID":return l.Type.uuid();case"BASE_64":return l.Type.bytes();case"BIG_INTEGER":return l.Type.string();default:x(t)}}};u();p();var De=class{constructor({context:t}){c(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.getFieldName(s.name),value:this.getSingleFileProperty({property:s,record:i})});break;case"fileArray":r.fileFields.push({name:this.context.getFieldName(s.name),value:this.getArrayFileProperty({property:s,record:i})});break;case"bodyProperty":r.bodyPropertyFields.push({name:this.context.getFieldName(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 l.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(r))}getArrayFileProperty({property:t,record:e}){let r=this.context.getFileArrayValues({property:t,record:e});return r==null?l.TypeInstantiation.nop():l.TypeInstantiation.slice({valueType:l.Type.reference(this.context.getIoReaderTypeReference()),values:r.map(i=>l.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(i)))})}getBodyProperty({property:t,record:e}){let r=e[t.name.wireValue];return r==null?l.TypeInstantiation.nop():this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:r})}};var Qe=class n extends me{constructor({ir:e,config:r}){super({ir:e,config:r});c(this,"ir");c(this,"customConfig");c(this,"dynamicTypeMapper");c(this,"dynamicTypeInstantiationMapper");c(this,"filePropertyMapper");c(this,"rootImportPath");this.ir=e,this.customConfig=r.customConfig!=null?r.customConfig:void 0,this.dynamicTypeMapper=new Me({context:this}),this.dynamicTypeInstantiationMapper=new Be({context:this}),this.filePropertyMapper=new De({context:this}),this.rootImportPath=Ze({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}getFieldName(e){return Ke(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 l.typeReference({name:"Context",importPath:"context"})}getContextTodoFunctionInvocation(){return l.invokeFunc({func:l.typeReference({name:"TODO",importPath:"context"}),arguments_:[]})}getIoReaderTypeReference(){return l.typeReference({name:"Reader",importPath:"io"})}getTestingTypeReference(){return l.typeReference({name:"T",importPath:"testing"})}getNewStringsReaderFunctionInvocation(e){return l.invokeFunc({func:l.typeReference({name:"NewReader",importPath:"strings"}),arguments_:[l.TypeInstantiation.string(e)]})}getClientConstructorName(){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 l.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 l.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=l.invokeMethod({on:i,method:o.method,arguments_:o.arguments_,multiline:o.multiline});return i}};0&&(module.exports={DynamicSnippetsGeneratorContext});
|
|
27
27
|
/*! Bundled license information:
|
|
28
28
|
|
|
29
29
|
@esbuild-plugins/node-globals-polyfill/Buffer.js:
|