1var qf=Object.defineProperty;var $f=(s,e,t)=>e in s?qf(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var g=(s,e,t)=>$f(s,typeof e!="symbol"?e+"":e,t);import{f$ as Qf,v as Mr}from"./server-AyD8BRBj.js";var kf=(s,e,t)=>{const r=s.req.raw.headers.get("Cookie");return r?Qf(r):{}},gs=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});g(this,"res");g(this,"status");this.res=t==null?void 0:t.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}},Ff=(s,e)=>new Response(s,{headers:{"Content-Type":e}}).formData(),jf=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,Uf=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,zf=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,Vf=(s,e)=>async(t,r)=>{let n={};const i=t.req.header("Content-Type");switch(s){case"json":if(!i||!jf.test(i))break;try{n=await t.req.json()}catch{const a="Malformed JSON in request body";throw new gs(400,{message:a})}break;case"form":{if(!i||!(Uf.test(i)||zf.test(i)))break;let a;if(t.req.bodyCache.formData)a=await t.req.bodyCache.formData;else try{const y=await t.req.arrayBuffer();a=await Ff(y,i),t.req.bodyCache.formData=a}catch(y){let d="Malformed FormData request.";throw d+=y instanceof Error?` ${y.message}`:` ${String(y)}`,new gs(400,{message:d})}const f={};a.forEach((y,d)=>{d.endsWith("[]")?(f[d]??(f[d]=[])).push(y):Array.isArray(f[d])?f[d].push(y):d in f?f[d]=[f[d],y]:f[d]=y}),n=f;break}case"query":n=Object.fromEntries(Object.entries(t.req.queries()).map(([a,f])=>f.length===1?[a,f[0]]:[a,f]));break;case"param":n=t.req.param();break;case"header":n=t.req.header();break;case"cookie":n=kf(t);break}const u=await e(n,t);if(u instanceof Response)return u;t.req.addValidatedData(s,u),await r()},Em=(s,e,t,r)=>Vf(s,async(n,i)=>{let u=n;if(s==="header"&&"_def"in e||s==="header"&&"_zod"in e){const f=Object.keys("in"in e?e.in.shape:e.shape),y=Object.fromEntries(f.map(d=>[d.toLowerCase(),d]));u=Object.fromEntries(Object.entries(n).map(([d,S])=>[y[d]||d,S]))}const a=await e.safeParseAsync(u);return a.success?a.data:i.json(a,400)});const L=Symbol.for("drizzle:entityKind");function Q(s,e){if(!s||typeof s!="object")return!1;if(s instanceof e)return!0;if(!Object.prototype.hasOwnProperty.call(e,L))throw new Error(`Class "${e.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let t=Object.getPrototypeOf(s).constructor;if(t)for(;t;){if(L in t&&t[L]===e[L])return!0;t=Object.getPrototypeOf(t)}return!1}var Bs;Bs=L;class de{constructor(e,t){g(this,"name");g(this,"keyAsName");g(this,"primary");g(this,"notNull");g(this,"default");g(this,"defaultFn");g(this,"onUpdateFn");g(this,"hasDefault");g(this,"isUnique");g(this,"uniqueName");g(this,"uniqueType");g(this,"dataType");g(this,"columnType");g(this,"enumValues");g(this,"generated");g(this,"generatedIdentity");g(this,"config");this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}g(de,Bs,"Column");var Os;Os=L;class fl{constructor(e,t,r){g(this,"config");g(this,"$default",this.$defaultFn);g(this,"$onUpdate",this.$onUpdateFn);this.config={name:e,keyAsName:e==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:r,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){this.config.name===""&&(this.config.name=e)}}g(fl,Os,"ColumnBuilder");const $e=Symbol.for("drizzle:Name");var Rs;Rs=L;class dl{constructor(e,t){g(this,"reference");g(this,"_onUpdate","no action");g(this,"_onDelete","no action");this.reference=()=>{const{name:r,columns:n,foreignColumns:i}=e();return{name:r,columns:n,foreignTable:i[0].table,foreignColumns:i}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete)}onUpdate(e){return this._onUpdate=e===void 0?"no action":e,this}onDelete(e){return this._onDelete=e===void 0?"no action":e,this}build(e){return new pl(e,this)}}g(dl,Rs,"PgForeignKeyBuilder");var Ms;Ms=L;class pl{constructor(e,t){g(this,"reference");g(this,"onUpdate");g(this,"onDelete");this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}getName(){const{name:e,columns:t,foreignColumns:r}=this.reference(),n=t.map(a=>a.name),i=r.map(a=>a.name),u=[this.table[$e],...n,r[0].table[$e],...i];return e??`${u.join("_")}_fk`}}g(pl,Ms,"PgForeignKey");function Wf(s,...e){return s(...e)}function ml(s){return new wl(s)}function gl(s,e){return`${s[$e]}_${e.join("_")}_unique`}var Ds;Ds=L;class yl{constructor(e,t){g(this,"columns");g(this,"nullsNotDistinctConfig",!1);this.name=t,this.columns=e}nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(e){return new bl(e,this.columns,this.nullsNotDistinctConfig,this.name)}}g(yl,Ds,"PgUniqueConstraintBuilder");var qs;qs=L;class wl{constructor(e){g(this,"name");this.name=e}on(...e){return new yl(e,this.name)}}g(wl,qs,"PgUniqueOnConstraintBuilder");var $s;$s=L;class bl{constructor(e,t,r,n){g(this,"columns");g(this,"name");g(this,"nullsNotDistinct",!1);this.table=e,this.columns=t,this.name=n??gl(this.table,this.columns.map(i=>i.name)),this.nullsNotDistinct=r}getName(){return this.name}}g(bl,$s,"PgUniqueConstraint");function ys(s,e,t){for(let r=e;r<s.length;r++){const n=s[r];if(n==="\\"){r++;continue}if(n==='"')return[s.slice(e,r).replace(/\\/g,""),r+1];if(!t&&(n===","||n==="}"))return[s.slice(e,r).replace(/\\/g,""),r]}return[s.slice(e).replace(/\\/g,""),s.length]}function vl(s,e=0){const t=[];let r=e,n=!1;for(;r<s.length;){const i=s[r];if(i===","){(n||r===e)&&t.push(""),n=!0,r++;continue}if(n=!1,i==="\\"){r+=2;continue}if(i==='"'){const[f,y]=ys(s,r+1,!0);t.push(f),r=y;continue}if(i==="}")return[t,r+1];if(i==="{"){const[f,y]=vl(s,r+1);t.push(f),r=y;continue}const[u,a]=ys(s,r,!1);t.push(u),r=a}return[t,r]}function Kf(s){const[e]=vl(s,1);return e}function Sl(s){return`{${s.map(e=>Array.isArray(e)?Sl(e):typeof e=="string"?`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`${e}`).join(",")}}`}var Qs,ks;class re extends(ks=fl,Qs=L,ks){constructor(){super(...arguments);g(this,"foreignKeyConfigs",[])}array(t){return new Tl(this.config.name,this,t)}references(t,r={}){return this.foreignKeyConfigs.push({ref:t,actions:r}),this}unique(t,r){return this.config.isUnique=!0,this.config.uniqueName=t,this.config.uniqueType=r==null?void 0:r.nulls,this}generatedAlwaysAs(t){return this.config.generated={as:t,type:"always",mode:"stored"},this}buildForeignKeys(t,r){return this.foreignKeyConfigs.map(({ref:n,actions:i})=>Wf((u,a)=>{const f=new dl(()=>{const y=u();return{columns:[t],foreignColumns:[y]}});return a.onUpdate&&f.onUpdate(a.onUpdate),a.onDelete&&f.onDelete(a.onDelete),f.build(r)},n,i))}buildExtraConfigColumn(t){return new El(t,this.config)}}g(re,Qs,"PgColumnBuilder");var Fs,js;class J extends(js=de,Fs=L,js){constructor(e,t){t.uniqueName||(t.uniqueName=gl(e,[t.name])),super(e,t),this.table=e}}g(J,Fs,"PgColumn");var Us,zs;class El extends(zs=J,Us=L,zs){constructor(){super(...arguments);g(this,"indexConfig",{order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass});g(this,"defaultConfig",{order:"asc",nulls:"last",opClass:void 0})}
1getSQLType(){return this.getSQLType()}asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(t){return this.indexConfig.opClass=t,this}}g(El,Us,"ExtraConfigColumn");var Vs;Vs=L;class Lt{constructor(e,t,r,n){g(this,"name");g(this,"keyAsName");g(this,"type");g(this,"indexConfig");this.name=e,this.keyAsName=t,this.type=r,this.indexConfig=n}}g(Lt,Vs,"IndexedColumn");var Ws,Ks;class Tl extends(Ks=re,Ws=L,Ks){constructor(e,t,r){super(e,"array","PgArray"),this.config.baseBuilder=t,this.config.size=r}build(e){const t=this.config.baseBuilder.build(e);return new wr(e,this.config,t)}}g(Tl,Ws,"PgArrayBuilder");var Hs,Js;const jt=class jt extends(Js=J,Hs=L,Js){constructor(t,r,n,i){super(t,r);g(this,"size");this.baseColumn=n,this.range=i,this.size=r.size}getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size=="number"?this.size:""}]`}mapFromDriverValue(t){return typeof t=="string"&&(t=Kf(t)),t.map(r=>this.baseColumn.mapFromDriverValue(r))}mapToDriverValue(t,r=!1){const n=t.map(i=>i===null?null:Q(this.baseColumn,jt)?this.baseColumn.mapToDriverValue(i,!0):this.baseColumn.mapToDriverValue(i));return r?n:Sl(n)}};g(jt,Hs,"PgArray");let wr=jt;var Gs,Ys;class _l extends(Ys=re,Gs=L,Ys){constructor(e,t){super(e,"string","PgEnumObjectColumn"),this.config.enum=t}build(e){return new Cl(e,this.config)}}g(_l,Gs,"PgEnumObjectColumnBuilder");var Zs,Xs;class Cl extends(Xs=J,Zs=L,Xs){constructor(t,r){super(t,r);g(this,"enum");g(this,"enumValues",this.config.enum.enumValues);this.enum=r.enum}getSQLType(){return this.enum.enumName}}g(Cl,Zs,"PgEnumObjectColumn");const Rt=Symbol.for("drizzle:isPgEnum");function Hf(s){return!!s&&typeof s=="function"&&Rt in s&&s[Rt]===!0}var en,tn;class Pl extends(tn=re,en=L,tn){constructor(e,t){super(e,"string","PgEnumColumn"),this.config.enum=t}build(e){return new Al(e,this.config)}}g(Pl,en,"PgEnumColumnBuilder");var rn,sn;class Al extends(sn=J,rn=L,sn){constructor(t,r){super(t,r);g(this,"enum",this.config.enum);g(this,"enumValues",this.config.enum.enumValues);this.enum=r.enum}getSQLType(){return this.enum.enumName}}g(Al,rn,"PgEnumColumn");function Wt(s,e){return Array.isArray(e)?xl(s,[...e],void 0):Nl(s,e,void 0)}function xl(s,e,t){const r=Object.assign(n=>new Pl(n??"",r),{enumName:s,enumValues:e,schema:t,[Rt]:!0});return r}function Nl(s,e,t){const r=Object.assign(n=>new _l(n??"",r),{enumName:s,enumValues:Object.values(e),schema:t,[Rt]:!0});return r}var nn;nn=L;class ve{constructor(e,t,r,n=!1,i=[]){this._={brand:"Subquery",sql:e,selectedFields:t,alias:r,isWith:n,usedTables:i}}}g(ve,nn,"Subquery");var on,an;class Dr extends(an=ve,on=L,an){}g(Dr,on,"WithSubquery");const Pe={startActiveSpan(s,e){return e()}},pe=Symbol.for("drizzle:ViewBaseConfig"),et=Symbol.for("drizzle:Schema"),br=Symbol.for("drizzle:Columns"),ws=Symbol.for("drizzle:ExtraConfigColumns"),fr=Symbol.for("drizzle:OriginalName"),dr=Symbol.for("drizzle:BaseName"),Mt=Symbol.for("drizzle:IsAlias"),bs=Symbol.for("drizzle:ExtraConfigBuilder"),Jf=Symbol.for("drizzle:IsDrizzleTable");var un,ln,cn,hn,fn,dn,pn,mn,gn,yn;yn=L,gn=$e,mn=fr,pn=et,dn=br,fn=ws,hn=dr,cn=Mt,ln=Jf,un=bs;class j{constructor(e,t,r){g(this,gn);g(this,mn);g(this,pn);g(this,dn);g(this,fn);g(this,hn);g(this,cn,!1);g(this,ln,!0);g(this,un);this[$e]=this[fr]=e,this[et]=t,this[dr]=r}}g(j,yn,"Table"),g(j,"Symbol",{Name:$e,Schema:et,OriginalName:fr,Columns:br,ExtraConfigColumns:ws,BaseName:dr,IsAlias:Mt,ExtraConfigBuilder:bs});function Re(s){return s[$e]}function pt(s){return`${s[et]??"public"}.${s[$e]}`}function Il(s){return s!=null&&typeof s.getSQL=="function"}function Gf(s){var t;const e={sql:"",params:[]};for(const r of s)e.sql+=r.sql,e.params.push(...r.params),(t=r.typings)!=null&&t.length&&(e.typings||(e.typings=[]),e.typings.push(...r.typings));return e}var wn;wn=L;class ge{constructor(e){g(this,"value");this.value=Array.isArray(e)?e:[e]}getSQL(){return new W([this])}}g(ge,wn,"StringChunk");var bn;bn=L;
1const Ue=class Ue{constructor(e){g(this,"decoder",Ll);g(this,"shouldInlineParams",!1);g(this,"usedTables",[]);this.queryChunks=e;for(const t of e)if(Q(t,j)){const r=t[j.Symbol.Schema];this.usedTables.push(r===void 0?t[j.Symbol.Name]:r+"."+t[j.Symbol.Name])}}append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return Pe.startActiveSpan("drizzle.buildSQL",t=>{const r=this.buildQueryFromSourceParams(this.queryChunks,e);return t==null||t.setAttributes({"drizzle.query.text":r.sql,"drizzle.query.params":JSON.stringify(r.params)}),r})}buildQueryFromSourceParams(e,t){const r=Object.assign({},t,{inlineParams:t.inlineParams||this.shouldInlineParams,paramStartIndex:t.paramStartIndex||{value:0}}),{casing:n,escapeName:i,escapeParam:u,prepareTyping:a,inlineParams:f,paramStartIndex:y}=r;return Gf(e.map(d=>{var S;if(Q(d,ge))return{sql:d.value.join(""),params:[]};if(Q(d,Dt))return{sql:i(d.value),params:[]};if(d===void 0)return{sql:"",params:[]};if(Array.isArray(d)){const w=[new ge("(")];for(const[v,c]of d.entries())w.push(c),v<d.length-1&&w.push(new ge(", "));return w.push(new ge(")")),this.buildQueryFromSourceParams(w,r)}if(Q(d,Ue))return this.buildQueryFromSourceParams(d.queryChunks,{...r,inlineParams:f||d.shouldInlineParams});if(Q(d,j)){const w=d[j.Symbol.Schema],v=d[j.Symbol.Name];return{sql:w===void 0||d[Mt]?i(v):i(w)+"."+i(v),params:[]}}if(Q(d,de)){const w=n.getColumnCasing(d);if(t.invokeSource==="indexes")return{sql:i(w),params:[]};const v=d.table[j.Symbol.Schema];return{sql:d.table[Mt]||v===void 0?i(d.table[j.Symbol.Name])+"."+i(w):i(v)+"."+i(d.table[j.Symbol.Name])+"."+i(w),params:[]}}if(Q(d,Qe)){const w=d[pe].schema,v=d[pe].name;return{sql:w===void 0||d[pe].isAlias?i(v):i(w)+"."+i(v),params:[]}}if(Q(d,Me)){if(Q(d.value,Ve))return{sql:u(y.value++,d),params:[d],typings:["none"]};const w=d.value===null?null:d.encoder.mapToDriverValue(d.value);if(Q(w,Ue))return this.buildQueryFromSourceParams([w],r);if(f)return{sql:this.mapInlineParam(w,r),params:[]};let v=["none"];return a&&(v=[a(d.encoder)]),{sql:u(y.value++,w),params:[w],typings:v}}return Q(d,Ve)?{sql:u(y.value++,d),params:[d],typings:["none"]}:Q(d,Ue.Aliased)&&d.fieldAlias!==void 0?{sql:i(d.fieldAlias),params:[]}:Q(d,ve)?d._.isWith?{sql:i(d._.alias),params:[]}:this.buildQueryFromSourceParams([new ge("("),d._.sql,new ge(") "),new Dt(d._.alias)],r):Hf(d)?d.schema?{sql:i(d.schema)+"."+i(d.enumName),params:[]}:{sql:i(d.enumName),params:[]}:Il(d)?(S=d.shouldOmitSQLParens)!=null&&S.call(d)?this.buildQueryFromSourceParams([d.getSQL()],r):this.buildQueryFromSourceParams([new ge("("),d.getSQL(),new ge(")")],r):f?{sql:this.mapInlineParam(d,r),params:[]}:{sql:u(y.value++,d),params:[d],typings:["none"]}}))}mapInlineParam(e,{escapeString:t}){if(e===null)return"null";if(typeof e=="number"||typeof e=="boolean")return e.toString();if(typeof e=="string")return t(e);if(typeof e=="object"){const r=e.toString();return t(r==="[object Object]"?JSON.stringify(e):r)}throw new Error("Unexpected param value: "+e)}getSQL(){return this}as(e){return e===void 0?this:new Ue.Aliased(this,e)}mapWith(e){return this.decoder=typeof e=="function"?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}};g(Ue,bn,"SQL");let W=Ue;var vn;vn=L;class Dt{constructor(e){g(this,"brand");this.value=e}getSQL(){return new W([this])}}g(Dt,vn,"Name");function Yf(s){return typeof s=="object"&&s!==null&&"mapToDriverValue"in s&&typeof s.mapToDriverValue=="function"}const Ll={mapFromDriverValue:s=>s},Bl={mapToDriverValue:s=>s};({...Ll,...Bl});var Sn;Sn=L;class Me{constructor(e,t=Bl){g(this,"brand");this.value=e,this.encoder=t}getSQL(){return new W([this])}}g(Me,Sn,"Param");function x(s,...e){const t=[];(e.length>0||s.length>0&&s[0]!=="")&&t.push(new ge(s[0]));for(const[r,n]of e.entries())t.push(n,new ge(s[r+1]));return new W(t)}(s=>{function e(){return new W([])}s.empty=e;function t(f){return new W(f)}s.fromList=t;function r(f){return new W([new ge(f)])}s.raw=r;function n(f,y){const d=[];for(const[S,w]of f.entries())S>0&&y!==void 0&&d.push(y),d.push(w);return new W(d)}s.join=n;function i(f){return new Dt(f)}s.identifier=i;function u(f){return new Ve(f)}s.placeholder=u;function a(f,y){return new Me(f,y)}s.param=a})(x||(x={}));(s=>{var t;t=L;
1const r=class r{constructor(i,u){g(this,"isSelectionField",!1);this.sql=i,this.fieldAlias=u}getSQL(){return this.sql}clone(){return new r(this.sql,this.fieldAlias)}};g(r,t,"SQL.Aliased");let e=r;s.Aliased=e})(W||(W={}));var En;En=L;class Ve{constructor(e){this.name=e}getSQL(){return new W([this])}}g(Ve,En,"Placeholder");function pr(s,e){return s.map(t=>{if(Q(t,Ve)){if(!(t.name in e))throw new Error(`No value for placeholder "${t.name}" was provided`);return e[t.name]}if(Q(t,Me)&&Q(t.value,Ve)){if(!(t.value.name in e))throw new Error(`No value for placeholder "${t.value.name}" was provided`);return t.encoder.mapToDriverValue(e[t.value.name])}return t})}const Zf=Symbol.for("drizzle:IsDrizzleView");var Tn,_n,Cn;Cn=L,_n=pe,Tn=Zf;class Qe{constructor({name:e,schema:t,selectedFields:r,query:n}){g(this,_n);g(this,Tn,!0);this[pe]={name:e,originalName:e,schema:t,selectedFields:r,query:n,isExisting:!n,isAlias:!1}}getSQL(){return new W([this])}}g(Qe,Cn,"View");de.prototype.getSQL=function(){return new W([this])};j.prototype.getSQL=function(){return new W([this])};ve.prototype.getSQL=function(){return new W([this])};var Pn;Pn=L;class mt{constructor(e){this.table=e}get(e,t){return t==="table"?this.table:e[t]}}g(mt,Pn,"ColumnAliasProxyHandler");var An;An=L;class Kt{constructor(e,t){this.alias=e,this.replaceOriginalName=t}get(e,t){if(t===j.Symbol.IsAlias)return!0;if(t===j.Symbol.Name)return this.alias;if(this.replaceOriginalName&&t===j.Symbol.OriginalName)return this.alias;if(t===pe)return{...e[pe],name:this.alias,isAlias:!0};if(t===j.Symbol.Columns){const n=e[j.Symbol.Columns];if(!n)return n;const i={};return Object.keys(n).map(u=>{i[u]=new Proxy(n[u],new mt(new Proxy(e,this)))}),i}const r=e[t];return Q(r,de)?new Proxy(r,new mt(new Proxy(e,this))):r}}g(Kt,An,"TableAliasProxyHandler");function mr(s,e){return new Proxy(s,new Kt(e,!1))}function Oe(s,e){return new Proxy(s,new mt(new Proxy(s.table,new Kt(e,!1))))}function Ol(s,e){return new W.Aliased(qt(s.sql,e),s.fieldAlias)}function qt(s,e){return x.join(s.queryChunks.map(t=>Q(t,de)?Oe(t,e):Q(t,W)?qt(t,e):Q(t,W.Aliased)?Ol(t,e):t))}var xn,Nn;class Rl extends(Nn=Error,xn=L,Nn){constructor({message:e,cause:t}){super(e),this.name="DrizzleError",this.cause=t}}g(Rl,xn,"DrizzleError");class qe extends Error{constructor(e,t,r){super(`Failed query: ${e} 2params: ${t}`),this.query=e,this.params=t,this.cause=r,Error.captureStackTrace(this,qe),r&&(this.cause=r)}}var In;In=L;class Ml{write(e){console.log(e)}}g(Ml,In,"ConsoleLogWriter");var Ln;Ln=L;class Dl{constructor(e){g(this,"writer");this.writer=(e==null?void 0:e.writer)??new Ml}logQuery(e,t){const r=t.map(i=>{try{return JSON.stringify(i)}catch{return String(i)}}),n=r.length?` -- params: [${r.join(", ")}]`:"";this.writer.write(`Query: ${e}${n}`)}}g(Dl,Ln,"DefaultLogger");var Bn;Bn=L;class ql{logQuery(){}}g(ql,Bn,"NoopLogger");var On,Rn;Rn=L,On=Symbol.toStringTag;class ke{constructor(){g(this,On,"QueryPromise")}catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e==null||e(),t),t=>{throw e==null||e(),t})}then(e,t){return this.execute().then(e,t)}}g(ke,Rn,"QueryPromise");function Xf(s,e,t){const r={},n=s.reduce((i,{path:u,field:a},f)=>{let y;Q(a,de)?y=a:Q(a,W)?y=a.decoder:y=a.sql.decoder;let d=i;for(const[S,w]of u.entries())if(S<u.length-1)w in d||(d[w]={}),d=d[w];else{const v=e[f],c=d[w]=v===null?null:y.mapFromDriverValue(v);if(t&&Q(a,de)&&u.length===2){const h=u[0];h in r?typeof r[h]=="string"&&r[h]!==Re(a.table)&&(r[h]=!1):r[h]=c===null?Re(a.table):!1}}return i},{});if(t&&Object.keys(r).length>0)for(const[i,u]of Object.entries(r))typeof u=="string"&&!t[u]&&(n[i]=null);return n}function We(s,e){return Object.entries(s).reduce((t,[r,n])=>{if(typeof r!="string")return t;const i=e?[...e,r]:[r];return Q(n,de)||Q(n,W)||Q(n,W.Aliased)?t.push({path:i,field:n}):Q(n,j)?t.push(...We(n[j.Symbol.Columns],i)):t.push(...We(n,i)),t},[])}function qr(s,e){const t=Object.keys(s),r=Object.keys(e);if(t.length!==r.length)return!1;for(const[n,i]of t.entries())if(i!==r[n])return!1;return!0}function $l(s,e){const t=Object.entries(e).filter(([,r])=>r!==void 0).map(([r,n])=>Q(n,W)||Q(n,de)?[r,n]:[r,new Me(n,s[j.Symbol.Columns][r])]);if(t.length===0)throw new Error("No values to set");return Object.fromEntries(t)}function ed(s,e){for(const t of e)for(const r of Object.getOwnPropertyNames(t.prototype))r!=="constructor"&&Ob
2ject.defineProperty(s.prototype,r,Object.getOwnPropertyDescriptor(t.prototype,r)||Object.create(null))}function $r(s){return s[j.Symbol.Columns]}function je(s){return Q(s,ve)?s._.alias:Q(s,Qe)?s[pe].name:Q(s,W)?void 0:s[j.Symbol.IsAlias]?s[j.Symbol.Name]:s[j.Symbol.BaseName]}function we(s,e){return{name:typeof s=="string"&&s.length>0?s:"",config:typeof s=="object"?s:e}}function td(s){if(typeof s!="object"||s===null||s.constructor.name!=="Object")return!1;if("logger"in s){const e=typeof s.logger;return!(e!=="boolean"&&(e!=="object"||typeof s.logger.logQuery!="function")&&e!=="undefined")}if("schema"in s){const e=typeof s.schema;return!(e!=="object"&&e!=="undefined")}if("casing"in s){const e=typeof s.casing;return!(e!=="string"&&e!=="undefined")}if("mode"in s)return!(s.mode!=="default"||s.mode!=="planetscale"||s.mode!==void 0);if("connection"in s){const e=typeof s.connection;return!(e!=="string"&&e!=="object"&&e!=="undefined")}if("client"in s){const e=typeof s.client;return!(e!=="object"&&e!=="function"&&e!=="undefined")}return Object.keys(s).length===0}typeof TextDecoder>"u"||new TextDecoder;var Mn,Dn;class yt extends(Dn=re,Mn=L,Dn){generatedAlwaysAsIdentity(e){if(e){const{name:t,...r}=e;this.config.generatedIdentity={type:"always",sequenceName:t,sequenceOptions:r}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity(e){if(e){const{name:t,...r}=e;this.config.generatedIdentity={type:"byDefault",sequenceName:t,sequenceOptions:r}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}}g(yt,Mn,"PgIntColumnBaseBuilder");var qn,$n;class Ql extends($n=yt,qn=L,$n){constructor(e){super(e,"number","PgBigInt53")}build(e){return new kl(e,this.config)}}g(Ql,qn,"PgBigInt53Builder");var Qn,kn;class kl extends(kn=J,Qn=L,kn){getSQLType(){return"bigint"}mapFromDriverValue(e){return typeof e=="number"?e:Number(e)}}g(kl,Qn,"PgBigInt53");var Fn,jn;class Fl extends(jn=yt,Fn=L,jn){constructor(e){super(e,"bigint","PgBigInt64")}build(e){return new jl(e,this.config)}}g(Fl,Fn,"PgBigInt64Builder");var Un,zn;class jl extends(zn=J,Un=L,zn){getSQLType(){return"bigint"}mapFromDriverValue(e){return BigInt(e)}}g(jl,Un,"PgBigInt64");function Ht(s,e){const{name:t,config:r}=we(s,e);return r.mode==="number"?new Ql(t):new Fl(t)}var Vn,Wn;class Ul extends(Wn=re,Vn=L,Wn){constructor(e){super(e,"number","PgBigSerial53"),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new zl(e,this.config)}}g(Ul,Vn,"PgBigSerial53Builder");var Kn,Hn;class zl extends(Hn=J,Kn=L,Hn){getSQLType(){return"bigserial"}mapFromDriverValue(e){return typeof e=="number"?e:Number(e)}}g(zl,Kn,"PgBigSerial53");var Jn,Gn;class Vl extends(Gn=re,Jn=L,Gn){constructor(e){super(e,"bigint","PgBigSerial64"),this.config.hasDefault=!0}build(e){return new Wl(e,this.config)}}
2g(Vl,Jn,"PgBigSerial64Builder");var Yn,Zn;class Wl extends(Zn=J,Yn=L,Zn){getSQLType(){return"bigserial"}mapFromDriverValue(e){return BigInt(e)}}g(Wl,Yn,"PgBigSerial64");function rd(s,e){const{name:t,config:r}=we(s,e);return r.mode==="number"?new Ul(t):new Vl(t)}var Xn,ei;class Kl extends(ei=re,Xn=L,ei){constructor(e){super(e,"boolean","PgBoolean")}build(e){return new Hl(e,this.config)}}g(Kl,Xn,"PgBooleanBuilder");var ti,ri;class Hl extends(ri=J,ti=L,ri){getSQLType(){return"boolean"}}g(Hl,ti,"PgBoolean");function Qr(s){return new Kl(s??"")}var si,ni;class Jl extends(ni=re,si=L,ni){constructor(e,t){super(e,"string","PgChar"),this.config.length=t.length,this.config.enumValues=t.enum}build(e){return new Gl(e,this.config)}}g(Jl,si,"PgCharBuilder");var ii,oi;class Gl extends(oi=J,ii=L,oi){constructor(){super(...arguments);g(this,"length",this.config.length);g(this,"enumValues",this.config.enumValues)}getSQLType(){return this.length===void 0?"char":`char(${this.length})`}}g(Gl,ii,"PgChar");function sd(s,e={}){const{name:t,config:r}=we(s,e);return new Jl(t,r)}var ai,ui;class Yl extends(ui=re,ai=L,ui){constructor(e){super(e,"string","PgCidr")}build(e){return new Zl(e,this.config)}}g(Yl,ai,"PgCidrBuilder");var li,ci;class Zl extends(ci=J,li=L,ci){getSQLType(){return"cidr"}}g(Zl,li,"PgCidr");function nd(s){return new Yl(s??"")}var hi,fi;class Xl extends(fi=re,hi=L,fi){constructor(e,t,r){super(e,"custom","PgCustomColumn"),this.config.fieldConfig=t,this.config.customTypeParams=r}build(e){return new ec(e,this.config)}}g(Xl,hi,"PgCustomColumnBuilder");var di,pi;class ec extends(pi=J,di=L,pi){constructor(t,r){super(t,r);g(this,"sqlName");g(this,"mapTo");g(this,"mapFrom");this.sqlName=r.customTypeParams.dataType(r.fieldConfig),this.mapTo=r.customTypeParams.toDriver,this.mapFrom=r.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(t){return typeof this.mapFrom=="function"?this.mapFrom(t):t}mapToDriverValue(t){return typeof this.mapTo=="function"?this.mapTo(t):t}}g(ec,di,"PgCustomColumn");function tc(s){return(e,t)=>{const{name:r,config:n}=we(e,t);return new Xl(r,n,s)}}var mi,gi;class tt extends(gi=re,mi=L,gi){defaultNow(){return this.default(x`now()`)}}g(tt,mi,"PgDateColumnBaseBuilder");var yi,wi;class rc extends(wi=tt,yi=L,wi){constructor(e){super(e,"date","PgDate")}build(e){return new kr(e,this.config)}}g(rc,yi,"PgDateBuilder");var bi,vi;class kr extends(vi=J,bi=L,vi){getSQLType(){return"date"}mapFromDriverValue(e){return new Date(e)}mapToDriverValue(e){return e.toISOString()}}g(kr,bi,"PgDate");var Si,Ei;class sc extends(Ei=tt,Si=L,Ei){constructor(e){super(e,"string","PgDateString")}build(e){return new Fr(e,this.config)}}g(sc,Si,"PgDateStringBuilder");var Ti,_i;class Fr extends(_i=J,Ti=L,_i){getSQLType(){return"date"}}g(Fr,Ti,"PgDateString");function Jt(s,e){const{name:t,config:r}=we(s,e);return(r==null?void 0:r.mode)==="date"?new rc(t):new sc(t)}var Ci,Pi;
2class nc extends(Pi=re,Ci=L,Pi){constructor(e){super(e,"number","PgDoublePrecision")}build(e){return new ic(e,this.config)}}g(nc,Ci,"PgDoublePrecisionBuilder");var Ai,xi;class ic extends(xi=J,Ai=L,xi){getSQLType(){return"double precision"}mapFromDriverValue(e){return typeof e=="string"?Number.parseFloat(e):e}}g(ic,Ai,"PgDoublePrecision");function id(s){return new nc(s??"")}var Ni,Ii;class oc extends(Ii=re,Ni=L,Ii){constructor(e){super(e,"string","PgInet")}build(e){return new ac(e,this.config)}}g(oc,Ni,"PgInetBuilder");var Li,Bi;class ac extends(Bi=J,Li=L,Bi){getSQLType(){return"inet"}}g(ac,Li,"PgInet");function od(s){return new oc(s??"")}var Oi,Ri;class uc extends(Ri=yt,Oi=L,Ri){constructor(e){super(e,"number","PgInteger")}build(e){return new lc(e,this.config)}}g(uc,Oi,"PgIntegerBuilder");var Mi,Di;class lc extends(Di=J,Mi=L,Di){getSQLType(){return"integer"}mapFromDriverValue(e){return typeof e=="string"?Number.parseInt(e):e}}g(lc,Mi,"PgInteger");function le(s){return new uc(s??"")}var qi,$i;class cc extends($i=re,qi=L,$i){constructor(e,t){super(e,"string","PgInterval"),this.config.intervalConfig=t}build(e){return new hc(e,this.config)}}g(cc,qi,"PgIntervalBuilder");var Qi,ki;class hc extends(ki=J,Qi=L,ki){constructor(){super(...arguments);g(this,"fields",this.config.intervalConfig.fields);g(this,"precision",this.config.intervalConfig.precision)}getSQLType(){const t=this.fields?` ${this.fields}`:"",r=this.precision?`(${this.precision})`:"";return`interval${t}${r}`}}g(hc,Qi,"PgInterval");function ad(s,e={}){const{name:t,config:r}=we(s,e);return new cc(t,r)}var Fi,ji;class fc extends(ji=re,Fi=L,ji){constructor(e){super(e,"json","PgJson")}build(e){return new jr(e,this.config)}}g(fc,Fi,"PgJsonBuilder");var Ui,zi;class jr extends(zi=J,Ui=L,zi){constructor(e,t){super(e,t)}getSQLType(){return"json"}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}}g(jr,Ui,"PgJson");function ud(s){return new fc(s??"")}var Vi,Wi;class dc extends(Wi=re,Vi=L,Wi){constructor(e){super(e,"json","PgJsonb")}build(e){return new Ur(e,this.config)}}g(dc,Vi,"PgJsonbBuilder");var Ki,Hi;class Ur extends(Hi=J,Ki=L,Hi){constructor(e,t){super(e,t)}getSQLType(){return"jsonb"}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}}g(Ur,Ki,"PgJsonb");function pc(s){return new dc(s??"")}var Ji,Gi;class mc extends(Gi=re,Ji=L,Gi){constructor(e){super(e,"array","PgLine")}build(e){return new gc(e,this.config)}}g(mc,Ji,"PgLineBuilder");var Yi,Zi;class gc extends(Zi=J,Yi=L,Zi){getSQLType(){return"line"}mapFromDriverValue(e){const[t,r,n]=e.slice(1,-1).split(",");return[Number.parseFloat(t),Number.parseFloat(r),Number.parseFloat(n)]}mapToDriverValue(e){return`{${e[0]},${e[1]},${e[2]}}`}}g(gc,Yi,"PgLine");var Xi,eo;class yc extends(eo=re,Xi=L,eo){constructor(e){super(e,"json","PgLineABC")}build(e){return new wc(e,this.config)}}g(yc,Xi,"PgLineABCBuilder");var to,ro;class wc extends(ro=J,to=L,ro){getSQLType(){return"line"}mapFromDriverValue(e){const[t,r,n]=e.slice(1,-1).split(",");return{a:Number.parseFloat(t),b:Number.parseFloat(r),c:Number.parseFloat(n)}}mapToDriverValue(e){return`{${e.a},${e.b},${e.c}}`}}g(wc,to,"PgLineABC");function ld(s,e){const{name:t,config:r}=we(s,e);return!(r!=null&&r.mode)||r.mode==="tuple"?new mc(t):new yc(t)}var so,no;class bc extends(no=re,so=L,no){constructor(e){super(e,"string","PgMacaddr")}build(e){return new vc(e,this.config)}}g(bc,so,"PgMacaddrBuilder");var io,oo;class vc extends(oo=J,io=L,oo){getSQLType(){return"macaddr"}}g(vc,io,"PgMacaddr");function cd(s){return new bc(s??"")}var ao,uo;class Sc extends(uo=re,ao=L,uo){constructor(e){super(e,"string","PgMacaddr8")}build(e){return new Ec(e,this.config)}}g(Sc,ao,"PgMacaddr8Builder");var lo,co;class Ec extends(co=J,lo=L,co){getSQLType(){return"macaddr8"}}g(Ec,lo,"PgMacaddr8");function hd(s){return new Sc(s??"")}var ho,fo;class Tc extends(fo=re,ho=L,fo){constructor(e,t,r){super(e,"string","PgNumeric"),this.config.precision=t,this.config.scale=r}build(e){return new zr(e,this.config)}}g(Tc,ho,"PgNumericBuilder");var po,mo;class zr extends(mo=J,po=L,mo){constructor(t,r){super(t,r);g(this,"precision");g(this,"scale");this.precision=r.precision,this.scale=r.scale}mapFromDriverValue(t){return typeof t=="string"?t:String(t)}getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}}g(zr,po,"PgNumeric");var go,yo;class _c extends(yo=re,go=L,yo){constructor(e,t,r){super(e,"number","PgNumericNumber"),this.config.precision=t,this.config.scale=r}build(e){return new Cc(e,this.config)}}g(_c,go,"PgNumericNumberBuilder");var wo,bo;class Cc extends(bo=J,wo=L,bo){constructor(t,r){super(t,r);g(this,"precision");g(this,"scale");g(this,"mapToDriverValue",String);this.precision=r.precision,this.scale=r.scale}mapFromDriverValue(t){return typeof t=="number"?t:Number(t)}getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}}g(Cc,wo,"PgNumericNumber");var vo,So;class Pc extends(So=re,vo=L,So){constructor(e,t,r){super(e,"bigint","PgNumericBigInt"),this.config.precision=t,this.config.scale=r}build(e){return new Ac(e,this.config)}}g(Pc,vo,"PgNumericBigIntBuilder");var Eo,To;class Ac extends(To=J,Eo=L,To){constructor(t,r){super(t,r);g(this,"precision");g(this,"scale");g(this,"mapFromDriverValue",BigInt);g(this,"mapToDriverValue",String);this.precision=r.precision,this.scale=r.scale}getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}}g(Ac,Eo,"PgNumericBigInt");function fd(s,e){const{name:t,config:r}=we(s,e),n=r==null?void 0:r.mode;return n==="number"?new _c(t,r==null?void 0:r.precision,r==null?void 0:r.scale):n==="bigint"?new Pc(t,r==null?void 0:r.precision,r==null?void 0:r.scale):new Tc(t,r==null?void 0:r.precision,r==null?void 0:r.scale)}var _o,Co;class xc extends(Co=re,_o=L,Co){constructor(e){super(e,"array","PgPointTuple")}build(e){return new Nc(e,this.config)}}g(xc,_o,"PgPointTupleBuilder");var Po,Ao;class Nc extends(Ao=J,Po=L,Ao){getSQLType(){return"point"}mapFromDriverValue(e){if(typeof e=="string"){const[t,r]=e.slice(1,-1).split(",");return[Number.parseFloat(t),Number.parseFloat(r)]}return[e.x,e.y]}mapToDriverValue(e){return`(${e[0]},${e[1]})`}}g(Nc,Po,"PgPointTuple");var xo,No;class Ic extends(No=re,xo=L,No){constructor(e){super(e,"json","PgPointObject")}build(e){return new Lc(e,this.config)}}g(Ic,xo,"PgPointObjectBuilder");var Io,Lo;class Lc extends(Lo=J,Io=L,Lo){getSQLType(){return"point"}mapFromDriverValue(e){if(typeof e=="string"){const[t,r]=e.slice(1,-1).split(",");return{x:Number.parseFloat(t),y:Number.parseFloat(r)}}return e}mapToDriverValue(e){return`(${e.x},${e.y})`}}
2g(Lc,Io,"PgPointObject");function dd(s,e){const{name:t,config:r}=we(s,e);return!(r!=null&&r.mode)||r.mode==="tuple"?new xc(t):new Ic(t)}function pd(s){const e=[];for(let t=0;t<s.length;t+=2)e.push(Number.parseInt(s.slice(t,t+2),16));return new Uint8Array(e)}function vs(s,e){const t=new ArrayBuffer(8),r=new DataView(t);for(let n=0;n<8;n++)r.setUint8(n,s[e+n]);return r.getFloat64(0,!0)}function Bc(s){const e=pd(s);let t=0;const r=e[t];t+=1;const n=new DataView(e.buffer),i=n.getUint32(t,r===1);if(t+=4,i&536870912&&(n.getUint32(t,r===1),t+=4),(i&65535)===1){const u=vs(e,t);t+=8;const a=vs(e,t);return t+=8,[u,a]}throw new Error("Unsupported geometry type")}var Bo,Oo;class Oc extends(Oo=re,Bo=L,Oo){constructor(e){super(e,"array","PgGeometry")}build(e){return new Rc(e,this.config)}}g(Oc,Bo,"PgGeometryBuilder");var Ro,Mo;class Rc extends(Mo=J,Ro=L,Mo){getSQLType(){return"geometry(point)"}mapFromDriverValue(e){return Bc(e)}mapToDriverValue(e){return`point(${e[0]} ${e[1]})`}}g(Rc,Ro,"PgGeometry");var Do,qo;class Mc extends(qo=re,Do=L,qo){constructor(e){super(e,"json","PgGeometryObject")}build(e){return new Dc(e,this.config)}}g(Mc,Do,"PgGeometryObjectBuilder");var $o,Qo;class Dc extends(Qo=J,$o=L,Qo){getSQLType(){return"geometry(point)"}mapFromDriverValue(e){const t=Bc(e);return{x:t[0],y:t[1]}}mapToDriverValue(e){return`point(${e.x} ${e.y})`}}g(Dc,$o,"PgGeometryObject");function md(s,e){const{name:t,config:r}=we(s,e);return!(r!=null&&r.mode)||r.mode==="tuple"?new Oc(t):new Mc(t)}var ko,Fo;class qc extends(Fo=re,ko=L,Fo){constructor(e,t){super(e,"number","PgReal"),this.config.length=t}build(e){return new $c(e,this.config)}}g(qc,ko,"PgRealBuilder");var jo,Uo;class $c extends(Uo=J,jo=L,Uo){constructor(t,r){super(t,r);g(this,"mapFromDriverValue",t=>typeof t=="string"?Number.parseFloat(t):t)}getSQLType(){return"real"}}g($c,jo,"PgReal");function vr(s){return new qc(s??"")}var zo,Vo;class Qc extends(Vo=re,zo=L,Vo){constructor(e){super(e,"number","PgSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new kc(e,this.config)}}g(Qc,zo,"PgSerialBuilder");var Wo,Ko;class kc extends(Ko=J,Wo=L,Ko){getSQLType(){return"serial"}}g(kc,Wo,"PgSerial");function gd(s){return new Qc(s??"")}var Ho,Jo;class Fc extends(Jo=yt,Ho=L,Jo){constructor(e){super(e,"number","PgSmallInt")}build(e){return new jc(e,this.config)}}g(Fc,Ho,"PgSmallIntBuilder");var Go,Yo;class jc extends(Yo=J,Go=L,Yo){constructor(){super(...arguments);g(this,"mapFromDriverValue",t=>typeof t=="string"?Number(t):t)}getSQLType(){return"smallint"}}g(jc,Go,"PgSmallInt");function yd(s){return new Fc(s??"")}var Zo,Xo;class Uc extends(Xo=re,Zo=L,Xo){constructor(e){super(e,"number","PgSmallSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new zc(e,this.config)}}g(Uc,Zo,"PgSmallSerialBuilder");var ea,ta;class zc extends(ta=J,ea=L,ta){getSQLType(){return"smallserial"}}g(zc,ea,"PgSmallSerial");function wd(s){return new Uc(s??"")}var ra,sa;class Vc extends(sa=re,ra=L,sa){constructor(e,t){super(e,"string","PgText"),this.config.enumValues=t.enum}build(e){return new Wc(e,this.config)}}g(Vc,ra,"PgTextBuilder");var na,ia;class Wc extends(ia=J,na=L,ia){constructor(){super(...arguments);g(this,"enumValues",this.config.enumValues)}getSQLType(){return"text"}}g(Wc,na,"PgText");function ne(s,e={}){const{name:t,config:r}=we(s,e);return new Vc(t,r)}var oa,aa;class Kc extends(aa=tt,oa=L,aa){constructor(e,t,r){super(e,"string","PgTime"),this.withTimezone=t,this.precision=r,this.config.withTimezone=t,this.config.precision=r}build(e){return new Vr(e,this.config)}}g(Kc,oa,"PgTimeBuilder");var ua,la;class Vr extends(la=J,ua=L,la){constructor(t,r){super(t,r);g(this,"withTimezone");g(this,"precision");this.withTimezone=r.withTimezone,this.precision=r.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}g(Vr,ua,"PgTime");function bd(s,e={}){const{name:t,config:r}=we(s,e);return new Kc(t,r.withTimezone??!1,r.precision)}var ca,ha;class Hc extends(ha=tt,ca=L,ha){constructor(e,t,r){super(e,"date","PgTimestamp"),this.config.withTimezone=t,this.config.precision=r}build(e){return new Wr(e,this.config)}}g(Hc,ca,"PgTimestampBuilder");var fa,da;class Wr extends(da=J,fa=L,da){constructor(t,r){super(t,r);g(this,"withTimezone");g(this,"precision");g(this,"mapFromDriverValue",t=>new Date(this.withTimezone?t:t+"+0000"));g(this,"mapToDriverValue",t=>t.toISOString());this.withTimezone=r.withTimezone,this.precision=r.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}
2${this.withTimezone?" with time zone":""}`}}g(Wr,fa,"PgTimestamp");var pa,ma;class Jc extends(ma=tt,pa=L,ma){constructor(e,t,r){super(e,"string","PgTimestampString"),this.config.withTimezone=t,this.config.precision=r}build(e){return new Kr(e,this.config)}}g(Jc,pa,"PgTimestampStringBuilder");var ga,ya;class Kr extends(ya=J,ga=L,ya){constructor(t,r){super(t,r);g(this,"withTimezone");g(this,"precision");this.withTimezone=r.withTimezone,this.precision=r.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}g(Kr,ga,"PgTimestampString");function De(s,e={}){const{name:t,config:r}=we(s,e);return(r==null?void 0:r.mode)==="string"?new Jc(t,r.withTimezone??!1,r.precision):new Hc(t,(r==null?void 0:r.withTimezone)??!1,r==null?void 0:r.precision)}var wa,ba;class Gc extends(ba=re,wa=L,ba){constructor(e){super(e,"string","PgUUID")}defaultRandom(){return this.default(x`gen_random_uuid()`)}build(e){return new Hr(e,this.config)}}g(Gc,wa,"PgUUIDBuilder");var va,Sa;class Hr extends(Sa=J,va=L,Sa){getSQLType(){return"uuid"}}g(Hr,va,"PgUUID");function Ie(s){return new Gc(s??"")}var Ea,Ta;class Yc extends(Ta=re,Ea=L,Ta){constructor(e,t){super(e,"string","PgVarchar"),this.config.length=t.length,this.config.enumValues=t.enum}build(e){return new Zc(e,this.config)}}g(Yc,Ea,"PgVarcharBuilder");var _a,Ca;class Zc extends(Ca=J,_a=L,Ca){constructor(){super(...arguments);g(this,"length",this.config.length);g(this,"enumValues",this.config.enumValues)}getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}}g(Zc,_a,"PgVarchar");function vd(s,e={}){const{name:t,config:r}=we(s,e);return new Yc(t,r)}var Pa,Aa;class Xc extends(Aa=re,Pa=L,Aa){constructor(e,t){super(e,"string","PgBinaryVector"),this.config.dimensions=t.dimensions}build(e){return new eh(e,this.config)}}g(Xc,Pa,"PgBinaryVectorBuilder");var xa,Na;class eh extends(Na=J,xa=L,Na){constructor(){super(...arguments);g(this,"dimensions",this.config.dimensions)}getSQLType(){return`bit(${this.dimensions})`}}g(eh,xa,"PgBinaryVector");function Sd(s,e){const{name:t,config:r}=we(s,e);return new Xc(t,r)}var Ia,La;class th extends(La=re,Ia=L,La){constructor(e,t){super(e,"array","PgHalfVector"),this.config.dimensions=t.dimensions}build(e){return new rh(e,this.config)}}g(th,Ia,"PgHalfVectorBuilder");var Ba,Oa;class rh extends(Oa=J,Ba=L,Oa){constructor(){super(...arguments);g(this,"dimensions",this.config.dimensions)}getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){return t.slice(1,-1).split(",").map(r=>Number.parseFloat(r))}}g(rh,Ba,"PgHalfVector");function Ed(s,e){const{name:t,config:r}=we(s,e);return new th(t,r)}var Ra,Ma;class sh extends(Ma=re,Ra=L,Ma){constructor(e,t){super(e,"string","PgSparseVector"),this.config.dimensions=t.dimensions}build(e){return new nh(e,this.config)}}g(sh,Ra,"PgSparseVectorBuilder");var Da,qa;class nh extends(qa=J,Da=L,qa){constructor(){super(...arguments);g(this,"dimensions",this.config.dimensions)}getSQLType(){return`sparsevec(${this.dimensions})`}}g(nh,Da,"PgSparseVector");function Td(s,e){const{name:t,config:r}=we(s,e);return new sh(t,r)}var $a,Qa;class ih extends(Qa=re,$a=L,Qa){constructor(e,t){super(e,"array","PgVector"),this.config.dimensions=t.dimensions}build(e){return new oh(e,this.config)}}g(ih,$a,"PgVectorBuilder");var ka,Fa;class oh extends(Fa=J,ka=L,Fa){constructor(){super(...arguments);g(this,"dimensions",this.config.dimensions)}getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){return t.slice(1,-1).split(",").map(r=>Number.parseFloat(r))}}g(oh,ka,"PgVector");function _d(s,e){const{name:t,config:r}=we(s,e);return new ih(t,r)}function Cd(){return{bigint:Ht,bigserial:rd,boolean:Qr,char:sd,cidr:nd,customType:tc,date:Jt,doublePrecision:id,inet:od,integer:le,interval:ad,json:ud,jsonb:pc,line:ld,macaddr:cd,macaddr8:hd,numeric:fd,point:dd,geometry:md,real:vr,serial:gd,smallint:yd,smallserial:wd,text:ne,time:bd,timestamp:De,uuid:Ie,varchar:vd,bit:Sd,halfvec:Ed,sparsevec:Td,vector:_d}}const Sr=Symbol.for("drizzle:PgInlineForeignKeys"),Ss=Symbol.for("drizzle:EnableRLS");var ja,Ua,za,Va,Wa,Ka;class be extends(Ka=j,Wa=L,Va=Sr,za=Ss,Ua=j.Symbol.ExtraConfigBuilder,ja=j.Symbol.ExtraConfigColumns,Ka){constructor(){super(...arguments);g(this,Va,[]);g(this,za,!1);
2g(this,Ua);g(this,ja,{})}}g(be,Wa,"PgTable"),g(be,"Symbol",Object.assign({},j.Symbol,{InlineForeignKeys:Sr,EnableRLS:Ss}));function ah(s,e,t,r,n=s){const i=new be(s,r,n),u=typeof e=="function"?e(Cd()):e,a=Object.fromEntries(Object.entries(u).map(([d,S])=>{const w=S;w.setName(d);const v=w.build(i);return i[Sr].push(...w.buildForeignKeys(v,i)),[d,v]})),f=Object.fromEntries(Object.entries(u).map(([d,S])=>{const w=S;w.setName(d);const v=w.buildExtraConfigColumn(i);return[d,v]})),y=Object.assign(i,a);return y[j.Symbol.Columns]=a,y[j.Symbol.ExtraConfigColumns]=f,t&&(y[be.Symbol.ExtraConfigBuilder]=t),Object.assign(y,{enableRLS:()=>(y[be.Symbol.EnableRLS]=!0,y)})}const rt=(s,e,t)=>ah(s,e,t,void 0);var Ha;Ha=L;class uh{constructor(e,t){g(this,"columns");g(this,"name");this.columns=e,this.name=t}build(e){return new lh(e,this.columns,this.name)}}g(uh,Ha,"PgPrimaryKeyBuilder");var Ja;Ja=L;class lh{constructor(e,t,r){g(this,"columns");g(this,"name");this.table=e,this.columns=t,this.name=r}getName(){return this.name??`${this.table[be.Symbol.Name]}_${this.columns.map(e=>e.name).join("_")}_pk`}}g(lh,Ja,"PgPrimaryKey");function Se(s,e){return Yf(e)&&!Il(s)&&!Q(s,Me)&&!Q(s,Ve)&&!Q(s,de)&&!Q(s,j)&&!Q(s,Qe)?new Me(s,e):s}const ch=(s,e)=>x`${s} = ${Se(e,s)}`,Pd=(s,e)=>x`${s} <> ${Se(e,s)}`;function Er(...s){const e=s.filter(t=>t!==void 0);if(e.length!==0)return e.length===1?new W(e):new W([new ge("("),x.join(e,new ge(" and ")),new ge(")")])}function Ad(...s){const e=s.filter(t=>t!==void 0);if(e.length!==0)return e.length===1?new W(e):new W([new ge("("),x.join(e,new ge(" or ")),new ge(")")])}function xd(s){return x`not ${s}`}const Nd=(s,e)=>x`${s} > ${Se(e,s)}`,Id=(s,e)=>x`${s} >= ${Se(e,s)}`,Ld=(s,e)=>x`${s} < ${Se(e,s)}`,Bd=(s,e)=>x`${s} <= ${Se(e,s)}`;function Od(s,e){return Array.isArray(e)?e.length===0?x`false`:x`${s} in ${e.map(t=>Se(t,s))}`:x`${s} in ${Se(e,s)}`}function Rd(s,e){return Array.isArray(e)?e.length===0?x`true`:x`${s} not in ${e.map(t=>Se(t,s))}`:x`${s} not in ${Se(e,s)}`}function Md(s){return x`${s} is null`}function Dd(s){return x`${s} is not null`}function qd(s){return x`exists ${s}`}function $d(s){return x`not exists ${s}`}function Qd(s,e,t){return x`${s} between ${Se(e,s)} and ${Se(t,s)}`}function kd(s,e,t){return x`${s} not between ${Se(e,s)} and ${Se(t,s)}`}function Fd(s,e){return x`${s} like ${e}`}function jd(s,e){return x`${s} not like ${e}`}function Ud(s,e){return x`${s} ilike ${e}`}function zd(s,e){return x`${s} not ilike ${e}`}function Vd(s){return x`${s} asc`}function Wd(s){return x`${s} desc`}var Ga;Ga=L;class Jr{constructor(e,t,r){g(this,"referencedTableName");g(this,"fieldName");this.sourceTable=e,this.referencedTable=t,this.relationName=r,this.referencedTableName=t[j.Symbol.Name]}}g(Jr,Ga,"Relation");var Ya;Ya=L;class hh{constructor(e,t){this.table=e,this.config=t}}g(hh,Ya,"Relations");var Za,Xa;const Ut=class Ut extends(Xa=Jr,Za=L,Xa){constructor(e,t,r,n){super(e,t,r==null?void 0:r.relationName),this.config=r,this.isNullable=n}withFieldName(e){const t=new Ut(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}};g(Ut,Za,"One");let Ke=Ut;var eu,tu;const zt=class zt extends(tu=Jr,eu=L,tu){constructor(e,t,r){super(e,t,r==null?void 0:r.relationName),this.config=r}withFieldName(e){const t=new zt(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}};g(zt,eu,"Many");let $t=zt;function Kd(){return{and:Er,between:Qd,eq:ch,exists:qd,gt:Nd,gte:Id,ilike:Ud,inArray:Od,isNull:Md,isNotNull:Dd,like:Fd,lt:Ld,lte:Bd,ne:Pd,not:xd,notBetween:kd,notExists:$d,notLike:jd,notIlike:zd,notInArray:Rd,or:Ad,sql:x}}function Hd(){return{sql:x,asc:Vd,desc:Wd}}function Jd(s,e){var i;Object.keys(s).length===1&&"default"in s&&!Q(s.default,j)&&(s=s.default);const t={},r={},n={};for(const[u,a]of Object.entries(s))if(Q(a,j)){const f=pt(a),y=r[f];t[f]=u,n[u]={tsName:u,dbName:a[j.Symbol.Name],schema:a[j.Symbol.Schema],columns:a[j.Symbol.Columns],relations:(y==null?void 0:y.relations)??{},primaryKey:(y==null?void 0:y.primaryKey)??[]};for(const S of Object.values(a[j.Symbol.Columns]))S.primary&&n[u].primaryKey.push(S);const d=(i=a[j.Symbol.ExtraConfigBuilder])==null?void 0:i.call(a,a[j.Symbol.ExtraConfigColumns]);if(d)for(const S of Object.values(d))Q(S,uh)&&n[u].primaryKey.push(...S.columns)}else if(Q(a,hh)){const f=pt(a.table),y=t[f],d=a.config(e(a.table));let S;for(const[w,v]of Object.entries(d))if(y){const c=n[y];c.relations[w]=v}else f in r||(r[f]={relations:{},primaryKey:S}),r[f].relations[w]=v}return{tables:n,tableNamesMap:t}}function Gd(s){return function(t,r){return new Ke(s,t,r,(r==null?void 0:r.fields.reduce((n,i)=>n&&i.notNull,!0))??!1)}}function Yd(s){return function(t,r){return new $t(s,t,r)}}function Zd(s,e,t){if(Q(t,Ke)&&t.config)return{fields:t.config.fields,references:t.config.references};const r=e[pt(t.referencedTable)];if(!r)throw new Error(`Table "${t.referencedTable[j.Symbol.Name]}" not found in schema`);const n=s[r];if(!n)throw new Error(`Table "${r}" not found in schema`);const i=t.sourceTable,u=e[pt(i)];if(!u)throw new Error(`Table "${i[j.Symbol.Name]}" not found in schema`);const a=[];for(const f of Object.values(n.relations))(t.relationName&&t!==f&&f.relationName===t.relationName||!t.relationName&&f.referencedTable===t.sourceTable)&&a.push(f);if(a.length>1)throw t.relationName?new Error(`There are multiple relations with
2name "${t.relationName}" in table "${r}"`):new Error(`There are multiple relations between "${r}" and "${t.sourceTable[j.Symbol.Name]}". Please specify relation name`);if(a[0]&&Q(a[0],Ke)&&a[0].config)return{fields:a[0].config.references,references:a[0].config.fields};throw new Error(`There is not enough information to infer relation "${u}.${t.fieldName}"`)}function Xd(s){return{one:Gd(s),many:Yd(s)}}function Tr(s,e,t,r,n=i=>i){const i={};for(const[u,a]of r.entries())if(a.isJson){const f=e.relations[a.tsKey],y=t[u],d=typeof y=="string"?JSON.parse(y):y;i[a.tsKey]=Q(f,Ke)?d&&Tr(s,s[a.relationTableTsKey],d,a.selection,n):d.map(S=>Tr(s,s[a.relationTableTsKey],S,a.selection,n))}else{const f=n(t[u]),y=a.field;let d;Q(y,de)?d=y:Q(y,W)?d=y.decoder:d=y.sql.decoder,i[a.tsKey]=f===null?null:d.mapFromDriverValue(f)}return i}var ru;ru=L;const Vt=class Vt{constructor(e){g(this,"config");this.config={...e}}get(e,t){if(t==="_")return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===pe)return{...e[pe],selectedFields:new Proxy(e[pe].selectedFields,this)};if(typeof t=="symbol")return e[t];const n=(Q(e,ve)?e._.selectedFields:Q(e,Qe)?e[pe].selectedFields:e)[t];if(Q(n,W.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!n.isSelectionField)return n.sql;
2const i=n.clone();return i.isSelectionField=!0,i}if(Q(n,W)){if(this.config.sqlBehavior==="sql")return n;throw new 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('alias')" method.`)}return Q(n,de)?this.config.alias?new Proxy(n,new mt(new Proxy(n.table,new Kt(this.config.alias,this.config.replaceOriginalName??!1)))):n:typeof n!="object"||n===null?n:new Proxy(n,new Vt(this.config))}};g(Vt,ru,"SelectionProxyHandler");let ce=Vt;var su;su=L;class fh{constructor(e,t){this.unique=e,this.name=t}on(...e){return new Bt(e.map(t=>{if(Q(t,W))return t;t=t;const r=new Lt(t.name,!!t.keyAsName,t.columnType,t.indexConfig);return t.indexConfig=JSON.parse(JSON.stringify(t.defaultConfig)),r}),this.unique,!1,this.name)}onOnly(...e){return new Bt(e.map(t=>{if(Q(t,W))return t;t=t;const r=new Lt(t.name,!!t.keyAsName,t.columnType,t.indexConfig);return t.indexConfig=t.defaultConfig,r}),this.unique,!0,this.name)}using(e,...t){return new Bt(t.map(r=>{if(Q(r,W))return r;r=r;const n=new Lt(r.name,!!r.keyAsName,r.columnType,r.indexConfig);return r.indexConfig=JSON.parse(JSON.stringify(r.defaultConfig)),n}),this.unique,!0,this.name,e)}}g(fh,su,"PgIndexBuilderOn");var nu;nu=L;class Bt{constructor(e,t,r,n,i="btree"){g(this,"config");this.config={name:n,columns:e,unique:t,only:r,method:i}}concurrently(){return this.config.concurrently=!0,this}with(e){return this.config.with=e,this}where(e){return this.config.where=e,this}build(e){return new dh(this.config,e)}}g(Bt,nu,"PgIndexBuilder");var iu;iu=L;class dh{constructor(e,t){g(this,"config");this.config={...e,table:t}}}g(dh,iu,"PgIndex");function Es(s){return new fh(!1,s)}const Ts=Symbol.for("drizzle:PgViewConfig");function ep(s){return(s.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(t=>t.toLowerCase()).join("_")}function tp(s){return(s.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((t,r,n)=>{const i=n===0?r.toLowerCase():`${r[0].toUpperCase()}${r.slice(1)}`;return t+i},"")}function rp(s){return s}var ou;ou=L;class ph{constructor(e){g(this,"cache",{});g(this,"cachedTables",{});g(this,"convert");this.convert=e==="snake_case"?ep:e==="camelCase"?tp:rp}getColumnCasing(e){if(!e.keyAsName)return e.name;const t=e.table[j.Symbol.Schema]??"public",r=e.table[j.Symbol.OriginalName],n=`${t}.${r}.${e.name}`;return this.cache[n]||this.cacheTable(e.table),this.cache[n]}cacheTable(e){const t=e[j.Symbol.Schema]??"public",r=e[j.Symbol.OriginalName],n=`${t}.${r}`;if(!this.cachedTables[n]){for(const i of Object.values(e[j.Symbol.Columns])){const u=`${n}.${i.name}`;this.cache[u]=this.convert(i.name)}this.cachedTables[n]=!0}}clearCache(){this.cache={},this.cachedTables={}}}g(ph,ou,"CasingCache");var au,uu;class wt extends(uu=Qe,au=L,uu){}g(wt,au,"PgViewBase");var lu;lu=L;class ct{constructor(e){g(this,"casing");this.casing=new ph(e==null?void 0:e.casing)}async migrate(e,t,r){const n=typeof r=="string"?"__drizzle_migrations":r.migrationsTable??"__drizzle_migrations",i=typeof r=="string"?"drizzle":r.migrationsSchema??"drizzle",u=x` 3 CREATE TABLE IF NOT EXISTS ${x.identifier(i)}.${x.identifier(n)} ( 4 id SERIAL PRIMARY KEY, 5 hash text NOT NULL, 6 created_at bigint 7 ) 8 `;await t.execute(x`CREATE SCHEMA IF NOT EXISTS ${x.identifier(i)}`),await t.execute(u);const f=(await t.all(x`select id, hash, created_at from ${x.identifier(i)}.${x.identifier(n)} order by created_at desc limit 1`))[0];await t.transaction(async y=>{for await(const d of e)if(!f||Number(f.created_at)<d.folderMillis){for(const S of d.sql)await y.execute(x.raw(S));await y.execute(x`insert into ${x.identifier(i)}.${x.identifier(n)} ("hash", "created_at") values(${d.hash}, ${d.folderMillis})`)}})}escapeName(e){return`"${e}"`}escapeParam(e){return`$${e+1}`}escapeString(e){return`'${e.replace(/'/g,"''")}'`}buildWithCTE(e){if(!(e!=null&&e.length))return;const t=[x`with `];for(const[r,n]of e.entries())t.push(x`${x.identifier(n._.alias)} as (${n._.sql})`),r<e.length-1&&t.push(x`, `);return t.push(x` `),x.join(t)}buildDeleteQuery({table:e,where:t,returning:r,withList:n}){const i=this.buildWithCTE(n),u=r?x` returning ${this.buildSelection(r,{isSingleTable:!0})}`:void 0,a=t?x` where ${t}`:void 0;return x`${i}delete from ${e}${a}${u}`}buildUpdateSet(e,t){const r=e[j.Symbol.Columns],n=Object.keys(r).filter(u=>{var a;
8return t[u]!==void 0||((a=r[u])==null?void 0:a.onUpdateFn)!==void 0}),i=n.length;return x.join(n.flatMap((u,a)=>{const f=r[u],y=t[u]??x.param(f.onUpdateFn(),f),d=x`${x.identifier(this.casing.getColumnCasing(f))} = ${y}`;return a<i-1?[d,x.raw(", ")]:[d]}))}buildUpdateQuery({table:e,set:t,where:r,returning:n,withList:i,from:u,joins:a}){const f=this.buildWithCTE(i),y=e[be.Symbol.Name],d=e[be.Symbol.Schema],S=e[be.Symbol.OriginalName],w=y===S?void 0:y,v=x`${d?x`${x.identifier(d)}.`:void 0}${x.identifier(S)}${w&&x` ${x.identifier(w)}`}`,c=this.buildUpdateSet(e,t),h=u&&x.join([x.raw(" from "),this.buildFromTable(u)]),b=this.buildJoins(a),E=n?x` returning ${this.buildSelection(n,{isSingleTable:!u})}`:void 0,C=r?x` where ${r}`:void 0;return x`${f}update ${v} set ${c}${h}${b}${C}${E}`}buildSelection(e,{isSingleTable:t=!1}={}){const r=e.length,n=e.flatMap(({field:i},u)=>{const a=[];if(Q(i,W.Aliased)&&i.isSelectionField)a.push(x.identifier(i.fieldAlias));else if(Q(i,W.Aliased)||Q(i,W)){const f=Q(i,W.Aliased)?i.sql:i;t?a.push(new W(f.queryChunks.map(y=>Q(y,J)?x.identifier(this.casing.getColumnCasing(y)):y))):a.push(f),Q(i,W.Aliased)&&a.push(x` as ${x.identifier(i.fieldAlias)}`)}else Q(i,de)&&(t?a.push(x.identifier(this.casing.getColumnCasing(i))):a.push(i));return u<r-1&&a.push(x`, `),a});return x.join(n)}buildJoins(e){if(!e||e.length===0)return;const t=[];for(const[r,n]of e.entries()){r===0&&t.push(x` `);const i=n.table,u=n.lateral?x` lateral`:void 0,a=n.on?x` on ${n.on}`:void 0;if(Q(i,be)){const f=i[be.Symbol.Name],y=i[be.Symbol.Schema],d=i[be.Symbol.OriginalName],S=f===d?void 0:n.alias;t.push(x`${x.raw(n.joinType)} join${u} ${y?x`${x.identifier(y)}.`:void 0}${x.identifier(d)}${S&&x` ${x.identifier(S)}`}${a}`)}else if(Q(i,Qe)){const f=i[pe].name,y=i[pe].schema,d=i[pe].originalName,S=f===d?void 0:n.alias;t.push(x`${x.raw(n.joinType)} join${u} ${y?x`${x.identifier(y)}.`:void 0}${x.identifier(d)}${S&&x` ${x.identifier(S)}`}${a}`)}else t.push(x`${x.raw(n.joinType)} join${u} ${i}${a}`);r<e.length-1&&t.push(x` `)}return x.join(t)}buildFromTable(e){if(Q(e,j)&&e[j.Symbol.IsAlias]){let t=x`${x.identifier(e[j.Symbol.OriginalName])}`;return e[j.Symbol.Schema]&&(t=x`${x.identifier(e[j.Symbol.Schema])}.${t}`),x`${t} ${x.identifier(e[j.Symbol.Name])}`}return e}buildSelectQuery({withList:e,fields:t,fieldsFlat:r,where:n,having:i,table:u,joins:a,orderBy:f,groupBy:y,limit:d,offset:S,lockingClause:w,distinct:v,setOperators:c}){const h=r??We(t);for(const D of h)if(Q(D.field,de)&&Re(D.field.table)!==(Q(u,ve)?u._.alias:Q(u,wt)?u[pe].name:Q(u,W)?void 0:Re(u))&&!(F=>a==null?void 0:a.some(({alias:H})=>H===(F[j.Symbol.IsAlias]?Re(F):F[j.Symbol.BaseName])))(D.field.table)){const F=Re(D.field.table);throw new Error(`Your "${D.path.join("->")}" field references a column "${F}"."${D.field.name}", but the table "${F}" is not part of the query! Did you forget to join it?`)}const b=!a||a.length===0,E=this.buildWithCTE(e);let C;v&&(C=v===!0?x` distinct`:x` distinct on (${x.join(v.on,x`, `)})`);const P=this.buildSelection(h,{isSingleTable:b}),O=this.buildFromTable(u),M=this.buildJoins(a),T=n?x` where ${n}`:void 0,I=i?x` having ${i}`:void 0;let N;f&&f.length>0&&(N=x` order by ${x.join(f,x`, `)}`);let _;y&&y.length>0&&(_=x` group by ${x.join(y,x`, `)}`);const q=typeof d=="object"||typeof d=="number"&&d>=0?x` limit ${d}`:void 0,R=S?x` offset ${S}`:void 0,U=x.empty();if(w){const D=x` for ${x.raw(w.strength)}`;w.config.of&&D.append(x` of ${x.join(Array.isArray(w.config.of)?w.config.of:[w.config.of],x`, `)}`),w.config.noWait?D.append(x` nowait`):w.config.skipLocked&&D.append(x` skip locked`),U.append(D)}const z=x`${E}select${C} ${P} from ${O}${M}${T}${_}${I}${N}${q}${R}${U}`;return c.length>0?this.buildSetOperations(z,c):z}buildSetOperations(e,t){const[r,...n]=t;if(!r)throw new Error("Cannot pass undefined values to any set operator");return n.length===0?this.buildSetOperationQuery({leftSelect:e,setOperator:r}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:r}),n)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:r,rightSelect:n,limit:i,orderBy:u,offset:a}}){const f=x`(${e.getSQL()}) `,y=x`(${n.getSQL()})`;let d;if(u&&u.length>0){const c=[];for(const h of u)if(Q(h,J))c.push(x.identifier(h.name));else if(Q(h,W)){for(let b=0;b<h.queryChunks.length;b++){const E=h.queryChunks[b];Q(E,J)&&(h.queryChunks[b]=x.identifier(E.name))}c.push(x`${h}`)}else c.push(x`${h}`);d=x` order by ${x.join(c,x`, `)} `}const S=typeof i=="object"||typeof i=="number"&&i>=0?x` limit ${i}`:void 0,w=x.raw(`${t} ${r?"all ":""}`),v=a?x` offset ${a}`:void 0;return x`${f}${w}${y}${d}${S}${v}`}buildInsertQuery({table:e,values:t,onConflict:r,returning:n,withList:i,select:u,overridingSystemValue_:a}){const f=[],y=e[j.Symbol.Columns],d=Object.entries(y).filter(([E,C])=>!C.shouldDisableInsert()),S=d.map(([,E])=>x.identifier(this.casing.getColumnCasing(E)));if(u){const E=t;Q(E,W)?f.push(E):f.push(E.getSQL())}else{const E=t;f.push(x.raw("values "));for(const[C,P]of E.entries()){const O=[];for(const[M,T]of d){const I=P[M];if(I===void 0||Q(I,Me)&&I.value===void 0)if(T.defaultFn!==void 0){const N=T.defaultFn(),_=Q(N,W)?N:x.param(N,T);O.push(_)}else if(!T.default&&T.onUpdateFn!==void 0){const N=T.onUpdateFn(),_=Q(N,W)?N:x.param(N,T);O.push(_)}else O.push(x`default`);else O.push(I)}f.push(O),C<E.length-1&&f.push(x`, `)}}const w=this.buildWithCTE(i),v=x.join(f),c=n?x` returning ${this.buildSelection(n,{isSingleTable:!0})}`:void 0,h=r?x` on conflict ${r}`:void 0,b=a===!0?x`overriding system value `:void 0;return x`${w}insert into ${e} ${S} ${b}${v}${h}${c}`}buildRefreshMaterializedViewQuery({view:e,concurrently:t,withNoData:r}){const n=t?x` concurrently`:void 0,i=r?x` with no data`:void 0;return x`refresh materialized view${n} ${e}${i}`}prepareTyping(e){return Q(e,Ur)||Q(e,jr)?"json":Q(e,zr)?"decimal":Q(e,Vr)?"time":Q(e,Wr)||Q(e,Kr)?"timestamp":Q(e,kr)||Q(e,Fr)?"date":Q(e,Hr)?"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:n,tableConfig:i,queryConfig:u,tableAlias:a,nestedQueryRelation:f,joinOn:y}){let d=[],S,w,v=[],c;const h=[];if(u===!0)d=Object.entries(i.columns).map(([C,P])=>({dbKey:P.name,tsKey:C,field:Oe(P,a),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{const E=Object.fromEntries(Object.entries(i.columns).map(([I,N])=>[I,Oe(N,a)]));if(u.where){const I=typeof u.where=="function"?u.where(E,Kd()):u.where;c=I&&qt(I,a)}const C=[];let P=[];if(u.columns){let I=!1;for(const[N,_]of Object.entries(u.columns))_!==void 0&&N in i.columns&&(!I&&_===!0&&(I=!0),P.push(N));P.length>0&&(P=I?P.filter(N=>{var _;return((_=u.columns)==null?void 0:_[N])===!0}):Object.keys(i.columns).filter(N=>!P.includes(N)))}else P=Object.keys(i.columns);for(const I of P){const N=i.columns[I];C.push({tsKey:I,value:N})}let O=[];u.with&&(O=Object.entries(u.with).filter(I=>!!I[1]).map(([I,N])=>
8({tsKey:I,queryConfig:N,relation:i.relations[I]})));let M;if(u.extras){M=typeof u.extras=="function"?u.extras(E,{sql:x}):u.extras;for(const[I,N]of Object.entries(M))C.push({tsKey:I,value:Ol(N,a)})}for(const{tsKey:I,value:N}of C)d.push({dbKey:Q(N,W.Aliased)?N.fieldAlias:i.columns[I].name,tsKey:I,field:Q(N,de)?Oe(N,a):N,relationTableTsKey:void 0,isJson:!1,selection:[]});let T=typeof u.orderBy=="function"?u.orderBy(E,Hd()):u.orderBy??[];Array.isArray(T)||(T=[T]),v=T.map(I=>Q(I,de)?Oe(I,a):qt(I,a)),S=u.limit,w=u.offset;for(const{tsKey:I,queryConfig:N,relation:_}of O){const q=Zd(t,r,_),R=pt(_.referencedTable),U=r[R],z=`${a}_${I}`,D=Er(...q.fields.map((Z,se)=>ch(Oe(q.references[se],z),Oe(Z,a)))),F=this.buildRelationalQueryWithoutPK({fullSchema:e,schema:t,tableNamesMap:r,table:e[U],tableConfig:t[U],queryConfig:Q(_,Ke)?N===!0?{limit:1}:{...N,limit:1}:N,tableAlias:z,joinOn:D,nestedQueryRelation:_}),H=x`${x.identifier(z)}.${x.identifier("data")}`.as(I);h.push({on:x`true`,table:new ve(F.sql,{},z),alias:z,joinType:"left",lateral:!0}),d.push({dbKey:I,tsKey:I,field:H,relationTableTsKey:U,isJson:!0,selection:F.selection})}}if(d.length===0)throw new Rl({message:`No fields selected for table "${i.tsName}" ("${a}")`});let b;if(c=Er(y,c),f){let E=x`json_build_array(${x.join(d.map(({field:O,tsKey:M,isJson:T})=>T?x`${x.identifier(`${a}_${M}`)}.${x.identifier("data")}`:Q(O,W.Aliased)?O.sql:O),x`, `)})`;Q(f,$t)&&(E=x`coalesce(json_agg(${E}${v.length>0?x` order by ${x.join(v,x`, `)}`:void 0}), '[]'::json)`);const C=[{dbKey:"data",tsKey:"data",field:E.as("data"),isJson:!0,relationTableTsKey:i.tsName,selection:d}];S!==void 0||w!==void 0||v.length>0?(b=this.buildSelectQuery({table:mr(n,a),fields:{},fieldsFlat:[{path:[],field:x.raw("*")}],where:c,limit:S,offset:w,orderBy:v,setOperators:[]}),c=void 0,S=void 0,w=void 0,v=[]):b=mr(n,a),b=this.buildSelectQuery({table:Q(b,be)?b:new ve(b,{},a),fields:{},fieldsFlat:C.map(({field:O})=>({path:[],field:Q(O,de)?Oe(O,a):O})),joins:h,where:c,limit:S,offset:w,orderBy:v,setOperators:[]})}else b=this.buildSelectQuery({table:mr(n,a),fields:{},fieldsFlat:d.map(({field:E})=>({path:[],field:Q(E,de)?Oe(E,a):E})),joins:h,where:c,limit:S,offset:w,orderBy:v,setOperators:[]});return{tableTsKey:i.tsName,sql:b,selection:d}}}g(ct,lu,"PgDialect");var cu;cu=L;class mh{getSelectedFields(){return this._.selectedFields}}g(mh,cu,"TypedQueryBuilder");var hu;hu=L;class Ce{constructor(e){g(this,"fields");g(this,"session");g(this,"dialect");g(this,"withList",[]);g(this,"distinct");g(this,"authToken");this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,e.withList&&(this.withList=e.withList),this.distinct=e.distinct}setToken(e){return this.authToken=e,this}from(e){const t=!!this.fields,r=e;let n;return this.fields?n=this.fields:Q(r,ve)?n=Object.fromEntries(Object.keys(r._.selectedFields).map(i=>[i,r[i]])):Q(r,wt)?n=r[pe].selectedFields:Q(r,W)?n={}:n=$r(r),new Gr({table:r,fields:n,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}}g(Ce,hu,"PgSelectBuilder");var fu,du;class gh extends(du=mh,fu=L,du){constructor({table:t,fields:r,isPartialSelect:n,session:i,dialect:u,withList:a,distinct:f}){super();g(this,"_");g(this,"config");g(this,"joinsNotNullableMap");g(this,"tableName");g(this,"isPartialSelect");g(this,"session");g(this,"dialect");g(this,"cacheConfig");g(this,"usedTables",new Set);g(this,"leftJoin",this.createJoin("left",!1));g(this,"leftJoinLateral",this.createJoin("left",!0));g(this,"rightJoin",this.createJoin("right",!1));g(this,"innerJoin",this.createJoin("inner",!1));g(this,"innerJoinLateral",this.createJoin("inner",!0));g(this,"fullJoin",this.createJoin("full",!1));g(this,"crossJoin",this.createJoin("cross",!1));g(this,"crossJoinLateral",this.createJoin("cross",!0));g(this,"union",this.createSetOperator("union",!1));g(this,"unionAll",this.createSetOperator("union",!0));g(this,"intersect",this.createSetOperator("intersect",!1));g(this,"intersectAll",this.createSetOperator("intersect",!0));g(this,"except",this.createSetOperator("except",!1));g(this,"exceptAll",this.createSetOperator("except",!0));this.config={withList:a,table:t,fields:{...r},distinct:f,setOperators:[]},this.isPartialSelect=n,this.session=i,this.dialect=u,this._={selectedFields:r,config:this.config},this.tableName=je(t),this.joinsNotNullableMap=typeof this.tableName=="string"?{[this.tableName]:!0}:{};for(const y of ze(t))this.usedTables.add(y)}getUsedTables(){return[...this.usedTables]}createJoin(t,r){return(n,i)=>{var f;const u=this.tableName,a=je(n);for(const y of ze(n))this.usedTables.add(y);
8if(typeof a=="string"&&((f=this.config.joins)!=null&&f.some(y=>y.alias===a)))throw new Error(`Alias "${a}" is already used in this query`);if(!this.isPartialSelect&&(Object.keys(this.joinsNotNullableMap).length===1&&typeof u=="string"&&(this.config.fields={[u]:this.config.fields}),typeof a=="string"&&!Q(n,W))){const y=Q(n,ve)?n._.selectedFields:Q(n,Qe)?n[pe].selectedFields:n[j.Symbol.Columns];this.config.fields[a]=y}if(typeof i=="function"&&(i=i(new Proxy(this.config.fields,new ce({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:i,table:n,joinType:t,alias:a,lateral:r}),typeof a=="string")switch(t){case"left":{this.joinsNotNullableMap[a]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([y])=>[y,!1])),this.joinsNotNullableMap[a]=!0;break}case"cross":case"inner":{this.joinsNotNullableMap[a]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([y])=>[y,!1])),this.joinsNotNullableMap[a]=!1;break}}return this}}createSetOperator(t,r){return n=>{const i=typeof n=="function"?n(sp()):n;if(!qr(this.getSelectedFields(),i.getSelectedFields()))throw new 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:t,isAll:r,rightSelect:i}),this}}addSetOperators(t){return this.config.setOperators.push(...t),this}where(t){return typeof t=="function"&&(t=t(new Proxy(this.config.fields,new ce({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=t,this}having(t){return typeof t=="function"&&(t=t(new Proxy(this.config.fields,new ce({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.having=t,this}groupBy(...t){if(typeof t[0]=="function"){const r=t[0](new Proxy(this.config.fields,new ce({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(r)?r:[r]}else this.config.groupBy=t;return this}orderBy(...t){if(typeof t[0]=="function"){const r=t[0](new Proxy(this.config.fields,new ce({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),n=Array.isArray(r)?r:[r];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=n:this.config.orderBy=n}else{const r=t;this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=r:this.config.orderBy=r}return this}limit(t){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=t:this.config.limit=t,this}offset(t){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=t:this.config.offset=t,this}for(t,r={}){return this.config.lockingClause={strength:t,config:r},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){const{typings:t,...r}=this.dialect.sqlToQuery(this.getSQL());return r}as(t){const r=[];if(r.push(...ze(this.config.table)),this.config.joins)for(const n of this.config.joins)r.push(...ze(n.table));return new Proxy(new ve(this.getSQL(),this.config.fields,t,!1,[...new Set(r)]),new ce({alias:t,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new ce({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}$withCache(t){return this.cacheConfig=t===void 0?{config:{},enable:!0,autoInvalidate:!0}:t===!1?{enable:!1}:{enable:!0,autoInvalidate:!0,...t},this}}g(gh,fu,"PgSelectQueryBuilder");var pu,mu;class Gr extends(mu=gh,pu=L,mu){constructor(){super(...arguments);g(this,"authToken");g(this,"execute",t=>Pe.startActiveSpan("drizzle.operation",()=>this._prepare().execute(t,this.authToken)))}_prepare(t){const{session:r,config:n,dialect:i,joinsNotNullableMap:u,authToken:a,cacheConfig:f,usedTables:y}=this;if(!r)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");const{fields:d}=n;return Pe.startActiveSpan("drizzle.prepareQuery",()=>{const S=We(d),w=r.prepareQuery(i.sqlToQuery(this.getSQL()),S,t,!0,void 0,{type:"select",tables:[...y]},f);return w.joinsNotNullableMap=u,w.setToken(a)})}prepare(t){return this._prepare(t)}setToken(t){return this.authToken=t,this}}g(Gr,pu,"PgSelect");ed(Gr,[ke]);function st(s,e){return(t,r,...n)=>{const i=[r,...n].map(u=>({type:s,isAll:e,rightSelect:u}));for(const u of i)if(!qr(t.getSelectedFields(),u.rightSelect.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return t.addSetOperators(i)}}const sp=()=>({union:np,unionAll:ip,intersect:op,intersectAll:ap,except:up,exceptAll:lp}),np=st("union",!1),ip=st("union",!0),op=st("intersect",!1),ap=st("intersect",!0),up=st("except",!1),lp=st("except",!0);var gu;gu=L;class bt{constructor(e){g(this,"dialect");g(this,"dialectConfig");g(this,"$with",(e,t)=>{const r=this;return{as:i=>(typeof i=="function"&&(i=i(r)),new Proxy(new Dr(i.getSQL(),t??("getSelectedFields"in i?i.getSelectedFields()??{}:{}),e,!0),new ce({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}});this.dialect=Q(e,ct)?e:void 0,this.dialectConfig=Q(e,ct)?void 0:e}with(...e){const t=this;function r(u){return new Ce({fields:u??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function n(u){return new Ce({fields:u??void 0,session:void 0,dialect:t.getDialect(),distinct:!0})}function i(u,a){return new Ce({fields:a??void 0,session:void 0,dialect:t.getDialect(),distinct:{on:u}})}return{select:r,selectDistinct:n,selectDistinctOn:i}}select(e){return new Ce({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new Ce({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn(e,t){return new Ce({fields:t??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:e}})}getDialect(){return this.dialect||(this.dialect=new ct(this.dialectConfig)),this.dialect}}g(bt,gu,"PgQueryBuilder");var yu;yu=L;class Yr{constructor(e,t){g(this,"config",{});this.name=e,this.schema=t}with(e){return this.config.with=e,this}}
8g(Yr,yu,"PgDefaultViewBuilderCore");var wu,bu;class yh extends(bu=Yr,wu=L,bu){as(e){typeof e=="function"&&(e=e(new bt));const t=new ce({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}),r=new Proxy(e.getSelectedFields(),t);return new Proxy(new Qt({pgConfig:this.config,config:{name:this.name,schema:this.schema,selectedFields:r,query:e.getSQL().inlineParams()}}),t)}}g(yh,wu,"PgViewBuilder");var vu,Su;class wh extends(Su=Yr,vu=L,Su){constructor(t,r,n){super(t,n);g(this,"columns");this.columns=$r(rt(t,r))}existing(){return new Proxy(new Qt({pgConfig:void 0,config:{name:this.name,schema:this.schema,selectedFields:this.columns,query:void 0}}),new ce({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}as(t){return new Proxy(new Qt({pgConfig:this.config,config:{name:this.name,schema:this.schema,selectedFields:this.columns,query:t.inlineParams()}}),new ce({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}}g(wh,vu,"PgManualViewBuilder");var Eu;Eu=L;class Zr{constructor(e,t){g(this,"config",{});this.name=e,this.schema=t}using(e){return this.config.using=e,this}with(e){return this.config.with=e,this}tablespace(e){return this.config.tablespace=e,this}withNoData(){return this.config.withNoData=!0,this}}g(Zr,Eu,"PgMaterializedViewBuilderCore");var Tu,_u;class bh extends(_u=Zr,Tu=L,_u){as(e){typeof e=="function"&&(e=e(new bt));const t=new ce({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}),r=new Proxy(e.getSelectedFields(),t);return new Proxy(new kt({pgConfig:{with:this.config.with,using:this.config.using,tablespace:this.config.tablespace,withNoData:this.config.withNoData},config:{name:this.name,schema:this.schema,selectedFields:r,query:e.getSQL().inlineParams()}}),t)}}g(bh,Tu,"PgMaterializedViewBuilder");var Cu,Pu;class vh extends(Pu=Zr,Cu=L,Pu){constructor(t,r,n){super(t,n);g(this,"columns");this.columns=$r(rt(t,r))}existing(){return new Proxy(new kt({pgConfig:{tablespace:this.config.tablespace,using:this.config.using,with:this.config.with,withNoData:this.config.withNoData},config:{name:this.name,schema:this.schema,selectedFields:this.columns,query:void 0}}),new ce({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}as(t){return new Proxy(new kt({pgConfig:{tablespace:this.config.tablespace,using:this.config.using,with:this.config.with,withNoData:this.config.withNoData},config:{name:this.name,schema:this.schema,selectedFields:this.columns,query:t.inlineParams()}}),new ce({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}}g(vh,Cu,"PgManualMaterializedViewBuilder");var Au,xu,Nu;class Qt extends(Nu=wt,xu=L,Au=Ts,Nu){constructor({pgConfig:t,config:r}){super(r);g(this,Au);t&&(this[Ts]={with:t.with})}}g(Qt,xu,"PgView");const _s=Symbol.for("drizzle:PgMaterializedViewConfig");var Iu,Lu,Bu;class kt extends(Bu=wt,Lu=L,Iu=_s,Bu){constructor({pgConfig:t,config:r}){super(r);g(this,Iu);this[_s]={with:t==null?void 0:t.with,using:t==null?void 0:t.using,tablespace:t==null?void 0:t.tablespace,withNoData:t==null?void 0:t.withNoData}}}g(kt,Lu,"PgMaterializedView");function cp(s,e,t){return e?new wh(s,e,t):new yh(s,t)}function hp(s,e,t){return e?new vh(s,e,t):new bh(s,t)}function ze(s){return Q(s,be)?[s[et]?`${s[et]}.${s[j.Symbol.BaseName]}`:s[j.Symbol.BaseName]]:Q(s,ve)?s._.usedTables??[]:Q(s,W)?s.usedTables??[]:[]}var Ou,Ru;class _r extends(Ru=ke,Ou=L,Ru){constructor(t,r,n,i){super();g(this,"config");g(this,"cacheConfig");g(this,"authToken");g(this,"execute",t=>Pe.startActiveSpan("drizzle.operation",()=>this._prepare().execute(t,this.authToken)));this.session=r,this.dialect=n,this.config={table:t,withList:i}}where(t){return this.config.where=t,this}returning(t=this.config.table[j.Symbol.Columns]){return this.config.returningFields=t,this.config.returning=We(t),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){const{typings:t,...r}=this.dialect.sqlToQuery(this.getSQL());return r}_prepare(t){return Pe.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,t,!0,void 0,{type:"delete",tables:ze(this.config.table)},this.cacheConfig))}prepare(t){return this._prepare(t)}setToken(t){return this.authToken=t,this}getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new ce({alias:Re(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}g(_r,Ou,"PgDelete");var Mu;Mu=L;class Cr{constructor(e,t,r,n,i){g(this,"authToken");this.table=e,this.session=t,this.dialect=r,this.withList=n,this.overridingSystemValue_=i}setToken(e){return this.authToken=e,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values(e){if(e=Array.isArray(e)?e:[e],e.length===0)throw new Error("values() must be called with at least one value");const t=e.map(r=>{const n={},i=this.table[j.Symbol.Columns];for(const u of Object.keys(r)){const a=r[u];n[u]=Q(a,W)?a:new Me(a,i[u])}return n});return new Pr(this.table,t,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select(e){const t=typeof e=="function"?e(new bt):e;if(!Q(t,W)&&!qr(this.table[br],t._.selectedFields))throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new Pr(this.table,t,this.session,this.dialect,this.withList,!0)}}g(Cr,Mu,"PgInsertBuilder");var Du,qu;class Pr extends(qu=ke,Du=L,qu){constructor(t,r,n,i,u,a,f){super();g(this,"config");
8g(this,"cacheConfig");g(this,"authToken");g(this,"execute",t=>Pe.startActiveSpan("drizzle.operation",()=>this._prepare().execute(t,this.authToken)));this.session=n,this.dialect=i,this.config={table:t,values:r,withList:u,select:a,overridingSystemValue_:f}}returning(t=this.config.table[j.Symbol.Columns]){return this.config.returningFields=t,this.config.returning=We(t),this}onConflictDoNothing(t={}){if(t.target===void 0)this.config.onConflict=x`do nothing`;else{let r="";r=Array.isArray(t.target)?t.target.map(i=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(i))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(t.target));const n=t.where?x` where ${t.where}`:void 0;this.config.onConflict=x`(${x.raw(r)})${n} do nothing`}return this}onConflictDoUpdate(t){if(t.where&&(t.targetWhere||t.setWhere))throw new Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');const r=t.where?x` where ${t.where}`:void 0,n=t.targetWhere?x` where ${t.targetWhere}`:void 0,i=t.setWhere?x` where ${t.setWhere}`:void 0,u=this.dialect.buildUpdateSet(this.config.table,$l(this.config.table,t.set));let a="";return a=Array.isArray(t.target)?t.target.map(f=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(f))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(t.target)),this.config.onConflict=x`(${x.raw(a)})${n} do update set ${u}${r}${i}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){const{typings:t,...r}=this.dialect.sqlToQuery(this.getSQL());return r}_prepare(t){return Pe.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,t,!0,void 0,{type:"insert",tables:ze(this.config.table)},this.cacheConfig))}prepare(t){return this._prepare(t)}setToken(t){return this.authToken=t,this}getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new ce({alias:Re(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}g(Pr,Du,"PgInsert");var $u,Qu;class Sh extends(Qu=ke,$u=L,Qu){constructor(t,r,n){super();g(this,"config");g(this,"authToken");g(this,"execute",t=>Pe.startActiveSpan("drizzle.operation",()=>this._prepare().execute(t,this.authToken)));this.session=r,this.dialect=n,this.config={view:t}}concurrently(){if(this.config.withNoData!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.concurrently=!0,this}withNoData(){if(this.config.concurrently!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){const{typings:t,...r}=this.dialect.sqlToQuery(this.getSQL());return r}_prepare(t){return Pe.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,t,!0))}prepare(t){return this._prepare(t)}setToken(t){return this.authToken=t,this}}g(Sh,$u,"PgRefreshMaterializedView");var ku;ku=L;class Ar{constructor(e,t,r,n){g(this,"authToken");this.table=e,this.session=t,this.dialect=r,this.withList=n}setToken(e){return this.authToken=e,this}set(e){return new Eh(this.table,$l(this.table,e),this.session,this.dialect,this.withList).setToken(this.authToken)}}g(Ar,ku,"PgUpdateBuilder");var Fu,ju;class Eh extends(ju=ke,Fu=L,ju){constructor(t,r,n,i,u){super();g(this,"config");g(this,"tableName");g(this,"joinsNotNullableMap");g(this,"cacheConfig");g(this,"leftJoin",this.createJoin("left"));g(this,"rightJoin",this.createJoin("right"));g(this,"innerJoin",this.createJoin("inner"));g(this,"fullJoin",this.createJoin("full"));g(this,"authToken");g(this,"execute",t=>this._prepare().execute(t,this.authToken));this.session=n,this.dialect=i,this.config={set:r,table:t,withList:u,joins:[]},this.tableName=je(t),this.joinsNotNullableMap=typeof this.tableName=="string"?{[this.tableName]:!0}:{}}from(t){const r=t,n=je(r);return typeof n=="string"&&(this.joinsNotNullableMap[n]=!0),this.config.from=r,this}getTableLikeFields(t){return Q(t,be)?t[j.Symbol.Columns]:Q(t,ve)?t._.selectedFields:t[pe].selectedFields}createJoin(t){return(r,n)=>{const i=je(r);if(typeof i=="string"&&this.config.joins.some(u=>u.alias===i))throw new Error(`Alias "${i}" is already used in this query`);
8if(typeof n=="function"){const u=this.config.from&&!Q(this.config.from,W)?this.getTableLikeFields(this.config.from):void 0;n=n(new Proxy(this.config.table[j.Symbol.Columns],new ce({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),u&&new Proxy(u,new ce({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}if(this.config.joins.push({on:n,table:r,joinType:t,alias:i}),typeof i=="string")switch(t){case"left":{this.joinsNotNullableMap[i]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([u])=>[u,!1])),this.joinsNotNullableMap[i]=!0;break}case"inner":{this.joinsNotNullableMap[i]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([u])=>[u,!1])),this.joinsNotNullableMap[i]=!1;break}}return this}}where(t){return this.config.where=t,this}returning(t){if(!t&&(t=Object.assign({},this.config.table[j.Symbol.Columns]),this.config.from)){const r=je(this.config.from);if(typeof r=="string"&&this.config.from&&!Q(this.config.from,W)){const n=this.getTableLikeFields(this.config.from);t[r]=n}for(const n of this.config.joins){const i=je(n.table);if(typeof i=="string"&&!Q(n.table,W)){const u=this.getTableLikeFields(n.table);t[i]=u}}}return this.config.returningFields=t,this.config.returning=We(t),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){const{typings:t,...r}=this.dialect.sqlToQuery(this.getSQL());return r}_prepare(t){const r=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,t,!0,void 0,{type:"insert",tables:ze(this.config.table)},this.cacheConfig);return r.joinsNotNullableMap=this.joinsNotNullableMap,r}prepare(t){return this._prepare(t)}setToken(t){return this.authToken=t,this}getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new ce({alias:Re(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}g(Eh,Fu,"PgUpdate");var Uu,zu,Vu;const dt=class dt extends(Vu=W,zu=L,Uu=Symbol.toStringTag,Vu){constructor(t){super(dt.buildEmbeddedCount(t.source,t.filters).queryChunks);g(this,"sql");g(this,"token");g(this,Uu,"PgCountBuilder");g(this,"session");this.params=t,this.mapWith(Number),this.session=t.session,this.sql=dt.buildCount(t.source,t.filters)}static buildEmbeddedCount(t,r){return x`(select count(*) from ${t}${x.raw(" where ").if(r)}${r})`}static buildCount(t,r){return x`select count(*) as count from ${t}${x.raw(" where ").if(r)}${r};`}setToken(t){return this.token=t,this}then(t,r){return Promise.resolve(this.session.count(this.sql,this.token)).then(t,r)}catch(t){return this.then(void 0,t)}finally(t){return this.then(r=>(t==null||t(),r),r=>{throw t==null||t(),r})}};g(dt,zu,"PgCountBuilder");let xr=dt;var Wu;Wu=L;class Th{constructor(e,t,r,n,i,u,a){this.fullSchema=e,this.schema=t,this.tableNamesMap=r,this.table=n,this.tableConfig=i,this.dialect=u,this.session=a}findMany(e){return new Nr(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},"many")}findFirst(e){return new Nr(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}}g(Th,Wu,"PgRelationalQueryBuilder");var Ku,Hu;class Nr extends(Hu=ke,Ku=L,Hu){constructor(t,r,n,i,u,a,f,y,d){super();g(this,"authToken");this.fullSchema=t,this.schema=r,this.tableNamesMap=n,this.table=i,this.tableConfig=u,this.dialect=a,this.session=f,this.config=y,this.mode=d}_prepare(t){return Pe.startActiveSpan("drizzle.prepareQuery",()=>{const{query:r,builtQuery:n}=this._toSQL();return this.session.prepareQuery(n,void 0,t,!0,(i,u)=>{const a=i.map(f=>Tr(this.schema,this.tableConfig,f,r.selection,u));return this.mode==="first"?a[0]:a})})}prepare(t){return this._prepare(t)}_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(){const t=this._getQuery(),r=this.dialect.sqlToQuery(t.sql);return{query:t,builtQuery:r}}toSQL(){return this._toSQL().builtQuery}setToken(t){return this.authToken=t,this}execute(){return Pe.startActiveSpan("drizzle.operation",()=>this._prepare().execute(void 0,this.authToken))}}g(Nr,Ku,"PgRelationalQuery");var Ju,Gu;class _h extends(Gu=ke,Ju=L,Gu){constructor(e,t,r,n){super(),this.execute=e,this.sql=t,this.query=r,this.mapBatchResult=n}getSQL(){return this.sql}getQuery(){return this.query}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return!1}}g(_h,Ju,"PgRaw");var Yu;Yu=L;class Ch{constructor(e,t,r){g(this,"query");g(this,"$with",(e,t)=>{const r=this;return{as:i=>(typeof i=="function"&&(i=i(new bt(r.dialect))),new Proxy(new Dr(i.getSQL(),t??("getSelectedFields"in i?i.getSelectedFields()??{}:{}),e,!0),new ce({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}});g(this,"$cache");g(this,"authToken");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(const[n,i]of Object.entries(this._.schema))this.query[n]=new Th(r.fullSchema,this._.schema,this._.tableNamesMap,r.fullSchema[n],i,e,t);
8this.$cache={invalidate:async n=>{}}}$count(e,t){return new xr({source:e,filters:t,session:this.session})}with(...e){const t=this;function r(y){return new Ce({fields:y??void 0,session:t.session,dialect:t.dialect,withList:e})}function n(y){return new Ce({fields:y??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})}function i(y,d){return new Ce({fields:d??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:{on:y}})}function u(y){return new Ar(y,t.session,t.dialect,e)}function a(y){return new Cr(y,t.session,t.dialect,e)}function f(y){return new _r(y,t.session,t.dialect,e)}return{select:r,selectDistinct:n,selectDistinctOn:i,update:u,insert:a,delete:f}}select(e){return new Ce({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new Ce({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn(e,t){return new Ce({fields:t??void 0,session:this.session,dialect:this.dialect,distinct:{on:e}})}update(e){return new Ar(e,this.session,this.dialect)}insert(e){return new Cr(e,this.session,this.dialect)}delete(e){return new _r(e,this.session,this.dialect)}refreshMaterializedView(e){return new Sh(e,this.session,this.dialect)}execute(e){const t=typeof e=="string"?x.raw(e):e.getSQL(),r=this.dialect.sqlToQuery(t),n=this.session.prepareQuery(r,void 0,void 0,!1);return new _h(()=>n.execute(void 0,this.authToken),t,r,i=>n.mapResult(i,!0))}transaction(e,t){return this.session.transaction(e,t)}}g(Ch,Yu,"PgDatabase");var Zu;Zu=L;class Ph{constructor(e,t,r){this.seqName=e,this.seqOptions=t,this.schema=r}}g(Ph,Zu,"PgSequence");function fp(s,e,t){return new Ph(s,e,t)}var Xu;Xu=L;class Ah{constructor(e){g(this,"table",(e,t,r)=>ah(e,t,r,this.schemaName));g(this,"view",(e,t)=>cp(e,t,this.schemaName));g(this,"materializedView",(e,t)=>hp(e,t,this.schemaName));g(this,"sequence",(e,t)=>fp(e,t,this.schemaName));this.schemaName=e}enum(e,t){return Array.isArray(t)?xl(e,[...t],this.schemaName):Nl(e,t,this.schemaName)}getSQL(){return new W([x.identifier(this.schemaName)])}shouldOmitSQLParens(){return!0}}g(Ah,Xu,"PgSchema");function dp(s){return new Ah(s)}var el;el=L;class xh{}g(xh,el,"Cache");var tl,rl;class Xr extends(rl=xh,tl=L,rl){strategy(){return"all"}async get(e){}async put(e,t,r,n){}async onMutate(e){}}g(Xr,tl,"NoopCache");async function Cs(s,e){const t=`${s}-${JSON.stringify(e)}`,n=new TextEncoder().encode(t),i=await crypto.subtle.digest("SHA-256",n);return[...new Uint8Array(i)].map(f=>f.toString(16).padStart(2,"0")).join("")}var sl;sl=L;class Nh{constructor(e,t,r,n){g(this,"authToken");g(this,"joinsNotNullableMap");var i;this.query=e,this.cache=t,this.queryMetadata=r,this.cacheConfig=n,t&&t.strategy()==="all"&&n===void 0&&(this.cacheConfig={enable:!0,autoInvalidate:!0}),(i=this.cacheConfig)!=null&&i.enable||(this.cacheConfig=void 0)}getQuery(){return this.query}mapResult(e,t){return e}setToken(e){return this.authToken=e,this}async queryWithCache(e,t,r){if(this.cache===void 0||Q(this.cache,Xr)||this.queryMetadata===void 0)try{return await r()}catch(n){throw new qe(e,t,n)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await r()}catch(n){throw new qe(e,t,n)}if((this.queryMetadata.type==="insert"||this.queryMetadata.type==="update"||this.queryMetadata.type==="delete")&&this.queryMetadata.tables.length>0)try{const[n]=await Promise.all([r(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return n}catch(n){throw new qe(e,t,n)}if(!this.cacheConfig)try{return await r()}catch(n){throw new qe(e,t,n)}if(this.queryMetadata.type==="select"){const n=await this.cache.get(this.cacheConfig.tag??await Cs(e,t),this.queryMetadata.tables,this.cacheConfig.tag!==void 0,this.cacheConfig.autoInvalidate);if(n===void 0){let i;try{i=await r()}catch(u){throw new qe(e,t,u)}return await this.cache.put(this.cacheConfig.tag??await Cs(e,t),i,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],this.cacheConfig.tag!==void 0,this.cacheConfig.config),i}return n}try{return await r()}catch(n){throw new qe(e,t,n)}}}g(Nh,sl,"PgPreparedQuery");var nl;nl=L;class Ih{constructor(e){this.dialect=e}execute(e,t){return Pe.startActiveSpan("drizzle.operation",()=>Pe.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){const r=await this.execute(e,t);return Number(r[0].count)}
8}g(Ih,nl,"PgSession");const vt=dp("geo"),Gt=vt.table("provinces",{id:le("id").primaryKey(),name:ne("name").notNull()}),Yt=vt.table("regencies",{id:le("id").primaryKey(),provinceId:le("province_id").references(()=>Gt.id).notNull(),name:ne("name").notNull()}),Zt=vt.table("districts",{id:le("id").primaryKey(),regencyId:le("regency_id").references(()=>Yt.id).notNull(),name:ne("name").notNull()}),es=vt.table("villages",{id:Ht("id",{mode:"number"}).primaryKey(),districtId:le("district_id").references(()=>Zt.id).notNull(),name:ne("name").notNull()});var pp=Object.create,nt=Object.defineProperty,mp=Object.getOwnPropertyDescriptor,gp=Object.getOwnPropertyNames,yp=Object.getPrototypeOf,wp=Object.prototype.hasOwnProperty,bp=(s,e,t)=>e in s?nt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,m=(s,e)=>nt(s,"name",{value:e,configurable:!0}),Ee=(s,e)=>()=>(s&&(e=s(s=0)),e),te=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),Ne=(s,e)=>{for(var t in e)nt(s,t,{get:e[t],enumerable:!0})},Lh=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of gp(e))!wp.call(s,n)&&n!==t&&nt(s,n,{get:()=>e[n],enumerable:!(r=mp(e,n))||r.enumerable});return s},He=(s,e,t)=>(t=s!=null?pp(yp(s)):{},Lh(e||!s||!s.__esModule?nt(t,"default",{value:s,enumerable:!0}):t,s)),ye=s=>Lh(nt({},"__esModule",{value:!0}),s),Y=(s,e,t)=>bp(s,typeof e!="symbol"?e+"":e,t),vp=te(s=>{V(),s.byteLength=f,s.toByteArray=d,s.fromByteArray=v;var e=[],t=[],r=typeof Uint8Array<"u"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(i=0,u=n.length;i<u;++i)e[i]=n[i],t[n.charCodeAt(i)]=i;var i,u;t[45]=62,t[95]=63;function a(c){var h=c.length;if(h%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var b=c.indexOf("=");b===-1&&(b=h);var E=b===h?0:4-b%4;return[b,E]}m(a,"getLens");function f(c){var h=a(c),b=h[0],E=h[1];return(b+E)*3/4-E}m(f,"byteLength");function y(c,h,b){return(h+b)*3/4-b}m(y,"_byteLength");function d(c){var h,b=a(c),E=b[0],C=b[1],P=new r(y(c,E,C)),O=0,M=C>0?E-4:E,T;for(T=0;T<M;T+=4)h=t[c.charCodeAt(T)]<<18|t[c.charCodeAt(T+1)]<<12|t[c.charCodeAt(T+2)]<<6|t[c.charCodeAt(T+3)],P[O++]=h>>16&255,P[O++]=h>>8&255,P[O++]=h&255;return C===2&&(h=t[c.charCodeAt(T)]<<2|t[c.charCodeAt(T+1)]>>4,P[O++]=h&255),C===1&&(h=t[c.charCodeAt(T)]<<10|t[c.charCodeAt(T+1)]<<4|t[c.charCodeAt(T+2)]>>2,P[O++]=h>>8&255,P[O++]=h&255),P}m(d,"toByteArray");function S(c){return e[c>>18&63]+e[c>>12&63]+e[c>>6&63]+e[c&63]}m(S,"tripletToBase64");function w(c,h,b){for(var E,C=[],P=h;P<b;P+=3)E=(c[P]<<16&16711680)+(c[P+1]<<8&65280)+(c[P+2]&255),C.push(S(E));return C.join("")}m(w,"encodeChunk");function v(c){for(var h,b=c.length,E=b%3,C=[],P=16383,O=0,M=b-E;O<M;O+=P)C.push(w(c,O,O+P>M?M:O+P));return E===1?(h=c[b-1],C.push(e[h>>2]+e[h<<4&63]+"==")):E===2&&(h=(c[b-2]<<8)+c[b-1],C.push(e[h>>10]+e[h>>4&63]+e[h<<2&63]+"=")),C.join("")}m(v,"fromByteArray")}),Sp=te(s=>{V(),s.read=function(e,t,r,n,i){var u,a,f=i*8-n-1,y=(1<<f)-1,d=y>>1,S=-7,w=r?i-1:0,v=r?-1:1,c=e[t+w];for(w+=v,u=c&(1<<-S)-1,c>>=-S,S+=f;S>0;u=u*256+e[t+w],w+=v,S-=8);for(a=u&(1<<-S)-1,u>>=-S,S+=n;S>0;a=a*256+e[t+w],w+=v,S-=8);if(u===0)u=1-d;else{if(u===y)return a?NaN:(c?-1:1)*(1/0);a=a+Math.pow(2,n),u=u-d}return(c?-1:1)*a*Math.pow(2,u-n)},s.write=function(e,t,r,n,i,u){var a,f,y,d=u*8-i-1,S=(1<<d)-1,w=S>>1,v=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,c=n?0:u-1,h=n?1:-1,b=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(f=isNaN(t)?1:0,a=S):(a=Math.floor(Math.log(t)/Math.LN2),t*(y=Math.pow(2,-a))<1&&(a--,y*=2),a+w>=1?t+=v/y:t+=v*Math.pow(2,1-w),t*y>=2&&(a++,y/=2),a+w>=S?(f=0,a=S):a+w>=1?(f=(t*y-1)*Math.pow(2,i),a=a+w):(f=t*Math.pow(2,w-1)*Math.pow(2,i),a=0));i>=8;e[r+c]=f&255,c+=h,f/=256,i-=8);for(a=a<<i|f,d+=i;d>0;e[r+c]=a&255,c+=h,a/=256,d-=8);e[r+c-h]|=b*128}}),Ep=te(s=>{V();var e=vp(),t=Sp(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;s.Buffer=a,s.SlowBuffer=C,s.INSPECT_MAX_BYTES=50;var n=2147483647;s.kMaxLength=n,a.TYPED_ARRAY_SUPPORT=i(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{let o=new Uint8Array(1),l={foo:m(function(){return 42},"foo")};return Object.setPrototypeOf(l,Uint8Array.prototype),Object.setPrototypeOf(o,l),o.foo()===42}catch{return!1}}m(i,"typedArraySupport"),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:m(function(){if(a.isBuffer(this))return this.buffer},"get")}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:m(function(){if(a.isBuffer(this))return this.byteOffset},"get")});function u(o){if(o>
8n)throw new RangeError('The value "'+o+'" is invalid for option "size"');let l=new Uint8Array(o);return Object.setPrototypeOf(l,a.prototype),l}m(u,"createBuffer");function a(o,l,p){if(typeof o=="number"){if(typeof l=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return S(o)}return f(o,l,p)}m(a,"Buffer"),a.poolSize=8192;function f(o,l,p){if(typeof o=="string")return w(o,l);if(ArrayBuffer.isView(o))return c(o);if(o==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o);if(xe(o,ArrayBuffer)||o&&xe(o.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(xe(o,SharedArrayBuffer)||o&&xe(o.buffer,SharedArrayBuffer)))return h(o,l,p);if(typeof o=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let A=o.valueOf&&o.valueOf();if(A!=null&&A!==o)return a.from(A,l,p);let B=b(o);if(B)return B;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof o[Symbol.toPrimitive]=="function")return a.from(o[Symbol.toPrimitive]("string"),l,p);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o)}m(f,"from"),a.from=function(o,l,p){return f(o,l,p)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function y(o){if(typeof o!="number")throw new TypeError('"size" argument must be of type number');if(o<0)throw new RangeError('The value "'+o+'" is invalid for option "size"')}m(y,"assertSize");function d(o,l,p){return y(o),o<=0?u(o):l!==void 0?typeof p=="string"?u(o).fill(l,p):u(o).fill(l):u(o)}m(d,"alloc"),a.alloc=function(o,l,p){return d(o,l,p)};function S(o){return y(o),u(o<0?0:E(o)|0)}m(S,"allocUnsafe"),a.allocUnsafe=function(o){return S(o)},a.allocUnsafeSlow=function(o){return S(o)};function w(o,l){if((typeof l!="string"||l==="")&&(l="utf8"),!a.isEncoding(l))throw new TypeError("Unknown encoding: "+l);let p=P(o,l)|0,A=u(p),B=A.write(o,l);return B!==p&&(A=A.slice(0,B)),A}m(w,"fromString");function v(o){let l=o.length<0?0:E(o.length)|0,p=u(l);for(let A=0;A<l;A+=1)p[A]=o[A]&255;return p}m(v,"fromArrayLike");function c(o){if(xe(o,Uint8Array)){let l=new Uint8Array(o);return h(l.buffer,l.byteOffset,l.byteLength)}return v(o)}m(c,"fromArrayView");function h(o,l,p){if(l<0||o.byteLength<l)throw new RangeError('"offset" is outside of buffer bounds');if(o.byteLength<l+(p||0))throw new RangeError('"length" is outside of buffer bounds');let A;return l===void 0&&p===void 0?A=new Uint8Array(o):p===void 0?A=new Uint8Array(o,l):A=new Uint8Array(o,l,p),Object.setPrototypeOf(A,a.prototype),A}m(h,"fromArrayBuffer");function b(o){if(a.isBuffer(o)){let l=E(o.length)|0,p=u(l);return p.length===0||o.copy(p,0,0,l),p}if(o.length!==void 0)return typeof o.length!="number"||Pt(o.length)?u(0):v(o);if(o.type==="Buffer"&&Array.isArray(o.data))return v(o.data)}m(b,"fromObject");function E(o){if(o>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return o|0}m(E,"checked");function C(o){return+o!=o&&(o=0),a.alloc(+o)}m(C,"SlowBuffer"),a.isBuffer=m(function(o){return o!=null&&o._isBuffer===!0&&o!==a.prototype},"isBuffer"),a.compare=m(function(o,l){if(xe(o,Uint8Array)&&(o=a.from(o,o.offset,o.byteLength)),xe(l,Uint8Array)&&(l=a.from(l,l.offset,l.byteLength)),!a.isBuffer(o)||!a.isBuffer(l))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(o===l)return 0;let p=o.length,A=l.length;for(let B=0,$=Math.min(p,A);B<$;++B)if(o[B]!==l[B]){p=o[B],A=l[B];break}return p<A?-1:A<p?1:0},"compare"),a.isEncoding=m(function(o){switch(String(o).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"),a.concat=m(function(o,l){if(!Array.isArray(o))throw new TypeError('"list" argument must be an Array of Buffers');if(o.length===0)return a.alloc(0);let p;if(l===void 0)for(l=0,p=0;p<o.length;++p)l+=o[p].length;let A=a.allocUnsafe(l),B=0;for(p=0;p<o.length;++p){let $=o[p];if(xe($,Uint8Array))B+$.length>A.length?(a.isBuffer($)||($=a.from($)),$.copy(A,B)):Uint8Array.prototype.set.call(A,$,B);else if(a.isBuffer($))$.copy(A,B);else throw new TypeError('"list" argument must be an Array of Buffers');B+=$.length}return A},"concat");function P(o,l){if(a.isBuffer(o))return o.length;if(ArrayBuffer.isView(o)||xe(o,ArrayBuffer))return o.byteLength;if(typeof o!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof o);let p=o.length,A=arguments.length>2&&arguments[2]===!0;if(!A&&p===0)return 0;let B=!1;for(;;)switch(l){case"ascii":case"latin1":case"binary":return p;case"utf8":case"utf-8":return Ct(o).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p*2;case"hex":return p>>>1;case"base64":return hr(o).length;default:if(B)return A?-1:Ct(o).length;l=(""+l).toLowerCase(),B=!0}
8}m(P,"byteLength"),a.byteLength=P;function O(o,l,p){let A=!1;if((l===void 0||l<0)&&(l=0),l>this.length||((p===void 0||p>this.length)&&(p=this.length),p<=0)||(p>>>=0,l>>>=0,p<=l))return"";for(o||(o="utf8");;)switch(o){case"hex":return X(this,l,p);case"utf8":case"utf-8":return D(this,l,p);case"ascii":return Z(this,l,p);case"latin1":case"binary":return se(this,l,p);case"base64":return z(this,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Te(this,l,p);default:if(A)throw new TypeError("Unknown encoding: "+o);o=(o+"").toLowerCase(),A=!0}}m(O,"slowToString"),a.prototype._isBuffer=!0;function M(o,l,p){let A=o[l];o[l]=o[p],o[p]=A}m(M,"swap"),a.prototype.swap16=m(function(){let o=this.length;if(o%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let l=0;l<o;l+=2)M(this,l,l+1);return this},"swap16"),a.prototype.swap32=m(function(){let o=this.length;if(o%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let l=0;l<o;l+=4)M(this,l,l+3),M(this,l+1,l+2);return this},"swap32"),a.prototype.swap64=m(function(){let o=this.length;if(o%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let l=0;l<o;l+=8)M(this,l,l+7),M(this,l+1,l+6),M(this,l+2,l+5),M(this,l+3,l+4);return this},"swap64"),a.prototype.toString=m(function(){let o=this.length;return o===0?"":arguments.length===0?D(this,0,o):O.apply(this,arguments)},"toString"),a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=m(function(o){if(!a.isBuffer(o))throw new TypeError("Argument must be a Buffer");return this===o?!0:a.compare(this,o)===0},"equals"),a.prototype.inspect=m(function(){let o="",l=s.INSPECT_MAX_BYTES;return o=this.toString("hex",0,l).replace(/(.{2})/g,"$1 ").trim(),this.length>l&&(o+=" ... "),"<Buffer "+o+">"},"inspect"),r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=m(function(o,l,p,A,B){if(xe(o,Uint8Array)&&(o=a.from(o,o.offset,o.byteLength)),!a.isBuffer(o))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof o);if(l===void 0&&(l=0),p===void 0&&(p=o?o.length:0),A===void 0&&(A=0),B===void 0&&(B=this.length),l<0||p>o.length||A<0||B>this.length)throw new RangeError("out of range index");if(A>=B&&l>=p)return 0;if(A>=B)return-1;if(l>=p)return 1;if(l>>>=0,p>>>=0,A>>>=0,B>>>=0,this===o)return 0;let $=B-A,k=p-l,oe=Math.min($,k),me=this.slice(A,B),ue=o.slice(l,p);for(let ae=0;ae<oe;++ae)if(me[ae]!==ue[ae]){$=me[ae],k=ue[ae];break}return $<k?-1:k<$?1:0},"compare");function T(o,l,p,A,B){if(o.length===0)return-1;if(typeof p=="string"?(A=p,p=0):p>2147483647?p=2147483647:p<-2147483648&&(p=-2147483648),p=+p,Pt(p)&&(p=B?0:o.length-1),p<0&&(p=o.length+p),p>=o.length){if(B)return-1;p=o.length-1}else if(p<0)if(B)p=0;else return-1;if(typeof l=="string"&&(l=a.from(l,A)),a.isBuffer(l))return l.length===0?-1:I(o,l,p,A,B);if(typeof l=="number")return l=l&255,typeof Uint8Array.prototype.indexOf=="function"?B?Uint8Array.prototype.indexOf.call(o,l,p):Uint8Array.prototype.lastIndexOf.call(o,l,p):I(o,[l],p,A,B);throw new TypeError("val must be string, number or Buffer")}m(T,"bidirectionalIndexOf");function I(o,l,p,A,B){let $=1,k=o.length,oe=l.length;if(A!==void 0&&(A=String(A).toLowerCase(),A==="ucs2"||A==="ucs-2"||A==="utf16le"||A==="utf-16le")){if(o.length<2||l.length<2)return-1;$=2,k/=2,oe/=2,p/=2}function me(ae,he){return $===1?ae[he]:ae.readUInt16BE(he*$)}m(me,"read");let ue;if(B){let ae=-1;for(ue=p;ue<k;ue++)if(me(o,ue)===me(l,ae===-1?0:ue-ae)){if(ae===-1&&(ae=ue),ue-ae+1===oe)return ae*$}else ae!==-1&&(ue-=ue-ae),ae=-1}else for(p+oe>k&&(p=k-oe),ue=p;ue>=0;ue--){let ae=!0;for(let he=0;he<oe;he++)if(me(o,ue+he)!==me(l,he)){ae=!1;break}if(ae)return ue}return-1}m(I,"arrayIndexOf"),a.prototype.includes=m(function(o,l,p){return this.indexOf(o,l,p)!==-1},"includes"),a.prototype.indexOf=m(function(o,l,p){return T(this,o,l,p,!0)},"indexOf"),a.prototype.lastIndexOf=m(function(o,l,p){return T(this,o,l,p,!1)},"lastIndexOf");function N(o,l,p,A){p=Number(p)||0;let B=o.length-p;A?(A=Number(A),A>B&&(A=B)):A=B;let $=l.length;A>$/2&&(A=$/2);let k;for(k=0;k<A;++k){let oe=parseInt(l.substr(k*2,2),16);if(Pt(oe))return k;o[p+k]=oe}return k}m(N,"hexWrite");function _(o,l,p,A){return at(Ct(l,o.length-p),o,p,A)}m(_,"utf8Write");function q(o,l,p,A){return at(ds(l),o,p,A)}m(q,"asciiWrite");function R(o,l,p,A){return at(hr(l),o,p,A)}m(R,"base64Write");function U(o,l,p,A){return at(ps(l,o.length-p),o,p,A)}m(U,"ucs2Write"),a.prototype.write=m(function(o,l,p,A){if(l===void 0)A="utf8",p=this.length,l=0;else if(p===void 0&&typeof l=="string")A=l,p=this.length,l=0;else if(isFinite(l))l=l>>>0,isFinite(p)?(p=p>>>0,A===void 0&&(A="utf8")):(A=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let B=this.length-l;if((p===void 0||p>B)&&(p=B),o.length>0&&(p<0||l<0)||l>this.length)throw new RangeError("Attempt to write outside buffer bounds");A||(A="utf8");let $=!1;for(;;)switch(A){case"hex":return N(this,o,l,p);case"utf8":case"utf-8":return _(this,o,l,p);case"ascii":case"latin1":case"binary":return q(this,o,l,p);case"base64":return R(this,o,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,o,l,p);default:if($)throw new TypeError("Unknown encoding: "+A);A=(""+A).toLowerCase(),$=!0}},"write"),a.prototype.toJSON=m(function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},"toJSON");function z(o,l,p){return l===0&&p===o.length?e.fromByteArray(o):e.fromByteArray(o.slice(l,p))}m(z,"base64Slice");function D(o,l,p){p=Math.min(o.length,p);let A=[],B=l;for(;B<p;
8){let $=o[B],k=null,oe=$>239?4:$>223?3:$>191?2:1;if(B+oe<=p){let me,ue,ae,he;switch(oe){case 1:$<128&&(k=$);break;case 2:me=o[B+1],(me&192)===128&&(he=($&31)<<6|me&63,he>127&&(k=he));break;case 3:me=o[B+1],ue=o[B+2],(me&192)===128&&(ue&192)===128&&(he=($&15)<<12|(me&63)<<6|ue&63,he>2047&&(he<55296||he>57343)&&(k=he));break;case 4:me=o[B+1],ue=o[B+2],ae=o[B+3],(me&192)===128&&(ue&192)===128&&(ae&192)===128&&(he=($&15)<<18|(me&63)<<12|(ue&63)<<6|ae&63,he>65535&&he<1114112&&(k=he))}}k===null?(k=65533,oe=1):k>65535&&(k-=65536,A.push(k>>>10&1023|55296),k=56320|k&1023),A.push(k),B+=oe}return H(A)}m(D,"utf8Slice");var F=4096;function H(o){let l=o.length;if(l<=F)return String.fromCharCode.apply(String,o);let p="",A=0;for(;A<l;)p+=String.fromCharCode.apply(String,o.slice(A,A+=F));return p}m(H,"decodeCodePointsArray");function Z(o,l,p){let A="";p=Math.min(o.length,p);for(let B=l;B<p;++B)A+=String.fromCharCode(o[B]&127);return A}m(Z,"asciiSlice");function se(o,l,p){let A="";p=Math.min(o.length,p);for(let B=l;B<p;++B)A+=String.fromCharCode(o[B]);return A}m(se,"latin1Slice");function X(o,l,p){let A=o.length;(!l||l<0)&&(l=0),(!p||p<0||p>A)&&(p=A);let B="";for(let $=l;$<p;++$)B+=Df[o[$]];return B}m(X,"hexSlice");function Te(o,l,p){let A=o.slice(l,p),B="";for(let $=0;$<A.length-1;$+=2)B+=String.fromCharCode(A[$]+A[$+1]*256);return B}m(Te,"utf16leSlice"),a.prototype.slice=m(function(o,l){let p=this.length;o=~~o,l=l===void 0?p:~~l,o<0?(o+=p,o<0&&(o=0)):o>p&&(o=p),l<0?(l+=p,l<0&&(l=0)):l>p&&(l=p),l<o&&(l=o);let A=this.subarray(o,l);return Object.setPrototypeOf(A,a.prototype),A},"slice");function ie(o,l,p){if(o%1!==0||o<0)throw new RangeError("offset is not uint");if(o+l>p)throw new RangeError("Trying to access beyond buffer length")}m(ie,"checkOffset"),a.prototype.readUintLE=a.prototype.readUIntLE=m(function(o,l,p){o=o>>>0,l=l>>>0,p||ie(o,l,this.length);let A=this[o],B=1,$=0;for(;++$<l&&(B*=256);)A+=this[o+$]*B;return A},"readUIntLE"),a.prototype.readUintBE=a.prototype.readUIntBE=m(function(o,l,p){o=o>>>0,l=l>>>0,p||ie(o,l,this.length);let A=this[o+--l],B=1;for(;l>0&&(B*=256);)A+=this[o+--l]*B;return A},"readUIntBE"),a.prototype.readUint8=a.prototype.readUInt8=m(function(o,l){return o=o>>>0,l||ie(o,1,this.length),this[o]},"readUInt8"),a.prototype.readUint16LE=a.prototype.readUInt16LE=m(function(o,l){return o=o>>>0,l||ie(o,2,this.length),this[o]|this[o+1]<<8},"readUInt16LE"),a.prototype.readUint16BE=a.prototype.readUInt16BE=m(function(o,l){return o=o>>>0,l||ie(o,2,this.length),this[o]<<8|this[o+1]},"readUInt16BE"),a.prototype.readUint32LE=a.prototype.readUInt32LE=m(function(o,l){return o=o>>>0,l||ie(o,4,this.length),(this[o]|this[o+1]<<8|this[o+2]<<16)+this[o+3]*16777216},"readUInt32LE"),a.prototype.readUint32BE=a.prototype.readUInt32BE=m(function(o,l){return o=o>>>0,l||ie(o,4,this.length),this[o]*16777216+(this[o+1]<<16|this[o+2]<<8|this[o+3])},"readUInt32BE"),a.prototype.readBigUInt64LE=Le(m(function(o){o=o>>>0,Fe(o,"offset");let l=this[o],p=this[o+7];(l===void 0||p===void 0)&&Ye(o,this.length-8);let A=l+this[++o]*2**8+this[++o]*2**16+this[++o]*2**24,B=this[++o]+this[++o]*2**8+this[++o]*2**16+p*2**24;return BigInt(A)+(BigInt(B)<<BigInt(32))},"readBigUInt64LE")),a.prototype.readBigUInt64BE=Le(m(function(o){o=o>>>0,Fe(o,"offset");let l=this[o],p=this[o+7];(l===void 0||p===void 0)&&Ye(o,this.length-8);let A=l*2**24+this[++o]*2**16+this[++o]*2**8+this[++o],B=this[++o]*2**24+this[++o]*2**16+this[++o]*2**8+p;return(BigInt(A)<<BigInt(32))+BigInt(B)},"readBigUInt64BE")),a.prototype.readIntLE=m(function(o,l,p){o=o>>>0,l=l>>>0,p||ie(o,l,this.length);let A=this[o],B=1,$=0;for(;++$<l&&(B*=256);)A+=this[o+$]*B;return B*=128,A>=B&&(A-=Math.pow(2,8*l)),A},"readIntLE"),a.prototype.readIntBE=m(function(o,l,p){o=o>>>0,l=l>>>0,p||ie(o,l,this.length);let A=l,B=1,$=this[o+--A];for(;A>0&&(B*=256);)$+=this[o+--A]*B;return B*=128,$>=B&&($-=Math.pow(2,8*l)),$},"readIntBE"),a.prototype.readInt8=m(function(o,l){return o=o>>>0,l||ie(o,1,this.length),this[o]&128?(255-this[o]+1)*-1:this[o]},"readInt8"),a.prototype.readInt16LE=m(function(o,l){o=o>>>0,l||ie(o,2,this.length);let p=this[o]|this[o+1]<<8;return p&32768?p|4294901760:p},"readInt16LE"),a.prototype.readInt16BE=m(function(o,l){o=o>>>0,l||ie(o,2,this.length);let p=this[o+1]|this[o]<<8;return p&32768?p|4294901760:p},"readInt16BE"),a.prototype.readInt32LE=m(function(o,l){return o=o>>>0,l||ie(o,4,this.length),this[o]|this[o+1]<<8|this[o+2]<<16|this[o+3]<<24},"readInt32LE"),a.prototype.readInt32BE=m(function(o,l){return o=o>>>0,l||ie(o,4,this.length),this[o]<<24|this[o+1]<<16|this[o+2]<<8|this[o+3]},"readInt32BE"),a.prototype.readBigInt64LE=Le(m(function(o){o=o>>>0,Fe(o,"offset");let l=this[o],p=this[o+7];(l===void 0||p===void 0)&&Ye(o,this.length-8);let A=this[o+4]+this[o+5]*2**8+this[o+6]*2**16+(p<<24);return(BigInt(A)<<BigInt(32))+BigInt(l+this[++o]*2**8+this[++o]*2**16+this[++o]*2**24)},"readBigInt64LE")),a.prototype.readBigInt64BE=Le(m(function(o){o=o>>>0,Fe(o,"offset");let l=this[o],p=this[o+7];(l===void 0||p===void 0)&&Ye(o,this.length-8);let A=(l<<24)+this[++o]*2**16+this[++o]*2**8+this[++o];return(BigInt(A)<<BigInt(32))+BigInt(this[++o]*2**24+this[++o]*2**16+this[++o]*2**8+p)},"readBigInt64BE")),a.prototype.readFloatLE=m(function(o,l){return o=o>>>0,l||ie(o,4,this.length),t.read(this,o,!0,23,4)},"readFloatLE"),a.prototype.readFloatBE=m(function(o,l){return o=o>>>0,l||ie(o,4,this.length),t.read(this,o,!1,23,4)},"readFloatBE"),a.prototype.readDoubleLE=m(function(o,l){return o=o>>>0,l||ie(o,8,this.length),t.read(this,o,!0,52,8)},"readDoubleLE"),a.prototype.readDoubleBE=m(function(o,l){return o=o>>>0,l||ie(o,8,this.length),t.read(this,o,!1,52,8)},"readDoubleBE");function fe(o,l,p,A,B,$){if(!a.isBuffer(o))throw new TypeError('"buffer" argument must be a Buffer instance');if(l>B||l<$)throw new RangeError('"value" argument is out of bounds');if(p+A>o.length)throw new RangeError("Index out of range")}m(fe,"checkInt"),a.prototype.writeUintLE=a.prototype.writeUIntLE=m(function(o,l,p,A){if(o=+o,l=l>>>0,p=p>>>0,!A){let k=Math.pow(2,8*p)-1;fe(this,o,l,p,k,0)}let B=1,$=0;for(this[l]=o&255;++$<p&&(B*=256);)this[l+$]=o/B&255;return l+p},"writeUIntLE"),a.prototype.writeUintBE=a.prototype.writeUIntBE=m(function(o,l,p,A){if(o=+o,l=l>>>0,p=p>>>0,!A){let k=Math.pow(2,8*p)-1;fe(this,o,l,p,k,0)}let B=p-1,$=1;for(this[l+B]=o&255;--B>=0&&($*=256);)this[l+B]=o/$&255;return l+p},"writeUIntBE"),a.prototype.writeUint8=a.prototype.writeUInt8=m(function(o,l,p){return o=+o,l=l>>>0,p||fe(this,o,l,1,255,0),this[l]=o&255,l+1},"writeUInt8"),a.prototype.writeUint16LE=a.prototype.writeUInt16LE=m(function(o,l,p){return o=+o,l=l>>>0,p||fe(this,o,l,2,65535,0),this[l]=o&255,this[l+1]=o>>>8,l+2},"writeUInt16LE"),a.prototype.writeUint16BE=a.prototype.writeUInt16BE=m(function(o,l,p){return o=+o,l=l>>>0,p||fe(this,o,l,2,65535,0),this[l]=o>>>8,this[l+1]=o&255,l+2},"writeUInt16BE"),a.prototype.writeUint32LE=a.prototype.writeUInt32LE=m(function(o,l,p){return o=+o,l=l>>>0,p||fe(this,o,l,4,4294967295,0),this[l+3]=o>>>24,this[l+2]=o>>>16,this[l+1]=o>>>8,this[l]=o&255,l+4},"writeUInt32LE"),a.prototype.writeUint32BE=a.prototype.writeUInt32BE=m(function(o,l,p){return o=+o,l=l>>>0,p||fe(this,o,l,4,4294967295,0),this[l]=o>>>24,this[l+1]=o>>>16,this[l+2]=o>>>8,this[l+3]=o&255,l+4},"writeUInt32BE");function it(o,l,p,A,B){cr(l,A,B,o,p,7);let $=Number(l&BigInt(4294967295));o[p++]=$,$=$>>8,o[p++]=$,$=$>>8,o[p++]=$,$=$>>8,o[p++]=$;let k=Number(l>>BigInt(32)&BigInt(4294967295));return o[p++]=k,k=k>>8,o[p++]=k,k=k>>8,o[p++]=k,k=k>>8,o[p++]=k,p}m(it,"wrtBigUInt64LE");function ot(o,l,p,A,B){cr(l,A,B,o,p,7);let $=Number(l&BigInt(4294967295));o[p+7]=$,$=$>>8,o[p+6]=$,$=$>>8,o[p+5]=$,$=$>>8,o[p+4]=$;let k=Number(l>>BigInt(32)&BigInt(4294967295));return o[p+3]=k,k=k>>8,o[p+2]=k,k=k>>8,o[p+1]=k,k=k>>8,o[p]=k,p+8}m(ot,"wrtBigUInt64BE"),a.prototype.writeBigUInt64LE=Le(m(function(o,l=0){return it(this,o,l,BigInt(0),BigInt("0xffffffffffffffff"))},"writeBigUInt64LE")),a.prototype.writeBigUInt64BE=Le(m(function(o,l=0){return ot(this,o,l,BigInt(0),BigInt("0xffffffffffffffff"))},"writeBigUInt64BE")),a.prototype.writeIntLE=m(function(o,l,p,A){if(o=+o,l=l>>>0,!A){let oe=Math.pow(2,8*p-1);fe(this,o,l,p,oe-1,-oe)}let B=0,$=1,k=0;for(this[l]=o&255;++B<p&&($*=256);)o<0&&k===0&&this[l+B-1]!==0&&(k=1),this[l+B]=(o/$>>0)-k&255;return l+p},"writeIntLE"),a.prototype.writeIntBE=m(function(o,l,p,A){if(o=+o,l=l>>>0,!A){let oe=Math.pow(2,8*p-1);fe(this,o,l,p,oe-1,-oe)}let B=p-1,$=1,k=0;for(this[l+B]=o&255;--B>=0&&($*=256);)o<0&&k===0&&this[l+B+1]!==0&&(k=1),this[l+B]=(o/$>>0)-k&255;return l+p},"writeIntBE"),a.prototype.writeInt8=m(function(o,l,p){return o=+o,l=l>>>0,p||fe(this,o,l,1,127,-128),o<0&&(o=255+o+1),this[l]=o&255,l+1},"writeInt8"),a.prototype.writeInt16LE=m(function(o,l,p){return o=+o,l=l>>>0,p||fe(this,o,l,2,32767,-32768),this[l]=o&255,this[l+1]=o>>>8,l+2},"writeInt16LE"),a.prototype.writeInt16BE=m(function(o,l,p){return o=+o,l=l>>>0,p||fe(this,o,l,2,32767,-32768),this[l]=o>>>8,this[l+1]=o&255,l+2},"writeInt16BE"),a.prototype.writeInt32LE=m(function(o,l,p){return o=+o,l=l>>>0,p||fe(this,o,l,4,2147483647,-2147483648),this[l]=o&255,this[l+1]=o>>>8,this[l+2]=o>>>16,this[l+3]=o>>>24,l+4},"writeInt32LE"),a.prototype.writeInt32BE=m(function(o,l,p){return o=+o,l=l>>>0,p||fe(this,o,l,4,2147483647,-2147483648),o<0&&(o=4294967295+o+1),this[l]=o>>>24,this[l+1]=o>>>16,this[l+2]=o>>>8,this[l+3]=o&255,l+4},"writeInt32BE"),a.prototype.writeBigInt64LE=Le(m(function(o,l=0){return it(this,o,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))},"writeBigInt64LE")),a.prototype.writeBigInt64BE=Le(m(function(o,l=0){return ot(this,o,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))},"writeBigInt64BE"));function or(o,l,p,A,B,$){if(p+A>o.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("Index out of range")}
8m(or,"checkIEEE754");function ar(o,l,p,A,B){return l=+l,p=p>>>0,B||or(o,l,p,4),t.write(o,l,p,A,23,4),p+4}m(ar,"writeFloat"),a.prototype.writeFloatLE=m(function(o,l,p){return ar(this,o,l,!0,p)},"writeFloatLE"),a.prototype.writeFloatBE=m(function(o,l,p){return ar(this,o,l,!1,p)},"writeFloatBE");function ur(o,l,p,A,B){return l=+l,p=p>>>0,B||or(o,l,p,8),t.write(o,l,p,A,52,8),p+8}m(ur,"writeDouble"),a.prototype.writeDoubleLE=m(function(o,l,p){return ur(this,o,l,!0,p)},"writeDoubleLE"),a.prototype.writeDoubleBE=m(function(o,l,p){return ur(this,o,l,!1,p)},"writeDoubleBE"),a.prototype.copy=m(function(o,l,p,A){if(!a.isBuffer(o))throw new TypeError("argument should be a Buffer");if(p||(p=0),!A&&A!==0&&(A=this.length),l>=o.length&&(l=o.length),l||(l=0),A>0&&A<p&&(A=p),A===p||o.length===0||this.length===0)return 0;if(l<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(A<0)throw new RangeError("sourceEnd out of bounds");A>this.length&&(A=this.length),o.length-l<A-p&&(A=o.length-l+p);let B=A-p;return this===o&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(l,p,A):Uint8Array.prototype.set.call(o,this.subarray(p,A),l),B},"copy"),a.prototype.fill=m(function(o,l,p,A){if(typeof o=="string"){if(typeof l=="string"?(A=l,l=0,p=this.length):typeof p=="string"&&(A=p,p=this.length),A!==void 0&&typeof A!="string")throw new TypeError("encoding must be a string");if(typeof A=="string"&&!a.isEncoding(A))throw new TypeError("Unknown encoding: "+A);if(o.length===1){let $=o.charCodeAt(0);(A==="utf8"&&$<128||A==="latin1")&&(o=$)}}else typeof o=="number"?o=o&255:typeof o=="boolean"&&(o=Number(o));if(l<0||this.length<l||this.length<p)throw new RangeError("Out of range index");if(p<=l)return this;l=l>>>0,p=p===void 0?this.length:p>>>0,o||(o=0);let B;if(typeof o=="number")for(B=l;B<p;++B)this[B]=o;else{let $=a.isBuffer(o)?o:a.from(o,A),k=$.length;if(k===0)throw new TypeError('The value "'+o+'" is invalid for argument "value"');for(B=0;B<p-l;++B)this[B+l]=$[B%k]}return this},"fill");var Ge={};function _t(o,l,p){var A;Ge[o]=(A=class extends p{constructor(){super(),Object.defineProperty(this,"message",{value:l.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${o}]`,this.stack,delete this.name}get code(){return o}set code(B){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:B,writable:!0})}toString(){return`${this.name} [${o}]: ${this.message}`}},m(A,"NodeError"),A)}m(_t,"E"),_t("ERR_BUFFER_OUT_OF_BOUNDS",function(o){return o?`${o} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),_t("ERR_INVALID_ARG_TYPE",function(o,l){return`The "${o}" argument must be of type number. Received type ${typeof l}`},TypeError),_t("ERR_OUT_OF_RANGE",function(o,l,p){let A=`The value of "${o}" is out of range.`,B=p;return Number.isInteger(p)&&Math.abs(p)>2**32?B=lr(String(p)):typeof p=="bigint"&&(B=String(p),(p>BigInt(2)**BigInt(32)||p<-(BigInt(2)**BigInt(32)))&&(B=lr(B)),B+="n"),A+=` It must be ${l}. Received ${B}`,A},RangeError);function lr(o){let l="",p=o.length,A=o[0]==="-"?1:0;for(;p>=A+4;p-=3)l=`_${o.slice(p-3,p)}${l}`;return`${o.slice(0,p)}${l}`}m(lr,"addNumericalSeparator");function hs(o,l,p){Fe(l,"offset"),(o[l]===void 0||o[l+p]===void 0)&&Ye(l,o.length-(p+1))}m(hs,"checkBounds");function cr(o,l,p,A,B,$){if(o>p||o<l){let k=typeof l=="bigint"?"n":"",oe;throw $>3?l===0||l===BigInt(0)?oe=`>= 0${k} and < 2${k} ** ${($+1)*8}${k}`:oe=`>= -(2${k} ** ${($+1)*8-1}${k}) and < 2 ** ${($+1)*8-1}${k}`:oe=`>= ${l}${k} and <= ${p}${k}`,new Ge.ERR_OUT_OF_RANGE("value",oe,o)}hs(A,B,$)}m(cr,"checkIntBI");function Fe(o,l){if(typeof o!="number")throw new Ge.ERR_INVALID_ARG_TYPE(l,"number",o)}m(Fe,"validateNumber");function Ye(o,l,p){throw Math.floor(o)!==o?(Fe(o,p),new Ge.ERR_OUT_OF_RANGE(p||"offset","an integer",o)):l<0?new Ge.ERR_BUFFER_OUT_OF_BOUNDS:new Ge.ERR_OUT_OF_RANGE(p||"offset",`>= ${p?1:0} and <= ${l}`,o)}m(Ye,"boundsError");var Mf=/[^+/0-9A-Za-z-_]/g;function fs(o){if(o=o.split("=")[0],o=o.trim().replace(Mf,""),o.length<2)return"";for(;o.length%4!==0;)o=o+"=";return o}m(fs,"base64clean");function Ct(o,l){l=l||1/0;let p,A=o.length,B=null,$=[];for(let k=0;k<A;
8++k){if(p=o.charCodeAt(k),p>55295&&p<57344){if(!B){if(p>56319){(l-=3)>-1&&$.push(239,191,189);continue}else if(k+1===A){(l-=3)>-1&&$.push(239,191,189);continue}B=p;continue}if(p<56320){(l-=3)>-1&&$.push(239,191,189),B=p;continue}p=(B-55296<<10|p-56320)+65536}else B&&(l-=3)>-1&&$.push(239,191,189);if(B=null,p<128){if((l-=1)<0)break;$.push(p)}else if(p<2048){if((l-=2)<0)break;$.push(p>>6|192,p&63|128)}else if(p<65536){if((l-=3)<0)break;$.push(p>>12|224,p>>6&63|128,p&63|128)}else if(p<1114112){if((l-=4)<0)break;$.push(p>>18|240,p>>12&63|128,p>>6&63|128,p&63|128)}else throw new Error("Invalid code point")}return $}m(Ct,"utf8ToBytes");function ds(o){let l=[];for(let p=0;p<o.length;++p)l.push(o.charCodeAt(p)&255);return l}m(ds,"asciiToBytes");function ps(o,l){let p,A,B,$=[];for(let k=0;k<o.length&&!((l-=2)<0);++k)p=o.charCodeAt(k),A=p>>8,B=p%256,$.push(B),$.push(A);return $}m(ps,"utf16leToBytes");function hr(o){return e.toByteArray(fs(o))}m(hr,"base64ToBytes");function at(o,l,p,A){let B;for(B=0;B<A&&!(B+p>=l.length||B>=o.length);++B)l[B+p]=o[B];return B}m(at,"blitBuffer");function xe(o,l){return o instanceof l||o!=null&&o.constructor!=null&&o.constructor.name!=null&&o.constructor.name===l.name}m(xe,"isInstance");function Pt(o){return o!==o}m(Pt,"numberIsNaN");var Df=(function(){let o="0123456789abcdef",l=new Array(256);for(let p=0;p<16;++p){let A=p*16;for(let B=0;B<16;++B)l[A+B]=o[p]+o[B]}return l})();function Le(o){return typeof BigInt>"u"?ms:o}m(Le,"defineBigIntMethod");function ms(){throw new Error("BigInt not supported")}m(ms,"BufferBigIntNotDefined")}),Xt,ts,G,ee,V=Ee(()=>{Xt=globalThis,ts=globalThis.setImmediate??(s=>setTimeout(s,0)),G=typeof globalThis.Buffer=="function"&&typeof globalThis.Buffer.allocUnsafe=="function"?globalThis.Buffer:Ep().Buffer,ee=globalThis.process??{},ee.env??(ee.env={});try{ee.nextTick(()=>{})}catch{let s=Promise.resolve();ee.nextTick=s.then.bind(s)}}),Je=te((s,e)=>{V();var t=typeof Reflect=="object"?Reflect:null,r=t&&typeof t.apply=="function"?t.apply:m(function(T,I,N){return Function.prototype.apply.call(T,I,N)},"ReflectApply"),n;t&&typeof t.ownKeys=="function"?n=t.ownKeys:Object.getOwnPropertySymbols?n=m(function(T){return Object.getOwnPropertyNames(T).concat(Object.getOwnPropertySymbols(T))},"ReflectOwnKeys"):n=m(function(T){return Object.getOwnPropertyNames(T)},"ReflectOwnKeys");function i(T){console&&console.warn&&console.warn(T)}m(i,"ProcessEmitWarning");var u=Number.isNaN||m(function(T){return T!==T},"NumberIsNaN");function a(){a.init.call(this)}m(a,"EventEmitter"),e.exports=a,e.exports.once=P,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var f=10;function y(T){if(typeof T!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof T)}m(y,"checkListener"),Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:m(function(){return f},"get"),set:m(function(T){if(typeof T!="number"||T<0||u(T))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+T+".");f=T},"set")}),a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=m(function(T){if(typeof T!="number"||T<0||u(T))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+T+".");return this._maxListeners=T,this},"setMaxListeners");function d(T){return T._maxListeners===void 0?a.defaultMaxListeners:T._maxListeners}m(d,"_getMaxListeners"),a.prototype.getMaxListeners=m(function(){return d(this)},"getMaxListeners"),a.prototype.emit=m(function(T){for(var I=[],N=1;N<arguments.length;N++)I.push(arguments[N]);var _=T==="error",q=this._events;if(q!==void 0)_=_&&q.error===void 0;else if(!_)return!1;if(_){var R;if(I.length>0&&(R=I[0]),R instanceof Error)throw R;var U=new Error("Unhandled error."+(R?" ("+R.message+")":""));throw U.context=R,U}var z=q[T];if(z===void 0)return!1;if(typeof z=="function")r(z,this,I);else for(var D=z.length,F=b(z,D),N=0;N<D;++N)r(F[N],this,I);return!0},"emit");function S(T,I,N,_){var q,R,U;if(y(N),R=T._events,R===void 0?(R=T._events=Object.create(null),T._eventsCount=0):(R.newListener!==void 0&&(T.emit("newListener",I,N.listener?N.listener:N),R=T._events),U=R[I]),U===void 0)U=R[I]=N,++T._eventsCount;else if(typeof U=="function"?U=R[I]=_?[N,U]:[U,N]:_?U.unshift(N):U.push(N),q=d(T),q>0&&U.length>q&&!U.warned){U.warned=!0;var z=new Error("Possible EventEmitter memory leak detected. "+U.length+" "+String(I)+" listeners added. Use emitter.setMaxListeners() to increase limit");z.name="MaxListenersExceededWarning",z.emitter=T,z.type=I,z.count=U.length,i(z)}return T}m(S,"_addListener"),a.prototype.addListener=m(function(T,I){return S(this,T,I,!1)},"addListener"),a.prototype.on=a.prototype.addListener,a.prototype.prependListener=m(function(T,I){return S(this,T,I,!0)},"prependListener");function w(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}m(w,"onceWrapper");function v(T,I,N){var _={fired:!1,wrapFn:void 0,target:T,type:I,listener:N},q=w.bind(_);return q.listener=N,_.wrapFn=q,q}m(v,"_onceWrap"),a.prototype.once=m(function(T,I){return y(I),this.on(T,v(this,T,I)),this},"once"),a.prototype.prependOnceListener=m(function(T,I){return y(I),this.prependListener(T,v(this,T,I)),this},"prependOnceListener"),a.prototype.removeListener=m(function(T,I){var N,_,q,R,U;if(y(I),_=this._events,_===void 0)return this;if(N=_[T],N===void 0)return this;if(N===I||N.listener===I)--this._eventsCount===0?this._events=Object.create(null):(delete _[T],_.removeListener&&this.emit
8("removeListener",T,N.listener||I));else if(typeof N!="function"){for(q=-1,R=N.length-1;R>=0;R--)if(N[R]===I||N[R].listener===I){U=N[R].listener,q=R;break}if(q<0)return this;q===0?N.shift():E(N,q),N.length===1&&(_[T]=N[0]),_.removeListener!==void 0&&this.emit("removeListener",T,U||I)}return this},"removeListener"),a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=m(function(T){var I,N,_;if(N=this._events,N===void 0)return this;if(N.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):N[T]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete N[T]),this;if(arguments.length===0){var q=Object.keys(N),R;for(_=0;_<q.length;++_)R=q[_],R!=="removeListener"&&this.removeAllListeners(R);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(I=N[T],typeof I=="function")this.removeListener(T,I);else if(I!==void 0)for(_=I.length-1;_>=0;_--)this.removeListener(T,I[_]);return this},"removeAllListeners");function c(T,I,N){var _=T._events;if(_===void 0)return[];var q=_[I];return q===void 0?[]:typeof q=="function"?N?[q.listener||q]:[q]:N?C(q):b(q,q.length)}m(c,"_listeners"),a.prototype.listeners=m(function(T){return c(this,T,!0)},"listeners"),a.prototype.rawListeners=m(function(T){return c(this,T,!1)},"rawListeners"),a.listenerCount=function(T,I){return typeof T.listenerCount=="function"?T.listenerCount(I):h.call(T,I)},a.prototype.listenerCount=h;function h(T){var I=this._events;if(I!==void 0){var N=I[T];if(typeof N=="function")return 1;if(N!==void 0)return N.length}return 0}m(h,"listenerCount"),a.prototype.eventNames=m(function(){return this._eventsCount>0?n(this._events):[]},"eventNames");function b(T,I){for(var N=new Array(I),_=0;_<I;++_)N[_]=T[_];return N}m(b,"arrayClone");function E(T,I){for(;I+1<T.length;I++)T[I]=T[I+1];T.pop()}m(E,"spliceOne");function C(T){for(var I=new Array(T.length),N=0;N<I.length;++N)I[N]=T[N].listener||T[N];return I}m(C,"unwrapListeners");function P(T,I){return new Promise(function(N,_){function q(U){T.removeListener(I,R),_(U)}m(q,"errorListener");function R(){typeof T.removeListener=="function"&&T.removeListener("error",q),N([].slice.call(arguments))}m(R,"resolver"),M(T,I,R,{once:!0}),I!=="error"&&O(T,q,{once:!0})})}m(P,"once");function O(T,I,N){typeof T.on=="function"&&M(T,"error",I,N)}m(O,"addErrorHandlerIfEventEmitter");function M(T,I,N,_){if(typeof T.on=="function")_.once?T.once(I,N):T.on(I,N);else if(typeof T.addEventListener=="function")T.addEventListener(I,m(function q(R){_.once&&T.removeEventListener(I,q),N(R)},"wrapListener"));else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof T)}m(M,"eventTargetAgnosticAddListener")}),Bh={};Ne(Bh,{Socket:()=>gt,isIP:()=>Oh});function Oh(s){return 0}var Ps,gr,ut,gt,St=Ee(()=>{V(),Ps=He(Je(),1),m(Oh,"isIP"),gr=/^[^.]+\./,ut=class K extends Ps.EventEmitter{constructor(){super(...arguments),Y(this,"opts",{}),Y(this,"connecting",!1),Y(this,"pending",!0),Y(this,"writable",!0),Y(this,"encrypted",!1),Y(this,"authorized",!1),Y(this,"destroyed",!1),Y(this,"ws",null),Y(this,"writeBuffer"),Y(this,"tlsState",0),Y(this,"tlsRead"),Y(this,"tlsWrite")}static get poolQueryViaFetch(){return K.opts.poolQueryViaFetch??K.defaults.poolQueryViaFetch}static set poolQueryViaFetch(e){K.opts.poolQueryViaFetch=e}static get fetchEndpoint(){return K.opts.fetchEndpoint??K.defaults.fetchEndpoint}static set fetchEndpoint(e){K.opts.fetchEndpoint=e}static get fetchConnectionCache(){return!0}static set fetchConnectionCache(e){console.warn("The `fetchConnectionCache` option is deprecated (now always `true`)")}static get fetchFunction(){return K.opts.fetchFunction??K.defaults.fetchFunction}static set fetchFunction(e){K.opts.fetchFunction=e}static get webSocketConstructor(){return K.opts.webSocketConstructor??K.defaults.webSocketConstructor}static set webSocketConstructor(e){K.opts.webSocketConstructor=e}get webSocketConstructor(){return this.opts.webSocketConstructor??K.webSocketConstructor}set webSocketConstructor(e){this.opts.webSocketConstructor=e}static get wsProxy(){return K.opts.wsProxy??K.defaults.wsProxy}static set wsProxy(e){K.opts.wsProxy=e}get wsProxy(){return this.opts.wsProxy??K.wsProxy}set wsProxy(e){this.opts.wsProxy=e}static get coalesceWrites(){return K.opts.coalesceWrites??K.defaults.coalesceWrites}static set coalesceWrites(e){K.opts.coalesceWrites=e}get coalesceWrites(){return this.opts.coalesceWrites??K.coalesceWrites}set coalesceWrites(e){this.opts.coalesceWrites=e}
8static get useSecureWebSocket(){return K.opts.useSecureWebSocket??K.defaults.useSecureWebSocket}static set useSecureWebSocket(e){K.opts.useSecureWebSocket=e}get useSecureWebSocket(){return this.opts.useSecureWebSocket??K.useSecureWebSocket}set useSecureWebSocket(e){this.opts.useSecureWebSocket=e}static get forceDisablePgSSL(){return K.opts.forceDisablePgSSL??K.defaults.forceDisablePgSSL}static set forceDisablePgSSL(e){K.opts.forceDisablePgSSL=e}get forceDisablePgSSL(){return this.opts.forceDisablePgSSL??K.forceDisablePgSSL}set forceDisablePgSSL(e){this.opts.forceDisablePgSSL=e}static get disableSNI(){return K.opts.disableSNI??K.defaults.disableSNI}static set disableSNI(e){K.opts.disableSNI=e}get disableSNI(){return this.opts.disableSNI??K.disableSNI}set disableSNI(e){this.opts.disableSNI=e}static get disableWarningInBrowsers(){return K.opts.disableWarningInBrowsers??K.defaults.disableWarningInBrowsers}static set disableWarningInBrowsers(e){K.opts.disableWarningInBrowsers=e}get disableWarningInBrowsers(){return this.opts.disableWarningInBrowsers??K.disableWarningInBrowsers}set disableWarningInBrowsers(e){this.opts.disableWarningInBrowsers=e}static get pipelineConnect(){return K.opts.pipelineConnect??K.defaults.pipelineConnect}static set pipelineConnect(e){K.opts.pipelineConnect=e}get pipelineConnect(){return this.opts.pipelineConnect??K.pipelineConnect}set pipelineConnect(e){this.opts.pipelineConnect=e}static get subtls(){return K.opts.subtls??K.defaults.subtls}static set subtls(e){K.opts.subtls=e}get subtls(){return this.opts.subtls??K.subtls}set subtls(e){this.opts.subtls=e}static get pipelineTLS(){return K.opts.pipelineTLS??K.defaults.pipelineTLS}static set pipelineTLS(e){K.opts.pipelineTLS=e}get pipelineTLS(){return this.opts.pipelineTLS??K.pipelineTLS}set pipelineTLS(e){this.opts.pipelineTLS=e}static get rootCerts(){return K.opts.rootCerts??K.defaults.rootCerts}static set rootCerts(e){K.opts.rootCerts=e}get rootCerts(){return this.opts.rootCerts??K.rootCerts}set rootCerts(e){this.opts.rootCerts=e}wsProxyAddrForHost(e,t){let r=this.wsProxy;if(r===void 0)throw new 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 typeof r=="function"?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 n=m(()=>{this.connecting=!1,this.pending=!1,this.emit("connect"),this.emit("ready")},"handleWebSocketOpen"),i=m((a,f=!1)=>{a.binaryType="arraybuffer",a.addEventListener("error",y=>{this.emit("error",y),this.emit("close")}),a.addEventListener("message",y=>{if(this.tlsState===0){let d=G.from(y.data);this.emit("data",d)}}),a.addEventListener("close",()=>{this.emit("close")}),f?n():a.addEventListener("open",n)},"configureWebSocket"),u;try{u=this.wsProxyAddrForHost(t,typeof e=="string"?parseInt(e,10):e)}catch(a){this.emit("error",a),this.emit("close");return}try{let a=(this.useSecureWebSocket?"wss:":"ws:")+"//"+u;if(this.webSocketConstructor!==void 0)this.ws=new this.webSocketConstructor(a),i(this.ws);else try{this.ws=new WebSocket(a),i(this.ws)}catch{this.ws=new __unstable_WebSocket(a),i(this.ws)}}catch(a){let f=(this.useSecureWebSocket?"https:":"http:")+"//"+u;fetch(f,{headers:{Upgrade:"websocket"}}).then(y=>{if(this.ws=y.webSocket,this.ws==null)throw a;this.ws.accept(),i(this.ws,!0)}).catch(y=>{this.emit("error",new Error(`All attempts to open a WebSocket to connect to the database failed. Please refer to https://github.com/neondatabase/serverless/blob/main/CONFIG.md#websocketconstructor-typeof-websocket--undefined. Details: ${y}`)),this.emit("close")})}}async startTls(e){if(this.subtls===void 0)throw new 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),n=r.read.bind(r),i=this.rawWrite.bind(this),{read:u,write:a}=await this.subtls.startTls(e,t,n,i,{useSNI:!this.disableSNI,expectPreData:this.pipelineTLS?new Uint8Array([83]):void 0});this.tlsRead=u,this.tlsWrite=a,this.tlsState=2,this.encrypted=!0,this.authorized=!0,this.emit
8("secureConnection",this),this.tlsReadLoop()}async tlsReadLoop(){for(;;){let e=await this.tlsRead();if(e===void 0)break;{let t=G.from(e);this.emit("data",t)}}}rawWrite(e){if(!this.coalesceWrites){this.ws&&this.ws.send(e);return}if(this.writeBuffer===void 0)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=n=>{}){return e.length===0?(r(),!0):(typeof e=="string"&&(e=G.from(e,t)),this.tlsState===0?(this.rawWrite(e),r()):this.tlsState===1?this.once("secureConnection",()=>{this.write(e,t,r)}):(this.tlsWrite(e),r()),!0)}end(e=G.alloc(0),t="utf8",r=()=>{}){return this.write(e,t,()=>{this.ws.close(),r()}),this}destroy(){return this.destroyed=!0,this.end()}},m(ut,"Socket"),Y(ut,"defaults",{poolQueryViaFetch:!1,fetchEndpoint:m((s,e,t)=>{let r;return t!=null&&t.jwtAuth?r=s.replace(gr,"apiauth."):r=s.replace(gr,"api."),"https://"+r+"/sql"},"fetchEndpoint"),fetchConnectionCache:!0,fetchFunction:void 0,webSocketConstructor:void 0,wsProxy:m(s=>s+"/v2","wsProxy"),useSecureWebSocket:!0,forceDisablePgSSL:!0,coalesceWrites:!0,pipelineConnect:"password",subtls:void 0,rootCerts:"",pipelineTLS:!1,disableSNI:!1,disableWarningInBrowsers:!1}),Y(ut,"opts",{}),gt=ut}),Rh={};Ne(Rh,{parse:()=>rs});function rs(s,e=!1){let{protocol:t}=new URL(s),r="http:"+s.substring(t.length),{username:n,password:i,host:u,hostname:a,port:f,pathname:y,search:d,searchParams:S,hash:w}=new URL(r);i=decodeURIComponent(i),n=decodeURIComponent(n),y=decodeURIComponent(y);let v=n+":"+i,c=e?Object.fromEntries(S.entries()):d;return{href:s,protocol:t,auth:v,username:n,password:i,host:u,hostname:a,port:f,pathname:y,search:d,query:c,hash:w}}var Mh=Ee(()=>{V(),m(rs,"parse")}),Dh=te(s=>{V(),s.parse=function(n,i){return new t(n,i).parse()};var e=class qh{constructor(i,u){this.source=i,this.transform=u||r,this.position=0,this.entries=[],this.recorded=[],this.dimension=0}isEof(){return this.position>=this.source.length}nextCharacter(){var i=this.source[this.position++];return i==="\\"?{value:this.source[this.position++],escaped:!0}:{value:i,escaped:!1}}record(i){this.recorded.push(i)}newEntry(i){var u;(this.recorded.length>0||i)&&(u=this.recorded.join(""),u==="NULL"&&!i&&(u=null),u!==null&&(u=this.transform(u)),this.entries.push(u),this.recorded=[])}consumeDimensions(){if(this.source[0]==="[")for(;!this.isEof();){var i=this.nextCharacter();if(i.value==="=")break}}parse(i){var u,a,f;for(this.consumeDimensions();!this.isEof();)if(u=this.nextCharacter(),u.value==="{"&&!f)this.dimension++,this.dimension>1&&(a=new qh(this.source.substr(this.position-1),this.transform),this.entries.push(a.parse(!0)),this.position+=a.position-2);else if(u.value==="}"&&!f){if(this.dimension--,!this.dimension&&(this.newEntry(),i))return this.entries}else u.value==='"'&&!u.escaped?(f&&this.newEntry(!0),f=!f):u.value===","&&!f?this.newEntry():this.record(u.value);if(this.dimension!==0)throw new Error("array dimension not balanced");return this.entries}};m(e,"ArrayParser");var t=e;function r(n){return n}m(r,"identity")}),$h=te((s,e)=>{V();var t=Dh();e.exports={create:m(function(r,n){return{parse:m(function(){return t.parse(r,n)},"parse")}},"create")}}),Tp=te((s,e)=>{V();var t=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/,r=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,n=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,i=/^-?infinity$/;e.exports=m(function(d){if(i.test(d))return Number(d.replace("i","I"));var S=t.exec(d);if(!S)return u(d)||null;var w=!!S[8],v=parseInt(S[1],10);w&&(v=f(v));var c=parseInt(S[2],10)-1,h=S[3],b=parseInt(S[4],10),E=parseInt(S[5],10),C=parseInt(S[6],10),P=S[7];P=P?1e3*parseFloat(P):0;var O,M=a(d);return M!=null?(O=new Date(Date.UTC(v,c,h,b,E,C,P)),y(v)&&O.setUTCFullYear(v),M!==0&&O.setTime(O.getTime()-M)):(O=new Date(v,c,h,b,E,C,P),y(v)&&O.setFullYear(v)),O},"parseDate");function u(d){var S=r.exec(d);if(S){var w=parseInt(S[1],10),v=!!S[4];v&&(w=f(w));var c=parseInt(S[2],10)-1,h=S[3],b=new Date(w,c,h);return y(w)&&b.setFullYear(w),b}}m(u,"getDate");
8function a(d){if(d.endsWith("+00"))return 0;var S=n.exec(d.split(" ")[1]);if(S){var w=S[1];if(w==="Z")return 0;var v=w==="-"?-1:1,c=parseInt(S[2],10)*3600+parseInt(S[3]||0,10)*60+parseInt(S[4]||0,10);return c*v*1e3}}m(a,"timeZoneOffset");function f(d){return-(d-1)}m(f,"bcYearToNegativeYear");function y(d){return d>=0&&d<100}m(y,"is0To99")}),_p=te((s,e)=>{V(),e.exports=r;var t=Object.prototype.hasOwnProperty;function r(n){for(var i=1;i<arguments.length;i++){var u=arguments[i];for(var a in u)t.call(u,a)&&(n[a]=u[a])}return n}m(r,"extend")}),Cp=te((s,e)=>{V();var t=_p();e.exports=r;function r(C){if(!(this instanceof r))return new r(C);t(this,E(C))}m(r,"PostgresInterval");var n=["seconds","minutes","hours","days","months","years"];r.prototype.toPostgres=function(){var C=n.filter(this.hasOwnProperty,this);return this.milliseconds&&C.indexOf("seconds")<0&&C.push("seconds"),C.length===0?"0":C.map(function(P){var O=this[P]||0;return P==="seconds"&&this.milliseconds&&(O=(O+this.milliseconds/1e3).toFixed(6).replace(/\.?0+$/,"")),O+" "+P},this).join(" ")};var i={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"S"},u=["years","months","days"],a=["hours","minutes","seconds"];r.prototype.toISOString=r.prototype.toISO=function(){var C=u.map(O,this).join(""),P=a.map(O,this).join("");return"P"+C+"T"+P;function O(M){var T=this[M]||0;return M==="seconds"&&this.milliseconds&&(T=(T+this.milliseconds/1e3).toFixed(6).replace(/0+$/,"")),T+i[M]}};var f="([+-]?\\d+)",y=f+"\\s+years?",d=f+"\\s+mons?",S=f+"\\s+days?",w="([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?",v=new RegExp([y,d,S,w].map(function(C){return"("+C+")?"}).join("\\s*")),c={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12},h=["hours","minutes","seconds","milliseconds"];function b(C){var P=C+"000000".slice(C.length);return parseInt(P,10)/1e3}m(b,"parseMilliseconds");function E(C){if(!C)return{};var P=v.exec(C),O=P[8]==="-";return Object.keys(c).reduce(function(M,T){var I=c[T],N=P[I];return!N||(N=T==="milliseconds"?b(N):parseInt(N,10),!N)||(O&&~h.indexOf(T)&&(N*=-1),M[T]=N),M},{})}m(E,"parse")}),Pp=te((s,e)=>{V(),e.exports=m(function(t){if(/^\\x/.test(t))return new G(t.substr(2),"hex");for(var r="",n=0;n<t.length;)if(t[n]!=="\\")r+=t[n],++n;else if(/[0-7]{3}/.test(t.substr(n+1,3)))r+=String.fromCharCode(parseInt(t.substr(n+1,3),8)),n+=4;else{for(var i=1;n+i<t.length&&t[n+i]==="\\";)i++;for(var u=0;u<Math.floor(i/2);++u)r+="\\";n+=Math.floor(i/2)*2}return new G(r,"binary")},"parseBytea")}),Ap=te((s,e)=>{V();var t=Dh(),r=$h(),n=Tp(),i=Cp(),u=Pp();function a(_){return m(function(q){return q===null?q:_(q)},"nullAllowed")}m(a,"allowNull");function f(_){return _===null?_:_==="TRUE"||_==="t"||_==="true"||_==="y"||_==="yes"||_==="on"||_==="1"}m(f,"parseBool");function y(_){return _?t.parse(_,f):null}m(y,"parseBoolArray");function d(_){return parseInt(_,10)}m(d,"parseBaseTenInt");function S(_){return _?t.parse(_,a(d)):null}m(S,"parseIntegerArray");function w(_){return _?t.parse(_,a(function(q){return O(q).trim()})):null}m(w,"parseBigIntegerArray");var v=m(function(_){if(!_)return null;var q=r.create(_,function(R){return R!==null&&(R=T(R)),R});return q.parse()},"parsePointArray"),c=m(function(_){if(!_)return null;var q=r.create(_,function(R){return R!==null&&(R=parseFloat(R)),R});return q.parse()},"parseFloatArray"),h=m(function(_){if(!_)return null;var q=r.create(_);return q.parse()},"parseStringArray"),b=m(function(_){if(!_)return null;var q=r.create(_,function(R){return R!==null&&(R=n(R)),R});return q.parse()},"parseDateArray"),E=m(function(_){if(!_)return null;var q=r.create(_,function(R){return R!==null&&(R=i(R)),R});return q.parse()},"parseIntervalArray"),C=m(function(_){return _?t.parse(_,a(u)):null},"parseByteAArray"),P=m(function(_){return parseInt(_,10)},"parseInteger"),O=m(function(_){var q=String(_);return/^\d+$/.test(q)?q:_},"parseBigInteger"),M=m(function(_){return _?t.parse(_,a(JSON.parse)):null},"parseJsonArray"),T=m(function(_){return _[0]!=="("?null:(_=_.substring(1,_.length-1).split(","),{x:parseFloat(_[0]),y:parseFloat(_[1])})},"parsePoint"),I=m(function(_){if(_[0]!=="<"&&_[1]!=="(")return null;for(var q="(",R="",U=!1,z=2;z<_.length-1;z++){if(U||(q+=_[z]),_[z]===")"){U=!0;continue}else if(!U)continue;_[z]!==","&&(R+=_[z])}var D=T(q);return D.radius=parseFloat(R),D},"parseCircle"),N=m(function(_){_(20,O),_(21,P),_(23,P),_(26,P),_(700,parseFloat),_(701,parseFloat),_(16,f),_(1082,n),_(1114,n),_(1184,n),_(600,T),_(651,h),_(718,I),_(1e3,y),_(1001,C),_(1005,S),_(1007,S),_(1028,S),_(1016,w),_(1017,v),_(1021,c),_(1022,c),_(1231,c),_(1014,h),_(1015,h),_(1008,h),_(1009,h),_(1040,h),_(1041,h),_(1115,b),_(1182,b),_(1185,b),_(1186,i),_(1187,E),_(17,u),_(114,JSON.parse.bind(JSON)),_(3802,JSON.parse.bind(JSON)),_(199,M),_(3807,M),_(3907,h),_(2951,h),_(791,h),_(1183,h),_(1270,h)},"init");e.exports={init:N}}),xp=te((s,e)=>{V();var t=1e6;function r(n){var i=n.readInt32BE(0),u=n.readUInt32BE(4),a="";i<0&&(i=~i+(u===0),u=~u+1>>>0,a="-");var f="",y,d,S,w,v,c;{if(y=i%t,i=i/t>>>0,d=4294967296*y+u,u=d/t>>>0,S=""+(d-t*u),u===0&&i===0)return a+S+f;for(w="",v=6-S.length,c=0;c<v;c++)w+="0";f=w+S+f}{if(y=i%t,i=i/t>>>0,d=4294967296*y+u,u=d/t>>>0,S=""+(d-t*u),u===0&&i===0)return a+S+f;for(w="",v=6-S.length,c=0;c<v;c++)w+="0";f=w+S+f}{if(y=i%t,i=i/t>>>0,d=4294967296*y+u,u=d/t>>>0,S=""+(d-t*u),u===0&&i===0)return a+S+f;for(w="",v=6-S.length,c=0;c<v;c++)w+="0";f=w+S+f}return y=i%t,d=4294967296*y+u,S=""+d%t,a+S+f}m(r,"readInt8"),e.exports=r}),Np=te((s,e)=>{V();var t=xp(),r=m(function(h,b,E,C,P){E=E||0,C=C||!1,P=P||function(U,z,D){return U*Math.pow(2,D)+z};var O=E>>3,M=m(function(U){return C?~U&255:U},"inv"),T=255,I=8-E%8;b<I&&(T=255<<8-b&255,I=b),E&&(T=T>>E%8);var N=0;E%8+b>=8&&(N=P(0,M(h[O])&T,I));for(var _=b+E>>3,q=O+1;q<_;q++)N=P(N,M(h[q]),8);var R=(b+E)%8;return R>0&&(N=P(N,M(h[_])>>8-R,R)),N},"parseBits"),n=m(function(h,b,E){var C=Math.pow(2,E-1)-1,P=r(h,1),O=r(h,E,1);if(O===0)return 0;var M=1,T=m(function(N,_,q){N===0&&(N=1);for(var R=1;R<=q;R++)M/=2,(_&1<<q-R)>0&&(N+=M);return N},"parsePrecisionBits"),I=r(h,b,E+1,!1,T);return O==Math.pow(2,E+1)-1?I===0?P===0?1/0:-1/0:NaN:(P===0?1:-1)*Math.pow(2,O-C)*I},"parseFloatFromBits"),i=m(function(h){return r(h,1)==1?-1*(r(h,15,1,!0)+1):r(h,15,1)},"parseInt16"),u=m(function(h){return r(h,1)==1?-1*(r(h,31,1,!0)+1):r(h,31,1)},"parseInt32"),a=m(function(h){return n(h,23,8)},"parseFloat32"),f=m(function(h){return n(h,52,11)},"parseFloat64"),y=m(function(h){var b=r(h,16,32);
8if(b==49152)return NaN;for(var E=Math.pow(1e4,r(h,16,16)),C=0,P=[],O=r(h,16),M=0;M<O;M++)C+=r(h,16,64+16*M)*E,E/=1e4;var T=Math.pow(10,r(h,16,48));return(b===0?1:-1)*Math.round(C*T)/T},"parseNumeric"),d=m(function(h,b){var E=r(b,1),C=r(b,63,1),P=new Date((E===0?1:-1)*C/1e3+9466848e5);return h||P.setTime(P.getTime()+P.getTimezoneOffset()*6e4),P.usec=C%1e3,P.getMicroSeconds=function(){return this.usec},P.setMicroSeconds=function(O){this.usec=O},P.getUTCMicroSeconds=function(){return this.usec},P},"parseDate"),S=m(function(h){for(var b=r(h,32),E=r(h,32,32),C=r(h,32,64),P=96,O=[],M=0;M<b;M++)O[M]=r(h,32,P),P+=32,P+=32;var T=m(function(N){var _=r(h,32,P);if(P+=32,_==4294967295)return null;var q;if(N==23||N==20)return q=r(h,_*8,P),P+=_*8,q;if(N==25)return q=h.toString(this.encoding,P>>3,(P+=_<<3)>>3),q;console.log("ERROR: ElementType not implemented: "+N)},"parseElement"),I=m(function(N,_){var q=[],R;if(N.length>1){var U=N.shift();for(R=0;R<U;R++)q[R]=I(N,_);N.unshift(U)}else for(R=0;R<N[0];R++)q[R]=T(_);return q},"parse");return I(O,C)},"parseArray"),w=m(function(h){return h.toString("utf8")},"parseText"),v=m(function(h){return h===null?null:r(h,8)>0},"parseBool"),c=m(function(h){h(20,t),h(21,i),h(23,u),h(26,u),h(1700,y),h(700,a),h(701,f),h(16,v),h(1114,d.bind(null,!1)),h(1184,d.bind(null,!0)),h(1e3,S),h(1007,S),h(1016,S),h(1008,S),h(1009,S),h(25,w)},"init");e.exports={init:c}}),Ip=te((s,e)=>{V(),e.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}}),er=te(s=>{V();var e=Ap(),t=Np(),r=$h(),n=Ip();s.getTypeParser=a,s.setTypeParser=f,s.arrayParser=r,s.builtins=n;var i={text:{},binary:{}};function u(y){return String(y)}m(u,"noParse");function a(y,d){return d=d||"text",i[d]&&i[d][y]||u}m(a,"getTypeParser");function f(y,d,S){typeof d=="function"&&(S=d,d="text"),i[d][y]=S}m(f,"setTypeParser"),e.init(function(y,d){i.text[y]=d}),t.init(function(y,d){i.binary[y]=d})}),ss=te((s,e)=>{V();var t=er();function r(n){this._types=n||t,this.text={},this.binary={}}m(r,"TypeOverrides"),r.prototype.getOverrides=function(n){switch(n){case"text":return this.text;case"binary":return this.binary;default:return{}}},r.prototype.setTypeParser=function(n,i,u){typeof i=="function"&&(u=i,i="text"),this.getOverrides(i)[n]=u},r.prototype.getTypeParser=function(n,i){return i=i||"text",this.getOverrides(i)[n]||this._types.getTypeParser(n,i)},e.exports=r});function ht(s){let e=1779033703,t=3144134277,r=1013904242,n=2773480762,i=1359893119,u=2600822924,a=528734635,f=1541459225,y=0,d=0,S=[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,2756734187,3204031479,3329325298],w=m((C,P)=>C>>>P|C<<32-P,"rrot"),v=new Uint32Array(64),c=new Uint8Array(64),h=m(()=>{for(let q=0,R=0;q<16;q++,R+=4)v[q]=c[R]<<24|c[R+1]<<16|c[R+2]<<8|c[R+3];for(let q=16;q<64;q++){let R=w(v[q-15],7)^w(v[q-15],18)^v[q-15]>>>3,U=w(v[q-2],17)^w(v[q-2],19)^v[q-2]>>>10;v[q]=v[q-16]+R+v[q-7]+U|0}let C=e,P=t,O=r,M=n,T=i,I=u,N=a,_=f;for(let q=0;q<64;q++){let R=w(T,6)^w(T,11)^w(T,25),U=T&I^~T&N,z=_+R+U+S[q]+v[q]|0,D=w(C,2)^w(C,13)^w(C,22),F=C&P^C&O^P&O,H=D+F|0;_=N,N=I,I=T,T=M+z|0,M=O,O=P,P=C,C=z+H|0}e=e+C|0,t=t+P|0,r=r+O|0,n=n+M|0,i=i+T|0,u=u+I|0,a=a+N|0,f=f+_|0,d=0},"process"),b=m(C=>{typeof C=="string"&&(C=new TextEncoder().encode(C));for(let P=0;P<C.length;P++)c[d++]=C[P],d===64&&h();y+=C.length},"add"),E=m(()=>{if(c[d++]=128,d==64&&h(),d+8>64){for(;d<64;)c[d++]=0;h()}for(;
8d<58;)c[d++]=0;let C=y*8;c[d++]=C/1099511627776&255,c[d++]=C/4294967296&255,c[d++]=C>>>24,c[d++]=C>>>16&255,c[d++]=C>>>8&255,c[d++]=C&255,h();let P=new Uint8Array(32);return P[0]=e>>>24,P[1]=e>>>16&255,P[2]=e>>>8&255,P[3]=e&255,P[4]=t>>>24,P[5]=t>>>16&255,P[6]=t>>>8&255,P[7]=t&255,P[8]=r>>>24,P[9]=r>>>16&255,P[10]=r>>>8&255,P[11]=r&255,P[12]=n>>>24,P[13]=n>>>16&255,P[14]=n>>>8&255,P[15]=n&255,P[16]=i>>>24,P[17]=i>>>16&255,P[18]=i>>>8&255,P[19]=i&255,P[20]=u>>>24,P[21]=u>>>16&255,P[22]=u>>>8&255,P[23]=u&255,P[24]=a>>>24,P[25]=a>>>16&255,P[26]=a>>>8&255,P[27]=a&255,P[28]=f>>>24,P[29]=f>>>16&255,P[30]=f>>>8&255,P[31]=f&255,P},"digest");return s===void 0?{add:b,digest:E}:(b(s),E())}var Lp=Ee(()=>{V(),m(ht,"sha256")}),Be,Ir,Bp=Ee(()=>{V(),Be=class Ae{constructor(){Y(this,"_dataLength",0),Y(this,"_bufferLength",0),Y(this,"_state",new Int32Array(4)),Y(this,"_buffer",new ArrayBuffer(68)),Y(this,"_buffer8"),Y(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(e){let t=Ae.hexChars,r=Ae.hexOut,n,i,u,a;for(a=0;a<4;a+=1)for(i=a*8,n=e[a],u=0;u<8;u+=2)r[i+1+u]=t.charAt(n&15),n>>>=4,r[i+0+u]=t.charAt(n&15),n>>>=4;return r.join("")}static _md5cycle(e,t){let r=e[0],n=e[1],i=e[2],u=e[3];r+=(n&i|~n&u)+t[0]-680876936|0,r=(r<<7|r>>>25)+n|0,u+=(r&n|~r&i)+t[1]-389564586|0,u=(u<<12|u>>>20)+r|0,i+=(u&r|~u&n)+t[2]+606105819|0,i=(i<<17|i>>>15)+u|0,n+=(i&u|~i&r)+t[3]-1044525330|0,n=(n<<22|n>>>10)+i|0,r+=(n&i|~n&u)+t[4]-176418897|0,r=(r<<7|r>>>25)+n|0,u+=(r&n|~r&i)+t[5]+1200080426|0,u=(u<<12|u>>>20)+r|0,i+=(u&r|~u&n)+t[6]-1473231341|0,i=(i<<17|i>>>15)+u|0,n+=(i&u|~i&r)+t[7]-45705983|0,n=(n<<22|n>>>10)+i|0,r+=(n&i|~n&u)+t[8]+1770035416|0,r=(r<<7|r>>>25)+n|0,u+=(r&n|~r&i)+t[9]-1958414417|0,u=(u<<12|u>>>20)+r|0,i+=(u&r|~u&n)+t[10]-42063|0,i=(i<<17|i>>>15)+u|0,n+=(i&u|~i&r)+t[11]-1990404162|0,n=(n<<22|n>>>10)+i|0,r+=(n&i|~n&u)+t[12]+1804603682|0,r=(r<<7|r>>>25)+n|0,u+=(r&n|~r&i)+t[13]-40341101|0,u=(u<<12|u>>>20)+r|0,i+=(u&r|~u&n)+t[14]-1502002290|0,i=(i<<17|i>>>15)+u|0,n+=(i&u|~i&r)+t[15]+1236535329|0,n=(n<<22|n>>>10)+i|0,r+=(n&u|i&~u)+t[1]-165796510|0,r=(r<<5|r>>>27)+n|0,u+=(r&i|n&~i)+t[6]-1069501632|0,u=(u<<9|u>>>23)+r|0,i+=(u&n|r&~n)+t[11]+643717713|0,i=(i<<14|i>>>18)+u|0,n+=(i&r|u&~r)+t[0]-373897302|0,n=(n<<20|n>>>12)+i|0,r+=(n&u|i&~u)+t[5]-701558691|0,r=(r<<5|r>>>27)+n|0,u+=(r&i|n&~i)+t[10]+38016083|0,u=(u<<9|u>>>23)+r|0,i+=(u&n|r&~n)+t[15]-660478335|0,i=(i<<14|i>>>18)+u|0,n+=(i&r|u&~r)+t[4]-405537848|0,n=(n<<20|n>>>12)+i|0,r+=(n&u|i&~u)+t[9]+568446438|0,r=(r<<5|r>>>27)+n|0,u+=(r&i|n&~i)+t[14]-1019803690|0,u=(u<<9|u>>>23)+r|0,i+=(u&n|r&~n)+t[3]-187363961|0,i=(i<<14|i>>>18)+u|0,n+=(i&r|u&~r)+t[8]+1163531501|0,n=(n<<20|n>>>12)+i|0,r+=(n&u|i&~u)+t[13]-1444681467|0,r=(r<<5|r>>>27)+n|0,u+=(r&i|n&~i)+t[2]-51403784|0,u=(u<<9|u>>>23)+r|0,i+=(u&n|r&~n)+t[7]+1735328473|0,i=(i<<14|i>>>18)+u|0,n+=(i&r|u&~r)+t[12]-1926607734|0,n=(n<<20|n>>>12)+i|0,r+=(n^i^u)+t[5]-378558|0,r=(r<<4|r>>>28)+n|0,u+=(r^n^i)+t[8]-2022574463|0,u=(u<<11|u>>>21)+r|0,i+=(u^r^n)+t[11]+1839030562|0,i=(i<<16|i>>>16)+u|0,n+=(i^u^r)+t[14]-35309556|0,n=(n<<23|n>>>9)+i|0,r+=(n^i^u)+t[1]-1530992060|0,r=(r<<4|r>>>28)+n|0,u+=(r^n^i)+t[4]+1272893353|0,u=(u<<11|u>>>21)+r|0,i+=(u^r^n)+t[7]-155497632|0,i=(i<<16|i>>>16)+u|0,n+=(i^u^r)+t[10]-1094730640|0,n=(n<<23|n>>>9)+i|0,r+=(n^i^u)+t[13]+681279174|0,r=(r<<4|r>>>28)+n|0,u+=(r^n^i)+t[0]-358537222|0,u=(u<<11|u>>>21)+r|0,i+=(u^r^n)+t[3]-722521979|0,i=(i<<16|i>>>16)+u|0,n+=(i^u^r)+t[6]+76029189|0,n=(n<<23|n>>>9)+i|0,r+=(n^i^u)+t[9]-640364487|0,r=(r<<4|r>>>28)+n|0,u+=(r^n^i)+t[12]-421815835|0,u=(u<<11|u>>>21)+r|0,i+=(u^r^n)+t[15]+530742520|0,i=(i<<16|i>>>16)+u|0,n+=(i^u^r)+t[2]-995338651|0,n=(n<<23|n>>>9)+i|0,r+=(i^(n|~u))+t[0]-198630844|0,r=(r<<6|r>>>26)+n|0,u+=(n^(r|~i))+t[7]+1126891415|0,u=(u<<10|u>>>22)+r|0,i+=(r^(u|~n))+t[14]-1416354905|0,i=(i<<15|i>>>17)+u|0,n+=(u^(i|~r))+t[5]-57434055|0,n=(n<<21|n>>>11)+i|0,r+=(i^(n|~u))+t[12]+1700485571|0,r=(r<<6|r>>>26)+n|0,u+=(n^(r|~i))+t[3]-1894986606|0,u=(u<<10|u>>>
822)+r|0,i+=(r^(u|~n))+t[10]-1051523|0,i=(i<<15|i>>>17)+u|0,n+=(u^(i|~r))+t[1]-2054922799|0,n=(n<<21|n>>>11)+i|0,r+=(i^(n|~u))+t[8]+1873313359|0,r=(r<<6|r>>>26)+n|0,u+=(n^(r|~i))+t[15]-30611744|0,u=(u<<10|u>>>22)+r|0,i+=(r^(u|~n))+t[6]-1560198380|0,i=(i<<15|i>>>17)+u|0,n+=(u^(i|~r))+t[13]+1309151649|0,n=(n<<21|n>>>11)+i|0,r+=(i^(n|~u))+t[4]-145523070|0,r=(r<<6|r>>>26)+n|0,u+=(n^(r|~i))+t[11]-1120210379|0,u=(u<<10|u>>>22)+r|0,i+=(r^(u|~n))+t[2]+718787259|0,i=(i<<15|i>>>17)+u|0,n+=(u^(i|~r))+t[9]-343485551|0,n=(n<<21|n>>>11)+i|0,e[0]=r+e[0]|0,e[1]=n+e[1]|0,e[2]=i+e[2]|0,e[3]=u+e[3]|0}start(){return this._dataLength=0,this._bufferLength=0,this._state.set(Ae.stateIdentity),this}appendStr(e){let t=this._buffer8,r=this._buffer32,n=this._bufferLength,i,u;for(u=0;u<e.length;u+=1){if(i=e.charCodeAt(u),i<128)t[n++]=i;else if(i<2048)t[n++]=(i>>>6)+192,t[n++]=i&63|128;else if(i<55296||i>56319)t[n++]=(i>>>12)+224,t[n++]=i>>>6&63|128,t[n++]=i&63|128;else{if(i=(i-55296)*1024+(e.charCodeAt(++u)-56320)+65536,i>1114111)throw new Error("Unicode standard supports code points up to U+10FFFF");t[n++]=(i>>>18)+240,t[n++]=i>>>12&63|128,t[n++]=i>>>6&63|128,t[n++]=i&63|128}n>=64&&(this._dataLength+=64,Ae._md5cycle(this._state,r),n-=64,r[0]=r[16])}return this._bufferLength=n,this}appendAsciiStr(e){let t=this._buffer8,r=this._buffer32,n=this._bufferLength,i,u=0;for(;;){for(i=Math.min(e.length-u,64-n);i--;)t[n++]=e.charCodeAt(u++);if(n<64)break;this._dataLength+=64,Ae._md5cycle(this._state,r),n=0}return this._bufferLength=n,this}appendByteArray(e){let t=this._buffer8,r=this._buffer32,n=this._bufferLength,i,u=0;for(;;){for(i=Math.min(e.length-u,64-n);i--;)t[n++]=e[u++];if(n<64)break;this._dataLength+=64,Ae._md5cycle(this._state,r),n=0}return this._bufferLength=n,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,n=this._state,i;for(this._dataLength=e.length,this._bufferLength=e.buflen,n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],i=0;i<t.length;i+=1)this._buffer8[i]=t.charCodeAt(i)}end(e=!1){let t=this._bufferLength,r=this._buffer8,n=this._buffer32,i=(t>>2)+1;this._dataLength+=t;let u=this._dataLength*8;if(r[t]=128,r[t+1]=r[t+2]=r[t+3]=0,n.set(Ae.buffer32Identity.subarray(i),i),t>55&&(Ae._md5cycle(this._state,n),n.set(Ae.buffer32Identity)),u<=4294967295)n[14]=u;else{let a=u.toString(16).match(/(.*?)(.{0,8})$/);if(a===null)return;let f=parseInt(a[2],16),y=parseInt(a[1],16)||0;n[14]=f,n[15]=y}return Ae._md5cycle(this._state,n),e?this._state:Ae._hex(this._state)}},m(Be,"Md5"),Y(Be,"stateIdentity",new Int32Array([1732584193,-271733879,-1732584194,271733878])),Y(Be,"buffer32Identity",new Int32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])),Y(Be,"hexChars","0123456789abcdef"),Y(Be,"hexOut",[]),Y(Be,"onePassHasher",new Be),Ir=Be}),ns={};Ne(ns,{createHash:()=>kh,createHmac:()=>Fh,randomBytes:()=>Qh});function Qh(s){return crypto.getRandomValues(G.alloc(s))}function kh(s){if(s==="sha256")return{update:m(function(e){return{digest:m(function(){return G.from(ht(e))},"digest")}},"update")};if(s==="md5")return{update:m(function(e){return{digest:m(function(){return typeof e=="string"?Ir.hashStr(e):Ir.hashByteArray(e)},"digest")}},"update")};throw new Error(`Hash type '${s}' not supported`)}function Fh(s,e){if(s!=="sha256")throw new Error(`Only sha256 is supported (requested: '${s}')`);return{update:m(function(t){return{digest:m(function(){typeof e=="string"&&(e=new TextEncoder().encode(e)),typeof t=="string"&&(t=new TextEncoder().encode(t));let r=e.length;if(r>64)e=ht(e);else if(r<64){let f=new Uint8Array(64);f.set(e),e=f}let n=new Uint8Array(64),i=new Uint8Array(64);for(let f=0;f<64;f++)n[f]=54^e[f],i[f]=92^e[f];let u=new Uint8Array(t.length+64);u.set(n,0),u.set(t,64);let a=new Uint8Array(96);return a.set(i,0),a.set(ht(u),64),G.from(ht(a))},"digest")}},"update")}}var jh=Ee(()=>{V(),Lp(),Bp(),m(Qh,"randomBytes"),m(kh,"createHash"),m(Fh,"createHmac")}),tr=te((s,e)=>{V(),e.exports={host:"localhost",user:ee.platform==="win32"?ee.env.USERNAME:ee.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 t=er(),r=t.getTypeParser(20,"text"),n=t.getTypeParser(1016,"text");e.exports.__defineSetter__("parseInt8",function(i){t.setTypeParser(20,"text",i?t.getTypeParser(23,"text"):r),t.setTypeParser(1016,"text",i?t.getTypeParser(1007,"text"):n)})}),rr=te((s,e)=>{V();var t=(jh(),ye(ns)),r=tr();function n(c){var h=c.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return'"'+h+'"'}m(n,"escapeElement");function i(c){for(var h="{",b=0;b<c.length;b++)b>0&&(h=h+","),c[b]===null||typeof c[b]>"u"?h=h+"NULL":Array.isArray(c[b])?h=h+i(c[b]):c[b]instanceof G?h+="\\\\x"+c[b].toString("hex"):h+=n(u(c[b]));return h=h+"}",h}m(i,"arrayString");var u=m(function(c,h){if(c==null)return null;if(c instanceof G)return c;if(ArrayBuffer.isView(c)){var b=G.from(c.buffer,c.byteOffset,c.byteLength);return b.length===c.byteLength?b:b.slice(c.byteOffset,c.byteOffset+c.byteLength)}return c instanceof Date?r.parseInputDatesAsUTC?d(c):y(c):Array.isArray(c)?i(c):typeof c=="object"?a(c,h):c.toString()},"prepareValue");function a(c,h){if(c&&typeof c.toPostgres=="function"){if(h=h||[],h.indexOf(c)!==-1)throw new Error('circular reference detected while preparing "'+c+'" for query');return h.push(c),u(c.toPostgres(u),h)}return JSON.stringify(c)}m(a,"prepareObject");function f(c,h){for(c=""+c;c.length<h;)c="0"+c;return c}m(f,"pad");function y(c){var h=-c.getTimezoneOffset(),b=c.getFullYear(),E=b<1;
8E&&(b=Math.abs(b)+1);var C=f(b,4)+"-"+f(c.getMonth()+1,2)+"-"+f(c.getDate(),2)+"T"+f(c.getHours(),2)+":"+f(c.getMinutes(),2)+":"+f(c.getSeconds(),2)+"."+f(c.getMilliseconds(),3);return h<0?(C+="-",h*=-1):C+="+",C+=f(Math.floor(h/60),2)+":"+f(h%60,2),E&&(C+=" BC"),C}m(y,"dateToString");function d(c){var h=c.getUTCFullYear(),b=h<1;b&&(h=Math.abs(h)+1);var E=f(h,4)+"-"+f(c.getUTCMonth()+1,2)+"-"+f(c.getUTCDate(),2)+"T"+f(c.getUTCHours(),2)+":"+f(c.getUTCMinutes(),2)+":"+f(c.getUTCSeconds(),2)+"."+f(c.getUTCMilliseconds(),3);return E+="+00:00",b&&(E+=" BC"),E}m(d,"dateToStringUTC");function S(c,h,b){return c=typeof c=="string"?{text:c}:c,h&&(typeof h=="function"?c.callback=h:c.values=h),b&&(c.callback=b),c}m(S,"normalizeQueryConfig");var w=m(function(c){return t.createHash("md5").update(c,"utf-8").digest("hex")},"md5"),v=m(function(c,h,b){var E=w(h+c),C=w(G.concat([G.from(E),b]));return"md5"+C},"postgresMd5PasswordHash");e.exports={prepareValue:m(function(c){return u(c)},"prepareValueWrapper"),normalizeQueryConfig:S,postgresMd5PasswordHash:v,md5:w}}),Et={};Ne(Et,{default:()=>Uh});var Uh,sr=Ee(()=>{V(),Uh={}}),Op=te((s,e)=>{V();var t=(jh(),ye(ns));function r(h){if(h.indexOf("SCRAM-SHA-256")===-1)throw new Error("SASL: Only mechanism SCRAM-SHA-256 is currently supported");let b=t.randomBytes(18).toString("base64");return{mechanism:"SCRAM-SHA-256",clientNonce:b,response:"n,,n=*,r="+b,message:"SASLInitialResponse"}}m(r,"startSession");function n(h,b,E){if(h.message!=="SASLInitialResponse")throw new Error("SASL: Last message was not SASLInitialResponse");if(typeof b!="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string");if(typeof E!="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");let C=y(E);if(C.nonce.startsWith(h.clientNonce)){if(C.nonce.length===h.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");var P=G.from(C.salt,"base64"),O=c(b,P,C.iteration),M=v(O,"Client Key"),T=w(M),I="n=*,r="+h.clientNonce,N="r="+C.nonce+",s="+C.salt+",i="+C.iteration,_="c=biws,r="+C.nonce,q=I+","+N+","+_,R=v(T,q),U=S(M,R),z=U.toString("base64"),D=v(O,"Server Key"),F=v(D,q);h.message="SASLResponse",h.serverSignature=F.toString("base64"),h.response=_+",p="+z}m(n,"continueSession");function i(h,b){if(h.message!=="SASLResponse")throw new Error("SASL: Last message was not SASLResponse");if(typeof b!="string")throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string");let{serverSignature:E}=d(b);if(E!==h.serverSignature)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does not match")}m(i,"finalizeSession");function u(h){if(typeof h!="string")throw new TypeError("SASL: text must be a string");return h.split("").map((b,E)=>h.charCodeAt(E)).every(b=>b>=33&&b<=43||b>=45&&b<=126)}m(u,"isPrintableChars");function a(h){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test(h)}m(a,"isBase64");function f(h){if(typeof h!="string")throw new TypeError("SASL: attribute pairs text must be a string");return new Map(h.split(",").map(b=>{if(!/^.=/.test(b))throw new Error("SASL: Invalid attribute pair entry");let E=b[0],C=b.substring(2);return[E,C]}))}m(f,"parseAttributePairs");function y(h){let b=f(h),E=b.get("r");if(E){if(!u(E))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing");let C=b.get("s");if(C){if(!a(C))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt must be base64")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing");let P=b.get("i");if(P){if(!/^[1-9][0-9]*$/.test(P))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing");let O=parseInt(P,10);return{nonce:E,salt:C,iteration:O}}m(y,"parseServerFirstMessage");function d(h){let b=f(h).get("v");if(b){if(!a(b))throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64")}else throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");return{serverSignature:b}}m(d,"parseServerFinalMessage");function S(h,b){if(!G.isBuffer(h))throw new TypeError("first argument must be a Buffer");if(!G.isBuffer(b))throw new TypeError("second argument must be a Buffer");if(h.length!==b.length)throw new Error("Buffer lengths must match");if(h.length===0)throw new Error("Buffers cannot be empty");return G.from(h.map((E,C)=>h[C]^b[C]))}m(S,"xorBuffers");function w(h){return t.createHash("sha256").update(h).digest()}m(w,"sha256");function v(h,b){return t.createHmac("sha256",h).update(b).digest()}m(v,"hmacSha256");function c(h,b,E){for(var C=v(h,G.concat([b,G.from([0,0,0,1])])),P=C,O=0;O<E-1;O++)C=v(h,C),P=S(P,C);return P}m(c,"Hi"),e.exports={startSession:r,continueSession:n,finalizeSession:i}}),is={};Ne(is,{join:()=>zh});function zh(...s){return s.join("/")}var Vh=Ee(()=>{V(),m(zh,"join")}),os={};Ne(os,{stat:()=>Wh});function Wh(s,e){e(new Error("No filesystem"))}var Kh=Ee(()=>{V(),m(Wh,"stat")}),as={};Ne(as,{default:()=>Hh});var Hh,Jh=Ee(()=>{V(),Hh={}}),Gh={};Ne(Gh,{StringDecoder:()=>Yh});var yr,Yh,Rp=Ee(()=>{V(),yr=class{constructor(e){Y(this,"td"),this.td=new TextDecoder(e)}write(e){return this.td.decode(e,{stream:!0})}end(e){return this.td.decode(e)}},m(yr,"StringDecoder"),Yh=yr}),Mp=te((s,e)=>{V();var{Transform:t}=(Jh(),ye(as)),{StringDecoder:r}=(Rp(),ye(Gh)),n=Symbol("last"),i=Symbol("decoder");function u(S,w,v){let c;if(this.overflow){if(c=this[i].write(S).split(this.matcher),c.length===1)return v();c.shift(),this.overflow=!1}else this[n]+=this[i].write(S),c=this[n].split(this.matcher);this[n]=c.pop();for(let h=0;h<c.length;h++)try{f(this,this.mapper(c[h]))}catch(b){return v(b)}if(this.overflow=this[n].length>this.maxLength,this.overflow&&!this.skipOverflow){v(new Error("maximum buffer reached"));return}v()}m(u,"transform");function a(S){if(this[n]+=this[i].end(),this[n])try{f(this,this.mapper(this[n]))}catch(w){return S(w)}S()}m(a,"flush");function f(S,w){w!==void 0&&S.push(w)}m(f,"push");function y(S){return S}m(y,"noop");function d(S,w,v){switch(S=S||/\r?\n/,w=w||y,v=v||{},arguments.length){case 1:typeof S=="function"?(w=S,S=/\r?\n/):typeof S=="object"&&!(S instanceof RegExp)&&!S[Symbol.split]&&(v=S,S=/\r?\n/);break;case 2:typeof S=="function"?(v=w,w=S,S=/\r?\n/):typeof w=="object"&&(v=w,w=y)}v=Object.assign({},v),v.autoDestroy=!0,v.transform=u,v.flush=a,v.readableObjectMode=!0;let c=new t(v);return c[n]="",c[i]=new r("utf8"),c.matcher=S,c.mapper=w,c.maxLength=v.maxLength,c.skipOverflow=v.skipOverflow||!1,c.overflow=!1,c._destroy=function(h,b){this._writableState.errorEmitted=!1,b(h)},c}m(d,"split"),e.exports=d}),Dp=te((s,e)=>{V();var t=(Vh(),ye(is)),r=(Jh(),ye(as)).Stream,n=Mp(),i=(sr(),ye(Et)),u=5432,a=ee.platform==="win32",f=ee.stderr,y=56,d=7,S=61440,w=32768;function v(M){return(M&S)==w}m(v,"isRegFile");var c=["host","port","database","user","password"],h=c.length,b=c[h-1];function E(){var M=f instanceof r&&f.writable===!0;if(M){var T=Array.prototype.slice.call(arguments).concat(` 9`);f.write(i.format.apply(i,T))}}m(E,"warn"),Object.defineProperty(e.exports,"isWin",{get:m(function(){return a},"get"),set:m(function(M){a=M},"set")}),e.exports.warnTo=function(M){var T=f;return f=M,T},e.exports.getFileName=function(M){var T=M||ee.env,I=T.PGPASSFILE||(a?t.join(T.APPDATA||"./","postgresql","pgpass.conf"):t.join(T.HOME||"./",".pgpass"));return I},e.exports.usePgPass=function(M,T){return Object.prototype.hasOwnProperty.call(ee.env,"PGPASSWORD")?!1:a?!0:(T=T||"<unkn>",v(M.mode)?M.mode&(y|d)?(E('WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less',T),!1):!0:(E('WARNING: password file "%s" is not a plain file',T),!1))};
9var C=e.exports.match=function(M,T){return c.slice(0,-1).reduce(function(I,N,_){return _==1&&Number(M[N]||u)===Number(T[N])?I&&!0:I&&(T[N]==="*"||T[N]===M[N])},!0)};e.exports.getPassword=function(M,T,I){var N,_=T.pipe(n());function q(z){var D=P(z);D&&O(D)&&C(M,D)&&(N=D[b],_.end())}m(q,"onLine");var R=m(function(){T.destroy(),I(N)},"onEnd"),U=m(function(z){T.destroy(),E("WARNING: error on reading file: %s",z),I(void 0)},"onErr");T.on("error",U),_.on("data",q).on("end",R).on("error",U)};var P=e.exports.parseLine=function(M){if(M.length<11||M.match(/^\s+#/))return null;for(var T="",I="",N=0,_=0,q=0,R={},U=!1,z=m(function(F,H,Z){var se=M.substring(H,Z);Object.hasOwnProperty.call(ee.env,"PGPASS_NO_DEESCAPE")||(se=se.replace(/\\([:\\])/g,"$1")),R[c[F]]=se},"addToObj"),D=0;D<M.length-1;D+=1){if(T=M.charAt(D+1),I=M.charAt(D),U=N==h-1,U){z(N,_);break}D>=0&&T==":"&&I!=="\\"&&(z(N,_,D+1),_=D+2,N+=1)}return R=Object.keys(R).length===h?R:null,R},O=e.exports.isValidEntry=function(M){for(var T={0:function(R){return R.length>0},1:function(R){return R==="*"?!0:(R=Number(R),isFinite(R)&&R>0&&R<9007199254740992&&Math.floor(R)===R)},2:function(R){return R.length>0},3:function(R){return R.length>0},4:function(R){return R.length>0}},I=0;I<c.length;I+=1){var N=T[I],_=M[c[I]]||"",q=N(_);if(!q)return!1}return!0}}),qp=te((s,e)=>{V(),Vh(),ye(is);var t=(Kh(),ye(os)),r=Dp();e.exports=function(n,i){var u=r.getFileName();t.stat(u,function(a,f){if(a||!r.usePgPass(f,u))return i(void 0);var y=t.createReadStream(u);r.getPassword(n,y,i)})},e.exports.warnTo=r.warnTo}),Zh={};Ne(Zh,{default:()=>Xh});var Xh,$p=Ee(()=>{V(),Xh={}}),Qp=te((s,e)=>{V();var t=(Mh(),ye(Rh)),r=(Kh(),ye(os));function n(i){if(i.charAt(0)==="/"){var a=i.split(" ");return{host:a[0],database:a[1]}}var u=t.parse(/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(i)?encodeURI(i).replace(/\%25(\d\d)/g,"%$1"):i,!0),a=u.query;for(var f in a)Array.isArray(a[f])&&(a[f]=a[f][a[f].length-1]);var y=(u.auth||":").split(":");if(a.user=y[0],a.password=y.splice(1).join(":"),a.port=u.port,u.protocol=="socket:")return a.host=decodeURI(u.pathname),a.database=u.query.db,a.client_encoding=u.query.encoding,a;a.host||(a.host=u.hostname);var d=u.pathname;if(!a.host&&d&&/^%2f/i.test(d)){var S=d.split("/");a.host=decodeURIComponent(S[0]),d=S.splice(1).join("/")}switch(d&&d.charAt(0)==="/"&&(d=d.slice(1)||null),a.database=d&&decodeURI(d),(a.ssl==="true"||a.ssl==="1")&&(a.ssl=!0),a.ssl==="0"&&(a.ssl=!1),(a.sslcert||a.sslkey||a.sslrootcert||a.sslmode)&&(a.ssl={}),a.sslcert&&(a.ssl.cert=r.readFileSync(a.sslcert).toString()),a.sslkey&&(a.ssl.key=r.readFileSync(a.sslkey).toString()),a.sslrootcert&&(a.ssl.ca=r.readFileSync(a.sslrootcert).toString()),a.sslmode){case"disable":{a.ssl=!1;break}case"prefer":case"require":case"verify-ca":case"verify-full":break;case"no-verify":{a.ssl.rejectUnauthorized=!1;break}}return a}m(n,"parse"),e.exports=n,n.parse=n}),us=te((s,e)=>{V();var t=($p(),ye(Zh)),r=tr(),n=Qp().parse,i=m(function(S,w,v){return v===void 0?v=ee.env["PG"+S.toUpperCase()]:v===!1||(v=ee.env[v]),w[S]||v||r[S]},"val"),u=m(function(){switch(ee.env.PGSSLMODE){case"disable":return!1;case"prefer":case"require":case"verify-ca":case"verify-full":return!0;case"no-verify":return{rejectUnauthorized:!1}}return r.ssl},"readSSLConfigFromEnvironment"),a=m(function(S){return"'"+(""+S).replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"},"quoteParamValue"),f=m(function(S,w,v){var c=w[v];c!=null&&S.push(v+"="+a(c))},"add"),y=class{constructor(w){w=typeof w=="string"?n(w):w||{},w.connectionString&&(w=Object.assign({},w,n(w.connectionString))),this.user=i("user",w),this.database=i("database",w),this.database===void 0&&(this.database=this.user),this.port=parseInt(i("port",w),10),this.host=i("host",w),Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:i("password",w)}),this.binary=i("binary",w),this.options=i("options",w),this.ssl=typeof w.ssl>"u"?u():w.ssl,typeof this.ssl=="string"&&this.ssl==="true"&&(this.ssl=!0),this.ssl==="no-verify"&&(this.ssl={rejectUnauthorized:!1}),this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,"key",{enumerable:!1}),this.client_encoding=i("client_encoding",w),this.replication=i("replication",w),this.isDomainSocket=!(this.host||"").indexOf("/"),this.application_name=i("application_name",w,"PGAPPNAME"),this.fallback_application_name=i("fallback_application_name",w,!1),this.statement_timeout=i("statement_timeout",w,!1),this.lock_timeout=i("lock_timeout",w,!1),this.idle_in_transaction_session_timeout=i("idle_in_transaction_session_timeout",w,!1),this.query_timeout=i("query_timeout",w,!1),w.connectionTimeoutMillis===void 0?this.connect_timeout=ee.env.PGCONNECT_TIMEOUT||0:this.connect_timeout=Math.floor(w.connectionTimeoutMillis/1e3),w.keepAlive===!1?this.keepalives=0:w.keepAlive===!0&&(this.keepalives=1),typeof w.keepAliveInitialDelayMillis=="number"&&(this.keepalives_idle=Math.floor(w.keepAliveInitialDelayMillis/1e3))}getLibpqConnectionString(w){var v=[];f(v,this,"user"),f(v,this,"password"),f(v,this,"port"),f(v,this,"application_name"),f(v,this,"fallback_application_name"),f(v,this,"connect_timeout"),f(v,this,"options");var c=typeof this.ssl=="object"?this.ssl:this.ssl?{sslmode:this.ssl}:{};if(f(v,c,"sslmode"),f(v,c,"sslca"),f(v,c,"sslkey"),f(v,c,"sslcert"),f(v,c,"sslrootcert"),this.database&&v.push("dbname="+a(this.database)),this.replication&&v.push("replication="+a(this.replication)),this.host&&v.push("host="+a(this.host)),this.isDomainSocket)return w(null,v.join(" "));this.client_encoding&&v.push("client_encoding="+a(this.client_encoding)),t.lookup(this.host,function(h,b){return h?w(h,null):(v.push("hostaddr="+a(b)),w(null,v.join(" ")))})}};m(y,"ConnectionParameters");var d=y;e.exports=d}),kp=te((s,e)=>{V();var t=er(),r=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/,n=class{constructor(a,f){this.command=null,this.rowCount=null,this.oid=null,this.rows=[],this.fields=[],this._parsers=void 0,this._types=f,this.RowCtor=null,this.rowAsArray=a==="array",this.rowAsArray&&(this.parseRow=this._parseRowAsArray)}addCommandComplete(a){var f;a.text?f=r.exec(a.text):f=r.exec(a.command),f&&(this.command=f[1],f[3]?(this.oid=parseInt(f[2],10),this.rowCount=parseInt(f[3],10)):f[2]&&(this.rowCount=parseInt(f[2],10)))}_parseRowAsArray(a){for(var f=new Array(a.length),y=0,d=a.length;y<d;y++){var S=a[y];S!==null?f[y]=this._parsers[y](S):f[y]=null}return f}parseRow(a){for(var f={},y=0,d=a.length;y<d;y++){var S=a[y],w=this.fields[y].name;S!==null?f[w]=this._parsers[y](S):f[w]=null}return f}addRow(a){this.rows.push(a)}addFields(a){this.fields=a,this.fields.length&&(this._parsers=new Array(a.length));for(var f=0;f<a.length;f++){var y=a[f];this._types?this._parsers[f]=this._types.getTypeParser(y.dataTypeID,y.format||"text"):this._parsers[f]=t.getTypeParser(y.dataTypeID,y.format||"text")}}};m(n,"Result");var i=n;e.exports=i}),Fp=te((s,e)=>{V();var{EventEmitter:t}=Je(),r=kp(),n=rr(),i=class extends t{constructor(f,y,d){super(),f=n.normalizeQueryConfig(f,y,d),this.text=f.text,this.values=f.values,this.rows=f.rows,this.types=f.types,this.name=f.name,this.binary=f.binary,this.portal=f.portal||"",this.callback=f.callback,this._rowMode=f.rowMode,ee.domain&&f.callback&&(this.callback=ee.domain.bind(f.callback)),this._result=new r(this._rowMode,this.types),this._results=this._result,this.isPreparedStatement=!1,this._canceledDueToError=!1,this._promise=null}requiresPreparation(){return this.name||this.rows?!0:!this.text||!this.values?!1:this.values.length>0}_checkForMultirow(){this._result.command&&(Array.isArray(this._results)||(this._results=[this._result]),this._result=new r(this._rowMode,this.types),this._results.push(this._result))}handleRowDescription(f){this._checkForMultirow(),this._result.addFields(f.fields),this._accumulateRows=this.callback||!this.listeners("row").length}handleDataRow(f){let y;if(!this._canceledDueToError){try{y=this._result.parseRow(f.fields)}catch(d){this._canceledDueToError=d;return}
9this.emit("row",y,this._result),this._accumulateRows&&this._result.addRow(y)}}handleCommandComplete(f,y){this._checkForMultirow(),this._result.addCommandComplete(f),this.rows&&y.sync()}handleEmptyQuery(f){this.rows&&f.sync()}handleError(f,y){if(this._canceledDueToError&&(f=this._canceledDueToError,this._canceledDueToError=!1),this.callback)return this.callback(f);this.emit("error",f)}handleReadyForQuery(f){if(this._canceledDueToError)return this.handleError(this._canceledDueToError,f);if(this.callback)try{this.callback(null,this._results)}catch(y){ee.nextTick(()=>{throw y})}this.emit("end",this._results)}submit(f){if(typeof this.text!="string"&&typeof this.name!="string")return new Error("A query must have either text or a name. Supplying neither is unsupported.");let y=f.parsedStatements[this.name];return this.text&&y&&this.text!==y?new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`):this.values&&!Array.isArray(this.values)?new Error("Query values must be an array"):(this.requiresPreparation()?this.prepare(f):f.query(this.text),null)}hasBeenParsed(f){return this.name&&f.parsedStatements[this.name]}handlePortalSuspended(f){this._getRows(f,this.rows)}_getRows(f,y){f.execute({portal:this.portal,rows:y}),y?f.flush():f.sync()}prepare(f){this.isPreparedStatement=!0,this.hasBeenParsed(f)||f.parse({text:this.text,name:this.name,types:this.types});try{f.bind({portal:this.portal,statement:this.name,values:this.values,binary:this.binary,valueMapper:n.prepareValue})}catch(y){this.handleError(y,f);return}f.describe({type:"P",name:this.portal||""}),this._getRows(f,this.rows)}handleCopyInResponse(f){f.sendCopyFail("No source stream defined")}handleCopyData(f,y){}};m(i,"Query");var u=i;e.exports=u}),ef=te(s=>{V(),Object.defineProperty(s,"__esModule",{value:!0}),s.NoticeMessage=s.DataRowMessage=s.CommandCompleteMessage=s.ReadyForQueryMessage=s.NotificationResponseMessage=s.BackendKeyDataMessage=s.AuthenticationMD5Password=s.ParameterStatusMessage=s.ParameterDescriptionMessage=s.RowDescriptionMessage=s.Field=s.CopyResponse=s.CopyDataMessage=s.DatabaseError=s.copyDone=s.emptyQuery=s.replicationStart=s.portalSuspended=s.noData=s.closeComplete=s.bindComplete=s.parseComplete=void 0,s.parseComplete={name:"parseComplete",length:5},s.bindComplete={name:"bindComplete",length:5},s.closeComplete={name:"closeComplete",length:5},s.noData={name:"noData",length:5},s.portalSuspended={name:"portalSuspended",length:5},s.replicationStart={name:"replicationStart",length:4},s.emptyQuery={name:"emptyQuery",length:4},s.copyDone={name:"copyDone",length:4};var e=class extends Error{constructor(D,F,H){super(D),this.length=F,this.name=H}};m(e,"DatabaseError");var t=e;s.DatabaseError=t;var r=class{constructor(D,F){this.length=D,this.chunk=F,this.name="copyData"}};m(r,"CopyDataMessage");var n=r;s.CopyDataMessage=n;var i=class{constructor(D,F,H,Z){this.length=D,this.name=F,this.binary=H,this.columnTypes=new Array(Z)}};m(i,"CopyResponse");var u=i;s.CopyResponse=u;var a=class{constructor(D,F,H,Z,se,X,Te){this.name=D,this.tableID=F,this.columnID=H,this.dataTypeID=Z,this.dataTypeSize=se,this.dataTypeModifier=X,this.format=Te}};m(a,"Field");var f=a;s.Field=f;var y=class{constructor(D,F){this.length=D,this.fieldCount=F,this.name="rowDescription",this.fields=new Array(this.fieldCount)}};m(y,"RowDescriptionMessage");var d=y;s.RowDescriptionMessage=d;var S=class{constructor(D,F){this.length=D,this.parameterCount=F,this.name="parameterDescription",this.dataTypeIDs=new Array(this.parameterCount)}};m(S,"ParameterDescriptionMessage");var w=S;s.ParameterDescriptionMessage=w;var v=class{constructor(D,F,H){this.length=D,this.parameterName=F,this.parameterValue=H,this.name="parameterStatus"}};m(v,"ParameterStatusMessage");var c=v;s.ParameterStatusMessage=c;var h=class{constructor(D,F){this.length=D,this.salt=F,this.name="authenticationMD5Password"}};m(h,"AuthenticationMD5Password");var b=h;s.AuthenticationMD5Password=b;var E=class{constructor(D,F,H){this.length=D,this.processID=F,this.secretKey=H,this.name="backendKeyData"}};m(E,"BackendKeyDataMessage");var C=E;s.BackendKeyDataMessage=C;var P=class{constructor(D,F,H,Z){this.length=D,this.processId=F,this.channel=H,this.payload=Z,this.name="notification"}};m(P,"NotificationResponseMessage");var O=P;s.NotificationResponseMessage=O;var M=class{constructor(D,F){this.length=D,this.status=F,this.name="readyForQuery"}};m(M,"ReadyForQueryMessage");var T=M;s.ReadyForQueryMessage=T;var I=class{constructor(D,F){this.length=D,this.text=F,this.name="commandComplete"}};m(I,"CommandCompleteMessage");var N=I;s.CommandCompleteMessage=N;var _=class{constructor(D,F){this.length=D,this.fields=F,this.name="dataRow",this.fieldCount=F.length}};m(_,"DataRowMessage");var q=_;s.DataRowMessage=q;var R=class{constructor(D,F){this.length=D,this.message=F,this.name="notice"}};m(R,"NoticeMessage");var U=R;s.NoticeMessage=U}),jp=te(s=>{V(),Object.defineProperty(s,"__esModule",{value:!0}),s.Writer=void 0;var e=class{constructor(n=256){this.size=n,this.offset=5,this.headerPosition=0,this.buffer=G.allocUnsafe(n)}ensure(n){if(this.buffer.length-this.offset<n){let i=this.buffer,u=i.length+(i.length>>1)+n;this.buffer=G.allocUnsafe(u),i.copy(this.buffer)}}addInt32(n){return this.ensure(4),this.buffer[this.offset++]=n>>>24&255,this.buffer[this.offset++]=n>>>16&255,this.buffer[this.offset++]=n>>>8&255,this.buffer[this.offset++]=n>>>0&255,this}addInt16(n){return this.ensure(2),this.buffer[this.offset++]=n>>>8&255,this.buffer[this.offset++]=n>>>0&255,this}addCString(n){if(!n)this.ensure(1);else{let i=G.byteLength(n);this.ensure(i+1),this.buffer.write(n,this.offset,"utf-8"),this.offset+=i}return this.buffer[this.offset++]=0,this}addString(n=""){let i=G.byteLength(n);return this.ensure(i),this.buffer.write(n,this.offset),this.offset+=i,this}add(n){return this.ensure(n.length),n.copy(this.buffer,this.offset),this.offset+=n.length,this}join(n){if(n){this.buffer[this.headerPosition]=n;let i=this.offset-(this.headerPosition+1);this.buffer.writeInt32BE(i,this.headerPosition+1)}return this.buffer.slice(n?0:5,this.offset)}flush(n){let i=this.join(n);return this.offset=5,this.headerPosition=0,this.buffer=G.allocUnsafe(this.size),i}};m(e,"Writer");var t=e;s.Writer=t}),Up=te(s=>{V(),Object.defineProperty(s,"__esModule",{value:!0}),s.serialize=void 0;var e=jp(),t=new e.Writer,r=m(D=>{t.addInt16(3).addInt16(0);for(let Z of Object.keys(D))t.addCString(Z).addCString(D[Z]);t.addCString("client_encoding").addCString("UTF8");let F=t.addCString("").flush(),H=F.length+4;return new e.Writer().addInt32(H).add(F).flush()},"startup"),n=m(()=>{let D=G.allocUnsafe(8);return D.writeInt32BE(8,0),D.writeInt32BE(80877103,4),D},"requestSsl"),i=m(D=>t.addCString(D).flush(112),"password"),u=m(function(D,F){return t.addCString(D).addInt32(G.byteLength(F)).addString(F),t.flush(112)},"sendSASLInitialResponseMessage"),a=m(function(D){return t.addString(D).flush(112)}
9,"sendSCRAMClientFinalMessage"),f=m(D=>t.addCString(D).flush(81),"query"),y=[],d=m(D=>{let F=D.name||"";F.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",F,F.length),console.error("This can cause conflicts and silent errors executing queries"));let H=D.types||y,Z=H.length,se=t.addCString(F).addCString(D.text).addInt16(Z);for(let X=0;X<Z;X++)se.addInt32(H[X]);return t.flush(80)},"parse"),S=new e.Writer,w=m(function(D,F){for(let H=0;H<D.length;H++){let Z=F?F(D[H],H):D[H];Z==null?(t.addInt16(0),S.addInt32(-1)):Z instanceof G?(t.addInt16(1),S.addInt32(Z.length),S.add(Z)):(t.addInt16(0),S.addInt32(G.byteLength(Z)),S.addString(Z))}},"writeValues"),v=m((D={})=>{let F=D.portal||"",H=D.statement||"",Z=D.binary||!1,se=D.values||y,X=se.length;return t.addCString(F).addCString(H),t.addInt16(X),w(se,D.valueMapper),t.addInt16(X),t.add(S.flush()),t.addInt16(Z?1:0),t.flush(66)},"bind"),c=G.from([69,0,0,0,9,0,0,0,0,0]),h=m(D=>{if(!D||!D.portal&&!D.rows)return c;let F=D.portal||"",H=D.rows||0,Z=G.byteLength(F),se=4+Z+1+4,X=G.allocUnsafe(1+se);return X[0]=69,X.writeInt32BE(se,1),X.write(F,5,"utf-8"),X[Z+5]=0,X.writeUInt32BE(H,X.length-4),X},"execute"),b=m((D,F)=>{let H=G.allocUnsafe(16);return H.writeInt32BE(16,0),H.writeInt16BE(1234,4),H.writeInt16BE(5678,6),H.writeInt32BE(D,8),H.writeInt32BE(F,12),H},"cancel"),E=m((D,F)=>{let H=4+G.byteLength(F)+1,Z=G.allocUnsafe(1+H);return Z[0]=D,Z.writeInt32BE(H,1),Z.write(F,5,"utf-8"),Z[H]=0,Z},"cstringMessage"),C=t.addCString("P").flush(68),P=t.addCString("S").flush(68),O=m(D=>D.name?E(68,`${D.type}${D.name||""}`):D.type==="P"?C:P,"describe"),M=m(D=>{let F=`${D.type}${D.name||""}`;return E(67,F)},"close"),T=m(D=>t.add(D).flush(100),"copyData"),I=m(D=>E(102,D),"copyFail"),N=m(D=>G.from([D,0,0,0,4]),"codeOnlyBuffer"),_=N(72),q=N(83),R=N(88),U=N(99),z={startup:r,password:i,requestSsl:n,sendSASLInitialResponseMessage:u,sendSCRAMClientFinalMessage:a,query:f,parse:d,bind:v,execute:h,describe:O,close:M,flush:m(()=>_,"flush"),sync:m(()=>q,"sync"),end:m(()=>R,"end"),copyData:T,copyDone:m(()=>U,"copyDone"),copyFail:I,cancel:b};s.serialize=z}),zp=te(s=>{V(),Object.defineProperty(s,"__esModule",{value:!0}),s.BufferReader=void 0;var e=G.allocUnsafe(0),t=class{constructor(i=0){this.offset=i,this.buffer=e,this.encoding="utf-8"}setBuffer(i,u){this.offset=i,this.buffer=u}int16(){let i=this.buffer.readInt16BE(this.offset);return this.offset+=2,i}byte(){let i=this.buffer[this.offset];return this.offset++,i}int32(){let i=this.buffer.readInt32BE(this.offset);return this.offset+=4,i}uint32(){let i=this.buffer.readUInt32BE(this.offset);return this.offset+=4,i}string(i){let u=this.buffer.toString(this.encoding,this.offset,this.offset+i);return this.offset+=i,u}cstring(){let i=this.offset,u=i;for(;this.buffer[u++]!==0;);return this.offset=u,this.buffer.toString(this.encoding,i,u-1)}bytes(i){let u=this.buffer.slice(this.offset,this.offset+i);return this.offset+=i,u}};m(t,"BufferReader");var r=t;s.BufferReader=r}),Vp=te(s=>{V(),Object.defineProperty(s,"__esModule",{value:!0}),s.Parser=void 0;var e=ef(),t=zp(),r=1,n=4,i=r+n,u=G.allocUnsafe(0),a=class{constructor(d){if(this.buffer=u,this.bufferLength=0,this.bufferOffset=0,this.reader=new t.BufferReader,(d==null?void 0:d.mode)==="binary")throw new Error("Binary mode not supported yet");this.mode=(d==null?void 0:d.mode)||"text"}parse(d,S){this.mergeBuffer(d);let w=this.bufferOffset+this.bufferLength,v=this.bufferOffset;for(;v+i<=w;){let c=this.buffer[v],h=this.buffer.readUInt32BE(v+r),b=r+h;if(b+v<=w){let E=this.handlePacket(v+i,c,h,this.buffer);S(E),v+=b}else break}v===w?(this.buffer=u,this.bufferLength=0,this.bufferOffset=0):(this.bufferLength=w-v,this.bufferOffset=v)}mergeBuffer(d){if(this.bufferLength>0){let S=this.bufferLength+d.byteLength;if(S+this.bufferOffset>this.buffer.byteLength){let w;if(S<=this.buffer.byteLength&&this.bufferOffset>=this.bufferLength)w=this.buffer;else{let v=this.buffer.byteLength*2;for(;S>=v;)v*=2;w=G.allocUnsafe(v)}this.buffer.copy(w,0,this.bufferOffset,this.bufferOffset+this.bufferLength),this.buffer=w,this.bufferOffset=0}d.copy(this.buffer,this.bufferOffset+this.bufferLength),this.bufferLength=S}else this.buffer=d,this.bufferOffset=0,this.bufferLength=d.byteLength}handlePacket(d,S,w,v){switch(S){case 50:return e.bindComplete;case 49:return e.parseComplete;case 51:return e.closeComplete;case 110:return e.noData;case 115:return e.portalSuspended;case 99:return e.copyDone;case 87:return e.replicationStart;case 73:return e.emptyQuery;case 68:return this.parseDataRowMessage(d,w,v);case 67:return this.parseCommandCompleteMessage(d,w,v);case 90:return this.parseReadyForQueryMessage(d,w,v);case 65:return this.parseNotificationMessage(d,w,v);case 82:return this.parseAuthenticationResponse(d,w,v);case 83:return this.parseParameterStatusMessage(d,w,v);case 75:return this.parseBackendKeyData(d,w,v);case 69:return this.parseErrorMessage(d,w,v,"error");
9case 78:return this.parseErrorMessage(d,w,v,"notice");case 84:return this.parseRowDescriptionMessage(d,w,v);case 116:return this.parseParameterDescriptionMessage(d,w,v);case 71:return this.parseCopyInMessage(d,w,v);case 72:return this.parseCopyOutMessage(d,w,v);case 100:return this.parseCopyData(d,w,v);default:return new e.DatabaseError("received invalid response: "+S.toString(16),w,"error")}}parseReadyForQueryMessage(d,S,w){this.reader.setBuffer(d,w);let v=this.reader.string(1);return new e.ReadyForQueryMessage(S,v)}parseCommandCompleteMessage(d,S,w){this.reader.setBuffer(d,w);let v=this.reader.cstring();return new e.CommandCompleteMessage(S,v)}parseCopyData(d,S,w){let v=w.slice(d,d+(S-4));return new e.CopyDataMessage(S,v)}parseCopyInMessage(d,S,w){return this.parseCopyMessage(d,S,w,"copyInResponse")}parseCopyOutMessage(d,S,w){return this.parseCopyMessage(d,S,w,"copyOutResponse")}parseCopyMessage(d,S,w,v){this.reader.setBuffer(d,w);let c=this.reader.byte()!==0,h=this.reader.int16(),b=new e.CopyResponse(S,v,c,h);for(let E=0;E<h;E++)b.columnTypes[E]=this.reader.int16();return b}parseNotificationMessage(d,S,w){this.reader.setBuffer(d,w);let v=this.reader.int32(),c=this.reader.cstring(),h=this.reader.cstring();return new e.NotificationResponseMessage(S,v,c,h)}parseRowDescriptionMessage(d,S,w){this.reader.setBuffer(d,w);let v=this.reader.int16(),c=new e.RowDescriptionMessage(S,v);for(let h=0;h<v;h++)c.fields[h]=this.parseField();return c}parseField(){let d=this.reader.cstring(),S=this.reader.uint32(),w=this.reader.int16(),v=this.reader.uint32(),c=this.reader.int16(),h=this.reader.int32(),b=this.reader.int16()===0?"text":"binary";return new e.Field(d,S,w,v,c,h,b)}parseParameterDescriptionMessage(d,S,w){this.reader.setBuffer(d,w);let v=this.reader.int16(),c=new e.ParameterDescriptionMessage(S,v);for(let h=0;h<v;h++)c.dataTypeIDs[h]=this.reader.int32();return c}parseDataRowMessage(d,S,w){this.reader.setBuffer(d,w);let v=this.reader.int16(),c=new Array(v);for(let h=0;h<v;h++){let b=this.reader.int32();c[h]=b===-1?null:this.reader.string(b)}return new e.DataRowMessage(S,c)}parseParameterStatusMessage(d,S,w){this.reader.setBuffer(d,w);let v=this.reader.cstring(),c=this.reader.cstring();return new e.ParameterStatusMessage(S,v,c)}parseBackendKeyData(d,S,w){this.reader.setBuffer(d,w);let v=this.reader.int32(),c=this.reader.int32();return new e.BackendKeyDataMessage(S,v,c)}parseAuthenticationResponse(d,S,w){this.reader.setBuffer(d,w);let v=this.reader.int32(),c={name:"authenticationOk",length:S};switch(v){case 0:break;case 3:c.length===8&&(c.name="authenticationCleartextPassword");break;case 5:if(c.length===12){c.name="authenticationMD5Password";let h=this.reader.bytes(4);return new e.AuthenticationMD5Password(S,h)}break;case 10:{c.name="authenticationSASL",c.mechanisms=[];let h;do h=this.reader.cstring(),h&&c.mechanisms.push(h);while(h)}break;case 11:c.name="authenticationSASLContinue",c.data=this.reader.string(S-8);break;case 12:c.name="authenticationSASLFinal",c.data=this.reader.string(S-8);break;default:throw new Error("Unknown authenticationOk message type "+v)}return c}parseErrorMessage(d,S,w,v){this.reader.setBuffer(d,w);let c={},h=this.reader.string(1);for(;h!=="\0";)c[h]=this.reader.cstring(),h=this.reader.string(1);let b=c.M,E=v==="notice"?new e.NoticeMessage(S,b):new e.DatabaseError(b,S,v);return E.severity=c.S,E.code=c.C,E.detail=c.D,E.hint=c.H,E.position=c.P,E.internalPosition=c.p,E.internalQuery=c.q,E.where=c.W,E.schema=c.s,E.table=c.t,E.column=c.c,E.dataType=c.d,E.constraint=c.n,E.file=c.F,E.line=c.L,E.routine=c.R,E}};m(a,"Parser");var f=a;s.Parser=f}),tf=te(s=>{V(),Object.defineProperty(s,"__esModule",{value:!0}),s.DatabaseError=s.serialize=s.parse=void 0;var e=ef();Object.defineProperty(s,"DatabaseError",{enumerable:!0,get:m(function(){return e.DatabaseError},"get")});var t=Up();Object.defineProperty(s,"serialize",{enumerable:!0,get:m(function(){return t.serialize},"get")});var r=Vp();function n(i,u){let a=new r.Parser;return i.on("data",f=>a.parse(f,u)),new Promise(f=>i.on("end",()=>f()))}m(n,"parse"),s.parse=n}),rf={};Ne(rf,{connect:()=>sf});function sf({socket:s,servername:e}){return s.startTls(e),s}var Wp=Ee(()=>{V(),m(sf,"connect")}),nf=te((s,e)=>{V();var t=(St(),ye(Bh)),r=Je().EventEmitter,{parse:n,serialize:i}=tf(),u=i.flush(),a=i.sync(),f=i.end(),y=class extends r{constructor(w){super(),w=w||{},this.stream=w.stream||new t.Socket,this._keepAlive=w.keepAlive,this._keepAliveInitialDelayMillis=w.keepAliveInitialDelayMillis,this.lastBuffer=!1,this.parsedStatements={},this.ssl=w.ssl||!1,this._ending=!1,this._emitMessage=!1;var v=this;this.on("newListener",function(c){c==="message"&&(v._emitMessage=!0)})}connect(w,v){var c=this;this._connecting=!0,this.stream.setNoDelay(!0),this.stream.connect(w,v),this.stream.once("connect",function(){c._keepAlive&&c.stream.setKeepAlive(!0,c._keepAliveInitialDelayMillis),c.emit("connect")});let h=m(function(b){c._ending&&(b.code==="ECONNRESET"||b.code==="EPIPE")||c.emit("error",b)},"reportStreamError");
9if(this.stream.on("error",h),this.stream.on("close",function(){c.emit("end")}),!this.ssl)return this.attachListeners(this.stream);this.stream.once("data",function(b){var E=b.toString("utf8");switch(E){case"S":break;case"N":return c.stream.end(),c.emit("error",new Error("The server does not support SSL connections"));default:return c.stream.end(),c.emit("error",new Error("There was an error establishing an SSL connection"))}var C=(Wp(),ye(rf));let P={socket:c.stream};c.ssl!==!0&&(Object.assign(P,c.ssl),"key"in c.ssl&&(P.key=c.ssl.key)),t.isIP(v)===0&&(P.servername=v);try{c.stream=C.connect(P)}catch(O){return c.emit("error",O)}c.attachListeners(c.stream),c.stream.on("error",h),c.emit("sslconnect")})}attachListeners(w){w.on("end",()=>{this.emit("end")}),n(w,v=>{var c=v.name==="error"?"errorMessage":v.name;this._emitMessage&&this.emit("message",v),this.emit(c,v)})}requestSsl(){this.stream.write(i.requestSsl())}startup(w){this.stream.write(i.startup(w))}cancel(w,v){this._send(i.cancel(w,v))}password(w){this._send(i.password(w))}sendSASLInitialResponseMessage(w,v){this._send(i.sendSASLInitialResponseMessage(w,v))}sendSCRAMClientFinalMessage(w){this._send(i.sendSCRAMClientFinalMessage(w))}_send(w){return this.stream.writable?this.stream.write(w):!1}query(w){this._send(i.query(w))}parse(w){this._send(i.parse(w))}bind(w){this._send(i.bind(w))}execute(w){this._send(i.execute(w))}flush(){this.stream.writable&&this.stream.write(u)}sync(){this._ending=!0,this._send(u),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(f,()=>{this.stream.end()})}close(w){this._send(i.close(w))}describe(w){this._send(i.describe(w))}sendCopyFromChunk(w){this._send(i.copyData(w))}endCopyFrom(){this._send(i.copyDone())}sendCopyFail(w){this._send(i.copyFail(w))}};m(y,"Connection");var d=y;e.exports=d}),Kp=te((s,e)=>{V();var t=Je().EventEmitter;sr(),ye(Et);var r=rr(),n=Op(),i=qp(),u=ss(),a=us(),f=Fp(),y=tr(),d=nf(),S=class extends t{constructor(c){super(),this.connectionParameters=new a(c),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 h=c||{};this._Promise=h.Promise||Xt.Promise,this._types=new u(h.types),this._ending=!1,this._connecting=!1,this._connected=!1,this._connectionError=!1,this._queryable=!0,this.connection=h.connection||new d({stream:h.stream,ssl:this.connectionParameters.ssl,keepAlive:h.keepAlive||!1,keepAliveInitialDelayMillis:h.keepAliveInitialDelayMillis||0,encoding:this.connectionParameters.client_encoding||"utf8"}),this.queryQueue=[],this.binary=h.binary||y.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=h.connectionTimeoutMillis||0}_errorAllQueries(c){let h=m(b=>{ee.nextTick(()=>{b.handleError(c,this.connection)})},"enqueueError");this.activeQuery&&(h(this.activeQuery),this.activeQuery=null),this.queryQueue.forEach(h),this.queryQueue.length=0}_connect(c){var h=this,b=this.connection;if(this._connectionCallback=c,this._connecting||this._connected){let E=new Error("Client has already been connected. You cannot reuse a client.");ee.nextTick(()=>{c(E)});return}this._connecting=!0,this.connectionTimeoutHandle,this._connectionTimeoutMillis>0&&(this.connectionTimeoutHandle=setTimeout(()=>{b._ending=!0,b.stream.destroy(new Error("timeout expired"))},this._connectionTimeoutMillis)),this.host&&this.host.indexOf("/")===0?b.connect(this.host+"/.s.PGSQL."+this.port):b.connect(this.port,this.host),b.on("connect",function(){h.ssl?b.requestSsl():b.startup(h.getStartupConf())}),b.on("sslconnect",function(){b.startup(h.getStartupConf())}),this._attachListeners(b),b.once("end",()=>{let E=this._ending?new Error("Connection terminated"):new 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)),ee.nextTick(()=>
9{this.emit("end")})})}connect(c){if(c){this._connect(c);return}return new this._Promise((h,b)=>{this._connect(E=>{E?b(E):h()})})}_attachListeners(c){c.on("authenticationCleartextPassword",this._handleAuthCleartextPassword.bind(this)),c.on("authenticationMD5Password",this._handleAuthMD5Password.bind(this)),c.on("authenticationSASL",this._handleAuthSASL.bind(this)),c.on("authenticationSASLContinue",this._handleAuthSASLContinue.bind(this)),c.on("authenticationSASLFinal",this._handleAuthSASLFinal.bind(this)),c.on("backendKeyData",this._handleBackendKeyData.bind(this)),c.on("error",this._handleErrorEvent.bind(this)),c.on("errorMessage",this._handleErrorMessage.bind(this)),c.on("readyForQuery",this._handleReadyForQuery.bind(this)),c.on("notice",this._handleNotice.bind(this)),c.on("rowDescription",this._handleRowDescription.bind(this)),c.on("dataRow",this._handleDataRow.bind(this)),c.on("portalSuspended",this._handlePortalSuspended.bind(this)),c.on("emptyQuery",this._handleEmptyQuery.bind(this)),c.on("commandComplete",this._handleCommandComplete.bind(this)),c.on("parseComplete",this._handleParseComplete.bind(this)),c.on("copyInResponse",this._handleCopyInResponse.bind(this)),c.on("copyData",this._handleCopyData.bind(this)),c.on("notification",this._handleNotification.bind(this))}_checkPgPass(c){let h=this.connection;typeof this.password=="function"?this._Promise.resolve().then(()=>this.password()).then(b=>{if(b!==void 0){if(typeof b!="string"){h.emit("error",new TypeError("Password must be a string"));return}this.connectionParameters.password=this.password=b}else this.connectionParameters.password=this.password=null;c()}).catch(b=>{h.emit("error",b)}):this.password!==null?c():i(this.connectionParameters,b=>{b!==void 0&&(this.connectionParameters.password=this.password=b),c()})}_handleAuthCleartextPassword(c){this._checkPgPass(()=>{this.connection.password(this.password)})}_handleAuthMD5Password(c){this._checkPgPass(()=>{let h=r.postgresMd5PasswordHash(this.user,this.password,c.salt);this.connection.password(h)})}_handleAuthSASL(c){this._checkPgPass(()=>{this.saslSession=n.startSession(c.mechanisms),this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism,this.saslSession.response)})}_handleAuthSASLContinue(c){n.continueSession(this.saslSession,this.password,c.data),this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}_handleAuthSASLFinal(c){n.finalizeSession(this.saslSession,c.data),this.saslSession=null}_handleBackendKeyData(c){this.processID=c.processID,this.secretKey=c.secretKey}_handleReadyForQuery(c){this._connecting&&(this._connecting=!1,this._connected=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback&&(this._connectionCallback(null,this),this._connectionCallback=null),this.emit("connect"));let{activeQuery:h}=this;this.activeQuery=null,this.readyForQuery=!0,h&&h.handleReadyForQuery(this.connection),this._pulseQueryQueue()}_handleErrorWhileConnecting(c){if(!this._connectionError){if(this._connectionError=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback)return this._connectionCallback(c);this.emit("error",c)}}_handleErrorEvent(c){if(this._connecting)return this._handleErrorWhileConnecting(c);this._queryable=!1,this._errorAllQueries(c),this.emit("error",c)}_handleErrorMessage(c){if(this._connecting)return this._handleErrorWhileConnecting(c);let h=this.activeQuery;if(!h){this._handleErrorEvent(c);return}this.activeQuery=null,h.handleError(c,this.connection)}_handleRowDescription(c){this.activeQuery.handleRowDescription(c)}_handleDataRow(c){this.activeQuery.handleDataRow(c)}_handlePortalSuspended(c){this.activeQuery.handlePortalSuspended(this.connection)}_handleEmptyQuery(c){this.activeQuery.handleEmptyQuery(this.connection)}_handleCommandComplete(c){this.activeQuery.handleCommandComplete(c,this.connection)}_handleParseComplete(c){this.activeQuery.name&&(this.connection.parsedStatements[this.activeQuery.name]=this.activeQuery.text)}_handleCopyInResponse(c){this.activeQuery.handleCopyInResponse(this.connection)}_handleCopyData(c){this.activeQuery.handleCopyData(c,this.connection)}
9_handleNotification(c){this.emit("notification",c)}_handleNotice(c){this.emit("notice",c)}getStartupConf(){var c=this.connectionParameters,h={user:c.user,database:c.database},b=c.application_name||c.fallback_application_name;return b&&(h.application_name=b),c.replication&&(h.replication=""+c.replication),c.statement_timeout&&(h.statement_timeout=String(parseInt(c.statement_timeout,10))),c.lock_timeout&&(h.lock_timeout=String(parseInt(c.lock_timeout,10))),c.idle_in_transaction_session_timeout&&(h.idle_in_transaction_session_timeout=String(parseInt(c.idle_in_transaction_session_timeout,10))),c.options&&(h.options=c.options),h}cancel(c,h){if(c.activeQuery===h){var b=this.connection;this.host&&this.host.indexOf("/")===0?b.connect(this.host+"/.s.PGSQL."+this.port):b.connect(this.port,this.host),b.on("connect",function(){b.cancel(c.processID,c.secretKey)})}else c.queryQueue.indexOf(h)!==-1&&c.queryQueue.splice(c.queryQueue.indexOf(h),1)}setTypeParser(c,h,b){return this._types.setTypeParser(c,h,b)}getTypeParser(c,h){return this._types.getTypeParser(c,h)}escapeIdentifier(c){return'"'+c.replace(/"/g,'""')+'"'}escapeLiteral(c){for(var h=!1,b="'",E=0;E<c.length;E++){var C=c[E];C==="'"?b+=C+C:C==="\\"?(b+=C+C,h=!0):b+=C}return b+="'",h===!0&&(b=" E"+b),b}_pulseQueryQueue(){if(this.readyForQuery===!0)if(this.activeQuery=this.queryQueue.shift(),this.activeQuery){this.readyForQuery=!1,this.hasExecuted=!0;let c=this.activeQuery.submit(this.connection);c&&ee.nextTick(()=>{this.activeQuery.handleError(c,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}else this.hasExecuted&&(this.activeQuery=null,this.emit("drain"))}query(c,h,b){var E,C,P,O,M;if(c==null)throw new TypeError("Client was passed a null or undefined query");return typeof c.submit=="function"?(P=c.query_timeout||this.connectionParameters.query_timeout,C=E=c,typeof h=="function"&&(E.callback=E.callback||h)):(P=this.connectionParameters.query_timeout,E=new f(c,h,b),E.callback||(C=new this._Promise((T,I)=>{E.callback=(N,_)=>N?I(N):T(_)}))),P&&(M=E.callback,O=setTimeout(()=>{var T=new Error("Query read timeout");ee.nextTick(()=>{E.handleError(T,this.connection)}),M(T),E.callback=()=>{};var I=this.queryQueue.indexOf(E);I>-1&&this.queryQueue.splice(I,1),this._pulseQueryQueue()},P),E.callback=(T,I)=>{clearTimeout(O),M(T,I)}),this.binary&&!E.binary&&(E.binary=!0),E._result&&!E._result._types&&(E._result._types=this._types),this._queryable?this._ending?(ee.nextTick(()=>{E.handleError(new Error("Client was closed and is not queryable"),this.connection)}),C):(this.queryQueue.push(E),this._pulseQueryQueue(),C):(ee.nextTick(()=>{E.handleError(new Error("Client has encountered a connection error and is not queryable"),this.connection)}),C)}ref(){this.connection.ref()}unref(){this.connection.unref()}end(c){if(this._ending=!0,!this.connection._connecting)if(c)c();else return this._Promise.resolve();if(this.activeQuery||!this._queryable?this.connection.stream.destroy():this.connection.end(),c)this.connection.once("end",c);else return new this._Promise(h=>{this.connection.once("end",h)})}};m(S,"Client");var w=S;w.Query=f,e.exports=w}),Hp=te((s,e)=>{V();var t=Je().EventEmitter,r=m(function(){},"NOOP"),n=m((c,h)=>{let b=c.findIndex(h);return b===-1?void 0:c.splice(b,1)[0]},"removeWhere"),i=class{constructor(h,b,E){this.client=h,this.idleListener=b,this.timeoutId=E}};m(i,"IdleItem");var u=i,a=class{constructor(h){this.callback=h}};m(a,"PendingItem");var f=a;function y(){throw new Error("Release called on client which has already been released to the pool.")}m(y,"throwOnDoubleRelease");function d(c,h){if(h)return{callback:h,result:void 0};let b,E,C=m(function(O,M){O?b(O):E(M)},"cb"),P=new c(function(O,M){E=O,b=M}).catch(O=>{throw Error.captureStackTrace(O),O});return{callback:C,result:P}}m(d,"promisify");function S(c,h){return m(function b(E){E.client=h,h.removeListener("error",b),h.on("error",()=>{c.log("additional client error after disconnection due to error",E)}),c._remove(h),c.emit("error",E,h)},"idleListener")}m(S,"makeIdleListener");var w=class extends t{constructor(h,b){super(),this.options=Object.assign({},h),h!=null&&"password"in h&&Object.defineProperty(this.options,"password",{configurable:!0,enumerable:!1,writable:!0,value:h.password}),h!=null&&h.ssl&&h.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||b||nr().Client,this.Promise=this.options.Promise||Xt.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(b=>{this._remove(b.client)}),this._clients.length||(this.ended=!0,this._endCallback());return}
9if(!this._pendingQueue.length){this.log("no queued requests");return}if(!this._idle.length&&this._isFull())return;let h=this._pendingQueue.shift();if(this._idle.length){let b=this._idle.pop();clearTimeout(b.timeoutId);let E=b.client;E.ref&&E.ref();let C=b.idleListener;return this._acquireClient(E,h,C,!1)}if(!this._isFull())return this.newClient(h);throw new Error("unexpected condition")}_remove(h){let b=n(this._idle,E=>E.client===h);b!==void 0&&clearTimeout(b.timeoutId),this._clients=this._clients.filter(E=>E!==h),h.end(),this.emit("remove",h)}connect(h){if(this.ending){let C=new Error("Cannot use a pool after calling end on the pool");return h?h(C):this.Promise.reject(C)}let b=d(this.Promise,h),E=b.result;if(this._isFull()||this._idle.length){if(this._idle.length&&ee.nextTick(()=>this._pulseQueue()),!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new f(b.callback)),E;let C=m((M,T,I)=>{clearTimeout(O),b.callback(M,T,I)},"queueCallback"),P=new f(C),O=setTimeout(()=>{n(this._pendingQueue,M=>M.callback===C),P.timedOut=!0,b.callback(new Error("timeout exceeded when trying to connect"))},this.options.connectionTimeoutMillis);return O.unref&&O.unref(),this._pendingQueue.push(P),E}return this.newClient(new f(b.callback)),E}newClient(h){let b=new this.Client(this.options);this._clients.push(b);let E=S(this,b);this.log("checking client timeout");let C,P=!1;this.options.connectionTimeoutMillis&&(C=setTimeout(()=>{this.log("ending client due to timeout"),P=!0,b.connection?b.connection.stream.destroy():b.end()},this.options.connectionTimeoutMillis)),this.log("connecting new client"),b.connect(O=>{if(C&&clearTimeout(C),b.on("error",E),O)this.log("client failed to connect",O),this._clients=this._clients.filter(M=>M!==b),P&&(O=new Error("Connection terminated due to connection timeout",{cause:O})),this._pulseQueue(),h.timedOut||h.callback(O,void 0,r);else{if(this.log("new client connected"),this.options.maxLifetimeSeconds!==0){let M=setTimeout(()=>{this.log("ending client due to expired lifetime"),this._expired.add(b),this._idle.findIndex(T=>T.client===b)!==-1&&this._acquireClient(b,new f((T,I,N)=>N()),E,!1)},this.options.maxLifetimeSeconds*1e3);M.unref(),b.once("end",()=>clearTimeout(M))}return this._acquireClient(b,h,E,!0)}})}_acquireClient(h,b,E,C){C&&this.emit("connect",h),this.emit("acquire",h),h.release=this._releaseOnce(h,E),h.removeListener("error",E),b.timedOut?C&&this.options.verify?this.options.verify(h,h.release):h.release():C&&this.options.verify?this.options.verify(h,P=>{if(P)return h.release(P),b.callback(P,void 0,r);b.callback(void 0,h,h.release)}):b.callback(void 0,h,h.release)}_releaseOnce(h,b){let E=!1;return C=>{E&&y(),E=!0,this._release(h,b,C)}}_release(h,b,E){if(h.on("error",b),h._poolUseCount=(h._poolUseCount||0)+1,this.emit("release",E,h),E||this.ending||!h._queryable||h._ending||h._poolUseCount>=this.options.maxUses){h._poolUseCount>=this.options.maxUses&&this.log("remove expended client"),this._remove(h),this._pulseQueue();return}if(this._expired.has(h)){this.log("remove expired client"),this._expired.delete(h),this._remove(h),this._pulseQueue();return}let C;this.options.idleTimeoutMillis&&this._isAboveMin()&&(C=setTimeout(()=>{this.log("remove idle client"),this._remove(h)},this.options.idleTimeoutMillis),this.options.allowExitOnIdle&&C.unref()),this.options.allowExitOnIdle&&h.unref(),this._idle.push(new u(h,b,C)),this._pulseQueue()}query(h,b,E){if(typeof h=="function"){let P=d(this.Promise,h);return ts(function(){return P.callback(new Error("Passing a function as the first parameter to pool.query is not supported"))}),P.result}typeof b=="function"&&(E=b,b=void 0);let C=d(this.Promise,E);return E=C.callback,this.connect((P,O)=>{if(P)return E(P);let M=!1,T=m(I=>{M||(M=!0,O.release(I),E(I))},"onError");O.once("error",T),this.log("dispatching query");try{O.query(h,b,(I,N)=>{if(this.log("query dispatched"),O.removeListener("error",T),!M)return M=!0,O.release(I),I?E(I):E(void 0,N)})}catch(I){return O.release(I),E(I)}}),C.result}end(h){if(this.log("ending"),this.ending){let E=new Error("Called end on pool more than once");return h?h(E):this.Promise.reject(E)}this.ending=!0;let b=d(this.Promise,h);return this._endCallback=b.callback,this._pulseQueue(),b.result}get waitingCount(){return this._pendingQueue.length}get idleCount(){return this._idle.length}get expiredCount(){return this._clients.reduce((h,b)=>h+(this._expired.has(b)?1:0),0)}get totalCount(){return this._clients.length}};m(w,"Pool");var v=w;e.exports=v}),of={};Ne(of,{default:()=>af});var af,Jp=Ee(()=>{V(),af={}}),Gp=te((s,e)=>{e.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-stream
9s":"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"}}),Yp=te((s,e)=>{V();var t=Je().EventEmitter,r=(sr(),ye(Et)),n=rr(),i=e.exports=function(a,f,y){t.call(this),a=n.normalizeQueryConfig(a,f,y),this.text=a.text,this.values=a.values,this.name=a.name,this.callback=a.callback,this.state="new",this._arrayMode=a.rowMode==="array",this._emitRowEvents=!1,this.on("newListener",(function(d){d==="row"&&(this._emitRowEvents=!0)}).bind(this))};r.inherits(i,t);var u={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"schema",tableName:"table",columnName:"column",dataTypeName:"dataType",constraintName:"constraint",sourceFile:"file",sourceLine:"line",sourceFunction:"routine"};i.prototype.handleError=function(a){var f=this.native.pq.resultErrorFields();if(f)for(var y in f){var d=u[y]||y;a[d]=f[y]}this.callback?this.callback(a):this.emit("error",a),this.state="error"},i.prototype.then=function(a,f){return this._getPromise().then(a,f)},i.prototype.catch=function(a){return this._getPromise().catch(a)},i.prototype._getPromise=function(){return this._promise?this._promise:(this._promise=new Promise((function(a,f){this._once("end",a),this._once("error",f)}).bind(this)),this._promise)},i.prototype.submit=function(a){this.state="running";var f=this;this.native=a.native,a.native.arrayMode=this._arrayMode;var y=m(function(w,v,c){if(a.native.arrayMode=!1,ts(function(){f.emit("_done")}),w)return f.handleError(w);f._emitRowEvents&&(c.length>1?v.forEach((h,b)=>{h.forEach(E=>{f.emit("row",E,c[b])})}):v.forEach(function(h){f.emit("row",h,c)})),f.state="end",f.emit("end",c),f.callback&&f.callback(null,c)},"after");if(ee.domain&&(y=ee.domain.bind(y)),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 d=(this.values||[]).map(n.prepareValue);if(a.namedQueries[this.name]){if(this.text&&a.namedQueries[this.name]!==this.text){let w=new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);return y(w)}return a.native.execute(this.name,d,y)}return a.native.prepare(this.name,this.text,d.length,function(w){return w?y(w):(a.namedQueries[f.name]=f.text,f.native.execute(f.name,d,y))})}else if(this.values){if(!Array.isArray(this.values)){let w=new Error("Query values must be an array");return y(w)}var S=this.values.map(n.prepareValue);a.native.query(this.text,S,y)}else a.native.query(this.text,y)}}),Zp=te((s,e)=>{V();var t=(Jp(),ye(of)),r=ss();Gp();var n=Je().EventEmitter,i=(sr(),ye(Et)),u=us(),a=Yp(),f=e.exports=function(y){n.call(this),y=y||{},this._Promise=y.Promise||Xt.Promise,this._types=new r(y.types),this.native=new t({types:this._types}),this._queryQueue=[],this._ending=!1,this._connecting=!1,this._connected=!1,this._queryable=!0;var d=this.connectionParameters=new u(y);this.user=d.user,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:d.password}),this.database=d.database,this.host=d.host,this.port=d.port,this.namedQueries={}};f.Query=a,i.inherits(f,n),f.prototype._errorAllQueries=function(y){let d=m(S=>{ee.nextTick(()=>{S.native=this.native,S.handleError(y)})},"enqueueError");this._hasActiveQuery()&&(d(this._activeQuery),this._activeQuery=null),this._queryQueue.forEach(d),this._queryQueue.length=0},f.prototype._connect=function(y){var d=this;if(this._connecting){ee.nextTick(()=>y(new Error("Client has already been connected. You cannot reuse a client.")));return}this._connecting=!0,this.connectionParameters.getLibpqConnectionString(function(S,w){if
9(S)return y(S);d.native.connect(w,function(v){if(v)return d.native.end(),y(v);d._connected=!0,d.native.on("error",function(c){d._queryable=!1,d._errorAllQueries(c),d.emit("error",c)}),d.native.on("notification",function(c){d.emit("notification",{channel:c.relname,payload:c.extra})}),d.emit("connect"),d._pulseQueryQueue(!0),y()})})},f.prototype.connect=function(y){if(y){this._connect(y);return}return new this._Promise((d,S)=>{this._connect(w=>{w?S(w):d()})})},f.prototype.query=function(y,d,S){var w,v,c,h,b;if(y==null)throw new TypeError("Client was passed a null or undefined query");if(typeof y.submit=="function")c=y.query_timeout||this.connectionParameters.query_timeout,v=w=y,typeof d=="function"&&(y.callback=d);else if(c=this.connectionParameters.query_timeout,w=new a(y,d,S),!w.callback){let E,C;v=new this._Promise((P,O)=>{E=P,C=O}),w.callback=(P,O)=>P?C(P):E(O)}return c&&(b=w.callback,h=setTimeout(()=>{var E=new Error("Query read timeout");ee.nextTick(()=>{w.handleError(E,this.connection)}),b(E),w.callback=()=>{};var C=this._queryQueue.indexOf(w);C>-1&&this._queryQueue.splice(C,1),this._pulseQueryQueue()},c),w.callback=(E,C)=>{clearTimeout(h),b(E,C)}),this._queryable?this._ending?(w.native=this.native,ee.nextTick(()=>{w.handleError(new Error("Client was closed and is not queryable"))}),v):(this._queryQueue.push(w),this._pulseQueryQueue(),v):(w.native=this.native,ee.nextTick(()=>{w.handleError(new Error("Client has encountered a connection error and is not queryable"))}),v)},f.prototype.end=function(y){var d=this;this._ending=!0,this._connected||this.once("connect",this.end.bind(this,y));var S;return y||(S=new this._Promise(function(w,v){y=m(c=>c?v(c):w(),"cb")})),this.native.end(function(){d._errorAllQueries(new Error("Connection terminated")),ee.nextTick(()=>{d.emit("end"),y&&y()})}),S},f.prototype._hasActiveQuery=function(){return this._activeQuery&&this._activeQuery.state!=="error"&&this._activeQuery.state!=="end"},f.prototype._pulseQueryQueue=function(y){if(this._connected&&!this._hasActiveQuery()){var d=this._queryQueue.shift();if(!d){y||this.emit("drain");return}this._activeQuery=d,d.submit(this);var S=this;d.once("_done",function(){S._pulseQueryQueue()})}},f.prototype.cancel=function(y){this._activeQuery===y?this.native.cancel(function(){}):this._queryQueue.indexOf(y)!==-1&&this._queryQueue.splice(this._queryQueue.indexOf(y),1)},f.prototype.ref=function(){},f.prototype.unref=function(){},f.prototype.setTypeParser=function(y,d,S){return this._types.setTypeParser(y,d,S)},f.prototype.getTypeParser=function(y,d){return this._types.getTypeParser(y,d)}}),As=te((s,e)=>{V(),e.exports=Zp()}),nr=te((s,e)=>{V();var t=Kp(),r=tr(),n=nf(),i=Hp(),{DatabaseError:u}=tf(),a=m(y=>{var d;return d=class extends i{constructor(S){super(S,y)}},m(d,"BoundPool"),d},"poolFactory"),f=m(function(y){this.defaults=r,this.Client=y,this.Query=this.Client.Query,this.Pool=a(this.Client),this._pools=[],this.Connection=n,this.types=er(),this.DatabaseError=u},"PG");typeof ee.env.NODE_PG_FORCE_NATIVE<"u"?e.exports=new f(As()):(e.exports=new f(t),Object.defineProperty(e.exports,"native",{configurable:!0,enumerable:!1,get(){var y=null;try{y=new f(As())}catch(d){if(d.code!=="MODULE_NOT_FOUND")throw d}return Object.defineProperty(e.exports,"native",{value:y}),y}}))});V();V();St();Mh();V();var Xp=Object.defineProperty,em=Object.defineProperties,tm=Object.getOwnPropertyDescriptors,xs=Object.getOwnPropertySymbols,rm=Object.prototype.hasOwnProperty,sm=Object.prototype.propertyIsEnumerable,Ns=m((s,e,t)=>e in s?Xp(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,"__defNormalProp"),nm=m((s,e)=>{for(var t in e||(e={}))rm.call(e,t)&&Ns(s,t,e[t]);if(xs)for(var t of xs(e))sm.call(e,t)&&Ns(s,t,e[t]);return s},"__spreadValues"),im=m((s,e)=>em(s,tm(e)),"__spreadProps"),om=1008e3,Is=new Uint8Array(new Uint16Array([258]).buffer)[0]===2,am=new TextDecoder,ls=new TextEncoder,At=ls.encode("0123456789abcdef"),xt=ls.encode("0123456789ABCDEF"),um=ls.encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),uf=um.slice();uf[62]=45;uf[63]=95;var lt,Nt;function lf(s,{alphabet:e,scratchArr:t}={}
9){if(!lt)if(lt=new Uint16Array(256),Nt=new Uint16Array(256),Is)for(let v=0;v<256;v++)lt[v]=At[v&15]<<8|At[v>>>4],Nt[v]=xt[v&15]<<8|xt[v>>>4];else for(let v=0;v<256;v++)lt[v]=At[v&15]|At[v>>>4]<<8,Nt[v]=xt[v&15]|xt[v>>>4]<<8;s.byteOffset%4!==0&&(s=new Uint8Array(s));let r=s.length,n=r>>>1,i=r>>>2,u=t||new Uint16Array(r),a=new Uint32Array(s.buffer,s.byteOffset,i),f=new Uint32Array(u.buffer,u.byteOffset,n),y=e==="upper"?Nt:lt,d=0,S=0,w;if(Is)for(;d<i;)w=a[d++],f[S++]=y[w>>>8&255]<<16|y[w&255],f[S++]=y[w>>>24]<<16|y[w>>>16&255];else for(;d<i;)w=a[d++],f[S++]=y[w>>>24]<<16|y[w>>>16&255],f[S++]=y[w>>>8&255]<<16|y[w&255];for(d<<=2;d<r;)u[d]=y[s[d++]];return am.decode(u.subarray(0,r))}m(lf,"_toHex");function cf(s,e={}){let t="",r=s.length,n=om>>>1,i=Math.ceil(r/n),u=new Uint16Array(i>1?n:r);for(let a=0;a<i;a++){let f=a*n,y=f+n;t+=lf(s.subarray(f,y),im(nm({},e),{scratchArr:u}))}return t}m(cf,"_toHexChunked");function hf(s,e={}){return e.alphabet!=="upper"&&typeof s.toHex=="function"?s.toHex():cf(s,e)}m(hf,"toHex");V();var ff=class df{constructor(e,t){this.strings=e,this.values=t}toParameterizedQuery(e={query:"",params:[]}){var n;let{strings:t,values:r}=this;for(let i=0,u=t.length;i<u;i++)if(e.query+=t[i],i<r.length){let a=r[i];if(a instanceof gf)e.query+=a.sql;else if(a instanceof Ot)if(a.queryData instanceof df)a.queryData.toParameterizedQuery(e);else{if((n=a.queryData.params)!=null&&n.length)throw new Error("This query is not composable");e.query+=a.queryData.query}else{let{params:f}=e;f.push(a),e.query+="$"+f.length,(a instanceof G||ArrayBuffer.isView(a))&&(e.query+="::bytea")}}return e}};m(ff,"SqlTemplate");var pf=ff,mf=class{constructor(e){this.sql=e}};m(mf,"UnsafeRawSql");var gf=mf;V();function cs(){typeof window<"u"&&typeof document<"u"&&typeof console<"u"&&typeof console.warn=="function"&&console.warn(` 10 ************************************************************ 11 * * 12 * WARNING: Running SQL directly from the browser can have * 13 * security implications. Even if your database is * 14 * protected by Row-Level Security (RLS), use it at your * 15 * own risk. This approach is great for fast prototyping, * 16 * but ensure proper safeguards are in place to prevent * 17 * misuse or execution of expensive SQL queries by your * 18 * end users. * 19 * * 20 * If you've assessed the risks, suppress this message * 21 * using the disableWarningInBrowsers configuration * 22 * parameter. * 23 * * 24 ************************************************************`)}m(cs,"warnIfBrowser");St();var lm=He(ss()),cm=He(rr()),yf=class wf extends Error{constructor(e){super(e),Y(this,"name","NeonDbError"),Y(this,"severity"),Y(this,"code"),Y(this,"detail"),Y(this,"hint"),Y(this,"position"),Y(this,"internalPosition"),Y(this,"internalQuery"),Y(this,"where"),Y(this,"schema"),Y(this,"table"),Y(this,"column"),Y(this,"dataType"),Y(this,"constraint"),Y(this,"file"),Y(this,"line"),Y(this,"routine"),Y(this,"sourceError"),"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,wf)}};m(yf,"NeonDbError");var Xe=yf,Ls="transaction() expects an array of queries, or a function returning an array of queries",hm=["severity","code","detail","hint","position","internalPosition","internalQuery","where","schema","table","column","dataType","constraint","file","line","routine"];function bf(s){return s instanceof G?"\\x"+hf(s):s}m(bf,"encodeBuffersAsBytea");function Lr(s){let{query:e,params:t}=s instanceof pf?s.toParameterizedQuery():s;return{query:e,params:t.map(r=>bf((0,cm.prepareValue)(r)))}}m(Lr,"prepareQuery");function ft(s,{arrayMode:e,fullResults:t,fetchOptions:r,isolationLevel:n,readOnly:i,deferrable:u,authToken:a,disableWarningInBrowsers:f}={}){if(!s)throw new Error("No database connection string was provided to `neon()`. Perhaps an environment variable has not been set?");let y;try{y=rs(s)}catch{throw new Error("Database connection string provided to `neon()` is not a valid URL. Connection string: "+String(s))}let{protocol:d,username:S,hostname:w,port:v,pathname:c}=y;if(d!=="postgres:"&&d!=="postgresql:"||!S||!w||!c)throw new Error("Database connection string format for `neon()` should be: postgresql://user:[email protected]/dbname?option=value");function h(E,...C){if(!(Array.isArray(E)&&Array.isArray(E.raw)&&Array.isArray(C)))throw new 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 Ot(b,new pf(E,C))}m(h,"templateFn"),h.query=(E,C,P)=>new Ot(b,{query:E,params:C??[]},P),h.unsafe=E=>new gf(E),h.transaction=async(E,C)=>{if(typeof E=="function"&&(E=E(h)),!Array.isArray(E))throw new Error(Ls);
24E.forEach(M=>{if(!(M instanceof Ot))throw new Error(Ls)});let P=E.map(M=>M.queryData),O=E.map(M=>M.opts??{});return b(P,O,C)};async function b(E,C,P){let{fetchEndpoint:O,fetchFunction:M}=gt,T=Array.isArray(E)?{queries:E.map(se=>Lr(se))}:Lr(E),I=r??{},N=e??!1,_=t??!1,q=n,R=i,U=u;P!==void 0&&(P.fetchOptions!==void 0&&(I={...I,...P.fetchOptions}),P.arrayMode!==void 0&&(N=P.arrayMode),P.fullResults!==void 0&&(_=P.fullResults),P.isolationLevel!==void 0&&(q=P.isolationLevel),P.readOnly!==void 0&&(R=P.readOnly),P.deferrable!==void 0&&(U=P.deferrable)),C!==void 0&&!Array.isArray(C)&&C.fetchOptions!==void 0&&(I={...I,...C.fetchOptions});let z=a;!Array.isArray(C)&&(C==null?void 0:C.authToken)!==void 0&&(z=C.authToken);let D=typeof O=="function"?O(w,v,{jwtAuth:z!==void 0}):O,F={"Neon-Connection-String":s,"Neon-Raw-Text-Output":"true","Neon-Array-Mode":"true"},H=await Sf(z);H&&(F.Authorization=`Bearer ${H}`),Array.isArray(E)&&(q!==void 0&&(F["Neon-Batch-Isolation-Level"]=q),R!==void 0&&(F["Neon-Batch-Read-Only"]=String(R)),U!==void 0&&(F["Neon-Batch-Deferrable"]=String(U))),f||gt.disableWarningInBrowsers||cs();let Z;try{Z=await(M??fetch)(D,{method:"POST",body:JSON.stringify(T),headers:F,...I})}catch(se){let X=new Xe(`Error connecting to database: ${se}`);throw X.sourceError=se,X}if(Z.ok){let se=await Z.json();if(Array.isArray(E)){let X=se.results;if(!Array.isArray(X))throw new Xe("Neon internal error: unexpected result format");return X.map((Te,ie)=>{let fe=C[ie]??{},it=fe.arrayMode??N,ot=fe.fullResults??_;return Br(Te,{arrayMode:it,fullResults:ot,types:fe.types})})}else{let X=C??{},Te=X.arrayMode??N,ie=X.fullResults??_;return Br(se,{arrayMode:Te,fullResults:ie,types:X.types})}}else{let{status:se}=Z;if(se===400){let X=await Z.json(),Te=new Xe(X.message);for(let ie of hm)Te[ie]=X[ie]??void 0;throw Te}else{let X=await Z.text();throw new Xe(`Server error (HTTP status ${se}): ${X}`)}}}return m(b,"execute"),h}m(ft,"neon");var vf=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)}};m(vf,"NeonQueryPromise");var Ot=vf;function Br(s,{arrayMode:e,fullResults:t,types:r}){let n=new lm.default(r),i=s.fields.map(f=>f.name),u=s.fields.map(f=>n.getTypeParser(f.dataTypeID)),a=e===!0?s.rows.map(f=>f.map((y,d)=>y===null?null:u[d](y))):s.rows.map(f=>Object.fromEntries(f.map((y,d)=>[i[d],y===null?null:u[d](y)])));return t?(s.viaNeonFetch=!0,s.rowAsArray=e,s.rows=a,s._parsers=u,s._types=n,s):a}m(Br,"processQueryResult");async function Sf(s){if(typeof s=="string")return s;if(typeof s=="function")try{return await Promise.resolve(s())}catch(e){let t=new Xe("Error getting auth token.");throw e instanceof Error&&(t=new Xe(`Error getting auth token: ${e.message}`)),t}}m(Sf,"getAuthToken");V();var fm=He(nr());V();var dm=He(nr()),Ef=class extends dm.Client{constructor(e){super(e),this.config=e}get neonConfig(){return this.connection.stream}connect(e){var y,d;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=typeof this.config!="string"&&((y=this.config)==null?void 0:y.host)!==void 0||typeof this.config!="string"&&((d=this.config)==null?void 0:d.connectionString)!==void 0||ee.env.PGHOST!==void 0,n=ee.env.USER??ee.env.USERNAME;if(!r&&this.host==="localhost"&&this.user===n&&this.database===n&&this.password===null)throw new Error(`No database host or connection string was set, and key parameters have default values (host: localhost, user: ${n}, db: ${n}, password: null). Is an environment variable missing? Alternatively, if you intended to connect with these parameters, please set the host to 'localhost' explicitly.`);let i=super.connect(e),u=t.pipelineTLS&&this.ssl,a=t.pipelineConnect==="password";if(!u&&!t.pipelineConnect)return i;let f=this.connection;if(u&&f.on("connect",()=>f.stream.emit("data","S")),a){f.removeAllListeners("authenticationCleartextPassword"),f.removeAllListeners("readyForQuery"),f.once("readyForQuery",()=>f.on("readyForQuery",this._handleReadyForQuery.bind(this)));let S=this.ssl?"sslconnect":"connect";f.on(S,()=>{this.neonConfig.disableWarningInBrowsers||cs(),this._handleAuthCleartextPassword(),this._handleReadyForQuery()})}return i}async _handleAuthSASLContinue(e){if(typeof crypto>"u"||crypto.subtle===void 0||crypto.subtle.importKey===void 0)throw new Error("Cannot use SASL auth when `crypto.subtle` is not defined");let t=crypto.subtle,r=this.saslSession,n=this.password,i=e.data;
24if(r.message!=="SASLInitialResponse"||typeof n!="string"||typeof i!="string")throw new Error("SASL: protocol error");let u=Object.fromEntries(i.split(",").map(se=>{if(!/^.=/.test(se))throw new Error("SASL: Invalid attribute pair entry");let X=se[0],Te=se.substring(2);return[X,Te]})),a=u.r,f=u.s,y=u.i;if(!a||!/^[!-+--~]+$/.test(a))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing/unprintable");if(!f||!/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test(f))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing/not base64");if(!y||!/^[1-9][0-9]*$/.test(y))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: missing/invalid iteration count");if(!a.startsWith(r.clientNonce))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");if(a.length===r.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short");let d=parseInt(y,10),S=G.from(f,"base64"),w=new TextEncoder,v=w.encode(n),c=await t.importKey("raw",v,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),h=new Uint8Array(await t.sign("HMAC",c,G.concat([S,G.from([0,0,0,1])]))),b=h;for(var E=0;E<d-1;E++)h=new Uint8Array(await t.sign("HMAC",c,h)),b=G.from(b.map((se,X)=>b[X]^h[X]));let C=b,P=await t.importKey("raw",C,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),O=new Uint8Array(await t.sign("HMAC",P,w.encode("Client Key"))),M=await t.digest("SHA-256",O),T="n=*,r="+r.clientNonce,I="r="+a+",s="+f+",i="+d,N="c=biws,r="+a,_=T+","+I+","+N,q=await t.importKey("raw",M,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);var R=new Uint8Array(await t.sign("HMAC",q,w.encode(_))),U=G.from(O.map((se,X)=>O[X]^R[X])),z=U.toString("base64");let D=await t.importKey("raw",C,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),F=await t.sign("HMAC",D,w.encode("Server Key")),H=await t.importKey("raw",F,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);var Z=G.from(await t.sign("HMAC",H,w.encode(_)));r.message="SASLResponse",r.serverSignature=Z.toString("base64"),r.response=N+",p="+z,this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}};m(Ef,"NeonClient");var pm=Ef;St();var mm=He(us());function Tf(s,e){if(e)return{callback:e,result:void 0};let t,r,n=m(function(u,a){u?t(u):r(a)},"cb"),i=new s(function(u,a){r=u,t=a});return{callback:n,result:i}}m(Tf,"promisify");var gm=class extends fm.Pool{constructor(){super(...arguments),Y(this,"Client",pm),Y(this,"hasFetchUnsupportedListeners",!1),Y(this,"addListener",this.on)}on(e,t){return e!=="error"&&(this.hasFetchUnsupportedListeners=!0),super.on(e,t)}query(e,t,r){var i;if(!gt.poolQueryViaFetch||this.hasFetchUnsupportedListeners||typeof e=="function")return super.query(e,t,r);typeof t=="function"&&(r=t,t=void 0);let n=Tf(this.Promise,r);r=n.callback;try{let u=new mm.default(this.options),a=encodeURIComponent,f=encodeURI,y=`postgresql://${a(u.user)}:${a(u.password)}@${a(u.host)}/${f(u.database)}`,d=typeof e=="string"?e:e.text,S=t??e.values??[];ft(y,{fullResults:!0,arrayMode:e.rowMode==="array"}).query(d,S,{types:e.types??((i=this.options)==null?void 0:i.types)}).then(w=>r(void 0,w)).catch(w=>r(w))}catch(u){r(u)}return n.result}};m(gm,"NeonPool");St();var Tt=He(nr());Tt.DatabaseError;Tt.defaults;Tt.escapeIdentifier;Tt.escapeLiteral;var _e=Tt.types;/*! Bundled license information: 25 26ieee754/index.js: 27 (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *) 28 29buffer/index.js: 30 (*! 31 * The buffer module from node.js, for the browser. 32 * 33 * @author Feross Aboukhadijeh <https://feross.org> 34 * @license MIT 35 *) 36*/const It={arrayMode:!1,fullResults:!0},Or={arrayMode:!0,fullResults:!0};var il,ol;class _f extends(ol=Nh,il=L,ol){constructor(t,r,n,i,u,a,f,y,d){super(r,i,u,a);g(this,"clientQuery");this.client=t,this.logger=n,this.fields=f,this._isResponseInArrayMode=y,this.customResultMapper=d,this.clientQuery=t.query??t}async execute(t={},r=this.authToken){const n=pr(this.query.params,t);this.logger.logQuery(this.query.sql,n);const{fields:i,clientQuery:u,query:a,customResultMapper:f}=this;if(!i&&!f)return this.queryWithCache(a.sql,n,async()=>u(a.sql,n,r===void 0?It:{...It,authToken:r}));const y=await this.queryWithCache(a.sql,n,async()=>await u(a.sql,n,r===void 0?Or:{...Or,authToken:r}));return this.mapResult(y)}mapResult(t){if(!this.fields&&!this.customResultMapper)return t;const r=t.rows;return this.customResultMapper?this.customResultMapper(r):r.map(n=>Xf(this.fields,n,this.joinsNotNullableMap))}all(t={}){const r=pr(this.query.params,t);return this.logger.logQuery(this.query.sql,r),this.clientQuery(this.query.sql,r,this.authToken===void 0?It:{...It,authToken:this.authToken}).then(n=>n.rows)}values(t={},r){const n=pr(this.query.params,t);return this.logger.logQuery(this.query.sql,n),this.clientQuery(this.query.sql,n,{arrayMode:!0,fullResults:!0,authToken:r}).then(i=>i.rows)}isResponseInArrayMode(){return this._isResponseInArrayMode}}g(_f,il,"NeonHttpPreparedQuery");var al,ul;class Cf extends(ul=Ih,al=L,ul){constructor(t,r,n,i={}){super(r);g(this,"clientQuery");g(this,"logger");
36g(this,"cache");this.client=t,this.schema=n,this.options=i,this.clientQuery=t.query??t,this.logger=i.logger??new ql,this.cache=i.cache??new Xr}prepareQuery(t,r,n,i,u,a,f){return new _f(this.client,t,this.logger,this.cache,a,f,r,i,u)}async batch(t){const r=[],n=[];for(const u of t){const a=u._prepare(),f=a.getQuery();r.push(a),n.push(this.clientQuery(f.sql,f.params,{fullResults:!0,arrayMode:a.isResponseInArrayMode()}))}return(await this.client.transaction(n,Or)).map((u,a)=>r[a].mapResult(u,!0))}async query(t,r){return this.logger.logQuery(t,r),await this.clientQuery(t,r,{arrayMode:!0,fullResults:!0})}async queryObjects(t,r){return this.clientQuery(t,r,{arrayMode:!1,fullResults:!0})}async count(t,r){const n=await this.execute(t,r);return Number(n.rows[0].count)}async transaction(t,r={}){throw new Error("No transactions support in neon-http driver")}}g(Cf,al,"NeonHttpSession");var ll;ll=L;class Pf{constructor(e,t,r={}){this.client=e,this.dialect=t,this.options=r,this.initMappers()}createSession(e){return new Cf(this.client,this.dialect,e,{logger:this.options.logger,cache:this.options.cache})}initMappers(){_e.setTypeParser(_e.builtins.TIMESTAMPTZ,e=>e),_e.setTypeParser(_e.builtins.TIMESTAMP,e=>e),_e.setTypeParser(_e.builtins.DATE,e=>e),_e.setTypeParser(_e.builtins.INTERVAL,e=>e),_e.setTypeParser(1231,e=>e),_e.setTypeParser(1115,e=>e),_e.setTypeParser(1185,e=>e),_e.setTypeParser(1187,e=>e),_e.setTypeParser(1182,e=>e)}}g(Pf,ll,"NeonHttpDriver");function Ft(s,e,t,r){return new Proxy(s,{get(n,i){const u=n[i];return typeof u!="function"&&(typeof u!="object"||u===null)?u:r?Ft(u,e,t):i==="query"?Ft(u,e,t,!0):new Proxy(u,{apply(a,f,y){const d=a.call(f,...y);return typeof d=="object"&&d!==null&&"setToken"in d&&typeof d.setToken=="function"&&d.setToken(e),t(a,i,d)}})}})}var cl,hl;class Af extends(hl=Ch,cl=L,hl){$withAuth(e){return this.authToken=e,Ft(this,e,(t,r,n)=>r==="with"?Ft(n,e,(i,u,a)=>a):n)}async batch(e){return this.session.batch(e)}}g(Af,cl,"NeonHttpDatabase");function Ze(s,e={}){var f;const t=new ct({casing:e.casing});let r;e.logger===!0?r=new Dl:e.logger!==!1&&(r=e.logger);let n;if(e.schema){const y=Jd(e.schema,Xd);n={fullSchema:e.schema,schema:y.tables,tableNamesMap:y.tableNamesMap}}const u=new Pf(s,t,{logger:r,cache:e.cache}).createSession(n),a=new Af(t,u,n);return a.$client=s,a.$cache=e.cache,a.$cache&&(a.$cache.invalidate=(f=e.cache)==null?void 0:f.onMutate),a}function Rr(...s){if(typeof s[0]=="string"){const e=ft(s[0]);return Ze(e,s[1])}if(td(s[0])){const{connection:e,client:t,...r}=s[0];if(t)return Ze(t,r);if(typeof e=="object"){const{connectionString:i,...u}=e,a=ft(i,u);return Ze(a,r)}const n=ft(e);return Ze(n,r)}return Ze(s[0],s[1])}(s=>{function e(t){return Ze({},t)}s.mock=e})(Rr||(Rr={}));const xf=tc({dataType(){return"bytea"},toDriver(s){return s},fromDriver(s){return s}}),Nf=Wt("sppg_source",["web","Data_SPPG_Yayasan_260925.pdf"]),ir=rt("sppg",{id:Ie("id").primaryKey().$default(()=>Mr()),name:ne("name").notNull(),createdAt:De("created_at").defaultNow().notNull(),updatedAt:De("updated_at").defaultNow().notNull().$onUpdate(()=>new Date),rawProvince:ne("raw_province").notNull(),rawRegency:ne("raw_regency").notNull(),rawDistrict:ne("raw_district").notNull(),rawVillage:ne("raw_village").notNull(),source:Nf("source").notNull(),provinceId:le("province_id").references(()=>Gt.id),regencyId:le("regency_id").references(()=>Yt.id),districtId:le("district_id").references(()=>Zt.id),villageId:Ht("village_id",{mode:"number"}).references(()=>es.id),operationalDate:Jt("operational_date"),sppi:ne("head_name"),type:ne("t
36ype"),phone:ne("phone")},s=>[ml("sppg_raw_unique").on(s.name,s.rawProvince,s.rawRegency,s.rawDistrict,s.rawVillage,s.operationalDate,s.sppi)]),If=Wt("education_level",["tk","sd","smp","sma","lainnya"]),Lf=rt("schools",{id:Ie("id").primaryKey().$default(()=>Mr()),npsn:ne("npsn").notNull().unique(),name:ne("name").notNull(),educationLevel:If("education_level"),sppgId:Ie("sppg_id").references(()=>ir.id),createdAt:De("created_at").defaultNow().notNull(),updatedAt:De("updated_at").notNull().$onUpdate(()=>new Date),raw:pc("raw"),rawProvince:ne("raw_province").notNull(),rawRegency:ne("raw_regency").notNull(),rawDistrict:ne("raw_district").notNull(),rawVillage:ne("raw_village").notNull(),provinceId:le("province_id").references(()=>Gt.id),regencyId:le("regency_id").references(()=>Yt.id),districtId:le("district_id").references(()=>Zt.id),villageId:Ht("village_id",{mode:"number"}).references(()=>es.id)},s=>[Es("schools_name_btree").using("btree",s.name.op("text_pattern_ops")),Es("schools_name_gin").using("gin",s.name.op("gin_trgm_ops"))]),Bf=Wt("role",["siswa","guru","ortu","ibu_balita"]),Of=Wt("gender",["laki-laki","perempuan"]),Rf=rt("accounts",{id:Ie("id").defaultRandom().primaryKey(),email:ne("email").notNull().unique(),name:ne("name").notNull(),avatarPath:ne("avatar_path"),role:Bf("role").notNull(),schoolId:Ie("school_id").references(()=>Lf.id),sppgId:Ie("sppg_id").references(()=>ir.id),passwordHash:xf("password_hash").notNull(),phone:ne("phone"),gender:Of("gender"),birthDate:Jt("birth_date"),bot:Qr("bot").notNull().default(!1),createdAt:De("created_at").defaultNow().notNull(),updatedAt:De("updated_at").defaultNow().notNull().$onUpdate(()=>new Date)}),ym=rt("reviews",{id:Ie("id").primaryKey().$default(()=>Mr()),accountId:Ie("account_id").references(()=>Rf.id).notNull(),sppgId:Ie("sppg_id").references(()=>ir.id).notNull(),date:Jt().notNull().generatedAlwaysAs(x`DATE(created_at AT TIME ZONE 'UTC' AT TIME ZONE 'Asia/Jakarta')`),photoPaths:ne("photo_paths").array().notNull().default([]),bot:Qr("bot").default(!1).notNull(),tasteRating:le("taste_rating").notNull(),appearanceRating:le("appearance_rating").notNull(),timingRating:le("timing_rating").notNull(),nutritionalNeedsRating:le("nutritional_needs_rating").notNull(),karbohidratRating:le("karbohidrat_rating").notNull(),proteinRating:le("protein_rating").notNull(),sayuranRating:le("sayuran_rating").notNull(),buahRating:le("buah_rating").notNull(),susuRating:le("susu_rating").notNull(),generalNotes:ne("general_notes"),requestKarbo:ne("request_karbo"),requestProtein:ne("request_protein"),requestSayuran:ne("request_sayuran"),requestBuah:ne("request_buah"),requestSusu:ne("request_susu"),overallTasteRating:vr("overall_taste_rating").generatedAlwaysAs(x`(taste_rating + appearance_rating + timing_rating + nutritional_needs_rating * 2)::real / 5`).notNull(),overallNutritionRating:vr("overall_nutrition_rating").generatedAlwaysAs(x`(karbohidrat_rating + protein_rating + sayuran_rating + buah_rating + susu_rating)::real / 5`).notNull(),createdAt:De("created_at").defaultNow().notNull(),updatedAt:De("updated_at").defaultNow().notNull().$onUpdate(()=>new Date)},s=>[ml().on(s.date,s.accountId)]);function wm(s){return x.raw(`excluded.${s.name}`)}const bm=Object.freeze(Object.defineProperty({__proto__:null,accounts:Rf,bytea:xf,districts:Zt,educationLevelEnum:If,excluded:wm,genderEnum:Of,geo:vt,provinces:Gt,regencies:Yt,reviews:ym,roleEnum:Bf,schools:Lf,sppg:ir,sppgSource:Nf,villages:es},Symbol.toStringTag,{value:"Module"}));function Xm(s){return Rr(s.POSTGRES_DSN,{schema:bm})}export{Fd as $,Ml as A,Dl as B,mt as C,Rl as D,hh as E,Yd as F,Gd as G,Xd as H,Jd as I,Kd as J,Hd as K,Tr as L,$t as M,ql as N,Ke as O,Zd as P,ke as Q,Jr as R,Qd as S,Kt as T,Se as U,qd as V,Nd as W,Id as X,Od as Y,Dd as Z,Md as _,Rf as a,Ld as a0,Bd as a1,Pd as a2,xd as a3,kd as a4,$d as a5,zd as a6,Rd as a7,jd as a8,Ad as a9,je as aA,qr as aB,td as aC,Xf as aD,$l as aE,We as aF,pe as aG,Dt as aa,Me as ab,Ve as ac,W as ad,ge as ae,Qe as af,pr as ag,Yf as ah,Il as ai,Ll as aj,Bl as ak,ve as al,Dr as am,dr as an,br as ao,bs as ap,ws as aq,Mt as ar,fr as as,et as at,j as au,Re as av,pt as aw,ed as ax,we as ay,$r as az,x as b,ir as c,Zt as d,ch as e,Er as f,Xm as g,ym as h,Ud as i,wm as j,Wd as k,Vd as l,mr as m,Oe as n,Ol as o,Gt as p,qt as q,Yt as r,Lf as s,fl as t,de as u,es as v,L as w,Q as x,qe as y,Em as z};
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.