drizzle-postgis
Advanced tools
Comparing version 1.0.0 to 1.1.0
(function (exports) { | ||
'use strict'; | ||
var er=Object.create;var qt=Object.defineProperty;var rr=Object.getOwnPropertyDescriptor;var nr=Object.getOwnPropertyNames;var ir=Object.getPrototypeOf,or=Object.prototype.hasOwnProperty;var A=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var L=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),St=(t,e)=>{for(var r in e)qt(t,r,{get:e[r],enumerable:!0});},sr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of nr(e))!or.call(t,i)&&i!==r&&qt(t,i,{get:()=>e[i],enumerable:!(n=rr(e,i))||n.enumerable});return t};var ar=(t,e,r)=>(r=t!=null?er(ir(t)):{},sr(e||!t||!t.__esModule?qt(r,"default",{value:t,enumerable:!0}):r,t));var $=L((ri,Te)=>{Te.exports={wkt:{Point:"POINT",LineString:"LINESTRING",Polygon:"POLYGON",MultiPoint:"MULTIPOINT",MultiLineString:"MULTILINESTRING",MultiPolygon:"MULTIPOLYGON",GeometryCollection:"GEOMETRYCOLLECTION"},wkb:{Point:1,LineString:2,Polygon:3,MultiPoint:4,MultiLineString:5,MultiPolygon:6,GeometryCollection:7},geoJSON:{Point:"Point",LineString:"LineString",Polygon:"Polygon",MultiPoint:"MultiPoint",MultiLineString:"MultiLineString",MultiPolygon:"MultiPolygon",GeometryCollection:"GeometryCollection"}};});var R=L((ni,Oe)=>{Oe.exports=v;function v(t,e){this.buffer=new Buffer(t),this.position=0,this.allowResize=e;}function _(t,e){return function(r,n){this.ensureSize(e),t.call(this.buffer,r,this.position,n),this.position+=e;}}v.prototype.writeUInt8=_(Buffer.prototype.writeUInt8,1);v.prototype.writeUInt16LE=_(Buffer.prototype.writeUInt16LE,2);v.prototype.writeUInt16BE=_(Buffer.prototype.writeUInt16BE,2);v.prototype.writeUInt32LE=_(Buffer.prototype.writeUInt32LE,4);v.prototype.writeUInt32BE=_(Buffer.prototype.writeUInt32BE,4);v.prototype.writeInt8=_(Buffer.prototype.writeInt8,1);v.prototype.writeInt16LE=_(Buffer.prototype.writeInt16LE,2);v.prototype.writeInt16BE=_(Buffer.prototype.writeInt16BE,2);v.prototype.writeInt32LE=_(Buffer.prototype.writeInt32LE,4);v.prototype.writeInt32BE=_(Buffer.prototype.writeInt32BE,4);v.prototype.writeFloatLE=_(Buffer.prototype.writeFloatLE,4);v.prototype.writeFloatBE=_(Buffer.prototype.writeFloatBE,4);v.prototype.writeDoubleLE=_(Buffer.prototype.writeDoubleLE,8);v.prototype.writeDoubleBE=_(Buffer.prototype.writeDoubleBE,8);v.prototype.writeBuffer=function(t){this.ensureSize(t.length),t.copy(this.buffer,this.position,0,t.length),this.position+=t.length;};v.prototype.writeVarInt=function(t){for(var e=1;t&4294967168;)this.writeUInt8(t&127|128),t>>>=7,e++;return this.writeUInt8(t&127),e};v.prototype.ensureSize=function(t){if(this.buffer.length<this.position+t)if(this.allowResize){var e=new Buffer(this.position+t);this.buffer.copy(e,0,0,this.buffer.length),this.buffer=e;}else throw new RangeError("index out of range")};});var re=L((ii,Le)=>{Le.exports={encode:function(t){return t<<1^t>>31},decode:function(t){return t>>1^-(t&1)}};});var D=L((oi,Ge)=>{Ge.exports=l;var pr=A("util"),Mt=J(),at=$(),Ne=R(),E=re();function l(t,e,r,n,i){Mt.call(this),this.x=t,this.y=e,this.z=r,this.m=n,this.srid=i,this.hasZ=typeof this.z<"u",this.hasM=typeof this.m<"u";}pr.inherits(l,Mt);l.Z=function(t,e,r,n){var i=new l(t,e,r,void 0,n);return i.hasZ=!0,i};l.M=function(t,e,r,n){var i=new l(t,e,void 0,r,n);return i.hasM=!0,i};l.ZM=function(t,e,r,n,i){var o=new l(t,e,r,n,i);return o.hasZ=!0,o.hasM=!0,o};l._parseWkt=function(t,e){var r=new l;if(r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM,t.isMatch(["EMPTY"]))return r;t.expectGroupStart();var n=t.matchCoordinate(e);return r.x=n.x,r.y=n.y,r.z=n.z,r.m=n.m,t.expectGroupEnd(),r};l._parseWkb=function(t,e){var r=l._readWkbPoint(t,e);return r.srid=e.srid,r};l._readWkbPoint=function(t,e){return new l(t.readDouble(),t.readDouble(),e.hasZ?t.readDouble():void 0,e.hasM?t.readDouble():void 0)};l._parseTwkb=function(t,e){var r=new l;return r.hasZ=e.hasZ,r.hasM=e.hasM,e.isEmpty||(r.x=E.decode(t.readVarInt())/e.precisionFactor,r.y=E.decode(t.readVarInt())/e.precisionFactor,r.z=e.hasZ?E.decode(t.readVarInt())/e.zPrecisionFactor:void 0,r.m=e.hasM?E.decode(t.readVarInt())/e.mPrecisionFactor:void 0),r};l._readTwkbPoint=function(t,e,r){return r.x+=E.decode(t.readVarInt())/e.precisionFactor,r.y+=E.decode(t.readVarInt())/e.precisionFactor,e.hasZ&&(r.z+=E.decode(t.readVarInt())/e.zPrecisionFactor),e.hasM&&(r.m+=E.decode(t.readVarInt())/e.mPrecisionFactor),new l(r.x,r.y,r.z,r.m)};l._parseGeoJSON=function(t){return l._readGeoJSONPoint(t.coordinates)};l._readGeoJSONPoint=function(t){return t.length===0?new l:t.length>2?new l(t[0],t[1],t[2]):new l(t[0],t[1])};l.prototype.toWkt=function(){return typeof this.x>"u"&&typeof this.y>"u"&&typeof this.z>"u"&&typeof this.m>"u"?this._getWktType(at.wkt.Point,!0):this._getWktType(at.wkt.Point,!1)+"("+this._getWktCoordinate(this)+")"};l.prototype.toWkb=function(t){var e=new Ne(this._getWkbSize());return e.writeInt8(1),this._writeWkbType(e,at.wkb.Point,t),typeof this.x>"u"&&typeof this.y>"u"?(e.writeDoubleLE(NaN),e.writeDoubleLE(NaN),this.hasZ&&e.writeDoubleLE(NaN),this.hasM&&e.writeDoubleLE(NaN)):this._writeWkbPoint(e),e.buffer};l.prototype._writeWkbPoint=function(t){t.writeDoubleLE(this.x),t.writeDoubleLE(this.y),this.hasZ&&t.writeDoubleLE(this.z),this.hasM&&t.writeDoubleLE(this.m);};l.prototype.toTwkb=function(){var t=new Ne(0,!0),e=Mt.getTwkbPrecision(5,0,0),r=typeof this.x>"u"&&typeof this.y>"u";return this._writeTwkbHeader(t,at.wkb.Point,e,r),r||this._writeTwkbPoint(t,e,new l(0,0,0,0)),t.buffer};l.prototype._writeTwkbPoint=function(t,e,r){var n=this.x*e.xyFactor,i=this.y*e.xyFactor,o=this.z*e.zFactor,s=this.m*e.mFactor;t.writeVarInt(E.encode(n-r.x)),t.writeVarInt(E.encode(i-r.y)),this.hasZ&&t.writeVarInt(E.encode(o-r.z)),this.hasM&&t.writeVarInt(E.encode(s-r.m)),r.x=n,r.y=i,r.z=o,r.m=s;};l.prototype._getWkbSize=function(){var t=21;return this.hasZ&&(t+=8),this.hasM&&(t+=8),t};l.prototype.toGeoJSON=function(t){var e=Mt.prototype.toGeoJSON.call(this,t);return e.type=at.geoJSON.Point,typeof this.x>"u"&&typeof this.y>"u"?e.coordinates=[]:typeof this.z<"u"?e.coordinates=[this.x,this.y,this.z]:e.coordinates=[this.x,this.y],e};});var vt=L((si,We)=>{We.exports=m;var fr=A("util"),Pt=J(),ut=$(),ht=D(),_e=R();function m(t,e){Pt.call(this),this.points=t||[],this.srid=e,this.points.length>0&&(this.hasZ=this.points[0].hasZ,this.hasM=this.points[0].hasM);}fr.inherits(m,Pt);m.Z=function(t,e){var r=new m(t,e);return r.hasZ=!0,r};m.M=function(t,e){var r=new m(t,e);return r.hasM=!0,r};m.ZM=function(t,e){var r=new m(t,e);return r.hasZ=!0,r.hasM=!0,r};m._parseWkt=function(t,e){var r=new m;return r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM,t.isMatch(["EMPTY"])||(t.expectGroupStart(),r.points.push.apply(r.points,t.matchCoordinates(e)),t.expectGroupEnd()),r};m._parseWkb=function(t,e){var r=new m;r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM;for(var n=t.readUInt32(),i=0;i<n;i++)r.points.push(ht._readWkbPoint(t,e));return r};m._parseTwkb=function(t,e){var r=new m;if(r.hasZ=e.hasZ,r.hasM=e.hasM,e.isEmpty)return r;for(var n=new ht(0,0,e.hasZ?0:void 0,e.hasM?0:void 0),i=t.readVarInt(),o=0;o<i;o++)r.points.push(ht._readTwkbPoint(t,e,n));return r};m._parseGeoJSON=function(t){var e=new m;t.coordinates.length>0&&(e.hasZ=t.coordinates[0].length>2);for(var r=0;r<t.coordinates.length;r++)e.points.push(ht._readGeoJSONPoint(t.coordinates[r]));return e};m.prototype.toWkt=function(){return this.points.length===0?this._getWktType(ut.wkt.LineString,!0):this._getWktType(ut.wkt.LineString,!1)+this._toInnerWkt()};m.prototype._toInnerWkt=function(){for(var t="(",e=0;e<this.points.length;e++)t+=this._getWktCoordinate(this.points[e])+",";return t=t.slice(0,-1),t+=")",t};m.prototype.toWkb=function(t){var e=new _e(this._getWkbSize());e.writeInt8(1),this._writeWkbType(e,ut.wkb.LineString,t),e.writeUInt32LE(this.points.length);for(var r=0;r<this.points.length;r++)this.points[r]._writeWkbPoint(e);return e.buffer};m.prototype.toTwkb=function(){var t=new _e(0,!0),e=Pt.getTwkbPrecision(5,0,0),r=this.points.length===0;if(this._writeTwkbHeader(t,ut.wkb.LineString,e,r),this.points.length>0){t.writeVarInt(this.points.length);for(var n=new ht(0,0,0,0),i=0;i<this.points.length;i++)this.points[i]._writeTwkbPoint(t,e,n);}return t.buffer};m.prototype._getWkbSize=function(){var t=16;return this.hasZ&&(t+=8),this.hasM&&(t+=8),9+this.points.length*t};m.prototype.toGeoJSON=function(t){var e=Pt.prototype.toGeoJSON.call(this,t);e.type=ut.geoJSON.LineString,e.coordinates=[];for(var r=0;r<this.points.length;r++)this.hasZ?e.coordinates.push([this.points[r].x,this.points[r].y,this.points[r].z]):e.coordinates.push([this.points[r].x,this.points[r].y]);return e};});var Ot=L((ai,$e)=>{$e.exports=d;var lr=A("util"),Tt=J(),pt=$(),z=D(),Ee=R();function d(t,e,r){Tt.call(this),this.exteriorRing=t||[],this.interiorRings=e||[],this.srid=r,this.exteriorRing.length>0&&(this.hasZ=this.exteriorRing[0].hasZ,this.hasM=this.exteriorRing[0].hasM);}lr.inherits(d,Tt);d.Z=function(t,e,r){var n=new d(t,e,r);return n.hasZ=!0,n};d.M=function(t,e,r){var n=new d(t,e,r);return n.hasM=!0,n};d.ZM=function(t,e,r){var n=new d(t,e,r);return n.hasZ=!0,n.hasM=!0,n};d._parseWkt=function(t,e){var r=new d;if(r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM,t.isMatch(["EMPTY"]))return r;for(t.expectGroupStart(),t.expectGroupStart(),r.exteriorRing.push.apply(r.exteriorRing,t.matchCoordinates(e)),t.expectGroupEnd();t.isMatch([","]);)t.expectGroupStart(),r.interiorRings.push(t.matchCoordinates(e)),t.expectGroupEnd();return t.expectGroupEnd(),r};d._parseWkb=function(t,e){var r=new d;r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM;var n=t.readUInt32();if(n>0){for(var i=t.readUInt32(),o=0;o<i;o++)r.exteriorRing.push(z._readWkbPoint(t,e));for(o=1;o<n;o++){for(var s=[],c=t.readUInt32(),p=0;p<c;p++)s.push(z._readWkbPoint(t,e));r.interiorRings.push(s);}}return r};d._parseTwkb=function(t,e){var r=new d;if(r.hasZ=e.hasZ,r.hasM=e.hasM,e.isEmpty)return r;for(var n=new z(0,0,e.hasZ?0:void 0,e.hasM?0:void 0),i=t.readVarInt(),o=t.readVarInt(),s=0;s<o;s++)r.exteriorRing.push(z._readTwkbPoint(t,e,n));for(s=1;s<i;s++){for(var c=[],p=t.readVarInt(),a=0;a<p;a++)c.push(z._readTwkbPoint(t,e,n));r.interiorRings.push(c);}return r};d._parseGeoJSON=function(t){var e=new d;t.coordinates.length>0&&t.coordinates[0].length>0&&(e.hasZ=t.coordinates[0][0].length>2);for(var r=0;r<t.coordinates.length;r++){r>0&&e.interiorRings.push([]);for(var n=0;n<t.coordinates[r].length;n++)r===0?e.exteriorRing.push(z._readGeoJSONPoint(t.coordinates[r][n])):e.interiorRings[r-1].push(z._readGeoJSONPoint(t.coordinates[r][n]));}return e};d.prototype.toWkt=function(){return this.exteriorRing.length===0?this._getWktType(pt.wkt.Polygon,!0):this._getWktType(pt.wkt.Polygon,!1)+this._toInnerWkt()};d.prototype._toInnerWkt=function(){for(var t="((",e=0;e<this.exteriorRing.length;e++)t+=this._getWktCoordinate(this.exteriorRing[e])+",";for(t=t.slice(0,-1),t+=")",e=0;e<this.interiorRings.length;e++){t+=",(";for(var r=0;r<this.interiorRings[e].length;r++)t+=this._getWktCoordinate(this.interiorRings[e][r])+",";t=t.slice(0,-1),t+=")";}return t+=")",t};d.prototype.toWkb=function(t){var e=new Ee(this._getWkbSize());e.writeInt8(1),this._writeWkbType(e,pt.wkb.Polygon,t),this.exteriorRing.length>0?(e.writeUInt32LE(1+this.interiorRings.length),e.writeUInt32LE(this.exteriorRing.length)):e.writeUInt32LE(0);for(var r=0;r<this.exteriorRing.length;r++)this.exteriorRing[r]._writeWkbPoint(e);for(r=0;r<this.interiorRings.length;r++){e.writeUInt32LE(this.interiorRings[r].length);for(var n=0;n<this.interiorRings[r].length;n++)this.interiorRings[r][n]._writeWkbPoint(e);}return e.buffer};d.prototype.toTwkb=function(){var t=new Ee(0,!0),e=Tt.getTwkbPrecision(5,0,0),r=this.exteriorRing.length===0;if(this._writeTwkbHeader(t,pt.wkb.Polygon,e,r),this.exteriorRing.length>0){t.writeVarInt(1+this.interiorRings.length),t.writeVarInt(this.exteriorRing.length);for(var n=new z(0,0,0,0),i=0;i<this.exteriorRing.length;i++)this.exteriorRing[i]._writeTwkbPoint(t,e,n);for(i=0;i<this.interiorRings.length;i++){t.writeVarInt(this.interiorRings[i].length);for(var o=0;o<this.interiorRings[i].length;o++)this.interiorRings[i][o]._writeTwkbPoint(t,e,n);}}return t.buffer};d.prototype._getWkbSize=function(){var t=16;this.hasZ&&(t+=8),this.hasM&&(t+=8);var e=9;this.exteriorRing.length>0&&(e+=4+this.exteriorRing.length*t);for(var r=0;r<this.interiorRings.length;r++)e+=4+this.interiorRings[r].length*t;return e};d.prototype.toGeoJSON=function(t){var e=Tt.prototype.toGeoJSON.call(this,t);if(e.type=pt.geoJSON.Polygon,e.coordinates=[],this.exteriorRing.length>0){for(var r=[],n=0;n<this.exteriorRing.length;n++)this.hasZ?r.push([this.exteriorRing[n].x,this.exteriorRing[n].y,this.exteriorRing[n].z]):r.push([this.exteriorRing[n].x,this.exteriorRing[n].y]);e.coordinates.push(r);}for(var i=0;i<this.interiorRings.length;i++){for(var o=[],s=0;s<this.interiorRings[i].length;s++)this.hasZ?o.push([this.interiorRings[i][s].x,this.interiorRings[i][s].y,this.interiorRings[i][s].z]):o.push([this.interiorRings[i][s].x,this.interiorRings[i][s].y]);e.coordinates.push(o);}return e};});var ne=L((ui,Ze)=>{Ze.exports=w;var cr=A("util"),ft=$(),lt=J(),Lt=D(),Ie=R();function w(t,e){lt.call(this),this.points=t||[],this.srid=e,this.points.length>0&&(this.hasZ=this.points[0].hasZ,this.hasM=this.points[0].hasM);}cr.inherits(w,lt);w.Z=function(t,e){var r=new w(t,e);return r.hasZ=!0,r};w.M=function(t,e){var r=new w(t,e);return r.hasM=!0,r};w.ZM=function(t,e){var r=new w(t,e);return r.hasZ=!0,r.hasM=!0,r};w._parseWkt=function(t,e){var r=new w;return r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM,t.isMatch(["EMPTY"])||(t.expectGroupStart(),r.points.push.apply(r.points,t.matchCoordinates(e)),t.expectGroupEnd()),r};w._parseWkb=function(t,e){var r=new w;r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM;for(var n=t.readUInt32(),i=0;i<n;i++)r.points.push(lt.parse(t,e));return r};w._parseTwkb=function(t,e){var r=new w;if(r.hasZ=e.hasZ,r.hasM=e.hasM,e.isEmpty)return r;for(var n=new Lt(0,0,e.hasZ?0:void 0,e.hasM?0:void 0),i=t.readVarInt(),o=0;o<i;o++)r.points.push(Lt._readTwkbPoint(t,e,n));return r};w._parseGeoJSON=function(t){var e=new w;t.coordinates.length>0&&(e.hasZ=t.coordinates[0].length>2);for(var r=0;r<t.coordinates.length;r++)e.points.push(Lt._parseGeoJSON({coordinates:t.coordinates[r]}));return e};w.prototype.toWkt=function(){if(this.points.length===0)return this._getWktType(ft.wkt.MultiPoint,!0);for(var t=this._getWktType(ft.wkt.MultiPoint,!1)+"(",e=0;e<this.points.length;e++)t+=this._getWktCoordinate(this.points[e])+",";return t=t.slice(0,-1),t+=")",t};w.prototype.toWkb=function(){var t=new Ie(this._getWkbSize());t.writeInt8(1),this._writeWkbType(t,ft.wkb.MultiPoint),t.writeUInt32LE(this.points.length);for(var e=0;e<this.points.length;e++)t.writeBuffer(this.points[e].toWkb({srid:this.srid}));return t.buffer};w.prototype.toTwkb=function(){var t=new Ie(0,!0),e=lt.getTwkbPrecision(5,0,0),r=this.points.length===0;if(this._writeTwkbHeader(t,ft.wkb.MultiPoint,e,r),this.points.length>0){t.writeVarInt(this.points.length);for(var n=new Lt(0,0,0,0),i=0;i<this.points.length;i++)this.points[i]._writeTwkbPoint(t,e,n);}return t.buffer};w.prototype._getWkbSize=function(){var t=16;return this.hasZ&&(t+=8),this.hasM&&(t+=8),t+=5,9+this.points.length*t};w.prototype.toGeoJSON=function(t){var e=lt.prototype.toGeoJSON.call(this,t);e.type=ft.geoJSON.MultiPoint,e.coordinates=[];for(var r=0;r<this.points.length;r++)e.coordinates.push(this.points[r].toGeoJSON().coordinates);return e};});var se=L((hi,Ce)=>{Ce.exports=S;var gr=A("util"),ct=$(),gt=J(),ie=D(),oe=vt(),Be=R();function S(t,e){gt.call(this),this.lineStrings=t||[],this.srid=e,this.lineStrings.length>0&&(this.hasZ=this.lineStrings[0].hasZ,this.hasM=this.lineStrings[0].hasM);}gr.inherits(S,gt);S.Z=function(t,e){var r=new S(t,e);return r.hasZ=!0,r};S.M=function(t,e){var r=new S(t,e);return r.hasM=!0,r};S.ZM=function(t,e){var r=new S(t,e);return r.hasZ=!0,r.hasM=!0,r};S._parseWkt=function(t,e){var r=new S;if(r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM,t.isMatch(["EMPTY"]))return r;t.expectGroupStart();do t.expectGroupStart(),r.lineStrings.push(new oe(t.matchCoordinates(e))),t.expectGroupEnd();while(t.isMatch([","]));return t.expectGroupEnd(),r};S._parseWkb=function(t,e){var r=new S;r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM;for(var n=t.readUInt32(),i=0;i<n;i++)r.lineStrings.push(gt.parse(t,e));return r};S._parseTwkb=function(t,e){var r=new S;if(r.hasZ=e.hasZ,r.hasM=e.hasM,e.isEmpty)return r;for(var n=new ie(0,0,e.hasZ?0:void 0,e.hasM?0:void 0),i=t.readVarInt(),o=0;o<i;o++){var s=new oe;s.hasZ=e.hasZ,s.hasM=e.hasM;for(var c=t.readVarInt(),p=0;p<c;p++)s.points.push(ie._readTwkbPoint(t,e,n));r.lineStrings.push(s);}return r};S._parseGeoJSON=function(t){var e=new S;t.coordinates.length>0&&t.coordinates[0].length>0&&(e.hasZ=t.coordinates[0][0].length>2);for(var r=0;r<t.coordinates.length;r++)e.lineStrings.push(oe._parseGeoJSON({coordinates:t.coordinates[r]}));return e};S.prototype.toWkt=function(){if(this.lineStrings.length===0)return this._getWktType(ct.wkt.MultiLineString,!0);for(var t=this._getWktType(ct.wkt.MultiLineString,!1)+"(",e=0;e<this.lineStrings.length;e++)t+=this.lineStrings[e]._toInnerWkt()+",";return t=t.slice(0,-1),t+=")",t};S.prototype.toWkb=function(){var t=new Be(this._getWkbSize());t.writeInt8(1),this._writeWkbType(t,ct.wkb.MultiLineString),t.writeUInt32LE(this.lineStrings.length);for(var e=0;e<this.lineStrings.length;e++)t.writeBuffer(this.lineStrings[e].toWkb({srid:this.srid}));return t.buffer};S.prototype.toTwkb=function(){var t=new Be(0,!0),e=gt.getTwkbPrecision(5,0,0),r=this.lineStrings.length===0;if(this._writeTwkbHeader(t,ct.wkb.MultiLineString,e,r),this.lineStrings.length>0){t.writeVarInt(this.lineStrings.length);for(var n=new ie(0,0,0,0),i=0;i<this.lineStrings.length;i++){t.writeVarInt(this.lineStrings[i].points.length);for(var o=0;o<this.lineStrings[i].points.length;o++)this.lineStrings[i].points[o]._writeTwkbPoint(t,e,n);}}return t.buffer};S.prototype._getWkbSize=function(){for(var t=9,e=0;e<this.lineStrings.length;e++)t+=this.lineStrings[e]._getWkbSize();return t};S.prototype.toGeoJSON=function(t){var e=gt.prototype.toGeoJSON.call(this,t);e.type=ct.geoJSON.MultiLineString,e.coordinates=[];for(var r=0;r<this.lineStrings.length;r++)e.coordinates.push(this.lineStrings[r].toGeoJSON().coordinates);return e};});var ue=L((pi,Re)=>{Re.exports=b;var yr=A("util"),yt=$(),mt=J(),Nt=D(),ae=Ot(),qe=R();function b(t,e){mt.call(this),this.polygons=t||[],this.srid=e,this.polygons.length>0&&(this.hasZ=this.polygons[0].hasZ,this.hasM=this.polygons[0].hasM);}yr.inherits(b,mt);b.Z=function(t,e){var r=new b(t,e);return r.hasZ=!0,r};b.M=function(t,e){var r=new b(t,e);return r.hasM=!0,r};b.ZM=function(t,e){var r=new b(t,e);return r.hasZ=!0,r.hasM=!0,r};b._parseWkt=function(t,e){var r=new b;if(r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM,t.isMatch(["EMPTY"]))return r;t.expectGroupStart();do{t.expectGroupStart();var n=[],i=[];for(t.expectGroupStart(),n.push.apply(n,t.matchCoordinates(e)),t.expectGroupEnd();t.isMatch([","]);)t.expectGroupStart(),i.push(t.matchCoordinates(e)),t.expectGroupEnd();r.polygons.push(new ae(n,i)),t.expectGroupEnd();}while(t.isMatch([","]));return t.expectGroupEnd(),r};b._parseWkb=function(t,e){var r=new b;r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM;for(var n=t.readUInt32(),i=0;i<n;i++)r.polygons.push(mt.parse(t,e));return r};b._parseTwkb=function(t,e){var r=new b;if(r.hasZ=e.hasZ,r.hasM=e.hasM,e.isEmpty)return r;for(var n=new Nt(0,0,e.hasZ?0:void 0,e.hasM?0:void 0),i=t.readVarInt(),o=0;o<i;o++){var s=new ae;s.hasZ=e.hasZ,s.hasM=e.hasM;for(var c=t.readVarInt(),p=t.readVarInt(),a=0;a<p;a++)s.exteriorRing.push(Nt._readTwkbPoint(t,e,n));for(a=1;a<c;a++){for(var y=[],O=t.readVarInt(),j=0;j<O;j++)y.push(Nt._readTwkbPoint(t,e,n));s.interiorRings.push(y);}r.polygons.push(s);}return r};b._parseGeoJSON=function(t){var e=new b;t.coordinates.length>0&&t.coordinates[0].length>0&&t.coordinates[0][0].length>0&&(e.hasZ=t.coordinates[0][0][0].length>2);for(var r=0;r<t.coordinates.length;r++)e.polygons.push(ae._parseGeoJSON({coordinates:t.coordinates[r]}));return e};b.prototype.toWkt=function(){if(this.polygons.length===0)return this._getWktType(yt.wkt.MultiPolygon,!0);for(var t=this._getWktType(yt.wkt.MultiPolygon,!1)+"(",e=0;e<this.polygons.length;e++)t+=this.polygons[e]._toInnerWkt()+",";return t=t.slice(0,-1),t+=")",t};b.prototype.toWkb=function(){var t=new qe(this._getWkbSize());t.writeInt8(1),this._writeWkbType(t,yt.wkb.MultiPolygon),t.writeUInt32LE(this.polygons.length);for(var e=0;e<this.polygons.length;e++)t.writeBuffer(this.polygons[e].toWkb({srid:this.srid}));return t.buffer};b.prototype.toTwkb=function(){var t=new qe(0,!0),e=mt.getTwkbPrecision(5,0,0),r=this.polygons.length===0;if(this._writeTwkbHeader(t,yt.wkb.MultiPolygon,e,r),this.polygons.length>0){t.writeVarInt(this.polygons.length);for(var n=new Nt(0,0,0,0),i=0;i<this.polygons.length;i++){t.writeVarInt(1+this.polygons[i].interiorRings.length),t.writeVarInt(this.polygons[i].exteriorRing.length);for(var o=0;o<this.polygons[i].exteriorRing.length;o++)this.polygons[i].exteriorRing[o]._writeTwkbPoint(t,e,n);for(o=0;o<this.polygons[i].interiorRings.length;o++){t.writeVarInt(this.polygons[i].interiorRings[o].length);for(var s=0;s<this.polygons[i].interiorRings[o].length;s++)this.polygons[i].interiorRings[o][s]._writeTwkbPoint(t,e,n);}}}return t.buffer};b.prototype._getWkbSize=function(){for(var t=9,e=0;e<this.polygons.length;e++)t+=this.polygons[e]._getWkbSize();return t};b.prototype.toGeoJSON=function(t){var e=mt.prototype.toGeoJSON.call(this,t);e.type=yt.geoJSON.MultiPolygon,e.coordinates=[];for(var r=0;r<this.polygons.length;r++)e.coordinates.push(this.polygons[r].toGeoJSON().coordinates);return e};});var he=L((fi,Je)=>{Je.exports=x;var mr=A("util"),dt=$(),Q=J(),De=R();function x(t,e){Q.call(this),this.geometries=t||[],this.srid=e,this.geometries.length>0&&(this.hasZ=this.geometries[0].hasZ,this.hasM=this.geometries[0].hasM);}mr.inherits(x,Q);x.Z=function(t,e){var r=new x(t,e);return r.hasZ=!0,r};x.M=function(t,e){var r=new x(t,e);return r.hasM=!0,r};x.ZM=function(t,e){var r=new x(t,e);return r.hasZ=!0,r.hasM=!0,r};x._parseWkt=function(t,e){var r=new x;if(r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM,t.isMatch(["EMPTY"]))return r;t.expectGroupStart();do r.geometries.push(Q.parse(t));while(t.isMatch([","]));return t.expectGroupEnd(),r};x._parseWkb=function(t,e){var r=new x;r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM;for(var n=t.readUInt32(),i=0;i<n;i++)r.geometries.push(Q.parse(t,e));return r};x._parseTwkb=function(t,e){var r=new x;if(r.hasZ=e.hasZ,r.hasM=e.hasM,e.isEmpty)return r;for(var n=t.readVarInt(),i=0;i<n;i++)r.geometries.push(Q.parseTwkb(t));return r};x._parseGeoJSON=function(t){for(var e=new x,r=0;r<t.geometries.length;r++)e.geometries.push(Q._parseGeoJSON(t.geometries[r],!0));return e.geometries.length>0&&(e.hasZ=e.geometries[0].hasZ),e};x.prototype.toWkt=function(){if(this.geometries.length===0)return this._getWktType(dt.wkt.GeometryCollection,!0);for(var t=this._getWktType(dt.wkt.GeometryCollection,!1)+"(",e=0;e<this.geometries.length;e++)t+=this.geometries[e].toWkt()+",";return t=t.slice(0,-1),t+=")",t};x.prototype.toWkb=function(){var t=new De(this._getWkbSize());t.writeInt8(1),this._writeWkbType(t,dt.wkb.GeometryCollection),t.writeUInt32LE(this.geometries.length);for(var e=0;e<this.geometries.length;e++)t.writeBuffer(this.geometries[e].toWkb({srid:this.srid}));return t.buffer};x.prototype.toTwkb=function(){var t=new De(0,!0),e=Q.getTwkbPrecision(5,0,0),r=this.geometries.length===0;if(this._writeTwkbHeader(t,dt.wkb.GeometryCollection,e,r),this.geometries.length>0){t.writeVarInt(this.geometries.length);for(var n=0;n<this.geometries.length;n++)t.writeBuffer(this.geometries[n].toTwkb());}return t.buffer};x.prototype._getWkbSize=function(){for(var t=9,e=0;e<this.geometries.length;e++)t+=this.geometries[e]._getWkbSize();return t};x.prototype.toGeoJSON=function(t){var e=Q.prototype.toGeoJSON.call(this,t);e.type=dt.geoJSON.GeometryCollection,e.geometries=[];for(var r=0;r<this.geometries.length;r++)e.geometries.push(this.geometries[r].toGeoJSON());return e};});var Qe=L((li,ze)=>{ze.exports=B;function B(t,e){this.buffer=t,this.position=0,this.isBigEndian=e||!1;}function F(t,e,r){return function(){var n;return this.isBigEndian?n=e.call(this.buffer,this.position):n=t.call(this.buffer,this.position),this.position+=r,n}}B.prototype.readUInt8=F(Buffer.prototype.readUInt8,Buffer.prototype.readUInt8,1);B.prototype.readUInt16=F(Buffer.prototype.readUInt16LE,Buffer.prototype.readUInt16BE,2);B.prototype.readUInt32=F(Buffer.prototype.readUInt32LE,Buffer.prototype.readUInt32BE,4);B.prototype.readInt8=F(Buffer.prototype.readInt8,Buffer.prototype.readInt8,1);B.prototype.readInt16=F(Buffer.prototype.readInt16LE,Buffer.prototype.readInt16BE,2);B.prototype.readInt32=F(Buffer.prototype.readInt32LE,Buffer.prototype.readInt32BE,4);B.prototype.readFloat=F(Buffer.prototype.readFloatLE,Buffer.prototype.readFloatBE,4);B.prototype.readDouble=F(Buffer.prototype.readDoubleLE,Buffer.prototype.readDoubleBE,8);B.prototype.readVarInt=function(){var t,e=0,r=0;do t=this.buffer[this.position+r],e+=(t&127)<<7*r,r++;while(t>=128);return this.position+=r,e};});var Ue=L((ci,Fe)=>{Fe.exports=I;var X=$(),Gt=D();function I(t){this.value=t,this.position=0;}I.prototype.match=function(t){this.skipWhitespaces();for(var e=0;e<t.length;e++)if(this.value.substring(this.position).indexOf(t[e])===0)return this.position+=t[e].length,t[e];return null};I.prototype.matchRegex=function(t){this.skipWhitespaces();for(var e=0;e<t.length;e++){var r=this.value.substring(this.position).match(t[e]);if(r)return this.position+=r[0].length,r}return null};I.prototype.isMatch=function(t){this.skipWhitespaces();for(var e=0;e<t.length;e++)if(this.value.substring(this.position).indexOf(t[e])===0)return this.position+=t[e].length,!0;return !1};I.prototype.matchType=function(){var t=this.match([X.wkt.Point,X.wkt.LineString,X.wkt.Polygon,X.wkt.MultiPoint,X.wkt.MultiLineString,X.wkt.MultiPolygon,X.wkt.GeometryCollection]);if(!t)throw new Error("Expected geometry type");return t};I.prototype.matchDimension=function(){var t=this.match(["ZM","Z","M"]);switch(t){case"ZM":return {hasZ:!0,hasM:!0};case"Z":return {hasZ:!0,hasM:!1};case"M":return {hasZ:!1,hasM:!0};default:return {hasZ:!1,hasM:!1}}};I.prototype.expectGroupStart=function(){if(!this.isMatch(["("]))throw new Error("Expected group start")};I.prototype.expectGroupEnd=function(){if(!this.isMatch([")"]))throw new Error("Expected group end")};I.prototype.matchCoordinate=function(t){var e;if(t.hasZ&&t.hasM?e=this.matchRegex([/^(\S*)\s+(\S*)\s+(\S*)\s+([^\s,)]*)/]):t.hasZ||t.hasM?e=this.matchRegex([/^(\S*)\s+(\S*)\s+([^\s,)]*)/]):e=this.matchRegex([/^(\S*)\s+([^\s,)]*)/]),!e)throw new Error("Expected coordinates");return t.hasZ&&t.hasM?new Gt(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]),parseFloat(e[4])):t.hasZ?new Gt(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])):t.hasM?new Gt(parseFloat(e[1]),parseFloat(e[2]),void 0,parseFloat(e[3])):new Gt(parseFloat(e[1]),parseFloat(e[2]))};I.prototype.matchCoordinates=function(t){var e=[];do{var r=this.isMatch(["("]);e.push(this.matchCoordinate(t)),r&&this.expectGroupEnd();}while(this.isMatch([","]));return e};I.prototype.skipWhitespaces=function(){for(;this.position<this.value.length&&this.value[this.position]===" ";)this.position++;};});var J=L((gi,Ve)=>{Ve.exports=T;var g=$(),Wt=D(),Et=vt(),$t=Ot(),It=ne(),Zt=se(),Bt=ue(),Ct=he(),wt=Qe(),dr=R(),pe=Ue(),_t=re();function T(){this.srid=void 0,this.hasZ=!1,this.hasM=!1;}T.parse=function(t,e){var r=typeof t;if(r==="string"||t instanceof pe)return T._parseWkt(t);if(Buffer.isBuffer(t)||t instanceof wt)return T._parseWkb(t,e);throw new Error("first argument must be a string or Buffer")};T._parseWkt=function(t){var e,r;t instanceof pe?e=t:e=new pe(t);var n=e.matchRegex([/^SRID=(\d+);/]);n&&(r=parseInt(n[1],10));var i=e.matchType(),o=e.matchDimension(),s={srid:r,hasZ:o.hasZ,hasM:o.hasM};switch(i){case g.wkt.Point:return Wt._parseWkt(e,s);case g.wkt.LineString:return Et._parseWkt(e,s);case g.wkt.Polygon:return $t._parseWkt(e,s);case g.wkt.MultiPoint:return It._parseWkt(e,s);case g.wkt.MultiLineString:return Zt._parseWkt(e,s);case g.wkt.MultiPolygon:return Bt._parseWkt(e,s);case g.wkt.GeometryCollection:return Ct._parseWkt(e,s)}};T._parseWkb=function(t,e){var r,n,i,o={};switch(t instanceof wt?r=t:r=new wt(t),r.isBigEndian=!r.readInt8(),n=r.readUInt32(),o.hasSrid=(n&536870912)===536870912,o.isEwkb=n&536870912||n&1073741824||n&2147483648,o.hasSrid&&(o.srid=r.readUInt32()),o.hasZ=!1,o.hasM=!1,!o.isEwkb&&(!e||!e.isEwkb)?n>=1e3&&n<2e3?(o.hasZ=!0,i=n-1e3):n>=2e3&&n<3e3?(o.hasM=!0,i=n-2e3):n>=3e3&&n<4e3?(o.hasZ=!0,o.hasM=!0,i=n-3e3):i=n:(n&2147483648&&(o.hasZ=!0),n&1073741824&&(o.hasM=!0),i=n&15),i){case g.wkb.Point:return Wt._parseWkb(r,o);case g.wkb.LineString:return Et._parseWkb(r,o);case g.wkb.Polygon:return $t._parseWkb(r,o);case g.wkb.MultiPoint:return It._parseWkb(r,o);case g.wkb.MultiLineString:return Zt._parseWkb(r,o);case g.wkb.MultiPolygon:return Bt._parseWkb(r,o);case g.wkb.GeometryCollection:return Ct._parseWkb(r,o);default:throw new Error("GeometryType "+i+" not supported")}};T.parseTwkb=function(t){var e,r={};t instanceof wt?e=t:e=new wt(t);var n=e.readUInt8(),i=e.readUInt8(),o=n&15;if(r.precision=_t.decode(n>>4),r.precisionFactor=Math.pow(10,r.precision),r.hasBoundingBox=i>>0&1,r.hasSizeAttribute=i>>1&1,r.hasIdList=i>>2&1,r.hasExtendedPrecision=i>>3&1,r.isEmpty=i>>4&1,r.hasExtendedPrecision){var s=e.readUInt8();r.hasZ=(s&1)===1,r.hasM=(s&2)===2,r.zPrecision=_t.decode((s&28)>>2),r.zPrecisionFactor=Math.pow(10,r.zPrecision),r.mPrecision=_t.decode((s&224)>>5),r.mPrecisionFactor=Math.pow(10,r.mPrecision);}else r.hasZ=!1,r.hasM=!1;if(r.hasSizeAttribute&&e.readVarInt(),r.hasBoundingBox){var c=2;r.hasZ&&c++,r.hasM&&c++;for(var p=0;p<c;p++)e.readVarInt(),e.readVarInt();}switch(o){case g.wkb.Point:return Wt._parseTwkb(e,r);case g.wkb.LineString:return Et._parseTwkb(e,r);case g.wkb.Polygon:return $t._parseTwkb(e,r);case g.wkb.MultiPoint:return It._parseTwkb(e,r);case g.wkb.MultiLineString:return Zt._parseTwkb(e,r);case g.wkb.MultiPolygon:return Bt._parseTwkb(e,r);case g.wkb.GeometryCollection:return Ct._parseTwkb(e,r);default:throw new Error("GeometryType "+o+" not supported")}};T.parseGeoJSON=function(t){return T._parseGeoJSON(t)};T._parseGeoJSON=function(t,e){var r;switch(t.type){case g.geoJSON.Point:r=Wt._parseGeoJSON(t);break;case g.geoJSON.LineString:r=Et._parseGeoJSON(t);break;case g.geoJSON.Polygon:r=$t._parseGeoJSON(t);break;case g.geoJSON.MultiPoint:r=It._parseGeoJSON(t);break;case g.geoJSON.MultiLineString:r=Zt._parseGeoJSON(t);break;case g.geoJSON.MultiPolygon:r=Bt._parseGeoJSON(t);break;case g.geoJSON.GeometryCollection:r=Ct._parseGeoJSON(t);break;default:throw new Error("GeometryType "+t.type+" not supported")}if(t.crs&&t.crs.type&&t.crs.type==="name"&&t.crs.properties&&t.crs.properties.name){var n=t.crs.properties.name;if(n.indexOf("EPSG:")===0)r.srid=parseInt(n.substring(5));else if(n.indexOf("urn:ogc:def:crs:EPSG::")===0)r.srid=parseInt(n.substring(22));else throw new Error("Unsupported crs: "+n)}else e||(r.srid=4326);return r};T.prototype.toEwkt=function(){return "SRID="+this.srid+";"+this.toWkt()};T.prototype.toEwkb=function(){var t=new dr(this._getWkbSize()+4),e=this.toWkb();return t.writeInt8(1),t.writeUInt32LE((e.slice(1,5).readUInt32LE(0)|536870912)>>>0,!0),t.writeUInt32LE(this.srid),t.writeBuffer(e.slice(5)),t.buffer};T.prototype._getWktType=function(t,e){var r=t;return this.hasZ&&this.hasM?r+=" ZM ":this.hasZ?r+=" Z ":this.hasM&&(r+=" M "),e&&!this.hasZ&&!this.hasM&&(r+=" "),e&&(r+="EMPTY"),r};T.prototype._getWktCoordinate=function(t){var e=t.x+" "+t.y;return this.hasZ&&(e+=" "+t.z),this.hasM&&(e+=" "+t.m),e};T.prototype._writeWkbType=function(t,e,r){var n=0;typeof this.srid>"u"&&(!r||typeof r.srid>"u")?this.hasZ&&this.hasM?n+=3e3:this.hasZ?n+=1e3:this.hasM&&(n+=2e3):(this.hasZ&&(n|=2147483648),this.hasM&&(n|=1073741824)),t.writeUInt32LE(n+e>>>0,!0);};T.getTwkbPrecision=function(t,e,r){return {xy:t,z:e,m:r,xyFactor:Math.pow(10,t),zFactor:Math.pow(10,e),mFactor:Math.pow(10,r)}};T.prototype._writeTwkbHeader=function(t,e,r,n){var i=(_t.encode(r.xy)<<4)+e,o=(this.hasZ||this.hasM)<<3;if(o+=n<<4,t.writeUInt8(i),t.writeUInt8(o),this.hasZ||this.hasM){var s=0;this.hasZ&&(s|=1),this.hasM&&(s|=2),t.writeUInt8(s);}};T.prototype.toGeoJSON=function(t){var e={};return this.srid&&t&&(t.shortCrs?e.crs={type:"name",properties:{name:"EPSG:"+this.srid}}:t.longCrs&&(e.crs={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::"+this.srid}})),e};});var Ae=L(C=>{C.Types=$();C.Geometry=J();C.Point=D();C.LineString=vt();C.Polygon=Ot();C.MultiPoint=ne();C.MultiLineString=se();C.MultiPolygon=ue();C.GeometryCollection=he();});var Ye={};St(Ye,{box2D:()=>wr,box2DfromDriver:()=>He,fromDriver:()=>W,geometry:()=>Sr,geometryCollection:()=>Tr,lineString:()=>kr,multiLineString:()=>Mr,multiPoint:()=>xr,multiPolygon:()=>vr,point:()=>br,polygon:()=>Pr});var h=Symbol.for("drizzle:entityKind");function k(t,e){if(!t||typeof t!="object")return !1;if(t instanceof e)return !0;if(!Object.prototype.hasOwnProperty.call(e,h))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 r=t.constructor;if(r)for(;r;){if(h in r&&r[h]===e[h])return !0;r=Object.getPrototypeOf(r);}return !1}var q=class{constructor(e,r){this.table=e,this.config=r,this.name=r.name,this.notNull=r.notNull,this.default=r.default,this.defaultFn=r.defaultFn,this.onUpdateFn=r.onUpdateFn,this.hasDefault=r.hasDefault,this.primary=r.primaryKey,this.isUnique=r.isUnique,this.uniqueName=r.uniqueName,this.uniqueType=r.uniqueType,this.dataType=r.dataType,this.columnType=r.columnType;}static[h]="Column";name;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}};var K=Symbol.for("drizzle:SubqueryConfig"),tt=class{static[h]="Subquery";[K];constructor(e,r,n,i=!1){this[K]={sql:e,selection:r,alias:n,isWith:i};}};function bt(t,...e){return t(...e)}var ce={startActiveSpan(t,e){return e()}};var rt=Symbol.for("drizzle:ViewBaseConfig");var Jt=Symbol.for("drizzle:Name"),zt=Symbol.for("drizzle:Schema"),ge=Symbol.for("drizzle:Columns"),Qt=Symbol.for("drizzle:OriginalName"),Ft=Symbol.for("drizzle:BaseName"),ye=Symbol.for("drizzle:IsAlias"),me=Symbol.for("drizzle:ExtraConfigBuilder"),ur=Symbol.for("drizzle:IsDrizzleTable"),N=class{static[h]="Table";static Symbol={Name:Jt,Schema:zt,OriginalName:Qt,Columns:ge,BaseName:Ft,IsAlias:ye,ExtraConfigBuilder:me};[Jt];[Qt];[zt];[ge];[Ft];[ye]=!1;[me]=void 0;[ur]=!0;constructor(e,r,n){this[Jt]=this[Qt]=e,this[zt]=r,this[Ft]=n;}};function Ut(t){return typeof t=="object"&&t!==null&&"getSQL"in t&&typeof t.getSQL=="function"}function hr(t){let e={sql:"",params:[]};for(let r of t)e.sql+=r.sql,e.params.push(...r.params),r.typings?.length&&(e.typings||(e.typings=[]),e.typings.push(...r.typings));return e}var G=class{static[h]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e];}getSQL(){return new P([this])}},P=class t{constructor(e){this.queryChunks=e;}static[h]="SQL";decoder=Se;shouldInlineParams=!1;append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return ce.startActiveSpan("drizzle.buildSQL",r=>{let n=this.buildQueryFromSourceParams(this.queryChunks,e);return r?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(e,r){let n=Object.assign({},r,{inlineParams:r.inlineParams||this.shouldInlineParams,paramStartIndex:r.paramStartIndex||{value:0}}),{escapeName:i,escapeParam:o,prepareTyping:s,inlineParams:c,paramStartIndex:p}=n;return hr(e.map(a=>{if(k(a,G))return {sql:a.value.join(""),params:[]};if(k(a,nt))return {sql:i(a.value),params:[]};if(a===void 0)return {sql:"",params:[]};if(Array.isArray(a)){let y=[new G("(")];for(let[O,j]of a.entries())y.push(j),O<a.length-1&&y.push(new G(", "));return y.push(new G(")")),this.buildQueryFromSourceParams(y,n)}if(k(a,t))return this.buildQueryFromSourceParams(a.queryChunks,{...n,inlineParams:c||a.shouldInlineParams});if(k(a,N)){let y=a[N.Symbol.Schema],O=a[N.Symbol.Name];return {sql:y===void 0?i(O):i(y)+"."+i(O),params:[]}}if(k(a,q))return {sql:i(a.table[N.Symbol.Name])+"."+i(a.name),params:[]};if(k(a,it)){let y=a[rt].schema,O=a[rt].name;return {sql:y===void 0?i(O):i(y)+"."+i(O),params:[]}}if(k(a,H)){let y=a.value===null?null:a.encoder.mapToDriverValue(a.value);if(k(y,t))return this.buildQueryFromSourceParams([y],n);if(c)return {sql:this.mapInlineParam(y,n),params:[]};let O;return s!==void 0&&(O=[s(a.encoder)]),{sql:o(p.value++,y),params:[y],typings:O}}return k(a,et)?{sql:o(p.value++,a),params:[a]}:k(a,t.Aliased)&&a.fieldAlias!==void 0?{sql:i(a.fieldAlias),params:[]}:k(a,tt)?a[K].isWith?{sql:i(a[K].alias),params:[]}:this.buildQueryFromSourceParams([new G("("),a[K].sql,new G(") "),new nt(a[K].alias)],n):Ut(a)?this.buildQueryFromSourceParams([new G("("),a.getSQL(),new G(")")],n):c?{sql:this.mapInlineParam(a,n),params:[]}:{sql:o(p.value++,a),params:[a]}}))}mapInlineParam(e,{escapeString:r}){if(e===null)return "null";if(typeof e=="number"||typeof e=="boolean")return e.toString();if(typeof e=="string")return r(e);if(typeof e=="object"){let n=e.toString();return r(n==="[object Object]"?JSON.stringify(e):n)}throw new Error("Unexpected param value: "+e)}getSQL(){return this}as(e){return e===void 0?this:new t.Aliased(this,e)}mapWith(e){return this.decoder=typeof e=="function"?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}},nt=class{constructor(e){this.value=e;}static[h]="Name";brand;getSQL(){return new P([this])}};function we(t){return typeof t=="object"&&t!==null&&"mapToDriverValue"in t&&typeof t.mapToDriverValue=="function"}var Se={mapFromDriverValue:t=>t},be={mapToDriverValue:t=>t};({...Se,...be});var H=class{constructor(e,r=be){this.value=e,this.encoder=r;}static[h]="Param";brand;getSQL(){return new P([this])}};function u(t,...e){let r=[];(e.length>0||t.length>0&&t[0]!=="")&&r.push(new G(t[0]));for(let[n,i]of e.entries())r.push(i,new G(t[n+1]));return new P(r)}(t=>{function e(){return new P([])}t.empty=e;function r(p){return new P(p)}t.fromList=r;function n(p){return new P([new G(p)])}t.raw=n;function i(p,a){let y=[];for(let[O,j]of p.entries())O>0&&a!==void 0&&y.push(a),y.push(j);return new P(y)}t.join=i;function o(p){return new nt(p)}t.identifier=o;function s(p){return new et(p)}t.placeholder=s;function c(p,a){return new H(p,a)}t.param=c;})(u||(u={}));(t=>{class e{constructor(n,i){this.sql=n,this.fieldAlias=i;}static[h]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new e(this.sql,this.fieldAlias)}}t.Aliased=e;})(P||(P={}));var et=class{constructor(e){this.name=e;}static[h]="Placeholder";getSQL(){return new P([this])}};var it=class{static[h]="View";[rt];constructor({name:e,schema:r,selectedFields:n,query:i}){this[rt]={name:e,originalName:e,schema:r,selectedFields:n,query:i,isExisting:!i,isAlias:!1};}getSQL(){return new P([this])}};q.prototype.getSQL=function(){return new P([this])};N.prototype.getSQL=function(){return new P([this])};tt.prototype.getSQL=function(){return new P([this])};var xt=class{static[h]="ColumnBuilder";config;constructor(e,r,n){this.config={name:e,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:r,columnType:n};}$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}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}};function M(t,e){return we(e)&&!Ut(t)&&!k(t,H)&&!k(t,et)&&!k(t,q)&&!k(t,N)&&!k(t,it)?new H(t,e):t}var xe=Symbol.for("drizzle:PgInlineForeignKeys"),Y=class extends N{static[h]="PgTable";static Symbol=Object.assign({},N.Symbol,{InlineForeignKeys:xe});[xe]=[];[N.Symbol.ExtraConfigBuilder]=void 0};var kt=class{static[h]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(e,r){this.reference=()=>{let{name:n,columns:i,foreignColumns:o}=e();return {name:n,columns:i,foreignTable:o[0].table,foreignColumns:o}},r&&(this._onUpdate=r.onUpdate,this._onDelete=r.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 Vt(e,this)}},Vt=class{constructor(e,r){this.table=e,this.reference=r.reference,this.onUpdate=r._onUpdate,this.onDelete=r._onDelete;}static[h]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:r,foreignColumns:n}=this.reference(),i=r.map(c=>c.name),o=n.map(c=>c.name),s=[this.table[Y.Symbol.Name],...i,n[0].table[Y.Symbol.Name],...o];return e??`${s.join("_")}_fk`}};function Ht(t,e){return `${t[Y.Symbol.Name]}_${e.join("_")}_unique`}function Me(t,e,r){for(let n=e;n<t.length;n++){let i=t[n];if(i==="\\"){n++;continue}if(i==='"')return [t.slice(e,n).replace(/\\/g,""),n+1];if(!r&&(i===","||i==="}"))return [t.slice(e,n).replace(/\\/g,""),n]}return [t.slice(e).replace(/\\/g,""),t.length]}function Pe(t,e=0){let r=[],n=e,i=!1;for(;n<t.length;){let o=t[n];if(o===","){(i||n===e)&&r.push(""),i=!0,n++;continue}if(i=!1,o==="\\"){n+=2;continue}if(o==='"'){let[p,a]=Me(t,n+1,!0);r.push(p),n=a;continue}if(o==="}")return [r,n+1];if(o==="{"){let[p,a]=Pe(t,n+1);r.push(p),n=a;continue}let[s,c]=Me(t,n,!1);r.push(s),n=c;}return [r,n]}function ve(t){let[e]=Pe(t,1);return e}function Yt(t){return `{${t.map(e=>Array.isArray(e)?Yt(e):typeof e=="string"?`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`${e}`).join(",")}}`}var ot=class extends xt{foreignKeyConfigs=[];static[h]="PgColumnBuilder";array(e){return new Xt(this.config.name,this,e)}references(e,r={}){return this.foreignKeyConfigs.push({ref:e,actions:r}),this}unique(e,r){return this.config.isUnique=!0,this.config.uniqueName=e,this.config.uniqueType=r?.nulls,this}buildForeignKeys(e,r){return this.foreignKeyConfigs.map(({ref:n,actions:i})=>bt((o,s)=>{let c=new kt(()=>{let p=o();return {columns:[e],foreignColumns:[p]}});return s.onUpdate&&c.onUpdate(s.onUpdate),s.onDelete&&c.onDelete(s.onDelete),c.build(r)},n,i))}},st=class extends q{constructor(e,r){r.uniqueName||(r.uniqueName=Ht(e,[r.name])),super(e,r),this.table=e;}static[h]="PgColumn"},Xt=class extends ot{static[h]="PgArrayBuilder";constructor(e,r,n){super(e,"array","PgArray"),this.config.baseBuilder=r,this.config.size=n;}build(e){let r=this.config.baseBuilder.build(e);return new jt(e,this.config,r)}},jt=class t extends st{constructor(e,r,n,i){super(e,r),this.baseColumn=n,this.range=i,this.size=r.size;}size;static[h]="PgArray";getSQLType(){return `${this.baseColumn.getSQLType()}[${typeof this.size=="number"?this.size:""}]`}mapFromDriverValue(e){return typeof e=="string"&&(e=ve(e)),e.map(r=>this.baseColumn.mapFromDriverValue(r))}mapToDriverValue(e,r=!1){let n=e.map(i=>i===null?null:k(this.baseColumn,t)?this.baseColumn.mapToDriverValue(i,!0):this.baseColumn.mapToDriverValue(i));return r?n:Yt(n)}};var te=class extends ot{static[h]="PgCustomColumnBuilder";constructor(e,r,n){super(e,"custom","PgCustomColumn"),this.config.fieldConfig=r,this.config.customTypeParams=n;}build(e){return new ee(e,this.config)}},ee=class extends st{static[h]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor(e,r){super(e,r),this.sqlName=r.customTypeParams.dataType(r.fieldConfig),this.mapTo=r.customTypeParams.toDriver,this.mapFrom=r.customTypeParams.fromDriver;}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom=="function"?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo=="function"?this.mapTo(e):e}};function Z(t){return (e,r)=>new te(e,r,t)}var Ke=ar(Ae()),U=t=>{let e="geometry";return t?.type&&(e+=`(${t.type}`,t?.srid&&(e+=`,${t.srid}`),e+=")"),e};function V(t){return u`ST_GeomFromGeoJSON(${JSON.stringify(t)})`}function W(t){let e=Buffer.from(t,"hex");return Ke.default.Geometry.parse(e).toGeoJSON({shortCrs:!0})}function He(t){let e=t.match(/BOX\((?<xmin>[0-9\.]+),? ?(?<ymin>[0-9\.]+),? ?(?<xmax>[0-9\.]+),? ?(?<ymax>[0-9\.]+)\)/);if(!e?.groups)throw new Error(`Box2D parse error, value: ${t}`);return [Number.parseFloat(e.groups.xmin),Number.parseFloat(e.groups.ymin),Number.parseFloat(e.groups.xmax),Number.parseFloat(e.groups.ymax)]}var wr=Z({dataType:()=>"box2d",toDriver:t=>`BOX(${t[0]} ${t[1]}, ${t[2]} ${t[3]})`,fromDriver:He}),Sr=Z({dataType:U,toDriver:t=>V(t),fromDriver:t=>W(t)}),br=Z({dataType:t=>U({type:`Point${t?.is3D?"Z":""}`,...t}),toDriver:t=>V(t),fromDriver:t=>W(t)}),xr=Z({dataType:t=>U({type:`MultiPoint${t?.is3D?"Z":""}`,...t}),toDriver:t=>V(t),fromDriver:t=>W(t)}),kr=Z({dataType:t=>U({type:`LineString${t?.is3D?"Z":""}`,...t}),toDriver:t=>V(t),fromDriver:t=>W(t)}),Mr=Z({dataType:t=>U({type:`MultiLineString${t?.is3D?"Z":""}`,...t}),toDriver:t=>V(t),fromDriver:t=>W(t)}),Pr=Z({dataType:t=>U({type:`Polygon${t?.is3D?"Z":""}`,...t}),toDriver:t=>V(t),fromDriver:t=>W(t)}),vr=Z({dataType:t=>U({type:`MultiPolygon${t?.is3D?"Z":""}`,...t}),toDriver:t=>V(t),fromDriver:t=>W(t)}),Tr=Z({dataType:t=>U({type:"GeometryCollection",...t}),toDriver:t=>V(t),fromDriver:t=>W(t)});var je={};St(je,{addMeasure:()=>Cr,area:()=>Lr,asText:()=>_r,closestPoint:()=>Nr,geoHash:()=>Br,geomFromGeoJSON:()=>Zr,geomFromText:()=>Gr,isValid:()=>$r,isValidReason:()=>Ir,x:()=>Wr,y:()=>Er});var Xe={};St(Xe,{gisExtensionSchema:()=>f,setPostGISSchema:()=>Or});var f=u.raw("");function Or(t){f=t.length?u.raw(`${t}.`):u.empty();}function Lr(t){return u`${f}ST_Area(${t})`.mapWith(Number)}function Nr(t,e){return u`${f}ST_ClosestPoint(${t}, ${e})`.mapWith(W)}function Gr(t){return u`${f}ST_GeomFromText(${t})`.mapWith(W)}function _r(t){return u`${f}ST_AsText(${t})`}function Wr(t){return u`${f}ST_X(${t})`.mapWith(Number)}function Er(t){return u`${f}ST_Y(${t})`.mapWith(Number)}function $r(t){return u`${f}ST_IsValid(${t},0)`.mapWith(Boolean)}function Ir(t){return u`${f}ST_IsValidReason(${t})`}function Zr(t){return u`${f}ST_GeomFromGeoJSON(${JSON.stringify(t)})`.mapWith(W)}function Br(t,e=20){return u`${f}ST_GeoHash(${t}, ${e})`}function Cr(t,e,r){return u`${f}ST_AddMeasure(${t}, ${e}, ${r})`}var tr={};St(tr,{bboxAbove:()=>Vr,bboxBelow:()=>Fr,bboxContain:()=>Xr,bboxContained:()=>Yr,bboxLeft:()=>Qr,bboxOverlaps:()=>qr,bboxOverlapsND:()=>Rr,bboxOverlapsOrAbove:()=>Ur,bboxOverlapsOrBelow:()=>Jr,bboxOverlapsOrLeft:()=>Dr,bboxOverlapsOrRight:()=>zr,bboxRight:()=>Ar,bboxSame:()=>Hr,distanceBox:()=>en,distanceBoxND:()=>nn,distanceCPA:()=>tn,distanceCentroidND:()=>rn,distanceKNN:()=>jr,eq:()=>Kr});var qr=(t,e)=>u`${t} OPERATOR(${f}&&) ${M(e,t)}`,Rr=(t,e)=>u`${t} OPERATOR(${f}&&&) ${M(e,t)}`,Dr=(t,e)=>u`${t} OPERATOR(${f}&<) ${M(e,t)}`,Jr=(t,e)=>u`${t} OPERATOR(${f}&<|) ${M(e,t)}`,zr=(t,e)=>u`${t} OPERATOR(${f}&>) ${M(e,t)}`,Qr=(t,e)=>u`${t} OPERATOR(${f}<<) ${M(e,t)}`,Fr=(t,e)=>u`${t} OPERATOR(${f}<<|) ${M(e,t)}`,Ur=(t,e)=>u`${t} OPERATOR(${f}|&>) ${M(e,t)}`,Vr=(t,e)=>u`${t} OPERATOR(${f}|>>) ${M(e,t)}`,Ar=(t,e)=>u`${t} OPERATOR(${f}>>) ${M(e,t)}`,Kr=(t,e)=>u`${t} OPERATOR(${f}=) ${M(e,t)}`,Hr=(t,e)=>u`${t} OPERATOR(${f}~=) ${M(e,t)}`,Yr=(t,e)=>u`${t} OPERATOR(${f}@) ${M(e,t)}`,Xr=(t,e)=>u`${t} OPERATOR(${f}~) ${M(e,t)}`,jr=(t,e)=>u`${t} OPERATOR(${f}<->) ${M(e,t)}`,tn=(t,e)=>u`${t} OPERATOR(${f}|=|) ${M(e,t)}`,en=(t,e)=>u`${t} OPERATOR(${f}<#>) ${M(e,t)}`,rn=(t,e)=>u`${t} OPERATOR(${f}<<->>) ${M(e,t)}`,nn=(t,e)=>u`${t} OPERATOR(${f}<<#>>) ${M(e,t)}`; | ||
var ar=Object.create;var Bt=Object.defineProperty;var ur=Object.getOwnPropertyDescriptor;var hr=Object.getOwnPropertyNames;var pr=Object.getPrototypeOf,fr=Object.prototype.hasOwnProperty;var K=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var L=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),wt=(t,e)=>{for(var r in e)Bt(t,r,{get:e[r],enumerable:!0});},lr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of hr(e))!fr.call(t,i)&&i!==r&&Bt(t,i,{get:()=>e[i],enumerable:!(n=ur(e,i))||n.enumerable});return t};var cr=(t,e,r)=>(r=t!=null?ar(pr(t)):{},lr(e||!t||!t.__esModule?Bt(r,"default",{value:t,enumerable:!0}):r,t));var $=L((li,_e)=>{_e.exports={wkt:{Point:"POINT",LineString:"LINESTRING",Polygon:"POLYGON",MultiPoint:"MULTIPOINT",MultiLineString:"MULTILINESTRING",MultiPolygon:"MULTIPOLYGON",GeometryCollection:"GEOMETRYCOLLECTION"},wkb:{Point:1,LineString:2,Polygon:3,MultiPoint:4,MultiLineString:5,MultiPolygon:6,GeometryCollection:7},geoJSON:{Point:"Point",LineString:"LineString",Polygon:"Polygon",MultiPoint:"MultiPoint",MultiLineString:"MultiLineString",MultiPolygon:"MultiPolygon",GeometryCollection:"GeometryCollection"}};});var R=L((ci,We)=>{We.exports=M;function M(t,e){this.buffer=new Buffer(t),this.position=0,this.allowResize=e;}function G(t,e){return function(r,n){this.ensureSize(e),t.call(this.buffer,r,this.position,n),this.position+=e;}}M.prototype.writeUInt8=G(Buffer.prototype.writeUInt8,1);M.prototype.writeUInt16LE=G(Buffer.prototype.writeUInt16LE,2);M.prototype.writeUInt16BE=G(Buffer.prototype.writeUInt16BE,2);M.prototype.writeUInt32LE=G(Buffer.prototype.writeUInt32LE,4);M.prototype.writeUInt32BE=G(Buffer.prototype.writeUInt32BE,4);M.prototype.writeInt8=G(Buffer.prototype.writeInt8,1);M.prototype.writeInt16LE=G(Buffer.prototype.writeInt16LE,2);M.prototype.writeInt16BE=G(Buffer.prototype.writeInt16BE,2);M.prototype.writeInt32LE=G(Buffer.prototype.writeInt32LE,4);M.prototype.writeInt32BE=G(Buffer.prototype.writeInt32BE,4);M.prototype.writeFloatLE=G(Buffer.prototype.writeFloatLE,4);M.prototype.writeFloatBE=G(Buffer.prototype.writeFloatBE,4);M.prototype.writeDoubleLE=G(Buffer.prototype.writeDoubleLE,8);M.prototype.writeDoubleBE=G(Buffer.prototype.writeDoubleBE,8);M.prototype.writeBuffer=function(t){this.ensureSize(t.length),t.copy(this.buffer,this.position,0,t.length),this.position+=t.length;};M.prototype.writeVarInt=function(t){for(var e=1;t&4294967168;)this.writeUInt8(t&127|128),t>>>=7,e++;return this.writeUInt8(t&127),e};M.prototype.ensureSize=function(t){if(this.buffer.length<this.position+t)if(this.allowResize){var e=new Buffer(this.position+t);this.buffer.copy(e,0,0,this.buffer.length),this.buffer=e;}else throw new RangeError("index out of range")};});var ne=L((gi,$e)=>{$e.exports={encode:function(t){return t<<1^t>>31},decode:function(t){return t>>1^-(t&1)}};});var D=L((yi,Ce)=>{Ce.exports=l;var mr=K("util"),Pt=J(),st=$(),Ie=R(),W=ne();function l(t,e,r,n,i){Pt.call(this),this.x=t,this.y=e,this.z=r,this.m=n,this.srid=i,this.hasZ=typeof this.z<"u",this.hasM=typeof this.m<"u";}mr.inherits(l,Pt);l.Z=function(t,e,r,n){var i=new l(t,e,r,void 0,n);return i.hasZ=!0,i};l.M=function(t,e,r,n){var i=new l(t,e,void 0,r,n);return i.hasM=!0,i};l.ZM=function(t,e,r,n,i){var o=new l(t,e,r,n,i);return o.hasZ=!0,o.hasM=!0,o};l._parseWkt=function(t,e){var r=new l;if(r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM,t.isMatch(["EMPTY"]))return r;t.expectGroupStart();var n=t.matchCoordinate(e);return r.x=n.x,r.y=n.y,r.z=n.z,r.m=n.m,t.expectGroupEnd(),r};l._parseWkb=function(t,e){var r=l._readWkbPoint(t,e);return r.srid=e.srid,r};l._readWkbPoint=function(t,e){return new l(t.readDouble(),t.readDouble(),e.hasZ?t.readDouble():void 0,e.hasM?t.readDouble():void 0)};l._parseTwkb=function(t,e){var r=new l;return r.hasZ=e.hasZ,r.hasM=e.hasM,e.isEmpty||(r.x=W.decode(t.readVarInt())/e.precisionFactor,r.y=W.decode(t.readVarInt())/e.precisionFactor,r.z=e.hasZ?W.decode(t.readVarInt())/e.zPrecisionFactor:void 0,r.m=e.hasM?W.decode(t.readVarInt())/e.mPrecisionFactor:void 0),r};l._readTwkbPoint=function(t,e,r){return r.x+=W.decode(t.readVarInt())/e.precisionFactor,r.y+=W.decode(t.readVarInt())/e.precisionFactor,e.hasZ&&(r.z+=W.decode(t.readVarInt())/e.zPrecisionFactor),e.hasM&&(r.m+=W.decode(t.readVarInt())/e.mPrecisionFactor),new l(r.x,r.y,r.z,r.m)};l._parseGeoJSON=function(t){return l._readGeoJSONPoint(t.coordinates)};l._readGeoJSONPoint=function(t){return t.length===0?new l:t.length>2?new l(t[0],t[1],t[2]):new l(t[0],t[1])};l.prototype.toWkt=function(){return typeof this.x>"u"&&typeof this.y>"u"&&typeof this.z>"u"&&typeof this.m>"u"?this._getWktType(st.wkt.Point,!0):this._getWktType(st.wkt.Point,!1)+"("+this._getWktCoordinate(this)+")"};l.prototype.toWkb=function(t){var e=new Ie(this._getWkbSize());return e.writeInt8(1),this._writeWkbType(e,st.wkb.Point,t),typeof this.x>"u"&&typeof this.y>"u"?(e.writeDoubleLE(NaN),e.writeDoubleLE(NaN),this.hasZ&&e.writeDoubleLE(NaN),this.hasM&&e.writeDoubleLE(NaN)):this._writeWkbPoint(e),e.buffer};l.prototype._writeWkbPoint=function(t){t.writeDoubleLE(this.x),t.writeDoubleLE(this.y),this.hasZ&&t.writeDoubleLE(this.z),this.hasM&&t.writeDoubleLE(this.m);};l.prototype.toTwkb=function(){var t=new Ie(0,!0),e=Pt.getTwkbPrecision(5,0,0),r=typeof this.x>"u"&&typeof this.y>"u";return this._writeTwkbHeader(t,st.wkb.Point,e,r),r||this._writeTwkbPoint(t,e,new l(0,0,0,0)),t.buffer};l.prototype._writeTwkbPoint=function(t,e,r){var n=this.x*e.xyFactor,i=this.y*e.xyFactor,o=this.z*e.zFactor,s=this.m*e.mFactor;t.writeVarInt(W.encode(n-r.x)),t.writeVarInt(W.encode(i-r.y)),this.hasZ&&t.writeVarInt(W.encode(o-r.z)),this.hasM&&t.writeVarInt(W.encode(s-r.m)),r.x=n,r.y=i,r.z=o,r.m=s;};l.prototype._getWkbSize=function(){var t=21;return this.hasZ&&(t+=8),this.hasM&&(t+=8),t};l.prototype.toGeoJSON=function(t){var e=Pt.prototype.toGeoJSON.call(this,t);return e.type=st.geoJSON.Point,typeof this.x>"u"&&typeof this.y>"u"?e.coordinates=[]:typeof this.z<"u"?e.coordinates=[this.x,this.y,this.z]:e.coordinates=[this.x,this.y],e};});var vt=L((mi,Be)=>{Be.exports=m;var dr=K("util"),kt=J(),at=$(),ut=D(),Ze=R();function m(t,e){kt.call(this),this.points=t||[],this.srid=e,this.points.length>0&&(this.hasZ=this.points[0].hasZ,this.hasM=this.points[0].hasM);}dr.inherits(m,kt);m.Z=function(t,e){var r=new m(t,e);return r.hasZ=!0,r};m.M=function(t,e){var r=new m(t,e);return r.hasM=!0,r};m.ZM=function(t,e){var r=new m(t,e);return r.hasZ=!0,r.hasM=!0,r};m._parseWkt=function(t,e){var r=new m;return r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM,t.isMatch(["EMPTY"])||(t.expectGroupStart(),r.points.push.apply(r.points,t.matchCoordinates(e)),t.expectGroupEnd()),r};m._parseWkb=function(t,e){var r=new m;r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM;for(var n=t.readUInt32(),i=0;i<n;i++)r.points.push(ut._readWkbPoint(t,e));return r};m._parseTwkb=function(t,e){var r=new m;if(r.hasZ=e.hasZ,r.hasM=e.hasM,e.isEmpty)return r;for(var n=new ut(0,0,e.hasZ?0:void 0,e.hasM?0:void 0),i=t.readVarInt(),o=0;o<i;o++)r.points.push(ut._readTwkbPoint(t,e,n));return r};m._parseGeoJSON=function(t){var e=new m;t.coordinates.length>0&&(e.hasZ=t.coordinates[0].length>2);for(var r=0;r<t.coordinates.length;r++)e.points.push(ut._readGeoJSONPoint(t.coordinates[r]));return e};m.prototype.toWkt=function(){return this.points.length===0?this._getWktType(at.wkt.LineString,!0):this._getWktType(at.wkt.LineString,!1)+this._toInnerWkt()};m.prototype._toInnerWkt=function(){for(var t="(",e=0;e<this.points.length;e++)t+=this._getWktCoordinate(this.points[e])+",";return t=t.slice(0,-1),t+=")",t};m.prototype.toWkb=function(t){var e=new Ze(this._getWkbSize());e.writeInt8(1),this._writeWkbType(e,at.wkb.LineString,t),e.writeUInt32LE(this.points.length);for(var r=0;r<this.points.length;r++)this.points[r]._writeWkbPoint(e);return e.buffer};m.prototype.toTwkb=function(){var t=new Ze(0,!0),e=kt.getTwkbPrecision(5,0,0),r=this.points.length===0;if(this._writeTwkbHeader(t,at.wkb.LineString,e,r),this.points.length>0){t.writeVarInt(this.points.length);for(var n=new ut(0,0,0,0),i=0;i<this.points.length;i++)this.points[i]._writeTwkbPoint(t,e,n);}return t.buffer};m.prototype._getWkbSize=function(){var t=16;return this.hasZ&&(t+=8),this.hasM&&(t+=8),9+this.points.length*t};m.prototype.toGeoJSON=function(t){var e=kt.prototype.toGeoJSON.call(this,t);e.type=at.geoJSON.LineString,e.coordinates=[];for(var r=0;r<this.points.length;r++)this.hasZ?e.coordinates.push([this.points[r].x,this.points[r].y,this.points[r].z]):e.coordinates.push([this.points[r].x,this.points[r].y]);return e};});var Tt=L((di,Re)=>{Re.exports=d;var wr=K("util"),Mt=J(),ht=$(),Q=D(),qe=R();function d(t,e,r){Mt.call(this),this.exteriorRing=t||[],this.interiorRings=e||[],this.srid=r,this.exteriorRing.length>0&&(this.hasZ=this.exteriorRing[0].hasZ,this.hasM=this.exteriorRing[0].hasM);}wr.inherits(d,Mt);d.Z=function(t,e,r){var n=new d(t,e,r);return n.hasZ=!0,n};d.M=function(t,e,r){var n=new d(t,e,r);return n.hasM=!0,n};d.ZM=function(t,e,r){var n=new d(t,e,r);return n.hasZ=!0,n.hasM=!0,n};d._parseWkt=function(t,e){var r=new d;if(r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM,t.isMatch(["EMPTY"]))return r;for(t.expectGroupStart(),t.expectGroupStart(),r.exteriorRing.push.apply(r.exteriorRing,t.matchCoordinates(e)),t.expectGroupEnd();t.isMatch([","]);)t.expectGroupStart(),r.interiorRings.push(t.matchCoordinates(e)),t.expectGroupEnd();return t.expectGroupEnd(),r};d._parseWkb=function(t,e){var r=new d;r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM;var n=t.readUInt32();if(n>0){for(var i=t.readUInt32(),o=0;o<i;o++)r.exteriorRing.push(Q._readWkbPoint(t,e));for(o=1;o<n;o++){for(var s=[],c=t.readUInt32(),p=0;p<c;p++)s.push(Q._readWkbPoint(t,e));r.interiorRings.push(s);}}return r};d._parseTwkb=function(t,e){var r=new d;if(r.hasZ=e.hasZ,r.hasM=e.hasM,e.isEmpty)return r;for(var n=new Q(0,0,e.hasZ?0:void 0,e.hasM?0:void 0),i=t.readVarInt(),o=t.readVarInt(),s=0;s<o;s++)r.exteriorRing.push(Q._readTwkbPoint(t,e,n));for(s=1;s<i;s++){for(var c=[],p=t.readVarInt(),a=0;a<p;a++)c.push(Q._readTwkbPoint(t,e,n));r.interiorRings.push(c);}return r};d._parseGeoJSON=function(t){var e=new d;t.coordinates.length>0&&t.coordinates[0].length>0&&(e.hasZ=t.coordinates[0][0].length>2);for(var r=0;r<t.coordinates.length;r++){r>0&&e.interiorRings.push([]);for(var n=0;n<t.coordinates[r].length;n++)r===0?e.exteriorRing.push(Q._readGeoJSONPoint(t.coordinates[r][n])):e.interiorRings[r-1].push(Q._readGeoJSONPoint(t.coordinates[r][n]));}return e};d.prototype.toWkt=function(){return this.exteriorRing.length===0?this._getWktType(ht.wkt.Polygon,!0):this._getWktType(ht.wkt.Polygon,!1)+this._toInnerWkt()};d.prototype._toInnerWkt=function(){for(var t="((",e=0;e<this.exteriorRing.length;e++)t+=this._getWktCoordinate(this.exteriorRing[e])+",";for(t=t.slice(0,-1),t+=")",e=0;e<this.interiorRings.length;e++){t+=",(";for(var r=0;r<this.interiorRings[e].length;r++)t+=this._getWktCoordinate(this.interiorRings[e][r])+",";t=t.slice(0,-1),t+=")";}return t+=")",t};d.prototype.toWkb=function(t){var e=new qe(this._getWkbSize());e.writeInt8(1),this._writeWkbType(e,ht.wkb.Polygon,t),this.exteriorRing.length>0?(e.writeUInt32LE(1+this.interiorRings.length),e.writeUInt32LE(this.exteriorRing.length)):e.writeUInt32LE(0);for(var r=0;r<this.exteriorRing.length;r++)this.exteriorRing[r]._writeWkbPoint(e);for(r=0;r<this.interiorRings.length;r++){e.writeUInt32LE(this.interiorRings[r].length);for(var n=0;n<this.interiorRings[r].length;n++)this.interiorRings[r][n]._writeWkbPoint(e);}return e.buffer};d.prototype.toTwkb=function(){var t=new qe(0,!0),e=Mt.getTwkbPrecision(5,0,0),r=this.exteriorRing.length===0;if(this._writeTwkbHeader(t,ht.wkb.Polygon,e,r),this.exteriorRing.length>0){t.writeVarInt(1+this.interiorRings.length),t.writeVarInt(this.exteriorRing.length);for(var n=new Q(0,0,0,0),i=0;i<this.exteriorRing.length;i++)this.exteriorRing[i]._writeTwkbPoint(t,e,n);for(i=0;i<this.interiorRings.length;i++){t.writeVarInt(this.interiorRings[i].length);for(var o=0;o<this.interiorRings[i].length;o++)this.interiorRings[i][o]._writeTwkbPoint(t,e,n);}}return t.buffer};d.prototype._getWkbSize=function(){var t=16;this.hasZ&&(t+=8),this.hasM&&(t+=8);var e=9;this.exteriorRing.length>0&&(e+=4+this.exteriorRing.length*t);for(var r=0;r<this.interiorRings.length;r++)e+=4+this.interiorRings[r].length*t;return e};d.prototype.toGeoJSON=function(t){var e=Mt.prototype.toGeoJSON.call(this,t);if(e.type=ht.geoJSON.Polygon,e.coordinates=[],this.exteriorRing.length>0){for(var r=[],n=0;n<this.exteriorRing.length;n++)this.hasZ?r.push([this.exteriorRing[n].x,this.exteriorRing[n].y,this.exteriorRing[n].z]):r.push([this.exteriorRing[n].x,this.exteriorRing[n].y]);e.coordinates.push(r);}for(var i=0;i<this.interiorRings.length;i++){for(var o=[],s=0;s<this.interiorRings[i].length;s++)this.hasZ?o.push([this.interiorRings[i][s].x,this.interiorRings[i][s].y,this.interiorRings[i][s].z]):o.push([this.interiorRings[i][s].x,this.interiorRings[i][s].y]);e.coordinates.push(o);}return e};});var ie=L((wi,Je)=>{Je.exports=w;var Sr=K("util"),pt=$(),ft=J(),Ot=D(),De=R();function w(t,e){ft.call(this),this.points=t||[],this.srid=e,this.points.length>0&&(this.hasZ=this.points[0].hasZ,this.hasM=this.points[0].hasM);}Sr.inherits(w,ft);w.Z=function(t,e){var r=new w(t,e);return r.hasZ=!0,r};w.M=function(t,e){var r=new w(t,e);return r.hasM=!0,r};w.ZM=function(t,e){var r=new w(t,e);return r.hasZ=!0,r.hasM=!0,r};w._parseWkt=function(t,e){var r=new w;return r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM,t.isMatch(["EMPTY"])||(t.expectGroupStart(),r.points.push.apply(r.points,t.matchCoordinates(e)),t.expectGroupEnd()),r};w._parseWkb=function(t,e){var r=new w;r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM;for(var n=t.readUInt32(),i=0;i<n;i++)r.points.push(ft.parse(t,e));return r};w._parseTwkb=function(t,e){var r=new w;if(r.hasZ=e.hasZ,r.hasM=e.hasM,e.isEmpty)return r;for(var n=new Ot(0,0,e.hasZ?0:void 0,e.hasM?0:void 0),i=t.readVarInt(),o=0;o<i;o++)r.points.push(Ot._readTwkbPoint(t,e,n));return r};w._parseGeoJSON=function(t){var e=new w;t.coordinates.length>0&&(e.hasZ=t.coordinates[0].length>2);for(var r=0;r<t.coordinates.length;r++)e.points.push(Ot._parseGeoJSON({coordinates:t.coordinates[r]}));return e};w.prototype.toWkt=function(){if(this.points.length===0)return this._getWktType(pt.wkt.MultiPoint,!0);for(var t=this._getWktType(pt.wkt.MultiPoint,!1)+"(",e=0;e<this.points.length;e++)t+=this._getWktCoordinate(this.points[e])+",";return t=t.slice(0,-1),t+=")",t};w.prototype.toWkb=function(){var t=new De(this._getWkbSize());t.writeInt8(1),this._writeWkbType(t,pt.wkb.MultiPoint),t.writeUInt32LE(this.points.length);for(var e=0;e<this.points.length;e++)t.writeBuffer(this.points[e].toWkb({srid:this.srid}));return t.buffer};w.prototype.toTwkb=function(){var t=new De(0,!0),e=ft.getTwkbPrecision(5,0,0),r=this.points.length===0;if(this._writeTwkbHeader(t,pt.wkb.MultiPoint,e,r),this.points.length>0){t.writeVarInt(this.points.length);for(var n=new Ot(0,0,0,0),i=0;i<this.points.length;i++)this.points[i]._writeTwkbPoint(t,e,n);}return t.buffer};w.prototype._getWkbSize=function(){var t=16;return this.hasZ&&(t+=8),this.hasM&&(t+=8),t+=5,9+this.points.length*t};w.prototype.toGeoJSON=function(t){var e=ft.prototype.toGeoJSON.call(this,t);e.type=pt.geoJSON.MultiPoint,e.coordinates=[];for(var r=0;r<this.points.length;r++)e.coordinates.push(this.points[r].toGeoJSON().coordinates);return e};});var ae=L((Si,Qe)=>{Qe.exports=S;var br=K("util"),lt=$(),ct=J(),oe=D(),se=vt(),ze=R();function S(t,e){ct.call(this),this.lineStrings=t||[],this.srid=e,this.lineStrings.length>0&&(this.hasZ=this.lineStrings[0].hasZ,this.hasM=this.lineStrings[0].hasM);}br.inherits(S,ct);S.Z=function(t,e){var r=new S(t,e);return r.hasZ=!0,r};S.M=function(t,e){var r=new S(t,e);return r.hasM=!0,r};S.ZM=function(t,e){var r=new S(t,e);return r.hasZ=!0,r.hasM=!0,r};S._parseWkt=function(t,e){var r=new S;if(r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM,t.isMatch(["EMPTY"]))return r;t.expectGroupStart();do t.expectGroupStart(),r.lineStrings.push(new se(t.matchCoordinates(e))),t.expectGroupEnd();while(t.isMatch([","]));return t.expectGroupEnd(),r};S._parseWkb=function(t,e){var r=new S;r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM;for(var n=t.readUInt32(),i=0;i<n;i++)r.lineStrings.push(ct.parse(t,e));return r};S._parseTwkb=function(t,e){var r=new S;if(r.hasZ=e.hasZ,r.hasM=e.hasM,e.isEmpty)return r;for(var n=new oe(0,0,e.hasZ?0:void 0,e.hasM?0:void 0),i=t.readVarInt(),o=0;o<i;o++){var s=new se;s.hasZ=e.hasZ,s.hasM=e.hasM;for(var c=t.readVarInt(),p=0;p<c;p++)s.points.push(oe._readTwkbPoint(t,e,n));r.lineStrings.push(s);}return r};S._parseGeoJSON=function(t){var e=new S;t.coordinates.length>0&&t.coordinates[0].length>0&&(e.hasZ=t.coordinates[0][0].length>2);for(var r=0;r<t.coordinates.length;r++)e.lineStrings.push(se._parseGeoJSON({coordinates:t.coordinates[r]}));return e};S.prototype.toWkt=function(){if(this.lineStrings.length===0)return this._getWktType(lt.wkt.MultiLineString,!0);for(var t=this._getWktType(lt.wkt.MultiLineString,!1)+"(",e=0;e<this.lineStrings.length;e++)t+=this.lineStrings[e]._toInnerWkt()+",";return t=t.slice(0,-1),t+=")",t};S.prototype.toWkb=function(){var t=new ze(this._getWkbSize());t.writeInt8(1),this._writeWkbType(t,lt.wkb.MultiLineString),t.writeUInt32LE(this.lineStrings.length);for(var e=0;e<this.lineStrings.length;e++)t.writeBuffer(this.lineStrings[e].toWkb({srid:this.srid}));return t.buffer};S.prototype.toTwkb=function(){var t=new ze(0,!0),e=ct.getTwkbPrecision(5,0,0),r=this.lineStrings.length===0;if(this._writeTwkbHeader(t,lt.wkb.MultiLineString,e,r),this.lineStrings.length>0){t.writeVarInt(this.lineStrings.length);for(var n=new oe(0,0,0,0),i=0;i<this.lineStrings.length;i++){t.writeVarInt(this.lineStrings[i].points.length);for(var o=0;o<this.lineStrings[i].points.length;o++)this.lineStrings[i].points[o]._writeTwkbPoint(t,e,n);}}return t.buffer};S.prototype._getWkbSize=function(){for(var t=9,e=0;e<this.lineStrings.length;e++)t+=this.lineStrings[e]._getWkbSize();return t};S.prototype.toGeoJSON=function(t){var e=ct.prototype.toGeoJSON.call(this,t);e.type=lt.geoJSON.MultiLineString,e.coordinates=[];for(var r=0;r<this.lineStrings.length;r++)e.coordinates.push(this.lineStrings[r].toGeoJSON().coordinates);return e};});var he=L((bi,Ue)=>{Ue.exports=b;var xr=K("util"),gt=$(),yt=J(),Lt=D(),ue=Tt(),Fe=R();function b(t,e){yt.call(this),this.polygons=t||[],this.srid=e,this.polygons.length>0&&(this.hasZ=this.polygons[0].hasZ,this.hasM=this.polygons[0].hasM);}xr.inherits(b,yt);b.Z=function(t,e){var r=new b(t,e);return r.hasZ=!0,r};b.M=function(t,e){var r=new b(t,e);return r.hasM=!0,r};b.ZM=function(t,e){var r=new b(t,e);return r.hasZ=!0,r.hasM=!0,r};b._parseWkt=function(t,e){var r=new b;if(r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM,t.isMatch(["EMPTY"]))return r;t.expectGroupStart();do{t.expectGroupStart();var n=[],i=[];for(t.expectGroupStart(),n.push.apply(n,t.matchCoordinates(e)),t.expectGroupEnd();t.isMatch([","]);)t.expectGroupStart(),i.push(t.matchCoordinates(e)),t.expectGroupEnd();r.polygons.push(new ue(n,i)),t.expectGroupEnd();}while(t.isMatch([","]));return t.expectGroupEnd(),r};b._parseWkb=function(t,e){var r=new b;r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM;for(var n=t.readUInt32(),i=0;i<n;i++)r.polygons.push(yt.parse(t,e));return r};b._parseTwkb=function(t,e){var r=new b;if(r.hasZ=e.hasZ,r.hasM=e.hasM,e.isEmpty)return r;for(var n=new Lt(0,0,e.hasZ?0:void 0,e.hasM?0:void 0),i=t.readVarInt(),o=0;o<i;o++){var s=new ue;s.hasZ=e.hasZ,s.hasM=e.hasM;for(var c=t.readVarInt(),p=t.readVarInt(),a=0;a<p;a++)s.exteriorRing.push(Lt._readTwkbPoint(t,e,n));for(a=1;a<c;a++){for(var y=[],O=t.readVarInt(),tt=0;tt<O;tt++)y.push(Lt._readTwkbPoint(t,e,n));s.interiorRings.push(y);}r.polygons.push(s);}return r};b._parseGeoJSON=function(t){var e=new b;t.coordinates.length>0&&t.coordinates[0].length>0&&t.coordinates[0][0].length>0&&(e.hasZ=t.coordinates[0][0][0].length>2);for(var r=0;r<t.coordinates.length;r++)e.polygons.push(ue._parseGeoJSON({coordinates:t.coordinates[r]}));return e};b.prototype.toWkt=function(){if(this.polygons.length===0)return this._getWktType(gt.wkt.MultiPolygon,!0);for(var t=this._getWktType(gt.wkt.MultiPolygon,!1)+"(",e=0;e<this.polygons.length;e++)t+=this.polygons[e]._toInnerWkt()+",";return t=t.slice(0,-1),t+=")",t};b.prototype.toWkb=function(){var t=new Fe(this._getWkbSize());t.writeInt8(1),this._writeWkbType(t,gt.wkb.MultiPolygon),t.writeUInt32LE(this.polygons.length);for(var e=0;e<this.polygons.length;e++)t.writeBuffer(this.polygons[e].toWkb({srid:this.srid}));return t.buffer};b.prototype.toTwkb=function(){var t=new Fe(0,!0),e=yt.getTwkbPrecision(5,0,0),r=this.polygons.length===0;if(this._writeTwkbHeader(t,gt.wkb.MultiPolygon,e,r),this.polygons.length>0){t.writeVarInt(this.polygons.length);for(var n=new Lt(0,0,0,0),i=0;i<this.polygons.length;i++){t.writeVarInt(1+this.polygons[i].interiorRings.length),t.writeVarInt(this.polygons[i].exteriorRing.length);for(var o=0;o<this.polygons[i].exteriorRing.length;o++)this.polygons[i].exteriorRing[o]._writeTwkbPoint(t,e,n);for(o=0;o<this.polygons[i].interiorRings.length;o++){t.writeVarInt(this.polygons[i].interiorRings[o].length);for(var s=0;s<this.polygons[i].interiorRings[o].length;s++)this.polygons[i].interiorRings[o][s]._writeTwkbPoint(t,e,n);}}}return t.buffer};b.prototype._getWkbSize=function(){for(var t=9,e=0;e<this.polygons.length;e++)t+=this.polygons[e]._getWkbSize();return t};b.prototype.toGeoJSON=function(t){var e=yt.prototype.toGeoJSON.call(this,t);e.type=gt.geoJSON.MultiPolygon,e.coordinates=[];for(var r=0;r<this.polygons.length;r++)e.coordinates.push(this.polygons[r].toGeoJSON().coordinates);return e};});var pe=L((xi,Ae)=>{Ae.exports=x;var Pr=K("util"),mt=$(),F=J(),Ve=R();function x(t,e){F.call(this),this.geometries=t||[],this.srid=e,this.geometries.length>0&&(this.hasZ=this.geometries[0].hasZ,this.hasM=this.geometries[0].hasM);}Pr.inherits(x,F);x.Z=function(t,e){var r=new x(t,e);return r.hasZ=!0,r};x.M=function(t,e){var r=new x(t,e);return r.hasM=!0,r};x.ZM=function(t,e){var r=new x(t,e);return r.hasZ=!0,r.hasM=!0,r};x._parseWkt=function(t,e){var r=new x;if(r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM,t.isMatch(["EMPTY"]))return r;t.expectGroupStart();do r.geometries.push(F.parse(t));while(t.isMatch([","]));return t.expectGroupEnd(),r};x._parseWkb=function(t,e){var r=new x;r.srid=e.srid,r.hasZ=e.hasZ,r.hasM=e.hasM;for(var n=t.readUInt32(),i=0;i<n;i++)r.geometries.push(F.parse(t,e));return r};x._parseTwkb=function(t,e){var r=new x;if(r.hasZ=e.hasZ,r.hasM=e.hasM,e.isEmpty)return r;for(var n=t.readVarInt(),i=0;i<n;i++)r.geometries.push(F.parseTwkb(t));return r};x._parseGeoJSON=function(t){for(var e=new x,r=0;r<t.geometries.length;r++)e.geometries.push(F._parseGeoJSON(t.geometries[r],!0));return e.geometries.length>0&&(e.hasZ=e.geometries[0].hasZ),e};x.prototype.toWkt=function(){if(this.geometries.length===0)return this._getWktType(mt.wkt.GeometryCollection,!0);for(var t=this._getWktType(mt.wkt.GeometryCollection,!1)+"(",e=0;e<this.geometries.length;e++)t+=this.geometries[e].toWkt()+",";return t=t.slice(0,-1),t+=")",t};x.prototype.toWkb=function(){var t=new Ve(this._getWkbSize());t.writeInt8(1),this._writeWkbType(t,mt.wkb.GeometryCollection),t.writeUInt32LE(this.geometries.length);for(var e=0;e<this.geometries.length;e++)t.writeBuffer(this.geometries[e].toWkb({srid:this.srid}));return t.buffer};x.prototype.toTwkb=function(){var t=new Ve(0,!0),e=F.getTwkbPrecision(5,0,0),r=this.geometries.length===0;if(this._writeTwkbHeader(t,mt.wkb.GeometryCollection,e,r),this.geometries.length>0){t.writeVarInt(this.geometries.length);for(var n=0;n<this.geometries.length;n++)t.writeBuffer(this.geometries[n].toTwkb());}return t.buffer};x.prototype._getWkbSize=function(){for(var t=9,e=0;e<this.geometries.length;e++)t+=this.geometries[e]._getWkbSize();return t};x.prototype.toGeoJSON=function(t){var e=F.prototype.toGeoJSON.call(this,t);e.type=mt.geoJSON.GeometryCollection,e.geometries=[];for(var r=0;r<this.geometries.length;r++)e.geometries.push(this.geometries[r].toGeoJSON());return e};});var He=L((Pi,Ke)=>{Ke.exports=Z;function Z(t,e){this.buffer=t,this.position=0,this.isBigEndian=e||!1;}function U(t,e,r){return function(){var n;return this.isBigEndian?n=e.call(this.buffer,this.position):n=t.call(this.buffer,this.position),this.position+=r,n}}Z.prototype.readUInt8=U(Buffer.prototype.readUInt8,Buffer.prototype.readUInt8,1);Z.prototype.readUInt16=U(Buffer.prototype.readUInt16LE,Buffer.prototype.readUInt16BE,2);Z.prototype.readUInt32=U(Buffer.prototype.readUInt32LE,Buffer.prototype.readUInt32BE,4);Z.prototype.readInt8=U(Buffer.prototype.readInt8,Buffer.prototype.readInt8,1);Z.prototype.readInt16=U(Buffer.prototype.readInt16LE,Buffer.prototype.readInt16BE,2);Z.prototype.readInt32=U(Buffer.prototype.readInt32LE,Buffer.prototype.readInt32BE,4);Z.prototype.readFloat=U(Buffer.prototype.readFloatLE,Buffer.prototype.readFloatBE,4);Z.prototype.readDouble=U(Buffer.prototype.readDoubleLE,Buffer.prototype.readDoubleBE,8);Z.prototype.readVarInt=function(){var t,e=0,r=0;do t=this.buffer[this.position+r],e+=(t&127)<<7*r,r++;while(t>=128);return this.position+=r,e};});var Xe=L((ki,Ye)=>{Ye.exports=I;var j=$(),Nt=D();function I(t){this.value=t,this.position=0;}I.prototype.match=function(t){this.skipWhitespaces();for(var e=0;e<t.length;e++)if(this.value.substring(this.position).indexOf(t[e])===0)return this.position+=t[e].length,t[e];return null};I.prototype.matchRegex=function(t){this.skipWhitespaces();for(var e=0;e<t.length;e++){var r=this.value.substring(this.position).match(t[e]);if(r)return this.position+=r[0].length,r}return null};I.prototype.isMatch=function(t){this.skipWhitespaces();for(var e=0;e<t.length;e++)if(this.value.substring(this.position).indexOf(t[e])===0)return this.position+=t[e].length,!0;return !1};I.prototype.matchType=function(){var t=this.match([j.wkt.Point,j.wkt.LineString,j.wkt.Polygon,j.wkt.MultiPoint,j.wkt.MultiLineString,j.wkt.MultiPolygon,j.wkt.GeometryCollection]);if(!t)throw new Error("Expected geometry type");return t};I.prototype.matchDimension=function(){var t=this.match(["ZM","Z","M"]);switch(t){case"ZM":return {hasZ:!0,hasM:!0};case"Z":return {hasZ:!0,hasM:!1};case"M":return {hasZ:!1,hasM:!0};default:return {hasZ:!1,hasM:!1}}};I.prototype.expectGroupStart=function(){if(!this.isMatch(["("]))throw new Error("Expected group start")};I.prototype.expectGroupEnd=function(){if(!this.isMatch([")"]))throw new Error("Expected group end")};I.prototype.matchCoordinate=function(t){var e;if(t.hasZ&&t.hasM?e=this.matchRegex([/^(\S*)\s+(\S*)\s+(\S*)\s+([^\s,)]*)/]):t.hasZ||t.hasM?e=this.matchRegex([/^(\S*)\s+(\S*)\s+([^\s,)]*)/]):e=this.matchRegex([/^(\S*)\s+([^\s,)]*)/]),!e)throw new Error("Expected coordinates");return t.hasZ&&t.hasM?new Nt(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]),parseFloat(e[4])):t.hasZ?new Nt(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])):t.hasM?new Nt(parseFloat(e[1]),parseFloat(e[2]),void 0,parseFloat(e[3])):new Nt(parseFloat(e[1]),parseFloat(e[2]))};I.prototype.matchCoordinates=function(t){var e=[];do{var r=this.isMatch(["("]);e.push(this.matchCoordinate(t)),r&&this.expectGroupEnd();}while(this.isMatch([","]));return e};I.prototype.skipWhitespaces=function(){for(;this.position<this.value.length&&this.value[this.position]===" ";)this.position++;};});var J=L((vi,je)=>{je.exports=T;var g=$(),Gt=D(),_t=vt(),Wt=Tt(),$t=ie(),It=ae(),Ct=he(),Zt=pe(),dt=He(),kr=R(),fe=Xe(),Et=ne();function T(){this.srid=void 0,this.hasZ=!1,this.hasM=!1;}T.parse=function(t,e){var r=typeof t;if(r==="string"||t instanceof fe)return T._parseWkt(t);if(Buffer.isBuffer(t)||t instanceof dt)return T._parseWkb(t,e);throw new Error("first argument must be a string or Buffer")};T._parseWkt=function(t){var e,r;t instanceof fe?e=t:e=new fe(t);var n=e.matchRegex([/^SRID=(\d+);/]);n&&(r=parseInt(n[1],10));var i=e.matchType(),o=e.matchDimension(),s={srid:r,hasZ:o.hasZ,hasM:o.hasM};switch(i){case g.wkt.Point:return Gt._parseWkt(e,s);case g.wkt.LineString:return _t._parseWkt(e,s);case g.wkt.Polygon:return Wt._parseWkt(e,s);case g.wkt.MultiPoint:return $t._parseWkt(e,s);case g.wkt.MultiLineString:return It._parseWkt(e,s);case g.wkt.MultiPolygon:return Ct._parseWkt(e,s);case g.wkt.GeometryCollection:return Zt._parseWkt(e,s)}};T._parseWkb=function(t,e){var r,n,i,o={};switch(t instanceof dt?r=t:r=new dt(t),r.isBigEndian=!r.readInt8(),n=r.readUInt32(),o.hasSrid=(n&536870912)===536870912,o.isEwkb=n&536870912||n&1073741824||n&2147483648,o.hasSrid&&(o.srid=r.readUInt32()),o.hasZ=!1,o.hasM=!1,!o.isEwkb&&(!e||!e.isEwkb)?n>=1e3&&n<2e3?(o.hasZ=!0,i=n-1e3):n>=2e3&&n<3e3?(o.hasM=!0,i=n-2e3):n>=3e3&&n<4e3?(o.hasZ=!0,o.hasM=!0,i=n-3e3):i=n:(n&2147483648&&(o.hasZ=!0),n&1073741824&&(o.hasM=!0),i=n&15),i){case g.wkb.Point:return Gt._parseWkb(r,o);case g.wkb.LineString:return _t._parseWkb(r,o);case g.wkb.Polygon:return Wt._parseWkb(r,o);case g.wkb.MultiPoint:return $t._parseWkb(r,o);case g.wkb.MultiLineString:return It._parseWkb(r,o);case g.wkb.MultiPolygon:return Ct._parseWkb(r,o);case g.wkb.GeometryCollection:return Zt._parseWkb(r,o);default:throw new Error("GeometryType "+i+" not supported")}};T.parseTwkb=function(t){var e,r={};t instanceof dt?e=t:e=new dt(t);var n=e.readUInt8(),i=e.readUInt8(),o=n&15;if(r.precision=Et.decode(n>>4),r.precisionFactor=Math.pow(10,r.precision),r.hasBoundingBox=i>>0&1,r.hasSizeAttribute=i>>1&1,r.hasIdList=i>>2&1,r.hasExtendedPrecision=i>>3&1,r.isEmpty=i>>4&1,r.hasExtendedPrecision){var s=e.readUInt8();r.hasZ=(s&1)===1,r.hasM=(s&2)===2,r.zPrecision=Et.decode((s&28)>>2),r.zPrecisionFactor=Math.pow(10,r.zPrecision),r.mPrecision=Et.decode((s&224)>>5),r.mPrecisionFactor=Math.pow(10,r.mPrecision);}else r.hasZ=!1,r.hasM=!1;if(r.hasSizeAttribute&&e.readVarInt(),r.hasBoundingBox){var c=2;r.hasZ&&c++,r.hasM&&c++;for(var p=0;p<c;p++)e.readVarInt(),e.readVarInt();}switch(o){case g.wkb.Point:return Gt._parseTwkb(e,r);case g.wkb.LineString:return _t._parseTwkb(e,r);case g.wkb.Polygon:return Wt._parseTwkb(e,r);case g.wkb.MultiPoint:return $t._parseTwkb(e,r);case g.wkb.MultiLineString:return It._parseTwkb(e,r);case g.wkb.MultiPolygon:return Ct._parseTwkb(e,r);case g.wkb.GeometryCollection:return Zt._parseTwkb(e,r);default:throw new Error("GeometryType "+o+" not supported")}};T.parseGeoJSON=function(t){return T._parseGeoJSON(t)};T._parseGeoJSON=function(t,e){var r;switch(t.type){case g.geoJSON.Point:r=Gt._parseGeoJSON(t);break;case g.geoJSON.LineString:r=_t._parseGeoJSON(t);break;case g.geoJSON.Polygon:r=Wt._parseGeoJSON(t);break;case g.geoJSON.MultiPoint:r=$t._parseGeoJSON(t);break;case g.geoJSON.MultiLineString:r=It._parseGeoJSON(t);break;case g.geoJSON.MultiPolygon:r=Ct._parseGeoJSON(t);break;case g.geoJSON.GeometryCollection:r=Zt._parseGeoJSON(t);break;default:throw new Error("GeometryType "+t.type+" not supported")}if(t.crs&&t.crs.type&&t.crs.type==="name"&&t.crs.properties&&t.crs.properties.name){var n=t.crs.properties.name;if(n.indexOf("EPSG:")===0)r.srid=parseInt(n.substring(5));else if(n.indexOf("urn:ogc:def:crs:EPSG::")===0)r.srid=parseInt(n.substring(22));else throw new Error("Unsupported crs: "+n)}else e||(r.srid=4326);return r};T.prototype.toEwkt=function(){return "SRID="+this.srid+";"+this.toWkt()};T.prototype.toEwkb=function(){var t=new kr(this._getWkbSize()+4),e=this.toWkb();return t.writeInt8(1),t.writeUInt32LE((e.slice(1,5).readUInt32LE(0)|536870912)>>>0,!0),t.writeUInt32LE(this.srid),t.writeBuffer(e.slice(5)),t.buffer};T.prototype._getWktType=function(t,e){var r=t;return this.hasZ&&this.hasM?r+=" ZM ":this.hasZ?r+=" Z ":this.hasM&&(r+=" M "),e&&!this.hasZ&&!this.hasM&&(r+=" "),e&&(r+="EMPTY"),r};T.prototype._getWktCoordinate=function(t){var e=t.x+" "+t.y;return this.hasZ&&(e+=" "+t.z),this.hasM&&(e+=" "+t.m),e};T.prototype._writeWkbType=function(t,e,r){var n=0;typeof this.srid>"u"&&(!r||typeof r.srid>"u")?this.hasZ&&this.hasM?n+=3e3:this.hasZ?n+=1e3:this.hasM&&(n+=2e3):(this.hasZ&&(n|=2147483648),this.hasM&&(n|=1073741824)),t.writeUInt32LE(n+e>>>0,!0);};T.getTwkbPrecision=function(t,e,r){return {xy:t,z:e,m:r,xyFactor:Math.pow(10,t),zFactor:Math.pow(10,e),mFactor:Math.pow(10,r)}};T.prototype._writeTwkbHeader=function(t,e,r,n){var i=(Et.encode(r.xy)<<4)+e,o=(this.hasZ||this.hasM)<<3;if(o+=n<<4,t.writeUInt8(i),t.writeUInt8(o),this.hasZ||this.hasM){var s=0;this.hasZ&&(s|=1),this.hasM&&(s|=2),t.writeUInt8(s);}};T.prototype.toGeoJSON=function(t){var e={};return this.srid&&t&&(t.shortCrs?e.crs={type:"name",properties:{name:"EPSG:"+this.srid}}:t.longCrs&&(e.crs={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::"+this.srid}})),e};});var tr=L(B=>{B.Types=$();B.Geometry=J();B.Point=D();B.LineString=vt();B.Polygon=Tt();B.MultiPoint=ie();B.MultiLineString=ae();B.MultiPolygon=he();B.GeometryCollection=pe();});var nr={};wt(nr,{box2D:()=>vr,box2DfromDriver:()=>rr,fromDriver:()=>_,geometry:()=>Mr,geometryCollection:()=>_r,lineString:()=>Lr,multiLineString:()=>Nr,multiPoint:()=>Or,multiPolygon:()=>Gr,point:()=>Tr,polygon:()=>Er});var u=Symbol.for("drizzle:entityKind");function P(t,e){if(!t||typeof t!="object")return !1;if(t instanceof e)return !0;if(!Object.prototype.hasOwnProperty.call(e,u))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 r=t.constructor;if(r)for(;r;){if(u in r&&r[u]===e[u])return !0;r=Object.getPrototypeOf(r);}return !1}var q=class{constructor(e,r){this.table=e,this.config=r,this.name=r.name,this.notNull=r.notNull,this.default=r.default,this.defaultFn=r.defaultFn,this.onUpdateFn=r.onUpdateFn,this.hasDefault=r.hasDefault,this.primary=r.primaryKey,this.isUnique=r.isUnique,this.uniqueName=r.uniqueName,this.uniqueType=r.uniqueType,this.dataType=r.dataType,this.columnType=r.columnType;}static[u]="Column";name;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}};var St=class{static[u]="ColumnBuilder";config;constructor(e,r,n){this.config={name:e,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:r,columnType:n};}$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}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}};var qt=Symbol.for("drizzle:Name"),Rt=Symbol.for("drizzle:Schema"),le=Symbol.for("drizzle:Columns"),ce=Symbol.for("drizzle:ExtraConfigColumns"),Dt=Symbol.for("drizzle:OriginalName"),Jt=Symbol.for("drizzle:BaseName"),ge=Symbol.for("drizzle:IsAlias"),ye=Symbol.for("drizzle:ExtraConfigBuilder"),gr=Symbol.for("drizzle:IsDrizzleTable"),N=class{static[u]="Table";static Symbol={Name:qt,Schema:Rt,OriginalName:Dt,Columns:le,ExtraConfigColumns:ce,BaseName:Jt,IsAlias:ge,ExtraConfigBuilder:ye};[qt];[Dt];[Rt];[le];[ce];[Jt];[ge]=!1;[ye]=void 0;[gr]=!0;constructor(e,r,n){this[qt]=this[Dt]=e,this[Rt]=r,this[Jt]=n;}};var me=Symbol.for("drizzle:PgInlineForeignKeys"),H=class extends N{static[u]="PgTable";static Symbol=Object.assign({},N.Symbol,{InlineForeignKeys:me});[me]=[];[N.Symbol.ExtraConfigBuilder]=void 0};var bt=class{static[u]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(e,r){this.reference=()=>{let{name:n,columns:i,foreignColumns:o}=e();return {name:n,columns:i,foreignTable:o[0].table,foreignColumns:o}},r&&(this._onUpdate=r.onUpdate,this._onDelete=r.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 zt(e,this)}},zt=class{constructor(e,r){this.table=e,this.reference=r.reference,this.onUpdate=r._onUpdate,this.onDelete=r._onDelete;}static[u]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:r,foreignColumns:n}=this.reference(),i=r.map(c=>c.name),o=n.map(c=>c.name),s=[this.table[H.Symbol.Name],...i,n[0].table[H.Symbol.Name],...o];return e??`${s.join("_")}_fk`}};function xt(t,...e){return t(...e)}function Ut(t,e){return `${t[H.Symbol.Name]}_${e.join("_")}_unique`}function we(t,e,r){for(let n=e;n<t.length;n++){let i=t[n];if(i==="\\"){n++;continue}if(i==='"')return [t.slice(e,n).replace(/\\/g,""),n+1];if(!r&&(i===","||i==="}"))return [t.slice(e,n).replace(/\\/g,""),n]}return [t.slice(e).replace(/\\/g,""),t.length]}function Se(t,e=0){let r=[],n=e,i=!1;for(;n<t.length;){let o=t[n];if(o===","){(i||n===e)&&r.push(""),i=!0,n++;continue}if(i=!1,o==="\\"){n+=2;continue}if(o==='"'){let[p,a]=we(t,n+1,!0);r.push(p),n=a;continue}if(o==="}")return [r,n+1];if(o==="{"){let[p,a]=Se(t,n+1);r.push(p),n=a;continue}let[s,c]=we(t,n,!1);r.push(s),n=c;}return [r,n]}function be(t){let[e]=Se(t,1);return e}function Vt(t){return `{${t.map(e=>Array.isArray(e)?Vt(e):typeof e=="string"?`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`${e}`).join(",")}}`}var Y=class extends St{foreignKeyConfigs=[];static[u]="PgColumnBuilder";array(e){return new Kt(this.config.name,this,e)}references(e,r={}){return this.foreignKeyConfigs.push({ref:e,actions:r}),this}unique(e,r){return this.config.isUnique=!0,this.config.uniqueName=e,this.config.uniqueType=r?.nulls,this}buildForeignKeys(e,r){return this.foreignKeyConfigs.map(({ref:n,actions:i})=>xt((o,s)=>{let c=new bt(()=>{let p=o();return {columns:[e],foreignColumns:[p]}});return s.onUpdate&&c.onUpdate(s.onUpdate),s.onDelete&&c.onDelete(s.onDelete),c.build(r)},n,i))}buildExtraConfigColumn(e){return new At(e,this.config)}},z=class extends q{constructor(e,r){r.uniqueName||(r.uniqueName=Ut(e,[r.name])),super(e,r),this.table=e;}static[u]="PgColumn"},At=class extends z{static[u]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};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(e){return this.indexConfig.opClass=e,this}},Kt=class extends Y{static[u]="PgArrayBuilder";constructor(e,r,n){super(e,"array","PgArray"),this.config.baseBuilder=r,this.config.size=n;}build(e){let r=this.config.baseBuilder.build(e);return new Ht(e,this.config,r)}},Ht=class t extends z{constructor(e,r,n,i){super(e,r),this.baseColumn=n,this.range=i,this.size=r.size;}size;static[u]="PgArray";getSQLType(){return `${this.baseColumn.getSQLType()}[${typeof this.size=="number"?this.size:""}]`}mapFromDriverValue(e){return typeof e=="string"&&(e=be(e)),e.map(r=>this.baseColumn.mapFromDriverValue(r))}mapToDriverValue(e,r=!1){let n=e.map(i=>i===null?null:P(this.baseColumn,t)?this.baseColumn.mapToDriverValue(i,!0):this.baseColumn.mapToDriverValue(i));return r?n:Vt(n)}};var Pe=Symbol.for("drizzle:isPgEnum");function ve(t){return !!t&&typeof t=="function"&&Pe in t&&t[Pe]===!0}var et=class{static[u]="Subquery";constructor(e,r,n,i=!1){this._={brand:"Subquery",sql:e,selectedFields:r,alias:n,isWith:i};}};var Oe={startActiveSpan(t,e){return e()}};var nt=Symbol.for("drizzle:ViewBaseConfig");function te(t){return t!=null&&typeof t.getSQL=="function"}function yr(t){let e={sql:"",params:[]};for(let r of t)e.sql+=r.sql,e.params.push(...r.params),r.typings?.length&&(e.typings||(e.typings=[]),e.typings.push(...r.typings));return e}var E=class{static[u]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e];}getSQL(){return new v([this])}},v=class t{constructor(e){this.queryChunks=e;}static[u]="SQL";decoder=Ee;shouldInlineParams=!1;append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return Oe.startActiveSpan("drizzle.buildSQL",r=>{let n=this.buildQueryFromSourceParams(this.queryChunks,e);return r?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(e,r){let n=Object.assign({},r,{inlineParams:r.inlineParams||this.shouldInlineParams,paramStartIndex:r.paramStartIndex||{value:0}}),{escapeName:i,escapeParam:o,prepareTyping:s,inlineParams:c,paramStartIndex:p}=n;return yr(e.map(a=>{if(P(a,E))return {sql:a.value.join(""),params:[]};if(P(a,it))return {sql:i(a.value),params:[]};if(a===void 0)return {sql:"",params:[]};if(Array.isArray(a)){let y=[new E("(")];for(let[O,tt]of a.entries())y.push(tt),O<a.length-1&&y.push(new E(", "));return y.push(new E(")")),this.buildQueryFromSourceParams(y,n)}if(P(a,t))return this.buildQueryFromSourceParams(a.queryChunks,{...n,inlineParams:c||a.shouldInlineParams});if(P(a,N)){let y=a[N.Symbol.Schema],O=a[N.Symbol.Name];return {sql:y===void 0?i(O):i(y)+"."+i(O),params:[]}}if(P(a,q))return r.invokeSource==="indexes"?{sql:i(a.name),params:[]}:{sql:i(a.table[N.Symbol.Name])+"."+i(a.name),params:[]};if(P(a,ot)){let y=a[nt].schema,O=a[nt].name;return {sql:y===void 0?i(O):i(y)+"."+i(O),params:[]}}if(P(a,X)){let y=a.value===null?null:a.encoder.mapToDriverValue(a.value);if(P(y,t))return this.buildQueryFromSourceParams([y],n);if(c)return {sql:this.mapInlineParam(y,n),params:[]};let O;return s!==void 0&&(O=[s(a.encoder)]),{sql:o(p.value++,y),params:[y],typings:O}}return P(a,rt)?{sql:o(p.value++,a),params:[a]}:P(a,t.Aliased)&&a.fieldAlias!==void 0?{sql:i(a.fieldAlias),params:[]}:P(a,et)?a._.isWith?{sql:i(a._.alias),params:[]}:this.buildQueryFromSourceParams([new E("("),a._.sql,new E(") "),new it(a._.alias)],n):ve(a)?a.schema?{sql:i(a.schema)+"."+i(a.enumName),params:[]}:{sql:i(a.enumName),params:[]}:te(a)?this.buildQueryFromSourceParams([new E("("),a.getSQL(),new E(")")],n):c?{sql:this.mapInlineParam(a,n),params:[]}:{sql:o(p.value++,a),params:[a]}}))}mapInlineParam(e,{escapeString:r}){if(e===null)return "null";if(typeof e=="number"||typeof e=="boolean")return e.toString();if(typeof e=="string")return r(e);if(typeof e=="object"){let n=e.toString();return r(n==="[object Object]"?JSON.stringify(e):n)}throw new Error("Unexpected param value: "+e)}getSQL(){return this}as(e){return e===void 0?this:new t.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}},it=class{constructor(e){this.value=e;}static[u]="Name";brand;getSQL(){return new v([this])}};function Ne(t){return typeof t=="object"&&t!==null&&"mapToDriverValue"in t&&typeof t.mapToDriverValue=="function"}var Ee={mapFromDriverValue:t=>t},Ge={mapToDriverValue:t=>t};({...Ee,...Ge});var X=class{constructor(e,r=Ge){this.value=e,this.encoder=r;}static[u]="Param";brand;getSQL(){return new v([this])}};function h(t,...e){let r=[];(e.length>0||t.length>0&&t[0]!=="")&&r.push(new E(t[0]));for(let[n,i]of e.entries())r.push(i,new E(t[n+1]));return new v(r)}(t=>{function e(){return new v([])}t.empty=e;function r(p){return new v(p)}t.fromList=r;function n(p){return new v([new E(p)])}t.raw=n;function i(p,a){let y=[];for(let[O,tt]of p.entries())O>0&&a!==void 0&&y.push(a),y.push(tt);return new v(y)}t.join=i;function o(p){return new it(p)}t.identifier=o;function s(p){return new rt(p)}t.placeholder=s;function c(p,a){return new X(p,a)}t.param=c;})(h||(h={}));(t=>{class e{constructor(n,i){this.sql=n,this.fieldAlias=i;}static[u]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new e(this.sql,this.fieldAlias)}}t.Aliased=e;})(v||(v={}));var rt=class{constructor(e){this.name=e;}static[u]="Placeholder";getSQL(){return new v([this])}};var ot=class{static[u]="View";[nt];constructor({name:e,schema:r,selectedFields:n,query:i}){this[nt]={name:e,originalName:e,schema:r,selectedFields:n,query:i,isExisting:!i,isAlias:!1};}getSQL(){return new v([this])}};q.prototype.getSQL=function(){return new v([this])};N.prototype.getSQL=function(){return new v([this])};et.prototype.getSQL=function(){return new v([this])};function k(t,e){return Ne(e)&&!te(t)&&!P(t,X)&&!P(t,rt)&&!P(t,q)&&!P(t,N)&&!P(t,ot)?new X(t,e):t}var ee=class extends Y{static[u]="PgCustomColumnBuilder";constructor(e,r,n){super(e,"custom","PgCustomColumn"),this.config.fieldConfig=r,this.config.customTypeParams=n;}build(e){return new re(e,this.config)}},re=class extends z{static[u]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor(e,r){super(e,r),this.sqlName=r.customTypeParams.dataType(r.fieldConfig),this.mapTo=r.customTypeParams.toDriver,this.mapFrom=r.customTypeParams.fromDriver;}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom=="function"?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo=="function"?this.mapTo(e):e}};function C(t){return (e,r)=>new ee(e,r,t)}var er=cr(tr()),V=t=>{let e="geometry";return t?.type?(e+=`(${t.type}`,t?.srid&&(e+=`,${t.srid}`),`${e})`):`${e}(Geometry)`};function A(t){return h`ST_GeomFromGeoJSON(${JSON.stringify(t)})`}function _(t){let e=Buffer.from(t,"hex");return er.default.Geometry.parse(e).toGeoJSON({shortCrs:!0})}function rr(t){let e=t.match(/BOX\((?<xmin>[0-9\.]+),? ?(?<ymin>[0-9\.]+),? ?(?<xmax>[0-9\.]+),? ?(?<ymax>[0-9\.]+)\)/);if(!e?.groups)throw new Error(`Box2D parse error, value: ${t}`);return [Number.parseFloat(e.groups.xmin),Number.parseFloat(e.groups.ymin),Number.parseFloat(e.groups.xmax),Number.parseFloat(e.groups.ymax)]}var vr=C({dataType:()=>"box2d",toDriver:t=>`BOX(${t[0]} ${t[1]}, ${t[2]} ${t[3]})`,fromDriver:rr}),Mr=C({dataType:V,toDriver:t=>A(t),fromDriver:t=>_(t)}),Tr=C({dataType:t=>V({type:`Point${t?.is3D?"Z":""}`,...t}),toDriver:t=>A(t),fromDriver:t=>_(t)}),Or=C({dataType:t=>V({type:`MultiPoint${t?.is3D?"Z":""}`,...t}),toDriver:t=>A(t),fromDriver:t=>_(t)}),Lr=C({dataType:t=>V({type:`LineString${t?.is3D?"Z":""}`,...t}),toDriver:t=>A(t),fromDriver:t=>_(t)}),Nr=C({dataType:t=>V({type:`MultiLineString${t?.is3D?"Z":""}`,...t}),toDriver:t=>A(t),fromDriver:t=>_(t)}),Er=C({dataType:t=>V({type:`Polygon${t?.is3D?"Z":""}`,...t}),toDriver:t=>A(t),fromDriver:t=>_(t)}),Gr=C({dataType:t=>V({type:`MultiPolygon${t?.is3D?"Z":""}`,...t}),toDriver:t=>A(t),fromDriver:t=>_(t)}),_r=C({dataType:t=>V({type:"GeometryCollection",...t}),toDriver:t=>A(t),fromDriver:t=>_(t)});var or={};wt(or,{addMeasure:()=>Qr,area:()=>$r,asText:()=>Zr,closestPoint:()=>Ir,geoHash:()=>zr,geomFromGeoJSON:()=>Jr,geomFromText:()=>Cr,isValid:()=>Rr,isValidReason:()=>Dr,x:()=>Br,y:()=>qr});var ir={};wt(ir,{gisExtensionSchema:()=>f,setPostGISSchema:()=>Wr});var f=h.raw("");function Wr(t){f=t.length?h.raw(`${t}.`):h.empty();}function $r(t){return h`${f}ST_Area(${t})`.mapWith(Number)}function Ir(t,e){return h`${f}ST_ClosestPoint(${t}, ${e})`.mapWith(_)}function Cr(t){return h`${f}ST_GeomFromText(${t})`.mapWith(_)}function Zr(t){return h`${f}ST_AsText(${t})`}function Br(t){return h`${f}ST_X(${t})`.mapWith(Number)}function qr(t){return h`${f}ST_Y(${t})`.mapWith(Number)}function Rr(t){return h`${f}ST_IsValid(${t},0)`.mapWith(Boolean)}function Dr(t){return h`${f}ST_IsValidReason(${t})`}function Jr(t){return h`${f}ST_GeomFromGeoJSON(${JSON.stringify(t)})`.mapWith(_)}function zr(t,e=20){return h`${f}ST_GeoHash(${t}, ${e})`}function Qr(t,e,r){return h`${f}ST_AddMeasure(${t}, ${e}, ${r})`}var sr={};wt(sr,{bboxAbove:()=>jr,bboxBelow:()=>Yr,bboxContain:()=>on,bboxContained:()=>nn,bboxLeft:()=>Hr,bboxOverlaps:()=>Fr,bboxOverlapsND:()=>Ur,bboxOverlapsOrAbove:()=>Xr,bboxOverlapsOrBelow:()=>Ar,bboxOverlapsOrLeft:()=>Vr,bboxOverlapsOrRight:()=>Kr,bboxRight:()=>tn,bboxSame:()=>rn,distanceBox:()=>un,distanceBoxND:()=>pn,distanceCPA:()=>an,distanceCentroidND:()=>hn,distanceKNN:()=>sn,eq:()=>en});var Fr=(t,e)=>h`${t} OPERATOR(${f}&&) ${k(e,t)}`,Ur=(t,e)=>h`${t} OPERATOR(${f}&&&) ${k(e,t)}`,Vr=(t,e)=>h`${t} OPERATOR(${f}&<) ${k(e,t)}`,Ar=(t,e)=>h`${t} OPERATOR(${f}&<|) ${k(e,t)}`,Kr=(t,e)=>h`${t} OPERATOR(${f}&>) ${k(e,t)}`,Hr=(t,e)=>h`${t} OPERATOR(${f}<<) ${k(e,t)}`,Yr=(t,e)=>h`${t} OPERATOR(${f}<<|) ${k(e,t)}`,Xr=(t,e)=>h`${t} OPERATOR(${f}|&>) ${k(e,t)}`,jr=(t,e)=>h`${t} OPERATOR(${f}|>>) ${k(e,t)}`,tn=(t,e)=>h`${t} OPERATOR(${f}>>) ${k(e,t)}`,en=(t,e)=>h`${t} OPERATOR(${f}=) ${k(e,t)}`,rn=(t,e)=>h`${t} OPERATOR(${f}~=) ${k(e,t)}`,nn=(t,e)=>h`${t} OPERATOR(${f}@) ${k(e,t)}`,on=(t,e)=>h`${t} OPERATOR(${f}~) ${k(e,t)}`,sn=(t,e)=>h`${t} OPERATOR(${f}<->) ${k(e,t)}`,an=(t,e)=>h`${t} OPERATOR(${f}|=|) ${k(e,t)}`,un=(t,e)=>h`${t} OPERATOR(${f}<#>) ${k(e,t)}`,hn=(t,e)=>h`${t} OPERATOR(${f}<<->>) ${k(e,t)}`,pn=(t,e)=>h`${t} OPERATOR(${f}<<#>>) ${k(e,t)}`; | ||
exports.config = Xe; | ||
exports.functions = je; | ||
exports.models = Ye; | ||
exports.operators = tr; | ||
exports.config = ir; | ||
exports.functions = or; | ||
exports.models = nr; | ||
exports.operators = sr; | ||
@@ -11,0 +11,0 @@ return exports; |
'use strict'; | ||
var Tr = require('wkx'); | ||
var ve = require('wkx'); | ||
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } | ||
var Tr__default = /*#__PURE__*/_interopDefault(Tr); | ||
var ve__default = /*#__PURE__*/_interopDefault(ve); | ||
var xr=Object.defineProperty;var B=(r,e)=>{for(var t in e)xr(r,t,{get:e[t],enumerable:!0});};var gr={};B(gr,{box2D:()=>Lr,box2DfromDriver:()=>hr,fromDriver:()=>$,geometry:()=>Dr,geometryCollection:()=>qr,lineString:()=>Gr,multiLineString:()=>vr,multiPoint:()=>Qr,multiPolygon:()=>Ar,point:()=>Pr,polygon:()=>Cr});var a=Symbol.for("drizzle:entityKind");function c(r,e){if(!r||typeof r!="object")return !1;if(r instanceof e)return !0;if(!Object.prototype.hasOwnProperty.call(e,a))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=r.constructor;if(t)for(;t;){if(a in t&&t[a]===e[a])return !0;t=Object.getPrototypeOf(t);}return !1}var x=class{constructor(e,t){this.table=e,this.config=t,this.name=t.name,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;}static[a]="Column";name;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}};var T=Symbol.for("drizzle:SubqueryConfig"),P=class{static[a]="Subquery";[T];constructor(e,t,n,i=!1){this[T]={sql:e,selection:t,alias:n,isWith:i};}};function z(r,...e){return r(...e)}var or={startActiveSpan(r,e){return e()}};var G=Symbol.for("drizzle:ViewBaseConfig");var V=Symbol.for("drizzle:Name"),K=Symbol.for("drizzle:Schema"),ir=Symbol.for("drizzle:Columns"),I=Symbol.for("drizzle:OriginalName"),U=Symbol.for("drizzle:BaseName"),sr=Symbol.for("drizzle:IsAlias"),ar=Symbol.for("drizzle:ExtraConfigBuilder"),wr=Symbol.for("drizzle:IsDrizzleTable"),S=class{static[a]="Table";static Symbol={Name:V,Schema:K,OriginalName:I,Columns:ir,BaseName:U,IsAlias:sr,ExtraConfigBuilder:ar};[V];[I];[K];[ir];[U];[sr]=!1;[ar]=void 0;[wr]=!0;constructor(e,t,n){this[V]=this[I]=e,this[K]=t,this[U]=n;}};function j(r){return typeof r=="object"&&r!==null&&"getSQL"in r&&typeof r.getSQL=="function"}function Nr(r){let e={sql:"",params:[]};for(let t of r)e.sql+=t.sql,e.params.push(...t.params),t.typings?.length&&(e.typings||(e.typings=[]),e.typings.push(...t.typings));return e}var h=class{static[a]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e];}getSQL(){return new y([this])}},y=class r{constructor(e){this.queryChunks=e;}static[a]="SQL";decoder=lr;shouldInlineParams=!1;append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return or.startActiveSpan("drizzle.buildSQL",t=>{let n=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(e,t){let n=Object.assign({},t,{inlineParams:t.inlineParams||this.shouldInlineParams,paramStartIndex:t.paramStartIndex||{value:0}}),{escapeName:i,escapeParam:p,prepareTyping:g,inlineParams:d,paramStartIndex:l}=n;return Nr(e.map(o=>{if(c(o,h))return {sql:o.value.join(""),params:[]};if(c(o,v))return {sql:i(o.value),params:[]};if(o===void 0)return {sql:"",params:[]};if(Array.isArray(o)){let m=[new h("(")];for(let[b,W]of o.entries())m.push(W),b<o.length-1&&m.push(new h(", "));return m.push(new h(")")),this.buildQueryFromSourceParams(m,n)}if(c(o,r))return this.buildQueryFromSourceParams(o.queryChunks,{...n,inlineParams:d||o.shouldInlineParams});if(c(o,S)){let m=o[S.Symbol.Schema],b=o[S.Symbol.Name];return {sql:m===void 0?i(b):i(m)+"."+i(b),params:[]}}if(c(o,x))return {sql:i(o.table[S.Symbol.Name])+"."+i(o.name),params:[]};if(c(o,C)){let m=o[G].schema,b=o[G].name;return {sql:m===void 0?i(b):i(m)+"."+i(b),params:[]}}if(c(o,L)){let m=o.value===null?null:o.encoder.mapToDriverValue(o.value);if(c(m,r))return this.buildQueryFromSourceParams([m],n);if(d)return {sql:this.mapInlineParam(m,n),params:[]};let b;return g!==void 0&&(b=[g(o.encoder)]),{sql:p(l.value++,m),params:[m],typings:b}}return c(o,Q)?{sql:p(l.value++,o),params:[o]}:c(o,r.Aliased)&&o.fieldAlias!==void 0?{sql:i(o.fieldAlias),params:[]}:c(o,P)?o[T].isWith?{sql:i(o[T].alias),params:[]}:this.buildQueryFromSourceParams([new h("("),o[T].sql,new h(") "),new v(o[T].alias)],n):j(o)?this.buildQueryFromSourceParams([new h("("),o.getSQL(),new h(")")],n):d?{sql:this.mapInlineParam(o,n),params:[]}:{sql:p(l.value++,o),params:[o]}}))}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"){let n=e.toString();return t(n==="[object Object]"?JSON.stringify(e):n)}throw new Error("Unexpected param value: "+e)}getSQL(){return this}as(e){return e===void 0?this:new r.Aliased(this,e)}mapWith(e){return this.decoder=typeof e=="function"?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}},v=class{constructor(e){this.value=e;}static[a]="Name";brand;getSQL(){return new y([this])}};function pr(r){return typeof r=="object"&&r!==null&&"mapToDriverValue"in r&&typeof r.mapToDriverValue=="function"}var lr={mapFromDriverValue:r=>r},mr={mapToDriverValue:r=>r};({...lr,...mr});var L=class{constructor(e,t=mr){this.value=e,this.encoder=t;}static[a]="Param";brand;getSQL(){return new y([this])}};function s(r,...e){let t=[];(e.length>0||r.length>0&&r[0]!=="")&&t.push(new h(r[0]));for(let[n,i]of e.entries())t.push(i,new h(r[n+1]));return new y(t)}(r=>{function e(){return new y([])}r.empty=e;function t(l){return new y(l)}r.fromList=t;function n(l){return new y([new h(l)])}r.raw=n;function i(l,o){let m=[];for(let[b,W]of l.entries())b>0&&o!==void 0&&m.push(o),m.push(W);return new y(m)}r.join=i;function p(l){return new v(l)}r.identifier=p;function g(l){return new Q(l)}r.placeholder=g;function d(l,o){return new L(l,o)}r.param=d;})(s||(s={}));(r=>{class e{constructor(n,i){this.sql=n,this.fieldAlias=i;}static[a]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new e(this.sql,this.fieldAlias)}}r.Aliased=e;})(y||(y={}));var Q=class{constructor(e){this.name=e;}static[a]="Placeholder";getSQL(){return new y([this])}};var C=class{static[a]="View";[G];constructor({name:e,schema:t,selectedFields:n,query:i}){this[G]={name:e,originalName:e,schema:t,selectedFields:n,query:i,isExisting:!i,isAlias:!1};}getSQL(){return new y([this])}};x.prototype.getSQL=function(){return new y([this])};S.prototype.getSQL=function(){return new y([this])};P.prototype.getSQL=function(){return new y([this])};var R=class{static[a]="ColumnBuilder";config;constructor(e,t,n){this.config={name:e,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:n};}$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}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}};function f(r,e){return pr(e)&&!j(r)&&!c(r,L)&&!c(r,Q)&&!c(r,x)&&!c(r,S)&&!c(r,C)?new L(r,e):r}var cr=Symbol.for("drizzle:PgInlineForeignKeys"),D=class extends S{static[a]="PgTable";static Symbol=Object.assign({},S.Symbol,{InlineForeignKeys:cr});[cr]=[];[S.Symbol.ExtraConfigBuilder]=void 0};var E=class{static[a]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(e,t){this.reference=()=>{let{name:n,columns:i,foreignColumns:p}=e();return {name:n,columns:i,foreignTable:p[0].table,foreignColumns:p}},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 M(e,this)}},M=class{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete;}static[a]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),i=t.map(d=>d.name),p=n.map(d=>d.name),g=[this.table[D.Symbol.Name],...i,n[0].table[D.Symbol.Name],...p];return e??`${g.join("_")}_fk`}};function X(r,e){return `${r[D.Symbol.Name]}_${e.join("_")}_unique`}function yr(r,e,t){for(let n=e;n<r.length;n++){let i=r[n];if(i==="\\"){n++;continue}if(i==='"')return [r.slice(e,n).replace(/\\/g,""),n+1];if(!t&&(i===","||i==="}"))return [r.slice(e,n).replace(/\\/g,""),n]}return [r.slice(e).replace(/\\/g,""),r.length]}function dr(r,e=0){let t=[],n=e,i=!1;for(;n<r.length;){let p=r[n];if(p===","){(i||n===e)&&t.push(""),i=!0,n++;continue}if(i=!1,p==="\\"){n+=2;continue}if(p==='"'){let[l,o]=yr(r,n+1,!0);t.push(l),n=o;continue}if(p==="}")return [t,n+1];if(p==="{"){let[l,o]=dr(r,n+1);t.push(l),n=o;continue}let[g,d]=yr(r,n,!1);t.push(g),n=d;}return [t,n]}function Sr(r){let[e]=dr(r,1);return e}function H(r){return `{${r.map(e=>Array.isArray(e)?H(e):typeof e=="string"?`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`${e}`).join(",")}}`}var A=class extends R{foreignKeyConfigs=[];static[a]="PgColumnBuilder";array(e){return new Y(this.config.name,this,e)}references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e,t){return this.config.isUnique=!0,this.config.uniqueName=e,this.config.uniqueType=t?.nulls,this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:i})=>z((p,g)=>{let d=new E(()=>{let l=p();return {columns:[e],foreignColumns:[l]}});return g.onUpdate&&d.onUpdate(g.onUpdate),g.onDelete&&d.onDelete(g.onDelete),d.build(t)},n,i))}},q=class extends x{constructor(e,t){t.uniqueName||(t.uniqueName=X(e,[t.name])),super(e,t),this.table=e;}static[a]="PgColumn"},Y=class extends A{static[a]="PgArrayBuilder";constructor(e,t,n){super(e,"array","PgArray"),this.config.baseBuilder=t,this.config.size=n;}build(e){let t=this.config.baseBuilder.build(e);return new k(e,this.config,t)}},k=class r extends q{constructor(e,t,n,i){super(e,t),this.baseColumn=n,this.range=i,this.size=t.size;}size;static[a]="PgArray";getSQLType(){return `${this.baseColumn.getSQLType()}[${typeof this.size=="number"?this.size:""}]`}mapFromDriverValue(e){return typeof e=="string"&&(e=Sr(e)),e.map(t=>this.baseColumn.mapFromDriverValue(t))}mapToDriverValue(e,t=!1){let n=e.map(i=>i===null?null:c(this.baseColumn,r)?this.baseColumn.mapToDriverValue(i,!0):this.baseColumn.mapToDriverValue(i));return t?n:H(n)}};var rr=class extends A{static[a]="PgCustomColumnBuilder";constructor(e,t,n){super(e,"custom","PgCustomColumn"),this.config.fieldConfig=t,this.config.customTypeParams=n;}build(e){return new er(e,this.config)}},er=class extends q{static[a]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver;}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom=="function"?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo=="function"?this.mapTo(e):e}};function O(r){return (e,t)=>new rr(e,t,r)}var w=r=>{let e="geometry";return r?.type&&(e+=`(${r.type}`,r?.srid&&(e+=`,${r.srid}`),e+=")"),e};function N(r){return s`ST_GeomFromGeoJSON(${JSON.stringify(r)})`}function $(r){let e=Buffer.from(r,"hex");return Tr__default.default.Geometry.parse(e).toGeoJSON({shortCrs:!0})}function hr(r){let e=r.match(/BOX\((?<xmin>[0-9\.]+),? ?(?<ymin>[0-9\.]+),? ?(?<xmax>[0-9\.]+),? ?(?<ymax>[0-9\.]+)\)/);if(!e?.groups)throw new Error(`Box2D parse error, value: ${r}`);return [Number.parseFloat(e.groups.xmin),Number.parseFloat(e.groups.ymin),Number.parseFloat(e.groups.xmax),Number.parseFloat(e.groups.ymax)]}var Lr=O({dataType:()=>"box2d",toDriver:r=>`BOX(${r[0]} ${r[1]}, ${r[2]} ${r[3]})`,fromDriver:hr}),Dr=O({dataType:w,toDriver:r=>N(r),fromDriver:r=>$(r)}),Pr=O({dataType:r=>w({type:`Point${r?.is3D?"Z":""}`,...r}),toDriver:r=>N(r),fromDriver:r=>$(r)}),Qr=O({dataType:r=>w({type:`MultiPoint${r?.is3D?"Z":""}`,...r}),toDriver:r=>N(r),fromDriver:r=>$(r)}),Gr=O({dataType:r=>w({type:`LineString${r?.is3D?"Z":""}`,...r}),toDriver:r=>N(r),fromDriver:r=>$(r)}),vr=O({dataType:r=>w({type:`MultiLineString${r?.is3D?"Z":""}`,...r}),toDriver:r=>N(r),fromDriver:r=>$(r)}),Cr=O({dataType:r=>w({type:`Polygon${r?.is3D?"Z":""}`,...r}),toDriver:r=>N(r),fromDriver:r=>$(r)}),Ar=O({dataType:r=>w({type:`MultiPolygon${r?.is3D?"Z":""}`,...r}),toDriver:r=>N(r),fromDriver:r=>$(r)}),qr=O({dataType:r=>w({type:"GeometryCollection",...r}),toDriver:r=>N(r),fromDriver:r=>$(r)});var br={};B(br,{addMeasure:()=>jr,area:()=>zr,asText:()=>Wr,closestPoint:()=>Rr,geoHash:()=>Ur,geomFromGeoJSON:()=>Ir,geomFromText:()=>Er,isValid:()=>Vr,isValidReason:()=>Kr,x:()=>Fr,y:()=>Jr});var $r={};B($r,{gisExtensionSchema:()=>u,setPostGISSchema:()=>Br});var u=s.raw("");function Br(r){u=r.length?s.raw(`${r}.`):s.empty();}function zr(r){return s`${u}ST_Area(${r})`.mapWith(Number)}function Rr(r,e){return s`${u}ST_ClosestPoint(${r}, ${e})`.mapWith($)}function Er(r){return s`${u}ST_GeomFromText(${r})`.mapWith($)}function Wr(r){return s`${u}ST_AsText(${r})`}function Fr(r){return s`${u}ST_X(${r})`.mapWith(Number)}function Jr(r){return s`${u}ST_Y(${r})`.mapWith(Number)}function Vr(r){return s`${u}ST_IsValid(${r},0)`.mapWith(Boolean)}function Kr(r){return s`${u}ST_IsValidReason(${r})`}function Ir(r){return s`${u}ST_GeomFromGeoJSON(${JSON.stringify(r)})`.mapWith($)}function Ur(r,e=20){return s`${u}ST_GeoHash(${r}, ${e})`}function jr(r,e,t){return s`${u}ST_AddMeasure(${r}, ${e}, ${t})`}var Or={};B(Or,{bboxAbove:()=>ee,bboxBelow:()=>kr,bboxContain:()=>se,bboxContained:()=>ie,bboxLeft:()=>Yr,bboxOverlaps:()=>Mr,bboxOverlapsND:()=>_r,bboxOverlapsOrAbove:()=>re,bboxOverlapsOrBelow:()=>Xr,bboxOverlapsOrLeft:()=>Zr,bboxOverlapsOrRight:()=>Hr,bboxRight:()=>te,bboxSame:()=>oe,distanceBox:()=>pe,distanceBoxND:()=>me,distanceCPA:()=>ue,distanceCentroidND:()=>le,distanceKNN:()=>ae,eq:()=>ne});var Mr=(r,e)=>s`${r} OPERATOR(${u}&&) ${f(e,r)}`,_r=(r,e)=>s`${r} OPERATOR(${u}&&&) ${f(e,r)}`,Zr=(r,e)=>s`${r} OPERATOR(${u}&<) ${f(e,r)}`,Xr=(r,e)=>s`${r} OPERATOR(${u}&<|) ${f(e,r)}`,Hr=(r,e)=>s`${r} OPERATOR(${u}&>) ${f(e,r)}`,Yr=(r,e)=>s`${r} OPERATOR(${u}<<) ${f(e,r)}`,kr=(r,e)=>s`${r} OPERATOR(${u}<<|) ${f(e,r)}`,re=(r,e)=>s`${r} OPERATOR(${u}|&>) ${f(e,r)}`,ee=(r,e)=>s`${r} OPERATOR(${u}|>>) ${f(e,r)}`,te=(r,e)=>s`${r} OPERATOR(${u}>>) ${f(e,r)}`,ne=(r,e)=>s`${r} OPERATOR(${u}=) ${f(e,r)}`,oe=(r,e)=>s`${r} OPERATOR(${u}~=) ${f(e,r)}`,ie=(r,e)=>s`${r} OPERATOR(${u}@) ${f(e,r)}`,se=(r,e)=>s`${r} OPERATOR(${u}~) ${f(e,r)}`,ae=(r,e)=>s`${r} OPERATOR(${u}<->) ${f(e,r)}`,ue=(r,e)=>s`${r} OPERATOR(${u}|=|) ${f(e,r)}`,pe=(r,e)=>s`${r} OPERATOR(${u}<#>) ${f(e,r)}`,le=(r,e)=>s`${r} OPERATOR(${u}<<->>) ${f(e,r)}`,me=(r,e)=>s`${r} OPERATOR(${u}<<#>>) ${f(e,r)}`; | ||
var Ce=Object.defineProperty;var q=(e,r)=>{for(var t in r)Ce(e,t,{get:r[t],enumerable:!0});};var Ne={};q(Ne,{box2D:()=>Ge,box2DfromDriver:()=>we,fromDriver:()=>$,geometry:()=>Ae,geometryCollection:()=>We,lineString:()=>Be,multiLineString:()=>ze,multiPoint:()=>Ee,multiPolygon:()=>Re,point:()=>qe,polygon:()=>Fe});var s=Symbol.for("drizzle:entityKind");function c(e,r){if(!e||typeof e!="object")return !1;if(e instanceof r)return !0;if(!Object.prototype.hasOwnProperty.call(r,s))throw new Error(`Class "${r.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=e.constructor;if(t)for(;t;){if(s in t&&t[s]===r[s])return !0;t=Object.getPrototypeOf(t);}return !1}var O=class{constructor(r,t){this.table=r,this.config=t,this.name=t.name,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;}static[s]="Column";name;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;config;mapFromDriverValue(r){return r}mapToDriverValue(r){return r}};var E=class{static[s]="ColumnBuilder";config;constructor(r,t,n){this.config={name:r,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:n};}$type(){return this}notNull(){return this.config.notNull=!0,this}default(r){return this.config.default=r,this.config.hasDefault=!0,this}$defaultFn(r){return this.config.defaultFn=r,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(r){return this.config.onUpdateFn=r,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}};var R=Symbol.for("drizzle:Name"),W=Symbol.for("drizzle:Schema"),ne=Symbol.for("drizzle:Columns"),oe=Symbol.for("drizzle:ExtraConfigColumns"),J=Symbol.for("drizzle:OriginalName"),V=Symbol.for("drizzle:BaseName"),ie=Symbol.for("drizzle:IsAlias"),se=Symbol.for("drizzle:ExtraConfigBuilder"),De=Symbol.for("drizzle:IsDrizzleTable"),h=class{static[s]="Table";static Symbol={Name:R,Schema:W,OriginalName:J,Columns:ne,ExtraConfigColumns:oe,BaseName:V,IsAlias:ie,ExtraConfigBuilder:se};[R];[J];[W];[ne];[oe];[V];[ie]=!1;[se]=void 0;[De]=!0;constructor(r,t,n){this[R]=this[J]=r,this[W]=t,this[V]=n;}};var ae=Symbol.for("drizzle:PgInlineForeignKeys"),L=class extends h{static[s]="PgTable";static Symbol=Object.assign({},h.Symbol,{InlineForeignKeys:ae});[ae]=[];[h.Symbol.ExtraConfigBuilder]=void 0};var B=class{static[s]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(r,t){this.reference=()=>{let{name:n,columns:i,foreignColumns:l}=r();return {name:n,columns:i,foreignTable:l[0].table,foreignColumns:l}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete);}onUpdate(r){return this._onUpdate=r===void 0?"no action":r,this}onDelete(r){return this._onDelete=r===void 0?"no action":r,this}build(r){return new K(r,this)}},K=class{constructor(r,t){this.table=r,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete;}static[s]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:r,columns:t,foreignColumns:n}=this.reference(),i=t.map(d=>d.name),l=n.map(d=>d.name),S=[this.table[L.Symbol.Name],...i,n[0].table[L.Symbol.Name],...l];return r??`${S.join("_")}_fk`}};function z(e,...r){return e(...r)}function j(e,r){return `${e[L.Symbol.Name]}_${r.join("_")}_unique`}function le(e,r,t){for(let n=r;n<e.length;n++){let i=e[n];if(i==="\\"){n++;continue}if(i==='"')return [e.slice(r,n).replace(/\\/g,""),n+1];if(!t&&(i===","||i==="}"))return [e.slice(r,n).replace(/\\/g,""),n]}return [e.slice(r).replace(/\\/g,""),e.length]}function pe(e,r=0){let t=[],n=r,i=!1;for(;n<e.length;){let l=e[n];if(l===","){(i||n===r)&&t.push(""),i=!0,n++;continue}if(i=!1,l==="\\"){n+=2;continue}if(l==='"'){let[p,o]=le(e,n+1,!0);t.push(p),n=o;continue}if(l==="}")return [t,n+1];if(l==="{"){let[p,o]=pe(e,n+1);t.push(p),n=o;continue}let[S,d]=le(e,n,!1);t.push(S),n=d;}return [t,n]}function me(e){let[r]=pe(e,1);return r}function _(e){return `{${e.map(r=>Array.isArray(r)?_(r):typeof r=="string"?`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`${r}`).join(",")}}`}var P=class extends E{foreignKeyConfigs=[];static[s]="PgColumnBuilder";array(r){return new Z(this.config.name,this,r)}references(r,t={}){return this.foreignKeyConfigs.push({ref:r,actions:t}),this}unique(r,t){return this.config.isUnique=!0,this.config.uniqueName=r,this.config.uniqueType=t?.nulls,this}buildForeignKeys(r,t){return this.foreignKeyConfigs.map(({ref:n,actions:i})=>z((l,S)=>{let d=new B(()=>{let p=l();return {columns:[r],foreignColumns:[p]}});return S.onUpdate&&d.onUpdate(S.onUpdate),S.onDelete&&d.onDelete(S.onDelete),d.build(t)},n,i))}buildExtraConfigColumn(r){return new M(r,this.config)}},w=class extends O{constructor(r,t){t.uniqueName||(t.uniqueName=j(r,[t.name])),super(r,t),this.table=r;}static[s]="PgColumn"},M=class extends w{static[s]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};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(r){return this.indexConfig.opClass=r,this}},Z=class extends P{static[s]="PgArrayBuilder";constructor(r,t,n){super(r,"array","PgArray"),this.config.baseBuilder=t,this.config.size=n;}build(r){let t=this.config.baseBuilder.build(r);return new X(r,this.config,t)}},X=class e extends w{constructor(r,t,n,i){super(r,t),this.baseColumn=n,this.range=i,this.size=t.size;}size;static[s]="PgArray";getSQLType(){return `${this.baseColumn.getSQLType()}[${typeof this.size=="number"?this.size:""}]`}mapFromDriverValue(r){return typeof r=="string"&&(r=me(r)),r.map(t=>this.baseColumn.mapFromDriverValue(t))}mapToDriverValue(r,t=!1){let n=r.map(i=>i===null?null:c(this.baseColumn,e)?this.baseColumn.mapToDriverValue(i,!0):this.baseColumn.mapToDriverValue(i));return t?n:_(n)}};var fe=Symbol.for("drizzle:isPgEnum");function de(e){return !!e&&typeof e=="function"&&fe in e&&e[fe]===!0}var D=class{static[s]="Subquery";constructor(r,t,n,i=!1){this._={brand:"Subquery",sql:r,selectedFields:t,alias:n,isWith:i};}};var Se={startActiveSpan(e,r){return r()}};var v=Symbol.for("drizzle:ViewBaseConfig");function ee(e){return e!=null&&typeof e.getSQL=="function"}function Qe(e){let r={sql:"",params:[]};for(let t of e)r.sql+=t.sql,r.params.push(...t.params),t.typings?.length&&(r.typings||(r.typings=[]),r.typings.push(...t.typings));return r}var g=class{static[s]="StringChunk";value;constructor(r){this.value=Array.isArray(r)?r:[r];}getSQL(){return new y([this])}},y=class e{constructor(r){this.queryChunks=r;}static[s]="SQL";decoder=xe;shouldInlineParams=!1;append(r){return this.queryChunks.push(...r.queryChunks),this}toQuery(r){return Se.startActiveSpan("drizzle.buildSQL",t=>{let n=this.buildQueryFromSourceParams(this.queryChunks,r);return t?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(r,t){let n=Object.assign({},t,{inlineParams:t.inlineParams||this.shouldInlineParams,paramStartIndex:t.paramStartIndex||{value:0}}),{escapeName:i,escapeParam:l,prepareTyping:S,inlineParams:d,paramStartIndex:p}=n;return Qe(r.map(o=>{if(c(o,g))return {sql:o.value.join(""),params:[]};if(c(o,G))return {sql:i(o.value),params:[]};if(o===void 0)return {sql:"",params:[]};if(Array.isArray(o)){let m=[new g("(")];for(let[b,F]of o.entries())m.push(F),b<o.length-1&&m.push(new g(", "));return m.push(new g(")")),this.buildQueryFromSourceParams(m,n)}if(c(o,e))return this.buildQueryFromSourceParams(o.queryChunks,{...n,inlineParams:d||o.shouldInlineParams});if(c(o,h)){let m=o[h.Symbol.Schema],b=o[h.Symbol.Name];return {sql:m===void 0?i(b):i(m)+"."+i(b),params:[]}}if(c(o,O))return t.invokeSource==="indexes"?{sql:i(o.name),params:[]}:{sql:i(o.table[h.Symbol.Name])+"."+i(o.name),params:[]};if(c(o,A)){let m=o[v].schema,b=o[v].name;return {sql:m===void 0?i(b):i(m)+"."+i(b),params:[]}}if(c(o,C)){let m=o.value===null?null:o.encoder.mapToDriverValue(o.value);if(c(m,e))return this.buildQueryFromSourceParams([m],n);if(d)return {sql:this.mapInlineParam(m,n),params:[]};let b;return S!==void 0&&(b=[S(o.encoder)]),{sql:l(p.value++,m),params:[m],typings:b}}return c(o,Q)?{sql:l(p.value++,o),params:[o]}:c(o,e.Aliased)&&o.fieldAlias!==void 0?{sql:i(o.fieldAlias),params:[]}:c(o,D)?o._.isWith?{sql:i(o._.alias),params:[]}:this.buildQueryFromSourceParams([new g("("),o._.sql,new g(") "),new G(o._.alias)],n):de(o)?o.schema?{sql:i(o.schema)+"."+i(o.enumName),params:[]}:{sql:i(o.enumName),params:[]}:ee(o)?this.buildQueryFromSourceParams([new g("("),o.getSQL(),new g(")")],n):d?{sql:this.mapInlineParam(o,n),params:[]}:{sql:l(p.value++,o),params:[o]}}))}mapInlineParam(r,{escapeString:t}){if(r===null)return "null";if(typeof r=="number"||typeof r=="boolean")return r.toString();if(typeof r=="string")return t(r);if(typeof r=="object"){let n=r.toString();return t(n==="[object Object]"?JSON.stringify(r):n)}throw new Error("Unexpected param value: "+r)}getSQL(){return this}as(r){return r===void 0?this:new e.Aliased(this,r)}mapWith(r){return this.decoder=typeof r=="function"?{mapFromDriverValue:r}:r,this}inlineParams(){return this.shouldInlineParams=!0,this}if(r){return r?this:void 0}},G=class{constructor(r){this.value=r;}static[s]="Name";brand;getSQL(){return new y([this])}};function be(e){return typeof e=="object"&&e!==null&&"mapToDriverValue"in e&&typeof e.mapToDriverValue=="function"}var xe={mapFromDriverValue:e=>e},Oe={mapToDriverValue:e=>e};({...xe,...Oe});var C=class{constructor(r,t=Oe){this.value=r,this.encoder=t;}static[s]="Param";brand;getSQL(){return new y([this])}};function a(e,...r){let t=[];(r.length>0||e.length>0&&e[0]!=="")&&t.push(new g(e[0]));for(let[n,i]of r.entries())t.push(i,new g(e[n+1]));return new y(t)}(e=>{function r(){return new y([])}e.empty=r;function t(p){return new y(p)}e.fromList=t;function n(p){return new y([new g(p)])}e.raw=n;function i(p,o){let m=[];for(let[b,F]of p.entries())b>0&&o!==void 0&&m.push(o),m.push(F);return new y(m)}e.join=i;function l(p){return new G(p)}e.identifier=l;function S(p){return new Q(p)}e.placeholder=S;function d(p,o){return new C(p,o)}e.param=d;})(a||(a={}));(e=>{class r{constructor(n,i){this.sql=n,this.fieldAlias=i;}static[s]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new r(this.sql,this.fieldAlias)}}e.Aliased=r;})(y||(y={}));var Q=class{constructor(r){this.name=r;}static[s]="Placeholder";getSQL(){return new y([this])}};var A=class{static[s]="View";[v];constructor({name:r,schema:t,selectedFields:n,query:i}){this[v]={name:r,originalName:r,schema:t,selectedFields:n,query:i,isExisting:!i,isAlias:!1};}getSQL(){return new y([this])}};O.prototype.getSQL=function(){return new y([this])};h.prototype.getSQL=function(){return new y([this])};D.prototype.getSQL=function(){return new y([this])};function f(e,r){return be(r)&&!ee(e)&&!c(e,C)&&!c(e,Q)&&!c(e,O)&&!c(e,h)&&!c(e,A)?new C(e,r):e}var re=class extends P{static[s]="PgCustomColumnBuilder";constructor(r,t,n){super(r,"custom","PgCustomColumn"),this.config.fieldConfig=t,this.config.customTypeParams=n;}build(r){return new te(r,this.config)}},te=class extends w{static[s]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor(r,t){super(r,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver;}getSQLType(){return this.sqlName}mapFromDriverValue(r){return typeof this.mapFrom=="function"?this.mapFrom(r):r}mapToDriverValue(r){return typeof this.mapTo=="function"?this.mapTo(r):r}};function x(e){return (r,t)=>new re(r,t,e)}var N=e=>{let r="geometry";return e?.type?(r+=`(${e.type}`,e?.srid&&(r+=`,${e.srid}`),`${r})`):`${r}(Geometry)`};function T(e){return a`ST_GeomFromGeoJSON(${JSON.stringify(e)})`}function $(e){let r=Buffer.from(e,"hex");return ve__default.default.Geometry.parse(r).toGeoJSON({shortCrs:!0})}function we(e){let r=e.match(/BOX\((?<xmin>[0-9\.]+),? ?(?<ymin>[0-9\.]+),? ?(?<xmax>[0-9\.]+),? ?(?<ymax>[0-9\.]+)\)/);if(!r?.groups)throw new Error(`Box2D parse error, value: ${e}`);return [Number.parseFloat(r.groups.xmin),Number.parseFloat(r.groups.ymin),Number.parseFloat(r.groups.xmax),Number.parseFloat(r.groups.ymax)]}var Ge=x({dataType:()=>"box2d",toDriver:e=>`BOX(${e[0]} ${e[1]}, ${e[2]} ${e[3]})`,fromDriver:we}),Ae=x({dataType:N,toDriver:e=>T(e),fromDriver:e=>$(e)}),qe=x({dataType:e=>N({type:`Point${e?.is3D?"Z":""}`,...e}),toDriver:e=>T(e),fromDriver:e=>$(e)}),Ee=x({dataType:e=>N({type:`MultiPoint${e?.is3D?"Z":""}`,...e}),toDriver:e=>T(e),fromDriver:e=>$(e)}),Be=x({dataType:e=>N({type:`LineString${e?.is3D?"Z":""}`,...e}),toDriver:e=>T(e),fromDriver:e=>$(e)}),ze=x({dataType:e=>N({type:`MultiLineString${e?.is3D?"Z":""}`,...e}),toDriver:e=>T(e),fromDriver:e=>$(e)}),Fe=x({dataType:e=>N({type:`Polygon${e?.is3D?"Z":""}`,...e}),toDriver:e=>T(e),fromDriver:e=>$(e)}),Re=x({dataType:e=>N({type:`MultiPolygon${e?.is3D?"Z":""}`,...e}),toDriver:e=>T(e),fromDriver:e=>$(e)}),We=x({dataType:e=>N({type:"GeometryCollection",...e}),toDriver:e=>T(e),fromDriver:e=>$(e)});var Le={};q(Le,{addMeasure:()=>Ye,area:()=>Ve,asText:()=>Ue,closestPoint:()=>Ke,geoHash:()=>He,geomFromGeoJSON:()=>Xe,geomFromText:()=>Ie,isValid:()=>Me,isValidReason:()=>Ze,x:()=>je,y:()=>_e});var Te={};q(Te,{gisExtensionSchema:()=>u,setPostGISSchema:()=>Je});var u=a.raw("");function Je(e){u=e.length?a.raw(`${e}.`):a.empty();}function Ve(e){return a`${u}ST_Area(${e})`.mapWith(Number)}function Ke(e,r){return a`${u}ST_ClosestPoint(${e}, ${r})`.mapWith($)}function Ie(e){return a`${u}ST_GeomFromText(${e})`.mapWith($)}function Ue(e){return a`${u}ST_AsText(${e})`}function je(e){return a`${u}ST_X(${e})`.mapWith(Number)}function _e(e){return a`${u}ST_Y(${e})`.mapWith(Number)}function Me(e){return a`${u}ST_IsValid(${e},0)`.mapWith(Boolean)}function Ze(e){return a`${u}ST_IsValidReason(${e})`}function Xe(e){return a`${u}ST_GeomFromGeoJSON(${JSON.stringify(e)})`.mapWith($)}function He(e,r=20){return a`${u}ST_GeoHash(${e}, ${r})`}function Ye(e,r,t){return a`${u}ST_AddMeasure(${e}, ${r}, ${t})`}var Pe={};q(Pe,{bboxAbove:()=>ar,bboxBelow:()=>ir,bboxContain:()=>cr,bboxContained:()=>mr,bboxLeft:()=>or,bboxOverlaps:()=>ke,bboxOverlapsND:()=>er,bboxOverlapsOrAbove:()=>sr,bboxOverlapsOrBelow:()=>tr,bboxOverlapsOrLeft:()=>rr,bboxOverlapsOrRight:()=>nr,bboxRight:()=>ur,bboxSame:()=>pr,distanceBox:()=>dr,distanceBoxND:()=>gr,distanceCPA:()=>yr,distanceCentroidND:()=>hr,distanceKNN:()=>fr,eq:()=>lr});var ke=(e,r)=>a`${e} OPERATOR(${u}&&) ${f(r,e)}`,er=(e,r)=>a`${e} OPERATOR(${u}&&&) ${f(r,e)}`,rr=(e,r)=>a`${e} OPERATOR(${u}&<) ${f(r,e)}`,tr=(e,r)=>a`${e} OPERATOR(${u}&<|) ${f(r,e)}`,nr=(e,r)=>a`${e} OPERATOR(${u}&>) ${f(r,e)}`,or=(e,r)=>a`${e} OPERATOR(${u}<<) ${f(r,e)}`,ir=(e,r)=>a`${e} OPERATOR(${u}<<|) ${f(r,e)}`,sr=(e,r)=>a`${e} OPERATOR(${u}|&>) ${f(r,e)}`,ar=(e,r)=>a`${e} OPERATOR(${u}|>>) ${f(r,e)}`,ur=(e,r)=>a`${e} OPERATOR(${u}>>) ${f(r,e)}`,lr=(e,r)=>a`${e} OPERATOR(${u}=) ${f(r,e)}`,pr=(e,r)=>a`${e} OPERATOR(${u}~=) ${f(r,e)}`,mr=(e,r)=>a`${e} OPERATOR(${u}@) ${f(r,e)}`,cr=(e,r)=>a`${e} OPERATOR(${u}~) ${f(r,e)}`,fr=(e,r)=>a`${e} OPERATOR(${u}<->) ${f(r,e)}`,yr=(e,r)=>a`${e} OPERATOR(${u}|=|) ${f(r,e)}`,dr=(e,r)=>a`${e} OPERATOR(${u}<#>) ${f(r,e)}`,hr=(e,r)=>a`${e} OPERATOR(${u}<<->>) ${f(r,e)}`,gr=(e,r)=>a`${e} OPERATOR(${u}<<#>>) ${f(r,e)}`; | ||
exports.config = $r; | ||
exports.functions = br; | ||
exports.models = gr; | ||
exports.operators = Or; | ||
exports.config = Te; | ||
exports.functions = Le; | ||
exports.models = Ne; | ||
exports.operators = Pe; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "drizzle-postgis", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A Drizzle extension/plugin to help work with PostGIS and GeoJSON", | ||
@@ -47,4 +47,4 @@ "keywords": [ | ||
"dotenv": "^16.4.5", | ||
"drizzle-kit": "^0.20.14", | ||
"drizzle-orm": "^0.30.5", | ||
"drizzle-kit": "^0.22.6", | ||
"drizzle-orm": "^0.31.2", | ||
"postgres": "^3.4.4", | ||
@@ -65,5 +65,5 @@ "semantic-release": "^23.0.6", | ||
"patchedDependencies": { | ||
"drizzle-kit@0.20.14": "patches/drizzle-kit@0.20.14.patch" | ||
"drizzle-kit@0.22.6": "patches/drizzle-kit@0.22.6.patch" | ||
} | ||
} | ||
} |
@@ -18,3 +18,3 @@ <h1 align="center" style="border-bottom: none;">🌐 drizzle-postgis</h1> | ||
I'm a GIS beginner, please let me know if you see anything problematic in the way this library is implemented. | ||
The library is also missing support for very many functions, and test coverage exists but is not complete. | ||
The library is also missing support for very many functions. PRs are very welcome, all I ask is that you add test coverage for any new functions :) | ||
@@ -25,7 +25,3 @@ ## 🎉 Installation | ||
> **NOTE** | ||
> Unfortunately drizzle-kit has a bug that causes custom types to be quoted. | ||
> In order to use this with migrations, you need to apply a [patch](https://github.com/Schmavery/drizzle-postgis/blob/main/patches/drizzle-kit%400.20.14.patch). | ||
> This is the only solution until this issue is fixed! | ||
> https://github.com/drizzle-team/drizzle-kit-mirror/issues/350 | ||
Patching drizzle-kit (See Troubleshooting for more info) is no longer required in most cases (unless you need to generate migrations with a box2d type). | ||
@@ -38,2 +34,41 @@ ## ❓Troubleshooting | ||
### NOTE for people using box2d | ||
> Unfortunately drizzle-kit has a bug that causes some custom types to be quoted. The only type in this library that is still affected (as of drizzle-kit 0.22.0) is `box2d`. | ||
> In order to use this with migrations, you need to apply a patch (see below). | ||
> This issue tracks this problem somewhat: https://github.com/drizzle-team/drizzle-kit-mirror/issues/350 | ||
#### Step 1: Obtain the Patch File | ||
The patch file is located in repository under the `patches` directory: `patches/drizzle-kit@<version>.patch`. (Replace <version> with your installed version of drizzle-kit). | ||
You can copy the patch file content directly from the repository to your local patches directory. | ||
#### Step 2: Apply the Patch | ||
If you're using pnpm, you can apply the patch by adding the following lines to your `package.json` file under the `pnpm` section: | ||
```json | ||
"pnpm": { | ||
"patchedDependencies": { | ||
"drizzle-kit@<version>": "patches/drizzle-kit@<version>.patch" | ||
} | ||
} | ||
``` | ||
This configuration tells pnpm to apply the specified patch to the `drizzle-kit@<version>` dependency. | ||
Note that `patches/drizzle-kit@<version>.patch` is the path to the patch file | ||
After updating your `package.json`, run `pnpm install` to install the patched dependency. | ||
#### Alternative: Manual Patching (not recommended) | ||
If you prefer not to modify your `package.json`, you can manually apply the patch using the `patch` command: | ||
1. Save the patch file content to a local file, e.g., `drizzle-kit.patch`. | ||
2. Navigate to the directory where `drizzle-kit` is installed (usually `node_modules/drizzle-kit`). | ||
3. Run the following command: `patch -p1 < /path/to/drizzle-kit.patch` | ||
This will apply the patch to the `drizzle-kit` dependency. | ||
## 📚 Auto generate docs | ||
@@ -49,3 +84,4 @@ | ||
## 🙏 Thanks to | ||
## 🙏 Thanks to | ||
- 🚧 [@akashrajpurohit/ts-npm-template](https://akashrajpurohit.com/blog/building-and-publishing-typescript-npm-packages-a-stepbystep-guide/?ref=ts-npm-template-readme) - an opinionated bootstrap template to create NPM packages. | ||
@@ -57,2 +93,2 @@ - ⌨️ [Typescript](https://www.typescriptlang.org/) with [tsup](https://tsup.egoist.dev/) build tool. | ||
- 🔀 [Github Actions](https://github.com/features/actions) - CI pipelines | ||
- 📦 [PNPM](https://pnpm.io/) - Package manager | ||
- 📦 [PNPM](https://pnpm.io/) - Package manager |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
693793
963
90