UNPKG

@influxdata/influxdb3-client-browser

Version:
4 lines 276 kB
"use strict";var influxdb=(()=>{var $n=Object.defineProperty;var Uf=Object.getOwnPropertyDescriptor;var Mf=Object.getOwnPropertyNames;var Rf=Object.prototype.hasOwnProperty;var kf=(r,t,e)=>t in r?$n(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var cr=(r,t)=>{for(var e in t)$n(r,e,{get:t[e],enumerable:!0})},Cf=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Mf(t))!Rf.call(r,n)&&n!==e&&$n(r,n,{get:()=>t[n],enumerable:!(i=Uf(t,n))||i.enumerable});return r};var Vf=r=>Cf($n({},"__esModule",{value:!0}),r);var j=(r,t,e)=>kf(r,typeof t!="symbol"?t+"":t,e);var Mp={};cr(Mp,{AbortError:()=>Bi,DEFAULT_ConnectionOptions:()=>Xo,DEFAULT_QueryOptions:()=>Hn,DEFAULT_WriteOptions:()=>Yo,GetFieldTypeMissmatchError:()=>qn,HttpError:()=>ee,IllegalArgumentError:()=>lr,InfluxDBClient:()=>Wn,Log:()=>Fr,Point:()=>Di,PointValues:()=>ur,RequestTimedOutError:()=>Go,collectAll:()=>ll,consoleLogger:()=>Yc,convertTime:()=>aa,convertTimeToNanos:()=>oa,createTextDecoderCombiner:()=>Ko,currentTime:()=>nl,dateToProtocolTimestamp:()=>sl,escape:()=>Le,fromConnectionString:()=>Zo,fromEnv:()=>Qo,isNumber:()=>Zr,parsePrecision:()=>ra,precisionToV2ApiString:()=>ta,precisionToV3ApiString:()=>ea,setLogger:()=>Pf,useProcessHrtime:()=>il,writableDataToLineProtocol:()=>ca});var lr=class r extends Error{constructor(t){super(t),this.name="IllegalArgumentError",Object.setPrototypeOf(this,r.prototype)}},ee=class r extends Error{constructor(e,i,n,s,o,a){var c;super();this.statusCode=e;this.statusMessage=i;this.body=n;this.contentType=s;this.headers=o;j(this,"code");j(this,"json");if(Object.setPrototypeOf(this,r.prototype),a)this.message=a;else if(n&&(s!=null&&s.startsWith("application/json")||!s))try{if(this.json=JSON.parse(n),this.message=this.json.message,this.code=this.json.code,!this.message){let l=this.json;(c=l.data)!=null&&c.error_message?this.message=l.data.error_message:l.error&&(this.message=l.error)}}catch(l){}this.message||(this.message=`${e} ${i} : ${n}`),this.name="HttpError"}},Go=class r extends Error{constructor(){super(),Object.setPrototypeOf(this,r.prototype),this.name="RequestTimedOutError",this.message="Request timed out"}},Bi=class r extends Error{constructor(){super(),this.name="AbortError",Object.setPrototypeOf(this,r.prototype),this.message="Response aborted"}};function Ko(){let r=new TextDecoder("utf-8");return{concat(t,e){let i=new Uint8Array(t.length+e.length);return i.set(t),i.set(e,t.length),i},copy(t,e,i){let n=new Uint8Array(i-e);return n.set(t.subarray(e,i)),n},toUtf8String(t,e,i){return r.decode(t.subarray(e,i))}}}var Xo={timeout:1e4,queryTimeout:6e4},Yo={precision:"ns",gzipThreshold:1e3,noSync:!1},Hn={type:"sql"};function Zo(r){if(!r)throw Error("Connection string not set!");let t=new URL(r.trim(),"http://localhost"),e={host:r.indexOf("://")>0?t.origin+t.pathname:t.pathname};return t.searchParams.has("token")&&(e.token=t.searchParams.get("token")),t.searchParams.has("authScheme")&&(e.authScheme=t.searchParams.get("authScheme")),t.searchParams.has("database")&&(e.database=t.searchParams.get("database")),t.searchParams.has("timeout")&&(e.timeout=parseInt(t.searchParams.get("timeout"))),t.searchParams.has("precision")&&(e.writeOptions||(e.writeOptions={}),e.writeOptions.precision=ra(t.searchParams.get("precision"))),t.searchParams.has("gzipThreshold")&&(e.writeOptions||(e.writeOptions={}),e.writeOptions.gzipThreshold=parseInt(t.searchParams.get("gzipThreshold"))),t.searchParams.has("writeNoSync")&&(e.writeOptions||(e.writeOptions={}),e.writeOptions.noSync=Xc(t.searchParams.get("writeNoSync"))),e}function Qo(){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()};if(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=ra(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=Xc(process.env.INFLUX_WRITE_NO_SYNC)),process.env.INFLUX_GRPC_OPTIONS){let t=process.env.INFLUX_GRPC_OPTIONS.split(",");r.grpcOptions||(r.grpcOptions={});for(let e of t){let i=e.split("=");if(i.length!=2)continue;let n=parseInt(i[1]);Number.isNaN(n)&&(n=parseFloat(i[1]),Number.isNaN(n)&&(n=i[1])),r.grpcOptions[i[0]]=n}}return r}function Xc(r){return["true","1","t","y","yes"].includes(r.trim().toLowerCase())}function ta(r){switch(r){case"ns":case"us":case"ms":case"s":return r;default:throw Error(`Unsupported precision '${r}'`)}}function ea(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 ra(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 Yc={error(r,t){console.error(`ERROR: ${r}`,t||"")},warn(r,t){console.warn(`WARN: ${r}`,t||"")}},Jn=Yc,Fr={error(r,t){Jn.error(r,t)},warn(r,t){Jn.warn(r,t)}};function Pf(r){let t=Jn;return Jn=r,t}function ia(r,t){return function(e){let i="",n=0,s=0;for(;s<e.length;){let o=r.indexOf(e[s]);o>=0&&(i+=e.substring(n,s),i+=t[o],n=s+1),s++}return n==0?e:(n<e.length&&(i+=e.substring(n,e.length)),i)}}function jf(r,t){let e=ia(r,t);return i=>`"${e(i)}"`}var Le={measurement:ia(`, \r `,["\\,","\\ ","\\n","\\r","\\t"]),quoted:jf('"\\',['\\"',"\\\\"]),tag:ia(`, = \r `,["\\,","\\ ","\\=","\\n","\\r","\\t"])};var rl="000000000";function il(r){return!1}il(!0);var Zc=Date.now(),na=0;function sa(){{let r=Date.now();r!==Zc?(Zc=r,na=0):na++;let t=String(na);return String(r)+rl.substr(0,6-t.length)+t}}function Qc(){return String(Date.now())+rl.substr(0,3)}function tl(){return String(Date.now())}function el(){return String(Math.floor(Date.now()/1e3))}var nl={s:el,ms:tl,us:Qc,ns:sa,seconds:el,millis:tl,micros:Qc,nanos:sa},sl={s:r=>`${Math.floor(r.getTime()/1e3)}`,ms:r=>`${r.getTime()}`,us:r=>`${r.getTime()}000`,ns:r=>`${r.getTime()}000000`};function oa(r){return r===void 0?sa():typeof r=="string"?r.length>0?r:void 0:r instanceof Date?`${r.getTime()}000000`:String(typeof r=="number"?Math.floor(r):r)}var aa=(r,t="ns")=>r===void 0?nl[t]():typeof r=="string"?r.length>0?r:void 0:r instanceof Date?sl[t](r):String(typeof r=="number"?Math.floor(r):r);var Yr=r=>{throw r},ol=r=>r!==void 0,al=r=>r instanceof Array||r instanceof Object&&typeof r.length=="number"&&(r.length===0||Object.getOwnPropertyNames(r).some(t=>t==="0")),cl=r=>{let t=new Uint8Array(4);return t[0]=r>>0,t[1]=r>>8,t[2]=r>>16,t[3]=r>>24,t},ll=async r=>{let t=[];for await(let e of r)t.push(e);return t},Zr=r=>r===null||typeof r=="string"&&(r===""||r.indexOf(" ")!==-1)?!1:r!==""&&!isNaN(Number(r==null?void 0:r.toString())),ul=r=>Zr(r)?typeof r=="string"?Number(r)>=0:typeof r=="number"&&r>=0:!1;var ca=(r,t)=>{let e=al(r)&&typeof r!="string"?Array.from(r):[r];return e.length===0?[]:typeof e[0]=="string"?e:e.map(n=>n.toLineProtocol(void 0,t)).filter(ol)};var zf=r=>typeof r=="number"?"float":typeof r=="string"?"string":typeof r=="boolean"?"boolean":void 0,qn=class r extends Error{constructor(t,e,i){super(`field ${t} of type ${i} doesn't match expected type ${e}!`),this.name="GetFieldTypeMissmatchError",Object.setPrototypeOf(this,r.prototype)}},ur=class r{constructor(){j(this,"_name");j(this,"_time");j(this,"_tags",{});j(this,"_fields",{})}getMeasurement(){return this._name}setMeasurement(t){return this._name=t,this}getTimestamp(){return this._time}setTimestamp(t){return this._time=t,this}getTag(t){return this._tags[t]}setTag(t,e){return this._tags[t]=e,this}removeTag(t){return delete this._tags[t],this}getTagNames(){return Object.keys(this._tags)}getFloatField(t){return this.getField(t,"float")}setFloatField(t,e){let i;if(typeof e=="number"?i=e:i=parseFloat(e),!isFinite(i))throw new Error(`invalid float value for field '${t}': '${e}'!`);return this._fields[t]=["float",i],this}getIntegerField(t){return this.getField(t,"integer")}setIntegerField(t,e){let i;if(typeof e=="number"?i=e:i=parseInt(String(e)),isNaN(i)||i<=-9223372036854776e3||i>=9223372036854776e3)throw new Error(`invalid integer value for field '${t}': '${e}'!`);return this._fields[t]=["integer",Math.floor(i)],this}getUintegerField(t){return this.getField(t,"uinteger")}setUintegerField(t,e){if(typeof e=="number"){if(isNaN(e)||e<0||e>Number.MAX_SAFE_INTEGER)throw new Error(`uint value for field '${t}' out of range: ${e}`);this._fields[t]=["uinteger",Math.floor(e)]}else{let i=String(e);for(let n=0;n<i.length;n++){let s=i.charCodeAt(n);if(s<48||s>57)throw new Error(`uint value has an unsupported character at pos ${n}: ${e}`)}if(i.length>20||i.length===20&&i.localeCompare("18446744073709551615")>0)throw new Error(`uint value for field '${t}' out of range: ${i}`);this._fields[t]=["uinteger",+i]}return this}getStringField(t){return this.getField(t,"string")}setStringField(t,e){return e!=null&&(typeof e!="string"&&(e=String(e)),this._fields[t]=["string",e]),this}getBooleanField(t){return this.getField(t,"boolean")}setBooleanField(t,e){return this._fields[t]=["boolean",!!e],this}getField(t,e){let i=this._fields[t];if(!i)return;let[n,s]=i;if(e!==void 0&&e!==n)throw new qn(t,e,n);return s}getFieldType(t){let e=this._fields[t];if(e)return e[0]}setField(t,e,i){switch(i!=null?i:zf(e)){case"string":return this.setStringField(t,e);case"boolean":return this.setBooleanField(t,e);case"float":return this.setFloatField(t,e);case"integer":return this.setIntegerField(t,e);case"uinteger":return this.setUintegerField(t,e);case void 0:return this;default:throw new Error(`invalid field type for field '${t}': type -> ${i}, value -> ${e}!`)}}setFields(t){for(let[e,i]of Object.entries(t))this.setField(e,i);return this}removeField(t){return delete this._fields[t],this}getFieldNames(){return Object.keys(this._fields)}hasFields(){return this.getFieldNames().length>0}copy(){let t=new r;return t._name=this._name,t._time=this._time,t._tags=Object.fromEntries(Object.entries(this._tags)),t._fields=Object.fromEntries(Object.entries(this._fields).map(e=>[...e])),t}asPoint(t){return Di.fromValues(t?this.setMeasurement(t):this)}};var Wf=(r,t)=>{switch(r){case"string":return Le.quoted(t);case"boolean":return t?"T":"F";case"float":return`${t}`;case"integer":return`${t}i`;case"uinteger":return`${t}u`}},Di=class r{constructor(t){j(this,"_values");t instanceof ur?this._values=t:this._values=new ur,typeof t=="string"&&this._values.setMeasurement(t)}static measurement(t){return new r(t)}static fromValues(t){if(!t.getMeasurement()||t.getMeasurement()==="")throw new Error("Cannot convert values to point without measurement set!");return new r(t)}getMeasurement(){return this._values.getMeasurement()}setMeasurement(t){return t!==""&&this._values.setMeasurement(t),this}getTimestamp(){return this._values.getTimestamp()}setTimestamp(t){return this._values.setTimestamp(t),this}getTag(t){return this._values.getTag(t)}setTag(t,e){return this._values.setTag(t,e),this}removeTag(t){return this._values.removeTag(t),this}getTagNames(){return this._values.getTagNames()}getFloatField(t){return this._values.getFloatField(t)}setFloatField(t,e){return this._values.setFloatField(t,e),this}getIntegerField(t){return this._values.getIntegerField(t)}setIntegerField(t,e){return this._values.setIntegerField(t,e),this}getUintegerField(t){return this._values.getUintegerField(t)}setUintegerField(t,e){return this._values.setUintegerField(t,e),this}getStringField(t){return this._values.getStringField(t)}setStringField(t,e){return this._values.setStringField(t,e),this}getBooleanField(t){return this._values.getBooleanField(t)}setBooleanField(t,e){return this._values.setBooleanField(t,e),this}getField(t,e){return this._values.getField(t,e)}getFieldType(t){return this._values.getFieldType(t)}setField(t,e,i){return this._values.setField(t,e,i),this}setFields(t){return this._values.setFields(t),this}removeField(t){return this._values.removeField(t),this}getFieldNames(){return this._values.getFieldNames()}hasFields(){return this._values.hasFields()}copy(){return new r(this._values.copy())}toLineProtocol(t,e){if(!this._values.getMeasurement())return;let i="";if(this._values.getFieldNames().sort().forEach(a=>{if(a){let c=this._values.getFieldType(a),l=this._values.getField(a);if(c===void 0||l===void 0)return;let u=Wf(c,l);i.length>0&&(i+=","),i+=`${Le.tag(a)}=${u}`}}),i.length===0)return;let n="",s=this._values.getTagNames();if(e){let a=new Set(s),c=Object.keys(e);for(let l=c.length;l--;)a.has(c[l])&&c.splice(l,1);c.sort().forEach(l=>{if(l){let u=e[l];u&&(n+=",",n+=`${Le.tag(l)}=${Le.tag(u)}`)}})}s.sort().forEach(a=>{if(a){let c=this._values.getTag(a);c&&(n+=",",n+=`${Le.tag(a)}=${Le.tag(c)}`)}});let o=this._values.getTimestamp();return t?typeof t=="string"?o=aa(o,t):o=t(o):o=oa(o),`${Le.measurement(this.getMeasurement())}${n} ${i}${o!==void 0?` ${o}`:""}`}toString(){let t=this.toLineProtocol(void 0);return t||`invalid point: ${JSON.stringify(this,void 0)}`}};function la(r={}){let t=0,e={next:i=>{if(t===0&&r.next&&i!==null&&i!==void 0)return r.next(i)},error:i=>{t===0&&(t=1,r.error&&r.error(i))},complete:()=>{t===0&&(t=2,r.complete&&r.complete())},responseStarted:(i,n)=>{r.responseStarted&&r.responseStarted(i,n)}};return r.useCancellable&&(e.useCancellable=r.useCancellable.bind(r)),r.useResume&&(e.useResume=r.useResume.bind(r)),e}function Gn(r){let t={};return r.headers.forEach((e,i)=>{let n=t[i];n===void 0?t[i]=e:Array.isArray(n)?n.push(e):t[i]=[n,e]}),t}var Fi=class{constructor(t){this._connectionOptions=t;j(this,"chunkCombiner",Ko());j(this,"_defaultHeaders");j(this,"_url");j(this,"requestDecorator",function(){});var e;if(this._defaultHeaders={"content-type":"application/json; charset=utf-8",...t.headers},this._connectionOptions.token){let i=(e=this._connectionOptions.authScheme)!=null?e:"Token";this._defaultHeaders.Authorization=`${i} ${this._connectionOptions.token}`}this._url=String(this._connectionOptions.host),this._url.endsWith("/")&&(this._url=this._url.substring(0,this._url.length-1)),this._url.endsWith("/api/v2")&&(this._url=this._url.substring(0,this._url.length-7),Fr.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${this._url} !`))}send(t,e,i,n){let s=la(n),o=!1,a=i.signal,c,l=()=>{},u=l;if(n&&n.useCancellable){let d=new AbortController;a||(a=d.signal,i={...i,signal:a}),a.addEventListener("abort",()=>{u()}),n.useCancellable({cancel(){o=!0,d.abort()},isCancelled(){return o||a.aborted}})}this._fetch(t,e,i).then(async d=>{if(n!=null&&n.responseStarted&&s.responseStarted(Gn(d),d.status),await this._throwOnErrorResponse(d),d.body){let p=d.body.getReader(),I;do{if(c&&await c,o)break;if(I=await p.read(),s.next(I.value)===!1){let w=s.useResume;if(!w){let X="Unable to pause, useResume is not configured!";return await p.cancel(X),Promise.reject(new Error(X))}c=new Promise(X=>{u=()=>{X(),c=void 0,u=l},w(u)})}}while(!I.done)}else if(d.arrayBuffer){let p=await d.arrayBuffer();s.next(new Uint8Array(p))}else{let p=await d.text();s.next(new TextEncoder().encode(p))}}).catch(d=>{o||s.error(d)}).finally(()=>s.complete())}async _throwOnErrorResponse(t){if(t.status>=300){let e="";try{if(e=await t.text(),!e){let i=t.headers.get("x-influxdb-error");i&&(e=i)}}catch(i){throw Fr.warn("Unable to receive error body",i),new ee(t.status,t.statusText,void 0,t.headers.get("content-type"),Gn(t))}throw new ee(t.status,t.statusText,e,t.headers.get("content-type"),Gn(t))}}async*iterate(t,e,i){var s;let n=await this._fetch(t,e,i);if(await this._throwOnErrorResponse(n),n.body){let o=n.body.getReader();for(;;){let{value:a,done:c}=await o.read();if(c)break;if((s=i.signal)!=null&&s.aborted)throw await n.body.cancel(),new Bi;yield a}}else if(n.arrayBuffer){let o=await n.arrayBuffer();yield new Uint8Array(o)}else{let o=await n.text();yield new TextEncoder().encode(o)}}async request(t,e,i,n){var l,u;let s=await this._fetch(t,e,i),{headers:o}=s,a=o.get("content-type")||"";n&&n(Gn(s),s.status),await this._throwOnErrorResponse(s);let c=(u=(l=i.headers)==null?void 0:l.accept)!=null?u:a;if(c.includes("json"))return await s.json();if(c.includes("text")||c.startsWith("application/csv"))return await s.text()}_fetch(t,e,i){let{method:n,headers:s,...o}=i,a=`${this._url}${t}`,c={method:n,body:n==="GET"||n==="HEAD"?void 0:typeof e=="string"?e:JSON.stringify(e),headers:{...this._defaultHeaders,...s},credentials:"omit",...this._connectionOptions.transportOptions,...o};return this.requestDecorator(c,i,a),fetch(a,c)}};function Ar(r){let t=typeof r;if(t=="object"){if(Array.isArray(r))return"array";if(r===null)return"null"}return t}function ua(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}var Ue="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Kn=[];for(let r=0;r<Ue.length;r++)Kn[Ue[r].charCodeAt(0)]=r;Kn[45]=Ue.indexOf("+");Kn[95]=Ue.indexOf("/");function Ai(r){let t=r.length*3/4;r[r.length-2]=="="?t-=2:r[r.length-1]=="="&&(t-=1);let e=new Uint8Array(t),i=0,n=0,s,o=0;for(let a=0;a<r.length;a++){if(s=Kn[r.charCodeAt(a)],s===void 0)switch(r[a]){case"=":n=0;case` `:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(n){case 0:o=s,n=1;break;case 1:e[i++]=o<<2|(s&48)>>4,o=s,n=2;break;case 2:e[i++]=(o&15)<<4|(s&60)>>2,o=s,n=3;break;case 3:e[i++]=(o&3)<<6|s,n=0;break}}if(n==1)throw Error("invalid base64 string.");return e.subarray(0,i)}function Ni(r){let t="",e=0,i,n=0;for(let s=0;s<r.length;s++)switch(i=r[s],e){case 0:t+=Ue[i>>2],n=(i&3)<<4,e=1;break;case 1:t+=Ue[n|i>>4],n=(i&15)<<2,e=2;break;case 2:t+=Ue[n|i>>6],t+=Ue[i&63],e=0;break}return e&&(t+=Ue[n],t+="=",e==1&&(t+="=")),t}var Nr;(function(r){r.symbol=Symbol.for("protobuf-ts/unknown"),r.onRead=(e,i,n,s,o)=>{(t(i)?i[r.symbol]:i[r.symbol]=[]).push({no:n,wireType:s,data:o})},r.onWrite=(e,i,n)=>{for(let{no:s,wireType:o,data:a}of r.list(i))n.tag(s,o).raw(a)},r.list=(e,i)=>{if(t(e)){let n=e[r.symbol];return i?n.filter(s=>s.no==i):n}return[]},r.last=(e,i)=>r.list(e,i).slice(-1)[0];let t=e=>e&&Array.isArray(e[r.symbol])})(Nr||(Nr={}));function fa(r,t){return Object.assign(Object.assign({},r),t)}var nt;(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"})(nt||(nt={}));function fl(){let r=0,t=0;for(let i=0;i<28;i+=7){let n=this.buf[this.pos++];if(r|=(n&127)<<i,(n&128)==0)return this.assertBounds(),[r,t]}let e=this.buf[this.pos++];if(r|=(e&15)<<28,t=(e&112)>>4,(e&128)==0)return this.assertBounds(),[r,t];for(let i=3;i<=31;i+=7){let n=this.buf[this.pos++];if(t|=(n&127)<<i,(n&128)==0)return this.assertBounds(),[r,t]}throw new Error("invalid varint")}function Yn(r,t,e){for(let s=0;s<28;s=s+7){let o=r>>>s,a=!(!(o>>>7)&&t==0),c=(a?o|128:o)&255;if(e.push(c),!a)return}let i=r>>>28&15|(t&7)<<4,n=t>>3!=0;if(e.push((n?i|128:i)&255),!!n){for(let s=3;s<31;s=s+7){let o=t>>>s,a=!!(o>>>7),c=(a?o|128:o)&255;if(e.push(c),!a)return}e.push(t>>>31&1)}}var Xn=65536*65536;function da(r){let t=r[0]=="-";t&&(r=r.slice(1));let e=1e6,i=0,n=0;function s(o,a){let c=Number(r.slice(o,a));n*=e,i=i*e+c,i>=Xn&&(n=n+(i/Xn|0),i=i%Xn)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[t,i,n]}function Zn(r,t){if(t>>>0<=2097151)return""+(Xn*t+(r>>>0));let e=r&16777215,i=(r>>>24|t<<8)>>>0&16777215,n=t>>16&65535,s=e+i*6777216+n*6710656,o=i+n*8147497,a=n*2,c=1e7;s>=c&&(o+=Math.floor(s/c),s%=c),o>=c&&(a+=Math.floor(o/c),o%=c);function l(u,d){let p=u?String(u):"";return d?"0000000".slice(p.length)+p:p}return l(a,0)+l(o,a)+l(s,1)}function ha(r,t){if(r>=0){for(;r>127;)t.push(r&127|128),r=r>>>7;t.push(r)}else{for(let e=0;e<9;e++)t.push(r&127|128),r=r>>7;t.push(1)}}function dl(){let r=this.buf[this.pos++],t=r&127;if((r&128)==0)return this.assertBounds(),t;if(r=this.buf[this.pos++],t|=(r&127)<<7,(r&128)==0)return this.assertBounds(),t;if(r=this.buf[this.pos++],t|=(r&127)<<14,(r&128)==0)return this.assertBounds(),t;if(r=this.buf[this.pos++],t|=(r&127)<<21,(r&128)==0)return this.assertBounds(),t;r=this.buf[this.pos++],t|=(r&15)<<28;for(let e=5;(r&128)!==0&&e<10;e++)r=this.buf[this.pos++];if((r&128)!=0)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var tt;function $f(){let r=new DataView(new ArrayBuffer(8));tt=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}$f();function hl(r){if(!r)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}var pl=/^-?[0-9]+$/,ts=4294967296,Qn=2147483648,es=class{constructor(t,e){this.lo=t|0,this.hi=e|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let t=this.hi*ts+(this.lo>>>0);if(!Number.isSafeInteger(t))throw new Error("cannot convert to safe number");return t}},ft=class r extends es{static from(t){if(tt)switch(typeof t){case"string":if(t=="0")return this.ZERO;if(t=="")throw new Error("string is no integer");t=tt.C(t);case"number":if(t===0)return this.ZERO;t=tt.C(t);case"bigint":if(!t)return this.ZERO;if(t<tt.UMIN)throw new Error("signed value for ulong");if(t>tt.UMAX)throw new Error("ulong too large");return tt.V.setBigUint64(0,t,!0),new r(tt.V.getInt32(0,!0),tt.V.getInt32(4,!0))}else switch(typeof t){case"string":if(t=="0")return this.ZERO;if(t=t.trim(),!pl.test(t))throw new Error("string is no integer");let[e,i,n]=da(t);if(e)throw new Error("signed value for ulong");return new r(i,n);case"number":if(t==0)return this.ZERO;if(!Number.isSafeInteger(t))throw new Error("number is no integer");if(t<0)throw new Error("signed value for ulong");return new r(t,t/ts)}throw new Error("unknown value "+typeof t)}toString(){return tt?this.toBigInt().toString():Zn(this.lo,this.hi)}toBigInt(){return hl(tt),tt.V.setInt32(0,this.lo,!0),tt.V.setInt32(4,this.hi,!0),tt.V.getBigUint64(0,!0)}};ft.ZERO=new ft(0,0);var K=class r extends es{static from(t){if(tt)switch(typeof t){case"string":if(t=="0")return this.ZERO;if(t=="")throw new Error("string is no integer");t=tt.C(t);case"number":if(t===0)return this.ZERO;t=tt.C(t);case"bigint":if(!t)return this.ZERO;if(t<tt.MIN)throw new Error("signed long too small");if(t>tt.MAX)throw new Error("signed long too large");return tt.V.setBigInt64(0,t,!0),new r(tt.V.getInt32(0,!0),tt.V.getInt32(4,!0))}else switch(typeof t){case"string":if(t=="0")return this.ZERO;if(t=t.trim(),!pl.test(t))throw new Error("string is no integer");let[e,i,n]=da(t);if(e){if(n>Qn||n==Qn&&i!=0)throw new Error("signed long too small")}else if(n>=Qn)throw new Error("signed long too large");let s=new r(i,n);return e?s.negate():s;case"number":if(t==0)return this.ZERO;if(!Number.isSafeInteger(t))throw new Error("number is no integer");return t>0?new r(t,t/ts):new r(-t,-t/ts).negate()}throw new Error("unknown value "+typeof t)}isNegative(){return(this.hi&Qn)!==0}negate(){let t=~this.hi,e=this.lo;return e?e=~e+1:t+=1,new r(e,t)}toString(){if(tt)return this.toBigInt().toString();if(this.isNegative()){let t=this.negate();return"-"+Zn(t.lo,t.hi)}return Zn(this.lo,this.hi)}toBigInt(){return hl(tt),tt.V.setInt32(0,this.lo,!0),tt.V.setInt32(4,this.hi,!0),tt.V.getBigInt64(0,!0)}};K.ZERO=new K(0,0);var ml={readUnknownField:!0,readerFactory:r=>new pa(r)};function yl(r){return r?Object.assign(Object.assign({},ml),r):ml}var pa=class{constructor(t,e){this.varint64=fl,this.uint32=dl,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.textDecoder=e!=null?e:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let t=this.uint32(),e=t>>>3,i=t&7;if(e<=0||i<0||i>5)throw new Error("illegal tag: field no "+e+" wire type "+i);return[e,i]}skip(t){let e=this.pos;switch(t){case nt.Varint:for(;this.buf[this.pos++]&128;);break;case nt.Bit64:this.pos+=4;case nt.Bit32:this.pos+=4;break;case nt.LengthDelimited:let i=this.uint32();this.pos+=i;break;case nt.StartGroup:let n;for(;(n=this.tag()[1])!==nt.EndGroup;)this.skip(n);break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(e,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)}int64(){return new K(...this.varint64())}uint64(){return new ft(...this.varint64())}sint64(){let[t,e]=this.varint64(),i=-(t&1);return t=(t>>>1|(e&1)<<31)^i,e=e>>>1^i,new K(t,e)}bool(){let[t,e]=this.varint64();return t!==0||e!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new ft(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 t=this.uint32(),e=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(e,e+t)}string(){return this.textDecoder.decode(this.bytes())}};function M(r,t){if(!r)throw new Error(t)}function ma(r,t){throw new Error(t!=null?t:"Unexpected object: "+r)}var Hf=34028234663852886e22,Jf=-34028234663852886e22,qf=4294967295,Gf=2147483647,Kf=-2147483648;function Me(r){if(typeof r!="number")throw new Error("invalid int 32: "+typeof r);if(!Number.isInteger(r)||r>Gf||r<Kf)throw new Error("invalid int 32: "+r)}function fr(r){if(typeof r!="number")throw new Error("invalid uint 32: "+typeof r);if(!Number.isInteger(r)||r>qf||r<0)throw new Error("invalid uint 32: "+r)}function Er(r){if(typeof r!="number")throw new Error("invalid float 32: "+typeof r);if(Number.isFinite(r)&&(r>Hf||r<Jf))throw new Error("invalid float 32: "+r)}var gl={writeUnknownFields:!0,writerFactory:()=>new ya};function bl(r){return r?Object.assign(Object.assign({},gl),r):gl}var ya=class{constructor(t){this.stack=[],this.textEncoder=t!=null?t:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let t=0;for(let n=0;n<this.chunks.length;n++)t+=this.chunks[n].length;let e=new Uint8Array(t),i=0;for(let n=0;n<this.chunks.length;n++)e.set(this.chunks[n],i),i+=this.chunks[n].length;return this.chunks=[],e}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let t=this.finish(),e=this.stack.pop();if(!e)throw new Error("invalid state, fork stack empty");return this.chunks=e.chunks,this.buf=e.buf,this.uint32(t.byteLength),this.raw(t)}tag(t,e){return this.uint32((t<<3|e)>>>0)}raw(t){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(t),this}uint32(t){for(fr(t);t>127;)this.buf.push(t&127|128),t=t>>>7;return this.buf.push(t),this}int32(t){return Me(t),ha(t,this.buf),this}bool(t){return this.buf.push(t?1:0),this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){let e=this.textEncoder.encode(t);return this.uint32(e.byteLength),this.raw(e)}float(t){Er(t);let e=new Uint8Array(4);return new DataView(e.buffer).setFloat32(0,t,!0),this.raw(e)}double(t){let e=new Uint8Array(8);return new DataView(e.buffer).setFloat64(0,t,!0),this.raw(e)}fixed32(t){fr(t);let e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,t,!0),this.raw(e)}sfixed32(t){Me(t);let e=new Uint8Array(4);return new DataView(e.buffer).setInt32(0,t,!0),this.raw(e)}sint32(t){return Me(t),t=(t<<1^t>>31)>>>0,ha(t,this.buf),this}sfixed64(t){let e=new Uint8Array(8),i=new DataView(e.buffer),n=K.from(t);return i.setInt32(0,n.lo,!0),i.setInt32(4,n.hi,!0),this.raw(e)}fixed64(t){let e=new Uint8Array(8),i=new DataView(e.buffer),n=ft.from(t);return i.setInt32(0,n.lo,!0),i.setInt32(4,n.hi,!0),this.raw(e)}int64(t){let e=K.from(t);return Yn(e.lo,e.hi,this.buf),this}sint64(t){let e=K.from(t),i=e.hi>>31,n=e.lo<<1^i,s=(e.hi<<1|e.lo>>>31)^i;return Yn(n,s,this.buf),this}uint64(t){let e=ft.from(t);return Yn(e.lo,e.hi,this.buf),this}};var _l={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},wl={ignoreUnknownFields:!1};function ga(r){return r?Object.assign(Object.assign({},wl),r):wl}function ba(r){return r?Object.assign(Object.assign({},_l),r):_l}function _a(r,t){var e,i;let n=Object.assign(Object.assign({},r),t);return n.typeRegistry=[...(e=r==null?void 0:r.typeRegistry)!==null&&e!==void 0?e:[],...(i=t==null?void 0:t.typeRegistry)!==null&&i!==void 0?i:[]],n}var rs=Symbol.for("protobuf-ts/message-type");function Qr(r){let t=!1,e=[];for(let i=0;i<r.length;i++){let n=r.charAt(i);n=="_"?t=!0:/\d/.test(n)?(e.push(n),t=!0):t?(e.push(n.toUpperCase()),t=!1):i==0?e.push(n.toLowerCase()):e.push(n)}return e.join("")}var h;(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"})(h||(h={}));var Tt;(function(r){r[r.BIGINT=0]="BIGINT",r[r.STRING=1]="STRING",r[r.NUMBER=2]="NUMBER"})(Tt||(Tt={}));var Ei;(function(r){r[r.NO=0]="NO",r[r.PACKED=1]="PACKED",r[r.UNPACKED=2]="UNPACKED"})(Ei||(Ei={}));function Il(r){var t,e,i,n;return r.localName=(t=r.localName)!==null&&t!==void 0?t:Qr(r.name),r.jsonName=(e=r.jsonName)!==null&&e!==void 0?e:Qr(r.name),r.repeat=(i=r.repeat)!==null&&i!==void 0?i:Ei.NO,r.opt=(n=r.opt)!==null&&n!==void 0?n:r.repeat||r.oneof?!1:r.kind=="message",r}function vl(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 is=class{constructor(t){var e;this.fields=(e=t.fields)!==null&&e!==void 0?e:[]}prepare(){if(this.data)return;let t=[],e=[],i=[];for(let n of this.fields)if(n.oneof)i.includes(n.oneof)||(i.push(n.oneof),t.push(n.oneof),e.push(n.oneof));else switch(e.push(n.localName),n.kind){case"scalar":case"enum":(!n.opt||n.repeat)&&t.push(n.localName);break;case"message":n.repeat&&t.push(n.localName);break;case"map":t.push(n.localName);break}this.data={req:t,known:e,oneofs:Object.values(i)}}is(t,e,i=!1){if(e<0)return!0;if(t==null||typeof t!="object")return!1;this.prepare();let n=Object.keys(t),s=this.data;if(n.length<s.req.length||s.req.some(o=>!n.includes(o))||!i&&n.some(o=>!s.known.includes(o)))return!1;if(e<1)return!0;for(let o of s.oneofs){let a=t[o];if(!vl(a))return!1;if(a.oneofKind===void 0)continue;let c=this.fields.find(l=>l.localName===a.oneofKind);if(!c||!this.field(a[a.oneofKind],c,i,e))return!1}for(let o of this.fields)if(o.oneof===void 0&&!this.field(t[o.localName],o,i,e))return!1;return!0}field(t,e,i,n){let s=e.repeat;switch(e.kind){case"scalar":return t===void 0?e.opt:s?this.scalars(t,e.T,n,e.L):this.scalar(t,e.T,e.L);case"enum":return t===void 0?e.opt:s?this.scalars(t,h.INT32,n):this.scalar(t,h.INT32);case"message":return t===void 0?!0:s?this.messages(t,e.T(),i,n):this.message(t,e.T(),i,n);case"map":if(typeof t!="object"||t===null)return!1;if(n<2)return!0;if(!this.mapKeys(t,e.K,n))return!1;switch(e.V.kind){case"scalar":return this.scalars(Object.values(t),e.V.T,n,e.V.L);case"enum":return this.scalars(Object.values(t),h.INT32,n);case"message":return this.messages(Object.values(t),e.V.T(),i,n)}break}return!0}message(t,e,i,n){return i?e.isAssignable(t,n):e.is(t,n)}messages(t,e,i,n){if(!Array.isArray(t))return!1;if(n<2)return!0;if(i){for(let s=0;s<t.length&&s<n;s++)if(!e.isAssignable(t[s],n-1))return!1}else for(let s=0;s<t.length&&s<n;s++)if(!e.is(t[s],n-1))return!1;return!0}scalar(t,e,i){let n=typeof t;switch(e){case h.UINT64:case h.FIXED64:case h.INT64:case h.SFIXED64:case h.SINT64:switch(i){case Tt.BIGINT:return n=="bigint";case Tt.NUMBER:return n=="number"&&!isNaN(t);default:return n=="string"}case h.BOOL:return n=="boolean";case h.STRING:return n=="string";case h.BYTES:return t instanceof Uint8Array;case h.DOUBLE:case h.FLOAT:return n=="number"&&!isNaN(t);default:return n=="number"&&Number.isInteger(t)}}scalars(t,e,i,n){if(!Array.isArray(t))return!1;if(i<2)return!0;if(Array.isArray(t)){for(let s=0;s<t.length&&s<i;s++)if(!this.scalar(t[s],e,n))return!1}return!0}mapKeys(t,e,i){let n=Object.keys(t);switch(e){case h.INT32:case h.FIXED32:case h.SFIXED32:case h.SINT32:case h.UINT32:return this.scalars(n.slice(0,i).map(s=>parseInt(s)),e,i);case h.BOOL:return this.scalars(n.slice(0,i).map(s=>s=="true"?!0:s=="false"?!1:s),e,i);default:return this.scalars(n,e,i,Tt.STRING)}}};function Ft(r,t){switch(t){case Tt.BIGINT:return r.toBigInt();case Tt.NUMBER:return r.toNumber();default:return r.toString()}}var ns=class{constructor(t){this.info=t}prepare(){var t;if(this.fMap===void 0){this.fMap={};let e=(t=this.info.fields)!==null&&t!==void 0?t:[];for(let i of e)this.fMap[i.name]=i,this.fMap[i.jsonName]=i,this.fMap[i.localName]=i}}assert(t,e,i){if(!t){let n=Ar(i);throw(n=="number"||n=="boolean")&&(n=i.toString()),new Error(`Cannot parse JSON ${n} for ${this.info.typeName}#${e}`)}}read(t,e,i){this.prepare();let n=[];for(let[s,o]of Object.entries(t)){let a=this.fMap[s];if(!a){if(!i.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}let c=a.localName,l;if(a.oneof){if(o===null&&(a.kind!=="enum"||a.T()[0]!=="google.protobuf.NullValue"))continue;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),l=e[a.oneof]={oneofKind:c}}else l=e;if(a.kind=="map"){if(o===null)continue;this.assert(ua(o),a.name,o);let u=l[c];for(let[d,p]of Object.entries(o)){this.assert(p!==null,a.name+" map value",null);let I;switch(a.V.kind){case"message":I=a.V.T().internalJsonRead(p,i);break;case"enum":if(I=this.enum(a.V.T(),p,a.name,i.ignoreUnknownFields),I===!1)continue;break;case"scalar":I=this.scalar(p,a.V.T,a.V.L,a.name);break}this.assert(I!==void 0,a.name+" map value",p);let w=d;a.K==h.BOOL&&(w=w=="true"?!0:w=="false"?!1:w),w=this.scalar(w,a.K,Tt.STRING,a.name).toString(),u[w]=I}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);let u=l[c];for(let d of o){this.assert(d!==null,a.name,null);let p;switch(a.kind){case"message":p=a.T().internalJsonRead(d,i);break;case"enum":if(p=this.enum(a.T(),d,a.name,i.ignoreUnknownFields),p===!1)continue;break;case"scalar":p=this.scalar(d,a.T,a.L,a.name);break}this.assert(p!==void 0,a.name,o),u.push(p)}}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}l[c]=a.T().internalJsonRead(o,i,l[c]);break;case"enum":if(o===null)continue;let u=this.enum(a.T(),o,a.name,i.ignoreUnknownFields);if(u===!1)continue;l[c]=u;break;case"scalar":if(o===null)continue;l[c]=this.scalar(o,a.T,a.L,a.name);break}}}enum(t,e,i,n){if(t[0]=="google.protobuf.NullValue"&&M(e===null||e==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${i}, enum ${t[0]} only accepts null.`),e===null)return 0;switch(typeof e){case"number":return M(Number.isInteger(e),`Unable to parse field ${this.info.typeName}#${i}, enum can only be integral number, got ${e}.`),e;case"string":let s=e;t[2]&&e.substring(0,t[2].length)===t[2]&&(s=e.substring(t[2].length));let o=t[1][s];return typeof o=="undefined"&&n?!1:(M(typeof o=="number",`Unable to parse field ${this.info.typeName}#${i}, enum ${t[0]} has no value for "${e}".`),o)}M(!1,`Unable to parse field ${this.info.typeName}#${i}, cannot parse enum value from ${typeof e}".`)}scalar(t,e,i,n){let s;try{switch(e){case h.DOUBLE:case h.FLOAT:if(t===null)return 0;if(t==="NaN")return Number.NaN;if(t==="Infinity")return Number.POSITIVE_INFINITY;if(t==="-Infinity")return Number.NEGATIVE_INFINITY;if(t===""){s="empty string";break}if(typeof t=="string"&&t.trim().length!==t.length){s="extra whitespace";break}if(typeof t!="string"&&typeof t!="number")break;let o=Number(t);if(Number.isNaN(o)){s="not a number";break}if(!Number.isFinite(o)){s="too large or small";break}return e==h.FLOAT&&Er(o),o;case h.INT32:case h.FIXED32:case h.SFIXED32:case h.SINT32:case h.UINT32:if(t===null)return 0;let a;if(typeof t=="number"?a=t:t===""?s="empty string":typeof t=="string"&&(t.trim().length!==t.length?s="extra whitespace":a=Number(t)),a===void 0)break;return e==h.UINT32?fr(a):Me(a),a;case h.INT64:case h.SFIXED64:case h.SINT64:if(t===null)return Ft(K.ZERO,i);if(typeof t!="number"&&typeof t!="string")break;return Ft(K.from(t),i);case h.FIXED64:case h.UINT64:if(t===null)return Ft(ft.ZERO,i);if(typeof t!="number"&&typeof t!="string")break;return Ft(ft.from(t),i);case h.BOOL:if(t===null)return!1;if(typeof t!="boolean")break;return t;case h.STRING:if(t===null)return"";if(typeof t!="string"){s="extra whitespace";break}try{encodeURIComponent(t)}catch(c){c="invalid UTF8";break}return t;case h.BYTES:if(t===null||t==="")return new Uint8Array(0);if(typeof t!="string")break;return Ai(t)}}catch(o){s=o.message}this.assert(!1,n+(s?" - "+s:""),t)}};var ss=class{constructor(t){var e;this.fields=(e=t.fields)!==null&&e!==void 0?e:[]}write(t,e){let i={},n=t;for(let s of this.fields){if(!s.oneof){let l=this.field(s,n[s.localName],e);l!==void 0&&(i[e.useProtoFieldName?s.name:s.jsonName]=l);continue}let o=n[s.oneof];if(o.oneofKind!==s.localName)continue;let a=s.kind=="scalar"||s.kind=="enum"?Object.assign(Object.assign({},e),{emitDefaultValues:!0}):e,c=this.field(s,o[s.localName],a);M(c!==void 0),i[e.useProtoFieldName?s.name:s.jsonName]=c}return i}field(t,e,i){let n;if(t.kind=="map"){M(typeof e=="object"&&e!==null);let s={};switch(t.V.kind){case"scalar":for(let[c,l]of Object.entries(e)){let u=this.scalar(t.V.T,l,t.name,!1,!0);M(u!==void 0),s[c.toString()]=u}break;case"message":let o=t.V.T();for(let[c,l]of Object.entries(e)){let u=this.message(o,l,t.name,i);M(u!==void 0),s[c.toString()]=u}break;case"enum":let a=t.V.T();for(let[c,l]of Object.entries(e)){M(l===void 0||typeof l=="number");let u=this.enum(a,l,t.name,!1,!0,i.enumAsInteger);M(u!==void 0),s[c.toString()]=u}break}(i.emitDefaultValues||Object.keys(s).length>0)&&(n=s)}else if(t.repeat){M(Array.isArray(e));let s=[];switch(t.kind){case"scalar":for(let c=0;c<e.length;c++){let l=this.scalar(t.T,e[c],t.name,t.opt,!0);M(l!==void 0),s.push(l)}break;case"enum":let o=t.T();for(let c=0;c<e.length;c++){M(e[c]===void 0||typeof e[c]=="number");let l=this.enum(o,e[c],t.name,t.opt,!0,i.enumAsInteger);M(l!==void 0),s.push(l)}break;case"message":let a=t.T();for(let c=0;c<e.length;c++){let l=this.message(a,e[c],t.name,i);M(l!==void 0),s.push(l)}break}(i.emitDefaultValues||s.length>0||i.emitDefaultValues)&&(n=s)}else switch(t.kind){case"scalar":n=this.scalar(t.T,e,t.name,t.opt,i.emitDefaultValues);break;case"enum":n=this.enum(t.T(),e,t.name,t.opt,i.emitDefaultValues,i.enumAsInteger);break;case"message":n=this.message(t.T(),e,t.name,i);break}return n}enum(t,e,i,n,s,o){if(t[0]=="google.protobuf.NullValue")return!s&&!n?void 0:null;if(e===void 0){M(n);return}if(!(e===0&&!s&&!n))return M(typeof e=="number"),M(Number.isInteger(e)),o||!t[1].hasOwnProperty(e)?e:t[2]?t[2]+t[1][e]:t[1][e]}message(t,e,i,n){return e===void 0?n.emitDefaultValues?null:void 0:t.internalJsonWrite(e,n)}scalar(t,e,i,n,s){if(e===void 0){M(n);return}let o=s||n;switch(t){case h.INT32:case h.SFIXED32:case h.SINT32:return e===0?o?0:void 0:(Me(e),e);case h.FIXED32:case h.UINT32:return e===0?o?0:void 0:(fr(e),e);case h.FLOAT:Er(e);case h.DOUBLE:return e===0?o?0:void 0:(M(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e);case h.STRING:return e===""?o?"":void 0:(M(typeof e=="string"),e);case h.BOOL:return e===!1?o?!1:void 0:(M(typeof e=="boolean"),e);case h.UINT64:case h.FIXED64:M(typeof e=="number"||typeof e=="string"||typeof e=="bigint");let a=ft.from(e);return a.isZero()&&!o?void 0:a.toString();case h.INT64:case h.SFIXED64:case h.SINT64:M(typeof e=="number"||typeof e=="string"||typeof e=="bigint");let c=K.from(e);return c.isZero()&&!o?void 0:c.toString();case h.BYTES:return M(e instanceof Uint8Array),e.byteLength?Ni(e):o?"":void 0}}};function Li(r,t=Tt.STRING){switch(r){case h.BOOL:return!1;case h.UINT64:case h.FIXED64:return Ft(ft.ZERO,t);case h.INT64:case h.SFIXED64:case h.SINT64:return Ft(K.ZERO,t);case h.DOUBLE:case h.FLOAT:return 0;case h.BYTES:return new Uint8Array(0);case h.STRING:return"";default:return 0}}var os=class{constructor(t){this.info=t}prepare(){var t;if(!this.fieldNoToField){let e=(t=this.info.fields)!==null&&t!==void 0?t:[];this.fieldNoToField=new Map(e.map(i=>[i.no,i]))}}read(t,e,i,n){this.prepare();let s=n===void 0?t.len:t.pos+n;for(;t.pos<s;){let[o,a]=t.tag(),c=this.fieldNoToField.get(o);if(!c){let p=i.readUnknownField;if(p=="throw")throw new Error(`Unknown field ${o} (wire type ${a}) for ${this.info.typeName}`);let I=t.skip(a);p!==!1&&(p===!0?Nr.onRead:p)(this.info.typeName,e,o,a,I);continue}let l=e,u=c.repeat,d=c.localName;switch(c.oneof&&(l=l[c.oneof],l.oneofKind!==d&&(l=e[c.oneof]={oneofKind:d})),c.kind){case"scalar":case"enum":let p=c.kind=="enum"?h.INT32:c.T,I=c.kind=="scalar"?c.L:void 0;if(u){let ut=l[d];if(a==nt.LengthDelimited&&p!=h.STRING&&p!=h.BYTES){let mt=t.uint32()+t.pos;for(;t.pos<mt;)ut.push(this.scalar(t,p,I))}else ut.push(this.scalar(t,p,I))}else l[d]=this.scalar(t,p,I);break;case"message":if(u){let ut=l[d],mt=c.T().internalBinaryRead(t,t.uint32(),i);ut.push(mt)}else l[d]=c.T().internalBinaryRead(t,t.uint32(),i,l[d]);break;case"map":let[w,X]=this.mapEntry(c,t,i);l[d][w]=X;break}}}mapEntry(t,e,i){let n=e.uint32(),s=e.pos+n,o,a;for(;e.pos<s;){let[c,l]=e.tag();switch(c){case 1:t.K==h.BOOL?o=e.bool().toString():o=this.scalar(e,t.K,Tt.STRING);break;case 2:switch(t.V.kind){case"scalar":a=this.scalar(e,t.V.T,t.V.L);break;case"enum":a=e.int32();break;case"message":a=t.V.T().internalBinaryRead(e,e.uint32(),i);break}break;default:throw new Error(`Unknown field ${c} (wire type ${l}) in map entry for ${this.info.typeName}#${t.name}`)}}if(o===void 0){let c=Li(t.K);o=t.K==h.BOOL?c.toString():c}if(a===void 0)switch(t.V.kind){case"scalar":a=Li(t.V.T,t.V.L);break;case"enum":a=0;break;case"message":a=t.V.T().create();break}return[o,a]}scalar(t,e,i){switch(e){case h.INT32:return t.int32();case h.STRING:return t.string();case h.BOOL:return t.bool();case h.DOUBLE:return t.double();case h.FLOAT:return t.float();case h.INT64:return Ft(t.int64(),i);case h.UINT64:return Ft(t.uint64(),i);case h.FIXED64:return Ft(t.fixed64(),i);case h.FIXED32:return t.fixed32();case h.BYTES:return t.bytes();case h.UINT32:return t.uint32();case h.SFIXED32:return t.sfixed32();case h.SFIXED64:return Ft(t.sfixed64(),i);case h.SINT32:return t.sint32();case h.SINT64:return Ft(t.sint64(),i)}}};var as=class{constructor(t){this.info=t}prepare(){if(!this.fields){let t=this.info.fields?this.info.fields.concat():[];this.fields=t.sort((e,i)=>e.no-i.no)}}write(t,e,i){this.prepare();for(let s of this.fields){let o,a,c=s.repeat,l=s.localName;if(s.oneof){let u=t[s.oneof];if(u.oneofKind!==l)continue;o=u[l],a=!0}else o=t[l],a=!1;switch(s.kind){case"scalar":case"enum":let u=s.kind=="enum"?h.INT32:s.T;if(c)if(M(Array.isArray(o)),c==Ei.PACKED)this.packed(e,u,s.no,o);else for(let d of o)this.scalar(e,u,s.no,d,!0);else o===void 0?M(s.opt):this.scalar(e,u,s.no,o,a||s.opt);break;case"message":if(c){M(Array.isArray(o));for(let d of o)this.message(e,i,s.T(),s.no,d)}else this.message(e,i,s.T(),s.no,o);break;case"map":M(typeof o=="object"&&o!==null);for(let[d,p]of Object.entries(o))this.mapEntry(e,i,s,d,p);break}}let n=i.writeUnknownFields;n!==!1&&(n===!0?Nr.onWrite:n)(this.info.typeName,t,e)}mapEntry(t,e,i,n,s){t.tag(i.no,nt.LengthDelimited),t.fork();let o=n;switch(i.K){case h.INT32:case h.FIXED32:case h.UINT32:case h.SFIXED32:case h.SINT32:o=Number.parseInt(n);break;case h.BOOL:M(n=="true"||n=="false"),o=n=="true";break}switch(this.scalar(t,i.K,1,o,!0),i.V.kind){case"scalar":this.scalar(t,i.V.T,2,s,!0);break;case"enum":this.scalar(t,h.INT32,2,s,!0);break;case"message":this.message(t,e,i.V.T(),2,s);break}t.join()}message(t,e,i,n,s){s!==void 0&&(i.internalBinaryWrite(s,t.tag(n,nt.LengthDelimited).fork(),e),t.join())}scalar(t,e,i,n,s){let[o,a,c]=this.scalarInfo(e,n);(!c||s)&&(t.tag(i,o),t[a](n))}packed(t,e,i,n){if(!n.length)return;M(e!==h.BYTES&&e!==h.STRING),t.tag(i,nt.LengthDelimited),t.fork();let[,s]=this.scalarInfo(e);for(let o=0;o<n.length;o++)t[s](n[o]);t.join()}scalarInfo(t,e){let i=nt.Varint,n,s=e===void 0,o=e===0;switch(t){case h.INT32:n="int32";break;case h.STRING:o=s||!e.length,i=nt.LengthDelimited,n="string";break;case h.BOOL:o=e===!1,n="bool";break;case h.UINT32:n="uint32";break;case h.DOUBLE:i=nt.Bit64,n="double";break;case h.FLOAT:i=nt.Bit32,n="float";break;case h.INT64:o=s||K.from(e).isZero(),n="int64";break;case h.UINT64:o=s||ft.from(e).isZero(),n="uint64";break;case h.FIXED64:o=s||ft.from(e).isZero(),i=nt.Bit64,n="fixed64";break;case h.BYTES:o=s||!e.byteLength,i=nt.LengthDelimited,n="bytes";break;case h.FIXED32:i=nt.Bit32,n="fixed32";break;case h.SFIXED32:i=nt.Bit32,n="sfixed32";break;case h.SFIXED64:o=s||K.from(e).isZero(),i=nt.Bit64,n="sfixed64";break;case h.SINT32:n="sint32";break;case h.SINT64:o=s||K.from(e).isZero(),n="sint64";break}return[i,n,s||o]}};function Sl(r){let t=r.messagePrototype?Object.create(r.messagePrototype):Object.defineProperty({},rs,{value:r});for(let e of r.fields){let i=e.localName;if(!e.opt)if(e.oneof)t[e.oneof]={oneofKind:void 0};else if(e.repeat)t[i]=[];else switch(e.kind){case"scalar":t[i]=Li(e.T,e.L);break;case"enum":t[i]=0;break;case"map":t[i]={};break}}return t}function cs(r,t,e){let i,n=e,s;for(let o of r.fields){let a=o.localName;if(o.oneof){let c=n[o.oneof];if((c==null?void 0:c.oneofKind)==null)continue;if(i=c[a],s=t[o.oneof],s.oneofKind=c.oneofKind,i==null){delete s[a];continue}}else if(i=n[a],s=t,i==null)continue;switch(o.repeat&&(s[a].length=i.length),o.kind){case"scalar":case"enum":if(o.repeat)for(let l=0;l<i.length;l++)s[a][l]=i[l];else s[a]=i;break;case"message":let c=o.T();if(o.repeat)for(let l=0;l<i.length;l++)s[a][l]=c.create(i[l]);else s[a]===void 0?s[a]=c.create(i):c.mergePartial(s[a],i);break;case"map":switch(o.V.kind){case"scalar":case"enum":Object.assign(s[a],i);break;case"message":let l=o.V.T();for(let u of Object.keys(i))s[a][u]=l.create(i[u]);break}break}}}function Ol(r,t,e){if(t===e)return!0;if(!t||!e)return!1;for(let i of r.fields){let n=i.localName,s=i.oneof?t[i.oneof][n]:t[n],o=i.oneof?e[i.oneof][n]:e[n];switch(i.kind){case"enum":case"scalar":let a=i.kind=="enum"?h.INT32:i.T;if(!(i.repeat?xl(a,s,o):Bl(a,s,o)))return!1;break;case"map":if(!(i.V.kind=="message"?Tl(i.V.T(),ls(s),ls(o)):xl(i.V.kind=="enum"?h.INT32:i.V.T,ls(s),ls(o))))return!1;break;case"message":let c=i.T();if(!(i.repeat?Tl(c,s,o):c.equals(s,o)))return!1;break}}return!0}var ls=Object.values;function Bl(r,t,e){if(t===e)return!0;if(r!==h.BYTES)return!1;let i=t,n=e;if(i.length!==n.length)return!1;for(let s=0;s<i.length;s++)if(i[s]!=n[s])return!1;return!0}function xl(r,t,e){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!Bl(r,t[i],e[i]))return!1;return!0}function Tl(r,t,e){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!r.equals(t[i],e[i]))return!1;return!0}var Dl=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({})),Xf=Dl[rs]={},et=class{constructor(t,e,i){this.defaultCheckDepth=16,this.typeName=t,this.fields=e.map(Il),this.options=i!=null?i:{},Xf.value=this,this.messagePrototype=Object.create(null,Dl),this.refTypeCheck=new is(this),this.refJsonReader=new ns(this),this.refJsonWriter=new ss(this),this.refBinReader=new os(this),this.refBinWriter=new as(this)}create(t){let e=Sl(this);return t!==void 0&&cs(this,e,t),e}clone(t){let e=this.create();return cs(this,e,t),e}equals(t,e){return Ol(this,t,e)}is(t,e=this.defaultCheckDepth){return this.refTypeCheck.is(t,e,!1)}isAssignable(t,e=this.defaultCheckDepth){return this.refTypeCheck.is(t,e,!0)}mergePartial(t,e){cs(this,t,e)}fromBinary(t,e){let i=yl(e);return this.internalBinaryRead(i.readerFactory(t),t.byteLength,i)}fromJson(t,e){return this.internalJsonRead(t,ga(e))}fromJsonString(t,e){let i=JSON.parse(t);return this.fromJson(i,e)}toJson(t,e){return this.internalJsonWrite(t,ba(e))}toJsonString(t,e){var i;let n=this.toJson(t,e);return JSON.stringify(n,null,(i=e==null?void 0:e.prettySpaces)!==null&&i!==void 0?i:0)}toBinary(t,e){let i=bl(e);return this.internalBinaryWrite(t,i.writerFactory(),i).finish()}internalJsonRead(t,e,i){if(t!==null&&typeof t=="object"&&!Array.isArray(t)){let n=i!=null?i:this.create();return this.refJsonReader.read(t,n,e),n}throw new Error(`Unable to parse message ${this.typeName} from JSON ${Ar(t)}.`)}internalJsonWrite(t,e){return this.refJsonWriter.write(t,e)}internalBinaryWrite(t,e,i){return this.refBinWriter.write(t,e,i),e}internalBinaryRead(t,e,i,n){let s=n!=null?n:this.create();return this.refBinReader.read(t,s,i,e),s}};function Fl(r,t){var e,i,n;let s=r;return s.service=t,s.localName=(e=s.localName)!==null&&e!==void 0?e:Qr(s.name),s.serverStreaming=!!s.serverStreaming,s.clientStreaming=!!s.clientStreaming,s.options=(i=s.options)!==null&&i!==void 0?i:{},s.idempotency=(n=s.idempotency)!==null&&n!==void 0?n:void 0,s}var Ui=class{constructor(t,e,i){this.typeName=t,this.methods=e.map(n=>Fl(n,this)),this.options=i!=null?i: