@influxdata/influxdb3-client 0.1.0-nightly.760

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.
@@ -0,0 +1,478 @@
1
+ /** IllegalArgumentError is thrown when illegal argument is supplied. */
2
+ declare class IllegalArgumentError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ /**
6
+ * A general HTTP error.
7
+ */
8
+ declare class HttpError extends Error {
9
+ readonly statusCode: number;
10
+ readonly statusMessage: string | undefined;
11
+ readonly body?: string | undefined;
12
+ readonly contentType?: string | null | undefined;
13
+ /** application error code, when available */
14
+ code: string | undefined;
15
+ /** json error response */
16
+ json: any;
17
+ constructor(statusCode: number, statusMessage: string | undefined, body?: string | undefined, contentType?: string | null | undefined, message?: string);
18
+ }
19
+ /** RequestTimedOutError indicates request timeout in the communication with the server */
20
+ declare class RequestTimedOutError extends Error {
21
+ constructor();
22
+ }
23
+ /** AbortError indicates that the communication with the server was aborted */
24
+ declare class AbortError extends Error {
25
+ constructor();
26
+ }
27
+
28
+ /**
29
+ * ChunkCombiner is a simplified platform-neutral manipulation of Uint8arrays
30
+ * that allows to process text data on the fly. The implementation can be optimized
31
+ * for the target platform (node vs browser).
32
+ */
33
+ interface ChunkCombiner {
34
+ /**
35
+ * Concatenates first and second chunk.
36
+ * @param first - first chunk
37
+ * @param second - second chunk
38
+ * @returns first + second
39
+ */
40
+ concat(first: Uint8Array, second: Uint8Array): Uint8Array;
41
+ /**
42
+ * Converts chunk into a string.
43
+ * @param chunk - chunk
44
+ * @param start - start index
45
+ * @param end - end index
46
+ * @returns string representation of chunk slice
47
+ */
48
+ toUtf8String(chunk: Uint8Array, start: number, end: number): string;
49
+ /**
50
+ * Creates a new chunk from the supplied chunk.
51
+ * @param chunk - chunk to copy
52
+ * @param start - start index
53
+ * @param end - end index
54
+ * @returns a copy of a chunk slice
55
+ */
56
+ copy(chunk: Uint8Array, start: number, end: number): Uint8Array;
57
+ }
58
+ /**
59
+ * Creates a chunk combiner instance that uses UTF-8
60
+ * TextDecoder to decode Uint8Arrays into strings.
61
+ */
62
+ declare function createTextDecoderCombiner(): ChunkCombiner;
63
+
64
+ /**
65
+ * Allows to cancel a running execution.
66
+ */
67
+ interface Cancellable {
68
+ /**
69
+ * Cancels execution.
70
+ */
71
+ cancel(): void;
72
+ isCancelled(): boolean;
73
+ }
74
+
75
+ /**
76
+ * Type of HTTP headers.
77
+ */
78
+ type HttpHeaders = {
79
+ [header: string]: string | string[] | undefined;
80
+ };
81
+
82
+ /**
83
+ * Informs about a start of response processing.
84
+ * @param headers - response HTTP headers
85
+ * @param statusCode - response status code
86
+ */
87
+ type ResponseStartedFn = (headers: HttpHeaders, statusCode?: number) => void;
88
+ /**
89
+ * Observes communication with the server.
90
+ */
91
+ interface CommunicationObserver<T> {
92
+ /**
93
+ * Data chunk received, can be called multiple times.
94
+ * @param data - data
95
+ * @returns when `false` value is returned and {@link CommunicationObserver.useResume} is defined,
96
+ * future calls to `next` are paused until resume is called.
97
+ */
98
+ next(data: T): void | boolean;
99
+ /**
100
+ * Communication ended with an error.
101
+ */
102
+ error(error: Error): void;
103
+ /**
104
+ * Communication was successful.
105
+ */
106
+ complete(): void;
107
+ /**
108
+ * Informs about a start of response processing.
109
+ */
110
+ responseStarted?: ResponseStartedFn;
111
+ /**
112
+ * Setups cancelllable for this communication.
113
+ */
114
+ useCancellable?: (cancellable: Cancellable) => void;
115
+ /**
116
+ * Setups a callback that resumes reading of next data, it is called whenever
117
+ * {@link CommunicationObserver.next} returns `false`.
118
+ *
119
+ * @param resume - a function that will resume reading of next data when called
120
+ */
121
+ useResume?: (resume: () => void) => void;
122
+ }
123
+
124
+ /**
125
+ * Options for sending a request message.
126
+ */
127
+ interface SendOptions {
128
+ /** HTTP method (POST, PUT, GET, PATCH ...) */
129
+ method: string;
130
+ /** Request HTTP headers. */
131
+ headers?: {
132
+ [key: string]: string;
133
+ };
134
+ /** When specified, message body larger than the treshold is gzipped */
135
+ gzipThreshold?: number;
136
+ /** Abort signal */
137
+ signal?: AbortSignal;
138
+ }
139
+ /**
140
+ * Simpified platform-neutral transport layer for communication with InfluxDB.
141
+ */
142
+ interface Transport {
143
+ /**
144
+ * Send data to the server and receive communication events via callbacks.
145
+ *
146
+ * @param path - HTTP request path
147
+ * @param requestBody - HTTP request body
148
+ * @param options - send options
149
+ * @param callbacks - communication callbacks to received data in Uint8Array
150
+ */
151
+ send(path: string, requestBody: string, options: SendOptions, callbacks?: Partial<CommunicationObserver<Uint8Array>>): void;
152
+ /**
153
+ * Sends data to the server and receives decoded result. The type of the result depends on
154
+ * response's content-type (deserialized json, text).
155
+
156
+ * @param path - HTTP request path
157
+ * @param requestBody - request body
158
+ * @param options - send options
159
+ * @returns response data
160
+ */
161
+ request(path: string, requestBody: any, options: SendOptions, responseStarted?: ResponseStartedFn): Promise<any>;
162
+ /**
163
+ * Sends requestBody and returns response chunks in an async iterable
164
+ * that can be easily consumed in an `for-await` loop.
165
+ *
166
+ * @param path - HTTP request path
167
+ * @param requestBody - request body
168
+ * @param options - send options
169
+ * @returns async iterable
170
+ */
171
+ iterate(path: string, requestBody: any, options: SendOptions): AsyncIterableIterator<Uint8Array>;
172
+ }
173
+
174
+ /**
175
+ * Option for the communication with InfluxDB server.
176
+ */
177
+ interface ConnectionOptions {
178
+ /** base host URL */
179
+ host: string;
180
+ /** authentication token */
181
+ token?: string;
182
+ /**
183
+ * socket timeout, 10000 milliseconds by default in node.js
184
+ * @defaultValue 10000
185
+ */
186
+ timeout?: number;
187
+ /**
188
+ * default database for write query if not present as argument.
189
+ */
190
+ database?: string;
191
+ /**
192
+ * TransportOptions supply extra options for the transport layer, they differ between node.js and browser/deno.
193
+ * Node.js transport accepts options specified in {@link https://nodejs.org/api/http.html#http_http_request_options_callback | http.request } or
194
+ * {@link https://nodejs.org/api/https.html#https_https_request_options_callback | https.request }. For example, an `agent` property can be set to
195
+ * {@link https://www.npmjs.com/package/proxy-http-agent | setup HTTP/HTTPS proxy }, {@link https://nodejs.org/api/tls.html#tls_tls_connect_options_callback | rejectUnauthorized }
196
+ * property can disable TLS server certificate verification. Additionally,
197
+ * {@link https://github.com/follow-redirects/follow-redirects | follow-redirects } property can be also specified
198
+ * in order to follow redirects in node.js.
199
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch | fetch } is used under the hood in browser/deno.
200
+ * For example,
201
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch | redirect } property can be set to 'error' to abort request if a redirect occurs.
202
+ */
203
+ transportOptions?: {
204
+ [key: string]: any;
205
+ };
206
+ /**
207
+ * Default HTTP headers to send with every request.
208
+ */
209
+ headers?: Record<string, string>;
210
+ /**
211
+ * Full HTTP web proxy URL including schema, for example http://your-proxy:8080.
212
+ */
213
+ proxyUrl?: string;
214
+ }
215
+ /** default connection options */
216
+ declare const DEFAULT_ConnectionOptions: Partial<ConnectionOptions>;
217
+ /**
218
+ * Options used by {@link InfluxDBClient.write} .
219
+ */
220
+ interface WriteOptions {
221
+ /** Precision to use in writes for timestamp. default ns */
222
+ precision: WritePrecision;
223
+ /** HTTP headers that will be sent with every write request */
224
+ headers?: {
225
+ [key: string]: string;
226
+ };
227
+ /** When specified, write bodies larger than the threshold are gzipped */
228
+ gzipThreshold?: number;
229
+ /** InfluxDB Enterprise write consistency as explained in https://docs.influxdata.com/enterprise_influxdb/v1.9/concepts/clustering/#write-consistency */
230
+ consistency?: 'any' | 'one' | 'quorum' | 'all';
231
+ }
232
+ /** default writeOptions */
233
+ declare const DEFAULT_WriteOptions: WriteOptions;
234
+ type QueryType = 'sql' | 'influxql';
235
+ /**
236
+ * Options used by {@link InfluxDBClient} .
237
+ */
238
+ interface ClientOptions extends ConnectionOptions {
239
+ /** supplies and overrides default writing options */
240
+ writeOptions?: Partial<WriteOptions>;
241
+ /** specifies custom transport */
242
+ transport?: Transport;
243
+ }
244
+ /**
245
+ * Timestamp precision used in write operations.
246
+ * See {@link https://docs.influxdata.com/influxdb/latest/api/#operation/PostWrite }
247
+ */
248
+ type WritePrecision = 'ns' | 'us' | 'ms' | 's';
249
+
250
+ /**
251
+ * Logging interface.
252
+ */
253
+ interface Logger {
254
+ error(message: string, err?: any): void;
255
+ warn(message: string, err?: any): void;
256
+ }
257
+ /**
258
+ * Logger that logs to console.out
259
+ */
260
+ declare const consoleLogger: Logger;
261
+ declare const Log: Logger;
262
+ /**
263
+ * Sets custom logger.
264
+ * @param logger - logger to use
265
+ * @returns previous logger
266
+ */
267
+ declare function setLogger(logger: Logger): Logger;
268
+
269
+ /**
270
+ * Provides functions escape specific parts in InfluxDB line protocol.
271
+ */
272
+ declare const escape: {
273
+ /**
274
+ * Measurement escapes measurement names.
275
+ */
276
+ measurement: (value: string) => string;
277
+ /**
278
+ * Quoted escapes quoted values, such as database names.
279
+ */
280
+ quoted: (value: string) => string;
281
+ /**
282
+ * TagEscaper escapes tag keys, tag values, and field keys.
283
+ */
284
+ tag: (value: string) => string;
285
+ };
286
+
287
+ declare function useProcessHrtime(use: boolean): boolean;
288
+ /**
289
+ * Exposes functions that creates strings that represent a timestamp that
290
+ * can be used in the line protocol. Micro and nano timestamps are emulated
291
+ * depending on the js platform in use.
292
+ */
293
+ declare const currentTime: {
294
+ s: () => string;
295
+ ms: () => string;
296
+ us: () => string;
297
+ ns: () => string;
298
+ seconds: () => string;
299
+ millis: () => string;
300
+ micros: () => string;
301
+ nanos: () => string;
302
+ };
303
+ /**
304
+ * dateToProtocolTimestamp provides converters for JavaScript Date to InfluxDB Write Protocol Timestamp. Keys are supported precisions.
305
+ */
306
+ declare const dateToProtocolTimestamp: {
307
+ s: (d: Date) => string;
308
+ ms: (d: Date) => string;
309
+ us: (d: Date) => string;
310
+ ns: (d: Date) => string;
311
+ };
312
+ /**
313
+ * convertTimeToNanos converts Point's timestamp to a string.
314
+ * @param value - supported timestamp value
315
+ * @returns line protocol value
316
+ */
317
+ declare function convertTimeToNanos(value: string | number | Date | undefined): string | undefined;
318
+ declare const convertTime: (value: string | number | Date | undefined, precision?: WritePrecision) => string | undefined;
319
+
320
+ interface TimeConverter {
321
+ (value: string | number | Date | undefined): string | undefined;
322
+ }
323
+
324
+ type PointRecord = {
325
+ measurement: string;
326
+ fields: Record<string, number | string>;
327
+ tags?: Record<string, string>;
328
+ timestamp?: string | number | Date;
329
+ };
330
+ /**
331
+ * Point defines values of a single measurement.
332
+ */
333
+ declare class Point {
334
+ private name;
335
+ private tags;
336
+ /** escaped field values */
337
+ fields: {
338
+ [key: string]: string;
339
+ };
340
+ private time;
341
+ /**
342
+ * Create a new Point with specified a measurement name.
343
+ *
344
+ * @param measurementName - the measurement name
345
+ */
346
+ constructor(measurementName?: string);
347
+ /**
348
+ * Sets point's measurement.
349
+ *
350
+ * @param name - measurement name
351
+ * @returns this
352
+ */
353
+ measurement(name: string): Point;
354
+ /**
355
+ * Adds a tag. The caller has to ensure that both name and value are not empty
356
+ * and do not end with backslash.
357
+ *
358
+ * @param name - tag name
359
+ * @param value - tag value
360
+ * @returns this
361
+ */
362
+ tag(name: string, value: string): Point;
363
+ /**
364
+ * Adds a boolean field.
365
+ *
366
+ * @param field - field name
367
+ * @param value - field value
368
+ * @returns this
369
+ */
370
+ booleanField(name: string, value: boolean | any): Point;
371
+ /**
372
+ * Adds an integer field.
373
+ *
374
+ * @param name - field name
375
+ * @param value - field value
376
+ * @returns this
377
+ * @throws NaN or out of int64 range value is supplied
378
+ */
379
+ intField(name: string, value: number | any): Point;
380
+ /**
381
+ * Adds an unsigned integer field.
382
+ *
383
+ * @param name - field name
384
+ * @param value - field value
385
+ * @returns this
386
+ * @throws NaN out of range value is supplied
387
+ */
388
+ uintField(name: string, value: number | any): Point;
389
+ /**
390
+ * Adds a number field.
391
+ *
392
+ * @param name - field name
393
+ * @param value - field value
394
+ * @returns this
395
+ * @throws NaN/Infinity/-Infinity is supplied
396
+ */
397
+ floatField(name: string, value: number | any): Point;
398
+ /**
399
+ * Adds a string field.
400
+ *
401
+ * @param name - field name
402
+ * @param value - field value
403
+ * @returns this
404
+ */
405
+ stringField(name: string, value: string | any): Point;
406
+ /**
407
+ * Sets point timestamp. Timestamp can be specified as a Date (preferred), number, string
408
+ * or an undefined value. An undefined value instructs to assign a local timestamp using
409
+ * the client's clock. An empty string can be used to let the server assign
410
+ * the timestamp. A number value represents time as a count of time units since epoch, the
411
+ * exact time unit then depends on the {@link InfluxDBClient.write | precision} of the API
412
+ * that writes the point.
413
+ *
414
+ * Beware that the current time in nanoseconds can't precisely fit into a JS number,
415
+ * which can hold at most 2^53 integer number. Nanosecond precision numbers are thus supplied as
416
+ * a (base-10) string. An application can also use ES2020 BigInt to represent nanoseconds,
417
+ * BigInt's `toString()` returns the required high-precision string.
418
+ *
419
+ * Note that InfluxDB requires the timestamp to fit into int64 data type.
420
+ *
421
+ * @param value - point time
422
+ * @returns this
423
+ */
424
+ timestamp(value: Date | number | string | undefined): Point;
425
+ /**
426
+ * Creates an InfluxDB protocol line out of this instance.
427
+ * @param settings - settings control serialization of a point timestamp and can also add default tags,
428
+ * nanosecond timestamp precision is used when no `settings` or no `settings.convertTime` is supplied.
429
+ * @returns an InfluxDB protocol line out of this instance
430
+ */
431
+ toLineProtocol(convertTimePrecision?: TimeConverter | WritePrecision): string | undefined;
432
+ toString(): string;
433
+ static fromRecord(record: PointRecord): Point;
434
+ }
435
+
436
+ /** Prevents confusion with the ArrayLike type. Use with PointRecord */
437
+ type NotArrayLike<T> = T & {
438
+ length?: string;
439
+ };
440
+ /** Prevents confusion with the PointRecord type. */
441
+ type NotPointRecord<T> = T & {
442
+ measurement?: void;
443
+ };
444
+ /**
445
+ * The `WritableData` type represents different types of data that can be written.
446
+ * The data can either be a uniform ArrayLike collection or a single value of the following types:
447
+ *
448
+ * - `Point`: Represents a {@link Point} object.
449
+ *
450
+ * - `string`: Represents lines of the [Line Protocol](https://bit.ly/2QL99fu).
451
+ *
452
+ * - `PointRecord`: Represents an anonymous object. Note that a single `PointRecord`
453
+ * should not have a property of name length, as it could be misinterpreted as ArrayLike.
454
+ * If unsure, encapsulate your record in an array, i.e. [record].
455
+ */
456
+ type WritableData = NotPointRecord<ArrayLike<string> | ArrayLike<Point> | ArrayLike<PointRecord>> | NotArrayLike<PointRecord> | string | Point;
457
+ declare const writableDataToLineProtocol: (data: WritableData) => string[];
458
+
459
+ /**
460
+ * `InfluxDBClient` for interacting with an InfluxDB server, simplifying common operations such as writing, querying.
461
+ */
462
+ declare class InfluxDBClient {
463
+ private readonly _options;
464
+ private readonly _writeApi;
465
+ private readonly _queryApi;
466
+ readonly transport: Transport;
467
+ /**
468
+ * Creates a new instance of the `InfluxDBClient` for interacting with an InfluxDB server, simplifying common operations such as writing, querying.
469
+ * @param options - client options
470
+ */
471
+ constructor(options: ClientOptions);
472
+ private _mergeWriteOptions;
473
+ write(data: WritableData, database?: string, org?: string, writeOptions?: Partial<WriteOptions>): Promise<void>;
474
+ query(query: string, database?: string, queryType?: QueryType): AsyncGenerator<Record<string, any>, void, void>;
475
+ close(): Promise<void>;
476
+ }
477
+
478
+ export { AbortError, Cancellable, ChunkCombiner, ClientOptions, CommunicationObserver, ConnectionOptions, DEFAULT_ConnectionOptions, DEFAULT_WriteOptions, HttpHeaders as Headers, HttpError, HttpHeaders, IllegalArgumentError, InfluxDBClient, Log, Logger, NotArrayLike, NotPointRecord, Point, PointRecord, QueryType, RequestTimedOutError, ResponseStartedFn, SendOptions, TimeConverter, Transport, WritableData, WriteOptions, WritePrecision, consoleLogger, convertTime, convertTimeToNanos, createTextDecoderCombiner, currentTime, dateToProtocolTimestamp, escape, setLogger, useProcessHrtime, writableDataToLineProtocol };
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";var Yt=Object.create;var Y=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var er=Object.getPrototypeOf,tr=Object.prototype.hasOwnProperty;var rr=(i,e)=>{for(var t in e)Y(i,t,{get:e[t],enumerable:!0})},tt=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Qt(e))!tr.call(i,n)&&n!==t&&Y(i,n,{get:()=>e[n],enumerable:!(r=zt(e,n))||r.enumerable});return i};var j=(i,e,t)=>(t=i!=null?Yt(er(i)):{},tt(e||!i||!i.__esModule?Y(t,"default",{value:i,enumerable:!0}):t,i)),nr=i=>tt(Y({},"__esModule",{value:!0}),i);var Rr={};rr(Rr,{AbortError:()=>C,DEFAULT_ConnectionOptions:()=>be,DEFAULT_WriteOptions:()=>we,HttpError:()=>S,IllegalArgumentError:()=>W,InfluxDBClient:()=>Z,Log:()=>V,Point:()=>M,RequestTimedOutError:()=>$,consoleLogger:()=>rt,convertTime:()=>Te,convertTimeToNanos:()=>Re,createTextDecoderCombiner:()=>ir,currentTime:()=>ft,dateToProtocolTimestamp:()=>ct,escape:()=>P,setLogger:()=>sr,useProcessHrtime:()=>lt,writableDataToLineProtocol:()=>Ne});module.exports=nr(Rr);var W=class i extends Error{constructor(e){super(e),this.name="IllegalArgumentError",Object.setPrototypeOf(this,i.prototype)}},S=class i extends Error{constructor(t,r,n,s,o){super();this.statusCode=t;this.statusMessage=r;this.body=n;this.contentType=s;if(Object.setPrototypeOf(this,i.prototype),o)this.message=o;else if(n){if(s!=null&&s.startsWith("application/json"))try{this.json=JSON.parse(n),this.message=this.json.message,this.code=this.json.code}catch(a){}this.message||(this.message=`${t} ${r} : ${n}`)}else this.message=`${t} ${r}`;this.name="HttpError"}},$=class i extends Error{constructor(){super(),Object.setPrototypeOf(this,i.prototype),this.name="RequestTimedOutError",this.message="Request timed out"}},C=class i extends Error{constructor(){super(),this.name="AbortError",Object.setPrototypeOf(this,i.prototype),this.message="Response aborted"}};function ir(){let i=new TextDecoder("utf-8");return{concat(e,t){let r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r},copy(e,t,r){let n=new Uint8Array(r-t);return n.set(e.subarray(t,r)),n},toUtf8String(e,t,r){return i.decode(e.subarray(t,r))}}}var be={timeout:1e4},we={precision:"ns",gzipThreshold:1e3};var rt={error(i,e){console.error(`ERROR: ${i}`,e||"")},warn(i,e){console.warn(`WARN: ${i}`,e||"")}},z=rt,V={error(i,e){z.error(i,e)},warn(i,e){z.warn(i,e)}};function sr(i){let e=z;return z=i,e}function ke(i,e){return function(t){let r="",n=0,s=0;for(;s<t.length;){let o=i.indexOf(t[s]);o>=0&&(r+=t.substring(n,s),r+=e[o],n=s+1),s++}return n==0?t:(n<t.length&&(r+=t.substring(n,t.length)),r)}}function or(i,e){let t=ke(i,e);return r=>`"${t(r)}"`}var P={measurement:ke(`,
2
+ \r `,["\\,","\\ ","\\n","\\r","\\t"]),quoted:or('"\\',['\\"',"\\\\"]),tag:ke(`, =
3
+ \r `,["\\,","\\ ","\\=","\\n","\\r","\\t"])};var ee="000000000",Be=!1;function lt(i){return Be=i&&process&&typeof process.hrtime=="function"}lt(!0);var nt,Q,it=Date.now(),Oe=0;function Ie(){if(Be){let i=process.hrtime(),e=Date.now();Q?(i[0]=i[0]-Q[0],i[1]=i[1]-Q[1],i[1]<0&&(i[0]-=1,i[1]+=1e9),e=nt+i[0]*1e3+Math.floor(i[1]/1e6)):(Q=i,nt=e);let t=String(i[1]%1e6);return String(e)+ee.substr(0,6-t.length)+t}else{let i=Date.now();i!==it?(it=i,Oe=0):Oe++;let e=String(Oe);return String(i)+ee.substr(0,6-e.length)+e}}function st(){if(Be){let i=process.hrtime(),e=String(Math.trunc(i[1]/1e3)%1e3);return String(Date.now())+ee.substr(0,3-e.length)+e}else return String(Date.now())+ee.substr(0,3)}function ot(){return String(Date.now())}function at(){return String(Math.floor(Date.now()/1e3))}var ft={s:at,ms:ot,us:st,ns:Ie,seconds:at,millis:ot,micros:st,nanos:Ie},ct={s:i=>`${Math.floor(i.getTime()/1e3)}`,ms:i=>`${i.getTime()}`,us:i=>`${i.getTime()}000`,ns:i=>`${i.getTime()}000000`};function Re(i){return i===void 0?Ie():typeof i=="string"?i.length>0?i:void 0:i instanceof Date?`${i.getTime()}000000`:String(typeof i=="number"?Math.floor(i):i)}var Te=(i,e="ns")=>i===void 0?ft[e]():typeof i=="string"?i.length>0?i:void 0:i instanceof Date?ct[e](i):String(typeof i=="number"?Math.floor(i):i);var M=class i{constructor(e){this.tags={};this.fields={};e&&(this.name=e)}measurement(e){return this.name=e,this}tag(e,t){return this.tags[e]=t,this}booleanField(e,t){return this.fields[e]=t?"T":"F",this}intField(e,t){let r;if(typeof t=="number"?r=t:r=parseInt(String(t)),isNaN(r)||r<=-9223372036854776e3||r>=9223372036854776e3)throw new Error(`invalid integer value for field '${e}': '${t}'!`);return this.fields[e]=`${Math.floor(r)}i`,this}uintField(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]=`${Math.floor(t)}u`}else{let r=String(t);for(let n=0;n<r.length;n++){let s=r.charCodeAt(n);if(s<48||s>57)throw new Error(`uint value has an unsupported character at pos ${n}: ${t}`)}if(r.length>20||r.length===20&&r.localeCompare("18446744073709551615")>0)throw new Error(`uint value for field '${e}' out of range: ${r}`);this.fields[e]=`${r}u`}return this}floatField(e,t){let r;if(typeof t=="number"?r=t:r=parseFloat(t),!isFinite(r))throw new Error(`invalid float value for field '${e}': '${t}'!`);return this.fields[e]=String(r),this}stringField(e,t){return t!=null&&(typeof t!="string"&&(t=String(t)),this.fields[e]=P.quoted(t)),this}timestamp(e){return this.time=e,this}toLineProtocol(e){if(!this.name)return;let t="";if(Object.keys(this.fields).sort().forEach(o=>{if(o){let a=this.fields[o];t.length>0&&(t+=","),t+=`${P.tag(o)}=${a}`}}),t.length===0)return;let r="",n=this.tags;Object.keys(n).sort().forEach(o=>{if(o){let a=n[o];a&&(r+=",",r+=`${P.tag(o)}=${P.tag(a)}`)}});let s=this.time;return e?typeof e=="string"?s=Te(s,e):s=e(s):s=Re(s),`${P.measurement(this.name)}${r} ${t}${s!==void 0?` ${s}`:""}`}toString(){let e=this.toLineProtocol(void 0);return e||`invalid point: ${JSON.stringify(this,void 0)}`}static fromRecord(e){let{measurement:t,fields:r,tags:n,timestamp:s}=e;if(!t)throw new Error("measurement must be defined on the Point record!");if(!r)throw new Error("fields must be defined on the Point record!");let o=new i(t);s!==void 0&&o.timestamp(s);for(let[a,l]of Object.entries(r))if(typeof l=="number")o.floatField(a,l);else if(typeof l=="string")o.stringField(a,l);else throw new Error(`unsuported type of field ${a}: ${typeof l}`);if(n)for(let[a,l]of Object.entries(n))if(typeof l=="string")o.tag(a,l);else throw new Error(`tag has to be string ${a}: ${typeof l}`);return o}};var xe=i=>{throw i},ut=i=>i!==void 0,pt=i=>i instanceof Array||i instanceof Object&&typeof i.length=="number"&&(i.length===0||Object.getOwnPropertyNames(i).some(e=>e==="0")),ht=i=>{let e=new Uint8Array(4);return e[0]=i>>0,e[1]=i>>8,e[2]=i>>16,e[3]=i>>24,e};var Ne=i=>{let e=pt(i)&&typeof i!="string"?Array.from(i):[i];if(e.length===0)return[];let t=typeof e[0]=="string",r=e[0]instanceof M;return t?e:(r?e:e.map(M.fromRecord)).map(n=>n.toLineProtocol()).filter(ut)};var H=class{constructor(e){this.transport=e;this.closed=!1;this.doWrite=this.doWrite.bind(this)}_createWritePath(e,t,r){let n=[`bucket=${encodeURIComponent(e)}`,`precision=${t.precision}`];r&&n.push(`org=${encodeURIComponent(r)}`);let s=t==null?void 0:t.consistency;return s&&n.push(`consistency=${encodeURIComponent(s)}`),`/api/v2/write?${n.join("&")}`}doWrite(e,t,r,n){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((m,w)=>{o=m,a=w}),f,u={responseStarted(m,w){f=w},error(m){if(m instanceof S&&m.json&&typeof m.json.error=="string"&&m.json.error.includes("hinted handoff queue not empty")){V.warn(`Write to InfluxDB returns: ${m.json.error}`),f=204,u.complete();return}V.error("Write to InfluxDB failed.",m),a(m)},complete(){if(f==204||f==null)o();else{let m=`204 HTTP response status code expected, but ${f} returned`,w=new S(f,m,void 0,"0");w.message=m,u.error(w)}}},h={...we,...n},d={method:"POST",headers:{"content-type":"text/plain; charset=utf-8",...n==null?void 0:n.headers},gzipThreshold:h.gzipThreshold};return this.transport.send(this._createWritePath(t,h,r),e.join(`
4
+ `),d,u),l}async close(){this.closed=!0}};var Ee=require("url"),mt=j(require("http")),gt=j(require("https")),te=require("buffer");var K=j(require("zlib"));function Fe(i={}){let e=0,t={next:r=>{if(e===0&&i.next&&r!==null&&r!==void 0)return i.next(r)},error:r=>{e===0&&(e=1,i.error&&i.error(r))},complete:()=>{e===0&&(e=2,i.complete&&i.complete())},responseStarted:(r,n)=>{i.responseStarted&&i.responseStarted(r,n)}};return i.useCancellable&&(t.useCancellable=i.useCancellable.bind(i)),i.useResume&&(t.useResume=i.useResume.bind(i)),t}var dt="0.1.0.nightly";var yt=require("stream");var ar={flush:K.default.constants.Z_SYNC_FLUSH,finishFlush:K.default.constants.Z_SYNC_FLUSH},lr=te.Buffer.allocUnsafe(0),Se=class{constructor(){this.cancelled=!1}cancel(){this.cancelled=!0,this.resume&&(this.resume(),this.resume=void 0)}isCancelled(){return this.cancelled}},Ae=class{constructor(e){var l,f,u,h,d,m,w;let{host:t,proxyUrl:r,token:n,transportOptions:s,...o}=e,a=(0,Ee.parse)(r||t);if(this.token=n,this.defaultOptions={...be,...o,...s,port:a.port,protocol:a.protocol,hostname:a.hostname},this.contextPath=r?t:(l=a.path)!=null?l:"",this.contextPath.endsWith("/")&&(this.contextPath=this.contextPath.substring(0,this.contextPath.length-1)),Object.keys(this.defaultOptions).forEach(U=>this.defaultOptions[U]===void 0&&delete this.defaultOptions[U]),this.contextPath.endsWith("/api/v2")&&(V.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${a.protocol}//${a.hostname}:${a.port} !`),this.contextPath=""),a.protocol==="http:")this.requestApi=(h=(u=(f=this.defaultOptions["follow-redirects"])==null?void 0:f.http)==null?void 0:u.request)!=null?h:mt.request;else if(a.protocol==="https:")this.requestApi=(w=(m=(d=this.defaultOptions["follow-redirects"])==null?void 0:d.https)==null?void 0:m.request)!=null?w:gt.request;else throw new Error(`Unsupported protocol "${a.protocol} in URL: "${e.host}"`);this.headers={"User-Agent":`influxdb-client-js/${dt}`,...e.headers},r&&(this.headers.Host=(0,Ee.parse)(t).host)}send(e,t,r,n){let s=new Se;n&&n.useCancellable&&n.useCancellable(s),this.createRequestMessage(e,t,r,o=>{this._request(o,s,n)},o=>(n==null?void 0:n.error)&&n.error(o))}request(e,t,r,n){t?typeof t!="string"&&(t=JSON.stringify(t)):t="";let s=lr,o,a;return new Promise((l,f)=>{this.send(e,t,r,{responseStarted(u,h){n&&n(u,h),o=String(u["content-type"]),a=h},next:u=>{s=te.Buffer.concat([s,u])},complete:()=>{var h,d;let u=(d=(h=r.headers)==null?void 0:h.accept)!=null?d:o;try{a===204&&l(void 0),u.includes("json")?s.length?l(JSON.parse(s.toString("utf8"))):l(void 0):u.includes("text")||u.startsWith("application/csv")?l(s.toString("utf8")):l(s)}catch(m){f(m)}},error:u=>{f(u)}})})}async*iterate(e,t,r){var u;let n,s;function o(h){n=h,s(h)}let a=await new Promise((h,d)=>{s=d,this.createRequestMessage(e,t,r,h,o)});(u=a.signal)!=null&&u.addEventListener&&a.signal.addEventListener("abort",()=>{o(new C)});let l=await new Promise((h,d)=>{s=d;let m=this.requestApi(a,h);m.on("timeout",()=>o(new $)),m.on("error",o),m.write(a.body),m.end()}),f=await new Promise((h,d)=>{s=d,this._prepareResponse(l,h,o)});for await(let h of f){if(n)throw n;yield h}}createRequestMessage(e,t,r,n,s){let o=te.Buffer.from(t,"utf-8"),a={"content-type":"application/json; charset=utf-8",...this.headers};this.token&&(a.authorization=`Token ${this.token}`);let l={...this.defaultOptions,path:this.contextPath+e,method:r.method,headers:{...a,...r.headers}};if(r.signal&&(l.signal=r.signal),r.gzipThreshold!==void 0&&r.gzipThreshold<o.length){K.default.gzip(o,(f,u)=>{if(f)return s(f);l.headers["content-encoding"]="gzip",l.body=u,n(l)});return}l.body=o,l.headers["content-length"]=l.body.length,n(l)}_prepareResponse(e,t,r){var a;e.on("aborted",()=>{r(new C)}),e.on("error",r);let n=(a=e.statusCode)!=null?a:600,s=e.headers["content-encoding"],o;if(s==="gzip"?(o=K.default.createGunzip(ar),o=(0,yt.pipeline)(e,o,l=>l&&r(l))):o=e,n>=300){let l="",f=String(e.headers["content-type"]).startsWith("application/json");o.on("data",u=>{l+=u.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()),r(new S(n,e.statusMessage,l,e.headers["retry-after"],e.headers["content-type"]))})}else t(o)}_request(e,t,r){var o;let n=Fe(r);if(t.isCancelled()){n.complete();return}(o=e.signal)!=null&&o.addEventListener&&e.signal.addEventListener("abort",()=>{n.error(new C)});let s=this.requestApi(e,a=>{if(t.isCancelled()){a.resume(),n.complete();return}n.responseStarted(a.headers,a.statusCode),this._prepareResponse(a,l=>{l.on("data",f=>{if(t.isCancelled())a.resume();else if(n.next(f)===!1){if(!n.useResume){n.error(new Error("Unable to pause, useResume is not configured!")),a.resume();return}a.pause();let u=()=>{a.resume()};t.resume=u,n.useResume(u)}}),l.on("end",n.complete)},n.error)});typeof s.setTimeout=="function"&&e.timeout&&s.setTimeout(e.timeout),s.on("timeout",()=>{n.error(new $)}),s.on("error",a=>{n.error(a)}),e.body&&s.write(e.body),s.end()}},bt=Ae;var Jt=require("apache-arrow");var _t=require("@protobuf-ts/runtime-rpc");function re(i){let e=typeof i;if(e=="object"){if(Array.isArray(i))return"array";if(i===null)return"null"}return e}function wt(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}var E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),ne=[];for(let i=0;i<E.length;i++)ne[E[i].charCodeAt(0)]=i;ne["-".charCodeAt(0)]=E.indexOf("+");ne["_".charCodeAt(0)]=E.indexOf("/");function kt(i){let e=i.length*3/4;i[i.length-2]=="="?e-=2:i[i.length-1]=="="&&(e-=1);let t=new Uint8Array(e),r=0,n=0,s,o=0;for(let a=0;a<i.length;a++){if(s=ne[i.charCodeAt(a)],s===void 0)switch(i[a]){case"=":n=0;case`
5
+ `:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(n){case 0:o=s,n=1;break;case 1:t[r++]=o<<2|(s&48)>>4,o=s,n=2;break;case 2:t[r++]=(o&15)<<4|(s&60)>>2,o=s,n=3;break;case 3:t[r++]=(o&3)<<6|s,n=0;break}}if(n==1)throw Error("invalid base64 string.");return t.subarray(0,r)}function Ot(i){let e="",t=0,r,n=0;for(let s=0;s<i.length;s++)switch(r=i[s],t){case 0:e+=E[r>>2],n=(r&3)<<4,t=1;break;case 1:e+=E[n|r>>4],n=(r&15)<<2,t=2;break;case 2:e+=E[n|r>>6],e+=E[r&63],t=0;break}return t&&(e+=E[n],e+="=",t==1&&(e+="=")),e}var g;(function(i){i.symbol=Symbol.for("protobuf-ts/unknown"),i.onRead=(t,r,n,s,o)=>{(e(r)?r[i.symbol]:r[i.symbol]=[]).push({no:n,wireType:s,data:o})},i.onWrite=(t,r,n)=>{for(let{no:s,wireType:o,data:a}of i.list(r))n.tag(s,o).raw(a)},i.list=(t,r)=>{if(e(t)){let n=t[i.symbol];return r?n.filter(s=>s.no==r):n}return[]},i.last=(t,r)=>i.list(t,r).slice(-1)[0];let e=t=>t&&Array.isArray(t[i.symbol])})(g||(g={}));var p;(function(i){i[i.Varint=0]="Varint",i[i.Bit64=1]="Bit64",i[i.LengthDelimited=2]="LengthDelimited",i[i.StartGroup=3]="StartGroup",i[i.EndGroup=4]="EndGroup",i[i.Bit32=5]="Bit32"})(p||(p={}));function It(){let i=0,e=0;for(let r=0;r<28;r+=7){let n=this.buf[this.pos++];if(i|=(n&127)<<r,!(n&128))return this.assertBounds(),[i,e]}let t=this.buf[this.pos++];if(i|=(t&15)<<28,e=(t&112)>>4,!(t&128))return this.assertBounds(),[i,e];for(let r=3;r<=31;r+=7){let n=this.buf[this.pos++];if(e|=(n&127)<<r,!(n&128))return this.assertBounds(),[i,e]}throw new Error("invalid varint")}function se(i,e,t){for(let s=0;s<28;s=s+7){let o=i>>>s,a=!(!(o>>>7)&&e==0),l=(a?o|128:o)&255;if(t.push(l),!a)return}let r=i>>>28&15|(e&7)<<4,n=!!(e>>3);if(t.push((n?r|128:r)&255),!!n){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 ie=65536*65536;function De(i){let e=i[0]=="-";e&&(i=i.slice(1));let t=1e6,r=0,n=0;function s(o,a){let l=Number(i.slice(o,a));n*=t,r=r*t+l,r>=ie&&(n=n+(r/ie|0),r=r%ie)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,r,n]}function oe(i,e){if(e<=2097151)return""+(ie*e+(i>>>0));let t=i&16777215,r=(i>>>24|e<<8)>>>0&16777215,n=e>>16&65535,s=t+r*6777216+n*6710656,o=r+n*8147497,a=n*2,l=1e7;s>=l&&(o+=Math.floor(s/l),s%=l),o>=l&&(a+=Math.floor(o/l),o%=l);function f(u,h){let d=u?String(u):"";return h?"0000000".slice(d.length)+d:d}return f(a,0)+f(o,a)+f(s,1)}function Ue(i,e){if(i>=0){for(;i>127;)e.push(i&127|128),i=i>>>7;e.push(i)}else{for(let t=0;t<9;t++)e.push(i&127|128),i=i>>7;e.push(1)}}function Bt(){let i=this.buf[this.pos++],e=i&127;if(!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<7,!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<14,!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<21,!(i&128))return this.assertBounds(),e;i=this.buf[this.pos++],e|=(i&15)<<28;for(let t=5;i&128&&t<10;t++)i=this.buf[this.pos++];if(i&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}function fr(){let i=new DataView(new ArrayBuffer(8));return globalThis.BigInt!==void 0&&typeof i.getBigInt64=="function"&&typeof i.getBigUint64=="function"&&typeof i.setBigInt64=="function"&&typeof i.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:i}:void 0}var b=fr();function Rt(i){if(!i)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}var Tt=/^-?[0-9]+$/,ae=65536*65536,le=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*ae+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}},I=class i extends le{static from(e){if(b)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=b.C(e);case"number":if(e===0)return this.ZERO;e=b.C(e);case"bigint":if(!e)return this.ZERO;if(e<b.UMIN)throw new Error("signed value for ulong");if(e>b.UMAX)throw new Error("ulong too large");return b.V.setBigUint64(0,e,!0),new i(b.V.getInt32(0,!0),b.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Tt.test(e))throw new Error("string is no integer");let[t,r,n]=De(e);if(t)throw new Error("signed value");return new i(r,n);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 i(e,e/ae)}throw new Error("unknown value "+typeof e)}toString(){return b?this.toBigInt().toString():oe(this.lo,this.hi)}toBigInt(){return Rt(b),b.V.setInt32(0,this.lo,!0),b.V.setInt32(4,this.hi,!0),b.V.getBigUint64(0,!0)}};I.ZERO=new I(0,0);var k=class i extends le{static from(e){if(b)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=b.C(e);case"number":if(e===0)return this.ZERO;e=b.C(e);case"bigint":if(!e)return this.ZERO;if(e<b.MIN)throw new Error("ulong too small");if(e>b.MAX)throw new Error("ulong too large");return b.V.setBigInt64(0,e,!0),new i(b.V.getInt32(0,!0),b.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Tt.test(e))throw new Error("string is no integer");let[t,r,n]=De(e),s=new i(r,n);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 i(e,e/ae):new i(-e,-e/ae).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&2147483648)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new i(t,e)}toString(){if(b)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+oe(e.lo,e.hi)}return oe(this.lo,this.hi)}toBigInt(){return Rt(b),b.V.setInt32(0,this.lo,!0),b.V.setInt32(4,this.hi,!0),b.V.getBigInt64(0,!0)}};k.ZERO=new k(0,0);var xt={readUnknownField:!0,readerFactory:i=>new Ce(i)};function Nt(i){return i?Object.assign(Object.assign({},xt),i):xt}var Ce=class{constructor(e,t){this.varint64=It,this.uint32=Bt,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,r=e&7;if(t<=0||r<0||r>5)throw new Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(e){let t=this.pos;switch(e){case p.Varint:for(;this.buf[this.pos++]&128;);break;case p.Bit64:this.pos+=4;case p.Bit32:this.pos+=4;break;case p.LengthDelimited:let r=this.uint32();this.pos+=r;break;case p.StartGroup:let n;for(;(n=this.tag()[1])!==p.EndGroup;)this.skip(n);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 k(...this.varint64())}uint64(){return new I(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(e&1);return e=(e>>>1|(t&1)<<31)^r,t=t>>>1^r,new k(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 I(this.sfixed32(),this.sfixed32())}sfixed64(){return new k(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 y(i,e){if(!i)throw new Error(e)}var cr=34028234663852886e22,ur=-34028234663852886e22,pr=4294967295,hr=2147483647,dr=-2147483648;function A(i){if(typeof i!="number")throw new Error("invalid int 32: "+typeof i);if(!Number.isInteger(i)||i>hr||i<dr)throw new Error("invalid int 32: "+i)}function L(i){if(typeof i!="number")throw new Error("invalid uint 32: "+typeof i);if(!Number.isInteger(i)||i>pr||i<0)throw new Error("invalid uint 32: "+i)}function v(i){if(typeof i!="number")throw new Error("invalid float 32: "+typeof i);if(Number.isFinite(i)&&(i>cr||i<ur))throw new Error("invalid float 32: "+i)}var Ft={writeUnknownFields:!0,writerFactory:()=>new Pe};function Et(i){return i?Object.assign(Object.assign({},Ft),i):Ft}var Pe=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 n=0;n<this.chunks.length;n++)e+=this.chunks[n].length;let t=new Uint8Array(e),r=0;for(let n=0;n<this.chunks.length;n++)t.set(this.chunks[n],r),r+=this.chunks[n].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 A(e),Ue(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){v(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){A(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return A(e),e=(e<<1^e>>31)>>>0,Ue(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),n=k.from(e);return r.setInt32(0,n.lo,!0),r.setInt32(4,n.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),n=I.from(e);return r.setInt32(0,n.lo,!0),r.setInt32(4,n.hi,!0),this.raw(t)}int64(e){let t=k.from(e);return se(t.lo,t.hi,this.buf),this}sint64(e){let t=k.from(e),r=t.hi>>31,n=t.lo<<1^r,s=(t.hi<<1|t.lo>>>31)^r;return se(n,s,this.buf),this}uint64(e){let t=I.from(e);return se(t.lo,t.hi,this.buf),this}};var St={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},At={ignoreUnknownFields:!1};function Dt(i){return i?Object.assign(Object.assign({},At),i):At}function Ut(i){return i?Object.assign(Object.assign({},St),i):St}var B=Symbol.for("protobuf-ts/message-type");function Le(i){let e=!1,t=[];for(let r=0;r<i.length;r++){let n=i.charAt(r);n=="_"?e=!0:/\d/.test(n)?(t.push(n),e=!0):e?(t.push(n.toUpperCase()),e=!1):r==0?t.push(n.toLowerCase()):t.push(n)}return t.join("")}var c;(function(i){i[i.DOUBLE=1]="DOUBLE",i[i.FLOAT=2]="FLOAT",i[i.INT64=3]="INT64",i[i.UINT64=4]="UINT64",i[i.INT32=5]="INT32",i[i.FIXED64=6]="FIXED64",i[i.FIXED32=7]="FIXED32",i[i.BOOL=8]="BOOL",i[i.STRING=9]="STRING",i[i.BYTES=12]="BYTES",i[i.UINT32=13]="UINT32",i[i.SFIXED32=15]="SFIXED32",i[i.SFIXED64=16]="SFIXED64",i[i.SINT32=17]="SINT32",i[i.SINT64=18]="SINT64"})(c||(c={}));var x;(function(i){i[i.BIGINT=0]="BIGINT",i[i.STRING=1]="STRING",i[i.NUMBER=2]="NUMBER"})(x||(x={}));var G;(function(i){i[i.NO=0]="NO",i[i.PACKED=1]="PACKED",i[i.UNPACKED=2]="UNPACKED"})(G||(G={}));function Ct(i){var e,t,r,n;return i.localName=(e=i.localName)!==null&&e!==void 0?e:Le(i.name),i.jsonName=(t=i.jsonName)!==null&&t!==void 0?t:Le(i.name),i.repeat=(r=i.repeat)!==null&&r!==void 0?r:G.NO,i.opt=(n=i.opt)!==null&&n!==void 0?n:i.repeat||i.oneof?!1:i.kind=="message",i}function Pt(i){if(typeof i!="object"||i===null||!i.hasOwnProperty("oneofKind"))return!1;switch(typeof i.oneofKind){case"string":return i[i.oneofKind]===void 0?!1:Object.keys(i).length==2;case"undefined":return Object.keys(i).length==1;default:return!1}}var fe=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}prepare(){if(this.data)return;let e=[],t=[],r=[];for(let n of this.fields)if(n.oneof)r.includes(n.oneof)||(r.push(n.oneof),e.push(n.oneof),t.push(n.oneof));else switch(t.push(n.localName),n.kind){case"scalar":case"enum":(!n.opt||n.repeat)&&e.push(n.localName);break;case"message":n.repeat&&e.push(n.localName);break;case"map":e.push(n.localName);break}this.data={req:e,known:t,oneofs:Object.values(r)}}is(e,t,r=!1){if(t<0)return!0;if(e==null||typeof e!="object")return!1;this.prepare();let n=Object.keys(e),s=this.data;if(n.length<s.req.length||s.req.some(o=>!n.includes(o))||!r&&n.some(o=>!s.known.includes(o)))return!1;if(t<1)return!0;for(let o of s.oneofs){let a=e[o];if(!Pt(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,r,t))return!1}for(let o of this.fields)if(o.oneof===void 0&&!this.field(e[o.localName],o,r,t))return!1;return!0}field(e,t,r,n){let s=t.repeat;switch(t.kind){case"scalar":return e===void 0?t.opt:s?this.scalars(e,t.T,n,t.L):this.scalar(e,t.T,t.L);case"enum":return e===void 0?t.opt:s?this.scalars(e,c.INT32,n):this.scalar(e,c.INT32);case"message":return e===void 0?!0:s?this.messages(e,t.T(),r,n):this.message(e,t.T(),r,n);case"map":if(typeof e!="object"||e===null)return!1;if(n<2)return!0;if(!this.mapKeys(e,t.K,n))return!1;switch(t.V.kind){case"scalar":return this.scalars(Object.values(e),t.V.T,n,t.V.L);case"enum":return this.scalars(Object.values(e),c.INT32,n);case"message":return this.messages(Object.values(e),t.V.T(),r,n)}break}return!0}message(e,t,r,n){return r?t.isAssignable(e,n):t.is(e,n)}messages(e,t,r,n){if(!Array.isArray(e))return!1;if(n<2)return!0;if(r){for(let s=0;s<e.length&&s<n;s++)if(!t.isAssignable(e[s],n-1))return!1}else for(let s=0;s<e.length&&s<n;s++)if(!t.is(e[s],n-1))return!1;return!0}scalar(e,t,r){let n=typeof e;switch(t){case c.UINT64:case c.FIXED64:case c.INT64:case c.SFIXED64:case c.SINT64:switch(r){case x.BIGINT:return n=="bigint";case x.NUMBER:return n=="number"&&!isNaN(e);default:return n=="string"}case c.BOOL:return n=="boolean";case c.STRING:return n=="string";case c.BYTES:return e instanceof Uint8Array;case c.DOUBLE:case c.FLOAT:return n=="number"&&!isNaN(e);default:return n=="number"&&Number.isInteger(e)}}scalars(e,t,r,n){if(!Array.isArray(e))return!1;if(r<2)return!0;if(Array.isArray(e)){for(let s=0;s<e.length&&s<r;s++)if(!this.scalar(e[s],t,n))return!1}return!0}mapKeys(e,t,r){let n=Object.keys(e);switch(t){case c.INT32:case c.FIXED32:case c.SFIXED32:case c.SINT32:case c.UINT32:return this.scalars(n.slice(0,r).map(s=>parseInt(s)),t,r);case c.BOOL:return this.scalars(n.slice(0,r).map(s=>s=="true"?!0:s=="false"?!1:s),t,r);default:return this.scalars(n,t,r,x.STRING)}}};function N(i,e){switch(e){case x.BIGINT:return i.toBigInt();case x.NUMBER:return i.toNumber();default:return i.toString()}}var ce=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 r of t)this.fMap[r.name]=r,this.fMap[r.jsonName]=r,this.fMap[r.localName]=r}}assert(e,t,r){if(!e){let n=re(r);throw(n=="number"||n=="boolean")&&(n=r.toString()),new Error(`Cannot parse JSON ${n} for ${this.info.typeName}#${t}`)}}read(e,t,r){this.prepare();let n=[];for(let[s,o]of Object.entries(e)){let a=this.fMap[s];if(!a){if(!r.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(n.includes(a.oneof))throw new Error(`Multiple members of the oneof group "${a.oneof}" of ${this.info.typeName} are present in JSON.`);n.push(a.oneof),f=t[a.oneof]={oneofKind:l}}else f=t;if(a.kind=="map"){if(o===null)continue;this.assert(wt(o),a.name,o);let u=f[l];for(let[h,d]of Object.entries(o)){this.assert(d!==null,a.name+" map value",null);let m;switch(a.V.kind){case"message":m=a.V.T().internalJsonRead(d,r);break;case"enum":if(m=this.enum(a.V.T(),d,a.name,r.ignoreUnknownFields),m===!1)continue;break;case"scalar":m=this.scalar(d,a.V.T,a.V.L,a.name);break}this.assert(m!==void 0,a.name+" map value",d);let w=h;a.K==c.BOOL&&(w=w=="true"?!0:w=="false"?!1:w),w=this.scalar(w,a.K,x.STRING,a.name).toString(),u[w]=m}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);let u=f[l];for(let h of o){this.assert(h!==null,a.name,null);let d;switch(a.kind){case"message":d=a.T().internalJsonRead(h,r);break;case"enum":if(d=this.enum(a.T(),h,a.name,r.ignoreUnknownFields),d===!1)continue;break;case"scalar":d=this.scalar(h,a.T,a.L,a.name);break}this.assert(d!==void 0,a.name,o),u.push(d)}}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,r,f[l]);break;case"enum":let u=this.enum(a.T(),o,a.name,r.ignoreUnknownFields);if(u===!1)continue;f[l]=u;break;case"scalar":f[l]=this.scalar(o,a.T,a.L,a.name);break}}}enum(e,t,r,n){if(e[0]=="google.protobuf.NullValue"&&y(t===null,`Unable to parse field ${this.info.typeName}#${r}, enum ${e[0]} only accepts null.`),t===null)return 0;switch(typeof t){case"number":return y(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${r}, 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"&&n?!1:(y(typeof o=="number",`Unable to parse field ${this.info.typeName}#${r}, enum ${e[0]} has no value for "${t}".`),o)}y(!1,`Unable to parse field ${this.info.typeName}#${r}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,r,n){let s;try{switch(t){case c.DOUBLE:case c.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==c.FLOAT&&v(o),o;case c.INT32:case c.FIXED32:case c.SFIXED32:case c.SINT32:case c.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==c.UINT32?L(a):A(a),a;case c.INT64:case c.SFIXED64:case c.SINT64:if(e===null)return N(k.ZERO,r);if(typeof e!="number"&&typeof e!="string")break;return N(k.from(e),r);case c.FIXED64:case c.UINT64:if(e===null)return N(I.ZERO,r);if(typeof e!="number"&&typeof e!="string")break;return N(I.from(e),r);case c.BOOL:if(e===null)return!1;if(typeof e!="boolean")break;return e;case c.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 c.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,n+(s?" - "+s:""),e)}};var ue=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}write(e,t){let r={},n=e;for(let s of this.fields){if(!s.oneof){let f=this.field(s,n[s.localName],t);f!==void 0&&(r[t.useProtoFieldName?s.name:s.jsonName]=f);continue}let o=n[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);y(l!==void 0),r[t.useProtoFieldName?s.name:s.jsonName]=l}return r}field(e,t,r){let n;if(e.kind=="map"){y(typeof t=="object"&&t!==null);let s={};switch(e.V.kind){case"scalar":for(let[l,f]of Object.entries(t)){let u=this.scalar(e.V.T,f,e.name,!1,!0);y(u!==void 0),s[l.toString()]=u}break;case"message":let o=e.V.T();for(let[l,f]of Object.entries(t)){let u=this.message(o,f,e.name,r);y(u!==void 0),s[l.toString()]=u}break;case"enum":let a=e.V.T();for(let[l,f]of Object.entries(t)){y(f===void 0||typeof f=="number");let u=this.enum(a,f,e.name,!1,!0,r.enumAsInteger);y(u!==void 0),s[l.toString()]=u}break}(r.emitDefaultValues||Object.keys(s).length>0)&&(n=s)}else if(e.repeat){y(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);y(f!==void 0),s.push(f)}break;case"enum":let o=e.T();for(let l=0;l<t.length;l++){y(t[l]===void 0||typeof t[l]=="number");let f=this.enum(o,t[l],e.name,e.opt,!0,r.enumAsInteger);y(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,r);y(f!==void 0),s.push(f)}break}(r.emitDefaultValues||s.length>0||r.emitDefaultValues)&&(n=s)}else switch(e.kind){case"scalar":n=this.scalar(e.T,t,e.name,e.opt,r.emitDefaultValues);break;case"enum":n=this.enum(e.T(),t,e.name,e.opt,r.emitDefaultValues,r.enumAsInteger);break;case"message":n=this.message(e.T(),t,e.name,r);break}return n}enum(e,t,r,n,s,o){if(e[0]=="google.protobuf.NullValue")return null;if(t===void 0){y(n);return}if(!(t===0&&!s&&!n))return y(typeof t=="number"),y(Number.isInteger(t)),o||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}message(e,t,r,n){return t===void 0?n.emitDefaultValues?null:void 0:e.internalJsonWrite(t,n)}scalar(e,t,r,n,s){if(t===void 0){y(n);return}let o=s||n;switch(e){case c.INT32:case c.SFIXED32:case c.SINT32:return t===0?o?0:void 0:(A(t),t);case c.FIXED32:case c.UINT32:return t===0?o?0:void 0:(L(t),t);case c.FLOAT:v(t);case c.DOUBLE:return t===0?o?0:void 0:(y(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case c.STRING:return t===""?o?"":void 0:(y(typeof t=="string"),t);case c.BOOL:return t===!1?o?!1:void 0:(y(typeof t=="boolean"),t);case c.UINT64:case c.FIXED64:y(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let a=I.from(t);return a.isZero()&&!o?void 0:a.toString();case c.INT64:case c.SFIXED64:case c.SINT64:y(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let l=k.from(t);return l.isZero()&&!o?void 0:l.toString();case c.BYTES:return y(t instanceof Uint8Array),t.byteLength?Ot(t):o?"":void 0}}};function J(i,e=x.STRING){switch(i){case c.BOOL:return!1;case c.UINT64:case c.FIXED64:return N(I.ZERO,e);case c.INT64:case c.SFIXED64:case c.SINT64:return N(k.ZERO,e);case c.DOUBLE:case c.FLOAT:return 0;case c.BYTES:return new Uint8Array(0);case c.STRING:return"";default:return 0}}var pe=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(r=>[r.no,r]))}}read(e,t,r,n){this.prepare();let s=n===void 0?e.len:e.pos+n;for(;e.pos<s;){let[o,a]=e.tag(),l=this.fieldNoToField.get(o);if(!l){let d=r.readUnknownField;if(d=="throw")throw new Error(`Unknown field ${o} (wire type ${a}) for ${this.info.typeName}`);let m=e.skip(a);d!==!1&&(d===!0?g.onRead:d)(this.info.typeName,t,o,a,m);continue}let f=t,u=l.repeat,h=l.localName;switch(l.oneof&&(f=f[l.oneof],f.oneofKind!==h&&(f=t[l.oneof]={oneofKind:h})),l.kind){case"scalar":case"enum":let d=l.kind=="enum"?c.INT32:l.T,m=l.kind=="scalar"?l.L:void 0;if(u){let F=f[h];if(a==p.LengthDelimited&&d!=c.STRING&&d!=c.BYTES){let q=e.uint32()+e.pos;for(;e.pos<q;)F.push(this.scalar(e,d,m))}else F.push(this.scalar(e,d,m))}else f[h]=this.scalar(e,d,m);break;case"message":if(u){let F=f[h],q=l.T().internalBinaryRead(e,e.uint32(),r);F.push(q)}else f[h]=l.T().internalBinaryRead(e,e.uint32(),r,f[h]);break;case"map":let[w,U]=this.mapEntry(l,e,r);f[h][w]=U;break}}}mapEntry(e,t,r){let n=t.uint32(),s=t.pos+n,o,a;for(;t.pos<s;){let[l,f]=t.tag();switch(l){case 1:e.K==c.BOOL?o=t.bool().toString():o=this.scalar(t,e.K,x.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(),r);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=J(e.K);o=e.K==c.BOOL?l.toString():l}if(a===void 0)switch(e.V.kind){case"scalar":a=J(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,r){switch(t){case c.INT32:return e.int32();case c.STRING:return e.string();case c.BOOL:return e.bool();case c.DOUBLE:return e.double();case c.FLOAT:return e.float();case c.INT64:return N(e.int64(),r);case c.UINT64:return N(e.uint64(),r);case c.FIXED64:return N(e.fixed64(),r);case c.FIXED32:return e.fixed32();case c.BYTES:return e.bytes();case c.UINT32:return e.uint32();case c.SFIXED32:return e.sfixed32();case c.SFIXED64:return N(e.sfixed64(),r);case c.SINT32:return e.sint32();case c.SINT64:return N(e.sint64(),r)}}};var he=class{constructor(e){this.info=e}prepare(){if(!this.fields){let e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort((t,r)=>t.no-r.no)}}write(e,t,r){this.prepare();for(let s of this.fields){let o,a,l=s.repeat,f=s.localName;if(s.oneof){let u=e[s.oneof];if(u.oneofKind!==f)continue;o=u[f],a=!0}else o=e[f],a=!1;switch(s.kind){case"scalar":case"enum":let u=s.kind=="enum"?c.INT32:s.T;if(l)if(y(Array.isArray(o)),l==G.PACKED)this.packed(t,u,s.no,o);else for(let h of o)this.scalar(t,u,s.no,h,!0);else o===void 0?y(s.opt):this.scalar(t,u,s.no,o,a||s.opt);break;case"message":if(l){y(Array.isArray(o));for(let h of o)this.message(t,r,s.T(),s.no,h)}else this.message(t,r,s.T(),s.no,o);break;case"map":y(typeof o=="object"&&o!==null);for(let[h,d]of Object.entries(o))this.mapEntry(t,r,s,h,d);break}}let n=r.writeUnknownFields;n!==!1&&(n===!0?g.onWrite:n)(this.info.typeName,e,t)}mapEntry(e,t,r,n,s){e.tag(r.no,p.LengthDelimited),e.fork();let o=n;switch(r.K){case c.INT32:case c.FIXED32:case c.UINT32:case c.SFIXED32:case c.SINT32:o=Number.parseInt(n);break;case c.BOOL:y(n=="true"||n=="false"),o=n=="true";break}switch(this.scalar(e,r.K,1,o,!0),r.V.kind){case"scalar":this.scalar(e,r.V.T,2,s,!0);break;case"enum":this.scalar(e,c.INT32,2,s,!0);break;case"message":this.message(e,t,r.V.T(),2,s);break}e.join()}message(e,t,r,n,s){s!==void 0&&(r.internalBinaryWrite(s,e.tag(n,p.LengthDelimited).fork(),t),e.join())}scalar(e,t,r,n,s){let[o,a,l]=this.scalarInfo(t,n);(!l||s)&&(e.tag(r,o),e[a](n))}packed(e,t,r,n){if(!n.length)return;y(t!==c.BYTES&&t!==c.STRING),e.tag(r,p.LengthDelimited),e.fork();let[,s]=this.scalarInfo(t);for(let o=0;o<n.length;o++)e[s](n[o]);e.join()}scalarInfo(e,t){let r=p.Varint,n,s=t===void 0,o=t===0;switch(e){case c.INT32:n="int32";break;case c.STRING:o=s||!t.length,r=p.LengthDelimited,n="string";break;case c.BOOL:o=t===!1,n="bool";break;case c.UINT32:n="uint32";break;case c.DOUBLE:r=p.Bit64,n="double";break;case c.FLOAT:r=p.Bit32,n="float";break;case c.INT64:o=s||k.from(t).isZero(),n="int64";break;case c.UINT64:o=s||I.from(t).isZero(),n="uint64";break;case c.FIXED64:o=s||I.from(t).isZero(),r=p.Bit64,n="fixed64";break;case c.BYTES:o=s||!t.byteLength,r=p.LengthDelimited,n="bytes";break;case c.FIXED32:r=p.Bit32,n="fixed32";break;case c.SFIXED32:r=p.Bit32,n="sfixed32";break;case c.SFIXED64:o=s||k.from(t).isZero(),r=p.Bit64,n="sfixed64";break;case c.SINT32:n="sint32";break;case c.SINT64:o=s||k.from(t).isZero(),n="sint64";break}return[r,n,s||o]}};function Lt(i){let e={};Object.defineProperty(e,B,{enumerable:!1,value:i});for(let t of i.fields){let r=t.localName;if(!t.opt)if(t.oneof)e[t.oneof]={oneofKind:void 0};else if(t.repeat)e[r]=[];else switch(t.kind){case"scalar":e[r]=J(t.T,t.L);break;case"enum":e[r]=0;break;case"map":e[r]={};break}}return e}function O(i,e,t){let r,n=t,s;for(let o of i.fields){let a=o.localName;if(o.oneof){let l=n[o.oneof];if((l==null?void 0:l.oneofKind)==null)continue;if(r=l[a],s=e[o.oneof],s.oneofKind=l.oneofKind,r==null){delete s[a];continue}}else if(r=n[a],s=e,r==null)continue;switch(o.repeat&&(s[a].length=r.length),o.kind){case"scalar":case"enum":if(o.repeat)for(let f=0;f<r.length;f++)s[a][f]=r[f];else s[a]=r;break;case"message":let l=o.T();if(o.repeat)for(let f=0;f<r.length;f++)s[a][f]=l.create(r[f]);else s[a]===void 0?s[a]=l.create(r):l.mergePartial(s[a],r);break;case"map":switch(o.V.kind){case"scalar":case"enum":Object.assign(s[a],r);break;case"message":let f=o.V.T();for(let u of Object.keys(r))s[a][u]=f.create(r[u]);break}break}}}function Vt(i,e,t){if(e===t)return!0;if(!e||!t)return!1;for(let r of i.fields){let n=r.localName,s=r.oneof?e[r.oneof][n]:e[n],o=r.oneof?t[r.oneof][n]:t[n];switch(r.kind){case"enum":case"scalar":let a=r.kind=="enum"?c.INT32:r.T;if(!(r.repeat?Wt(a,s,o):Mt(a,s,o)))return!1;break;case"map":if(!(r.V.kind=="message"?$t(r.V.T(),de(s),de(o)):Wt(r.V.kind=="enum"?c.INT32:r.V.T,de(s),de(o))))return!1;break;case"message":let l=r.T();if(!(r.repeat?$t(l,s,o):l.equals(s,o)))return!1;break}}return!0}var de=Object.values;function Mt(i,e,t){if(e===t)return!0;if(i!==c.BYTES)return!1;let r=e,n=t;if(r.length!==n.length)return!1;for(let s=0;s<r.length;s++)if(r[s]!=n[s])return!1;return!0}function Wt(i,e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Mt(i,e[r],t[r]))return!1;return!0}function $t(i,e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!i.equals(e[r],t[r]))return!1;return!0}var R=class{constructor(e,t,r){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(Ct),this.options=r!=null?r:{},this.refTypeCheck=new fe(this),this.refJsonReader=new ce(this),this.refJsonWriter=new ue(this),this.refBinReader=new pe(this),this.refBinWriter=new he(this)}create(e){let t=Lt(this);return e!==void 0&&O(this,t,e),t}clone(e){let t=this.create();return O(this,t,e),t}equals(e,t){return Vt(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){O(this,e,t)}fromBinary(e,t){let r=Nt(t);return this.internalBinaryRead(r.readerFactory(e),e.byteLength,r)}fromJson(e,t){return this.internalJsonRead(e,Dt(t))}fromJsonString(e,t){let r=JSON.parse(e);return this.fromJson(r,t)}toJson(e,t){return this.internalJsonWrite(e,Ut(t))}toJsonString(e,t){var r;let n=this.toJson(e,t);return JSON.stringify(n,null,(r=t==null?void 0:t.prettySpaces)!==null&&r!==void 0?r:0)}toBinary(e,t){let r=Et(t);return this.internalBinaryWrite(e,r.writerFactory(),r).finish()}internalJsonRead(e,t,r){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let n=r!=null?r:this.create();return this.refJsonReader.read(e,n,t),n}throw new Error(`Unable to parse message ${this.typeName} from JSON ${re(e)}.`)}internalJsonWrite(e,t){return this.refJsonWriter.write(e,t)}internalBinaryWrite(e,t,r){return this.refBinWriter.write(e,t,r),t}internalBinaryRead(e,t,r,n){let s=n!=null?n:this.create();return this.refBinReader.read(e,s,r,t),s}};var qt=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.PATH=1]="PATH",r[r.CMD=2]="CMD",r))(qt||{}),Ve=class extends R{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}])}create(e){let t={protocolVersion:BigInt(0),payload:new Uint8Array(0)};return globalThis.Object.defineProperty(t,B,{enumerable:!1,value:this}),e!==void 0&&O(this,t,e),t}internalBinaryRead(e,t,r,n){let s=n!=null?n:this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.protocolVersion=e.uint64().toBigInt();break;case 2:s.payload=e.bytes();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let u=e.skip(l);f!==!1&&(f===!0?g.onRead:f)(this.typeName,s,a,l,u)}}return s}internalBinaryWrite(e,t,r){e.protocolVersion!==BigInt(0)&&t.tag(1,p.Varint).uint64(e.protocolVersion),e.payload.length&&t.tag(2,p.LengthDelimited).bytes(e.payload);let n=r.writeUnknownFields;return n!==!1&&(n==!0?g.onWrite:n)(this.typeName,e,t),t}},mr=new Ve,Me=class extends R{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}])}create(e){let t={protocolVersion:BigInt(0),payload:new Uint8Array(0)};return globalThis.Object.defineProperty(t,B,{enumerable:!1,value:this}),e!==void 0&&O(this,t,e),t}internalBinaryRead(e,t,r,n){let s=n!=null?n:this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.protocolVersion=e.uint64().toBigInt();break;case 2:s.payload=e.bytes();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let u=e.skip(l);f!==!1&&(f===!0?g.onRead:f)(this.typeName,s,a,l,u)}}return s}internalBinaryWrite(e,t,r){e.protocolVersion!==BigInt(0)&&t.tag(1,p.Varint).uint64(e.protocolVersion),e.payload.length&&t.tag(2,p.LengthDelimited).bytes(e.payload);let n=r.writeUnknownFields;return n!==!1&&(n==!0?g.onWrite:n)(this.typeName,e,t),t}},gr=new Me,ve=class extends R{constructor(){super("arrow.flight.protocol.BasicAuth",[{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"password",kind:"scalar",T:9}])}create(e){let t={username:"",password:""};return globalThis.Object.defineProperty(t,B,{enumerable:!1,value:this}),e!==void 0&&O(this,t,e),t}internalBinaryRead(e,t,r,n){let s=n!=null?n:this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 2:s.username=e.string();break;case 3:s.password=e.string();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let u=e.skip(l);f!==!1&&(f===!0?g.onRead:f)(this.typeName,s,a,l,u)}}return s}internalBinaryWrite(e,t,r){e.username!==""&&t.tag(2,p.LengthDelimited).string(e.username),e.password!==""&&t.tag(3,p.LengthDelimited).string(e.password);let n=r.writeUnknownFields;return n!==!1&&(n==!0?g.onWrite:n)(this.typeName,e,t),t}},Pi=new ve,_e=class extends R{constructor(){super("arrow.flight.protocol.Empty",[])}create(e){let t={};return globalThis.Object.defineProperty(t,B,{enumerable:!1,value:this}),e!==void 0&&O(this,t,e),t}internalBinaryRead(e,t,r,n){return n!=null?n:this.create()}internalBinaryWrite(e,t,r){let n=r.writeUnknownFields;return n!==!1&&(n==!0?g.onWrite:n)(this.typeName,e,t),t}},yr=new _e,qe=class extends R{constructor(){super("arrow.flight.protocol.ActionType",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}])}create(e){let t={type:"",description:""};return globalThis.Object.defineProperty(t,B,{enumerable:!1,value:this}),e!==void 0&&O(this,t,e),t}internalBinaryRead(e,t,r,n){let s=n!=null?n:this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.type=e.string();break;case 2:s.description=e.string();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let u=e.skip(l);f!==!1&&(f===!0?g.onRead:f)(this.typeName,s,a,l,u)}}return s}internalBinaryWrite(e,t,r){e.type!==""&&t.tag(1,p.LengthDelimited).string(e.type),e.description!==""&&t.tag(2,p.LengthDelimited).string(e.description);let n=r.writeUnknownFields;return n!==!1&&(n==!0?g.onWrite:n)(this.typeName,e,t),t}},br=new qe,je=class extends R{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}create(e){let t={expression:new Uint8Array(0)};return globalThis.Object.defineProperty(t,B,{enumerable:!1,value:this}),e!==void 0&&O(this,t,e),t}internalBinaryRead(e,t,r,n){let s=n!=null?n:this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.expression=e.bytes();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let u=e.skip(l);f!==!1&&(f===!0?g.onRead:f)(this.typeName,s,a,l,u)}}return s}internalBinaryWrite(e,t,r){e.expression.length&&t.tag(1,p.LengthDelimited).bytes(e.expression);let n=r.writeUnknownFields;return n!==!1&&(n==!0?g.onWrite:n)(this.typeName,e,t),t}},wr=new je,He=class extends R{constructor(){super("arrow.flight.protocol.Action",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"body",kind:"scalar",T:12}])}create(e){let t={type:"",body:new Uint8Array(0)};return globalThis.Object.defineProperty(t,B,{enumerable:!1,value:this}),e!==void 0&&O(this,t,e),t}internalBinaryRead(e,t,r,n){let s=n!=null?n:this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.type=e.string();break;case 2:s.body=e.bytes();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let u=e.skip(l);f!==!1&&(f===!0?g.onRead:f)(this.typeName,s,a,l,u)}}return s}internalBinaryWrite(e,t,r){e.type!==""&&t.tag(1,p.LengthDelimited).string(e.type),e.body.length&&t.tag(2,p.LengthDelimited).bytes(e.body);let n=r.writeUnknownFields;return n!==!1&&(n==!0?g.onWrite:n)(this.typeName,e,t),t}},kr=new He,Ke=class extends R{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}create(e){let t={body:new Uint8Array(0)};return globalThis.Object.defineProperty(t,B,{enumerable:!1,value:this}),e!==void 0&&O(this,t,e),t}internalBinaryRead(e,t,r,n){let s=n!=null?n:this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.body=e.bytes();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let u=e.skip(l);f!==!1&&(f===!0?g.onRead:f)(this.typeName,s,a,l,u)}}return s}internalBinaryWrite(e,t,r){e.body.length&&t.tag(1,p.LengthDelimited).bytes(e.body);let n=r.writeUnknownFields;return n!==!1&&(n==!0?g.onWrite:n)(this.typeName,e,t),t}},Or=new Ke,Ge=class extends R{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}create(e){let t={schema:new Uint8Array(0)};return globalThis.Object.defineProperty(t,B,{enumerable:!1,value:this}),e!==void 0&&O(this,t,e),t}internalBinaryRead(e,t,r,n){let s=n!=null?n:this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.schema=e.bytes();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let u=e.skip(l);f!==!1&&(f===!0?g.onRead:f)(this.typeName,s,a,l,u)}}return s}internalBinaryWrite(e,t,r){e.schema.length&&t.tag(1,p.LengthDelimited).bytes(e.schema);let n=r.writeUnknownFields;return n!==!1&&(n==!0?g.onWrite:n)(this.typeName,e,t),t}},Ir=new Ge,Je=class extends R{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",qt]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}create(e){let t={type:0,cmd:new Uint8Array(0),path:[]};return globalThis.Object.defineProperty(t,B,{enumerable:!1,value:this}),e!==void 0&&O(this,t,e),t}internalBinaryRead(e,t,r,n){let s=n!=null?n:this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.type=e.int32();break;case 2:s.cmd=e.bytes();break;case 3:s.path.push(e.string());break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let u=e.skip(l);f!==!1&&(f===!0?g.onRead:f)(this.typeName,s,a,l,u)}}return s}internalBinaryWrite(e,t,r){e.type!==0&&t.tag(1,p.Varint).int32(e.type),e.cmd.length&&t.tag(2,p.LengthDelimited).bytes(e.cmd);for(let s=0;s<e.path.length;s++)t.tag(3,p.LengthDelimited).string(e.path[s]);let n=r.writeUnknownFields;return n!==!1&&(n==!0?g.onWrite:n)(this.typeName,e,t),t}},D=new Je,Xe=class extends R{constructor(){super("arrow.flight.protocol.FlightInfo",[{no:1,name:"schema",kind:"scalar",T:12},{no:2,name:"flight_descriptor",kind:"message",T:()=>D},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>We},{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}])}create(e){let t={schema:new Uint8Array(0),endpoint:[],totalRecords:BigInt(0),totalBytes:BigInt(0),ordered:!1};return globalThis.Object.defineProperty(t,B,{enumerable:!1,value:this}),e!==void 0&&O(this,t,e),t}internalBinaryRead(e,t,r,n){let s=n!=null?n:this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.schema=e.bytes();break;case 2:s.flightDescriptor=D.internalBinaryRead(e,e.uint32(),r,s.flightDescriptor);break;case 3:s.endpoint.push(We.internalBinaryRead(e,e.uint32(),r));break;case 4:s.totalRecords=e.int64().toBigInt();break;case 5:s.totalBytes=e.int64().toBigInt();break;case 6:s.ordered=e.bool();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let u=e.skip(l);f!==!1&&(f===!0?g.onRead:f)(this.typeName,s,a,l,u)}}return s}internalBinaryWrite(e,t,r){e.schema.length&&t.tag(1,p.LengthDelimited).bytes(e.schema),e.flightDescriptor&&D.internalBinaryWrite(e.flightDescriptor,t.tag(2,p.LengthDelimited).fork(),r).join();for(let s=0;s<e.endpoint.length;s++)We.internalBinaryWrite(e.endpoint[s],t.tag(3,p.LengthDelimited).fork(),r).join();e.totalRecords!==BigInt(0)&&t.tag(4,p.Varint).int64(e.totalRecords),e.totalBytes!==BigInt(0)&&t.tag(5,p.Varint).int64(e.totalBytes),e.ordered!==!1&&t.tag(6,p.Varint).bool(e.ordered);let n=r.writeUnknownFields;return n!==!1&&(n==!0?g.onWrite:n)(this.typeName,e,t),t}},vt=new Xe,Ze=class extends R{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>_},{no:2,name:"location",kind:"message",repeat:1,T:()=>$e}])}create(e){let t={location:[]};return globalThis.Object.defineProperty(t,B,{enumerable:!1,value:this}),e!==void 0&&O(this,t,e),t}internalBinaryRead(e,t,r,n){let s=n!=null?n:this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.ticket=_.internalBinaryRead(e,e.uint32(),r,s.ticket);break;case 2:s.location.push($e.internalBinaryRead(e,e.uint32(),r));break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let u=e.skip(l);f!==!1&&(f===!0?g.onRead:f)(this.typeName,s,a,l,u)}}return s}internalBinaryWrite(e,t,r){e.ticket&&_.internalBinaryWrite(e.ticket,t.tag(1,p.LengthDelimited).fork(),r).join();for(let s=0;s<e.location.length;s++)$e.internalBinaryWrite(e.location[s],t.tag(2,p.LengthDelimited).fork(),r).join();let n=r.writeUnknownFields;return n!==!1&&(n==!0?g.onWrite:n)(this.typeName,e,t),t}},We=new Ze,Ye=class extends R{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}create(e){let t={uri:""};return globalThis.Object.defineProperty(t,B,{enumerable:!1,value:this}),e!==void 0&&O(this,t,e),t}internalBinaryRead(e,t,r,n){let s=n!=null?n:this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.uri=e.string();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let u=e.skip(l);f!==!1&&(f===!0?g.onRead:f)(this.typeName,s,a,l,u)}}return s}internalBinaryWrite(e,t,r){e.uri!==""&&t.tag(1,p.LengthDelimited).string(e.uri);let n=r.writeUnknownFields;return n!==!1&&(n==!0?g.onWrite:n)(this.typeName,e,t),t}},$e=new Ye,ze=class extends R{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}create(e){let t={ticket:new Uint8Array(0)};return globalThis.Object.defineProperty(t,B,{enumerable:!1,value:this}),e!==void 0&&O(this,t,e),t}internalBinaryRead(e,t,r,n){let s=n!=null?n:this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.ticket=e.bytes();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let u=e.skip(l);f!==!1&&(f===!0?g.onRead:f)(this.typeName,s,a,l,u)}}return s}internalBinaryWrite(e,t,r){e.ticket.length&&t.tag(1,p.LengthDelimited).bytes(e.ticket);let n=r.writeUnknownFields;return n!==!1&&(n==!0?g.onWrite:n)(this.typeName,e,t),t}},_=new ze,Qe=class extends R{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>D},{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}])}create(e){let t={dataHeader:new Uint8Array(0),appMetadata:new Uint8Array(0),dataBody:new Uint8Array(0)};return globalThis.Object.defineProperty(t,B,{enumerable:!1,value:this}),e!==void 0&&O(this,t,e),t}internalBinaryRead(e,t,r,n){let s=n!=null?n:this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.flightDescriptor=D.internalBinaryRead(e,e.uint32(),r,s.flightDescriptor);break;case 2:s.dataHeader=e.bytes();break;case 3:s.appMetadata=e.bytes();break;case 1e3:s.dataBody=e.bytes();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let u=e.skip(l);f!==!1&&(f===!0?g.onRead:f)(this.typeName,s,a,l,u)}}return s}internalBinaryWrite(e,t,r){e.flightDescriptor&&D.internalBinaryWrite(e.flightDescriptor,t.tag(1,p.LengthDelimited).fork(),r).join(),e.dataHeader.length&&t.tag(2,p.LengthDelimited).bytes(e.dataHeader),e.appMetadata.length&&t.tag(3,p.LengthDelimited).bytes(e.appMetadata),e.dataBody.length&&t.tag(1e3,p.LengthDelimited).bytes(e.dataBody);let n=r.writeUnknownFields;return n!==!1&&(n==!0?g.onWrite:n)(this.typeName,e,t),t}},me=new Qe,et=class extends R{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}create(e){let t={appMetadata:new Uint8Array(0)};return globalThis.Object.defineProperty(t,B,{enumerable:!1,value:this}),e!==void 0&&O(this,t,e),t}internalBinaryRead(e,t,r,n){let s=n!=null?n:this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.appMetadata=e.bytes();break;default:let f=r.readUnknownField;if(f==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let u=e.skip(l);f!==!1&&(f===!0?g.onRead:f)(this.typeName,s,a,l,u)}}return s}internalBinaryWrite(e,t,r){e.appMetadata.length&&t.tag(1,p.LengthDelimited).bytes(e.appMetadata);let n=r.writeUnknownFields;return n!==!1&&(n==!0?g.onWrite:n)(this.typeName,e,t),t}},Br=new et,T=new _t.ServiceType("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:mr,O:gr},{name:"ListFlights",serverStreaming:!0,options:{},I:wr,O:vt},{name:"GetFlightInfo",options:{},I:D,O:vt},{name:"GetSchema",options:{},I:D,O:Ir},{name:"DoGet",serverStreaming:!0,options:{},I:_,O:me},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:me,O:Br},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:me,O:me},{name:"DoAction",serverStreaming:!0,options:{},I:kr,O:Or},{name:"ListActions",serverStreaming:!0,options:{},I:yr,O:br}]);var jt=j(require("@grpc/grpc-js")),ge=class extends jt.Client{constructor(t,r,n={},s={}){super(t,r,n);this._binaryOptions=s}handshake(t,r){let n=T.methods[0];return this.makeBidiStreamRequest(`/${T.typeName}/${n.name}`,s=>Buffer.from(n.I.toBinary(s,this._binaryOptions)),s=>n.O.fromBinary(s,this._binaryOptions),t,r)}listFlights(t,r,n){let s=T.methods[1];return this.makeServerStreamRequest(`/${T.typeName}/${s.name}`,o=>Buffer.from(s.I.toBinary(o,this._binaryOptions)),o=>s.O.fromBinary(o,this._binaryOptions),t,r,n)}getFlightInfo(t,r,n,s){let o=T.methods[2];return this.makeUnaryRequest(`/${T.typeName}/${o.name}`,a=>Buffer.from(o.I.toBinary(a,this._binaryOptions)),a=>o.O.fromBinary(a,this._binaryOptions),t,r,n,s)}getSchema(t,r,n,s){let o=T.methods[3];return this.makeUnaryRequest(`/${T.typeName}/${o.name}`,a=>Buffer.from(o.I.toBinary(a,this._binaryOptions)),a=>o.O.fromBinary(a,this._binaryOptions),t,r,n,s)}doGet(t,r,n){let s=T.methods[4];return this.makeServerStreamRequest(`/${T.typeName}/${s.name}`,o=>Buffer.from(s.I.toBinary(o,this._binaryOptions)),o=>s.O.fromBinary(o,this._binaryOptions),t,r,n)}doPut(t,r){let n=T.methods[5];return this.makeBidiStreamRequest(`/${T.typeName}/${n.name}`,s=>Buffer.from(n.I.toBinary(s,this._binaryOptions)),s=>n.O.fromBinary(s,this._binaryOptions),t,r)}doExchange(t,r){let n=T.methods[6];return this.makeBidiStreamRequest(`/${T.typeName}/${n.name}`,s=>Buffer.from(n.I.toBinary(s,this._binaryOptions)),s=>n.O.fromBinary(s,this._binaryOptions),t,r)}doAction(t,r,n){let s=T.methods[7];return this.makeServerStreamRequest(`/${T.typeName}/${s.name}`,o=>Buffer.from(s.I.toBinary(o,this._binaryOptions)),o=>s.O.fromBinary(o,this._binaryOptions),t,r,n)}listActions(t,r,n){let s=T.methods[8];return this.makeServerStreamRequest(`/${T.typeName}/${s.name}`,o=>Buffer.from(s.I.toBinary(o,this._binaryOptions)),o=>s.O.fromBinary(o,this._binaryOptions),t,r,n)}};var Ht="http://",Kt="https://",Gt=i=>{i=i.replace(/\/$/,"");let e;return i.startsWith(Ht)?(i=i.slice(Ht.length),e=!1,i.includes(":")||(i=`${i}:80`)):i.startsWith(Kt)&&(i=i.slice(Kt.length),e=!0,i.includes(":")||(i=`${i}:443`)),{url:i,safe:e}};var ye=j(require("@grpc/grpc-js"));var X=class{constructor(e){this._options=e;this.closed=!1;let{url:t,safe:r}=Gt(this._options.host),n=ye.credentials[r==null||r?"createSsl":"createInsecure"]();this.flightClient=new ge(t,n)}async*query(e,t,r="sql"){var d;if(this.closed)throw new Error("queryApi: already closed!");let n=this.flightClient,s={database:t,sql_query:e,query_type:r},o=_.create({ticket:new TextEncoder().encode(JSON.stringify(s))}),a=new ye.Metadata,l=this._options.token;l&&a.set("authorization",`Bearer ${l}`);let f=n.doGet(o,a),u=async function*(){for await(let m of f)yield ht(m.dataHeader.length),yield m.dataHeader,yield m.dataBody}(),h=await Jt.RecordBatchReader.from(u);for await(let m of h)for(let w=0;w<m.numRows;w++){let U=Object.create(null);for(let F=0;F<m.numCols;F++){let q=m.schema.fields[F].name,Zt=(d=m.getChildAt(F))==null?void 0:d.get(w);U[q]=Zt}yield U}f.cancel()}async close(){this.closed=!0,this.flightClient.close()}};var Xt=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
6
+ `,Z=class{constructor(e){this._mergeWriteOptions=e=>({...this._options.writeOptions,...e});var r;if(e==null)throw new W("No configuration specified!");this._options=e;let t=this._options.host;if(typeof t!="string")throw new W("No host specified!");t.endsWith("/")&&(this._options.host=t.substring(0,t.length-1)),this._queryApi=new X(this._options),this.transport=(r=this._options.transport)!=null?r:new bt(this._options),this._writeApi=new H(this.transport)}async write(e,t,r,n){var s;await this._writeApi.doWrite(Ne(e),(s=t!=null?t:this._options.database)!=null?s:xe(new Error(Xt)),r,this._mergeWriteOptions(n))}query(e,t,r="sql"){var n;return this._queryApi.query(e,(n=t!=null?t:this._options.database)!=null?n:xe(new Error(Xt)),r)}async close(){await this._writeApi.close(),await this._queryApi.close()}};0&&(module.exports={AbortError,DEFAULT_ConnectionOptions,DEFAULT_WriteOptions,HttpError,IllegalArgumentError,InfluxDBClient,Log,Point,RequestTimedOutError,consoleLogger,convertTime,convertTimeToNanos,createTextDecoderCombiner,currentTime,dateToProtocolTimestamp,escape,setLogger,useProcessHrtime,writableDataToLineProtocol});
7
+ //# sourceMappingURL=index.js.map
Binary file