@influxdata/influxdb3-client-browser 1.2.0-nightly.8630 → 1.2.0-nightly.8663

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -808,6 +808,7 @@ declare const DEFAULT_ConnectionOptions: Partial<ConnectionOptions>;
808
808
  * },
809
809
  * precision: 'ns',
810
810
  * gzipThreshold: 1000,
811
+ * noSync: false,
811
812
  * })
812
813
  * ```
813
814
  */
@@ -818,6 +819,17 @@ interface WriteOptions {
818
819
  headers?: Record<string, string>;
819
820
  /** When specified, write bodies larger than the threshold are gzipped */
820
821
  gzipThreshold?: number;
822
+ /**
823
+ * Instructs the server whether to wait with the response until WAL persistence completes.
824
+ * noSync=true means faster write but without the confirmation that the data was persisted.
825
+ *
826
+ * Note: This option is supported by InfluxDB 3 Core and Enterprise servers only.
827
+ * For other InfluxDB 3 server types (InfluxDB Clustered, InfluxDB Clould Serverless/Dedicated)
828
+ * the write operation will fail with an error.
829
+ *
830
+ * Default value: false.
831
+ */
832
+ noSync?: boolean;
821
833
  /** default tags
822
834
  *
823
835
  * @example Default tags using client config
@@ -913,6 +925,9 @@ declare function fromConnectionString(connectionString: string): ClientOptions;
913
925
  * Creates `ClientOptions` from environment variables.
914
926
  */
915
927
  declare function fromEnv(): ClientOptions;
928
+ declare function precisionToV2ApiString(precision: WritePrecision): string;
929
+ declare function precisionToV3ApiString(precision: WritePrecision): string;
930
+ declare function parsePrecision(value: string): WritePrecision;
916
931
 
917
932
  /**
918
933
  * Logging interface.
@@ -1029,6 +1044,7 @@ declare class InfluxDBClient {
1029
1044
  * - timeout - I/O timeout
1030
1045
  * - precision - timestamp precision when writing data
1031
1046
  * - gzipThreshold - payload size threshold for gzipping data
1047
+ * - writeNoSync - skip waiting for WAL persistence on write
1032
1048
  *
1033
1049
  * @param connectionString - connection string
1034
1050
  */
@@ -1044,6 +1060,7 @@ declare class InfluxDBClient {
1044
1060
  * - INFLUX_DATABASE - database (bucket) name
1045
1061
  * - INFLUX_PRECISION - timestamp precision when writing data
1046
1062
  * - INFLUX_GZIP_THRESHOLD - payload size threshold for gzipping data
1063
+ * - INFLUX_WRITE_NO_SYNC - skip waiting for WAL persistence on write
1047
1064
  */
1048
1065
  constructor();
1049
1066
  private _mergeWriteOptions;
@@ -1099,4 +1116,4 @@ declare class InfluxDBClient {
1099
1116
  close(): Promise<void>;
1100
1117
  }
1101
1118
 
1102
- export { AbortError, type Cancellable, type ChunkCombiner, type ClientOptions, type CommunicationObserver, type ConnectionOptions, DEFAULT_ConnectionOptions, DEFAULT_QueryOptions, DEFAULT_WriteOptions, GetFieldTypeMissmatchError, type HttpHeaders as Headers, HttpError, type HttpHeaders, IllegalArgumentError, InfluxDBClient, Log, type Logger, Point, type PointFieldType, PointValues, type QParamType, type QueryOptions, type QueryType, RequestTimedOutError, type ResponseStartedFn, type SendOptions, type TimeConverter, type Transport, type WritableData, type WriteOptions, type WritePrecision, collectAll, consoleLogger, convertTime, convertTimeToNanos, createTextDecoderCombiner, currentTime, dateToProtocolTimestamp, escape, fromConnectionString, fromEnv, isNumber, setLogger, useProcessHrtime, writableDataToLineProtocol };
1119
+ export { AbortError, type Cancellable, type ChunkCombiner, type ClientOptions, type CommunicationObserver, type ConnectionOptions, DEFAULT_ConnectionOptions, DEFAULT_QueryOptions, DEFAULT_WriteOptions, GetFieldTypeMissmatchError, type HttpHeaders as Headers, HttpError, type HttpHeaders, IllegalArgumentError, InfluxDBClient, Log, type Logger, Point, type PointFieldType, PointValues, type QParamType, type QueryOptions, type QueryType, RequestTimedOutError, type ResponseStartedFn, type SendOptions, type TimeConverter, type Transport, type WritableData, type WriteOptions, type WritePrecision, collectAll, consoleLogger, convertTime, convertTimeToNanos, createTextDecoderCombiner, currentTime, dateToProtocolTimestamp, escape, fromConnectionString, fromEnv, isNumber, parsePrecision, precisionToV2ApiString, precisionToV3ApiString, setLogger, useProcessHrtime, writableDataToLineProtocol };
package/dist/index.d.ts CHANGED
@@ -808,6 +808,7 @@ declare const DEFAULT_ConnectionOptions: Partial<ConnectionOptions>;
808
808
  * },
809
809
  * precision: 'ns',
810
810
  * gzipThreshold: 1000,
811
+ * noSync: false,
811
812
  * })
812
813
  * ```
813
814
  */
