@fern-api/go-dynamic-snippets 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
- "use strict";var ce=Object.defineProperty,ct=Object.defineProperties,pt=Object.getOwnPropertyDescriptor,ft=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertyNames,ue=Object.getOwnPropertySymbols;var Re=Object.prototype.hasOwnProperty,ke=Object.prototype.propertyIsEnumerable;var Ie=(n,t,e)=>t in n?ce(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,_e=(n,t)=>{for(var e in t||(t={}))Re.call(t,e)&&Ie(n,e,t[e]);if(ue)for(var e of ue(t))ke.call(t,e)&&Ie(n,e,t[e]);return n},Be=(n,t)=>ct(n,ft(t));var Le=n=>typeof n=="symbol"?n:n+"",De=(n,t)=>{var e={};for(var r in n)Re.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&ue)for(var r of ue(n))t.indexOf(r)<0&&ke.call(n,r)&&(e[r]=n[r]);return e};var Ee=(n,t)=>()=>(n&&(t=n(n=0)),t);var Ce=(n,t)=>{for(var e in t)ce(n,e,{get:t[e],enumerable:!0})},ht=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of lt(t))!Re.call(n,i)&&i!==e&&ce(n,i,{get:()=>t[i],enumerable:!(r=pt(t,i))||r.enumerable});return n};var mt=n=>ht(ce({},"__esModule",{value:!0}),n);var f=(n,t,e)=>Ie(n,typeof t!="symbol"?t+"":t,e);function Ve(){throw new Error("setTimeout has not been defined")}function $e(){throw new Error("clearTimeout has not been defined")}function Oe(n){if(C===setTimeout)return setTimeout(n,0);if((C===Ve||!C)&&setTimeout)return C=setTimeout,setTimeout(n,0);try{return C(n,0)}catch(t){try{return C.call(null,n,0)}catch(e){return C.call(this,n,0)}}}function dt(n){if(M===clearTimeout)return clearTimeout(n);if((M===$e||!M)&&clearTimeout)return M=clearTimeout,clearTimeout(n);try{return M(n)}catch(t){try{return M.call(null,n)}catch(e){return M.call(this,n)}}}function yt(){!Q||!$||(Q=!1,$.length?_=$.concat(_):pe=-1,_.length&&Ge())}function Ge(){if(!Q){var n=Oe(yt);Q=!0;for(var t=_.length;t;){for($=_,_=[];++pe<t;)$&&$[pe].run();pe=-1,t=_.length}$=null,Q=!1,dt(n)}}function wt(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];_.push(new Ye(n,t)),_.length===1&&!Q&&Oe(Ge)}function Ye(n,t){this.fun=n,this.array=t}function O(){}function Bt(n){throw new Error("process.binding is not supported")}function Lt(){return"/"}function Dt(n){throw new Error("process.chdir is not supported")}function Ct(){return 0}function Vt(n){var t=Mt.call(Z)*.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 Ot(){var n=new Date,t=n-$t;return t/1e3}var C,M,_,Q,$,pe,xt,gt,Tt,vt,It,Rt,Et,At,Nt,Ut,Pt,bt,Ft,St,kt,_t,Z,Mt,$t,m,Me,c=Ee(()=>{"use strict";C=Ve,M=$e;typeof globalThis.setTimeout=="function"&&(C=setTimeout);typeof globalThis.clearTimeout=="function"&&(M=clearTimeout);_=[],Q=!1,pe=-1;Ye.prototype.run=function(){this.fun.apply(null,this.array)};xt="browser",gt="browser",Tt=!0,vt={},It=[],Rt="",Et={},At={},Nt={};Ut=O,Pt=O,bt=O,Ft=O,St=O,kt=O,_t=O;Z=globalThis.performance||{},Mt=Z.now||Z.mozNow||Z.msNow||Z.oNow||Z.webkitNow||function(){return new Date().getTime()};$t=new Date;m={nextTick:wt,title:xt,browser:Tt,env:vt,argv:It,version:Rt,versions:Et,on:Ut,addListener:Pt,once:bt,off:Ft,removeListener:St,removeAllListeners:kt,emit:_t,binding:Bt,cwd:Lt,chdir:Dt,umask:Ct,hrtime:Vt,platform:gt,release:At,config:Nt,uptime:Ot},Me={};Object.keys(Me).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]=Me[n]:e=e[i]||(e[i]={})}})});function qe(){Ne=!0;for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=n.length;t<e;++t)F[t]=n[t],A[n.charCodeAt(t)]=t;A[45]=62,A[95]=63}function Yt(n){Ne||qe();var t,e,r,i,o,s,l=n.length;if(l%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o=n[l-2]==="="?2:n[l-1]==="="?1:0,s=new Gt(l*3/4-o),r=o>0?l-4:l;var h=0;for(t=0,e=0;t<r;t+=4,e+=3)i=A[n.charCodeAt(t)]<<18|A[n.charCodeAt(t+1)]<<12|A[n.charCodeAt(t+2)]<<6|A[n.charCodeAt(t+3)],s[h++]=i>>16&255,s[h++]=i>>8&255,s[h++]=i&255;return o===2?(i=A[n.charCodeAt(t)]<<2|A[n.charCodeAt(t+1)]>>4,s[h++]=i&255):o===1&&(i=A[n.charCodeAt(t)]<<10|A[n.charCodeAt(t+1)]<<4|A[n.charCodeAt(t+2)]>>2,s[h++]=i>>8&255,s[h++]=i&255),s}function Wt(n){return F[n>>18&63]+F[n>>12&63]+F[n>>6&63]+F[n&63]}function jt(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(Wt(r));return i.join("")}function We(n){Ne||qe();for(var t,e=n.length,r=e%3,i="",o=[],s=16383,l=0,h=e-r;l<h;l+=s)o.push(jt(n,l,l+s>h?h:l+s));return r===1?(t=n[e-1],i+=F[t>>2],i+=F[t<<4&63],i+="=="):r===2&&(t=(n[e-2]<<8)+n[e-1],i+=F[t>>10],i+=F[t>>4&63],i+=F[t<<2&63],i+="="),o.push(i),o.join("")}function fe(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function B(n,t){if(fe()<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 Ue(this,n)}return ze(this,n,t,e)}function ze(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?zt(n,t,e,r):typeof t=="string"?qt(n,t,e):Xt(n,t)}function Xe(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 Ht(n,t,e,r){return Xe(t),t<=0?B(n,t):e!==void 0?typeof r=="string"?B(n,t).fill(e,r):B(n,t).fill(e):B(n,t)}function Ue(n,t){if(Xe(t),n=B(n,t<0?0:Pe(t)|0),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)n[e]=0;return n}function qt(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=Je(t,e)|0;n=B(n,r);var i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Ae(n,t){var e=t.length<0?0:Pe(t.length)|0;n=B(n,e);for(var r=0;r<e;r+=1)n[r]=t[r]&255;return n}function zt(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=Ae(n,t),n}function Xt(n,t){if(S(t)){var e=Pe(t.length)|0;return n=B(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"||mr(t.length)?B(n,0):Ae(n,t);if(t.type==="Buffer"&&Array.isArray(t.data))return Ae(n,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Pe(n){if(n>=fe())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+fe().toString(16)+" bytes");return n|0}function S(n){return!!(n!=null&&n._isBuffer)}function Je(n,t){if(S(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 le(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 le(n).length;t=(""+t).toLowerCase(),r=!0}}function Jt(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 sr(this,t,e);case"utf8":case"utf-8":return Ke(this,t,e);case"ascii":return ir(this,t,e);case"latin1":case"binary":return or(this,t,e);case"base64":return rr(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ar(this,t,e);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),r=!0}}function G(n,t,e){var r=n[t];n[t]=n[e],n[e]=r}function Ze(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)),S(t))return t.length===0?-1:je(n,t,e,r,i);if(typeof t=="number")return t=t&255,a.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):je(n,[t],e,r,i);throw new TypeError("val must be string, number or Buffer")}function je(n,t,e,r,i){var o=1,s=n.length,l=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,l/=2,e/=2}function h(E,J){return o===1?E[J]:E.readUInt16BE(J*o)}var y;if(i){var w=-1;for(y=e;y<s;y++)if(h(n,y)===h(t,w===-1?0:y-w)){if(w===-1&&(w=y),y-w+1===l)return w*o}else w!==-1&&(y-=y-w),w=-1}else for(e+l>s&&(e=s-l),y=e;y>=0;y--){for(var d=!0,P=0;P<l;P++)if(h(n,y+P)!==h(t,P)){d=!1;break}if(d)return y}return-1}function Zt(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 l=parseInt(t.substr(s*2,2),16);if(isNaN(l))return s;n[e+s]=l}return s}function Qt(n,t,e,r){return de(le(t,n.length-e),n,e,r)}function Qe(n,t,e,r){return de(lr(t),n,e,r)}function Kt(n,t,e,r){return Qe(n,t,e,r)}function er(n,t,e,r){return de(nt(t),n,e,r)}function tr(n,t,e,r){return de(hr(t,n.length-e),n,e,r)}function rr(n,t,e){return t===0&&e===n.length?We(n):We(n.slice(t,e))}function Ke(n,t,e){e=Math.min(n.length,e);for(var r=[],i=t;i<e;){var o=n[i],s=null,l=o>239?4:o>223?3:o>191?2:1;if(i+l<=e){var h,y,w,d;switch(l){case 1:o<128&&(s=o);break;case 2:h=n[i+1],(h&192)===128&&(d=(o&31)<<6|h&63,d>127&&(s=d));break;case 3:h=n[i+1],y=n[i+2],(h&192)===128&&(y&192)===128&&(d=(o&15)<<12|(h&63)<<6|y&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:h=n[i+1],y=n[i+2],w=n[i+3],(h&192)===128&&(y&192)===128&&(w&192)===128&&(d=(o&15)<<18|(h&63)<<12|(y&63)<<6|w&63,d>65535&&d<1114112&&(s=d))}}s===null?(s=65533,l=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),i+=l}return nr(r)}function nr(n){var t=n.length;if(t<=He)return String.fromCharCode.apply(String,n);for(var e="",r=0;r<t;)e+=String.fromCharCode.apply(String,n.slice(r,r+=He));return e}function ir(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 or(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 sr(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+=fr(n[o]);return i}function ar(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 v(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 I(n,t,e,r,i,o){if(!S(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 he(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 me(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 et(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 tt(n,t,e,r,i){return i||et(n,t,e,4,34028234663852886e22,-34028234663852886e22),ot(n,t,e,r,23,4),e+4}function rt(n,t,e,r,i){return i||et(n,t,e,8,17976931348623157e292,-17976931348623157e292),ot(n,t,e,r,52,8),e+8}function cr(n){if(n=pr(n).replace(ur,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function pr(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")}function fr(n){return n<16?"0"+n.toString(16):n.toString(16)}function le(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 lr(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function hr(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 Yt(cr(n))}function de(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 mr(n){return n!==n}function dr(n){return n!=null&&(!!n._isBuffer||it(n)||yr(n))}function it(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function yr(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&it(n.slice(0,0))}function ye(n,t,e,r,i){var o,s,l=i*8-r-1,h=(1<<l)-1,y=h>>1,w=-7,d=e?i-1:0,P=e?-1:1,E=n[t+d];for(d+=P,o=E&(1<<-w)-1,E>>=-w,w+=l;w>0;o=o*256+n[t+d],d+=P,w-=8);for(s=o&(1<<-w)-1,o>>=-w,w+=r;w>0;s=s*256+n[t+d],d+=P,w-=8);if(o===0)o=1-y;else{if(o===h)return s?NaN:(E?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-y}return(E?-1:1)*s*Math.pow(2,o-r)}function ot(n,t,e,r,i,o){var s,l,h,y=o*8-i-1,w=(1<<y)-1,d=w>>1,P=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=r?0:o-1,J=r?1:-1,ut=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(l=isNaN(t)?1:0,s=w):(s=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-s))<1&&(s--,h*=2),s+d>=1?t+=P/h:t+=P*Math.pow(2,1-d),t*h>=2&&(s++,h/=2),s+d>=w?(l=0,s=w):s+d>=1?(l=(t*h-1)*Math.pow(2,i),s=s+d):(l=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;n[e+E]=l&255,E+=J,l/=256,i-=8);for(s=s<<i|l,y+=i;y>0;n[e+E]=s&255,E+=J,s/=256,y-=8);n[e+E-J]|=ut*128}var F,A,Gt,Ne,He,ur,st=Ee(()=>{"use strict";c();p();F=[],A=[],Gt=typeof Uint8Array!="undefined"?Uint8Array:Array,Ne=!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 ze(null,n,t,e)};a.kMaxLength=fe();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 Ht(null,n,t,e)};a.allocUnsafe=function(n){return Ue(null,n)};a.allocUnsafeSlow=function(n){return Ue(null,n)};a.isBuffer=dr;a.compare=function(t,e){if(!S(t)||!S(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(!S(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i};a.byteLength=Je;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)G(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)G(this,e,e+3),G(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)G(this,e,e+7),G(this,e+1,e+6),G(this,e+2,e+5),G(this,e+3,e+4);return this};a.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?Ke(this,0,t):Jt.apply(this,arguments)};a.prototype.equals=function(t){if(!S(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(!S(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,l=r-e,h=Math.min(s,l),y=this.slice(i,o),w=t.slice(e,r),d=0;d<h;++d)if(y[d]!==w[d]){s=y[d],l=w[d];break}return s<l?-1:l<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 Ze(this,t,e,r,!0)};a.prototype.lastIndexOf=function(t,e,r){return Ze(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 Zt(this,t,e,r);case"utf8":case"utf-8":return Qt(this,t,e,r);case"ascii":return Qe(this,t,e,r);case"latin1":case"binary":return Kt(this,t,e,r);case"base64":return er(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return tr(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)}};He=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||v(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||v(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||v(t,1,this.length),this[t]};a.prototype.readUInt16LE=function(t,e){return e||v(t,2,this.length),this[t]|this[t+1]<<8};a.prototype.readUInt16BE=function(t,e){return e||v(t,2,this.length),this[t]<<8|this[t+1]};a.prototype.readUInt32LE=function(t,e){return e||v(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||v(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||v(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||v(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||v(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};a.prototype.readInt16LE=function(t,e){e||v(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||v(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||v(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||v(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||v(t,4,this.length),ye(this,t,!0,23,4)};a.prototype.readFloatBE=function(t,e){return e||v(t,4,this.length),ye(this,t,!1,23,4)};a.prototype.readDoubleLE=function(t,e){return e||v(t,8,this.length),ye(this,t,!0,52,8)};a.prototype.readDoubleBE=function(t,e){return e||v(t,8,this.length),ye(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;I(this,t,e,r,o,0)}var s=1,l=0;for(this[e]=t&255;++l<r&&(s*=256);)this[e+l]=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;I(this,t,e,r,o,0)}var s=r-1,l=1;for(this[e+s]=t&255;--s>=0&&(l*=256);)this[e+s]=t/l&255;return e+r};a.prototype.writeUInt8=function(t,e,r){return t=+t,e=e|0,r||I(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||I(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):he(this,t,e,!0),e+2};a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=e|0,r||I(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):he(this,t,e,!1),e+2};a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=e|0,r||I(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):me(this,t,e,!0),e+4};a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=e|0,r||I(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):me(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);I(this,t,e,r,o-1,-o)}var s=0,l=1,h=0;for(this[e]=t&255;++s<r&&(l*=256);)t<0&&h===0&&this[e+s-1]!==0&&(h=1),this[e+s]=(t/l>>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);I(this,t,e,r,o-1,-o)}var s=r-1,l=1,h=0;for(this[e+s]=t&255;--s>=0&&(l*=256);)t<0&&h===0&&this[e+s+1]!==0&&(h=1),this[e+s]=(t/l>>0)-h&255;return e+r};a.prototype.writeInt8=function(t,e,r){return t=+t,e=e|0,r||I(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||I(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):he(this,t,e,!0),e+2};a.prototype.writeInt16BE=function(t,e,r){return t=+t,e=e|0,r||I(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):he(this,t,e,!1),e+2};a.prototype.writeInt32LE=function(t,e,r){return t=+t,e=e|0,r||I(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):me(this,t,e,!0),e+4};a.prototype.writeInt32BE=function(t,e,r){return t=+t,e=e|0,r||I(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):me(this,t,e,!1),e+4};a.prototype.writeFloatLE=function(t,e,r){return tt(this,t,e,!0,r)};a.prototype.writeFloatBE=function(t,e,r){return tt(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 l=S(t)?t:le(new a(t,i).toString()),h=l.length;for(s=0;s<r-e;++s)this[s+e]=l[s%h]}return this};ur=/[^+\/0-9A-Za-z-_]/g});var p=Ee(()=>{"use strict";st()});var Xr={};Ce(Xr,{DynamicSnippetsGeneratorContext:()=>Se});module.exports=mt(Xr);c();p();c();p();c();p();function g(n){throw new Error("Unexpected value: "+JSON.stringify(n))}c();p();function K(n){return Object.keys(n)}c();p();c();p();var Y=class{};c();p();c();p();var V=class extends Y{constructor(e){super();f(this,"value");this.value=e}write(e){typeof this.value=="string"?e.write(this.value):this.value(e)}};var wr=4,ee=class{constructor(){f(this,"buffer","");f(this,"indentLevel",0);f(this,"hasWrittenAnything",!1);f(this,"lastCharacterIsNewline",!1)}write(t){let e=t.length>0&&t.endsWith(`
1
+ "use strict";var ce=Object.defineProperty,ct=Object.defineProperties,pt=Object.getOwnPropertyDescriptor,lt=Object.getOwnPropertyDescriptors,ft=Object.getOwnPropertyNames,ue=Object.getOwnPropertySymbols;var Re=Object.prototype.hasOwnProperty,ke=Object.prototype.propertyIsEnumerable;var Ie=(n,t,e)=>t in n?ce(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,_e=(n,t)=>{for(var e in t||(t={}))Re.call(t,e)&&Ie(n,e,t[e]);if(ue)for(var e of ue(t))ke.call(t,e)&&Ie(n,e,t[e]);return n},Be=(n,t)=>ct(n,lt(t));var Le=n=>typeof n=="symbol"?n:n+"",De=(n,t)=>{var e={};for(var r in n)Re.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&ue)for(var r of ue(n))t.indexOf(r)<0&&ke.call(n,r)&&(e[r]=n[r]);return e};var Ee=(n,t)=>()=>(n&&(t=n(n=0)),t);var Ce=(n,t)=>{for(var e in t)ce(n,e,{get:t[e],enumerable:!0})},ht=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ft(t))!Re.call(n,i)&&i!==e&&ce(n,i,{get:()=>t[i],enumerable:!(r=pt(t,i))||r.enumerable});return n};var mt=n=>ht(ce({},"__esModule",{value:!0}),n);var l=(n,t,e)=>Ie(n,typeof t!="symbol"?t+"":t,e);function Ve(){throw new Error("setTimeout has not been defined")}function $e(){throw new Error("clearTimeout has not been defined")}function Oe(n){if(C===setTimeout)return setTimeout(n,0);if((C===Ve||!C)&&setTimeout)return C=setTimeout,setTimeout(n,0);try{return C(n,0)}catch(t){try{return C.call(null,n,0)}catch(e){return C.call(this,n,0)}}}function dt(n){if(M===clearTimeout)return clearTimeout(n);if((M===$e||!M)&&clearTimeout)return M=clearTimeout,clearTimeout(n);try{return M(n)}catch(t){try{return M.call(null,n)}catch(e){return M.call(this,n)}}}function yt(){!Q||!$||(Q=!1,$.length?_=$.concat(_):pe=-1,_.length&&Ge())}function Ge(){if(!Q){var n=Oe(yt);Q=!0;for(var t=_.length;t;){for($=_,_=[];++pe<t;)$&&$[pe].run();pe=-1,t=_.length}$=null,Q=!1,dt(n)}}function wt(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];_.push(new Ye(n,t)),_.length===1&&!Q&&Oe(Ge)}function Ye(n,t){this.fun=n,this.array=t}function O(){}function Bt(n){throw new Error("process.binding is not supported")}function Lt(){return"/"}function Dt(n){throw new Error("process.chdir is not supported")}function Ct(){return 0}function Vt(n){var t=Mt.call(Z)*.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 Ot(){var n=new Date,t=n-$t;return t/1e3}var C,M,_,Q,$,pe,xt,Tt,gt,vt,It,Rt,Et,At,Nt,Ut,bt,Pt,Ft,St,kt,_t,Z,Mt,$t,m,Me,c=Ee(()=>{"use strict";C=Ve,M=$e;typeof globalThis.setTimeout=="function"&&(C=setTimeout);typeof globalThis.clearTimeout=="function"&&(M=clearTimeout);_=[],Q=!1,pe=-1;Ye.prototype.run=function(){this.fun.apply(null,this.array)};xt="browser",Tt="browser",gt=!0,vt={},It=[],Rt="",Et={},At={},Nt={};Ut=O,bt=O,Pt=O,Ft=O,St=O,kt=O,_t=O;Z=globalThis.performance||{},Mt=Z.now||Z.mozNow||Z.msNow||Z.oNow||Z.webkitNow||function(){return new Date().getTime()};$t=new Date;m={nextTick:wt,title:xt,browser:gt,env:vt,argv:It,version:Rt,versions:Et,on:Ut,addListener:bt,once:Pt,off:Ft,removeListener:St,removeAllListeners:kt,emit:_t,binding:Bt,cwd:Lt,chdir:Dt,umask:Ct,hrtime:Vt,platform:Tt,release:At,config:Nt,uptime:Ot},Me={};Object.keys(Me).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]=Me[n]:e=e[i]||(e[i]={})}})});function qe(){Ne=!0;for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=n.length;t<e;++t)F[t]=n[t],A[n.charCodeAt(t)]=t;A[45]=62,A[95]=63}function Yt(n){Ne||qe();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 Gt(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=A[n.charCodeAt(t)]<<18|A[n.charCodeAt(t+1)]<<12|A[n.charCodeAt(t+2)]<<6|A[n.charCodeAt(t+3)],s[h++]=i>>16&255,s[h++]=i>>8&255,s[h++]=i&255;return o===2?(i=A[n.charCodeAt(t)]<<2|A[n.charCodeAt(t+1)]>>4,s[h++]=i&255):o===1&&(i=A[n.charCodeAt(t)]<<10|A[n.charCodeAt(t+1)]<<4|A[n.charCodeAt(t+2)]>>2,s[h++]=i>>8&255,s[h++]=i&255),s}function Wt(n){return F[n>>18&63]+F[n>>12&63]+F[n>>6&63]+F[n&63]}function jt(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(Wt(r));return i.join("")}function We(n){Ne||qe();for(var t,e=n.length,r=e%3,i="",o=[],s=16383,f=0,h=e-r;f<h;f+=s)o.push(jt(n,f,f+s>h?h:f+s));return r===1?(t=n[e-1],i+=F[t>>2],i+=F[t<<4&63],i+="=="):r===2&&(t=(n[e-2]<<8)+n[e-1],i+=F[t>>10],i+=F[t>>4&63],i+=F[t<<2&63],i+="="),o.push(i),o.join("")}function le(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function B(n,t){if(le()<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 Ue(this,n)}return ze(this,n,t,e)}function ze(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?zt(n,t,e,r):typeof t=="string"?qt(n,t,e):Xt(n,t)}function Xe(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 Ht(n,t,e,r){return Xe(t),t<=0?B(n,t):e!==void 0?typeof r=="string"?B(n,t).fill(e,r):B(n,t).fill(e):B(n,t)}function Ue(n,t){if(Xe(t),n=B(n,t<0?0:be(t)|0),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)n[e]=0;return n}function qt(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=Je(t,e)|0;n=B(n,r);var i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Ae(n,t){var e=t.length<0?0:be(t.length)|0;n=B(n,e);for(var r=0;r<e;r+=1)n[r]=t[r]&255;return n}function zt(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=Ae(n,t),n}function Xt(n,t){if(S(t)){var e=be(t.length)|0;return n=B(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"||mr(t.length)?B(n,0):Ae(n,t);if(t.type==="Buffer"&&Array.isArray(t.data))return Ae(n,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function be(n){if(n>=le())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+le().toString(16)+" bytes");return n|0}function S(n){return!!(n!=null&&n._isBuffer)}function Je(n,t){if(S(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 fe(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 fe(n).length;t=(""+t).toLowerCase(),r=!0}}function Jt(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 sr(this,t,e);case"utf8":case"utf-8":return Ke(this,t,e);case"ascii":return ir(this,t,e);case"latin1":case"binary":return or(this,t,e);case"base64":return rr(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ar(this,t,e);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),r=!0}}function G(n,t,e){var r=n[t];n[t]=n[e],n[e]=r}function Ze(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)),S(t))return t.length===0?-1:je(n,t,e,r,i);if(typeof t=="number")return t=t&255,a.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):je(n,[t],e,r,i);throw new TypeError("val must be string, number or Buffer")}function je(n,t,e,r,i){var o=1,s=n.length,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(E,J){return o===1?E[J]:E.readUInt16BE(J*o)}var y;if(i){var w=-1;for(y=e;y<s;y++)if(h(n,y)===h(t,w===-1?0:y-w)){if(w===-1&&(w=y),y-w+1===f)return w*o}else w!==-1&&(y-=y-w),w=-1}else for(e+f>s&&(e=s-f),y=e;y>=0;y--){for(var d=!0,b=0;b<f;b++)if(h(n,y+b)!==h(t,b)){d=!1;break}if(d)return y}return-1}function Zt(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 Qt(n,t,e,r){return de(fe(t,n.length-e),n,e,r)}function Qe(n,t,e,r){return de(fr(t),n,e,r)}function Kt(n,t,e,r){return Qe(n,t,e,r)}function er(n,t,e,r){return de(nt(t),n,e,r)}function tr(n,t,e,r){return de(hr(t,n.length-e),n,e,r)}function rr(n,t,e){return t===0&&e===n.length?We(n):We(n.slice(t,e))}function Ke(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,y,w,d;switch(f){case 1:o<128&&(s=o);break;case 2:h=n[i+1],(h&192)===128&&(d=(o&31)<<6|h&63,d>127&&(s=d));break;case 3:h=n[i+1],y=n[i+2],(h&192)===128&&(y&192)===128&&(d=(o&15)<<12|(h&63)<<6|y&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:h=n[i+1],y=n[i+2],w=n[i+3],(h&192)===128&&(y&192)===128&&(w&192)===128&&(d=(o&15)<<18|(h&63)<<12|(y&63)<<6|w&63,d>65535&&d<1114112&&(s=d))}}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 nr(r)}function nr(n){var t=n.length;if(t<=He)return String.fromCharCode.apply(String,n);for(var e="",r=0;r<t;)e+=String.fromCharCode.apply(String,n.slice(r,r+=He));return e}function ir(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 or(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 sr(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+=lr(n[o]);return i}function ar(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 v(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 I(n,t,e,r,i,o){if(!S(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 he(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 me(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 et(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 tt(n,t,e,r,i){return i||et(n,t,e,4,34028234663852886e22,-34028234663852886e22),ot(n,t,e,r,23,4),e+4}function rt(n,t,e,r,i){return i||et(n,t,e,8,17976931348623157e292,-17976931348623157e292),ot(n,t,e,r,52,8),e+8}function cr(n){if(n=pr(n).replace(ur,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function pr(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")}function lr(n){return n<16?"0"+n.toString(16):n.toString(16)}function fe(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 fr(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function hr(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 Yt(cr(n))}function de(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 mr(n){return n!==n}function dr(n){return n!=null&&(!!n._isBuffer||it(n)||yr(n))}function it(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function yr(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&it(n.slice(0,0))}function ye(n,t,e,r,i){var o,s,f=i*8-r-1,h=(1<<f)-1,y=h>>1,w=-7,d=e?i-1:0,b=e?-1:1,E=n[t+d];for(d+=b,o=E&(1<<-w)-1,E>>=-w,w+=f;w>0;o=o*256+n[t+d],d+=b,w-=8);for(s=o&(1<<-w)-1,o>>=-w,w+=r;w>0;s=s*256+n[t+d],d+=b,w-=8);if(o===0)o=1-y;else{if(o===h)return s?NaN:(E?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-y}return(E?-1:1)*s*Math.pow(2,o-r)}function ot(n,t,e,r,i,o){var s,f,h,y=o*8-i-1,w=(1<<y)-1,d=w>>1,b=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=r?0:o-1,J=r?1:-1,ut=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=w):(s=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-s))<1&&(s--,h*=2),s+d>=1?t+=b/h:t+=b*Math.pow(2,1-d),t*h>=2&&(s++,h/=2),s+d>=w?(f=0,s=w):s+d>=1?(f=(t*h-1)*Math.pow(2,i),s=s+d):(f=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;n[e+E]=f&255,E+=J,f/=256,i-=8);for(s=s<<i|f,y+=i;y>0;n[e+E]=s&255,E+=J,s/=256,y-=8);n[e+E-J]|=ut*128}var F,A,Gt,Ne,He,ur,st=Ee(()=>{"use strict";c();p();F=[],A=[],Gt=typeof Uint8Array!="undefined"?Uint8Array:Array,Ne=!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 ze(null,n,t,e)};a.kMaxLength=le();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 Ht(null,n,t,e)};a.allocUnsafe=function(n){return Ue(null,n)};a.allocUnsafeSlow=function(n){return Ue(null,n)};a.isBuffer=dr;a.compare=function(t,e){if(!S(t)||!S(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(!S(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i};a.byteLength=Je;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)G(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)G(this,e,e+3),G(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)G(this,e,e+7),G(this,e+1,e+6),G(this,e+2,e+5),G(this,e+3,e+4);return this};a.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?Ke(this,0,t):Jt.apply(this,arguments)};a.prototype.equals=function(t){if(!S(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(!S(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),y=this.slice(i,o),w=t.slice(e,r),d=0;d<h;++d)if(y[d]!==w[d]){s=y[d],f=w[d];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 Ze(this,t,e,r,!0)};a.prototype.lastIndexOf=function(t,e,r){return Ze(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 Zt(this,t,e,r);case"utf8":case"utf-8":return Qt(this,t,e,r);case"ascii":return Qe(this,t,e,r);case"latin1":case"binary":return Kt(this,t,e,r);case"base64":return er(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return tr(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)}};He=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||v(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||v(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||v(t,1,this.length),this[t]};a.prototype.readUInt16LE=function(t,e){return e||v(t,2,this.length),this[t]|this[t+1]<<8};a.prototype.readUInt16BE=function(t,e){return e||v(t,2,this.length),this[t]<<8|this[t+1]};a.prototype.readUInt32LE=function(t,e){return e||v(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||v(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||v(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||v(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||v(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};a.prototype.readInt16LE=function(t,e){e||v(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||v(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||v(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||v(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||v(t,4,this.length),ye(this,t,!0,23,4)};a.prototype.readFloatBE=function(t,e){return e||v(t,4,this.length),ye(this,t,!1,23,4)};a.prototype.readDoubleLE=function(t,e){return e||v(t,8,this.length),ye(this,t,!0,52,8)};a.prototype.readDoubleBE=function(t,e){return e||v(t,8,this.length),ye(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;I(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;I(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||I(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||I(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):he(this,t,e,!0),e+2};a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=e|0,r||I(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):he(this,t,e,!1),e+2};a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=e|0,r||I(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):me(this,t,e,!0),e+4};a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=e|0,r||I(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):me(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);I(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);I(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||I(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||I(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):he(this,t,e,!0),e+2};a.prototype.writeInt16BE=function(t,e,r){return t=+t,e=e|0,r||I(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):he(this,t,e,!1),e+2};a.prototype.writeInt32LE=function(t,e,r){return t=+t,e=e|0,r||I(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):me(this,t,e,!0),e+4};a.prototype.writeInt32BE=function(t,e,r){return t=+t,e=e|0,r||I(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):me(this,t,e,!1),e+4};a.prototype.writeFloatLE=function(t,e,r){return tt(this,t,e,!0,r)};a.prototype.writeFloatBE=function(t,e,r){return tt(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=S(t)?t:fe(new a(t,i).toString()),h=f.length;for(s=0;s<r-e;++s)this[s+e]=f[s%h]}return this};ur=/[^+\/0-9A-Za-z-_]/g});var p=Ee(()=>{"use strict";st()});var Xr={};Ce(Xr,{DynamicSnippetsGeneratorContext:()=>Se});module.exports=mt(Xr);c();p();c();p();c();p();function T(n){throw new Error("Unexpected value: "+JSON.stringify(n))}c();p();function K(n){return Object.keys(n)}c();p();c();p();var Y=class{};c();p();c();p();var V=class extends Y{constructor(e){super();l(this,"value");this.value=e}write(e){typeof this.value=="string"?e.write(this.value):this.value(e)}};var wr=4,ee=class{constructor(){l(this,"buffer","");l(this,"indentLevel",0);l(this,"hasWrittenAnything",!1);l(this,"lastCharacterIsNewline",!1)}write(t){let e=t.length>0&&t.endsWith(`
2
2
  `),r=e?t.substring(0,t.length-1):t,i=this.getIndentString(),o=r.replaceAll(`
3
3
  `,`
4
4
  ${i}`);this.isAtStartOfLine()&&(o=i+o),e&&(o+=`
5
5
  `),this.writeInternal(o)}writeNoIndent(t){let e=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=e}writeNode(t){t.write(this)}writeNodeStatement(t){t.write(this),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new V(t).write(this),this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(t,e){new V(t).write(this),this.write(" ("),this.writeNode(e),this.write(") {"),this.writeNewLineIfLastLineNot(),this.indent()}endControlFlow(){this.dedent(),this.writeLine("}")}openBlock(t,e="{",r,i="}"){let o=t.filter(s=>s!==void 0).join(" ");o?this.write(`${o} ${e!=null?e:""}`):this.write(e!=null?e:"");try{this.indent(),r(),this.dedent()}finally{this.write(i!=null?i:"")}}writeLine(t=""){this.write(t),this.writeNewLineIfLastLineNot()}newLine(){this.writeInternal(`
6
6
  `)}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
7
- `)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:t,delimiter:e,writeFunction:r}){if(t.length>0){let i=t[0];i!=null&&r(i);for(let o=1;o<t.length;o++){this.write(e);let s=t[o];s!=null&&r(s)}}}writeInternal(t){return t.length>0&&(this.hasWrittenAnything=!0,this.lastCharacterIsNewline=t.endsWith(`
8
- `)),this.buffer+=t}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*wr)}};c();p();var we=class{},te=class extends we{async format(t){return t}formatSync(t){return t}};c();p();function be(n){return(n==null?void 0:n.name)!=null}c();p();c();p();c();p();c();p();var re=class{constructor(){f(this,"REFERENCE_REGEX",/^(GET|POST|PUT|DELETE|PATCH)\s(\/[a-zA-Z0-9\/{}_-]*)$/)}validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let r=t.match(this.REFERENCE_REGEX);if(!(r==null||r[1]==null||r[2]==null))return{method:r[1],path:r[2]}}};c();p();var T={Critical:"CRITICAL",Warning:"WARNING"},ne=class n{constructor(){f(this,"errors");f(this,"path");this.errors=[],this.path=[]}add(t){this.errors.push(Be(_e({},t),{path:[...this.path]}))}scope(t){this.path.push(t)}unscope(){this.path.pop()}getBySeverity(t){return this.errors.filter(e=>e.severity===t)}empty(){return this.errors.length===0}size(){return this.errors.length}clone(){let t=new n;return t.errors=[...this.errors],t.path=[...this.path],t}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(t=>({severity:t.severity,path:t.path!=null?this.pathToStringArray(t.path):void 0,message:t.message}))}pathToStringArray(t){let e=[];for(let r of t){if(typeof r=="string"){e.push(r);continue}e[e.length-1]+=`[${r.index}]`}return e}};var ie=class{constructor({ir:t,config:e}){f(this,"config");f(this,"errors");f(this,"_ir");f(this,"httpEndpointReferenceParser");this._ir=t,this.config=e,this.errors=new ne,this.httpEndpointReferenceParser=new re}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 l=this.isListTypeReference(s.typeReference)&&!Array.isArray(o)?[o]:o;r.push({name:s.name,typeReference:s.typeReference,value:l})}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 l=t.find(h=>h.name.wireValue===o);if(l==null){if(r)continue;this.errors.add({severity:T.Critical,message:this.newParameterNotRecognizedError(o).message});continue}i.push({name:l.name,typeReference:l.typeReference,value:s})}finally{this.errors.unscope()}}return i}getSingleFileValue({property:t,record:e}){let r=e[t.wireValue];if(r!=null){if(typeof r!="string"){this.errors.add({severity:T.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:T.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:T.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:T.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:T.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:T.Critical,message:this.newParameterNotRecognizedError(i).message});return}if(typeof o!="string"){this.errors.add({severity:T.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:T.Critical,message:`No type found for discriminant value "${o}"`});return}let y=r,{[i]:l}=y,h=De(y,[Le(i)]);return{singleDiscriminatedUnionType:s,discriminantValue:s.discriminantValue,value:h}}resolveEndpointOrThrow(t){let e=this.httpEndpointReferenceParser.tryParse(t);if(e==null)throw new Error(`Failed to parse endpoint reference "${t}"`);return this.resolveEndpointLocationOrThrow(e)}resolveEndpointLocationOrThrow(t){let e=[];for(let r of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:r,parsedEndpoint:t})&&e.push(r);if(e.length===0)throw new Error(`Failed to find endpoint identified by "${t.method} ${t.path}"`);return e}needsRequestParameter({request:t,inlinePathParameters:e,inlineFileProperties:r}){var i;return this.includePathParametersInWrappedRequest({request:t,inlinePathParameters:e})||t.queryParameters!=null&&t.queryParameters.length>0||t.headers!=null&&t.headers.length>0?!0:t.body!=null?this.includeRequestBodyInWrappedRequest({body:t.body,inlineFileProperties:r}):!((i=t.metadata)!=null&&i.onlyPathParameters)}includePathParametersInWrappedRequest({request:t,inlinePathParameters:e}){var r,i;return e&&((i=(r=t.metadata)==null?void 0:r.includePathParameters)!=null?i:!1)}isFileUploadRequestBody(t){switch(t.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:g(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:g(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:T.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:T.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:T.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let i=new Set(K(r.urls));for(let o of K(t))i.has(o)&&i.delete(o);return i.size>0?(this.errors.add({severity:T.Critical,message:`The provided environments are invalid; got: [${Object.keys(t).join(", ")}], expected: [${K(r.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:t}){if(typeof t!="number"){this.errors.add({severity:T.Critical,message:this.newTypeMismatchError({expected:"number",value:t}).message});return}return t}getValueAsBoolean({value:t}){if(typeof t!="boolean"){this.errors.add({severity:T.Critical,message:this.newTypeMismatchError({expected:"boolean",value:t}).message});return}return t}getValueAsString({value:t}){if(typeof t!="string"){this.errors.add({severity:T.Critical,message:this.newTypeMismatchError({expected:"string",value:t}).message});return}return t}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:g(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:g(e)}})}fileUploadHasFileProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:g(e)}})}isListTypeReference(t){return t.type==="optional"?this.isListTypeReference(t.value):t.type==="list"||t.type==="set"}parsedEndpointMatches({endpoint:t,parsedEndpoint:e}){return t.location.method===e.method&&t.location.path===e.path}};c();p();c();p();function oe(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}c();p();c();p();c();p();c();p();c();p();c();p();var xr=/[^0-9a-zA-Z_]/g,W=class extends ee{constructor({packageName:e,rootImportPath:r,importPath:i,customConfig:o,formatter:s}){super();f(this,"packageName");f(this,"rootImportPath");f(this,"importPath");f(this,"customConfig");f(this,"formatter");f(this,"imports",{});this.packageName=e,this.rootImportPath=r,this.importPath=i,this.customConfig=o,this.formatter=s!=null?s:new te}addImport(e){let r=this.imports[e];if(r!=null)return r;let i=this.getValidAlias(oe(e));for(;i in this.imports;)i="_"+i;return this.imports[e]=i,i}getValidAlias(e){let r=e.split("-");return r[0]==null?e:r[0].replace(xr,"")}};var se=class extends W{constructor({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o}){super({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o})}async toString(){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}
9
- ${t}`)}return t}toStringSync(){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}
7
+ `)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:t,delimiter:e,writeFunction:r}){if(t.length>0){let i=t[0];i!=null&&r(i);for(let o=1;o<t.length;o++){this.write(e);let s=t[o];s!=null&&r(s)}}}toString(){return this.buffer}writeInternal(t){return t.length>0&&(this.hasWrittenAnything=!0,this.lastCharacterIsNewline=t.endsWith(`
8
+ `)),this.buffer+=t}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*wr)}};c();p();var we=class{},te=class extends we{async format(t){return t}formatSync(t){return t}};c();p();function Pe(n){return(n==null?void 0:n.name)!=null}c();p();c();p();c();p();c();p();var re=class{constructor(){l(this,"REFERENCE_REGEX",/^(GET|POST|PUT|DELETE|PATCH)\s(\/[a-zA-Z0-9\/{}_-]*)$/)}validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let r=t.match(this.REFERENCE_REGEX);if(!(r==null||r[1]==null||r[2]==null))return{method:r[1],path:r[2]}}};c();p();var g={Critical:"CRITICAL",Warning:"WARNING"},ne=class n{constructor(){l(this,"errors");l(this,"path");this.errors=[],this.path=[]}add(t){this.errors.push(Be(_e({},t),{path:[...this.path]}))}scope(t){this.path.push(t)}unscope(){this.path.pop()}getBySeverity(t){return this.errors.filter(e=>e.severity===t)}empty(){return this.errors.length===0}size(){return this.errors.length}clone(){let t=new n;return t.errors=[...this.errors],t.path=[...this.path],t}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(t=>({severity:t.severity,path:t.path!=null?this.pathToStringArray(t.path):void 0,message:t.message}))}pathToStringArray(t){let e=[];for(let r of t){if(typeof r=="string"){e.push(r);continue}e[e.length-1]+=`[${r.index}]`}return e}};var ie=class{constructor({ir:t,config:e}){l(this,"config");l(this,"errors");l(this,"_ir");l(this,"httpEndpointReferenceParser");this._ir=t,this.config=e,this.errors=new ne,this.httpEndpointReferenceParser=new re}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}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:g.Critical,message:this.newParameterNotRecognizedError(o).message});continue}i.push({name:f.name,typeReference:f.typeReference,value:s})}finally{this.errors.unscope()}}return i}getSingleFileValue({property:t,record:e}){let r=e[t.wireValue];if(r!=null){if(typeof r!="string"){this.errors.add({severity:g.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:g.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:g.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:g.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:g.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:g.Critical,message:this.newParameterNotRecognizedError(i).message});return}if(typeof o!="string"){this.errors.add({severity:g.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:g.Critical,message:`No type found for discriminant value "${o}"`});return}let y=r,{[i]:f}=y,h=De(y,[Le(i)]);return{singleDiscriminatedUnionType:s,discriminantValue:s.discriminantValue,value:h}}resolveEndpointOrThrow(t){let e=this.httpEndpointReferenceParser.tryParse(t);if(e==null)throw new Error(`Failed to parse endpoint reference "${t}"`);return this.resolveEndpointLocationOrThrow(e)}resolveEndpointLocationOrThrow(t){let e=[];for(let r of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:r,parsedEndpoint:t})&&e.push(r);if(e.length===0)throw new Error(`Failed to find endpoint identified by "${t.method} ${t.path}"`);return e}needsRequestParameter({request:t,inlinePathParameters:e,inlineFileProperties:r}){var i;return this.includePathParametersInWrappedRequest({request:t,inlinePathParameters:e})||t.queryParameters!=null&&t.queryParameters.length>0||t.headers!=null&&t.headers.length>0?!0:t.body!=null?this.includeRequestBodyInWrappedRequest({body:t.body,inlineFileProperties:r}):!((i=t.metadata)!=null&&i.onlyPathParameters)}includePathParametersInWrappedRequest({request:t,inlinePathParameters:e}){var r,i;return e&&((i=(r=t.metadata)==null?void 0:r.includePathParameters)!=null?i:!1)}isFileUploadRequestBody(t){switch(t.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:T(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:T(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:g.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:g.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:g.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let i=new Set(K(r.urls));for(let o of K(t))i.has(o)&&i.delete(o);return i.size>0?(this.errors.add({severity:g.Critical,message:`The provided environments are invalid; got: [${Object.keys(t).join(", ")}], expected: [${K(r.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:t}){if(typeof t!="number"){this.errors.add({severity:g.Critical,message:this.newTypeMismatchError({expected:"number",value:t}).message});return}return t}getValueAsBoolean({value:t}){if(typeof t!="boolean"){this.errors.add({severity:g.Critical,message:this.newTypeMismatchError({expected:"boolean",value:t}).message});return}return t}getValueAsString({value:t}){if(typeof t!="string"){this.errors.add({severity:g.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:T(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:T(e)}})}fileUploadHasFileProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:T(e)}})}isListTypeReference(t){return t.type==="optional"?this.isListTypeReference(t.value):t.type==="list"||t.type==="set"}parsedEndpointMatches({endpoint:t,parsedEndpoint:e}){return t.location.method===e.method&&t.location.path===e.path}};c();p();c();p();function oe(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}c();p();c();p();c();p();c();p();c();p();c();p();var xr=/[^0-9a-zA-Z_]/g,W=class extends ee{constructor({packageName:e,rootImportPath:r,importPath:i,customConfig:o,formatter:s}){super();l(this,"packageName");l(this,"rootImportPath");l(this,"importPath");l(this,"customConfig");l(this,"formatter");l(this,"imports",{});this.packageName=e,this.rootImportPath=r,this.importPath=i,this.customConfig=o,this.formatter=s!=null?s:new te}addImport(e){let r=this.imports[e];if(r!=null)return r;let i=this.getValidAlias(oe(e));for(;i in this.imports;)i="_"+i;return this.imports[e]=i,i}getValidAlias(e){let r=e.split("-");return r[0]==null?e:r[0].replace(xr,"")}};var se=class extends W{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}
9
+ ${t}`)}return t}toString(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.formatSync(t)}catch(e){throw new Error(`Failed to format Go file: ${e}
10
10
  ${t}`)}return t}getContent(){let t=`package ${this.packageName}
11
11
 
12
12
  `,e=this.stringifyImports();return e.length>0?`${t}${e}
@@ -14,9 +14,9 @@ ${t}`)}return t}getContent(){let t=`package ${this.packageName}
14
14
  ${this.buffer}`:t+this.buffer}stringifyImports(){let t=Object.entries(this.imports).filter(([e,r])=>e!==this.importPath).map(([e,r])=>` ${r} "${e}"`).join(`
15
15
  `);return t?`import (
16
16
  ${t}
17
- )`:""}};var x=class extends Y{async toString({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o}){let s=new se({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o});return this.write(s),s.toString()}toStringSync({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o}){let s=new se({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o});return this.write(s),s.toStringSync()}};var R=class extends x{constructor({name:e,importPath:r}){super();f(this,"name");f(this,"importPath");this.name=e,this.importPath=r}write(e){if(e.importPath===this.importPath){e.write(this.name);return}let r=e.addImport(this.importPath);e.write(`${r}.${this.name}`)}};var gr=new Set(["any","bytes","map","slice"]),ae=class n extends x{constructor(e){super();f(this,"internalType");this.internalType=e}write(e,{comment:r}={}){switch(this.internalType.type){case"any":e.write("interface{}");break;case"bool":e.write("bool");break;case"bytes":e.write("[]byte");break;case"date":case"dateTime":e.writeNode(Tr);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(vr);break;default:g(this.internalType)}}isOptional(){return this.internalType.type==="optional"}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 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 isAlreadyOptional(e){return e.internalType.type==="optional"||gr.has(e.internalType.type)}},Tr=new R({importPath:"time",name:"Time"}),vr=new R({importPath:"github.com/google/uuid",name:"UUID"});c();p();var Ir="sdk";function Fe({config:n,customConfig:t}){let e=Er({config:n}),r=Rr({config:n,customConfig:t});return e!=null?Nr({importPath:r,majorVersion:e}):r}function Rr({config:n,customConfig:t}){var e,r,i;return(i=(r=t==null?void 0:t.importPath)!=null?r:(e=t==null?void 0:t.module)==null?void 0:e.path)!=null?i:n.output.mode.type==="github"?Ur(n.output.mode.repoUrl,"https://"):Ir}function Er({config:n}){let t=Ar({config:n});if(!(t==null||t==="v0"||t==="v1"))return`${t}`}function Ar({config:n}){let t=Pr(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 Nr({importPath:n,majorVersion:t}){return oe(n)===t?n:`${n}/${t}`}function Ur(n,t){return n.startsWith(t)?n.slice(t.length):n}function Pr(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}c();p();c();p();var k=class extends x{constructor(e){super();f(this,"arg");this.arg=e}write(e){return new V(this.arg).write(e)}};c();p();c();p();var N=class extends x{constructor({docs:e}={}){super();f(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
18
- `).forEach(r=>{e.writeLine(`// ${r}`)})}};var j=class extends x{constructor({name:e,docs:r}){super();f(this,"name");f(this,"docs");f(this,"members",[]);this.name=e,this.docs=r}addMember(e){this.members.push(e)}write(e){e.writeNode(new N({docs:this.docs})),e.write(`type ${this.name} string`)}};c();p();var H=class extends x{constructor({name:e,type:r,docs:i}){super();f(this,"name");f(this,"type");f(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)}};c();p();c();p();var L=class extends x{constructor({name:e,parameters:r,return_:i,body:o,docs:s,typeReference:l}){super();f(this,"name");f(this,"parameters");f(this,"return_");f(this,"body");f(this,"docs");f(this,"typeReference");this.name=e,this.parameters=r,this.return_=i,this.body=o,this.docs=s,this.typeReference=l}write(e){var r;if(e.writeNode(new N({docs:this.docs})),e.write("func "),this.typeReference!=null&&this.writeReceiver({writer:e,typeReference:this.typeReference}),e.write(`${this.name}`),this.parameters.length===0)e.write("() ");else{e.writeLine("(");for(let i of this.parameters)e.writeNode(i),e.writeLine(",");e.write(")")}this.return_!=null&&(e.write("("),this.return_.forEach((i,o)=>{o>0&&e.write(", "),e.writeNode(i)}),e.write(")")),e.writeLine(" {"),e.indent(),(r=this.body)==null||r.write(e),e.dedent(),e.writeNewLineIfLastLineNot(),e.writeLine("}")}writeReceiver({writer:e,typeReference:r}){e.write(`(${this.getReceiverName(r.name)} `),r.write(e),e.write(") ")}getReceiverName(e){return e.charAt(0).toLowerCase()}};var q=class extends x{constructor({name:e,parameters:r,return_:i,body:o,docs:s}){super();f(this,"func");this.func=new L({name:e,parameters:r,return_:i,body:o,docs:s})}get name(){return this.func.name}get parameters(){return this.func.parameters}get return_(){return this.func.return_}get body(){return this.func.body}get docs(){return this.func.docs}write(e){e.writeNode(this.func)}};c();p();c();p();c();p();c();p();var D=class extends x{constructor({method:e,arguments_:r,on:i}){super();f(this,"on");f(this,"method");f(this,"arguments_");this.on=i,this.method=e,this.arguments_=r}write(e){this.on.write(e),e.write("."),e.write(this.method),xe({writer:e,arguments_:this.arguments_})}};var br=new Set(["bool","date","dateTime","float64","int","int64","string","uuid"]),at=new Set(["any","bytes","map","slice"]),U=class n extends x{constructor(e){super();f(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(kr({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(`
19
- `)?`\`${this.internalType.value}\``:`"${this.internalType.value}"`);break;case"struct":this.writeStruct({writer:e,struct:this.internalType});break;case"uuid":e.writeNode(_r({value:this.internalType.value}));break;default:g(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}){return new this({type:"optional",value:new this({type:"struct",typeReference:e,fields:r})})}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("[]interface{}"),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]interface{}");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=Br({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(br.has(r.internalType.type)){e.writeNode(Fr({writer:e,type:r}));return}if(at.has(r.internalType.type)){r.write(e);return}if(r.internalType.type==="enum"){e.writeNode(new D({on:r.internalType.typeReference,method:"Ptr",arguments_:[]}));return}e.write("&"),r.write(e)}static isAlreadyOptional(e){return e.internalType.type==="optional"||at.has(e.internalType.type)}writeSlice({writer:e,slice:r}){e.write("[]"),e.writeNode(r.valueType);let i=Dr({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);let i=Lr({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 Fr({writer:n,type:t}){return new b({func:new R({name:Sr({type:t}),importPath:n.rootImportPath}),arguments_:[t]})}function Sr({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 kr({writer:n,type:t}){let e=t instanceof Date?"MustParseDate":"MustParseDateTime";return new b({func:new R({name:e,importPath:n.rootImportPath}),arguments_:[new k(`"${t.value}"`)]})}function _r({value:n}){return new b({func:new R({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new k(`"${n}"`)]})}function Br({entries:n}){return n.filter(t=>!U.isNop(t.key)&&!U.isNop(t.value))}function Lr({fields:n}){return n.filter(t=>!U.isNop(t.value))}function Dr({values:n}){return n.filter(t=>!U.isNop(t))}function xe({writer:n,arguments_:t}){let e=Mr(t);if(e.length===0){n.write("()");return}n.writeLine("("),n.indent();for(let r of e)Cr({writer:n,argument:r}),n.writeLine(",");n.dedent(),n.write(")")}function Cr({writer:n,argument:t}){be(t)?t.assignment.write(n):t.write(n)}function Mr(n){return n.filter(t=>!(t instanceof U&&U.isNop(t)))}var b=class extends x{constructor({func:e,arguments_:r}){super();f(this,"func");f(this,"arguments_");this.func=e,this.arguments_=r}write(e){e.writeNode(this.func),xe({writer:e,arguments_:this.arguments_})}};c();p();var z=class extends x{constructor({name:e,type:r,docs:i}){super();f(this,"name");f(this,"type");f(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)}};c();p();var X=class extends x{constructor({name:e,importPath:r,docs:i}){super();f(this,"name");f(this,"importPath");f(this,"docs");f(this,"fields",[]);f(this,"methods",[]);this.name=e,this.importPath=r,this.docs=i}addField(e){this.fields.push(e)}addMethod(e){this.methods.push(e)}write(e){if(e.writeNode(new N({docs:this.docs})),e.write(`type ${this.name} struct {`),this.fields.length>0)e.writeLine("}");else{e.newLine(),e.indent();for(let r of this.fields)e.writeNode(r),e.newLine();e.dedent(),e.writeLine("}")}(this.constructor!=null||this.methods.length>0)&&e.newLine();for(let r of this.methods)e.writeNode(r),e.newLine()}};var u={};Ce(u,{AstNode:()=>x,CodeBlock:()=>k,Enum:()=>j,Field:()=>H,Func:()=>q,FuncInvocation:()=>b,Method:()=>L,MethodInvocation:()=>D,Parameter:()=>z,Struct:()=>X,Type:()=>ae,TypeInstantiation:()=>U,TypeReference:()=>R,Writer:()=>W,codeblock:()=>Vr,enum_:()=>$r,field:()=>Or,func:()=>Gr,invokeFunc:()=>Yr,invokeMethod:()=>Wr,method:()=>jr,parameter:()=>Hr,struct:()=>qr,typeReference:()=>zr});c();p();function Vr(n){return new k(n)}function $r(n){return new j(n)}function Or(n){return new H(n)}function Gr(n){return new q(n)}function Yr(n){return new b(n)}function Wr(n){return new D(n)}function jr(n){return new L(n)}function Hr(n){return new z(n)}function qr(n){return new X(n)}function zr(n){return new R(n)}c();p();var ge=class{constructor({context:t}){f(this,"context");this.context=t}convert(t){if(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"optional":return u.TypeInstantiation.optional(this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as}));case"primitive":return this.convertPrimitive({primitive:t.typeReference.value,value:t.value,as:t.as});case"set":return this.convertList({list:t.typeReference.value,value:t.value});case"unknown":return this.convertUnknown({value:t.value});default:g(t.typeReference)}}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:T.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:T.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.convert({typeReference:t.typeReference,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.convertUndicriminatedUnion({undicriminatedUnion:t,value:e});default:g(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 l=this.context.resolveNamedType({typeId:o.typeId});return l==null?u.TypeInstantiation.nop():u.TypeInstantiation.structPointer({typeReference:r,fields:[{name:this.context.getTypeName(o.discriminantValue.name),value:this.convertNamed({named:l,value:i.value})},...s]})}case"singleProperty":{let l=this.context.getRecord(i.value);if(l==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:l[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:g(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:T.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:T.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)}`}convertUndicriminatedUnion({undicriminatedUnion:t,value:e}){let r=this.findMatchingUndiscriminatedUnionType({undicriminatedUnion: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({undicriminatedUnion: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:T.Critical,message:`None of the types in the undicriminated 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({optional:t});case"primitive":return this.getUndiscriminatedUnionFieldNameForPrimitive({primitive:t.value});case"set":return this.getUndiscriminatedUnionFieldNameForSet({set:t});case"unknown":return"Unknown"}}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({optional: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}BoolLiteral`;case"string":return`${t.value}StringLiteral`;default:g(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:g(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});return i==null?u.TypeInstantiation.nop():u.TypeInstantiation.dateTime(i)}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:g(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})}};c();p();var Te=class{constructor({context:t}){f(this,"context");this.context=t}convert(t){switch(t.typeReference.type){case"list":return u.Type.slice(this.convert({typeReference:t.typeReference}));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"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:g(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:g(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:g(t)}}};c();p();var ve=class{constructor({context:t}){f(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:g(s)}return r}getSingleFileProperty({property:t,record:e}){let r=this.context.getSingleFileValue({property:t,record:e});return r==null?u.TypeInstantiation.nop():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 Se=class n extends ie{constructor({ir:e,config:r}){super({ir:e,config:r});f(this,"ir");f(this,"customConfig");f(this,"dynamicTypeMapper");f(this,"dynamicTypeInstantiationMapper");f(this,"filePropertyMapper");f(this,"rootImportPath");this.ir=e,this.customConfig=r.customConfig!=null?r.customConfig:void 0,this.dynamicTypeMapper=new Te({context:this}),this.dynamicTypeInstantiationMapper=new ge({context:this}),this.filePropertyMapper=new ve({context:this}),this.rootImportPath=Fe({config:r,customConfig:this.customConfig})}clone(){return new n({ir:this.ir,config:this.config})}getMethodName(e){return e.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("/")}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"})}getNewStringsReaderFunctionInvocation(e){return u.invokeFunc({func:u.typeReference({name:"NewReader",importPath:"strings"}),arguments_:[u.TypeInstantiation.string(e)]})}getClientConstructorName(){var e;return((e=this.customConfig)==null?void 0:e.exportedClientName)!=null?`New${this.customConfig.exportedClientName}`:"NewClient"}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})}};0&&(module.exports={DynamicSnippetsGeneratorContext});
17
+ )`:""}};var x=class extends Y{async toStringAsync({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o}){let s=new se({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 se({packageName:t,rootImportPath:e,importPath:r,customConfig:i,formatter:o});return this.write(s),s.toString()}};var R=class extends x{constructor({name:e,importPath:r}){super();l(this,"name");l(this,"importPath");this.name=e,this.importPath=r}write(e){if(e.importPath===this.importPath){e.write(this.name);return}let r=e.addImport(this.importPath);e.write(`${r}.${this.name}`)}};var Tr=new Set(["any","bytes","map","slice"]),ae=class n extends x{constructor(e){super();l(this,"internalType");this.internalType=e}write(e,{comment:r}={}){switch(this.internalType.type){case"any":e.write("interface{}");break;case"bool":e.write("bool");break;case"bytes":e.write("[]byte");break;case"date":case"dateTime":e.writeNode(gr);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(vr);break;default:T(this.internalType)}}isOptional(){return this.internalType.type==="optional"}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 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 isAlreadyOptional(e){return e.internalType.type==="optional"||Tr.has(e.internalType.type)}},gr=new R({importPath:"time",name:"Time"}),vr=new R({importPath:"github.com/google/uuid",name:"UUID"});c();p();var Ir="sdk";function Fe({config:n,customConfig:t}){let e=Er({config:n}),r=Rr({config:n,customConfig:t});return e!=null?Nr({importPath:r,majorVersion:e}):r}function Rr({config:n,customConfig:t}){var e,r,i;return(i=(r=t==null?void 0:t.importPath)!=null?r:(e=t==null?void 0:t.module)==null?void 0:e.path)!=null?i:n.output.mode.type==="github"?Ur(n.output.mode.repoUrl,"https://"):Ir}function Er({config:n}){let t=Ar({config:n});if(!(t==null||t==="v0"||t==="v1"))return`${t}`}function Ar({config:n}){let t=br(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 Nr({importPath:n,majorVersion:t}){return oe(n)===t?n:`${n}/${t}`}function Ur(n,t){return n.startsWith(t)?n.slice(t.length):n}function br(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}c();p();c();p();var k=class extends x{constructor(e){super();l(this,"arg");this.arg=e}write(e){return new V(this.arg).write(e)}};c();p();c();p();var N=class extends x{constructor({docs:e}={}){super();l(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
18
+ `).forEach(r=>{e.writeLine(`// ${r}`)})}};var j=class extends x{constructor({name:e,docs:r}){super();l(this,"name");l(this,"docs");l(this,"members",[]);this.name=e,this.docs=r}addMember(e){this.members.push(e)}write(e){e.writeNode(new N({docs:this.docs})),e.write(`type ${this.name} string`)}};c();p();var H=class extends x{constructor({name:e,type:r,docs:i}){super();l(this,"name");l(this,"type");l(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)}};c();p();c();p();var L=class extends x{constructor({name:e,parameters:r,return_:i,body:o,docs:s,typeReference:f}){super();l(this,"name");l(this,"parameters");l(this,"return_");l(this,"body");l(this,"docs");l(this,"typeReference");this.name=e,this.parameters=r,this.return_=i,this.body=o,this.docs=s,this.typeReference=f}write(e){var r;if(e.writeNode(new N({docs:this.docs})),e.write("func "),this.typeReference!=null&&this.writeReceiver({writer:e,typeReference:this.typeReference}),e.write(`${this.name}`),this.parameters.length===0)e.write("() ");else{e.writeLine("(");for(let i of this.parameters)e.writeNode(i),e.writeLine(",");e.write(")")}this.return_!=null&&(e.write("("),this.return_.forEach((i,o)=>{o>0&&e.write(", "),e.writeNode(i)}),e.write(")")),e.writeLine(" {"),e.indent(),(r=this.body)==null||r.write(e),e.dedent(),e.writeNewLineIfLastLineNot(),e.writeLine("}")}writeReceiver({writer:e,typeReference:r}){e.write(`(${this.getReceiverName(r.name)} `),r.write(e),e.write(") ")}getReceiverName(e){return e.charAt(0).toLowerCase()}};var q=class extends x{constructor({name:e,parameters:r,return_:i,body:o,docs:s}){super();l(this,"func");this.func=new L({name:e,parameters:r,return_:i,body:o,docs:s})}get name(){return this.func.name}get parameters(){return this.func.parameters}get return_(){return this.func.return_}get body(){return this.func.body}get docs(){return this.func.docs}write(e){e.writeNode(this.func)}};c();p();c();p();c();p();c();p();var D=class extends x{constructor({method:e,arguments_:r,on:i}){super();l(this,"on");l(this,"method");l(this,"arguments_");this.on=i,this.method=e,this.arguments_=r}write(e){this.on.write(e),e.write("."),e.write(this.method),xe({writer:e,arguments_:this.arguments_})}};var Pr=new Set(["bool","date","dateTime","float64","int","int64","string","uuid"]),at=new Set(["any","bytes","map","slice"]),U=class n extends x{constructor(e){super();l(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(kr({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(`
19
+ `)?`\`${this.internalType.value}\``:`"${this.internalType.value}"`);break;case"struct":this.writeStruct({writer:e,struct:this.internalType});break;case"uuid":e.writeNode(_r({value:this.internalType.value}));break;default:T(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}){return new this({type:"optional",value:new this({type:"struct",typeReference:e,fields:r})})}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("[]interface{}"),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]interface{}");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=Br({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(Pr.has(r.internalType.type)){e.writeNode(Fr({writer:e,type:r}));return}if(at.has(r.internalType.type)){r.write(e);return}if(r.internalType.type==="enum"){e.writeNode(new D({on:r.internalType.typeReference,method:"Ptr",arguments_:[]}));return}e.write("&"),r.write(e)}static isAlreadyOptional(e){return e.internalType.type==="optional"||at.has(e.internalType.type)}writeSlice({writer:e,slice:r}){e.write("[]"),e.writeNode(r.valueType);let i=Dr({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);let i=Lr({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 Fr({writer:n,type:t}){return new P({func:new R({name:Sr({type:t}),importPath:n.rootImportPath}),arguments_:[t]})}function Sr({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 kr({writer:n,type:t}){let e=t instanceof Date?"MustParseDate":"MustParseDateTime";return new P({func:new R({name:e,importPath:n.rootImportPath}),arguments_:[new k(`"${t.value}"`)]})}function _r({value:n}){return new P({func:new R({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new k(`"${n}"`)]})}function Br({entries:n}){return n.filter(t=>!U.isNop(t.key)&&!U.isNop(t.value))}function Lr({fields:n}){return n.filter(t=>!U.isNop(t.value))}function Dr({values:n}){return n.filter(t=>!U.isNop(t))}function xe({writer:n,arguments_:t}){let e=Mr(t);if(e.length===0){n.write("()");return}n.writeLine("("),n.indent();for(let r of e)Cr({writer:n,argument:r}),n.writeLine(",");n.dedent(),n.write(")")}function Cr({writer:n,argument:t}){Pe(t)?t.assignment.write(n):t.write(n)}function Mr(n){return n.filter(t=>!(t instanceof U&&U.isNop(t)))}var P=class extends x{constructor({func:e,arguments_:r}){super();l(this,"func");l(this,"arguments_");this.func=e,this.arguments_=r}write(e){e.writeNode(this.func),xe({writer:e,arguments_:this.arguments_})}};c();p();var z=class extends x{constructor({name:e,type:r,docs:i}){super();l(this,"name");l(this,"type");l(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)}};c();p();var X=class extends x{constructor({name:e,importPath:r,docs:i}){super();l(this,"name");l(this,"importPath");l(this,"docs");l(this,"fields",[]);l(this,"methods",[]);this.name=e,this.importPath=r,this.docs=i}addField(e){this.fields.push(e)}addMethod(e){this.methods.push(e)}write(e){if(e.writeNode(new N({docs:this.docs})),e.write(`type ${this.name} struct {`),this.fields.length>0)e.writeLine("}");else{e.newLine(),e.indent();for(let r of this.fields)e.writeNode(r),e.newLine();e.dedent(),e.writeLine("}")}(this.constructor!=null||this.methods.length>0)&&e.newLine();for(let r of this.methods)e.writeNode(r),e.newLine()}};var u={};Ce(u,{AstNode:()=>x,CodeBlock:()=>k,Enum:()=>j,Field:()=>H,Func:()=>q,FuncInvocation:()=>P,Method:()=>L,MethodInvocation:()=>D,Parameter:()=>z,Struct:()=>X,Type:()=>ae,TypeInstantiation:()=>U,TypeReference:()=>R,Writer:()=>W,codeblock:()=>Vr,enum_:()=>$r,field:()=>Or,func:()=>Gr,invokeFunc:()=>Yr,invokeMethod:()=>Wr,method:()=>jr,parameter:()=>Hr,struct:()=>qr,typeReference:()=>zr});c();p();function Vr(n){return new k(n)}function $r(n){return new j(n)}function Or(n){return new H(n)}function Gr(n){return new q(n)}function Yr(n){return new P(n)}function Wr(n){return new D(n)}function jr(n){return new L(n)}function Hr(n){return new z(n)}function qr(n){return new X(n)}function zr(n){return new R(n)}c();p();var Te=class{constructor({context:t}){l(this,"context");this.context=t}convert(t){if(t.value===null&&!this.context.isNullable(t.typeReference)&&this.context.errors.add({severity:g.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":return u.TypeInstantiation.optional(this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as}));case"optional":return u.TypeInstantiation.optional(this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as}));case"primitive":return this.convertPrimitive({primitive:t.typeReference.value,value:t.value,as:t.as});case"set":return this.convertList({list:t.typeReference.value,value:t.value});case"unknown":return this.convertUnknown({value:t.value});default:T(t.typeReference)}}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:g.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:g.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.convert({typeReference:t.typeReference,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.convertUndicriminatedUnion({undicriminatedUnion:t,value:e});default:T(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:T(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:g.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:g.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)}`}convertUndicriminatedUnion({undicriminatedUnion:t,value:e}){let r=this.findMatchingUndiscriminatedUnionType({undicriminatedUnion: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({undicriminatedUnion: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:g.Critical,message:`None of the types in the undicriminated 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:T(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:T(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:T(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});return i==null?u.TypeInstantiation.nop():u.TypeInstantiation.dateTime(i)}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:T(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})}};c();p();var ge=class{constructor({context:t}){l(this,"context");this.context=t}convert(t){switch(t.typeReference.type){case"list":return u.Type.slice(this.convert({typeReference:t.typeReference}));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:T(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:T(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:T(t)}}};c();p();var ve=class{constructor({context:t}){l(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:T(s)}return r}getSingleFileProperty({property:t,record:e}){let r=this.context.getSingleFileValue({property:t,record:e});return r==null?u.TypeInstantiation.nop():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 Se=class n extends ie{constructor({ir:e,config:r}){super({ir:e,config:r});l(this,"ir");l(this,"customConfig");l(this,"dynamicTypeMapper");l(this,"dynamicTypeInstantiationMapper");l(this,"filePropertyMapper");l(this,"rootImportPath");this.ir=e,this.customConfig=r.customConfig!=null?r.customConfig:void 0,this.dynamicTypeMapper=new ge({context:this}),this.dynamicTypeInstantiationMapper=new Te({context:this}),this.filePropertyMapper=new ve({context:this}),this.rootImportPath=Fe({config:r,customConfig:this.customConfig})}clone(){return new n({ir:this.ir,config:this.config})}getMethodName(e){return e.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("/")}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"})}getNewStringsReaderFunctionInvocation(e){return u.invokeFunc({func:u.typeReference({name:"NewReader",importPath:"strings"}),arguments_:[u.TypeInstantiation.string(e)]})}getClientConstructorName(){var e;return((e=this.customConfig)==null?void 0:e.exportedClientName)!=null?`New${this.customConfig.exportedClientName}`:"NewClient"}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})}};0&&(module.exports={DynamicSnippetsGeneratorContext});
20
20
  /*! Bundled license information:
21
21
 
22
22
  @esbuild-plugins/node-globals-polyfill/Buffer.js: