@noormdev/cli 1.0.0-alpha.0 → 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-4MUZ22JB.js +4 -0
- package/dist/chunk-BX5KFQ6D.js +1 -0
- package/dist/chunk-DGJUBN33.js +1 -0
- package/dist/chunk-MQJKW43U.js +1 -0
- package/dist/chunk-O7NFFKRC.js +1 -0
- package/dist/chunk-RBOB52ZJ.js +6 -0
- package/dist/chunk-TGNLDSZU.js +213 -0
- package/dist/devtools-RJP7TZE6.js +7 -0
- package/dist/engine-E7UBRVEC.js +1 -0
- package/dist/esm-FK2ZKTD7.js +2 -0
- package/dist/index.js +719 -271
- package/dist/mssql-2XQG4WUZ.js +1 -0
- package/dist/mysql-XWGAH4UX.js +1 -0
- package/dist/mysql2-KRZWXZIF.js +3007 -0
- package/dist/open-QFL643MX.js +2 -0
- package/dist/postgres-KQB7PRSJ.js +1 -0
- package/dist/sqlite-SK4I3XQS.js +1 -0
- package/dist/tarn-E5JKU5EV.js +1 -0
- package/dist/tedious-R2TVM4UU.js +191 -0
- package/package.json +2 -6
- package/dist/chunk-FQKJMLMW.js +0 -1
- package/dist/chunk-WOT6VMZA.js +0 -1
- package/dist/engine-Z55HXOAZ.js +0 -1
- package/dist/mssql-GVXYXFBZ.js +0 -1
- package/dist/mysql-LUTQ2CEP.js +0 -1
- package/dist/postgres-DEDRRMUE.js +0 -1
- package/dist/sqlite-OQR7CVXV.js +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{a as m,c as x,e as Y}from"./chunk-DGJUBN33.js";var T=x((Sr,je)=>{"use strict";var Ve=["nodebuffer","arraybuffer","fragments"],$e=typeof Blob<"u";$e&&Ve.push("blob");je.exports={BINARY_TYPES:Ve,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:$e,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var K=x((xr,re)=>{"use strict";var{EMPTY_BUFFER:Zt}=T(),Se=Buffer[Symbol.species];function Qt(t,e){if(t.length===0)return Zt;if(t.length===1)return t[0];let s=Buffer.allocUnsafe(e),r=0;for(let i=0;i<t.length;i++){let n=t[i];s.set(n,r),r+=n.length}return r<e?new Se(s.buffer,s.byteOffset,r):s}function ze(t,e,s,r,i){for(let n=0;n<i;n++)s[r+n]=t[n]^e[n&3]}function He(t,e){for(let s=0;s<t.length;s++)t[s]^=e[s&3]}function Jt(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function xe(t){if(xe.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Se(t):ArrayBuffer.isView(t)?e=new Se(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),xe.readOnly=!1),e}re.exports={concat:Qt,mask:ze,toArrayBuffer:Jt,toBuffer:xe,unmask:He};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=m("bufferutil");re.exports.mask=function(e,s,r,i,n){n<48?ze(e,s,r,i,n):t.mask(e,s,r,i,n)},re.exports.unmask=function(e,s){e.length<32?He(e,s):t.unmask(e,s)}}catch{}});var Xe=x((Er,Ke)=>{"use strict";var Ye=Symbol("kDone"),Ee=Symbol("kRun"),ve=class{constructor(e){this[Ye]=()=>{this.pending--,this[Ee]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ee]()}[Ee](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Ye])}}};Ke.exports=ve});var Z=x((vr,et)=>{"use strict";var X=m("zlib"),Ze=K(),es=Xe(),{kStatusCode:Qe}=T(),ts=Buffer[Symbol.species],ss=Buffer.from([0,0,255,255]),ne=Symbol("permessage-deflate"),k=Symbol("total-length"),W=Symbol("callback"),N=Symbol("buffers"),F=Symbol("error"),ie,be=class{constructor(e,s,r){if(this._maxPayload=r|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!s,this._deflate=null,this._inflate=null,this.params=null,!ie){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ie=new es(i)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[W];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let s=this._options,r=e.find(i=>!(s.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(s.serverMaxWindowBits===!1||typeof s.serverMaxWindowBits=="number"&&s.serverMaxWindowBits>i.server_max_window_bits)||typeof s.clientMaxWindowBits=="number"&&!i.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return s.serverNoContextTakeover&&(r.server_no_context_takeover=!0),s.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof s.serverMaxWindowBits=="number"&&(r.server_max_window_bits=s.serverMaxWindowBits),typeof s.clientMaxWindowBits=="number"?r.client_max_window_bits=s.clientMaxWindowBits:(r.client_max_window_bits===!0||s.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let s=e[0];if(this._options.clientNoContextTakeover===!1&&s.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!s.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(s.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&s.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return s}normalizeParams(e){return e.forEach(s=>{Object.keys(s).forEach(r=>{let i=s[r];if(i.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(i=i[0],r==="client_max_window_bits"){if(i!==!0){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=n}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else if(r==="server_max_window_bits"){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=n}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else throw new Error(`Unknown parameter "${r}"`);s[r]=i})}),e}decompress(e,s,r){ie.add(i=>{this._decompress(e,s,(n,o)=>{i(),r(n,o)})})}compress(e,s,r){ie.add(i=>{this._compress(e,s,(n,o)=>{i(),r(n,o)})})}_decompress(e,s,r){let i=this._isServer?"client":"server";if(!this._inflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?X.Z_DEFAULT_WINDOWBITS:this.params[n];this._inflate=X.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[ne]=this,this._inflate[k]=0,this._inflate[N]=[],this._inflate.on("error",is),this._inflate.on("data",Je)}this._inflate[W]=r,this._inflate.write(e),s&&this._inflate.write(ss),this._inflate.flush(()=>{let n=this._inflate[F];if(n){this._inflate.close(),this._inflate=null,r(n);return}let o=Ze.concat(this._inflate[N],this._inflate[k]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[k]=0,this._inflate[N]=[],s&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,s,r){let i=this._isServer?"server":"client";if(!this._deflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?X.Z_DEFAULT_WINDOWBITS:this.params[n];this._deflate=X.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[k]=0,this._deflate[N]=[],this._deflate.on("data",rs)}this._deflate[W]=r,this._deflate.write(e),this._deflate.flush(X.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let n=Ze.concat(this._deflate[N],this._deflate[k]);s&&(n=new ts(n.buffer,n.byteOffset,n.length-4)),this._deflate[W]=null,this._deflate[k]=0,this._deflate[N]=[],s&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),r(null,n)})}};et.exports=be;function rs(t){this[N].push(t),this[k]+=t.length}function Je(t){if(this[k]+=t.length,this[ne]._maxPayload<1||this[k]<=this[ne]._maxPayload){this[N].push(t);return}this[F]=new RangeError("Max payload size exceeded"),this[F].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[F][Qe]=1009,this.removeListener("data",Je),this.reset()}function is(t){if(this[ne]._inflate=null,this[F]){this[W](this[F]);return}t[Qe]=1007,this[W](t)}});var q=x((br,oe)=>{"use strict";var{isUtf8:tt}=m("buffer"),{hasBlob:ns}=T(),os=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function as(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function we(t){let e=t.length,s=0;for(;s<e;)if((t[s]&128)===0)s++;else if((t[s]&224)===192){if(s+1===e||(t[s+1]&192)!==128||(t[s]&254)===192)return!1;s+=2}else if((t[s]&240)===224){if(s+2>=e||(t[s+1]&192)!==128||(t[s+2]&192)!==128||t[s]===224&&(t[s+1]&224)===128||t[s]===237&&(t[s+1]&224)===160)return!1;s+=3}else if((t[s]&248)===240){if(s+3>=e||(t[s+1]&192)!==128||(t[s+2]&192)!==128||(t[s+3]&192)!==128||t[s]===240&&(t[s+1]&240)===128||t[s]===244&&t[s+1]>143||t[s]>244)return!1;s+=4}else return!1;return!0}function ls(t){return ns&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}oe.exports={isBlob:ls,isValidStatusCode:as,isValidUTF8:we,tokenChars:os};if(tt)oe.exports.isValidUTF8=function(t){return t.length<24?we(t):tt(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=m("utf-8-validate");oe.exports.isValidUTF8=function(e){return e.length<32?we(e):t(e)}}catch{}});var Le=x((wr,lt)=>{"use strict";var{Writable:fs}=m("stream"),st=Z(),{BINARY_TYPES:hs,EMPTY_BUFFER:rt,kStatusCode:cs,kWebSocket:us}=T(),{concat:Oe,toArrayBuffer:ds,unmask:_s}=K(),{isValidStatusCode:ps,isValidUTF8:it}=q(),ae=Buffer[Symbol.species],v=0,nt=1,ot=2,at=3,Te=4,ke=5,le=6,Ce=class extends fs{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||hs[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[us]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=v}_write(e,s,r){if(this._opcode===8&&this._state==v)return r();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new ae(r.buffer,r.byteOffset+e,r.length-e),new ae(r.buffer,r.byteOffset,e)}let s=Buffer.allocUnsafe(e);do{let r=this._buffers[0],i=s.length-e;e>=r.length?s.set(this._buffers.shift(),i):(s.set(new Uint8Array(r.buffer,r.byteOffset,e),i),this._buffers[0]=new ae(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0);return s}startLoop(e){this._loop=!0;do switch(this._state){case v:this.getInfo(e);break;case nt:this.getPayloadLength16(e);break;case ot:this.getPayloadLength64(e);break;case at:this.getMask();break;case Te:this.getData(e);break;case ke:case le:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let s=this.consume(2);if((s[0]&48)!==0){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(i);return}let r=(s[0]&64)===64;if(r&&!this._extensions[st.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._fin=(s[0]&128)===128,this._opcode=s[0]&15,this._payloadLength=s[1]&127,this._opcode===0){if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(i);return}if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(s[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(i);return}this._payloadLength===126?this._state=nt:this._payloadLength===127?this._state=ot:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let s=this.consume(8),r=s.readUInt32BE(0);if(r>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(i);return}this._payloadLength=r*Math.pow(2,32)+s.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(s);return}this._masked?this._state=at:this._state=Te}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Te}getData(e){let s=rt;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}s=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&_s(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._compressed){this._state=ke,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[st.extensionName].decompress(e,this._fin,(i,n)=>{if(i)return s(i);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(o);return}this._fragments.push(n)}this.dataMessage(s),this._state===v&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=v;return}let s=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=Oe(r,s):this._binaryType==="arraybuffer"?i=ds(Oe(r,s)):this._binaryType==="blob"?i=new Blob(r):i=r,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=v):(this._state=le,setImmediate(()=>{this.emit("message",i,!0),this._state=v,this.startLoop(e)}))}else{let i=Oe(r,s);if(!this._skipUTF8Validation&&!it(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(n);return}this._state===ke||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=v):(this._state=le,setImmediate(()=>{this.emit("message",i,!1),this._state=v,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,rt),this.end();else{let r=e.readUInt16BE(0);if(!ps(r)){let n=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(n);return}let i=new ae(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!it(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");s(n);return}this._loop=!1,this.emit("conclude",r,i),this.end()}this._state=v;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=v):(this._state=le,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=v,this.startLoop(s)}))}createError(e,s,r,i,n){this._loop=!1,this._errored=!0;let o=new e(r?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(o,this.createError),o.code=n,o[cs]=i,o}};lt.exports=Ce});var Be=x((Tr,ct)=>{"use strict";var{Duplex:Or}=m("stream"),{randomFillSync:ms}=m("crypto"),ft=Z(),{EMPTY_BUFFER:gs,kWebSocket:ys,NOOP:Ss}=T(),{isBlob:G,isValidStatusCode:xs}=q(),{mask:ht,toBuffer:B}=K(),b=Symbol("kByteLength"),Es=Buffer.alloc(4),fe=8*1024,R,V=fe,w=0,vs=1,bs=2,Ne=class t{constructor(e,s,r){this._extensions=s||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=w,this.onerror=Ss,this[ys]=void 0}static frame(e,s){let r,i=!1,n=2,o=!1;s.mask&&(r=s.maskBuffer||Es,s.generateMask?s.generateMask(r):(V===fe&&(R===void 0&&(R=Buffer.alloc(fe)),ms(R,0,fe),V=0),r[0]=R[V++],r[1]=R[V++],r[2]=R[V++],r[3]=R[V++]),o=(r[0]|r[1]|r[2]|r[3])===0,n=6);let l;typeof e=="string"?(!s.mask||o)&&s[b]!==void 0?l=s[b]:(e=Buffer.from(e),l=e.length):(l=e.length,i=s.mask&&s.readOnly&&!o);let f=l;l>=65536?(n+=8,f=127):l>125&&(n+=2,f=126);let a=Buffer.allocUnsafe(i?l+n:n);return a[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(a[0]|=64),a[1]=f,f===126?a.writeUInt16BE(l,2):f===127&&(a[2]=a[3]=0,a.writeUIntBE(l,4,6)),s.mask?(a[1]|=128,a[n-4]=r[0],a[n-3]=r[1],a[n-2]=r[2],a[n-1]=r[3],o?[a,e]:i?(ht(e,r,a,n,l),[a]):(ht(e,r,e,0,l),[a,e])):[a,e]}close(e,s,r,i){let n;if(e===void 0)n=gs;else{if(typeof e!="number"||!xs(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0);else{let l=Buffer.byteLength(s);if(l>123)throw new RangeError("The message must not be greater than 123 bytes");n=Buffer.allocUnsafe(2+l),n.writeUInt16BE(e,0),typeof s=="string"?n.write(s,2):n.set(s,2)}}let o={[b]:n.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==w?this.enqueue([this.dispatch,n,!1,o,i]):this.sendFrame(t.frame(n,o),i)}ping(e,s,r){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):G(e)?(i=e.size,n=!1):(e=B(e),i=e.length,n=B.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};G(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==w?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}pong(e,s,r){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):G(e)?(i=e.size,n=!1):(e=B(e),i=e.length,n=B.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};G(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==w?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}send(e,s,r){let i=this._extensions[ft.extensionName],n=s.binary?2:1,o=s.compress,l,f;typeof e=="string"?(l=Buffer.byteLength(e),f=!1):G(e)?(l=e.size,f=!1):(e=B(e),l=e.length,f=B.readOnly),this._firstFragment?(this._firstFragment=!1,o&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=l>=i._threshold),this._compress=o):(o=!1,n=0),s.fin&&(this._firstFragment=!0);let a={[b]:l,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:f,rsv1:o};G(e)?this._state!==w?this.enqueue([this.getBlobData,e,this._compress,a,r]):this.getBlobData(e,this._compress,a,r):this._state!==w?this.enqueue([this.dispatch,e,this._compress,a,r]):this.dispatch(e,this._compress,a,r)}getBlobData(e,s,r,i){this._bufferedBytes+=r[b],this._state=bs,e.arrayBuffer().then(n=>{if(this._socket.destroyed){let l=new Error("The socket was closed while the blob was being read");process.nextTick(Pe,this,l,i);return}this._bufferedBytes-=r[b];let o=B(n);s?this.dispatch(o,s,r,i):(this._state=w,this.sendFrame(t.frame(o,r),i),this.dequeue())}).catch(n=>{process.nextTick(ws,this,n,i)})}dispatch(e,s,r,i){if(!s){this.sendFrame(t.frame(e,r),i);return}let n=this._extensions[ft.extensionName];this._bufferedBytes+=r[b],this._state=vs,n.compress(e,r.fin,(o,l)=>{if(this._socket.destroyed){let f=new Error("The socket was closed while data was being compressed");Pe(this,f,i);return}this._bufferedBytes-=r[b],this._state=w,r.readOnly=!1,this.sendFrame(t.frame(l,r),i),this.dequeue()})}dequeue(){for(;this._state===w&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][b],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][b],this._queue.push(e)}sendFrame(e,s){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],s),this._socket.uncork()):this._socket.write(e[0],s)}};ct.exports=Ne;function Pe(t,e,s){typeof s=="function"&&s(e);for(let r=0;r<t._queue.length;r++){let i=t._queue[r],n=i[i.length-1];typeof n=="function"&&n(e)}}function ws(t,e,s){Pe(t,e,s),t.onerror(e)}});var xt=x((kr,St)=>{"use strict";var{kForOnEventAttribute:Q,kListener:Re}=T(),ut=Symbol("kCode"),dt=Symbol("kData"),_t=Symbol("kError"),pt=Symbol("kMessage"),mt=Symbol("kReason"),$=Symbol("kTarget"),gt=Symbol("kType"),yt=Symbol("kWasClean"),C=class{constructor(e){this[$]=null,this[gt]=e}get target(){return this[$]}get type(){return this[gt]}};Object.defineProperty(C.prototype,"target",{enumerable:!0});Object.defineProperty(C.prototype,"type",{enumerable:!0});var I=class extends C{constructor(e,s={}){super(e),this[ut]=s.code===void 0?0:s.code,this[mt]=s.reason===void 0?"":s.reason,this[yt]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[ut]}get reason(){return this[mt]}get wasClean(){return this[yt]}};Object.defineProperty(I.prototype,"code",{enumerable:!0});Object.defineProperty(I.prototype,"reason",{enumerable:!0});Object.defineProperty(I.prototype,"wasClean",{enumerable:!0});var j=class extends C{constructor(e,s={}){super(e),this[_t]=s.error===void 0?null:s.error,this[pt]=s.message===void 0?"":s.message}get error(){return this[_t]}get message(){return this[pt]}};Object.defineProperty(j.prototype,"error",{enumerable:!0});Object.defineProperty(j.prototype,"message",{enumerable:!0});var J=class extends C{constructor(e,s={}){super(e),this[dt]=s.data===void 0?null:s.data}get data(){return this[dt]}};Object.defineProperty(J.prototype,"data",{enumerable:!0});var Os={addEventListener(t,e,s={}){for(let i of this.listeners(t))if(!s[Q]&&i[Re]===e&&!i[Q])return;let r;if(t==="message")r=function(n,o){let l=new J("message",{data:o?n:n.toString()});l[$]=this,he(e,this,l)};else if(t==="close")r=function(n,o){let l=new I("close",{code:n,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});l[$]=this,he(e,this,l)};else if(t==="error")r=function(n){let o=new j("error",{error:n,message:n.message});o[$]=this,he(e,this,o)};else if(t==="open")r=function(){let n=new C("open");n[$]=this,he(e,this,n)};else return;r[Q]=!!s[Q],r[Re]=e,s.once?this.once(t,r):this.on(t,r)},removeEventListener(t,e){for(let s of this.listeners(t))if(s[Re]===e&&!s[Q]){this.removeListener(t,s);break}}};St.exports={CloseEvent:I,ErrorEvent:j,Event:C,EventTarget:Os,MessageEvent:J};function he(t,e,s){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,s):t.call(e,s)}});var Ie=x((Cr,Et)=>{"use strict";var{tokenChars:ee}=q();function O(t,e,s){t[e]===void 0?t[e]=[s]:t[e].push(s)}function Ts(t){let e=Object.create(null),s=Object.create(null),r=!1,i=!1,n=!1,o,l,f=-1,a=-1,h=-1,c=0;for(;c<t.length;c++)if(a=t.charCodeAt(c),o===void 0)if(h===-1&&ee[a]===1)f===-1&&(f=c);else if(c!==0&&(a===32||a===9))h===-1&&f!==-1&&(h=c);else if(a===59||a===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c);let g=t.slice(f,h);a===44?(O(e,g,s),s=Object.create(null)):o=g,f=h=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);else if(l===void 0)if(h===-1&&ee[a]===1)f===-1&&(f=c);else if(a===32||a===9)h===-1&&f!==-1&&(h=c);else if(a===59||a===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c),O(s,t.slice(f,h),!0),a===44&&(O(e,o,s),s=Object.create(null),o=void 0),f=h=-1}else if(a===61&&f!==-1&&h===-1)l=t.slice(f,c),f=h=-1;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(i){if(ee[a]!==1)throw new SyntaxError(`Unexpected character at index ${c}`);f===-1?f=c:r||(r=!0),i=!1}else if(n)if(ee[a]===1)f===-1&&(f=c);else if(a===34&&f!==-1)n=!1,h=c;else if(a===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(a===34&&t.charCodeAt(c-1)===61)n=!0;else if(h===-1&&ee[a]===1)f===-1&&(f=c);else if(f!==-1&&(a===32||a===9))h===-1&&(h=c);else if(a===59||a===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c);let g=t.slice(f,h);r&&(g=g.replace(/\\/g,""),r=!1),O(s,l,g),a===44&&(O(e,o,s),s=Object.create(null),o=void 0),l=void 0,f=h=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);if(f===-1||n||a===32||a===9)throw new SyntaxError("Unexpected end of input");h===-1&&(h=c);let _=t.slice(f,h);return o===void 0?O(e,_,s):(l===void 0?O(s,_,!0):r?O(s,l,_.replace(/\\/g,"")):O(s,l,_),O(e,o,s)),e}function ks(t){return Object.keys(t).map(e=>{let s=t[e];return Array.isArray(s)||(s=[s]),s.map(r=>[e].concat(Object.keys(r).map(i=>{let n=r[i];return Array.isArray(n)||(n=[n]),n.map(o=>o===!0?i:`${i}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Et.exports={format:ks,parse:Ts}});var _e=x((Pr,Rt)=>{"use strict";var Cs=m("events"),Ls=m("https"),Ns=m("http"),wt=m("net"),Ps=m("tls"),{randomBytes:Bs,createHash:Rs}=m("crypto"),{Duplex:Lr,Readable:Nr}=m("stream"),{URL:Ue}=m("url"),P=Z(),Is=Le(),Us=Be(),{isBlob:Ds}=q(),{BINARY_TYPES:vt,EMPTY_BUFFER:ce,GUID:Ms,kForOnEventAttribute:De,kListener:As,kStatusCode:Ws,kWebSocket:y,NOOP:Ot}=T(),{EventTarget:{addEventListener:Fs,removeEventListener:qs}}=xt(),{format:Gs,parse:Vs}=Ie(),{toBuffer:$s}=K(),js=30*1e3,Tt=Symbol("kAborted"),Me=[8,13],L=["CONNECTING","OPEN","CLOSING","CLOSED"],zs=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,d=class t extends Cs{constructor(e,s,r){super(),this._binaryType=vt[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=ce,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,s===void 0?s=[]:Array.isArray(s)||(typeof s=="object"&&s!==null?(r=s,s=[]):s=[s]),kt(this,e,s,r)):(this._autoPong=r.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){vt.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,s,r){let i=new Is({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),n=new Us(e,this._extensions,r.generateMask);this._receiver=i,this._sender=n,this._socket=e,i[y]=this,n[y]=this,e[y]=this,i.on("conclude",Ks),i.on("drain",Xs),i.on("error",Zs),i.on("message",Qs),i.on("ping",Js),i.on("pong",er),n.onerror=tr,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",Nt),e.on("data",de),e.on("end",Pt),e.on("error",Bt),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[P.extensionName]&&this._extensions[P.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,s){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){E(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,s,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Lt(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=s=void 0):typeof s=="function"&&(r=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ae(this,e,r);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||ce,s,r)}pong(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=s=void 0):typeof s=="function"&&(r=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ae(this,e,r);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||ce,s,r)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof s=="function"&&(r=s,s={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ae(this,e,r);return}let i={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[P.extensionName]||(i.compress=!1),this._sender.send(e||ce,i,r)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){E(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(d,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")});Object.defineProperty(d.prototype,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")});Object.defineProperty(d,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")});Object.defineProperty(d.prototype,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")});Object.defineProperty(d,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")});Object.defineProperty(d.prototype,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")});Object.defineProperty(d,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")});Object.defineProperty(d.prototype,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(d.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(d.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[De])return e[As];return null},set(e){for(let s of this.listeners(t))if(s[De]){this.removeListener(t,s);break}typeof e=="function"&&this.addEventListener(t,e,{[De]:!0})}})});d.prototype.addEventListener=Fs;d.prototype.removeEventListener=qs;Rt.exports=d;function kt(t,e,s,r){let i={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:Me[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=i.autoPong,!Me.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${Me.join(", ")})`);let n;if(e instanceof Ue)n=e;else try{n=new Ue(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}n.protocol==="http:"?n.protocol="ws:":n.protocol==="https:"&&(n.protocol="wss:"),t._url=n.href;let o=n.protocol==="wss:",l=n.protocol==="ws+unix:",f;if(n.protocol!=="ws:"&&!o&&!l?f=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:l&&!n.pathname?f="The URL's pathname is empty":n.hash&&(f="The URL contains a fragment identifier"),f){let u=new SyntaxError(f);if(t._redirects===0)throw u;ue(t,u);return}let a=o?443:80,h=Bs(16).toString("base64"),c=o?Ls.request:Ns.request,_=new Set,g;if(i.createConnection=i.createConnection||(o?Ys:Hs),i.defaultPort=i.defaultPort||a,i.port=n.port||a,i.host=n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":h,Connection:"Upgrade",Upgrade:"websocket"},i.path=n.pathname+n.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(g=new P(i.perMessageDeflate!==!0?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=Gs({[P.extensionName]:g.offer()})),s.length){for(let u of s){if(typeof u!="string"||!zs.test(u)||_.has(u))throw new SyntaxError("An invalid or duplicated subprotocol was specified");_.add(u)}i.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(n.username||n.password)&&(i.auth=`${n.username}:${n.password}`),l){let u=i.path.split(":");i.socketPath=u[0],i.path=u[1]}let p;if(i.followRedirects){if(t._redirects===0){t._originalIpc=l,t._originalSecure=o,t._originalHostOrSocketPath=l?i.socketPath:n.host;let u=r&&r.headers;if(r={...r,headers:{}},u)for(let[S,M]of Object.entries(u))r.headers[S.toLowerCase()]=M}else if(t.listenerCount("redirect")===0){let u=l?t._originalIpc?i.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:n.host===t._originalHostOrSocketPath;(!u||t._originalSecure&&!o)&&(delete i.headers.authorization,delete i.headers.cookie,u||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),p=t._req=c(i),t._redirects&&t.emit("redirect",t.url,p)}else p=t._req=c(i);i.timeout&&p.on("timeout",()=>{E(t,p,"Opening handshake has timed out")}),p.on("error",u=>{p===null||p[Tt]||(p=t._req=null,ue(t,u))}),p.on("response",u=>{let S=u.headers.location,M=u.statusCode;if(S&&i.followRedirects&&M>=300&&M<400){if(++t._redirects>i.maxRedirects){E(t,p,"Maximum redirects exceeded");return}p.abort();let z;try{z=new Ue(S,e)}catch{let A=new SyntaxError(`Invalid URL: ${S}`);ue(t,A);return}kt(t,z,s,r)}else t.emit("unexpected-response",p,u)||E(t,p,`Unexpected server response: ${u.statusCode}`)}),p.on("upgrade",(u,S,M)=>{if(t.emit("upgrade",u),t.readyState!==d.CONNECTING)return;p=t._req=null;let z=u.headers.upgrade;if(z===void 0||z.toLowerCase()!=="websocket"){E(t,S,"Invalid Upgrade header");return}let Fe=Rs("sha1").update(h+Ms).digest("base64");if(u.headers["sec-websocket-accept"]!==Fe){E(t,S,"Invalid Sec-WebSocket-Accept header");return}let A=u.headers["sec-websocket-protocol"],H;if(A!==void 0?_.size?_.has(A)||(H="Server sent an invalid subprotocol"):H="Server sent a subprotocol but none was requested":_.size&&(H="Server sent no subprotocol"),H){E(t,S,H);return}A&&(t._protocol=A);let qe=u.headers["sec-websocket-extensions"];if(qe!==void 0){if(!g){E(t,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let ge;try{ge=Vs(qe)}catch{E(t,S,"Invalid Sec-WebSocket-Extensions header");return}let Ge=Object.keys(ge);if(Ge.length!==1||Ge[0]!==P.extensionName){E(t,S,"Server indicated an extension that was not requested");return}try{g.accept(ge[P.extensionName])}catch{E(t,S,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[P.extensionName]=g}t.setSocket(S,M,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(p,t):p.end()}function ue(t,e){t._readyState=d.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Hs(t){return t.path=t.socketPath,wt.connect(t)}function Ys(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=wt.isIP(t.host)?"":t.host),Ps.connect(t)}function E(t,e,s){t._readyState=d.CLOSING;let r=new Error(s);Error.captureStackTrace(r,E),e.setHeader?(e[Tt]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(ue,t,r)):(e.destroy(r),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Ae(t,e,s){if(e){let r=Ds(e)?e.size:$s(e).length;t._socket?t._sender._bufferedBytes+=r:t._bufferedAmount+=r}if(s){let r=new Error(`WebSocket is not open: readyState ${t.readyState} (${L[t.readyState]})`);process.nextTick(s,r)}}function Ks(t,e){let s=this[y];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=t,s._socket[y]!==void 0&&(s._socket.removeListener("data",de),process.nextTick(Ct,s._socket),t===1005?s.close():s.close(t,e))}function Xs(){let t=this[y];t.isPaused||t._socket.resume()}function Zs(t){let e=this[y];e._socket[y]!==void 0&&(e._socket.removeListener("data",de),process.nextTick(Ct,e._socket),e.close(t[Ws])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function bt(){this[y].emitClose()}function Qs(t,e){this[y].emit("message",t,e)}function Js(t){let e=this[y];e._autoPong&&e.pong(t,!this._isServer,Ot),e.emit("ping",t)}function er(t){this[y].emit("pong",t)}function Ct(t){t.resume()}function tr(t){let e=this[y];e.readyState!==d.CLOSED&&(e.readyState===d.OPEN&&(e._readyState=d.CLOSING,Lt(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Lt(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),js)}function Nt(){let t=this[y];this.removeListener("close",Nt),this.removeListener("data",de),this.removeListener("end",Pt),t._readyState=d.CLOSING;let e;!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&(e=t._socket.read())!==null&&t._receiver.write(e),t._receiver.end(),this[y]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",bt),t._receiver.on("finish",bt))}function de(t){this[y]._receiver.write(t)||this.pause()}function Pt(){let t=this[y];t._readyState=d.CLOSING,t._receiver.end(),this.end()}function Bt(){let t=this[y];this.removeListener("error",Bt),this.on("error",Ot),t&&(t._readyState=d.CLOSING,this.destroy())}});var Mt=x((Rr,Dt)=>{"use strict";var Br=_e(),{Duplex:sr}=m("stream");function It(t){t.emit("close")}function rr(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Ut(t){this.removeListener("error",Ut),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function ir(t,e){let s=!0,r=new sr({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(n,o){let l=!o&&r._readableState.objectMode?n.toString():n;r.push(l)||t.pause()}),t.once("error",function(n){r.destroyed||(s=!1,r.destroy(n))}),t.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(i,n){if(t.readyState===t.CLOSED){n(i),process.nextTick(It,r);return}let o=!1;t.once("error",function(f){o=!0,n(f)}),t.once("close",function(){o||n(i),process.nextTick(It,r)}),s&&t.terminate()},r._final=function(i){if(t.readyState===t.CONNECTING){t.once("open",function(){r._final(i)});return}t._socket!==null&&(t._socket._writableState.finished?(i(),r._readableState.endEmitted&&r.destroy()):(t._socket.once("finish",function(){i()}),t.close()))},r._read=function(){t.isPaused&&t.resume()},r._write=function(i,n,o){if(t.readyState===t.CONNECTING){t.once("open",function(){r._write(i,n,o)});return}t.send(i,o)},r.on("end",rr),r.on("error",Ut),r}Dt.exports=ir});var Wt=x((Ir,At)=>{"use strict";var{tokenChars:nr}=q();function or(t){let e=new Set,s=-1,r=-1,i=0;for(i;i<t.length;i++){let o=t.charCodeAt(i);if(r===-1&&nr[o]===1)s===-1&&(s=i);else if(i!==0&&(o===32||o===9))r===-1&&s!==-1&&(r=i);else if(o===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${i}`);r===-1&&(r=i);let l=t.slice(s,r);if(e.has(l))throw new SyntaxError(`The "${l}" subprotocol is duplicated`);e.add(l),s=r=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(s===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let n=t.slice(s,i);if(e.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return e.add(n),e}At.exports={parse:or}});var zt=x((Dr,jt)=>{"use strict";var ar=m("events"),pe=m("http"),{Duplex:Ur}=m("stream"),{createHash:lr}=m("crypto"),Ft=Ie(),U=Z(),fr=Wt(),hr=_e(),{GUID:cr,kWebSocket:ur}=T(),dr=/^[+/0-9A-Za-z]{22}==$/,qt=0,Gt=1,$t=2,We=class extends ar{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:hr,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=pe.createServer((r,i)=>{let n=pe.STATUS_CODES[426];i.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),i.end(n)}),this._server.listen(e.port,e.host,e.backlog,s)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=_r(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,n,o)=>{this.handleUpgrade(i,n,o,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=qt}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===$t){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(te,this);return}if(e&&this.once("close",e),this._state!==Gt)if(this._state=Gt,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(te,this):process.nextTick(te,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{te(this)})}}shouldHandle(e){if(this.options.path){let s=e.url.indexOf("?");if((s!==-1?e.url.slice(0,s):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,s,r,i){s.on("error",Vt);let n=e.headers["sec-websocket-key"],o=e.headers.upgrade,l=+e.headers["sec-websocket-version"];if(e.method!=="GET"){D(this,e,s,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){D(this,e,s,400,"Invalid Upgrade header");return}if(n===void 0||!dr.test(n)){D(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(l!==13&&l!==8){D(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){se(s,400);return}let f=e.headers["sec-websocket-protocol"],a=new Set;if(f!==void 0)try{a=fr.parse(f)}catch{D(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let h=e.headers["sec-websocket-extensions"],c={};if(this.options.perMessageDeflate&&h!==void 0){let _=new U(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let g=Ft.parse(h);g[U.extensionName]&&(_.accept(g[U.extensionName]),c[U.extensionName]=_)}catch{D(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let _={origin:e.headers[`${l===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(_,(g,p,u,S)=>{if(!g)return se(s,p||401,u,S);this.completeUpgrade(c,n,a,e,s,r,i)});return}if(!this.options.verifyClient(_))return se(s,401)}this.completeUpgrade(c,n,a,e,s,r,i)}completeUpgrade(e,s,r,i,n,o,l){if(!n.readable||!n.writable)return n.destroy();if(n[ur])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>qt)return se(n,503);let a=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${lr("sha1").update(s+cr).digest("base64")}`],h=new this.options.WebSocket(null,void 0,this.options);if(r.size){let c=this.options.handleProtocols?this.options.handleProtocols(r,i):r.values().next().value;c&&(a.push(`Sec-WebSocket-Protocol: ${c}`),h._protocol=c)}if(e[U.extensionName]){let c=e[U.extensionName].params,_=Ft.format({[U.extensionName]:[c]});a.push(`Sec-WebSocket-Extensions: ${_}`),h._extensions=e}this.emit("headers",a,i),n.write(a.concat(`\r
|
|
2
|
+
`).join(`\r
|
|
3
|
+
`)),n.removeListener("error",Vt),h.setSocket(n,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(h),h.on("close",()=>{this.clients.delete(h),this._shouldEmitClose&&!this.clients.size&&process.nextTick(te,this)})),l(h,i)}};jt.exports=We;function _r(t,e){for(let s of Object.keys(e))t.on(s,e[s]);return function(){for(let r of Object.keys(e))t.removeListener(r,e[r])}}function te(t){t._state=$t,t.emit("close")}function Vt(){this.destroy()}function se(t,e,s,r){s=s||pe.STATUS_CODES[e],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...r},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${pe.STATUS_CODES[e]}\r
|
|
4
|
+
`+Object.keys(r).map(i=>`${i}: ${r[i]}`).join(`\r
|
|
5
|
+
`)+`\r
|
|
6
|
+
\r
|
|
7
|
+
`+s)}function D(t,e,s,r,i,n){if(t.listenerCount("wsClientError")){let o=new Error(i);Error.captureStackTrace(o,D),t.emit("wsClientError",o,s,e)}else se(s,r,i,n)}});var pr=Y(Mt(),1),mr=Y(Le(),1),gr=Y(Be(),1),Ht=Y(_e(),1),yr=Y(zt(),1);var Yt=Ht.default;var me=global;me.WebSocket||=Yt;me.window||=global;me.self||=global;me.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__=[{type:1,value:7,isEnabled:!0},{type:2,value:"InternalApp",isEnabled:!0,isValid:!0},{type:2,value:"InternalAppContext",isEnabled:!0,isValid:!0},{type:2,value:"InternalStdoutContext",isEnabled:!0,isValid:!0},{type:2,value:"InternalStderrContext",isEnabled:!0,isValid:!0},{type:2,value:"InternalStdinContext",isEnabled:!0,isValid:!0},{type:2,value:"InternalFocusContext",isEnabled:!0,isValid:!0}];import Kt from"react-devtools-core";Kt.initialize();Kt.connectToDevTools();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as a,l as b,m as c,n as d,o as e}from"./chunk-TGNLDSZU.js";import"./chunk-DGJUBN33.js";export{a as eta,b as isTemplate,d as processFile,e as processFiles,c as renderTemplate};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as m,c as f,e as fs}from"./chunk-DGJUBN33.js";var _e=f(bt=>{"use strict";bt.parse=function(r,e){return new ge(r,e).parse()};var ge=class r{constructor(e,t){this.source=e,this.transform=t||ds,this.position=0,this.entries=[],this.recorded=[],this.dimension=0}isEof(){return this.position>=this.source.length}nextCharacter(){var e=this.source[this.position++];return e==="\\"?{value:this.source[this.position++],escaped:!0}:{value:e,escaped:!1}}record(e){this.recorded.push(e)}newEntry(e){var t;(this.recorded.length>0||e)&&(t=this.recorded.join(""),t==="NULL"&&!e&&(t=null),t!==null&&(t=this.transform(t)),this.entries.push(t),this.recorded=[])}consumeDimensions(){if(this.source[0]==="[")for(;!this.isEof();){var e=this.nextCharacter();if(e.value==="=")break}}parse(e){var t,s,n;for(this.consumeDimensions();!this.isEof();)if(t=this.nextCharacter(),t.value==="{"&&!n)this.dimension++,this.dimension>1&&(s=new r(this.source.substr(this.position-1),this.transform),this.entries.push(s.parse(!0)),this.position+=s.position-2);else if(t.value==="}"&&!n){if(this.dimension--,!this.dimension&&(this.newEntry(),e))return this.entries}else t.value==='"'&&!t.escaped?(n&&this.newEntry(!0),n=!n):t.value===","&&!n?this.newEntry():this.record(t.value);if(this.dimension!==0)throw new Error("array dimension not balanced");return this.entries}};function ds(r){return r}});var we=f((Ao,vt)=>{"use strict";var ps=_e();vt.exports={create:function(r,e){return{parse:function(){return ps.parse(r,e)}}}}});var At=f((Po,Ct)=>{"use strict";var ms=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/,ys=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,gs=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,_s=/^-?infinity$/;Ct.exports=function(e){if(_s.test(e))return Number(e.replace("i","I"));var t=ms.exec(e);if(!t)return ws(e)||null;var s=!!t[8],n=parseInt(t[1],10);s&&(n=Et(n));var i=parseInt(t[2],10)-1,o=t[3],a=parseInt(t[4],10),u=parseInt(t[5],10),c=parseInt(t[6],10),h=t[7];h=h?1e3*parseFloat(h):0;var d,p=Ss(e);return p!=null?(d=new Date(Date.UTC(n,i,o,a,u,c,h)),Se(n)&&d.setUTCFullYear(n),p!==0&&d.setTime(d.getTime()-p)):(d=new Date(n,i,o,a,u,c,h),Se(n)&&d.setFullYear(n)),d};function ws(r){var e=ys.exec(r);if(e){var t=parseInt(e[1],10),s=!!e[4];s&&(t=Et(t));var n=parseInt(e[2],10)-1,i=e[3],o=new Date(t,n,i);return Se(t)&&o.setFullYear(t),o}}function Ss(r){if(r.endsWith("+00"))return 0;var e=gs.exec(r.split(" ")[1]);if(e){var t=e[1];if(t==="Z")return 0;var s=t==="-"?-1:1,n=parseInt(e[2],10)*3600+parseInt(e[3]||0,10)*60+parseInt(e[4]||0,10);return n*s*1e3}}function Et(r){return-(r-1)}function Se(r){return r>=0&&r<100}});var xt=f((xo,Pt)=>{"use strict";Pt.exports=vs;var bs=Object.prototype.hasOwnProperty;function vs(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)bs.call(t,s)&&(r[s]=t[s])}return r}});var It=f((To,Mt)=>{"use strict";var Es=xt();Mt.exports=k;function k(r){if(!(this instanceof k))return new k(r);Es(this,Os(r))}var Cs=["seconds","minutes","hours","days","months","years"];k.prototype.toPostgres=function(){var r=Cs.filter(this.hasOwnProperty,this);return this.milliseconds&&r.indexOf("seconds")<0&&r.push("seconds"),r.length===0?"0":r.map(function(e){var t=this[e]||0;return e==="seconds"&&this.milliseconds&&(t=(t+this.milliseconds/1e3).toFixed(6).replace(/\.?0+$/,"")),t+" "+e},this).join(" ")};var As={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"S"},Ps=["years","months","days"],xs=["hours","minutes","seconds"];k.prototype.toISOString=k.prototype.toISO=function(){var r=Ps.map(t,this).join(""),e=xs.map(t,this).join("");return"P"+r+"T"+e;function t(s){var n=this[s]||0;return s==="seconds"&&this.milliseconds&&(n=(n+this.milliseconds/1e3).toFixed(6).replace(/0+$/,"")),n+As[s]}};var be="([+-]?\\d+)",Ts=be+"\\s+years?",Ms=be+"\\s+mons?",Is=be+"\\s+days?",Rs="([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?",qs=new RegExp([Ts,Ms,Is,Rs].map(function(r){return"("+r+")?"}).join("\\s*")),Tt={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12},ks=["hours","minutes","seconds","milliseconds"];function Ls(r){var e=r+"000000".slice(r.length);return parseInt(e,10)/1e3}function Os(r){if(!r)return{};var e=qs.exec(r),t=e[8]==="-";return Object.keys(Tt).reduce(function(s,n){var i=Tt[n],o=e[i];return!o||(o=n==="milliseconds"?Ls(o):parseInt(o,10),!o)||(t&&~ks.indexOf(n)&&(o*=-1),s[n]=o),s},{})}});var kt=f((Mo,qt)=>{"use strict";var Rt=Buffer.from||Buffer;qt.exports=function(e){if(/^\\x/.test(e))return Rt(e.substr(2),"hex");for(var t="",s=0;s<e.length;)if(e[s]!=="\\")t+=e[s],++s;else if(/[0-7]{3}/.test(e.substr(s+1,3)))t+=String.fromCharCode(parseInt(e.substr(s+1,3),8)),s+=4;else{for(var n=1;s+n<e.length&&e[s+n]==="\\";)n++;for(var i=0;i<Math.floor(n/2);++i)t+="\\";s+=Math.floor(n/2)*2}return Rt(t,"binary")}});var Nt=f((Io,Ft)=>{"use strict";var H=_e(),G=we(),ee=At(),Ot=It(),Dt=kt();function te(r){return function(t){return t===null?t:r(t)}}function Bt(r){return r===null?r:r==="TRUE"||r==="t"||r==="true"||r==="y"||r==="yes"||r==="on"||r==="1"}function Ds(r){return r?H.parse(r,Bt):null}function Bs(r){return parseInt(r,10)}function ve(r){return r?H.parse(r,te(Bs)):null}function Qs(r){return r?H.parse(r,te(function(e){return Qt(e).trim()})):null}var Fs=function(r){if(!r)return null;var e=G.create(r,function(t){return t!==null&&(t=Pe(t)),t});return e.parse()},Ee=function(r){if(!r)return null;var e=G.create(r,function(t){return t!==null&&(t=parseFloat(t)),t});return e.parse()},A=function(r){if(!r)return null;var e=G.create(r);return e.parse()},Ce=function(r){if(!r)return null;var e=G.create(r,function(t){return t!==null&&(t=ee(t)),t});return e.parse()},Ns=function(r){if(!r)return null;var e=G.create(r,function(t){return t!==null&&(t=Ot(t)),t});return e.parse()},Us=function(r){return r?H.parse(r,te(Dt)):null},Ae=function(r){return parseInt(r,10)},Qt=function(r){var e=String(r);return/^\d+$/.test(e)?e:r},Lt=function(r){return r?H.parse(r,te(JSON.parse)):null},Pe=function(r){return r[0]!=="("?null:(r=r.substring(1,r.length-1).split(","),{x:parseFloat(r[0]),y:parseFloat(r[1])})},js=function(r){if(r[0]!=="<"&&r[1]!=="(")return null;for(var e="(",t="",s=!1,n=2;n<r.length-1;n++){if(s||(e+=r[n]),r[n]===")"){s=!0;continue}else if(!s)continue;r[n]!==","&&(t+=r[n])}var i=Pe(e);return i.radius=parseFloat(t),i},Hs=function(r){r(20,Qt),r(21,Ae),r(23,Ae),r(26,Ae),r(700,parseFloat),r(701,parseFloat),r(16,Bt),r(1082,ee),r(1114,ee),r(1184,ee),r(600,Pe),r(651,A),r(718,js),r(1e3,Ds),r(1001,Us),r(1005,ve),r(1007,ve),r(1028,ve),r(1016,Qs),r(1017,Fs),r(1021,Ee),r(1022,Ee),r(1231,Ee),r(1014,A),r(1015,A),r(1008,A),r(1009,A),r(1040,A),r(1041,A),r(1115,Ce),r(1182,Ce),r(1185,Ce),r(1186,Ot),r(1187,Ns),r(17,Dt),r(114,JSON.parse.bind(JSON)),r(3802,JSON.parse.bind(JSON)),r(199,Lt),r(3807,Lt),r(3907,A),r(2951,A),r(791,A),r(1183,A),r(1270,A)};Ft.exports={init:Hs}});var jt=f((Ro,Ut)=>{"use strict";var b=1e6;function Gs(r){var e=r.readInt32BE(0),t=r.readUInt32BE(4),s="";e<0&&(e=~e+(t===0),t=~t+1>>>0,s="-");var n="",i,o,a,u,c,h;{if(i=e%b,e=e/b>>>0,o=4294967296*i+t,t=o/b>>>0,a=""+(o-b*t),t===0&&e===0)return s+a+n;for(u="",c=6-a.length,h=0;h<c;h++)u+="0";n=u+a+n}{if(i=e%b,e=e/b>>>0,o=4294967296*i+t,t=o/b>>>0,a=""+(o-b*t),t===0&&e===0)return s+a+n;for(u="",c=6-a.length,h=0;h<c;h++)u+="0";n=u+a+n}{if(i=e%b,e=e/b>>>0,o=4294967296*i+t,t=o/b>>>0,a=""+(o-b*t),t===0&&e===0)return s+a+n;for(u="",c=6-a.length,h=0;h<c;h++)u+="0";n=u+a+n}return i=e%b,o=4294967296*i+t,a=""+o%b,s+a+n}Ut.exports=Gs});var Kt=f((qo,zt)=>{"use strict";var Vs=jt(),g=function(r,e,t,s,n){t=t||0,s=s||!1,n=n||function(E,me,ye){return E*Math.pow(2,ye)+me};var i=t>>3,o=function(E){return s?~E&255:E},a=255,u=8-t%8;e<u&&(a=255<<8-e&255,u=e),t&&(a=a>>t%8);var c=0;t%8+e>=8&&(c=n(0,o(r[i])&a,u));for(var h=e+t>>3,d=i+1;d<h;d++)c=n(c,o(r[d]),8);var p=(e+t)%8;return p>0&&(c=n(c,o(r[h])>>8-p,p)),c},Vt=function(r,e,t){var s=Math.pow(2,t-1)-1,n=g(r,1),i=g(r,t,1);if(i===0)return 0;var o=1,a=function(c,h,d){c===0&&(c=1);for(var p=1;p<=d;p++)o/=2,(h&1<<d-p)>0&&(c+=o);return c},u=g(r,e,t+1,!1,a);return i==Math.pow(2,t+1)-1?u===0?n===0?1/0:-1/0:NaN:(n===0?1:-1)*Math.pow(2,i-s)*u},zs=function(r){return g(r,1)==1?-1*(g(r,15,1,!0)+1):g(r,15,1)},Ht=function(r){return g(r,1)==1?-1*(g(r,31,1,!0)+1):g(r,31,1)},Ks=function(r){return Vt(r,23,8)},Ws=function(r){return Vt(r,52,11)},Ys=function(r){var e=g(r,16,32);if(e==49152)return NaN;for(var t=Math.pow(1e4,g(r,16,16)),s=0,n=[],i=g(r,16),o=0;o<i;o++)s+=g(r,16,64+16*o)*t,t/=1e4;var a=Math.pow(10,g(r,16,48));return(e===0?1:-1)*Math.round(s*a)/a},Gt=function(r,e){var t=g(e,1),s=g(e,63,1),n=new Date((t===0?1:-1)*s/1e3+9466848e5);return r||n.setTime(n.getTime()+n.getTimezoneOffset()*6e4),n.usec=s%1e3,n.getMicroSeconds=function(){return this.usec},n.setMicroSeconds=function(i){this.usec=i},n.getUTCMicroSeconds=function(){return this.usec},n},V=function(r){for(var e=g(r,32),t=g(r,32,32),s=g(r,32,64),n=96,i=[],o=0;o<e;o++)i[o]=g(r,32,n),n+=32,n+=32;var a=function(c){var h=g(r,32,n);if(n+=32,h==4294967295)return null;var d;if(c==23||c==20)return d=g(r,h*8,n),n+=h*8,d;if(c==25)return d=r.toString(this.encoding,n>>3,(n+=h<<3)>>3),d;console.log("ERROR: ElementType not implemented: "+c)},u=function(c,h){var d=[],p;if(c.length>1){var E=c.shift();for(p=0;p<E;p++)d[p]=u(c,h);c.unshift(E)}else for(p=0;p<c[0];p++)d[p]=a(h);return d};return u(i,s)},$s=function(r){return r.toString("utf8")},Zs=function(r){return r===null?null:g(r,8)>0},Js=function(r){r(20,Vs),r(21,zs),r(23,Ht),r(26,Ht),r(1700,Ys),r(700,Ks),r(701,Ws),r(16,Zs),r(1114,Gt.bind(null,!1)),r(1184,Gt.bind(null,!0)),r(1e3,V),r(1007,V),r(1016,V),r(1008,V),r(1009,V),r(25,$s)};zt.exports={init:Js}});var Yt=f((ko,Wt)=>{"use strict";Wt.exports={BOOL:16,BYTEA:17,CHAR:18,INT8:20,INT2:21,INT4:23,REGPROC:24,TEXT:25,OID:26,TID:27,XID:28,CID:29,JSON:114,XML:142,PG_NODE_TREE:194,SMGR:210,PATH:602,POLYGON:604,CIDR:650,FLOAT4:700,FLOAT8:701,ABSTIME:702,RELTIME:703,TINTERVAL:704,CIRCLE:718,MACADDR8:774,MONEY:790,MACADDR:829,INET:869,ACLITEM:1033,BPCHAR:1042,VARCHAR:1043,DATE:1082,TIME:1083,TIMESTAMP:1114,TIMESTAMPTZ:1184,INTERVAL:1186,TIMETZ:1266,BIT:1560,VARBIT:1562,NUMERIC:1700,REFCURSOR:1790,REGPROCEDURE:2202,REGOPER:2203,REGOPERATOR:2204,REGCLASS:2205,REGTYPE:2206,UUID:2950,TXID_SNAPSHOT:2970,PG_LSN:3220,PG_NDISTINCT:3361,PG_DEPENDENCIES:3402,TSVECTOR:3614,TSQUERY:3615,GTSVECTOR:3642,REGCONFIG:3734,REGDICTIONARY:3769,JSONB:3802,REGNAMESPACE:4089,REGROLE:4096}});var W=f(K=>{"use strict";var Xs=Nt(),en=Kt(),tn=we(),rn=Yt();K.getTypeParser=sn;K.setTypeParser=nn;K.arrayParser=tn;K.builtins=rn;var z={text:{},binary:{}};function $t(r){return String(r)}function sn(r,e){return e=e||"text",z[e]&&z[e][r]||$t}function nn(r,e,t){typeof e=="function"&&(t=e,e="text"),z[e][r]=t}Xs.init(function(r,e){z.text[r]=e});en.init(function(r,e){z.binary[r]=e})});var Y=f((Oo,xe)=>{"use strict";xe.exports={host:"localhost",user:process.platform==="win32"?process.env.USERNAME:process.env.USER,database:void 0,password:null,connectionString:void 0,port:5432,rows:0,binary:!1,max:10,idleTimeoutMillis:3e4,client_encoding:"",ssl:!1,application_name:void 0,fallback_application_name:void 0,options:void 0,parseInputDatesAsUTC:!1,statement_timeout:!1,lock_timeout:!1,idle_in_transaction_session_timeout:!1,query_timeout:!1,connect_timeout:0,keepalives:1,keepalives_idle:0};var L=W(),on=L.getTypeParser(20,"text"),an=L.getTypeParser(1016,"text");xe.exports.__defineSetter__("parseInt8",function(r){L.setTypeParser(20,"text",r?L.getTypeParser(23,"text"):on),L.setTypeParser(1016,"text",r?L.getTypeParser(1007,"text"):an)})});var O=f((Do,Xt)=>{"use strict";var un=Y(),Zt=m("util"),{isDate:cn}=Zt.types||Zt;function hn(r){return'"'+r.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'}function Jt(r){let e="{";for(let t=0;t<r.length;t++)if(t>0&&(e=e+","),r[t]===null||typeof r[t]>"u")e=e+"NULL";else if(Array.isArray(r[t]))e=e+Jt(r[t]);else if(ArrayBuffer.isView(r[t])){let s=r[t];if(!(s instanceof Buffer)){let n=Buffer.from(s.buffer,s.byteOffset,s.byteLength);n.length===s.byteLength?s=n:s=n.slice(s.byteOffset,s.byteOffset+s.byteLength)}e+="\\\\x"+s.toString("hex")}else e+=hn(re(r[t]));return e=e+"}",e}var re=function(r,e){if(r==null)return null;if(typeof r=="object"){if(r instanceof Buffer)return r;if(ArrayBuffer.isView(r)){let t=Buffer.from(r.buffer,r.byteOffset,r.byteLength);return t.length===r.byteLength?t:t.slice(r.byteOffset,r.byteOffset+r.byteLength)}return cn(r)?un.parseInputDatesAsUTC?dn(r):fn(r):Array.isArray(r)?Jt(r):ln(r,e)}return r.toString()};function ln(r,e){if(r&&typeof r.toPostgres=="function"){if(e=e||[],e.indexOf(r)!==-1)throw new Error('circular reference detected while preparing "'+r+'" for query');return e.push(r),re(r.toPostgres(re),e)}return JSON.stringify(r)}function fn(r){let e=-r.getTimezoneOffset(),t=r.getFullYear(),s=t<1;s&&(t=Math.abs(t)+1);let n=String(t).padStart(4,"0")+"-"+String(r.getMonth()+1).padStart(2,"0")+"-"+String(r.getDate()).padStart(2,"0")+"T"+String(r.getHours()).padStart(2,"0")+":"+String(r.getMinutes()).padStart(2,"0")+":"+String(r.getSeconds()).padStart(2,"0")+"."+String(r.getMilliseconds()).padStart(3,"0");return e<0?(n+="-",e*=-1):n+="+",n+=String(Math.floor(e/60)).padStart(2,"0")+":"+String(e%60).padStart(2,"0"),s&&(n+=" BC"),n}function dn(r){let e=r.getUTCFullYear(),t=e<1;t&&(e=Math.abs(e)+1);let s=String(e).padStart(4,"0")+"-"+String(r.getUTCMonth()+1).padStart(2,"0")+"-"+String(r.getUTCDate()).padStart(2,"0")+"T"+String(r.getUTCHours()).padStart(2,"0")+":"+String(r.getUTCMinutes()).padStart(2,"0")+":"+String(r.getUTCSeconds()).padStart(2,"0")+"."+String(r.getUTCMilliseconds()).padStart(3,"0");return s+="+00:00",t&&(s+=" BC"),s}function pn(r,e,t){return r=typeof r=="string"?{text:r}:r,e&&(typeof e=="function"?r.callback=e:r.values=e),t&&(r.callback=t),r}var mn=function(r){return'"'+r.replace(/"/g,'""')+'"'},yn=function(r){let e=!1,t="'";if(r==null||typeof r!="string")return"''";for(let s=0;s<r.length;s++){let n=r[s];n==="'"?t+=n+n:n==="\\"?(t+=n+n,e=!0):t+=n}return t+="'",e===!0&&(t=" E"+t),t};Xt.exports={prepareValue:function(e){return re(e)},normalizeQueryConfig:pn,escapeIdentifier:mn,escapeLiteral:yn}});var tr=f((Bo,er)=>{"use strict";var D=m("crypto");function Te(r){return D.createHash("md5").update(r,"utf-8").digest("hex")}function gn(r,e,t){let s=Te(e+r);return"md5"+Te(Buffer.concat([Buffer.from(s),t]))}function _n(r){return D.createHash("sha256").update(r).digest()}function wn(r,e){return r=r.replace(/(\D)-/,"$1"),D.createHash(r).update(e).digest()}function Sn(r,e){return D.createHmac("sha256",r).update(e).digest()}async function bn(r,e,t){return D.pbkdf2Sync(r,e,t,32,"sha256")}er.exports={postgresMd5PasswordHash:gn,randomBytes:D.randomBytes,deriveKey:bn,sha256:_n,hashByName:wn,hmacSha256:Sn,md5:Te}});var ir=f((Qo,nr)=>{"use strict";var rr=m("crypto");nr.exports={postgresMd5PasswordHash:En,randomBytes:vn,deriveKey:xn,sha256:Cn,hashByName:An,hmacSha256:Pn,md5:Me};var sr=rr.webcrypto||globalThis.crypto,R=sr.subtle,Ie=new TextEncoder;function vn(r){return sr.getRandomValues(Buffer.alloc(r))}async function Me(r){try{return rr.createHash("md5").update(r,"utf-8").digest("hex")}catch{let t=typeof r=="string"?Ie.encode(r):r,s=await R.digest("MD5",t);return Array.from(new Uint8Array(s)).map(n=>n.toString(16).padStart(2,"0")).join("")}}async function En(r,e,t){let s=await Me(e+r);return"md5"+await Me(Buffer.concat([Buffer.from(s),t]))}async function Cn(r){return await R.digest("SHA-256",r)}async function An(r,e){return await R.digest(r,e)}async function Pn(r,e){let t=await R.importKey("raw",r,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return await R.sign("HMAC",t,Ie.encode(e))}async function xn(r,e,t){let s=await R.importKey("raw",Ie.encode(r),"PBKDF2",!1,["deriveBits"]),n={name:"PBKDF2",hash:"SHA-256",salt:e,iterations:t};return await R.deriveBits(n,s,256,["deriveBits"])}});var qe=f((Fo,Re)=>{"use strict";var Tn=parseInt(process.versions&&process.versions.node&&process.versions.node.split(".")[0])<15;Tn?Re.exports=tr():Re.exports=ir()});var ur=f((No,ar)=>{"use strict";function q(r,e){return new Error("SASL channel binding: "+r+" when parsing public certificate "+e.toString("base64"))}function ke(r,e){let t=r[e++];if(t<128)return{length:t,index:e};let s=t&127;if(s>4)throw q("bad length",r);t=0;for(let n=0;n<s;n++)t=t<<8|r[e++];return{length:t,index:e}}function or(r,e){if(r[e++]!==6)throw q("non-OID data",r);let{length:t,index:s}=ke(r,e);e=s;let n=e+t,i=r[e++],o=(i/40>>0)+"."+i%40;for(;e<n;){let a=0;for(;e<n;){let u=r[e++];if(a=a<<7|u&127,u<128)break}o+="."+a}return{oid:o,index:e}}function $(r,e){if(r[e++]!==48)throw q("non-sequence data",r);return ke(r,e)}function Mn(r,e){e===void 0&&(e=0),e=$(r,e).index;let{length:t,index:s}=$(r,e);e=s+t,e=$(r,e).index;let{oid:n,index:i}=or(r,e);switch(n){case"1.2.840.113549.1.1.4":return"MD5";case"1.2.840.113549.1.1.5":return"SHA-1";case"1.2.840.113549.1.1.11":return"SHA-256";case"1.2.840.113549.1.1.12":return"SHA-384";case"1.2.840.113549.1.1.13":return"SHA-512";case"1.2.840.113549.1.1.14":return"SHA-224";case"1.2.840.113549.1.1.15":return"SHA512-224";case"1.2.840.113549.1.1.16":return"SHA512-256";case"1.2.840.10045.4.1":return"SHA-1";case"1.2.840.10045.4.3.1":return"SHA-224";case"1.2.840.10045.4.3.2":return"SHA-256";case"1.2.840.10045.4.3.3":return"SHA-384";case"1.2.840.10045.4.3.4":return"SHA-512";case"1.2.840.113549.1.1.10":{if(e=i,e=$(r,e).index,r[e++]!==160)throw q("non-tag data",r);e=ke(r,e).index,e=$(r,e).index;let{oid:o}=or(r,e);switch(o){case"1.2.840.113549.2.5":return"MD5";case"1.3.14.3.2.26":return"SHA-1";case"2.16.840.1.101.3.4.2.1":return"SHA-256";case"2.16.840.1.101.3.4.2.2":return"SHA-384";case"2.16.840.1.101.3.4.2.3":return"SHA-512"}throw q("unknown hash OID "+o,r)}case"1.3.101.110":case"1.3.101.112":return"SHA-512";case"1.3.101.111":case"1.3.101.113":throw q("Ed448 certificate channel binding is not currently supported by Postgres")}throw q("unknown OID "+n,r)}ar.exports={signatureAlgorithmHashFromCertificate:Mn}});var fr=f((Uo,lr)=>{"use strict";var T=qe(),{signatureAlgorithmHashFromCertificate:In}=ur();function Rn(r,e){let t=["SCRAM-SHA-256"];e&&t.unshift("SCRAM-SHA-256-PLUS");let s=t.find(o=>r.includes(o));if(!s)throw new Error("SASL: Only mechanism(s) "+t.join(" and ")+" are supported");if(s==="SCRAM-SHA-256-PLUS"&&typeof e.getPeerCertificate!="function")throw new Error("SASL: Mechanism SCRAM-SHA-256-PLUS requires a certificate");let n=T.randomBytes(18).toString("base64");return{mechanism:s,clientNonce:n,response:(s==="SCRAM-SHA-256-PLUS"?"p=tls-server-end-point":e?"y":"n")+",,n=*,r="+n,message:"SASLInitialResponse"}}async function qn(r,e,t,s){if(r.message!=="SASLInitialResponse")throw new Error("SASL: Last message was not SASLInitialResponse");if(typeof e!="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string");if(e==="")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string");if(typeof t!="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");let n=On(t);if(n.nonce.startsWith(r.clientNonce)){if(n.nonce.length===r.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");let i="n=*,r="+r.clientNonce,o="r="+n.nonce+",s="+n.salt+",i="+n.iteration,a=s?"eSws":"biws";if(r.mechanism==="SCRAM-SHA-256-PLUS"){let St=s.getPeerCertificate().raw,X=In(St);(X==="MD5"||X==="SHA-1")&&(X="SHA-256");let ls=await T.hashByName(X,St);a=Buffer.concat([Buffer.from("p=tls-server-end-point,,"),Buffer.from(ls)]).toString("base64")}let u="c="+a+",r="+n.nonce,c=i+","+o+","+u,h=Buffer.from(n.salt,"base64"),d=await T.deriveKey(e,h,n.iteration),p=await T.hmacSha256(d,"Client Key"),E=await T.sha256(p),me=await T.hmacSha256(E,c),ye=Bn(Buffer.from(p),Buffer.from(me)).toString("base64"),cs=await T.hmacSha256(d,"Server Key"),hs=await T.hmacSha256(cs,c);r.message="SASLResponse",r.serverSignature=Buffer.from(hs).toString("base64"),r.response=u+",p="+ye}function kn(r,e){if(r.message!=="SASLResponse")throw new Error("SASL: Last message was not SASLResponse");if(typeof e!="string")throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string");let{serverSignature:t}=Dn(e);if(t!==r.serverSignature)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does not match")}function Ln(r){if(typeof r!="string")throw new TypeError("SASL: text must be a string");return r.split("").map((e,t)=>r.charCodeAt(t)).every(e=>e>=33&&e<=43||e>=45&&e<=126)}function cr(r){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test(r)}function hr(r){if(typeof r!="string")throw new TypeError("SASL: attribute pairs text must be a string");return new Map(r.split(",").map(e=>{if(!/^.=/.test(e))throw new Error("SASL: Invalid attribute pair entry");let t=e[0],s=e.substring(2);return[t,s]}))}function On(r){let e=hr(r),t=e.get("r");if(t){if(!Ln(t))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing");let s=e.get("s");if(s){if(!cr(s))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt must be base64")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing");let n=e.get("i");if(n){if(!/^[1-9][0-9]*$/.test(n))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing");let i=parseInt(n,10);return{nonce:t,salt:s,iteration:i}}function Dn(r){let t=hr(r).get("v");if(t){if(!cr(t))throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64")}else throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");return{serverSignature:t}}function Bn(r,e){if(!Buffer.isBuffer(r))throw new TypeError("first argument must be a Buffer");if(!Buffer.isBuffer(e))throw new TypeError("second argument must be a Buffer");if(r.length!==e.length)throw new Error("Buffer lengths must match");if(r.length===0)throw new Error("Buffers cannot be empty");return Buffer.from(r.map((t,s)=>r[s]^e[s]))}lr.exports={startSession:Rn,continueSession:qn,finalizeSession:kn}});var ne=f((jo,dr)=>{"use strict";var Qn=W();function se(r){this._types=r||Qn,this.text={},this.binary={}}se.prototype.getOverrides=function(r){switch(r){case"text":return this.text;case"binary":return this.binary;default:return{}}};se.prototype.setTypeParser=function(r,e,t){typeof e=="function"&&(t=e,e="text"),this.getOverrides(e)[r]=t};se.prototype.getTypeParser=function(r,e){return e=e||"text",this.getOverrides(e)[r]||this._types.getTypeParser(r,e)};dr.exports=se});var yr=f((Ho,mr)=>{"use strict";function B(r,e={}){if(r.charAt(0)==="/"){let u=r.split(" ");return{host:u[0],database:u[1]}}let t={},s,n=!1;/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(r)&&(r=encodeURI(r).replace(/%25(\d\d)/g,"%$1"));try{try{s=new URL(r,"postgres://base")}catch{s=new URL(r.replace("@/","@___DUMMY___/"),"postgres://base"),n=!0}}catch(u){u.input&&(u.input="*****REDACTED*****")}for(let u of s.searchParams.entries())t[u[0]]=u[1];if(t.user=t.user||decodeURIComponent(s.username),t.password=t.password||decodeURIComponent(s.password),s.protocol=="socket:")return t.host=decodeURI(s.pathname),t.database=s.searchParams.get("db"),t.client_encoding=s.searchParams.get("encoding"),t;let i=n?"":s.hostname;t.host?i&&/^%2f/i.test(i)&&(s.pathname=i+s.pathname):t.host=decodeURIComponent(i),t.port||(t.port=s.port);let o=s.pathname.slice(1)||null;t.database=o?decodeURI(o):null,(t.ssl==="true"||t.ssl==="1")&&(t.ssl=!0),t.ssl==="0"&&(t.ssl=!1),(t.sslcert||t.sslkey||t.sslrootcert||t.sslmode)&&(t.ssl={});let a=t.sslcert||t.sslkey||t.sslrootcert?m("fs"):null;if(t.sslcert&&(t.ssl.cert=a.readFileSync(t.sslcert).toString()),t.sslkey&&(t.ssl.key=a.readFileSync(t.sslkey).toString()),t.sslrootcert&&(t.ssl.ca=a.readFileSync(t.sslrootcert).toString()),e.useLibpqCompat&&t.uselibpqcompat)throw new Error("Both useLibpqCompat and uselibpqcompat are set. Please use only one of them.");if(t.uselibpqcompat==="true"||e.useLibpqCompat)switch(t.sslmode){case"disable":{t.ssl=!1;break}case"prefer":{t.ssl.rejectUnauthorized=!1;break}case"require":{t.sslrootcert?t.ssl.checkServerIdentity=function(){}:t.ssl.rejectUnauthorized=!1;break}case"verify-ca":{if(!t.ssl.ca)throw new Error("SECURITY WARNING: Using sslmode=verify-ca requires specifying a CA with sslrootcert. If a public CA is used, verify-ca allows connections to a server that somebody else may have registered with the CA, making you vulnerable to Man-in-the-Middle attacks. Either specify a custom CA certificate with sslrootcert parameter or use sslmode=verify-full for proper security.");t.ssl.checkServerIdentity=function(){};break}case"verify-full":break}else switch(t.sslmode){case"disable":{t.ssl=!1;break}case"prefer":case"require":case"verify-ca":case"verify-full":break;case"no-verify":{t.ssl.rejectUnauthorized=!1;break}}return t}function Fn(r){return Object.entries(r).reduce((t,[s,n])=>(n!=null&&(t[s]=n),t),{})}function pr(r){return Object.entries(r).reduce((t,[s,n])=>{if(s==="ssl"){let i=n;typeof i=="boolean"&&(t[s]=i),typeof i=="object"&&(t[s]=Fn(i))}else if(n!=null)if(s==="port"){if(n!==""){let i=parseInt(n,10);if(isNaN(i))throw new Error(`Invalid ${s}: ${n}`);t[s]=i}}else t[s]=n;return t},{})}function Nn(r){return pr(B(r))}mr.exports=B;B.parse=B;B.toClientConfig=pr;B.parseIntoClientConfig=Nn});var Oe=f((Go,wr)=>{"use strict";var Un=m("dns"),_r=Y(),gr=yr().parse,S=function(r,e,t){return t===void 0?t=process.env["PG"+r.toUpperCase()]:t===!1||(t=process.env[t]),e[r]||t||_r[r]},jn=function(){switch(process.env.PGSSLMODE){case"disable":return!1;case"prefer":case"require":case"verify-ca":case"verify-full":return!0;case"no-verify":return{rejectUnauthorized:!1}}return _r.ssl},Q=function(r){return"'"+(""+r).replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"},P=function(r,e,t){let s=e[t];s!=null&&r.push(t+"="+Q(s))},Le=class{constructor(e){e=typeof e=="string"?gr(e):e||{},e.connectionString&&(e=Object.assign({},e,gr(e.connectionString))),this.user=S("user",e),this.database=S("database",e),this.database===void 0&&(this.database=this.user),this.port=parseInt(S("port",e),10),this.host=S("host",e),Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:S("password",e)}),this.binary=S("binary",e),this.options=S("options",e),this.ssl=typeof e.ssl>"u"?jn():e.ssl,typeof this.ssl=="string"&&this.ssl==="true"&&(this.ssl=!0),this.ssl==="no-verify"&&(this.ssl={rejectUnauthorized:!1}),this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,"key",{enumerable:!1}),this.client_encoding=S("client_encoding",e),this.replication=S("replication",e),this.isDomainSocket=!(this.host||"").indexOf("/"),this.application_name=S("application_name",e,"PGAPPNAME"),this.fallback_application_name=S("fallback_application_name",e,!1),this.statement_timeout=S("statement_timeout",e,!1),this.lock_timeout=S("lock_timeout",e,!1),this.idle_in_transaction_session_timeout=S("idle_in_transaction_session_timeout",e,!1),this.query_timeout=S("query_timeout",e,!1),e.connectionTimeoutMillis===void 0?this.connect_timeout=process.env.PGCONNECT_TIMEOUT||0:this.connect_timeout=Math.floor(e.connectionTimeoutMillis/1e3),e.keepAlive===!1?this.keepalives=0:e.keepAlive===!0&&(this.keepalives=1),typeof e.keepAliveInitialDelayMillis=="number"&&(this.keepalives_idle=Math.floor(e.keepAliveInitialDelayMillis/1e3))}getLibpqConnectionString(e){let t=[];P(t,this,"user"),P(t,this,"password"),P(t,this,"port"),P(t,this,"application_name"),P(t,this,"fallback_application_name"),P(t,this,"connect_timeout"),P(t,this,"options");let s=typeof this.ssl=="object"?this.ssl:this.ssl?{sslmode:this.ssl}:{};if(P(t,s,"sslmode"),P(t,s,"sslca"),P(t,s,"sslkey"),P(t,s,"sslcert"),P(t,s,"sslrootcert"),this.database&&t.push("dbname="+Q(this.database)),this.replication&&t.push("replication="+Q(this.replication)),this.host&&t.push("host="+Q(this.host)),this.isDomainSocket)return e(null,t.join(" "));this.client_encoding&&t.push("client_encoding="+Q(this.client_encoding)),Un.lookup(this.host,function(n,i){return n?e(n,null):(t.push("hostaddr="+Q(i)),e(null,t.join(" ")))})}};wr.exports=Le});var Be=f((Vo,br)=>{"use strict";var Hn=W(),Sr=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/,De=class{constructor(e,t){this.command=null,this.rowCount=null,this.oid=null,this.rows=[],this.fields=[],this._parsers=void 0,this._types=t,this.RowCtor=null,this.rowAsArray=e==="array",this.rowAsArray&&(this.parseRow=this._parseRowAsArray),this._prebuiltEmptyResultObject=null}addCommandComplete(e){let t;e.text?t=Sr.exec(e.text):t=Sr.exec(e.command),t&&(this.command=t[1],t[3]?(this.oid=parseInt(t[2],10),this.rowCount=parseInt(t[3],10)):t[2]&&(this.rowCount=parseInt(t[2],10)))}_parseRowAsArray(e){let t=new Array(e.length);for(let s=0,n=e.length;s<n;s++){let i=e[s];i!==null?t[s]=this._parsers[s](i):t[s]=null}return t}parseRow(e){let t={...this._prebuiltEmptyResultObject};for(let s=0,n=e.length;s<n;s++){let i=e[s],o=this.fields[s].name;if(i!==null){let a=this.fields[s].format==="binary"?Buffer.from(i):i;t[o]=this._parsers[s](a)}else t[o]=null}return t}addRow(e){this.rows.push(e)}addFields(e){this.fields=e,this.fields.length&&(this._parsers=new Array(e.length));let t={};for(let s=0;s<e.length;s++){let n=e[s];t[n.name]=null,this._types?this._parsers[s]=this._types.getTypeParser(n.dataTypeID,n.format||"text"):this._parsers[s]=Hn.getTypeParser(n.dataTypeID,n.format||"text")}this._prebuiltEmptyResultObject={...t}}};br.exports=De});var Ar=f((zo,Cr)=>{"use strict";var{EventEmitter:Gn}=m("events"),vr=Be(),Er=O(),Qe=class extends Gn{constructor(e,t,s){super(),e=Er.normalizeQueryConfig(e,t,s),this.text=e.text,this.values=e.values,this.rows=e.rows,this.types=e.types,this.name=e.name,this.queryMode=e.queryMode,this.binary=e.binary,this.portal=e.portal||"",this.callback=e.callback,this._rowMode=e.rowMode,process.domain&&e.callback&&(this.callback=process.domain.bind(e.callback)),this._result=new vr(this._rowMode,this.types),this._results=this._result,this._canceledDueToError=!1}requiresPreparation(){return this.queryMode==="extended"||this.name||this.rows?!0:!this.text||!this.values?!1:this.values.length>0}_checkForMultirow(){this._result.command&&(Array.isArray(this._results)||(this._results=[this._result]),this._result=new vr(this._rowMode,this._result._types),this._results.push(this._result))}handleRowDescription(e){this._checkForMultirow(),this._result.addFields(e.fields),this._accumulateRows=this.callback||!this.listeners("row").length}handleDataRow(e){let t;if(!this._canceledDueToError){try{t=this._result.parseRow(e.fields)}catch(s){this._canceledDueToError=s;return}this.emit("row",t,this._result),this._accumulateRows&&this._result.addRow(t)}}handleCommandComplete(e,t){this._checkForMultirow(),this._result.addCommandComplete(e),this.rows&&t.sync()}handleEmptyQuery(e){this.rows&&e.sync()}handleError(e,t){if(this._canceledDueToError&&(e=this._canceledDueToError,this._canceledDueToError=!1),this.callback)return this.callback(e);this.emit("error",e)}handleReadyForQuery(e){if(this._canceledDueToError)return this.handleError(this._canceledDueToError,e);if(this.callback)try{this.callback(null,this._results)}catch(t){process.nextTick(()=>{throw t})}this.emit("end",this._results)}submit(e){if(typeof this.text!="string"&&typeof this.name!="string")return new Error("A query must have either text or a name. Supplying neither is unsupported.");let t=e.parsedStatements[this.name];if(this.text&&t&&this.text!==t)return new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);if(this.values&&!Array.isArray(this.values))return new Error("Query values must be an array");if(this.requiresPreparation()){e.stream.cork&&e.stream.cork();try{this.prepare(e)}finally{e.stream.uncork&&e.stream.uncork()}}else e.query(this.text);return null}hasBeenParsed(e){return this.name&&e.parsedStatements[this.name]}handlePortalSuspended(e){this._getRows(e,this.rows)}_getRows(e,t){e.execute({portal:this.portal,rows:t}),t?e.flush():e.sync()}prepare(e){this.hasBeenParsed(e)||e.parse({text:this.text,name:this.name,types:this.types});try{e.bind({portal:this.portal,statement:this.name,values:this.values,binary:this.binary,valueMapper:Er.prepareValue})}catch(t){this.handleError(t,e);return}e.describe({type:"P",name:this.portal||""}),this._getRows(e,this.rows)}handleCopyInResponse(e){e.sendCopyFail("No source stream defined")}handleCopyData(e,t){}};Cr.exports=Qe});var Xe=f(l=>{"use strict";Object.defineProperty(l,"__esModule",{value:!0});l.NoticeMessage=l.DataRowMessage=l.CommandCompleteMessage=l.ReadyForQueryMessage=l.NotificationResponseMessage=l.BackendKeyDataMessage=l.AuthenticationMD5Password=l.ParameterStatusMessage=l.ParameterDescriptionMessage=l.RowDescriptionMessage=l.Field=l.CopyResponse=l.CopyDataMessage=l.DatabaseError=l.copyDone=l.emptyQuery=l.replicationStart=l.portalSuspended=l.noData=l.closeComplete=l.bindComplete=l.parseComplete=void 0;l.parseComplete={name:"parseComplete",length:5};l.bindComplete={name:"bindComplete",length:5};l.closeComplete={name:"closeComplete",length:5};l.noData={name:"noData",length:5};l.portalSuspended={name:"portalSuspended",length:5};l.replicationStart={name:"replicationStart",length:4};l.emptyQuery={name:"emptyQuery",length:4};l.copyDone={name:"copyDone",length:4};var Fe=class extends Error{constructor(e,t,s){super(e),this.length=t,this.name=s}};l.DatabaseError=Fe;var Ne=class{constructor(e,t){this.length=e,this.chunk=t,this.name="copyData"}};l.CopyDataMessage=Ne;var Ue=class{constructor(e,t,s,n){this.length=e,this.name=t,this.binary=s,this.columnTypes=new Array(n)}};l.CopyResponse=Ue;var je=class{constructor(e,t,s,n,i,o,a){this.name=e,this.tableID=t,this.columnID=s,this.dataTypeID=n,this.dataTypeSize=i,this.dataTypeModifier=o,this.format=a}};l.Field=je;var He=class{constructor(e,t){this.length=e,this.fieldCount=t,this.name="rowDescription",this.fields=new Array(this.fieldCount)}};l.RowDescriptionMessage=He;var Ge=class{constructor(e,t){this.length=e,this.parameterCount=t,this.name="parameterDescription",this.dataTypeIDs=new Array(this.parameterCount)}};l.ParameterDescriptionMessage=Ge;var Ve=class{constructor(e,t,s){this.length=e,this.parameterName=t,this.parameterValue=s,this.name="parameterStatus"}};l.ParameterStatusMessage=Ve;var ze=class{constructor(e,t){this.length=e,this.salt=t,this.name="authenticationMD5Password"}};l.AuthenticationMD5Password=ze;var Ke=class{constructor(e,t,s){this.length=e,this.processID=t,this.secretKey=s,this.name="backendKeyData"}};l.BackendKeyDataMessage=Ke;var We=class{constructor(e,t,s,n){this.length=e,this.processId=t,this.channel=s,this.payload=n,this.name="notification"}};l.NotificationResponseMessage=We;var Ye=class{constructor(e,t){this.length=e,this.status=t,this.name="readyForQuery"}};l.ReadyForQueryMessage=Ye;var $e=class{constructor(e,t){this.length=e,this.text=t,this.name="commandComplete"}};l.CommandCompleteMessage=$e;var Ze=class{constructor(e,t){this.length=e,this.fields=t,this.name="dataRow",this.fieldCount=t.length}};l.DataRowMessage=Ze;var Je=class{constructor(e,t){this.length=e,this.message=t,this.name="notice"}};l.NoticeMessage=Je});var Pr=f(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.Writer=void 0;var et=class{constructor(e=256){this.size=e,this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(e)}ensure(e){if(this.buffer.length-this.offset<e){let s=this.buffer,n=s.length+(s.length>>1)+e;this.buffer=Buffer.allocUnsafe(n),s.copy(this.buffer)}}addInt32(e){return this.ensure(4),this.buffer[this.offset++]=e>>>24&255,this.buffer[this.offset++]=e>>>16&255,this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addInt16(e){return this.ensure(2),this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addCString(e){if(!e)this.ensure(1);else{let t=Buffer.byteLength(e);this.ensure(t+1),this.buffer.write(e,this.offset,"utf-8"),this.offset+=t}return this.buffer[this.offset++]=0,this}addString(e=""){let t=Buffer.byteLength(e);return this.ensure(t),this.buffer.write(e,this.offset),this.offset+=t,this}add(e){return this.ensure(e.length),e.copy(this.buffer,this.offset),this.offset+=e.length,this}join(e){if(e){this.buffer[this.headerPosition]=e;let t=this.offset-(this.headerPosition+1);this.buffer.writeInt32BE(t,this.headerPosition+1)}return this.buffer.slice(e?0:5,this.offset)}flush(e){let t=this.join(e);return this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(this.size),t}};ie.Writer=et});var Tr=f(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});ae.serialize=void 0;var tt=Pr(),y=new tt.Writer,Vn=r=>{y.addInt16(3).addInt16(0);for(let s of Object.keys(r))y.addCString(s).addCString(r[s]);y.addCString("client_encoding").addCString("UTF8");let e=y.addCString("").flush(),t=e.length+4;return new tt.Writer().addInt32(t).add(e).flush()},zn=()=>{let r=Buffer.allocUnsafe(8);return r.writeInt32BE(8,0),r.writeInt32BE(80877103,4),r},Kn=r=>y.addCString(r).flush(112),Wn=function(r,e){return y.addCString(r).addInt32(Buffer.byteLength(e)).addString(e),y.flush(112)},Yn=function(r){return y.addString(r).flush(112)},$n=r=>y.addCString(r).flush(81),xr=[],Zn=r=>{let e=r.name||"";e.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",e,e.length),console.error("This can cause conflicts and silent errors executing queries"));let t=r.types||xr,s=t.length,n=y.addCString(e).addCString(r.text).addInt16(s);for(let i=0;i<s;i++)n.addInt32(t[i]);return y.flush(80)},F=new tt.Writer,Jn=function(r,e){for(let t=0;t<r.length;t++){let s=e?e(r[t],t):r[t];s==null?(y.addInt16(0),F.addInt32(-1)):s instanceof Buffer?(y.addInt16(1),F.addInt32(s.length),F.add(s)):(y.addInt16(0),F.addInt32(Buffer.byteLength(s)),F.addString(s))}},Xn=(r={})=>{let e=r.portal||"",t=r.statement||"",s=r.binary||!1,n=r.values||xr,i=n.length;return y.addCString(e).addCString(t),y.addInt16(i),Jn(n,r.valueMapper),y.addInt16(i),y.add(F.flush()),y.addInt16(1),y.addInt16(s?1:0),y.flush(66)},ei=Buffer.from([69,0,0,0,9,0,0,0,0,0]),ti=r=>{if(!r||!r.portal&&!r.rows)return ei;let e=r.portal||"",t=r.rows||0,s=Buffer.byteLength(e),n=4+s+1+4,i=Buffer.allocUnsafe(1+n);return i[0]=69,i.writeInt32BE(n,1),i.write(e,5,"utf-8"),i[s+5]=0,i.writeUInt32BE(t,i.length-4),i},ri=(r,e)=>{let t=Buffer.allocUnsafe(16);return t.writeInt32BE(16,0),t.writeInt16BE(1234,4),t.writeInt16BE(5678,6),t.writeInt32BE(r,8),t.writeInt32BE(e,12),t},rt=(r,e)=>{let s=4+Buffer.byteLength(e)+1,n=Buffer.allocUnsafe(1+s);return n[0]=r,n.writeInt32BE(s,1),n.write(e,5,"utf-8"),n[s]=0,n},si=y.addCString("P").flush(68),ni=y.addCString("S").flush(68),ii=r=>r.name?rt(68,`${r.type}${r.name||""}`):r.type==="P"?si:ni,oi=r=>{let e=`${r.type}${r.name||""}`;return rt(67,e)},ai=r=>y.add(r).flush(100),ui=r=>rt(102,r),oe=r=>Buffer.from([r,0,0,0,4]),ci=oe(72),hi=oe(83),li=oe(88),fi=oe(99),di={startup:Vn,password:Kn,requestSsl:zn,sendSASLInitialResponseMessage:Wn,sendSCRAMClientFinalMessage:Yn,query:$n,parse:Zn,bind:Xn,execute:ti,describe:ii,close:oi,flush:()=>ci,sync:()=>hi,end:()=>li,copyData:ai,copyDone:()=>fi,copyFail:ui,cancel:ri};ae.serialize=di});var Mr=f(ue=>{"use strict";Object.defineProperty(ue,"__esModule",{value:!0});ue.BufferReader=void 0;var pi=Buffer.allocUnsafe(0),st=class{constructor(e=0){this.offset=e,this.buffer=pi,this.encoding="utf-8"}setBuffer(e,t){this.offset=e,this.buffer=t}int16(){let e=this.buffer.readInt16BE(this.offset);return this.offset+=2,e}byte(){let e=this.buffer[this.offset];return this.offset++,e}int32(){let e=this.buffer.readInt32BE(this.offset);return this.offset+=4,e}uint32(){let e=this.buffer.readUInt32BE(this.offset);return this.offset+=4,e}string(e){let t=this.buffer.toString(this.encoding,this.offset,this.offset+e);return this.offset+=e,t}cstring(){let e=this.offset,t=e;for(;this.buffer[t++]!==0;);return this.offset=t,this.buffer.toString(this.encoding,e,t-1)}bytes(e){let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}};ue.BufferReader=st});var qr=f(ce=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});ce.Parser=void 0;var _=Xe(),mi=Mr(),nt=1,yi=4,Ir=nt+yi,Rr=Buffer.allocUnsafe(0),it=class{constructor(e){if(this.buffer=Rr,this.bufferLength=0,this.bufferOffset=0,this.reader=new mi.BufferReader,e?.mode==="binary")throw new Error("Binary mode not supported yet");this.mode=e?.mode||"text"}parse(e,t){this.mergeBuffer(e);let s=this.bufferOffset+this.bufferLength,n=this.bufferOffset;for(;n+Ir<=s;){let i=this.buffer[n],o=this.buffer.readUInt32BE(n+nt),a=nt+o;if(a+n<=s){let u=this.handlePacket(n+Ir,i,o,this.buffer);t(u),n+=a}else break}n===s?(this.buffer=Rr,this.bufferLength=0,this.bufferOffset=0):(this.bufferLength=s-n,this.bufferOffset=n)}mergeBuffer(e){if(this.bufferLength>0){let t=this.bufferLength+e.byteLength;if(t+this.bufferOffset>this.buffer.byteLength){let n;if(t<=this.buffer.byteLength&&this.bufferOffset>=this.bufferLength)n=this.buffer;else{let i=this.buffer.byteLength*2;for(;t>=i;)i*=2;n=Buffer.allocUnsafe(i)}this.buffer.copy(n,0,this.bufferOffset,this.bufferOffset+this.bufferLength),this.buffer=n,this.bufferOffset=0}e.copy(this.buffer,this.bufferOffset+this.bufferLength),this.bufferLength=t}else this.buffer=e,this.bufferOffset=0,this.bufferLength=e.byteLength}handlePacket(e,t,s,n){switch(t){case 50:return _.bindComplete;case 49:return _.parseComplete;case 51:return _.closeComplete;case 110:return _.noData;case 115:return _.portalSuspended;case 99:return _.copyDone;case 87:return _.replicationStart;case 73:return _.emptyQuery;case 68:return this.parseDataRowMessage(e,s,n);case 67:return this.parseCommandCompleteMessage(e,s,n);case 90:return this.parseReadyForQueryMessage(e,s,n);case 65:return this.parseNotificationMessage(e,s,n);case 82:return this.parseAuthenticationResponse(e,s,n);case 83:return this.parseParameterStatusMessage(e,s,n);case 75:return this.parseBackendKeyData(e,s,n);case 69:return this.parseErrorMessage(e,s,n,"error");case 78:return this.parseErrorMessage(e,s,n,"notice");case 84:return this.parseRowDescriptionMessage(e,s,n);case 116:return this.parseParameterDescriptionMessage(e,s,n);case 71:return this.parseCopyInMessage(e,s,n);case 72:return this.parseCopyOutMessage(e,s,n);case 100:return this.parseCopyData(e,s,n);default:return new _.DatabaseError("received invalid response: "+t.toString(16),s,"error")}}parseReadyForQueryMessage(e,t,s){this.reader.setBuffer(e,s);let n=this.reader.string(1);return new _.ReadyForQueryMessage(t,n)}parseCommandCompleteMessage(e,t,s){this.reader.setBuffer(e,s);let n=this.reader.cstring();return new _.CommandCompleteMessage(t,n)}parseCopyData(e,t,s){let n=s.slice(e,e+(t-4));return new _.CopyDataMessage(t,n)}parseCopyInMessage(e,t,s){return this.parseCopyMessage(e,t,s,"copyInResponse")}parseCopyOutMessage(e,t,s){return this.parseCopyMessage(e,t,s,"copyOutResponse")}parseCopyMessage(e,t,s,n){this.reader.setBuffer(e,s);let i=this.reader.byte()!==0,o=this.reader.int16(),a=new _.CopyResponse(t,n,i,o);for(let u=0;u<o;u++)a.columnTypes[u]=this.reader.int16();return a}parseNotificationMessage(e,t,s){this.reader.setBuffer(e,s);let n=this.reader.int32(),i=this.reader.cstring(),o=this.reader.cstring();return new _.NotificationResponseMessage(t,n,i,o)}parseRowDescriptionMessage(e,t,s){this.reader.setBuffer(e,s);let n=this.reader.int16(),i=new _.RowDescriptionMessage(t,n);for(let o=0;o<n;o++)i.fields[o]=this.parseField();return i}parseField(){let e=this.reader.cstring(),t=this.reader.uint32(),s=this.reader.int16(),n=this.reader.uint32(),i=this.reader.int16(),o=this.reader.int32(),a=this.reader.int16()===0?"text":"binary";return new _.Field(e,t,s,n,i,o,a)}parseParameterDescriptionMessage(e,t,s){this.reader.setBuffer(e,s);let n=this.reader.int16(),i=new _.ParameterDescriptionMessage(t,n);for(let o=0;o<n;o++)i.dataTypeIDs[o]=this.reader.int32();return i}parseDataRowMessage(e,t,s){this.reader.setBuffer(e,s);let n=this.reader.int16(),i=new Array(n);for(let o=0;o<n;o++){let a=this.reader.int32();i[o]=a===-1?null:this.reader.string(a)}return new _.DataRowMessage(t,i)}parseParameterStatusMessage(e,t,s){this.reader.setBuffer(e,s);let n=this.reader.cstring(),i=this.reader.cstring();return new _.ParameterStatusMessage(t,n,i)}parseBackendKeyData(e,t,s){this.reader.setBuffer(e,s);let n=this.reader.int32(),i=this.reader.int32();return new _.BackendKeyDataMessage(t,n,i)}parseAuthenticationResponse(e,t,s){this.reader.setBuffer(e,s);let n=this.reader.int32(),i={name:"authenticationOk",length:t};switch(n){case 0:break;case 3:i.length===8&&(i.name="authenticationCleartextPassword");break;case 5:if(i.length===12){i.name="authenticationMD5Password";let o=this.reader.bytes(4);return new _.AuthenticationMD5Password(t,o)}break;case 10:{i.name="authenticationSASL",i.mechanisms=[];let o;do o=this.reader.cstring(),o&&i.mechanisms.push(o);while(o)}break;case 11:i.name="authenticationSASLContinue",i.data=this.reader.string(t-8);break;case 12:i.name="authenticationSASLFinal",i.data=this.reader.string(t-8);break;default:throw new Error("Unknown authenticationOk message type "+n)}return i}parseErrorMessage(e,t,s,n){this.reader.setBuffer(e,s);let i={},o=this.reader.string(1);for(;o!=="\0";)i[o]=this.reader.cstring(),o=this.reader.string(1);let a=i.M,u=n==="notice"?new _.NoticeMessage(t,a):new _.DatabaseError(a,t,n);return u.severity=i.S,u.code=i.C,u.detail=i.D,u.hint=i.H,u.position=i.P,u.internalPosition=i.p,u.internalQuery=i.q,u.where=i.W,u.schema=i.s,u.table=i.t,u.column=i.c,u.dataType=i.d,u.constraint=i.n,u.file=i.F,u.line=i.L,u.routine=i.R,u}};ce.Parser=it});var ot=f(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.DatabaseError=M.serialize=M.parse=void 0;var gi=Xe();Object.defineProperty(M,"DatabaseError",{enumerable:!0,get:function(){return gi.DatabaseError}});var _i=Tr();Object.defineProperty(M,"serialize",{enumerable:!0,get:function(){return _i.serialize}});var wi=qr();function Si(r,e){let t=new wi.Parser;return r.on("data",s=>t.parse(s,e)),new Promise(s=>r.on("end",()=>s()))}M.parse=Si});var kr=f(at=>{"use strict";Object.defineProperty(at,"__esModule",{value:!0});at.default={}});var Or=f((ea,Lr)=>{"use strict";var{getStream:bi,getSecureStream:vi}=Pi();Lr.exports={getStream:bi,getSecureStream:vi};function Ei(){function r(t){let s=m("net");return new s.Socket}function e(t){return m("tls").connect(t)}return{getStream:r,getSecureStream:e}}function Ci(){function r(t){let{CloudflareSocket:s}=kr();return new s(t)}function e(t){return t.socket.startTls(t),t.socket}return{getStream:r,getSecureStream:e}}function Ai(){if(typeof navigator=="object"&&navigator!==null&&typeof navigator.userAgent=="string")return navigator.userAgent==="Cloudflare-Workers";if(typeof Response=="function"){let r=new Response(null,{cf:{thing:!0}});if(typeof r.cf=="object"&&r.cf!==null&&r.cf.thing)return!0}return!1}function Pi(){return Ai()?Ci():Ei()}});var ct=f((ta,Dr)=>{"use strict";var xi=m("events").EventEmitter,{parse:Ti,serialize:w}=ot(),{getStream:Mi,getSecureStream:Ii}=Or(),Ri=w.flush(),qi=w.sync(),ki=w.end(),ut=class extends xi{constructor(e){super(),e=e||{},this.stream=e.stream||Mi(e.ssl),typeof this.stream=="function"&&(this.stream=this.stream(e)),this._keepAlive=e.keepAlive,this._keepAliveInitialDelayMillis=e.keepAliveInitialDelayMillis,this.lastBuffer=!1,this.parsedStatements={},this.ssl=e.ssl||!1,this._ending=!1,this._emitMessage=!1;let t=this;this.on("newListener",function(s){s==="message"&&(t._emitMessage=!0)})}connect(e,t){let s=this;this._connecting=!0,this.stream.setNoDelay(!0),this.stream.connect(e,t),this.stream.once("connect",function(){s._keepAlive&&s.stream.setKeepAlive(!0,s._keepAliveInitialDelayMillis),s.emit("connect")});let n=function(i){s._ending&&(i.code==="ECONNRESET"||i.code==="EPIPE")||s.emit("error",i)};if(this.stream.on("error",n),this.stream.on("close",function(){s.emit("end")}),!this.ssl)return this.attachListeners(this.stream);this.stream.once("data",function(i){switch(i.toString("utf8")){case"S":break;case"N":return s.stream.end(),s.emit("error",new Error("The server does not support SSL connections"));default:return s.stream.end(),s.emit("error",new Error("There was an error establishing an SSL connection"))}let a={socket:s.stream};s.ssl!==!0&&(Object.assign(a,s.ssl),"key"in s.ssl&&(a.key=s.ssl.key));let u=m("net");u.isIP&&u.isIP(t)===0&&(a.servername=t);try{s.stream=Ii(a)}catch(c){return s.emit("error",c)}s.attachListeners(s.stream),s.stream.on("error",n),s.emit("sslconnect")})}attachListeners(e){Ti(e,t=>{let s=t.name==="error"?"errorMessage":t.name;this._emitMessage&&this.emit("message",t),this.emit(s,t)})}requestSsl(){this.stream.write(w.requestSsl())}startup(e){this.stream.write(w.startup(e))}cancel(e,t){this._send(w.cancel(e,t))}password(e){this._send(w.password(e))}sendSASLInitialResponseMessage(e,t){this._send(w.sendSASLInitialResponseMessage(e,t))}sendSCRAMClientFinalMessage(e){this._send(w.sendSCRAMClientFinalMessage(e))}_send(e){return this.stream.writable?this.stream.write(e):!1}query(e){this._send(w.query(e))}parse(e){this._send(w.parse(e))}bind(e){this._send(w.bind(e))}execute(e){this._send(w.execute(e))}flush(){this.stream.writable&&this.stream.write(Ri)}sync(){this._ending=!0,this._send(qi)}ref(){this.stream.ref()}unref(){this.stream.unref()}end(){if(this._ending=!0,!this._connecting||!this.stream.writable){this.stream.end();return}return this.stream.write(ki,()=>{this.stream.end()})}close(e){this._send(w.close(e))}describe(e){this._send(w.describe(e))}sendCopyFromChunk(e){this._send(w.copyData(e))}endCopyFrom(){this._send(w.copyDone())}sendCopyFail(e){this._send(w.copyFail(e))}};Dr.exports=ut});var Nr=f((ra,Fr)=>{"use strict";var{Transform:Li}=m("stream"),{StringDecoder:Oi}=m("string_decoder"),I=Symbol("last"),he=Symbol("decoder");function Di(r,e,t){let s;if(this.overflow){if(s=this[he].write(r).split(this.matcher),s.length===1)return t();s.shift(),this.overflow=!1}else this[I]+=this[he].write(r),s=this[I].split(this.matcher);this[I]=s.pop();for(let n=0;n<s.length;n++)try{Qr(this,this.mapper(s[n]))}catch(i){return t(i)}if(this.overflow=this[I].length>this.maxLength,this.overflow&&!this.skipOverflow){t(new Error("maximum buffer reached"));return}t()}function Bi(r){if(this[I]+=this[he].end(),this[I])try{Qr(this,this.mapper(this[I]))}catch(e){return r(e)}r()}function Qr(r,e){e!==void 0&&r.push(e)}function Br(r){return r}function Qi(r,e,t){switch(r=r||/\r?\n/,e=e||Br,t=t||{},arguments.length){case 1:typeof r=="function"?(e=r,r=/\r?\n/):typeof r=="object"&&!(r instanceof RegExp)&&!r[Symbol.split]&&(t=r,r=/\r?\n/);break;case 2:typeof r=="function"?(t=e,e=r,r=/\r?\n/):typeof e=="object"&&(t=e,e=Br)}t=Object.assign({},t),t.autoDestroy=!0,t.transform=Di,t.flush=Bi,t.readableObjectMode=!0;let s=new Li(t);return s[I]="",s[he]=new Oi("utf8"),s.matcher=r,s.mapper=e,s.maxLength=t.maxLength,s.skipOverflow=t.skipOverflow||!1,s.overflow=!1,s._destroy=function(n,i){this._writableState.errorEmitted=!1,i(n)},s}Fr.exports=Qi});var Hr=f((sa,x)=>{"use strict";var Ur=m("path"),Fi=m("stream").Stream,Ni=Nr(),jr=m("util"),Ui=5432,le=process.platform==="win32",Z=process.stderr,ji=56,Hi=7,Gi=61440,Vi=32768;function zi(r){return(r&Gi)==Vi}var N=["host","port","database","user","password"],ht=N.length,Ki=N[ht-1];function lt(){var r=Z instanceof Fi&&Z.writable===!0;if(r){var e=Array.prototype.slice.call(arguments).concat(`
|
|
2
|
+
`);Z.write(jr.format.apply(jr,e))}}Object.defineProperty(x.exports,"isWin",{get:function(){return le},set:function(r){le=r}});x.exports.warnTo=function(r){var e=Z;return Z=r,e};x.exports.getFileName=function(r){var e=r||process.env,t=e.PGPASSFILE||(le?Ur.join(e.APPDATA||"./","postgresql","pgpass.conf"):Ur.join(e.HOME||"./",".pgpass"));return t};x.exports.usePgPass=function(r,e){return Object.prototype.hasOwnProperty.call(process.env,"PGPASSWORD")?!1:le?!0:(e=e||"<unkn>",zi(r.mode)?r.mode&(ji|Hi)?(lt('WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less',e),!1):!0:(lt('WARNING: password file "%s" is not a plain file',e),!1))};var Wi=x.exports.match=function(r,e){return N.slice(0,-1).reduce(function(t,s,n){return n==1&&Number(r[s]||Ui)===Number(e[s])?t&&!0:t&&(e[s]==="*"||e[s]===r[s])},!0)};x.exports.getPassword=function(r,e,t){var s,n=e.pipe(Ni());function i(u){var c=Yi(u);c&&$i(c)&&Wi(r,c)&&(s=c[Ki],n.end())}var o=function(){e.destroy(),t(s)},a=function(u){e.destroy(),lt("WARNING: error on reading file: %s",u),t(void 0)};e.on("error",a),n.on("data",i).on("end",o).on("error",a)};var Yi=x.exports.parseLine=function(r){if(r.length<11||r.match(/^\s+#/))return null;for(var e="",t="",s=0,n=0,i=0,o={},a=!1,u=function(h,d,p){var E=r.substring(d,p);Object.hasOwnProperty.call(process.env,"PGPASS_NO_DEESCAPE")||(E=E.replace(/\\([:\\])/g,"$1")),o[N[h]]=E},c=0;c<r.length-1;c+=1){if(e=r.charAt(c+1),t=r.charAt(c),a=s==ht-1,a){u(s,n);break}c>=0&&e==":"&&t!=="\\"&&(u(s,n,c+1),n=c+2,s+=1)}return o=Object.keys(o).length===ht?o:null,o},$i=x.exports.isValidEntry=function(r){for(var e={0:function(o){return o.length>0},1:function(o){return o==="*"?!0:(o=Number(o),isFinite(o)&&o>0&&o<9007199254740992&&Math.floor(o)===o)},2:function(o){return o.length>0},3:function(o){return o.length>0},4:function(o){return o.length>0}},t=0;t<N.length;t+=1){var s=e[t],n=r[N[t]]||"",i=s(n);if(!i)return!1}return!0}});var Vr=f((ia,ft)=>{"use strict";var na=m("path"),Gr=m("fs"),fe=Hr();ft.exports=function(r,e){var t=fe.getFileName();Gr.stat(t,function(s,n){if(s||!fe.usePgPass(n,t))return e(void 0);var i=Gr.createReadStream(t);fe.getPassword(r,i,e)})};ft.exports.warnTo=fe.warnTo});var Yr=f((oa,Wr)=>{"use strict";var Zi=m("events").EventEmitter,zr=O(),dt=fr(),Ji=ne(),Xi=Oe(),Kr=Ar(),eo=Y(),to=ct(),ro=qe(),de=class extends Zi{constructor(e){super(),this.connectionParameters=new Xi(e),this.user=this.connectionParameters.user,this.database=this.connectionParameters.database,this.port=this.connectionParameters.port,this.host=this.connectionParameters.host,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:this.connectionParameters.password}),this.replication=this.connectionParameters.replication;let t=e||{};this._Promise=t.Promise||global.Promise,this._types=new Ji(t.types),this._ending=!1,this._ended=!1,this._connecting=!1,this._connected=!1,this._connectionError=!1,this._queryable=!0,this.enableChannelBinding=!!t.enableChannelBinding,this.connection=t.connection||new to({stream:t.stream,ssl:this.connectionParameters.ssl,keepAlive:t.keepAlive||!1,keepAliveInitialDelayMillis:t.keepAliveInitialDelayMillis||0,encoding:this.connectionParameters.client_encoding||"utf8"}),this.queryQueue=[],this.binary=t.binary||eo.binary,this.processID=null,this.secretKey=null,this.ssl=this.connectionParameters.ssl||!1,this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,"key",{enumerable:!1}),this._connectionTimeoutMillis=t.connectionTimeoutMillis||0}_errorAllQueries(e){let t=s=>{process.nextTick(()=>{s.handleError(e,this.connection)})};this.activeQuery&&(t(this.activeQuery),this.activeQuery=null),this.queryQueue.forEach(t),this.queryQueue.length=0}_connect(e){let t=this,s=this.connection;if(this._connectionCallback=e,this._connecting||this._connected){let n=new Error("Client has already been connected. You cannot reuse a client.");process.nextTick(()=>{e(n)});return}this._connecting=!0,this._connectionTimeoutMillis>0&&(this.connectionTimeoutHandle=setTimeout(()=>{s._ending=!0,s.stream.destroy(new Error("timeout expired"))},this._connectionTimeoutMillis),this.connectionTimeoutHandle.unref&&this.connectionTimeoutHandle.unref()),this.host&&this.host.indexOf("/")===0?s.connect(this.host+"/.s.PGSQL."+this.port):s.connect(this.port,this.host),s.on("connect",function(){t.ssl?s.requestSsl():s.startup(t.getStartupConf())}),s.on("sslconnect",function(){s.startup(t.getStartupConf())}),this._attachListeners(s),s.once("end",()=>{let n=this._ending?new Error("Connection terminated"):new Error("Connection terminated unexpectedly");clearTimeout(this.connectionTimeoutHandle),this._errorAllQueries(n),this._ended=!0,this._ending||(this._connecting&&!this._connectionError?this._connectionCallback?this._connectionCallback(n):this._handleErrorEvent(n):this._connectionError||this._handleErrorEvent(n)),process.nextTick(()=>{this.emit("end")})})}connect(e){if(e){this._connect(e);return}return new this._Promise((t,s)=>{this._connect(n=>{n?s(n):t()})})}_attachListeners(e){e.on("authenticationCleartextPassword",this._handleAuthCleartextPassword.bind(this)),e.on("authenticationMD5Password",this._handleAuthMD5Password.bind(this)),e.on("authenticationSASL",this._handleAuthSASL.bind(this)),e.on("authenticationSASLContinue",this._handleAuthSASLContinue.bind(this)),e.on("authenticationSASLFinal",this._handleAuthSASLFinal.bind(this)),e.on("backendKeyData",this._handleBackendKeyData.bind(this)),e.on("error",this._handleErrorEvent.bind(this)),e.on("errorMessage",this._handleErrorMessage.bind(this)),e.on("readyForQuery",this._handleReadyForQuery.bind(this)),e.on("notice",this._handleNotice.bind(this)),e.on("rowDescription",this._handleRowDescription.bind(this)),e.on("dataRow",this._handleDataRow.bind(this)),e.on("portalSuspended",this._handlePortalSuspended.bind(this)),e.on("emptyQuery",this._handleEmptyQuery.bind(this)),e.on("commandComplete",this._handleCommandComplete.bind(this)),e.on("parseComplete",this._handleParseComplete.bind(this)),e.on("copyInResponse",this._handleCopyInResponse.bind(this)),e.on("copyData",this._handleCopyData.bind(this)),e.on("notification",this._handleNotification.bind(this))}_checkPgPass(e){let t=this.connection;if(typeof this.password=="function")this._Promise.resolve().then(()=>this.password()).then(s=>{if(s!==void 0){if(typeof s!="string"){t.emit("error",new TypeError("Password must be a string"));return}this.connectionParameters.password=this.password=s}else this.connectionParameters.password=this.password=null;e()}).catch(s=>{t.emit("error",s)});else if(this.password!==null)e();else try{Vr()(this.connectionParameters,n=>{n!==void 0&&(this.connectionParameters.password=this.password=n),e()})}catch(s){this.emit("error",s)}}_handleAuthCleartextPassword(e){this._checkPgPass(()=>{this.connection.password(this.password)})}_handleAuthMD5Password(e){this._checkPgPass(async()=>{try{let t=await ro.postgresMd5PasswordHash(this.user,this.password,e.salt);this.connection.password(t)}catch(t){this.emit("error",t)}})}_handleAuthSASL(e){this._checkPgPass(()=>{try{this.saslSession=dt.startSession(e.mechanisms,this.enableChannelBinding&&this.connection.stream),this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism,this.saslSession.response)}catch(t){this.connection.emit("error",t)}})}async _handleAuthSASLContinue(e){try{await dt.continueSession(this.saslSession,this.password,e.data,this.enableChannelBinding&&this.connection.stream),this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}catch(t){this.connection.emit("error",t)}}_handleAuthSASLFinal(e){try{dt.finalizeSession(this.saslSession,e.data),this.saslSession=null}catch(t){this.connection.emit("error",t)}}_handleBackendKeyData(e){this.processID=e.processID,this.secretKey=e.secretKey}_handleReadyForQuery(e){this._connecting&&(this._connecting=!1,this._connected=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback&&(this._connectionCallback(null,this),this._connectionCallback=null),this.emit("connect"));let{activeQuery:t}=this;this.activeQuery=null,this.readyForQuery=!0,t&&t.handleReadyForQuery(this.connection),this._pulseQueryQueue()}_handleErrorWhileConnecting(e){if(!this._connectionError){if(this._connectionError=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback)return this._connectionCallback(e);this.emit("error",e)}}_handleErrorEvent(e){if(this._connecting)return this._handleErrorWhileConnecting(e);this._queryable=!1,this._errorAllQueries(e),this.emit("error",e)}_handleErrorMessage(e){if(this._connecting)return this._handleErrorWhileConnecting(e);let t=this.activeQuery;if(!t){this._handleErrorEvent(e);return}this.activeQuery=null,t.handleError(e,this.connection)}_handleRowDescription(e){this.activeQuery.handleRowDescription(e)}_handleDataRow(e){this.activeQuery.handleDataRow(e)}_handlePortalSuspended(e){this.activeQuery.handlePortalSuspended(this.connection)}_handleEmptyQuery(e){this.activeQuery.handleEmptyQuery(this.connection)}_handleCommandComplete(e){if(this.activeQuery==null){let t=new Error("Received unexpected commandComplete message from backend.");this._handleErrorEvent(t);return}this.activeQuery.handleCommandComplete(e,this.connection)}_handleParseComplete(){if(this.activeQuery==null){let e=new Error("Received unexpected parseComplete message from backend.");this._handleErrorEvent(e);return}this.activeQuery.name&&(this.connection.parsedStatements[this.activeQuery.name]=this.activeQuery.text)}_handleCopyInResponse(e){this.activeQuery.handleCopyInResponse(this.connection)}_handleCopyData(e){this.activeQuery.handleCopyData(e,this.connection)}_handleNotification(e){this.emit("notification",e)}_handleNotice(e){this.emit("notice",e)}getStartupConf(){let e=this.connectionParameters,t={user:e.user,database:e.database},s=e.application_name||e.fallback_application_name;return s&&(t.application_name=s),e.replication&&(t.replication=""+e.replication),e.statement_timeout&&(t.statement_timeout=String(parseInt(e.statement_timeout,10))),e.lock_timeout&&(t.lock_timeout=String(parseInt(e.lock_timeout,10))),e.idle_in_transaction_session_timeout&&(t.idle_in_transaction_session_timeout=String(parseInt(e.idle_in_transaction_session_timeout,10))),e.options&&(t.options=e.options),t}cancel(e,t){if(e.activeQuery===t){let s=this.connection;this.host&&this.host.indexOf("/")===0?s.connect(this.host+"/.s.PGSQL."+this.port):s.connect(this.port,this.host),s.on("connect",function(){s.cancel(e.processID,e.secretKey)})}else e.queryQueue.indexOf(t)!==-1&&e.queryQueue.splice(e.queryQueue.indexOf(t),1)}setTypeParser(e,t,s){return this._types.setTypeParser(e,t,s)}getTypeParser(e,t){return this._types.getTypeParser(e,t)}escapeIdentifier(e){return zr.escapeIdentifier(e)}escapeLiteral(e){return zr.escapeLiteral(e)}_pulseQueryQueue(){if(this.readyForQuery===!0)if(this.activeQuery=this.queryQueue.shift(),this.activeQuery){this.readyForQuery=!1,this.hasExecuted=!0;let e=this.activeQuery.submit(this.connection);e&&process.nextTick(()=>{this.activeQuery.handleError(e,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}else this.hasExecuted&&(this.activeQuery=null,this.emit("drain"))}query(e,t,s){let n,i,o,a,u;if(e==null)throw new TypeError("Client was passed a null or undefined query");return typeof e.submit=="function"?(o=e.query_timeout||this.connectionParameters.query_timeout,i=n=e,typeof t=="function"&&(n.callback=n.callback||t)):(o=e.query_timeout||this.connectionParameters.query_timeout,n=new Kr(e,t,s),n.callback||(i=new this._Promise((c,h)=>{n.callback=(d,p)=>d?h(d):c(p)}).catch(c=>{throw Error.captureStackTrace(c),c}))),o&&(u=n.callback,a=setTimeout(()=>{let c=new Error("Query read timeout");process.nextTick(()=>{n.handleError(c,this.connection)}),u(c),n.callback=()=>{};let h=this.queryQueue.indexOf(n);h>-1&&this.queryQueue.splice(h,1),this._pulseQueryQueue()},o),n.callback=(c,h)=>{clearTimeout(a),u(c,h)}),this.binary&&!n.binary&&(n.binary=!0),n._result&&!n._result._types&&(n._result._types=this._types),this._queryable?this._ending?(process.nextTick(()=>{n.handleError(new Error("Client was closed and is not queryable"),this.connection)}),i):(this.queryQueue.push(n),this._pulseQueryQueue(),i):(process.nextTick(()=>{n.handleError(new Error("Client has encountered a connection error and is not queryable"),this.connection)}),i)}ref(){this.connection.ref()}unref(){this.connection.unref()}end(e){if(this._ending=!0,!this.connection._connecting||this._ended)if(e)e();else return this._Promise.resolve();if(this.activeQuery||!this._queryable?this.connection.stream.destroy():this.connection.end(),e)this.connection.once("end",e);else return new this._Promise(t=>{this.connection.once("end",t)})}};de.Query=Kr;Wr.exports=de});var Xr=f((aa,Jr)=>{"use strict";var so=m("events").EventEmitter,$r=function(){},Zr=(r,e)=>{let t=r.findIndex(e);return t===-1?void 0:r.splice(t,1)[0]},pt=class{constructor(e,t,s){this.client=e,this.idleListener=t,this.timeoutId=s}},U=class{constructor(e){this.callback=e}};function no(){throw new Error("Release called on client which has already been released to the pool.")}function pe(r,e){if(e)return{callback:e,result:void 0};let t,s,n=function(o,a){o?t(o):s(a)},i=new r(function(o,a){s=o,t=a}).catch(o=>{throw Error.captureStackTrace(o),o});return{callback:n,result:i}}function io(r,e){return function t(s){s.client=e,e.removeListener("error",t),e.on("error",()=>{r.log("additional client error after disconnection due to error",s)}),r._remove(e),r.emit("error",s,e)}}var mt=class extends so{constructor(e,t){super(),this.options=Object.assign({},e),e!=null&&"password"in e&&Object.defineProperty(this.options,"password",{configurable:!0,enumerable:!1,writable:!0,value:e.password}),e!=null&&e.ssl&&e.ssl.key&&Object.defineProperty(this.options.ssl,"key",{enumerable:!1}),this.options.max=this.options.max||this.options.poolSize||10,this.options.min=this.options.min||0,this.options.maxUses=this.options.maxUses||1/0,this.options.allowExitOnIdle=this.options.allowExitOnIdle||!1,this.options.maxLifetimeSeconds=this.options.maxLifetimeSeconds||0,this.log=this.options.log||function(){},this.Client=this.options.Client||t||yt().Client,this.Promise=this.options.Promise||global.Promise,typeof this.options.idleTimeoutMillis>"u"&&(this.options.idleTimeoutMillis=1e4),this._clients=[],this._idle=[],this._expired=new WeakSet,this._pendingQueue=[],this._endCallback=void 0,this.ending=!1,this.ended=!1}_isFull(){return this._clients.length>=this.options.max}_isAboveMin(){return this._clients.length>this.options.min}_pulseQueue(){if(this.log("pulse queue"),this.ended){this.log("pulse queue ended");return}if(this.ending){this.log("pulse queue on ending"),this._idle.length&&this._idle.slice().map(t=>{this._remove(t.client)}),this._clients.length||(this.ended=!0,this._endCallback());return}if(!this._pendingQueue.length){this.log("no queued requests");return}if(!this._idle.length&&this._isFull())return;let e=this._pendingQueue.shift();if(this._idle.length){let t=this._idle.pop();clearTimeout(t.timeoutId);let s=t.client;s.ref&&s.ref();let n=t.idleListener;return this._acquireClient(s,e,n,!1)}if(!this._isFull())return this.newClient(e);throw new Error("unexpected condition")}_remove(e,t){let s=Zr(this._idle,i=>i.client===e);s!==void 0&&clearTimeout(s.timeoutId),this._clients=this._clients.filter(i=>i!==e);let n=this;e.end(()=>{n.emit("remove",e),typeof t=="function"&&t()})}connect(e){if(this.ending){let n=new Error("Cannot use a pool after calling end on the pool");return e?e(n):this.Promise.reject(n)}let t=pe(this.Promise,e),s=t.result;if(this._isFull()||this._idle.length){if(this._idle.length&&process.nextTick(()=>this._pulseQueue()),!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new U(t.callback)),s;let n=(a,u,c)=>{clearTimeout(o),t.callback(a,u,c)},i=new U(n),o=setTimeout(()=>{Zr(this._pendingQueue,a=>a.callback===n),i.timedOut=!0,t.callback(new Error("timeout exceeded when trying to connect"))},this.options.connectionTimeoutMillis);return o.unref&&o.unref(),this._pendingQueue.push(i),s}return this.newClient(new U(t.callback)),s}newClient(e){let t=new this.Client(this.options);this._clients.push(t);let s=io(this,t);this.log("checking client timeout");let n,i=!1;this.options.connectionTimeoutMillis&&(n=setTimeout(()=>{this.log("ending client due to timeout"),i=!0,t.connection?t.connection.stream.destroy():t.end()},this.options.connectionTimeoutMillis)),this.log("connecting new client"),t.connect(o=>{if(n&&clearTimeout(n),t.on("error",s),o)this.log("client failed to connect",o),this._clients=this._clients.filter(a=>a!==t),i&&(o=new Error("Connection terminated due to connection timeout",{cause:o})),this._pulseQueue(),e.timedOut||e.callback(o,void 0,$r);else{if(this.log("new client connected"),this.options.maxLifetimeSeconds!==0){let a=setTimeout(()=>{this.log("ending client due to expired lifetime"),this._expired.add(t),this._idle.findIndex(c=>c.client===t)!==-1&&this._acquireClient(t,new U((c,h,d)=>d()),s,!1)},this.options.maxLifetimeSeconds*1e3);a.unref(),t.once("end",()=>clearTimeout(a))}return this._acquireClient(t,e,s,!0)}})}_acquireClient(e,t,s,n){n&&this.emit("connect",e),this.emit("acquire",e),e.release=this._releaseOnce(e,s),e.removeListener("error",s),t.timedOut?n&&this.options.verify?this.options.verify(e,e.release):e.release():n&&this.options.verify?this.options.verify(e,i=>{if(i)return e.release(i),t.callback(i,void 0,$r);t.callback(void 0,e,e.release)}):t.callback(void 0,e,e.release)}_releaseOnce(e,t){let s=!1;return n=>{s&&no(),s=!0,this._release(e,t,n)}}_release(e,t,s){if(e.on("error",t),e._poolUseCount=(e._poolUseCount||0)+1,this.emit("release",s,e),s||this.ending||!e._queryable||e._ending||e._poolUseCount>=this.options.maxUses)return e._poolUseCount>=this.options.maxUses&&this.log("remove expended client"),this._remove(e,this._pulseQueue.bind(this));if(this._expired.has(e))return this.log("remove expired client"),this._expired.delete(e),this._remove(e,this._pulseQueue.bind(this));let i;this.options.idleTimeoutMillis&&this._isAboveMin()&&(i=setTimeout(()=>{this.log("remove idle client"),this._remove(e,this._pulseQueue.bind(this))},this.options.idleTimeoutMillis),this.options.allowExitOnIdle&&i.unref()),this.options.allowExitOnIdle&&e.unref(),this._idle.push(new pt(e,t,i)),this._pulseQueue()}query(e,t,s){if(typeof e=="function"){let i=pe(this.Promise,e);return setImmediate(function(){return i.callback(new Error("Passing a function as the first parameter to pool.query is not supported"))}),i.result}typeof t=="function"&&(s=t,t=void 0);let n=pe(this.Promise,s);return s=n.callback,this.connect((i,o)=>{if(i)return s(i);let a=!1,u=c=>{a||(a=!0,o.release(c),s(c))};o.once("error",u),this.log("dispatching query");try{o.query(e,t,(c,h)=>{if(this.log("query dispatched"),o.removeListener("error",u),!a)return a=!0,o.release(c),c?s(c):s(void 0,h)})}catch(c){return o.release(c),s(c)}}),n.result}end(e){if(this.log("ending"),this.ending){let s=new Error("Called end on pool more than once");return e?e(s):this.Promise.reject(s)}this.ending=!0;let t=pe(this.Promise,e);return this._endCallback=t.callback,this._pulseQueue(),t.result}get waitingCount(){return this._pendingQueue.length}get idleCount(){return this._idle.length}get expiredCount(){return this._clients.reduce((e,t)=>e+(this._expired.has(t)?1:0),0)}get totalCount(){return this._clients.length}};Jr.exports=mt});var rs=f((ua,ts)=>{"use strict";var es=m("events").EventEmitter,oo=m("util"),gt=O(),j=ts.exports=function(r,e,t){es.call(this),r=gt.normalizeQueryConfig(r,e,t),this.text=r.text,this.values=r.values,this.name=r.name,this.queryMode=r.queryMode,this.callback=r.callback,this.state="new",this._arrayMode=r.rowMode==="array",this._emitRowEvents=!1,this.on("newListener",function(s){s==="row"&&(this._emitRowEvents=!0)}.bind(this))};oo.inherits(j,es);var ao={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"schema",tableName:"table",columnName:"column",dataTypeName:"dataType",constraintName:"constraint",sourceFile:"file",sourceLine:"line",sourceFunction:"routine"};j.prototype.handleError=function(r){let e=this.native.pq.resultErrorFields();if(e)for(let t in e){let s=ao[t]||t;r[s]=e[t]}this.callback?this.callback(r):this.emit("error",r),this.state="error"};j.prototype.then=function(r,e){return this._getPromise().then(r,e)};j.prototype.catch=function(r){return this._getPromise().catch(r)};j.prototype._getPromise=function(){return this._promise?this._promise:(this._promise=new Promise(function(r,e){this._once("end",r),this._once("error",e)}.bind(this)),this._promise)};j.prototype.submit=function(r){this.state="running";let e=this;this.native=r.native,r.native.arrayMode=this._arrayMode;let t=function(s,n,i){if(r.native.arrayMode=!1,setImmediate(function(){e.emit("_done")}),s)return e.handleError(s);e._emitRowEvents&&(i.length>1?n.forEach((o,a)=>{o.forEach(u=>{e.emit("row",u,i[a])})}):n.forEach(function(o){e.emit("row",o,i)})),e.state="end",e.emit("end",i),e.callback&&e.callback(null,i)};if(process.domain&&(t=process.domain.bind(t)),this.name){this.name.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",this.name,this.name.length),console.error("This can cause conflicts and silent errors executing queries"));let s=(this.values||[]).map(gt.prepareValue);if(r.namedQueries[this.name]){if(this.text&&r.namedQueries[this.name]!==this.text){let n=new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);return t(n)}return r.native.execute(this.name,s,t)}return r.native.prepare(this.name,this.text,s.length,function(n){return n?t(n):(r.namedQueries[e.name]=e.text,e.native.execute(e.name,s,t))})}else if(this.values){if(!Array.isArray(this.values)){let n=new Error("Query values must be an array");return t(n)}let s=this.values.map(gt.prepareValue);r.native.query(this.text,s,t)}else this.queryMode==="extended"?r.native.query(this.text,[],t):r.native.query(this.text,t)}});var as=f((ca,os)=>{"use strict";var ss;try{ss=m("pg-native")}catch(r){throw r}var uo=ne(),ns=m("events").EventEmitter,co=m("util"),ho=Oe(),is=rs(),v=os.exports=function(r){ns.call(this),r=r||{},this._Promise=r.Promise||global.Promise,this._types=new uo(r.types),this.native=new ss({types:this._types}),this._queryQueue=[],this._ending=!1,this._connecting=!1,this._connected=!1,this._queryable=!0;let e=this.connectionParameters=new ho(r);r.nativeConnectionString&&(e.nativeConnectionString=r.nativeConnectionString),this.user=e.user,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:e.password}),this.database=e.database,this.host=e.host,this.port=e.port,this.namedQueries={}};v.Query=is;co.inherits(v,ns);v.prototype._errorAllQueries=function(r){let e=t=>{process.nextTick(()=>{t.native=this.native,t.handleError(r)})};this._hasActiveQuery()&&(e(this._activeQuery),this._activeQuery=null),this._queryQueue.forEach(e),this._queryQueue.length=0};v.prototype._connect=function(r){let e=this;if(this._connecting){process.nextTick(()=>r(new Error("Client has already been connected. You cannot reuse a client.")));return}this._connecting=!0,this.connectionParameters.getLibpqConnectionString(function(t,s){if(e.connectionParameters.nativeConnectionString&&(s=e.connectionParameters.nativeConnectionString),t)return r(t);e.native.connect(s,function(n){if(n)return e.native.end(),r(n);e._connected=!0,e.native.on("error",function(i){e._queryable=!1,e._errorAllQueries(i),e.emit("error",i)}),e.native.on("notification",function(i){e.emit("notification",{channel:i.relname,payload:i.extra})}),e.emit("connect"),e._pulseQueryQueue(!0),r()})})};v.prototype.connect=function(r){if(r){this._connect(r);return}return new this._Promise((e,t)=>{this._connect(s=>{s?t(s):e()})})};v.prototype.query=function(r,e,t){let s,n,i,o,a;if(r==null)throw new TypeError("Client was passed a null or undefined query");if(typeof r.submit=="function")i=r.query_timeout||this.connectionParameters.query_timeout,n=s=r,typeof e=="function"&&(r.callback=e);else if(i=r.query_timeout||this.connectionParameters.query_timeout,s=new is(r,e,t),!s.callback){let u,c;n=new this._Promise((h,d)=>{u=h,c=d}).catch(h=>{throw Error.captureStackTrace(h),h}),s.callback=(h,d)=>h?c(h):u(d)}return i&&(a=s.callback,o=setTimeout(()=>{let u=new Error("Query read timeout");process.nextTick(()=>{s.handleError(u,this.connection)}),a(u),s.callback=()=>{};let c=this._queryQueue.indexOf(s);c>-1&&this._queryQueue.splice(c,1),this._pulseQueryQueue()},i),s.callback=(u,c)=>{clearTimeout(o),a(u,c)}),this._queryable?this._ending?(s.native=this.native,process.nextTick(()=>{s.handleError(new Error("Client was closed and is not queryable"))}),n):(this._queryQueue.push(s),this._pulseQueryQueue(),n):(s.native=this.native,process.nextTick(()=>{s.handleError(new Error("Client has encountered a connection error and is not queryable"))}),n)};v.prototype.end=function(r){let e=this;this._ending=!0,this._connected||this.once("connect",this.end.bind(this,r));let t;return r||(t=new this._Promise(function(s,n){r=i=>i?n(i):s()})),this.native.end(function(){e._errorAllQueries(new Error("Connection terminated")),process.nextTick(()=>{e.emit("end"),r&&r()})}),t};v.prototype._hasActiveQuery=function(){return this._activeQuery&&this._activeQuery.state!=="error"&&this._activeQuery.state!=="end"};v.prototype._pulseQueryQueue=function(r){if(!this._connected||this._hasActiveQuery())return;let e=this._queryQueue.shift();if(!e){r||this.emit("drain");return}this._activeQuery=e,e.submit(this);let t=this;e.once("_done",function(){t._pulseQueryQueue()})};v.prototype.cancel=function(r){this._activeQuery===r?this.native.cancel(function(){}):this._queryQueue.indexOf(r)!==-1&&this._queryQueue.splice(this._queryQueue.indexOf(r),1)};v.prototype.ref=function(){};v.prototype.unref=function(){};v.prototype.setTypeParser=function(r,e,t){return this._types.setTypeParser(r,e,t)};v.prototype.getTypeParser=function(r,e){return this._types.getTypeParser(r,e)}});var _t=f((ha,us)=>{"use strict";us.exports=as()});var yt=f((fa,J)=>{"use strict";var lo=Yr(),fo=Y(),po=ct(),mo=Be(),yo=O(),go=Xr(),_o=ne(),{DatabaseError:wo}=ot(),{escapeIdentifier:So,escapeLiteral:bo}=O(),vo=r=>class extends go{constructor(t){super(t,r)}},wt=function(r){this.defaults=fo,this.Client=r,this.Query=this.Client.Query,this.Pool=vo(this.Client),this._pools=[],this.Connection=po,this.types=W(),this.DatabaseError=wo,this.TypeOverrides=_o,this.escapeIdentifier=So,this.escapeLiteral=bo,this.Result=mo,this.utils=yo};typeof process.env.NODE_PG_FORCE_NATIVE<"u"?J.exports=new wt(_t()):(J.exports=new wt(lo),Object.defineProperty(J.exports,"native",{configurable:!0,enumerable:!1,get(){let r=null;try{r=new wt(_t())}catch(e){if(e.code!=="MODULE_NOT_FOUND")throw e}return Object.defineProperty(J.exports,"native",{value:r}),r}}))});var C=fs(yt(),1),da=C.default.Client,pa=C.default.Pool,ma=C.default.Connection,ya=C.default.types,ga=C.default.Query,_a=C.default.DatabaseError,wa=C.default.escapeIdentifier,Sa=C.default.escapeLiteral,ba=C.default.Result,va=C.default.TypeOverrides,Ea=C.default.defaults,Ca=C.default;export{da as Client,ma as Connection,_a as DatabaseError,pa as Pool,ga as Query,ba as Result,va as TypeOverrides,Ca as default,Ea as defaults,wa as escapeIdentifier,Sa as escapeLiteral,ya as types};
|