@@ -818,6 +819,17 @@ interface WriteOptions {
818
819
  headers?: Record<string, string>;
819
820
  /** When specified, write bodies larger than the threshold are gzipped */
820
821
  gzipThreshold?: number;
822
+ /**
823
+ * Instructs the server whether to wait with the response until WAL persistence completes.
824
+ * noSync=true means faster write but without the confirmation that the data was persisted.
825
+ *
826
+ * Note: This option is supported by InfluxDB 3 Core and Enterprise servers only.
827
+ * For other InfluxDB 3 server types (InfluxDB Clustered, InfluxDB Clould Serverless/Dedicated)
828
+ * the write operation will fail with an error.
829
+ *
830
+ * Default value: false.
831
+ */
832
+ noSync?: boolean;
821
833
  /** default tags
822
834
  *
823
835
  * @example Default tags using client config
@@ -913,6 +925,9 @@ declare function fromConnectionString(connectionString: string): ClientOptions;
913
925
  * Creates `ClientOptions` from environment variables.
914
926
  */
915
927
  declare function fromEnv(): ClientOptions;
928
+ declare function precisionToV2ApiString(precision: WritePrecision): string;
929
+ declare function precisionToV3ApiString(precision: WritePrecision): string;
930
+ declare function parsePrecision(value: string): WritePrecision;
916
931
 
917
932
  /**
918
933
  * Logging interface.
@@ -1029,6 +1044,7 @@ declare class InfluxDBClient {
1029
1044
  * - timeout - I/O timeout
1030
1045
  * - precision - timestamp precision when writing data
1031
1046
  * - gzipThreshold - payload size threshold for gzipping data
1047
+ * - writeNoSync - skip waiting for WAL persistence on write
1032
1048
  *
1033
1049
  * @param connectionString - connection string
1034
1050
  */
@@ -1044,6 +1060,7 @@ declare class InfluxDBClient {
1044
1060
  * - INFLUX_DATABASE - database (bucket) name
1045
1061
  * - INFLUX_PRECISION - timestamp precision when writing data
1046
1062
  * - INFLUX_GZIP_THRESHOLD - payload size threshold for gzipping data
1063
+ * - INFLUX_WRITE_NO_SYNC - skip waiting for WAL persistence on write
1047
1064
  */
1048
1065
  constructor();
1049
1066
  private _mergeWriteOptions;
@@ -1099,4 +1116,4 @@ declare class InfluxDBClient {
1099
1116
  close(): Promise<void>;
1100
1117
  }
1101
1118
 
1102
- export { AbortError, type Cancellable, type ChunkCombiner, type ClientOptions, type CommunicationObserver, type ConnectionOptions, DEFAULT_ConnectionOptions, DEFAULT_QueryOptions, DEFAULT_WriteOptions, GetFieldTypeMissmatchError, type HttpHeaders as Headers, HttpError, type HttpHeaders, IllegalArgumentError, InfluxDBClient, Log, type Logger, Point, type PointFieldType, PointValues, type QParamType, type QueryOptions, type QueryType, RequestTimedOutError, type ResponseStartedFn, type SendOptions, type TimeConverter, type Transport, type WritableData, type WriteOptions, type WritePrecision, collectAll, consoleLogger, convertTime, convertTimeToNanos, createTextDecoderCombiner, currentTime, dateToProtocolTimestamp, escape, fromConnectionString, fromEnv, isNumber, setLogger, useProcessHrtime, writableDataToLineProtocol };
1119
+ export { AbortError, type Cancellable, type ChunkCombiner, type ClientOptions, type CommunicationObserver, type ConnectionOptions, DEFAULT_ConnectionOptions, DEFAULT_QueryOptions, DEFAULT_WriteOptions, GetFieldTypeMissmatchError, type HttpHeaders as Headers, HttpError, type HttpHeaders, IllegalArgumentError, InfluxDBClient, Log, type Logger, Point, type PointFieldType, PointValues, type QParamType, type QueryOptions, type QueryType, RequestTimedOutError, type ResponseStartedFn, type SendOptions, type TimeConverter, type Transport, type WritableData, type WriteOptions, type WritePrecision, collectAll, consoleLogger, convertTime, convertTimeToNanos, createTextDecoderCombiner, currentTime, dateToProtocolTimestamp, escape, fromConnectionString, fromEnv, isNumber, parsePrecision, precisionToV2ApiString, precisionToV3ApiString, setLogger, useProcessHrtime, writableDataToLineProtocol };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";var wr=Object.create;var J=Object.defineProperty;var Fr=Object.getOwnPropertyDescriptor;var xr=Object.getOwnPropertyNames;var Or=Object.getPrototypeOf,Ir=Object.prototype.hasOwnProperty;var Nr=(r,e,t)=>e in r?J(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var Er=(r,e)=>{for(var t in e)J(r,t,{get:e[t],enumerable:!0})},wt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of xr(e))!Ir.call(r,i)&&i!==t&&J(r,i,{get:()=>e[i],enumerable:!(n=Fr(e,i))||n.enumerable});return r};var ee=(r,e,t)=>(t=r!=null?wr(Or(r)):{},wt(e||!r||!r.__esModule?J(t,"default",{value:r,enumerable:!0}):t,r)),kr=r=>wt(J({},"__esModule",{value:!0}),r);var h=(r,e,t)=>Nr(r,typeof e!="symbol"?e+"":e,t);var tn={};Er(tn,{AbortError:()=>U,DEFAULT_ConnectionOptions:()=>Se,DEFAULT_QueryOptions:()=>te,DEFAULT_WriteOptions:()=>Re,GetFieldTypeMissmatchError:()=>se,HttpError:()=>P,IllegalArgumentError:()=>R,InfluxDBClient:()=>Y,Log:()=>V,Point:()=>X,PointValues:()=>A,RequestTimedOutError:()=>B,collectAll:()=>Dt,consoleLogger:()=>Ft,convertTime:()=>Ve,convertTimeToNanos:()=>Be,createTextDecoderCombiner:()=>_r,currentTime:()=>_t,dateToProtocolTimestamp:()=>St,escape:()=>_,fromConnectionString:()=>Pe,fromEnv:()=>Ae,isNumber:()=>M,setLogger:()=>Sr,useProcessHrtime:()=>kt,writableDataToLineProtocol:()=>ve});module.exports=kr(tn);var R=class r extends Error{constructor(e){super(e),this.name="IllegalArgumentError",Object.setPrototypeOf(this,r.prototype)}},P=class r extends Error{constructor(t,n,i,s,o,a){var l;super();this.statusCode=t;this.statusMessage=n;this.body=i;this.contentType=s;this.headers=o;h(this,"code");h(this,"json");if(Object.setPrototypeOf(this,r.prototype),a)this.message=a;else if(i&&(s!=null&&s.startsWith("application/json")||!s))try{if(this.json=JSON.parse(i),this.message=this.json.message,this.code=this.json.code,!this.message){let f=this.json;(l=f.data)!=null&&l.error_message?this.message=f.data.error_message:f.error&&(this.message=f.error)}}catch(f){}this.message||(this.message=`${t} ${n} : ${i}`),this.name="HttpError"}},B=class r extends Error{constructor(){super(),Object.setPrototypeOf(this,r.prototype),this.name="RequestTimedOutError",this.message="Request timed out"}},U=class r extends Error{constructor(){super(),this.name="AbortError",Object.setPrototypeOf(this,r.prototype),this.message="Response aborted"}};function _r(){let r=new TextDecoder("utf-8");return{concat(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n},copy(e,t,n){let i=new Uint8Array(n-t);return i.set(e.subarray(t,n)),i},toUtf8String(e,t,n){return r.decode(e.subarray(t,n))}}}var Se={timeout:1e4,queryTimeout:6e4},Re={precision:"ns",gzipThreshold:1e3},te={type:"sql"};function Pe(r){if(!r)throw Error("Connection string not set!");let e=new URL(r.trim(),"http://localhost"),t={host:r.indexOf("://")>0?e.origin+e.pathname:e.pathname};return e.searchParams.has("token")&&(t.token=e.searchParams.get("token")),e.searchParams.has("authScheme")&&(t.authScheme=e.searchParams.get("authScheme")),e.searchParams.has("database")&&(t.database=e.searchParams.get("database")),e.searchParams.has("timeout")&&(t.timeout=parseInt(e.searchParams.get("timeout"))),e.searchParams.has("precision")&&(t.writeOptions||(t.writeOptions={}),t.writeOptions.precision=e.searchParams.get("precision")),e.searchParams.has("gzipThreshold")&&(t.writeOptions||(t.writeOptions={}),t.writeOptions.gzipThreshold=parseInt(e.searchParams.get("gzipThreshold"))),t}function Ae(){if(!process.env.INFLUX_HOST)throw Error("INFLUX_HOST variable not set!");if(!process.env.INFLUX_TOKEN)throw Error("INFLUX_TOKEN variable not set!");let r={host:process.env.INFLUX_HOST.trim()};return process.env.INFLUX_TOKEN&&(r.token=process.env.INFLUX_TOKEN.trim()),process.env.INFLUX_AUTH_SCHEME&&(r.authScheme=process.env.INFLUX_AUTH_SCHEME.trim()),process.env.INFLUX_DATABASE&&(r.database=process.env.INFLUX_DATABASE.trim()),process.env.INFLUX_TIMEOUT&&(r.timeout=parseInt(process.env.INFLUX_TIMEOUT.trim())),process.env.INFLUX_PRECISION&&(r.writeOptions||(r.writeOptions={}),r.writeOptions.precision=process.env.INFLUX_PRECISION),process.env.INFLUX_GZIP_THRESHOLD&&(r.writeOptions||(r.writeOptions={}),r.writeOptions.gzipThreshold=parseInt(process.env.INFLUX_GZIP_THRESHOLD)),r}var Ft={error(r,e){console.error(`ERROR: ${r}`,e||"")},warn(r,e){console.warn(`WARN: ${r}`,e||"")}},re=Ft,V={error(r,e){re.error(r,e)},warn(r,e){re.warn(r,e)}};function Sr(r){let e=re;return re=r,e}function De(r,e){return function(t){let n="",i=0,s=0;for(;s<t.length;){let o=r.indexOf(t[s]);o>=0&&(n+=t.substring(i,s),n+=e[o],i=s+1),s++}return i==0?t:(i<t.length&&(n+=t.substring(i,t.length)),n)}}function Rr(r,e){let t=De(r,e);return n=>`"${t(n)}"`}var _={measurement:De(`,
2
- \r `,["\\,","\\ ","\\n","\\r","\\t"]),quoted:Rr('"\\',['\\"',"\\\\"]),tag:De(`, =
3
- \r `,["\\,","\\ ","\\=","\\n","\\r","\\t"])};var ie="000000000",Le=!1;function kt(r){return Le=r&&process&&typeof process.hrtime=="function"}kt(!0);var xt,ne,Ot=Date.now(),Ue=0;function Ce(){if(Le){let r=process.hrtime(),e=Date.now();ne?(r[0]=r[0]-ne[0],r[1]=r[1]-ne[1],r[1]<0&&(r[0]-=1,r[1]+=1e9),e=xt+r[0]*1e3+Math.floor(r[1]/1e6)):(ne=r,xt=e);let t=String(r[1]%1e6);return String(e)+ie.substr(0,6-t.length)+t}else{let r=Date.now();r!==Ot?(Ot=r,Ue=0):Ue++;let e=String(Ue);return String(r)+ie.substr(0,6-e.length)+e}}function It(){if(Le){let r=process.hrtime(),e=String(Math.trunc(r[1]/1e3)%1e3);return String(Date.now())+ie.substr(0,3-e.length)+e}else return String(Date.now())+ie.substr(0,3)}function Nt(){return String(Date.now())}function Et(){return String(Math.floor(Date.now()/1e3))}var _t={s:Et,ms:Nt,us:It,ns:Ce,seconds:Et,millis:Nt,micros:It,nanos:Ce},St={s:r=>`${Math.floor(r.getTime()/1e3)}`,ms:r=>`${r.getTime()}`,us:r=>`${r.getTime()}000`,ns:r=>`${r.getTime()}000000`};function Be(r){return r===void 0?Ce():typeof r=="string"?r.length>0?r:void 0:r instanceof Date?`${r.getTime()}000000`:String(typeof r=="number"?Math.floor(r):r)}var Ve=(r,e="ns")=>r===void 0?_t[e]():typeof r=="string"?r.length>0?r:void 0:r instanceof Date?St[e](r):String(typeof r=="number"?Math.floor(r):r);var v=r=>{throw r},Rt=r=>r!==void 0,Pt=r=>r instanceof Array||r instanceof Object&&typeof r.length=="number"&&(r.length===0||Object.getOwnPropertyNames(r).some(e=>e==="0")),At=r=>{let e=new Uint8Array(4);return e[0]=r>>0,e[1]=r>>8,e[2]=r>>16,e[3]=r>>24,e},Dt=async r=>{let e=[];for await(let t of r)e.push(t);return e},M=r=>r===null||typeof r=="string"&&(r===""||r.indexOf(" ")!==-1)?!1:r!==""&&!isNaN(Number(r==null?void 0:r.toString())),Ut=r=>M(r)?typeof r=="string"?Number(r)>=0:typeof r=="number"&&r>=0:!1;var ve=(r,e)=>{let t=Pt(r)&&typeof r!="string"?Array.from(r):[r];return t.length===0?[]:typeof t[0]=="string"?t:t.map(i=>i.toLineProtocol(void 0,e)).filter(Rt)};var Pr=r=>typeof r=="number"?"float":typeof r=="string"?"string":typeof r=="boolean"?"boolean":void 0,se=class r extends Error{constructor(e,t,n){super(`field ${e} of type ${n} doesn't match expected type ${t}!`),this.name="GetFieldTypeMissmatchError",Object.setPrototypeOf(this,r.prototype)}},A=class r{constructor(){h(this,"_name");h(this,"_time");h(this,"_tags",{});h(this,"_fields",{})}getMeasurement(){return this._name}setMeasurement(e){return this._name=e,this}getTimestamp(){return this._time}setTimestamp(e){return this._time=e,this}getTag(e){return this._tags[e]}setTag(e,t){return this._tags[e]=t,this}removeTag(e){return delete this._tags[e],this}getTagNames(){return Object.keys(this._tags)}getFloatField(e){return this.getField(e,"float")}setFloatField(e,t){let n;if(typeof t=="number"?n=t:n=parseFloat(t),!isFinite(n))throw new Error(`invalid float value for field '${e}': '${t}'!`);return this._fields[e]=["float",n],this}getIntegerField(e){return this.getField(e,"integer")}setIntegerField(e,t){let n;if(typeof t=="number"?n=t:n=parseInt(String(t)),isNaN(n)||n<=-9223372036854776e3||n>=9223372036854776e3)throw new Error(`invalid integer value for field '${e}': '${t}'!`);return this._fields[e]=["integer",Math.floor(n)],this}getUintegerField(e){return this.getField(e,"uinteger")}setUintegerField(e,t){if(typeof t=="number"){if(isNaN(t)||t<0||t>Number.MAX_SAFE_INTEGER)throw new Error(`uint value for field '${e}' out of range: ${t}`);this._fields[e]=["uinteger",Math.floor(t)]}else{let n=String(t);for(let i=0;i<n.length;i++){let s=n.charCodeAt(i);if(s<48||s>57)throw new Error(`uint value has an unsupported character at pos ${i}: ${t}`)}if(n.length>20||n.length===20&&n.localeCompare("18446744073709551615")>0)throw new Error(`uint value for field '${e}' out of range: ${n}`);this._fields[e]=["uinteger",+n]}return this}getStringField(e){return this.getField(e,"string")}setStringField(e,t){return t!=null&&(typeof t!="string"&&(t=String(t)),this._fields[e]=["string",t]),this}getBooleanField(e){return this.getField(e,"boolean")}setBooleanField(e,t){return this._fields[e]=["boolean",!!t],this}getField(e,t){let n=this._fields[e];if(!n)return;let[i,s]=n;if(t!==void 0&&t!==i)throw new se(e,t,i);return s}getFieldType(e){let t=this._fields[e];if(t)return t[0]}setField(e,t,n){switch(n!=null?n:Pr(t)){case"string":return this.setStringField(e,t);case"boolean":return this.setBooleanField(e,t);case"float":return this.setFloatField(e,t);case"integer":return this.setIntegerField(e,t);case"uinteger":return this.setUintegerField(e,t);case void 0:return this;default:throw new Error(`invalid field type for field '${e}': type -> ${n}, value -> ${t}!`)}}setFields(e){for(let[t,n]of Object.entries(e))this.setField(t,n);return this}removeField(e){return delete this._fields[e],this}getFieldNames(){return Object.keys(this._fields)}hasFields(){return this.getFieldNames().length>0}copy(){let e=new r;return e._name=this._name,e._time=this._time,e._tags=Object.fromEntries(Object.entries(this._tags)),e._fields=Object.fromEntries(Object.entries(this._fields).map(t=>[...t])),e}asPoint(e){return X.fromValues(e?this.setMeasurement(e):this)}};var Ar=(r,e)=>{switch(r){case"string":return _.quoted(e);case"boolean":return e?"T":"F";case"float":return`${e}`;case"integer":return`${e}i`;case"uinteger":return`${e}u`}},X=class r{constructor(e){h(this,"_values");e instanceof A?this._values=e:this._values=new A,typeof e=="string"&&this._values.setMeasurement(e)}static measurement(e){return new r(e)}static fromValues(e){if(!e.getMeasurement()||e.getMeasurement()==="")throw new Error("Cannot convert values to point without measurement set!");return new r(e)}getMeasurement(){return this._values.getMeasurement()}setMeasurement(e){return e!==""&&this._values.setMeasurement(e),this}getTimestamp(){return this._values.getTimestamp()}setTimestamp(e){return this._values.setTimestamp(e),this}getTag(e){return this._values.getTag(e)}setTag(e,t){return this._values.setTag(e,t),this}removeTag(e){return this._values.removeTag(e),this}getTagNames(){return this._values.getTagNames()}getFloatField(e){return this._values.getFloatField(e)}setFloatField(e,t){return this._values.setFloatField(e,t),this}getIntegerField(e){return this._values.getIntegerField(e)}setIntegerField(e,t){return this._values.setIntegerField(e,t),this}getUintegerField(e){return this._values.getUintegerField(e)}setUintegerField(e,t){return this._values.setUintegerField(e,t),this}getStringField(e){return this._values.getStringField(e)}setStringField(e,t){return this._values.setStringField(e,t),this}getBooleanField(e){return this._values.getBooleanField(e)}setBooleanField(e,t){return this._values.setBooleanField(e,t),this}getField(e,t){return this._values.getField(e,t)}getFieldType(e){return this._values.getFieldType(e)}setField(e,t,n){return this._values.setField(e,t,n),this}setFields(e){return this._values.setFields(e),this}removeField(e){return this._values.removeField(e),this}getFieldNames(){return this._values.getFieldNames()}hasFields(){return this._values.hasFields()}copy(){return new r(this._values.copy())}toLineProtocol(e,t){if(!this._values.getMeasurement())return;let n="";if(this._values.getFieldNames().sort().forEach(a=>{if(a){let l=this._values.getFieldType(a),f=this._values.getField(a);if(l===void 0||f===void 0)return;let c=Ar(l,f);n.length>0&&(n+=","),n+=`${_.tag(a)}=${c}`}}),n.length===0)return;let i="",s=this._values.getTagNames();if(t){let a=new Set(s),l=Object.keys(t);for(let f=l.length;f--;)a.has(l[f])&&l.splice(f,1);l.sort().forEach(f=>{if(f){let c=t[f];c&&(i+=",",i+=`${_.tag(f)}=${_.tag(c)}`)}})}s.sort().forEach(a=>{if(a){let l=this._values.getTag(a);l&&(i+=",",i+=`${_.tag(a)}=${_.tag(l)}`)}});let o=this._values.getTimestamp();return e?typeof e=="string"?o=Ve(o,e):o=e(o):o=Be(o),`${_.measurement(this.getMeasurement())}${i} ${n}${o!==void 0?` ${o}`:""}`}toString(){let e=this.toLineProtocol(void 0);return e||`invalid point: ${JSON.stringify(this,void 0)}`}};var We=require("url"),Ct=ee(require("http")),Lt=ee(require("https")),ae=require("buffer");var H=ee(require("zlib"));function Me(r={}){let e=0,t={next:n=>{if(e===0&&r.next&&n!==null&&n!==void 0)return r.next(n)},error:n=>{e===0&&(e=1,r.error&&r.error(n))},complete:()=>{e===0&&(e=2,r.complete&&r.complete())},responseStarted:(n,i)=>{r.responseStarted&&r.responseStarted(n,i)}};return r.useCancellable&&(t.useCancellable=r.useCancellable.bind(r)),r.useResume&&(t.useResume=r.useResume.bind(r)),t}var Dr="1.2.0.nightly",oe=`influxdb3-js/${Dr}`;var Bt=require("stream");var Ur={flush:H.default.constants.Z_SYNC_FLUSH,finishFlush:H.default.constants.Z_SYNC_FLUSH},Cr=ae.Buffer.allocUnsafe(0),$e=class{constructor(){h(this,"_cancelled",!1);h(this,"resume")}cancel(){this._cancelled=!0,this.resume&&(this.resume(),this.resume=void 0)}isCancelled(){return this._cancelled}},qe=class{constructor(e){h(this,"_defaultOptions");h(this,"_requestApi");h(this,"_contextPath");h(this,"_token");h(this,"_authScheme");h(this,"_headers");var f,c,p,m,T,g,O;let{host:t,proxyUrl:n,token:i,authScheme:s,transportOptions:o,...a}=e,l=(0,We.parse)(n||t);if(this._token=i,this._authScheme=s,this._defaultOptions={...a,...o,port:l.port,protocol:l.protocol,hostname:l.hostname},this._contextPath=n?t:(f=l.path)!=null?f:"",this._contextPath.endsWith("/")&&(this._contextPath=this._contextPath.substring(0,this._contextPath.length-1)),Object.keys(this._defaultOptions).forEach(k=>this._defaultOptions[k]===void 0&&delete this._defaultOptions[k]),this._contextPath.endsWith("/api/v2")&&(V.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${l.protocol}//${l.hostname}:${l.port} !`),this._contextPath=""),l.protocol==="http:")this._requestApi=(m=(p=(c=this._defaultOptions["follow-redirects"])==null?void 0:c.http)==null?void 0:p.request)!=null?m:Ct.request;else if(l.protocol==="https:")this._requestApi=(O=(g=(T=this._defaultOptions["follow-redirects"])==null?void 0:T.https)==null?void 0:g.request)!=null?O:Lt.request;else throw new Error(`Unsupported protocol "${l.protocol} in URL: "${e.host}"`);this._headers={"User-Agent":oe,...e.headers},n&&(this._headers.Host=(0,We.parse)(t).host)}send(e,t,n,i){let s=new $e;i&&i.useCancellable&&i.useCancellable(s),this._createRequestMessage(e,t,n,o=>{this._request(o,s,i)},o=>(i==null?void 0:i.error)&&i.error(o))}request(e,t,n,i){t?typeof t!="string"&&(t=JSON.stringify(t)):t="";let s=Cr,o,a;return new Promise((l,f)=>{this.send(e,t,n,{responseStarted(c,p){i&&i(c,p),o=String(c["content-type"]),a=p},next:c=>{s=ae.Buffer.concat([s,c])},complete:()=>{var p,m;let c=(m=(p=n.headers)==null?void 0:p.accept)!=null?m:o;try{a===204&&l(void 0),c.includes("json")?s.length?l(JSON.parse(s.toString("utf8"))):l(void 0):c.includes("text")||c.startsWith("application/csv")?l(s.toString("utf8")):l(s)}catch(T){f(T)}},error:c=>{f(c)}})})}async*iterate(e,t,n){var c;let i,s;function o(p){i=p,s(p)}let a=await new Promise((p,m)=>{s=m,this._createRequestMessage(e,t,n,p,o)});(c=a.signal)!=null&&c.addEventListener&&a.signal.addEventListener("abort",()=>{o(new U)});let l=await new Promise((p,m)=>{s=m;let T=this._requestApi(a,p);T.on("timeout",()=>o(new B)),T.on("error",o),T.write(a.body),T.end()}),f=await new Promise((p,m)=>{s=m,this._prepareResponse(l,p,o)});for await(let p of f){if(i)throw i;yield p}}_createRequestMessage(e,t,n,i,s){var f;let o=ae.Buffer.from(t,"utf-8"),a={"content-type":"application/json; charset=utf-8",...this._headers};if(this._token){let c=(f=this._authScheme)!=null?f:"Token";a.authorization=`${c} ${this._token}`}let l={...this._defaultOptions,path:this._contextPath+e,method:n.method,headers:{...a,...n.headers}};if(n.signal&&(l.signal=n.signal),n.gzipThreshold!==void 0&&n.gzipThreshold<o.length){H.default.gzip(o,(c,p)=>{if(c)return s(c);l.headers["content-encoding"]="gzip",l.body=p,i(l)});return}l.body=o,l.headers["content-length"]=l.body.length,i(l)}_prepareResponse(e,t,n){var a;e.on("aborted",()=>{n(new U)}),e.on("error",n);let i=(a=e.statusCode)!=null?a:600,s=e.headers["content-encoding"],o;if(s==="gzip"?(o=H.default.createGunzip(Ur),o=(0,Bt.pipeline)(e,o,l=>l&&n(l))):o=e,i>=300){let l="",f=String(e.headers["content-type"]).startsWith("application/json");o.on("data",c=>{l+=c.toString(),!f&&l.length>1e3&&(l=l.slice(0,1e3),e.resume())}),o.on("end",()=>{l===""&&e.headers["x-influxdb-error"]&&(l=e.headers["x-influxdb-error"].toString()),n(new P(i,e.statusMessage,l,e.headers["content-type"],e.headers))})}else t(o)}_request(e,t,n){var o;let i=Me(n);if(t.isCancelled()){i.complete();return}(o=e.signal)!=null&&o.addEventListener&&e.signal.addEventListener("abort",()=>{i.error(new U)});let s=this._requestApi(e,a=>{if(t.isCancelled()){a.resume(),i.complete();return}i.responseStarted(a.headers,a.statusCode),this._prepareResponse(a,l=>{l.on("data",f=>{if(t.isCancelled())a.resume();else if(i.next(f)===!1){if(!i.useResume){i.error(new Error("Unable to pause, useResume is not configured!")),a.resume();return}a.pause();let c=()=>{a.resume()};t.resume=c,i.useResume(c)}}),l.on("end",i.complete)},i.error)});typeof s.setTimeout=="function"&&e.timeout&&s.setTimeout(e.timeout),s.on("timeout",()=>{i.error(new B)}),s.on("error",a=>{i.error(a)}),e.body&&s.write(e.body),s.end()}},Vt=qe;var $t=require("@protobuf-ts/grpc-transport");var vt="http://",Mt="https://",Wt=r=>{r=r.replace(/\/$/,"");let e;return r.startsWith(vt)?(r=r.slice(vt.length),e=!1,r.includes(":")||(r=`${r}:80`)):r.startsWith(Mt)&&(r=r.slice(Mt.length),e=!0,r.includes(":")||(r=`${r}:443`)),{url:r,safe:e}};var qt=ee(require("@grpc/grpc-js")),jt=({host:r,timeout:e})=>{let{url:t,safe:n}=Wt(r),i=qt.credentials[n==null||n?"createSsl":"createInsecure"]();return new $t.GrpcTransport({host:t,channelCredentials:i,timeout:e})};var Lr={writeTransport:r=>new Vt(r),queryTransport:jt},G=Lr;var K=class{constructor(e){this._options=e;h(this,"_closed",!1);h(this,"_transport");var t;this._transport=(t=this._options.transport)!=null?t:G.writeTransport(this._options),this.doWrite=this.doWrite.bind(this)}_createWritePath(e,t,n){let i=[`bucket=${encodeURIComponent(e)}`,`precision=${t.precision}`];return n&&i.push(`org=${encodeURIComponent(n)}`),`/api/v2/write?${i.join("&")}`}doWrite(e,t,n,i){if(this._closed)return Promise.reject(new Error("writeApi: already closed!"));if(e.length<=0||e.length===1&&e[0]==="")return Promise.resolve();let o,a,l=new Promise((g,O)=>{o=g,a=O}),f,c,p={responseStarted(g,O){f=O,c=g},error(g){if(g instanceof P&&g.json&&typeof g.json.error=="string"&&g.json.error.includes("hinted handoff queue not empty")){V.warn(`Write to InfluxDB returns: ${g.json.error}`),f=204,p.complete();return}V.error("Write to InfluxDB failed.",g),a(g)},complete(){if(f==null||f>=200&&f<300)o();else{let g=`2xx HTTP response status code expected, but ${f} returned`,O=new P(f,g,void 0,"0",c);O.message=g,p.error(O)}}},m={...Re,...i},T={method:"POST",headers:{"content-type":"text/plain; charset=utf-8",...i==null?void 0:i.headers},gzipThreshold:m.gzipThreshold};return this._transport.send(this._createWritePath(t,m,n),e.join(`
4
- `),T,p),l}async close(){this._closed=!0}};var _e=require("apache-arrow");var pr=require("@protobuf-ts/runtime-rpc");function C(r){let e=typeof r;if(e=="object"){if(Array.isArray(r))return"array";if(r===null)return"null"}return e}function je(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}var S="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),le=[];for(let r=0;r<S.length;r++)le[S[r].charCodeAt(0)]=r;le[45]=S.indexOf("+");le[95]=S.indexOf("/");function Jt(r){let e=r.length*3/4;r[r.length-2]=="="?e-=2:r[r.length-1]=="="&&(e-=1);let t=new Uint8Array(e),n=0,i=0,s,o=0;for(let a=0;a<r.length;a++){if(s=le[r.charCodeAt(a)],s===void 0)switch(r[a]){case"=":i=0;case`
5
- `:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(i){case 0:o=s,i=1;break;case 1:t[n++]=o<<2|(s&48)>>4,o=s,i=2;break;case 2:t[n++]=(o&15)<<4|(s&60)>>2,o=s,i=3;break;case 3:t[n++]=(o&3)<<6|s,i=0;break}}if(i==1)throw Error("invalid base64 string.");return t.subarray(0,n)}function Xt(r){let e="",t=0,n,i=0;for(let s=0;s<r.length;s++)switch(n=r[s],t){case 0:e+=S[n>>2],i=(n&3)<<4,t=1;break;case 1:e+=S[i|n>>4],i=(n&15)<<2,t=2;break;case 2:e+=S[i|n>>6],e+=S[n&63],t=0;break}return t&&(e+=S[i],e+="=",t==1&&(e+="=")),e}var W;(function(r){r.symbol=Symbol.for("protobuf-ts/unknown"),r.onRead=(t,n,i,s,o)=>{(e(n)?n[r.symbol]:n[r.symbol]=[]).push({no:i,wireType:s,data:o})},r.onWrite=(t,n,i)=>{for(let{no:s,wireType:o,data:a}of r.list(n))i.tag(s,o).raw(a)},r.list=(t,n)=>{if(e(t)){let i=t[r.symbol];return n?i.filter(s=>s.no==n):i}return[]},r.last=(t,n)=>r.list(t,n).slice(-1)[0];let e=t=>t&&Array.isArray(t[r.symbol])})(W||(W={}));var F;(function(r){r[r.Varint=0]="Varint",r[r.Bit64=1]="Bit64",r[r.LengthDelimited=2]="LengthDelimited",r[r.StartGroup=3]="StartGroup",r[r.EndGroup=4]="EndGroup",r[r.Bit32=5]="Bit32"})(F||(F={}));function Ht(){let r=0,e=0;for(let n=0;n<28;n+=7){let i=this.buf[this.pos++];if(r|=(i&127)<<n,(i&128)==0)return this.assertBounds(),[r,e]}let t=this.buf[this.pos++];if(r|=(t&15)<<28,e=(t&112)>>4,(t&128)==0)return this.assertBounds(),[r,e];for(let n=3;n<=31;n+=7){let i=this.buf[this.pos++];if(e|=(i&127)<<n,(i&128)==0)return this.assertBounds(),[r,e]}throw new Error("invalid varint")}function fe(r,e,t){for(let s=0;s<28;s=s+7){let o=r>>>s,a=!(!(o>>>7)&&e==0),l=(a?o|128:o)&255;if(t.push(l),!a)return}let n=r>>>28&15|(e&7)<<4,i=e>>3!=0;if(t.push((i?n|128:n)&255),!!i){for(let s=3;s<31;s=s+7){let o=e>>>s,a=!!(o>>>7),l=(a?o|128:o)&255;if(t.push(l),!a)return}t.push(e>>>31&1)}}var ue=65536*65536;function Je(r){let e=r[0]=="-";e&&(r=r.slice(1));let t=1e6,n=0,i=0;function s(o,a){let l=Number(r.slice(o,a));i*=t,n=n*t+l,n>=ue&&(i=i+(n/ue|0),n=n%ue)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,n,i]}function ce(r,e){if(e>>>0<=2097151)return""+(ue*e+(r>>>0));let t=r&16777215,n=(r>>>24|e<<8)>>>0&16777215,i=e>>16&65535,s=t+n*6777216+i*6710656,o=n+i*8147497,a=i*2,l=1e7;s>=l&&(o+=Math.floor(s/l),s%=l),o>=l&&(a+=Math.floor(o/l),o%=l);function f(c,p){let m=c?String(c):"";return p?"0000000".slice(m.length)+m:m}return f(a,0)+f(o,a)+f(s,1)}function Xe(r,e){if(r>=0){for(;r>127;)e.push(r&127|128),r=r>>>7;e.push(r)}else{for(let t=0;t<9;t++)e.push(r&127|128),r=r>>7;e.push(1)}}function Gt(){let r=this.buf[this.pos++],e=r&127;if((r&128)==0)return this.assertBounds(),e;if(r=this.buf[this.pos++],e|=(r&127)<<7,(r&128)==0)return this.assertBounds(),e;if(r=this.buf[this.pos++],e|=(r&127)<<14,(r&128)==0)return this.assertBounds(),e;if(r=this.buf[this.pos++],e|=(r&127)<<21,(r&128)==0)return this.assertBounds(),e;r=this.buf[this.pos++],e|=(r&15)<<28;for(let t=5;(r&128)!==0&&t<10;t++)r=this.buf[this.pos++];if((r&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var y;function Br(){let r=new DataView(new ArrayBuffer(8));y=globalThis.BigInt!==void 0&&typeof r.getBigInt64=="function"&&typeof r.getBigUint64=="function"&&typeof r.setBigInt64=="function"&&typeof r.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:r}:void 0}Br();function Kt(r){if(!r)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}var Zt=/^-?[0-9]+$/,me=4294967296,pe=2147483648,he=class{constructor(e,t){this.lo=e|0,this.hi=t|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let e=this.hi*me+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}},x=class r extends he{static from(e){if(y)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=y.C(e);case"number":if(e===0)return this.ZERO;e=y.C(e);case"bigint":if(!e)return this.ZERO;if(e<y.UMIN)throw new Error("signed value for ulong");if(e>y.UMAX)throw new Error("ulong too large");return y.V.setBigUint64(0,e,!0),new r(y.V.getInt32(0,!0),y.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Zt.test(e))throw new Error("string is no integer");let[t,n,i]=Je(e);if(t)throw new Error("signed value for ulong");return new r(n,i);case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new r(e,e/me)}throw new Error("unknown value "+typeof e)}toString(){return y?this.toBigInt().toString():ce(this.lo,this.hi)}toBigInt(){return Kt(y),y.V.setInt32(0,this.lo,!0),y.V.setInt32(4,this.hi,!0),y.V.getBigUint64(0,!0)}};x.ZERO=new x(0,0);var b=class r extends he{static from(e){if(y)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=y.C(e);case"number":if(e===0)return this.ZERO;e=y.C(e);case"bigint":if(!e)return this.ZERO;if(e<y.MIN)throw new Error("signed long too small");if(e>y.MAX)throw new Error("signed long too large");return y.V.setBigInt64(0,e,!0),new r(y.V.getInt32(0,!0),y.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Zt.test(e))throw new Error("string is no integer");let[t,n,i]=Je(e);if(t){if(i>pe||i==pe&&n!=0)throw new Error("signed long too small")}else if(i>=pe)throw new Error("signed long too large");let s=new r(n,i);return t?s.negate():s;case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new r(e,e/me):new r(-e,-e/me).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&pe)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new r(t,e)}toString(){if(y)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+ce(e.lo,e.hi)}return ce(this.lo,this.hi)}toBigInt(){return Kt(y),y.V.setInt32(0,this.lo,!0),y.V.setInt32(4,this.hi,!0),y.V.getBigInt64(0,!0)}};b.ZERO=new b(0,0);var Qt={readUnknownField:!0,readerFactory:r=>new He(r)};function zt(r){return r?Object.assign(Object.assign({},Qt),r):Qt}var He=class{constructor(e,t){this.varint64=Ht,this.uint32=Gt,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t!=null?t:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let e=this.uint32(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e){let t=this.pos;switch(e){case F.Varint:for(;this.buf[this.pos++]&128;);break;case F.Bit64:this.pos+=4;case F.Bit32:this.pos+=4;break;case F.LengthDelimited:let n=this.uint32();this.pos+=n;break;case F.StartGroup:let i;for(;(i=this.tag()[1])!==F.EndGroup;)this.skip(i);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return new b(...this.varint64())}uint64(){return new x(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,new b(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new x(this.sfixed32(),this.sfixed32())}sfixed64(){return new b(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}};function d(r,e){if(!r)throw new Error(e)}var Vr=34028234663852886e22,vr=-34028234663852886e22,Mr=4294967295,Wr=2147483647,$r=-2147483648;function D(r){if(typeof r!="number")throw new Error("invalid int 32: "+typeof r);if(!Number.isInteger(r)||r>Wr||r<$r)throw new Error("invalid int 32: "+r)}function L(r){if(typeof r!="number")throw new Error("invalid uint 32: "+typeof r);if(!Number.isInteger(r)||r>Mr||r<0)throw new Error("invalid uint 32: "+r)}function $(r){if(typeof r!="number")throw new Error("invalid float 32: "+typeof r);if(Number.isFinite(r)&&(r>Vr||r<vr))throw new Error("invalid float 32: "+r)}var Yt={writeUnknownFields:!0,writerFactory:()=>new Ge};function er(r){return r?Object.assign(Object.assign({},Yt),r):Yt}var Ge=class{constructor(e){this.stack=[],this.textEncoder=e!=null?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let i=0;i<this.chunks.length;i++)e+=this.chunks[i].length;let t=new Uint8Array(e),n=0;for(let i=0;i<this.chunks.length;i++)t.set(this.chunks[i],n),n+=this.chunks[i].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(L(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return D(e),Xe(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){$(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){L(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){D(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return D(e),e=(e<<1^e>>31)>>>0,Xe(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=b.from(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=x.from(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=b.from(e);return fe(t.lo,t.hi,this.buf),this}sint64(e){let t=b.from(e),n=t.hi>>31,i=t.lo<<1^n,s=(t.hi<<1|t.lo>>>31)^n;return fe(i,s,this.buf),this}uint64(e){let t=x.from(e);return fe(t.lo,t.hi,this.buf),this}};var tr={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},rr={ignoreUnknownFields:!1};function nr(r){return r?Object.assign(Object.assign({},rr),r):rr}function ir(r){return r?Object.assign(Object.assign({},tr),r):tr}var de=Symbol.for("protobuf-ts/message-type");function Ke(r){let e=!1,t=[];for(let n=0;n<r.length;n++){let i=r.charAt(n);i=="_"?e=!0:/\d/.test(i)?(t.push(i),e=!0):e?(t.push(i.toUpperCase()),e=!1):n==0?t.push(i.toLowerCase()):t.push(i)}return t.join("")}var u;(function(r){r[r.DOUBLE=1]="DOUBLE",r[r.FLOAT=2]="FLOAT",r[r.INT64=3]="INT64",r[r.UINT64=4]="UINT64",r[r.INT32=5]="INT32",r[r.FIXED64=6]="FIXED64",r[r.FIXED32=7]="FIXED32",r[r.BOOL=8]="BOOL",r[r.STRING=9]="STRING",r[r.BYTES=12]="BYTES",r[r.UINT32=13]="UINT32",r[r.SFIXED32=15]="SFIXED32",r[r.SFIXED64=16]="SFIXED64",r[r.SINT32=17]="SINT32",r[r.SINT64=18]="SINT64"})(u||(u={}));var I;(function(r){r[r.BIGINT=0]="BIGINT",r[r.STRING=1]="STRING",r[r.NUMBER=2]="NUMBER"})(I||(I={}));var Z;(function(r){r[r.NO=0]="NO",r[r.PACKED=1]="PACKED",r[r.UNPACKED=2]="UNPACKED"})(Z||(Z={}));function sr(r){var e,t,n,i;return r.localName=(e=r.localName)!==null&&e!==void 0?e:Ke(r.name),r.jsonName=(t=r.jsonName)!==null&&t!==void 0?t:Ke(r.name),r.repeat=(n=r.repeat)!==null&&n!==void 0?n:Z.NO,r.opt=(i=r.opt)!==null&&i!==void 0?i:r.repeat||r.oneof?!1:r.kind=="message",r}function or(r){if(typeof r!="object"||r===null||!r.hasOwnProperty("oneofKind"))return!1;switch(typeof r.oneofKind){case"string":return r[r.oneofKind]===void 0?!1:Object.keys(r).length==2;case"undefined":return Object.keys(r).length==1;default:return!1}}var ge=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}prepare(){if(this.data)return;let e=[],t=[],n=[];for(let i of this.fields)if(i.oneof)n.includes(i.oneof)||(n.push(i.oneof),e.push(i.oneof),t.push(i.oneof));else switch(t.push(i.localName),i.kind){case"scalar":case"enum":(!i.opt||i.repeat)&&e.push(i.localName);break;case"message":i.repeat&&e.push(i.localName);break;case"map":e.push(i.localName);break}this.data={req:e,known:t,oneofs:Object.values(n)}}is(e,t,n=!1){if(t<0)return!0;if(e==null||typeof e!="object")return!1;this.prepare();let i=Object.keys(e),s=this.data;if(i.length<s.req.length||s.req.some(o=>!i.includes(o))||!n&&i.some(o=>!s.known.includes(o)))return!1;if(t<1)return!0;for(let o of s.oneofs){let a=e[o];if(!or(a))return!1;if(a.oneofKind===void 0)continue;let l=this.fields.find(f=>f.localName===a.oneofKind);if(!l||!this.field(a[a.oneofKind],l,n,t))return!1}for(let o of this.fields)if(o.oneof===void 0&&!this.field(e[o.localName],o,n,t))return!1;return!0}field(e,t,n,i){let s=t.repeat;switch(t.kind){case"scalar":return e===void 0?t.opt:s?this.scalars(e,t.T,i,t.L):this.scalar(e,t.T,t.L);case"enum":return e===void 0?t.opt:s?this.scalars(e,u.INT32,i):this.scalar(e,u.INT32);case"message":return e===void 0?!0:s?this.messages(e,t.T(),n,i):this.message(e,t.T(),n,i);case"map":if(typeof e!="object"||e===null)return!1;if(i<2)return!0;if(!this.mapKeys(e,t.K,i))return!1;switch(t.V.kind){case"scalar":return this.scalars(Object.values(e),t.V.T,i,t.V.L);case"enum":return this.scalars(Object.values(e),u.INT32,i);case"message":return this.messages(Object.values(e),t.V.T(),n,i)}break}return!0}message(e,t,n,i){return n?t.isAssignable(e,i):t.is(e,i)}messages(e,t,n,i){if(!Array.isArray(e))return!1;if(i<2)return!0;if(n){for(let s=0;s<e.length&&s<i;s++)if(!t.isAssignable(e[s],i-1))return!1}else for(let s=0;s<e.length&&s<i;s++)if(!t.is(e[s],i-1))return!1;return!0}scalar(e,t,n){let i=typeof e;switch(t){case u.UINT64:case u.FIXED64:case u.INT64:case u.SFIXED64:case u.SINT64:switch(n){case I.BIGINT:return i=="bigint";case I.NUMBER:return i=="number"&&!isNaN(e);default:return i=="string"}case u.BOOL:return i=="boolean";case u.STRING:return i=="string";case u.BYTES:return e instanceof Uint8Array;case u.DOUBLE:case u.FLOAT:return i=="number"&&!isNaN(e);default:return i=="number"&&Number.isInteger(e)}}scalars(e,t,n,i){if(!Array.isArray(e))return!1;if(n<2)return!0;if(Array.isArray(e)){for(let s=0;s<e.length&&s<n;s++)if(!this.scalar(e[s],t,i))return!1}return!0}mapKeys(e,t,n){let i=Object.keys(e);switch(t){case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:return this.scalars(i.slice(0,n).map(s=>parseInt(s)),t,n);case u.BOOL:return this.scalars(i.slice(0,n).map(s=>s=="true"?!0:s=="false"?!1:s),t,n);default:return this.scalars(i,t,n,I.STRING)}}};function N(r,e){switch(e){case I.BIGINT:return r.toBigInt();case I.NUMBER:return r.toNumber();default:return r.toString()}}var be=class{constructor(e){this.info=e}prepare(){var e;if(this.fMap===void 0){this.fMap={};let t=(e=this.info.fields)!==null&&e!==void 0?e:[];for(let n of t)this.fMap[n.name]=n,this.fMap[n.jsonName]=n,this.fMap[n.localName]=n}}assert(e,t,n){if(!e){let i=C(n);throw(i=="number"||i=="boolean")&&(i=n.toString()),new Error(`Cannot parse JSON ${i} for ${this.info.typeName}#${t}`)}}read(e,t,n){this.prepare();let i=[];for(let[s,o]of Object.entries(e)){let a=this.fMap[s];if(!a){if(!n.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}let l=a.localName,f;if(a.oneof){if(o===null&&(a.kind!=="enum"||a.T()[0]!=="google.protobuf.NullValue"))continue;if(i.includes(a.oneof))throw new Error(`Multiple members of the oneof group "${a.oneof}" of ${this.info.typeName} are present in JSON.`);i.push(a.oneof),f=t[a.oneof]={oneofKind:l}}else f=t;if(a.kind=="map"){if(o===null)continue;this.assert(je(o),a.name,o);let c=f[l];for(let[p,m]of Object.entries(o)){this.assert(m!==null,a.name+" map value",null);let T;switch(a.V.kind){case"message":T=a.V.T().internalJsonRead(m,n);break;case"enum":if(T=this.enum(a.V.T(),m,a.name,n.ignoreUnknownFields),T===!1)continue;break;case"scalar":T=this.scalar(m,a.V.T,a.V.L,a.name);break}this.assert(T!==void 0,a.name+" map value",m);let g=p;a.K==u.BOOL&&(g=g=="true"?!0:g=="false"?!1:g),g=this.scalar(g,a.K,I.STRING,a.name).toString(),c[g]=T}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);let c=f[l];for(let p of o){this.assert(p!==null,a.name,null);let m;switch(a.kind){case"message":m=a.T().internalJsonRead(p,n);break;case"enum":if(m=this.enum(a.T(),p,a.name,n.ignoreUnknownFields),m===!1)continue;break;case"scalar":m=this.scalar(p,a.T,a.L,a.name);break}this.assert(m!==void 0,a.name,o),c.push(m)}}else switch(a.kind){case"message":if(o===null&&a.T().typeName!="google.protobuf.Value"){this.assert(a.oneof===void 0,a.name+" (oneof member)",null);continue}f[l]=a.T().internalJsonRead(o,n,f[l]);break;case"enum":if(o===null)continue;let c=this.enum(a.T(),o,a.name,n.ignoreUnknownFields);if(c===!1)continue;f[l]=c;break;case"scalar":if(o===null)continue;f[l]=this.scalar(o,a.T,a.L,a.name);break}}}enum(e,t,n,i){if(e[0]=="google.protobuf.NullValue"&&d(t===null||t==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} only accepts null.`),t===null)return 0;switch(typeof t){case"number":return d(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${n}, enum can only be integral number, got ${t}.`),t;case"string":let s=t;e[2]&&t.substring(0,e[2].length)===e[2]&&(s=t.substring(e[2].length));let o=e[1][s];return typeof o=="undefined"&&i?!1:(d(typeof o=="number",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} has no value for "${t}".`),o)}d(!1,`Unable to parse field ${this.info.typeName}#${n}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,n,i){let s;try{switch(t){case u.DOUBLE:case u.FLOAT:if(e===null)return 0;if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""){s="empty string";break}if(typeof e=="string"&&e.trim().length!==e.length){s="extra whitespace";break}if(typeof e!="string"&&typeof e!="number")break;let o=Number(e);if(Number.isNaN(o)){s="not a number";break}if(!Number.isFinite(o)){s="too large or small";break}return t==u.FLOAT&&$(o),o;case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:if(e===null)return 0;let a;if(typeof e=="number"?a=e:e===""?s="empty string":typeof e=="string"&&(e.trim().length!==e.length?s="extra whitespace":a=Number(e)),a===void 0)break;return t==u.UINT32?L(a):D(a),a;case u.INT64:case u.SFIXED64:case u.SINT64:if(e===null)return N(b.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return N(b.from(e),n);case u.FIXED64:case u.UINT64:if(e===null)return N(x.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return N(x.from(e),n);case u.BOOL:if(e===null)return!1;if(typeof e!="boolean")break;return e;case u.STRING:if(e===null)return"";if(typeof e!="string"){s="extra whitespace";break}try{encodeURIComponent(e)}catch(l){l="invalid UTF8";break}return e;case u.BYTES:if(e===null||e==="")return new Uint8Array(0);if(typeof e!="string")break;return Jt(e)}}catch(o){s=o.message}this.assert(!1,i+(s?" - "+s:""),e)}};var ye=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}write(e,t){let n={},i=e;for(let s of this.fields){if(!s.oneof){let f=this.field(s,i[s.localName],t);f!==void 0&&(n[t.useProtoFieldName?s.name:s.jsonName]=f);continue}let o=i[s.oneof];if(o.oneofKind!==s.localName)continue;let a=s.kind=="scalar"||s.kind=="enum"?Object.assign(Object.assign({},t),{emitDefaultValues:!0}):t,l=this.field(s,o[s.localName],a);d(l!==void 0),n[t.useProtoFieldName?s.name:s.jsonName]=l}return n}field(e,t,n){let i;if(e.kind=="map"){d(typeof t=="object"&&t!==null);let s={};switch(e.V.kind){case"scalar":for(let[l,f]of Object.entries(t)){let c=this.scalar(e.V.T,f,e.name,!1,!0);d(c!==void 0),s[l.toString()]=c}break;case"message":let o=e.V.T();for(let[l,f]of Object.entries(t)){let c=this.message(o,f,e.name,n);d(c!==void 0),s[l.toString()]=c}break;case"enum":let a=e.V.T();for(let[l,f]of Object.entries(t)){d(f===void 0||typeof f=="number");let c=this.enum(a,f,e.name,!1,!0,n.enumAsInteger);d(c!==void 0),s[l.toString()]=c}break}(n.emitDefaultValues||Object.keys(s).length>0)&&(i=s)}else if(e.repeat){d(Array.isArray(t));let s=[];switch(e.kind){case"scalar":for(let l=0;l<t.length;l++){let f=this.scalar(e.T,t[l],e.name,e.opt,!0);d(f!==void 0),s.push(f)}break;case"enum":let o=e.T();for(let l=0;l<t.length;l++){d(t[l]===void 0||typeof t[l]=="number");let f=this.enum(o,t[l],e.name,e.opt,!0,n.enumAsInteger);d(f!==void 0),s.push(f)}break;case"message":let a=e.T();for(let l=0;l<t.length;l++){let f=this.message(a,t[l],e.name,n);d(f!==void 0),s.push(f)}break}(n.emitDefaultValues||s.length>0||n.emitDefaultValues)&&(i=s)}else switch(e.kind){case"scalar":i=this.scalar(e.T,t,e.name,e.opt,n.emitDefaultValues);break;case"enum":i=this.enum(e.T(),t,e.name,e.opt,n.emitDefaultValues,n.enumAsInteger);break;case"message":i=this.message(e.T(),t,e.name,n);break}return i}enum(e,t,n,i,s,o){if(e[0]=="google.protobuf.NullValue")return!s&&!i?void 0:null;if(t===void 0){d(i);return}if(!(t===0&&!s&&!i))return d(typeof t=="number"),d(Number.isInteger(t)),o||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}message(e,t,n,i){return t===void 0?i.emitDefaultValues?null:void 0:e.internalJsonWrite(t,i)}scalar(e,t,n,i,s){if(t===void 0){d(i);return}let o=s||i;switch(e){case u.INT32:case u.SFIXED32:case u.SINT32:return t===0?o?0:void 0:(D(t),t);case u.FIXED32:case u.UINT32:return t===0?o?0:void 0:(L(t),t);case u.FLOAT:$(t);case u.DOUBLE:return t===0?o?0:void 0:(d(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case u.STRING:return t===""?o?"":void 0:(d(typeof t=="string"),t);case u.BOOL:return t===!1?o?!1:void 0:(d(typeof t=="boolean"),t);case u.UINT64:case u.FIXED64:d(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let a=x.from(t);return a.isZero()&&!o?void 0:a.toString();case u.INT64:case u.SFIXED64:case u.SINT64:d(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let l=b.from(t);return l.isZero()&&!o?void 0:l.toString();case u.BYTES:return d(t instanceof Uint8Array),t.byteLength?Xt(t):o?"":void 0}}};function Q(r,e=I.STRING){switch(r){case u.BOOL:return!1;case u.UINT64:case u.FIXED64:return N(x.ZERO,e);case u.INT64:case u.SFIXED64:case u.SINT64:return N(b.ZERO,e);case u.DOUBLE:case u.FLOAT:return 0;case u.BYTES:return new Uint8Array(0);case u.STRING:return"";default:return 0}}var Te=class{constructor(e){this.info=e}prepare(){var e;if(!this.fieldNoToField){let t=(e=this.info.fields)!==null&&e!==void 0?e:[];this.fieldNoToField=new Map(t.map(n=>[n.no,n]))}}read(e,t,n,i){this.prepare();let s=i===void 0?e.len:e.pos+i;for(;e.pos<s;){let[o,a]=e.tag(),l=this.fieldNoToField.get(o);if(!l){let m=n.readUnknownField;if(m=="throw")throw new Error(`Unknown field ${o} (wire type ${a}) for ${this.info.typeName}`);let T=e.skip(a);m!==!1&&(m===!0?W.onRead:m)(this.info.typeName,t,o,a,T);continue}let f=t,c=l.repeat,p=l.localName;switch(l.oneof&&(f=f[l.oneof],f.oneofKind!==p&&(f=t[l.oneof]={oneofKind:p})),l.kind){case"scalar":case"enum":let m=l.kind=="enum"?u.INT32:l.T,T=l.kind=="scalar"?l.L:void 0;if(c){let k=f[p];if(a==F.LengthDelimited&&m!=u.STRING&&m!=u.BYTES){let j=e.uint32()+e.pos;for(;e.pos<j;)k.push(this.scalar(e,m,T))}else k.push(this.scalar(e,m,T))}else f[p]=this.scalar(e,m,T);break;case"message":if(c){let k=f[p],j=l.T().internalBinaryRead(e,e.uint32(),n);k.push(j)}else f[p]=l.T().internalBinaryRead(e,e.uint32(),n,f[p]);break;case"map":let[g,O]=this.mapEntry(l,e,n);f[p][g]=O;break}}}mapEntry(e,t,n){let i=t.uint32(),s=t.pos+i,o,a;for(;t.pos<s;){let[l,f]=t.tag();switch(l){case 1:e.K==u.BOOL?o=t.bool().toString():o=this.scalar(t,e.K,I.STRING);break;case 2:switch(e.V.kind){case"scalar":a=this.scalar(t,e.V.T,e.V.L);break;case"enum":a=t.int32();break;case"message":a=e.V.T().internalBinaryRead(t,t.uint32(),n);break}break;default:throw new Error(`Unknown field ${l} (wire type ${f}) in map entry for ${this.info.typeName}#${e.name}`)}}if(o===void 0){let l=Q(e.K);o=e.K==u.BOOL?l.toString():l}if(a===void 0)switch(e.V.kind){case"scalar":a=Q(e.V.T,e.V.L);break;case"enum":a=0;break;case"message":a=e.V.T().create();break}return[o,a]}scalar(e,t,n){switch(t){case u.INT32:return e.int32();case u.STRING:return e.string();case u.BOOL:return e.bool();case u.DOUBLE:return e.double();case u.FLOAT:return e.float();case u.INT64:return N(e.int64(),n);case u.UINT64:return N(e.uint64(),n);case u.FIXED64:return N(e.fixed64(),n);case u.FIXED32:return e.fixed32();case u.BYTES:return e.bytes();case u.UINT32:return e.uint32();case u.SFIXED32:return e.sfixed32();case u.SFIXED64:return N(e.sfixed64(),n);case u.SINT32:return e.sint32();case u.SINT64:return N(e.sint64(),n)}}};var we=class{constructor(e){this.info=e}prepare(){if(!this.fields){let e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort((t,n)=>t.no-n.no)}}write(e,t,n){this.prepare();for(let s of this.fields){let o,a,l=s.repeat,f=s.localName;if(s.oneof){let c=e[s.oneof];if(c.oneofKind!==f)continue;o=c[f],a=!0}else o=e[f],a=!1;switch(s.kind){case"scalar":case"enum":let c=s.kind=="enum"?u.INT32:s.T;if(l)if(d(Array.isArray(o)),l==Z.PACKED)this.packed(t,c,s.no,o);else for(let p of o)this.scalar(t,c,s.no,p,!0);else o===void 0?d(s.opt):this.scalar(t,c,s.no,o,a||s.opt);break;case"message":if(l){d(Array.isArray(o));for(let p of o)this.message(t,n,s.T(),s.no,p)}else this.message(t,n,s.T(),s.no,o);break;case"map":d(typeof o=="object"&&o!==null);for(let[p,m]of Object.entries(o))this.mapEntry(t,n,s,p,m);break}}let i=n.writeUnknownFields;i!==!1&&(i===!0?W.onWrite:i)(this.info.typeName,e,t)}mapEntry(e,t,n,i,s){e.tag(n.no,F.LengthDelimited),e.fork();let o=i;switch(n.K){case u.INT32:case u.FIXED32:case u.UINT32:case u.SFIXED32:case u.SINT32:o=Number.parseInt(i);break;case u.BOOL:d(i=="true"||i=="false"),o=i=="true";break}switch(this.scalar(e,n.K,1,o,!0),n.V.kind){case"scalar":this.scalar(e,n.V.T,2,s,!0);break;case"enum":this.scalar(e,u.INT32,2,s,!0);break;case"message":this.message(e,t,n.V.T(),2,s);break}e.join()}message(e,t,n,i,s){s!==void 0&&(n.internalBinaryWrite(s,e.tag(i,F.LengthDelimited).fork(),t),e.join())}scalar(e,t,n,i,s){let[o,a,l]=this.scalarInfo(t,i);(!l||s)&&(e.tag(n,o),e[a](i))}packed(e,t,n,i){if(!i.length)return;d(t!==u.BYTES&&t!==u.STRING),e.tag(n,F.LengthDelimited),e.fork();let[,s]=this.scalarInfo(t);for(let o=0;o<i.length;o++)e[s](i[o]);e.join()}scalarInfo(e,t){let n=F.Varint,i,s=t===void 0,o=t===0;switch(e){case u.INT32:i="int32";break;case u.STRING:o=s||!t.length,n=F.LengthDelimited,i="string";break;case u.BOOL:o=t===!1,i="bool";break;case u.UINT32:i="uint32";break;case u.DOUBLE:n=F.Bit64,i="double";break;case u.FLOAT:n=F.Bit32,i="float";break;case u.INT64:o=s||b.from(t).isZero(),i="int64";break;case u.UINT64:o=s||x.from(t).isZero(),i="uint64";break;case u.FIXED64:o=s||x.from(t).isZero(),n=F.Bit64,i="fixed64";break;case u.BYTES:o=s||!t.byteLength,n=F.LengthDelimited,i="bytes";break;case u.FIXED32:n=F.Bit32,i="fixed32";break;case u.SFIXED32:n=F.Bit32,i="sfixed32";break;case u.SFIXED64:o=s||b.from(t).isZero(),n=F.Bit64,i="sfixed64";break;case u.SINT32:i="sint32";break;case u.SINT64:o=s||b.from(t).isZero(),i="sint64";break}return[n,i,s||o]}};function ar(r){let e=r.messagePrototype?Object.create(r.messagePrototype):Object.defineProperty({},de,{value:r});for(let t of r.fields){let n=t.localName;if(!t.opt)if(t.oneof)e[t.oneof]={oneofKind:void 0};else if(t.repeat)e[n]=[];else switch(t.kind){case"scalar":e[n]=Q(t.T,t.L);break;case"enum":e[n]=0;break;case"map":e[n]={};break}}return e}function Fe(r,e,t){let n,i=t,s;for(let o of r.fields){let a=o.localName;if(o.oneof){let l=i[o.oneof];if((l==null?void 0:l.oneofKind)==null)continue;if(n=l[a],s=e[o.oneof],s.oneofKind=l.oneofKind,n==null){delete s[a];continue}}else if(n=i[a],s=e,n==null)continue;switch(o.repeat&&(s[a].length=n.length),o.kind){case"scalar":case"enum":if(o.repeat)for(let f=0;f<n.length;f++)s[a][f]=n[f];else s[a]=n;break;case"message":let l=o.T();if(o.repeat)for(let f=0;f<n.length;f++)s[a][f]=l.create(n[f]);else s[a]===void 0?s[a]=l.create(n):l.mergePartial(s[a],n);break;case"map":switch(o.V.kind){case"scalar":case"enum":Object.assign(s[a],n);break;case"message":let f=o.V.T();for(let c of Object.keys(n))s[a][c]=f.create(n[c]);break}break}}}function fr(r,e,t){if(e===t)return!0;if(!e||!t)return!1;for(let n of r.fields){let i=n.localName,s=n.oneof?e[n.oneof][i]:e[i],o=n.oneof?t[n.oneof][i]:t[i];switch(n.kind){case"enum":case"scalar":let a=n.kind=="enum"?u.INT32:n.T;if(!(n.repeat?lr(a,s,o):cr(a,s,o)))return!1;break;case"map":if(!(n.V.kind=="message"?ur(n.V.T(),xe(s),xe(o)):lr(n.V.kind=="enum"?u.INT32:n.V.T,xe(s),xe(o))))return!1;break;case"message":let l=n.T();if(!(n.repeat?ur(l,s,o):l.equals(s,o)))return!1;break}}return!0}var xe=Object.values;function cr(r,e,t){if(e===t)return!0;if(r!==u.BYTES)return!1;let n=e,i=t;if(n.length!==i.length)return!1;for(let s=0;s<n.length;s++)if(n[s]!=i[s])return!1;return!0}function lr(r,e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!cr(r,e[n],t[n]))return!1;return!0}function ur(r,e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!r.equals(e[n],t[n]))return!1;return!0}var qr=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({})),w=class{constructor(e,t,n){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(sr),this.options=n!=null?n:{},this.messagePrototype=Object.create(null,Object.assign(Object.assign({},qr),{[de]:{value:this}})),this.refTypeCheck=new ge(this),this.refJsonReader=new be(this),this.refJsonWriter=new ye(this),this.refBinReader=new Te(this),this.refBinWriter=new we(this)}create(e){let t=ar(this);return e!==void 0&&Fe(this,t,e),t}clone(e){let t=this.create();return Fe(this,t,e),t}equals(e,t){return fr(this,e,t)}is(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!1)}isAssignable(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!0)}mergePartial(e,t){Fe(this,e,t)}fromBinary(e,t){let n=zt(t);return this.internalBinaryRead(n.readerFactory(e),e.byteLength,n)}fromJson(e,t){return this.internalJsonRead(e,nr(t))}fromJsonString(e,t){let n=JSON.parse(e);return this.fromJson(n,t)}toJson(e,t){return this.internalJsonWrite(e,ir(t))}toJsonString(e,t){var n;let i=this.toJson(e,t);return JSON.stringify(i,null,(n=t==null?void 0:t.prettySpaces)!==null&&n!==void 0?n:0)}toBinary(e,t){let n=er(t);return this.internalBinaryWrite(e,n.writerFactory(),n).finish()}internalJsonRead(e,t,n){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let i=n!=null?n:this.create();return this.refJsonReader.read(e,i,t),i}throw new Error(`Unable to parse message ${this.typeName} from JSON ${C(e)}.`)}internalJsonWrite(e,t){return this.refJsonWriter.write(e,t)}internalBinaryWrite(e,t,n){return this.refBinWriter.write(e,t,n),t}internalBinaryRead(e,t,n,i){let s=i!=null?i:this.create();return this.refBinReader.read(e,s,n,t),s}};var Ze=class extends w{constructor(){super("google.protobuf.Timestamp",[{no:1,name:"seconds",kind:"scalar",T:3,L:0},{no:2,name:"nanos",kind:"scalar",T:5}])}now(){let e=this.create(),t=Date.now();return e.seconds=b.from(Math.floor(t/1e3)).toBigInt(),e.nanos=t%1e3*1e6,e}toDate(e){return new Date(b.from(e.seconds).toNumber()*1e3+Math.ceil(e.nanos/1e6))}fromDate(e){let t=this.create(),n=e.getTime();return t.seconds=b.from(Math.floor(n/1e3)).toBigInt(),t.nanos=n%1e3*1e6,t}internalJsonWrite(e,t){let n=b.from(e.seconds).toNumber()*1e3;if(n<Date.parse("0001-01-01T00:00:00Z")||n>Date.parse("9999-12-31T23:59:59Z"))throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");if(e.nanos<0)throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");let i="Z";if(e.nanos>0){let s=(e.nanos+1e9).toString().substring(1);s.substring(3)==="000000"?i="."+s.substring(0,3)+"Z":s.substring(6)==="000"?i="."+s.substring(0,6)+"Z":i="."+s+"Z"}return new Date(n).toISOString().replace(".000Z",i)}internalJsonRead(e,t,n){if(typeof e!="string")throw new Error("Unable to parse Timestamp from JSON "+C(e)+".");let i=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!i)throw new Error("Unable to parse Timestamp from JSON. Invalid format.");let s=Date.parse(i[1]+"-"+i[2]+"-"+i[3]+"T"+i[4]+":"+i[5]+":"+i[6]+(i[8]?i[8]:"Z"));if(Number.isNaN(s))throw new Error("Unable to parse Timestamp from JSON. Invalid value.");if(s<Date.parse("0001-01-01T00:00:00Z")||s>Date.parse("9999-12-31T23:59:59Z"))throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");return n||(n=this.create()),n.seconds=b.from(s/1e3).toBigInt(),n.nanos=0,i[7]&&(n.nanos=parseInt("1"+i[7]+"0".repeat(9-i[7].length))-1e9),n}},Qe=new Ze;var mr=(n=>(n[n.UNKNOWN=0]="UNKNOWN",n[n.PATH=1]="PATH",n[n.CMD=2]="CMD",n))(mr||{}),hr=(i=>(i[i.UNSPECIFIED=0]="UNSPECIFIED",i[i.CANCELLED=1]="CANCELLED",i[i.CANCELLING=2]="CANCELLING",i[i.NOT_CANCELLABLE=3]="NOT_CANCELLABLE",i))(hr||{}),ze=class extends w{constructor(){super("arrow.flight.protocol.HandshakeRequest",[{no:1,name:"protocol_version",kind:"scalar",T:4,L:0},{no:2,name:"payload",kind:"scalar",T:12}])}},jr=new ze,Ye=class extends w{constructor(){super("arrow.flight.protocol.HandshakeResponse",[{no:1,name:"protocol_version",kind:"scalar",T:4,L:0},{no:2,name:"payload",kind:"scalar",T:12}])}},Jr=new Ye,et=class extends w{constructor(){super("arrow.flight.protocol.BasicAuth",[{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"password",kind:"scalar",T:9}])}},ks=new et,tt=class extends w{constructor(){super("arrow.flight.protocol.Empty",[])}},Xr=new tt,rt=class extends w{constructor(){super("arrow.flight.protocol.ActionType",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}])}},Hr=new rt,nt=class extends w{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}},Gr=new nt,it=class extends w{constructor(){super("arrow.flight.protocol.Action",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"body",kind:"scalar",T:12}])}},Kr=new it,st=class extends w{constructor(){super("arrow.flight.protocol.CancelFlightInfoRequest",[{no:1,name:"info",kind:"message",T:()=>Ie}])}},_s=new st,ot=class extends w{constructor(){super("arrow.flight.protocol.RenewFlightEndpointRequest",[{no:1,name:"endpoint",kind:"message",T:()=>dr}])}},Ss=new ot,at=class extends w{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}},Zr=new at,lt=class extends w{constructor(){super("arrow.flight.protocol.CancelFlightInfoResult",[{no:1,name:"status",kind:"enum",T:()=>["arrow.flight.protocol.CancelStatus",hr,"CANCEL_STATUS_"]}])}},Rs=new lt,ut=class extends w{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}},Qr=new ut,ft=class extends w{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",mr]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}},q=new ft,ct=class extends w{constructor(){super("arrow.flight.protocol.FlightInfo",[{no:1,name:"schema",kind:"scalar",T:12},{no:2,name:"flight_descriptor",kind:"message",T:()=>q},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>dr},{no:4,name:"total_records",kind:"scalar",T:3,L:0},{no:5,name:"total_bytes",kind:"scalar",T:3,L:0},{no:6,name:"ordered",kind:"scalar",T:8},{no:7,name:"app_metadata",kind:"scalar",T:12}])}},Ie=new ct,pt=class extends w{constructor(){super("arrow.flight.protocol.PollInfo",[{no:1,name:"info",kind:"message",T:()=>Ie},{no:2,name:"flight_descriptor",kind:"message",T:()=>q},{no:3,name:"progress",kind:"scalar",opt:!0,T:1},{no:4,name:"expiration_time",kind:"message",T:()=>Qe}])}},zr=new pt,mt=class extends w{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>Ne},{no:2,name:"location",kind:"message",repeat:1,T:()=>Yr},{no:3,name:"expiration_time",kind:"message",T:()=>Qe},{no:4,name:"app_metadata",kind:"scalar",T:12}])}},dr=new mt,ht=class extends w{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}},Yr=new ht,dt=class extends w{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}},Ne=new dt,gt=class extends w{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>q},{no:2,name:"data_header",kind:"scalar",T:12},{no:3,name:"app_metadata",kind:"scalar",T:12},{no:1e3,name:"data_body",kind:"scalar",T:12}])}},Oe=new gt,bt=class extends w{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}},en=new bt,Ee=new pr.ServiceType("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:jr,O:Jr},{name:"ListFlights",serverStreaming:!0,options:{},I:Gr,O:Ie},{name:"GetFlightInfo",options:{},I:q,O:Ie},{name:"PollFlightInfo",options:{},I:q,O:zr},{name:"GetSchema",options:{},I:q,O:Qr},{name:"DoGet",serverStreaming:!0,options:{},I:Ne,O:Oe},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:Oe,O:en},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:Oe,O:Oe},{name:"DoAction",serverStreaming:!0,options:{},I:Kr,O:Zr},{name:"ListActions",serverStreaming:!0,options:{},I:Xr,O:Hr}]);var E=require("@protobuf-ts/runtime-rpc");var ke=class{constructor(e){this._transport=e;h(this,"typeName",Ee.typeName);h(this,"methods",Ee.methods);h(this,"options",Ee.options)}handshake(e){let t=this.methods[0],n=this._transport.mergeOptions(e);return(0,E.stackIntercept)("duplex",this._transport,t,n)}listFlights(e,t){let n=this.methods[1],i=this._transport.mergeOptions(t);return(0,E.stackIntercept)("serverStreaming",this._transport,n,i,e)}getFlightInfo(e,t){let n=this.methods[2],i=this._transport.mergeOptions(t);return(0,E.stackIntercept)("unary",this._transport,n,i,e)}pollFlightInfo(e,t){let n=this.methods[3],i=this._transport.mergeOptions(t);return(0,E.stackIntercept)("unary",this._transport,n,i,e)}getSchema(e,t){let n=this.methods[4],i=this._transport.mergeOptions(t);return(0,E.stackIntercept)("unary",this._transport,n,i,e)}doGet(e,t){let n=this.methods[5],i=this._transport.mergeOptions(t);return(0,E.stackIntercept)("serverStreaming",this._transport,n,i,e)}doPut(e){let t=this.methods[6],n=this._transport.mergeOptions(e);return(0,E.stackIntercept)("duplex",this._transport,t,n)}doExchange(e){let t=this.methods[7],n=this._transport.mergeOptions(e);return(0,E.stackIntercept)("duplex",this._transport,t,n)}doAction(e,t){let n=this.methods[8],i=this._transport.mergeOptions(t);return(0,E.stackIntercept)("serverStreaming",this._transport,n,i,e)}listActions(e,t){let n=this.methods[9],i=this._transport.mergeOptions(t);return(0,E.stackIntercept)("serverStreaming",this._transport,n,i,e)}};var gr=/\$(\w+)/g;function br(r){return!!r.match(gr)}function yr(r,e){let t=r.match(gr);if(t)for(let n of t)e[n.trim().replace("$","")]||v(new Error(`No parameter matching ${n} provided in the query params map`));return!0}var Tr=require("apache-arrow/enum");function yt(r,e){if(e==null)return null;let t=r.metadata.get("iox::column::type");if(!t||r.typeId===Tr.Type.Timestamp)return e;let[,,n,i]=t.split("::");if(n==="field")switch(i){case"integer":return M(e)?parseInt(e):(console.warn(`Value ${e} is not an integer`),e);case"uinteger":return Ut(e)?parseInt(e):(console.warn(`Value ${e} is not an unsigned integer`),e);case"float":return M(e)?parseFloat(e):(console.warn(`Value ${e} is not a float`),e);case"boolean":return typeof e=="boolean"||console.warn(`Value ${e} is not a boolean`),e;case"string":return typeof e=="string"?String(e):(console.warn(`Value ${e} is not a string`),e);default:return e}return e}var z=class{constructor(e){this._options=e;h(this,"_closed",!1);h(this,"_flightClient");h(this,"_transport");h(this,"_defaultHeaders");let{host:t,queryTimeout:n}=this._options;this._defaultHeaders=this._options.headers,this._transport=G.queryTransport({host:t,timeout:n}),this._flightClient=new ke(this._transport)}prepareTicket(e,t,n){let i={database:e,sql_query:t,query_type:n.type};if(n.params){let s={};for(let o of Object.keys(n.params))n.params[o]&&(s[o]=n.params[o]);i.params=s}return Ne.create({ticket:new TextEncoder().encode(JSON.stringify(i))})}prepareMetadata(e){let t={"User-Agent":oe,...this._defaultHeaders,...e},n=this._options.token;return n&&(t.authorization=`Bearer ${n}`),t}async*_queryRawBatches(e,t,n){if(n.params&&br(e)&&yr(e,n.params),this._closed)throw new Error("queryApi: already closed!");let i=this._flightClient,s=this.prepareTicket(t,e,n),a={meta:this.prepareMetadata(n.headers)},l=i.doGet(s,a),f=async function*(){for await(let p of l.responses)yield At(p.dataHeader.length),yield p.dataHeader,yield p.dataBody}();yield*await _e.RecordBatchReader.from(f)}async*query(e,t,n){let i=this._queryRawBatches(e,t,n);for await(let s of i)for(let o of s){let a={};for(let l of s.schema.fields){let f=o[l.name];a[l.name]=yt(l,f)}yield a}}async*queryPoints(e,t,n){var s;let i=this._queryRawBatches(e,t,n);for await(let o of i)for(let a=0;a<o.numRows;a++){let l=new A;for(let f=0;f<o.numCols;f++){let c=o.schema.fields[f],p=c.name,m=(s=o.getChildAt(f))==null?void 0:s.get(a),T=c.typeId,g=c.metadata.get("iox::column::type");if(m==null)continue;if((p==="measurement"||p=="iox::measurement")&&typeof m=="string"){l.setMeasurement(m);continue}if(!g){p==="time"&&T===_e.Type.Timestamp?l.setTimestamp(m):l.setField(p,m);continue}let[,,O,k]=g.split("::");if(O==="field"){if(k&&m!==void 0&&m!==null){let j=yt(c,m);l.setField(p,j,k)}}else O==="tag"?l.setTag(p,m):O==="timestamp"&&l.setTimestamp(m)}yield l}}async close(){var e,t;this._closed=!0,(t=(e=this._transport).close)==null||t.call(e)}};var Tt=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
6
- `,Y=class{constructor(...e){h(this,"_options");h(this,"_writeApi");h(this,"_queryApi");h(this,"_mergeWriteOptions",e=>{var i;let t={...(i=this._options.writeOptions)==null?void 0:i.headers,...e==null?void 0:e.headers},n={...this._options.writeOptions,...e};return n.headers=t,n});h(this,"_mergeQueryOptions",e=>{var s,o;let t={...(s=this._options.queryOptions)==null?void 0:s.headers,...e==null?void 0:e.headers},n={...(o=this._options.queryOptions)==null?void 0:o.params,...e==null?void 0:e.params},i={...this._options.queryOptions,...e};return i.headers=t,i.params=n,i});let t;switch(e.length){case 0:{t=Ae();break}case 1:{if(e[0]==null)throw new R("No configuration specified!");typeof e[0]=="string"?t=Pe(e[0]):t=e[0];break}default:throw new R("Multiple arguments specified!")}this._options={...Se,...t};let n=this._options.host;if(typeof n!="string")throw new R("No host specified!");if(n.endsWith("/")&&(this._options.host=n.substring(0,n.length-1)),typeof this._options.token!="string")throw new R("No token specified!");this._queryApi=new z(this._options),this._writeApi=new K(this._options)}async write(e,t,n,i){var o;let s=this._mergeWriteOptions(i);await this._writeApi.doWrite(ve(e,s==null?void 0:s.defaultTags),(o=t!=null?t:this._options.database)!=null?o:v(new Error(Tt)),n,s)}query(e,t,n=(i=>(i=this._options.queryOptions)!=null?i:te)()){var o;let s=this._mergeQueryOptions(n);return this._queryApi.query(e,(o=t!=null?t:this._options.database)!=null?o:v(new Error(Tt)),s)}queryPoints(e,t,n=(i=>(i=this._options.queryOptions)!=null?i:te)()){var o;let s=this._mergeQueryOptions(n);return this._queryApi.queryPoints(e,(o=t!=null?t:this._options.database)!=null?o:v(new Error(Tt)),s)}async close(){await this._writeApi.close(),await this._queryApi.close()}};0&&(module.exports={AbortError,DEFAULT_ConnectionOptions,DEFAULT_QueryOptions,DEFAULT_WriteOptions,GetFieldTypeMissmatchError,HttpError,IllegalArgumentError,InfluxDBClient,Log,Point,PointValues,RequestTimedOutError,collectAll,consoleLogger,convertTime,convertTimeToNanos,createTextDecoderCombiner,currentTime,dateToProtocolTimestamp,escape,fromConnectionString,fromEnv,isNumber,setLogger,useProcessHrtime,writableDataToLineProtocol});
1
+ "use strict";var Ir=Object.create;var j=Object.defineProperty;var Nr=Object.getOwnPropertyDescriptor;var Er=Object.getOwnPropertyNames;var _r=Object.getPrototypeOf,kr=Object.prototype.hasOwnProperty;var Sr=(r,e,t)=>e in r?j(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var Rr=(r,e)=>{for(var t in e)j(r,t,{get:e[t],enumerable:!0})},xt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Er(e))!kr.call(r,i)&&i!==t&&j(r,i,{get:()=>e[i],enumerable:!(n=Nr(e,i))||n.enumerable});return r};var ee=(r,e,t)=>(t=r!=null?Ir(_r(r)):{},xt(e||!r||!r.__esModule?j(t,"default",{value:r,enumerable:!0}):t,r)),Pr=r=>xt(j({},"__esModule",{value:!0}),r);var d=(r,e,t)=>Sr(r,typeof e!="symbol"?e+"":e,t);var on={};Rr(on,{AbortError:()=>D,DEFAULT_ConnectionOptions:()=>Se,DEFAULT_QueryOptions:()=>te,DEFAULT_WriteOptions:()=>Re,GetFieldTypeMissmatchError:()=>se,HttpError:()=>k,IllegalArgumentError:()=>P,InfluxDBClient:()=>Y,Log:()=>V,Point:()=>J,PointValues:()=>A,RequestTimedOutError:()=>B,collectAll:()=>Bt,consoleLogger:()=>Nt,convertTime:()=>We,convertTimeToNanos:()=>Me,createTextDecoderCombiner:()=>Ar,currentTime:()=>At,dateToProtocolTimestamp:()=>Ut,escape:()=>S,fromConnectionString:()=>Pe,fromEnv:()=>Ae,isNumber:()=>M,parsePrecision:()=>Ce,precisionToV2ApiString:()=>Ue,precisionToV3ApiString:()=>De,setLogger:()=>Ur,useProcessHrtime:()=>Pt,writableDataToLineProtocol:()=>$e});module.exports=Pr(on);var P=class r extends Error{constructor(e){super(e),this.name="IllegalArgumentError",Object.setPrototypeOf(this,r.prototype)}},k=class r extends Error{constructor(t,n,i,s,o,a){var l;super();this.statusCode=t;this.statusMessage=n;this.body=i;this.contentType=s;this.headers=o;d(this,"code");d(this,"json");if(Object.setPrototypeOf(this,r.prototype),a)this.message=a;else if(i&&(s!=null&&s.startsWith("application/json")||!s))try{if(this.json=JSON.parse(i),this.message=this.json.message,this.code=this.json.code,!this.message){let c=this.json;(l=c.data)!=null&&l.error_message?this.message=c.data.error_message:c.error&&(this.message=c.error)}}catch(c){}this.message||(this.message=`${t} ${n} : ${i}`),this.name="HttpError"}},B=class r extends Error{constructor(){super(),Object.setPrototypeOf(this,r.prototype),this.name="RequestTimedOutError",this.message="Request timed out"}},D=class r extends Error{constructor(){super(),this.name="AbortError",Object.setPrototypeOf(this,r.prototype),this.message="Response aborted"}};function Ar(){let r=new TextDecoder("utf-8");return{concat(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n},copy(e,t,n){let i=new Uint8Array(n-t);return i.set(e.subarray(t,n)),i},toUtf8String(e,t,n){return r.decode(e.subarray(t,n))}}}var Se={timeout:1e4,queryTimeout:6e4},Re={precision:"ns",gzipThreshold:1e3,noSync:!1},te={type:"sql"};function Pe(r){if(!r)throw Error("Connection string not set!");let e=new URL(r.trim(),"http://localhost"),t={host:r.indexOf("://")>0?e.origin+e.pathname:e.pathname};return e.searchParams.has("token")&&(t.token=e.searchParams.get("token")),e.searchParams.has("authScheme")&&(t.authScheme=e.searchParams.get("authScheme")),e.searchParams.has("database")&&(t.database=e.searchParams.get("database")),e.searchParams.has("timeout")&&(t.timeout=parseInt(e.searchParams.get("timeout"))),e.searchParams.has("precision")&&(t.writeOptions||(t.writeOptions={}),t.writeOptions.precision=Ce(e.searchParams.get("precision"))),e.searchParams.has("gzipThreshold")&&(t.writeOptions||(t.writeOptions={}),t.writeOptions.gzipThreshold=parseInt(e.searchParams.get("gzipThreshold"))),e.searchParams.has("writeNoSync")&&(t.writeOptions||(t.writeOptions={}),t.writeOptions.noSync=It(e.searchParams.get("writeNoSync"))),t}function Ae(){if(!process.env.INFLUX_HOST)throw Error("INFLUX_HOST variable not set!");if(!process.env.INFLUX_TOKEN)throw Error("INFLUX_TOKEN variable not set!");let r={host:process.env.INFLUX_HOST.trim()};return process.env.INFLUX_TOKEN&&(r.token=process.env.INFLUX_TOKEN.trim()),process.env.INFLUX_AUTH_SCHEME&&(r.authScheme=process.env.INFLUX_AUTH_SCHEME.trim()),process.env.INFLUX_DATABASE&&(r.database=process.env.INFLUX_DATABASE.trim()),process.env.INFLUX_TIMEOUT&&(r.timeout=parseInt(process.env.INFLUX_TIMEOUT.trim())),process.env.INFLUX_PRECISION&&(r.writeOptions||(r.writeOptions={}),r.writeOptions.precision=Ce(process.env.INFLUX_PRECISION)),process.env.INFLUX_GZIP_THRESHOLD&&(r.writeOptions||(r.writeOptions={}),r.writeOptions.gzipThreshold=parseInt(process.env.INFLUX_GZIP_THRESHOLD)),process.env.INFLUX_WRITE_NO_SYNC&&(r.writeOptions||(r.writeOptions={}),r.writeOptions.noSync=It(process.env.INFLUX_WRITE_NO_SYNC)),r}function It(r){return["true","1","t","y","yes"].includes(r.trim().toLowerCase())}function Ue(r){switch(r){case"ns":case"us":case"ms":case"s":return r;default:throw Error(`Unsupported precision '${r}'`)}}function De(r){switch(r){case"ns":return"nanosecond";case"us":return"microsecond";case"ms":return"millisecond";case"s":return"second";default:throw Error(`Unsupported precision '${r}'`)}}function Ce(r){switch(r.trim().toLowerCase()){case"ns":case"nanosecond":return"ns";case"us":case"microsecond":return"us";case"ms":case"millisecond":return"ms";case"s":case"second":return"s";default:throw Error(`Unsupported precision '${r}'`)}}var Nt={error(r,e){console.error(`ERROR: ${r}`,e||"")},warn(r,e){console.warn(`WARN: ${r}`,e||"")}},re=Nt,V={error(r,e){re.error(r,e)},warn(r,e){re.warn(r,e)}};function Ur(r){let e=re;return re=r,e}function Le(r,e){return function(t){let n="",i=0,s=0;for(;s<t.length;){let o=r.indexOf(t[s]);o>=0&&(n+=t.substring(i,s),n+=e[o],i=s+1),s++}return i==0?t:(i<t.length&&(n+=t.substring(i,t.length)),n)}}function Dr(r,e){let t=Le(r,e);return n=>`"${t(n)}"`}var S={measurement:Le(`,
2
+ \r `,["\\,","\\ ","\\n","\\r","\\t"]),quoted:Dr('"\\',['\\"',"\\\\"]),tag:Le(`, =
3
+ \r `,["\\,","\\ ","\\=","\\n","\\r","\\t"])};var ie="000000000",ve=!1;function Pt(r){return ve=r&&process&&typeof process.hrtime=="function"}Pt(!0);var Et,ne,_t=Date.now(),Be=0;function Ve(){if(ve){let r=process.hrtime(),e=Date.now();ne?(r[0]=r[0]-ne[0],r[1]=r[1]-ne[1],r[1]<0&&(r[0]-=1,r[1]+=1e9),e=Et+r[0]*1e3+Math.floor(r[1]/1e6)):(ne=r,Et=e);let t=String(r[1]%1e6);return String(e)+ie.substr(0,6-t.length)+t}else{let r=Date.now();r!==_t?(_t=r,Be=0):Be++;let e=String(Be);return String(r)+ie.substr(0,6-e.length)+e}}function kt(){if(ve){let r=process.hrtime(),e=String(Math.trunc(r[1]/1e3)%1e3);return String(Date.now())+ie.substr(0,3-e.length)+e}else return String(Date.now())+ie.substr(0,3)}function St(){return String(Date.now())}function Rt(){return String(Math.floor(Date.now()/1e3))}var At={s:Rt,ms:St,us:kt,ns:Ve,seconds:Rt,millis:St,micros:kt,nanos:Ve},Ut={s:r=>`${Math.floor(r.getTime()/1e3)}`,ms:r=>`${r.getTime()}`,us:r=>`${r.getTime()}000`,ns:r=>`${r.getTime()}000000`};function Me(r){return r===void 0?Ve():typeof r=="string"?r.length>0?r:void 0:r instanceof Date?`${r.getTime()}000000`:String(typeof r=="number"?Math.floor(r):r)}var We=(r,e="ns")=>r===void 0?At[e]():typeof r=="string"?r.length>0?r:void 0:r instanceof Date?Ut[e](r):String(typeof r=="number"?Math.floor(r):r);var v=r=>{throw r},Dt=r=>r!==void 0,Ct=r=>r instanceof Array||r instanceof Object&&typeof r.length=="number"&&(r.length===0||Object.getOwnPropertyNames(r).some(e=>e==="0")),Lt=r=>{let e=new Uint8Array(4);return e[0]=r>>0,e[1]=r>>8,e[2]=r>>16,e[3]=r>>24,e},Bt=async r=>{let e=[];for await(let t of r)e.push(t);return e},M=r=>r===null||typeof r=="string"&&(r===""||r.indexOf(" ")!==-1)?!1:r!==""&&!isNaN(Number(r==null?void 0:r.toString())),Vt=r=>M(r)?typeof r=="string"?Number(r)>=0:typeof r=="number"&&r>=0:!1;var $e=(r,e)=>{let t=Ct(r)&&typeof r!="string"?Array.from(r):[r];return t.length===0?[]:typeof t[0]=="string"?t:t.map(i=>i.toLineProtocol(void 0,e)).filter(Dt)};var Cr=r=>typeof r=="number"?"float":typeof r=="string"?"string":typeof r=="boolean"?"boolean":void 0,se=class r extends Error{constructor(e,t,n){super(`field ${e} of type ${n} doesn't match expected type ${t}!`),this.name="GetFieldTypeMissmatchError",Object.setPrototypeOf(this,r.prototype)}},A=class r{constructor(){d(this,"_name");d(this,"_time");d(this,"_tags",{});d(this,"_fields",{})}getMeasurement(){return this._name}setMeasurement(e){return this._name=e,this}getTimestamp(){return this._time}setTimestamp(e){return this._time=e,this}getTag(e){return this._tags[e]}setTag(e,t){return this._tags[e]=t,this}removeTag(e){return delete this._tags[e],this}getTagNames(){return Object.keys(this._tags)}getFloatField(e){return this.getField(e,"float")}setFloatField(e,t){let n;if(typeof t=="number"?n=t:n=parseFloat(t),!isFinite(n))throw new Error(`invalid float value for field '${e}': '${t}'!`);return this._fields[e]=["float",n],this}getIntegerField(e){return this.getField(e,"integer")}setIntegerField(e,t){let n;if(typeof t=="number"?n=t:n=parseInt(String(t)),isNaN(n)||n<=-9223372036854776e3||n>=9223372036854776e3)throw new Error(`invalid integer value for field '${e}': '${t}'!`);return this._fields[e]=["integer",Math.floor(n)],this}getUintegerField(e){return this.getField(e,"uinteger")}setUintegerField(e,t){if(typeof t=="number"){if(isNaN(t)||t<0||t>Number.MAX_SAFE_INTEGER)throw new Error(`uint value for field '${e}' out of range: ${t}`);this._fields[e]=["uinteger",Math.floor(t)]}else{let n=String(t);for(let i=0;i<n.length;i++){let s=n.charCodeAt(i);if(s<48||s>57)throw new Error(`uint value has an unsupported character at pos ${i}: ${t}`)}if(n.length>20||n.length===20&&n.localeCompare("18446744073709551615")>0)throw new Error(`uint value for field '${e}' out of range: ${n}`);this._fields[e]=["uinteger",+n]}return this}getStringField(e){return this.getField(e,"string")}setStringField(e,t){return t!=null&&(typeof t!="string"&&(t=String(t)),this._fields[e]=["string",t]),this}getBooleanField(e){return this.getField(e,"boolean")}setBooleanField(e,t){return this._fields[e]=["boolean",!!t],this}getField(e,t){let n=this._fields[e];if(!n)return;let[i,s]=n;if(t!==void 0&&t!==i)throw new se(e,t,i);return s}getFieldType(e){let t=this._fields[e];if(t)return t[0]}setField(e,t,n){switch(n!=null?n:Cr(t)){case"string":return this.setStringField(e,t);case"boolean":return this.setBooleanField(e,t);case"float":return this.setFloatField(e,t);case"integer":return this.setIntegerField(e,t);case"uinteger":return this.setUintegerField(e,t);case void 0:return this;default:throw new Error(`invalid field type for field '${e}': type -> ${n}, value -> ${t}!`)}}setFields(e){for(let[t,n]of Object.entries(e))this.setField(t,n);return this}removeField(e){return delete this._fields[e],this}getFieldNames(){return Object.keys(this._fields)}hasFields(){return this.getFieldNames().length>0}copy(){let e=new r;return e._name=this._name,e._time=this._time,e._tags=Object.fromEntries(Object.entries(this._tags)),e._fields=Object.fromEntries(Object.entries(this._fields).map(t=>[...t])),e}asPoint(e){return J.fromValues(e?this.setMeasurement(e):this)}};var Lr=(r,e)=>{switch(r){case"string":return S.quoted(e);case"boolean":return e?"T":"F";case"float":return`${e}`;case"integer":return`${e}i`;case"uinteger":return`${e}u`}},J=class r{constructor(e){d(this,"_values");e instanceof A?this._values=e:this._values=new A,typeof e=="string"&&this._values.setMeasurement(e)}static measurement(e){return new r(e)}static fromValues(e){if(!e.getMeasurement()||e.getMeasurement()==="")throw new Error("Cannot convert values to point without measurement set!");return new r(e)}getMeasurement(){return this._values.getMeasurement()}setMeasurement(e){return e!==""&&this._values.setMeasurement(e),this}getTimestamp(){return this._values.getTimestamp()}setTimestamp(e){return this._values.setTimestamp(e),this}getTag(e){return this._values.getTag(e)}setTag(e,t){return this._values.setTag(e,t),this}removeTag(e){return this._values.removeTag(e),this}getTagNames(){return this._values.getTagNames()}getFloatField(e){return this._values.getFloatField(e)}setFloatField(e,t){return this._values.setFloatField(e,t),this}getIntegerField(e){return this._values.getIntegerField(e)}setIntegerField(e,t){return this._values.setIntegerField(e,t),this}getUintegerField(e){return this._values.getUintegerField(e)}setUintegerField(e,t){return this._values.setUintegerField(e,t),this}getStringField(e){return this._values.getStringField(e)}setStringField(e,t){return this._values.setStringField(e,t),this}getBooleanField(e){return this._values.getBooleanField(e)}setBooleanField(e,t){return this._values.setBooleanField(e,t),this}getField(e,t){return this._values.getField(e,t)}getFieldType(e){return this._values.getFieldType(e)}setField(e,t,n){return this._values.setField(e,t,n),this}setFields(e){return this._values.setFields(e),this}removeField(e){return this._values.removeField(e),this}getFieldNames(){return this._values.getFieldNames()}hasFields(){return this._values.hasFields()}copy(){return new r(this._values.copy())}toLineProtocol(e,t){if(!this._values.getMeasurement())return;let n="";if(this._values.getFieldNames().sort().forEach(a=>{if(a){let l=this._values.getFieldType(a),c=this._values.getField(a);if(l===void 0||c===void 0)return;let f=Lr(l,c);n.length>0&&(n+=","),n+=`${S.tag(a)}=${f}`}}),n.length===0)return;let i="",s=this._values.getTagNames();if(t){let a=new Set(s),l=Object.keys(t);for(let c=l.length;c--;)a.has(l[c])&&l.splice(c,1);l.sort().forEach(c=>{if(c){let f=t[c];f&&(i+=",",i+=`${S.tag(c)}=${S.tag(f)}`)}})}s.sort().forEach(a=>{if(a){let l=this._values.getTag(a);l&&(i+=",",i+=`${S.tag(a)}=${S.tag(l)}`)}});let o=this._values.getTimestamp();return e?typeof e=="string"?o=We(o,e):o=e(o):o=Me(o),`${S.measurement(this.getMeasurement())}${i} ${n}${o!==void 0?` ${o}`:""}`}toString(){let e=this.toLineProtocol(void 0);return e||`invalid point: ${JSON.stringify(this,void 0)}`}};var Xe=require("url"),vt=ee(require("http")),Mt=ee(require("https")),ae=require("buffer");var H=ee(require("zlib"));function qe(r={}){let e=0,t={next:n=>{if(e===0&&r.next&&n!==null&&n!==void 0)return r.next(n)},error:n=>{e===0&&(e=1,r.error&&r.error(n))},complete:()=>{e===0&&(e=2,r.complete&&r.complete())},responseStarted:(n,i)=>{r.responseStarted&&r.responseStarted(n,i)}};return r.useCancellable&&(t.useCancellable=r.useCancellable.bind(r)),r.useResume&&(t.useResume=r.useResume.bind(r)),t}var Br="1.2.0.nightly",oe=`influxdb3-js/${Br}`;var Wt=require("stream");var Vr={flush:H.default.constants.Z_SYNC_FLUSH,finishFlush:H.default.constants.Z_SYNC_FLUSH},vr=ae.Buffer.allocUnsafe(0),je=class{constructor(){d(this,"_cancelled",!1);d(this,"resume")}cancel(){this._cancelled=!0,this.resume&&(this.resume(),this.resume=void 0)}isCancelled(){return this._cancelled}},Je=class{constructor(e){d(this,"_defaultOptions");d(this,"_requestApi");d(this,"_contextPath");d(this,"_token");d(this,"_authScheme");d(this,"_headers");var c,f,p,m,w,h,x;let{host:t,proxyUrl:n,token:i,authScheme:s,transportOptions:o,...a}=e,l=(0,Xe.parse)(n||t);if(this._token=i,this._authScheme=s,this._defaultOptions={...a,...o,port:l.port,protocol:l.protocol,hostname:l.hostname},this._contextPath=n?t:(c=l.path)!=null?c:"",this._contextPath.endsWith("/")&&(this._contextPath=this._contextPath.substring(0,this._contextPath.length-1)),Object.keys(this._defaultOptions).forEach(_=>this._defaultOptions[_]===void 0&&delete this._defaultOptions[_]),this._contextPath.endsWith("/api/v2")&&(V.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${l.protocol}//${l.hostname}:${l.port} !`),this._contextPath=""),l.protocol==="http:")this._requestApi=(m=(p=(f=this._defaultOptions["follow-redirects"])==null?void 0:f.http)==null?void 0:p.request)!=null?m:vt.request;else if(l.protocol==="https:")this._requestApi=(x=(h=(w=this._defaultOptions["follow-redirects"])==null?void 0:w.https)==null?void 0:h.request)!=null?x:Mt.request;else throw new Error(`Unsupported protocol "${l.protocol} in URL: "${e.host}"`);this._headers={"User-Agent":oe,...e.headers},n&&(this._headers.Host=(0,Xe.parse)(t).host)}send(e,t,n,i){let s=new je;i&&i.useCancellable&&i.useCancellable(s),this._createRequestMessage(e,t,n,o=>{this._request(o,s,i)},o=>(i==null?void 0:i.error)&&i.error(o))}request(e,t,n,i){t?typeof t!="string"&&(t=JSON.stringify(t)):t="";let s=vr,o,a;return new Promise((l,c)=>{this.send(e,t,n,{responseStarted(f,p){i&&i(f,p),o=String(f["content-type"]),a=p},next:f=>{s=ae.Buffer.concat([s,f])},complete:()=>{var p,m;let f=(m=(p=n.headers)==null?void 0:p.accept)!=null?m:o;try{a===204&&l(void 0),f.includes("json")?s.length?l(JSON.parse(s.toString("utf8"))):l(void 0):f.includes("text")||f.startsWith("application/csv")?l(s.toString("utf8")):l(s)}catch(w){c(w)}},error:f=>{c(f)}})})}async*iterate(e,t,n){var f;let i,s;function o(p){i=p,s(p)}let a=await new Promise((p,m)=>{s=m,this._createRequestMessage(e,t,n,p,o)});(f=a.signal)!=null&&f.addEventListener&&a.signal.addEventListener("abort",()=>{o(new D)});let l=await new Promise((p,m)=>{s=m;let w=this._requestApi(a,p);w.on("timeout",()=>o(new B)),w.on("error",o),w.write(a.body),w.end()}),c=await new Promise((p,m)=>{s=m,this._prepareResponse(l,p,o)});for await(let p of c){if(i)throw i;yield p}}_createRequestMessage(e,t,n,i,s){var c;let o=ae.Buffer.from(t,"utf-8"),a={"content-type":"application/json; charset=utf-8",...this._headers};if(this._token){let f=(c=this._authScheme)!=null?c:"Token";a.authorization=`${f} ${this._token}`}let l={...this._defaultOptions,path:this._contextPath+e,method:n.method,headers:{...a,...n.headers}};if(n.signal&&(l.signal=n.signal),n.gzipThreshold!==void 0&&n.gzipThreshold<o.length){H.default.gzip(o,(f,p)=>{if(f)return s(f);l.headers["content-encoding"]="gzip",l.body=p,i(l)});return}l.body=o,l.headers["content-length"]=l.body.length,i(l)}_prepareResponse(e,t,n){var a;e.on("aborted",()=>{n(new D)}),e.on("error",n);let i=(a=e.statusCode)!=null?a:600,s=e.headers["content-encoding"],o;if(s==="gzip"?(o=H.default.createGunzip(Vr),o=(0,Wt.pipeline)(e,o,l=>l&&n(l))):o=e,i>=300){let l="",c=String(e.headers["content-type"]).startsWith("application/json");o.on("data",f=>{l+=f.toString(),!c&&l.length>1e3&&(l=l.slice(0,1e3),e.resume())}),o.on("end",()=>{l===""&&e.headers["x-influxdb-error"]&&(l=e.headers["x-influxdb-error"].toString()),n(new k(i,e.statusMessage,l,e.headers["content-type"],e.headers))})}else t(o)}_request(e,t,n){var o;let i=qe(n);if(t.isCancelled()){i.complete();return}(o=e.signal)!=null&&o.addEventListener&&e.signal.addEventListener("abort",()=>{i.error(new D)});let s=this._requestApi(e,a=>{if(t.isCancelled()){a.resume(),i.complete();return}i.responseStarted(a.headers,a.statusCode),this._prepareResponse(a,l=>{l.on("data",c=>{if(t.isCancelled())a.resume();else if(i.next(c)===!1){if(!i.useResume){i.error(new Error("Unable to pause, useResume is not configured!")),a.resume();return}a.pause();let f=()=>{a.resume()};t.resume=f,i.useResume(f)}}),l.on("end",i.complete)},i.error)});typeof s.setTimeout=="function"&&e.timeout&&s.setTimeout(e.timeout),s.on("timeout",()=>{i.error(new B)}),s.on("error",a=>{i.error(a)}),e.body&&s.write(e.body),s.end()}},$t=Je;var Jt=require("@protobuf-ts/grpc-transport");var qt="http://",Xt="https://",jt=r=>{r=r.replace(/\/$/,"");let e;return r.startsWith(qt)?(r=r.slice(qt.length),e=!1,r.includes(":")||(r=`${r}:80`)):r.startsWith(Xt)&&(r=r.slice(Xt.length),e=!0,r.includes(":")||(r=`${r}:443`)),{url:r,safe:e}};var Ht=ee(require("@grpc/grpc-js")),Gt=({host:r,timeout:e})=>{let{url:t,safe:n}=jt(r),i=Ht.credentials[n==null||n?"createSsl":"createInsecure"]();return new Jt.GrpcTransport({host:t,channelCredentials:i,timeout:e})};var Mr={writeTransport:r=>new $t(r),queryTransport:Gt},G=Mr;var K=class{constructor(e){this._options=e;d(this,"_closed",!1);d(this,"_transport");var t;this._transport=(t=this._options.transport)!=null?t:G.writeTransport(this._options),this.doWrite=this.doWrite.bind(this)}_createWritePath(e,t,n){let i=t.precision,s,o=[];return n&&o.push(`org=${encodeURIComponent(n)}`),t.noSync?(s="/api/v3/write_lp",o.push(`db=${encodeURIComponent(e)}`),o.push(`precision=${De(i)}`),o.push("no_sync=true")):(s="/api/v2/write",o.push(`bucket=${encodeURIComponent(e)}`),o.push(`precision=${Ue(i)}`)),`${s}?${o.join("&")}`}doWrite(e,t,n,i){if(this._closed)return Promise.reject(new Error("writeApi: already closed!"));if(e.length<=0||e.length===1&&e[0]==="")return Promise.resolve();let o,a,l=new Promise((h,x)=>{o=h,a=x}),c={...Re,...i},f,p,m={responseStarted(h,x){f=x,p=h},error(h){if(h instanceof k&&h.json&&typeof h.json.error=="string"&&h.json.error.includes("hinted handoff queue not empty")){V.warn(`Write to InfluxDB returns: ${h.json.error}`),f=204,m.complete();return}h instanceof k&&h.statusCode==405&&c.noSync&&(h=new k(h.statusCode,"Server doesn't support write with noSync=true (supported by InfluxDB 3 Core/Enterprise servers only).",h.body,h.contentType,h.headers)),V.error("Write to InfluxDB failed.",h),a(h)},complete(){if(f==null||f>=200&&f<300)o();else{let h=`2xx HTTP response status code expected, but ${f} returned`,x=new k(f,h,void 0,"0",p);x.message=h,m.error(x)}}},w={method:"POST",headers:{"content-type":"text/plain; charset=utf-8",...i==null?void 0:i.headers},gzipThreshold:c.gzipThreshold};return this._transport.send(this._createWritePath(t,c,n),e.join(`
4
+ `),w,m),l}async close(){this._closed=!0}};var ke=require("apache-arrow");var gr=require("@protobuf-ts/runtime-rpc");function C(r){let e=typeof r;if(e=="object"){if(Array.isArray(r))return"array";if(r===null)return"null"}return e}function He(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}var R="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),le=[];for(let r=0;r<R.length;r++)le[R[r].charCodeAt(0)]=r;le[45]=R.indexOf("+");le[95]=R.indexOf("/");function Kt(r){let e=r.length*3/4;r[r.length-2]=="="?e-=2:r[r.length-1]=="="&&(e-=1);let t=new Uint8Array(e),n=0,i=0,s,o=0;for(let a=0;a<r.length;a++){if(s=le[r.charCodeAt(a)],s===void 0)switch(r[a]){case"=":i=0;case`
5
+ `:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(i){case 0:o=s,i=1;break;case 1:t[n++]=o<<2|(s&48)>>4,o=s,i=2;break;case 2:t[n++]=(o&15)<<4|(s&60)>>2,o=s,i=3;break;case 3:t[n++]=(o&3)<<6|s,i=0;break}}if(i==1)throw Error("invalid base64 string.");return t.subarray(0,n)}function Zt(r){let e="",t=0,n,i=0;for(let s=0;s<r.length;s++)switch(n=r[s],t){case 0:e+=R[n>>2],i=(n&3)<<4,t=1;break;case 1:e+=R[i|n>>4],i=(n&15)<<2,t=2;break;case 2:e+=R[i|n>>6],e+=R[n&63],t=0;break}return t&&(e+=R[i],e+="=",t==1&&(e+="=")),e}var W;(function(r){r.symbol=Symbol.for("protobuf-ts/unknown"),r.onRead=(t,n,i,s,o)=>{(e(n)?n[r.symbol]:n[r.symbol]=[]).push({no:i,wireType:s,data:o})},r.onWrite=(t,n,i)=>{for(let{no:s,wireType:o,data:a}of r.list(n))i.tag(s,o).raw(a)},r.list=(t,n)=>{if(e(t)){let i=t[r.symbol];return n?i.filter(s=>s.no==n):i}return[]},r.last=(t,n)=>r.list(t,n).slice(-1)[0];let e=t=>t&&Array.isArray(t[r.symbol])})(W||(W={}));var F;(function(r){r[r.Varint=0]="Varint",r[r.Bit64=1]="Bit64",r[r.LengthDelimited=2]="LengthDelimited",r[r.StartGroup=3]="StartGroup",r[r.EndGroup=4]="EndGroup",r[r.Bit32=5]="Bit32"})(F||(F={}));function Qt(){let r=0,e=0;for(let n=0;n<28;n+=7){let i=this.buf[this.pos++];if(r|=(i&127)<<n,(i&128)==0)return this.assertBounds(),[r,e]}let t=this.buf[this.pos++];if(r|=(t&15)<<28,e=(t&112)>>4,(t&128)==0)return this.assertBounds(),[r,e];for(let n=3;n<=31;n+=7){let i=this.buf[this.pos++];if(e|=(i&127)<<n,(i&128)==0)return this.assertBounds(),[r,e]}throw new Error("invalid varint")}function ce(r,e,t){for(let s=0;s<28;s=s+7){let o=r>>>s,a=!(!(o>>>7)&&e==0),l=(a?o|128:o)&255;if(t.push(l),!a)return}let n=r>>>28&15|(e&7)<<4,i=e>>3!=0;if(t.push((i?n|128:n)&255),!!i){for(let s=3;s<31;s=s+7){let o=e>>>s,a=!!(o>>>7),l=(a?o|128:o)&255;if(t.push(l),!a)return}t.push(e>>>31&1)}}var ue=65536*65536;function Ge(r){let e=r[0]=="-";e&&(r=r.slice(1));let t=1e6,n=0,i=0;function s(o,a){let l=Number(r.slice(o,a));i*=t,n=n*t+l,n>=ue&&(i=i+(n/ue|0),n=n%ue)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,n,i]}function fe(r,e){if(e>>>0<=2097151)return""+(ue*e+(r>>>0));let t=r&16777215,n=(r>>>24|e<<8)>>>0&16777215,i=e>>16&65535,s=t+n*6777216+i*6710656,o=n+i*8147497,a=i*2,l=1e7;s>=l&&(o+=Math.floor(s/l),s%=l),o>=l&&(a+=Math.floor(o/l),o%=l);function c(f,p){let m=f?String(f):"";return p?"0000000".slice(m.length)+m:m}return c(a,0)+c(o,a)+c(s,1)}function Ke(r,e){if(r>=0){for(;r>127;)e.push(r&127|128),r=r>>>7;e.push(r)}else{for(let t=0;t<9;t++)e.push(r&127|128),r=r>>7;e.push(1)}}function zt(){let r=this.buf[this.pos++],e=r&127;if((r&128)==0)return this.assertBounds(),e;if(r=this.buf[this.pos++],e|=(r&127)<<7,(r&128)==0)return this.assertBounds(),e;if(r=this.buf[this.pos++],e|=(r&127)<<14,(r&128)==0)return this.assertBounds(),e;if(r=this.buf[this.pos++],e|=(r&127)<<21,(r&128)==0)return this.assertBounds(),e;r=this.buf[this.pos++],e|=(r&15)<<28;for(let t=5;(r&128)!==0&&t<10;t++)r=this.buf[this.pos++];if((r&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var y;function Wr(){let r=new DataView(new ArrayBuffer(8));y=globalThis.BigInt!==void 0&&typeof r.getBigInt64=="function"&&typeof r.getBigUint64=="function"&&typeof r.setBigInt64=="function"&&typeof r.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:r}:void 0}Wr();function Yt(r){if(!r)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}var er=/^-?[0-9]+$/,me=4294967296,pe=2147483648,he=class{constructor(e,t){this.lo=e|0,this.hi=t|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let e=this.hi*me+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}},O=class r extends he{static from(e){if(y)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=y.C(e);case"number":if(e===0)return this.ZERO;e=y.C(e);case"bigint":if(!e)return this.ZERO;if(e<y.UMIN)throw new Error("signed value for ulong");if(e>y.UMAX)throw new Error("ulong too large");return y.V.setBigUint64(0,e,!0),new r(y.V.getInt32(0,!0),y.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!er.test(e))throw new Error("string is no integer");let[t,n,i]=Ge(e);if(t)throw new Error("signed value for ulong");return new r(n,i);case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new r(e,e/me)}throw new Error("unknown value "+typeof e)}toString(){return y?this.toBigInt().toString():fe(this.lo,this.hi)}toBigInt(){return Yt(y),y.V.setInt32(0,this.lo,!0),y.V.setInt32(4,this.hi,!0),y.V.getBigUint64(0,!0)}};O.ZERO=new O(0,0);var b=class r extends he{static from(e){if(y)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=y.C(e);case"number":if(e===0)return this.ZERO;e=y.C(e);case"bigint":if(!e)return this.ZERO;if(e<y.MIN)throw new Error("signed long too small");if(e>y.MAX)throw new Error("signed long too large");return y.V.setBigInt64(0,e,!0),new r(y.V.getInt32(0,!0),y.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!er.test(e))throw new Error("string is no integer");let[t,n,i]=Ge(e);if(t){if(i>pe||i==pe&&n!=0)throw new Error("signed long too small")}else if(i>=pe)throw new Error("signed long too large");let s=new r(n,i);return t?s.negate():s;case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new r(e,e/me):new r(-e,-e/me).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&pe)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new r(t,e)}toString(){if(y)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+fe(e.lo,e.hi)}return fe(this.lo,this.hi)}toBigInt(){return Yt(y),y.V.setInt32(0,this.lo,!0),y.V.setInt32(4,this.hi,!0),y.V.getBigInt64(0,!0)}};b.ZERO=new b(0,0);var tr={readUnknownField:!0,readerFactory:r=>new Ze(r)};function rr(r){return r?Object.assign(Object.assign({},tr),r):tr}var Ze=class{constructor(e,t){this.varint64=Qt,this.uint32=zt,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t!=null?t:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let e=this.uint32(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e){let t=this.pos;switch(e){case F.Varint:for(;this.buf[this.pos++]&128;);break;case F.Bit64:this.pos+=4;case F.Bit32:this.pos+=4;break;case F.LengthDelimited:let n=this.uint32();this.pos+=n;break;case F.StartGroup:let i;for(;(i=this.tag()[1])!==F.EndGroup;)this.skip(i);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return new b(...this.varint64())}uint64(){return new O(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,new b(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new O(this.sfixed32(),this.sfixed32())}sfixed64(){return new b(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}};function g(r,e){if(!r)throw new Error(e)}var $r=34028234663852886e22,qr=-34028234663852886e22,Xr=4294967295,jr=2147483647,Jr=-2147483648;function U(r){if(typeof r!="number")throw new Error("invalid int 32: "+typeof r);if(!Number.isInteger(r)||r>jr||r<Jr)throw new Error("invalid int 32: "+r)}function L(r){if(typeof r!="number")throw new Error("invalid uint 32: "+typeof r);if(!Number.isInteger(r)||r>Xr||r<0)throw new Error("invalid uint 32: "+r)}function $(r){if(typeof r!="number")throw new Error("invalid float 32: "+typeof r);if(Number.isFinite(r)&&(r>$r||r<qr))throw new Error("invalid float 32: "+r)}var nr={writeUnknownFields:!0,writerFactory:()=>new Qe};function ir(r){return r?Object.assign(Object.assign({},nr),r):nr}var Qe=class{constructor(e){this.stack=[],this.textEncoder=e!=null?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let i=0;i<this.chunks.length;i++)e+=this.chunks[i].length;let t=new Uint8Array(e),n=0;for(let i=0;i<this.chunks.length;i++)t.set(this.chunks[i],n),n+=this.chunks[i].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(L(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return U(e),Ke(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){$(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){L(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){U(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return U(e),e=(e<<1^e>>31)>>>0,Ke(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=b.from(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=O.from(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=b.from(e);return ce(t.lo,t.hi,this.buf),this}sint64(e){let t=b.from(e),n=t.hi>>31,i=t.lo<<1^n,s=(t.hi<<1|t.lo>>>31)^n;return ce(i,s,this.buf),this}uint64(e){let t=O.from(e);return ce(t.lo,t.hi,this.buf),this}};var sr={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},or={ignoreUnknownFields:!1};function ar(r){return r?Object.assign(Object.assign({},or),r):or}function lr(r){return r?Object.assign(Object.assign({},sr),r):sr}var de=Symbol.for("protobuf-ts/message-type");function ze(r){let e=!1,t=[];for(let n=0;n<r.length;n++){let i=r.charAt(n);i=="_"?e=!0:/\d/.test(i)?(t.push(i),e=!0):e?(t.push(i.toUpperCase()),e=!1):n==0?t.push(i.toLowerCase()):t.push(i)}return t.join("")}var u;(function(r){r[r.DOUBLE=1]="DOUBLE",r[r.FLOAT=2]="FLOAT",r[r.INT64=3]="INT64",r[r.UINT64=4]="UINT64",r[r.INT32=5]="INT32",r[r.FIXED64=6]="FIXED64",r[r.FIXED32=7]="FIXED32",r[r.BOOL=8]="BOOL",r[r.STRING=9]="STRING",r[r.BYTES=12]="BYTES",r[r.UINT32=13]="UINT32",r[r.SFIXED32=15]="SFIXED32",r[r.SFIXED64=16]="SFIXED64",r[r.SINT32=17]="SINT32",r[r.SINT64=18]="SINT64"})(u||(u={}));var I;(function(r){r[r.BIGINT=0]="BIGINT",r[r.STRING=1]="STRING",r[r.NUMBER=2]="NUMBER"})(I||(I={}));var Z;(function(r){r[r.NO=0]="NO",r[r.PACKED=1]="PACKED",r[r.UNPACKED=2]="UNPACKED"})(Z||(Z={}));function ur(r){var e,t,n,i;return r.localName=(e=r.localName)!==null&&e!==void 0?e:ze(r.name),r.jsonName=(t=r.jsonName)!==null&&t!==void 0?t:ze(r.name),r.repeat=(n=r.repeat)!==null&&n!==void 0?n:Z.NO,r.opt=(i=r.opt)!==null&&i!==void 0?i:r.repeat||r.oneof?!1:r.kind=="message",r}function cr(r){if(typeof r!="object"||r===null||!r.hasOwnProperty("oneofKind"))return!1;switch(typeof r.oneofKind){case"string":return r[r.oneofKind]===void 0?!1:Object.keys(r).length==2;case"undefined":return Object.keys(r).length==1;default:return!1}}var ge=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}prepare(){if(this.data)return;let e=[],t=[],n=[];for(let i of this.fields)if(i.oneof)n.includes(i.oneof)||(n.push(i.oneof),e.push(i.oneof),t.push(i.oneof));else switch(t.push(i.localName),i.kind){case"scalar":case"enum":(!i.opt||i.repeat)&&e.push(i.localName);break;case"message":i.repeat&&e.push(i.localName);break;case"map":e.push(i.localName);break}this.data={req:e,known:t,oneofs:Object.values(n)}}is(e,t,n=!1){if(t<0)return!0;if(e==null||typeof e!="object")return!1;this.prepare();let i=Object.keys(e),s=this.data;if(i.length<s.req.length||s.req.some(o=>!i.includes(o))||!n&&i.some(o=>!s.known.includes(o)))return!1;if(t<1)return!0;for(let o of s.oneofs){let a=e[o];if(!cr(a))return!1;if(a.oneofKind===void 0)continue;let l=this.fields.find(c=>c.localName===a.oneofKind);if(!l||!this.field(a[a.oneofKind],l,n,t))return!1}for(let o of this.fields)if(o.oneof===void 0&&!this.field(e[o.localName],o,n,t))return!1;return!0}field(e,t,n,i){let s=t.repeat;switch(t.kind){case"scalar":return e===void 0?t.opt:s?this.scalars(e,t.T,i,t.L):this.scalar(e,t.T,t.L);case"enum":return e===void 0?t.opt:s?this.scalars(e,u.INT32,i):this.scalar(e,u.INT32);case"message":return e===void 0?!0:s?this.messages(e,t.T(),n,i):this.message(e,t.T(),n,i);case"map":if(typeof e!="object"||e===null)return!1;if(i<2)return!0;if(!this.mapKeys(e,t.K,i))return!1;switch(t.V.kind){case"scalar":return this.scalars(Object.values(e),t.V.T,i,t.V.L);case"enum":return this.scalars(Object.values(e),u.INT32,i);case"message":return this.messages(Object.values(e),t.V.T(),n,i)}break}return!0}message(e,t,n,i){return n?t.isAssignable(e,i):t.is(e,i)}messages(e,t,n,i){if(!Array.isArray(e))return!1;if(i<2)return!0;if(n){for(let s=0;s<e.length&&s<i;s++)if(!t.isAssignable(e[s],i-1))return!1}else for(let s=0;s<e.length&&s<i;s++)if(!t.is(e[s],i-1))return!1;return!0}scalar(e,t,n){let i=typeof e;switch(t){case u.UINT64:case u.FIXED64:case u.INT64:case u.SFIXED64:case u.SINT64:switch(n){case I.BIGINT:return i=="bigint";case I.NUMBER:return i=="number"&&!isNaN(e);default:return i=="string"}case u.BOOL:return i=="boolean";case u.STRING:return i=="string";case u.BYTES:return e instanceof Uint8Array;case u.DOUBLE:case u.FLOAT:return i=="number"&&!isNaN(e);default:return i=="number"&&Number.isInteger(e)}}scalars(e,t,n,i){if(!Array.isArray(e))return!1;if(n<2)return!0;if(Array.isArray(e)){for(let s=0;s<e.length&&s<n;s++)if(!this.scalar(e[s],t,i))return!1}return!0}mapKeys(e,t,n){let i=Object.keys(e);switch(t){case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:return this.scalars(i.slice(0,n).map(s=>parseInt(s)),t,n);case u.BOOL:return this.scalars(i.slice(0,n).map(s=>s=="true"?!0:s=="false"?!1:s),t,n);default:return this.scalars(i,t,n,I.STRING)}}};function N(r,e){switch(e){case I.BIGINT:return r.toBigInt();case I.NUMBER:return r.toNumber();default:return r.toString()}}var be=class{constructor(e){this.info=e}prepare(){var e;if(this.fMap===void 0){this.fMap={};let t=(e=this.info.fields)!==null&&e!==void 0?e:[];for(let n of t)this.fMap[n.name]=n,this.fMap[n.jsonName]=n,this.fMap[n.localName]=n}}assert(e,t,n){if(!e){let i=C(n);throw(i=="number"||i=="boolean")&&(i=n.toString()),new Error(`Cannot parse JSON ${i} for ${this.info.typeName}#${t}`)}}read(e,t,n){this.prepare();let i=[];for(let[s,o]of Object.entries(e)){let a=this.fMap[s];if(!a){if(!n.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}let l=a.localName,c;if(a.oneof){if(o===null&&(a.kind!=="enum"||a.T()[0]!=="google.protobuf.NullValue"))continue;if(i.includes(a.oneof))throw new Error(`Multiple members of the oneof group "${a.oneof}" of ${this.info.typeName} are present in JSON.`);i.push(a.oneof),c=t[a.oneof]={oneofKind:l}}else c=t;if(a.kind=="map"){if(o===null)continue;this.assert(He(o),a.name,o);let f=c[l];for(let[p,m]of Object.entries(o)){this.assert(m!==null,a.name+" map value",null);let w;switch(a.V.kind){case"message":w=a.V.T().internalJsonRead(m,n);break;case"enum":if(w=this.enum(a.V.T(),m,a.name,n.ignoreUnknownFields),w===!1)continue;break;case"scalar":w=this.scalar(m,a.V.T,a.V.L,a.name);break}this.assert(w!==void 0,a.name+" map value",m);let h=p;a.K==u.BOOL&&(h=h=="true"?!0:h=="false"?!1:h),h=this.scalar(h,a.K,I.STRING,a.name).toString(),f[h]=w}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);let f=c[l];for(let p of o){this.assert(p!==null,a.name,null);let m;switch(a.kind){case"message":m=a.T().internalJsonRead(p,n);break;case"enum":if(m=this.enum(a.T(),p,a.name,n.ignoreUnknownFields),m===!1)continue;break;case"scalar":m=this.scalar(p,a.T,a.L,a.name);break}this.assert(m!==void 0,a.name,o),f.push(m)}}else switch(a.kind){case"message":if(o===null&&a.T().typeName!="google.protobuf.Value"){this.assert(a.oneof===void 0,a.name+" (oneof member)",null);continue}c[l]=a.T().internalJsonRead(o,n,c[l]);break;case"enum":if(o===null)continue;let f=this.enum(a.T(),o,a.name,n.ignoreUnknownFields);if(f===!1)continue;c[l]=f;break;case"scalar":if(o===null)continue;c[l]=this.scalar(o,a.T,a.L,a.name);break}}}enum(e,t,n,i){if(e[0]=="google.protobuf.NullValue"&&g(t===null||t==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} only accepts null.`),t===null)return 0;switch(typeof t){case"number":return g(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${n}, enum can only be integral number, got ${t}.`),t;case"string":let s=t;e[2]&&t.substring(0,e[2].length)===e[2]&&(s=t.substring(e[2].length));let o=e[1][s];return typeof o=="undefined"&&i?!1:(g(typeof o=="number",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} has no value for "${t}".`),o)}g(!1,`Unable to parse field ${this.info.typeName}#${n}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,n,i){let s;try{switch(t){case u.DOUBLE:case u.FLOAT:if(e===null)return 0;if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""){s="empty string";break}if(typeof e=="string"&&e.trim().length!==e.length){s="extra whitespace";break}if(typeof e!="string"&&typeof e!="number")break;let o=Number(e);if(Number.isNaN(o)){s="not a number";break}if(!Number.isFinite(o)){s="too large or small";break}return t==u.FLOAT&&$(o),o;case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:if(e===null)return 0;let a;if(typeof e=="number"?a=e:e===""?s="empty string":typeof e=="string"&&(e.trim().length!==e.length?s="extra whitespace":a=Number(e)),a===void 0)break;return t==u.UINT32?L(a):U(a),a;case u.INT64:case u.SFIXED64:case u.SINT64:if(e===null)return N(b.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return N(b.from(e),n);case u.FIXED64:case u.UINT64:if(e===null)return N(O.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return N(O.from(e),n);case u.BOOL:if(e===null)return!1;if(typeof e!="boolean")break;return e;case u.STRING:if(e===null)return"";if(typeof e!="string"){s="extra whitespace";break}try{encodeURIComponent(e)}catch(l){l="invalid UTF8";break}return e;case u.BYTES:if(e===null||e==="")return new Uint8Array(0);if(typeof e!="string")break;return Kt(e)}}catch(o){s=o.message}this.assert(!1,i+(s?" - "+s:""),e)}};var ye=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}write(e,t){let n={},i=e;for(let s of this.fields){if(!s.oneof){let c=this.field(s,i[s.localName],t);c!==void 0&&(n[t.useProtoFieldName?s.name:s.jsonName]=c);continue}let o=i[s.oneof];if(o.oneofKind!==s.localName)continue;let a=s.kind=="scalar"||s.kind=="enum"?Object.assign(Object.assign({},t),{emitDefaultValues:!0}):t,l=this.field(s,o[s.localName],a);g(l!==void 0),n[t.useProtoFieldName?s.name:s.jsonName]=l}return n}field(e,t,n){let i;if(e.kind=="map"){g(typeof t=="object"&&t!==null);let s={};switch(e.V.kind){case"scalar":for(let[l,c]of Object.entries(t)){let f=this.scalar(e.V.T,c,e.name,!1,!0);g(f!==void 0),s[l.toString()]=f}break;case"message":let o=e.V.T();for(let[l,c]of Object.entries(t)){let f=this.message(o,c,e.name,n);g(f!==void 0),s[l.toString()]=f}break;case"enum":let a=e.V.T();for(let[l,c]of Object.entries(t)){g(c===void 0||typeof c=="number");let f=this.enum(a,c,e.name,!1,!0,n.enumAsInteger);g(f!==void 0),s[l.toString()]=f}break}(n.emitDefaultValues||Object.keys(s).length>0)&&(i=s)}else if(e.repeat){g(Array.isArray(t));let s=[];switch(e.kind){case"scalar":for(let l=0;l<t.length;l++){let c=this.scalar(e.T,t[l],e.name,e.opt,!0);g(c!==void 0),s.push(c)}break;case"enum":let o=e.T();for(let l=0;l<t.length;l++){g(t[l]===void 0||typeof t[l]=="number");let c=this.enum(o,t[l],e.name,e.opt,!0,n.enumAsInteger);g(c!==void 0),s.push(c)}break;case"message":let a=e.T();for(let l=0;l<t.length;l++){let c=this.message(a,t[l],e.name,n);g(c!==void 0),s.push(c)}break}(n.emitDefaultValues||s.length>0||n.emitDefaultValues)&&(i=s)}else switch(e.kind){case"scalar":i=this.scalar(e.T,t,e.name,e.opt,n.emitDefaultValues);break;case"enum":i=this.enum(e.T(),t,e.name,e.opt,n.emitDefaultValues,n.enumAsInteger);break;case"message":i=this.message(e.T(),t,e.name,n);break}return i}enum(e,t,n,i,s,o){if(e[0]=="google.protobuf.NullValue")return!s&&!i?void 0:null;if(t===void 0){g(i);return}if(!(t===0&&!s&&!i))return g(typeof t=="number"),g(Number.isInteger(t)),o||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}message(e,t,n,i){return t===void 0?i.emitDefaultValues?null:void 0:e.internalJsonWrite(t,i)}scalar(e,t,n,i,s){if(t===void 0){g(i);return}let o=s||i;switch(e){case u.INT32:case u.SFIXED32:case u.SINT32:return t===0?o?0:void 0:(U(t),t);case u.FIXED32:case u.UINT32:return t===0?o?0:void 0:(L(t),t);case u.FLOAT:$(t);case u.DOUBLE:return t===0?o?0:void 0:(g(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case u.STRING:return t===""?o?"":void 0:(g(typeof t=="string"),t);case u.BOOL:return t===!1?o?!1:void 0:(g(typeof t=="boolean"),t);case u.UINT64:case u.FIXED64:g(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let a=O.from(t);return a.isZero()&&!o?void 0:a.toString();case u.INT64:case u.SFIXED64:case u.SINT64:g(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let l=b.from(t);return l.isZero()&&!o?void 0:l.toString();case u.BYTES:return g(t instanceof Uint8Array),t.byteLength?Zt(t):o?"":void 0}}};function Q(r,e=I.STRING){switch(r){case u.BOOL:return!1;case u.UINT64:case u.FIXED64:return N(O.ZERO,e);case u.INT64:case u.SFIXED64:case u.SINT64:return N(b.ZERO,e);case u.DOUBLE:case u.FLOAT:return 0;case u.BYTES:return new Uint8Array(0);case u.STRING:return"";default:return 0}}var we=class{constructor(e){this.info=e}prepare(){var e;if(!this.fieldNoToField){let t=(e=this.info.fields)!==null&&e!==void 0?e:[];this.fieldNoToField=new Map(t.map(n=>[n.no,n]))}}read(e,t,n,i){this.prepare();let s=i===void 0?e.len:e.pos+i;for(;e.pos<s;){let[o,a]=e.tag(),l=this.fieldNoToField.get(o);if(!l){let m=n.readUnknownField;if(m=="throw")throw new Error(`Unknown field ${o} (wire type ${a}) for ${this.info.typeName}`);let w=e.skip(a);m!==!1&&(m===!0?W.onRead:m)(this.info.typeName,t,o,a,w);continue}let c=t,f=l.repeat,p=l.localName;switch(l.oneof&&(c=c[l.oneof],c.oneofKind!==p&&(c=t[l.oneof]={oneofKind:p})),l.kind){case"scalar":case"enum":let m=l.kind=="enum"?u.INT32:l.T,w=l.kind=="scalar"?l.L:void 0;if(f){let _=c[p];if(a==F.LengthDelimited&&m!=u.STRING&&m!=u.BYTES){let X=e.uint32()+e.pos;for(;e.pos<X;)_.push(this.scalar(e,m,w))}else _.push(this.scalar(e,m,w))}else c[p]=this.scalar(e,m,w);break;case"message":if(f){let _=c[p],X=l.T().internalBinaryRead(e,e.uint32(),n);_.push(X)}else c[p]=l.T().internalBinaryRead(e,e.uint32(),n,c[p]);break;case"map":let[h,x]=this.mapEntry(l,e,n);c[p][h]=x;break}}}mapEntry(e,t,n){let i=t.uint32(),s=t.pos+i,o,a;for(;t.pos<s;){let[l,c]=t.tag();switch(l){case 1:e.K==u.BOOL?o=t.bool().toString():o=this.scalar(t,e.K,I.STRING);break;case 2:switch(e.V.kind){case"scalar":a=this.scalar(t,e.V.T,e.V.L);break;case"enum":a=t.int32();break;case"message":a=e.V.T().internalBinaryRead(t,t.uint32(),n);break}break;default:throw new Error(`Unknown field ${l} (wire type ${c}) in map entry for ${this.info.typeName}#${e.name}`)}}if(o===void 0){let l=Q(e.K);o=e.K==u.BOOL?l.toString():l}if(a===void 0)switch(e.V.kind){case"scalar":a=Q(e.V.T,e.V.L);break;case"enum":a=0;break;case"message":a=e.V.T().create();break}return[o,a]}scalar(e,t,n){switch(t){case u.INT32:return e.int32();case u.STRING:return e.string();case u.BOOL:return e.bool();case u.DOUBLE:return e.double();case u.FLOAT:return e.float();case u.INT64:return N(e.int64(),n);case u.UINT64:return N(e.uint64(),n);case u.FIXED64:return N(e.fixed64(),n);case u.FIXED32:return e.fixed32();case u.BYTES:return e.bytes();case u.UINT32:return e.uint32();case u.SFIXED32:return e.sfixed32();case u.SFIXED64:return N(e.sfixed64(),n);case u.SINT32:return e.sint32();case u.SINT64:return N(e.sint64(),n)}}};var Te=class{constructor(e){this.info=e}prepare(){if(!this.fields){let e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort((t,n)=>t.no-n.no)}}write(e,t,n){this.prepare();for(let s of this.fields){let o,a,l=s.repeat,c=s.localName;if(s.oneof){let f=e[s.oneof];if(f.oneofKind!==c)continue;o=f[c],a=!0}else o=e[c],a=!1;switch(s.kind){case"scalar":case"enum":let f=s.kind=="enum"?u.INT32:s.T;if(l)if(g(Array.isArray(o)),l==Z.PACKED)this.packed(t,f,s.no,o);else for(let p of o)this.scalar(t,f,s.no,p,!0);else o===void 0?g(s.opt):this.scalar(t,f,s.no,o,a||s.opt);break;case"message":if(l){g(Array.isArray(o));for(let p of o)this.message(t,n,s.T(),s.no,p)}else this.message(t,n,s.T(),s.no,o);break;case"map":g(typeof o=="object"&&o!==null);for(let[p,m]of Object.entries(o))this.mapEntry(t,n,s,p,m);break}}let i=n.writeUnknownFields;i!==!1&&(i===!0?W.onWrite:i)(this.info.typeName,e,t)}mapEntry(e,t,n,i,s){e.tag(n.no,F.LengthDelimited),e.fork();let o=i;switch(n.K){case u.INT32:case u.FIXED32:case u.UINT32:case u.SFIXED32:case u.SINT32:o=Number.parseInt(i);break;case u.BOOL:g(i=="true"||i=="false"),o=i=="true";break}switch(this.scalar(e,n.K,1,o,!0),n.V.kind){case"scalar":this.scalar(e,n.V.T,2,s,!0);break;case"enum":this.scalar(e,u.INT32,2,s,!0);break;case"message":this.message(e,t,n.V.T(),2,s);break}e.join()}message(e,t,n,i,s){s!==void 0&&(n.internalBinaryWrite(s,e.tag(i,F.LengthDelimited).fork(),t),e.join())}scalar(e,t,n,i,s){let[o,a,l]=this.scalarInfo(t,i);(!l||s)&&(e.tag(n,o),e[a](i))}packed(e,t,n,i){if(!i.length)return;g(t!==u.BYTES&&t!==u.STRING),e.tag(n,F.LengthDelimited),e.fork();let[,s]=this.scalarInfo(t);for(let o=0;o<i.length;o++)e[s](i[o]);e.join()}scalarInfo(e,t){let n=F.Varint,i,s=t===void 0,o=t===0;switch(e){case u.INT32:i="int32";break;case u.STRING:o=s||!t.length,n=F.LengthDelimited,i="string";break;case u.BOOL:o=t===!1,i="bool";break;case u.UINT32:i="uint32";break;case u.DOUBLE:n=F.Bit64,i="double";break;case u.FLOAT:n=F.Bit32,i="float";break;case u.INT64:o=s||b.from(t).isZero(),i="int64";break;case u.UINT64:o=s||O.from(t).isZero(),i="uint64";break;case u.FIXED64:o=s||O.from(t).isZero(),n=F.Bit64,i="fixed64";break;case u.BYTES:o=s||!t.byteLength,n=F.LengthDelimited,i="bytes";break;case u.FIXED32:n=F.Bit32,i="fixed32";break;case u.SFIXED32:n=F.Bit32,i="sfixed32";break;case u.SFIXED64:o=s||b.from(t).isZero(),n=F.Bit64,i="sfixed64";break;case u.SINT32:i="sint32";break;case u.SINT64:o=s||b.from(t).isZero(),i="sint64";break}return[n,i,s||o]}};function fr(r){let e=r.messagePrototype?Object.create(r.messagePrototype):Object.defineProperty({},de,{value:r});for(let t of r.fields){let n=t.localName;if(!t.opt)if(t.oneof)e[t.oneof]={oneofKind:void 0};else if(t.repeat)e[n]=[];else switch(t.kind){case"scalar":e[n]=Q(t.T,t.L);break;case"enum":e[n]=0;break;case"map":e[n]={};break}}return e}function Fe(r,e,t){let n,i=t,s;for(let o of r.fields){let a=o.localName;if(o.oneof){let l=i[o.oneof];if((l==null?void 0:l.oneofKind)==null)continue;if(n=l[a],s=e[o.oneof],s.oneofKind=l.oneofKind,n==null){delete s[a];continue}}else if(n=i[a],s=e,n==null)continue;switch(o.repeat&&(s[a].length=n.length),o.kind){case"scalar":case"enum":if(o.repeat)for(let c=0;c<n.length;c++)s[a][c]=n[c];else s[a]=n;break;case"message":let l=o.T();if(o.repeat)for(let c=0;c<n.length;c++)s[a][c]=l.create(n[c]);else s[a]===void 0?s[a]=l.create(n):l.mergePartial(s[a],n);break;case"map":switch(o.V.kind){case"scalar":case"enum":Object.assign(s[a],n);break;case"message":let c=o.V.T();for(let f of Object.keys(n))s[a][f]=c.create(n[f]);break}break}}}function hr(r,e,t){if(e===t)return!0;if(!e||!t)return!1;for(let n of r.fields){let i=n.localName,s=n.oneof?e[n.oneof][i]:e[i],o=n.oneof?t[n.oneof][i]:t[i];switch(n.kind){case"enum":case"scalar":let a=n.kind=="enum"?u.INT32:n.T;if(!(n.repeat?pr(a,s,o):dr(a,s,o)))return!1;break;case"map":if(!(n.V.kind=="message"?mr(n.V.T(),Oe(s),Oe(o)):pr(n.V.kind=="enum"?u.INT32:n.V.T,Oe(s),Oe(o))))return!1;break;case"message":let l=n.T();if(!(n.repeat?mr(l,s,o):l.equals(s,o)))return!1;break}}return!0}var Oe=Object.values;function dr(r,e,t){if(e===t)return!0;if(r!==u.BYTES)return!1;let n=e,i=t;if(n.length!==i.length)return!1;for(let s=0;s<n.length;s++)if(n[s]!=i[s])return!1;return!0}function pr(r,e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!dr(r,e[n],t[n]))return!1;return!0}function mr(r,e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!r.equals(e[n],t[n]))return!1;return!0}var Hr=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({})),T=class{constructor(e,t,n){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(ur),this.options=n!=null?n:{},this.messagePrototype=Object.create(null,Object.assign(Object.assign({},Hr),{[de]:{value:this}})),this.refTypeCheck=new ge(this),this.refJsonReader=new be(this),this.refJsonWriter=new ye(this),this.refBinReader=new we(this),this.refBinWriter=new Te(this)}create(e){let t=fr(this);return e!==void 0&&Fe(this,t,e),t}clone(e){let t=this.create();return Fe(this,t,e),t}equals(e,t){return hr(this,e,t)}is(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!1)}isAssignable(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!0)}mergePartial(e,t){Fe(this,e,t)}fromBinary(e,t){let n=rr(t);return this.internalBinaryRead(n.readerFactory(e),e.byteLength,n)}fromJson(e,t){return this.internalJsonRead(e,ar(t))}fromJsonString(e,t){let n=JSON.parse(e);return this.fromJson(n,t)}toJson(e,t){return this.internalJsonWrite(e,lr(t))}toJsonString(e,t){var n;let i=this.toJson(e,t);return JSON.stringify(i,null,(n=t==null?void 0:t.prettySpaces)!==null&&n!==void 0?n:0)}toBinary(e,t){let n=ir(t);return this.internalBinaryWrite(e,n.writerFactory(),n).finish()}internalJsonRead(e,t,n){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let i=n!=null?n:this.create();return this.refJsonReader.read(e,i,t),i}throw new Error(`Unable to parse message ${this.typeName} from JSON ${C(e)}.`)}internalJsonWrite(e,t){return this.refJsonWriter.write(e,t)}internalBinaryWrite(e,t,n){return this.refBinWriter.write(e,t,n),t}internalBinaryRead(e,t,n,i){let s=i!=null?i:this.create();return this.refBinReader.read(e,s,n,t),s}};var Ye=class extends T{constructor(){super("google.protobuf.Timestamp",[{no:1,name:"seconds",kind:"scalar",T:3,L:0},{no:2,name:"nanos",kind:"scalar",T:5}])}now(){let e=this.create(),t=Date.now();return e.seconds=b.from(Math.floor(t/1e3)).toBigInt(),e.nanos=t%1e3*1e6,e}toDate(e){return new Date(b.from(e.seconds).toNumber()*1e3+Math.ceil(e.nanos/1e6))}fromDate(e){let t=this.create(),n=e.getTime();return t.seconds=b.from(Math.floor(n/1e3)).toBigInt(),t.nanos=n%1e3*1e6,t}internalJsonWrite(e,t){let n=b.from(e.seconds).toNumber()*1e3;if(n<Date.parse("0001-01-01T00:00:00Z")||n>Date.parse("9999-12-31T23:59:59Z"))throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");if(e.nanos<0)throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");let i="Z";if(e.nanos>0){let s=(e.nanos+1e9).toString().substring(1);s.substring(3)==="000000"?i="."+s.substring(0,3)+"Z":s.substring(6)==="000"?i="."+s.substring(0,6)+"Z":i="."+s+"Z"}return new Date(n).toISOString().replace(".000Z",i)}internalJsonRead(e,t,n){if(typeof e!="string")throw new Error("Unable to parse Timestamp from JSON "+C(e)+".");let i=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!i)throw new Error("Unable to parse Timestamp from JSON. Invalid format.");let s=Date.parse(i[1]+"-"+i[2]+"-"+i[3]+"T"+i[4]+":"+i[5]+":"+i[6]+(i[8]?i[8]:"Z"));if(Number.isNaN(s))throw new Error("Unable to parse Timestamp from JSON. Invalid value.");if(s<Date.parse("0001-01-01T00:00:00Z")||s>Date.parse("9999-12-31T23:59:59Z"))throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");return n||(n=this.create()),n.seconds=b.from(s/1e3).toBigInt(),n.nanos=0,i[7]&&(n.nanos=parseInt("1"+i[7]+"0".repeat(9-i[7].length))-1e9),n}},et=new Ye;var br=(n=>(n[n.UNKNOWN=0]="UNKNOWN",n[n.PATH=1]="PATH",n[n.CMD=2]="CMD",n))(br||{}),yr=(i=>(i[i.UNSPECIFIED=0]="UNSPECIFIED",i[i.CANCELLED=1]="CANCELLED",i[i.CANCELLING=2]="CANCELLING",i[i.NOT_CANCELLABLE=3]="NOT_CANCELLABLE",i))(yr||{}),tt=class extends T{constructor(){super("arrow.flight.protocol.HandshakeRequest",[{no:1,name:"protocol_version",kind:"scalar",T:4,L:0},{no:2,name:"payload",kind:"scalar",T:12}])}},Gr=new tt,rt=class extends T{constructor(){super("arrow.flight.protocol.HandshakeResponse",[{no:1,name:"protocol_version",kind:"scalar",T:4,L:0},{no:2,name:"payload",kind:"scalar",T:12}])}},Kr=new rt,nt=class extends T{constructor(){super("arrow.flight.protocol.BasicAuth",[{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"password",kind:"scalar",T:9}])}},Ps=new nt,it=class extends T{constructor(){super("arrow.flight.protocol.Empty",[])}},Zr=new it,st=class extends T{constructor(){super("arrow.flight.protocol.ActionType",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}])}},Qr=new st,ot=class extends T{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}},zr=new ot,at=class extends T{constructor(){super("arrow.flight.protocol.Action",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"body",kind:"scalar",T:12}])}},Yr=new at,lt=class extends T{constructor(){super("arrow.flight.protocol.CancelFlightInfoRequest",[{no:1,name:"info",kind:"message",T:()=>Ie}])}},As=new lt,ut=class extends T{constructor(){super("arrow.flight.protocol.RenewFlightEndpointRequest",[{no:1,name:"endpoint",kind:"message",T:()=>wr}])}},Us=new ut,ct=class extends T{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}},en=new ct,ft=class extends T{constructor(){super("arrow.flight.protocol.CancelFlightInfoResult",[{no:1,name:"status",kind:"enum",T:()=>["arrow.flight.protocol.CancelStatus",yr,"CANCEL_STATUS_"]}])}},Ds=new ft,pt=class extends T{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}},tn=new pt,mt=class extends T{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",br]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}},q=new mt,ht=class extends T{constructor(){super("arrow.flight.protocol.FlightInfo",[{no:1,name:"schema",kind:"scalar",T:12},{no:2,name:"flight_descriptor",kind:"message",T:()=>q},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>wr},{no:4,name:"total_records",kind:"scalar",T:3,L:0},{no:5,name:"total_bytes",kind:"scalar",T:3,L:0},{no:6,name:"ordered",kind:"scalar",T:8},{no:7,name:"app_metadata",kind:"scalar",T:12}])}},Ie=new ht,dt=class extends T{constructor(){super("arrow.flight.protocol.PollInfo",[{no:1,name:"info",kind:"message",T:()=>Ie},{no:2,name:"flight_descriptor",kind:"message",T:()=>q},{no:3,name:"progress",kind:"scalar",opt:!0,T:1},{no:4,name:"expiration_time",kind:"message",T:()=>et}])}},rn=new dt,gt=class extends T{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>Ne},{no:2,name:"location",kind:"message",repeat:1,T:()=>nn},{no:3,name:"expiration_time",kind:"message",T:()=>et},{no:4,name:"app_metadata",kind:"scalar",T:12}])}},wr=new gt,bt=class extends T{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}},nn=new bt,yt=class extends T{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}},Ne=new yt,wt=class extends T{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>q},{no:2,name:"data_header",kind:"scalar",T:12},{no:3,name:"app_metadata",kind:"scalar",T:12},{no:1e3,name:"data_body",kind:"scalar",T:12}])}},xe=new wt,Tt=class extends T{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}},sn=new Tt,Ee=new gr.ServiceType("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:Gr,O:Kr},{name:"ListFlights",serverStreaming:!0,options:{},I:zr,O:Ie},{name:"GetFlightInfo",options:{},I:q,O:Ie},{name:"PollFlightInfo",options:{},I:q,O:rn},{name:"GetSchema",options:{},I:q,O:tn},{name:"DoGet",serverStreaming:!0,options:{},I:Ne,O:xe},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:xe,O:sn},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:xe,O:xe},{name:"DoAction",serverStreaming:!0,options:{},I:Yr,O:en},{name:"ListActions",serverStreaming:!0,options:{},I:Zr,O:Qr}]);var E=require("@protobuf-ts/runtime-rpc");var _e=class{constructor(e){this._transport=e;d(this,"typeName",Ee.typeName);d(this,"methods",Ee.methods);d(this,"options",Ee.options)}handshake(e){let t=this.methods[0],n=this._transport.mergeOptions(e);return(0,E.stackIntercept)("duplex",this._transport,t,n)}listFlights(e,t){let n=this.methods[1],i=this._transport.mergeOptions(t);return(0,E.stackIntercept)("serverStreaming",this._transport,n,i,e)}getFlightInfo(e,t){let n=this.methods[2],i=this._transport.mergeOptions(t);return(0,E.stackIntercept)("unary",this._transport,n,i,e)}pollFlightInfo(e,t){let n=this.methods[3],i=this._transport.mergeOptions(t);return(0,E.stackIntercept)("unary",this._transport,n,i,e)}getSchema(e,t){let n=this.methods[4],i=this._transport.mergeOptions(t);return(0,E.stackIntercept)("unary",this._transport,n,i,e)}doGet(e,t){let n=this.methods[5],i=this._transport.mergeOptions(t);return(0,E.stackIntercept)("serverStreaming",this._transport,n,i,e)}doPut(e){let t=this.methods[6],n=this._transport.mergeOptions(e);return(0,E.stackIntercept)("duplex",this._transport,t,n)}doExchange(e){let t=this.methods[7],n=this._transport.mergeOptions(e);return(0,E.stackIntercept)("duplex",this._transport,t,n)}doAction(e,t){let n=this.methods[8],i=this._transport.mergeOptions(t);return(0,E.stackIntercept)("serverStreaming",this._transport,n,i,e)}listActions(e,t){let n=this.methods[9],i=this._transport.mergeOptions(t);return(0,E.stackIntercept)("serverStreaming",this._transport,n,i,e)}};var Tr=/\$(\w+)/g;function Fr(r){return!!r.match(Tr)}function Or(r,e){let t=r.match(Tr);if(t)for(let n of t)e[n.trim().replace("$","")]||v(new Error(`No parameter matching ${n} provided in the query params map`));return!0}var xr=require("apache-arrow/enum");function Ft(r,e){if(e==null)return null;let t=r.metadata.get("iox::column::type");if(!t||r.typeId===xr.Type.Timestamp)return e;let[,,n,i]=t.split("::");if(n==="field")switch(i){case"integer":return M(e)?parseInt(e):(console.warn(`Value ${e} is not an integer`),e);case"uinteger":return Vt(e)?parseInt(e):(console.warn(`Value ${e} is not an unsigned integer`),e);case"float":return M(e)?parseFloat(e):(console.warn(`Value ${e} is not a float`),e);case"boolean":return typeof e=="boolean"||console.warn(`Value ${e} is not a boolean`),e;case"string":return typeof e=="string"?String(e):(console.warn(`Value ${e} is not a string`),e);default:return e}return e}var z=class{constructor(e){this._options=e;d(this,"_closed",!1);d(this,"_flightClient");d(this,"_transport");d(this,"_defaultHeaders");let{host:t,queryTimeout:n}=this._options;this._defaultHeaders=this._options.headers,this._transport=G.queryTransport({host:t,timeout:n}),this._flightClient=new _e(this._transport)}prepareTicket(e,t,n){let i={database:e,sql_query:t,query_type:n.type};if(n.params){let s={};for(let o of Object.keys(n.params))n.params[o]&&(s[o]=n.params[o]);i.params=s}return Ne.create({ticket:new TextEncoder().encode(JSON.stringify(i))})}prepareMetadata(e){let t={"User-Agent":oe,...this._defaultHeaders,...e},n=this._options.token;return n&&(t.authorization=`Bearer ${n}`),t}async*_queryRawBatches(e,t,n){if(n.params&&Fr(e)&&Or(e,n.params),this._closed)throw new Error("queryApi: already closed!");let i=this._flightClient,s=this.prepareTicket(t,e,n),a={meta:this.prepareMetadata(n.headers)},l=i.doGet(s,a),c=async function*(){for await(let p of l.responses)yield Lt(p.dataHeader.length),yield p.dataHeader,yield p.dataBody}();yield*await ke.RecordBatchReader.from(c)}async*query(e,t,n){let i=this._queryRawBatches(e,t,n);for await(let s of i)for(let o of s){let a={};for(let l of s.schema.fields){let c=o[l.name];a[l.name]=Ft(l,c)}yield a}}async*queryPoints(e,t,n){var s;let i=this._queryRawBatches(e,t,n);for await(let o of i)for(let a=0;a<o.numRows;a++){let l=new A;for(let c=0;c<o.numCols;c++){let f=o.schema.fields[c],p=f.name,m=(s=o.getChildAt(c))==null?void 0:s.get(a),w=f.typeId,h=f.metadata.get("iox::column::type");if(m==null)continue;if((p==="measurement"||p=="iox::measurement")&&typeof m=="string"){l.setMeasurement(m);continue}if(!h){p==="time"&&w===ke.Type.Timestamp?l.setTimestamp(m):l.setField(p,m);continue}let[,,x,_]=h.split("::");if(x==="field"){if(_&&m!==void 0&&m!==null){let X=Ft(f,m);l.setField(p,X,_)}}else x==="tag"?l.setTag(p,m):x==="timestamp"&&l.setTimestamp(m)}yield l}}async close(){var e,t;this._closed=!0,(t=(e=this._transport).close)==null||t.call(e)}};var Ot=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
6
+ `,Y=class{constructor(...e){d(this,"_options");d(this,"_writeApi");d(this,"_queryApi");d(this,"_mergeWriteOptions",e=>{var i;let t={...(i=this._options.writeOptions)==null?void 0:i.headers,...e==null?void 0:e.headers},n={...this._options.writeOptions,...e};return n.headers=t,n});d(this,"_mergeQueryOptions",e=>{var s,o;let t={...(s=this._options.queryOptions)==null?void 0:s.headers,...e==null?void 0:e.headers},n={...(o=this._options.queryOptions)==null?void 0:o.params,...e==null?void 0:e.params},i={...this._options.queryOptions,...e};return i.headers=t,i.params=n,i});let t;switch(e.length){case 0:{t=Ae();break}case 1:{if(e[0]==null)throw new P("No configuration specified!");typeof e[0]=="string"?t=Pe(e[0]):t=e[0];break}default:throw new P("Multiple arguments specified!")}this._options={...Se,...t};let n=this._options.host;if(typeof n!="string")throw new P("No host specified!");if(n.endsWith("/")&&(this._options.host=n.substring(0,n.length-1)),typeof this._options.token!="string")throw new P("No token specified!");this._queryApi=new z(this._options),this._writeApi=new K(this._options)}async write(e,t,n,i){var o;let s=this._mergeWriteOptions(i);await this._writeApi.doWrite($e(e,s==null?void 0:s.defaultTags),(o=t!=null?t:this._options.database)!=null?o:v(new Error(Ot)),n,s)}query(e,t,n=(i=>(i=this._options.queryOptions)!=null?i:te)()){var o;let s=this._mergeQueryOptions(n);return this._queryApi.query(e,(o=t!=null?t:this._options.database)!=null?o:v(new Error(Ot)),s)}queryPoints(e,t,n=(i=>(i=this._options.queryOptions)!=null?i:te)()){var o;let s=this._mergeQueryOptions(n);return this._queryApi.queryPoints(e,(o=t!=null?t:this._options.database)!=null?o:v(new Error(Ot)),s)}async close(){await this._writeApi.close(),await this._queryApi.close()}};0&&(module.exports={AbortError,DEFAULT_ConnectionOptions,DEFAULT_QueryOptions,DEFAULT_WriteOptions,GetFieldTypeMissmatchError,HttpError,IllegalArgumentError,InfluxDBClient,Log,Point,PointValues,RequestTimedOutError,collectAll,consoleLogger,convertTime,convertTimeToNanos,createTextDecoderCombiner,currentTime,dateToProtocolTimestamp,escape,fromConnectionString,fromEnv,isNumber,parsePrecision,precisionToV2ApiString,precisionToV3ApiString,setLogger,useProcessHrtime,writableDataToLineProtocol});
7
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.gz CHANGED
Binary file