@fern-api/python-dynamic-snippets 4.63.5 → 4.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +8 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
"use strict";var Ye=Object.defineProperty;var Bi=Object.getOwnPropertyDescriptor;var Pi=Object.getOwnPropertyNames;var Fi=Object.prototype.hasOwnProperty;var Ci=(p,t,e)=>t in p?Ye(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e;var ve=(p,t)=>()=>(p&&(t=p(p=0)),t);var mt=(p,t)=>{for(var e in t)Ye(p,e,{get:t[e],enumerable:!0})},ki=(p,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Pi(t))!Fi.call(p,a)&&a!==e&&Ye(p,a,{get:()=>t[a],enumerable:!(i=Bi(t,a))||i.enumerable});return p};var Li=p=>ki(Ye({},"__esModule",{value:!0}),p);var y=(p,t,e)=>Ci(p,typeof t!="symbol"?t+"":t,e);var f=ve(()=>{"use strict"});var w={};mt(w,{_debugEnd:()=>Rr,_debugProcess:()=>Tr,_events:()=>Dr,_eventsCount:()=>jr,_exiting:()=>or,_fatalExceptions:()=>vr,_getActiveHandles:()=>pr,_getActiveRequests:()=>ur,_kill:()=>cr,_linkedBinding:()=>nr,_maxListeners:()=>$r,_preload_modules:()=>Or,_rawDebug:()=>tr,_startProfilerIdleNotifier:()=>Ar,_stopProfilerIdleNotifier:()=>Nr,_tickCallback:()=>Er,abort:()=>Fr,addListener:()=>Wr,allowedNodeEnvironmentFlags:()=>gr,arch:()=>Dt,argv:()=>qt,argv0:()=>Mr,assert:()=>xr,binding:()=>Yt,browser:()=>er,chdir:()=>Kt,config:()=>ar,cpuUsage:()=>Ke,cwd:()=>Jt,debugPort:()=>Ur,default:()=>Kr,dlopen:()=>sr,domain:()=>ir,emit:()=>Qr,emitWarning:()=>Qt,env:()=>Wt,execArgv:()=>Gt,execPath:()=>Lr,exit:()=>hr,features:()=>wr,hasUncaughtExceptionCaptureCallback:()=>br,hrtime:()=>Je,kill:()=>mr,listeners:()=>Jr,memoryUsage:()=>dr,moduleLoadList:()=>rr,nextTick:()=>_t,off:()=>Gr,on:()=>re,once:()=>qr,openStdin:()=>yr,pid:()=>Cr,platform:()=>jt,ppid:()=>kr,prependListener:()=>Yr,prependOnceListener:()=>Zr,reallyExit:()=>lr,release:()=>Xt,removeAllListeners:()=>Hr,removeListener:()=>zr,resourceUsage:()=>fr,setSourceMapsEnabled:()=>_r,setUncaughtExceptionCaptureCallback:()=>Ir,stderr:()=>Br,stdin:()=>Pr,stdout:()=>Sr,title:()=>$t,umask:()=>Zt,uptime:()=>Vr,version:()=>zt,versions:()=>Ht});function gt(p){throw new Error("Node.js process "+p+" is not supported by JSPM core outside of Node.js")}function Ui(){!Ie||!me||(Ie=!1,me.length?te=me.concat(te):Ze=-1,te.length&&Ot())}function Ot(){if(!Ie){var p=setTimeout(Ui,0);Ie=!0;for(var t=te.length;t;){for(me=te,te=[];++Ze<t;)me&&me[Ze].run();Ze=-1,t=te.length}me=null,Ie=!1,clearTimeout(p)}}function _t(p){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];te.push(new Vt(p,t)),te.length===1&&!Ie&&setTimeout(Ot,0)}function Vt(p,t){this.fun=p,this.array=t}function j(){}function nr(p){gt("_linkedBinding")}function sr(p){gt("dlopen")}function ur(){return[]}function pr(){return[]}function xr(p,t){if(!p)throw new Error(t||"assertion error")}function br(){return!1}function Vr(){return ae.now()/1e3}function Je(p){var t=Math.floor((Date.now()-ae.now())*.001),e=ae.now()*.001,i=Math.floor(e)+t,a=Math.floor(e%1*1e9);return p&&(i=i-p[0],a=a-p[1],a<0&&(i--,a+=yt)),[i,a]}function re(){return Kr}function Jr(p){return[]}var te,Ie,me,Ze,$t,Dt,jt,Wt,qt,Gt,zt,Ht,Qt,Yt,Zt,Jt,Kt,Xt,er,tr,rr,ir,or,ar,lr,cr,Ke,fr,dr,mr,hr,yr,gr,wr,vr,Ir,Er,Tr,Rr,Ar,Nr,Sr,Br,Pr,Fr,Cr,kr,Lr,Ur,Mr,Or,_r,ae,ht,yt,$r,Dr,jr,Wr,qr,Gr,zr,Hr,Qr,Yr,Zr,Kr,Xr=ve(()=>{"use strict";f();m();d();te=[],Ie=!1,Ze=-1;Vt.prototype.run=function(){this.fun.apply(null,this.array)};$t="browser",Dt="x64",jt="browser",Wt={PATH:"/usr/bin",LANG:typeof navigator<"u"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},qt=["/usr/bin/node"],Gt=[],zt="v16.8.0",Ht={},Qt=function(p,t){console.warn((t?t+": ":"")+p)},Yt=function(p){gt("binding")},Zt=function(p){return 0},Jt=function(){return"/"},Kt=function(p){},Xt={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};er=!0,tr=j,rr=[];ir={},or=!1,ar={};lr=j,cr=j,Ke=function(){return{}},fr=Ke,dr=Ke,mr=j,hr=j,yr=j,gr={};wr={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},vr=j,Ir=j;Er=j,Tr=j,Rr=j,Ar=j,Nr=j,Sr=void 0,Br=void 0,Pr=void 0,Fr=j,Cr=2,kr=1,Lr="/bin/usr/node",Ur=9229,Mr="node",Or=[],_r=j,ae={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};ae.now===void 0&&(ht=Date.now(),ae.timing&&ae.timing.navigationStart&&(ht=ae.timing.navigationStart),ae.now=()=>Date.now()-ht);yt=1e9;Je.bigint=function(p){var t=Je(p);return typeof BigInt>"u"?t[0]*yt+t[1]:BigInt(t[0]*yt)+BigInt(t[1])};$r=10,Dr={},jr=0;Wr=re,qr=re,Gr=re,zr=re,Hr=re,Qr=j,Yr=re,Zr=re;Kr={version:zt,versions:Ht,arch:Dt,platform:jt,browser:er,release:Xt,_rawDebug:tr,moduleLoadList:rr,binding:Yt,_linkedBinding:nr,_events:Dr,_eventsCount:jr,_maxListeners:$r,on:re,addListener:Wr,once:qr,off:Gr,removeListener:zr,removeAllListeners:Hr,emit:Qr,prependListener:Yr,prependOnceListener:Zr,listeners:Jr,domain:ir,_exiting:or,config:ar,dlopen:sr,uptime:Vr,_getActiveRequests:ur,_getActiveHandles:pr,reallyExit:lr,_kill:cr,cpuUsage:Ke,resourceUsage:fr,memoryUsage:dr,kill:mr,exit:hr,openStdin:yr,allowedNodeEnvironmentFlags:gr,assert:xr,features:wr,_fatalExceptions:vr,setUncaughtExceptionCaptureCallback:Ir,hasUncaughtExceptionCaptureCallback:br,emitWarning:Qt,nextTick:_t,_tickCallback:Er,_debugProcess:Tr,_debugEnd:Rr,_startProfilerIdleNotifier:Ar,_stopProfilerIdleNotifier:Nr,stdout:Sr,stdin:Pr,stderr:Br,abort:Fr,umask:Zt,chdir:Kt,cwd:Jt,env:Wt,title:$t,argv:qt,execArgv:Gt,pid:Cr,ppid:kr,execPath:Lr,debugPort:Ur,hrtime:Je,argv0:Mr,_preload_modules:Or,setSourceMapsEnabled:_r}});var d=ve(()=>{"use strict";Xr()});function Mi(){if(en)return Oe;en=!0,Oe.byteLength=E,Oe.toByteArray=A,Oe.fromByteArray=$;for(var p=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,l=i.length;a<l;++a)p[a]=i[a],t[i.charCodeAt(a)]=a;t[45]=62,t[95]=63;function s(T){var N=T.length;if(N%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=T.indexOf("=");k===-1&&(k=N);var M=k===N?0:4-k%4;return[k,M]}function E(T){var N=s(T),k=N[0],M=N[1];return(k+M)*3/4-M}function b(T,N,k){return(N+k)*3/4-k}function A(T){var N,k=s(T),M=k[0],q=k[1],V=new e(b(T,M,q)),G=0,H=q>0?M-4:M,W;for(W=0;W<H;W+=4)N=t[T.charCodeAt(W)]<<18|t[T.charCodeAt(W+1)]<<12|t[T.charCodeAt(W+2)]<<6|t[T.charCodeAt(W+3)],V[G++]=N>>16&255,V[G++]=N>>8&255,V[G++]=N&255;return q===2&&(N=t[T.charCodeAt(W)]<<2|t[T.charCodeAt(W+1)]>>4,V[G++]=N&255),q===1&&(N=t[T.charCodeAt(W)]<<10|t[T.charCodeAt(W+1)]<<4|t[T.charCodeAt(W+2)]>>2,V[G++]=N>>8&255,V[G++]=N&255),V}function R(T){return p[T>>18&63]+p[T>>12&63]+p[T>>6&63]+p[T&63]}function F(T,N,k){for(var M,q=[],V=N;V<k;V+=3)M=(T[V]<<16&16711680)+(T[V+1]<<8&65280)+(T[V+2]&255),q.push(R(M));return q.join("")}function $(T){for(var N,k=T.length,M=k%3,q=[],V=16383,G=0,H=k-M;G<H;G+=V)q.push(F(T,G,G+V>H?H:G+V));return M===1?(N=T[k-1],q.push(p[N>>2]+p[N<<4&63]+"==")):M===2&&(N=(T[k-2]<<8)+T[k-1],q.push(p[N>>10]+p[N>>4&63]+p[N<<2&63]+"=")),q.join("")}return Oe}function Oi(){if(tn)return Xe;tn=!0;return Xe.read=function(p,t,e,i,a){var l,s,E=a*8-i-1,b=(1<<E)-1,A=b>>1,R=-7,F=e?a-1:0,$=e?-1:1,T=p[t+F];for(F+=$,l=T&(1<<-R)-1,T>>=-R,R+=E;R>0;l=l*256+p[t+F],F+=$,R-=8);for(s=l&(1<<-R)-1,l>>=-R,R+=i;R>0;s=s*256+p[t+F],F+=$,R-=8);if(l===0)l=1-A;else{if(l===b)return s?NaN:(T?-1:1)*(1/0);s=s+Math.pow(2,i),l=l-A}return(T?-1:1)*s*Math.pow(2,l-i)},Xe.write=function(p,t,e,i,a,l){var s,E,b,A=l*8-a-1,R=(1<<A)-1,F=R>>1,$=a===23?Math.pow(2,-24)-Math.pow(2,-77):0,T=i?0:l-1,N=i?1:-1,k=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(E=isNaN(t)?1:0,s=R):(s=Math.floor(Math.log(t)/Math.LN2),t*(b=Math.pow(2,-s))<1&&(s--,b*=2),s+F>=1?t+=$/b:t+=$*Math.pow(2,1-F),t*b>=2&&(s++,b/=2),s+F>=R?(E=0,s=R):s+F>=1?(E=(t*b-1)*Math.pow(2,a),s=s+F):(E=t*Math.pow(2,F-1)*Math.pow(2,a),s=0));a>=8;p[e+T]=E&255,T+=N,E/=256,a-=8);for(s=s<<a|E,A+=a;A>0;p[e+T]=s&255,T+=N,s/=256,A-=8);p[e+T-N]|=k*128},Xe}function nn(){if(rn)return he;rn=!0;let p=Mi(),t=Oi(),e=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;he.Buffer=s,he.SlowBuffer=q,he.INSPECT_MAX_BYTES=50;let i=2147483647;he.kMaxLength=i,s.TYPED_ARRAY_SUPPORT=a(),!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function a(){try{let o=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(o,r),o.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function l(o){if(o>i)throw new RangeError('The value "'+o+'" is invalid for option "size"');let r=new Uint8Array(o);return Object.setPrototypeOf(r,s.prototype),r}function s(o,r,n){if(typeof o=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return R(o)}return E(o,r,n)}s.poolSize=8192;function E(o,r,n){if(typeof o=="string")return F(o,r);if(ArrayBuffer.isView(o))return T(o);if(o==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o);if(J(o,ArrayBuffer)||o&&J(o.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(J(o,SharedArrayBuffer)||o&&J(o.buffer,SharedArrayBuffer)))return N(o,r,n);if(typeof o=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let u=o.valueOf&&o.valueOf();if(u!=null&&u!==o)return s.from(u,r,n);let c=k(o);if(c)return c;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof o[Symbol.toPrimitive]=="function")return s.from(o[Symbol.toPrimitive]("string"),r,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o)}s.from=function(o,r,n){return E(o,r,n)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function b(o){if(typeof o!="number")throw new TypeError('"size" argument must be of type number');if(o<0)throw new RangeError('The value "'+o+'" is invalid for option "size"')}function A(o,r,n){return b(o),o<=0?l(o):r!==void 0?typeof n=="string"?l(o).fill(r,n):l(o).fill(r):l(o)}s.alloc=function(o,r,n){return A(o,r,n)};function R(o){return b(o),l(o<0?0:M(o)|0)}s.allocUnsafe=function(o){return R(o)},s.allocUnsafeSlow=function(o){return R(o)};function F(o,r){if((typeof r!="string"||r==="")&&(r="utf8"),!s.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let n=V(o,r)|0,u=l(n),c=u.write(o,r);return c!==n&&(u=u.slice(0,c)),u}function $(o){let r=o.length<0?0:M(o.length)|0,n=l(r);for(let u=0;u<r;u+=1)n[u]=o[u]&255;return n}function T(o){if(J(o,Uint8Array)){let r=new Uint8Array(o);return N(r.buffer,r.byteOffset,r.byteLength)}return $(o)}function N(o,r,n){if(r<0||o.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(o.byteLength<r+(n||0))throw new RangeError('"length" is outside of buffer bounds');let u;return r===void 0&&n===void 0?u=new Uint8Array(o):n===void 0?u=new Uint8Array(o,r):u=new Uint8Array(o,r,n),Object.setPrototypeOf(u,s.prototype),u}function k(o){if(s.isBuffer(o)){let r=M(o.length)|0,n=l(r);return n.length===0||o.copy(n,0,0,r),n}if(o.length!==void 0)return typeof o.length!="number"||dt(o.length)?l(0):$(o);if(o.type==="Buffer"&&Array.isArray(o.data))return $(o.data)}function M(o){if(o>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return o|0}function q(o){return+o!=o&&(o=0),s.alloc(+o)}s.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==s.prototype},s.compare=function(r,n){if(J(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),J(n,Uint8Array)&&(n=s.from(n,n.offset,n.byteLength)),!s.isBuffer(r)||!s.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===n)return 0;let u=r.length,c=n.length;for(let h=0,g=Math.min(u,c);h<g;++h)if(r[h]!==n[h]){u=r[h],c=n[h];break}return u<c?-1:c<u?1:0},s.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(r,n){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return s.alloc(0);let u;if(n===void 0)for(n=0,u=0;u<r.length;++u)n+=r[u].length;let c=s.allocUnsafe(n),h=0;for(u=0;u<r.length;++u){let g=r[u];if(J(g,Uint8Array))h+g.length>c.length?(s.isBuffer(g)||(g=s.from(g)),g.copy(c,h)):Uint8Array.prototype.set.call(c,g,h);else if(s.isBuffer(g))g.copy(c,h);else throw new TypeError('"list" argument must be an Array of Buffers');h+=g.length}return c};function V(o,r){if(s.isBuffer(o))return o.length;if(ArrayBuffer.isView(o)||J(o,ArrayBuffer))return o.byteLength;if(typeof o!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof o);let n=o.length,u=arguments.length>2&&arguments[2]===!0;if(!u&&n===0)return 0;let c=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return ft(o).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return Mt(o).length;default:if(c)return u?-1:ft(o).length;r=(""+r).toLowerCase(),c=!0}}s.byteLength=V;function G(o,r,n){let u=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,r>>>=0,n<=r))return"";for(o||(o="utf8");;)switch(o){case"hex":return vi(this,r,n);case"utf8":case"utf-8":return Nt(this,r,n);case"ascii":return xi(this,r,n);case"latin1":case"binary":return wi(this,r,n);case"base64":return yi(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ii(this,r,n);default:if(u)throw new TypeError("Unknown encoding: "+o);o=(o+"").toLowerCase(),u=!0}}s.prototype._isBuffer=!0;function H(o,r,n){let u=o[r];o[r]=o[n],o[n]=u}s.prototype.swap16=function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<r;n+=2)H(this,n,n+1);return this},s.prototype.swap32=function(){let r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<r;n+=4)H(this,n,n+3),H(this,n+1,n+2);return this},s.prototype.swap64=function(){let r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<r;n+=8)H(this,n,n+7),H(this,n+1,n+6),H(this,n+2,n+5),H(this,n+3,n+4);return this},s.prototype.toString=function(){let r=this.length;return r===0?"":arguments.length===0?Nt(this,0,r):G.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(r){if(!s.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:s.compare(this,r)===0},s.prototype.inspect=function(){let r="",n=he.INSPECT_MAX_BYTES;return r=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(r+=" ... "),"<Buffer "+r+">"},e&&(s.prototype[e]=s.prototype.inspect),s.prototype.compare=function(r,n,u,c,h){if(J(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),!s.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(n===void 0&&(n=0),u===void 0&&(u=r?r.length:0),c===void 0&&(c=0),h===void 0&&(h=this.length),n<0||u>r.length||c<0||h>this.length)throw new RangeError("out of range index");if(c>=h&&n>=u)return 0;if(c>=h)return-1;if(n>=u)return 1;if(n>>>=0,u>>>=0,c>>>=0,h>>>=0,this===r)return 0;let g=h-c,B=u-n,O=Math.min(g,B),U=this.slice(c,h),_=r.slice(n,u);for(let L=0;L<O;++L)if(U[L]!==_[L]){g=U[L],B=_[L];break}return g<B?-1:B<g?1:0};function W(o,r,n,u,c){if(o.length===0)return-1;if(typeof n=="string"?(u=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,dt(n)&&(n=c?0:o.length-1),n<0&&(n=o.length+n),n>=o.length){if(c)return-1;n=o.length-1}else if(n<0)if(c)n=0;else return-1;if(typeof r=="string"&&(r=s.from(r,u)),s.isBuffer(r))return r.length===0?-1:At(o,r,n,u,c);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?c?Uint8Array.prototype.indexOf.call(o,r,n):Uint8Array.prototype.lastIndexOf.call(o,r,n):At(o,[r],n,u,c);throw new TypeError("val must be string, number or Buffer")}function At(o,r,n,u,c){let h=1,g=o.length,B=r.length;if(u!==void 0&&(u=String(u).toLowerCase(),u==="ucs2"||u==="ucs-2"||u==="utf16le"||u==="utf-16le")){if(o.length<2||r.length<2)return-1;h=2,g/=2,B/=2,n/=2}function O(_,L){return h===1?_[L]:_.readUInt16BE(L*h)}let U;if(c){let _=-1;for(U=n;U<g;U++)if(O(o,U)===O(r,_===-1?0:U-_)){if(_===-1&&(_=U),U-_+1===B)return _*h}else _!==-1&&(U-=U-_),_=-1}else for(n+B>g&&(n=g-B),U=n;U>=0;U--){let _=!0;for(let L=0;L<B;L++)if(O(o,U+L)!==O(r,L)){_=!1;break}if(_)return U}return-1}s.prototype.includes=function(r,n,u){return this.indexOf(r,n,u)!==-1},s.prototype.indexOf=function(r,n,u){return W(this,r,n,u,!0)},s.prototype.lastIndexOf=function(r,n,u){return W(this,r,n,u,!1)};function ci(o,r,n,u){n=Number(n)||0;let c=o.length-n;u?(u=Number(u),u>c&&(u=c)):u=c;let h=r.length;u>h/2&&(u=h/2);let g;for(g=0;g<u;++g){let B=parseInt(r.substr(g*2,2),16);if(dt(B))return g;o[n+g]=B}return g}function fi(o,r,n,u){return Qe(ft(r,o.length-n),o,n,u)}function di(o,r,n,u){return Qe(Ri(r),o,n,u)}function mi(o,r,n,u){return Qe(Mt(r),o,n,u)}function hi(o,r,n,u){return Qe(Ai(r,o.length-n),o,n,u)}s.prototype.write=function(r,n,u,c){if(n===void 0)c="utf8",u=this.length,n=0;else if(u===void 0&&typeof n=="string")c=n,u=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(u)?(u=u>>>0,c===void 0&&(c="utf8")):(c=u,u=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let h=this.length-n;if((u===void 0||u>h)&&(u=h),r.length>0&&(u<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");c||(c="utf8");let g=!1;for(;;)switch(c){case"hex":return ci(this,r,n,u);case"utf8":case"utf-8":return fi(this,r,n,u);case"ascii":case"latin1":case"binary":return di(this,r,n,u);case"base64":return mi(this,r,n,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return hi(this,r,n,u);default:if(g)throw new TypeError("Unknown encoding: "+c);c=(""+c).toLowerCase(),g=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function yi(o,r,n){return r===0&&n===o.length?p.fromByteArray(o):p.fromByteArray(o.slice(r,n))}function Nt(o,r,n){n=Math.min(o.length,n);let u=[],c=r;for(;c<n;){let h=o[c],g=null,B=h>239?4:h>223?3:h>191?2:1;if(c+B<=n){let O,U,_,L;switch(B){case 1:h<128&&(g=h);break;case 2:O=o[c+1],(O&192)===128&&(L=(h&31)<<6|O&63,L>127&&(g=L));break;case 3:O=o[c+1],U=o[c+2],(O&192)===128&&(U&192)===128&&(L=(h&15)<<12|(O&63)<<6|U&63,L>2047&&(L<55296||L>57343)&&(g=L));break;case 4:O=o[c+1],U=o[c+2],_=o[c+3],(O&192)===128&&(U&192)===128&&(_&192)===128&&(L=(h&15)<<18|(O&63)<<12|(U&63)<<6|_&63,L>65535&&L<1114112&&(g=L))}}g===null?(g=65533,B=1):g>65535&&(g-=65536,u.push(g>>>10&1023|55296),g=56320|g&1023),u.push(g),c+=B}return gi(u)}let St=4096;function gi(o){let r=o.length;if(r<=St)return String.fromCharCode.apply(String,o);let n="",u=0;for(;u<r;)n+=String.fromCharCode.apply(String,o.slice(u,u+=St));return n}function xi(o,r,n){let u="";n=Math.min(o.length,n);for(let c=r;c<n;++c)u+=String.fromCharCode(o[c]&127);return u}function wi(o,r,n){let u="";n=Math.min(o.length,n);for(let c=r;c<n;++c)u+=String.fromCharCode(o[c]);return u}function vi(o,r,n){let u=o.length;(!r||r<0)&&(r=0),(!n||n<0||n>u)&&(n=u);let c="";for(let h=r;h<n;++h)c+=Ni[o[h]];return c}function Ii(o,r,n){let u=o.slice(r,n),c="";for(let h=0;h<u.length-1;h+=2)c+=String.fromCharCode(u[h]+u[h+1]*256);return c}s.prototype.slice=function(r,n){let u=this.length;r=~~r,n=n===void 0?u:~~n,r<0?(r+=u,r<0&&(r=0)):r>u&&(r=u),n<0?(n+=u,n<0&&(n=0)):n>u&&(n=u),n<r&&(n=r);let c=this.subarray(r,n);return Object.setPrototypeOf(c,s.prototype),c};function D(o,r,n){if(o%1!==0||o<0)throw new RangeError("offset is not uint");if(o+r>n)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(r,n,u){r=r>>>0,n=n>>>0,u||D(r,n,this.length);let c=this[r],h=1,g=0;for(;++g<n&&(h*=256);)c+=this[r+g]*h;return c},s.prototype.readUintBE=s.prototype.readUIntBE=function(r,n,u){r=r>>>0,n=n>>>0,u||D(r,n,this.length);let c=this[r+--n],h=1;for(;n>0&&(h*=256);)c+=this[r+--n]*h;return c},s.prototype.readUint8=s.prototype.readUInt8=function(r,n){return r=r>>>0,n||D(r,1,this.length),this[r]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(r,n){return r=r>>>0,n||D(r,2,this.length),this[r]|this[r+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(r,n){return r=r>>>0,n||D(r,2,this.length),this[r]<<8|this[r+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(r,n){return r=r>>>0,n||D(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(r,n){return r=r>>>0,n||D(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},s.prototype.readBigUInt64LE=oe(function(r){r=r>>>0,we(r,"offset");let n=this[r],u=this[r+7];(n===void 0||u===void 0)&&Me(r,this.length-8);let c=n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,h=this[++r]+this[++r]*2**8+this[++r]*2**16+u*2**24;return BigInt(c)+(BigInt(h)<<BigInt(32))}),s.prototype.readBigUInt64BE=oe(function(r){r=r>>>0,we(r,"offset");let n=this[r],u=this[r+7];(n===void 0||u===void 0)&&Me(r,this.length-8);let c=n*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],h=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+u;return(BigInt(c)<<BigInt(32))+BigInt(h)}),s.prototype.readIntLE=function(r,n,u){r=r>>>0,n=n>>>0,u||D(r,n,this.length);let c=this[r],h=1,g=0;for(;++g<n&&(h*=256);)c+=this[r+g]*h;return h*=128,c>=h&&(c-=Math.pow(2,8*n)),c},s.prototype.readIntBE=function(r,n,u){r=r>>>0,n=n>>>0,u||D(r,n,this.length);let c=n,h=1,g=this[r+--c];for(;c>0&&(h*=256);)g+=this[r+--c]*h;return h*=128,g>=h&&(g-=Math.pow(2,8*n)),g},s.prototype.readInt8=function(r,n){return r=r>>>0,n||D(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},s.prototype.readInt16LE=function(r,n){r=r>>>0,n||D(r,2,this.length);let u=this[r]|this[r+1]<<8;return u&32768?u|4294901760:u},s.prototype.readInt16BE=function(r,n){r=r>>>0,n||D(r,2,this.length);let u=this[r+1]|this[r]<<8;return u&32768?u|4294901760:u},s.prototype.readInt32LE=function(r,n){return r=r>>>0,n||D(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},s.prototype.readInt32BE=function(r,n){return r=r>>>0,n||D(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},s.prototype.readBigInt64LE=oe(function(r){r=r>>>0,we(r,"offset");let n=this[r],u=this[r+7];(n===void 0||u===void 0)&&Me(r,this.length-8);let c=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(u<<24);return(BigInt(c)<<BigInt(32))+BigInt(n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),s.prototype.readBigInt64BE=oe(function(r){r=r>>>0,we(r,"offset");let n=this[r],u=this[r+7];(n===void 0||u===void 0)&&Me(r,this.length-8);let c=(n<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(c)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+u)}),s.prototype.readFloatLE=function(r,n){return r=r>>>0,n||D(r,4,this.length),t.read(this,r,!0,23,4)},s.prototype.readFloatBE=function(r,n){return r=r>>>0,n||D(r,4,this.length),t.read(this,r,!1,23,4)},s.prototype.readDoubleLE=function(r,n){return r=r>>>0,n||D(r,8,this.length),t.read(this,r,!0,52,8)},s.prototype.readDoubleBE=function(r,n){return r=r>>>0,n||D(r,8,this.length),t.read(this,r,!1,52,8)};function z(o,r,n,u,c,h){if(!s.isBuffer(o))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>c||r<h)throw new RangeError('"value" argument is out of bounds');if(n+u>o.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(r,n,u,c){if(r=+r,n=n>>>0,u=u>>>0,!c){let B=Math.pow(2,8*u)-1;z(this,r,n,u,B,0)}let h=1,g=0;for(this[n]=r&255;++g<u&&(h*=256);)this[n+g]=r/h&255;return n+u},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(r,n,u,c){if(r=+r,n=n>>>0,u=u>>>0,!c){let B=Math.pow(2,8*u)-1;z(this,r,n,u,B,0)}let h=u-1,g=1;for(this[n+h]=r&255;--h>=0&&(g*=256);)this[n+h]=r/g&255;return n+u},s.prototype.writeUint8=s.prototype.writeUInt8=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,1,255,0),this[n]=r&255,n+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,2,65535,0),this[n]=r&255,this[n+1]=r>>>8,n+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,2,65535,0),this[n]=r>>>8,this[n+1]=r&255,n+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,4,4294967295,0),this[n+3]=r>>>24,this[n+2]=r>>>16,this[n+1]=r>>>8,this[n]=r&255,n+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,4,4294967295,0),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4};function Bt(o,r,n,u,c){Ut(r,u,c,o,n,7);let h=Number(r&BigInt(4294967295));o[n++]=h,h=h>>8,o[n++]=h,h=h>>8,o[n++]=h,h=h>>8,o[n++]=h;let g=Number(r>>BigInt(32)&BigInt(4294967295));return o[n++]=g,g=g>>8,o[n++]=g,g=g>>8,o[n++]=g,g=g>>8,o[n++]=g,n}function Pt(o,r,n,u,c){Ut(r,u,c,o,n,7);let h=Number(r&BigInt(4294967295));o[n+7]=h,h=h>>8,o[n+6]=h,h=h>>8,o[n+5]=h,h=h>>8,o[n+4]=h;let g=Number(r>>BigInt(32)&BigInt(4294967295));return o[n+3]=g,g=g>>8,o[n+2]=g,g=g>>8,o[n+1]=g,g=g>>8,o[n]=g,n+8}s.prototype.writeBigUInt64LE=oe(function(r,n=0){return Bt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=oe(function(r,n=0){return Pt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(r,n,u,c){if(r=+r,n=n>>>0,!c){let O=Math.pow(2,8*u-1);z(this,r,n,u,O-1,-O)}let h=0,g=1,B=0;for(this[n]=r&255;++h<u&&(g*=256);)r<0&&B===0&&this[n+h-1]!==0&&(B=1),this[n+h]=(r/g>>0)-B&255;return n+u},s.prototype.writeIntBE=function(r,n,u,c){if(r=+r,n=n>>>0,!c){let O=Math.pow(2,8*u-1);z(this,r,n,u,O-1,-O)}let h=u-1,g=1,B=0;for(this[n+h]=r&255;--h>=0&&(g*=256);)r<0&&B===0&&this[n+h+1]!==0&&(B=1),this[n+h]=(r/g>>0)-B&255;return n+u},s.prototype.writeInt8=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,1,127,-128),r<0&&(r=255+r+1),this[n]=r&255,n+1},s.prototype.writeInt16LE=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,2,32767,-32768),this[n]=r&255,this[n+1]=r>>>8,n+2},s.prototype.writeInt16BE=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,2,32767,-32768),this[n]=r>>>8,this[n+1]=r&255,n+2},s.prototype.writeInt32LE=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,4,2147483647,-2147483648),this[n]=r&255,this[n+1]=r>>>8,this[n+2]=r>>>16,this[n+3]=r>>>24,n+4},s.prototype.writeInt32BE=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4},s.prototype.writeBigInt64LE=oe(function(r,n=0){return Bt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=oe(function(r,n=0){return Pt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Ft(o,r,n,u,c,h){if(n+u>o.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Ct(o,r,n,u,c){return r=+r,n=n>>>0,c||Ft(o,r,n,4),t.write(o,r,n,u,23,4),n+4}s.prototype.writeFloatLE=function(r,n,u){return Ct(this,r,n,!0,u)},s.prototype.writeFloatBE=function(r,n,u){return Ct(this,r,n,!1,u)};function kt(o,r,n,u,c){return r=+r,n=n>>>0,c||Ft(o,r,n,8),t.write(o,r,n,u,52,8),n+8}s.prototype.writeDoubleLE=function(r,n,u){return kt(this,r,n,!0,u)},s.prototype.writeDoubleBE=function(r,n,u){return kt(this,r,n,!1,u)},s.prototype.copy=function(r,n,u,c){if(!s.isBuffer(r))throw new TypeError("argument should be a Buffer");if(u||(u=0),!c&&c!==0&&(c=this.length),n>=r.length&&(n=r.length),n||(n=0),c>0&&c<u&&(c=u),c===u||r.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(u<0||u>=this.length)throw new RangeError("Index out of range");if(c<0)throw new RangeError("sourceEnd out of bounds");c>this.length&&(c=this.length),r.length-n<c-u&&(c=r.length-n+u);let h=c-u;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,u,c):Uint8Array.prototype.set.call(r,this.subarray(u,c),n),h},s.prototype.fill=function(r,n,u,c){if(typeof r=="string"){if(typeof n=="string"?(c=n,n=0,u=this.length):typeof u=="string"&&(c=u,u=this.length),c!==void 0&&typeof c!="string")throw new TypeError("encoding must be a string");if(typeof c=="string"&&!s.isEncoding(c))throw new TypeError("Unknown encoding: "+c);if(r.length===1){let g=r.charCodeAt(0);(c==="utf8"&&g<128||c==="latin1")&&(r=g)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(n<0||this.length<n||this.length<u)throw new RangeError("Out of range index");if(u<=n)return this;n=n>>>0,u=u===void 0?this.length:u>>>0,r||(r=0);let h;if(typeof r=="number")for(h=n;h<u;++h)this[h]=r;else{let g=s.isBuffer(r)?r:s.from(r,c),B=g.length;if(B===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(h=0;h<u-n;++h)this[h+n]=g[h%B]}return this};let xe={};function ct(o,r,n){xe[o]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${o}]`,this.stack,delete this.name}get code(){return o}set code(c){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:c,writable:!0})}toString(){return`${this.name} [${o}]: ${this.message}`}}}ct("ERR_BUFFER_OUT_OF_BOUNDS",function(o){return o?`${o} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ct("ERR_INVALID_ARG_TYPE",function(o,r){return`The "${o}" argument must be of type number. Received type ${typeof r}`},TypeError),ct("ERR_OUT_OF_RANGE",function(o,r,n){let u=`The value of "${o}" is out of range.`,c=n;return Number.isInteger(n)&&Math.abs(n)>2**32?c=Lt(String(n)):typeof n=="bigint"&&(c=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(c=Lt(c)),c+="n"),u+=` It must be ${r}. Received ${c}`,u},RangeError);function Lt(o){let r="",n=o.length,u=o[0]==="-"?1:0;for(;n>=u+4;n-=3)r=`_${o.slice(n-3,n)}${r}`;return`${o.slice(0,n)}${r}`}function bi(o,r,n){we(r,"offset"),(o[r]===void 0||o[r+n]===void 0)&&Me(r,o.length-(n+1))}function Ut(o,r,n,u,c,h){if(o>n||o<r){let g=typeof r=="bigint"?"n":"",B;throw r===0||r===BigInt(0)?B=`>= 0${g} and < 2${g} ** ${(h+1)*8}${g}`:B=`>= -(2${g} ** ${(h+1)*8-1}${g}) and < 2 ** ${(h+1)*8-1}${g}`,new xe.ERR_OUT_OF_RANGE("value",B,o)}bi(u,c,h)}function we(o,r){if(typeof o!="number")throw new xe.ERR_INVALID_ARG_TYPE(r,"number",o)}function Me(o,r,n){throw Math.floor(o)!==o?(we(o,n),new xe.ERR_OUT_OF_RANGE("offset","an integer",o)):r<0?new xe.ERR_BUFFER_OUT_OF_BOUNDS:new xe.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,o)}let Ei=/[^+/0-9A-Za-z-_]/g;function Ti(o){if(o=o.split("=")[0],o=o.trim().replace(Ei,""),o.length<2)return"";for(;o.length%4!==0;)o=o+"=";return o}function ft(o,r){r=r||1/0;let n,u=o.length,c=null,h=[];for(let g=0;g<u;++g){if(n=o.charCodeAt(g),n>55295&&n<57344){if(!c){if(n>56319){(r-=3)>-1&&h.push(239,191,189);continue}else if(g+1===u){(r-=3)>-1&&h.push(239,191,189);continue}c=n;continue}if(n<56320){(r-=3)>-1&&h.push(239,191,189),c=n;continue}n=(c-55296<<10|n-56320)+65536}else c&&(r-=3)>-1&&h.push(239,191,189);if(c=null,n<128){if((r-=1)<0)break;h.push(n)}else if(n<2048){if((r-=2)<0)break;h.push(n>>6|192,n&63|128)}else if(n<65536){if((r-=3)<0)break;h.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((r-=4)<0)break;h.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return h}function Ri(o){let r=[];for(let n=0;n<o.length;++n)r.push(o.charCodeAt(n)&255);return r}function Ai(o,r){let n,u,c,h=[];for(let g=0;g<o.length&&!((r-=2)<0);++g)n=o.charCodeAt(g),u=n>>8,c=n%256,h.push(c),h.push(u);return h}function Mt(o){return p.toByteArray(Ti(o))}function Qe(o,r,n,u){let c;for(c=0;c<u&&!(c+n>=r.length||c>=o.length);++c)r[c+n]=o[c];return c}function J(o,r){return o instanceof r||o!=null&&o.constructor!=null&&o.constructor.name!=null&&o.constructor.name===r.name}function dt(o){return o!==o}let Ni=(function(){let o="0123456789abcdef",r=new Array(256);for(let n=0;n<16;++n){let u=n*16;for(let c=0;c<16;++c)r[u+c]=o[n]+o[c]}return r})();function oe(o){return typeof BigInt>"u"?Si:o}function Si(){throw new Error("BigInt not supported")}return he}var Oe,en,Xe,tn,he,rn,on=ve(()=>{"use strict";f();m();d();Oe={},en=!1;Xe={},tn=!1;he={},rn=!1});var ye,v,fs,ds,an=ve(()=>{"use strict";f();m();d();on();ye=nn();ye.Buffer;ye.SlowBuffer;ye.INSPECT_MAX_BYTES;ye.kMaxLength;v=ye.Buffer,fs=ye.INSPECT_MAX_BYTES,ds=ye.kMaxLength});var m=ve(()=>{"use strict";an()});var Xa={};mt(Xa,{DynamicSnippetsGenerator:()=>lt});module.exports=Li(Xa);f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();var _i=typeof global=="object"&&global&&global.Object===Object&&global,sn=_i;var Vi=typeof self=="object"&&self&&self.Object===Object&&self,$i=sn||Vi||Function("return this")(),un=$i;var Di=un.Symbol,ne=Di;f();m();d();var pn=Object.prototype,ji=pn.hasOwnProperty,Wi=pn.toString,_e=ne?ne.toStringTag:void 0;function qi(p){var t=ji.call(p,_e),e=p[_e];try{p[_e]=void 0;var i=!0}catch{}var a=Wi.call(p);return i&&(t?p[_e]=e:delete p[_e]),a}var ln=qi;f();m();d();var Gi=Object.prototype,zi=Gi.toString;function Hi(p){return zi.call(p)}var cn=Hi;var Qi="[object Null]",Yi="[object Undefined]",fn=ne?ne.toStringTag:void 0;function Zi(p){return p==null?p===void 0?Yi:Qi:fn&&fn in Object(p)?ln(p):cn(p)}var dn=Zi;f();m();d();function Ji(p){return p!=null&&typeof p=="object"}var mn=Ji;var Ki="[object Symbol]";function Xi(p){return typeof p=="symbol"||mn(p)&&dn(p)==Ki}var hn=Xi;f();m();d();f();m();d();function eo(p,t){for(var e=-1,i=p==null?0:p.length,a=Array(i);++e<i;)a[e]=t(p[e],e,p);return a}var yn=eo;f();m();d();var to=Array.isArray,gn=to;var ro=1/0,xn=ne?ne.prototype:void 0,wn=xn?xn.toString:void 0;function vn(p){if(typeof p=="string")return p;if(gn(p))return yn(p,vn)+"";if(hn(p))return wn?wn.call(p):"";var t=p+"";return t=="0"&&1/p==-ro?"-0":t}var In=vn;f();m();d();function no(p){return p==null?"":In(p)}var se=no;f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();function io(p,t,e){var i=-1,a=p.length;t<0&&(t=-t>a?0:a+t),e=e>a?a:e,e<0&&(e+=a),a=t>e?0:e-t>>>0,t>>>=0;for(var l=Array(a);++i<a;)l[i]=p[i+t];return l}var bn=io;function oo(p,t,e){var i=p.length;return e=e===void 0?i:e,!t&&e>=i?p:bn(p,t,e)}var En=oo;f();m();d();var ao="\\ud800-\\udfff",so="\\u0300-\\u036f",uo="\\ufe20-\\ufe2f",po="\\u20d0-\\u20ff",lo=so+uo+po,co="\\ufe0e\\ufe0f",fo="\\u200d",mo=RegExp("["+fo+ao+lo+co+"]");function ho(p){return mo.test(p)}var et=ho;f();m();d();f();m();d();function yo(p){return p.split("")}var Tn=yo;f();m();d();var Rn="\\ud800-\\udfff",go="\\u0300-\\u036f",xo="\\ufe20-\\ufe2f",wo="\\u20d0-\\u20ff",vo=go+xo+wo,Io="\\ufe0e\\ufe0f",bo="["+Rn+"]",xt="["+vo+"]",wt="\\ud83c[\\udffb-\\udfff]",Eo="(?:"+xt+"|"+wt+")",An="[^"+Rn+"]",Nn="(?:\\ud83c[\\udde6-\\uddff]){2}",Sn="[\\ud800-\\udbff][\\udc00-\\udfff]",To="\\u200d",Bn=Eo+"?",Pn="["+Io+"]?",Ro="(?:"+To+"(?:"+[An,Nn,Sn].join("|")+")"+Pn+Bn+")*",Ao=Pn+Bn+Ro,No="(?:"+[An+xt+"?",xt,Nn,Sn,bo].join("|")+")",So=RegExp(wt+"(?="+wt+")|"+No+Ao,"g");function Bo(p){return p.match(So)||[]}var Fn=Bo;function Po(p){return et(p)?Fn(p):Tn(p)}var Cn=Po;function Fo(p){return function(t){t=se(t);var e=et(t)?Cn(t):void 0,i=e?e[0]:t.charAt(0),a=e?En(e,1).join(""):t.slice(1);return i[p]()+a}}var kn=Fo;var Co=kn("toUpperCase"),Ln=Co;function ko(p){return Ln(se(p).toLowerCase())}var Un=ko;f();m();d();f();m();d();function Lo(p,t,e,i){var a=-1,l=p==null?0:p.length;for(i&&l&&(e=p[++a]);++a<l;)e=t(e,p[a],a,p);return e}var Mn=Lo;f();m();d();f();m();d();f();m();d();function Uo(p){return function(t){return p?.[t]}}var On=Uo;var Mo={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},Oo=On(Mo),_n=Oo;var _o=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Vo="\\u0300-\\u036f",$o="\\ufe20-\\ufe2f",Do="\\u20d0-\\u20ff",jo=Vo+$o+Do,Wo="["+jo+"]",qo=RegExp(Wo,"g");function Go(p){return p=se(p),p&&p.replace(_o,_n).replace(qo,"")}var Vn=Go;f();m();d();f();m();d();var zo=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Ho(p){return p.match(zo)||[]}var $n=Ho;f();m();d();var Qo=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function Yo(p){return Qo.test(p)}var Dn=Yo;f();m();d();var zn="\\ud800-\\udfff",Zo="\\u0300-\\u036f",Jo="\\ufe20-\\ufe2f",Ko="\\u20d0-\\u20ff",Xo=Zo+Jo+Ko,Hn="\\u2700-\\u27bf",Qn="a-z\\xdf-\\xf6\\xf8-\\xff",ea="\\xac\\xb1\\xd7\\xf7",ta="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",ra="\\u2000-\\u206f",na=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Yn="A-Z\\xc0-\\xd6\\xd8-\\xde",ia="\\ufe0e\\ufe0f",Zn=ea+ta+ra+na,Jn="['\u2019]",jn="["+Zn+"]",oa="["+Xo+"]",Kn="\\d+",aa="["+Hn+"]",Xn="["+Qn+"]",ei="[^"+zn+Zn+Kn+Hn+Qn+Yn+"]",sa="\\ud83c[\\udffb-\\udfff]",ua="(?:"+oa+"|"+sa+")",pa="[^"+zn+"]",ti="(?:\\ud83c[\\udde6-\\uddff]){2}",ri="[\\ud800-\\udbff][\\udc00-\\udfff]",be="["+Yn+"]",la="\\u200d",Wn="(?:"+Xn+"|"+ei+")",ca="(?:"+be+"|"+ei+")",qn="(?:"+Jn+"(?:d|ll|m|re|s|t|ve))?",Gn="(?:"+Jn+"(?:D|LL|M|RE|S|T|VE))?",ni=ua+"?",ii="["+ia+"]?",fa="(?:"+la+"(?:"+[pa,ti,ri].join("|")+")"+ii+ni+")*",da="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ma="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",ha=ii+ni+fa,ya="(?:"+[aa,ti,ri].join("|")+")"+ha,ga=RegExp([be+"?"+Xn+"+"+qn+"(?="+[jn,be,"$"].join("|")+")",ca+"+"+Gn+"(?="+[jn,be+Wn,"$"].join("|")+")",be+"?"+Wn+"+"+qn,be+"+"+Gn,ma,da,Kn,ya].join("|"),"g");function xa(p){return p.match(ga)||[]}var oi=xa;function wa(p,t,e){return p=se(p),t=e?void 0:t,t===void 0?Dn(p)?oi(p):$n(p):p.match(t)||[]}var ai=wa;var va="['\u2019]",Ia=RegExp(va,"g");function ba(p){return function(t){return Mn(ai(Vn(t).replace(Ia,"")),p,"")}}var tt=ba;var Ea=tt(function(p,t,e){return t=t.toLowerCase(),p+(e?Un(t):t)}),vt=Ea;f();m();d();var Ta=tt(function(p,t,e){return p+(e?"_":"")+t.toLowerCase()}),It=Ta;f();m();d();function C(p){throw new Error("Unexpected value: "+JSON.stringify(p))}f();m();d();function Ve(p){return Object.keys(p)}f();m();d();f();m();d();f();m();d();var $e=w.env.FERN_STACK_TRACK?.toLowerCase()??"",K=$e!==""&&$e!=="0"&&$e!=="false",bt=["single","multiline","box"].includes($e)?$e:"single";K&&(Error.stackTraceLimit=50);var Ra=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),Aa=new Set(["stacktrace"]);function nt({maxFrames:p=50,skip:t=0,filterPaths:e=[],filterFunctions:i=[],stopOn:a=[],filterNode:l=!0,filterJs:s=!0,formatFilename:E=b=>b}={}){if(!K)return[];i=[...i,...Ra],e=[...e,...Aa],a=[...a,"runInteractiveTask"];let b=!1;return(new Error().stack??"").split(`
|
|
2
|
-
`).map(A=>{let R=A.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(R&&R.length===5){let[,
|
|
3
|
-
`:""}${i.fn} - ${i.path}:${i.position}`).join(""):""}frames(t){let e=this.tracking.get(t);return e?[...e]:[]}free(t){this.tracking.delete(t)}clear(){this.tracking=new WeakMap}},
|
|
1
|
+
"use strict";var Ye=Object.defineProperty;var Bi=Object.getOwnPropertyDescriptor;var Pi=Object.getOwnPropertyNames;var Fi=Object.prototype.hasOwnProperty;var Ci=(p,t,e)=>t in p?Ye(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e;var Ie=(p,t)=>()=>(p&&(t=p(p=0)),t);var mt=(p,t)=>{for(var e in t)Ye(p,e,{get:t[e],enumerable:!0})},ki=(p,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Pi(t))!Fi.call(p,a)&&a!==e&&Ye(p,a,{get:()=>t[a],enumerable:!(i=Bi(t,a))||i.enumerable});return p};var Li=p=>ki(Ye({},"__esModule",{value:!0}),p);var y=(p,t,e)=>Ci(p,typeof t!="symbol"?t+"":t,e);var f=Ie(()=>{"use strict"});var I={};mt(I,{_debugEnd:()=>Rr,_debugProcess:()=>Er,_events:()=>$r,_eventsCount:()=>jr,_exiting:()=>or,_fatalExceptions:()=>Ir,_getActiveHandles:()=>pr,_getActiveRequests:()=>ur,_kill:()=>cr,_linkedBinding:()=>nr,_maxListeners:()=>Dr,_preload_modules:()=>Or,_rawDebug:()=>tr,_startProfilerIdleNotifier:()=>Ar,_stopProfilerIdleNotifier:()=>Nr,_tickCallback:()=>br,abort:()=>Fr,addListener:()=>Wr,allowedNodeEnvironmentFlags:()=>gr,arch:()=>$t,argv:()=>qt,argv0:()=>Mr,assert:()=>xr,binding:()=>Yt,browser:()=>er,chdir:()=>Kt,config:()=>ar,cpuUsage:()=>Ke,cwd:()=>Jt,debugPort:()=>Ur,default:()=>Kr,dlopen:()=>sr,domain:()=>ir,emit:()=>Qr,emitWarning:()=>Qt,env:()=>Wt,execArgv:()=>Gt,execPath:()=>Lr,exit:()=>hr,features:()=>wr,hasUncaughtExceptionCaptureCallback:()=>Tr,hrtime:()=>Je,kill:()=>mr,listeners:()=>Jr,memoryUsage:()=>dr,moduleLoadList:()=>rr,nextTick:()=>_t,off:()=>Gr,on:()=>re,once:()=>qr,openStdin:()=>yr,pid:()=>Cr,platform:()=>jt,ppid:()=>kr,prependListener:()=>Yr,prependOnceListener:()=>Zr,reallyExit:()=>lr,release:()=>Xt,removeAllListeners:()=>Hr,removeListener:()=>zr,resourceUsage:()=>fr,setSourceMapsEnabled:()=>_r,setUncaughtExceptionCaptureCallback:()=>vr,stderr:()=>Br,stdin:()=>Pr,stdout:()=>Sr,title:()=>Dt,umask:()=>Zt,uptime:()=>Vr,version:()=>zt,versions:()=>Ht});function gt(p){throw new Error("Node.js process "+p+" is not supported by JSPM core outside of Node.js")}function Ui(){!ve||!me||(ve=!1,me.length?te=me.concat(te):Ze=-1,te.length&&Ot())}function Ot(){if(!ve){var p=setTimeout(Ui,0);ve=!0;for(var t=te.length;t;){for(me=te,te=[];++Ze<t;)me&&me[Ze].run();Ze=-1,t=te.length}me=null,ve=!1,clearTimeout(p)}}function _t(p){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];te.push(new Vt(p,t)),te.length===1&&!ve&&setTimeout(Ot,0)}function Vt(p,t){this.fun=p,this.array=t}function j(){}function nr(p){gt("_linkedBinding")}function sr(p){gt("dlopen")}function ur(){return[]}function pr(){return[]}function xr(p,t){if(!p)throw new Error(t||"assertion error")}function Tr(){return!1}function Vr(){return ae.now()/1e3}function Je(p){var t=Math.floor((Date.now()-ae.now())*.001),e=ae.now()*.001,i=Math.floor(e)+t,a=Math.floor(e%1*1e9);return p&&(i=i-p[0],a=a-p[1],a<0&&(i--,a+=yt)),[i,a]}function re(){return Kr}function Jr(p){return[]}var te,ve,me,Ze,Dt,$t,jt,Wt,qt,Gt,zt,Ht,Qt,Yt,Zt,Jt,Kt,Xt,er,tr,rr,ir,or,ar,lr,cr,Ke,fr,dr,mr,hr,yr,gr,wr,Ir,vr,br,Er,Rr,Ar,Nr,Sr,Br,Pr,Fr,Cr,kr,Lr,Ur,Mr,Or,_r,ae,ht,yt,Dr,$r,jr,Wr,qr,Gr,zr,Hr,Qr,Yr,Zr,Kr,Xr=Ie(()=>{"use strict";f();m();d();te=[],ve=!1,Ze=-1;Vt.prototype.run=function(){this.fun.apply(null,this.array)};Dt="browser",$t="x64",jt="browser",Wt={PATH:"/usr/bin",LANG:typeof navigator<"u"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},qt=["/usr/bin/node"],Gt=[],zt="v16.8.0",Ht={},Qt=function(p,t){console.warn((t?t+": ":"")+p)},Yt=function(p){gt("binding")},Zt=function(p){return 0},Jt=function(){return"/"},Kt=function(p){},Xt={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};er=!0,tr=j,rr=[];ir={},or=!1,ar={};lr=j,cr=j,Ke=function(){return{}},fr=Ke,dr=Ke,mr=j,hr=j,yr=j,gr={};wr={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},Ir=j,vr=j;br=j,Er=j,Rr=j,Ar=j,Nr=j,Sr=void 0,Br=void 0,Pr=void 0,Fr=j,Cr=2,kr=1,Lr="/bin/usr/node",Ur=9229,Mr="node",Or=[],_r=j,ae={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};ae.now===void 0&&(ht=Date.now(),ae.timing&&ae.timing.navigationStart&&(ht=ae.timing.navigationStart),ae.now=()=>Date.now()-ht);yt=1e9;Je.bigint=function(p){var t=Je(p);return typeof BigInt>"u"?t[0]*yt+t[1]:BigInt(t[0]*yt)+BigInt(t[1])};Dr=10,$r={},jr=0;Wr=re,qr=re,Gr=re,zr=re,Hr=re,Qr=j,Yr=re,Zr=re;Kr={version:zt,versions:Ht,arch:$t,platform:jt,browser:er,release:Xt,_rawDebug:tr,moduleLoadList:rr,binding:Yt,_linkedBinding:nr,_events:$r,_eventsCount:jr,_maxListeners:Dr,on:re,addListener:Wr,once:qr,off:Gr,removeListener:zr,removeAllListeners:Hr,emit:Qr,prependListener:Yr,prependOnceListener:Zr,listeners:Jr,domain:ir,_exiting:or,config:ar,dlopen:sr,uptime:Vr,_getActiveRequests:ur,_getActiveHandles:pr,reallyExit:lr,_kill:cr,cpuUsage:Ke,resourceUsage:fr,memoryUsage:dr,kill:mr,exit:hr,openStdin:yr,allowedNodeEnvironmentFlags:gr,assert:xr,features:wr,_fatalExceptions:Ir,setUncaughtExceptionCaptureCallback:vr,hasUncaughtExceptionCaptureCallback:Tr,emitWarning:Qt,nextTick:_t,_tickCallback:br,_debugProcess:Er,_debugEnd:Rr,_startProfilerIdleNotifier:Ar,_stopProfilerIdleNotifier:Nr,stdout:Sr,stdin:Pr,stderr:Br,abort:Fr,umask:Zt,chdir:Kt,cwd:Jt,env:Wt,title:Dt,argv:qt,execArgv:Gt,pid:Cr,ppid:kr,execPath:Lr,debugPort:Ur,hrtime:Je,argv0:Mr,_preload_modules:Or,setSourceMapsEnabled:_r}});var d=Ie(()=>{"use strict";Xr()});function Mi(){if(en)return Oe;en=!0,Oe.byteLength=w,Oe.toByteArray=A,Oe.fromByteArray=D;for(var p=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,l=i.length;a<l;++a)p[a]=i[a],t[i.charCodeAt(a)]=a;t[45]=62,t[95]=63;function s(E){var N=E.length;if(N%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=E.indexOf("=");k===-1&&(k=N);var M=k===N?0:4-k%4;return[k,M]}function w(E){var N=s(E),k=N[0],M=N[1];return(k+M)*3/4-M}function b(E,N,k){return(N+k)*3/4-k}function A(E){var N,k=s(E),M=k[0],q=k[1],V=new e(b(E,M,q)),G=0,H=q>0?M-4:M,W;for(W=0;W<H;W+=4)N=t[E.charCodeAt(W)]<<18|t[E.charCodeAt(W+1)]<<12|t[E.charCodeAt(W+2)]<<6|t[E.charCodeAt(W+3)],V[G++]=N>>16&255,V[G++]=N>>8&255,V[G++]=N&255;return q===2&&(N=t[E.charCodeAt(W)]<<2|t[E.charCodeAt(W+1)]>>4,V[G++]=N&255),q===1&&(N=t[E.charCodeAt(W)]<<10|t[E.charCodeAt(W+1)]<<4|t[E.charCodeAt(W+2)]>>2,V[G++]=N>>8&255,V[G++]=N&255),V}function R(E){return p[E>>18&63]+p[E>>12&63]+p[E>>6&63]+p[E&63]}function C(E,N,k){for(var M,q=[],V=N;V<k;V+=3)M=(E[V]<<16&16711680)+(E[V+1]<<8&65280)+(E[V+2]&255),q.push(R(M));return q.join("")}function D(E){for(var N,k=E.length,M=k%3,q=[],V=16383,G=0,H=k-M;G<H;G+=V)q.push(C(E,G,G+V>H?H:G+V));return M===1?(N=E[k-1],q.push(p[N>>2]+p[N<<4&63]+"==")):M===2&&(N=(E[k-2]<<8)+E[k-1],q.push(p[N>>10]+p[N>>4&63]+p[N<<2&63]+"=")),q.join("")}return Oe}function Oi(){if(tn)return Xe;tn=!0;return Xe.read=function(p,t,e,i,a){var l,s,w=a*8-i-1,b=(1<<w)-1,A=b>>1,R=-7,C=e?a-1:0,D=e?-1:1,E=p[t+C];for(C+=D,l=E&(1<<-R)-1,E>>=-R,R+=w;R>0;l=l*256+p[t+C],C+=D,R-=8);for(s=l&(1<<-R)-1,l>>=-R,R+=i;R>0;s=s*256+p[t+C],C+=D,R-=8);if(l===0)l=1-A;else{if(l===b)return s?NaN:(E?-1:1)*(1/0);s=s+Math.pow(2,i),l=l-A}return(E?-1:1)*s*Math.pow(2,l-i)},Xe.write=function(p,t,e,i,a,l){var s,w,b,A=l*8-a-1,R=(1<<A)-1,C=R>>1,D=a===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=i?0:l-1,N=i?1:-1,k=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(w=isNaN(t)?1:0,s=R):(s=Math.floor(Math.log(t)/Math.LN2),t*(b=Math.pow(2,-s))<1&&(s--,b*=2),s+C>=1?t+=D/b:t+=D*Math.pow(2,1-C),t*b>=2&&(s++,b/=2),s+C>=R?(w=0,s=R):s+C>=1?(w=(t*b-1)*Math.pow(2,a),s=s+C):(w=t*Math.pow(2,C-1)*Math.pow(2,a),s=0));a>=8;p[e+E]=w&255,E+=N,w/=256,a-=8);for(s=s<<a|w,A+=a;A>0;p[e+E]=s&255,E+=N,s/=256,A-=8);p[e+E-N]|=k*128},Xe}function nn(){if(rn)return he;rn=!0;let p=Mi(),t=Oi(),e=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;he.Buffer=s,he.SlowBuffer=q,he.INSPECT_MAX_BYTES=50;let i=2147483647;he.kMaxLength=i,s.TYPED_ARRAY_SUPPORT=a(),!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function a(){try{let o=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(o,r),o.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function l(o){if(o>i)throw new RangeError('The value "'+o+'" is invalid for option "size"');let r=new Uint8Array(o);return Object.setPrototypeOf(r,s.prototype),r}function s(o,r,n){if(typeof o=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return R(o)}return w(o,r,n)}s.poolSize=8192;function w(o,r,n){if(typeof o=="string")return C(o,r);if(ArrayBuffer.isView(o))return E(o);if(o==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o);if(J(o,ArrayBuffer)||o&&J(o.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(J(o,SharedArrayBuffer)||o&&J(o.buffer,SharedArrayBuffer)))return N(o,r,n);if(typeof o=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let u=o.valueOf&&o.valueOf();if(u!=null&&u!==o)return s.from(u,r,n);let c=k(o);if(c)return c;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof o[Symbol.toPrimitive]=="function")return s.from(o[Symbol.toPrimitive]("string"),r,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o)}s.from=function(o,r,n){return w(o,r,n)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function b(o){if(typeof o!="number")throw new TypeError('"size" argument must be of type number');if(o<0)throw new RangeError('The value "'+o+'" is invalid for option "size"')}function A(o,r,n){return b(o),o<=0?l(o):r!==void 0?typeof n=="string"?l(o).fill(r,n):l(o).fill(r):l(o)}s.alloc=function(o,r,n){return A(o,r,n)};function R(o){return b(o),l(o<0?0:M(o)|0)}s.allocUnsafe=function(o){return R(o)},s.allocUnsafeSlow=function(o){return R(o)};function C(o,r){if((typeof r!="string"||r==="")&&(r="utf8"),!s.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let n=V(o,r)|0,u=l(n),c=u.write(o,r);return c!==n&&(u=u.slice(0,c)),u}function D(o){let r=o.length<0?0:M(o.length)|0,n=l(r);for(let u=0;u<r;u+=1)n[u]=o[u]&255;return n}function E(o){if(J(o,Uint8Array)){let r=new Uint8Array(o);return N(r.buffer,r.byteOffset,r.byteLength)}return D(o)}function N(o,r,n){if(r<0||o.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(o.byteLength<r+(n||0))throw new RangeError('"length" is outside of buffer bounds');let u;return r===void 0&&n===void 0?u=new Uint8Array(o):n===void 0?u=new Uint8Array(o,r):u=new Uint8Array(o,r,n),Object.setPrototypeOf(u,s.prototype),u}function k(o){if(s.isBuffer(o)){let r=M(o.length)|0,n=l(r);return n.length===0||o.copy(n,0,0,r),n}if(o.length!==void 0)return typeof o.length!="number"||dt(o.length)?l(0):D(o);if(o.type==="Buffer"&&Array.isArray(o.data))return D(o.data)}function M(o){if(o>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return o|0}function q(o){return+o!=o&&(o=0),s.alloc(+o)}s.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==s.prototype},s.compare=function(r,n){if(J(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),J(n,Uint8Array)&&(n=s.from(n,n.offset,n.byteLength)),!s.isBuffer(r)||!s.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===n)return 0;let u=r.length,c=n.length;for(let h=0,x=Math.min(u,c);h<x;++h)if(r[h]!==n[h]){u=r[h],c=n[h];break}return u<c?-1:c<u?1:0},s.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(r,n){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return s.alloc(0);let u;if(n===void 0)for(n=0,u=0;u<r.length;++u)n+=r[u].length;let c=s.allocUnsafe(n),h=0;for(u=0;u<r.length;++u){let x=r[u];if(J(x,Uint8Array))h+x.length>c.length?(s.isBuffer(x)||(x=s.from(x)),x.copy(c,h)):Uint8Array.prototype.set.call(c,x,h);else if(s.isBuffer(x))x.copy(c,h);else throw new TypeError('"list" argument must be an Array of Buffers');h+=x.length}return c};function V(o,r){if(s.isBuffer(o))return o.length;if(ArrayBuffer.isView(o)||J(o,ArrayBuffer))return o.byteLength;if(typeof o!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof o);let n=o.length,u=arguments.length>2&&arguments[2]===!0;if(!u&&n===0)return 0;let c=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return ft(o).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return Mt(o).length;default:if(c)return u?-1:ft(o).length;r=(""+r).toLowerCase(),c=!0}}s.byteLength=V;function G(o,r,n){let u=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,r>>>=0,n<=r))return"";for(o||(o="utf8");;)switch(o){case"hex":return Ii(this,r,n);case"utf8":case"utf-8":return Nt(this,r,n);case"ascii":return xi(this,r,n);case"latin1":case"binary":return wi(this,r,n);case"base64":return yi(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return vi(this,r,n);default:if(u)throw new TypeError("Unknown encoding: "+o);o=(o+"").toLowerCase(),u=!0}}s.prototype._isBuffer=!0;function H(o,r,n){let u=o[r];o[r]=o[n],o[n]=u}s.prototype.swap16=function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<r;n+=2)H(this,n,n+1);return this},s.prototype.swap32=function(){let r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<r;n+=4)H(this,n,n+3),H(this,n+1,n+2);return this},s.prototype.swap64=function(){let r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<r;n+=8)H(this,n,n+7),H(this,n+1,n+6),H(this,n+2,n+5),H(this,n+3,n+4);return this},s.prototype.toString=function(){let r=this.length;return r===0?"":arguments.length===0?Nt(this,0,r):G.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(r){if(!s.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:s.compare(this,r)===0},s.prototype.inspect=function(){let r="",n=he.INSPECT_MAX_BYTES;return r=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(r+=" ... "),"<Buffer "+r+">"},e&&(s.prototype[e]=s.prototype.inspect),s.prototype.compare=function(r,n,u,c,h){if(J(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),!s.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(n===void 0&&(n=0),u===void 0&&(u=r?r.length:0),c===void 0&&(c=0),h===void 0&&(h=this.length),n<0||u>r.length||c<0||h>this.length)throw new RangeError("out of range index");if(c>=h&&n>=u)return 0;if(c>=h)return-1;if(n>=u)return 1;if(n>>>=0,u>>>=0,c>>>=0,h>>>=0,this===r)return 0;let x=h-c,P=u-n,O=Math.min(x,P),U=this.slice(c,h),_=r.slice(n,u);for(let L=0;L<O;++L)if(U[L]!==_[L]){x=U[L],P=_[L];break}return x<P?-1:P<x?1:0};function W(o,r,n,u,c){if(o.length===0)return-1;if(typeof n=="string"?(u=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,dt(n)&&(n=c?0:o.length-1),n<0&&(n=o.length+n),n>=o.length){if(c)return-1;n=o.length-1}else if(n<0)if(c)n=0;else return-1;if(typeof r=="string"&&(r=s.from(r,u)),s.isBuffer(r))return r.length===0?-1:At(o,r,n,u,c);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?c?Uint8Array.prototype.indexOf.call(o,r,n):Uint8Array.prototype.lastIndexOf.call(o,r,n):At(o,[r],n,u,c);throw new TypeError("val must be string, number or Buffer")}function At(o,r,n,u,c){let h=1,x=o.length,P=r.length;if(u!==void 0&&(u=String(u).toLowerCase(),u==="ucs2"||u==="ucs-2"||u==="utf16le"||u==="utf-16le")){if(o.length<2||r.length<2)return-1;h=2,x/=2,P/=2,n/=2}function O(_,L){return h===1?_[L]:_.readUInt16BE(L*h)}let U;if(c){let _=-1;for(U=n;U<x;U++)if(O(o,U)===O(r,_===-1?0:U-_)){if(_===-1&&(_=U),U-_+1===P)return _*h}else _!==-1&&(U-=U-_),_=-1}else for(n+P>x&&(n=x-P),U=n;U>=0;U--){let _=!0;for(let L=0;L<P;L++)if(O(o,U+L)!==O(r,L)){_=!1;break}if(_)return U}return-1}s.prototype.includes=function(r,n,u){return this.indexOf(r,n,u)!==-1},s.prototype.indexOf=function(r,n,u){return W(this,r,n,u,!0)},s.prototype.lastIndexOf=function(r,n,u){return W(this,r,n,u,!1)};function ci(o,r,n,u){n=Number(n)||0;let c=o.length-n;u?(u=Number(u),u>c&&(u=c)):u=c;let h=r.length;u>h/2&&(u=h/2);let x;for(x=0;x<u;++x){let P=parseInt(r.substr(x*2,2),16);if(dt(P))return x;o[n+x]=P}return x}function fi(o,r,n,u){return Qe(ft(r,o.length-n),o,n,u)}function di(o,r,n,u){return Qe(Ri(r),o,n,u)}function mi(o,r,n,u){return Qe(Mt(r),o,n,u)}function hi(o,r,n,u){return Qe(Ai(r,o.length-n),o,n,u)}s.prototype.write=function(r,n,u,c){if(n===void 0)c="utf8",u=this.length,n=0;else if(u===void 0&&typeof n=="string")c=n,u=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(u)?(u=u>>>0,c===void 0&&(c="utf8")):(c=u,u=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let h=this.length-n;if((u===void 0||u>h)&&(u=h),r.length>0&&(u<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");c||(c="utf8");let x=!1;for(;;)switch(c){case"hex":return ci(this,r,n,u);case"utf8":case"utf-8":return fi(this,r,n,u);case"ascii":case"latin1":case"binary":return di(this,r,n,u);case"base64":return mi(this,r,n,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return hi(this,r,n,u);default:if(x)throw new TypeError("Unknown encoding: "+c);c=(""+c).toLowerCase(),x=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function yi(o,r,n){return r===0&&n===o.length?p.fromByteArray(o):p.fromByteArray(o.slice(r,n))}function Nt(o,r,n){n=Math.min(o.length,n);let u=[],c=r;for(;c<n;){let h=o[c],x=null,P=h>239?4:h>223?3:h>191?2:1;if(c+P<=n){let O,U,_,L;switch(P){case 1:h<128&&(x=h);break;case 2:O=o[c+1],(O&192)===128&&(L=(h&31)<<6|O&63,L>127&&(x=L));break;case 3:O=o[c+1],U=o[c+2],(O&192)===128&&(U&192)===128&&(L=(h&15)<<12|(O&63)<<6|U&63,L>2047&&(L<55296||L>57343)&&(x=L));break;case 4:O=o[c+1],U=o[c+2],_=o[c+3],(O&192)===128&&(U&192)===128&&(_&192)===128&&(L=(h&15)<<18|(O&63)<<12|(U&63)<<6|_&63,L>65535&&L<1114112&&(x=L))}}x===null?(x=65533,P=1):x>65535&&(x-=65536,u.push(x>>>10&1023|55296),x=56320|x&1023),u.push(x),c+=P}return gi(u)}let St=4096;function gi(o){let r=o.length;if(r<=St)return String.fromCharCode.apply(String,o);let n="",u=0;for(;u<r;)n+=String.fromCharCode.apply(String,o.slice(u,u+=St));return n}function xi(o,r,n){let u="";n=Math.min(o.length,n);for(let c=r;c<n;++c)u+=String.fromCharCode(o[c]&127);return u}function wi(o,r,n){let u="";n=Math.min(o.length,n);for(let c=r;c<n;++c)u+=String.fromCharCode(o[c]);return u}function Ii(o,r,n){let u=o.length;(!r||r<0)&&(r=0),(!n||n<0||n>u)&&(n=u);let c="";for(let h=r;h<n;++h)c+=Ni[o[h]];return c}function vi(o,r,n){let u=o.slice(r,n),c="";for(let h=0;h<u.length-1;h+=2)c+=String.fromCharCode(u[h]+u[h+1]*256);return c}s.prototype.slice=function(r,n){let u=this.length;r=~~r,n=n===void 0?u:~~n,r<0?(r+=u,r<0&&(r=0)):r>u&&(r=u),n<0?(n+=u,n<0&&(n=0)):n>u&&(n=u),n<r&&(n=r);let c=this.subarray(r,n);return Object.setPrototypeOf(c,s.prototype),c};function $(o,r,n){if(o%1!==0||o<0)throw new RangeError("offset is not uint");if(o+r>n)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(r,n,u){r=r>>>0,n=n>>>0,u||$(r,n,this.length);let c=this[r],h=1,x=0;for(;++x<n&&(h*=256);)c+=this[r+x]*h;return c},s.prototype.readUintBE=s.prototype.readUIntBE=function(r,n,u){r=r>>>0,n=n>>>0,u||$(r,n,this.length);let c=this[r+--n],h=1;for(;n>0&&(h*=256);)c+=this[r+--n]*h;return c},s.prototype.readUint8=s.prototype.readUInt8=function(r,n){return r=r>>>0,n||$(r,1,this.length),this[r]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(r,n){return r=r>>>0,n||$(r,2,this.length),this[r]|this[r+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(r,n){return r=r>>>0,n||$(r,2,this.length),this[r]<<8|this[r+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(r,n){return r=r>>>0,n||$(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(r,n){return r=r>>>0,n||$(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},s.prototype.readBigUInt64LE=oe(function(r){r=r>>>0,we(r,"offset");let n=this[r],u=this[r+7];(n===void 0||u===void 0)&&Me(r,this.length-8);let c=n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,h=this[++r]+this[++r]*2**8+this[++r]*2**16+u*2**24;return BigInt(c)+(BigInt(h)<<BigInt(32))}),s.prototype.readBigUInt64BE=oe(function(r){r=r>>>0,we(r,"offset");let n=this[r],u=this[r+7];(n===void 0||u===void 0)&&Me(r,this.length-8);let c=n*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],h=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+u;return(BigInt(c)<<BigInt(32))+BigInt(h)}),s.prototype.readIntLE=function(r,n,u){r=r>>>0,n=n>>>0,u||$(r,n,this.length);let c=this[r],h=1,x=0;for(;++x<n&&(h*=256);)c+=this[r+x]*h;return h*=128,c>=h&&(c-=Math.pow(2,8*n)),c},s.prototype.readIntBE=function(r,n,u){r=r>>>0,n=n>>>0,u||$(r,n,this.length);let c=n,h=1,x=this[r+--c];for(;c>0&&(h*=256);)x+=this[r+--c]*h;return h*=128,x>=h&&(x-=Math.pow(2,8*n)),x},s.prototype.readInt8=function(r,n){return r=r>>>0,n||$(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},s.prototype.readInt16LE=function(r,n){r=r>>>0,n||$(r,2,this.length);let u=this[r]|this[r+1]<<8;return u&32768?u|4294901760:u},s.prototype.readInt16BE=function(r,n){r=r>>>0,n||$(r,2,this.length);let u=this[r+1]|this[r]<<8;return u&32768?u|4294901760:u},s.prototype.readInt32LE=function(r,n){return r=r>>>0,n||$(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},s.prototype.readInt32BE=function(r,n){return r=r>>>0,n||$(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},s.prototype.readBigInt64LE=oe(function(r){r=r>>>0,we(r,"offset");let n=this[r],u=this[r+7];(n===void 0||u===void 0)&&Me(r,this.length-8);let c=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(u<<24);return(BigInt(c)<<BigInt(32))+BigInt(n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),s.prototype.readBigInt64BE=oe(function(r){r=r>>>0,we(r,"offset");let n=this[r],u=this[r+7];(n===void 0||u===void 0)&&Me(r,this.length-8);let c=(n<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(c)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+u)}),s.prototype.readFloatLE=function(r,n){return r=r>>>0,n||$(r,4,this.length),t.read(this,r,!0,23,4)},s.prototype.readFloatBE=function(r,n){return r=r>>>0,n||$(r,4,this.length),t.read(this,r,!1,23,4)},s.prototype.readDoubleLE=function(r,n){return r=r>>>0,n||$(r,8,this.length),t.read(this,r,!0,52,8)},s.prototype.readDoubleBE=function(r,n){return r=r>>>0,n||$(r,8,this.length),t.read(this,r,!1,52,8)};function z(o,r,n,u,c,h){if(!s.isBuffer(o))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>c||r<h)throw new RangeError('"value" argument is out of bounds');if(n+u>o.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(r,n,u,c){if(r=+r,n=n>>>0,u=u>>>0,!c){let P=Math.pow(2,8*u)-1;z(this,r,n,u,P,0)}let h=1,x=0;for(this[n]=r&255;++x<u&&(h*=256);)this[n+x]=r/h&255;return n+u},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(r,n,u,c){if(r=+r,n=n>>>0,u=u>>>0,!c){let P=Math.pow(2,8*u)-1;z(this,r,n,u,P,0)}let h=u-1,x=1;for(this[n+h]=r&255;--h>=0&&(x*=256);)this[n+h]=r/x&255;return n+u},s.prototype.writeUint8=s.prototype.writeUInt8=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,1,255,0),this[n]=r&255,n+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,2,65535,0),this[n]=r&255,this[n+1]=r>>>8,n+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,2,65535,0),this[n]=r>>>8,this[n+1]=r&255,n+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,4,4294967295,0),this[n+3]=r>>>24,this[n+2]=r>>>16,this[n+1]=r>>>8,this[n]=r&255,n+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,4,4294967295,0),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4};function Bt(o,r,n,u,c){Ut(r,u,c,o,n,7);let h=Number(r&BigInt(4294967295));o[n++]=h,h=h>>8,o[n++]=h,h=h>>8,o[n++]=h,h=h>>8,o[n++]=h;let x=Number(r>>BigInt(32)&BigInt(4294967295));return o[n++]=x,x=x>>8,o[n++]=x,x=x>>8,o[n++]=x,x=x>>8,o[n++]=x,n}function Pt(o,r,n,u,c){Ut(r,u,c,o,n,7);let h=Number(r&BigInt(4294967295));o[n+7]=h,h=h>>8,o[n+6]=h,h=h>>8,o[n+5]=h,h=h>>8,o[n+4]=h;let x=Number(r>>BigInt(32)&BigInt(4294967295));return o[n+3]=x,x=x>>8,o[n+2]=x,x=x>>8,o[n+1]=x,x=x>>8,o[n]=x,n+8}s.prototype.writeBigUInt64LE=oe(function(r,n=0){return Bt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=oe(function(r,n=0){return Pt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(r,n,u,c){if(r=+r,n=n>>>0,!c){let O=Math.pow(2,8*u-1);z(this,r,n,u,O-1,-O)}let h=0,x=1,P=0;for(this[n]=r&255;++h<u&&(x*=256);)r<0&&P===0&&this[n+h-1]!==0&&(P=1),this[n+h]=(r/x>>0)-P&255;return n+u},s.prototype.writeIntBE=function(r,n,u,c){if(r=+r,n=n>>>0,!c){let O=Math.pow(2,8*u-1);z(this,r,n,u,O-1,-O)}let h=u-1,x=1,P=0;for(this[n+h]=r&255;--h>=0&&(x*=256);)r<0&&P===0&&this[n+h+1]!==0&&(P=1),this[n+h]=(r/x>>0)-P&255;return n+u},s.prototype.writeInt8=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,1,127,-128),r<0&&(r=255+r+1),this[n]=r&255,n+1},s.prototype.writeInt16LE=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,2,32767,-32768),this[n]=r&255,this[n+1]=r>>>8,n+2},s.prototype.writeInt16BE=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,2,32767,-32768),this[n]=r>>>8,this[n+1]=r&255,n+2},s.prototype.writeInt32LE=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,4,2147483647,-2147483648),this[n]=r&255,this[n+1]=r>>>8,this[n+2]=r>>>16,this[n+3]=r>>>24,n+4},s.prototype.writeInt32BE=function(r,n,u){return r=+r,n=n>>>0,u||z(this,r,n,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4},s.prototype.writeBigInt64LE=oe(function(r,n=0){return Bt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=oe(function(r,n=0){return Pt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Ft(o,r,n,u,c,h){if(n+u>o.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Ct(o,r,n,u,c){return r=+r,n=n>>>0,c||Ft(o,r,n,4),t.write(o,r,n,u,23,4),n+4}s.prototype.writeFloatLE=function(r,n,u){return Ct(this,r,n,!0,u)},s.prototype.writeFloatBE=function(r,n,u){return Ct(this,r,n,!1,u)};function kt(o,r,n,u,c){return r=+r,n=n>>>0,c||Ft(o,r,n,8),t.write(o,r,n,u,52,8),n+8}s.prototype.writeDoubleLE=function(r,n,u){return kt(this,r,n,!0,u)},s.prototype.writeDoubleBE=function(r,n,u){return kt(this,r,n,!1,u)},s.prototype.copy=function(r,n,u,c){if(!s.isBuffer(r))throw new TypeError("argument should be a Buffer");if(u||(u=0),!c&&c!==0&&(c=this.length),n>=r.length&&(n=r.length),n||(n=0),c>0&&c<u&&(c=u),c===u||r.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(u<0||u>=this.length)throw new RangeError("Index out of range");if(c<0)throw new RangeError("sourceEnd out of bounds");c>this.length&&(c=this.length),r.length-n<c-u&&(c=r.length-n+u);let h=c-u;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,u,c):Uint8Array.prototype.set.call(r,this.subarray(u,c),n),h},s.prototype.fill=function(r,n,u,c){if(typeof r=="string"){if(typeof n=="string"?(c=n,n=0,u=this.length):typeof u=="string"&&(c=u,u=this.length),c!==void 0&&typeof c!="string")throw new TypeError("encoding must be a string");if(typeof c=="string"&&!s.isEncoding(c))throw new TypeError("Unknown encoding: "+c);if(r.length===1){let x=r.charCodeAt(0);(c==="utf8"&&x<128||c==="latin1")&&(r=x)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(n<0||this.length<n||this.length<u)throw new RangeError("Out of range index");if(u<=n)return this;n=n>>>0,u=u===void 0?this.length:u>>>0,r||(r=0);let h;if(typeof r=="number")for(h=n;h<u;++h)this[h]=r;else{let x=s.isBuffer(r)?r:s.from(r,c),P=x.length;if(P===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(h=0;h<u-n;++h)this[h+n]=x[h%P]}return this};let xe={};function ct(o,r,n){xe[o]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${o}]`,this.stack,delete this.name}get code(){return o}set code(c){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:c,writable:!0})}toString(){return`${this.name} [${o}]: ${this.message}`}}}ct("ERR_BUFFER_OUT_OF_BOUNDS",function(o){return o?`${o} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ct("ERR_INVALID_ARG_TYPE",function(o,r){return`The "${o}" argument must be of type number. Received type ${typeof r}`},TypeError),ct("ERR_OUT_OF_RANGE",function(o,r,n){let u=`The value of "${o}" is out of range.`,c=n;return Number.isInteger(n)&&Math.abs(n)>2**32?c=Lt(String(n)):typeof n=="bigint"&&(c=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(c=Lt(c)),c+="n"),u+=` It must be ${r}. Received ${c}`,u},RangeError);function Lt(o){let r="",n=o.length,u=o[0]==="-"?1:0;for(;n>=u+4;n-=3)r=`_${o.slice(n-3,n)}${r}`;return`${o.slice(0,n)}${r}`}function Ti(o,r,n){we(r,"offset"),(o[r]===void 0||o[r+n]===void 0)&&Me(r,o.length-(n+1))}function Ut(o,r,n,u,c,h){if(o>n||o<r){let x=typeof r=="bigint"?"n":"",P;throw r===0||r===BigInt(0)?P=`>= 0${x} and < 2${x} ** ${(h+1)*8}${x}`:P=`>= -(2${x} ** ${(h+1)*8-1}${x}) and < 2 ** ${(h+1)*8-1}${x}`,new xe.ERR_OUT_OF_RANGE("value",P,o)}Ti(u,c,h)}function we(o,r){if(typeof o!="number")throw new xe.ERR_INVALID_ARG_TYPE(r,"number",o)}function Me(o,r,n){throw Math.floor(o)!==o?(we(o,n),new xe.ERR_OUT_OF_RANGE("offset","an integer",o)):r<0?new xe.ERR_BUFFER_OUT_OF_BOUNDS:new xe.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,o)}let bi=/[^+/0-9A-Za-z-_]/g;function Ei(o){if(o=o.split("=")[0],o=o.trim().replace(bi,""),o.length<2)return"";for(;o.length%4!==0;)o=o+"=";return o}function ft(o,r){r=r||1/0;let n,u=o.length,c=null,h=[];for(let x=0;x<u;++x){if(n=o.charCodeAt(x),n>55295&&n<57344){if(!c){if(n>56319){(r-=3)>-1&&h.push(239,191,189);continue}else if(x+1===u){(r-=3)>-1&&h.push(239,191,189);continue}c=n;continue}if(n<56320){(r-=3)>-1&&h.push(239,191,189),c=n;continue}n=(c-55296<<10|n-56320)+65536}else c&&(r-=3)>-1&&h.push(239,191,189);if(c=null,n<128){if((r-=1)<0)break;h.push(n)}else if(n<2048){if((r-=2)<0)break;h.push(n>>6|192,n&63|128)}else if(n<65536){if((r-=3)<0)break;h.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((r-=4)<0)break;h.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return h}function Ri(o){let r=[];for(let n=0;n<o.length;++n)r.push(o.charCodeAt(n)&255);return r}function Ai(o,r){let n,u,c,h=[];for(let x=0;x<o.length&&!((r-=2)<0);++x)n=o.charCodeAt(x),u=n>>8,c=n%256,h.push(c),h.push(u);return h}function Mt(o){return p.toByteArray(Ei(o))}function Qe(o,r,n,u){let c;for(c=0;c<u&&!(c+n>=r.length||c>=o.length);++c)r[c+n]=o[c];return c}function J(o,r){return o instanceof r||o!=null&&o.constructor!=null&&o.constructor.name!=null&&o.constructor.name===r.name}function dt(o){return o!==o}let Ni=(function(){let o="0123456789abcdef",r=new Array(256);for(let n=0;n<16;++n){let u=n*16;for(let c=0;c<16;++c)r[u+c]=o[n]+o[c]}return r})();function oe(o){return typeof BigInt>"u"?Si:o}function Si(){throw new Error("BigInt not supported")}return he}var Oe,en,Xe,tn,he,rn,on=Ie(()=>{"use strict";f();m();d();Oe={},en=!1;Xe={},tn=!1;he={},rn=!1});var ye,v,fs,ds,an=Ie(()=>{"use strict";f();m();d();on();ye=nn();ye.Buffer;ye.SlowBuffer;ye.INSPECT_MAX_BYTES;ye.kMaxLength;v=ye.Buffer,fs=ye.INSPECT_MAX_BYTES,ds=ye.kMaxLength});var m=Ie(()=>{"use strict";an()});var Xa={};mt(Xa,{DynamicSnippetsGenerator:()=>lt});module.exports=Li(Xa);f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();var _i=typeof global=="object"&&global&&global.Object===Object&&global,sn=_i;var Vi=typeof self=="object"&&self&&self.Object===Object&&self,Di=sn||Vi||Function("return this")(),un=Di;var $i=un.Symbol,ne=$i;f();m();d();var pn=Object.prototype,ji=pn.hasOwnProperty,Wi=pn.toString,_e=ne?ne.toStringTag:void 0;function qi(p){var t=ji.call(p,_e),e=p[_e];try{p[_e]=void 0;var i=!0}catch{}var a=Wi.call(p);return i&&(t?p[_e]=e:delete p[_e]),a}var ln=qi;f();m();d();var Gi=Object.prototype,zi=Gi.toString;function Hi(p){return zi.call(p)}var cn=Hi;var Qi="[object Null]",Yi="[object Undefined]",fn=ne?ne.toStringTag:void 0;function Zi(p){return p==null?p===void 0?Yi:Qi:fn&&fn in Object(p)?ln(p):cn(p)}var dn=Zi;f();m();d();function Ji(p){return p!=null&&typeof p=="object"}var mn=Ji;var Ki="[object Symbol]";function Xi(p){return typeof p=="symbol"||mn(p)&&dn(p)==Ki}var hn=Xi;f();m();d();f();m();d();function eo(p,t){for(var e=-1,i=p==null?0:p.length,a=Array(i);++e<i;)a[e]=t(p[e],e,p);return a}var yn=eo;f();m();d();var to=Array.isArray,gn=to;var ro=1/0,xn=ne?ne.prototype:void 0,wn=xn?xn.toString:void 0;function In(p){if(typeof p=="string")return p;if(gn(p))return yn(p,In)+"";if(hn(p))return wn?wn.call(p):"";var t=p+"";return t=="0"&&1/p==-ro?"-0":t}var vn=In;f();m();d();function no(p){return p==null?"":vn(p)}var se=no;f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();f();m();d();function io(p,t,e){var i=-1,a=p.length;t<0&&(t=-t>a?0:a+t),e=e>a?a:e,e<0&&(e+=a),a=t>e?0:e-t>>>0,t>>>=0;for(var l=Array(a);++i<a;)l[i]=p[i+t];return l}var Tn=io;function oo(p,t,e){var i=p.length;return e=e===void 0?i:e,!t&&e>=i?p:Tn(p,t,e)}var bn=oo;f();m();d();var ao="\\ud800-\\udfff",so="\\u0300-\\u036f",uo="\\ufe20-\\ufe2f",po="\\u20d0-\\u20ff",lo=so+uo+po,co="\\ufe0e\\ufe0f",fo="\\u200d",mo=RegExp("["+fo+ao+lo+co+"]");function ho(p){return mo.test(p)}var et=ho;f();m();d();f();m();d();function yo(p){return p.split("")}var En=yo;f();m();d();var Rn="\\ud800-\\udfff",go="\\u0300-\\u036f",xo="\\ufe20-\\ufe2f",wo="\\u20d0-\\u20ff",Io=go+xo+wo,vo="\\ufe0e\\ufe0f",To="["+Rn+"]",xt="["+Io+"]",wt="\\ud83c[\\udffb-\\udfff]",bo="(?:"+xt+"|"+wt+")",An="[^"+Rn+"]",Nn="(?:\\ud83c[\\udde6-\\uddff]){2}",Sn="[\\ud800-\\udbff][\\udc00-\\udfff]",Eo="\\u200d",Bn=bo+"?",Pn="["+vo+"]?",Ro="(?:"+Eo+"(?:"+[An,Nn,Sn].join("|")+")"+Pn+Bn+")*",Ao=Pn+Bn+Ro,No="(?:"+[An+xt+"?",xt,Nn,Sn,To].join("|")+")",So=RegExp(wt+"(?="+wt+")|"+No+Ao,"g");function Bo(p){return p.match(So)||[]}var Fn=Bo;function Po(p){return et(p)?Fn(p):En(p)}var Cn=Po;function Fo(p){return function(t){t=se(t);var e=et(t)?Cn(t):void 0,i=e?e[0]:t.charAt(0),a=e?bn(e,1).join(""):t.slice(1);return i[p]()+a}}var kn=Fo;var Co=kn("toUpperCase"),Ln=Co;function ko(p){return Ln(se(p).toLowerCase())}var Un=ko;f();m();d();f();m();d();function Lo(p,t,e,i){var a=-1,l=p==null?0:p.length;for(i&&l&&(e=p[++a]);++a<l;)e=t(e,p[a],a,p);return e}var Mn=Lo;f();m();d();f();m();d();f();m();d();function Uo(p){return function(t){return p?.[t]}}var On=Uo;var Mo={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},Oo=On(Mo),_n=Oo;var _o=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Vo="\\u0300-\\u036f",Do="\\ufe20-\\ufe2f",$o="\\u20d0-\\u20ff",jo=Vo+Do+$o,Wo="["+jo+"]",qo=RegExp(Wo,"g");function Go(p){return p=se(p),p&&p.replace(_o,_n).replace(qo,"")}var Vn=Go;f();m();d();f();m();d();var zo=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Ho(p){return p.match(zo)||[]}var Dn=Ho;f();m();d();var Qo=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function Yo(p){return Qo.test(p)}var $n=Yo;f();m();d();var zn="\\ud800-\\udfff",Zo="\\u0300-\\u036f",Jo="\\ufe20-\\ufe2f",Ko="\\u20d0-\\u20ff",Xo=Zo+Jo+Ko,Hn="\\u2700-\\u27bf",Qn="a-z\\xdf-\\xf6\\xf8-\\xff",ea="\\xac\\xb1\\xd7\\xf7",ta="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",ra="\\u2000-\\u206f",na=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Yn="A-Z\\xc0-\\xd6\\xd8-\\xde",ia="\\ufe0e\\ufe0f",Zn=ea+ta+ra+na,Jn="['\u2019]",jn="["+Zn+"]",oa="["+Xo+"]",Kn="\\d+",aa="["+Hn+"]",Xn="["+Qn+"]",ei="[^"+zn+Zn+Kn+Hn+Qn+Yn+"]",sa="\\ud83c[\\udffb-\\udfff]",ua="(?:"+oa+"|"+sa+")",pa="[^"+zn+"]",ti="(?:\\ud83c[\\udde6-\\uddff]){2}",ri="[\\ud800-\\udbff][\\udc00-\\udfff]",Te="["+Yn+"]",la="\\u200d",Wn="(?:"+Xn+"|"+ei+")",ca="(?:"+Te+"|"+ei+")",qn="(?:"+Jn+"(?:d|ll|m|re|s|t|ve))?",Gn="(?:"+Jn+"(?:D|LL|M|RE|S|T|VE))?",ni=ua+"?",ii="["+ia+"]?",fa="(?:"+la+"(?:"+[pa,ti,ri].join("|")+")"+ii+ni+")*",da="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ma="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",ha=ii+ni+fa,ya="(?:"+[aa,ti,ri].join("|")+")"+ha,ga=RegExp([Te+"?"+Xn+"+"+qn+"(?="+[jn,Te,"$"].join("|")+")",ca+"+"+Gn+"(?="+[jn,Te+Wn,"$"].join("|")+")",Te+"?"+Wn+"+"+qn,Te+"+"+Gn,ma,da,Kn,ya].join("|"),"g");function xa(p){return p.match(ga)||[]}var oi=xa;function wa(p,t,e){return p=se(p),t=e?void 0:t,t===void 0?$n(p)?oi(p):Dn(p):p.match(t)||[]}var ai=wa;var Ia="['\u2019]",va=RegExp(Ia,"g");function Ta(p){return function(t){return Mn(ai(Vn(t).replace(va,"")),p,"")}}var tt=Ta;var ba=tt(function(p,t,e){return t=t.toLowerCase(),p+(e?Un(t):t)}),It=ba;f();m();d();var Ea=tt(function(p,t,e){return p+(e?"_":"")+t.toLowerCase()}),vt=Ea;f();m();d();function B(p){throw new Error("Unexpected value: "+JSON.stringify(p))}f();m();d();function Ve(p){return Object.keys(p)}f();m();d();f();m();d();f();m();d();var De=I.env.FERN_STACK_TRACK?.toLowerCase()??"",K=De!==""&&De!=="0"&&De!=="false",Tt=["single","multiline","box"].includes(De)?De:"single";K&&(Error.stackTraceLimit=50);var Ra=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),Aa=new Set(["stacktrace"]);function nt({maxFrames:p=50,skip:t=0,filterPaths:e=[],filterFunctions:i=[],stopOn:a=[],filterNode:l=!0,filterJs:s=!0,formatFilename:w=b=>b}={}){if(!K)return[];i=[...i,...Ra],e=[...e,...Aa],a=[...a,"runInteractiveTask"];let b=!1;return(new Error().stack??"").split(`
|
|
2
|
+
`).map(A=>{let R=A.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(R&&R.length===5){let[,C,D,E,N]=R;if(!C||!D||!E||!N)return;if(b||a.some(k=>C?.includes(k))){b=!0;return}switch(C){case"Object.<anonymous>":C="";break;case"Object.object":case"Object.alias":case"Object.union":case"Object.enum":case"Object.undiscriminatedUnion":C=`${C.substring(C.indexOf(".")+1)}()=> { ... }`;break}return{fn:C,path:w(D),position:`${E}:${N}`}}}).filter(A=>A&&!i.some(R=>A.fn.includes(R))&&!(l&&A.path?.startsWith("node:"))&&!(s&&A.path?.endsWith(".js"))&&!e.some(R=>A.path.includes(R))).slice(t,t+p)}var rt=class{constructor({maxFrames:t=50,skip:e=0,filterPaths:i=[],filterFunctions:a=[],stopOn:l=[],filterNode:s=!0,filterJs:w=!0,multiline:b=!1,formatFilename:A=R=>R}={}){y(this,"maxFrames");y(this,"skip");y(this,"filterPaths");y(this,"filterFunctions");y(this,"stopOn");y(this,"filterNode");y(this,"filterJs");y(this,"multiline");y(this,"formatFilename");y(this,"tracking",new WeakMap);this.maxFrames=t,this.skip=e,this.filterPaths=i,this.filterFunctions=a,this.stopOn=l,this.filterNode=s,this.filterJs=w,this.multiline=b,this.formatFilename=A}tag(t){let e=this.tracking.get(t)||new Set;nt({maxFrames:this.maxFrames,skip:this.skip,filterPaths:this.filterPaths,filterFunctions:this.filterFunctions,stopOn:this.stopOn,filterNode:this.filterNode,filterJs:this.filterJs,formatFilename:this.formatFilename}).forEach(i=>e.add(i)),this.tracking.set(t,e)}trace(t){if(!K)return"";let e=this.tracking.get(t);return e?[...e].map(i=>`${this.multiline?`
|
|
3
|
+
`:""}${i.fn} - ${i.path}:${i.position}`).join(""):""}frames(t){let e=this.tracking.get(t);return e?[...e]:[]}free(t){this.tracking.delete(t)}clear(){this.tracking=new WeakMap}},bt;function si({maxFrames:p=50,skip:t=0,filterPaths:e=[],filterFunctions:i=[],stopOn:a=[],filterNode:l=!0,filterJs:s=!0,multiline:w=!1,formatFilename:b=A=>A}={}){K&&(bt??(bt=new rt({maxFrames:p,skip:t,filterPaths:e,filterFunctions:i,stopOn:a,filterNode:l,filterJs:s,multiline:w,formatFilename:b})))}function ui(p){bt?.tag(p)}function Et(p){return bt?.frames(p)??[]}var ge=class{constructor(){ui(this)}};f();m();d();f();m();d();f();m();d();var Q=class extends ge{constructor(e){super();y(this,"value");this.value=e}write(e){typeof this.value=="string"?e.write(this.value):typeof this.value=="function"?this.value(e):this.value.write(e)}};var Na=4;si({skip:0,maxFrames:15,filterFunctions:["Abstract"]});var $e=class{constructor(){y(this,"lineBuffer",[]);y(this,"indentLevel",0);y(this,"hasWrittenAnything",!1);y(this,"lastCharacterIsSemicolon",!1);y(this,"lastCharacterIsNewline",!1);y(this,"nodeStackFrames",[])}get buffer(){return K&&this.nodeStackFrames.length>0&&this.writeInternal(`
|
|
4
4
|
`),this.lineBuffer.join(`
|
|
5
5
|
`)+(this.lastCharacterIsNewline?`
|
|
6
6
|
`:"")}write(...t){for(let e of t)if(e!=null)if(typeof e=="string"){let i=e.length>0&&e.endsWith(`
|
|
7
7
|
`),a=i?e.substring(0,e.length-1):e,l=this.getIndentString(),s=a.replaceAll(`
|
|
8
8
|
`,`
|
|
9
9
|
${l}`);this.isAtStartOfLine()&&(s=l+s),i&&(s+=`
|
|
10
|
-
`),this.writeInternal(s)}else this.writeNode(e)}writeStatement(...t){this.write(...t),this.write(";"),this.writeNewLineIfLastLineNot()}writeNoIndent(t){let e=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=e}writeNode(t){K&&this.nodeStackFrames.push(...
|
|
10
|
+
`),this.writeInternal(s)}else this.writeNode(e)}writeStatement(...t){this.write(...t),this.write(";"),this.writeNewLineIfLastLineNot()}writeNoIndent(t){let e=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=e}writeNode(t){K&&this.nodeStackFrames.push(...Et(t)),t.write(this),K&&Tt!=="single"&&this.writeInternal(`
|
|
11
11
|
`)}writeNodeOrString(t){if(typeof t=="string"){this.write(t);return}this.writeNode(t)}writeNodeStatement(t){this.writeNode(t),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new Q(t).write(this),t.endsWith(";")||this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(t,e){new Q(t).write(this),this.write(" (",e,")"),this.pushScope()}controlFlowWithoutStatement(t){new Q(t).write(this),this.pushScope()}endControlFlow(){this.popScope()}contiguousControlFlow(t,e){this.dedent(),this.write("} "),new Q(t).write(this),this.write(" (",e,")"),this.pushScope()}alternativeControlFlow(t){this.dedent(),this.write("} "),new Q(t).write(this),this.pushScope()}pushScope(){this.writeLine("{"),this.indent()}popScope(t=!0){this.dedent(),this.writeNewLineIfLastLineNot(),t?this.writeLine("}"):this.write("}")}writeLine(...t){this.write(...t.length===0?[""]:t),this.writeNewLineIfLastLineNot()}newLine(){this.writeInternal(`
|
|
12
12
|
`)}writeSemicolonIfLastCharacterIsNot(){this.lastCharacterIsSemicolon||this.writeInternal(";")}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
|
|
13
13
|
`)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:t,delimiter:e,writeFunction:i}){if(t.length>0){let a=t[0];a!=null&&i(a);for(let l=1;l<t.length;l++){this.write(e);let s=t[l];s!=null&&i(s)}}}toString(){return this.buffer}writeInternal(t){if(t.length===0)return;let e=!this.lastCharacterIsNewline;this.hasWrittenAnything=!0,this.lastCharacterIsNewline=t.endsWith(`
|
|
14
14
|
`),this.lastCharacterIsSemicolon=t.endsWith(";");let i=t.split(`
|
|
15
|
-
`),a=K&&!this.shouldSkipTracking(i)&&this.lastCharacterIsNewline;e&&(this.lastLine=`${this.lastLine}${i.shift()||""}`),this.lastCharacterIsNewline&&i.pop(),this.lineBuffer.push(...i),a&&this.appendTrackingComment()}set lastLine(t){this.lineBuffer.length>0?this.lineBuffer[this.lineBuffer.length-1]=t:this.lineBuffer.push(t)}get lastLine(){return this.lineBuffer[this.lineBuffer.length-1]||""}shouldSkipTracking(t){return!1}formatStack(t,e=""){return t.map(i=>`${e?`(${e}) `:""} ${i.fn} - ${i.path} : ${i.position}`)}filterStack(t){return t.filter(e=>!e.fn.startsWith(`${this.constructor.name}.`))}appendTrackingComment(){let t=[...this.formatStack(this.filterStack(nt({maxFrames:15,skip:3}))),...this.formatStack(this.filterStack(this.nodeStackFrames),"node")];switch(this.nodeStackFrames.length=0,bt){case"single":return this.singleLineTrackingComment(t);case"multiline":return this.multiLineTrackingComment(t);case"box":return this.boxTrackingComment(t)}}singleLineTrackingComment(t){this.lastLine=`${this.lastLine} // ${t.join(" ")}`}multiLineTrackingComment(t){this.lineBuffer.push(...t.map(e=>` // ${e}`))}boxTrackingComment(t){this.lineBuffer.push("/*",...t.map(e=>` ${e}`),"*/")}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*this.getTabSize())}getTabSize(){return Na}};f();m();d();f();m();d();f();m();d();var je=class{constructor(){y(this,"reporter");y(this,"snippet");y(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:t,snippet:e}){this.shouldUpdate({snippet:e,reporter:t.errors})&&(this.reporter=t.errors.clone(),this.snippet=e)}getResponseOrThrow({endpoint:t}){if(this.snippet!=null&&this.reporter!=null)return{snippet:this.snippet,errors:this.reporter.toDynamicSnippetErrors()};throw this.err??new Error(`Failed to generate snippet for endpoint "${t.method} ${t.path}"`)}shouldUpdate({snippet:t,reporter:e}){return this.reporter==null||this.reporter.size()>0&&e.size()===0?!0:t.length>(this.snippet?.length??0)}};var We=class{constructor(t){y(this,"context");this.context=t}async generate(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let a=new je;for(let l of i){let s=this.context.clone(),E=this.createSnippetGenerator(s);try{let b=await E.generateSnippet({endpoint:l,request:t,options:e});if(s.errors.empty())return{snippet:b,errors:void 0};a.update({context:s,snippet:b})}catch(b){a.err==null&&(a.err=b)}}return a.getResponseOrThrow({endpoint:t.endpoint})}async generateSnippetAst(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let a;for(let l of i){let s=this.context.clone(),E=this.createSnippetGenerator(s);try{return await E.generateSnippetAst({endpoint:l,request:t,options:e})}catch(b){a=b}}throw a??new Error(`Failed to generate snippet AST for endpoint: ${t.endpoint.method} ${t.endpoint.path}`)}generateSync(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let a=new je;for(let l of i){let s=this.context.clone(),E=this.createSnippetGenerator(s);try{let b=E.generateSnippetSync({endpoint:l,request:t,options:e});if(s.errors.empty())return{snippet:b,errors:void 0};a.update({context:s,snippet:b})}catch(b){a.err==null&&(a.err=b)}}return a.getResponseOrThrow({endpoint:t.endpoint})}resolveEndpoints({request:t,options:e}){if(e.endpointId!=null){let i=this.context.resolveEndpointById(e.endpointId);if(i==null)throw new Error(`No endpoint found with ID "${e.endpointId}"`);return[i]}return this.context.resolveEndpointLocationOrThrow(t.endpoint)}};f();m();d();f();m();d();f();m();d();var qe=class{constructor(){y(this,"REFERENCE_REGEX",/^(?:(\w+)::)?(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/)}validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let i=t.match(this.REFERENCE_REGEX);if(!(i==null||i[2]==null||i[3]==null))return{namespace:i[1],method:i[2],path:i[3]}}};f();m();d();var P={Critical:"CRITICAL",Warning:"WARNING"},Ge=class p{constructor(){y(this,"errors");y(this,"path");this.errors=[],this.path=[]}add(t){this.errors.push({...t,path:[...this.path]})}scope(t){this.path.push(t)}unscope(){this.path.pop()}getBySeverity(t){return this.errors.filter(e=>e.severity===t)}empty(){return this.errors.length===0}size(){return this.errors.length}truncate(t){this.errors.length=t}clone(){let t=new p;return t.errors=[...this.errors],t.path=[...this.path],t}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(t=>({severity:t.severity,path:t.path!=null?this.pathToStringArray(t.path):void 0,message:t.message}))}pathToStringArray(t){let e=[];for(let i of t){if(typeof i=="string"){e.push(i);continue}e[e.length-1]+=`[${i.index}]`}return e}};var ze=class{constructor({ir:t,config:e,options:i={}}){y(this,"config");y(this,"options");y(this,"errors");y(this,"_ir");y(this,"httpEndpointReferenceParser");this._ir=t,this.config=e,this.options=i,this.errors=new Ge,this.httpEndpointReferenceParser=new qe}associateQueryParametersByWireValue({parameters:t,values:e}){let i=[];for(let[a,l]of Object.entries(e))if(l!==void 0){this.errors.scope(a);try{let s=t.find(b=>b.name.wireValue===a);if(s==null)throw this.newParameterNotRecognizedError(a);let E=this.isListTypeReference(s.typeReference)&&!Array.isArray(l)?[l]:l;i.push({name:s.name,typeReference:s.typeReference,value:E})}finally{this.errors.unscope()}}return i}associateByWireValueOrDefault({parameters:t,values:e}){let i=[];for(let a of t){this.errors.scope(a.name.wireValue);try{let l=e[a.name.wireValue];if(l==null)if(a.typeReference.type==="primitive"&&a.typeReference.value==="STRING")l=`<${a.name.wireValue}>`;else{this.errors.add({severity:P.Critical,message:this.newParameterNotRecognizedError(a.name.wireValue).message});continue}i.push({name:a.name,typeReference:a.typeReference,value:l})}finally{this.errors.unscope()}}return i}associateByWireValue({parameters:t,values:e,ignoreMissingParameters:i}){let a=[];for(let[l,s]of Object.entries(e))if(s!==void 0){this.errors.scope(l);try{let E=t.find(b=>b.name.wireValue===l);if(E==null){if(i)continue;this.errors.add({severity:P.Critical,message:this.newParameterNotRecognizedError(l).message});continue}a.push({name:E.name,typeReference:E.typeReference,value:s})}finally{this.errors.unscope()}}return a}getExampleObjectProperties({parameters:t,snippetObject:e}){let i=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},a=[];for(let l of t){let s=i[l.name.wireValue];s==null?l.typeReference.type==="nullable"&&a.push({name:l.name,typeReference:l.typeReference,value:null}):a.push({name:l.name,typeReference:l.typeReference,value:s})}return a}getSingleFileValue({property:t,record:e}){let i=e[t.wireValue];if(i!=null){if(typeof i!="string"){this.errors.add({severity:P.Critical,message:`Expected file value to be a string, got ${typeof i}`});return}return i}}getFileArrayValues({property:t,record:e}){let i=e[t.wireValue];if(i==null)return;if(!Array.isArray(i)){this.errors.add({severity:P.Critical,message:`Expected file array value to be an array of strings, got ${typeof i}`});return}let a=[];for(let l of i){if(typeof l!="string"){this.errors.add({severity:P.Critical,message:`Expected file array value to be an array of strings, got ${typeof l}`});return}a.push(l)}return a}getRecord(t){if(typeof t!="object"||Array.isArray(t)){this.errors.add({severity:P.Critical,message:`Expected object with key, value pairs but got: ${Array.isArray(t)?"array":typeof t}`});return}return t??{}}resolveNamedType({typeId:t}){let e=this._ir.types[t];if(e==null){this.errors.add({severity:P.Critical,message:`Type identified by "${t}" could not be found`});return}return e}resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e}){let i=this.getRecord(e);if(i==null)return;let a=t.discriminant.wireValue,l=i[a];if(l==null){this.errors.add({severity:P.Critical,message:this.newParameterNotRecognizedError(a).message});return}if(typeof l!="string"){this.errors.add({severity:P.Critical,message:`Expected discriminant value to be a string but got: ${typeof l}`});return}let s=t.types[l];if(s==null){this.errors.add({severity:P.Critical,message:`No type found for discriminant value "${l}"`});return}let{[a]:E,...b}=i;return{singleDiscriminatedUnionType:s,discriminantValue:s.discriminantValue,value:b}}resolveEndpointOrThrow(t){let e=this.httpEndpointReferenceParser.tryParse(t);if(e==null)throw new Error(`Failed to parse endpoint reference "${t}"`);return this.resolveEndpointLocationOrThrow(e)}resolveEndpointLocation(t){let e=[];for(let i of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:i,parsedEndpoint:t})&&e.push(i);return e}resolveEndpointLocationOrThrow(t){let e=this.resolveEndpointLocation(t);if(e.length===0)throw new Error(`Failed to find endpoint identified by "${t.method} ${t.path}"`);return e}resolveEndpointById(t){return this._ir.endpoints[t]}resolveEndpointByIdOrThrow(t){let e=this.resolveEndpointById(t);if(e==null)throw new Error(`Failed to find endpoint with ID "${t}"`);return e}needsRequestParameter({request:t,inlinePathParameters:e,inlineFileProperties:i}){return this.includePathParametersInWrappedRequest({request:t,inlinePathParameters:e})||t.queryParameters!=null&&t.queryParameters.length>0||t.headers!=null&&t.headers.length>0?!0:t.body!=null?this.includeRequestBodyInWrappedRequest({body:t.body,inlineFileProperties:i}):!t.metadata?.onlyPathParameters}includePathParametersInWrappedRequest({request:t,inlinePathParameters:e}){return e&&(t.metadata?.includePathParameters??!1)}isFileUploadRequestBody(t){switch(t.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:C(t)}}resolveEnvironmentName(t){if(this._ir.environments==null)return;let e=this._ir.environments.environments;switch(e.type){case"singleBaseUrl":{let i=e.environments.find(a=>a.id===t);return i?.name}case"multipleBaseUrls":{let i=e.environments.find(a=>a.id===t);return i?.name}default:C(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:P.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:P.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let i=e.environments[0];if(i==null)return this.errors.add({severity:P.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let a=new Set(Ve(i.urls));for(let l of Ve(t))a.has(l)&&a.delete(l);return a.size>0?(this.errors.add({severity:P.Critical,message:`The provided environments are invalid; got: [${Object.keys(t).join(", ")}], expected: [${Ve(i.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:t}){if(typeof t!="number"){this.errors.add({severity:P.Critical,message:this.newTypeMismatchError({expected:"number",value:t}).message});return}return t}getValueAsBoolean({value:t}){if(typeof t!="boolean"){this.errors.add({severity:P.Critical,message:this.newTypeMismatchError({expected:"boolean",value:t}).message});return}return t}getValueAsString({value:t}){if(typeof t!="string"){this.errors.add({severity:P.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:C(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:C(e)}})}fileUploadHasFileProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:C(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}};f();m();d();var Y={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};f();m();d();f();m();d();var x={};mt(x,{AccessAttribute:()=>Ee,AstNode:()=>S,Class:()=>ue,ClassInstantiation:()=>Re,CodeBlock:()=>ie,Comment:()=>Ae,Decorator:()=>Ne,Field:()=>pe,Lambda:()=>Se,LambdaParameter:()=>Be,Method:()=>ce,MethodArgument:()=>Fe,MethodInvocation:()=>Ce,ModuleImport:()=>Z,Operator:()=>ke,Parameter:()=>le,PythonFile:()=>Le,Reference:()=>ee,StarImport:()=>fe,Type:()=>ot,TypeInstantiation:()=>de,accessAttribute:()=>Pa,assign:()=>Fa,class_:()=>ka,codeBlock:()=>Va,comment:()=>$a,decorator:()=>Ua,field:()=>_a,file:()=>Ca,instantiateClass:()=>La,invokeFunction:()=>qa,invokeMethod:()=>Ga,lambda:()=>Da,lambdaParameter:()=>ja,method:()=>Wa,methodArgument:()=>Ha,operator:()=>Qa,parameter:()=>za,reference:()=>Ma,starImport:()=>Oa});f();m();d();f();m();d();f();m();d();f();m();d();var He=class extends De{constructor(){super(...arguments);y(this,"fullyQualifiedModulePathsToImportedNames",{})}setRefNameOverrides(e){this.fullyQualifiedModulePathsToImportedNames=e}unsetRefNameOverrides(){this.fullyQualifiedModulePathsToImportedNames={}}getRefNameOverride(e){let i=this.fullyQualifiedModulePathsToImportedNames[e.getFullyQualifiedModulePath()];return i||{name:e.alias??e.name,isAlias:!!e.alias}}toString(){return this.buffer}async toStringFormatted(e){return e.format(this.buffer)}};var S=class extends ge{constructor(){super(...arguments);y(this,"references",[])}addReference(e){this.references.push(e)}inheritReferences(e){e!==void 0&&e.references.forEach(i=>{this.references.includes(i)||this.addReference(i)})}getReferences(){return this.references}toString(){let e=new He;return this.write(e),e.toString()}async toStringFormatted(e){let i=new He;return this.write(i),i.toStringFormatted(e)}};var Ee=class extends S{constructor({lhs:e,rhs:i}){super();y(this,"lhs");y(this,"rhs");this.lhs=e,this.inheritReferences(e),this.rhs=i,this.inheritReferences(i)}write(e){this.lhs.write(e),e.write("."),this.rhs.write(e)}};f();m();d();var it=class extends S{constructor({lhs:e,rhs:i}){super();y(this,"lhs");y(this,"rhs");this.lhs=e,this.inheritReferences(e),this.rhs=i,this.inheritReferences(i)}write(e){this.lhs.write(e),e.write(" = "),this.rhs.write(e)}};f();m();d();var Te=class extends S{constructor({reference:e,arguments_:i,multiline:a}){super();y(this,"reference");y(this,"arguments");y(this,"multiline");this.reference=e,this.arguments=i,this.multiline=a??!1,this.inheritReferences(e),this.arguments.forEach(l=>{this.inheritReferences(l)})}write(e){if(this.reference.write(e),this.arguments.length===0){e.write("()");return}e.write("("),this.multiline&&(e.newLine(),e.indent()),this.arguments.forEach((i,a)=>{i.write(e),a<this.arguments.length-1?(e.write(","),this.multiline?e.newLine():e.write(" ")):this.multiline&&e.write(",")}),this.multiline&&(e.newLine(),e.dedent()),e.write(")")}};f();m();d();var ue=class extends S{constructor({docs:e,name:i,extends_:a,decorators:l}){super();y(this,"name");y(this,"extends_");y(this,"decorators");y(this,"fields",[]);y(this,"docs");y(this,"statements",[]);this.name=i,this.extends_=a??[],this.decorators=l??[],this.docs=e,this.extends_.forEach(s=>{this.inheritReferences(s)}),this.decorators.forEach(s=>{this.inheritReferences(s)})}write(e){this.decorators.forEach(i=>{i.write(e)}),e.write(`class ${this.name}`),this.extends_.length>0&&(e.write("("),this.extends_.forEach((i,a)=>{a>0&&e.write(", "),i.write(e)}),e.write(")")),e.write(":"),e.newLine(),e.indent(),this.docs!=null&&(e.write('"""'),e.write(this.docs),e.write('"""')),e.writeNewLineIfLastLineNot(),this.fields.forEach(i=>{i.write(e),e.writeNewLineIfLastLineNot()}),e.dedent(),e.indent(),this.statements.length?this.writeStatements({writer:e}):e.write("pass"),e.dedent()}add(e){this.statements.push(e),this.inheritReferences(e)}writeStatements({writer:e}){this.statements.forEach((i,a)=>{i.write(e),e.writeNewLineIfLastLineNot()})}addField(e){this.add(e)}};f();m();d();var Re=class extends Te{constructor({classReference:t,...e}){super({reference:t,...e})}};f();m();d();var ie=class extends S{constructor(e){super();y(this,"arg");this.arg=e}write(e){return new Q(this.arg).write(e)}};f();m();d();var Ae=class extends S{constructor({docs:e}){super();y(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
|
|
16
|
-
`).forEach(i=>{e.writeLine(`# ${i}`)})}};f();m();d();var Ne=class extends S{constructor({callable:e}){super();y(this,"callable");this.callable=e,this.inheritReferences(e)}write(e){e.write("@"),this.callable.write(e),e.newLine()}};f();m();d();var pe=class extends S{constructor({name:e,type:i,initializer:a,docs:l}){super();y(this,"name");y(this,"type");y(this,"initializer");y(this,"docs");this.name=e,this.type=i,this.initializer=a,this.docs=l,this.inheritReferences(this.type),this.inheritReferences(this.initializer)}write(e){e.write(this.name),this.type!==void 0&&(e.write(": "),this.type.write(e)),this.initializer!==void 0&&(e.write(" = "),this.initializer.write(e)),this.docs!=null&&(e.newLine(),e.write('"""'),e.newLine(),e.write(this.docs),e.newLine(),e.write('"""'))}};f();m();d();var Se=class extends S{constructor({parameters:e,body:i}){super();y(this,"parameters");y(this,"body");this.parameters=e??[],this.body=i,this.inheritReferences(i)}write(e){e.write("lambda"),this.parameters&&this.parameters.length&&(e.write(" "),this.parameters.forEach((i,a)=>{i.write(e),a<this.parameters.length-1&&e.write(", ")})),e.write(": "),this.body.write(e)}};f();m();d();f();m();d();var le=class extends S{constructor({name:e,type:i,initializer:a}){super();y(this,"name");y(this,"initializer");y(this,"type");this.name=e,this.type=i,this.initializer=a}write(e){e.write(this.name),this.type&&(e.write(": "),this.type.write(e)),this.initializer!==void 0&&(e.write(" = "),this.initializer.write(e))}};var Be=class extends le{constructor({name:t,initializer:e}){super({name:t,initializer:e,type:void 0})}};f();m();d();var Pe;(function(p){p[p.STATIC=0]="STATIC",p[p.INSTANCE=1]="INSTANCE",p[p.CLASS=2]="CLASS"})(Pe||(Pe={}));var ce=class extends S{constructor({static_:e,name:i,parameters:a,return_:l,docstring:s,type:E,decorators:b}){super();y(this,"name");y(this,"return");y(this,"docstring");y(this,"type");y(this,"parameters");y(this,"decorators");y(this,"statements",[]);y(this,"static_");this.name=i,this.parameters=a??[],this.return=l,this.docstring=s,this.type=E,this.decorators=b??[],this.static_=e??!1,this.parameters.forEach(A=>{this.inheritReferences(A)}),this.inheritReferences(this.return),this.decorators.forEach(A=>{this.inheritReferences(A)}),this.statements.forEach(A=>{this.inheritReferences(A)})}addStatement(e){this.statements.push(e),this.inheritReferences(e)}write(e){this.static_&&this.decorators.push(x.decorator({callable:x.codeBlock("staticmethod")})),this.decorators.forEach(l=>{l.write(e)}),this.type===Pe.CLASS?x.decorator({callable:new ie("classmethod")}).write(e):this.type===Pe.STATIC&&x.decorator({callable:new ie("staticmethod")}).write(e),e.write(`def ${this.name}(`);let a=this.parameters.length>3;a&&(e.newLine(),e.indent()),this.type===Pe.INSTANCE?(e.write("self"),this.parameters.length>0&&(e.write(a?",":", "),a&&e.newLine())):this.type===Pe.CLASS&&(e.write("cls"),this.parameters.length>0&&(e.write(a?",":", "),a&&e.newLine())),this.parameters.forEach((l,s)=>{l.write(e),s<this.parameters.length-1&&(e.write(a?",":", "),a&&e.newLine())}),a&&(e.write(","),e.dedent(),e.newLine()),e.write(")"),this.return&&(e.write(" -> "),this.return.write(e)),e.write(":"),e.newLine(),this.docstring&&(e.indent(),e.write('"""'),e.write(this.docstring),e.write('"""'),e.newLine(),e.dedent()),this.statements.length?(e.indent(),this.statements.forEach((l,s)=>{l.write(e),s<this.statements.length-1&&e.newLine()}),e.dedent()):(e.indent(),e.write("pass"),e.dedent()),e.newLine()}};f();m();d();var Fe=class extends S{constructor({name:e,value:i}){super();y(this,"name");y(this,"value");this.name=e,this.value=i,this.inheritReferences(this.value)}write(e){this.name!==void 0&&(e.write(this.name),e.write("=")),this.value.write(e)}};f();m();d();var Ce=class extends S{constructor({on:e,method:i,arguments_:a,multiline:l}){super();y(this,"on");y(this,"method");y(this,"arguments");y(this,"multiline");this.on=e,this.method=i,this.arguments=a,this.multiline=l??!1,this.inheritReferences(e),this.arguments.forEach(s=>{this.inheritReferences(s)})}write(e){if(this.on.write(e),e.write("."),e.write(this.method),this.arguments.length===0){e.write("()");return}e.write("("),this.multiline&&(e.newLine(),e.indent()),this.arguments.forEach((i,a)=>{i.write(e),a<this.arguments.length-1?(e.write(","),this.multiline?e.newLine():e.write(" ")):this.multiline&&e.write(",")}),this.multiline&&(e.newLine(),e.dedent()),e.write(")")}};f();m();d();f();m();d();var X={Or:"or",And:"and",Add:"add",Subtract:"subtract",Multiply:"multiple",Divide:"divide",Modulo:"modulo",LeftShift:"leftShift",RightShift:"rightShift"};var ke=class extends S{constructor({operator:e,lhs:i,rhs:a}){super();y(this,"operator");y(this,"lhs");y(this,"rhs");this.operator=e,this.lhs=i,this.inheritReferences(i),this.rhs=a,this.inheritReferences(a)}getOperatorString(){switch(this.operator){case X.Or:return"or";case X.And:return"and";case X.Add:return"+";case X.Subtract:return"-";case X.Multiply:return"*";case X.Divide:return"/";case X.Modulo:return"%";case X.LeftShift:return"<<";case X.RightShift:return">>";default:C(this.operator)}}write(e){this.lhs.write(e),e.write(" "),e.write(this.getOperatorString()),e.write(" "),this.rhs.write(e)}};f();m();d();f();m();d();function pi(p){if(!p)return"Class";let t=p.replace(/[^a-zA-Z0-9\s_-]/g," ").replace(/[-_\s]+/g," ").trim();return!t||/^\d+$/.test(t)?"Class"+(t||""):(/^\d/.test(t)&&(t="Class"+t),t.split(/(?=[A-Z])|[-_\s]+/).filter(i=>i.length>0).map(i=>i.split(/(?<=\d)(?=[a-zA-Z])|(?<=[a-zA-Z])(?=\d)/).filter(a=>a.length>0)).flat().map((i,a)=>a===0&&/^\d/.test(i)?"Class"+i.charAt(0).toUpperCase()+i.slice(1).toLowerCase():i.length>1&&i===i.toUpperCase()&&!/^\d+$/.test(i)?i:i.charAt(0).toUpperCase()+i.slice(1).toLowerCase()).join(""))}f();m();d();f();m();d();var ee=class extends S{constructor({name:e,modulePath:i,genericTypes:a,alias:l,attribute:s}){super();y(this,"name");y(this,"modulePath");y(this,"genericTypes");y(this,"alias");y(this,"attribute");this.name=e,this.modulePath=i??[],this.genericTypes=a??[],this.alias=l,this.attribute=s??[],this.references.push(this),this.genericTypes.forEach(E=>{this.inheritReferences(E)})}write(e){let i=e.getRefNameOverride(this);e.write(i.name),this.genericTypes.length>0&&(e.write("["),this.genericTypes.forEach((a,l)=>{l>0&&e.write(", "),a.write(e)}),e.write("]")),this.attribute.length>0&&(e.write("."),this.attribute.forEach((a,l)=>{l>0&&e.write("."),e.write(a)}))}getFullyQualifiedPath(){return this.modulePath.join(".")}getFullyQualifiedModulePath(){return`${this.getFullyQualifiedPath()}.${this.name}`}};var Z=class extends ee{constructor({module:t}){super({name:t,modulePath:[t]})}write(t){throw new Error("Not intended to be written outside the context of a PythonFile.")}};f();m();d();var fe=class extends ee{constructor({modulePath:e}){super({name:"*",modulePath:e});y(this,"docs")}write(e){throw new Error("Not intended to be written outside the context of a PythonFile.")}};var Le=class extends S{constructor({path:e,statements:i,isInitFile:a=!1,comments:l,imports:s}){super();y(this,"path");y(this,"isInitFile");y(this,"statements",[]);y(this,"comments");this.path=e,this.isInitFile=a,i?.forEach(E=>this.addStatement(E)),this.comments=l??[],s?.forEach(E=>this.addReference(E))}addStatement(e){this.statements.push(e),this.inheritReferences(e)}write(e){let i=this.deduplicateReferences();this.updateWriterRefNameOverrides({writer:e,uniqueReferences:i}),this.writeComments(e),this.writeImports({writer:e,uniqueReferences:i}),this.statements.forEach((a,l)=>{a.write(e),e.newLine(),l<this.statements.length-1&&e.newLine()}),e.unsetRefNameOverrides()}updateWriterRefNameOverrides({writer:e,uniqueReferences:i}){let a=new Map(i),l={},s=this.getInitialUsedNames(),E=this.path.join("."),b=i.get(E);if(b){let{references:R}=b;R.forEach(F=>{let $=F.getFullyQualifiedModulePath(),T=F.name;l[$]={name:T,isAlias:!1},s.add(F.name)}),a.delete(E)}Array.from(a.values()).flatMap(({references:R})=>R).forEach(R=>{if(R instanceof fe||R instanceof Z)return;let F=R.alias??R.name,$=R.getFullyQualifiedModulePath(),T=F,N=R.modulePath.length-1,k=!!R.alias;for(;s.has(T);){k=!0;let M=R.modulePath[N];N<0||!M?T=`_${T}`:T=`${pi(M)}${T}`,N--}s.add(T),l[$]={name:T,isAlias:k}}),e.setRefNameOverrides(l)}getInitialUsedNames(){let e=new Set;return this.statements.forEach(i=>{(i instanceof ue||i instanceof ce||i instanceof pe)&&e.add(i.name)}),e}deduplicateReferences(){let e=new Map;for(let i of this.references){let a=i.name,l=i.getFullyQualifiedPath();if(l==="")continue;let s=e.get(l);s?s.referenceNames.has(a)||(s.references.push(i),s.referenceNames.add(a)):e.set(l,{modulePath:i.modulePath,references:[i],referenceNames:new Set([a])})}return e}writeComments(e){this.comments.forEach(i=>{i.write(e)}),this.comments.length>0&&e.newLine()}getImportName({writer:e,reference:i}){let a=e.getRefNameOverride(i),l=i.name,s=a.isAlias?a.name:void 0;return`${l}${s?` as ${s}`:""}`}writeImports({writer:e,uniqueReferences:i}){if(i.size!==0){for(let[a,{modulePath:l,references:s}]of i){let E=l;if(!this.isDefinedInFile(E)){if(s.some(b=>b instanceof Z)){e.write(`import ${a}`),e.newLine();continue}if(E[0]===this.path[0]){let b=0;for(;b<this.path.length&&b<E.length&&this.path[b]===E[b];)b++;let A=this.path.length-b;this.isInitFile&&A++;let R=A>0?".".repeat(A):".";R+=E.slice(b).join("."),e.write(`from ${R} import ${s.map(F=>this.getImportName({writer:e,reference:F})).join(", ")}`)}else e.write(`from ${a} import ${s.map(b=>this.getImportName({writer:e,reference:b})).join(", ")}`);e.newLine()}}e.newLine()}}isDefinedInFile(e){return e.length===this.path.length&&e.every((i,a)=>i===this.path[a])}};f();m();d();var ot=class extends S{constructor(e){super();y(this,"internalType");this.internalType=e}write(e){switch(this.internalType.type){case"int":e.write("int");break;case"float":e.write("float");break;case"bool":e.write("bool");break;case"str":e.write("str");break;case"bytes":e.write("bytes");break;case"list":e.write("List["),this.internalType.value.write(e),e.write("]");break;case"set":e.write("Set["),this.internalType.value.write(e),e.write("]");break;case"tuple":e.write("Tuple["),this.internalType.values.forEach((i,a)=>{a>0&&e.write(", "),i.write(e)}),e.write("]");break;case"dict":e.write("Dict["),this.internalType.keyType.write(e),e.write(", "),this.internalType.valueType.write(e),e.write("]");break;case"none":e.write("None");break;case"uuid":e.write("UUID");break;case"optional":e.write("Optional["),this.internalType.value.write(e),e.write("]");break;case"union":e.write("Union["),this.internalType.values.forEach((i,a)=>{a>0&&e.write(", "),i.write(e)}),e.write("]");break;case"any":e.write("Any");break;case"reference":this.internalType.value.write(e);break;case"datetime":e.write("datetime");break;case"literal":typeof this.internalType.value=="string"?e.write(`Literal["${this.internalType.value}"]`):e.write(`Literal[${this.internalType.value}]`);break;default:C(this.internalType)}}static int(){return new this({type:"int"})}static float(){return new this({type:"float"})}static bool(){return new this({type:"bool"})}static str(){return new this({type:"str"})}static bytes(){return new this({type:"bytes"})}static list(e){let i=new this({type:"list",value:e});return i.addReference(x.reference({name:"List",modulePath:["typing"]})),i.inheritReferences(e),i}static set(e){let i=new this({type:"set",value:e});return i.addReference(x.reference({name:"Set",modulePath:["typing"]})),i.inheritReferences(e),i}static tuple(e){let i=new this({type:"tuple",values:e});return i.addReference(x.reference({name:"Tuple",modulePath:["typing"]})),e.forEach(a=>i.inheritReferences(a)),i}static dict(e,i){let a=new this({type:"dict",keyType:e,valueType:i});return a.addReference(x.reference({name:"Dict",modulePath:["typing"]})),a.inheritReferences(e),a.inheritReferences(i),a}static none(){return new this({type:"none"})}static uuid(){let e=new this({type:"uuid"});return e.addReference(x.reference({name:"UUID",modulePath:["uuid"]})),e}static optional(e){if(this.isAlreadyOptional(e))return e;let i=new this({type:"optional",value:e});return i.addReference(x.reference({name:"Optional",modulePath:["typing"]})),i.inheritReferences(e),i}static union(e){let i=new this({type:"union",values:e});return i.addReference(x.reference({name:"Union",modulePath:["typing"]})),e.forEach(a=>i.inheritReferences(a)),i}static any(){let e=new this({type:"any"});return e.addReference(x.reference({name:"Any",modulePath:["typing"]})),e}static datetime(){let e=new this({type:"datetime"});return e.addReference(x.reference({name:"datetime",modulePath:["datetime"]})),e}static reference(e){let i=new this({type:"reference",value:e});return i.addReference(e),i}static literal(e){let i=new this({type:"literal",value:e});return i.addReference(x.reference({name:"Literal",modulePath:["typing"]})),i}static isAlreadyOptional(e){return e.internalType.type==="optional"}};f();m();d();var de=class p extends S{constructor(e){super();y(this,"internalType");this.internalType=e}static int(e){return new this({type:"int",value:e})}static float(e){return new this({type:"float",value:e})}static bool(e){return new this({type:"bool",value:e})}static str(e,i={multiline:!1,startOnNewLine:!1,endWithNewLine:!1}){return new this({type:"str",value:e,config:i})}static bytes(e){return new this({type:"bytes",value:e})}static list(e,i={endWithComma:!1}){let a=new this({type:"list",values:e,config:i});return e.forEach(l=>a.inheritReferences(l)),a}static set(e,i={endWithComma:!1}){let a=new this({type:"set",values:e,config:i});return e.forEach(l=>a.inheritReferences(l)),a}static tuple(e,i={endWithComma:!1}){let a=new this({type:"tuple",values:e,config:i});return e.forEach(l=>a.inheritReferences(l)),a}static typedDict(e,i={endWithComma:!1}){let a=new this({type:"typedDict",entries:e,config:i});return e.forEach(l=>a.inheritReferences(l.value)),a}static date(e){let i=new this({type:"date",value:e});return i.addReference(new Z({module:"datetime"})),i}static datetime(e){let i=new this({type:"datetime",value:e});return i.addReference(new Z({module:"datetime"})),i}static dict(e,i={endWithComma:!1}){let a=new this({type:"dict",entries:e,config:i});return e.forEach(l=>{a.inheritReferences(l.key),a.inheritReferences(l.value)}),a}static reference(e){let i=new this({type:"reference",value:e});return i.inheritReferences(e),i}static none(){return new this({type:"none"})}static unknown(e){return new this({type:"unknown",value:e})}static uuid(e){let i=new this({type:"uuid",value:e});return i.addReference(new Z({module:"uuid"})),i}static nop(){return new this({type:"nop"})}static isNop(e){return e instanceof p&&e.internalType.type==="nop"}isTypedDict(){return this.internalType.type==="typedDict"}asTypedDictOrThrow(){if(this.isTypedDict())return this.internalType;throw new Error("Internal error; python.TypeInstantiation is not a TypedDict")}write(e){switch(this.internalType.type){case"int":e.write(this.internalType.value.toString());break;case"float":e.write(this.internalType.value.toString());break;case"bool":this.internalType.value?e.write("True"):e.write("False");break;case"str":if(this.internalType.config?.multiline){let{startOnNewLine:i,endWithNewLine:a}=this.internalType.config;this.writeStringWithTripleQuotes({writer:e,value:this.internalType.value,startOnNewLine:i,endWithNewLine:a})}else e.write(`"${this.escapeString(this.internalType.value)}"`);break;case"date":e.write(`datetime.date.fromisoformat("${this.internalType.value}")`);break;case"datetime":{let i=this.internalType.value.replace(/Z$/,"+00:00");e.write(`datetime.datetime.fromisoformat("${i}")`);break}case"bytes":e.write(`b"${this.internalType.value}"`);break;case"list":{let i=this.internalType,a=Rt({values:i.values});if(a.length===0){e.write("[]");break}e.write("["),i.config?.multiline&&(e.newLine(),e.indent()),a.forEach((l,s)=>{s>0&&(e.write(","),i.config?.multiline?e.newLine():e.write(" ")),l.write(e),s===a.length-1&&i.config?.endWithComma&&e.write(",")}),i.config?.multiline&&(e.newLine(),e.dedent()),e.write("]");break}case"set":{let i=this.internalType,a=Rt({values:i.values});if(a.length===0){e.write("{}");break}e.write("{"),i.config?.multiline&&(e.newLine(),e.indent()),a.forEach((l,s)=>{s>0&&(e.write(","),i.config?.multiline?e.newLine():e.write(" ")),l.write(e),s===a.length-1&&i.config?.endWithComma&&e.write(",")}),i.config?.multiline&&(e.newLine(),e.dedent()),e.write("}");break}case"tuple":{let i=this.internalType,a=Rt({values:i.values});if(a.length===0){e.write("()");break}e.write("("),i.config?.multiline&&(e.newLine(),e.indent()),a.forEach((l,s)=>{s>0&&(e.write(","),i.config?.multiline?e.newLine():e.write(" ")),l.write(e),(a.length===1||s===a.length-1&&i.config?.endWithComma)&&e.write(",")}),i.config?.multiline&&(e.newLine(),e.dedent()),e.write(")");break}case"dict":{let i=this.internalType,a=Sa({entries:i.entries});if(a.length===0){e.write("{}");break}e.write("{"),i.config?.multiline&&(e.newLine(),e.indent()),a.forEach((l,s)=>{s>0&&(e.write(","),i.config?.multiline?e.newLine():e.write(" ")),l.key.write(e),e.write(": "),l.value.write(e),s===a.length-1&&i.config?.endWithComma&&e.write(",")}),i.config?.multiline&&(e.newLine(),e.dedent()),e.write("}");break}case"typedDict":{let i=this.internalType,a=Ba({entries:i.entries});if(a.length===0){e.write("{}");break}e.write("{"),i.config?.multiline&&(e.writeLine(),e.indent()),a.forEach((l,s)=>{s>0&&(e.write(","),i.config?.multiline?e.newLine():e.write(" ")),e.write(`"${l.name}": `),l.value.write(e)}),i.config?.multiline&&(e.newLine(),e.dedent()),e.write("}");break}case"reference":{this.internalType.value.write(e);break}case"none":e.write("None");break;case"unknown":this.writeUnknown({writer:e,value:this.internalType.value});break;case"uuid":e.write(`uuid.UUID("${this.internalType.value}")`);break;case"nop":break;default:C(this.internalType)}}writeStringWithTripleQuotes({writer:e,value:i,startOnNewLine:a,endWithNewLine:l}){e.write('"""');let s=i.split(`
|
|
15
|
+
`),a=K&&!this.shouldSkipTracking(i)&&this.lastCharacterIsNewline;e&&(this.lastLine=`${this.lastLine}${i.shift()||""}`),this.lastCharacterIsNewline&&i.pop(),this.lineBuffer.push(...i),a&&this.appendTrackingComment()}set lastLine(t){this.lineBuffer.length>0?this.lineBuffer[this.lineBuffer.length-1]=t:this.lineBuffer.push(t)}get lastLine(){return this.lineBuffer[this.lineBuffer.length-1]||""}shouldSkipTracking(t){return!1}formatStack(t,e=""){return t.map(i=>`${e?`(${e}) `:""} ${i.fn} - ${i.path} : ${i.position}`)}filterStack(t){return t.filter(e=>!e.fn.startsWith(`${this.constructor.name}.`))}appendTrackingComment(){let t=[...this.formatStack(this.filterStack(nt({maxFrames:15,skip:3}))),...this.formatStack(this.filterStack(this.nodeStackFrames),"node")];switch(this.nodeStackFrames.length=0,Tt){case"single":return this.singleLineTrackingComment(t);case"multiline":return this.multiLineTrackingComment(t);case"box":return this.boxTrackingComment(t)}}singleLineTrackingComment(t){this.lastLine=`${this.lastLine} // ${t.join(" ")}`}multiLineTrackingComment(t){this.lineBuffer.push(...t.map(e=>` // ${e}`))}boxTrackingComment(t){this.lineBuffer.push("/*",...t.map(e=>` ${e}`),"*/")}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*this.getTabSize())}getTabSize(){return Na}};f();m();d();f();m();d();f();m();d();var je=class{constructor(){y(this,"reporter");y(this,"snippet");y(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:t,snippet:e}){this.shouldUpdate({snippet:e,reporter:t.errors})&&(this.reporter=t.errors.clone(),this.snippet=e)}getResponseOrThrow({endpoint:t}){if(this.snippet!=null&&this.reporter!=null)return{snippet:this.snippet,errors:this.reporter.toDynamicSnippetErrors()};throw this.err??new Error(`Failed to generate snippet for endpoint "${t.method} ${t.path}"`)}shouldUpdate({snippet:t,reporter:e}){return this.reporter==null||this.reporter.size()>0&&e.size()===0?!0:t.length>(this.snippet?.length??0)}};var We=class{constructor(t){y(this,"context");this.context=t}async generate(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let a=new je;for(let l of i){let s=this.context.clone(),w=this.createSnippetGenerator(s);try{let b=await w.generateSnippet({endpoint:l,request:t,options:e});if(s.errors.empty())return{snippet:b,errors:void 0};a.update({context:s,snippet:b})}catch(b){a.err==null&&(a.err=b)}}return a.getResponseOrThrow({endpoint:t.endpoint})}async generateSnippetAst(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let a;for(let l of i){let s=this.context.clone(),w=this.createSnippetGenerator(s);try{return await w.generateSnippetAst({endpoint:l,request:t,options:e})}catch(b){a=b}}throw a??new Error(`Failed to generate snippet AST for endpoint: ${t.endpoint.method} ${t.endpoint.path}`)}generateSync(t,e={}){let i=this.resolveEndpoints({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let a=new je;for(let l of i){let s=this.context.clone(),w=this.createSnippetGenerator(s);try{let b=w.generateSnippetSync({endpoint:l,request:t,options:e});if(s.errors.empty())return{snippet:b,errors:void 0};a.update({context:s,snippet:b})}catch(b){a.err==null&&(a.err=b)}}return a.getResponseOrThrow({endpoint:t.endpoint})}resolveEndpoints({request:t,options:e}){if(e.endpointId!=null){let i=this.context.resolveEndpointById(e.endpointId);if(i==null)throw new Error(`No endpoint found with ID "${e.endpointId}"`);return[i]}return this.context.resolveEndpointLocationOrThrow(t.endpoint)}};f();m();d();f();m();d();f();m();d();var qe=class{constructor(){y(this,"REFERENCE_REGEX",/^(?:(\w+)::)?(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/)}validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let i=t.match(this.REFERENCE_REGEX);if(!(i==null||i[2]==null||i[3]==null))return{namespace:i[1],method:i[2],path:i[3]}}};f();m();d();var F={Critical:"CRITICAL",Warning:"WARNING"},Ge=class p{constructor(){y(this,"errors");y(this,"path");this.errors=[],this.path=[]}add(t){this.errors.push({...t,path:[...this.path]})}scope(t){this.path.push(t)}unscope(){this.path.pop()}getBySeverity(t){return this.errors.filter(e=>e.severity===t)}empty(){return this.errors.length===0}size(){return this.errors.length}truncate(t){this.errors.length=t}clone(){let t=new p;return t.errors=[...this.errors],t.path=[...this.path],t}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(t=>({severity:t.severity,path:t.path!=null?this.pathToStringArray(t.path):void 0,message:t.message}))}pathToStringArray(t){let e=[];for(let i of t){if(typeof i=="string"){e.push(i);continue}e[e.length-1]+=`[${i.index}]`}return e}};var ze=class{constructor({ir:t,config:e,options:i={}}){y(this,"config");y(this,"options");y(this,"errors");y(this,"_ir");y(this,"httpEndpointReferenceParser");this._ir=t,this.config=e,this.options=i,this.errors=new Ge,this.httpEndpointReferenceParser=new qe}associateQueryParametersByWireValue({parameters:t,values:e}){let i=[];for(let[a,l]of Object.entries(e))if(l!==void 0){this.errors.scope(a);try{let s=t.find(b=>b.name.wireValue===a);if(s==null)throw this.newParameterNotRecognizedError(a);let w=this.isListTypeReference(s.typeReference)&&!Array.isArray(l)?[l]:l;i.push({name:s.name,typeReference:s.typeReference,value:w})}finally{this.errors.unscope()}}return i}associateByWireValueOrDefault({parameters:t,values:e}){let i=[];for(let a of t){this.errors.scope(a.name.wireValue);try{let l=e[a.name.wireValue];if(l==null)if(a.typeReference.type==="primitive"&&a.typeReference.value==="STRING")l=`<${a.name.wireValue}>`;else{this.errors.add({severity:F.Critical,message:this.newParameterNotRecognizedError(a.name.wireValue).message});continue}i.push({name:a.name,typeReference:a.typeReference,value:l})}finally{this.errors.unscope()}}return i}associateByWireValue({parameters:t,values:e,ignoreMissingParameters:i}){let a=[];for(let[l,s]of Object.entries(e))if(s!==void 0){this.errors.scope(l);try{let w=t.find(b=>b.name.wireValue===l);if(w==null){if(i)continue;this.errors.add({severity:F.Critical,message:this.newParameterNotRecognizedError(l).message});continue}a.push({name:w.name,typeReference:w.typeReference,value:s})}finally{this.errors.unscope()}}return a}getExampleObjectProperties({parameters:t,snippetObject:e}){let i=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},a=[];for(let l of t){let s=i[l.name.wireValue];s==null?l.typeReference.type==="nullable"&&a.push({name:l.name,typeReference:l.typeReference,value:null}):a.push({name:l.name,typeReference:l.typeReference,value:s})}return a}getSingleFileValue({property:t,record:e}){let i=e[t.wireValue];if(i!=null){if(typeof i!="string"){this.errors.add({severity:F.Critical,message:`Expected file value to be a string, got ${typeof i}`});return}return i}}getFileArrayValues({property:t,record:e}){let i=e[t.wireValue];if(i==null)return;if(!Array.isArray(i)){this.errors.add({severity:F.Critical,message:`Expected file array value to be an array of strings, got ${typeof i}`});return}let a=[];for(let l of i){if(typeof l!="string"){this.errors.add({severity:F.Critical,message:`Expected file array value to be an array of strings, got ${typeof l}`});return}a.push(l)}return a}getRecord(t){if(typeof t!="object"||Array.isArray(t)){this.errors.add({severity:F.Critical,message:`Expected object with key, value pairs but got: ${Array.isArray(t)?"array":typeof t}`});return}return t??{}}resolveNamedType({typeId:t}){let e=this._ir.types[t];if(e==null){this.errors.add({severity:F.Critical,message:`Type identified by "${t}" could not be found`});return}return e}resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e}){let i=this.getRecord(e);if(i==null)return;let a=t.discriminant.wireValue,l=i[a];if(l==null){this.errors.add({severity:F.Critical,message:this.newParameterNotRecognizedError(a).message});return}if(typeof l!="string"){this.errors.add({severity:F.Critical,message:`Expected discriminant value to be a string but got: ${typeof l}`});return}let s=t.types[l];if(s==null){this.errors.add({severity:F.Critical,message:`No type found for discriminant value "${l}"`});return}let{[a]:w,...b}=i;return{singleDiscriminatedUnionType:s,discriminantValue:s.discriminantValue,value:b}}resolveEndpointOrThrow(t){let e=this.httpEndpointReferenceParser.tryParse(t);if(e==null)throw new Error(`Failed to parse endpoint reference "${t}"`);return this.resolveEndpointLocationOrThrow(e)}resolveEndpointLocation(t){let e=[];for(let i of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:i,parsedEndpoint:t})&&e.push(i);return e}resolveEndpointLocationOrThrow(t){let e=this.resolveEndpointLocation(t);if(e.length===0)throw new Error(`Failed to find endpoint identified by "${t.method} ${t.path}"`);return e}resolveEndpointById(t){return this._ir.endpoints[t]}resolveEndpointByIdOrThrow(t){let e=this.resolveEndpointById(t);if(e==null)throw new Error(`Failed to find endpoint with ID "${t}"`);return e}needsRequestParameter({request:t,inlinePathParameters:e,inlineFileProperties:i}){return this.includePathParametersInWrappedRequest({request:t,inlinePathParameters:e})||t.queryParameters!=null&&t.queryParameters.length>0||t.headers!=null&&t.headers.length>0?!0:t.body!=null?this.includeRequestBodyInWrappedRequest({body:t.body,inlineFileProperties:i}):!t.metadata?.onlyPathParameters}includePathParametersInWrappedRequest({request:t,inlinePathParameters:e}){return e&&(t.metadata?.includePathParameters??!1)}isFileUploadRequestBody(t){switch(t.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:B(t)}}resolveEnvironmentName(t){if(this._ir.environments==null)return;let e=this._ir.environments.environments;switch(e.type){case"singleBaseUrl":{let i=e.environments.find(a=>a.id===t);return i?.name}case"multipleBaseUrls":{let i=e.environments.find(a=>a.id===t);return i?.name}default:B(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:F.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:F.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let i=e.environments[0];if(i==null)return this.errors.add({severity:F.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let a=new Set(Ve(i.urls));for(let l of Ve(t))a.has(l)&&a.delete(l);return a.size>0?(this.errors.add({severity:F.Critical,message:`The provided environments are invalid; got: [${Object.keys(t).join(", ")}], expected: [${Ve(i.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:t}){if(typeof t!="number"){this.errors.add({severity:F.Critical,message:this.newTypeMismatchError({expected:"number",value:t}).message});return}return t}getValueAsBoolean({value:t}){if(typeof t!="boolean"){this.errors.add({severity:F.Critical,message:this.newTypeMismatchError({expected:"boolean",value:t}).message});return}return t}getValueAsString({value:t}){if(typeof t!="string"){this.errors.add({severity:F.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:B(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:B(e)}})}fileUploadHasFileProperties({fileUpload:t}){return t.properties.some(e=>{switch(e.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:B(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}};f();m();d();var Y={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};f();m();d();f();m();d();var g={};mt(g,{AccessAttribute:()=>be,AstNode:()=>S,Class:()=>ue,ClassInstantiation:()=>Re,CodeBlock:()=>ie,Comment:()=>Ae,Decorator:()=>Ne,Field:()=>pe,Lambda:()=>Se,LambdaParameter:()=>Be,Method:()=>ce,MethodArgument:()=>Fe,MethodInvocation:()=>Ce,ModuleImport:()=>Z,Operator:()=>ke,Parameter:()=>le,PythonFile:()=>Le,Reference:()=>ee,StarImport:()=>fe,Type:()=>ot,TypeInstantiation:()=>de,accessAttribute:()=>Pa,assign:()=>Fa,class_:()=>ka,codeBlock:()=>Va,comment:()=>Da,decorator:()=>Ua,field:()=>_a,file:()=>Ca,instantiateClass:()=>La,invokeFunction:()=>qa,invokeMethod:()=>Ga,lambda:()=>$a,lambdaParameter:()=>ja,method:()=>Wa,methodArgument:()=>Ha,operator:()=>Qa,parameter:()=>za,reference:()=>Ma,starImport:()=>Oa});f();m();d();f();m();d();f();m();d();f();m();d();var He=class extends $e{constructor(){super(...arguments);y(this,"fullyQualifiedModulePathsToImportedNames",{})}setRefNameOverrides(e){this.fullyQualifiedModulePathsToImportedNames=e}unsetRefNameOverrides(){this.fullyQualifiedModulePathsToImportedNames={}}getRefNameOverride(e){let i=this.fullyQualifiedModulePathsToImportedNames[e.getFullyQualifiedModulePath()];return i||{name:e.alias??e.name,isAlias:!!e.alias}}toString(){return this.buffer}async toStringFormatted(e){return e.format(this.buffer)}};var S=class extends ge{constructor(){super(...arguments);y(this,"references",[])}addReference(e){this.references.push(e)}inheritReferences(e){e!==void 0&&e.references.forEach(i=>{this.references.includes(i)||this.addReference(i)})}getReferences(){return this.references}toString(){let e=new He;return this.write(e),e.toString()}async toStringFormatted(e){let i=new He;return this.write(i),i.toStringFormatted(e)}};var be=class extends S{constructor({lhs:e,rhs:i}){super();y(this,"lhs");y(this,"rhs");this.lhs=e,this.inheritReferences(e),this.rhs=i,this.inheritReferences(i)}write(e){this.lhs.write(e),e.write("."),this.rhs.write(e)}};f();m();d();var it=class extends S{constructor({lhs:e,rhs:i}){super();y(this,"lhs");y(this,"rhs");this.lhs=e,this.inheritReferences(e),this.rhs=i,this.inheritReferences(i)}write(e){this.lhs.write(e),e.write(" = "),this.rhs.write(e)}};f();m();d();var Ee=class extends S{constructor({reference:e,arguments_:i,multiline:a}){super();y(this,"reference");y(this,"arguments");y(this,"multiline");this.reference=e,this.arguments=i,this.multiline=a??!1,this.inheritReferences(e),this.arguments.forEach(l=>{this.inheritReferences(l)})}write(e){if(this.reference.write(e),this.arguments.length===0){e.write("()");return}e.write("("),this.multiline&&(e.newLine(),e.indent()),this.arguments.forEach((i,a)=>{i.write(e),a<this.arguments.length-1?(e.write(","),this.multiline?e.newLine():e.write(" ")):this.multiline&&e.write(",")}),this.multiline&&(e.newLine(),e.dedent()),e.write(")")}};f();m();d();var ue=class extends S{constructor({docs:e,name:i,extends_:a,decorators:l}){super();y(this,"name");y(this,"extends_");y(this,"decorators");y(this,"fields",[]);y(this,"docs");y(this,"statements",[]);this.name=i,this.extends_=a??[],this.decorators=l??[],this.docs=e,this.extends_.forEach(s=>{this.inheritReferences(s)}),this.decorators.forEach(s=>{this.inheritReferences(s)})}write(e){this.decorators.forEach(i=>{i.write(e)}),e.write(`class ${this.name}`),this.extends_.length>0&&(e.write("("),this.extends_.forEach((i,a)=>{a>0&&e.write(", "),i.write(e)}),e.write(")")),e.write(":"),e.newLine(),e.indent(),this.docs!=null&&(e.write('"""'),e.write(this.docs),e.write('"""')),e.writeNewLineIfLastLineNot(),this.fields.forEach(i=>{i.write(e),e.writeNewLineIfLastLineNot()}),e.dedent(),e.indent(),this.statements.length?this.writeStatements({writer:e}):e.write("pass"),e.dedent()}add(e){this.statements.push(e),this.inheritReferences(e)}writeStatements({writer:e}){this.statements.forEach((i,a)=>{i.write(e),e.writeNewLineIfLastLineNot()})}addField(e){this.add(e)}};f();m();d();var Re=class extends Ee{constructor({classReference:t,...e}){super({reference:t,...e})}};f();m();d();var ie=class extends S{constructor(e){super();y(this,"arg");this.arg=e}write(e){return new Q(this.arg).write(e)}};f();m();d();var Ae=class extends S{constructor({docs:e}){super();y(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
|
|
16
|
+
`).forEach(i=>{e.writeLine(`# ${i}`)})}};f();m();d();var Ne=class extends S{constructor({callable:e}){super();y(this,"callable");this.callable=e,this.inheritReferences(e)}write(e){e.write("@"),this.callable.write(e),e.newLine()}};f();m();d();var pe=class extends S{constructor({name:e,type:i,initializer:a,docs:l}){super();y(this,"name");y(this,"type");y(this,"initializer");y(this,"docs");this.name=e,this.type=i,this.initializer=a,this.docs=l,this.inheritReferences(this.type),this.inheritReferences(this.initializer)}write(e){e.write(this.name),this.type!==void 0&&(e.write(": "),this.type.write(e)),this.initializer!==void 0&&(e.write(" = "),this.initializer.write(e)),this.docs!=null&&(e.newLine(),e.write('"""'),e.newLine(),e.write(this.docs),e.newLine(),e.write('"""'))}};f();m();d();var Se=class extends S{constructor({parameters:e,body:i}){super();y(this,"parameters");y(this,"body");this.parameters=e??[],this.body=i,this.inheritReferences(i)}write(e){e.write("lambda"),this.parameters&&this.parameters.length&&(e.write(" "),this.parameters.forEach((i,a)=>{i.write(e),a<this.parameters.length-1&&e.write(", ")})),e.write(": "),this.body.write(e)}};f();m();d();f();m();d();var le=class extends S{constructor({name:e,type:i,initializer:a}){super();y(this,"name");y(this,"initializer");y(this,"type");this.name=e,this.type=i,this.initializer=a}write(e){e.write(this.name),this.type&&(e.write(": "),this.type.write(e)),this.initializer!==void 0&&(e.write(" = "),this.initializer.write(e))}};var Be=class extends le{constructor({name:t,initializer:e}){super({name:t,initializer:e,type:void 0})}};f();m();d();var Pe;(function(p){p[p.STATIC=0]="STATIC",p[p.INSTANCE=1]="INSTANCE",p[p.CLASS=2]="CLASS"})(Pe||(Pe={}));var ce=class extends S{constructor({static_:e,name:i,parameters:a,return_:l,docstring:s,type:w,decorators:b}){super();y(this,"name");y(this,"return");y(this,"docstring");y(this,"type");y(this,"parameters");y(this,"decorators");y(this,"statements",[]);y(this,"static_");this.name=i,this.parameters=a??[],this.return=l,this.docstring=s,this.type=w,this.decorators=b??[],this.static_=e??!1,this.parameters.forEach(A=>{this.inheritReferences(A)}),this.inheritReferences(this.return),this.decorators.forEach(A=>{this.inheritReferences(A)}),this.statements.forEach(A=>{this.inheritReferences(A)})}addStatement(e){this.statements.push(e),this.inheritReferences(e)}write(e){this.static_&&this.decorators.push(g.decorator({callable:g.codeBlock("staticmethod")})),this.decorators.forEach(l=>{l.write(e)}),this.type===Pe.CLASS?g.decorator({callable:new ie("classmethod")}).write(e):this.type===Pe.STATIC&&g.decorator({callable:new ie("staticmethod")}).write(e),e.write(`def ${this.name}(`);let a=this.parameters.length>3;a&&(e.newLine(),e.indent()),this.type===Pe.INSTANCE?(e.write("self"),this.parameters.length>0&&(e.write(a?",":", "),a&&e.newLine())):this.type===Pe.CLASS&&(e.write("cls"),this.parameters.length>0&&(e.write(a?",":", "),a&&e.newLine())),this.parameters.forEach((l,s)=>{l.write(e),s<this.parameters.length-1&&(e.write(a?",":", "),a&&e.newLine())}),a&&(e.write(","),e.dedent(),e.newLine()),e.write(")"),this.return&&(e.write(" -> "),this.return.write(e)),e.write(":"),e.newLine(),this.docstring&&(e.indent(),e.write('"""'),e.write(this.docstring),e.write('"""'),e.newLine(),e.dedent()),this.statements.length?(e.indent(),this.statements.forEach((l,s)=>{l.write(e),s<this.statements.length-1&&e.newLine()}),e.dedent()):(e.indent(),e.write("pass"),e.dedent()),e.newLine()}};f();m();d();var Fe=class extends S{constructor({name:e,value:i}){super();y(this,"name");y(this,"value");this.name=e,this.value=i,this.inheritReferences(this.value)}write(e){this.name!==void 0&&(e.write(this.name),e.write("=")),this.value.write(e)}};f();m();d();var Ce=class extends S{constructor({on:e,method:i,arguments_:a,multiline:l}){super();y(this,"on");y(this,"method");y(this,"arguments");y(this,"multiline");this.on=e,this.method=i,this.arguments=a,this.multiline=l??!1,this.inheritReferences(e),this.arguments.forEach(s=>{this.inheritReferences(s)})}write(e){if(this.on.write(e),e.write("."),e.write(this.method),this.arguments.length===0){e.write("()");return}e.write("("),this.multiline&&(e.newLine(),e.indent()),this.arguments.forEach((i,a)=>{i.write(e),a<this.arguments.length-1?(e.write(","),this.multiline?e.newLine():e.write(" ")):this.multiline&&e.write(",")}),this.multiline&&(e.newLine(),e.dedent()),e.write(")")}};f();m();d();f();m();d();var X={Or:"or",And:"and",Add:"add",Subtract:"subtract",Multiply:"multiple",Divide:"divide",Modulo:"modulo",LeftShift:"leftShift",RightShift:"rightShift"};var ke=class extends S{constructor({operator:e,lhs:i,rhs:a}){super();y(this,"operator");y(this,"lhs");y(this,"rhs");this.operator=e,this.lhs=i,this.inheritReferences(i),this.rhs=a,this.inheritReferences(a)}getOperatorString(){switch(this.operator){case X.Or:return"or";case X.And:return"and";case X.Add:return"+";case X.Subtract:return"-";case X.Multiply:return"*";case X.Divide:return"/";case X.Modulo:return"%";case X.LeftShift:return"<<";case X.RightShift:return">>";default:B(this.operator)}}write(e){this.lhs.write(e),e.write(" "),e.write(this.getOperatorString()),e.write(" "),this.rhs.write(e)}};f();m();d();f();m();d();function pi(p){if(!p)return"Class";let t=p.replace(/[^a-zA-Z0-9\s_-]/g," ").replace(/[-_\s]+/g," ").trim();return!t||/^\d+$/.test(t)?"Class"+(t||""):(/^\d/.test(t)&&(t="Class"+t),t.split(/(?=[A-Z])|[-_\s]+/).filter(i=>i.length>0).map(i=>i.split(/(?<=\d)(?=[a-zA-Z])|(?<=[a-zA-Z])(?=\d)/).filter(a=>a.length>0)).flat().map((i,a)=>a===0&&/^\d/.test(i)?"Class"+i.charAt(0).toUpperCase()+i.slice(1).toLowerCase():i.length>1&&i===i.toUpperCase()&&!/^\d+$/.test(i)?i:i.charAt(0).toUpperCase()+i.slice(1).toLowerCase()).join(""))}f();m();d();f();m();d();var ee=class extends S{constructor({name:e,modulePath:i,genericTypes:a,alias:l,attribute:s}){super();y(this,"name");y(this,"modulePath");y(this,"genericTypes");y(this,"alias");y(this,"attribute");this.name=e,this.modulePath=i??[],this.genericTypes=a??[],this.alias=l,this.attribute=s??[],this.references.push(this),this.genericTypes.forEach(w=>{this.inheritReferences(w)})}write(e){let i=e.getRefNameOverride(this);e.write(i.name),this.genericTypes.length>0&&(e.write("["),this.genericTypes.forEach((a,l)=>{l>0&&e.write(", "),a.write(e)}),e.write("]")),this.attribute.length>0&&(e.write("."),this.attribute.forEach((a,l)=>{l>0&&e.write("."),e.write(a)}))}getFullyQualifiedPath(){return this.modulePath.join(".")}getFullyQualifiedModulePath(){return`${this.getFullyQualifiedPath()}.${this.name}`}};var Z=class extends ee{constructor({module:t}){super({name:t,modulePath:[t]})}write(t){throw new Error("Not intended to be written outside the context of a PythonFile.")}};f();m();d();var fe=class extends ee{constructor({modulePath:e}){super({name:"*",modulePath:e});y(this,"docs")}write(e){throw new Error("Not intended to be written outside the context of a PythonFile.")}};var Le=class extends S{constructor({path:e,statements:i,isInitFile:a=!1,comments:l,imports:s}){super();y(this,"path");y(this,"isInitFile");y(this,"statements",[]);y(this,"comments");this.path=e,this.isInitFile=a,i?.forEach(w=>this.addStatement(w)),this.comments=l??[],s?.forEach(w=>this.addReference(w))}addStatement(e){this.statements.push(e),this.inheritReferences(e)}write(e){let i=this.deduplicateReferences();this.updateWriterRefNameOverrides({writer:e,uniqueReferences:i}),this.writeComments(e),this.writeImports({writer:e,uniqueReferences:i}),this.statements.forEach((a,l)=>{a.write(e),e.newLine(),l<this.statements.length-1&&e.newLine()}),e.unsetRefNameOverrides()}updateWriterRefNameOverrides({writer:e,uniqueReferences:i}){let a=new Map(i),l={},s=this.getInitialUsedNames(),w=this.path.join("."),b=i.get(w);if(b){let{references:R}=b;R.forEach(C=>{let D=C.getFullyQualifiedModulePath(),E=C.name;l[D]={name:E,isAlias:!1},s.add(C.name)}),a.delete(w)}Array.from(a.values()).flatMap(({references:R})=>R).forEach(R=>{if(R instanceof fe||R instanceof Z)return;let C=R.alias??R.name,D=R.getFullyQualifiedModulePath(),E=C,N=R.modulePath.length-1,k=!!R.alias;for(;s.has(E);){k=!0;let M=R.modulePath[N];N<0||!M?E=`_${E}`:E=`${pi(M)}${E}`,N--}s.add(E),l[D]={name:E,isAlias:k}}),e.setRefNameOverrides(l)}getInitialUsedNames(){let e=new Set;return this.statements.forEach(i=>{(i instanceof ue||i instanceof ce||i instanceof pe)&&e.add(i.name)}),e}deduplicateReferences(){let e=new Map;for(let i of this.references){let a=i.name,l=i.getFullyQualifiedPath();if(l==="")continue;let s=e.get(l);s?s.referenceNames.has(a)||(s.references.push(i),s.referenceNames.add(a)):e.set(l,{modulePath:i.modulePath,references:[i],referenceNames:new Set([a])})}return e}writeComments(e){this.comments.forEach(i=>{i.write(e)}),this.comments.length>0&&e.newLine()}getImportName({writer:e,reference:i}){let a=e.getRefNameOverride(i),l=i.name,s=a.isAlias?a.name:void 0;return`${l}${s?` as ${s}`:""}`}writeImports({writer:e,uniqueReferences:i}){if(i.size!==0){for(let[a,{modulePath:l,references:s}]of i){let w=l;if(!this.isDefinedInFile(w)){if(s.some(b=>b instanceof Z)){e.write(`import ${a}`),e.newLine();continue}if(w[0]===this.path[0]){let b=0;for(;b<this.path.length&&b<w.length&&this.path[b]===w[b];)b++;let A=this.path.length-b;this.isInitFile&&A++;let R=A>0?".".repeat(A):".";R+=w.slice(b).join("."),e.write(`from ${R} import ${s.map(C=>this.getImportName({writer:e,reference:C})).join(", ")}`)}else e.write(`from ${a} import ${s.map(b=>this.getImportName({writer:e,reference:b})).join(", ")}`);e.newLine()}}e.newLine()}}isDefinedInFile(e){return e.length===this.path.length&&e.every((i,a)=>i===this.path[a])}};f();m();d();var ot=class extends S{constructor(e){super();y(this,"internalType");this.internalType=e}write(e){switch(this.internalType.type){case"int":e.write("int");break;case"float":e.write("float");break;case"bool":e.write("bool");break;case"str":e.write("str");break;case"bytes":e.write("bytes");break;case"list":e.write("List["),this.internalType.value.write(e),e.write("]");break;case"set":e.write("Set["),this.internalType.value.write(e),e.write("]");break;case"tuple":e.write("Tuple["),this.internalType.values.forEach((i,a)=>{a>0&&e.write(", "),i.write(e)}),e.write("]");break;case"dict":e.write("Dict["),this.internalType.keyType.write(e),e.write(", "),this.internalType.valueType.write(e),e.write("]");break;case"none":e.write("None");break;case"uuid":e.write("UUID");break;case"optional":e.write("Optional["),this.internalType.value.write(e),e.write("]");break;case"union":e.write("Union["),this.internalType.values.forEach((i,a)=>{a>0&&e.write(", "),i.write(e)}),e.write("]");break;case"any":e.write("Any");break;case"reference":this.internalType.value.write(e);break;case"datetime":e.write("datetime");break;case"literal":typeof this.internalType.value=="string"?e.write(`Literal["${this.internalType.value}"]`):e.write(`Literal[${this.internalType.value}]`);break;default:B(this.internalType)}}static int(){return new this({type:"int"})}static float(){return new this({type:"float"})}static bool(){return new this({type:"bool"})}static str(){return new this({type:"str"})}static bytes(){return new this({type:"bytes"})}static list(e){let i=new this({type:"list",value:e});return i.addReference(g.reference({name:"List",modulePath:["typing"]})),i.inheritReferences(e),i}static set(e){let i=new this({type:"set",value:e});return i.addReference(g.reference({name:"Set",modulePath:["typing"]})),i.inheritReferences(e),i}static tuple(e){let i=new this({type:"tuple",values:e});return i.addReference(g.reference({name:"Tuple",modulePath:["typing"]})),e.forEach(a=>i.inheritReferences(a)),i}static dict(e,i){let a=new this({type:"dict",keyType:e,valueType:i});return a.addReference(g.reference({name:"Dict",modulePath:["typing"]})),a.inheritReferences(e),a.inheritReferences(i),a}static none(){return new this({type:"none"})}static uuid(){let e=new this({type:"uuid"});return e.addReference(g.reference({name:"UUID",modulePath:["uuid"]})),e}static optional(e){if(this.isAlreadyOptional(e))return e;let i=new this({type:"optional",value:e});return i.addReference(g.reference({name:"Optional",modulePath:["typing"]})),i.inheritReferences(e),i}static union(e){let i=new this({type:"union",values:e});return i.addReference(g.reference({name:"Union",modulePath:["typing"]})),e.forEach(a=>i.inheritReferences(a)),i}static any(){let e=new this({type:"any"});return e.addReference(g.reference({name:"Any",modulePath:["typing"]})),e}static datetime(){let e=new this({type:"datetime"});return e.addReference(g.reference({name:"datetime",modulePath:["datetime"]})),e}static reference(e){let i=new this({type:"reference",value:e});return i.addReference(e),i}static literal(e){let i=new this({type:"literal",value:e});return i.addReference(g.reference({name:"Literal",modulePath:["typing"]})),i}static isAlreadyOptional(e){return e.internalType.type==="optional"}};f();m();d();var de=class p extends S{constructor(e){super();y(this,"internalType");this.internalType=e}static int(e){return new this({type:"int",value:e})}static float(e){return new this({type:"float",value:e})}static bool(e){return new this({type:"bool",value:e})}static str(e,i={multiline:!1,startOnNewLine:!1,endWithNewLine:!1}){return new this({type:"str",value:e,config:i})}static bytes(e){return new this({type:"bytes",value:e})}static list(e,i={endWithComma:!1}){let a=new this({type:"list",values:e,config:i});return e.forEach(l=>a.inheritReferences(l)),a}static set(e,i={endWithComma:!1}){let a=new this({type:"set",values:e,config:i});return e.forEach(l=>a.inheritReferences(l)),a}static tuple(e,i={endWithComma:!1}){let a=new this({type:"tuple",values:e,config:i});return e.forEach(l=>a.inheritReferences(l)),a}static typedDict(e,i={endWithComma:!1}){let a=new this({type:"typedDict",entries:e,config:i});return e.forEach(l=>a.inheritReferences(l.value)),a}static date(e){let i=new this({type:"date",value:e});return i.addReference(new Z({module:"datetime"})),i}static datetime(e){let i=new this({type:"datetime",value:e});return i.addReference(new Z({module:"datetime"})),i}static dict(e,i={endWithComma:!1}){let a=new this({type:"dict",entries:e,config:i});return e.forEach(l=>{a.inheritReferences(l.key),a.inheritReferences(l.value)}),a}static reference(e){let i=new this({type:"reference",value:e});return i.inheritReferences(e),i}static none(){return new this({type:"none"})}static unknown(e){return new this({type:"unknown",value:e})}static uuid(e){let i=new this({type:"uuid",value:e});return i.addReference(new Z({module:"uuid"})),i}static nop(){return new this({type:"nop"})}static isNop(e){return e instanceof p&&e.internalType.type==="nop"}isTypedDict(){return this.internalType.type==="typedDict"}asTypedDictOrThrow(){if(this.isTypedDict())return this.internalType;throw new Error("Internal error; python.TypeInstantiation is not a TypedDict")}write(e){switch(this.internalType.type){case"int":e.write(this.internalType.value.toString());break;case"float":e.write(this.internalType.value.toString());break;case"bool":this.internalType.value?e.write("True"):e.write("False");break;case"str":if(this.internalType.config?.multiline){let{startOnNewLine:i,endWithNewLine:a}=this.internalType.config;this.writeStringWithTripleQuotes({writer:e,value:this.internalType.value,startOnNewLine:i,endWithNewLine:a})}else e.write(`"${this.escapeString(this.internalType.value)}"`);break;case"date":e.write(`datetime.date.fromisoformat("${this.internalType.value}")`);break;case"datetime":{let i=this.internalType.value.replace(/Z$/,"+00:00");e.write(`datetime.datetime.fromisoformat("${i}")`);break}case"bytes":e.write(`b"${this.internalType.value}"`);break;case"list":{let i=this.internalType,a=Rt({values:i.values});if(a.length===0){e.write("[]");break}e.write("["),i.config?.multiline&&(e.newLine(),e.indent()),a.forEach((l,s)=>{s>0&&(e.write(","),i.config?.multiline?e.newLine():e.write(" ")),l.write(e),s===a.length-1&&i.config?.endWithComma&&e.write(",")}),i.config?.multiline&&(e.newLine(),e.dedent()),e.write("]");break}case"set":{let i=this.internalType,a=Rt({values:i.values});if(a.length===0){e.write("{}");break}e.write("{"),i.config?.multiline&&(e.newLine(),e.indent()),a.forEach((l,s)=>{s>0&&(e.write(","),i.config?.multiline?e.newLine():e.write(" ")),l.write(e),s===a.length-1&&i.config?.endWithComma&&e.write(",")}),i.config?.multiline&&(e.newLine(),e.dedent()),e.write("}");break}case"tuple":{let i=this.internalType,a=Rt({values:i.values});if(a.length===0){e.write("()");break}e.write("("),i.config?.multiline&&(e.newLine(),e.indent()),a.forEach((l,s)=>{s>0&&(e.write(","),i.config?.multiline?e.newLine():e.write(" ")),l.write(e),(a.length===1||s===a.length-1&&i.config?.endWithComma)&&e.write(",")}),i.config?.multiline&&(e.newLine(),e.dedent()),e.write(")");break}case"dict":{let i=this.internalType,a=Sa({entries:i.entries});if(a.length===0){e.write("{}");break}e.write("{"),i.config?.multiline&&(e.newLine(),e.indent()),a.forEach((l,s)=>{s>0&&(e.write(","),i.config?.multiline?e.newLine():e.write(" ")),l.key.write(e),e.write(": "),l.value.write(e),s===a.length-1&&i.config?.endWithComma&&e.write(",")}),i.config?.multiline&&(e.newLine(),e.dedent()),e.write("}");break}case"typedDict":{let i=this.internalType,a=Ba({entries:i.entries});if(a.length===0){e.write("{}");break}e.write("{"),i.config?.multiline&&(e.writeLine(),e.indent()),a.forEach((l,s)=>{s>0&&(e.write(","),i.config?.multiline?e.newLine():e.write(" ")),e.write(`"${l.name}": `),l.value.write(e)}),i.config?.multiline&&(e.newLine(),e.dedent()),e.write("}");break}case"reference":{this.internalType.value.write(e);break}case"none":e.write("None");break;case"unknown":this.writeUnknown({writer:e,value:this.internalType.value});break;case"uuid":e.write(`uuid.UUID("${this.internalType.value}")`);break;case"nop":break;default:B(this.internalType)}}writeStringWithTripleQuotes({writer:e,value:i,startOnNewLine:a,endWithNewLine:l}){e.write('"""');let s=i.split(`
|
|
17
17
|
`);if(s.length<=1){e.write(this.escapeString(s[0]??"")),e.write('"""');return}a&&e.writeNoIndent(`\\
|
|
18
|
-
`),s.forEach((
|
|
18
|
+
`),s.forEach((w,b)=>{e.writeNoIndent(this.escapeString(w)),b===s.length-1?l&&e.writeNoIndent(`\\
|
|
19
19
|
`):e.writeNoIndent(`
|
|
20
|
-
`)}),e.writeNoIndent('"""')}escapeString(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/'/g,"\\'").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}writeUnknown({writer:e,value:i}){switch(typeof i){case"boolean":e.write(i?"True":"False");return;case"string":e.write(`"${this.escapeString(i)}"`);return;case"number":e.write(i.toString());return;case"object":if(i==null){e.write("None");return}if(Array.isArray(i)){this.writeUnknownArray({writer:e,value:i});return}this.writeUnknownObject({writer:e,value:i});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof i}`)}}writeUnknownArray({writer:e,value:i}){if(i.length===0){e.write("[]");return}e.write("["),i.forEach((a,l)=>{l>0&&e.write(", "),e.writeNode(p.unknown(a))}),e.write("]")}writeUnknownObject({writer:e,value:i}){let a=Object.entries(i);if(a.length===0){e.write("{}");return}e.write("{"),a.forEach(([l,s],E)=>{E>0&&e.write(", "),e.write(`"${l}": `),e.writeNode(p.unknown(s))}),e.write("}")}};function Sa({entries:p}){return p.filter(t=>!de.isNop(t.key)&&!de.isNop(t.value))}function Ba({entries:p}){return p.filter(t=>!de.isNop(t.value))}function Rt({values:p}){return p.filter(t=>!de.isNop(t))}function Pa(p){return new Ee(p)}function Fa(p){return new it(p)}function Ca(p){return new Le(p)}function ka(p){return new ue(p)}function La(p){return new Re(p)}function Ua(p){return new Ne(p)}function Ma(p){return new ee(p)}function Oa(p){return new fe(p)}function _a(p){return new pe(p)}function Va(p){return new ie(p)}function $a(p){return new Ae(p)}function Da(p){return new Se(p)}function ja(p){return new Be(p)}function Wa(p){return new ce(p)}function qa(p){return new Te(p)}function Ga(p){return new Ce(p)}function za(p){return new le(p)}function Ha(p){return new Fe(p)}function Qa(p){return new ke(p)}f();m();d();var Ya="value",at=class{constructor({context:t}){y(this,"context");this.context=t}convert(t){if(t.value===null)return this.context.isNullable(t.typeReference)?x.TypeInstantiation.none():(this.context.errors.add({severity:P.Critical,message:"Expected non-null value, but got null"}),x.TypeInstantiation.nop());if(t.value===void 0)return x.TypeInstantiation.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return this.convertLiteral({literalType:t.typeReference.value,value:t.value});case"map":return this.convertMap({map:t.typeReference,value:t.value});case"named":{let e=this.context.resolveNamedType({typeId:t.typeReference.value});return e==null?x.TypeInstantiation.nop():this.convertNamed({named:e,value:t.value,as:t.as})}case"optional":return this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as});case"nullable":return this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as});case"primitive":return this.convertPrimitive({primitive:t.typeReference.value,value:t.value,as:t.as});case"set":return this.convertSet({set:t.typeReference.value,value:t.value});case"unknown":return x.TypeInstantiation.unknown(t.value);default:C(t.typeReference)}}convertLiteral({literalType:t,value:e}){switch(t.type){case"boolean":{let i=this.context.getValueAsBoolean({value:e});return i==null?x.TypeInstantiation.nop():x.TypeInstantiation.bool(i)}case"string":{let i=this.context.getValueAsString({value:e});return i==null?x.TypeInstantiation.nop():x.TypeInstantiation.str(i)}default:C(t)}}convertList({list:t,value:e}){return Array.isArray(e)?x.TypeInstantiation.list(e.map((i,a)=>{this.context.errors.scope({index:a});try{return this.convert({typeReference:t,value:i})}finally{this.context.errors.unscope()}}),{multiline:!0}):(this.context.errors.add({severity:P.Critical,message:`Expected array but got: ${typeof e}`}),x.TypeInstantiation.nop())}convertSet({set:t,value:e}){return Array.isArray(e)?x.TypeInstantiation.list(e.map((i,a)=>{this.context.errors.scope({index:a});try{return this.convert({typeReference:t,value:i})}finally{this.context.errors.unscope()}}),{multiline:!0}):(this.context.errors.add({severity:P.Critical,message:`Expected array but got: ${typeof e}`}),x.TypeInstantiation.nop())}convertMap({map:t,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:P.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),x.TypeInstantiation.nop()):x.TypeInstantiation.dict(Object.entries(e).map(([i,a])=>{this.context.errors.scope(i);try{return{key:this.convert({typeReference:t.key,value:i,as:"key"}),value:this.convert({typeReference:t.value,value:a})}}finally{this.context.errors.unscope()}}),{multiline:!0})}convertNamed({named:t,value:e,as:i}){switch(t.type){case"alias":return this.convert({typeReference:t.typeReference,value:e,as:i});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:t,value:e});case"enum":return this.convertEnum({enum_:t,value:e});case"object":return this.convertObject({object_:t,value:e});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e});default:C(t)}}convertDiscriminatedUnion({discriminatedUnion:t,value:e}){let i=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e});if(i==null)return x.TypeInstantiation.nop();let a=i.singleDiscriminatedUnionType,l=this.convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:i,unionVariant:a});if(l==null)return x.TypeInstantiation.nop();let s={name:this.context.getPropertyName(t.discriminant.name),value:x.TypeInstantiation.str(a.discriminantValue.wireValue)};return x.TypeInstantiation.typedDict([s,...l],{multiline:!0})}convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:t,unionVariant:e}){let i=this.getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e});switch(e.type){case"samePropertiesAsObject":{let a=this.context.resolveNamedType({typeId:e.typeId});if(a==null)return;if(a.type!=="object"){this.context.errors.add({severity:P.Critical,message:"Internal error; expected union value to be an object"});return}let l=this.convertObjectEntries({object_:a,value:t.value});return[...i,...l]}case"singleProperty":try{this.context.errors.scope(e.discriminantValue.wireValue);let a=this.context.getRecord(t.value);return a==null?[...i,{name:Ya,value:this.convert({typeReference:e.typeReference,value:t.value})}]:[...i,{name:this.context.getPropertyName(e.discriminantValue.name),value:this.convert({typeReference:e.typeReference,value:a[e.discriminantValue.wireValue]})}]}finally{this.context.errors.unscope()}case"noProperties":return i;default:C(e)}}getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e}){return this.context.associateByWireValue({parameters:e.properties??[],values:this.context.getRecord(t.value)??{},ignoreMissingParameters:!0}).map(a=>{this.context.errors.scope(a.name.wireValue);try{return{name:this.context.getPropertyName(a.name.name),value:this.convert(a)}}finally{this.context.errors.unscope()}})}convertObjectEntries({object_:t,value:e}){return this.context.associateByWireValue({parameters:t.properties,values:this.context.getRecord(e)??{}}).map(a=>{this.context.errors.scope(a.name.wireValue);try{return{name:this.context.getPropertyName(a.name.name),value:this.convert(a)}}finally{this.context.errors.unscope()}})}convertObject({object_:t,value:e}){let i=this.convertObjectEntries({object_:t,value:e});if(this.context.useTypedDictRequests())return x.TypeInstantiation.typedDict(i,{multiline:!0});let a=this.context.getTypeClassReference(t.declaration);return x.TypeInstantiation.reference(x.instantiateClass({classReference:a,arguments_:i.map(l=>x.methodArgument({name:l.name,value:l.value})),multiline:!0}))}convertEnum({enum_:t,value:e}){let i=this.getEnumValue({enum_:t,value:e});return i==null?x.TypeInstantiation.nop():x.TypeInstantiation.str(i)}getEnumValue({enum_:t,value:e}){if(typeof e!="string"){this.context.errors.add({severity:P.Critical,message:`Expected enum value string, got: ${typeof e}`});return}if(t.values.find(a=>a.wireValue===e)==null){this.context.errors.add({severity:P.Critical,message:`An enum value named "${e}" does not exist in this context`});return}return e}convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e}){let i=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e});return i??x.TypeInstantiation.nop()}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e}){for(let i of t.types){let a=this.context.errors.size();try{let l=this.convert({typeReference:i,value:e});if(x.TypeInstantiation.isNop(l)){this.context.errors.truncate(a);continue}return l}catch{this.context.errors.truncate(a);continue}}this.context.errors.add({severity:P.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof e}" value`})}convertPrimitive({primitive:t,value:e,as:i}){switch(t){case"INTEGER":case"LONG":case"UINT":case"UINT_64":{let a=this.getValueAsNumber({value:e,as:i});return a==null?x.TypeInstantiation.nop():x.TypeInstantiation.int(a)}case"FLOAT":case"DOUBLE":{let a=this.getValueAsNumber({value:e});return a==null?x.TypeInstantiation.nop():x.TypeInstantiation.float(a)}case"BOOLEAN":{let a=this.getValueAsBoolean({value:e,as:i});return a==null?x.TypeInstantiation.nop():x.TypeInstantiation.bool(a)}case"BASE_64":case"BIG_INTEGER":case"STRING":{let a=this.context.getValueAsString({value:e});return a==null?x.TypeInstantiation.nop():x.TypeInstantiation.str(a)}case"UUID":{let a=this.context.getValueAsString({value:e});return a==null?x.TypeInstantiation.nop():x.TypeInstantiation.uuid(a)}case"DATE":{let a=this.context.getValueAsString({value:e});return a==null?x.TypeInstantiation.nop():x.TypeInstantiation.date(a)}case"DATE_TIME":{let a=this.context.getValueAsString({value:e});return a==null?x.TypeInstantiation.nop():x.TypeInstantiation.datetime(a)}default:C(t)}}getValueAsNumber({value:t,as:e}){let i=e==="key"&&typeof t=="string"?Number(t):t;return this.context.getValueAsNumber({value:i})}getValueAsBoolean({value:t,as:e}){let i=e==="key"?typeof t=="string"?t==="true":t==="false"?!1:t:t;return this.context.getValueAsBoolean({value:i})}};f();m();d();var st=class{constructor({context:t}){y(this,"context");this.context=t}getFilePropertyInfo({body:t,value:e}){let i={fileFields:[],bodyPropertyFields:[]},a=this.context.getRecord(e)??{};for(let l of t.properties)switch(l.type){case"file":{let s=this.getSingleFileProperty({property:l,record:a});if(x.TypeInstantiation.isNop(s))break;i.fileFields.push({name:this.context.getPropertyName(l.name),value:s});break}case"fileArray":{let s=this.getArrayFileProperty({property:l,record:a});if(x.TypeInstantiation.isNop(s))break;i.fileFields.push({name:this.context.getPropertyName(l.name),value:s});break}case"bodyProperty":{let s=this.getBodyProperty({property:l,record:a});if(x.TypeInstantiation.isNop(s))break;i.bodyPropertyFields.push({name:this.context.getPropertyName(l.name.name),value:s});break}default:C(l)}return i}getSingleFileProperty({property:t,record:e}){let i=this.context.getSingleFileValue({property:t,record:e});return i==null&&(i=`example_${t.wireValue??"file"}`),this.context.getFileFromString(i)}getArrayFileProperty({property:t,record:e}){let i=this.context.getFileArrayValues({property:t,record:e});if(i==null){let a=`example_${t.wireValue??"files"}`;return x.TypeInstantiation.list([this.context.getFileFromString(a)])}return x.TypeInstantiation.list(i.map(a=>this.context.getFileFromString(a)))}getBodyProperty({property:t,record:e}){let i=e[t.name.wireValue];return i==null?x.TypeInstantiation.nop():this.context.dynamicTypeLiteralMapper.convert({typeReference:t.typeReference,value:i})}};var Za=["list","set"],ut=class p extends ze{constructor({ir:e,config:i}){super({ir:e,config:i});y(this,"ir");y(this,"customConfig");y(this,"dynamicTypeLiteralMapper");y(this,"filePropertyMapper");this.ir=e,this.customConfig=i.customConfig??{},this.dynamicTypeLiteralMapper=new at({context:this}),this.filePropertyMapper=new st({context:this})}clone(){return new p({ir:this.ir,config:this.config})}getClassName(e){let i=e.pascalCase.safeName,a=this.getRootClientClassName();return i===a?`${a}Model`:i}getTypedDictClassName(e){return`${this.getClassName(e)}Params`}getPropertyName(e){let i=e.snakeCase.safeName;return i.startsWith("_")?"f_"+i.substring(i.lastIndexOf("_")+1):i}getMethodName(e){return Za.includes(e.snakeCase.unsafeName)?e.snakeCase.unsafeName:e.snakeCase.safeName}getRootClientClassReference(){return x.reference({name:this.getRootClientClassName(),modulePath:this.getRootModulePath()})}getTypeClassReference(e){let i=this.getClassName(e.name),a=[...this.getRootModulePath(),...e.fernFilepath.allParts.map(l=>l.snakeCase.safeName)];return x.reference({name:i,modulePath:a})}useTypedDictRequests(){return this.customConfig.use_typeddict_requests===!0}getRootClientClassName(){return this.customConfig.client?.exported_class_name!=null?this.customConfig.client.exported_class_name:this.customConfig.client_class_name!=null?this.customConfig.client_class_name:this.customConfig.client?.class_name!=null?this.customConfig.client.class_name:this.pascalCase(this.config.organization)+this.pascalCase(this.config.workspaceName)}getEnvironmentClassName(){return`${this.getRootClientClassName()}Environment`}getEnvironmentTypeReferenceFromID(e){let i=this.resolveEnvironmentName(e);if(i!=null)return x.accessAttribute({lhs:this.getEnvironmentClassReference(),rhs:x.codeBlock(this.getEnvironmentEnumName(i))})}getEnvironmentClassReference(){return x.reference({name:this.getEnvironmentClassName(),modulePath:this.getEnvironmentModulePath()})}getEnvironmentEnumName(e){return e.screamingSnakeCase.safeName}isPrimitive(e){switch(e.type){case"primitive":return!0;case"optional":case"nullable":return this.isPrimitive(e.value);case"named":{let i=this.resolveNamedType({typeId:e.value});if(i==null)return!1;switch(i.type){case"alias":return this.isPrimitive(i.typeReference);case"discriminatedUnion":case"undiscriminatedUnion":case"object":case"enum":return!1;default:C(i)}break}case"list":case"set":case"map":case"literal":case"unknown":return!1;default:C(e)}}getFileFromString(e){return x.TypeInstantiation.str(e)}getRootModulePath(){if(this.customConfig.package_name!=null)return[this.customConfig.package_name];let e=this.cleanOrganizationName();return this.customConfig.use_api_name_in_package?[e,this.getApiName()]:[e]}getCoreModulePath(){return this.getRootModulePath().concat("core")}getEnvironmentModulePath(){return this.getRootModulePath().concat("environment")}shouldInlinePathParameters(){return!0}cleanOrganizationName(){return this.config.organization.replace(/[^a-zA-Z0-9]/g,"_")}getApiName(){return It(this.config.workspaceName)}pascalCase(e){let i=vt(e);return i.charAt(0).toUpperCase()+i.slice(1)}};f();m();d();var Ja={type:"primitive",value:"STRING"},Ka=["example"],li="client",Ue="request",pt=class{constructor({context:t}){y(this,"context");this.context=t}async generateSnippet({endpoint:t,request:e}){return this.buildPythonFile({endpoint:t,snippet:e}).toString()}generateSnippetSync({endpoint:t,request:e}){return this.buildPythonFile({endpoint:t,snippet:e}).toString()}async generateSnippetAst({endpoint:t,request:e}){return this.buildPythonFile({endpoint:t,snippet:e})}generateMethodCallSnippetAst({endpoint:t,request:e}){return this.callMethod({endpoint:t,snippet:e})}buildPythonFile({endpoint:t,snippet:e}){return x.file({path:Ka,statements:[this.constructClient({endpoint:t,snippet:e}),this.callMethod({endpoint:t,snippet:e})]})}constructClient({endpoint:t,snippet:e}){return x.assign({lhs:x.reference({name:li}),rhs:x.instantiateClass({classReference:this.context.getRootClientClassReference(),arguments_:this.getConstructorArgs({endpoint:t,snippet:e}).map(i=>x.methodArgument({name:i.name,value:i.value})),multiline:!0})})}getConstructorArgs({endpoint:t,snippet:e}){let i=[],a=this.getConstructorEnvironmentArgs({baseUrl:e.baseURL,environment:e.environment});return a.length>0&&i.push(...a),t.auth!=null&&(e.auth!=null?i.push(...this.getConstructorAuthArgs({auth:t.auth,values:e.auth})):this.context.errors.add({severity:P.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(Y.PathParameters),this.context.ir.pathParameters!=null&&i.push(...this.getPathParameters({namedParameters:this.context.ir.pathParameters,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(Y.Headers),this.context.ir.headers!=null&&e.headers!=null&&i.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:e.headers})),this.context.errors.unscope(),i}getConstructorEnvironmentArgs({baseUrl:t,environment:e}){let i=this.getEnvironmentValue({baseUrl:t,environment:e});return i==null?[]:e!=null&&this.context.isMultiEnvironmentValues(e)?[{name:"environment",value:i}]:[{name:this.getEnvironmentOptionName({environment:e}),value:i}]}getEnvironmentValue({baseUrl:t,environment:e}){if(t!=null&&e!=null){this.context.errors.add({severity:P.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(t!=null)return x.TypeInstantiation.str(t);if(e!=null){if(this.context.isSingleEnvironmentID(e)){let i=this.context.getEnvironmentTypeReferenceFromID(e);if(i==null){this.context.errors.add({severity:P.Warning,message:`Environment ${JSON.stringify(e)} was not found`});return}return x.TypeInstantiation.reference(i)}if(this.context.isMultiEnvironmentValues(e))return this.context.validateMultiEnvironmentUrlValues(e)?x.TypeInstantiation.reference(x.instantiateClass({classReference:this.context.getEnvironmentClassReference(),arguments_:Object.entries(e).map(([i,a])=>({name:i,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:Ja,value:a})})).map(i=>x.methodArgument({name:i.name,value:i.value})),multiline:!0})):void 0}}getConstructorAuthArgs({auth:t,values:e}){switch(t.type){case"basic":return e.type!=="basic"?(this.addAuthMismatchError(t,e),[]):this.getConstructorBasicAuthArg({auth:t,values:e});case"bearer":return e.type!=="bearer"?(this.addAuthMismatchError(t,e),[]):this.getConstructorBearerAuthArgs({auth:t,values:e});case"header":return e.type!=="header"?(this.addAuthMismatchError(t,e),[]):this.getConstructorHeaderAuthArgs({auth:t,values:e});case"oauth":return e.type!=="oauth"?(this.addAuthMismatchError(t,e),[]):this.getConstructorOAuthArgs({auth:t,values:e});case"inferred":return e.type!=="inferred"?(this.addAuthMismatchError(t,e),[]):this.getConstructorInferredAuthArgs({auth:t,values:e});default:C(t)}}addAuthMismatchError(t,e){this.context.errors.add({severity:P.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message})}addWarning(t){this.context.errors.add({severity:P.Warning,message:t})}getConstructorBasicAuthArg({auth:t,values:e}){return[{name:this.context.getPropertyName(t.username),value:x.TypeInstantiation.str(e.username)},{name:this.context.getPropertyName(t.password),value:x.TypeInstantiation.str(e.password)}]}getConstructorBearerAuthArgs({auth:t,values:e}){return[{name:this.context.getPropertyName(t.token),value:x.TypeInstantiation.str(e.token)}]}getConstructorHeaderAuthArgs({auth:t,values:e}){return[{name:this.context.getPropertyName(t.header.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t.header.typeReference,value:e.value})}]}getConstructorOAuthArgs({auth:t,values:e}){return[{name:this.context.getPropertyName(t.clientId),value:x.TypeInstantiation.str(e.clientId)},{name:this.context.getPropertyName(t.clientSecret),value:x.TypeInstantiation.str(e.clientSecret)}]}getConstructorInferredAuthArgs({auth:t,values:e}){let i=t.parameters??[];if(i.length===0)return this.addWarning("Inferred auth scheme is missing parameters; cannot generate constructor arguments."),[];let a=e.values;if(a==null)return this.addWarning("Inferred auth values were not provided; cannot generate constructor arguments."),[];let l=[];for(let s of i){let E=s.name.wireValue;if(!Object.hasOwn(a,E)){this.addWarning(`Missing inferred auth value for ${E}`);continue}let b=a[E],A=this.context.dynamicTypeLiteralMapper.convert({typeReference:s.typeReference,value:b});x.TypeInstantiation.isNop(A)||l.push({name:this.context.getPropertyName(s.name.name),value:A})}return l}getConstructorHeaderArgs({headers:t,values:e}){let i=[];for(let a of t){let l=e[a.name.wireValue],s=this.getConstructorHeaderArg({header:a,value:l});s!=null&&i.push(s)}return i}getConstructorHeaderArg({header:t,value:e}){let i=this.context.dynamicTypeLiteralMapper.convert({typeReference:t.typeReference,value:e});if(!x.TypeInstantiation.isNop(i))return{name:this.context.getPropertyName(t.name.name),value:i}}callMethod({endpoint:t,snippet:e}){return x.invokeMethod({on:x.reference({name:li}),method:this.getMethod({endpoint:t}),arguments_:this.getMethodArgs({endpoint:t,snippet:e}).filter(i=>!x.TypeInstantiation.isNop(i.value)).map(i=>x.methodArgument({name:i.name,value:i.value})),multiline:!0})}getMethodArgs({endpoint:t,snippet:e}){switch(t.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:t.request,snippet:e});case"body":return this.getMethodArgsForBodyRequest({request:t.request,snippet:e});default:C(t.request)}}getMethodArgsForBodyRequest({request:t,snippet:e}){let i=[];this.context.errors.scope(Y.PathParameters);let a=[...this.context.ir.pathParameters??[],...t.pathParameters??[]],l=new Set;if(t.body!=null){let s=this.getBodyRequestArgs({body:t.body,value:e.requestBody});if(l=new Set(s.map(E=>E.name)),t.body.type==="typeReference"){let E=t.body.value;if(E.type==="named"){let b=this.context.resolveNamedType({typeId:E.value});if(b!=null&&b.type==="object")for(let A of b.properties)this.resolvesToLiteralType(A.typeReference)||l.add(this.context.getPropertyName(A.name.name))}}}if(a.length>0){let E=this.getPathParameters({namedParameters:a,snippet:e}).map(b=>l.has(b.name)?{...b,name:b.name+"_"}:b);i.push(...E)}return this.context.errors.unscope(),this.context.errors.scope(Y.RequestBody),t.body!=null&&i.push(...this.getBodyRequestArgs({body:t.body,value:e.requestBody})),this.context.errors.unscope(),i}getBodyRequestArgs({body:t,value:e}){switch(t.type){case"bytes":return[{name:Ue,value:this.getBytesBodyRequestTypeInstantiation({value:e})}];case"typeReference":return this.getBodyRequestArgsForTypeReference({typeReference:t.value,value:e});default:C(t)}}getBodyRequestArgsForTypeReference({typeReference:t,value:e}){switch(t.type){case"named":{let i=this.context.resolveNamedType({typeId:t.value});return i==null?[]:this.getBodyRequestArgsForNamedTypeReference({typeReference:t,named:i,value:e})}case"nullable":case"optional":{let i=t.value;return i.type==="named"&&this.context.resolveNamedType({typeId:i.value})?.type==="object"?[{name:Ue,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:i,value:e})}]:this.getBodyRequestArgsForTypeReference({typeReference:t.value,value:e})}case"list":case"map":case"set":case"literal":case"primitive":case"unknown":return[{name:Ue,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t,value:e})}];default:C(t)}}getBodyRequestArgsForNamedTypeReference({typeReference:t,named:e,value:i}){switch(e.type){case"alias":return this.getBodyRequestArgsForTypeReference({typeReference:e.typeReference,value:i});case"enum":case"discriminatedUnion":case"undiscriminatedUnion":return[{name:Ue,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t,value:i})}];case"object":return this.context.customConfig.inline_request_params===!1?[{name:Ue,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t,value:i})}]:this.context.associateByWireValue({parameters:e.properties,values:this.context.getRecord(i)??{}}).filter(s=>!this.resolvesToLiteralType(s.typeReference)).map(s=>({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)}));default:C(e)}}resolvesToLiteralType(t){switch(t.type){case"literal":return!0;case"optional":case"nullable":return this.resolvesToLiteralType(t.value);case"named":{let e=this.context.resolveNamedType({typeId:t.value});return e==null?!1:e.type==="alias"?this.resolvesToLiteralType(e.typeReference):!1}case"list":case"map":case"set":case"primitive":case"unknown":return!1;default:C(t)}}getBodyRequestArgsForBytes({body:t,value:e}){let i=this.getBytesBodyRequestTypeInstantiation({value:e});return x.TypeInstantiation.isNop(i)?[]:[{name:Ue,value:i}]}getBytesBodyRequestTypeInstantiation({value:t}){return typeof t!="string"?(this.context.errors.add({severity:P.Critical,message:`Expected bytes value to be a string, got ${typeof t}`}),x.TypeInstantiation.nop()):x.TypeInstantiation.bytes(t)}getBodyPropertyNamesForInlinedRequest(t){if(t.body==null)return new Set;switch(t.body.type){case"referenced":{let e=t.body.bodyType;if(e.type!=="typeReference")return new Set;let i=e.value;if(i.type!=="named")return new Set;let a=this.context.resolveNamedType({typeId:i.value});if(a==null||a.type!=="object")return new Set;let l=new Set;for(let s of a.properties)this.resolvesToLiteralType(s.typeReference)||l.add(this.context.getPropertyName(s.name.name));return l}case"properties":return new Set(t.body.value.filter(e=>!this.resolvesToLiteralType(e.typeReference)).map(e=>this.context.getPropertyName(e.name.name)));case"fileUpload":return new Set(t.body.properties.filter(e=>e.type==="bodyProperty").map(e=>this.context.getPropertyName(e.name.name)));default:C(t.body)}}getMethodArgsForInlinedRequest({request:t,snippet:e}){let i=[],a=this.context.shouldInlinePathParameters();this.context.errors.scope(Y.PathParameters);let l=[];t.pathParameters!=null&&l.push(...this.getPathParameters({namedParameters:t.pathParameters,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(Y.RequestBody);let s=this.getFilePropertyInfo({request:t,snippet:e});this.context.errors.unscope();let E=this.getBodyPropertyNamesForInlinedRequest(t),b=l.map(A=>E.has(A.name)?{...A,name:`${A.name}_`}:A);return this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:a})||i.push(...b),this.context.needsRequestParameter({request:t,inlinePathParameters:a,inlineFileProperties:!0})&&i.push(...this.getInlinedRequestArgs({request:t,snippet:e,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:a})?b:[],filePropertyInfo:s})),i}getFilePropertyInfo({request:t,snippet:e}){return t.body==null||!this.context.isFileUploadRequestBody(t.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:t.body,value:e.requestBody})}getInlinedRequestArgs({request:t,snippet:e,pathParameterFields:i,filePropertyInfo:a}){this.context.errors.scope(Y.QueryParameters);let s=this.context.associateQueryParametersByWireValue({parameters:t.queryParameters??[],values:e.queryParameters??{}}).map(R=>({name:this.context.getPropertyName(R.name.name),value:this.context.dynamicTypeLiteralMapper.convert(R)}));this.context.errors.unscope(),this.context.errors.scope(Y.Headers);let b=this.context.associateByWireValue({parameters:t.headers??[],values:e.headers??{}}).map(R=>({name:this.context.getPropertyName(R.name.name),value:this.context.dynamicTypeLiteralMapper.convert(R)}));this.context.errors.unscope(),this.context.errors.scope(Y.RequestBody);let A=t.body!=null?this.getInlinedRequestBodyObjectFields({body:t.body,value:e.requestBody,filePropertyInfo:a}):[];return this.context.errors.unscope(),[...i,...s,...b,...A]}getInlinedRequestBodyObjectFields({body:t,value:e,filePropertyInfo:i}){switch(t.type){case"properties":return this.getInlinedRequestBodyPropertyObjectFields({parameters:t.value,value:e});case"referenced":return this.getReferencedRequestBodyPropertyTypeInstantiation({body:t,value:e});case"fileUpload":return this.getFileUploadRequestBodyObjectFields({filePropertyInfo:i});default:C(t)}}getFileUploadRequestBodyObjectFields({filePropertyInfo:t}){return[...t.fileFields,...t.bodyPropertyFields]}getReferencedRequestBodyPropertyTypeInstantiation({body:t,value:e}){let i=t.bodyType;switch(i.type){case"bytes":return this.getBodyRequestArgsForBytes({body:t,value:e});case"typeReference":return this.getBodyRequestArgsForTypeReference({typeReference:i.value,value:e});default:C(i)}}getInlinedRequestBodyPropertyObjectFields({parameters:t,value:e}){let i=[],l=this.context.associateByWireValue({parameters:t,values:this.context.getRecord(e)??{}}).filter(s=>!this.resolvesToLiteralType(s.typeReference));for(let s of l)i.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)});return i}getPathParameters({namedParameters:t,snippet:e}){let i=[],a=t.filter(s=>!this.resolvesToLiteralType(s.typeReference)),l=this.context.associateByWireValue({parameters:a,values:e.pathParameters??{},ignoreMissingParameters:!0});for(let s of l)i.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)});return i}getMethod({endpoint:t}){return t.declaration.fernFilepath.allParts.length>0?`${t.declaration.fernFilepath.allParts.map(e=>this.context.getMethodName(e)).join(".")}.${this.context.getMethodName(t.declaration.name)}`:this.context.getMethodName(t.declaration.name)}getEnvironmentOptionName({environment:t}){return t!=null?"environment":"base_url"}};var lt=class extends We{constructor({ir:t,config:e}){super(new ut({ir:t,config:e}))}async generate(t,e={}){return super.generate(t,e)}generateSync(t,e={}){return super.generateSync(t,e)}async generateSnippetAst(t,e={}){return super.generateSnippetAst(t,e)}generateMethodCallSnippetAst({request:t,options:e={}}){let i=this.resolveEndpointsForMethodCall({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let a;for(let l of i){let s=this.context.clone(),E=this.createSnippetGenerator(s);try{return E.generateMethodCallSnippetAst({endpoint:l,request:t})}catch(b){a=b}}throw a??new Error(`Failed to generate method call snippet AST for endpoint: ${t.endpoint.method} ${t.endpoint.path}`)}resolveEndpointsForMethodCall({request:t,options:e}){if(e.endpointId!=null){let i=this.context.resolveEndpointById(e.endpointId);if(i==null)throw new Error(`No endpoint found with ID "${e.endpointId}"`);return[i]}return this.context.resolveEndpointLocationOrThrow(t.endpoint)}createSnippetGenerator(t){return new pt({context:t})}};0&&(module.exports={DynamicSnippetsGenerator});
|
|
20
|
+
`)}),e.writeNoIndent('"""')}escapeString(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/'/g,"\\'").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}writeUnknown({writer:e,value:i}){switch(typeof i){case"boolean":e.write(i?"True":"False");return;case"string":e.write(`"${this.escapeString(i)}"`);return;case"number":e.write(i.toString());return;case"object":if(i==null){e.write("None");return}if(Array.isArray(i)){this.writeUnknownArray({writer:e,value:i});return}this.writeUnknownObject({writer:e,value:i});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof i}`)}}writeUnknownArray({writer:e,value:i}){if(i.length===0){e.write("[]");return}e.write("["),i.forEach((a,l)=>{l>0&&e.write(", "),e.writeNode(p.unknown(a))}),e.write("]")}writeUnknownObject({writer:e,value:i}){let a=Object.entries(i);if(a.length===0){e.write("{}");return}e.write("{"),a.forEach(([l,s],w)=>{w>0&&e.write(", "),e.write(`"${l}": `),e.writeNode(p.unknown(s))}),e.write("}")}};function Sa({entries:p}){return p.filter(t=>!de.isNop(t.key)&&!de.isNop(t.value))}function Ba({entries:p}){return p.filter(t=>!de.isNop(t.value))}function Rt({values:p}){return p.filter(t=>!de.isNop(t))}function Pa(p){return new be(p)}function Fa(p){return new it(p)}function Ca(p){return new Le(p)}function ka(p){return new ue(p)}function La(p){return new Re(p)}function Ua(p){return new Ne(p)}function Ma(p){return new ee(p)}function Oa(p){return new fe(p)}function _a(p){return new pe(p)}function Va(p){return new ie(p)}function Da(p){return new Ae(p)}function $a(p){return new Se(p)}function ja(p){return new Be(p)}function Wa(p){return new ce(p)}function qa(p){return new Ee(p)}function Ga(p){return new Ce(p)}function za(p){return new le(p)}function Ha(p){return new Fe(p)}function Qa(p){return new ke(p)}f();m();d();var Ya="value",at=class{constructor({context:t}){y(this,"context");this.context=t}convert(t){if(t.value===null)return this.context.isNullable(t.typeReference)?g.TypeInstantiation.none():(this.context.errors.add({severity:F.Critical,message:"Expected non-null value, but got null"}),g.TypeInstantiation.nop());if(t.value===void 0)return g.TypeInstantiation.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return this.convertLiteral({literalType:t.typeReference.value,value:t.value});case"map":return this.convertMap({map:t.typeReference,value:t.value});case"named":{let e=this.context.resolveNamedType({typeId:t.typeReference.value});return e==null?g.TypeInstantiation.nop():this.convertNamed({named:e,value:t.value,as:t.as})}case"optional":return this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as});case"nullable":return this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as});case"primitive":return this.convertPrimitive({primitive:t.typeReference.value,value:t.value,as:t.as});case"set":return this.convertSet({set:t.typeReference.value,value:t.value});case"unknown":return g.TypeInstantiation.unknown(t.value);default:B(t.typeReference)}}convertLiteral({literalType:t,value:e}){switch(t.type){case"boolean":{let i=this.context.getValueAsBoolean({value:e});return i==null?g.TypeInstantiation.nop():g.TypeInstantiation.bool(i)}case"string":{let i=this.context.getValueAsString({value:e});return i==null?g.TypeInstantiation.nop():g.TypeInstantiation.str(i)}default:B(t)}}convertList({list:t,value:e}){return Array.isArray(e)?g.TypeInstantiation.list(e.map((i,a)=>{this.context.errors.scope({index:a});try{return this.convert({typeReference:t,value:i})}finally{this.context.errors.unscope()}}),{multiline:!0}):(this.context.errors.add({severity:F.Critical,message:`Expected array but got: ${typeof e}`}),g.TypeInstantiation.nop())}convertSet({set:t,value:e}){return Array.isArray(e)?g.TypeInstantiation.list(e.map((i,a)=>{this.context.errors.scope({index:a});try{return this.convert({typeReference:t,value:i})}finally{this.context.errors.unscope()}}),{multiline:!0}):(this.context.errors.add({severity:F.Critical,message:`Expected array but got: ${typeof e}`}),g.TypeInstantiation.nop())}convertMap({map:t,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:F.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),g.TypeInstantiation.nop()):g.TypeInstantiation.dict(Object.entries(e).map(([i,a])=>{this.context.errors.scope(i);try{return{key:this.convert({typeReference:t.key,value:i,as:"key"}),value:this.convert({typeReference:t.value,value:a})}}finally{this.context.errors.unscope()}}),{multiline:!0})}convertNamed({named:t,value:e,as:i}){switch(t.type){case"alias":return this.convert({typeReference:t.typeReference,value:e,as:i});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:t,value:e});case"enum":return this.convertEnum({enum_:t,value:e});case"object":return this.convertObject({object_:t,value:e});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e});default:B(t)}}convertDiscriminatedUnion({discriminatedUnion:t,value:e}){let i=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e});if(i==null)return g.TypeInstantiation.nop();let a=i.singleDiscriminatedUnionType,l=this.convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:i,unionVariant:a});if(l==null)return g.TypeInstantiation.nop();let s={name:this.context.getPropertyName(t.discriminant.name),value:g.TypeInstantiation.str(a.discriminantValue.wireValue)};return g.TypeInstantiation.typedDict([s,...l],{multiline:!0})}convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:t,unionVariant:e}){let i=this.getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e});switch(e.type){case"samePropertiesAsObject":{let a=this.context.resolveNamedType({typeId:e.typeId});if(a==null)return;if(a.type!=="object"){this.context.errors.add({severity:F.Critical,message:"Internal error; expected union value to be an object"});return}let l=this.convertObjectEntries({object_:a,value:t.value});return[...i,...l]}case"singleProperty":try{this.context.errors.scope(e.discriminantValue.wireValue);let a=this.context.getRecord(t.value);return a==null?[...i,{name:Ya,value:this.convert({typeReference:e.typeReference,value:t.value})}]:[...i,{name:this.context.getPropertyName(e.discriminantValue.name),value:this.convert({typeReference:e.typeReference,value:a[e.discriminantValue.wireValue]})}]}finally{this.context.errors.unscope()}case"noProperties":return i;default:B(e)}}getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e}){return this.context.associateByWireValue({parameters:e.properties??[],values:this.context.getRecord(t.value)??{},ignoreMissingParameters:!0}).map(a=>{this.context.errors.scope(a.name.wireValue);try{return{name:this.context.getPropertyName(a.name.name),value:this.convert(a)}}finally{this.context.errors.unscope()}})}convertObjectEntries({object_:t,value:e}){let i=this.context.getRecord(e)??{},a=this.context.associateByWireValue({parameters:t.properties,values:i}),l=new Set(Object.keys(i)),s=a.map(w=>{this.context.errors.scope(w.name.wireValue);try{return{name:this.context.getPropertyName(w.name.name),value:this.convert(w)}}finally{this.context.errors.unscope()}});for(let w of t.properties){if(l.has(w.name.wireValue)||this.context.isOptional(w.typeReference)||this.context.isNullable(w.typeReference))continue;let b=this.synthesizeDefaultValue(w.typeReference);g.TypeInstantiation.isNop(b)||s.push({name:this.context.getPropertyName(w.name.name),value:b})}return s}convertObject({object_:t,value:e}){let i=this.convertObjectEntries({object_:t,value:e});if(this.context.useTypedDictRequests())return g.TypeInstantiation.typedDict(i,{multiline:!0});let a=this.context.getTypeClassReference(t.declaration);return g.TypeInstantiation.reference(g.instantiateClass({classReference:a,arguments_:i.map(l=>g.methodArgument({name:l.name,value:l.value})),multiline:!0}))}convertEnum({enum_:t,value:e}){let i=this.getEnumValue({enum_:t,value:e});return i==null?g.TypeInstantiation.nop():g.TypeInstantiation.str(i)}getEnumValue({enum_:t,value:e}){if(typeof e!="string"){this.context.errors.add({severity:F.Critical,message:`Expected enum value string, got: ${typeof e}`});return}if(t.values.find(a=>a.wireValue===e)==null){this.context.errors.add({severity:F.Critical,message:`An enum value named "${e}" does not exist in this context`});return}return e}convertUndiscriminatedUnion({undiscriminatedUnion:t,value:e}){let i=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e});return i??g.TypeInstantiation.nop()}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:e}){for(let i of t.types){let a=this.context.errors.size();try{let l=this.convert({typeReference:i,value:e});if(g.TypeInstantiation.isNop(l)){this.context.errors.truncate(a);continue}return l}catch{this.context.errors.truncate(a);continue}}this.context.errors.add({severity:F.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof e}" value`})}synthesizeDefaultValue(t,e=new Set){switch(t.type){case"optional":case"nullable":return g.TypeInstantiation.nop();case"primitive":return this.synthesizeDefaultPrimitive(t.value);case"literal":return this.synthesizeDefaultLiteral(t.value);case"list":return g.TypeInstantiation.list([]);case"set":return g.TypeInstantiation.list([]);case"map":return g.TypeInstantiation.dict([]);case"named":{if(e.has(t.value))return g.TypeInstantiation.nop();let i=this.context.resolveNamedType({typeId:t.value});return i==null?g.TypeInstantiation.nop():this.synthesizeDefaultNamed({named:i,typeId:t.value,seen:e})}case"unknown":return g.TypeInstantiation.nop();default:B(t)}}synthesizeDefaultPrimitive(t){switch(t){case"STRING":case"BASE_64":case"BIG_INTEGER":return g.TypeInstantiation.str("string");case"INTEGER":case"LONG":case"UINT":case"UINT_64":return g.TypeInstantiation.int(1);case"FLOAT":case"DOUBLE":return g.TypeInstantiation.float(1.1);case"BOOLEAN":return g.TypeInstantiation.bool(!0);case"DATE":return g.TypeInstantiation.date("2024-01-15");case"DATE_TIME":return g.TypeInstantiation.datetime("2024-01-15T09:30:00Z");case"UUID":return g.TypeInstantiation.uuid("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32");default:B(t)}}synthesizeDefaultLiteral(t){switch(t.type){case"boolean":return g.TypeInstantiation.bool(t.value);case"string":return g.TypeInstantiation.str(t.value);default:B(t)}}synthesizeDefaultNamed({named:t,typeId:e,seen:i}){let a=new Set(i);switch(a.add(e),t.type){case"alias":return this.synthesizeDefaultValue(t.typeReference,a);case"enum":{let l=t.values[0];return l==null?g.TypeInstantiation.nop():g.TypeInstantiation.str(l.wireValue)}case"object":{let l=[];for(let w of t.properties){if(this.context.isOptional(w.typeReference)||this.context.isNullable(w.typeReference))continue;let b=this.synthesizeDefaultValue(w.typeReference,a);g.TypeInstantiation.isNop(b)||l.push({name:this.context.getPropertyName(w.name.name),value:b})}if(this.context.useTypedDictRequests())return g.TypeInstantiation.typedDict(l,{multiline:!0});let s=this.context.getTypeClassReference(t.declaration);return g.TypeInstantiation.reference(g.instantiateClass({classReference:s,arguments_:l.map(w=>g.methodArgument({name:w.name,value:w.value})),multiline:!0}))}case"discriminatedUnion":case"undiscriminatedUnion":return g.TypeInstantiation.nop();default:B(t)}}convertPrimitive({primitive:t,value:e,as:i}){switch(t){case"INTEGER":case"LONG":case"UINT":case"UINT_64":{let a=this.getValueAsNumber({value:e,as:i});return a==null?g.TypeInstantiation.nop():g.TypeInstantiation.int(a)}case"FLOAT":case"DOUBLE":{let a=this.getValueAsNumber({value:e});return a==null?g.TypeInstantiation.nop():g.TypeInstantiation.float(a)}case"BOOLEAN":{let a=this.getValueAsBoolean({value:e,as:i});return a==null?g.TypeInstantiation.nop():g.TypeInstantiation.bool(a)}case"BASE_64":case"BIG_INTEGER":case"STRING":{let a=this.context.getValueAsString({value:e});return a==null?g.TypeInstantiation.nop():g.TypeInstantiation.str(a)}case"UUID":{let a=this.context.getValueAsString({value:e});return a==null?g.TypeInstantiation.nop():g.TypeInstantiation.uuid(a)}case"DATE":{let a=this.context.getValueAsString({value:e});return a==null?g.TypeInstantiation.nop():g.TypeInstantiation.date(a)}case"DATE_TIME":{let a=this.context.getValueAsString({value:e});return a==null?g.TypeInstantiation.nop():g.TypeInstantiation.datetime(a)}default:B(t)}}getValueAsNumber({value:t,as:e}){let i=e==="key"&&typeof t=="string"?Number(t):t;return this.context.getValueAsNumber({value:i})}getValueAsBoolean({value:t,as:e}){let i=e==="key"?typeof t=="string"?t==="true":t==="false"?!1:t:t;return this.context.getValueAsBoolean({value:i})}};f();m();d();var st=class{constructor({context:t}){y(this,"context");this.context=t}getFilePropertyInfo({body:t,value:e}){let i={fileFields:[],bodyPropertyFields:[]},a=this.context.getRecord(e)??{};for(let l of t.properties)switch(l.type){case"file":{let s=this.getSingleFileProperty({property:l,record:a});if(g.TypeInstantiation.isNop(s))break;i.fileFields.push({name:this.context.getPropertyName(l.name),value:s});break}case"fileArray":{let s=this.getArrayFileProperty({property:l,record:a});if(g.TypeInstantiation.isNop(s))break;i.fileFields.push({name:this.context.getPropertyName(l.name),value:s});break}case"bodyProperty":{let s=this.getBodyProperty({property:l,record:a});if(g.TypeInstantiation.isNop(s))break;i.bodyPropertyFields.push({name:this.context.getPropertyName(l.name.name),value:s});break}default:B(l)}return i}getSingleFileProperty({property:t,record:e}){let i=this.context.getSingleFileValue({property:t,record:e});return i==null&&(i=`example_${t.wireValue??"file"}`),this.context.getFileFromString(i)}getArrayFileProperty({property:t,record:e}){let i=this.context.getFileArrayValues({property:t,record:e});if(i==null){let a=`example_${t.wireValue??"files"}`;return g.TypeInstantiation.list([this.context.getFileFromString(a)])}return g.TypeInstantiation.list(i.map(a=>this.context.getFileFromString(a)))}getBodyProperty({property:t,record:e}){let i=e[t.name.wireValue];return i==null?g.TypeInstantiation.nop():this.context.dynamicTypeLiteralMapper.convert({typeReference:t.typeReference,value:i})}};var Za=["list","set"],ut=class p extends ze{constructor({ir:e,config:i}){super({ir:e,config:i});y(this,"ir");y(this,"customConfig");y(this,"dynamicTypeLiteralMapper");y(this,"filePropertyMapper");this.ir=e,this.customConfig=i.customConfig??{},this.dynamicTypeLiteralMapper=new at({context:this}),this.filePropertyMapper=new st({context:this})}clone(){return new p({ir:this.ir,config:this.config})}getClassName(e){let i=e.pascalCase.safeName,a=this.getRootClientClassName();return i===a?`${a}Model`:i}getTypedDictClassName(e){return`${this.getClassName(e)}Params`}getPropertyName(e){let i=e.snakeCase.safeName;return i.startsWith("_")?"f_"+i.substring(i.lastIndexOf("_")+1):i}getMethodName(e){return Za.includes(e.snakeCase.unsafeName)?e.snakeCase.unsafeName:e.snakeCase.safeName}getRootClientClassReference(){return g.reference({name:this.getRootClientClassName(),modulePath:this.getRootModulePath()})}getTypeClassReference(e){let i=this.getClassName(e.name),a=[...this.getRootModulePath(),...e.fernFilepath.allParts.map(l=>l.snakeCase.safeName)];return g.reference({name:i,modulePath:a})}useTypedDictRequests(){return this.customConfig.use_typeddict_requests===!0}getRootClientClassName(){return this.customConfig.client?.exported_class_name!=null?this.customConfig.client.exported_class_name:this.customConfig.client_class_name!=null?this.customConfig.client_class_name:this.customConfig.client?.class_name!=null?this.customConfig.client.class_name:this.pascalCase(this.config.organization)+this.pascalCase(this.config.workspaceName)}getEnvironmentClassName(){return`${this.getRootClientClassName()}Environment`}getEnvironmentTypeReferenceFromID(e){let i=this.resolveEnvironmentName(e);if(i!=null)return g.accessAttribute({lhs:this.getEnvironmentClassReference(),rhs:g.codeBlock(this.getEnvironmentEnumName(i))})}getEnvironmentClassReference(){return g.reference({name:this.getEnvironmentClassName(),modulePath:this.getEnvironmentModulePath()})}getEnvironmentEnumName(e){return e.screamingSnakeCase.safeName}isPrimitive(e){switch(e.type){case"primitive":return!0;case"optional":case"nullable":return this.isPrimitive(e.value);case"named":{let i=this.resolveNamedType({typeId:e.value});if(i==null)return!1;switch(i.type){case"alias":return this.isPrimitive(i.typeReference);case"discriminatedUnion":case"undiscriminatedUnion":case"object":case"enum":return!1;default:B(i)}break}case"list":case"set":case"map":case"literal":case"unknown":return!1;default:B(e)}}getFileFromString(e){return g.TypeInstantiation.str(e)}getRootModulePath(){if(this.customConfig.package_name!=null)return[this.customConfig.package_name];let e=this.cleanOrganizationName();return this.customConfig.use_api_name_in_package?[e,this.getApiName()]:[e]}getCoreModulePath(){return this.getRootModulePath().concat("core")}getEnvironmentModulePath(){return this.getRootModulePath().concat("environment")}shouldInlinePathParameters(){return!0}cleanOrganizationName(){return this.config.organization.replace(/[^a-zA-Z0-9]/g,"_")}getApiName(){return vt(this.config.workspaceName)}pascalCase(e){let i=It(e);return i.charAt(0).toUpperCase()+i.slice(1)}};f();m();d();var Ja={type:"primitive",value:"STRING"},Ka=["example"],li="client",Ue="request",pt=class{constructor({context:t}){y(this,"context");this.context=t}async generateSnippet({endpoint:t,request:e}){return this.buildPythonFile({endpoint:t,snippet:e}).toString()}generateSnippetSync({endpoint:t,request:e}){return this.buildPythonFile({endpoint:t,snippet:e}).toString()}async generateSnippetAst({endpoint:t,request:e}){return this.buildPythonFile({endpoint:t,snippet:e})}generateMethodCallSnippetAst({endpoint:t,request:e}){return this.callMethod({endpoint:t,snippet:e})}buildPythonFile({endpoint:t,snippet:e}){return g.file({path:Ka,statements:[this.constructClient({endpoint:t,snippet:e}),this.callMethod({endpoint:t,snippet:e})]})}constructClient({endpoint:t,snippet:e}){return g.assign({lhs:g.reference({name:li}),rhs:g.instantiateClass({classReference:this.context.getRootClientClassReference(),arguments_:this.getConstructorArgs({endpoint:t,snippet:e}).map(i=>g.methodArgument({name:i.name,value:i.value})),multiline:!0})})}getConstructorArgs({endpoint:t,snippet:e}){let i=[],a=this.getConstructorEnvironmentArgs({baseUrl:e.baseURL,environment:e.environment});return a.length>0&&i.push(...a),t.auth!=null&&(e.auth!=null?i.push(...this.getConstructorAuthArgs({auth:t.auth,values:e.auth})):this.context.errors.add({severity:F.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(Y.PathParameters),this.context.ir.pathParameters!=null&&i.push(...this.getPathParameters({namedParameters:this.context.ir.pathParameters,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(Y.Headers),this.context.ir.headers!=null&&e.headers!=null&&i.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:e.headers})),this.context.errors.unscope(),i}getConstructorEnvironmentArgs({baseUrl:t,environment:e}){let i=this.getEnvironmentValue({baseUrl:t,environment:e});return i==null?[]:e!=null&&this.context.isMultiEnvironmentValues(e)?[{name:"environment",value:i}]:[{name:this.getEnvironmentOptionName({environment:e}),value:i}]}getEnvironmentValue({baseUrl:t,environment:e}){if(t!=null&&e!=null){this.context.errors.add({severity:F.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(t!=null)return g.TypeInstantiation.str(t);if(e!=null){if(this.context.isSingleEnvironmentID(e)){let i=this.context.getEnvironmentTypeReferenceFromID(e);if(i==null){this.context.errors.add({severity:F.Warning,message:`Environment ${JSON.stringify(e)} was not found`});return}return g.TypeInstantiation.reference(i)}if(this.context.isMultiEnvironmentValues(e))return this.context.validateMultiEnvironmentUrlValues(e)?g.TypeInstantiation.reference(g.instantiateClass({classReference:this.context.getEnvironmentClassReference(),arguments_:Object.entries(e).map(([i,a])=>({name:i,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:Ja,value:a})})).map(i=>g.methodArgument({name:i.name,value:i.value})),multiline:!0})):void 0}}getConstructorAuthArgs({auth:t,values:e}){switch(t.type){case"basic":return e.type!=="basic"?(this.addAuthMismatchError(t,e),[]):this.getConstructorBasicAuthArg({auth:t,values:e});case"bearer":return e.type!=="bearer"?(this.addAuthMismatchError(t,e),[]):this.getConstructorBearerAuthArgs({auth:t,values:e});case"header":return e.type!=="header"?(this.addAuthMismatchError(t,e),[]):this.getConstructorHeaderAuthArgs({auth:t,values:e});case"oauth":return e.type!=="oauth"?(this.addAuthMismatchError(t,e),[]):this.getConstructorOAuthArgs({auth:t,values:e});case"inferred":return e.type!=="inferred"?(this.addAuthMismatchError(t,e),[]):this.getConstructorInferredAuthArgs({auth:t,values:e});default:B(t)}}addAuthMismatchError(t,e){this.context.errors.add({severity:F.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message})}addWarning(t){this.context.errors.add({severity:F.Warning,message:t})}getConstructorBasicAuthArg({auth:t,values:e}){return[{name:this.context.getPropertyName(t.username),value:g.TypeInstantiation.str(e.username)},{name:this.context.getPropertyName(t.password),value:g.TypeInstantiation.str(e.password)}]}getConstructorBearerAuthArgs({auth:t,values:e}){return[{name:this.context.getPropertyName(t.token),value:g.TypeInstantiation.str(e.token)}]}getConstructorHeaderAuthArgs({auth:t,values:e}){return[{name:this.context.getPropertyName(t.header.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t.header.typeReference,value:e.value})}]}getConstructorOAuthArgs({auth:t,values:e}){return[{name:this.context.getPropertyName(t.clientId),value:g.TypeInstantiation.str(e.clientId)},{name:this.context.getPropertyName(t.clientSecret),value:g.TypeInstantiation.str(e.clientSecret)}]}getConstructorInferredAuthArgs({auth:t,values:e}){let i=t.parameters??[];if(i.length===0)return this.addWarning("Inferred auth scheme is missing parameters; cannot generate constructor arguments."),[];let a=e.values;if(a==null)return this.addWarning("Inferred auth values were not provided; cannot generate constructor arguments."),[];let l=[];for(let s of i){let w=s.name.wireValue;if(!Object.hasOwn(a,w)){this.addWarning(`Missing inferred auth value for ${w}`);continue}let b=a[w],A=this.context.dynamicTypeLiteralMapper.convert({typeReference:s.typeReference,value:b});g.TypeInstantiation.isNop(A)||l.push({name:this.context.getPropertyName(s.name.name),value:A})}return l}getConstructorHeaderArgs({headers:t,values:e}){let i=[];for(let a of t){let l=e[a.name.wireValue],s=this.getConstructorHeaderArg({header:a,value:l});s!=null&&i.push(s)}return i}getConstructorHeaderArg({header:t,value:e}){let i=this.context.dynamicTypeLiteralMapper.convert({typeReference:t.typeReference,value:e});if(!g.TypeInstantiation.isNop(i))return{name:this.context.getPropertyName(t.name.name),value:i}}callMethod({endpoint:t,snippet:e}){return g.invokeMethod({on:g.reference({name:li}),method:this.getMethod({endpoint:t}),arguments_:this.getMethodArgs({endpoint:t,snippet:e}).filter(i=>!g.TypeInstantiation.isNop(i.value)).map(i=>g.methodArgument({name:i.name,value:i.value})),multiline:!0})}getMethodArgs({endpoint:t,snippet:e}){switch(t.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:t.request,snippet:e});case"body":return this.getMethodArgsForBodyRequest({request:t.request,snippet:e});default:B(t.request)}}getMethodArgsForBodyRequest({request:t,snippet:e}){let i=[];this.context.errors.scope(Y.PathParameters);let a=[...this.context.ir.pathParameters??[],...t.pathParameters??[]],l=new Set;if(t.body!=null){let s=this.getBodyRequestArgs({body:t.body,value:e.requestBody});if(l=new Set(s.map(w=>w.name)),t.body.type==="typeReference"){let w=t.body.value;if(w.type==="named"){let b=this.context.resolveNamedType({typeId:w.value});if(b!=null&&b.type==="object")for(let A of b.properties)this.resolvesToLiteralType(A.typeReference)||l.add(this.context.getPropertyName(A.name.name))}}}if(a.length>0){let w=this.getPathParameters({namedParameters:a,snippet:e}).map(b=>l.has(b.name)?{...b,name:b.name+"_"}:b);i.push(...w)}return this.context.errors.unscope(),this.context.errors.scope(Y.RequestBody),t.body!=null&&i.push(...this.getBodyRequestArgs({body:t.body,value:e.requestBody})),this.context.errors.unscope(),i}getBodyRequestArgs({body:t,value:e}){switch(t.type){case"bytes":return[{name:Ue,value:this.getBytesBodyRequestTypeInstantiation({value:e})}];case"typeReference":return this.getBodyRequestArgsForTypeReference({typeReference:t.value,value:e});default:B(t)}}getBodyRequestArgsForTypeReference({typeReference:t,value:e}){switch(t.type){case"named":{let i=this.context.resolveNamedType({typeId:t.value});return i==null?[]:this.getBodyRequestArgsForNamedTypeReference({typeReference:t,named:i,value:e})}case"nullable":case"optional":{let i=t.value;return i.type==="named"&&this.context.resolveNamedType({typeId:i.value})?.type==="object"?[{name:Ue,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:i,value:e})}]:this.getBodyRequestArgsForTypeReference({typeReference:t.value,value:e})}case"list":case"map":case"set":case"literal":case"primitive":case"unknown":return[{name:Ue,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t,value:e})}];default:B(t)}}getBodyRequestArgsForNamedTypeReference({typeReference:t,named:e,value:i}){switch(e.type){case"alias":return this.getBodyRequestArgsForTypeReference({typeReference:e.typeReference,value:i});case"enum":case"discriminatedUnion":case"undiscriminatedUnion":return[{name:Ue,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t,value:i})}];case"object":return this.context.customConfig.inline_request_params===!1?[{name:Ue,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t,value:i})}]:this.context.associateByWireValue({parameters:e.properties,values:this.context.getRecord(i)??{}}).filter(s=>!this.resolvesToLiteralType(s.typeReference)).map(s=>({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)}));default:B(e)}}resolvesToLiteralType(t){switch(t.type){case"literal":return!0;case"optional":case"nullable":return this.resolvesToLiteralType(t.value);case"named":{let e=this.context.resolveNamedType({typeId:t.value});return e==null?!1:e.type==="alias"?this.resolvesToLiteralType(e.typeReference):!1}case"list":case"map":case"set":case"primitive":case"unknown":return!1;default:B(t)}}getBodyRequestArgsForBytes({body:t,value:e}){let i=this.getBytesBodyRequestTypeInstantiation({value:e});return g.TypeInstantiation.isNop(i)?[]:[{name:Ue,value:i}]}getBytesBodyRequestTypeInstantiation({value:t}){return typeof t!="string"?(this.context.errors.add({severity:F.Critical,message:`Expected bytes value to be a string, got ${typeof t}`}),g.TypeInstantiation.nop()):g.TypeInstantiation.bytes(t)}getBodyPropertyNamesForInlinedRequest(t){if(t.body==null)return new Set;switch(t.body.type){case"referenced":{let e=t.body.bodyType;if(e.type!=="typeReference")return new Set;let i=e.value;if(i.type!=="named")return new Set;let a=this.context.resolveNamedType({typeId:i.value});if(a==null||a.type!=="object")return new Set;let l=new Set;for(let s of a.properties)this.resolvesToLiteralType(s.typeReference)||l.add(this.context.getPropertyName(s.name.name));return l}case"properties":return new Set(t.body.value.filter(e=>!this.resolvesToLiteralType(e.typeReference)).map(e=>this.context.getPropertyName(e.name.name)));case"fileUpload":return new Set(t.body.properties.filter(e=>e.type==="bodyProperty").map(e=>this.context.getPropertyName(e.name.name)));default:B(t.body)}}getMethodArgsForInlinedRequest({request:t,snippet:e}){let i=[],a=this.context.shouldInlinePathParameters();this.context.errors.scope(Y.PathParameters);let l=[];t.pathParameters!=null&&l.push(...this.getPathParameters({namedParameters:t.pathParameters,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(Y.RequestBody);let s=this.getFilePropertyInfo({request:t,snippet:e});this.context.errors.unscope();let w=this.getBodyPropertyNamesForInlinedRequest(t),b=l.map(A=>w.has(A.name)?{...A,name:`${A.name}_`}:A);return this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:a})||i.push(...b),this.context.needsRequestParameter({request:t,inlinePathParameters:a,inlineFileProperties:!0})&&i.push(...this.getInlinedRequestArgs({request:t,snippet:e,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:a})?b:[],filePropertyInfo:s})),i}getFilePropertyInfo({request:t,snippet:e}){return t.body==null||!this.context.isFileUploadRequestBody(t.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:t.body,value:e.requestBody})}getInlinedRequestArgs({request:t,snippet:e,pathParameterFields:i,filePropertyInfo:a}){this.context.errors.scope(Y.QueryParameters);let s=this.context.associateQueryParametersByWireValue({parameters:t.queryParameters??[],values:e.queryParameters??{}}).map(R=>({name:this.context.getPropertyName(R.name.name),value:this.context.dynamicTypeLiteralMapper.convert(R)}));this.context.errors.unscope(),this.context.errors.scope(Y.Headers);let b=this.context.associateByWireValue({parameters:t.headers??[],values:e.headers??{}}).map(R=>({name:this.context.getPropertyName(R.name.name),value:this.context.dynamicTypeLiteralMapper.convert(R)}));this.context.errors.unscope(),this.context.errors.scope(Y.RequestBody);let A=t.body!=null?this.getInlinedRequestBodyObjectFields({body:t.body,value:e.requestBody,filePropertyInfo:a}):[];return this.context.errors.unscope(),[...i,...s,...b,...A]}getInlinedRequestBodyObjectFields({body:t,value:e,filePropertyInfo:i}){switch(t.type){case"properties":return this.getInlinedRequestBodyPropertyObjectFields({parameters:t.value,value:e});case"referenced":return this.getReferencedRequestBodyPropertyTypeInstantiation({body:t,value:e});case"fileUpload":return this.getFileUploadRequestBodyObjectFields({filePropertyInfo:i});default:B(t)}}getFileUploadRequestBodyObjectFields({filePropertyInfo:t}){return[...t.fileFields,...t.bodyPropertyFields]}getReferencedRequestBodyPropertyTypeInstantiation({body:t,value:e}){let i=t.bodyType;switch(i.type){case"bytes":return this.getBodyRequestArgsForBytes({body:t,value:e});case"typeReference":return this.getBodyRequestArgsForTypeReference({typeReference:i.value,value:e});default:B(i)}}getInlinedRequestBodyPropertyObjectFields({parameters:t,value:e}){let i=[],l=this.context.associateByWireValue({parameters:t,values:this.context.getRecord(e)??{}}).filter(s=>!this.resolvesToLiteralType(s.typeReference));for(let s of l)i.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)});return i}getPathParameters({namedParameters:t,snippet:e}){let i=[],a=t.filter(s=>!this.resolvesToLiteralType(s.typeReference)),l=this.context.associateByWireValue({parameters:a,values:e.pathParameters??{},ignoreMissingParameters:!0});for(let s of l)i.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)});return i}getMethod({endpoint:t}){return t.declaration.fernFilepath.allParts.length>0?`${t.declaration.fernFilepath.allParts.map(e=>this.context.getMethodName(e)).join(".")}.${this.context.getMethodName(t.declaration.name)}`:this.context.getMethodName(t.declaration.name)}getEnvironmentOptionName({environment:t}){return t!=null?"environment":"base_url"}};var lt=class extends We{constructor({ir:t,config:e}){super(new ut({ir:t,config:e}))}async generate(t,e={}){return super.generate(t,e)}generateSync(t,e={}){return super.generateSync(t,e)}async generateSnippetAst(t,e={}){return super.generateSnippetAst(t,e)}generateMethodCallSnippetAst({request:t,options:e={}}){let i=this.resolveEndpointsForMethodCall({request:t,options:e});if(i.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let a;for(let l of i){let s=this.context.clone(),w=this.createSnippetGenerator(s);try{return w.generateMethodCallSnippetAst({endpoint:l,request:t})}catch(b){a=b}}throw a??new Error(`Failed to generate method call snippet AST for endpoint: ${t.endpoint.method} ${t.endpoint.path}`)}resolveEndpointsForMethodCall({request:t,options:e}){if(e.endpointId!=null){let i=this.context.resolveEndpointById(e.endpointId);if(i==null)throw new Error(`No endpoint found with ID "${e.endpointId}"`);return[i]}return this.context.resolveEndpointLocationOrThrow(t.endpoint)}createSnippetGenerator(t){return new pt({context:t})}};0&&(module.exports={DynamicSnippetsGenerator});
|
|
21
21
|
/*! Bundled license information:
|
|
22
22
|
|
|
23
23
|
@jspm/core/nodelibs/browser/chunk-DtuTasat.js:
|