PageSourceSearch

https://truemargin.ai/_next/static/chunks/11192.5ee46bf39124a7a8.js

js truemargin.ai collected 2026-10-05 13:08:27 UTC 192,988 bytes, 40 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[11192,25566],{25566:function(e){var t,r,i,s=e.exports={};function n(){throw Error("setTimeout has not been defined")}function o(){throw Error("clearTimeout has not been defined")}function a(e){if(t===setTimeout)return setTimeout(e,0);if((t===n||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:n}catch(e){t=n}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(e){r=o}}();var l=[],u=!1,h=-1;function c(){u&&i&&(u=!1,i.length?l=i.concat(l):h=-1,l.length&&f())}function f(){if(!u){var e=a(c);u=!0;for(var t=l.length;t;){for(i=l,l=[];++h<t;)i&&i[h].run();h=-1,t=l.length}i=null,u=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function p(){}s.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new d(e,t)),1!==l.length||u||a(f)},d.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=p,s.addListener=p,s.once=p,s.off=p,s.removeListener=p,s.removeAllListeners=p,s.emit=p,s.prependListener=p,s.prependOnceListener=p,s.listeners=function(e){return[]},s.binding=function(e){throw Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw Error("process.chdir is not supported")},s.umask=function(){return 0}},52527:function(e,t,r){"use strict";r.d(t,{V5:function(){return tk},qn:function(){return tS},vK:function(){return B}});var i,s,n,o,a,l,u=Object.create,h=Object.defineProperty,c=Object.getOwnPropertyDescriptor,f=Object.getOwnPropertyNames,d=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,y=(e,t,r)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,g=(e,t)=>h(e,"name",{value:t,configurable:!0}),m=(e,t)=>()=>(e&&(t=e(e=0)),t),b=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),w=(e,t)=>{for(var r in t)h(e,r,{get:t[r],enumerable:!0})},v=(e,t,r,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of f(t))p.call(e,s)||s===r||h(e,s,{get:()=>t[s],enumerable:!(i=c(t,s))||i.enumerable});return e},S=(e,t,r)=>(r=null!=e?u(d(e)):{},v(!t&&e&&e.__esModule?r:h(r,"default",{value:e,enumerable:!0}),e)),_=e=>v(h({},"__esModule",{value:!0}),e),E=(e,t,r)=>y(e,"symbol"!=typeof t?t+"":t,r),A=b(e=>{P(),e.byteLength=l,e.toByteArray=h,e.fromByteArray=d;var t,r,i=[],s=[],n="u">typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(t=0,r=o.length;t<r;++t)i[t]=o[t],s[o.charCodeAt(t)]=t;function a(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");-1===r&&(r=t);var i=r===t?0:4-r%4;return[r,i]}function l(e){var t=a(e),r=t[0],i=t[1];return(r+i)*3/4-i}function u(e,t,r){return(t+r)*3/4-r}function h(e){var t,r,i=a(e),o=i[0],l=i[1],h=new n(u(e,o,l)),c=0,f=l>0?o-4:o;for(r=0;r<f;r+=4)t=s[e.charCodeAt(r)]<<18|s[e.charCodeAt(r+1)]<<12|s[e.charCodeAt(r+2)]<<6|s[e.charCodeAt(r+3)],h[c++]=t>>16&255,h[c++]=t>>8&255,h[c++]=255&t;return 2===l&&(t=s[e.charCodeAt(r)]<<2|s[e.charCodeAt(r+1)]>>4,h[c++]=255&t),1===l&&(t=s[e.charCodeAt(r)]<<10|s[e.charCodeAt(r+1)]<<4|s[e.charCodeAt(r+2)]>>2,h[c++]=t>>8&255,h[c++]=255&t),h}function c(e){return i[e>>18&63]+i[e>>12&63]+i[e>>6&63]+i[63&e]}function f(e,t,r){for(var i=[],s=t;s<r;s+=3)i.push(c((e[s]<<16&16711680)+(e[s+1]<<8&65280)+(255&e[s+2])));return i.join("")}function d(e){for(var t,r=e.length,s=r%3,n=[],o=0,a=r-s;o<a;o+=16383)n.push(f(e,o,o+16383>a?a:o+16383));return 1===s?n.push(i[(t=e[r-1])>>2]+i[t<<4&63]+"=="):2===s&&n.push(i[(t=(e[r-2]<<8)+e[r-1])>>10]+i[t>>4&63]+i[t<<2&63]+"="),n.join("")}s[45]=62,s[95]=63,g(a,"getLens"),g(l,"byteLength"),g(u,"_byteLength"),g(h,"toByteArray"),g(c,"tripletToBase64"),g(f,"encodeChunk"),g(d,"fromByteArray")}),T=b(e=>{P(),e.read=function(e,t,r,i,s){var n,o,a=8*s-i-1,l=(1<<a)-1,u=l>>1,h=-7,c=r?s-1:0,f=r?-1:1,d=e[t+c];for(c+=f,n=d&(1<<-h)-1,d>>=-h,h+=a;h>0;n=256*n+e[t+c],c+=f,h-=8);for(o=n&(1<<-h)-1,n>>=-h,h+=i;h>0;o=256*o+e[t+c],c+=f,h-=8);if(0===n)n=1-u;else{if(n===l)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,i),n-=u}return(d?-1:1)*o*Math.pow(2,n-i)}
1,e.write=function(e,t,r,i,s,n){var o,a,l,u=8*n-s-1,h=(1<<u)-1,c=h>>1,f=23===s?5960464477539062e-23:0,d=i?0:n-1,p=i?1:-1,y=t<0||0===t&&1/t<0?1:0;for(isNaN(t=Math.abs(t))||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+c>=1?t+=f/l:t+=f*Math.pow(2,1-c),t*l>=2&&(o++,l/=2),o+c>=h?(a=0,o=h):o+c>=1?(a=(t*l-1)*Math.pow(2,s),o+=c):(a=t*Math.pow(2,c-1)*Math.pow(2,s),o=0));s>=8;e[r+d]=255&a,d+=p,a/=256,s-=8);for(o=o<<s|a,u+=s;u>0;e[r+d]=255&o,d+=p,o/=256,u-=8);e[r+d-p]|=128*y}}),C=b(e=>{P();var t=A(),r=T(),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function s(){try{let e=new Uint8Array(1),t={foo:g(function(){return 42},"foo")};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch{return!1}}function n(e){if(e>2147483647)throw RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,o.prototype),t}function o(e,t,r){if("number"==typeof e){if("string"==typeof t)throw TypeError('The "string" argument must be of type string. Received type number');return h(e)}return a(e,t,r)}function a(e,t,r){if("string"==typeof e)return c(e,t);if(ArrayBuffer.isView(e))return d(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(eo(e,ArrayBuffer)||e&&eo(e.buffer,ArrayBuffer)||"u">typeof SharedArrayBuffer&&(eo(e,SharedArrayBuffer)||e&&eo(e.buffer,SharedArrayBuffer)))return p(e,t,r);if("number"==typeof e)throw TypeError('The "value" argument must not be of type number. Received type number');let i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return o.from(i,t,r);let s=y(e);if(s)return s;if("u">typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return o.from(e[Symbol.toPrimitive]("string"),t,r);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw TypeError('"size" argument must be of type number');if(e<0)throw RangeError('The value "'+e+'" is invalid for option "size"')}function u(e,t,r){return l(e),e<=0?n(e):void 0!==t?"string"==typeof r?n(e).fill(t,r):n(e).fill(t):n(e)}function h(e){return l(e),n(e<0?0:0|m(e))}function c(e,t){if(("string"!=typeof t||""===t)&&(t="utf8"),!o.isEncoding(t))throw TypeError("Unknown encoding: "+t);let r=0|w(e,t),i=n(r),s=i.write(e,t);return s!==r&&(i=i.slice(0,s)),i}function f(e){let t=e.length<0?0:0|m(e.length),r=n(t);for(let i=0;i<t;i+=1)r[i]=255&e[i];return r}function d(e){if(eo(e,Uint8Array)){let t=new Uint8Array(e);return p(t.buffer,t.byteOffset,t.byteLength)}return f(e)}function p(e,t,r){let i;if(t<0||e.byteLength<t)throw RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(i=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),o.prototype),i}function y(e){if(o.isBuffer(e)){let t=0|m(e.length),r=n(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||ea(e.length)?n(0):f(e):"Buffer"===e.type&&Array.isArray(e.data)?f(e.data):void 0}function m(e){if(e>=2147483647)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|e}function b(e){return+e!=e&&(e=0),o.alloc(+e)}function w(e,t){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||eo(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;let s=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return et(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return es(e).length;default:if(s)return i?-1:et(e).length;t=(""+t).toLowerCase(),s=!0}}function v(e,t,r){let i=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0)||(r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return $(this,t,r);case"utf8":case"utf-8":return R(this,t,r);case"ascii":return O(this,t,r);case"latin1":case"binary":return N(this,t,r);case"base64":return k(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q(this,t,r);default:if(i)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function S(e,t,r){let i=e[t];e[t]=e[r],e[r]=i}function _(e,t,r,i,s){if(0===e.length)return -1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),ea(r=+r)&&(r=s?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(s)return -1;r=e.length-1}
1else if(r<0){if(!s)return -1;r=0}if("string"==typeof t&&(t=o.from(t,i)),o.isBuffer(t))return 0===t.length?-1:E(e,t,r,i,s);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):E(e,[t],r,i,s);throw TypeError("val must be string, number or Buffer")}function E(e,t,r,i,s){let n,o=1,a=e.length,l=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return -1;o=2,a/=2,l/=2,r/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(g(u,"read"),s){let i=-1;for(n=r;n<a;n++)if(u(e,n)===u(t,-1===i?0:n-i)){if(-1===i&&(i=n),n-i+1===l)return i*o}else -1!==i&&(n-=n-i),i=-1}else for(r+l>a&&(r=a-l),n=r;n>=0;n--){let r=!0;for(let i=0;i<l;i++)if(u(e,n+i)!==u(t,i)){r=!1;break}if(r)return n}return -1}function C(e,t,r,i){let s;r=Number(r)||0;let n=e.length-r;i?(i=Number(i))>n&&(i=n):i=n;let o=t.length;for(i>o/2&&(i=o/2),s=0;s<i;++s){let i=parseInt(t.substr(2*s,2),16);if(ea(i))break;e[r+s]=i}return s}function L(e,t,r,i){return en(et(t,e.length-r),e,r,i)}function I(e,t,r,i){return en(er(t),e,r,i)}function x(e,t,r,i){return en(es(t),e,r,i)}function M(e,t,r,i){return en(ei(t,e.length-r),e,r,i)}function k(e,r,i){return 0===r&&i===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(r,i))}function R(e,t,r){r=Math.min(e.length,r);let i=[],s=t;for(;s<r;){let t=e[s],n=null,o=t>239?4:t>223?3:t>191?2:1;if(s+o<=r){let r,i,a,l;switch(o){case 1:t<128&&(n=t);break;case 2:(192&(r=e[s+1]))==128&&(l=(31&t)<<6|63&r)>127&&(n=l);break;case 3:r=e[s+1],i=e[s+2],(192&r)==128&&(192&i)==128&&(l=(15&t)<<12|(63&r)<<6|63&i)>2047&&(l<55296||l>57343)&&(n=l);break;case 4:r=e[s+1],i=e[s+2],a=e[s+3],(192&r)==128&&(192&i)==128&&(192&a)==128&&(l=(15&t)<<18|(63&r)<<12|(63&i)<<6|63&a)>65535&&l<1114112&&(n=l)}}null===n?(n=65533,o=1):n>65535&&(n-=65536,i.push(n>>>10&1023|55296),n=56320|1023&n),i.push(n),s+=o}return B(i)}function B(e){let t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);let r="",i=0;for(;i<t;)r+=String.fromCharCode.apply(String,e.slice(i,i+=4096));return r}function O(e,t,r){let i="";r=Math.min(e.length,r);for(let s=t;s<r;++s)i+=String.fromCharCode(127&e[s]);return i}function N(e,t,r){let i="";r=Math.min(e.length,r);for(let s=t;s<r;++s)i+=String.fromCharCode(e[s]);return i}function $(e,t,r){let i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);let s="";for(let i=t;i<r;++i)s+=el[e[i]];return s}function Q(e,t,r){let i=e.slice(t,r),s="";for(let e=0;e<i.length-1;e+=2)s+=String.fromCharCode(i[e]+256*i[e+1]);return s}function q(e,t,r){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+t>r)throw RangeError("Trying to access beyond buffer length")}function D(e,t,r,i,s,n){if(!o.isBuffer(e))throw TypeError('"buffer" argument must be a Buffer instance');if(t>s||t<n)throw RangeError('"value" argument is out of bounds');if(r+i>e.length)throw RangeError("Index out of range")}function F(e,t,r,i,s){J(t,i,s,e,r,7);let n=Number(t&BigInt(4294967295));e[r++]=n,n>>=8,e[r++]=n,n>>=8,e[r++]=n,n>>=8,e[r++]=n;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o,r}function j(e,t,r,i,s){J(t,i,s,e,r,7);let n=Number(t&BigInt(4294967295));e[r+7]=n,n>>=8,e[r+6]=n,n>>=8,e[r+5]=n,n>>=8,e[r+4]=n;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=o,o>>=8,e[r+2]=o,o>>=8,e[r+1]=o,o>>=8,e[r]=o,r+8}function U(e,t,r,i,s,n){if(r+i>e.length||r<0)throw RangeError("Index out of range")}function W(e,t,i,s,n){return t=+t,i>>>=0,n||U(e,t,i,4,34028234663852886e22,-34028234663852886e22),r.write(e,t,i,s,23,4),i+4}function z(e,t,i,s,n){return t=+t,i>>>=0,n||U(e,t,i,8,17976931348623157e292,-17976931348623157e292),r.write(e,t,i,s,52,8),i+8}e.Buffer=o,e.SlowBuffer=b,e.INSPECT_MAX_BYTES=50,e.kMaxLength=2147483647,o.TYPED_ARRAY_SUPPORT=s(),!o.TYPED_ARRAY_SUPPORT&&"u">typeof console&&"function"==typeof console.error&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),g(s,"typedArraySupport"),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:g(function(){if(o.isBuffer(this))return this.buffer},"get")}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:g(function(){if(o.isBuffer(this))return this.byteOffset},"get")}),g(n,"createBuffer"),g(o,"Buffer"),o.poolSize=8192,g(a,"from"),o.from=function(e,t,r){return a(e,t,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),g(l,"assertSize"),g(u,"alloc"),o.alloc=function(e,t,r){return u(e,t,r)},g(h,"allocUnsafe"),o.allocUnsafe=function(e){return h(e)},o.allocUnsafeSlow=function(e){return h(e)},g(c,"fromString"),g(f,"fromArrayLike"),g(d,"fromArrayView"),g(p,"fromArrayBuffer"),g(y,"fromObject"),g(m,"checked"),g(b,"SlowBuffer"),o.isBuffer=g(function(e){return null!=e&&!0===e._isBuffer&&e!==o.prototype},"isBuffer"),o.compare=g(function(e,t){if(eo(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),eo(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(e)||!o.isBuffer(t))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let r=e.length,i=t.length;for(let s=0,n=Math.min(r,i);s<n;++s)if(e[s]!==t[s]){r=e[s],i=t[s];break}return r<i?-1:i<r?1:0},"compare"),o.isEncoding=g(function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},"isEncoding"),o.concat=g(function(e,t){let r;if(!Array.isArray(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return o.alloc(0);if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;let i=o.allocUnsafe(t),s=0;for(r=0;r<e.length;++r){let t=e[r];if(eo(t,Uint8Array))s+t.length>i.length?(o.isBuffer(t)||(t=o.from(t)),t.copy(i,s)):Uint8Array.prototype.set.call(i,t,s);else if(o.isBuffer(t))t.copy(i,s);else throw TypeError('"list" argument must be an Array of Buffers');s+=t.length}return i},"concat"),g(w,"byteLength"),o.byteLength=w,g(v,"slowToString"),o.prototype._isBuffer=!0,g(S,"swap"),o.prototype.swap16=g(function(){let e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)S(this,t,t+1);return this},"swap16"),o.prototype.swap32=g(function(){let e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)S(this,t,t+3),S(this,t+1,t+2);return this},"swap32"),o.prototype.swap64=g(function(){let e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)S(this,t,t+7),S(this,t+1,t+6),S(this,t+2,t+5),S(this,t+3,t+4);return this},"swap64"),o.prototype.toString=g(function(){let e=this.length;return 0===e?"":0==arguments.length?R(this,0,e):v.apply(this,arguments)}
1,"toString"),o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=g(function(e){if(!o.isBuffer(e))throw TypeError("Argument must be a Buffer");return this===e||0===o.compare(this,e)},"equals"),o.prototype.inspect=g(function(){let t="",r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},"inspect"),i&&(o.prototype[i]=o.prototype.inspect),o.prototype.compare=g(function(e,t,r,i,s){if(eo(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(e))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===s&&(s=this.length),t<0||r>e.length||i<0||s>this.length)throw RangeError("out of range index");if(i>=s&&t>=r)return 0;if(i>=s)return -1;if(t>=r)return 1;if(t>>>=0,r>>>=0,i>>>=0,s>>>=0,this===e)return 0;let n=s-i,a=r-t,l=Math.min(n,a),u=this.slice(i,s),h=e.slice(t,r);for(let e=0;e<l;++e)if(u[e]!==h[e]){n=u[e],a=h[e];break}return n<a?-1:a<n?1:0},"compare"),g(_,"bidirectionalIndexOf"),g(E,"arrayIndexOf"),o.prototype.includes=g(function(e,t,r){return -1!==this.indexOf(e,t,r)},"includes"),o.prototype.indexOf=g(function(e,t,r){return _(this,e,t,r,!0)},"indexOf"),o.prototype.lastIndexOf=g(function(e,t,r){return _(this,e,t,r,!1)},"lastIndexOf"),g(C,"hexWrite"),g(L,"utf8Write"),g(I,"asciiWrite"),g(x,"base64Write"),g(M,"ucs2Write"),o.prototype.write=g(function(e,t,r,i){if(void 0===t)i="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)i=t,r=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(r)?(r>>>=0,void 0===i&&(i="utf8")):(i=r,r=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-t;if((void 0===r||r>s)&&(r=s),e.length>0&&(r<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let n=!1;for(;;)switch(i){case"hex":return C(this,e,t,r);case"utf8":case"utf-8":return L(this,e,t,r);case"ascii":case"latin1":case"binary":return I(this,e,t,r);case"base64":return x(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,t,r);default:if(n)throw TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),n=!0}},"write"),o.prototype.toJSON=g(function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},"toJSON"),g(k,"base64Slice"),g(R,"utf8Slice"),g(B,"decodeCodePointsArray"),g(O,"asciiSlice"),g(N,"latin1Slice"),g($,"hexSlice"),g(Q,"utf16leSlice"),o.prototype.slice=g(function(e,t){let r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,o.prototype),i},"slice"),g(q,"checkOffset"),o.prototype.readUintLE=o.prototype.readUIntLE=g(function(e,t,r){e>>>=0,t>>>=0,r||q(e,t,this.length);let i=this[e],s=1,n=0;for(;++n<t&&(s*=256);)i+=this[e+n]*s;return i},"readUIntLE"),o.prototype.readUintBE=o.prototype.readUIntBE=g(function(e,t,r){e>>>=0,t>>>=0,r||q(e,t,this.length);let i=this[e+--t],s=1;for(;t>0&&(s*=256);)i+=this[e+--t]*s;return i},"readUIntBE"),o.prototype.readUint8=o.prototype.readUInt8=g(function(e,t){return e>>>=0,t||q(e,1,this.length),this[e]},"readUInt8"),o.prototype.readUint16LE=o.prototype.readUInt16LE=g(function(e,t){return e>>>=0,t||q(e,2,this.length),this[e]|this[e+1]<<8},"readUInt16LE"),o.prototype.readUint16BE=o.prototype.readUInt16BE=g(function(e,t){return e>>>=0,t||q(e,2,this.length),this[e]<<8|this[e+1]},"readUInt16BE"),o.prototype.readUint32LE=o.prototype.readUInt32LE=g(function(e,t){return e>>>=0,t||q(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},"readUInt32LE"),o.prototype.readUint32BE=o.prototype.readUInt32BE=g(function(e,t){return e>>>=0,t||q(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},"readUInt32BE"),o.prototype.readBigUInt64LE=eu(g(function(e){Y(e>>>=0,"offset");let t=this[e],r=this[e+7];(void 0===t||void 0===r)&&Z(e,this.length-8);let i=t+256*this[++e]+65536*this[++e]+16777216*this[++e],s=this[++e]+256*this[++e]+65536*this[++e]+16777216*r;return BigInt(i)+(BigInt(s)<<BigInt(32))},"readBigUInt64LE")),o.prototype.readBigUInt64BE=eu(g(function(e){Y(e>>>=0,"offset");let t=this[e],r=this[e+7];(void 0===t||void 0===r)&&Z(e,this.length-8);let i=16777216*t+65536*this[++e]+256*this[++e]+this[++e],s=16777216*this[++e]+65536*this[++e]+256*this[++e]+r;return(BigInt(i)<<BigInt(32))+BigInt(s)},"readBigUInt64BE")),o.prototype.readIntLE=g(function(e,t,r){e>>>=0,t>>>=0,r||q(e,t,this.length);let i=this[e],s=1,n=0;for(;++n<t&&(s*=256);)i+=this[e+n]*s;return i>=(s*=128)&&(i-=Math.pow(2,8*t)),i},"readIntLE"),o.prototype.readIntBE=g(function(e,t,r){e>>>=0,t>>>=0,r||q(e,t,this.length);let i=t,s=1,n=this[e+--i];for(;i>0&&(s*=256);)n+=this[e+--i]*s;return n>=(s*=128)&&(n-=Math.pow(2,8*t)),n},"readIntBE"),o.prototype.readInt8=g(function(e,t){return e>>>=0,t||q(e,1,this.length),128&this[e]?-((255-this[e]+1)*1):this[e]},"readInt8"),o.prototype.readInt16LE=g(function(e,t){e>>>=0,t||q(e,2,this.length);let r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},"readInt16LE"),o.prototype.readInt16BE=g(function(e,t){e>>>=0,t||q(e,2,this.length);let r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},"readInt16BE"),o.prototype.readInt32LE=g(function(e,t){return e>>>=0,t||q(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},"readInt32LE"),o.prototype.readInt32BE=g(function(e,t){return e>>>=0,t||q(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},"readInt32BE"),o.prototype.readBigInt64LE=eu(g(function(e){Y(e>>>=0,"offset");let t=this[e],r=this[e+7];return(void 0===t||void 0===r)&&Z(e,this.length-8),(BigInt(this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24))<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+16777216*this[++e])},"readBigInt64LE")),o.prototype.readBigInt64BE=eu(g(function(e){Y(e>>>=0,"offset");let t=this[e],r=this[e+7];return(void 0===t||void 0===r)&&Z(e,this.length-8),(BigInt((t<<24)+65536*this[++e]+256*this[++e]+this[++e])<<BigInt(32))+BigInt(16777216*this[++e]+65536*this[++e]+256*this[++e]+r)},"readBigInt64BE")),o.prototype.readFloatLE=g(function(e,t){return e>>>=0,t||q(e,4,this.length),r.read(this,e,!0,23,4)},"readFloatLE"),o.prototype.readFloatBE=g(function(e,t){return e>>>=0,t||q(e,4,this.length),r.read(this,e,!1,23,4)},"readFloatBE"),o.prototype.readDoubleLE=g(function(e,t){return e>>>=0,t||q(e,8,this.length),r.read(this,e,!0,52,8)},"readDoubleLE"),o.prototype.readDoubleBE=g(function(e,t){return e>>>=0,t||q(e,8,this.length),r.read(this,e,!1,52,8)},"readDoubleBE"),g(D,"checkInt"),o.prototype.writeUintLE=o.prototype.writeUIntLE=g(function(e,t,r,i){if(e=+e,t>>>=0,r>>>=0,!i){let i=Math.pow(2,8*r)-1;D(this,e,t,r,i,0)}let s=1,n=0;for(this[t]=255&e;++n<r&&(s*=256);)this[t+n]=e/s&255;return t+r},"writeUIntLE"),o.prototype.writeUintBE=o.prototype.writeUIntBE=g(function(e,t,r,i){if(e=+e,t>>>=0,r>>>=0,!i){let i=Math.pow(2,8*r)-1;D(this,e,t,r,i,0)}let s=r-1,n=1;for(this[t+s]=255&e;--s>=0&&(n*=256);)this[t+s]=e/n&255;return t+r},"writeUIntBE"),o.prototype.writeUint8=o.prototype.writeUInt8=g(function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,1,255,0),this[t]=255&e,t+1},"writeUInt8"),o.prototype.writeUint16LE=o.prototype.writeUInt16LE=g(function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},"writeUInt16LE"),o.prototype.writeUint16BE=o.prototype.writeUInt16BE=g(function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},"writeUInt16BE"),o.prototype.writeUint32LE=o.prototype.writeUInt32LE=g(function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},"writeUInt32LE"),o.prototype.writeUint32BE=o.prototype.writeUInt32BE=g(function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},"writeUInt32BE"),g(F,"wrtBigUInt64LE"),g(j,"wrtBigUInt64BE"),o.prototype.writeBigUInt64LE=eu(g(function(e,t=0){return F(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))},"writeBigUInt64LE")),o.prototype.writeBigUInt64BE=eu(g(function(e,t=0){return j(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))},"writeBigUInt64BE")),o.prototype.writeIntLE=g(function(e,t,r,i){if(e=+e,t>>>=0,!i){let i=Math.pow(2,8*r-1);D(this,e,t,r,i-1,-i)}let s=0,n=1,o=0;for(this[t]=255&e;++s<r&&(n*=256);)e<0&&0===o&&0!==this[t+s-1]&&(o=1),this[t+s]=(e/n>>0)-o&255;return t+r},"writeIntLE"),o.prototype.writeIntBE=g(function(e,t,r,i){if(e=+e,t>>>=0,!i){let i=Math.pow(2,8*r-1);D(this,e,t,r,i-1,-i)}let s=r-1,n=1,o=0;for(this[t+s]=255&e;--s>=0&&(n*=256);)e<0&&0===o&&0!==this[t+s+1]&&(o=1),this[t+s]=(e/n>>0)-o&255;return t+r},"writeIntBE"),o.prototype.writeInt8=g(function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},"writeInt8"),o.prototype.writeInt16LE=g(function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},"writeInt16LE"),o.prototype.writeInt16BE=g(function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},"writeInt16BE"),o.prototype.writeInt32LE=g(function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},"writeInt32LE"),o.prototype.writeInt32BE=g(function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},"writeInt32BE"),o.prototype.writeBigInt64LE=eu(g(function(e,t=0){return F(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))},"writeBigInt64LE")),o.prototype.writeBigInt64BE=eu(g(function(e,t=0){return j(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}
1,"writeBigInt64BE")),g(U,"checkIEEE754"),g(W,"writeFloat"),o.prototype.writeFloatLE=g(function(e,t,r){return W(this,e,t,!0,r)},"writeFloatLE"),o.prototype.writeFloatBE=g(function(e,t,r){return W(this,e,t,!1,r)},"writeFloatBE"),g(z,"writeDouble"),o.prototype.writeDoubleLE=g(function(e,t,r){return z(this,e,t,!0,r)},"writeDoubleLE"),o.prototype.writeDoubleBE=g(function(e,t,r){return z(this,e,t,!1,r)},"writeDoubleBE"),o.prototype.copy=g(function(e,t,r,i){if(!o.isBuffer(e))throw TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<r&&(i=r),i===r||0===e.length||0===this.length)return 0;if(t<0)throw RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw RangeError("Index out of range");if(i<0)throw RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-r&&(i=e.length-t+r);let s=i-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,i):Uint8Array.prototype.set.call(e,this.subarray(r,i),t),s},"copy"),o.prototype.fill=g(function(e,t,r,i){let s;if("string"==typeof e){if("string"==typeof t?(i=t,t=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),void 0!==i&&"string"!=typeof i)throw TypeError("encoding must be a string");if("string"==typeof i&&!o.isEncoding(i))throw TypeError("Unknown encoding: "+i);if(1===e.length){let t=e.charCodeAt(0);("utf8"===i&&t<128||"latin1"===i)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw RangeError("Out of range index");if(r<=t)return this;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s<r;++s)this[s]=e;else{let n=o.isBuffer(e)?e:o.from(e,i),a=n.length;if(0===a)throw TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<r-t;++s)this[s+t]=n[s%a]}return this},"fill");var V={};function G(e,t,r){var i;V[e]=(g(i=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}\
2]: ${this.message}`}},"NodeError"),i)}function H(e){let t="",r=e.length,i="-"===e[0]?1:0;for(;r>=i+4;r-=3)t=`\
3_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function K(e,t,r){Y(t,"offset"),(void 0===e[t]||void 0===e[t+r])&&Z(t,e.length-(r+1))}function J(e,t,r,i,s,n){if(e>r||e<t){let i="bigint"==typeof t?"n":"",s;throw s=n>3?0===t||t===BigInt(0)?`>= 0${i} and < 2${i}\
4 ** ${(n+1)*8}${i}`:`>= -(2${i} ** ${(n+1)*8-1}${i}) and < 2 ** ${(n+1)*8-1}${i}`:`>= ${t}${i} a\
5nd <= ${r}${i}`,new V.ERR_OUT_OF_RANGE("value",s,e)}K(i,s,n)}function Y(e,t){if("number"!=typeof e)throw new V.ERR_INVALID_ARG_TYPE(t,"number",e)}function Z(e,t,r){throw Math.floor(e)!==e?(Y(e,r),new V.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new V.ERR_BUFFER_OUT_OF_BOUNDS:new V.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}g(G,"E"),G("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),G("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received typ\
6e ${typeof t}`},TypeError),G("ERR_OUT_OF_RANGE",function(e,t,r){let i=`The value of "${e}" is out o\
7f range.`,s=r;return Number.isInteger(r)&&Math.abs(r)>4294967296?s=H(String(r)):"bigint"==typeof r&&(s=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(s=H(s)),s+="n"),i+=` It must be ${t}. Re\
8ceived ${s}`},RangeError),g(H,"addNumericalSeparator"),g(K,"checkBounds"),g(J,"checkIntBI"),g(Y,"validateNumber"),g(Z,"boundsError");var X=/[^+/0-9A-Za-z-_]/g;function ee(e){if((e=(e=e.split("=")[0]).trim().replace(X,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}function et(e,t){t=t||1/0;let r,i=e.length,s=null,n=[];for(let o=0;o<i;++o){if((r=e.charCodeAt(o))>55295&&r<57344){if(!s){if(r>56319||o+1===i){(t-=3)>-1&&n.push(239,191,189);continue}s=r;continue}if(r<56320){(t-=3)>-1&&n.push(239,191,189),s=r;continue}r=(s-55296<<10|r-56320)+65536}else s&&(t-=3)>-1&&n.push(239,191,189);if(s=null,r<128){if((t-=1)<0)break;n.push(r)}else if(r<2048){if((t-=2)<0)break;n.push(r>>6|192,63&r|128)}
8else if(r<65536){if((t-=3)<0)break;n.push(r>>12|224,r>>6&63|128,63&r|128)}else if(r<1114112){if((t-=4)<0)break;n.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}else throw Error("Invalid code point")}return n}function er(e){let t=[];for(let r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}function ei(e,t){let r,i,s=[];for(let n=0;n<e.length&&!((t-=2)<0);++n)i=(r=e.charCodeAt(n))>>8,s.push(r%256),s.push(i);return s}function es(e){return t.toByteArray(ee(e))}function en(e,t,r,i){let s;for(s=0;s<i&&!(s+r>=t.length||s>=e.length);++s)t[s+r]=e[s];return s}function eo(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function ea(e){return e!=e}g(ee,"base64clean"),g(et,"utf8ToBytes"),g(er,"asciiToBytes"),g(ei,"utf16leToBytes"),g(es,"base64ToBytes"),g(en,"blitBuffer"),g(eo,"isInstance"),g(ea,"numberIsNaN");var el=function(){let e="0123456789abcdef",t=Array(256);for(let r=0;r<16;++r){let i=16*r;for(let s=0;s<16;++s)t[i+s]=e[r]+e[s]}return t}();function eu(e){return typeof BigInt>"u"?eh:e}function eh(){throw Error("BigInt not supported")}g(eu,"defineBigIntMethod"),g(eh,"BufferBigIntNotDefined")}),P=m(()=>{n=globalThis,o=globalThis.setImmediate??(e=>setTimeout(e,0)),globalThis.clearImmediate??(e=>clearTimeout(e)),a="function"==typeof globalThis.Buffer&&"function"==typeof globalThis.Buffer.allocUnsafe?globalThis.Buffer:C().Buffer,(l=globalThis.process??{}).env??(l.env={});try{l.nextTick(()=>{})}catch{let e=Promise.resolve();l.nextTick=e.then.bind(e)}}),L=b((e,t)=>{P();var r,i="object"==typeof Reflect?Reflect:null,s=i&&"function"==typeof i.apply?i.apply:g(function(e,t,r){return Function.prototype.apply.call(e,t,r)},"ReflectApply");function n(e){console&&console.warn&&console.warn(e)}r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?g(function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))},"ReflectOwnKeys"):g(function(e){return Object.getOwnPropertyNames(e)},"ReflectOwnKeys"),g(n,"ProcessEmitWarning");var o=Number.isNaN||g(function(e){return e!=e},"NumberIsNaN");function a(){a.init.call(this)}g(a,"EventEmitter"),t.exports=a,t.exports.once=v,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var l=10;function u(e){if("function"!=typeof e)throw TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function h(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function c(e,t,r,i){var s,o,a;if(u(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),a=o[t]),void 0===a)a=o[t]=r,++e._eventsCount;else if("function"==typeof a?a=o[t]=i?[r,a]:[a,r]:i?a.unshift(r):a.push(r),(s=h(e))>0&&a.length>s&&!a.warned){a.warned=!0;var l=Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=a.length,n(l)}return e}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0==arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},s=f.bind(i);return s.listener=r,i.wrapFn=s,s}function p(e,t,r){var i=e._events;if(void 0===i)return[];var s=i[t];return void 0===s?[]:"function"==typeof s?r?[s.listener||s]:[s]:r?w(s):m(s,s.length)}function y(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function m(e,t){for(var r=Array(t),i=0;i<t;++i)r[i]=e[i];return r}function b(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function w(e){for(var t=Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function v(e,t){return new Promise(function(r,i){function s(r){e.removeListener(t,n),i(r)}function n(){"function"==typeof e.removeListener&&e.removeListener("error",s),r([].slice.call(arguments))}g(s,"errorListener"),g(n,"resolver"),_(e,t,n,{once:!0}),"error"!==t&&S(e,s,{once:!0})})}function S(e,t,r){"function"==typeof e.on&&_(e,"error",t,r)}
8function _(e,t,r,i){if("function"==typeof e.on)i.once?e.once(t,r):e.on(t,r);else if("function"==typeof e.addEventListener)e.addEventListener(t,g(function s(n){i.once&&e.removeEventListener(t,s),r(n)},"wrapListener"));else throw TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}g(u,"checkListener"),Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:g(function(){return l},"get"),set:g(function(e){if("number"!=typeof e||e<0||o(e))throw RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");l=e},"set")}),a.init=function(){(void 0===this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=g(function(e){if("number"!=typeof e||e<0||o(e))throw RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},"setMaxListeners"),g(h,"_getMaxListeners"),a.prototype.getMaxListeners=g(function(){return h(this)},"getMaxListeners"),a.prototype.emit=g(function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,n=this._events;if(void 0!==n)i=i&&void 0===n.error;else if(!i)return!1;if(i){if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var o,a=Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var l=n[e];if(void 0===l)return!1;if("function"==typeof l)s(l,this,t);else for(var u=l.length,h=m(l,u),r=0;r<u;++r)s(h[r],this,t);return!0},"emit"),g(c,"_addListener"),a.prototype.addListener=g(function(e,t){return c(this,e,t,!1)},"addListener"),a.prototype.on=a.prototype.addListener,a.prototype.prependListener=g(function(e,t){return c(this,e,t,!0)},"prependListener"),g(f,"onceWrapper"),g(d,"_onceWrap"),a.prototype.once=g(function(e,t){return u(t),this.on(e,d(this,e,t)),this},"once"),a.prototype.prependOnceListener=g(function(e,t){return u(t),this.prependListener(e,d(this,e,t)),this},"prependOnceListener"),a.prototype.removeListener=g(function(e,t){var r,i,s,n,o;if(u(t),void 0===(i=this._events)||void 0===(r=i[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(s=-1,n=r.length-1;n>=0;n--)if(r[n]===t||r[n].listener===t){o=r[n].listener,s=n;break}if(s<0)return this;0===s?r.shift():b(r,s),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,o||t)}return this},"removeListener"),a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=g(function(e){var t,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0==arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0==arguments.length){var s,n=Object.keys(r);for(i=0;i<n.length;++i)"removeListener"!==(s=n[i])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},"removeAllListeners"),g(p,"_listeners"),a.prototype.listeners=g(function(e){return p(this,e,!0)},"listeners"),a.prototype.rawListeners=g(function(e){return p(this,e,!1)},"rawListeners"),a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):y.call(e,t)},a.prototype.listenerCount=y,g(y,"listenerCount"),a.prototype.eventNames=g(function(){return this._eventsCount>0?r(this._events):[]},"eventNames"),g(m,"arrayClone"),g(b,"spliceOne"),g(w,"unwrapListeners"),g(v,"once"),g(S,"addErrorHandlerIfEventEmitter"),g(_,"eventTargetAgnosticAddListener")}),I={};function x(e){return 0}w(I,{Socket:()=>B,isIP:()=>x});var M,k,R,B,O=m(()=>{P(),M=S(L(),1),g(x,"isIP"),k=/^[^.]+\./,R=class e extends M.EventEmitter{constructor(){super(...arguments),E(this,"opts",{}),E(this,"connecting",!1),E(this,"pending",!0),E(this,"writable",!0),E(this,"encrypted",!1),E(this,"authorized",!1),E(this,"destroyed",!1),E(this,"ws",null),E(this,"writeBuffer"),E(this,"tlsState",0),E(this,"tlsRead"),E(this,"tlsWrite")}static get poolQueryViaFetch(){return e.opts.poolQueryViaFetch??e.defaults.poolQueryViaFetch}static set poolQueryViaFetch(t){e.opts.poolQueryViaFetch=t}static get fetchEndpoint(){return e.opts.fetchEndpoint??e.defaults.fetchEndpoint}static set fetchEndpoint(t){e.opts.fetchEndpoint=t}static get fetchConnectionCache(){return!0}static set fetchConnectionCache(e){console.warn("The `fetchConnectionCache` option is deprecated (now always `true`)")}static get fetchFunction(){return e.opts.fetchFunction??e.defaults.fetchFunction}static set fetchFunction(t){e.opts.fetchFunction=t}static get webSocketConstructor(){return e.opts.webSocketConstructor??e.defaults.webSocketConstructor}
8static set webSocketConstructor(t){e.opts.webSocketConstructor=t}get webSocketConstructor(){return this.opts.webSocketConstructor??e.webSocketConstructor}set webSocketConstructor(e){this.opts.webSocketConstructor=e}static get wsProxy(){return e.opts.wsProxy??e.defaults.wsProxy}static set wsProxy(t){e.opts.wsProxy=t}get wsProxy(){return this.opts.wsProxy??e.wsProxy}set wsProxy(e){this.opts.wsProxy=e}static get coalesceWrites(){return e.opts.coalesceWrites??e.defaults.coalesceWrites}static set coalesceWrites(t){e.opts.coalesceWrites=t}get coalesceWrites(){return this.opts.coalesceWrites??e.coalesceWrites}set coalesceWrites(e){this.opts.coalesceWrites=e}static get useSecureWebSocket(){return e.opts.useSecureWebSocket??e.defaults.useSecureWebSocket}static set useSecureWebSocket(t){e.opts.useSecureWebSocket=t}get useSecureWebSocket(){return this.opts.useSecureWebSocket??e.useSecureWebSocket}set useSecureWebSocket(e){this.opts.useSecureWebSocket=e}static get forceDisablePgSSL(){return e.opts.forceDisablePgSSL??e.defaults.forceDisablePgSSL}static set forceDisablePgSSL(t){e.opts.forceDisablePgSSL=t}get forceDisablePgSSL(){return this.opts.forceDisablePgSSL??e.forceDisablePgSSL}set forceDisablePgSSL(e){this.opts.forceDisablePgSSL=e}static get disableSNI(){return e.opts.disableSNI??e.defaults.disableSNI}static set disableSNI(t){e.opts.disableSNI=t}get disableSNI(){return this.opts.disableSNI??e.disableSNI}set disableSNI(e){this.opts.disableSNI=e}static get disableWarningInBrowsers(){return e.opts.disableWarningInBrowsers??e.defaults.disableWarningInBrowsers}static set disableWarningInBrowsers(t){e.opts.disableWarningInBrowsers=t}get disableWarningInBrowsers(){return this.opts.disableWarningInBrowsers??e.disableWarningInBrowsers}set disableWarningInBrowsers(e){this.opts.disableWarningInBrowsers=e}static get pipelineConnect(){return e.opts.pipelineConnect??e.defaults.pipelineConnect}static set pipelineConnect(t){e.opts.pipelineConnect=t}get pipelineConnect(){return this.opts.pipelineConnect??e.pipelineConnect}set pipelineConnect(e){this.opts.pipelineConnect=e}static get subtls(){return e.opts.subtls??e.defaults.subtls}static set subtls(t){e.opts.subtls=t}get subtls(){return this.opts.subtls??e.subtls}set subtls(e){this.opts.subtls=e}static get pipelineTLS(){return e.opts.pipelineTLS??e.defaults.pipelineTLS}static set pipelineTLS(t){e.opts.pipelineTLS=t}get pipelineTLS(){return this.opts.pipelineTLS??e.pipelineTLS}set pipelineTLS(e){this.opts.pipelineTLS=e}static get rootCerts(){return e.opts.rootCerts??e.defaults.rootCerts}static set rootCerts(t){e.opts.rootCerts=t}get rootCerts(){return this.opts.rootCerts??e.rootCerts}set rootCerts(e){this.opts.rootCerts=e}wsProxyAddrForHost(e,t){let r=this.wsProxy;if(void 0===r)throw Error("No WebSocket proxy is configured. Please see https://github.com/neondatabase/serverless/blob/main/CONFIG.md#wsproxy-string--host-string-port-number--string--string");return"function"==typeof r?r(e,t):`${r}?address=${e}:${t}`}setNoDelay(){return this}setKeepAlive(){return this}ref(){return this}unref(){return this}connect(e,t,r){this.connecting=!0,r&&this.once("connect",r);let i=g(()=>{this.connecting=!1,this.pending=!1,this.emit("connect"),this.emit("ready")},"handleWebSocketOpen"),s=g((e,t=!1)=>{e.binaryType="arraybuffer",e.addEventListener("error",e=>{this.emit("error",e),this.emit("close")}),e.addEventListener("message",e=>{if(0===this.tlsState){let t=a.from(e.data);this.emit("data",t)}}),e.addEventListener("close",()=>{this.emit("close")}),t?i():e.addEventListener("open",i)},"configureWebSocket"),n;try{n=this.wsProxyAddrForHost(t,"string"==typeof e?parseInt(e,10):e)}catch(e){this.emit("error",e),this.emit("close");return}try{let e=(this.useSecureWebSocket?"wss:":"ws:")+"//"+n;if(void 0!==this.webSocketConstructor)this.ws=new this.webSocketConstructor(e),s(this.ws);else try{this.ws=new WebSocket(e),s(this.ws)}catch{this.ws=new __unstable_WebSocket(e),s(this.ws)}}catch(e){fetch((this.useSecureWebSocket?"https:":"http:")+"//"+n,{headers:{Upgrade:"websocket"}}).then(t=>{if(this.ws=t.webSocket,null==this.ws)throw e;this.ws.accept(),s(this.ws,!0)}).catch(e=>
8{this.emit("error",Error(`All attempts to open a WebSocket to connect to the database failed. Please refer \
9to https://github.com/neondatabase/serverless/blob/main/CONFIG.md#websocketconstructor-typeof-websoc\
10ket--undefined. Details: ${e}`)),this.emit("close")})}}async startTls(e){if(void 0===this.subtls)throw Error("For Postgres SSL connections, you must set `neonConfig.subtls` to the subtls library. See https://github.com/neondatabase/serverless/blob/main/CONFIG.md for more information.");this.tlsState=1;let t=await this.subtls.TrustedCert.databaseFromPEM(this.rootCerts),r=new this.subtls.WebSocketReadQueue(this.ws),i=r.read.bind(r),s=this.rawWrite.bind(this),{read:n,write:o}=await this.subtls.startTls(e,t,i,s,{useSNI:!this.disableSNI,expectPreData:this.pipelineTLS?new Uint8Array([83]):void 0});this.tlsRead=n,this.tlsWrite=o,this.tlsState=2,this.encrypted=!0,this.authorized=!0,this.emit("secureConnection",this),this.tlsReadLoop()}async tlsReadLoop(){for(;;){let e=await this.tlsRead();if(void 0===e)break;{let t=a.from(e);this.emit("data",t)}}}rawWrite(e){if(!this.coalesceWrites){this.ws&&this.ws.send(e);return}if(void 0===this.writeBuffer)this.writeBuffer=e,setTimeout(()=>{this.ws&&this.ws.send(this.writeBuffer),this.writeBuffer=void 0},0);else{let t=new Uint8Array(this.writeBuffer.length+e.length);t.set(this.writeBuffer),t.set(e,this.writeBuffer.length),this.writeBuffer=t}}write(e,t="utf8",r=e=>{}){return 0===e.length?r():("string"==typeof e&&(e=a.from(e,t)),0===this.tlsState?(this.rawWrite(e),r()):1===this.tlsState?this.once("secureConnection",()=>{this.write(e,t,r)}):(this.tlsWrite(e),r())),!0}end(e=a.alloc(0),t="utf8",r=()=>{}){return this.write(e,t,()=>{this.ws.close(),r()}),this}destroy(){return this.destroyed=!0,this.end()}},g(R,"Socket"),E(R,"defaults",{poolQueryViaFetch:!1,fetchEndpoint:g((e,t,r)=>"https://"+(r?.jwtAuth?e.replace(k,"apiauth."):e.replace(k,"api."))+"/sql","fetchEndpoint"),fetchConnectionCache:!0,fetchFunction:void 0,webSocketConstructor:void 0,wsProxy:g(e=>e+"/v2","wsProxy"),useSecureWebSocket:!0,forceDisablePgSSL:!0,coalesceWrites:!0,pipelineConnect:"password",subtls:void 0,rootCerts:"",pipelineTLS:!1,disableSNI:!1,disableWarningInBrowsers:!1}),E(R,"opts",{}),B=R}),N={};function $(e,t=!1){let{protocol:r}=new URL(e),{username:i,password:s,host:n,hostname:o,port:a,pathname:l,search:u,searchParams:h,hash:c}=new URL("http:"+e.substring(r.length));s=decodeURIComponent(s),i=decodeURIComponent(i),l=decodeURIComponent(l);let f=i+":"+s,d=t?Object.fromEntries(h.entries()):u;return{href:e,protocol:r,auth:f,username:i,password:s,host:n,hostname:o,port:a,pathname:l,search:u,query:d,hash:c}}w(N,{parse:()=>$});var Q=m(()=>{P(),g($,"parse")}),q=b(e=>{P(),e.parse=function(e,t){return new r(e,t).parse()};var t=class e{constructor(e,t){this.source=e,this.transform=t||i,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)&&("NULL"!==(t=this.recorded.join(""))||e||(t=null),null!==t&&(t=this.transform(t)),this.entries.push(t),this.recorded=[])}consumeDimensions(){if("["===this.source[0])for(;!this.isEof()&&"="!==this.nextCharacter().value;);}parse(t){var r,i,s;for(this.consumeDimensions();!this.isEof();)if("{"!==(r=this.nextCharacter()).value||s){if("}"!==r.value||s)'"'!==r.value||r.escaped?","!==r.value||s?this.record(r.value):this.newEntry():(s&&this.newEntry(!0),s=!s);else if(this.dimension--,!this.dimension&&(this.newEntry(),t))return this.entries}else this.dimension++,this.dimension>1&&(i=new e(this.source.substr(this.position-1),this.transform),this.entries.push(i.parse(!0)),this.position+=i.position-2);if(0!==this.dimension)throw Error("array dimension not balanced");return this.entries}};g(t,"ArrayParser");var r=t;function i(e){return e}g(i,"identity")}),D=b((e,t)=>{P();var r=q();t.exports={create:g(function(e,t){return{parse:g(function(){return r.parse(e,t)},"parse")}},"create")}}),F=b((e,t)=>{P();var r=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/,i=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,s=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,n=/^-?infinity$/;function o(e){var t=i.exec(e);if(t){var r=parseInt(t[1],10);t[4]&&(r=l(r));var s=new Date(r,parseInt(t[2],10)-1,t[3]);return u(r)&&s.setFullYear(r),s}}function a(e){if(e.endsWith("+00"))return 0;var t=s.exec(e.split(" ")[1]);if(t){var r=t[1];return"Z"===r?0:(3600*parseInt(t[2],10)+60*parseInt(t[3]||0,10)+parseInt(t[4]||0,10))*("-"===r?-1:1)*1e3}}function l(e){return-(e-1)}function u(e){return e>=0&&e<100}t.exports=g(function(e){if(n.test(e))return Number(e.replace("i","I"));var t=r.exec(e);if(!t)return o(e)||null;var i=!!t[8],s=parseInt(t[1],10);i&&(s=l(s));var h=parseInt(t[2],10)-1,c=t[3],f=parseInt(t[4],10),d=parseInt(t[5],10),p=parseInt(t[6],10),y=t[7];y=y?1e3*parseFloat(y):0;var g,m=a(e);return null!=m?(g=new Date(Date.UTC(s,h,c,f,d,p,y)),u(s)&&g.setUTCFullYear(s),0!==m&&g.setTime(g.getTime()-m)):(g=new Date(s,h,c,f,d,p,y),u(s)&&g.setFullYear(s)),g},"parseDate"),g(o,"getDate"),g(a,"timeZoneOffset"),g(l,"bcYearToNegativeYear"),g(u,"
10is0To99")}),j=b((e,t)=>{P(),t.exports=i;var r=Object.prototype.hasOwnProperty;function i(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var s in i)r.call(i,s)&&(e[s]=i[s])}return e}g(i,"extend")}),U=b((e,t)=>{P();var r=j();function i(e){if(!(this instanceof i))return new i(e);r(this,d(e))}t.exports=i,g(i,"PostgresInterval");var s=["seconds","minutes","hours","days","months","years"];i.prototype.toPostgres=function(){var e=s.filter(this.hasOwnProperty,this);return this.milliseconds&&0>e.indexOf("seconds")&&e.push("seconds"),0===e.length?"0":e.map(function(e){var t=this[e]||0;return"seconds"===e&&this.milliseconds&&(t=(t+this.milliseconds/1e3).toFixed(6).replace(/\.?0+$/,"")),t+" "+e},this).join(" ")};var n={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"S"},o=["years","months","days"],a=["hours","minutes","seconds"];i.prototype.toISOString=i.prototype.toISO=function(){return"P"+o.map(e,this).join("")+"T"+a.map(e,this).join("");function e(e){var t=this[e]||0;return"seconds"===e&&this.milliseconds&&(t=(t+this.milliseconds/1e3).toFixed(6).replace(/0+$/,"")),t+n[e]}};var l="([+-]?\\d+)",u=new RegExp([l+"\\s+years?",l+"\\s+mons?",l+"\\s+days?","([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?"].map(function(e){return"("+e+")?"}).join("\\s*")),h={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12},c=["hours","minutes","seconds","milliseconds"];function f(e){return parseInt(e+"000000".slice(e.length),10)/1e3}function d(e){if(!e)return{};var t=u.exec(e),r="-"===t[8];return Object.keys(h).reduce(function(e,i){var s=t[h[i]];return s&&(s="milliseconds"===i?f(s):parseInt(s,10))&&(r&&~c.indexOf(i)&&(s*=-1),e[i]=s),e},{})}g(f,"parseMilliseconds"),g(d,"parse")}),W=b((e,t)=>{P(),t.exports=g(function(e){if(/^\\x/.test(e))return new a(e.substr(2),"hex");for(var t="",r=0;r<e.length;)if("\\"!==e[r])t+=e[r],++r;else if(/[0-7]{3}/.test(e.substr(r+1,3)))t+=String.fromCharCode(parseInt(e.substr(r+1,3),8)),r+=4;else{for(var i=1;r+i<e.length&&"\\"===e[r+i];)i++;for(var s=0;s<Math.floor(i/2);++s)t+="\\";r+=2*Math.floor(i/2)}return new a(t,"binary")},"parseBytea")}),z=b((e,t)=>{P();var r=q(),i=D(),s=F(),n=U(),o=W();function a(e){return g(function(t){return null===t?t:e(t)},"nullAllowed")}function l(e){return null===e?e:"TRUE"===e||"t"===e||"true"===e||"y"===e||"yes"===e||"on"===e||"1"===e}function u(e){return e?r.parse(e,l):null}function h(e){return parseInt(e,10)}function c(e){return e?r.parse(e,a(h)):null}function f(e){return e?r.parse(e,a(function(e){return S(e).trim()})):null}g(a,"allowNull"),g(l,"parseBool"),g(u,"parseBoolArray"),g(h,"parseBaseTenInt"),g(c,"parseIntegerArray"),g(f,"parseBigIntegerArray");var d=g(function(e){return e?i.create(e,function(e){return null!==e&&(e=E(e)),e}).parse():null},"parsePointArray"),p=g(function(e){return e?i.create(e,function(e){return null!==e&&(e=parseFloat(e)),e}).parse():null},"parseFloatArray"),y=g(function(e){return e?i.create(e).parse():null},"parseStringArray"),m=g(function(e){return e?i.create(e,function(e){return null!==e&&(e=s(e)),e}).parse():null},"parseDateArray"),b=g(function(e){return e?i.create(e,function(e){return null!==e&&(e=n(e)),e}).parse():null},"parseIntervalArray"),w=g(function(e){return e?r.parse(e,a(o)):null},"parseByteAArray"),v=g(function(e){return parseInt(e,10)},"parseInteger"),S=g(function(e){var t=String(e);return/^\d+$/.test(t)?t:e},"parseBigInteger"),_=g(function(e){return e?r.parse(e,a(JSON.parse)):null},"parseJsonArray"),E=g(function(e){return"("!==e[0]?null:{x:parseFloat((e=e.substring(1,e.length-1).split(","))[0]),y:parseFloat(e[1])}},"parsePoint"),A=g(function(e){if("<"!==e[0]&&"("!==e[1])return null;for(var t="(",r="",i=!1,s=2;s<e.length-1;s++){if(i||(t+=e[s]),")"===e[s]){i=!0;continue}i&&","!==e[s]&&(r+=e[s])}var n=E(t);return n.radius=parseFloat(r),n},"parseCircle"),T=g(function(e){e(20,S),e(21,v),e(23,v),e(26,v),e(700,parseFloat),e(701,parseFloat),e(16,l),e(1082,s),e(1114,s),e(1184,s),e(600,E),e(651,y),e(718,A),e(1e3,u),e(1001,w),e(1005,c),e(1007,c),e(1028,c),e(1016,f),e(1017,d),e(1021,p),e(1022,p),e(1231,p),e(1014,y),e(1015,y),e(1008,y),e(1009,y),e(1040,y),e(1041,y),e(1115,m),e(1182,m),e(1185,m),e(1186,n),e(1187,b),e(17,o),e(114,JSON.parse.bind(JSON)),e(3802,JSON.parse.bind(JSON)),e(199,_),e(3807,_),e(3907,y),e(2951,y),e(791,y),e(1183,y),e(1270,y)},"init");t.exports={init:T}}),V=b((e,t)=>{function r(e){var t=e.readInt32BE(0),r=e.readUInt32BE(4),i="";t<0&&(t=~t+(0===r),r=~r+1>>>0,i="-");var s,n,o,a,l,u,h="";if(s=t%1e6,t=t/1e6>>>0,r=(n=4294967296*s+r)/1e6>>>0,o=""+(n-1e6*r),0===r&&0===t)return i+o+h;for(a="",l=6-o.length,u=0;u<l;u++)a+="0";
10if(h=a+o+h,s=t%1e6,t=t/1e6>>>0,r=(n=4294967296*s+r)/1e6>>>0,o=""+(n-1e6*r),0===r&&0===t)return i+o+h;for(a="",l=6-o.length,u=0;u<l;u++)a+="0";if(h=a+o+h,s=t%1e6,t=t/1e6>>>0,r=(n=4294967296*s+r)/1e6>>>0,o=""+(n-1e6*r),0===r&&0===t)return i+o+h;for(a="",l=6-o.length,u=0;u<l;u++)a+="0";return h=a+o+h,i+(o=""+(n=4294967296*(s=t%1e6)+r)%1e6)+h}P(),g(r,"readInt8"),t.exports=r}),G=b((e,t)=>{P();var r=V(),i=g(function(e,t,r,i,s){r=r||0,i=i||!1,s=s||function(e,t,r){return e*Math.pow(2,r)+t};var n=r>>3,o=g(function(e){return i?255&~e:e},"inv"),a=255,l=8-r%8;t<l&&(a=255<<8-t&255,l=t),r&&(a>>=r%8);var u=0;r%8+t>=8&&(u=s(0,o(e[n])&a,l));for(var h=t+r>>3,c=n+1;c<h;c++)u=s(u,o(e[c]),8);var f=(t+r)%8;return f>0&&(u=s(u,o(e[h])>>8-f,f)),u},"parseBits"),s=g(function(e,t,r){var s=Math.pow(2,r-1)-1,n=i(e,1),o=i(e,r,1);if(0===o)return 0;var a=1,l=i(e,t,r+1,!1,g(function(e,t,r){0===e&&(e=1);for(var i=1;i<=r;i++)a/=2,(t&1<<r-i)>0&&(e+=a);return e},"parsePrecisionBits"));return o==Math.pow(2,r+1)-1?0===l?0===n?1/0:-1/0:NaN:(0===n?1:-1)*Math.pow(2,o-s)*l},"parseFloatFromBits"),n=g(function(e){return 1==i(e,1)?-1*(i(e,15,1,!0)+1):i(e,15,1)},"parseInt16"),o=g(function(e){return 1==i(e,1)?-1*(i(e,31,1,!0)+1):i(e,31,1)},"parseInt32"),a=g(function(e){return s(e,23,8)},"parseFloat32"),l=g(function(e){return s(e,52,11)},"parseFloat64"),u=g(function(e){var t=i(e,16,32);if(49152==t)return NaN;for(var r=Math.pow(1e4,i(e,16,16)),s=0,n=i(e,16),o=0;o<n;o++)s+=i(e,16,64+16*o)*r,r/=1e4;var a=Math.pow(10,i(e,16,48));return(0===t?1:-1)*Math.round(s*a)/a},"parseNumeric"),h=g(function(e,t){var r=i(t,1),s=i(t,63,1),n=new Date((0===r?1:-1)*s/1e3+9466848e5);return e||n.setTime(n.getTime()+6e4*n.getTimezoneOffset()),n.usec=s%1e3,n.getMicroSeconds=function(){return this.usec},n.setMicroSeconds=function(e){this.usec=e},n.getUTCMicroSeconds=function(){return this.usec},n},"parseDate"),c=g(function(e){for(var t=i(e,32),r=(i(e,32,32),i(e,32,64)),s=96,n=[],o=0;o<t;o++)n[o]=i(e,32,s),s+=64;var a=g(function(t){var r,n=i(e,32,s);return(s+=32,4294967295==n)?null:23==t||20==t?(r=i(e,8*n,s),s+=8*n,r):25==t?e.toString(this.encoding,s>>3,(s+=n<<3)>>3):void console.log("ERROR: ElementType not implemented: "+t)},"parseElement"),l=g(function(e,t){var r,i=[];if(e.length>1){var s=e.shift();for(r=0;r<s;r++)i[r]=l(e,t);e.unshift(s)}else for(r=0;r<e[0];r++)i[r]=a(t);return i},"parse");return l(n,r)},"parseArray"),f=g(function(e){return e.toString("utf8")},"parseText"),d=g(function(e){return null===e?null:i(e,8)>0},"parseBool"),p=g(function(e){e(20,r),e(21,n),e(23,o),e(26,o),e(1700,u),e(700,a),e(701,l),e(16,d),e(1114,h.bind(null,!1)),e(1184,h.bind(null,!0)),e(1e3,c),e(1007,c),e(1016,c),e(1008,c),e(1009,c),e(25,f)},"init");t.exports={init:p}}),H=b((e,t)=>{P(),t.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}}),K=b(e=>{P();var t=z(),r=G(),i=D(),s=H();e.getTypeParser=a,e.setTypeParser=l,e.arrayParser=i,e.builtins=s;var n={text:{},binary:{}};function o(e){return String(e)}function a(e,t){return n[t=t||"text"]&&n[t][e]||o}function l(e,t,r){"function"==typeof t&&(r=t,t="text"),n[t][e]=r}g(o,"noParse"),g(a,"getTypeParser"),g(l,"setTypeParser"),t.init(function(e,t){n.text[e]=t}),r.init(function(e,t){n.binary[e]=t})}),J=b((e,t)=>{P();var r=K();function i(e){this._types=e||r,this.text={},this.binary={}}g(i,"TypeOverrides"),i.prototype.getOverrides=function(e){switch(e){case"text":return this.text;case"binary":return this.binary;default:return{}}},i.prototype.setTypeParser=function(e,t,r){"function"==typeof t&&(r=t,t="text"),this.getOverrides(t)[e]=r},i.prototype.getTypeParser=function(e,t){return t=t||"text",this.getOverrides(t)[e]||this._types.getTypeParser(e,t)},t.exports=i});function Y(e){let t=1779033703,r=3144134277,i=1013904242,s=2773480762,n=1359893119,o=2600822924,a=528734635,l=1541459225,u=0,h=0,c=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756
10734187,3204031479,3329325298],f=g((e,t)=>e>>>t|e<<32-t,"rrot"),d=new Uint32Array(64),p=new Uint8Array(64),y=g(()=>{for(let e=0,t=0;e<16;e++,t+=4)d[e]=p[t]<<24|p[t+1]<<16|p[t+2]<<8|p[t+3];for(let e=16;e<64;e++){let t=f(d[e-15],7)^f(d[e-15],18)^d[e-15]>>>3,r=f(d[e-2],17)^f(d[e-2],19)^d[e-2]>>>10;d[e]=d[e-16]+t+d[e-7]+r|0}let e=t,u=r,y=i,g=s,m=n,b=o,w=a,v=l;for(let t=0;t<64;t++){let r=v+(f(m,6)^f(m,11)^f(m,25))+(m&b^~m&w)+c[t]+d[t]|0,i=(f(e,2)^f(e,13)^f(e,22))+(e&u^e&y^u&y)|0;v=w,w=b,b=m,m=g+r|0,g=y,y=u,u=e,e=r+i|0}t=t+e|0,r=r+u|0,i=i+y|0,s=s+g|0,n=n+m|0,o=o+b|0,a=a+w|0,l=l+v|0,h=0},"process"),m=g(e=>{"string"==typeof e&&(e=new TextEncoder().encode(e));for(let t=0;t<e.length;t++)p[h++]=e[t],64===h&&y();u+=e.length},"add"),b=g(()=>{if(p[h++]=128,64==h&&y(),h+8>64){for(;h<64;)p[h++]=0;y()}for(;h<58;)p[h++]=0;let e=8*u;p[h++]=e/1099511627776&255,p[h++]=e/4294967296&255,p[h++]=e>>>24,p[h++]=e>>>16&255,p[h++]=e>>>8&255,p[h++]=255&e,y();let c=new Uint8Array(32);return c[0]=t>>>24,c[1]=t>>>16&255,c[2]=t>>>8&255,c[3]=255&t,c[4]=r>>>24,c[5]=r>>>16&255,c[6]=r>>>8&255,c[7]=255&r,c[8]=i>>>24,c[9]=i>>>16&255,c[10]=i>>>8&255,c[11]=255&i,c[12]=s>>>24,c[13]=s>>>16&255,c[14]=s>>>8&255,c[15]=255&s,c[16]=n>>>24,c[17]=n>>>16&255,c[18]=n>>>8&255,c[19]=255&n,c[20]=o>>>24,c[21]=o>>>16&255,c[22]=o>>>8&255,c[23]=255&o,c[24]=a>>>24,c[25]=a>>>16&255,c[26]=a>>>8&255,c[27]=255&a,c[28]=l>>>24,c[29]=l>>>16&255,c[30]=l>>>8&255,c[31]=255&l,c},"digest");return void 0===e?{add:m,digest:b}:(m(e),b())}var Z,X,ee=m(()=>{P(),g(Y,"sha256")}),et=m(()=>{P(),g(Z=class e{constructor(){E(this,"_dataLength",0),E(this,"_bufferLength",0),E(this,"_state",new Int32Array(4)),E(this,"_buffer",new ArrayBuffer(68)),E(this,"_buffer8"),E(this,"_buffer32"),this._buffer8=new Uint8Array(this._buffer,0,68),this._buffer32=new Uint32Array(this._buffer,0,17),this.start()}static hashByteArray(e,t=!1){return this.onePassHasher.start().appendByteArray(e).end(t)}static hashStr(e,t=!1){return this.onePassHasher.start().appendStr(e).end(t)}static hashAsciiStr(e,t=!1){return this.onePassHasher.start().appendAsciiStr(e).end(t)}static _hex(t){let r=e.hexChars,i=e.hexOut,s,n,o,a;for(a=0;a<4;a+=1)for(n=8*a,s=t[a],o=0;o<8;o+=2)i[n+1+o]=r.charAt(15&s),s>>>=4,i[n+0+o]=r.charAt(15&s),s>>>=4;return i.join("")}static _md5cycle(e,t){let r=e[0],i=e[1],s=e[2],n=e[3];r+=(i&s|~i&n)+t[0]-680876936|0,n+=((r=(r<<7|r>>>25)+i|0)&i|~r&s)+t[1]-389564586|0,s+=((n=(n<<12|n>>>20)+r|0)&r|~n&i)+t[2]+606105819|0,i+=((s=(s<<17|s>>>15)+n|0)&n|~s&r)+t[3]-1044525330|0,r+=((i=(i<<22|i>>>10)+s|0)&s|~i&n)+t[4]-176418897|0,n+=((r=(r<<7|r>>>25)+i|0)&i|~r&s)+t[5]+1200080426|0,s+=((n=(n<<12|n>>>20)+r|0)&r|~n&i)+t[6]-1473231341|0,i+=((s=(s<<17|s>>>15)+n|0)&n|~s&r)+t[7]-45705983|0,r+=((i=(i<<22|i>>>10)+s|0)&s|~i&n)+t[8]+1770035416|0,n+=((r=(r<<7|r>>>25)+i|0)&i|~r&s)+t[9]-1958414417|0,s+=((n=(n<<12|n>>>20)+r|0)&r|~n&i)+t[10]-42063|0,i+=((s=(s<<17|s>>>15)+n|0)&n|~s&r)+t[11]-1990404162|0,r+=((i=(i<<22|i>>>10)+s|0)&s|~i&n)+t[12]+1804603682|0,n+=((r=(r<<7|r>>>25)+i|0)&i|~r&s)+t[13]-40341101|0,s+=((n=(n<<12|n>>>20)+r|0)&r|~n&i)+t[14]-1502002290|0,i+=((s=(s<<17|s>>>15)+n|0)&n|~s&r)+t[15]+1236535329|0,r+=((i=(i<<22|i>>>10)+s|0)&n|s&~n)+t[1]-165796510|0,n+=((r=(r<<5|r>>>27)+i|0)&s|i&~s)+t[6]-1069501632|0,s+=((n=(n<<9|n>>>23)+r|0)&i|r&~i)+t[11]+643717713|0,i+=((s=(s<<14|s>>>18)+n|0)&r|n&~r)+t[0]-373897302|0,r+=((i=(i<<20|i>>>12)+s|0)&n|s&~n)+t[5]-701558691|0,n+=((r=(r<<5|r>>>27)+i|0)&s|i&~s)+t[10]+38016083|0,s+=((n=(n<<9|n>>>23)+r|0)&i|r&~i)+t[15]-660478335|0,i+=((s=(s<<14|s>>>18)+n|0)&r|n&~r)+t[4]-405537848|0,r+=((i=(i<<20|i>>>12)+s|0)&n|s&~n)+t[9]+568446438|0,n+=((r=(r<<5|r>>>27)+i|0)&s|i&~s)+t[14]-1019803690|0,s+=((n=(n<<9|n>>>23)+r|0)&i|r&~i)+t[3]-187363961|0,i+=((s=(s<<14|s>>>18)+n|0)&r|n&~r)+t[8]+1163531501|0,r+=((i=(i<<20|i>>>12)+s|0)&n|s&~n)+t[13]-1444681467|0,n+=((r=(r<<5|r>>>27)+i|0)&s|i&~s)+t[2]-51403784|0,s+=((n=(n<<9|n>>>23)+r|0)&i|r&~i)+t[7]+1735328473|0,i+=((s=(s<<14|s>>>18)+n|0)&r|n&~r)+t[12]-1926607734|0,r+=((i=(i<<20|i>>>12)+s|0)^s^n)+t[5]-378558|0,n+=((r=(r<<4|r>>>28)+i|0)^i^s)+t[8]-2022574463|0,s+=((n=(n<<11|n>>>21)+r|0)^r^i)+t[11]+1839030562|0,i+=((s=(s<<16|s>>>16)+n|0)^n^r)+t[14]-35309556|0,r+=((i=(i<<23|i>>>9)+s|0)^s^n)+t[1]-1530992060|0,n+=((r=(r<<4|r>>>28)+i|0)^i^s)+t[4]+1272893353|0,s+=((n=(n<<11|n>>>21)+r|0)^r^i)+t[7]-155497632|0,i+=((s=(s<<16|s>>>16)+n|0)^n^r)+t[10]-1094730640|0,r+=((i=(i<<23|i>>>9)+s|0)^s^n)+t[13]+681279174|0,n+=((r=(r<<4|r>>>28)+i|0)^i^s)+t[0]-358537222|0,s+=((n=(n<<11|n>>>21)+r|0)^r^i)+t[3]-722521979|0,i+=((s=(s<<16|s>>>16)+n|0)^n^r)+t[6]+76029189|0,r+=((i=(i<<23|i>>>9)+s|0)^s^n)+t[9]-640364487|0,n+=((r=(r<<4|r>>>28)+i|0)^i^s)+t[12]-421815835|0,s+=((n=(n<<11|n>>>21)+r|0)^r^i)+t[15]+530742520|0,i+=((s=(s<<16|s>>>16)+n|0)^n^r)+t[2]-995338651|0,i=(i<<23|i>>>9)+s|0,r+=(s^(i|~n))+t[0]-198630844|0,r=(r<<6|r>>>26)+i|0,n+=(i^(r|~s))+t[7]+1126891415|0,n=(n<<10|n>>>22)+r|0,s+=(r^(n|~i))+t[14]-1416354905|0,s=(s<<15|s>>>17)+n|0,i+=(n^(s|~r))+t[5]-57434055|0,i=(i<<21|i>>>11)+s|0,r+=(s^(i|~n))+t[12]+1700485571|0,r=(r<<6|r>>>26)+i|0,n+=(i^(r|~s))+t[3]-1894986606|0,n=(n<<10|n>>>
1022)+r|0,s+=(r^(n|~i))+t[10]-1051523|0,s=(s<<15|s>>>17)+n|0,i+=(n^(s|~r))+t[1]-2054922799|0,i=(i<<21|i>>>11)+s|0,r+=(s^(i|~n))+t[8]+1873313359|0,r=(r<<6|r>>>26)+i|0,n+=(i^(r|~s))+t[15]-30611744|0,n=(n<<10|n>>>22)+r|0,s+=(r^(n|~i))+t[6]-1560198380|0,s=(s<<15|s>>>17)+n|0,i+=(n^(s|~r))+t[13]+1309151649|0,i=(i<<21|i>>>11)+s|0,r+=(s^(i|~n))+t[4]-145523070|0,r=(r<<6|r>>>26)+i|0,n+=(i^(r|~s))+t[11]-1120210379|0,n=(n<<10|n>>>22)+r|0,s+=(r^(n|~i))+t[2]+718787259|0,s=(s<<15|s>>>17)+n|0,i+=(n^(s|~r))+t[9]-343485551|0,i=(i<<21|i>>>11)+s|0,e[0]=r+e[0]|0,e[1]=i+e[1]|0,e[2]=s+e[2]|0,e[3]=n+e[3]|0}start(){return this._dataLength=0,this._bufferLength=0,this._state.set(e.stateIdentity),this}appendStr(t){let r=this._buffer8,i=this._buffer32,s=this._bufferLength,n,o;for(o=0;o<t.length;o+=1){if((n=t.charCodeAt(o))<128)r[s++]=n;else if(n<2048)r[s++]=(n>>>6)+192,r[s++]=63&n|128;else if(n<55296||n>56319)r[s++]=(n>>>12)+224,r[s++]=n>>>6&63|128,r[s++]=63&n|128;else{if((n=(n-55296)*1024+(t.charCodeAt(++o)-56320)+65536)>1114111)throw Error("Unicode standard supports code points up to U+10FFFF");r[s++]=(n>>>18)+240,r[s++]=n>>>12&63|128,r[s++]=n>>>6&63|128,r[s++]=63&n|128}s>=64&&(this._dataLength+=64,e._md5cycle(this._state,i),s-=64,i[0]=i[16])}return this._bufferLength=s,this}appendAsciiStr(t){let r=this._buffer8,i=this._buffer32,s=this._bufferLength,n,o=0;for(;;){for(n=Math.min(t.length-o,64-s);n--;)r[s++]=t.charCodeAt(o++);if(s<64)break;this._dataLength+=64,e._md5cycle(this._state,i),s=0}return this._bufferLength=s,this}appendByteArray(t){let r=this._buffer8,i=this._buffer32,s=this._bufferLength,n,o=0;for(;;){for(n=Math.min(t.length-o,64-s);n--;)r[s++]=t[o++];if(s<64)break;this._dataLength+=64,e._md5cycle(this._state,i),s=0}return this._bufferLength=s,this}getState(){let e=this._state;return{buffer:String.fromCharCode.apply(null,Array.from(this._buffer8)),buflen:this._bufferLength,length:this._dataLength,state:[e[0],e[1],e[2],e[3]]}}setState(e){let t=e.buffer,r=e.state,i=this._state,s;for(this._dataLength=e.length,this._bufferLength=e.buflen,i[0]=r[0],i[1]=r[1],i[2]=r[2],i[3]=r[3],s=0;s<t.length;s+=1)this._buffer8[s]=t.charCodeAt(s)}end(t=!1){let r=this._bufferLength,i=this._buffer8,s=this._buffer32,n=(r>>2)+1;this._dataLength+=r;let o=8*this._dataLength;if(i[r]=128,i[r+1]=i[r+2]=i[r+3]=0,s.set(e.buffer32Identity.subarray(n),n),r>55&&(e._md5cycle(this._state,s),s.set(e.buffer32Identity)),o<=4294967295)s[14]=o;else{let e=o.toString(16).match(/(.*?)(.{0,8})$/);if(null===e)return;let t=parseInt(e[2],16),r=parseInt(e[1],16)||0;s[14]=t,s[15]=r}return e._md5cycle(this._state,s),t?this._state:e._hex(this._state)}},"Md5"),E(Z,"stateIdentity",new Int32Array([1732584193,-271733879,-1732584194,271733878])),E(Z,"buffer32Identity",new Int32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])),E(Z,"hexChars","0123456789abcdef"),E(Z,"hexOut",[]),E(Z,"onePassHasher",new Z),X=Z}),er={};function ei(e){return crypto.getRandomValues(a.alloc(e))}function es(e){if("sha256"===e)return{update:g(function(e){return{digest:g(function(){return a.from(Y(e))},"digest")}},"update")};if("md5"===e)return{update:g(function(e){return{digest:g(function(){return"string"==typeof e?X.hashStr(e):X.hashByteArray(e)},"digest")}},"update")};throw Error(`Hash type '${e}' not supported`)}function en(e,t){if("sha256"!==e)throw Error(`\
11Only sha256 is supported (requested: '${e}')`);return{update:g(function(e){return{digest:g(function(){"string"==typeof t&&(t=new TextEncoder().encode(t)),"string"==typeof e&&(e=new TextEncoder().encode(e));let r=t.length;if(r>64)t=Y(t);else if(r<64){let e=new Uint8Array(64);e.set(t),t=e}let i=new Uint8Array(64),s=new Uint8Array(64);for(let e=0;e<64;e++)i[e]=54^t[e],s[e]=92^t[e];let n=new Uint8Array(e.length+64);n.set(i,0),n.set(e,64);let o=new Uint8Array(96);return o.set(s,0),o.set(Y(n),64),a.from(Y(o))},"digest")}},"update")}}w(er,{createHash:()=>es,createHmac:()=>en,randomBytes:()=>ei});var eo=m(()=>{P(),ee(),et(),g(ei,"randomBytes"),g(es,"createHash"),g(en,"createHmac")}),ea=b((e,t)=>{P(),t.exports={host:"localhost",user:"win32"===l.platform?l.env.USERNAME:l.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 r=K(),i=r.getTypeParser(20,"text"),s=r.getTypeParser(1016,"text");t.exports.__defineSetter__("parseInt8",function(e){r.setTypeParser(20,"text",e?r.getTypeParser(23,"text"):i),r.setTypeParser(1016,"text",e?r.getTypeParser(1007,"text"):s)})}),el=b((e,t)=>{P();var r=(eo(),_(er)),i=ea();function s(e){return'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'}function n(e){for(var t="{",r=0;r<e.length;r++)r>0&&(t+=","),null===e[r]||typeof e[r]>"u"?t+="NULL":Array.isArray(e[r])?t+=n(e[r]):e[r]instanceof a?t+="\\\\x"+e[r].toString("hex"):t+=s(o(e[r]));return t+"}"}g(s,"escapeElement"),g(n,"arrayString");var o=g(function(e,t){if(null==e)return null;if(e instanceof a)return e;if(ArrayBuffer.isView(e)){var r=a.from(e.buffer,e.byteOffset,e.byteLength);return r.length===e.byteLength?r:r.slice(e.byteOffset,e.byteOffset+e.byteLength)}return e instanceof Date?i.parseInputDatesAsUTC?c(e):h(e):Array.isArray(e)?n(e):"object"==typeof e?l(e,t):e.toString()},"prepareValue");
11function l(e,t){if(e&&"function"==typeof e.toPostgres){if(-1!==(t=t||[]).indexOf(e))throw Error('circular reference detected while preparing "'+e+'" for query');return t.push(e),o(e.toPostgres(o),t)}return JSON.stringify(e)}function u(e,t){for(e=""+e;e.length<t;)e="0"+e;return e}function h(e){var t=-e.getTimezoneOffset(),r=e.getFullYear(),i=r<1;i&&(r=Math.abs(r)+1);var s=u(r,4)+"-"+u(e.getMonth()+1,2)+"-"+u(e.getDate(),2)+"T"+u(e.getHours(),2)+":"+u(e.getMinutes(),2)+":"+u(e.getSeconds(),2)+"."+u(e.getMilliseconds(),3);return t<0?(s+="-",t*=-1):s+="+",s+=u(Math.floor(t/60),2)+":"+u(t%60,2),i&&(s+=" BC"),s}function c(e){var t=e.getUTCFullYear(),r=t<1;r&&(t=Math.abs(t)+1);var i=u(t,4)+"-"+u(e.getUTCMonth()+1,2)+"-"+u(e.getUTCDate(),2)+"T"+u(e.getUTCHours(),2)+":"+u(e.getUTCMinutes(),2)+":"+u(e.getUTCSeconds(),2)+"."+u(e.getUTCMilliseconds(),3);return i+="+00:00",r&&(i+=" BC"),i}function f(e,t,r){return e="string"==typeof e?{text:e}:e,t&&("function"==typeof t?e.callback=t:e.values=t),r&&(e.callback=r),e}g(l,"prepareObject"),g(u,"pad"),g(h,"dateToString"),g(c,"dateToStringUTC"),g(f,"normalizeQueryConfig");var d=g(function(e){return r.createHash("md5").update(e,"utf-8").digest("hex")},"md5"),p=g(function(e,t,r){var i=d(t+e);return"md5"+d(a.concat([a.from(i),r]))},"postgresMd5PasswordHash");t.exports={prepareValue:g(function(e){return o(e)},"prepareValueWrapper"),normalizeQueryConfig:f,postgresMd5PasswordHash:p,md5:d}}),eu={};w(eu,{default:()=>eh});var eh,ec=m(()=>{P(),eh={}}),ef=b((e,t)=>{P();var r=(eo(),_(er));function i(e){if(-1===e.indexOf("SCRAM-SHA-256"))throw Error("SASL: Only mechanism SCRAM-SHA-256 is currently supported");let t=r.randomBytes(18).toString("base64");return{mechanism:"SCRAM-SHA-256",clientNonce:t,response:"n,,n=*,r="+t,message:"SASLInitialResponse"}}function s(e,t,r){if("SASLInitialResponse"!==e.message)throw Error("SASL: Last message was not SASLInitialResponse");if("string"!=typeof t)throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string");if("string"!=typeof r)throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");let i=h(r);if(i.nonce.startsWith(e.clientNonce)){if(i.nonce.length===e.clientNonce.length)throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short")}else throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");var s=y(t,a.from(i.salt,"base64"),i.iteration),n=p(s,"Client Key"),o=d(n),l="n=*,r="+e.clientNonce,u="r="+i.nonce+",s="+i.salt+",i="+i.iteration,c="c=biws,r="+i.nonce,g=l+","+u+","+c,m=f(n,p(o,g)).toString("base64"),b=p(s,"Server Key"),w=p(b,g);e.message="SASLResponse",e.serverSignature=w.toString("base64"),e.response=c+",p="+m}function n(e,t){if("SASLResponse"!==e.message)throw Error("SASL: Last message was not SASLResponse");if("string"!=typeof t)throw Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string");let{serverSignature:r}=c(t);if(r!==e.serverSignature)throw Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does not match")}function o(e){if("string"!=typeof e)throw TypeError("SASL: text must be a string");return e.split("").map((t,r)=>e.charCodeAt(r)).every(e=>e>=33&&e<=43||e>=45&&e<=126)}function l(e){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test(e)}function u(e){if("string"!=typeof e)throw TypeError("SASL: attribute pairs text must be a string");return new Map(e.split(",").map(e=>{if(!/^.=/.test(e))throw Error("SASL: Invalid attribute pair entry");return[e[0],e.substring(2)]}))}function h(e){let t=u(e),r=t.get("r");if(r){if(!o(r))throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters")}else throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing");let i=t.get("s");if(i){if(!l(i))throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt must be base64")}else throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing");let s=t.get("i");if(s){if(!/^[1-9][0-9]*$/.test(s))throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count")}else throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing");return{nonce:r,salt:i,iteration:parseInt(s,10)}}function c(e){let t=u(e).get("v");if(t){if(!l(t))throw Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64")}else throw Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");return{serverSignature:t}}function f(e,t){if(!a.isBuffer(e))throw TypeError("first argument must be a Buffer");if(!a.isBuffer(t))throw TypeError("second argument must be a Buffer");if(e.length!==t.length)throw Error("Buffer lengths must match");if(0===e.length)throw Error("Buffers cannot be empty");return a.from(e.map((r,i)=>e[i]^t[i]))}function d(e){return r.createHash("sha256").update(e).digest()}function p(e,t){return r.createHmac("sha256",e).update(t).digest()}function y(e,t,r){for(var i=p(e,a.concat([t,a.from([0,0,0,1])])),s=i,n=0;n<r-1;n++)s=f(s,i=p(e,i));return s}g(i,"startSession"),g(s,"continueSession"),g(n,"finalizeSession"),g(o,"isPrintableChars"),g(l,"isBase64"),g(u,"parseAttributePairs"),g(h,"parseServerFirstMessage"),g(c,"parseServerFinalMessage"),g(f,"xorBuffers"),g(d,"sha256"),g(p,"hmacSha256"),g(y,"Hi"),t.exp
11orts={startSession:i,continueSession:s,finalizeSession:n}}),ed={};function ep(...e){return e.join("/")}w(ed,{join:()=>ep});var ey=m(()=>{P(),g(ep,"join")}),eg={};function em(e,t){t(Error("No filesystem"))}w(eg,{stat:()=>em});var eb=m(()=>{P(),g(em,"stat")}),ew={};w(ew,{default:()=>ev});var ev,eS=m(()=>{P(),ev={}}),e_={};w(e_,{StringDecoder:()=>eA});var eE,eA,eT=m(()=>{P(),g(eE=class{constructor(e){E(this,"td"),this.td=new TextDecoder(e)}write(e){return this.td.decode(e,{stream:!0})}end(e){return this.td.decode(e)}},"StringDecoder"),eA=eE}),eC=b((e,t)=>{P();var{Transform:r}=(eS(),_(ew)),{StringDecoder:i}=(eT(),_(e_)),s=Symbol("last"),n=Symbol("decoder");function o(e,t,r){let i;if(this.overflow){if(1===(i=this[n].write(e).split(this.matcher)).length)return r();i.shift(),this.overflow=!1}else this[s]+=this[n].write(e),i=this[s].split(this.matcher);this[s]=i.pop();for(let e=0;e<i.length;e++)try{l(this,this.mapper(i[e]))}catch(e){return r(e)}if(this.overflow=this[s].length>this.maxLength,this.overflow&&!this.skipOverflow){r(Error("maximum buffer reached"));return}r()}function a(e){if(this[s]+=this[n].end(),this[s])try{l(this,this.mapper(this[s]))}catch(t){return e(t)}e()}function l(e,t){void 0!==t&&e.push(t)}function u(e){return e}function h(e,t,l){switch(e=e||/\r?\n/,t=t||u,l=l||{},arguments.length){case 1:"function"==typeof e?(t=e,e=/\r?\n/):"object"!=typeof e||e instanceof RegExp||e[Symbol.split]||(l=e,e=/\r?\n/);break;case 2:"function"==typeof e?(l=t,t=e,e=/\r?\n/):"object"==typeof t&&(l=t,t=u)}(l=Object.assign({},l)).autoDestroy=!0,l.transform=o,l.flush=a,l.readableObjectMode=!0;let h=new r(l);return h[s]="",h[n]=new i("utf8"),h.matcher=e,h.mapper=t,h.maxLength=l.maxLength,h.skipOverflow=l.skipOverflow||!1,h.overflow=!1,h._destroy=function(e,t){this._writableState.errorEmitted=!1,t(e)},h}g(o,"transform"),g(a,"flush"),g(l,"push"),g(u,"noop"),g(h,"split"),t.exports=h}),eP=b((e,t)=>{P();var r=(ey(),_(ed)),i=(eS(),_(ew)).Stream,s=eC(),n=(ec(),_(eu)),o="win32"===l.platform,a=l.stderr;function u(e){return(61440&e)==32768}g(u,"isRegFile");var h=["host","port","database","user","password"],c=h.length,f=h[c-1];function d(){if(a instanceof i&&!0===a.writable){var e=Array.prototype.slice.call(arguments).concat(`
12`);a.write(n.format.apply(n,e))}}g(d,"warn"),Object.defineProperty(t.exports,"isWin",{get:g(function(){return o},"get"),set:g(function(e){o=e},"set")}),t.exports.warnTo=function(e){var t=a;return a=e,t},t.exports.getFileName=function(e){var t=e||l.env;return t.PGPASSFILE||(o?r.join(t.APPDATA||"./","postgresql","pgpass.conf"):r.join(t.HOME||"./",".pgpass"))},t.exports.usePgPass=function(e,t){return!Object.prototype.hasOwnProperty.call(l.env,"PGPASSWORD")&&(!!o||(t=t||"<unkn>",u(e.mode)?!(63&e.mode)||(d('WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less',t),!1):(d('WARNING: password file "%s" is not a plain file',t),!1)))};var p=t.exports.match=function(e,t){return h.slice(0,-1).reduce(function(r,i,s){return 1==s&&Number(e[i]||5432)===Number(t[i])?r&&!0:r&&("*"===t[i]||t[i]===e[i])},!0)};t.exports.getPassword=function(e,t,r){var i,n=t.pipe(s());function o(t){var r=y(t);r&&m(r)&&p(e,r)&&(i=r[f],n.end())}g(o,"onLine");var a=g(function(){t.destroy(),r(i)},"onEnd"),l=g(function(e){t.destroy(),d("WARNING: error on reading file: %s",e),r(void 0)},"onErr");t.on("error",l),n.on("data",o).on("end",a).on("error",l)};var y=t.exports.parseLine=function(e){if(e.length<11||e.match(/^\s+#/))return null;for(var t="",r="",i=0,s=0,n={},o=g(function(t,r,i){var s=e.substring(r,i);Object.hasOwnProperty.call(l.env,"PGPASS_NO_DEESCAPE")||(s=s.replace(/\\([:\\])/g,"$1")),n[h[t]]=s},"addToObj"),a=0;a<e.length-1;a+=1){if(t=e.charAt(a+1),r=e.charAt(a),i==c-1){o(i,s);break}a>=0&&":"==t&&"\\"!==r&&(o(i,s,a+1),s=a+2,i+=1)}return n=Object.keys(n).length===c?n:null},m=t.exports.isValidEntry=function(e){for(var t={0:function(e){return e.length>0},1:function(e){return"*"===e||isFinite(e=Number(e))&&e>0&&e<9007199254740992&&Math.floor(e)===e},2:function(e){return e.length>0},3:function(e){return e.length>0},4:function(e){return e.length>0}},r=0;r<h.length;r+=1)if(!(0,t[r])(e[h[r]]||""))return!1;return!0}}),eL=b((e,t)=>{P(),ey(),_(ed);var r=(eb(),_(eg)),i=eP();t.exports=function(e,t){var s=i.getFileName();r.stat(s,function(n,o){if(n||!i.usePgPass(o,s))return t(void 0);var a=r.createReadStream(s);i.getPassword(e,a,t)})},t.exports.warnTo=i.warnTo}),eI={};w(eI,{default:()=>ex});var ex,eM=m(()=>{P(),ex={}}),ek=b((e,t)=>{P();var r=(Q(),_(N)),i=(eb(),_(eg));function s(e){if("/"===e.charAt(0)){var t=e.split(" ");return{host:t[0],database:t[1]}}var s=r.parse(/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(e)?encodeURI(e).replace(/\%25(\d\d)/g,"%$1"):e,!0),t=s.query;for(var n in t)Array.isArray(t[n])&&(t[n]=t[n][t[n].length-1]);var o=(s.auth||":").split(":");if(t.user=o[0],t.password=o.splice(1).join(":"),t.port=s.port,"socket:"==s.protocol)return t.host=decodeURI(s.pathname),t.database=s.query.db,t.client_encoding=s.query.encoding,t;t.host||(t.host=s.hostname);var a=s.pathname;if(!t.host&&a&&/^%2f/i.test(a)){var l=a.split("/");t.host=decodeURIComponent(l[0]),a=l.splice(1).join("/")}switch(a&&"/"===a.charAt(0)&&(a=a.slice(1)||null),t.database=a&&decodeURI(a),("true"===t.ssl||"1"===t.ssl)&&(t.ssl=!0),"0"===t.ssl&&(t.ssl=!1),(t.sslcert||t.sslkey||t.sslrootcert||t.sslmode)&&(t.ssl={}),t.sslcert&&(t.ssl.cert=i.readFileSync(t.sslcert).toString()),t.sslkey&&(t.ssl.key=i.readFileSync(t.sslkey).toString()),t.sslrootcert&&(t.ssl.ca=i.readFileSync(t.sslrootcert).toString()),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}return t}g(s,"parse"),t.exports=s,s.parse=s}),eR=b((e,t)=>{P();var r=(eM(),_(eI)),i=ea(),s=ek().parse,n=g(function(e,t,r){return void 0===r?r=l.env["PG"+e.toUpperCase()]:!1===r||(r=l.env[r]),t[e]||r||i[e]},"val"),o=g(function(){switch(l.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 i.ssl},"readSSLConfigFromEnvironment"),a=g(function(e){return"'"+(""+e).replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"},"quoteParamValue"),u=g(function(e,t,r){var i=t[r];null!=i&&e.push(r+"="+a(i))},"add"),h=class{constructor(e){(e="string"==typeof e?s(e):e||{}).connectionString&&(e=Object.assign({},e,s(e.connectionString))),this.user=n("user",e),this.database=n("database",e),void 0===this.database&&(this.database=this.user),this.port=parseInt(n("port",e),10),this.host=n("host",e),Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:n("password",e)}),this.binary=n("binary",e),this.options=n("options",e),this.ssl=typeof e.ssl>"u"?o():e.ssl,"string"==typeof this.ssl&&"true"===this.ssl&&(this.ssl=!0),"no-verify"===this.ssl&&(this.ssl={rejectUnauthorized:!1}),this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,"key",{enumerable:!1}),this.client_encoding=n("client_encoding",e),this.replication=n("replication",e),this.isDomainSocket=!(this.host||"").indexOf("/"),this.application_name=n("application_name",e,"PGAPPNAME"),this.fallback_application_name=n("fallback_application_name",e,!1),this.statement_timeout=n("statement_timeout",e,!1),this.lock_timeout=n("lock_timeout",e,!1),this.idle_in_transaction_session_timeout=n("idle_in_transaction_session_timeout",e,!1),this.query_timeout=n("query_timeout",e,!1),void 0===e.connectionTimeoutMillis?this.connect_timeout=l.env.PGCONNECT_TIMEOUT||0:this.connect_timeout=Math.floor(e.connectionTimeoutMillis/1e3),!1===e.keepAlive?this.keepalives=0:!0===e.keepAlive&&(this.keepalives=1),"number"==typeof e.keepAliveInitialDelayMillis&&(this.keepalives_idle=Math.floor(e.keepAliveInitialDelayMillis/1e3))}getLibpqConnectionString(e){var t=[];u(t,this,"user"),u(t,this,"password"),u(t,this,"port"),u(t,this,"application_name"),u(t,this,"fallback_application_name"),u(t,this,"connect_timeout"),u(t,this,"options");var i="object"==typeof this.ssl?this.ssl:this.ssl?{sslmode:this.ssl}:{};if(u(t,i,"sslmode"),u(t,i,"sslca"),u(t,i,"sslkey"),u(t,i,"sslcert"),u(t,i,"sslrootcert"),this.database&&t.push("dbname="+a(this.database)),this.replication&&t.push("replication="+a(this.replication)),this.host&&t.push("host="+a(this.host)),this.isDomainSocket)return e(null,t.join(" "));this.client_encoding&&t.push("client_encoding="+a(this.client_encoding)),r.lookup(this.host,function(r,i){return r?e(r,null):(t.push("hostaddr="+a(i)),e(null,t.join(" ")))})}};
12g(h,"ConnectionParameters"),t.exports=h}),eB=b((e,t)=>{P();var r=K(),i=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/,s=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="array"===e,this.rowAsArray&&(this.parseRow=this._parseRowAsArray)}addCommandComplete(e){var t;(t=e.text?i.exec(e.text):i.exec(e.command))&&(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){for(var t=Array(e.length),r=0,i=e.length;r<i;r++){var s=e[r];null!==s?t[r]=this._parsers[r](s):t[r]=null}return t}parseRow(e){for(var t={},r=0,i=e.length;r<i;r++){var s=e[r],n=this.fields[r].name;null!==s?t[n]=this._parsers[r](s):t[n]=null}return t}addRow(e){this.rows.push(e)}addFields(e){this.fields=e,this.fields.length&&(this._parsers=Array(e.length));for(var t=0;t<e.length;t++){var i=e[t];this._types?this._parsers[t]=this._types.getTypeParser(i.dataTypeID,i.format||"text"):this._parsers[t]=r.getTypeParser(i.dataTypeID,i.format||"text")}}};g(s,"Result"),t.exports=s}),eO=b((e,t)=>{P();var{EventEmitter:r}=L(),i=eB(),s=el(),n=class extends r{constructor(e,t,r){super(),e=s.normalizeQueryConfig(e,t,r),this.text=e.text,this.values=e.values,this.rows=e.rows,this.types=e.types,this.name=e.name,this.binary=e.binary,this.portal=e.portal||"",this.callback=e.callback,this._rowMode=e.rowMode,l.domain&&e.callback&&(this.callback=l.domain.bind(e.callback)),this._result=new i(this._rowMode,this.types),this._results=this._result,this.isPreparedStatement=!1,this._canceledDueToError=!1,this._promise=null}requiresPreparation(){return!!this.name||!!this.rows||!!this.text&&!!this.values&&this.values.length>0}_checkForMultirow(){this._result.command&&(Array.isArray(this._results)||(this._results=[this._result]),this._result=new i(this._rowMode,this.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(e){this._canceledDueToError=e;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(e){l.nextTick(()=>{throw e})}this.emit("end",this._results)}submit(e){if("string"!=typeof this.text&&"string"!=typeof this.name)return Error("A query must have either text or a name. Supplying neither is unsupported.");let t=e.parsedStatements[this.name];return this.text&&t&&this.text!==t?Error(`Prepared statements must be unique - '${this.name}\
13' was used for a different statement`):this.values&&!Array.isArray(this.values)?Error("Query values must be an array"):(this.requiresPreparation()?this.prepare(e):e.query(this.text),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.isPreparedStatement=!0,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:s.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){}};g(n,"Query"),t.exports=n}),eN=b(e=>{P(),Object.defineProperty(e,"__esModule",{value:!0}),e.NoticeMessage=e.DataRowMessage=e.CommandCompleteMessage=e.ReadyForQueryMessage=e.NotificationResponseMessage=e.BackendKeyDataMessage=e.AuthenticationMD5Password=e.ParameterStatusMessage=e.ParameterDescriptionMessage=e.RowDescriptionMessage=e.Field=e.CopyResponse=e.CopyDataMessage=e.DatabaseError=e.copyDone=e.emptyQuery=e.replicationStart=e.portalSuspended=e.noData=e.closeComplete=e.bindComplete=e.parseComplete=void 0,e.parseComplete={name:"parseComplete",length:5},e.bindComplete={name:"bindComplete",length:5},e.closeComplete={name:"closeComplete",length:5},e.noData={name:"noData",length:5},e.portalSuspended={name:"portalSuspended",length:5},e.replicationStart={name:"replicationStart",length:4},e.emptyQuery={name:"emptyQuery",length:4},e.copyDone={name:"copyDone",length:4};
13var t=class extends Error{constructor(e,t,r){super(e),this.length=t,this.name=r}};g(t,"DatabaseError"),e.DatabaseError=t;var r=class{constructor(e,t){this.length=e,this.chunk=t,this.name="copyData"}};g(r,"CopyDataMessage"),e.CopyDataMessage=r;var i=class{constructor(e,t,r,i){this.length=e,this.name=t,this.binary=r,this.columnTypes=Array(i)}};g(i,"CopyResponse"),e.CopyResponse=i;var s=class{constructor(e,t,r,i,s,n,o){this.name=e,this.tableID=t,this.columnID=r,this.dataTypeID=i,this.dataTypeSize=s,this.dataTypeModifier=n,this.format=o}};g(s,"Field"),e.Field=s;var n=class{constructor(e,t){this.length=e,this.fieldCount=t,this.name="rowDescription",this.fields=Array(this.fieldCount)}};g(n,"RowDescriptionMessage"),e.RowDescriptionMessage=n;var o=class{constructor(e,t){this.length=e,this.parameterCount=t,this.name="parameterDescription",this.dataTypeIDs=Array(this.parameterCount)}};g(o,"ParameterDescriptionMessage"),e.ParameterDescriptionMessage=o;var a=class{constructor(e,t,r){this.length=e,this.parameterName=t,this.parameterValue=r,this.name="parameterStatus"}};g(a,"ParameterStatusMessage"),e.ParameterStatusMessage=a;var l=class{constructor(e,t){this.length=e,this.salt=t,this.name="authenticationMD5Password"}};g(l,"AuthenticationMD5Password"),e.AuthenticationMD5Password=l;var u=class{constructor(e,t,r){this.length=e,this.processID=t,this.secretKey=r,this.name="backendKeyData"}};g(u,"BackendKeyDataMessage"),e.BackendKeyDataMessage=u;
13var h=class{constructor(e,t,r,i){this.length=e,this.processId=t,this.channel=r,this.payload=i,this.name="notification"}};g(h,"NotificationResponseMessage"),e.NotificationResponseMessage=h;var c=class{constructor(e,t){this.length=e,this.status=t,this.name="readyForQuery"}};g(c,"ReadyForQueryMessage"),e.ReadyForQueryMessage=c;var f=class{constructor(e,t){this.length=e,this.text=t,this.name="commandComplete"}};g(f,"CommandCompleteMessage"),e.CommandCompleteMessage=f;var d=class{constructor(e,t){this.length=e,this.fields=t,this.name="dataRow",this.fieldCount=t.length}};g(d,"DataRowMessage"),e.DataRowMessage=d;var p=class{constructor(e,t){this.length=e,this.message=t,this.name="notice"}};g(p,"NoticeMessage"),e.NoticeMessage=p}),e$=b(e=>{P(),Object.defineProperty(e,"__esModule",{value:!0}),e.Writer=void 0;var t=class{constructor(e=256){this.size=e,this.offset=5,this.headerPosition=0,this.buffer=a.allocUnsafe(e)}ensure(e){if(this.buffer.length-this.offset<e){let t=this.buffer,r=t.length+(t.length>>1)+e;this.buffer=a.allocUnsafe(r),t.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){let t=a.byteLength(e);this.ensure(t+1),this.buffer.write(e,this.offset,"utf-8"),this.offset+=t}else this.ensure(1);return this.buffer[this.offset++]=0,this}addString(e=""){let t=a.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=a.allocUnsafe(this.size),t}};g(t,"Writer"),e.Writer=t}),eQ=b(e=>{P(),Object.defineProperty(e,"__esModule",{value:!0}),e.serialize=void 0;var t=e$(),r=new t.Writer,i=g(e=>{for(let t of(r.addInt16(3).addInt16(0),Object.keys(e)))r.addCString(t).addCString(e[t]);r.addCString("client_encoding").addCString("UTF8");let i=r.addCString("").flush(),s=i.length+4;return new t.Writer().addInt32(s).add(i).flush()},"startup"),s=g(()=>{let e=a.allocUnsafe(8);return e.writeInt32BE(8,0),e.writeInt32BE(80877103,4),e},"requestSsl"),n=g(e=>r.addCString(e).flush(112),"password"),o=g(function(e,t){return r.addCString(e).addInt32(a.byteLength(t)).addString(t),r.flush(112)},"sendSASLInitialResponseMessage"),l=g(function(e){return r.addString(e).flush(112)},"sendSCRAMClientFinalMessage"),u=g(e=>r.addCString(e).flush(81),"query"),h=[],c=g(e=>{let t=e.name||"";t.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",t,t.length),console.error("This can cause conflicts and silent errors executing queries"));let i=e.types||h,s=i.length,n=r.addCString(t).addCString(e.text).addInt16(s);for(let e=0;e<s;e++)n.addInt32(i[e]);return r.flush(80)},"parse"),f=new t.Writer,d=g(function(e,t){for(let i=0;i<e.length;i++){let s=t?t(e[i],i):e[i];null==s?(r.addInt16(0),f.addInt32(-1)):s instanceof a?(r.addInt16(1),f.addInt32(s.length),f.add(s)):(r.addInt16(0),f.addInt32(a.byteLength(s)),f.addString(s))}},"writeValues"),p=g((e={})=>{let t=e.portal||"",i=e.statement||"",s=e.binary||!1,n=e.values||h,o=n.length;return r.addCString(t).addCString(i),r.addInt16(o),d(n,e.valueMapper),r.addInt16(o),r.add(f.flush()),r.addInt16(s?1:0),r.flush(66)},"bind"),y=a.from([69,0,0,0,9,0,0,0,0,0]),m=g(e=>{if(!e||!e.portal&&!e.rows)return y;let t=e.portal||"",r=e.rows||0,i=a.byteLength(t),s=4+i+1+4,n=a.allocUnsafe(1+s);return n[0]=69,n.writeInt32BE(s,1),n.write(t,5,"utf-8"),n[i+5]=0,n.writeUInt32BE(r,n.length-4),n},"execute"),b=g((e,t)=>{let r=a.allocUnsafe(16);return r.writeInt32BE(16,0),r.writeInt16BE(1234,4),r.writeInt16BE(5678,6),r.writeInt32BE(e,8),r.writeInt32BE(t,12),r},"cancel"),w=g((e,t)=>{let r=4+a.byteLength(t)+1,i=a.allocUnsafe(1+r);return i[0]=e,i.writeInt32BE(r,1),i.write(t,5,"utf-8"),i[r]=0,i},"cstringMessage"),v=r.addCString("P").flush(68),S=r.addCString("S").flush(68),_=g(e=>
13e.name?w(68,`${e.type}${e.name||""}`):"P"===e.type?v:S,"describe"),E=g(e=>w(67,`${e.type}${e.name||""}`),"close"),A=g(e=>r.add(e).flush(100),"copyData"),T=g(e=>w(102,e),"copyFail"),C=g(e=>a.from([e,0,0,0,4]),"codeOnlyBuffer"),L=C(72),I=C(83),x=C(88),M=C(99),k={startup:i,password:n,requestSsl:s,sendSASLInitialResponseMessage:o,sendSCRAMClientFinalMessage:l,query:u,parse:c,bind:p,execute:m,describe:_,close:E,flush:g(()=>L,"flush"),sync:g(()=>I,"sync"),end:g(()=>x,"end"),copyData:A,copyDone:g(()=>M,"copyDone"),copyFail:T,cancel:b};e.serialize=k}),eq=b(e=>{P(),Object.defineProperty(e,"__esModule",{value:!0}),e.BufferReader=void 0;var t=a.allocUnsafe(0),r=class{constructor(e=0){this.offset=e,this.buffer=t,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(;0!==this.buffer[t++];);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}};g(r,"BufferReader"),e.BufferReader=r}),eD=b(e=>{P(),Object.defineProperty(e,"__esModule",{value:!0}),e.Parser=void 0;var t=eN(),r=eq(),i=a.allocUnsafe(0),s=class{constructor(e){if(this.buffer=i,this.bufferLength=0,this.bufferOffset=0,this.reader=new r.BufferReader,e?.mode==="binary")throw Error("Binary mode not supported yet");this.mode=e?.mode||"text"}parse(e,t){this.mergeBuffer(e);let r=this.bufferOffset+this.bufferLength,s=this.bufferOffset;for(;s+5<=r;){let e=this.buffer[s],i=this.buffer.readUInt32BE(s+1),n=1+i;if(n+s<=r)t(this.handlePacket(s+5,e,i,this.buffer)),s+=n;else break}s===r?(this.buffer=i,this.bufferLength=0,this.bufferOffset=0):(this.bufferLength=r-s,this.bufferOffset=s)}mergeBuffer(e){if(this.bufferLength>0){let t=this.bufferLength+e.byteLength;if(t+this.bufferOffset>this.buffer.byteLength){let e;if(t<=this.buffer.byteLength&&this.bufferOffset>=this.bufferLength)e=this.buffer;else{let r=2*this.buffer.byteLength;for(;t>=r;)r*=2;e=a.allocUnsafe(r)}this.buffer.copy(e,0,this.bufferOffset,this.bufferOffset+this.bufferLength),this.buffer=e,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,r,i,s){switch(r){case 50:return t.bindComplete;case 49:return t.parseComplete;case 51:return t.closeComplete;case 110:return t.noData;case 115:return t.portalSuspended;case 99:return t.copyDone;case 87:return t.replicationStart;case 73:return t.emptyQuery;case 68:return this.parseDataRowMessage(e,i,s);case 67:return this.parseCommandCompleteMessage(e,i,s);case 90:return this.parseReadyForQueryMessage(e,i,s);case 65:return this.parseNotificationMessage(e,i,s);case 82:return this.parseAuthenticationResponse(e,i,s);case 83:return this.parseParameterStatusMessage(e,i,s);case 75:return this.parseBackendKeyData(e,i,s);case 69:return this.parseErrorMessage(e,i,s,"error");case 78:return this.parseErrorMessage(e,i,s,"notice");case 84:return this.parseRowDescriptionMessage(e,i,s);case 116:return this.parseParameterDescriptionMessage(e,i,s);case 71:return this.parseCopyInMessage(e,i,s);case 72:return this.parseCopyOutMessage(e,i,s);case 100:return this.parseCopyData(e,i,s);default:return new t.DatabaseError("received invalid response: "+r.toString(16),i,"error")}}parseReadyForQueryMessage(e,r,i){this.reader.setBuffer(e,i);let s=this.reader.string(1);return new t.ReadyForQueryMessage(r,s)}parseCommandCompleteMessage(e,r,i){this.reader.setBuffer(e,i);let s=this.reader.cstring();return new t.CommandCompleteMessage(r,s)}parseCopyData(e,r,i){let s=i.slice(e,e+(r-4));return new t.CopyDataMessage(r,s)}parseCopyInMessage(e,t,r){return this.parseCopyMessage(e,t,r,"copyInResponse")}parseCopyOutMessage(e,t,r){return this.parseCopyMessage(e,t,r,"copyOutResponse")}parseCopyMessage(e,r,i,s){this.reader.setBuffer(e,i);let n=0!==this.reader.byte(),o=this.reader.int16(),a=new t.CopyResponse(r,s,n,o);for(let e=0;e<o;e++)a.columnTypes[e]=this.reader.int16();return a}parseNotificationMessage(e,r,i){this.reader.setBuffer(e,i);let s=this.reader.int32(),n=this.reader.cstring(),o=this.reader.cstring();return new t.NotificationResponseMessage(r,s,n,o)}parseRowDescriptionMessage(e,r,i){this.reader.setBuffer(e,i);let s=this.reader.int16(),n=new t.RowDescriptionMessage(r,s);for(let e=0;e<s;e++)n.fields[e]=this.parseField();return n}parseField(){let e=this.reader.cstring(),r=this.reader.uint32(),i=this.reader.int16(),s=this.reader.uint32(),n=this.reader.int16(),o=this.reader.int32(),a=0===this.reader.int16()?"text":"binary";return new t.Field(e,r,i,s,n,o,a)}parseParameterDescriptionMessage(e,r,i){this.reader.setBuffer(e,i);let s=this.reader.int16(),n=new t.ParameterDescriptionMessage(r,s);for(let e=0;e<s;e++)n.dataTypeIDs[e]=this.reader.int32();return n}parseDataRowMessage(e,r,i){this.reader.setBuffer(e,i);let s=this.reader.int16(),n=Array(s);for(let e=0;e<s;e++){let t=this.reader.int32();n[e]=-1===t?null:this.reader.string(t)}return new t.DataRowMessage(r,n)}parseParameterStatusMessage(e,r,i){this.reader.setBuffer(e,i);let s=this.reader.cstring(),n=this.reader.cstring();return new t.ParameterStatusMessage(r,s,n)}parseBackendKeyData(e,r,i){this.reader.setBuffer(e,i);let s=this.reader.int32(),n=this.reader.int32();return new t.BackendKeyDataMessage(r,s,n)}parseAuthenticationResponse(e,r,i){this.reader.setBuffer(e,i);let s=this.reader.int32(),n={name:"authenticationOk",length:r};switch(s){case 0:break;case 3:8===n.length&&(n.name="authenticationCleartextPassword");break;case 5:if(12===n.length){n.name="authenticationMD5Password";let e=this.reader.bytes(4);return new t.AuthenticationMD5Password(r,e)}break;case 10:{let e;n.name="authenticationSASL",n.mechanisms=[];do(e=this.reader.cstring())&&n.mechanisms.push(e);while(e)}break;case 11:n.name="authenticationSASLContinue",n.data=this.reader.string(r-8);break;case 12:n.name="authenticationSASLFinal",n.data=this.reader.string(r-8);break;default:throw Error("Unknown authenticationOk message type "+s)}return n}parseErrorMessage(e,r,i,s){this.reader.setBuffer(e,i);let n={},o=this.reader.string(1);for(;"\0"!==o;)n[o]=this.reader.cstring(),o=this.reader.string(1);let a=n.M,l="notice"===s?new t.NoticeMessage(r,a):new t.DatabaseError(a,r,s);return l.severity=n.S,l.code=n.C,l.detail=n.D,l.hint=n.H,l.position=n.P,l.internalPosition=n.p,l.internalQuery=n.q,l.where=n.W,l.schema=n.s,l.table=n.t,l.column=n.c,l.dataType=n.d,l.constraint=n.n,l.file=n.F,l.line=n.L,l.rout
13ine=n.R,l}};g(s,"Parser"),e.Parser=s}),eF=b(e=>{P(),Object.defineProperty(e,"__esModule",{value:!0}),e.DatabaseError=e.serialize=e.parse=void 0;var t=eN();Object.defineProperty(e,"DatabaseError",{enumerable:!0,get:g(function(){return t.DatabaseError},"get")});var r=eQ();Object.defineProperty(e,"serialize",{enumerable:!0,get:g(function(){return r.serialize},"get")});var i=eD();function s(e,t){let r=new i.Parser;return e.on("data",e=>r.parse(e,t)),new Promise(t=>e.on("end",()=>t()))}g(s,"parse"),e.parse=s}),ej={};function eU({socket:e,servername:t}){return e.startTls(t),e}w(ej,{connect:()=>eU});var eW=m(()=>{P(),g(eU,"connect")}),ez=b((e,t)=>{P();var r=(O(),_(I)),i=L().EventEmitter,{parse:s,serialize:n}=eF(),o=n.flush(),a=n.sync(),l=n.end(),u=class extends i{constructor(e){super(),e=e||{},this.stream=e.stream||new r.Socket,this._keepAlive=e.keepAlive,this._keepAliveInitialDelayMillis=e.keepAliveInitialDelayMillis,this.lastBuffer=!1,this.parsedStatements={},this.ssl=e.ssl||!1,this._ending=!1,this._emitMessage=!1;var t=this;this.on("newListener",function(e){"message"===e&&(t._emitMessage=!0)})}connect(e,t){var i=this;this._connecting=!0,this.stream.setNoDelay(!0),this.stream.connect(e,t),this.stream.once("connect",function(){i._keepAlive&&i.stream.setKeepAlive(!0,i._keepAliveInitialDelayMillis),i.emit("connect")});let s=g(function(e){i._ending&&("ECONNRESET"===e.code||"EPIPE"===e.code)||i.emit("error",e)},"reportStreamError");if(this.stream.on("error",s),this.stream.on("close",function(){i.emit("end")}),!this.ssl)return this.attachListeners(this.stream);this.stream.once("data",function(e){switch(e.toString("utf8")){case"S":break;case"N":return i.stream.end(),i.emit("error",Error("The server does not support SSL connections"));default:return i.stream.end(),i.emit("error",Error("There was an error establishing an SSL connection"))}var n=(eW(),_(ej));let o={socket:i.stream};!0!==i.ssl&&(Object.assign(o,i.ssl),"key"in i.ssl&&(o.key=i.ssl.key)),0===r.isIP(t)&&(o.servername=t);try{i.stream=n.connect(o)}catch(e){return i.emit("error",e)}i.attachListeners(i.stream),i.stream.on("error",s),i.emit("sslconnect")})}attachListeners(e){e.on("end",()=>{this.emit("end")}),s(e,e=>{var t="error"===e.name?"errorMessage":e.name;this._emitMessage&&this.emit("message",e),this.emit(t,e)})}requestSsl(){this.stream.write(n.requestSsl())}startup(e){this.stream.write(n.startup(e))}cancel(e,t){this._send(n.cancel(e,t))}password(e){this._send(n.password(e))}sendSASLInitialResponseMessage(e,t){this._send(n.sendSASLInitialResponseMessage(e,t))}sendSCRAMClientFinalMessage(e){this._send(n.sendSCRAMClientFinalMessage(e))}_send(e){return!!this.stream.writable&&this.stream.write(e)}query(e){this._send(n.query(e))}parse(e){this._send(n.parse(e))}bind(e){this._send(n.bind(e))}execute(e){this._send(n.execute(e))}flush(){this.stream.writable&&this.stream.write(o)}sync(){this._ending=!0,this._send(o),this._send(a)}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(l,()=>{this.stream.end()})}close(e){this._send(n.close(e))}describe(e){this._send(n.describe(e))}sendCopyFromChunk(e){this._send(n.copyData(e))}endCopyFrom(){this._send(n.copyDone())}sendCopyFail(e){this._send(n.copyFail(e))}};g(u,"Connection"),t.exports=u}),eV=b((e,t)=>{P();var r=L().EventEmitter,i=(ec(),_(eu),el()),s=ef(),o=eL(),a=J(),u=eR(),h=eO(),c=ea(),f=ez(),d=class extends r{constructor(e){super(),this.connectionParameters=new u(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;var t=e||{};this._Promise=t.Promise||n.Promise,this._types=new a(t.types),this._ending=!1,this._connecting=!1,this._connected=!1,this._connectionError=!1,this._queryable=!0,this.connection=t.connection||new f({stream
13: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||c.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=g(t=>{l.nextTick(()=>{t.handleError(e,this.connection)})},"enqueueError");this.activeQuery&&(t(this.activeQuery),this.activeQuery=null),this.queryQueue.forEach(t),this.queryQueue.length=0}_connect(e){var t=this,r=this.connection;if(this._connectionCallback=e,this._connecting||this._connected){let t=Error("Client has already been connected. You cannot reuse a client.");l.nextTick(()=>{e(t)});return}this._connecting=!0,this.connectionTimeoutHandle,this._connectionTimeoutMillis>0&&(this.connectionTimeoutHandle=setTimeout(()=>{r._ending=!0,r.stream.destroy(Error("timeout expired"))},this._connectionTimeoutMillis)),this.host&&0===this.host.indexOf("/")?r.connect(this.host+"/.s.PGSQL."+this.port):r.connect(this.port,this.host),r.on("connect",function(){t.ssl?r.requestSsl():r.startup(t.getStartupConf())}),r.on("sslconnect",function(){r.startup(t.getStartupConf())}),this._attachListeners(r),r.once("end",()=>{let e=this._ending?Error("Connection terminated"):Error("Connection terminated unexpectedly");clearTimeout(this.connectionTimeoutHandle),this._errorAllQueries(e),this._ending||(this._connecting&&!this._connectionError?this._connectionCallback?this._connectionCallback(e):this._handleErrorEvent(e):this._connectionError||this._handleErrorEvent(e)),l.nextTick(()=>{this.emit("end")})})}connect(e){if(e){this._connect(e);return}return new this._Promise((e,t)=>{this._connect(r=>{r?t(r):e()})})}_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;"function"==typeof this.password?this._Promise.resolve().then(()=>this.password()).then(r=>{if(void 0!==r){if("string"!=typeof r){t.emit("error",TypeError("Password must be a string"));return}this.connectionParameters.password=this.password=r}else this.connectionParameters.password=this.password=null;e()}).catch(e=>{t.emit("error",e)}):null!==this.password?e():o(this.connectionParameters,t=>{void 0!==t&&(this.connectionParameters.password=this.password=t),e()})}_handleAuthCleartextPassword(e){this._checkPgPass(()=>{this.connection.password(this.password)})}_handleAuthMD5Password(e){this._checkPgPass(()=>{let t=i.postgresMd5PasswordHash(this.user,this.password,e.salt);this.connection.password(t)})}_handleAuthSASL(e){this._checkPgPass(()=>{this.saslSession=s.startSession(e.mechanisms),this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism,this.saslSession.response)})}_handleAuthSASLContinue(e){s.continueSession(this.saslSession,this.password,e.data),this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}_handleAuthSASLFinal(e){s.finalizeSession(this.saslSession,e.data),this.saslSession=null}_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
13("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){this.activeQuery.handleCommandComplete(e,this.connection)}_handleParseComplete(e){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(){var e=this.connectionParameters,t={user:e.user,database:e.database},r=e.application_name||e.fallback_application_name;return r&&(t.application_name=r),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){var r=this.connection;this.host&&0===this.host.indexOf("/")?r.connect(this.host+"/.s.PGSQL."+this.port):r.connect(this.port,this.host),r.on("connect",function(){r.cancel(e.processID,e.secretKey)})}else -1!==e.queryQueue.indexOf(t)&&e.queryQueue.splice(e.queryQueue.indexOf(t),1)}setTypeParser(e,t,r){return this._types.setTypeParser(e,t,r)}getTypeParser(e,t){return this._types.getTypeParser(e,t)}escapeIdentifier(e){return'"'+e.replace(/"/g,'""')+'"'}escapeLiteral(e){for(var t=!1,r="'",i=0;i<e.length;i++){var s=e[i];"'"===s?r+=s+s:"\\"===s?(r+=s+s,t=!0):r+=s}return r+="'",!0===t&&(r=" E"+r),r}_pulseQueryQueue(){if(!0===this.readyForQuery){if(this.activeQuery=this.queryQueue.shift(),this.activeQuery){this.readyForQuery=!1,this.hasExecuted=!0;let e=this.activeQuery.submit(this.connection);e&&l.nextTick(()=>{this.activeQuery.handleError(e,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}else this.hasExecuted&&(this.activeQuery=null,this.emit("drain"))}}query(e,t,r){var i,s,n,o,a;if(null==e)throw TypeError("Client was passed a null or undefined query");return"function"==typeof e.submit?(n=e.query_timeout||this.connectionParameters.query_timeout,s=i=e,"function"==typeof t&&(i.callback=i.callback||t)):(n=this.connectionParameters.query_timeout,(i=new h(e,t,r)).callback||(s=new this._Promise((e,t)=>{i.callback=(r,i)=>r?t(r):e(i)}))),n&&(a=i.callback,o=setTimeout(()=>{var e=Error("Query read timeout");l.nextTick(()=>{i.handleError(e,this.connection)}),a(e),i.callback=()=>{};var t=this.queryQueue.indexOf(i);t>-1&&this.queryQueue.splice(t,1),this._pulseQueryQueue()},n),i.callback=(e,t)=>{clearTimeout(o),a(e,t)}),this.binary&&!i.binary&&(i.binary=!0),i._result&&!i._result._types&&(i._result._types=this._types),this._queryable?this._ending?l.nextTick(()=>{i.handleError(Error("Client was closed and is not queryable"),this.connection)}):(this.queryQueue.push(i),this._pulseQueryQueue()):l.nextTick(()=>{i.handleError(Error("Client has encountered a connection error and is not queryable"),this.connection)}),s}ref(){this.connection.ref()}unref(){this.connection.unref()}end(e){if(this._ending=!0,!this.connection._connecting){if(!e)return this._Promise.resolve();e()}if(this.activeQuery||!this._queryable?this.connection.stream.destroy():this.connection.end(),!e)return new this._Promise(e=>{this.connection.once("end",e)});this.connection.once("end",e)}};g(d,"Client"),d.Query=h,t.exports=d}),eG=b((e,t)=>{P();var r=L().EventEmitter,i=g(function(){}
13,"NOOP"),s=g((e,t)=>{let r=e.findIndex(t);return -1===r?void 0:e.splice(r,1)[0]},"removeWhere"),a=class{constructor(e,t,r){this.client=e,this.idleListener=t,this.timeoutId=r}};g(a,"IdleItem");var u=class{constructor(e){this.callback=e}};function h(){throw Error("Release called on client which has already been released to the pool.")}function c(e,t){let r,i;return t?{callback:t,result:void 0}:{callback:g(function(e,t){e?r(e):i(t)},"cb"),result:new e(function(e,t){i=e,r=t}).catch(e=>{throw Error.captureStackTrace(e),e})}}function f(e,t){return g(function r(i){i.client=t,t.removeListener("error",r),t.on("error",()=>{e.log("additional client error after disconnection due to error",i)}),e._remove(t),e.emit("error",i,t)},"idleListener")}g(u,"PendingItem"),g(h,"throwOnDoubleRelease"),g(c,"promisify"),g(f,"makeIdleListener");var d=class extends r{constructor(e,t){super(),this.options=Object.assign({},e),null!=e&&"password"in e&&Object.defineProperty(this.options,"password",{configurable:!0,enumerable:!1,writable:!0,value:e.password}),null!=e&&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||e1().Client,this.Promise=this.options.Promise||n.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(e=>{this._remove(e.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 r=t.client;r.ref&&r.ref();let i=t.idleListener;return this._acquireClient(r,e,i,!1)}if(!this._isFull())return this.newClient(e);throw Error("unexpected condition")}_remove(e){let t=s(this._idle,t=>t.client===e);void 0!==t&&clearTimeout(t.timeoutId),this._clients=this._clients.filter(t=>t!==e),e.end(),this.emit("remove",e)}connect(e){if(this.ending){let t=Error("Cannot use a pool after calling end on the pool");return e?e(t):this.Promise.reject(t)}let t=c(this.Promise,e),r=t.result;if(this._isFull()||this._idle.length){if(this._idle.length&&l.nextTick(()=>this._pulseQueue()),!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new u(t.callback)),r;let e=g((e,r,i)=>{clearTimeout(n),t.callback(e,r,i)},"queueCallback"),i=new u(e),n=setTimeout(()=>{s(this._pendingQueue,t=>t.callback===e),i.timedOut=!0,t.callback(Error("timeout exceeded when trying to connect"))},this.options.connectionTimeoutMillis);return n.unref&&n.unref(),this._pendingQueue.push(i),r}return this.newClient(new u(t.callback)),r}newClient(e){let t=new this.Client(this.options);this._clients.push(t);let r=f(this,t);this.log("checking client timeout");let s,n=!1;this.options.connectionTimeoutMillis&&(s=setTimeout(()=>{this.log("ending client due to timeout"),n=!0,t.connection?t.connection.stream.destroy():t.end()},this.options.connectionTimeoutMillis)),this.log("connecting new client"),t.connect(o=>{if(s&&clearTimeout(s),t.on("error",r),o)this.log("client failed to connect",o),this._clients=this._clients.filter(e=>e!==t),n&&(o=Error("Connection terminated due to connection timeout",{cause:o})),this._pulseQueue(),e.timedOut||e.callback(o,void 0,i);else{if(this.log("new client connected"),0!==this.options.maxLifetimeSeconds){let e=setTimeout(()=>{this.log("ending client due to expired lifetime"),this._expired.add(t),-1!==this._idle.findIndex(e=>e.client===t)&&this._acquireClient(t,new u((e,t,r)=>r()),r,!1)},1e3*this.options.maxLifetimeSeconds);e.unref(),t.once("end",()=>clearTimeout(e))}return this._acquireClient(t,e,r,!0)}})}
13_acquireClient(e,t,r,s){s&&this.emit("connect",e),this.emit("acquire",e),e.release=this._releaseOnce(e,r),e.removeListener("error",r),t.timedOut?s&&this.options.verify?this.options.verify(e,e.release):e.release():s&&this.options.verify?this.options.verify(e,r=>{if(r)return e.release(r),t.callback(r,void 0,i);t.callback(void 0,e,e.release)}):t.callback(void 0,e,e.release)}_releaseOnce(e,t){let r=!1;return i=>{r&&h(),r=!0,this._release(e,t,i)}}_release(e,t,r){let i;if(e.on("error",t),e._poolUseCount=(e._poolUseCount||0)+1,this.emit("release",r,e),r||this.ending||!e._queryable||e._ending||e._poolUseCount>=this.options.maxUses){e._poolUseCount>=this.options.maxUses&&this.log("remove expended client"),this._remove(e),this._pulseQueue();return}if(this._expired.has(e)){this.log("remove expired client"),this._expired.delete(e),this._remove(e),this._pulseQueue();return}this.options.idleTimeoutMillis&&this._isAboveMin()&&(i=setTimeout(()=>{this.log("remove idle client"),this._remove(e)},this.options.idleTimeoutMillis),this.options.allowExitOnIdle&&i.unref()),this.options.allowExitOnIdle&&e.unref(),this._idle.push(new a(e,t,i)),this._pulseQueue()}query(e,t,r){if("function"==typeof e){let t=c(this.Promise,e);return o(function(){return t.callback(Error("Passing a function as the first parameter to pool.query is not supported"))}),t.result}"function"==typeof t&&(r=t,t=void 0);let i=c(this.Promise,r);return r=i.callback,this.connect((i,s)=>{if(i)return r(i);let n=!1,o=g(e=>{n||(n=!0,s.release(e),r(e))},"onError");s.once("error",o),this.log("dispatching query");try{s.query(e,t,(e,t)=>{if(this.log("query dispatched"),s.removeListener("error",o),!n)return n=!0,s.release(e),e?r(e):r(void 0,t)})}catch(e){return s.release(e),r(e)}}),i.result}end(e){if(this.log("ending"),this.ending){let t=Error("Called end on pool more than once");return e?e(t):this.Promise.reject(t)}this.ending=!0;let t=c(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}};g(d,"Pool"),t.exports=d}),eH={};w(eH,{default:()=>eK});var eK,eJ=m(()=>{P(),eK={}}),eY=b((e,t)=>{t.exports={name:"pg",version:"8.8.0",description:"PostgreSQL client - pure javascript & libpq with the same API",keywords:["database","libpq","pg","postgre","postgres","postgresql","rdbms"],homepage:"https://github.com/brianc/node-postgres",repository:{type:"git",url:"git://github.com/brianc/node-postgres.git",directory:"packages/pg"},author:"Brian Carlson <[email protected]>",main:"./lib",dependencies:{"buffer-writer":"2.0.0","packet-reader":"1.0.0","pg-connection-string":"^2.5.0","pg-pool":"^3.5.2","pg-protocol":"^1.5.0","pg-types":"^2.1.0",pgpass:"1.x"},devDependencies:{async:"2.6.4",bluebird:"3.5.2",co:"4.6.0","pg-copy-streams":"0.3.0"},peerDependencies:{"pg-native":">=3.0.1"},peerDependenciesMeta:{"pg-native":{optional:!0}},scripts:{test:"make test-all"},files:["lib","SPONSORS.md"],license:"MIT",engines:{node:">= 8.0.0"},gitHead:"c99fb2c127ddf8d712500db2c7b9a5491a178655"}}),eZ=b((e,t)=>{P();var r=L().EventEmitter,i=(ec(),_(eu)),s=el(),n=t.exports=function(e,t,i){r.call(this),e=s.normalizeQueryConfig(e,t,i),this.text=e.text,this.values=e.values,this.name=e.name,this.callback=e.callback,this.state="new",this._arrayMode="array"===e.rowMode,this._emitRowEvents=!1,this.on("newListener",(function(e){"row"===e&&(this._emitRowEvents=!0)}).bind(this))};i.inherits(n,r);var a={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"schema",tableName:"table",columnName:"column",dataTypeName:"dataType",constraintName:"constraint",sourceFile:"file",sourceLine:"line",sourceFunction:"routine"};n.prototype.handleError=function(e){var t=this.native.pq.resultErrorFields();if(t)for(var r in t)e[a[r]||r]=t[r];this.callback?this.callback(e):this.emit("error",e),this.state="error"},n.prototype.then=function(e,t){return this._getPromise().then(e,t)},n.prototype.catch=function(e){return this._getPromise().catch(e)},n.prototype._getPromise=function(){return this._promise||(this._promise=new Promise((function(e,t){this._once("end",e),this._once("error",t)}).bind(this))),this._promise},n.prototype.submit=function(e){this.state="running";var t=this;this.native=e.native,e.native.arrayMode=this._arrayMode;
13var r=g(function(r,i,s){if(e.native.arrayMode=!1,o(function(){t.emit("_done")}),r)return t.handleError(r);t._emitRowEvents&&(s.length>1?i.forEach((e,r)=>{e.forEach(e=>{t.emit("row",e,s[r])})}):i.forEach(function(e){t.emit("row",e,s)})),t.state="end",t.emit("end",s),t.callback&&t.callback(null,s)},"after");if(l.domain&&(r=l.domain.bind(r)),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"));var i=(this.values||[]).map(s.prepareValue);if(e.namedQueries[this.name]){if(this.text&&e.namedQueries[this.name]!==this.text){let e=Error(`Prepa\
14red statements must be unique - '${this.name}' was used for a different statement`);return r(e)}return e.native.execute(this.name,i,r)}return e.native.prepare(this.name,this.text,i.length,function(s){return s?r(s):(e.namedQueries[t.name]=t.text,t.native.execute(t.name,i,r))})}if(this.values){if(!Array.isArray(this.values)){let e=Error("Query values must be an array");return r(e)}var n=this.values.map(s.prepareValue);e.native.query(this.text,n,r)}else e.native.query(this.text,r)}}),eX=b((e,t)=>{P();var r=(eJ(),_(eH)),i=J(),s=(eY(),L().EventEmitter),o=(ec(),_(eu)),a=eR(),u=eZ(),h=t.exports=function(e){s.call(this),e=e||{},this._Promise=e.Promise||n.Promise,this._types=new i(e.types),this.native=new r({types:this._types}),this._queryQueue=[],this._ending=!1,this._connecting=!1,this._connected=!1,this._queryable=!0;var t=this.connectionParameters=new a(e);this.user=t.user,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:t.password}),this.database=t.database,this.host=t.host,this.port=t.port,this.namedQueries={}};h.Query=u,o.inherits(h,s),h.prototype._errorAllQueries=function(e){let t=g(t=>{l.nextTick(()=>{t.native=this.native,t.handleError(e)})},"enqueueError");this._hasActiveQuery()&&(t(this._activeQuery),this._activeQuery=null),this._queryQueue.forEach(t),this._queryQueue.length=0},h.prototype._connect=function(e){var t=this;if(this._connecting){l.nextTick(()=>e(Error("Client has already been connected. You cannot reuse a client.")));return}this._connecting=!0,this.connectionParameters.getLibpqConnectionString(function(r,i){if(r)return e(r);t.native.connect(i,function(r){if(r)return t.native.end(),e(r);t._connected=!0,t.native.on("error",function(e){t._queryable=!1,t._errorAllQueries(e),t.emit("error",e)}),t.native.on("notification",function(e){t.emit("notification",{channel:e.relname,payload:e.extra})}),t.emit("connect"),t._pulseQueryQueue(!0),e()})})},h.prototype.connect=function(e){if(e){this._connect(e);return}return new this._Promise((e,t)=>{this._connect(r=>{r?t(r):e()})})},h.prototype.query=function(e,t,r){var i,s,n,o,a;if(null==e)throw TypeError("Client was passed a null or undefined query");if("function"==typeof e.submit)n=e.query_timeout||this.connectionParameters.query_timeout,s=i=e,"function"==typeof t&&(e.callback=t);else if(n=this.connectionParameters.query_timeout,!(i=new u(e,t,r)).callback){let e,t;s=new this._Promise((r,i)=>{e=r,t=i}),i.callback=(r,i)=>r?t(r):e(i)}return n&&(a=i.callback,o=setTimeout(()=>{var e=Error("Query read timeout");l.nextTick(()=>{i.handleError(e,this.connection)}),a(e),i.callback=()=>{};var t=this._queryQueue.indexOf(i);t>-1&&this._queryQueue.splice(t,1),this._pulseQueryQueue()},n),i.callback=(e,t)=>{clearTimeout(o),a(e,t)}),this._queryable?this._ending?(i.native=this.native,l.nextTick(()=>{i.handleError(Error("Client was closed and is not queryable"))})):(this._queryQueue.push(i),this._pulseQueryQueue()):(i.native=this.native,l.nextTick(()=>{i.handleError(Error("Client has encountered a connection error and is not queryable"))})),s},h.prototype.end=function(e){var t,r=this;return this._ending=!0,this._connected||this.once("connect",this.end.bind(this,e)),e||(t=new this._Promise(function(t,r){e=g(e=>e?r(e):t(),"cb")})),this.native.end(function(){r._errorAllQueries(Error("Connection terminated")),l.nextTick(()=>{r.emit("end"),e&&e()})}),t},h.prototype._hasActiveQuery=function(){return this._activeQuery&&"error"!==this._activeQuery.state&&"end"!==this._activeQuery.state},h.prototype._pulseQueryQueue=function(e){if(this._connected&&!this._hasActiveQuery()){var t=this._queryQueue.shift();
14if(!t){e||this.emit("drain");return}this._activeQuery=t,t.submit(this);var r=this;t.once("_done",function(){r._pulseQueryQueue()})}},h.prototype.cancel=function(e){this._activeQuery===e?this.native.cancel(function(){}):-1!==this._queryQueue.indexOf(e)&&this._queryQueue.splice(this._queryQueue.indexOf(e),1)},h.prototype.ref=function(){},h.prototype.unref=function(){},h.prototype.setTypeParser=function(e,t,r){return this._types.setTypeParser(e,t,r)},h.prototype.getTypeParser=function(e,t){return this._types.getTypeParser(e,t)}}),e0=b((e,t)=>{P(),t.exports=eX()}),e1=b((e,t)=>{P();var r=eV(),i=ea(),s=ez(),n=eG(),{DatabaseError:o}=eF(),a=g(e=>{var t;return g(t=class extends n{constructor(t){super(t,e)}},"BoundPool"),t},"poolFactory"),u=g(function(e){this.defaults=i,this.Client=e,this.Query=this.Client.Query,this.Pool=a(this.Client),this._pools=[],this.Connection=s,this.types=K(),this.DatabaseError=o},"PG");"u">typeof l.env.NODE_PG_FORCE_NATIVE?t.exports=new u(e0()):(t.exports=new u(r),Object.defineProperty(t.exports,"native",{configurable:!0,enumerable:!1,get(){var e=null;try{e=new u(e0())}catch(e){if("MODULE_NOT_FOUND"!==e.code)throw e}return Object.defineProperty(t.exports,"native",{value:e}),e}}))});P(),P(),O(),Q(),P();var e2=Object.defineProperty,e6=Object.defineProperties,e5=Object.getOwnPropertyDescriptors,e3=Object.getOwnPropertySymbols,e4=Object.prototype.hasOwnProperty,e8=Object.prototype.propertyIsEnumerable,e7=g((e,t,r)=>t in e?e2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,"__defNormalProp"),e9=g((e,t)=>{for(var r in t||(t={}))e4.call(t,r)&&e7(e,r,t[r]);if(e3)for(var r of e3(t))e8.call(t,r)&&e7(e,r,t[r]);return e},"__spreadValues"),te=g((e,t)=>e6(e,e5(t)),"__spreadProps"),tt=2===new Uint8Array(new Uint16Array([258]).buffer)[0],tr=new TextDecoder,ti=new TextEncoder,ts=ti.encode("0123456789abcdef"),tn=ti.encode("0123456789ABCDEF"),to=ti.encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").slice();function ta(e,{alphabet:t,scratchArr:r}={}){if(!i){if(i=new Uint16Array(256),s=new Uint16Array(256),tt)for(let e=0;e<256;e++)i[e]=ts[15&e]<<8|ts[e>>>4],s[e]=tn[15&e]<<8|tn[e>>>4];else for(let e=0;e<256;e++)i[e]=ts[15&e]|ts[e>>>4]<<8,s[e]=tn[15&e]|tn[e>>>4]<<8}e.byteOffset%4!=0&&(e=new Uint8Array(e));let n=e.length,o=n>>>2,a=r||new Uint16Array(n),l=new Uint32Array(e.buffer,e.byteOffset,o),u=new Uint32Array(a.buffer,a.byteOffset,n>>>1),h="upper"===t?s:i,c=0,f=0,d;if(tt)for(;c<o;)d=l[c++],u[f++]=h[d>>>8&255]<<16|h[255&d],u[f++]=h[d>>>24]<<16|h[d>>>16&255];else for(;c<o;)d=l[c++],u[f++]=h[d>>>24]<<16|h[d>>>16&255],u[f++]=h[d>>>8&255]<<16|h[255&d];for(c<<=2;c<n;)a[c]=h[e[c++]];return tr.decode(a.subarray(0,n))}function tl(e,t={}){let r="",i=e.length,s=Math.ceil(i/504e3),n=new Uint16Array(s>1?504e3:i);for(let i=0;i<s;i++){let s=504e3*i,o=s+504e3;r+=ta(e.subarray(s,o),te(e9({},t),{scratchArr:n}))}return r}function tu(e,t={}){return"upper"!==t.alphabet&&"function"==typeof e.toHex?e.toHex():tl(e,t)}to[62]=45,to[63]=95,g(ta,"_toHex"),g(tl,"_toHexChunked"),g(tu,"toHex"),P();var th=class e{constructor(e,t){this.strings=e,this.values=t}toParameterizedQuery(t={query:"",params:[]}){let{strings:r,values:i}=this;for(let s=0,n=r.length;s<n;s++)if(t.query+=r[s],s<i.length){let r=i[s];if(r instanceof tf)t.query+=r.sql;else if(r instanceof tE){if(r.queryData instanceof e)r.queryData.toParameterizedQuery(t);else{if(r.queryData.params?.length)throw Error("This query is not composable");t.query+=r.queryData.query}}else{let{params:e}=t;e.push(r),t.query+="$"+e.length,(r instanceof a||ArrayBuffer.isView(r))&&(t.query+="::bytea")}}return t}};g(th,"SqlTemplate");var tc=class{constructor(e){this.sql=e}};g(tc,"UnsafeRawSql");var tf=tc;function td(){"u">typeof window&&"u">typeof document&&"u">typeof console&&"function"==typeof console.warn&&console.warn(`          
15        ************************************************************
16        *                                                          *
17        *  WARNING: Running SQL directly from the browser can have *
18        *  security implications. Even if your database is         *
19        *  protected by Row-Level Security (RLS), use it at your   *
20        *  own risk. This approach is great for fast prototyping,  *
21        *  but ensure proper safeguards are in place to prevent    *
22        *  misuse or execution of expensive SQL queries by your    *
23        *  end users.                                              *
24        *                                                          *
25        *  If you've assessed the risks, suppress this message     *
26        *  using the disableWarningInBrowsers configuration        *
27        *  parameter.                                              *
28        *                                                          *
29        ************************************************************`)}P(),g(td,"warnIfBrowser"),O();
29var tp=S(J()),ty=S(el()),tg=class e extends Error{constructor(t){super(t),E(this,"name","NeonDbError"),E(this,"severity"),E(this,"code"),E(this,"detail"),E(this,"hint"),E(this,"position"),E(this,"internalPosition"),E(this,"internalQuery"),E(this,"where"),E(this,"schema"),E(this,"table"),E(this,"column"),E(this,"dataType"),E(this,"constraint"),E(this,"file"),E(this,"line"),E(this,"routine"),E(this,"sourceError"),"captureStackTrace"in Error&&"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e)}};g(tg,"NeonDbError");var tm="transaction() expects an array of queries, or a function returning an array of queries",tb=["severity","code","detail","hint","position","internalPosition","internalQuery","where","schema","table","column","dataType","constraint","file","line","routine"];function tw(e){return e instanceof a?"\\x"+tu(e):e}function tv(e){let{query:t,params:r}=e instanceof th?e.toParameterizedQuery():e;return{query:t,params:r.map(e=>tw((0,ty.prepareValue)(e)))}}function tS(e,{arrayMode:t,fullResults:r,fetchOptions:i,isolationLevel:s,readOnly:n,deferrable:o,authToken:a,disableWarningInBrowsers:l}={}){let u;if(!e)throw Error("No database connection string was provided to `neon()`. Perhaps an environment variable has not been set?");try{u=$(e)}catch{throw Error("Database connection string provided to `neon()` is not a valid URL. Connection string: "+String(e))}let{protocol:h,username:c,hostname:f,port:d,pathname:p}=u;if("postgres:"!==h&&"postgresql:"!==h||!c||!f||!p)throw Error("Database connection string format for `neon()` should be: postgresql://user:[email protected]/dbname?option=value");function y(e,...t){if(!(Array.isArray(e)&&Array.isArray(e.raw)&&Array.isArray(t)))throw Error('This function can now be called only as a tagged-template function: sql`SELECT ${value}`, not sql("SELECT $1", [value], options). For a conventional function call with value placeholders ($1, $2, etc.), use sql.query("SELECT $1", [value], options).');return new tE(m,new th(e,t))}async function m(u,h,c){let p,{fetchEndpoint:y,fetchFunction:g}=B,m=Array.isArray(u)?{queries:u.map(e=>tv(e))}:tv(u),b=i??{},w=t??!1,v=r??!1,S=s,_=n,E=o;void 0!==c&&(void 0!==c.fetchOptions&&(b={...b,...c.fetchOptions}),void 0!==c.arrayMode&&(w=c.arrayMode),void 0!==c.fullResults&&(v=c.fullResults),void 0!==c.isolationLevel&&(S=c.isolationLevel),void 0!==c.readOnly&&(_=c.readOnly),void 0!==c.deferrable&&(E=c.deferrable)),void 0===h||Array.isArray(h)||void 0===h.fetchOptions||(b={...b,...h.fetchOptions});let A=a;Array.isArray(h)||h?.authToken===void 0||(A=h.authToken);let T="function"==typeof y?y(f,d,{jwtAuth:void 0!==A}):y,C={"Neon-Connection-String":e,"Neon-Raw-Text-Output":"true","Neon-Array-Mode":"true"},P=await tT(A);P&&(C.Authorization=`Bearer ${P}`),Array.isArray(u)&&(void 0!==S&&(C["Neon-Batch-Isolation-Level"]=S),void 0!==_&&(C["Neon-Batch-Read-Only"]=String(_)),void 0!==E&&(C["Neon-Batch-Deferrable"]=String(E))),l||B.disableWarningInBrowsers||td();try{p=await (g??fetch)(T,{method:"POST",body:JSON.stringify(m),headers:C,...b})}catch(t){let e=new tg(`Error connecting to database: ${t}`);throw e.sourceError=t,e}if(p.ok){let e=await p.json();if(Array.isArray(u)){let t=e.results;if(!Array.isArray(t))throw new tg("Neon internal error: unexpected result format");return t.map((e,t)=>{let r=h[t]??{};return tA(e,{arrayMode:r.arrayMode??w,fullResults:r.fullResults??v,types:r.types})})}{let t=h??{};return tA(e,{arrayMode:t.arrayMode??w,fullResults:t.fullResults??v,types:t.types})}}{let{status:e}=p;if(400===e){let e=await p.json(),t=new tg(e.message);for(let r of tb)t[r]=e[r]??void 0;throw t}{let t=await p.text();throw new tg(`Server error (HTTP status ${e}): ${t}`)}}}return g(y,"templateFn"),y.query=(e,t,r)=>new tE(m,{query:e,params:t??[]},r),y.unsafe=e=>new tf(e),y.transaction=async(e,t)=>{if("function"==typeof e&&(e=e(y)),!Array.isArray(e))throw Error(tm);return e.forEach(e=>{if(!(e instanceof tE))throw Error(tm)}),m(e.map(e=>e.queryData),e.map(e=>e.opts??{}),t)},g(m,"execute"),y}g(tw,"encodeBuffersAsBytea"),g(tv,"prepareQuery"),g(tS,"neon");var t_=class{constructor(e,t,r){this.execute=e,this.queryData=t,this.opts=r}then(e,t){return this.execute(this.queryData,this.opts).then(e,t)}catch(e){return this.execute(this.queryData,this.opts).catch(e)}finally(e){return this.execute(this.queryData,this.opts).finally(e)}};g(t_,"NeonQueryPromise");var tE=t_;function tA(e,{arrayMode:t,fullResults:r,types:i}){let s=new tp.default(i),n=e.fields.map(e=>e.name),o=e.fields.map(e=>s.getTypeParser(e.dataTypeID)),a=!0===t?e.rows.map(e=>e.map((e,t)=>null===e?null:o[t](e))):e.rows.map(e=>Object.fromEntries(e.map((e,t)=>[n[t],null===e?null:o[t](e)])));return r?(e.viaNeonFetch=!0,e.rowAsArray=t,e.rows=a,e._parsers=o,e._types=s,e):a}async function tT(e){if("string"==typeof e)return e;if("function"==typeof e)try{return await Promise.resolve(e())}catch(t){let e=new tg("Error getting auth token.");throw t instanceof Error&&(e=new tg(`Error getting auth token: ${t.message}`)),e}}g(tA,"processQueryResult"),g(tT,"getAuthToken"),P();var tC=S(e1());P();var tP=S(e1()),tL=class extends tP.Client{constructor(e){super(e),this.config=e}get neonConfig(){return this.connection.stream}connect(e){let{neonConfig:t}=this;t.forceDisablePgSSL&&(this.ssl=this.connection.ssl=!1),this.ssl&&t.useSecureWebSocket&&console.warn("SSL is enabled for both Postgres (e.g. ?sslmode=require in the connection string + forceDisablePgSSL = false) and the WebSocket tunnel (useSecureWebSocket = true). Double encryption will increase latency and CPU usage. It may be appropriate to disable SSL in the Postgres connection parameters or set forceDisablePgSSL = true.");let r="string"!=typeof this.config&&this.config?.host!==void 0||"string"!=typeof this.config&&this.config?.connectionString!==void 0||void 0!==l.env.PGHOST,i=l.env.USER??l.env.USERNAME;if(!r&&"localhost"===this.host&&this.user===i&&this.database===i&&null===this.password)throw Error(`No database host or connection string wa\
30s set, and key parameters have default values (host: localhost, user: ${i}, db: ${i}, password: null\
31). Is an environment variable missing? Alternatively, if you intended to connect with these paramete\
32rs, please set the host to 'localhost' explicitly.`);let s=super.connect(e),n=t.pipelineTLS&&this.ssl,o="password"===t.pipelineConnect;if(!n&&!t.pipelineConnect)return s;let a=this.connection;if(n&&a.on("connect",()=>
32a.stream.emit("data","S")),o){a.removeAllListeners("authenticationCleartextPassword"),a.removeAllListeners("readyForQuery"),a.once("readyForQuery",()=>a.on("readyForQuery",this._handleReadyForQuery.bind(this)));let e=this.ssl?"sslconnect":"connect";a.on(e,()=>{this.neonConfig.disableWarningInBrowsers||td(),this._handleAuthCleartextPassword(),this._handleReadyForQuery()})}return s}async _handleAuthSASLContinue(e){if(typeof crypto>"u"||void 0===crypto.subtle||void 0===crypto.subtle.importKey)throw Error("Cannot use SASL auth when `crypto.subtle` is not defined");let t=crypto.subtle,r=this.saslSession,i=this.password,s=e.data;if("SASLInitialResponse"!==r.message||"string"!=typeof i||"string"!=typeof s)throw Error("SASL: protocol error");let n=Object.fromEntries(s.split(",").map(e=>{if(!/^.=/.test(e))throw Error("SASL: Invalid attribute pair entry");return[e[0],e.substring(2)]})),o=n.r,l=n.s,u=n.i;if(!o||!/^[!-+--~]+$/.test(o))throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing/unprintable");if(!l||!/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test(l))throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing/not base64");if(!u||!/^[1-9][0-9]*$/.test(u))throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: missing/invalid iteration count");if(!o.startsWith(r.clientNonce))throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");if(o.length===r.clientNonce.length)throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short");let h=parseInt(u,10),c=a.from(l,"base64"),f=new TextEncoder,d=f.encode(i),p=await t.importKey("raw",d,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),y=new Uint8Array(await t.sign("HMAC",p,a.concat([c,a.from([0,0,0,1])]))),g=y;for(var m=0;m<h-1;m++)y=new Uint8Array(await t.sign("HMAC",p,y)),g=a.from(g.map((e,t)=>g[t]^y[t]));let b=g,w=await t.importKey("raw",b,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),v=new Uint8Array(await t.sign("HMAC",w,f.encode("Client Key"))),S=await t.digest("SHA-256",v),_="n=*,r="+r.clientNonce,E="r="+o+",s="+l+",i="+h,A="c=biws,r="+o,T=_+","+E+","+A,C=await t.importKey("raw",S,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);var P=new Uint8Array(await t.sign("HMAC",C,f.encode(T))),L=a.from(v.map((e,t)=>v[t]^P[t])).toString("base64");let I=await t.importKey("raw",b,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),x=await t.sign("HMAC",I,f.encode("Server Key")),M=await t.importKey("raw",x,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);var k=a.from(await t.sign("HMAC",M,f.encode(T)));r.message="SASLResponse",r.serverSignature=k.toString("base64"),r.response=A+",p="+L,this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}};g(tL,"NeonClient"),O();var tI=S(eR());function tx(e,t){let r,i;return t?{callback:t,result:void 0}:{callback:g(function(e,t){e?r(e):i(t)},"cb"),result:new e(function(e,t){i=e,r=t})}}g(tx,"promisify"),g(class extends tC.Pool{constructor(){super(...arguments),E(this,"Client",tL),E(this,"hasFetchUnsupportedListeners",!1),E(this,"addListener",this.on)}on(e,t){return"error"!==e&&(this.hasFetchUnsupportedListeners=!0),super.on(e,t)}query(e,t,r){if(!B.poolQueryViaFetch||this.hasFetchUnsupportedListeners||"function"==typeof e)return super.query(e,t,r);"function"==typeof t&&(r=t,t=void 0);let i=tx(this.Promise,r);r=i.callback;try{let i=new tI.default(this.options),s=encodeURIComponent,n=encodeURI,o=`postgresql://${s(i.user)}:${s(i.password)}@${s(i.host)}\
33/${n(i.database)}`,a="string"==typeof e?e:e.text,l=t??e.values??[];tS(o,{fullResults:!0,arrayMode:"array"===e.rowMode}).query(a,l,{types:e.types??this.options?.types}).then(e=>r(void 0,e)).catch(e=>r(e))}catch(e){r(e)}return i.result}},"NeonPool"),O();var tM=S(e1());tM.DatabaseError,tM.defaults,tM.escapeIdentifier,tM.escapeLiteral;var tk=tM.types},66102:function(e,t,r){"use strict";r.d(t,{tS:function(){return eN}});var i=r(52527),s=r(19952);class n{static [s.Q]="ConsoleLogWriter";write(e){console.log(e)}}class o{static [s.Q]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new n}logQuery(e,t){let r=t.map(e=>{try{return JSON.stringify(e)}catch{return String(e)}}),i=r.length?` -- params: [${r.join(", ")}]`:"";this.writer.write(`Query: ${e}${i}`)}}class a{static [s.Q]="NoopLogger";logQuery(){}}var l=r(56036),u=r(91275),h=r(83956),c=r(45081);class f{constructor(e){this.table=e}static [s.Q]="ColumnAliasProxyHandler";get(e,t){return"table"===t?this.table:e[t]}}class d{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static [s.Q]="TableAliasProxyHandler";get(e,t){if(t===h.iA.Symbol.IsAlias)return!0;
33if(t===h.iA.Symbol.Name||this.replaceOriginalName&&t===h.iA.Symbol.OriginalName)return this.alias;if(t===c.d)return{...e[c.d],name:this.alias,isAlias:!0};if(t===h.iA.Symbol.Columns){let t=e[h.iA.Symbol.Columns];if(!t)return t;let r={};return Object.keys(t).map(i=>{r[i]=new Proxy(t[i],new f(new Proxy(e,this)))}),r}let r=e[t];return(0,s.is)(r,l.s)?new Proxy(r,new f(new Proxy(e,this))):r}}class p{constructor(e){this.alias=e}static [s.Q]=null;get(e,t){return"sourceTable"===t?y(e.sourceTable,this.alias):e[t]}}function y(e,t){return new Proxy(e,new d(t,!1))}function g(e,t){return new Proxy(e,new f(new Proxy(e.table,new d(t,!1))))}function m(e,t){return new u.$s.Aliased(b(e.sql,t),e.fieldAlias)}function b(e,t){return u.i6.join(e.queryChunks.map(e=>(0,s.is)(e,l.s)?g(e,t):(0,s.is)(e,u.$s)?b(e,t):(0,s.is)(e,u.$s.Aliased)?m(e,t):e))}function w(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(e=>e.toLowerCase()).join("_")}function v(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((e,t,r)=>e+(0===r?t.toLowerCase():`${t[0].toUpperCase()}${t.slice(1)}`),"")}function S(e){return e}class _{static [s.Q]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert="snake_case"===e?w:"camelCase"===e?v:S}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[h.iA.Symbol.Schema]??"public",r=e.table[h.iA.Symbol.OriginalName],i=`${t}.${r}.${e.name}`;return this.cache[i]||this.cacheTable(e.table),this.cache[i]}cacheTable(e){let t=e[h.iA.Symbol.Schema]??"public",r=e[h.iA.Symbol.OriginalName],i=`${t}.${r}`;if(!this.cachedTables[i]){for(let t of Object.values(e[h.iA.Symbol.Columns])){let e=`${i}.${t.name}`;this.cache[e]=this.convert(t.name)}this.cachedTables[i]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class E extends Error{static [s.Q]="DrizzleError";constructor({message:e,cause:t}){super(e),this.name="DrizzleError",this.cause=t}}class A extends Error{constructor(e,t,r){super(`Failed query: ${e}
34params: ${t}`),this.query=e,this.params=t,this.cause=r,Error.captureStackTrace(this,A),r&&(this.cause=r)}}class T extends E{static [s.Q]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}var C=r(79298),P=r(98649),L=r(95173),I=r(81157),x=r(94433),M=r(23431),k=r(7902),R=r(18754),B=r(97821),O=r(68971),N=r(12425),$=r(16700);class Q{constructor(e,t,r){this.sourceTable=e,this.referencedTable=t,this.relationName=r,this.referencedTableName=t[h.iA.Symbol.Name]}static [s.Q]="Relation";referencedTableName;fieldName}class q{constructor(e,t){this.table=e,this.config=t}static [s.Q]="Relations"}
34class D extends Q{constructor(e,t,r,i){super(e,t,r?.relationName),this.config=r,this.isNullable=i}static [s.Q]="One";withFieldName(e){let t=new D(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}}class F extends Q{constructor(e,t,r){super(e,t,r?.relationName),this.config=r}static [s.Q]="Many";withFieldName(e){let t=new F(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}}function j(e){return{one:function(t,r){return new D(e,t,r,r?.fields.reduce((e,t)=>e&&t.notNull,!0)??!1)},many:function(t,r){return new F(e,t,r)}}}var U=r(11715),W=r(82312);class z extends u.G7{static [s.Q]="PgViewBase"}class V{static [s.Q]="PgDialect";casing;constructor(e){this.casing=new _(e?.casing)}async migrate(e,t,r){let i="string"==typeof r?"__drizzle_migrations":r.migrationsTable??"__drizzle_migrations",s="string"==typeof r?"drizzle":r.migrationsSchema??"drizzle",n=(0,u.i6)`
35			CREATE TABLE IF NOT EXISTS ${u.i6.identifier(s)}.${u.i6.identifier(i)} (
36				id SERIAL PRIMARY KEY,
37				hash text NOT NULL,
38				created_at bigint
39			)
40		`;await t.execute((0,u.i6)`CREATE SCHEMA IF NOT EXISTS ${u.i6.identifier(s)}`),await t.execute(n);let o=(await t.all((0,u.i6)`select id, hash, created_at from ${u.i6.identifier(s)}.${u.i6.identifier(i)} order by created_at desc limit 1`))[0];await t.transaction(async t=>{for await(let r of e)if(!o||Number(o.created_at)<r.folderMillis){for(let e of r.sql)await t.execute(u.i6.raw(e));await t.execute((0,u.i6)`insert into ${u.i6.identifier(s)}.${u.i6.identifier(i)} ("hash", "created_at") values(${r.hash}, ${r.folderMillis})`)}})}escapeName(e){return`"${e.replace(/"/g,'""')}"`}escapeParam(e){return`$${e+1}`}escapeString(e){return`'${e.replace(/'/g,"''")}'`}buildWithCTE(e){if(!e?.length)return;let t=[(0,u.i6)`with `];for(let[r,i]of e.entries())t.push((0,u.i6)`${u.i6.identifier(i._.alias)} as (${i._.sql})`),r<e.length-1&&t.push((0,u.i6)`, `);return t.push((0,u.i6)` `),u.i6.join(t)}buildDeleteQuery({table:e,where:t,returning:r,withList:i}){let s=this.buildWithCTE(i),n=r?(0,u.i6)` returning ${this.buildSelection(r,{isSingleTable:!0})}`:void 0,o=t?(0,u.i6)` where ${t}`:void 0;return(0,u.i6)`${s}delete from ${e}${o}${n}`}buildUpdateSet(e,t){let r=e[h.iA.Symbol.Columns],i=Object.keys(r).filter(e=>void 0!==t[e]||r[e]?.onUpdateFn!==void 0),n=i.length;return u.i6.join(i.flatMap((e,i)=>{let o=r[e],a=o.onUpdateFn?.(),l=t[e]??((0,s.is)(a,u.$s)?a:u.i6.param(a,o)),h=(0,u.i6)`${u.i6.identifier(this.casing.getColumnCasing(o))} = ${l}`;return i<n-1?[h,u.i6.raw(", ")]:[h]}))}buildUpdateQuery({table:e,set:t,where:r,returning:i,withList:s,from:n,joins:o}){let a=this.buildWithCTE(s),l=e[B.YA.Symbol.Name],h=e[B.YA.Symbol.Schema],c=e[B.YA.Symbol.OriginalName],f=l===c?void 0:l,d=(0,u.i6)`${h?(0,u.i6)`${u.i6.identifier(h)}.`:void 0}${u.i6.identifier(c)}${f&&(0,u.i6)` ${u.i6.identifier(f)}`}`,p=this.buildUpdateSet(e,t),y=n&&u.i6.join([u.i6.raw(" from "),this.buildFromTable(n)]),g=this.buildJoins(o),m=i?(0,u.i6)` returning ${this.buildSelection(i,{isSingleTable:!n})}`:void 0,b=r?(0,u.i6)` where ${r}`:void 0;return(0,u.i6)`${a}update ${d} set ${p}${y}${g}${b}${m}`}buildSelection(e,{isSingleTable:t=!1}={}){let r=e.length,i=e.flatMap(({field:e},i)=>{let n=[];if((0,s.is)(e,u.$s.Aliased)&&e.isSelectionField)n.push(u.i6.identifier(e.fieldAlias));else if((0,s.is)(e,u.$s.Aliased)||(0,s.is)(e,u.$s)){let r=(0,s.is)(e,u.$s.Aliased)?e.sql:e;t?n.push(new u.$s(r.queryChunks.map(e=>(0,s.is)(e,C.df)?u.i6.identifier(this.casing.getColumnCasing(e)):e))):n.push(r),(0,s.is)(e,u.$s.Aliased)&&n.push((0,u.i6)` as ${u.i6.identifier(e.fieldAlias)}`)}else if((0,s.is)(e,l.s))t?n.push(u.i6.identifier(this.casing.getColumnCasing(e))):n.push(e);else if((0,s.is)(e,U.k)){let t=Object.entries(e._.selectedFields);if(1===t.length){let r=t[0][1],i=(0,s.is)(r,u.$s)?r.decoder:(0,s.is)(r,l.s)?{mapFromDriverValue:e=>r.mapFromDriverValue(e)}:r.sql.decoder;i&&(e._.sql.decoder=i)}n.push(e)}return i<r-1&&n.push((0,u.i6)`, `),n});return u.i6.join(i)}buildJoins(e){if(!e||0===e.length)return;let t=[];for(let[r,i]of e.entries()){0===r&&t.push((0,u.i6)` `);let n=i.table,o=i.lateral?(0,u.i6)` lateral`:void 0,a=i.on?(0,u.i6)` on ${i.on}`:void 0;if((0,s.is)(n,B.YA)){let e=n[B.YA.Symbol.Name],r=n[B.YA.Symbol.Schema],s=n[B.YA.Symbol.OriginalName],l=e===s?void 0:i.alias;t.push((0,u.i6)`${u.i6.raw(i.joinType)} join${o} ${r?(0,u.i6)`${u.i6.identifier(r)}.`:void 0}${u.i6.identifier(s)}
40${l&&(0,u.i6)` ${u.i6.identifier(l)}`}${a}`)}else if((0,s.is)(n,u.G7)){let e=n[c.d].name,r=n[c.d].schema,s=n[c.d].originalName,l=e===s?void 0:i.alias;t.push((0,u.i6)`${u.i6.raw(i.joinType)} join${o} ${r?(0,u.i6)`${u.i6.identifier(r)}.`:void 0}${u.i6.identifier(s)}${l&&(0,u.i6)` ${u.i6.identifier(l)}`}${a}`)}else t.push((0,u.i6)`${u.i6.raw(i.joinType)} join${o} ${n}${a}`);r<e.length-1&&t.push((0,u.i6)` `)}return u.i6.join(t)}buildFromTable(e){if((0,s.is)(e,h.iA)&&e[h.iA.Symbol.IsAlias]){let t=(0,u.i6)`${u.i6.identifier(e[h.iA.Symbol.OriginalName])}`;return e[h.iA.Symbol.Schema]&&(t=(0,u.i6)`${u.i6.identifier(e[h.iA.Symbol.Schema])}.${t}`),(0,u.i6)`${t} ${u.i6.identifier(e[h.iA.Symbol.Name])}`}return e}buildSelectQuery({withList:e,fields:t,fieldsFlat:r,where:i,having:n,table:o,joins:a,orderBy:f,groupBy:d,limit:p,offset:y,lockingClause:g,distinct:m,setOperators:b}){let w,v,S;let _=r??(0,W.ZS)(t);for(let e of _){let t;if((0,s.is)(e.field,l.s)&&(0,h.SP)(e.field.table)!==((0,s.is)(o,U.k)?o._.alias:(0,s.is)(o,z)?o[c.d].name:(0,s.is)(o,u.$s)?void 0:(0,h.SP)(o))&&(t=e.field.table,!a?.some(({alias:e})=>e===(t[h.iA.Symbol.IsAlias]?h.SP(t):t[h.iA.Symbol.BaseName])))){let t=(0,h.SP)(e.field.table);throw Error(`Your "${e.path.join("->")}" field references a column "${t}"."${e.field.name}", but the table "${t}" is not part of the query! Did you forget to join it?`)}}let E=!a||0===a.length,A=this.buildWithCTE(e);m&&(w=!0===m?(0,u.i6)` distinct`:(0,u.i6)` distinct on (${u.i6.join(m.on,(0,u.i6)`, `)})`);let T=this.buildSelection(_,{isSingleTable:E}),C=this.buildFromTable(o),P=this.buildJoins(a),L=i?(0,u.i6)` where ${i}`:void 0,I=n?(0,u.i6)` having ${n}`:void 0;f&&f.length>0&&(v=(0,u.i6)` order by ${u.i6.join(f,(0,u.i6)`, `)}`),d&&d.length>0&&(S=(0,u.i6)` group by ${u.i6.join(d,(0,u.i6)`, `)}`);let x="object"==typeof p||"number"==typeof p&&p>=0?(0,u.i6)` limit ${p}`:void 0,M=y?(0,u.i6)` offset ${y}`:void 0,k=u.i6.empty();if(g){let e=(0,u.i6)` for ${u.i6.raw(g.strength)}`;g.config.of&&e.append((0,u.i6)` of ${u.i6.join(Array.isArray(g.config.of)?g.config.of:[g.config.of],(0,u.i6)`, `)}`),g.config.noWait?e.append((0,u.i6)` nowait`):g.config.skipLocked&&e.append((0,u.i6)` skip locked`),k.append(e)}let R=(0,u.i6)`${A}select${w} ${T} from ${C}${P}${L}${S}${I}${v}${x}${M}${k}`;return b.length>0?this.buildSetOperations(R,b):R}buildSetOperations(e,t){let[r,...i]=t;if(!r)throw Error("Cannot pass undefined values to any set operator");return 0===i.length?this.buildSetOperationQuery({leftSelect:e,setOperator:r}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:r}),i)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:r,rightSelect:i,limit:n,orderBy:o,offset:a}}){let l;let h=(0,u.i6)`(${e.getSQL()}) `,c=(0,u.i6)`(${i.getSQL()})`;if(o&&o.length>0){let e=[];for(let t of o)if((0,s.is)(t,C.df))e.push(u.i6.identifier(t.name));else if((0,s.is)(t,u.$s)){for(let e=0;e<t.queryChunks.length;e++){let r=t.queryChunks[e];(0,s.is)(r,C.df)&&(t.queryChunks[e]=u.i6.identifier(r.name))}e.push((0,u.i6)`${t}`)}else e.push((0,u.i6)`${t}`);l=(0,u.i6)` order by ${u.i6.join(e,(0,u.i6)`, `)} `}let f="object"==typeof n||"number"==typeof n&&n>=0?(0,u.i6)` limit ${n}`:void 0,d=u.i6.raw(`${t} ${r?"all ":""}`),p=a?(0,u.i6)` offset ${a}`:void 0;return(0,u.i6)`${h}${d}${c}${l}${f}${p}`}buildInsertQuery({table:e,values:t,onConflict:r,returning:i,withList:n,select:o,overridingSystemValue_:a}){let l=[],c=Object.entries(e[h.iA.Symbol.Columns]).filter(([e,t])=>!t.shouldDisableInsert()),f=c.map(([,e])=>u.i6.identifier(this.casing.getColumnCasing(e)));if(o)(0,s.is)(t,u.$s)?l.push(t):l.push(t.getSQL());else for(let[e,r]of(l.push(u.i6.raw("values ")),t.entries())){let i=[];for(let[e,t]of c){let n=r[e];if(void 0===n||(0,s.is)(n,u.dO)&&void 0===n.value){if(void 0!==t.defaultFn){let e=t.defaultFn(),r=(0,s.is)(e,u.$s)?e:u.i6.param(e,t);i.push(r)}else if(t.default||void 0===t.onUpdateFn)i.push((0,u.i6)`default`);else{let e=t.onUpdateFn(),r=(0,s.is)(e,u.$s)?e:u.i6.param(e,t);i.push(r)}}else i.push(n)}l.push(i),e<t.length-1&&l.push((0,u.i6)`, `)}let d=this.buildWithCTE(n),p=u.i6.join(l),y=i?(0,u.i6)` returning ${this.buildSelection(i,{isSingleTable:!0})}`:void 0,g=r?(0,u.i6)` on conflict ${r}`:void 0,m=!0===a?(0,u.i6)`overriding system value `:void 0;return(0,u.i6)`${d}insert into ${e} ${f} ${m}${p}${g}${y}`}buildRefreshMaterializedViewQuery({view:e,concurrently:t,withNoData:r}
40){let i=t?(0,u.i6)` concurrently`:void 0,s=r?(0,u.i6)` with no data`:void 0;return(0,u.i6)`refresh materialized view${i} ${e}${s}`}prepareTyping(e){return(0,s.is)(e,P.B2)||(0,s.is)(e,L.y2)?"json":(0,s.is)(e,I.OJ)?"decimal":(0,s.is)(e,x.vu)?"time":(0,s.is)(e,M.sC)||(0,s.is)(e,M.bf)?"timestamp":(0,s.is)(e,k.ch)||(0,s.is)(e,k.Ec)?"date":(0,s.is)(e,R.RX)?"uuid":"none"}sqlToQuery(e,t){return e.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,prepareTyping:this.prepareTyping,invokeSource:t})}buildRelationalQueryWithoutPK({fullSchema:e,schema:t,tableNamesMap:r,table:i,tableConfig:n,queryConfig:o,tableAlias:a,nestedQueryRelation:c,joinOn:f}){let d,p=[],w,v,S=[],_,A=[];if(!0===o)p=Object.entries(n.columns).map(([e,t])=>({dbKey:t.name,tsKey:e,field:g(t,a),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let i=Object.fromEntries(Object.entries(n.columns).map(([e,t])=>[e,g(t,a)]));if(o.where){let e="function"==typeof o.where?o.where(i,{and:N.xD,between:N.vX,eq:N.eq,exists:N.Gg,gt:N.gt,gte:N.eg,ilike:N.o$,inArray:N.d3,isNull:N.Ft,isNotNull:N.K0,like:N.vL,lt:N.lt,lte:N.G,ne:N.ne,not:N.ff,notBetween:N.OL,notExists:N.UN,notLike:N.Qg,notIlike:N.mM,notInArray:N.Nl,or:N.or,sql:u.i6}):o.where;_=e&&b(e,a)}let c=[],f=[];if(o.columns){let e=!1;for(let[t,r]of Object.entries(o.columns))void 0!==r&&t in n.columns&&(e||!0!==r||(e=!0),f.push(t));f.length>0&&(f=e?f.filter(e=>o.columns?.[e]===!0):Object.keys(n.columns).filter(e=>!f.includes(e)))}else f=Object.keys(n.columns);for(let e of f){let t=n.columns[e];c.push({tsKey:e,value:t})}let d=[];if(o.with&&(d=Object.entries(o.with).filter(e=>!!e[1]).map(([e,t])=>({tsKey:e,queryConfig:t,relation:n.relations[e]}))),o.extras)for(let[e,t]of Object.entries("function"==typeof o.extras?o.extras(i,{sql:u.i6}):o.extras))c.push({tsKey:e,value:m(t,a)});for(let{tsKey:e,value:t}of c)p.push({dbKey:(0,s.is)(t,u.$s.Aliased)?t.fieldAlias:n.columns[e].name,tsKey:e,field:(0,s.is)(t,l.s)?g(t,a):t,relationTableTsKey:void 0,isJson:!1,selection:[]});let y="function"==typeof o.orderBy?o.orderBy(i,{sql:u.i6,asc:$.d,desc:$.C}):o.orderBy??[];for(let{tsKey:i,queryConfig:n,relation:c}of(Array.isArray(y)||(y=[y]),S=y.map(e=>(0,s.is)(e,l.s)?g(e,a):b(e,a)),w=o.limit,v=o.offset,d)){let o=function(e,t,r){if((0,s.is)(r,D)&&r.config)return{fields:r.config.fields,references:r.config.references};let i=t[(0,h.Q0)(r.referencedTable)];if(!i)throw Error(`Table "${r.referencedTable[h.iA.Symbol.Name]}" not found in schema`);let n=e[i];if(!n)throw Error(`Table "${i}" not found in schema`);let o=r.sourceTable,a=t[(0,h.Q0)(o)];if(!a)throw Error(`Table "${o[h.iA.Symbol.Name]}" not found in schema`);let l=[];for(let e of Object.values(n.relations))(r.relationName&&r!==e&&e.relationName===r.relationName||!r.relationName&&e.referencedTable===r.sourceTable)&&l.push(e);if(l.length>1)throw r.relationName?Error(`There are multiple relations with name "${r.relationName}" in table "${i}"`):Error(`There are multiple relations between "${i}" and "${r.sourceTable[h.iA.Symbol.Name]}". Please specify relation name`);if(l[0]&&(0,s.is)(l[0],D)&&l[0].config)return{fields:l[0].config.references,references:l[0].config.fields};throw Error(`There is not enough information to infer relation "${a}.${r.fieldName}"`)}(t,r,c),l=r[(0,h.Q0)(c.referencedTable)],f=`${a}_${i}`,d=(0,N.xD)(...o.fields.map((e,t)=>(0,N.eq)(g(o.references[t],f),g(e,a)))),y=this.buildRelationalQueryWithoutPK({fullSchema:e,schema:t,tableNamesMap:r,table:e[l],tableConfig:t[l],queryConfig:(0,s.is)(c,D)?!0===n?{limit:1}:{...n,limit:1}:n,tableAlias:f,joinOn:d,nestedQueryRelation:c}),m=(0,u.i6)`${u.i6.identifier(f)}.${u.i6.identifier("data")}`.as(i);A.push({on:(0,u.i6)`true`,table:new U.k(y.sql,{},f),alias:f,joinType:"left",lateral:!0}),p.push({dbKey:i,tsKey:i,field:m,relationTableTsKey:l,isJson:!0,selection:y.selection})}}if(0===p.length)throw new E({message:`No fields selected for table "${n.tsName}" ("${a}")`});if(_=(0,N.xD)(f,_),c){let e=(0,u.i6)`json_build_array(${u.i6.join(p.map(({field:e,tsKey:t,isJson:r})=>r?(0,u.i6)`${u.i6.identifier(`${a}_${t}`)}.${u.i6.identifier("data")}`:(0,s.is)(e,u.$s.Aliased)?e.sql:e),(0,u.i6)`, `)})`;(0,s.is)(c,F)&&(e=(0,u.i6)`coalesce(json_agg(${e}${S.length>0?(0,u.i6)` order by ${u.i6.join(S,(0,u.i6)`, `)}`:void 0}), '[]'::json)`);let t=[{dbKey:"data",tsKey:"data",field:e.as("data"),isJson:!0,relationTableTsKey:n.tsName,selection:p}];void 0!==w||void 0!==v||S.length>0?(d=this.buildSelectQuery({table:y(i,a),fields:{},fieldsFlat:[{path:[],field:u.i6.raw("*")}],where:_,limit:w,offset:v,orderBy:S,setOperators:[]}),_=void 0,w=void 0,v=void 0,S=[]):d=y(i,a),d=this.buildSelectQuery({table:(0,s.is)(d,B.YA)?d:new U.k(d,{},a),fields:{},fieldsFlat:t.map(({field:e})=>({path:[],field:(0,s.is)(e,l.s)?g(e,a):e})),joins:A,where:_,limit:w,offset:v,orderBy:S,setOperators:[]})}else d=this.buildSelectQuery({table:y(i,a),fields:{},fieldsFlat:p.map(({field:e})=>({path:[],field:(0,s.is)(e,l.s)?g(e,a):e})),joins:A,where:_,limit:w,offset:v,orderBy:S,setOperators:[]});return{tableTsKey:n.tsName,sql:d,selection:p}}}class G{static [s.Q]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,t){if("_"===t)return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===c.d)return{...e[c.d],selectedFields:new Proxy(e[c.d].selectedFields,this)};if("symbol"==typeof t)return e[t];let r=((0,s.is)(e,U.k)?e._.selectedFields:(0,s.is)(e,u.G7)?e[c.d].selectedFields:e)[t];if((0,s.is)(r,u.$s.Aliased)){if("sql"===this.config.sqlAliasedBehavior&&!r.isSelectionField)return r.sql;let e=r.clone();return e.isSelectionField=!0,e}if((0,s.is)(r,u.$s)){if("sql"===this.config.sqlBehavior)return r;throw Error(`You tried to reference "${t}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('al
40ias')" method.`)}return(0,s.is)(r,l.s)?this.config.alias?new Proxy(r,new f(new Proxy(r.table,new d(this.config.alias,this.config.replaceOriginalName??!1)))):r:"object"!=typeof r||null===r?r:new Proxy(r,new G(this.config))}}class H{static [s.Q]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class K{static [s.Q]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}}var J=r(14517);function Y(e){return(0,s.is)(e,B.YA)?[e[h.V_]?`${e[h.V_]}.${e[h.iA.Symbol.BaseName]}`:e[h.iA.Symbol.BaseName]]:(0,s.is)(e,U.k)?e._.usedTables??[]:(0,s.is)(e,u.$s)?e.usedTables??[]:[]}class Z{static [s.Q]="PgSelectBuilder";fields;session;dialect;withList=[];distinct;constructor(e){this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,e.withList&&(this.withList=e.withList),this.distinct=e.distinct}authToken;setToken(e){return this.authToken=e,this}from(e){let t;let r=!!this.fields;return t=this.fields?this.fields:(0,s.is)(e,U.k)?Object.fromEntries(Object.keys(e._.selectedFields).map(t=>[t,e[t]])):(0,s.is)(e,z)?e[c.d].selectedFields:(0,s.is)(e,u.$s)?{}:(0,W.SS)(e),new ee({table:e,fields:t,isPartialSelect:r,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}}class X extends H{static [s.Q]="PgSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:e,fields:t,isPartialSelect:r,session:i,dialect:s,withList:n,distinct:o}){for(let a of(super(),this.config={withList:n,table:e,fields:{...t},distinct:o,setOperators:[]},this.isPartialSelect=r,this.session=i,this.dialect=s,this._={selectedFields:t,config:this.config},this.tableName=(0,W.dP)(e),this.joinsNotNullableMap="string"==typeof this.tableName?{[this.tableName]:!0}:{},Y(e)))this.usedTables.add(a)}getUsedTables(){return[...this.usedTables]}createJoin(e,t){return(r,i)=>{let n=this.tableName,o=(0,W.dP)(r);for(let e of Y(r))this.usedTables.add(e);if("string"==typeof o&&this.config.joins?.some(e=>e.alias===o))throw Error(`Alias "${o}" is already used in this query`);if(!this.isPartialSelect&&(1===Object.keys(this.joinsNotNullableMap).length&&"string"==typeof n&&(this.config.fields={[n]:this.config.fields}),"string"==typeof o&&!(0,s.is)(r,u.$s))){let e=(0,s.is)(r,U.k)?r._.selectedFields:(0,s.is)(r,u.G7)?r[c.d].selectedFields:r[h.iA.Symbol.Columns];this.config.fields[o]=e}if("function"==typeof i&&(i=i(new Proxy(this.config.fields,new G({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:i,table:r,joinType:e,alias:o,lateral:t}),"string"==typeof o)switch(e){case"left":this.joinsNotNullableMap[o]=!1;break;case"right":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[o]=!0;break;case"cross":case"inner":this.joinsNotNullableMap[o]=!0;break;case"full":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[o]=!1}return this}}leftJoin=this.createJoin("left",!1);leftJoinLateral=this.createJoin("left",!0);rightJoin=this.createJoin("right",!1);innerJoin=this.createJoin("inner",!1);innerJoinLateral=this.createJoin("inner",!0);fullJoin=this.createJoin("full",!1);crossJoin=this.createJoin("cross",!1);crossJoinLateral=this.createJoin("cross",!0);createSetOperator(e,t){return r=>{let i="function"==typeof r?r(er()):r;if(!(0,W.ux)(this.getSelectedFields(),i.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:e,isAll:t,rightSelect:i}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);intersectAll=this.createSetOperator("intersect",!0);except=this.createSetOperator("except",!1);exceptAll=this.createSetOperator("except",!0);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new G({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=e,this}having(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new G({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.having=e,this}groupBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.fields,new G({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(t)?t:[t]}else this.config.groupBy=e;return this}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.fields,new G({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),r=Array.isArray(t)?t:[t];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=r:this.config.orderBy=r}else this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=e:this.config.orderBy=e;return this}limit(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=e:this.config.limit=e,this}offset(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=e:this.config.offset=e,this}for(e,t={}){return this.config.lockingClause={strength:e,config:t},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}as(e){let t=[];if(t.push(...Y(this.config.table)),this.config.joins)for(let e of this.config.joins)t.push(...Y(e.table));return new Proxy(new U.k(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new G({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new G({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}$withCache(e){return this.cacheConfig=void 0===e?{config:{},enable:!0,autoInvalidate:!0}:!1===e?{enable:!1}:{enable:!0,autoInvalidate:!0,...e},this}}class ee extends X{static [s.Q]="PgSelect";_prepare(e){let{session:t,config:r,dialect:i,joinsNotNullableMap:s,authToken:n,cacheConfig:o,usedTables:a}=this;if(!t)throw Error("Cannot execute a query on a query builder. Please use a database instance instead.");let{fields:l}=r;return J.Z.startActiveSpan("drizzle.prepareQuery",()=>{let r=(0,W.ZS)(l),u=t.prepareQuery(i.sqlToQuery(this.getSQL()),r,e,!0,void 0,{type:"select",tables:[...a]},o);return u.joinsNotNullableMap=s,u.setToken(n)})}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>J.Z.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken))}
40function et(e,t){return(r,i,...s)=>{let n=[i,...s].map(r=>({type:e,isAll:t,rightSelect:r}));for(let e of n)if(!(0,W.ux)(r.getSelectedFields(),e.rightSelect.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return r.addSetOperators(n)}}(0,W.ef)(ee,[K]);let er=()=>({union:ei,unionAll:es,intersect:en,intersectAll:eo,except:ea,exceptAll:el}),ei=et("union",!1),es=et("union",!0),en=et("intersect",!1),eo=et("intersect",!0),ea=et("except",!1),el=et("except",!0);class eu{static [s.Q]="PgQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=(0,s.is)(e,V)?e:void 0,this.dialectConfig=(0,s.is)(e,V)?void 0:e}$with=(e,t)=>{let r=this;return{as:i=>("function"==typeof i&&(i=i(r)),new Proxy(new U.S(i.getSQL(),t??("getSelectedFields"in i?i.getSelectedFields()??{}:{}),e,!0),new G({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}};with(...e){let t=this;return{select:function(r){return new Z({fields:r??void 0,session:void 0,dialect:t.getDialect(),withList:e})},selectDistinct:function(e){return new Z({fields:e??void 0,session:void 0,dialect:t.getDialect(),distinct:!0})},selectDistinctOn:function(e,r){return new Z({fields:r??void 0,session:void 0,dialect:t.getDialect(),distinct:{on:e}})}}}select(e){return new Z({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new Z({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn(e,t){return new Z({fields:t??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:e}})}getDialect(){return this.dialect||(this.dialect=new V(this.dialectConfig)),this.dialect}}
40class eh{constructor(e,t,r,i){this.table=e,this.session=t,this.dialect=r,this.withList=i}static [s.Q]="PgUpdateBuilder";authToken;setToken(e){return this.authToken=e,this}set(e){return new ec(this.table,(0,W.M6)(this.table,e),this.session,this.dialect,this.withList).setToken(this.authToken)}}class ec extends K{constructor(e,t,r,i,s){super(),this.session=r,this.dialect=i,this.config={set:t,table:e,withList:s,joins:[]},this.tableName=(0,W.dP)(e),this.joinsNotNullableMap="string"==typeof this.tableName?{[this.tableName]:!0}:{}}static [s.Q]="PgUpdate";config;tableName;joinsNotNullableMap;cacheConfig;from(e){let t=(0,W.dP)(e);return"string"==typeof t&&(this.joinsNotNullableMap[t]=!0),this.config.from=e,this}getTableLikeFields(e){return(0,s.is)(e,B.YA)?e[h.iA.Symbol.Columns]:(0,s.is)(e,U.k)?e._.selectedFields:e[c.d].selectedFields}createJoin(e){return(t,r)=>{let i=(0,W.dP)(t);if("string"==typeof i&&this.config.joins.some(e=>e.alias===i))throw Error(`Alias "${i}" is already used in this query`);if("function"==typeof r){let e=this.config.from&&!(0,s.is)(this.config.from,u.$s)?this.getTableLikeFields(this.config.from):void 0;r=r(new Proxy(this.config.table[h.iA.Symbol.Columns],new G({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),e&&new Proxy(e,new G({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}if(this.config.joins.push({on:r,table:t,joinType:e,alias:i}),"string"==typeof i)switch(e){case"left":this.joinsNotNullableMap[i]=!1;break;case"right":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[i]=!0;break;case"inner":this.joinsNotNullableMap[i]=!0;break;case"full":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[i]=!1}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where(e){return this.config.where=e,this}returning(e){if(!e&&(e=Object.assign({},this.config.table[h.iA.Symbol.Columns]),this.config.from)){let t=(0,W.dP)(this.config.from);if("string"==typeof t&&this.config.from&&!(0,s.is)(this.config.from,u.$s)){let r=this.getTableLikeFields(this.config.from);e[t]=r}for(let t of this.config.joins){let r=(0,W.dP)(t.table);if("string"==typeof r&&!(0,s.is)(t.table,u.$s)){let i=this.getTableLikeFields(t.table);e[r]=i}}}return this.config.returningFields=e,this.config.returning=(0,W.ZS)(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){let t=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0,void 0,{type:"insert",tables:Y(this.config.table)},this.cacheConfig);return t.joinsNotNullableMap=this.joinsNotNullableMap,t}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>this._prepare().execute(e,this.authToken);getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new G({alias:(0,h.SP)(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class ef{constructor(e,t,r,i,s){this.table=e,this.session=t,this.dialect=r,this.withList=i,this.overridingSystemValue_=s}static [s.Q]="PgInsertBuilder";authToken;setToken(e){return this.authToken=e,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values(e){if(0===(e=Array.isArray(e)?e:[e]).length)throw Error("values() must be called with at least one value");let t=e.map(e=>{let t={},r=this.table[h.iA.Symbol.Columns];for(let i of Object.keys(e)){let n=e[i];t[i]=(0,s.is)(n,u.$s)?n:new u.dO(n,r[i])}return t});return new ed(this.table,t,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select(e){let t="function"==typeof e?e(new eu):e;if(!(0,s.is)(t,u.$s)&&!(0,W.ux)(this.table[h.oe],t._.selectedFields))throw Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new ed(this.table,t,this.session,this.dialect,this.withList,!0)}}class ed extends K{constructor(e,t,r,i,s,n,o){super(),this.session=r,this.dialect=i,this.config={table:e,values:t,withList:s,select:n,overridingSystemValue_:o}}static [s.Q]="PgInsert";config;cacheConfig;returning(e=this.config.table[h.iA.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=(0,W.ZS)(e),this}onConflictDoNothing(e={}){if(void 0===e.target)this.config.onConflict=(0,u.i6)`do nothing`;else{let t="";t=Array.isArray(e.target)?e.target.map(e=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(e))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target));
40let r=e.where?(0,u.i6)` where ${e.where}`:void 0;this.config.onConflict=(0,u.i6)`(${u.i6.raw(t)})${r} do nothing`}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');let t=e.where?(0,u.i6)` where ${e.where}`:void 0,r=e.targetWhere?(0,u.i6)` where ${e.targetWhere}`:void 0,i=e.setWhere?(0,u.i6)` where ${e.setWhere}`:void 0,s=this.dialect.buildUpdateSet(this.config.table,(0,W.M6)(this.config.table,e.set)),n="";return n=Array.isArray(e.target)?e.target.map(e=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(e))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target)),this.config.onConflict=(0,u.i6)`(${u.i6.raw(n)})${r} do update set ${s}${t}${i}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return J.Z.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0,void 0,{type:"insert",tables:Y(this.config.table)},this.cacheConfig))}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>J.Z.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken));getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new G({alias:(0,h.SP)(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}
40class ep extends K{constructor(e,t,r,i){super(),this.session=t,this.dialect=r,this.config={table:e,withList:i}}static [s.Q]="PgDelete";config;cacheConfig;where(e){return this.config.where=e,this}returning(e=this.config.table[h.iA.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=(0,W.ZS)(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return J.Z.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0,void 0,{type:"delete",tables:Y(this.config.table)},this.cacheConfig))}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>J.Z.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken));getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new G({alias:(0,h.SP)(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class ey extends u.$s{constructor(e){super(ey.buildEmbeddedCount(e.source,e.filters).queryChunks),this.params=e,this.mapWith(Number),this.session=e.session,this.sql=ey.buildCount(e.source,e.filters)}sql;token;static [s.Q]="PgCountBuilder";[Symbol.toStringTag]="PgCountBuilder";session;static buildEmbeddedCount(e,t){return(0,u.i6)`(select count(*) from ${e}${u.i6.raw(" where ").if(t)}${t})`}static buildCount(e,t){return(0,u.i6)`select count(*) as count from ${e}${u.i6.raw(" where ").if(t)}${t};`}setToken(e){return this.token=e,this}then(e,t){return Promise.resolve(this.session.count(this.sql,this.token)).then(e,t)}catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}}class eg{constructor(e,t,r,i,s,n,o){this.fullSchema=e,this.schema=t,this.tableNamesMap=r,this.table=i,this.tableConfig=s,this.dialect=n,this.session=o}static [s.Q]="PgRelationalQueryBuilder";findMany(e){return new em(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},"many")}findFirst(e){return new em(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}}class em extends K{constructor(e,t,r,i,s,n,o,a,l){super(),this.fullSchema=e,this.schema=t,this.tableNamesMap=r,this.table=i,this.tableConfig=s,this.dialect=n,this.session=o,this.config=a,this.mode=l}static [s.Q]="PgRelationalQuery";_prepare(e){return J.Z.startActiveSpan("drizzle.prepareQuery",()=>{let{query:t,builtQuery:r}=this._toSQL();return this.session.prepareQuery(r,void 0,e,!0,(e,r)=>{let i=e.map(e=>(function e(t,r,i,n,o=e=>e){let a={};for(let[h,c]of n.entries())if(c.isJson){let n=r.relations[c.tsKey],l=i[h],u="string"==typeof l?JSON.parse(l):l;a[c.tsKey]=(0,s.is)(n,D)?u&&e(t,t[c.relationTableTsKey],u,c.selection,o):u.map(r=>e(t,t[c.relationTableTsKey],r,c.selection,o))}else{let e;let t=o(i[h]),r=c.field;e=(0,s.is)(r,l.s)?r:(0,s.is)(r,u.$s)?r.decoder:r.sql.decoder,a[c.tsKey]=null===t?null:e.mapFromDriverValue(t)}return a})(this.schema,this.tableConfig,e,t.selection,r));return"first"===this.mode?i[0]:i})})}prepare(e){return this._prepare(e)}_getQuery(){return this.dialect.buildRelationalQueryWithoutPK({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName})}getSQL(){return this._getQuery().sql}_toSQL(){let e=this._getQuery(),t=this.dialect.sqlToQuery(e.sql);return{query:e,builtQuery:t}}toSQL(){return this._toSQL().builtQuery}authToken;setToken(e){return this.authToken=e,this}execute(){return J.Z.startActiveSpan("drizzle.operation",()=>this._prepare().execute(void 0,this.authToken))}}
40class eb extends K{constructor(e,t,r,i){super(),this.execute=e,this.sql=t,this.query=r,this.mapBatchResult=i}static [s.Q]="PgRaw";getSQL(){return this.sql}getQuery(){return this.query}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return!1}}class ew extends K{constructor(e,t,r){super(),this.session=t,this.dialect=r,this.config={view:e}}static [s.Q]="PgRefreshMaterializedView";config;concurrently(){if(void 0!==this.config.withNoData)throw Error("Cannot use concurrently and withNoData together");return this.config.concurrently=!0,this}withNoData(){if(void 0!==this.config.concurrently)throw Error("Cannot use concurrently and withNoData together");return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return J.Z.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,e,!0))}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>J.Z.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken))}class ev{constructor(e,t,r){if(this.dialect=e,this.session=t,this._=r?{schema:r.schema,fullSchema:r.fullSchema,tableNamesMap:r.tableNamesMap,session:t}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:t},this.query={},this._.schema)for(let[i,s]of Object.entries(this._.schema))this.query[i]=new eg(r.fullSchema,this._.schema,this._.tableNamesMap,r.fullSchema[i],s,e,t);this.$cache={invalidate:async e=>{}}}static [s.Q]="PgDatabase";query;$with=(e,t)=>{let r=this;return{as:i=>("function"==typeof i&&(i=i(new eu(r.dialect))),new Proxy(new U.S(i.getSQL(),t??("getSelectedFields"in i?i.getSelectedFields()??{}:{}),e,!0),new G({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}};$count(e,t){return new ey({source:e,filters:t,session:this.session})}$cache;with(...e){let t=this;return{select:function(r){return new Z({fields:r??void 0,session:t.session,dialect:t.dialect,withList:e})},selectDistinct:function(r){return new Z({fields:r??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})},selectDistinctOn:function(r,i){return new Z({fields:i??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:{on:r}})},update:function(r){return new eh(r,t.session,t.dialect,e)},insert:function(r){return new ef(r,t.session,t.dialect,e)},delete:function(r){return new ep(r,t.session,t.dialect,e)}}}select(e){return new Z({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new Z({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn(e,t){return new Z({fields:t??void 0,session:this.session,dialect:this.dialect,distinct:{on:e}})}update(e){return new eh(e,this.session,this.dialect)}insert(e){return new ef(e,this.session,this.dialect)}delete(e){return new ep(e,this.session,this.dialect)}refreshMaterializedView(e){return new ew(e,this.session,this.dialect)}authToken;execute(e){let t="string"==typeof e?u.i6.raw(e):e.getSQL(),r=this.dialect.sqlToQuery(t),i=this.session.prepareQuery(r,void 0,void 0,!1);return new eb(()=>i.execute(void 0,this.authToken),t,r,e=>i.mapResult(e,!0))}transaction(e,t){return this.session.transaction(e,t)}}class eS{static [s.Q]="Cache"}class e_ extends eS{strategy(){return"all"}static [s.Q]="NoopCache";async get(e){}async put(e,t,r,i){}async onMutate(e){}}async function eE(e,t){let r=`${e}-${JSON.stringify(t)}`,i=new TextEncoder().encode(r);return[...new Uint8Array(await crypto.subtle.digest("SHA-256",i))].map(e=>e.toString(16).padStart(2,"0")).join("")}
40class eA{constructor(e,t,r,i){this.query=e,this.cache=t,this.queryMetadata=r,this.cacheConfig=i,t&&"all"===t.strategy()&&void 0===i&&(this.cacheConfig={enable:!0,autoInvalidate:!0}),this.cacheConfig?.enable||(this.cacheConfig=void 0)}authToken;getQuery(){return this.query}mapResult(e,t){return e}setToken(e){return this.authToken=e,this}static [s.Q]="PgPreparedQuery";joinsNotNullableMap;async queryWithCache(e,t,r){if(void 0===this.cache||(0,s.is)(this.cache,e_)||void 0===this.queryMetadata)try{return await r()}catch(r){throw new A(e,t,r)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await r()}catch(r){throw new A(e,t,r)}if(("insert"===this.queryMetadata.type||"update"===this.queryMetadata.type||"delete"===this.queryMetadata.type)&&this.queryMetadata.tables.length>0)try{let[e]=await Promise.all([r(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return e}catch(r){throw new A(e,t,r)}if(!this.cacheConfig)try{return await r()}catch(r){throw new A(e,t,r)}if("select"===this.queryMetadata.type){let i=await this.cache.get(this.cacheConfig.tag??await eE(e,t),this.queryMetadata.tables,void 0!==this.cacheConfig.tag,this.cacheConfig.autoInvalidate);if(void 0===i){let i;try{i=await r()}catch(r){throw new A(e,t,r)}return await this.cache.put(this.cacheConfig.tag??await eE(e,t),i,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],void 0!==this.cacheConfig.tag,this.cacheConfig.config),i}return i}try{return await r()}catch(r){throw new A(e,t,r)}}}class eT{constructor(e){this.dialect=e}static [s.Q]="PgSession";execute(e,t){return J.Z.startActiveSpan("drizzle.operation",()=>J.Z.startActiveSpan("drizzle.prepareQuery",()=>this.prepareQuery(this.dialect.sqlToQuery(e),void 0,void 0,!1)).setToken(t).execute(void 0,t))}all(e){return this.prepareQuery(this.dialect.sqlToQuery(e),void 0,void 0,!1).all()}async count(e,t){return Number((await this.execute(e,t))[0].count)}}class eC extends ev{constructor(e,t,r,i=0){super(e,t,r),this.schema=r,this.nestedIndex=i}static [s.Q]="PgTransaction";rollback(){throw new T}getTransactionConfigSQL(e){let t=[];return e.isolationLevel&&t.push(`isolation level ${e.isolationLevel}`),e.accessMode&&t.push(e.accessMode),"boolean"==typeof e.deferrable&&t.push(e.deferrable?"deferrable":"not deferrable"),u.i6.raw(t.join(" "))}setTransaction(e){return this.session.execute((0,u.i6)`set transaction ${this.getTransactionConfigSQL(e)}`)}}let eP={arrayMode:!1,fullResults:!0},eL={arrayMode:!0,fullResults:!0};class eI extends eA{constructor(e,t,r,i,s,n,o,a,l){super(t,i,s,n),this.client=e,this.logger=r,this.fields=o,this._isResponseInArrayMode=a,this.customResultMapper=l,this.clientQuery=e.query??e}static [s.Q]="NeonHttpPreparedQuery";clientQuery;async execute(e={},t=this.authToken){let r=(0,u.Pr)(this.query.params,e);this.logger.logQuery(this.query.sql,r);let{fields:i,clientQuery:s,query:n,customResultMapper:o}=this;if(!i&&!o)return this.queryWithCache(n.sql,r,async()=>s(n.sql,r,void 0===t?eP:{...eP,authToken:t}));let a=await this.queryWithCache(n.sql,r,async()=>await s(n.sql,r,void 0===t?eL:{...eL,authToken:t}));return this.mapResult(a)}mapResult(e){if(!this.fields&&!this.customResultMapper)return e;let t=e.rows;return this.customResultMapper?this.customResultMapper(t):t.map(e=>(0,W.M4)(this.fields,e,this.joinsNotNullableMap))}all(e={}){let t=(0,u.Pr)(this.query.params,e);return this.logger.logQuery(this.query.sql,t),this.clientQuery(this.query.sql,t,void 0===this.authToken?eP:{...eP,authToken:this.authToken}).then(e=>e.rows)}values(e={},t){let r=(0,u.Pr)(this.query.params,e);return this.logger.logQuery(this.query.sql,r),this.clientQuery(this.query.sql,r,{arrayMode:!0,fullResults:!0,authToken:t}).then(e=>e.rows)}isResponseInArrayMode(){return this._isResponseInArrayMode}}class ex extends eT{constructor(e,t,r,i={}){super(t),this.client=e,this.schema=r,this.options=i,this.clientQuery=e.query??e,this.logger=i.logger??new a,this.cache=i.cache??new e_}static [s.Q]="NeonHttpSession";clientQuery;logger;cache;prepareQuery(e,t,r,i,s,n,o){return new eI(this.client,e,this.logger,this.cache,n,o,t,i,s)}async batch(e){let t=[],r=[];for(let i of e){let e=i._prepare(),s=e.getQuery();t.push(e),r.push(this.clientQuery(s.sql,s.params,{fullResults:!0,arrayMode:e.isResponseInArrayMode()}))}return(await this.client.transaction(r,eL)).map((e,r)=>t[r].mapResult(e,!0))}async query(e,t){return this.logger.logQuery(e,t),await this.clientQuery(e,t,{arrayMode:!0,fullResults:!0})}async queryObjects(e,t){return this.clientQuery(e,t,{arrayMode:!1,fullResults:!0})}async count(e,t){return Number((await this.execute(e,t)).rows[0].count)}
40async transaction(e,t={}){throw Error("No transactions support in neon-http driver")}}class eM extends null{static [s.Q]=null;async transaction(e){throw Error("No transactions support in neon-http driver")}}class ek{constructor(e,t,r={}){this.client=e,this.dialect=t,this.options=r,this.initMappers()}static [s.Q]="NeonHttpDriver";createSession(e){return new ex(this.client,this.dialect,e,{logger:this.options.logger,cache:this.options.cache})}initMappers(){i.V5.setTypeParser(i.V5.builtins.TIMESTAMPTZ,e=>e),i.V5.setTypeParser(i.V5.builtins.TIMESTAMP,e=>e),i.V5.setTypeParser(i.V5.builtins.DATE,e=>e),i.V5.setTypeParser(i.V5.builtins.INTERVAL,e=>e),i.V5.setTypeParser(1231,e=>e),i.V5.setTypeParser(1115,e=>e),i.V5.setTypeParser(1185,e=>e),i.V5.setTypeParser(1187,e=>e),i.V5.setTypeParser(1182,e=>e)}}function eR(e,t,r,i){return new Proxy(e,{get(e,s){let n=e[s];return"function"!=typeof n&&("object"!=typeof n||null===n)?n:i?eR(n,t,r):"query"===s?eR(n,t,r,!0):new Proxy(n,{apply(e,i,n){let o=e.call(i,...n);return"object"==typeof o&&null!==o&&"setToken"in o&&"function"==typeof o.setToken&&o.setToken(t),r(e,s,o)}})}})}class eB extends ev{static [s.Q]="NeonHttpDatabase";$withAuth(e){return this.authToken=e,eR(this,e,(t,r,i)=>"with"===r?eR(i,e,(e,t,r)=>r):i)}async batch(e){return this.session.batch(e)}}function eO(e,t={}){let r,i;let n=new V({casing:t.casing});if(!0===t.logger?r=new o:!1!==t.logger&&(r=t.logger),t.schema){let e=function(e,t){1===Object.keys(e).length&&"default"in e&&!(0,s.is)(e.default,h.iA)&&(e=e.default);let r={},i={},n={};for(let[o,a]of Object.entries(e))if((0,s.is)(a,h.iA)){let e=(0,h.Q0)(a),t=i[e];for(let i of(r[e]=o,n[o]={tsName:o,dbName:a[h.iA.Symbol.Name],schema:a[h.iA.Symbol.Schema],columns:a[h.iA.Symbol.Columns],relations:t?.relations??{},primaryKey:t?.primaryKey??[]},Object.values(a[h.iA.Symbol.Columns])))i.primary&&n[o].primaryKey.push(i);let l=a[h.iA.Symbol.ExtraConfigBuilder]?.(a[h.iA.Symbol.ExtraConfigColumns]);if(l)for(let e of Object.values(l))(0,s.is)(e,O.ut)&&n[o].primaryKey.push(...e.columns)}else if((0,s.is)(a,q)){let e;let s=(0,h.Q0)(a.table),o=r[s];for(let[r,l]of Object.entries(a.config(t(a.table))))if(o){let t=n[o];t.relations[r]=l,e&&t.primaryKey.push(...e)}else s in i||(i[s]={relations:{},primaryKey:e}),i[s].relations[r]=l}return{tables:n,tableNamesMap:r}}(t.schema,j);i={fullSchema:t.schema,schema:e.tables,tableNamesMap:e.tableNamesMap}}let a=new ek(e,n,{logger:r,cache:t.cache}).createSession(i),l=new eB(n,a,i);return l.$client=e,l.$cache=t.cache,l.$cache&&(l.$cache.invalidate=t.cache?.onMutate),l}function eN(...e){if("string"==typeof e[0])return eO((0,i.qn)(e[0]),e[1]);if((0,W.wM)(e[0])){let{connection:t,client:r,...s}=e[0];if(r)return eO(r,s);if("object"==typeof t){let{connectionString:e,...r}=t;return eO((0,i.qn)(e,r),s)}return eO((0,i.qn)(t),s)}return eO(e[0],e[1])}(eN||(eN={})).mock=function(e){return eO({},e)}},12425:function(e,t,r){"use strict";r.d(t,{Ft:function(){return w},G:function(){return g},Gg:function(){return S},K0:function(){return v},Nl:function(){return b},OL:function(){return A},Qg:function(){return C},UN:function(){return _},d3:function(){return m},eg:function(){return p},eq:function(){return l},ff:function(){return f},gt:function(){return d},lt:function(){return y},mM:function(){return L},ne:function(){return u},o$:function(){return P},or:function(){return c},vL:function(){return T},vX:function(){return E},xD:function(){return h}});var i=r(56036),s=r(19952),n=r(83956),o=r(91275);function a(e,t){return!(0,o._B)(t)||(0,o.zl)(e)||(0,s.is)(e,o.dO)||(0,s.is)(e,o.Vm)||(0,s.is)(e,i.s)||(0,s.is)(e,n.iA)||(0,s.is)(e,o.G7)?e:new o.dO(e,t)}let l=(e,t)=>(0,o.i6)`${e} = ${a(t,e)}`,u=(e,t)=>(0,o.i6)`${e} <> ${a(t,e)}`;function h(...e){let t=e.filter(e=>void 0!==e);return 0===t.length?void 0:new o.$s(1===t.length?t:[new o.Zm("("),o.i6.join(t,new o.Zm(" and ")),new o.Zm(")")])}function c(...e){let t=e.filter(e=>void 0!==e);return 0===t.length?void 0:new o.$s(1===t.length?t:[new o.Zm("("),o.i6.join(t,new o.Zm(" or ")),new o.Zm(")")])}function f(e){return(0,o.i6)`not ${e}`}let d=(e,t)=>(0,o.i6)`${e} > ${a(t,e)}`,p=(e,t)=>(0,o.i6)`${e} >= ${a(t,e)}`,y=(e,t)=>(0,o.i6)`${e} < ${a(t,e)}`,g=(e,t)=>(0,o.i6)`${e} <= ${a(t,e)}`;function m(e,t){return Array.isArray(t)?0===t.length?(0,o.i6)`false`:(0,o.i6)`${e} in ${t.map(t=>a(t,e))}`:(0,o.i6)`${e} in ${a(t,e)}`}function b(e,t){return Array.isArray(t)?0===t.length?(0,o.i6)`true`:(0,o.i6)`${e} not in ${t.map(t=>a(t,e))}`:(0,o.i6)`${e} not in ${a(t,e)}`}function w(e){return(0,o.i6)`${e} is null`}function v(e){return(0,o.i6)`${e} is not null`}function S(e){return(0,o.i6)`exists ${e}`}function _(e){return(0,o.i6)`not exists ${e}`}function E(e,t,r){return(0,o.i6)`${e} between ${a(t,e)} and ${a(r,e)}`}function A(e,t,r){return(0,o.i6)`${e} not between ${a(t,e)} and ${a(r,e)}`}function T(e,t){return(0,o.i6)`${e} like ${t}`}function C(e,t){return(0,o.i6)`${e} not like ${t}`}function P(e,t){return(0,o.i6)`${e} ilike ${t}`}function L(e,t){return(0,o.i6)`${e} not ilike ${t}`}},16700:function(e,t,r){"use strict";r.d(t,{C:function(){return n},d:function(){return s}});var i=r(91275);function s(e){return(0,i.i6)`${e} asc`}function n(e){return(0,i.i6)`${e} desc`}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.