spacewave 0.57.22 → 0.57.24

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,2 @@
1
+ import{t as e}from"./rolldown-runtime-Csi-cuKc.mjs";import{Buffer as t}from"node:buffer";function n(){var e=typeof SuppressedError==`function`?SuppressedError:function(e,t){var n=Error();return n.name=`SuppressedError`,n.error=e,n.suppressed=t,n},t={},n=[];function r(e,t){if(t!=null){if(Object(t)!==t)throw TypeError(`using declarations can only be used with objects, functions, null, or undefined.`);if(e)var r=t[Symbol.asyncDispose||Symbol.for(`Symbol.asyncDispose`)];if(r===void 0&&(r=t[Symbol.dispose||Symbol.for(`Symbol.dispose`)],e))var i=r;if(typeof r!=`function`)throw TypeError(`Object is not disposable.`);i&&(r=function(){try{i.call(t)}catch(e){return Promise.reject(e)}}),n.push({v:t,d:r,a:e})}else e&&n.push({d:t,a:e});return t}return{e:t,u:r.bind(null,!1),a:r.bind(null,!0),d:function(){var r,i=this.e,a=0;function o(){for(;r=n.pop();)try{if(!r.a&&a===1)return a=0,n.push(r),Promise.resolve().then(o);if(r.d){var e=r.d.call(r.v);if(r.a)return a|=2,Promise.resolve(e).then(o,s)}else a|=1}catch(e){return s(e)}if(a===1)return i===t?Promise.resolve():Promise.reject(i);if(i!==t)throw i}function s(n){return i=i===t?n:new e(n,i),o()}return o()}}}function r(e,t){if(!e)throw Error(t)}function i(e){if(typeof e!=`number`)throw Error(`invalid int 32: `+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw Error(`invalid int 32: `+e)}function a(e){if(typeof e!=`number`)throw Error(`invalid uint 32: `+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw Error(`invalid uint 32: `+e)}function o(e){if(typeof e!=`number`)throw Error(`invalid float 32: `+typeof e);if(Number.isFinite(e)&&(e>34028234663852886e22||e<-34028234663852886e22))throw Error(`invalid float 32: `+e)}function s(){let e=0,t=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(n&15)<<28,t=(n&112)>>4,!(n&128))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(t|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}throw Error(`invalid varint`)}function c(e,t,n){for(let r=0;r<28;r+=7){let i=e>>>r,a=!(!(i>>>7)&&t==0),o=(a?i|128:i)&255;if(n.push(o),!a)return}let r=e>>>28&15|(t&7)<<4,i=!!(t>>3);if(n.push((i?r|128:r)&255),i){for(let e=3;e<31;e+=7){let r=t>>>e,i=!!(r>>>7),a=(i?r|128:r)&255;if(n.push(a),!i)return}n.push(t>>>31&1)}}const l=4294967296;function ee(e){let t=e[0]===`-`;t&&(e=e.slice(1));let n=1e6,r=0,i=0;function a(t,a){let o=Number(e.slice(t,a));i*=n,r=r*n+o,r>=l&&(i+=r/l|0,r%=l)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?d(r,i):re(r,i)}function te(e,t){let n=re(e,t),r=n.hi&2147483648;r&&(n=d(n.lo,n.hi));let i=u(n.lo,n.hi);return r?`-`+i:i}function u(e,t){if({lo:e,hi:t}=ne(e,t),t<=2097151)return String(l*t+e);let n=e&16777215,r=(e>>>24|t<<8)&16777215,i=t>>16&65535,a=n+r*6777216+i*6710656,o=r+i*8147497,s=i*2,c=1e7;return a>=c&&(o+=Math.floor(a/c),a%=c),o>=c&&(s+=Math.floor(o/c),o%=c),s.toString()+ie(o)+ie(a)}function ne(e,t){return{lo:e>>>0,hi:t>>>0}}function re(e,t){return{lo:e|0,hi:t|0}}function d(e,t){return t=~t,e?e=~e+1:t+=1,re(e,t)}const ie=e=>{let t=String(e);return`0000000`.slice(t.length)+t};function ae(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(e&127|128),e>>=7;t.push(1)}}function oe(){let e=this.buf[this.pos++],t=e&127;if(!(e&128)||(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128)))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let t=5;e&128&&t<10;t++)e=this.buf[this.pos++];if(e&128)throw Error(`invalid varint`);return this.assertBounds(),t>>>0}function se(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt==`function`&&typeof e.getBigInt64==`function`&&typeof e.getBigUint64==`function`&&typeof e.setBigInt64==`function`&&typeof e.setBigUint64==`function`&&(typeof process!=`object`||typeof process.env!=`object`||process.env.BUF_BIGINT_DISABLE!==`1`)){let t=BigInt(`-9223372036854775808`),n=BigInt(`9223372036854775807`),r=BigInt(`0`),i=BigInt(`18446744073709551615`);return{zero:BigInt(0),supported:!0,parse(e){let r=typeof e==`bigint`?e:BigInt(e);if(r>n||r<t)throw Error(`int64 invalid: ${e}`);return r},uParse(e){let t=typeof e==`bigint`?e:BigInt(e);if(t>i||t<r)throw Error(`uint64 invalid: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)},uDec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0)}}}let t=e=>r(/^-?[0-9]+$/.test(e),`int64 invalid: ${e}`),n=e=>r(/^[0-9]+$/.test(e),`uint64 invalid: ${e}`);return{zero:`0`,supported:!1,parse(e){return typeof e!=`string`&&(e=e.toString()),t(e),e},uParse(e){return typeof e!=`string`&&(e=e.toString()),n(e),e},enc(e){return typeof e!=`string`&&(e=e.toString()),t(e),ee(e)},uEnc(e){return typeof e!=`string`&&(e=e.toString()),n(e),ee(e)},dec(e,t){return te(e,t)},uDec(e,t){return u(e,t)}}}const f=se();var p;(function(e){e[e.DOUBLE=1]=`DOUBLE`,e[e.FLOAT=2]=`FLOAT`,e[e.INT64=3]=`INT64`,e[e.UINT64=4]=`UINT64`,e[e.INT32=5]=`INT32`,e[e.FIXED64=6]=`FIXED64`,e[e.FIXED32=7]=`FIXED32`,e[e.BOOL=8]=`BOOL`,e[e.STRING=9]=`STRING`,e[e.BYTES=12]=`BYTES`,e[e.UINT32=13]=`UINT32`,e[e.SFIXED32=15]=`SFIXED32`,e[e.SFIXED64=16]=`SFIXED64`,e[e.SINT32=17]=`SINT32`,e[e.SINT64=18]=`SINT64`,e[e.DATE=100]=`DATE`})(p||={});var m;(function(e){e[e.BIGINT=0]=`BIGINT`,e[e.STRING=1]=`STRING`})(m||={});function ce(e,t,n){if(t===n)return!0;if(t==null||n==null)return t===n;if(e==p.BYTES){if(!(t instanceof Uint8Array)||!(n instanceof Uint8Array)||t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}if(e==p.DATE){let e=de(t,!1),r=de(n,!1);return e==null||r==null?e===r:e!=null&&r!=null&&+e==+r}switch(e){case p.UINT64:case p.FIXED64:case p.INT64:case p.SFIXED64:case p.SINT64:return t==n}return!1}function h(e,t){switch(e){case p.BOOL:return!1;case p.UINT64:case p.FIXED64:case p.INT64:case p.SFIXED64:case p.SINT64:return t==0?f.zero:`0`;case p.DOUBLE:case p.FLOAT:return 0;case p.BYTES:return new Uint8Array;case p.STRING:return``;case p.DATE:return null;default:return 0}}const le=+new Date(0);function g(e,t){if(t==null)return!0;switch(e){case p.DATE:return+t===le;case p.BOOL:return t===!1;case p.STRING:return t===``;case p.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return t==0}}function _(e,t,n,r=m.BIGINT){return t==null?h(e,r):e===p.BYTES?ue(t,n):g(e,t)?h(e,r):e===p.DATE?de(t,n):t}function ue(e,t){return!t&&e instanceof Uint8Array?e:new Uint8Array(e)}function de(e,t){if(e instanceof Date)return t?new Date(e.getTime()):e;if(typeof e==`string`||typeof e==`number`){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function fe(e,t){let n=me(e);return t?n:ye(ve(n))}function pe(e){return fe(e,!1)}function me(e){let t=!1,n=[];for(let r=0;r<e.length;r++){let i=e.charAt(r);switch(i){case`_`:t=!0;break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n.push(i),t=!1;break;default:t&&(t=!1,i=i.toUpperCase()),n.push(i)}}return n.join(``)}const he=new Set([`constructor`,`toString`,`toJSON`,`valueOf`,`__proto__`,`prototype`]),ge=new Set([`__proto__`]),_e=e=>`${e}$`,ve=e=>ge.has(e)?_e(e):e,ye=e=>he.has(e)?_e(e):e;function be(e){return typeof e==`string`&&!!e.length&&!he.has(e)}function v(e){if(typeof e!=`string`)throw Error(`illegal non-string object key: `+typeof e);if(!be(e))throw Error(`illegal object key: `+e)}var xe=class{_fields;_normalizer;all;numbersAsc;jsonNames;numbers;members;constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){let e={};for(let t of this.list())e[t.jsonName]=e[t.name]=t;this.jsonNames=e}return this.jsonNames[e]}find(e){if(!this.numbers){let e={};for(let t of this.list())e[t.no]=t;this.numbers=e}return this.numbers[e]}list(){return this.all||=this._normalizer(this._fields),this.all}byNumber(){return this.numbersAsc||=this.list().concat().sort((e,t)=>e.no-t.no),this.numbersAsc}byMember(){if(!this.members){this.members=[];let e=this.members,t;for(let n of this.list())n.oneof?n.oneof!==t&&(t=n.oneof,e.push(t)):e.push(n)}return this.members}};function Se(e,t){return new xe(e,e=>Ee(e,t))}function Ce(e,t){let n=e.localName;if(!t)return!1;if(e.repeated)return!!t[n]?.length;if(e.oneof)return t[e.oneof.localName]?.case===n;switch(e.kind){case`enum`:case`scalar`:return e.opt||e.req?t[n]!=null:e.kind==`enum`?t[n]!==e.T.values[0].no:!g(e.T,t[n]);case`message`:return t[n]!=null;case`map`:return t[n]!=null&&!!Object.keys(t[n]).length}}const we=me;function y(e){return e instanceof Function?e():e}var Te=class{kind=`oneof`;name;localName;repeated=!1;packed=!1;opt=!1;req=!1;default=void 0;fields=[];_lookup;constructor(e){this.name=e,this.localName=pe(e)}addField(e){r(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;e<this.fields.length;e++)this._lookup[this.fields[e].localName]=this.fields[e]}return this._lookup[e]}};function Ee(e,t){let n=[],r;for(let i of typeof e==`function`?e():e){let e=i;if(e.localName=fe(i.name,i.oneof!==void 0),e.jsonName=i.jsonName??we(i.name),e.repeated=i.repeated??!1,i.kind==`scalar`&&(e.L=i.L??m.BIGINT,e.utf8=i.utf8??!1),i.kind==`map`&&(e.keyUtf8=i.keyUtf8??!1),e.delimited=i.delimited??!1,e.req=i.req??!1,e.opt=i.opt??!1,i.packed===void 0&&(e.packed=t?i.kind==`enum`||i.kind==`scalar`&&i.T!=p.BYTES&&i.T!=p.STRING:!1),i.oneof!==void 0){let t=typeof i.oneof==`string`?i.oneof:i.oneof.name;(!r||r.name!=t)&&(r=new Te(t)),e.oneof=r,r.addField(e)}n.push(e)}return n}function De(e){return Array.isArray(e)}function Oe(e){return!Array.isArray(e)}function ke(e,t){let n=[];for(let r of Object.keys(e)){let i=e[r];typeof i==`number`&&n.push({no:i,name:t+r,localName:r})}return n}function b(e,t,n=``){let r=Object.create(null),i=Object.create(null),a=Oe(t)?ke(t,n):t,o=[];for(let e of a){let t=De(e)?{no:e[0],name:e[1],localName:e[1]}:`localName`in e?e:{...e,localName:e.name};o.push(t),r[t.name]=t,i[t.no]=t}return{typeName:e,values:o,findName(e){return r[e]},findNumber(e){return i[e]}}}function Ae(e){if(e.values.length<1)throw Error(`invalid enum: missing at least one value`);return e.values[0].no}function je(e,t){let n=Ae(e);if(t==null||t===``||t===n)return n;if(typeof t==`string`){let n=e.findName(t);if(!n)throw Error(`enum ${e.typeName}: invalid value: "${t}"`);return n.no}return t}function x(){return{}}function S(){return Object.create(null)}function Me(e){return e}function C(e,t,n,r=!1){if(e==null||t==null)return;let i=Me(t),a=Me(e);for(let e of n.byMember()){let t=e.localName;if(v(t),!(t in a)||a[t]===void 0)continue;let n=a[t];if(n===null){delete i[t];continue}switch(e.kind){case`oneof`:{if(typeof n!=`object`)throw Error(`field ${t}: invalid oneof: must be an object with case and value`);let{case:a,value:o}=n,s=a==null?null:e.findField(a),c=t in i?i[t]:void 0;if(typeof c!=`object`&&(c=x()),a!=null&&s==null)throw Error(`field ${t}: invalid oneof case: ${a}`);if(c.case=a,(c.case!==a||a==null)&&delete c.value,i[t]=c,!s)break;if(s.kind===`message`){let e=c.value;if(typeof e!=`object`&&(e=c.value=x()),o!=null){let t=y(s.T);C(o,e,t.fields)}}else s.kind===`scalar`?c.value=_(s.T,o,r):c.value=o;break}case`scalar`:if(e.repeated){if(!Array.isArray(n))throw Error(`field ${t}: invalid value: must be array`);let a=t in i?i[t]:null;(a==null||!Array.isArray(a))&&(a=i[t]=[]),a.push(...n.map(t=>_(e.T,t,r)));break}i[t]=_(e.T,n,r);break;case`enum`:i[t]=je(e.T,n);break;case`map`:{if(typeof n!=`object`)throw Error(`field ${e.localName}: invalid value: must be object`);let a=i[t];typeof a!=`object`&&(a=i[t]=S()),Ne(n,a,e.V,r);break}case`message`:{let r=y(e.T);if(e.repeated){if(!Array.isArray(n))throw Error(`field ${t}: invalid value: must be array`);let e=i[t];Array.isArray(e)||(e=i[t]=[]);for(let t of n)t!=null&&(r.fieldWrapper?e.push(r.fieldWrapper.unwrapField(r.fieldWrapper.wrapField(t))):e.push(r.create(t)));break}if(r.fieldWrapper)i[t]=r.fieldWrapper.unwrapField(r.fieldWrapper.wrapField(n));else{if(typeof n!=`object`)throw Error(`field ${e.localName}: invalid value: must be object`);let a=i[t];typeof a!=`object`&&(a=i[t]=x()),C(n,a,r.fields)}break}}}}function Ne(e,t,n,r){if(e!=null){if(typeof e!=`object`)throw Error(`invalid map: must be object`);switch(n.kind){case`scalar`:for(let[i,a]of Object.entries(e))v(i),a===void 0?delete t[i]:t[i]=_(n.T,a,r);break;case`enum`:for(let[r,i]of Object.entries(e))v(r),i===void 0?delete t[r]:t[r]=je(n.T,i);break;case`message`:{let r=y(n.T);for(let[n,i]of Object.entries(e)){if(v(n),i===void 0){delete t[n];continue}if(typeof i!=`object`)throw Error(`invalid value: must be object`);let e=t[n];r.fieldWrapper?e=t[n]=Tt(r.fields):typeof e!=`object`&&(e=t[n]=x()),C(i,e,r.fields)}break}}}}const Pe=Symbol(`@aptre/protobuf-es-lite/unknown-fields`);function Fe(e,t,n,r){if(typeof e!=`object`)return;let i=e;Array.isArray(i[Pe])||(i[Pe]=[]),i[Pe].push({no:t,wireType:n,data:r})}function Ie(e,t){return e?e.wrapField(t):t}function Le(e,t){return e?e.unwrapField(t):t}p.DATE,p.DOUBLE,p.FLOAT,p.INT64,p.UINT64,p.INT32,p.UINT32,p.BOOL,p.STRING,p.BYTES;var w;(function(e){e[e.Varint=0]=`Varint`,e[e.Bit64=1]=`Bit64`,e[e.LengthDelimited=2]=`LengthDelimited`,e[e.StartGroup=3]=`StartGroup`,e[e.EndGroup=4]=`EndGroup`,e[e.Bit32=5]=`Bit32`})(w||={});var Re=class{chunks;buf;stack=[];textEncoder;constructor(e){this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),n=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],n),n+=this.chunks[e].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 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(a(e);e>127;)this.buf.push(e&127|128),e>>>=7;return this.buf.push(e),this}int32(e){return i(e),ae(e,this.buf),this}bool(e){return this.buf.push(+!!e),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){o(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){a(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){i(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return i(e),e=(e<<1^e>>31)>>>0,ae(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=f.enc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=f.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=f.enc(e);return c(t.lo,t.hi,this.buf),this}sint64(e){let t=f.enc(e),n=t.hi>>31;return c(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=f.uEnc(e);return c(t.lo,t.hi,this.buf),this}},ze=class{pos;len;buf;view;textDecoder;fatalTextDecoder;constructor(e,t,n){this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder,this.fatalTextDecoder=n}tag(){let e=this.uint32(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw Error(`illegal tag: field no `+t+` wire type `+n);return[t,n]}skip(e){let t=this.pos;switch(e){case w.Varint:for(;this.buf[this.pos++]&128;);break;case w.Bit64:this.pos+=4;case w.Bit32:this.pos+=4;break;case w.LengthDelimited:let t=this.uint32();this.pos+=t;break;case w.StartGroup:let n;for(;(n=this.tag()[1])!==w.EndGroup;)this.skip(n);break;default:throw Error(`cant skip wire type `+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}varint64=s;assertBounds(){if(this.pos>this.len)throw RangeError(`premature EOF`)}uint32=oe;int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return f.dec(...this.varint64())}uint64(){return f.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,f.dec(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 f.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return f.dec(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(e=!1){return(e?this.fatalTextDecoder??=new TextDecoder(`utf-8`,{fatal:!0}):this.textDecoder).decode(this.bytes())}};const Be={readUnknownFields:!0,readerFactory:e=>new ze(e)},Ve={writeUnknownFields:!0,writerFactory:()=>new Re};function He(e){return e?{...Be,...e}:Be}function Ue(e){return e?{...Ve,...e}:Ve}function We(e,t,n,r,i){let{repeated:a}=n,{localName:o}=n;if(n.oneof){let t=e[n.oneof.localName];t||=e[n.oneof.localName]=x(),e=t,e.case!=o&&delete e.value,e.case=o,o=`value`}switch(n.kind){case`scalar`:case`enum`:{let i=n.kind==`enum`?p.INT32:n.T,s=Ke,c=n.kind==`scalar`&&n.utf8;if(n.kind==`scalar`&&n.L>0&&(s=qe),a){let n=e[o];if(Array.isArray(n)||(n=e[o]=[]),r==w.LengthDelimited&&i!=p.STRING&&i!=p.BYTES){let e=t.uint32()+t.pos;for(;t.pos<e;)n.push(s(t,i,c))}else n.push(s(t,i,c))}else e[o]=s(t,i,c);break}case`message`:{let r=n.T,s=r instanceof Function?r():r;if(a){let r=e[o];Array.isArray(r)||(r=e[o]=[]),r.push(Le(s.fieldWrapper,Je(t,x(),s.fields,i,n)))}else e[o]=Le(s.fieldWrapper,Je(t,x(),s.fields,i,n));break}case`map`:{let[r,a]=Ge(n,t,i);typeof e[o]!=`object`&&(e[o]=S()),e[o][r]=a;break}}}function Ge(e,t,n){let r=t.uint32(),i=t.pos+r,a,o;for(;t.pos<i;){let[r]=t.tag();switch(r){case 1:a=Ke(t,e.K,e.keyUtf8);break;case 2:switch(e.V.kind){case`scalar`:o=Ke(t,e.V.T,e.V.utf8===!0);break;case`enum`:o=t.int32();break;case`message`:o=Je(t,x(),y(e.V.T).fields,n,void 0)}}}if(a===void 0&&(a=h(e.K,m.BIGINT)),typeof a!=`string`&&typeof a!=`number`&&(a=a?.toString()??``),o===void 0)switch(e.V.kind){case`scalar`:o=h(e.V.T,m.BIGINT);break;case`enum`:o=e.V.T.values[0].no;break;case`message`:o=x()}return[a,o]}function Ke(e,t,n=!1){switch(t){case p.STRING:return e.string(n);case p.BOOL:return e.bool();case p.DOUBLE:return e.double();case p.FLOAT:return e.float();case p.INT32:return e.int32();case p.INT64:return e.int64();case p.UINT64:return e.uint64();case p.FIXED64:return e.fixed64();case p.BYTES:return e.bytes();case p.FIXED32:return e.fixed32();case p.SFIXED32:return e.sfixed32();case p.SFIXED64:return e.sfixed64();case p.SINT64:return e.sint64();case p.UINT32:return e.uint32();case p.SINT32:return e.sint32();case p.DATE:throw Error(`cannot read a date with readScalar`);default:throw Error(`unknown scalar type`)}}function qe(e,t,n=!1){let r=Ke(e,t,n);return typeof r==`bigint`?r.toString():r}function Je(e,t,n,r,i){return Ye(t,n,e,i?.delimited?i.no:e.uint32(),r,i?.delimited??!1),t}function Ye(e,t,n,r,i,a){let o=a?n.len:n.pos+r,s,c;for(;n.pos<o&&([s,c]=n.tag(),c!=w.EndGroup);){let r=t.find(s);if(!r){let t=n.skip(c);i.readUnknownFields&&Fe(e,s,c,t);continue}We(e,n,r,c,i)}if(a&&(c!=w.EndGroup||s!==r))throw Error(`invalid end group tag`)}function Xe(e,t,n,r){for(let i of t.byNumber()){let t=e;if(!Ce(i,t)){if(i.req)throw Error(`cannot encode field ${i.name} to binary: required field not set`);continue}let a=i.oneof?t[i.oneof.localName].value:t[i.localName];a!==void 0&&Ze(i,a,n,r)}r.writeUnknownFields&&Qe(e,n)}function Ze(e,t,n,i){r(t!==void 0);let a=e.repeated;switch(e.kind){case`scalar`:case`enum`:{let i=e.kind==`enum`?p.INT32:e.T;if(a){if(r(Array.isArray(t)),e.packed)et(n,i,e.no,t);else for(let r of t)T(n,i,e.no,r)}else T(n,i,e.no,t);break}case`message`:if(a){r(Array.isArray(t));for(let r of t)$e(n,i,e,r)}else $e(n,i,e,t);break;case`map`:r(typeof t==`object`&&!!t);for(let[r,a]of Object.entries(t))nt(n,i,e,r,a)}}function Qe(e,t){let n=e[Pe];if(n)for(let e of n)t.tag(e.no,e.wireType).raw(e.data)}function $e(e,t,n,r){let i=y(n.T),a=Ie(i.fieldWrapper,r);n.delimited?e.tag(n.no,w.StartGroup).raw(i.toBinary(a,t)).tag(n.no,w.EndGroup):e.tag(n.no,w.LengthDelimited).bytes(i.toBinary(a,t))}function T(e,t,n,i){r(i!==void 0);let[a,o]=tt(t);e.tag(n,a)[o](i)}function et(e,t,n,r){if(!r.length)return;e.tag(n,w.LengthDelimited).fork();let[,i]=tt(t);for(let t=0;t<r.length;t++)e[i](r[t]);e.join()}function tt(e){let t=w.Varint;switch(e){case p.BYTES:case p.STRING:t=w.LengthDelimited;break;case p.DOUBLE:case p.FIXED64:case p.SFIXED64:t=w.Bit64;break;case p.FIXED32:case p.SFIXED32:case p.FLOAT:t=w.Bit32}let n=p[e].toLowerCase();return[t,n]}function nt(e,t,n,i,a){e.tag(n.no,w.LengthDelimited),e.fork();let o=i;switch(n.K){case p.INT32:case p.FIXED32:case p.UINT32:case p.SFIXED32:case p.SINT32:o=Number.parseInt(i);break;case p.BOOL:r(i==`true`||i==`false`),o=i==`true`}switch(T(e,n.K,1,o),n.V.kind){case`scalar`:T(e,n.V.T,2,a);break;case`enum`:T(e,p.INT32,2,a);break;case`message`:{r(a!==void 0);let i=y(n.V.T);e.tag(2,w.LengthDelimited).bytes(i.toBinary(a,t));break}}e.join()}let E=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.split(``),rt=[];for(let e=0;e<E.length;e++)rt[E[e].charCodeAt(0)]=e;rt[45]=E.indexOf(`+`),rt[95]=E.indexOf(`/`);const it={dec(e){let t=e.length*3/4;e[e.length-2]==`=`?t-=2:e[e.length-1]==`=`&&--t;let n=new Uint8Array(t),r=0,i=0,a,o=0;for(let t=0;t<e.length;t++){if(a=rt[e.charCodeAt(t)],a===void 0)switch(e[t]){case`=`:i=0;case`
2
+ `:case`\r`:case` `:case` `:continue;default:throw Error(`invalid base64 string.`)}switch(i){case 0:o=a,i=1;break;case 1:n[r++]=o<<2|(a&48)>>4,o=a,i=2;break;case 2:n[r++]=(o&15)<<4|(a&60)>>2,o=a,i=3;break;case 3:n[r++]=(o&3)<<6|a,i=0}}if(i==1)throw Error(`invalid base64 string.`);return n.subarray(0,r)},enc(e){let t=``,n=0,r,i=0;for(let a=0;a<e.length;a++)switch(r=e[a],n){case 0:t+=E[r>>2],i=(r&3)<<4,n=1;break;case 1:t+=E[i|r>>4],i=(r&15)<<2,n=2;break;case 2:t+=E[i|r>>6],t+=E[r&63],n=0}return n&&(t+=E[i],t+=`=`,n==1&&(t+=`=`)),t}},at={ignoreUnknownFields:!1},ot={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function st(e){return e?{...at,...e}:at}function ct(e){return e?{...ot,...e}:ot}function D(e){if(e===null)return`null`;switch(typeof e){case`object`:return Array.isArray(e)?`array`:`object`;case`string`:return e.length>100?`string`:`"${e.split(`"`).join(`\\"`)}"`;default:return String(e)}}function lt(e,t,n,r,i){if(n==null||Array.isArray(n)||typeof n!=`object`)throw Error(`cannot decode message ${t} from JSON: ${D(n)}`);let a=new Map;for(let[o,s]of Object.entries(n)){let n=e.findJsonName(o);if(n){if(n.oneof){if(s===null&&n.kind==`scalar`)continue;let e=a.get(n.oneof);if(e!==void 0)throw Error(`cannot decode message ${t} from JSON: multiple keys for oneof "${n.oneof.name}" present: "${e}", "${o}"`);a.set(n.oneof,o)}dt(i,s,n,r)}else if(!r.ignoreUnknownFields)throw Error(`cannot decode message ${t} from JSON: key "${o}" is unknown`)}return i}function ut(e,t,n){let r=Object.create(null),i;try{for(i of t.byNumber()){let t=e;if(!Ce(i,t)){if(i.req)throw`required field not set`;if(!n.emitDefaultValues||!vt(i))continue}let a=i.oneof?t[i.oneof.localName].value:t[i.localName],o=yt(i,a,n);o!==void 0&&(r[n.useProtoFieldName?i.name:i.jsonName]=o)}}catch(e){let t=i?`cannot encode field ${i.name} to JSON`:`cannot encode message to JSON`,n=e instanceof Error?e.message:String(e);throw Error(t+(n.length>0?`: ${n}`:``),{cause:e})}return r}function dt(e,t,n,i){let a=n.localName;if(n.repeated){if(r(n.kind!=`map`),t===null)return;if(!Array.isArray(t))throw Error(`cannot decode field ${n.name} from JSON: ${D(t)}`);let o=e[a];Array.isArray(o)||(o=e[a]=[]);for(let e of t){if(e===null)throw Error(`cannot decode field ${n.name} from JSON: ${D(e)}`);switch(n.kind){case`message`:{let t=y(n.T);o.push(Le(t.fieldWrapper,t.fromJson(e,i)));break}case`enum`:{let t=mt(n.T,e,i.ignoreUnknownFields,!0);t!==pt&&o.push(t);break}case`scalar`:try{o.push(ht(n.T,e,n.L,!0))}catch(t){let r=`cannot decode field ${n.name} from JSON: ${D(e)}`;throw t instanceof Error&&t.message.length>0&&(r+=`: ${t.message}`),Error(r,{cause:t})}}}}else if(n.kind==`map`){if(t===null)return;if(typeof t!=`object`||Array.isArray(t))throw Error(`cannot decode field ${n.name} from JSON: ${D(t)}`);let r=e[a];typeof r!=`object`&&(r=e[a]=S());for(let[e,a]of Object.entries(t)){if(a===null)throw Error(`cannot decode field ${n.name} from JSON: map value null`);let o;try{o=gt(n.K,e)}catch(e){let r=`cannot decode map key for field ${n.name} from JSON: ${D(t)}`;throw e instanceof Error&&e.message.length>0&&(r+=`: ${e.message}`),Error(r,{cause:e})}switch(v(o),n.V.kind){case`message`:{let e=y(n.V.T);r[o]=e.fromJson(a,i);break}case`enum`:{let e=mt(n.V.T,a,i.ignoreUnknownFields,!0);e!==pt&&(r[o]=e);break}case`scalar`:try{r[o]=ht(n.V.T,a,m.BIGINT,!0)}catch(e){let r=`cannot decode map value for field ${n.name} from JSON: ${D(t)}`;throw e instanceof Error&&e.message.length>0&&(r+=`: ${e.message}`),Error(r,{cause:e})}}}}else switch(n.oneof&&(e=e[n.oneof.localName]={case:a},a=`value`),n.kind){case`message`:{let r=y(n.T);if(t===null&&r.typeName!=`google.protobuf.Value`)return;e[a]=Le(r.fieldWrapper,r.fromJson(t,i));break}case`enum`:{let r=mt(n.T,t,i.ignoreUnknownFields,!1);switch(r){case ft:_t(n,e);break;case pt:break;default:e[a]=r}break}case`scalar`:try{let r=ht(n.T,t,n.L,!1);switch(r){case ft:_t(n,e);break;default:e[a]=r}}catch(e){let r=`cannot decode field ${n.name} from JSON: ${D(t)}`;throw e instanceof Error&&e.message.length>0&&(r+=`: ${e.message}`),Error(r,{cause:e})}}}const ft=Symbol(),pt=Symbol();function mt(e,t,n,r){if(t===null)return e.typeName==`google.protobuf.NullValue`?0:r?e.values[0].no:ft;switch(typeof t){case`number`:if(Number.isInteger(t))return t;break;case`string`:{let r=e.findName(t);if(r!==void 0)return r.no;if(n)return pt;break}}throw Error(`cannot decode enum ${e.typeName} from JSON: ${D(t)}`)}function ht(e,t,n=m.BIGINT,r=!0){if(t==null)return r?h(e,n):ft;switch(e){case p.DOUBLE:case p.FLOAT:{if(t===`NaN`)return NaN;if(t===`Infinity`)return 1/0;if(t===`-Infinity`)return-1/0;if(t===``||typeof t==`string`&&t.trim().length!==t.length||typeof t!=`string`&&typeof t!=`number`)break;let n=Number(t);if(Number.isNaN(n)||!Number.isFinite(n))break;return e==p.FLOAT&&o(n),n}case p.INT32:case p.FIXED32:case p.SFIXED32:case p.SINT32:case p.UINT32:{let n;if(typeof t==`number`?n=t:typeof t==`string`&&t.length>0&&t.trim().length===t.length&&(n=Number(t)),n===void 0)break;return e==p.UINT32||e==p.FIXED32?a(n):i(n),n}case p.INT64:case p.SFIXED64:case p.SINT64:{if(typeof t!=`number`&&typeof t!=`string`)break;let e=f.parse(t);return n?e.toString():e}case p.FIXED64:case p.UINT64:{if(typeof t!=`number`&&typeof t!=`string`)break;let e=f.uParse(t);return n?e.toString():e}case p.BOOL:if(typeof t!=`boolean`)break;return t;case p.STRING:if(typeof t!=`string`)break;return t;case p.BYTES:if(t===``)return new Uint8Array;if(typeof t!=`string`)break;return it.dec(t)}throw Error()}function gt(e,t){if(e===p.BOOL)switch(t){case`true`:t=!0;break;case`false`:t=!1}return ht(e,t,m.BIGINT,!0)?.toString()??``}function _t(e,t){let n=e.localName,r=!e.opt&&!e.req;if(e.repeated)t[n]=[];else if(e.oneof)t[e.oneof.localName]={case:void 0};else switch(e.kind){case`map`:t[n]=S();break;case`enum`:t[n]=r?e.T.values[0].no:void 0;break;case`scalar`:t[n]=r?h(e.T,e.L):void 0;break;case`message`:t[n]=void 0}}function vt(e){return e.repeated||e.kind==`map`?!0:!(e.oneof||e.kind==`message`||e.opt||e.req)}function yt(e,t,n){if(e.kind==`map`){let i=Object.create(null);r(!t||typeof t==`object`);let a=t?Object.entries(t):[];switch(e.V.kind){case`scalar`:for(let[t,n]of a)i[t.toString()]=bt(e.V.T,n);break;case`message`:for(let[t,r]of a){let a=y(e.V.T);i[t.toString()]=a.toJson(r,n)}break;case`enum`:{let t=e.V.T;for(let[e,r]of a)i[e.toString()]=xt(t,r,n.enumAsInteger);break}}return n.emitDefaultValues||a.length>0?i:void 0}if(e.repeated){r(!t||Array.isArray(t));let i=[],a=t;if(a&&a.length)switch(e.kind){case`scalar`:for(let t=0;t<a.length;t++)i.push(bt(e.T,a[t]));break;case`enum`:for(let t=0;t<a.length;t++)i.push(xt(e.T,a[t],n.enumAsInteger));break;case`message`:{let t=y(e.T);for(let e=0;e<a.length;e++)i.push(t.toJson(Ie(t.fieldWrapper,a[e])));break}}return n.emitDefaultValues||i.length>0?i:void 0}switch(e.kind){case`scalar`:{let r=_(e.T,t,!1);return!n.emitDefaultValues&&g(e.T,r)?void 0:bt(e.T,t)}case`enum`:{let r=je(e.T,t);return!n.emitDefaultValues&&Ae(e.T)===r?void 0:xt(e.T,t,n.enumAsInteger)}case`message`:{if(!n.emitDefaultValues&&t==null)return;let r=y(e.T);return r.toJson(Ie(r.fieldWrapper,t))}}}function bt(e,t){switch(e){case p.INT32:case p.SFIXED32:case p.SINT32:case p.FIXED32:case p.UINT32:return r(typeof t==`number`),t;case p.FLOAT:case p.DOUBLE:return r(typeof t==`number`),Number.isNaN(t)?`NaN`:t===1/0?`Infinity`:t===-1/0?`-Infinity`:t;case p.STRING:return r(typeof t==`string`),t;case p.BOOL:return r(typeof t==`boolean`),t;case p.UINT64:case p.FIXED64:case p.INT64:case p.SFIXED64:case p.SINT64:return r(typeof t==`bigint`||typeof t==`string`||typeof t==`number`),t.toString();case p.BYTES:return r(t instanceof Uint8Array),it.enc(t);case p.DATE:throw Error(`cannot write date with writeScalar`);default:throw Error(`unknown scalar type`)}}function xt(e,t,n){return r(typeof t==`number`),e.typeName==`google.protobuf.NullValue`?null:n?t:e.findNumber(t)?.name??t}const St=[];function O(e,t){let{fields:n,typeName:r,delimitedMessageEncoding:i,fieldWrapper:a}=e,o=Se(n,e.packedByDefault??!0),s={typeName:r,fields:o,fieldWrapper:a,create(e){let t=x();return C(e,t,o),t},createComplete(e){let t=Tt(o);return C(e,t,o),t},equals(e,t){return Ct(o,e,t)},clone(e){return e==null?e:wt(e,o)},fromBinary(e,t){let n={};if(e&&e.length){let r=He(t);Ye(n,o,r.readerFactory(e),e.byteLength,r,i??!1)}return n},fromJson(e,t){let n={};if(e!=null){let i=st(t);lt(o,r,e,i,n)}return n},fromJsonString(e,t){let n=null;if(e)try{n=JSON.parse(e)}catch(e){throw Error(`cannot decode ${r} from JSON: ${e instanceof Error?e.message:String(e)}`,{cause:e})}return s.fromJson(n,t)},toBinary(e,t){if(e==null)return new Uint8Array;let n=Ue(t),r=n.writerFactory();return Xe(e,o,r,n),r.finish()},toJson(e,t){let n=ct(t);return ut(e,o,n)},toJsonString(e,t){let n=s.toJson(e,t);return JSON.stringify(n,null,t?.prettySpaces??0)},...t??{}};return s}function k(e,t){return O({typeName:e,fields:St,packedByDefault:t})}function Ct(e,t,n){if(t===n)return!0;let r=Me(t??{}),i=Me(n??{});return e.byMember().every(e=>{let t=r[e.localName],n=i[e.localName];if(e.repeated){let r=t??[],i=n??[];if(r.length!==i.length)return!1;switch(e.kind){case`message`:{let t=y(e.T);return r.every((e,n)=>t.equals(e,i[n]))}case`scalar`:return r.every((t,n)=>ce(e.T,t,i[n]));case`enum`:return r.every((e,t)=>ce(p.INT32,e,i[t]))}throw Error(`repeated cannot contain ${e.kind}`)}switch(e.kind){case`message`:return y(e.T).equals(t,n);case`enum`:return A(p.INT32,t,n);case`scalar`:return A(e.T,t,n);case`oneof`:{let r=t,i=n;if(r?.case!==i?.case)return!1;let a=r?.case,o=a===void 0?void 0:e.findField(a);if(o===void 0)return!0;switch(o.kind){case`message`:return y(o.T).equals(r?.value,i?.value);case`enum`:return A(p.INT32,r?.value,i?.value);case`scalar`:return A(o.T,r?.value,i?.value)}throw Error(`oneof cannot contain ${o.kind}`)}case`map`:{let r=t??{},i=n??{},a=Object.keys(r);if(a.length!==Object.keys(i).length)return!1;let o=e.V;return a.every(e=>{if(!(e in i))return!1;switch(o.kind){case`message`:return y(o.T).equals(r[e],i[e]);case`enum`:return A(p.INT32,r[e],i[e]);case`scalar`:return A(o.T,r[e],i[e])}})}}})}function A(e,t,n){return g(e,t)&&g(e,n)?!0:ce(e,t,n)}function wt(e,t){if(e==null)return null;let n=x();return C(e,n,t,!0),n}function Tt(e){let t={};for(let n of e.byMember()){let{localName:e,kind:r}=n;switch(v(e),r){case`oneof`:t[e]=x(),t[e].case=void 0;break;case`scalar`:t[e]=n.repeated?[]:h(n.T,m.BIGINT);break;case`enum`:t[e]=n.repeated?[]:Ae(n.T);break;case`message`:{if(n.oneof)break;if(n.repeated){t[e]=[];break}let r=y(n.T);t[e]=r.fieldWrapper?r.fieldWrapper.unwrapField(null):Tt(r.fields);break}case`map`:t[e]=S()}}return t}const Et=b(`hash.HashType`,function(e){return e[e.HashType_UNKNOWN=0]=`HashType_UNKNOWN`,e[e.HashType_SHA256=1]=`HashType_SHA256`,e[e.HashType_SHA1=2]=`HashType_SHA1`,e[e.HashType_BLAKE3=3]=`HashType_BLAKE3`,e}({})),Dt=O({typeName:`hash.Hash`,fields:[{no:1,name:`hash_type`,kind:`enum`,T:Et},{no:2,name:`hash`,kind:`scalar`,T:p.BYTES}]}),Ot=b(`block.StoreFeature`,function(e){return e[e.UNKNOWN=0]=`UNKNOWN`,e[e.NATIVE_BATCH_PUT=1]=`NATIVE_BATCH_PUT`,e[e.NATIVE_BATCH_EXISTS=2]=`NATIVE_BATCH_EXISTS`,e[e.SELF_BUFFERED=32]=`SELF_BUFFERED`,e}({}),`STORE_FEATURE_`),kt=b(`block.OverlayMode`,function(e){return e[e.UPPER_ONLY=0]=`UPPER_ONLY`,e[e.LOWER_ONLY=1]=`LOWER_ONLY`,e[e.UPPER_CACHE=2]=`UPPER_CACHE`,e[e.LOWER_CACHE=3]=`LOWER_CACHE`,e[e.UPPER_READ_CACHE=4]=`UPPER_READ_CACHE`,e[e.LOWER_READ_CACHE=5]=`LOWER_READ_CACHE`,e[e.UPPER_WRITE_CACHE=6]=`UPPER_WRITE_CACHE`,e[e.LOWER_WRITE_CACHE=7]=`LOWER_WRITE_CACHE`,e[e.UPPER_READBACK_CACHE=8]=`UPPER_READBACK_CACHE`,e}({})),j=O({typeName:`block.BlockRef`,fields:[{no:1,name:`hash`,kind:`message`,T:()=>Dt}]}),At=O({typeName:`block.BlockObject`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`refs`,kind:`message`,T:j,repeated:!0}]}),jt=O({typeName:`block.Access`,fields:[{no:1,name:`ref`,kind:`message`,T:j},{no:2,name:`size`,kind:`scalar`,T:p.UINT32},{no:3,name:`elapsed_us`,kind:`scalar`,T:p.UINT64}]}),Mt=O({typeName:`block.AccessLog`,fields:[{no:1,name:`accesses`,kind:`message`,T:jt,repeated:!0}]}),M=O({typeName:`block.PutOpts`,fields:[{no:1,name:`hash_type`,kind:`enum`,T:Et},{no:2,name:`force_block_ref`,kind:`message`,T:j},{no:3,name:`refs`,kind:`message`,T:j,repeated:!0},{no:4,name:`sync`,kind:`scalar`,T:p.BOOL},{no:5,name:`cache_fill`,kind:`scalar`,T:p.BOOL}]}),Nt=O({typeName:`block.transform.StepConfig`,fields:[{no:1,name:`id`,kind:`scalar`,T:p.STRING},{no:2,name:`config`,kind:`scalar`,T:p.BYTES}]}),Pt=O({typeName:`block.transform.Config`,fields:[{no:1,name:`steps`,kind:`message`,T:Nt,repeated:!0}]});var N;(function(e){e[e.Unary=0]=`Unary`,e[e.ServerStreaming=1]=`ServerStreaming`,e[e.ClientStreaming=2]=`ClientStreaming`,e[e.BiDiStreaming=3]=`BiDiStreaming`})(N||={});var Ft;(function(e){e[e.NoSideEffects=1]=`NoSideEffects`,e[e.Idempotent=2]=`Idempotent`})(Ft||={});const It=O({typeName:`configset.proto.ControllerConfig`,fields:[{no:1,name:`id`,kind:`scalar`,T:p.STRING},{no:2,name:`rev`,kind:`scalar`,T:p.UINT64},{no:3,name:`config`,kind:`scalar`,T:p.BYTES}],packedByDefault:!0});O({typeName:`configset.proto.ConfigSet`,fields:[{no:1,name:`configs`,kind:`map`,K:p.STRING,V:{kind:`message`,T:()=>It}}],packedByDefault:!0});const P={fromJson(e){if(typeof e!=`string`)throw Error(`cannot decode google.protobuf.Timestamp(json)}`);let t=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!t)throw Error(`cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string`);let n=Date.parse(t[1]+`-`+t[2]+`-`+t[3]+`T`+t[4]+`:`+t[5]+`:`+t[6]+(t[8]?t[8]:`Z`));if(Number.isNaN(n))throw Error(`cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string`);if(n<Date.parse(`0001-01-01T00:00:00Z`)||n>Date.parse(`9999-12-31T23:59:59Z`))throw Error(`cannot decode message google.protobuf.Timestamp from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);return{seconds:f.parse(n/1e3),nanos:t[7]?parseInt(`1`+t[7]+`0`.repeat(9-t[7].length))-1e9:0}},toJson(e){let t=Number(e.seconds)*1e3;if(t<Date.parse(`0001-01-01T00:00:00Z`)||t>Date.parse(`9999-12-31T23:59:59Z`))throw Error(`cannot encode google.protobuf.Timestamp to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);if(e.nanos!=null&&e.nanos<0)throw Error(`cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative`);let n=`Z`;if(e.nanos!=null&&e.nanos>0){let t=(e.nanos+1e9).toString().substring(1);n=t.substring(3)===`000000`?`.`+t.substring(0,3)+`Z`:t.substring(6)===`000`?`.`+t.substring(0,6)+`Z`:`.`+t+`Z`}return new Date(t).toISOString().replace(`.000Z`,n)},toDate(e){return!e?.seconds&&!e?.nanos?null:new Date(Number(e.seconds??0)*1e3+Math.ceil((e.nanos??0)/1e6))},fromDate(e){if(e==null)return{};let t=e.getTime(),n=Math.floor(t/1e3),r=t%1e3*1e6;return{seconds:f.parse(n),nanos:r}},equals(e,t){let n=e instanceof Date?e:P.toDate(e),r=t instanceof Date?t:P.toDate(t);return n===r?!0:n==null||r==null?n===r:+n==+r}},Lt=O({typeName:`google.protobuf.Timestamp`,fields:[{no:1,name:`seconds`,kind:`scalar`,T:p.INT64},{no:2,name:`nanos`,kind:`scalar`,T:p.INT32}],fieldWrapper:{wrapField(e){return e==null||e instanceof Date?P.fromDate(e):Lt.createComplete(e)},unwrapField(e){return P.toDate(e)}}},P),Rt=O({typeName:`bucket.LookupConfig`,fields:[{no:1,name:`disable`,kind:`scalar`,T:p.BOOL},{no:2,name:`controller`,kind:`message`,T:()=>It}]}),zt=O({typeName:`bucket.Config`,fields:[{no:1,name:`id`,kind:`scalar`,T:p.STRING},{no:2,name:`rev`,kind:`scalar`,T:p.UINT32},{no:4,name:`put_opts`,kind:`message`,T:()=>M},{no:5,name:`lookup`,kind:`message`,T:Rt}]}),Bt=O({typeName:`bucket.BucketInfo`,fields:[{no:1,name:`config`,kind:`message`,T:zt}]}),Vt=O({typeName:`bucket.ApplyBucketConfigResult`,fields:[{no:1,name:`volume_id`,kind:`scalar`,T:p.STRING},{no:2,name:`bucket_id`,kind:`scalar`,T:p.STRING},{no:3,name:`bucket_conf`,kind:`message`,T:zt},{no:4,name:`old_bucket_conf`,kind:`message`,T:zt},{no:5,name:`timestamp`,kind:`message`,T:()=>Lt},{no:6,name:`updated`,kind:`scalar`,T:p.BOOL},{no:7,name:`error`,kind:`scalar`,T:p.STRING}]}),F=O({typeName:`bucket.ObjectRef`,fields:[{no:1,name:`root_ref`,kind:`message`,T:()=>j},{no:2,name:`bucket_id`,kind:`scalar`,T:p.STRING},{no:3,name:`transform_conf_ref`,kind:`message`,T:()=>j},{no:4,name:`transform_conf`,kind:`message`,T:()=>Pt}]}),Ht=O({typeName:`bucket.BucketOpArgs`,fields:[{no:1,name:`bucket_id`,kind:`scalar`,T:p.STRING},{no:2,name:`volume_id`,kind:`scalar`,T:p.STRING}]});let Ut=function(e){return e[e.UNKNOWN=0]=`UNKNOWN`,e[e.RESOURCE_NOT_FOUND=1]=`RESOURCE_NOT_FOUND`,e[e.CLIENT_RELEASED=2]=`CLIENT_RELEASED`,e[e.INVALID_RESOURCE_ID=3]=`INVALID_RESOURCE_ID`,e[e.INVALID_CLIENT_ID=4]=`INVALID_CLIENT_ID`,e[e.RESOURCE_OR_CLIENT_RELEASED=5]=`RESOURCE_OR_CLIENT_RELEASED`,e}({});const Wt=O({typeName:`resource.ResourceFailure`,fields:[{no:1,name:`code`,kind:`enum`,T:b(`resource.ResourceFailureCode`,Ut,`RESOURCE_FAILURE_CODE_`)},{no:2,name:`message`,kind:`scalar`,T:p.STRING}]}),Gt=O({typeName:`resource.ResourceRpcInit`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Kt=O({typeName:`resource.ResourceRpcAck`,fields:[{no:1,name:`failure`,kind:`message`,T:Wt}]}),qt=k(`resource.ResourceRpcAbandon`,!0),Jt=O({typeName:`resource.ResourceRpcPacket`,fields:[{no:1,name:`init`,kind:`message`,T:Gt,oneof:`body`},{no:2,name:`ack`,kind:`message`,T:Kt,oneof:`body`},{no:3,name:`data`,kind:`scalar`,T:p.BYTES,oneof:`body`},{no:4,name:`abandon`,kind:`message`,T:qt,oneof:`body`}]}),Yt=k(`resource.ResourceClientInitRequest`,!0),Xt=O({typeName:`resource.ResourceClientAdopt`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Zt=O({typeName:`resource.ResourceClientRelease`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Qt=O({typeName:`resource.ResourceClientRequest`,fields:[{no:5,name:`control_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`init`,kind:`message`,T:Yt,oneof:`body`},{no:3,name:`adopt`,kind:`message`,T:Xt,oneof:`body`},{no:4,name:`release`,kind:`message`,T:Zt,oneof:`body`}]}),$t=O({typeName:`resource.ResourceClientInit`,fields:[{no:1,name:`client_handle_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`root_resource_id`,kind:`scalar`,T:p.UINT32}]}),en=O({typeName:`resource.ResourceReleasedResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),tn=O({typeName:`resource.ResourceClientControlAck`,fields:[{no:1,name:`control_id`,kind:`scalar`,T:p.UINT32}]}),nn=O({typeName:`resource.ResourceClientResponse`,fields:[{no:1,name:`init`,kind:`message`,T:$t,oneof:`body`},{no:2,name:`resource_released`,kind:`message`,T:en,oneof:`body`},{no:4,name:`control_ack`,kind:`message`,T:tn,oneof:`body`}]}),rn=O({typeName:`resource.ResourceAttachInit`,fields:[{no:1,name:`client_handle_id`,kind:`scalar`,T:p.UINT32}]}),an=O({typeName:`resource.ResourceAttachAdd`,fields:[{no:1,name:`attach_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`label`,kind:`scalar`,T:p.STRING}]}),on=O({typeName:`resource.ResourceAttachDetach`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),sn=O({typeName:`resource.ResourceAttachRequest`,fields:[{no:1,name:`init`,kind:`message`,T:rn,oneof:`body`},{no:2,name:`add`,kind:`message`,T:an,oneof:`body`},{no:3,name:`detach`,kind:`message`,T:on,oneof:`body`},{no:4,name:`mux_data`,kind:`scalar`,T:p.BYTES,oneof:`body`}]}),cn=O({typeName:`resource.ResourceAttachAck`,fields:[{no:1,name:`failure`,kind:`message`,T:Wt}]}),ln=O({typeName:`resource.ResourceAttachAddAck`,fields:[{no:1,name:`attach_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`failure`,kind:`message`,T:Wt},{no:3,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),un=O({typeName:`resource.ResourceAttachDetachAck`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),dn=O({typeName:`resource.ResourceAttachResponse`,fields:[{no:1,name:`ack`,kind:`message`,T:cn,oneof:`body`},{no:2,name:`add_ack`,kind:`message`,T:ln,oneof:`body`},{no:3,name:`detach_ack`,kind:`message`,T:un,oneof:`body`},{no:4,name:`mux_data`,kind:`scalar`,T:p.BYTES,oneof:`body`}]}),fn=k(`s4wave.block.cursor.FetchRequest`,!0),pn=O({typeName:`s4wave.block.cursor.FetchResponse`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`found`,kind:`scalar`,T:p.BOOL}]}),mn=O({typeName:`s4wave.block.cursor.SetBlockRequest`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`mark_dirty`,kind:`scalar`,T:p.BOOL},{no:3,name:`block_type`,kind:`scalar`,T:p.STRING}]}),hn=k(`s4wave.block.cursor.SetBlockResponse`,!0),gn=O({typeName:`s4wave.block.cursor.FollowRefRequest`,fields:[{no:1,name:`ref_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`blk_ref`,kind:`message`,T:()=>j}]}),_n=O({typeName:`s4wave.block.cursor.FollowRefResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),vn=k(`s4wave.block.cursor.GetRefRequest`,!0),yn=O({typeName:`s4wave.block.cursor.GetRefResponse`,fields:[{no:1,name:`ref`,kind:`message`,T:()=>j}]}),bn=k(`s4wave.block.cursor.IsDirtyRequest`,!0),xn=O({typeName:`s4wave.block.cursor.IsDirtyResponse`,fields:[{no:1,name:`dirty`,kind:`scalar`,T:p.BOOL}]}),Sn=k(`s4wave.block.cursor.MarkDirtyRequest`,!0),Cn=k(`s4wave.block.cursor.MarkDirtyResponse`,!0),wn=k(`s4wave.block.cursor.GetBlockRequest`,!0),Tn=O({typeName:`s4wave.block.cursor.GetBlockResponse`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`is_sub_block`,kind:`scalar`,T:p.BOOL}]}),En=O({typeName:`s4wave.block.cursor.UnmarshalRequest`,fields:[{no:1,name:`block_type`,kind:`scalar`,T:p.STRING}]}),Dn=O({typeName:`s4wave.block.cursor.UnmarshalResponse`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`found`,kind:`scalar`,T:p.BOOL}]}),On=k(`s4wave.block.cursor.IsSubBlockRequest`,!0),kn=O({typeName:`s4wave.block.cursor.IsSubBlockResponse`,fields:[{no:1,name:`is_sub_block`,kind:`scalar`,T:p.BOOL}]}),An=O({typeName:`s4wave.block.cursor.FollowSubBlockRequest`,fields:[{no:1,name:`ref_id`,kind:`scalar`,T:p.UINT32}]}),jn=O({typeName:`s4wave.block.cursor.FollowSubBlockResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Mn=O({typeName:`s4wave.block.cursor.SetAsSubBlockRequest`,fields:[{no:1,name:`ref_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`parent_resource_id`,kind:`scalar`,T:p.UINT32}]}),Nn=k(`s4wave.block.cursor.SetAsSubBlockResponse`,!0),Pn=O({typeName:`s4wave.block.cursor.ClearRefRequest`,fields:[{no:1,name:`ref_id`,kind:`scalar`,T:p.UINT32}]}),Fn=k(`s4wave.block.cursor.ClearRefResponse`,!0),In=k(`s4wave.block.cursor.ClearAllRefsRequest`,!0),Ln=k(`s4wave.block.cursor.ClearAllRefsResponse`,!0),Rn=O({typeName:`s4wave.block.cursor.SetRefRequest`,fields:[{no:1,name:`ref_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`target_resource_id`,kind:`scalar`,T:p.UINT32}]}),zn=k(`s4wave.block.cursor.SetRefResponse`,!0),Bn=O({typeName:`s4wave.block.cursor.GetExistingRefRequest`,fields:[{no:1,name:`ref_id`,kind:`scalar`,T:p.UINT32}]}),Vn=O({typeName:`s4wave.block.cursor.GetExistingRefResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Hn=O({typeName:`s4wave.block.cursor.GetAllRefsRequest`,fields:[{no:1,name:`existing_only`,kind:`scalar`,T:p.BOOL}]}),Un=O({typeName:`s4wave.block.cursor.GetAllRefsResponse`,fields:[{no:1,name:`refs`,kind:`map`,K:p.UINT32,V:{kind:`scalar`,T:p.UINT32}}]}),Wn=O({typeName:`s4wave.block.cursor.DetachRequest`,fields:[{no:1,name:`keep_refs`,kind:`scalar`,T:p.BOOL}]}),Gn=O({typeName:`s4wave.block.cursor.DetachResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Kn=k(`s4wave.block.cursor.DetachTransactionRequest`,!0),qn=O({typeName:`s4wave.block.cursor.DetachTransactionResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Jn=O({typeName:`s4wave.block.cursor.DetachRecursiveRequest`,fields:[{no:1,name:`detach_tx`,kind:`scalar`,T:p.BOOL},{no:2,name:`clone_blocks`,kind:`scalar`,T:p.BOOL},{no:3,name:`mark_dirty`,kind:`scalar`,T:p.BOOL}]}),Yn=O({typeName:`s4wave.block.cursor.DetachRecursiveResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Xn=k(`s4wave.block.cursor.ParentsRequest`,!0),Zn=O({typeName:`s4wave.block.cursor.ParentsResponse`,fields:[{no:1,name:`parent_resource_ids`,kind:`scalar`,T:p.UINT32,repeated:!0}]}),Qn=O({typeName:`s4wave.block.transaction.WriteRequest`,fields:[{no:1,name:`clear_tree`,kind:`scalar`,T:p.BOOL}]}),$n=O({typeName:`s4wave.block.transaction.WriteResponse`,fields:[{no:1,name:`root_ref`,kind:`message`,T:()=>j},{no:2,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),er=k(`s4wave.block.transaction.GetRootCursorRequest`,!0),tr=O({typeName:`s4wave.block.transaction.GetRootCursorResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),nr=O({typeName:`s4wave.bucket_lookup.MountBucketLookupRequest`,fields:[{no:1,name:`bucket_id`,kind:`scalar`,T:p.STRING},{no:2,name:`volume_id`,kind:`scalar`,T:p.STRING},{no:3,name:`transform_conf`,kind:`message`,T:()=>Pt}]}),rr=O({typeName:`s4wave.bucket_lookup.MountBucketLookupResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`bucket_id`,kind:`scalar`,T:p.STRING},{no:3,name:`volume_id`,kind:`scalar`,T:p.STRING}]}),ir=k(`s4wave.bucket_lookup.GetRefRequest`,!0),ar=O({typeName:`s4wave.bucket_lookup.GetRefResponse`,fields:[{no:1,name:`ref`,kind:`message`,T:()=>F},{no:2,name:`bucket_id_override`,kind:`scalar`,T:p.STRING}]}),or=O({typeName:`s4wave.bucket_lookup.FollowRefRequest`,fields:[{no:1,name:`ref`,kind:`message`,T:()=>F}]}),sr=O({typeName:`s4wave.bucket_lookup.FollowRefResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),cr=O({typeName:`s4wave.bucket_lookup.GetBlockRequest`,fields:[{no:1,name:`ref`,kind:`message`,T:()=>j}]}),lr=O({typeName:`s4wave.bucket_lookup.GetBlockResponse`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`found`,kind:`scalar`,T:p.BOOL}]}),ur=O({typeName:`s4wave.bucket_lookup.PutBlockRequest`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`opts`,kind:`message`,T:()=>M}]}),dr=O({typeName:`s4wave.bucket_lookup.PutBlockResponse`,fields:[{no:1,name:`ref`,kind:`message`,T:()=>j},{no:2,name:`existed`,kind:`scalar`,T:p.BOOL}]}),fr=O({typeName:`s4wave.bucket_lookup.PutBlockBatchEntry`,fields:[{no:1,name:`ref`,kind:`message`,T:()=>j},{no:2,name:`data`,kind:`scalar`,T:p.BYTES},{no:3,name:`refs`,kind:`message`,T:()=>j,repeated:!0},{no:4,name:`tombstone`,kind:`scalar`,T:p.BOOL}]}),pr=O({typeName:`s4wave.bucket_lookup.PutBlockBatchRequest`,fields:[{no:1,name:`entries`,kind:`message`,T:fr,repeated:!0}]}),mr=k(`s4wave.bucket_lookup.PutBlockBatchResponse`,!0),hr=O({typeName:`s4wave.bucket_lookup.GetBlockExistsBatchRequest`,fields:[{no:1,name:`refs`,kind:`message`,T:()=>j,repeated:!0}]}),gr=O({typeName:`s4wave.bucket_lookup.GetBlockExistsBatchResponse`,fields:[{no:1,name:`found`,kind:`scalar`,T:p.BOOL,repeated:!0}]}),_r=O({typeName:`s4wave.bucket_lookup.BuildTransactionRequest`,fields:[{no:1,name:`put_opts`,kind:`message`,T:()=>M}]}),vr=O({typeName:`s4wave.bucket_lookup.BuildTransactionResponse`,fields:[{no:1,name:`transaction_resource_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`cursor_resource_id`,kind:`scalar`,T:p.UINT32}]}),yr=O({typeName:`s4wave.bucket_lookup.BuildTransactionAtRefRequest`,fields:[{no:1,name:`put_opts`,kind:`message`,T:()=>M},{no:2,name:`ref`,kind:`message`,T:()=>j}]}),br=O({typeName:`s4wave.bucket_lookup.BuildTransactionAtRefResponse`,fields:[{no:1,name:`transaction_resource_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`cursor_resource_id`,kind:`scalar`,T:p.UINT32}]}),xr=k(`s4wave.bucket_lookup.CloneRequest`,!0),Sr=O({typeName:`s4wave.bucket_lookup.CloneResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Cr=k(`s4wave.bucket_lookup.ReleaseRequest`,!0),wr=k(`s4wave.bucket_lookup.ReleaseResponse`,!0),Tr=O({typeName:`s4wave.bucket_lookup.UnmarshalRequest`,fields:[{no:1,name:`ref`,kind:`message`,T:()=>F},{no:2,name:`data`,kind:`scalar`,T:p.BYTES},{no:3,name:`block_type`,kind:`scalar`,T:p.STRING}]}),Er=O({typeName:`s4wave.bucket_lookup.UnmarshalResponse`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`found`,kind:`scalar`,T:p.BOOL}]}),I=O({typeName:`quad.Quad`,fields:[{no:1,name:`subject`,kind:`scalar`,T:p.STRING},{no:2,name:`predicate`,kind:`scalar`,T:p.STRING},{no:3,name:`obj`,kind:`scalar`,T:p.STRING},{no:4,name:`label`,kind:`scalar`,T:p.STRING}]}),Dr=b(`s4wave.world.GraphEdgeBucketDirection`,function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.OUT=1]=`OUT`,e[e.IN=2]=`IN`,e[e.BOTH=3]=`BOTH`,e}({}),`GRAPH_EDGE_BUCKET_DIRECTION_`),Or=b(`s4wave.world.GraphPathDirection`,function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.OUT=1]=`OUT`,e[e.IN=2]=`IN`,e[e.BOTH=3]=`BOTH`,e}({}),`GRAPH_PATH_DIRECTION_`);let kr=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.UNHANDLED_OP=1]=`UNHANDLED_OP`,e[e.TYPED_OBJECT_GRANT_RETIRED=2]=`TYPED_OBJECT_GRANT_RETIRED`,e}({});const Ar=b(`s4wave.world.WorldErrorCode`,kr,`WORLD_ERROR_CODE_`),jr=O({typeName:`s4wave.world.ReleaseRootsRequest`,fields:[{no:1,name:`root_refs`,kind:`message`,T:()=>j,repeated:!0}]}),Mr=k(`s4wave.world.ReleaseRootsResponse`,!0),Nr=k(`s4wave.world.StageWorldStateRequest`,!0),Pr=O({typeName:`s4wave.world.StageWorldStateResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Fr=k(`s4wave.world.SyncRequest`,!0),Ir=O({typeName:`s4wave.world.SyncResponse`,fields:[{no:1,name:`fenced`,kind:`scalar`,T:p.BOOL}]}),Lr=O({typeName:`s4wave.world.EngineInfo`,fields:[{no:1,name:`engine_id`,kind:`scalar`,T:p.STRING},{no:2,name:`bucket_id`,kind:`scalar`,T:p.STRING}]}),Rr=k(`s4wave.world.GetEngineInfoRequest`,!0),zr=O({typeName:`s4wave.world.GetEngineInfoResponse`,fields:[{no:1,name:`engine_info`,kind:`message`,T:Lr},{no:2,name:`session_peer_id`,kind:`scalar`,T:p.STRING}]}),Br=O({typeName:`s4wave.world.WorldRootSnapshot`,fields:[{no:1,name:`root_ref`,kind:`message`,T:()=>F},{no:2,name:`seqno`,kind:`scalar`,T:p.UINT64},{no:3,name:`engine_info`,kind:`message`,T:Lr},{no:4,name:`storage_volume_id`,kind:`scalar`,T:p.STRING}]}),Vr=k(`s4wave.world.GetWorldRootSnapshotRequest`,!0),Hr=k(`s4wave.world.WatchWorldRootSnapshotsRequest`,!0),Ur=O({typeName:`s4wave.world.SetRetainedRootRequest`,fields:[{no:1,name:`name`,kind:`scalar`,T:p.STRING},{no:2,name:`root_ref`,kind:`message`,T:()=>j}]}),Wr=k(`s4wave.world.SetRetainedRootResponse`,!0),Gr=O({typeName:`s4wave.world.NewTransactionRequest`,fields:[{no:1,name:`write`,kind:`scalar`,T:p.BOOL}]}),Kr=O({typeName:`s4wave.world.NewTransactionResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`read_only`,kind:`scalar`,T:p.BOOL}]}),qr=k(`s4wave.world.GetSeqnoRequest`,!0),Jr=O({typeName:`s4wave.world.GetSeqnoResponse`,fields:[{no:1,name:`seqno`,kind:`scalar`,T:p.UINT64}]}),Yr=O({typeName:`s4wave.world.WaitSeqnoRequest`,fields:[{no:1,name:`seqno`,kind:`scalar`,T:p.UINT64}]}),Xr=O({typeName:`s4wave.world.WaitSeqnoResponse`,fields:[{no:1,name:`seqno`,kind:`scalar`,T:p.UINT64}]}),Zr=O({typeName:`s4wave.world.AccessWorldStateRequest`,fields:[{no:1,name:`ref`,kind:`message`,T:()=>F}]}),Qr=O({typeName:`s4wave.world.OpenNestedWorldRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),$r=O({typeName:`s4wave.world.OpenNestedWorldResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),ei=k(`s4wave.world.OpenOuterWorldRequest`,!0),ti=O({typeName:`s4wave.world.OpenOuterWorldResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),ni=O({typeName:`s4wave.world.AccessWorldStateResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),ri=O({typeName:`s4wave.world.CreateObjectRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`root_ref`,kind:`message`,T:()=>F}]}),ii=O({typeName:`s4wave.world.SetObjectRootMutation`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`root_ref`,kind:`message`,T:()=>F}]}),ai=O({typeName:`s4wave.world.SetGraphQuadRequest`,fields:[{no:1,name:`quad`,kind:`message`,T:()=>I}]}),oi=O({typeName:`s4wave.world.TransactionMutation`,fields:[{no:1,name:`create_object`,kind:`message`,T:ri,oneof:`mutation`},{no:2,name:`set_object_root`,kind:`message`,T:ii,oneof:`mutation`},{no:3,name:`set_graph_quad`,kind:`message`,T:ai,oneof:`mutation`}]}),si=O({typeName:`s4wave.world.CommitMutationsRequest`,fields:[{no:1,name:`mutations`,kind:`message`,T:oi,repeated:!0}]}),ci=O({typeName:`s4wave.world.CreateObjectMutationResult`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`rev`,kind:`scalar`,T:p.UINT64}]}),li=O({typeName:`s4wave.world.SetObjectRootMutationResult`,fields:[{no:1,name:`rev`,kind:`scalar`,T:p.UINT64}]}),ui=k(`s4wave.world.SetGraphQuadResponse`,!0),di=O({typeName:`s4wave.world.TransactionMutationResult`,fields:[{no:1,name:`create_object`,kind:`message`,T:ci,oneof:`result`},{no:2,name:`set_object_root`,kind:`message`,T:li,oneof:`result`},{no:3,name:`set_graph_quad`,kind:`message`,T:ui,oneof:`result`}]}),fi=O({typeName:`s4wave.world.CommitMutationsResponse`,fields:[{no:1,name:`results`,kind:`message`,T:di,repeated:!0}]}),pi=k(`s4wave.world.CommitRequest`,!0),mi=k(`s4wave.world.CommitResponse`,!0),hi=k(`s4wave.world.DiscardRequest`,!0),gi=k(`s4wave.world.DiscardResponse`,!0),_i=k(`s4wave.world.GetReadOnlyRequest`,!0),vi=O({typeName:`s4wave.world.GetReadOnlyResponse`,fields:[{no:1,name:`read_only`,kind:`scalar`,T:p.BOOL}]}),yi=k(`s4wave.world.BuildStorageCursorRequest`,!0),bi=O({typeName:`s4wave.world.BuildStorageCursorResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),xi=O({typeName:`s4wave.world.CreateObjectResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`object_key`,kind:`scalar`,T:p.STRING}]}),Si=O({typeName:`s4wave.world.GetObjectRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),Ci=O({typeName:`s4wave.world.GetObjectResponse`,fields:[{no:1,name:`found`,kind:`scalar`,T:p.BOOL},{no:2,name:`resource_id`,kind:`scalar`,T:p.UINT32},{no:3,name:`object_key`,kind:`scalar`,T:p.STRING}]}),wi=O({typeName:`s4wave.world.RenameObjectRequest`,fields:[{no:1,name:`old_object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`new_object_key`,kind:`scalar`,T:p.STRING},{no:3,name:`descendants`,kind:`scalar`,T:p.BOOL}]}),Ti=O({typeName:`s4wave.world.RenameObjectResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`object_key`,kind:`scalar`,T:p.STRING}]}),Ei=O({typeName:`s4wave.world.DeleteObjectRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),Di=O({typeName:`s4wave.world.DeleteObjectResponse`,fields:[{no:1,name:`deleted`,kind:`scalar`,T:p.BOOL}]}),Oi=O({typeName:`s4wave.world.IterateObjectsRequest`,fields:[{no:1,name:`prefix`,kind:`scalar`,T:p.STRING},{no:2,name:`reversed`,kind:`scalar`,T:p.BOOL}]}),ki=O({typeName:`s4wave.world.IterateObjectsResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Ai=O({typeName:`s4wave.world.ListObjectsRequest`,fields:[{no:1,name:`prefix`,kind:`scalar`,T:p.STRING},{no:2,name:`start_after`,kind:`scalar`,T:p.STRING},{no:3,name:`limit`,kind:`scalar`,T:p.UINT32},{no:4,name:`delimiter`,kind:`scalar`,T:p.STRING}]}),ji=O({typeName:`s4wave.world.ObjectMetadata`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`type_id`,kind:`scalar`,T:p.STRING},{no:3,name:`parent_object_key`,kind:`scalar`,T:p.STRING}]}),Mi=O({typeName:`s4wave.world.ListObjectsResponse`,fields:[{no:1,name:`objects`,kind:`message`,T:ji,repeated:!0},{no:2,name:`more`,kind:`scalar`,T:p.BOOL},{no:3,name:`prefixes`,kind:`scalar`,T:p.STRING,repeated:!0}]}),Ni=O({typeName:`s4wave.world.DeleteGraphQuadRequest`,fields:[{no:1,name:`quad`,kind:`message`,T:()=>I}]}),Pi=k(`s4wave.world.DeleteGraphQuadResponse`,!0),Fi=O({typeName:`s4wave.world.LookupGraphQuadsRequest`,fields:[{no:1,name:`filter`,kind:`message`,T:()=>I},{no:2,name:`limit`,kind:`scalar`,T:p.UINT32}]}),Ii=O({typeName:`s4wave.world.LookupGraphQuadsResponse`,fields:[{no:1,name:`quads`,kind:`message`,T:()=>I,repeated:!0}]}),Li=O({typeName:`s4wave.world.LookupGraphQuadsBatchRequest`,fields:[{no:1,name:`filters`,kind:`message`,T:()=>I,repeated:!0},{no:2,name:`limit_per_filter`,kind:`scalar`,T:p.UINT32}]}),Ri=O({typeName:`s4wave.world.LookupGraphQuadsBatchResult`,fields:[{no:1,name:`quads`,kind:`message`,T:()=>I,repeated:!0}]}),zi=O({typeName:`s4wave.world.LookupGraphQuadsBatchResponse`,fields:[{no:1,name:`results`,kind:`message`,T:Ri,repeated:!0}]}),Bi=O({typeName:`s4wave.world.ListGraphEdgeBucketsRequest`,fields:[{no:1,name:`origin_object_keys`,kind:`scalar`,T:p.STRING,repeated:!0},{no:2,name:`predicate`,kind:`scalar`,T:p.STRING},{no:3,name:`limit_per_origin`,kind:`scalar`,T:p.UINT32},{no:4,name:`direction`,kind:`enum`,T:Dr}]}),Vi=O({typeName:`s4wave.world.GraphEdgeBucket`,fields:[{no:1,name:`origin_object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`outgoing`,kind:`message`,T:()=>I,repeated:!0},{no:3,name:`incoming`,kind:`message`,T:()=>I,repeated:!0},{no:4,name:`outgoing_truncated`,kind:`scalar`,T:p.BOOL},{no:5,name:`incoming_truncated`,kind:`scalar`,T:p.BOOL}]}),Hi=O({typeName:`s4wave.world.ListGraphEdgeBucketsResponse`,fields:[{no:1,name:`buckets`,kind:`message`,T:Vi,repeated:!0}]}),Ui=O({typeName:`s4wave.world.ListObjectsWithTypeRequest`,fields:[{no:1,name:`type_id`,kind:`scalar`,T:p.STRING}]}),Wi=O({typeName:`s4wave.world.ListObjectsWithTypeResponse`,fields:[{no:1,name:`object_keys`,kind:`scalar`,T:p.STRING,repeated:!0}]}),Gi=O({typeName:`s4wave.world.ObjectRootRef`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`root_ref`,kind:`message`,T:()=>F},{no:3,name:`rev`,kind:`scalar`,T:p.UINT64},{no:4,name:`exists`,kind:`scalar`,T:p.BOOL}]}),Ki=O({typeName:`s4wave.world.GetObjectRootRefsBatchRequest`,fields:[{no:1,name:`object_keys`,kind:`scalar`,T:p.STRING,repeated:!0}]}),qi=O({typeName:`s4wave.world.GetObjectRootRefsBatchResponse`,fields:[{no:1,name:`root_refs`,kind:`message`,T:Gi,repeated:!0}]}),Ji=O({typeName:`s4wave.world.GetObjectMetadataBatchRequest`,fields:[{no:1,name:`object_keys`,kind:`scalar`,T:p.STRING,repeated:!0}]}),Yi=O({typeName:`s4wave.world.GetObjectMetadataBatchResponse`,fields:[{no:1,name:`metadata`,kind:`message`,T:ji,repeated:!0}]}),Xi=O({typeName:`s4wave.world.ObjectBody`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`body`,kind:`scalar`,T:p.BYTES},{no:3,name:`exists`,kind:`scalar`,T:p.BOOL},{no:4,name:`rev`,kind:`scalar`,T:p.UINT64}]}),Zi=O({typeName:`s4wave.world.GetObjectBodiesBatchRequest`,fields:[{no:1,name:`object_keys`,kind:`scalar`,T:p.STRING,repeated:!0}]}),Qi=O({typeName:`s4wave.world.GetObjectBodiesBatchResponse`,fields:[{no:1,name:`bodies`,kind:`message`,T:Xi,repeated:!0},{no:2,name:`world_seqno`,kind:`scalar`,T:p.UINT64}]}),$i=O({typeName:`s4wave.world.GraphPathStep`,fields:[{no:1,name:`direction`,kind:`enum`,T:Or},{no:2,name:`predicate`,kind:`scalar`,T:p.STRING},{no:3,name:`limit`,kind:`scalar`,T:p.UINT32}]}),ea=O({typeName:`s4wave.world.QueryGraphPathRequest`,fields:[{no:1,name:`start_keys`,kind:`scalar`,T:p.STRING,repeated:!0},{no:2,name:`steps`,kind:`message`,T:$i,repeated:!0},{no:3,name:`result_limit`,kind:`scalar`,T:p.UINT32},{no:4,name:`include_quads`,kind:`scalar`,T:p.BOOL},{no:5,name:`page_size`,kind:`scalar`,T:p.UINT32}]}),ta=O({typeName:`s4wave.world.QueryGraphPathResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),na=O({typeName:`s4wave.world.DeleteGraphObjectRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),ra=k(`s4wave.world.DeleteGraphObjectResponse`,!0),ia=O({typeName:`s4wave.world.ApplyWorldOpRequest`,fields:[{no:1,name:`op_type_id`,kind:`scalar`,T:p.STRING},{no:2,name:`op_data`,kind:`scalar`,T:p.BYTES},{no:3,name:`op_sender`,kind:`scalar`,T:p.STRING}]}),aa=O({typeName:`s4wave.world.ApplyWorldOpResponse`,fields:[{no:1,name:`seqno`,kind:`scalar`,T:p.UINT64},{no:2,name:`sys_err`,kind:`scalar`,T:p.BOOL},{no:3,name:`error_code`,kind:`enum`,T:Ar},{no:4,name:`rejection_code`,kind:`scalar`,T:p.STRING},{no:5,name:`rejection_message`,kind:`scalar`,T:p.STRING}]}),oa=k(`s4wave.world.WatchWorldStateRequest`,!0),sa=O({typeName:`s4wave.world.WatchWorldStateResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),ca=O({typeName:`s4wave.world.TrackedWorldStateSnapshot.ObjectAccess`,fields:[{no:1,name:`key`,kind:`scalar`,T:p.STRING},{no:2,name:`rev`,kind:`scalar`,T:p.UINT64}]}),la=O({typeName:`s4wave.world.TrackedWorldStateSnapshot`,fields:[{no:1,name:`object_accesses`,kind:`message`,T:ca,repeated:!0},{no:2,name:`has_quad_access`,kind:`scalar`,T:p.BOOL},{no:3,name:`initial_seqno`,kind:`scalar`,T:p.UINT64}]}),ua=k(`s4wave.world.ErrRequest`,!0),da=O({typeName:`s4wave.world.ErrResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING}]}),fa=k(`s4wave.world.ValidRequest`,!0),pa=O({typeName:`s4wave.world.ValidResponse`,fields:[{no:1,name:`valid`,kind:`scalar`,T:p.BOOL}]}),ma=k(`s4wave.world.KeyRequest`,!0),ha=O({typeName:`s4wave.world.KeyResponse`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),ga=k(`s4wave.world.NextRequest`,!0),_a=O({typeName:`s4wave.world.NextResponse`,fields:[{no:1,name:`valid`,kind:`scalar`,T:p.BOOL}]}),va=O({typeName:`s4wave.world.SeekRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),ya=k(`s4wave.world.SeekResponse`,!0),ba=k(`s4wave.world.CloseRequest`,!0),xa=k(`s4wave.world.CloseResponse`,!0),Sa=k(`s4wave.world.NextGraphPathQueryRequest`,!0),Ca=O({typeName:`s4wave.world.NextGraphPathQueryResponse`,fields:[{no:1,name:`object_keys`,kind:`scalar`,T:p.STRING,repeated:!0},{no:2,name:`quads`,kind:`message`,T:()=>I,repeated:!0},{no:3,name:`done`,kind:`scalar`,T:p.BOOL}]}),wa=k(`s4wave.world.CloseGraphPathQueryRequest`,!0),Ta=k(`s4wave.world.CloseGraphPathQueryResponse`,!0),Ea=k(`s4wave.world.GetKeyRequest`,!0),Da=O({typeName:`s4wave.world.GetKeyResponse`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),Oa=k(`s4wave.world.GetRootRefRequest`,!0),ka=O({typeName:`s4wave.world.GetRootRefResponse`,fields:[{no:1,name:`root_ref`,kind:`message`,T:()=>F},{no:2,name:`rev`,kind:`scalar`,T:p.UINT64}]}),Aa=O({typeName:`s4wave.world.SetRootRefRequest`,fields:[{no:1,name:`root_ref`,kind:`message`,T:()=>F}]}),ja=O({typeName:`s4wave.world.SetRootRefResponse`,fields:[{no:1,name:`rev`,kind:`scalar`,T:p.UINT64}]}),Ma=O({typeName:`s4wave.world.ApplyObjectOpRequest`,fields:[{no:1,name:`op_type_id`,kind:`scalar`,T:p.STRING},{no:2,name:`op_data`,kind:`scalar`,T:p.BYTES},{no:3,name:`op_sender`,kind:`scalar`,T:p.STRING}]}),Na=O({typeName:`s4wave.world.ApplyObjectOpResponse`,fields:[{no:1,name:`rev`,kind:`scalar`,T:p.UINT64},{no:2,name:`sys_err`,kind:`scalar`,T:p.BOOL},{no:3,name:`error_code`,kind:`enum`,T:Ar},{no:4,name:`rejection_code`,kind:`scalar`,T:p.STRING},{no:5,name:`rejection_message`,kind:`scalar`,T:p.STRING}]}),Pa=k(`s4wave.world.IncrementRevRequest`,!0),Fa=O({typeName:`s4wave.world.IncrementRevResponse`,fields:[{no:1,name:`rev`,kind:`scalar`,T:p.UINT64}]}),Ia=O({typeName:`s4wave.world.WaitRevRequest`,fields:[{no:1,name:`rev`,kind:`scalar`,T:p.UINT64},{no:2,name:`ignore_not_found`,kind:`scalar`,T:p.BOOL}]}),La=O({typeName:`s4wave.world.WaitRevResponse`,fields:[{no:1,name:`rev`,kind:`scalar`,T:p.UINT64}]}),Ra=O({typeName:`s4wave.world.AccessTypedObjectRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),za=O({typeName:`s4wave.world.AccessTypedObjectResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`type_id`,kind:`scalar`,T:p.STRING},{no:3,name:`error_code`,kind:`enum`,T:Ar}]}),Ba=O({typeName:`s4wave.world.WatchTypedObjectRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),Va=O({typeName:`s4wave.world.WatchTypedObjectResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`type_id`,kind:`scalar`,T:p.STRING}]}),Ha=O({typeName:`s4wave.world.ObjectRecordBase`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`root_ref`,kind:`message`,T:()=>F}]}),Ua=O({typeName:`s4wave.world.CompareObjectRecordsRequest`,fields:[{no:1,name:`bases`,kind:`message`,T:Ha,repeated:!0}]}),Wa=O({typeName:`s4wave.world.ObjectRecordChanges`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`keys`,kind:`scalar`,T:p.BYTES,repeated:!0},{no:3,name:`unknown`,kind:`scalar`,T:p.BOOL}]}),Ga=O({typeName:`s4wave.world.CompareObjectRecordsResponse`,fields:[{no:1,name:`changes`,kind:`message`,T:Wa,repeated:!0}]}),Ka=b(`blob.BlobType`,function(e){return e[e.BlobType_RAW=0]=`BlobType_RAW`,e[e.BlobType_CHUNKED=1]=`BlobType_CHUNKED`,e}({})),qa=b(`blob.ChunkerType`,function(e){return e[e.ChunkerType_DEFAULT=0]=`ChunkerType_DEFAULT`,e[e.ChunkerType_RABIN=1]=`ChunkerType_RABIN`,e[e.ChunkerType_JC=2]=`ChunkerType_JC`,e}({})),Ja=O({typeName:`blob.Chunk`,fields:[{no:1,name:`data_ref`,kind:`message`,T:()=>j},{no:2,name:`size`,kind:`scalar`,T:p.UINT64},{no:3,name:`start`,kind:`scalar`,T:p.UINT64}]}),Ya=O({typeName:`blob.RabinArgs`,fields:[{no:1,name:`pol`,kind:`scalar`,T:p.UINT64},{no:4,name:`random_pol`,kind:`scalar`,T:p.BOOL},{no:2,name:`chunking_min_size`,kind:`scalar`,T:p.UINT64},{no:3,name:`chunking_max_size`,kind:`scalar`,T:p.UINT64}]}),Xa=O({typeName:`blob.JcArgs`,fields:[{no:1,name:`key`,kind:`scalar`,T:p.BYTES},{no:2,name:`chunking_min_size`,kind:`scalar`,T:p.UINT64},{no:3,name:`chunking_target_size`,kind:`scalar`,T:p.UINT64},{no:4,name:`chunking_max_size`,kind:`scalar`,T:p.UINT64}]}),Za=O({typeName:`blob.ChunkerArgs`,fields:[{no:1,name:`chunker_type`,kind:`enum`,T:qa},{no:2,name:`rabin_args`,kind:`message`,T:Ya},{no:3,name:`jc_args`,kind:`message`,T:Xa}]}),Qa=O({typeName:`blob.ChunkIndex`,fields:[{no:1,name:`chunks`,kind:`message`,T:Ja,repeated:!0},{no:2,name:`chunker_args`,kind:`message`,T:Za},{no:3,name:`tail_start`,kind:`scalar`,T:p.UINT64}]}),$a=O({typeName:`blob.Blob`,fields:[{no:1,name:`blob_type`,kind:`enum`,T:Ka},{no:2,name:`total_size`,kind:`scalar`,T:p.UINT64},{no:3,name:`raw_data`,kind:`scalar`,T:p.BYTES},{no:4,name:`chunk_index`,kind:`message`,T:Qa}]}),eo=O({typeName:`blob.BuildBlobOpts`,fields:[{no:1,name:`raw_high_water_mark`,kind:`scalar`,T:p.UINT64},{no:2,name:`chunker_args`,kind:`message`,T:Za}]}),to=O({typeName:`kvtx.block.iavl.Node`,fields:[{no:1,name:`height`,kind:`scalar`,T:p.UINT32},{no:2,name:`size`,kind:`scalar`,T:p.UINT64},{no:3,name:`key`,kind:`scalar`,T:p.BYTES},{no:7,name:`value_ref`,kind:`message`,T:()=>j},{no:8,name:`value_blob`,kind:`message`,T:()=>$a},{no:5,name:`left_child_ref`,kind:`message`,T:()=>j},{no:6,name:`right_child_ref`,kind:`message`,T:()=>j}]}),no=O({typeName:`kvtx.block.okra.Root`,fields:[{no:1,name:`size`,kind:`scalar`,T:p.UINT64},{no:2,name:`height`,kind:`scalar`,T:p.UINT32},{no:3,name:`root_hash`,kind:`scalar`,T:p.BYTES},{no:4,name:`root_page_ref`,kind:`message`,T:()=>j},{no:5,name:`hash_size`,kind:`scalar`,T:p.UINT32},{no:6,name:`fanout_degree`,kind:`scalar`,T:p.UINT32}]}),ro=O({typeName:`kvtx.block.okra.Entry`,fields:[{no:1,name:`anchor`,kind:`scalar`,T:p.BOOL},{no:2,name:`key`,kind:`scalar`,T:p.BYTES},{no:3,name:`hash`,kind:`scalar`,T:p.BYTES},{no:4,name:`size`,kind:`scalar`,T:p.UINT64},{no:5,name:`child_ref`,kind:`message`,T:()=>j},{no:6,name:`value_ref`,kind:`message`,T:()=>j},{no:7,name:`value_is_blob`,kind:`scalar`,T:p.BOOL},{no:8,name:`value_blob`,kind:`message`,T:()=>$a}]}),io=O({typeName:`kvtx.block.okra.Page`,fields:[{no:1,name:`level`,kind:`scalar`,T:p.UINT32},{no:2,name:`lower_bound`,kind:`scalar`,T:p.BYTES},{no:3,name:`upper_bound`,kind:`scalar`,T:p.BYTES},{no:4,name:`starts_at_anchor`,kind:`scalar`,T:p.BOOL},{no:5,name:`size`,kind:`scalar`,T:p.UINT64},{no:6,name:`page_hash`,kind:`scalar`,T:p.BYTES},{no:7,name:`entries`,kind:`message`,T:ro,repeated:!0}]});let ao=function(e){return e[e.KV_IMPL_TYPE_UNKNOWN=0]=`KV_IMPL_TYPE_UNKNOWN`,e[e.KV_IMPL_TYPE_IAVL=1]=`KV_IMPL_TYPE_IAVL`,e[e.KV_IMPL_TYPE_OKRA=2]=`KV_IMPL_TYPE_OKRA`,e[e.KV_IMPL_TYPE_OKRA_INLINE=3]=`KV_IMPL_TYPE_OKRA_INLINE`,e}({});const oo=O({typeName:`kvtx.block.KeyValueStore`,fields:[{no:1,name:`impl_type`,kind:`enum`,T:b(`kvtx.block.KVImplType`,ao)},{no:2,name:`iavl_root`,kind:`message`,T:()=>to},{no:3,name:`okra_root`,kind:`message`,T:()=>no}]}),L=b(`kvtx.rpc.KvtxRetryClass`,function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.INVALID_SNAPSHOT=1]=`INVALID_SNAPSHOT`,e}({}),`KVTX_RETRY_CLASS_`),so=O({typeName:`kvtx.rpc.KvtxTransactionInit`,fields:[{no:1,name:`write`,kind:`scalar`,T:p.BOOL}]}),co=O({typeName:`kvtx.rpc.KvtxTransactionRequest`,fields:[{no:1,name:`init`,kind:`message`,T:so,oneof:`body`},{no:2,name:`commit`,kind:`scalar`,T:p.BOOL,oneof:`body`},{no:3,name:`discard`,kind:`scalar`,T:p.BOOL,oneof:`body`}]}),lo=O({typeName:`kvtx.rpc.KvtxTransactionAck`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`transaction_id`,kind:`scalar`,T:p.STRING},{no:3,name:`retry_class`,kind:`enum`,T:L}]}),uo=O({typeName:`kvtx.rpc.KvtxTransactionComplete`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`committed`,kind:`scalar`,T:p.BOOL},{no:3,name:`discarded`,kind:`scalar`,T:p.BOOL},{no:4,name:`retry_class`,kind:`enum`,T:L}]}),fo=O({typeName:`kvtx.rpc.KvtxTransactionResponse`,fields:[{no:1,name:`ack`,kind:`message`,T:lo,oneof:`body`},{no:2,name:`complete`,kind:`message`,T:uo,oneof:`body`}]}),po=O({typeName:`kvtx.rpc.KeyCountRequest`,fields:[{no:1,name:`accept_retry_class`,kind:`scalar`,T:p.BOOL}]}),mo=O({typeName:`kvtx.rpc.KeyCountResponse`,fields:[{no:1,name:`key_count`,kind:`scalar`,T:p.UINT64},{no:2,name:`error`,kind:`scalar`,T:p.STRING},{no:3,name:`retry_class`,kind:`enum`,T:L}]}),ho=O({typeName:`kvtx.rpc.KvtxKeyRequest`,fields:[{no:1,name:`key`,kind:`scalar`,T:p.BYTES}]}),go=O({typeName:`kvtx.rpc.KvtxKeyDataResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`found`,kind:`scalar`,T:p.BOOL},{no:3,name:`data`,kind:`scalar`,T:p.BYTES},{no:4,name:`retry_class`,kind:`enum`,T:L}]}),_o=O({typeName:`kvtx.rpc.KvtxKeyExistsResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`found`,kind:`scalar`,T:p.BOOL},{no:3,name:`retry_class`,kind:`enum`,T:L}]}),vo=O({typeName:`kvtx.rpc.KvtxSetKeyRequest`,fields:[{no:1,name:`key`,kind:`scalar`,T:p.BYTES},{no:2,name:`value`,kind:`scalar`,T:p.BYTES}]}),yo=O({typeName:`kvtx.rpc.KvtxSetKeyResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`retry_class`,kind:`enum`,T:L}]}),bo=O({typeName:`kvtx.rpc.KvtxDeleteKeyRequest`,fields:[{no:1,name:`key`,kind:`scalar`,T:p.BYTES}]}),xo=O({typeName:`kvtx.rpc.KvtxDeleteKeyResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`retry_class`,kind:`enum`,T:L}]}),So=O({typeName:`kvtx.rpc.KvtxScanPrefixRequest`,fields:[{no:1,name:`prefix`,kind:`scalar`,T:p.BYTES},{no:2,name:`only_keys`,kind:`scalar`,T:p.BOOL}]}),Co=O({typeName:`kvtx.rpc.KvtxScanPrefixResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`key`,kind:`scalar`,T:p.BYTES},{no:3,name:`value`,kind:`scalar`,T:p.BYTES},{no:4,name:`retry_class`,kind:`enum`,T:L}]}),wo=O({typeName:`kvtx.rpc.KvtxWatchRequest`,fields:[{no:1,name:`prefix`,kind:`scalar`,T:p.BYTES},{no:2,name:`only_keys`,kind:`scalar`,T:p.BOOL},{no:3,name:`max_records`,kind:`scalar`,T:p.UINT64},{no:4,name:`max_bytes`,kind:`scalar`,T:p.UINT64}]}),To=O({typeName:`kvtx.rpc.KvtxWatchEntry`,fields:[{no:1,name:`key`,kind:`scalar`,T:p.BYTES},{no:2,name:`value`,kind:`scalar`,T:p.BYTES}]}),Eo=O({typeName:`kvtx.rpc.KvtxWatchResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`entries`,kind:`message`,T:To,repeated:!0},{no:3,name:`limit_exceeded`,kind:`scalar`,T:p.BOOL}]}),Do=O({typeName:`kvtx.rpc.KvtxIterateInit`,fields:[{no:1,name:`prefix`,kind:`scalar`,T:p.BYTES},{no:2,name:`sort`,kind:`scalar`,T:p.BOOL},{no:3,name:`reverse`,kind:`scalar`,T:p.BOOL}]}),Oo=O({typeName:`kvtx.rpc.KvtxIterateRequest`,fields:[{no:1,name:`init`,kind:`message`,T:Do,oneof:`body`},{no:2,name:`lookup_value`,kind:`scalar`,T:p.BOOL,oneof:`body`},{no:3,name:`next`,kind:`scalar`,T:p.BOOL,oneof:`body`},{no:4,name:`seek`,kind:`scalar`,T:p.BYTES,oneof:`body`},{no:5,name:`seek_beginning`,kind:`scalar`,T:p.BOOL,oneof:`body`},{no:6,name:`close`,kind:`scalar`,T:p.BOOL,oneof:`body`}]}),ko=O({typeName:`kvtx.rpc.KvtxIterateStatus`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`valid`,kind:`scalar`,T:p.BOOL},{no:3,name:`key`,kind:`scalar`,T:p.BYTES},{no:4,name:`retry_class`,kind:`enum`,T:L}]}),Ao=O({typeName:`kvtx.rpc.KvtxIterateResponse`,fields:[{no:1,name:`ack`,kind:`scalar`,T:p.BOOL,oneof:`body`},{no:2,name:`req_error`,kind:`scalar`,T:p.STRING,oneof:`body`},{no:3,name:`status`,kind:`message`,T:ko,oneof:`body`},{no:4,name:`value`,kind:`scalar`,T:p.BYTES,oneof:`body`},{no:5,name:`closed`,kind:`scalar`,T:p.BOOL,oneof:`body`},{no:6,name:`retry_class`,kind:`enum`,T:L}]}),R=`ERR_RPC_ABORT`;var jo=class extends Error{rpcService;rpcMethod;rpcError;constructor(e,t,n){super(n),this.name=`RemoteRPCError`,this.rpcService=e,this.rpcMethod=t,this.rpcError=n}};function z(){let e={};return e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n}),e}var Mo=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw Error(`Max size for a FixedFIFO should be a power of two`);this.buffer=Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]===void 0&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},No=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Mo(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength==null?1:e.byteLength}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new Mo(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}},Po=class extends Error{type;code;constructor(e,t){super(e??`The operation was aborted`),this.type=`aborted`,this.code=t??`ABORT_ERR`}};function B(e={}){return Fo(e=>{let t=e.shift();if(t==null)return{done:!0};if(t.error!=null)throw t.error;return{done:t.done===!0,value:t.value}},e)}function Fo(e,t){t??={};let n=t.onEnd,r=new No,i,a,o,s=z(),c=async()=>{try{return r.isEmpty()?o?{done:!0}:await new Promise((t,n)=>{a=o=>{a=null,r.push(o);try{t(e(r))}catch(e){n(e)}return i}}):e(r)}finally{r.isEmpty()&&queueMicrotask(()=>{s.resolve(),s=z()})}},l=e=>a==null?(r.push(e),i):a(e),ee=e=>(r=new No,a==null?(r.push({error:e}),i):a({error:e})),te=e=>{if(o)return i;if(t?.objectMode!==!0&&e?.byteLength==null)throw Error(`objectMode was not true but tried to push non-Uint8Array value`);return l({done:!1,value:e})},u=e=>o?i:(o=!0,e==null?l({done:!0}):ee(e)),ne=()=>(r=new No,u(),{done:!0}),re=e=>(u(e),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:c,return:ne,throw:re,push:te,end:u,get readableLength(){return r.size},onEmpty:async e=>{let t=e?.signal;if(t?.throwIfAborted(),r.isEmpty())return;let n,i;t!=null&&(n=new Promise((e,n)=>{i=()=>{n(new Po)},t.addEventListener(`abort`,i)}));try{await Promise.race([s.promise,n])}finally{i!=null&&t!=null&&t?.removeEventListener(`abort`,i)}}},n==null)return i;let d=i;return i={[Symbol.asyncIterator](){return this},next(){return d.next()},throw(e){return d.throw(e),n!=null&&(n(e),n=void 0),{done:!0}},return(){return d.return(),n!=null&&(n(),n=void 0),{done:!0}},push:te,end(e){return d.end(e),n!=null&&(n(e),n=void 0),i},get readableLength(){return d.readableLength},onEmpty:e=>d.onEmpty(e)},i}var Io=class extends Error{type;code;constructor(e,t,n){super(e??`The operation was aborted`),this.type=`aborted`,this.name=n??`AbortError`,this.code=t??`ABORT_ERR`}};async function V(e,t,n){if(t==null)return e;if(t.aborted)return e.catch(()=>{}),Promise.reject(new Io(n?.errorMessage,n?.errorCode,n?.errorName));let r,i=new Io(n?.errorMessage,n?.errorCode,n?.errorName);try{return await Promise.race([e,new Promise((e,n)=>{r=()=>{n(i)},t.addEventListener(`abort`,r)})])}finally{r!=null&&t.removeEventListener(`abort`,r)}}var Lo=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=z(),this.haveNext=z()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult??await this.haveNext.promise,this.nextResult==null)throw Error(`HaveNext promise resolved but nextResult was undefined`);let e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=z(),e}async throw(e){return this.ended=!0,this.error=e,e!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(e)),{done:!0,value:void 0}}async return(){let e={done:!0,value:void 0};return this.ended=!0,this.nextResult=e,this.haveNext.resolve(),e}async push(e,t){await this._push(e,t)}async end(e,t){e==null?await this._push(void 0,t):await this.throw(e)}async _push(e,t){if(e!=null&&this.ended)throw this.error??Error(`Cannot push value onto an ended pushable`);for(;this.nextResult!=null;)await this.readNext.promise;e==null?(this.ended=!0,this.nextResult={done:!0,value:void 0}):this.nextResult={done:!1,value:e},this.haveNext.resolve(),this.haveNext=z(),await V(this.readNext.promise,t?.signal,t)}};function Ro(){return new Lo}function zo(e){return e[Symbol.asyncIterator]!=null}async function Bo(e,t,n){try{await Promise.all(e.map(async e=>{for await(let r of e)await t.push(r,{signal:n}),n.throwIfAborted()})),await t.end(void 0,{signal:n})}catch(e){await t.end(e,{signal:n}).catch(()=>{})}}async function*Vo(e){let t=new AbortController,n=Ro();Bo(e,n,t.signal).catch(()=>{});try{yield*n}finally{t.abort()}}function*Ho(e){for(let t of e)yield*t}function Uo(...e){let t=[];for(let n of e)zo(n)||t.push(n);return t.length===e.length?Ho(t):Vo(e)}function H(e,...t){if(e==null)throw Error(`Empty pipeline`);if(qo(e)){let t=e;e=()=>t.source}else if(Ko(e)||Go(e)){let t=e;e=()=>t}let n=[e,...t];if(n.length>1&&qo(n[n.length-1])&&(n[n.length-1]=n[n.length-1].sink),n.length>2)for(let e=1;e<n.length-1;e++)qo(n[e])&&(n[e]=Jo(n[e]));return Wo(...n)}const Wo=(...e)=>{let t;for(;e.length>0;)t=e.shift()(t);return t},Go=e=>e?.[Symbol.asyncIterator]!=null,Ko=e=>e?.[Symbol.iterator]!=null,qo=e=>e!=null&&e.sink!=null&&e.source!=null,Jo=e=>t=>{let n=e.sink(t);if(n?.then!=null){let t=B({objectMode:!0});n.then(()=>{t.end()},e=>{t.end(e)});let r,i=e.source;if(Go(i))r=async function*(){yield*i,t.end()};else if(Ko(i))r=function*(){yield*i,t.end()};else throw Error(`Unknown duplex source type - must be Iterable or AsyncIterable`);return Uo(t,r())}return e.source},Yo=O({typeName:`srpc.CallStart`,fields:[{no:1,name:`rpc_service`,kind:`scalar`,T:p.STRING},{no:2,name:`rpc_method`,kind:`scalar`,T:p.STRING},{no:3,name:`data`,kind:`scalar`,T:p.BYTES},{no:4,name:`data_is_zero`,kind:`scalar`,T:p.BOOL}],packedByDefault:!0}),Xo=O({typeName:`srpc.CallData`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`data_is_zero`,kind:`scalar`,T:p.BOOL},{no:3,name:`complete`,kind:`scalar`,T:p.BOOL},{no:4,name:`error`,kind:`scalar`,T:p.STRING}],packedByDefault:!0}),Zo=O({typeName:`srpc.Packet`,fields:[{no:1,name:`call_start`,kind:`message`,T:()=>Yo,oneof:`body`},{no:2,name:`call_data`,kind:`message`,T:()=>Xo,oneof:`body`},{no:3,name:`call_cancel`,kind:`scalar`,T:p.BOOL,oneof:`body`}],packedByDefault:!0});var Qo=class{sink;source;rpcDataSource;_source=B({objectMode:!0});_rpcDataSource=B({objectMode:!0});service;method;closed;remoteError;remoteCompleted=!1;invocationController=new AbortController;writeDrainAbort=new AbortController;constructor(){this.sink=this._createSink(),this.source=this._source,this.rpcDataSource=this.readRpcData()}get isClosed(){return this.closed??!1}get isRemoteCompleted(){return this.remoteCompleted}get invocationSignal(){return this.invocationController.signal}async writeCallData(e,t,n){await this.writeCallDataPacket(e,t,n)}async writeCallDataPacket(e,t,n,r){let i={data:e||new Uint8Array,dataIsZero:!!e&&e.length===0,complete:t||!1,error:n||``};await this.writePacket({body:{case:`callData`,value:i}},r)}async writeCallCancel(e=!1){await this.writePacket({body:{case:`callCancel`,value:!0}},{waitForDrain:!1}),e&&await this._source.onEmpty({signal:this.writeDrainAbort.signal})}async writeCallDataFromSource(e){try{for await(let t of e)await this.writeCallData(t);await this.writeCallData(void 0,!0)}catch(e){this.close(e)}}async writePacket(e,t){if(this.closed&&!t?.allowClosed)throw Error(R);if(this._source.push(e),!(t?.waitForDrain===!1||this._source.readableLength<=1))try{await this._source.onEmpty({signal:this.writeDrainAbort.signal})}catch(e){throw this.closed?Error(R,{cause:e}):e}}async handleMessage(e){return this.handlePacket(Zo.fromBinary(e))}async handlePacket(e){try{switch(e?.body?.case){case`callStart`:await this.handleCallStart(e.body.value);break;case`callData`:await this.handleCallData(e.body.value);break;case`callCancel`:e.body.value&&await this.handleCallCancel()}}catch(e){let t=e;t?.message||(t=Error(`error handling packet`)),this.close(t)}}async handleCallStart(e){throw Error(`unexpected call start: ${e.rpcService}/${e.rpcMethod}`)}pushRpcData(e,t){if(t)(!e||e.length!==0)&&(e=new Uint8Array);else if(!e||e.length===0)return;this._rpcDataSource.push(e)}async handleCallData(e){if(!this.service||!this.method)throw Error(`call start must be sent before call data`);this.pushRpcData(e.data,e.dataIsZero);let t=e.error?new jo(this.service,this.method,e.error):void 0;t&&(this.remoteError??=t,this.invocationController.abort()),(e.complete||t)&&(this.remoteCompleted=!0,this.endRpcData(t))}async handleCallCancel(){await this.close(Error(R))}async close(e){this.closed||(this.closed=e??!0,!this.remoteError&&e&&(this.remoteError=e),this.invocationController.abort(),e&&e.message&&await this.writeCallDataPacket(void 0,!0,e.message,{allowClosed:!0,waitForDrain:!1}),this.writeDrainAbort.abort(),this._source.end(),this.endRpcData(e))}endRpcData(e){e&&this._rpcDataSource.push(e),this._rpcDataSource.end()}async*readRpcData(){for await(let e of this._rpcDataSource){if(e instanceof Error)throw e;yield e}}async handleSourceEnd(){}_createSink(){return async e=>{try{if(Symbol.asyncIterator in e)for await(let t of e)await this.handlePacket(t);else for(let t of e)await this.handlePacket(t);await this.handleSourceEnd()}catch(e){this.close(e)}}}},$o=class extends Qo{constructor(e,t){super(),this.service=e,this.method=t}async writeCallStart(e){if(!this.service||!this.method)throw Error(`service and method must be set`);let t={rpcService:this.service,rpcMethod:this.method,data:e||new Uint8Array,dataIsZero:!!e&&e.length===0};await this.writePacket({body:{case:`callStart`,value:t}})}async handleCallStart(e){throw Error(`unexpected server to client rpc: ${e.rpcService||`<empty>`}/${e.rpcMethod||`<empty>`}`)}async handleSourceEnd(){this.isRemoteCompleted||await this.close(Error(`ERR_CLOSED_BEFORE_COMPLETION`))}};async function es(e,t){try{for await(let n of e)t.push(n);t.end()}catch(e){t.end(e)}}function ts(e){if(e.buffer instanceof ArrayBuffer)return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);let t=e.slice();return new Uint8Array(t.buffer,0,t.byteLength)}function U(e=0){return ts(t.alloc(e))}function ns(e=0){return ts(t.allocUnsafe(e))}function rs(e,n){return ts(t.concat(e,n))}function is(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0}const as=Symbol.for(`@achingbrain/uint8arraylist`);function os(e,t){if(t==null||t<0)throw RangeError(`index is out of bounds`);let n=0;for(let r of e){let e=n+r.byteLength;if(t<e)return{buf:r,index:t-n};n=e}throw RangeError(`index is out of bounds`)}function W(e){return!!e?.[as]}var G=class e{bufs;length;[as]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(W(n)){t+=n.byteLength;for(let e of n.bufs)this.bufs.push(e)}else throw Error(`Could not append value, must be an Uint8Array or a Uint8ArrayList`);this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(W(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw Error(`Could not prepend value, must be an Uint8Array or a Uint8ArrayList`);this.length+=t}get(e){let t=os(this.bufs,e);return t.buf[t.index]}set(e,t){let n=os(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(W(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw Error(`Could not write value, must be an Uint8Array or a Uint8ArrayList`)}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:r}=this._subList(e,t);return rs(n,r)}subarray(e,t){let{bufs:n,length:r}=this._subList(e,t);return n.length===1?n[0]:rs(n,r)}sublist(t,n){let{bufs:r,length:i}=this._subList(t,n),a=new e;return a.length=i,a.bufs=r,a}_subList(e,t){if(e??=0,t??=this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw RangeError(`index is out of bounds`);if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],r=0;for(let i=0;i<this.bufs.length;i++){let a=this.bufs[i],o=r,s=o+a.byteLength;if(r=s,e>=s)continue;let c=e>=o&&e<s,l=t>o&&t<=s;if(c&&l){if(e===o&&t===s){n.push(a);break}let r=e-o;n.push(a.subarray(r,r+(t-e)));break}if(c){if(e===0){n.push(a);continue}n.push(a.subarray(e-o));continue}if(l){if(t===s){n.push(a);break}n.push(a.subarray(0,t-o));break}n.push(a)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!W(e)&&!(e instanceof Uint8Array))throw TypeError(`The "value" argument must be a Uint8ArrayList or Uint8Array`);let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let r=n.byteLength;if(r===0)throw TypeError(`search must be at least 1 byte long`);let i=new Int32Array(256);for(let e=0;e<256;e++)i[e]=-1;for(let e=0;e<r;e++)i[n[e]]=e;let a=i,o=this.byteLength-n.byteLength,s=n.byteLength-1,c;for(let e=t;e<=o;e+=c){c=0;for(let t=s;t>=0;t--){let r=this.get(e+t);if(n[t]!==r){c=Math.max(1,t-a[r]);break}}if(c===0)return e}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=ns(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let r=U(2);new DataView(r.buffer,r.byteOffset,r.byteLength).setInt16(0,t,n),this.write(r,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let r=U(4);new DataView(r.buffer,r.byteOffset,r.byteLength).setInt32(0,t,n),this.write(r,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let r=U(8);new DataView(r.buffer,r.byteOffset,r.byteLength).setBigInt64(0,t,n),this.write(r,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=ns(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let r=U(2);new DataView(r.buffer,r.byteOffset,r.byteLength).setUint16(0,t,n),this.write(r,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let r=U(4);new DataView(r.buffer,r.byteOffset,r.byteLength).setUint32(0,t,n),this.write(r,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let r=U(8);new DataView(r.buffer,r.byteOffset,r.byteLength).setBigUint64(0,t,n),this.write(r,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let r=U(4);new DataView(r.buffer,r.byteOffset,r.byteLength).setFloat32(0,t,n),this.write(r,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let r=U(8);new DataView(r.buffer,r.byteOffset,r.byteLength).setFloat64(0,t,n),this.write(r,e)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!is(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,n){let r=new e;return r.bufs=t,n??=t.reduce((e,t)=>e+t.byteLength,0),r.length=n,r}};function ss(e){let t=e.fromBinary.bind(e);return async function*(e){for await(let n of e)if(Array.isArray(n))for(let e of n)yield*[t(e)];else yield*[t(n)]}}function cs(e){return async function*(t){for await(let n of t)if(Array.isArray(n))for(let t of n)yield e.toBinary(t);else yield e.toBinary(n)}}const ls=1e7,us=ss(Zo),ds=cs(Zo),fs=e=>{if(e.length<4)throw RangeError(`Could not decode int32BE`);return e.getUint32(0,!0)};fs.bytes=4;const ps=e=>{let t=new G(new Uint8Array(4));return t.setUint32(0,e,!0),t};ps.bytes=4;async function*ms(e,t){for await(let n of e){let e=n instanceof Uint8Array?n.length:n.byteLength;if(e===0||e>ls)throw RangeError(`invalid packet length: ${e}`);yield new G(t(e),n)}}async function*hs(e,t){let n=new G;for await(let r of e)for(n.append(r);n.length>=t.bytes;){let e=t(n);if(e===0||e>ls)throw RangeError(`invalid packet length: ${e}`);let r=t.bytes+e;if(n.length<r)break;yield new G(n.slice(t.bytes,r)),n.consume(r)}if(n.length!==0)throw RangeError(`truncated packet frame`)}function gs(e=ps){return t=>ms(t,e)}function _s(e=fs){return t=>hs(t,e)}var vs=class{_value;_waiters;constructor(e){this._value=e||void 0,this._waiters=[]}get value(){return this._value}async wait(){let e=this._value;return e===void 0?new Promise(e=>{this.waitWithCb(t=>{e(t)})}):e}waitWithCb(e){e&&this._waiters.push(e)}set(e){if(this._value=e,e===void 0)return;let t=this._waiters;if(t.length!==0){this._waiters=[];for(let n of t)n(e)}}},ys=class extends vs{constructor(e){super(e)}get openStreamFunc(){return async()=>{let e=this.value;return e||=await this.wait(),e()}}},bs=class{openStreamCtr;constructor(e){this.openStreamCtr=new ys(e||void 0)}setOpenStreamFn(e){this.openStreamCtr.set(e||void 0)}async request(e,t,n,r){let i=await this.startRpc(e,t,n,r);for await(let e of i.rpcDataSource)return i.close(),e;let a=Error(`empty response`);throw i.close(a),a}async clientStreamingRequest(e,t,n,r){let i=await this.startRpc(e,t,null,r);i.writeCallDataFromSource(n).catch(e=>i.close(e));for await(let e of i.rpcDataSource)return i.close(),e;let a=Error(`empty response`);throw i.close(a),a}serverStreamingRequest(e,t,n,r){let i=B({objectMode:!0});return this.startRpc(e,t,n,r).then(async e=>es(e.rpcDataSource,i)).catch(e=>i.end(e)),i}bidirectionalStreamingRequest(e,t,n,r){let i=B({objectMode:!0});return this.startRpc(e,t,null,r).then(async e=>{let t=t=>{i.end(t),e.close(t)};e.writeCallDataFromSource(n).catch(t);try{for await(let t of e.rpcDataSource)i.push(t);i.end(),e.close()}catch(e){t(e)}}).catch(e=>i.end(e)),i}async startRpc(e,t,n,r){if(r?.aborted)throw Error(R);let i=await(await this.openStreamCtr.wait())(),a=new $o(e,t),o=()=>{if(a.isClosed)return;let e=Error(R);a.writeCallCancel().catch(()=>void 0),i.abort(e),a.close(e).catch(()=>void 0)};return r?.addEventListener(`abort`,o,{once:!0}),H(i,us,a,ds,i).then(async()=>{if(a.isClosed instanceof Error){i.abort(a.isClosed);return}await i.close(),await a.close()},async e=>{let t=e instanceof Error?e:Error(String(e));i.abort(t),await a.close(t)}).finally(()=>{r?.removeEventListener(`abort`,o)}),await a.writeCallStart(n??void 0),a}},xs=class extends Qo{lookupMethod;constructor(e){super(),this.lookupMethod=e}async handleCallStart(e){if(this.service||this.method)throw Error(`call start must be sent only once`);if(this.service=e.rpcService,this.method=e.rpcMethod,!this.service||!this.method)throw Error(`rpcService and rpcMethod cannot be empty`);if(!this.lookupMethod)throw Error(`LookupMethod is not defined`);let t=await this.lookupMethod(this.service,this.method);if(!t)throw Error(`not found: ${this.service}/${this.method}`);this.pushRpcData(e.data,e.dataIsZero),this.invokeRPC(t)}async handleCallData(e){if(!this.service||!this.method)throw Error(`call start must be sent before call data`);return super.handleCallData(e)}async invokeRPC(e){let t=this._createDataSink();try{await e(this.rpcDataSource,t,{signal:this.invocationSignal})}catch(e){this.close(e)}}_createDataSink(){return async e=>{try{for await(let t of e)await this.writeCallData(t);await this.writeCallData(void 0,!0),this.close()}catch(e){this.close(e)}}}},Ss=class{lookupMethod;constructor(e){this.lookupMethod=e}get rpcStreamHandler(){return async e=>Cs(e,this.startRpc())}startRpc(){return new xs(this.lookupMethod)}handlePacketStream(e){let t=this.startRpc();return Cs(e,t).catch(()=>void 0),t}};async function Cs(e,t){try{if(await H(e,us,t,ds,e),t.isClosed instanceof Error)throw e.abort(t.isClosed),t.isClosed;await e.close(),await t.close()}catch(n){let r=n instanceof Error?n:Error(String(n));throw e.abort(r),await t.close(r),r}}function ws(e){if(e!=null){if(typeof e[Symbol.iterator]==`function`)return e[Symbol.iterator]();if(typeof e[Symbol.asyncIterator]==`function`)return e[Symbol.asyncIterator]();if(typeof e.next==`function`)return e}throw Error(`argument is not an iterator or iterable`)}const Ts=(e,...t)=>{try{[...t]}catch{}};var K=class extends Error{static name=`InvalidFrameError`;constructor(e=`The frame was invalid`){super(e),this.name=`InvalidFrameError`}},Es=class extends Error{static name=`UnrequestedPingError`;constructor(e=`Unrequested ping error`){super(e),this.name=`UnrequestedPingError`}},Ds=class extends Error{static name=`NotMatchingPingError`;constructor(e=`Unrequested ping error`){super(e),this.name=`NotMatchingPingError`}},Os=class extends Error{static name=`InvalidStateError`;constructor(e=`Invalid state`){super(e),this.name=`InvalidStateError`}},ks=class extends Error{static name=`StreamAlreadyExistsError`;constructor(e=`Strean already exists`){super(e),this.name=`StreamAlreadyExistsError`}},As=class extends Error{static name=`DecodeInvalidVersionError`;constructor(e=`Decode invalid version`){super(e),this.name=`DecodeInvalidVersionError`}},js=class extends Error{static name=`BothClientsError`;constructor(e=`Both clients`){super(e),this.name=`BothClientsError`}},Ms=class extends Error{static name=`ReceiveWindowExceededError`;constructor(e=`Receive window exceeded`){super(e),this.name=`ReceiveWindowExceededError`}};const Ns=new Set([K.name,Es.name,Ds.name,ks.name,As.name,js.name,Ms.name]),Ps=262144,Fs=Symbol.for(`@libp2p/service-capabilities`);var Is=class extends Error{static name=`AbortError`;constructor(e=`The operation was aborted`){super(e),this.name=`AbortError`}},q=class extends Error{static name=`InvalidParametersError`;constructor(e=`Invalid parameters`){super(e),this.name=`InvalidParametersError`}},J=class extends Error{static name=`MuxerClosedError`;constructor(e=`The muxer is closed`){super(e),this.name=`MuxerClosedError`}},Ls=class extends Error{static name=`TooManyOutboundProtocolStreamsError`;constructor(e=`Too many outbound protocol streams`){super(e),this.name=`TooManyOutboundProtocolStreamsError`}};const Rs={enableKeepAlive:!0,keepAliveInterval:3e4,maxInboundStreams:1e3,maxOutboundStreams:1e3,initialStreamWindowSize:Ps,maxStreamWindowSize:16777216,maxMessageSize:65536};function zs(e){if(e.keepAliveInterval<=0)throw new q(`keep-alive interval must be positive`);if(e.maxInboundStreams<0)throw new q(`max inbound streams must be larger or equal 0`);if(e.maxOutboundStreams<0)throw new q(`max outbound streams must be larger or equal 0`);if(e.initialStreamWindowSize<262144)throw new q(`InitialStreamWindowSize must be larger or equal 256 kB`);if(e.maxStreamWindowSize<e.initialStreamWindowSize)throw new q(`MaxStreamWindowSize must be larger than the InitialStreamWindowSize`);if(e.maxStreamWindowSize>2**32-1)throw new q(`MaxStreamWindowSize must be less than equal MAX_UINT32`);if(e.maxMessageSize<1024)throw new q(`MaxMessageSize must be greater than a kilobyte`)}var Y;(function(e){e[e.Data=0]=`Data`,e[e.WindowUpdate=1]=`WindowUpdate`,e[e.Ping=2]=`Ping`,e[e.GoAway=3]=`GoAway`})(Y||={});var X;(function(e){e[e.SYN=1]=`SYN`,e[e.ACK=2]=`ACK`,e[e.FIN=4]=`FIN`,e[e.RST=8]=`RST`})(X||={}),Object.values(X).filter(e=>typeof e!=`string`);var Z;(function(e){e[e.NormalTermination=0]=`NormalTermination`,e[e.ProtocolError=1]=`ProtocolError`,e[e.InternalError=2]=`InternalError`})(Z||={});const Bs=2**24;function Vs(e){if(e[0]!==0)throw new K(`Invalid frame version`);return{type:e[1],flag:(e[2]<<8)+e[3],streamID:e[4]*Bs+(e[5]<<16)+(e[6]<<8)+e[7],length:e[8]*Bs+(e[9]<<16)+(e[10]<<8)+e[11]}}var Hs=class{source;buffer;frameInProgress;constructor(e){this.source=Us(e),this.buffer=new G,this.frameInProgress=!1}async*emitFrames(){for await(let e of this.source)for(this.buffer.append(e);;){let e=this.readHeader();if(e===void 0)break;let{type:t,length:n}=e;t===Y.Data?(this.frameInProgress=!0,yield{header:e,readData:this.readBytes.bind(this,n)}):yield{header:e}}}readHeader(){if(this.frameInProgress)throw new Os(`decoding frame already in progress`);if(this.buffer.length<12)return;let e=Vs(this.buffer.subarray(0,12));return this.buffer.consume(12),e}async readBytes(e){if(this.buffer.length<e){for await(let t of this.source)if(this.buffer.append(t),this.buffer.length>=e)break}let t=this.buffer.sublist(0,e);return this.buffer.consume(e),this.frameInProgress=!1,t}};function Us(e){if(e[Symbol.iterator]!==void 0){let t=e[Symbol.iterator]();return t.return=void 0,{[Symbol.iterator](){return t}}}if(e[Symbol.asyncIterator]!==void 0){let t=e[Symbol.asyncIterator]();return t.return=void 0,{[Symbol.asyncIterator](){return t}}}throw Error(`a source must be either an iterable or an async iterable`)}function Ws(e){let t=new Uint8Array(12);return t[1]=e.type,t[2]=e.flag>>>8,t[3]=e.flag,t[4]=e.streamID>>>24,t[5]=e.streamID>>>16,t[6]=e.streamID>>>8,t[7]=e.streamID,t[8]=e.length>>>24,t[9]=e.length>>>16,t[10]=e.length>>>8,t[11]=e.length,t}var Gs=class extends Error{static name=`StreamResetError`;constructor(e=`The stream has been reset`){super(e),this.name=`StreamResetError`}},Ks=class extends Error{static name=`StreamStateError`;constructor(e=`The stream is in an invalid state`){super(e),this.name=`StreamStateError`}};function qs(e){return e!=null&&typeof e.then==`function`&&typeof e.catch==`function`&&typeof e.finally==`function`}function Js(e,t){let n=ws(e).return?.();qs(n)&&n.catch(e=>{t.error(`could not cause iterator to return`,e)})}function Ys(e){return e!=null&&typeof e.then==`function`&&typeof e.catch==`function`&&typeof e.finally==`function`}var Xs=class{id;direction;timeline;protocol;metadata;source;status;readStatus;writeStatus;log;sinkController;sinkEnd;closed;endErr;streamSource;onEnd;onCloseRead;onCloseWrite;onReset;onAbort;sendCloseWriteTimeout;sendingData;constructor(e){this.sinkController=new AbortController,this.sinkEnd=z(),this.closed=z(),this.log=e.log,this.status=`open`,this.readStatus=`ready`,this.writeStatus=`ready`,this.id=e.id,this.metadata=e.metadata??{},this.direction=e.direction,this.timeline={open:Date.now()},this.sendCloseWriteTimeout=e.sendCloseWriteTimeout??5e3,this.onEnd=e.onEnd,this.onCloseRead=e.onCloseRead,this.onCloseWrite=e.onCloseWrite,this.onReset=e.onReset,this.onAbort=e.onAbort,this.source=this.streamSource=B({onEnd:e=>{e==null?this.log.trace(`source ended`):this.log.trace(`source ended with error`,e),this.onSourceEnd(e)}}),this.sink=this.sink.bind(this)}async sink(e){if(this.writeStatus!==`ready`)throw new Ks(`writable end state is "${this.writeStatus}" not "ready"`);try{this.writeStatus=`writing`;let t={signal:this.sinkController.signal};if(this.direction===`outbound`){let e=this.sendNewStream(t);Ys(e)&&await e}let n=()=>{Js(e,this.log)};try{this.sinkController.signal.addEventListener(`abort`,n),this.log.trace(`sink reading from source`);for await(let n of e){n=n instanceof Uint8Array?new G(n):n;let e=this.sendData(n,t);Ys(e)&&(this.sendingData=z(),await e,this.sendingData.resolve(),this.sendingData=void 0)}}finally{this.sinkController.signal.removeEventListener(`abort`,n)}this.log.trace(`sink finished reading from source, write status is "%s"`,this.writeStatus),this.writeStatus===`writing`&&(this.writeStatus=`closing`,this.log.trace(`send close write to remote`),await this.sendCloseWrite({signal:AbortSignal.timeout(this.sendCloseWriteTimeout)}),this.writeStatus=`closed`),this.onSinkEnd()}catch(e){throw this.log.trace(`sink ended with error, calling abort with error`,e),this.abort(e),e}finally{this.log.trace(`resolve sink end`),this.sinkEnd.resolve()}}onSourceEnd(e){this.timeline.closeRead??(this.timeline.closeRead=Date.now(),this.readStatus=`closed`,e!=null&&this.endErr==null&&(this.endErr=e),this.onCloseRead?.(),this.timeline.closeWrite==null?this.log.trace(`source ended, waiting for sink to end`):(this.log.trace(`source and sink ended`),this.timeline.close=Date.now(),this.status!==`aborted`&&this.status!==`reset`&&(this.status=`closed`),this.onEnd!=null&&this.onEnd(this.endErr),this.closed.resolve()))}onSinkEnd(e){this.timeline.closeWrite??(this.timeline.closeWrite=Date.now(),this.writeStatus=`closed`,e!=null&&this.endErr==null&&(this.endErr=e),this.onCloseWrite?.(),this.timeline.closeRead==null?this.log.trace(`sink ended, waiting for source to end`):(this.log.trace(`sink and source ended`),this.timeline.close=Date.now(),this.status!==`aborted`&&this.status!==`reset`&&(this.status=`closed`),this.onEnd!=null&&this.onEnd(this.endErr),this.closed.resolve()))}async close(e){this.status===`open`&&(this.log.trace(`closing gracefully`),this.status=`closing`,await V(Promise.all([this.closeWrite(e),this.closeRead(e),this.closed.promise]),e?.signal),this.status=`closed`,this.log.trace(`closed gracefully`))}async closeRead(e={}){if(this.readStatus===`closing`||this.readStatus===`closed`)return;this.log.trace(`closing readable end of stream with starting read status "%s"`,this.readStatus);let t=this.readStatus;this.readStatus=`closing`,this.status!==`reset`&&this.status!==`aborted`&&this.timeline.closeRead==null&&(this.log.trace(`send close read to remote`),await this.sendCloseRead(e)),t===`ready`&&(this.log.trace(`ending internal source queue with %d queued bytes`,this.streamSource.readableLength),this.streamSource.end()),this.log.trace(`closed readable end of stream`)}async closeWrite(e={}){this.writeStatus!==`closing`&&this.writeStatus!==`closed`&&(this.log.trace(`closing writable end of stream with starting write status "%s"`,this.writeStatus),this.writeStatus===`ready`&&(this.log.trace(`sink was never sunk, sink an empty array`),await V(this.sink([]),e.signal)),this.writeStatus===`writing`&&(this.sendingData!=null&&await V(this.sendingData.promise,e.signal),this.log.trace(`aborting source passed to .sink`),this.sinkController.abort(),await V(this.sinkEnd.promise,e.signal)),this.writeStatus=`closed`,this.log.trace(`closed writable end of stream`))}abort(e){if(this.status===`closed`||this.status===`aborted`||this.status===`reset`)return;this.log(`abort with error`,e),this.log(`try to send reset to remote`);let t=this.sendReset();Ys(t)&&t.catch(e=>{this.log.error(`error sending reset message`,e)}),this.status=`aborted`,this.timeline.abort=Date.now(),this._closeSinkAndSource(e),this.onAbort?.(e)}reset(){if(this.status===`closed`||this.status===`aborted`||this.status===`reset`)return;let e=new Gs(`stream reset`);this.status=`reset`,this.timeline.reset=Date.now(),this._closeSinkAndSource(e),this.onReset?.()}_closeSinkAndSource(e){this._closeSink(e),this._closeSource(e)}_closeSink(e){this.writeStatus===`writing`&&(this.log.trace(`end sink source`),this.sinkController.abort()),this.onSinkEnd(e)}_closeSource(e){this.readStatus!==`closing`&&this.readStatus!==`closed`&&(this.log.trace(`ending source with %d bytes to be read by consumer`,this.streamSource.readableLength),this.readStatus=`closing`,this.streamSource.end(e))}remoteCloseWrite(){if(this.readStatus===`closing`||this.readStatus===`closed`){this.log(`received remote close write but local source is already closed`);return}this.log.trace(`remote close write`),this._closeSource()}remoteCloseRead(){if(this.writeStatus===`closing`||this.writeStatus===`closed`){this.log(`received remote close read but local sink is already closed`);return}this.log.trace(`remote close read`),this._closeSink()}destroy(){if(this.status===`closed`||this.status===`aborted`||this.status===`reset`){this.log(`received destroy but we are already closed`);return}this.log.trace(`stream destroyed`),this._closeSinkAndSource()}sourcePush(e){this.streamSource.push(e)}sourceReadableLength(){return this.streamSource.readableLength}};function Zs(e){let[t,n]=e[Symbol.asyncIterator]==null?[e[Symbol.iterator](),Symbol.iterator]:[e[Symbol.asyncIterator](),Symbol.asyncIterator],r=[];return{peek:()=>t.next(),push:e=>{r.push(e)},next:()=>r.length>0?{done:!1,value:r.shift()}:t.next(),[n](){return this}}}function Qs(e){return e[Symbol.asyncIterator]!=null}function $s(e){return e?.then!=null}function ec(e,t){let n=0;if(Qs(e))return(async function*(){for await(let r of e){let e=t(r,n++);$s(e)&&await e,yield r}})();let r=Zs(e),{value:i,done:a}=r.next();if(a===!0)return function*(){}();let o=t(i,n++);if(typeof o?.then==`function`)return(async function*(){await o,yield i;for(let e of r){let r=t(e,n++);$s(r)&&await r,yield e}})();let s=t;return(function*(){yield i;for(let e of r)s(e,n++),yield e})()}var Q;(function(e){e[e.Init=0]=`Init`,e[e.SYNSent=1]=`SYNSent`,e[e.SYNReceived=2]=`SYNReceived`,e[e.Established=3]=`Established`,e[e.Finished=4]=`Finished`})(Q||={});var tc=class extends Xs{name;state;config;_id;sendWindowCapacity;sendWindowCapacityUpdate;recvWindow;recvWindowCapacity;epochStart;getRTT;sendFrame;constructor(e){super({...e,onEnd:t=>{this.state=Q.Finished,e.onEnd?.(t)}}),this.config=e.config,this._id=parseInt(e.id,10),this.name=e.name,this.state=e.state,this.sendWindowCapacity=Ps,this.recvWindow=this.config.initialStreamWindowSize,this.recvWindowCapacity=this.recvWindow,this.epochStart=Date.now(),this.getRTT=e.getRTT,this.sendFrame=e.sendFrame,this.source=ec(this.source,()=>{this.sendWindowUpdate()})}async sendNewStream(){}async sendData(e,t={}){for(e=e.sublist();e.byteLength!==0;){if(this.sendWindowCapacity===0&&(this.log?.trace(`wait for send window capacity, status %s`,this.status),await this.waitForSendWindowCapacity(t),this.status===`closed`||this.status===`aborted`||this.status===`reset`)){this.log?.trace(`%s while waiting for send window capacity`,this.status);return}let n=Math.min(this.sendWindowCapacity,this.config.maxMessageSize-12,e.length),r=this.getSendFlags();this.sendFrame({type:Y.Data,flag:r,streamID:this._id,length:n},e.sublist(0,n)),this.sendWindowCapacity-=n,e.consume(n)}}sendReset(){this.sendFrame({type:Y.WindowUpdate,flag:X.RST,streamID:this._id,length:0})}async sendCloseWrite(){let e=this.getSendFlags()|X.FIN;this.sendFrame({type:Y.WindowUpdate,flag:e,streamID:this._id,length:0})}async sendCloseRead(){}async waitForSendWindowCapacity(e={}){if(this.sendWindowCapacity>0)return;let t,n,r=()=>{this.status===`open`||this.status===`closing`?n(new Is(`Stream aborted`)):t()};e.signal?.addEventListener(`abort`,r);try{await new Promise((e,r)=>{this.sendWindowCapacityUpdate=()=>{e()},n=r,t=e})}finally{e.signal?.removeEventListener(`abort`,r)}}handleWindowUpdate(e){this.log?.trace(`stream received window update id=%s`,this._id),this.processFlags(e.flag);let t=this.sendWindowCapacity;this.sendWindowCapacity+=e.length,t===0&&e.length>0&&this.sendWindowCapacityUpdate?.()}async handleData(e,t){if(this.log?.trace(`stream received data id=%s`,this._id),this.processFlags(e.flag),this.recvWindowCapacity<e.length)throw new Ms(`Receive window exceeded`);let n=await t();this.recvWindowCapacity-=e.length,this.sourcePush(n)}processFlags(e){(e&X.ACK)===X.ACK&&this.state===Q.SYNSent&&(this.state=Q.Established),(e&X.FIN)===X.FIN&&this.remoteCloseWrite(),(e&X.RST)===X.RST&&this.reset()}getSendFlags(){switch(this.state){case Q.Init:return this.state=Q.SYNSent,X.SYN;case Q.SYNReceived:return this.state=Q.Established,X.ACK;default:return 0}}sendWindowUpdate(){if(this.readStatus!==`ready`)return;let e=this.getSendFlags(),t=Date.now(),n=this.getRTT();if(e===0&&n>-1&&t-this.epochStart<n*4&&(this.recvWindow=Math.min(this.recvWindow*2,this.config.maxStreamWindowSize)),this.recvWindowCapacity>=this.recvWindow&&e===0)return;let r=this.recvWindow-this.recvWindowCapacity;this.recvWindowCapacity=this.recvWindow,this.epochStart=t,this.sendFrame({type:Y.WindowUpdate,flag:e,streamID:this._id,length:r})}};const nc=`/yamux/1.0.0`;var rc=class{protocol=nc;_components;_init;constructor(e,t={}){this._components=e,this._init=t}[Symbol.toStringTag]=`@chainsafe/libp2p-yamux`;[Fs]=[`@libp2p/stream-multiplexing`];createStreamMuxer(e){return new ic(this._components,{...this._init,...e})}},ic=class{protocol=nc;source;sink;config;log;logger;closeController;nextStreamID;_streams;nextPingID;activePing;rtt;client;localGoAway;remoteGoAway;numInboundStreams;numOutboundStreams;onIncomingStream;onStreamEnd;constructor(e,t){this.client=t.direction===`outbound`,this.config={...Rs,...t},this.logger=e.logger,this.log=this.logger.forComponent(`libp2p:yamux`),zs(this.config),this.closeController=new AbortController,Ts(1/0,this.closeController.signal),this.onIncomingStream=t.onIncomingStream,this.onStreamEnd=t.onStreamEnd,this._streams=new Map,this.source=B({onEnd:()=>{this.log?.trace(`muxer source ended`),this._streams.forEach(e=>{e.destroy()})}}),this.sink=async e=>{let t=()=>{let t=ws(e);if(t.return!=null){let e=t.return();ac(e)&&e.catch(e=>{this.log?.(`could not cause sink source to return`,e)})}},n,r;try{let r=new Hs(e);try{this.closeController.signal.addEventListener(`abort`,t);for await(let e of r.emitFrames())await this.handleFrame(e.header,e.readData)}finally{this.closeController.signal.removeEventListener(`abort`,t)}n=Z.NormalTermination}catch(e){Ns.has(e.name)?(this.log?.error(`protocol error in sink`,e),n=Z.ProtocolError):(this.log?.error(`internal error in sink`,e),n=Z.InternalError),r=e}this.log?.trace(`muxer sink ended`),r==null?await this.close({reason:n}):this.abort(r,n)},this.numInboundStreams=0,this.numOutboundStreams=0,this.nextStreamID=this.client?1:2,this.nextPingID=0,this.rtt=-1,this.log?.trace(`muxer created`),this.config.enableKeepAlive&&this.keepAliveLoop().catch(e=>this.log?.error(`keepalive error: %s`,e)),this.ping().catch(e=>this.log?.error(`ping error: %s`,e))}get streams(){return Array.from(this._streams.values())}newStream(e){if(this.remoteGoAway!==void 0)throw new J(`Muxer closed remotely`);if(this.localGoAway!==void 0)throw new J(`Muxer closed locally`);let t=this.nextStreamID;if(this.nextStreamID+=2,this.numOutboundStreams>=this.config.maxOutboundStreams)throw new Ls(`max outbound streams exceeded`);this.log?.trace(`new outgoing stream id=%s`,t);let n=this._newStream(t,e,Q.Init,`outbound`);return this._streams.set(t,n),this.numOutboundStreams++,n.sendWindowUpdate(),n}async ping(){if(this.remoteGoAway!==void 0)throw new J(`Muxer closed remotely`);if(this.localGoAway!==void 0)throw new J(`Muxer closed locally`);if(this.activePing===void 0){let e=()=>{};this.activePing={id:this.nextPingID++,promise:new Promise((t,n)=>{let r=()=>{n(new J(`Muxer closed locally`))};this.closeController.signal.addEventListener(`abort`,r,{once:!0}),e=()=>{this.closeController.signal.removeEventListener(`abort`,r),t()}}),resolve:e};let t=Date.now();this.sendPing(this.activePing.id);try{await this.activePing.promise}finally{delete this.activePing}let n=Date.now();this.rtt=n-t}else await this.activePing.promise;return this.rtt}getRTT(){return this.rtt}async close(e={}){if(this.closeController.signal.aborted)return;let t=e?.reason??Z.NormalTermination;if(this.log?.trace(`muxer close reason=%s`,t),e.signal==null){let t=AbortSignal.timeout(500);Ts(1/0,t),e={...e,signal:t}}try{await Promise.all([...this._streams.values()].map(async t=>t.close(e))),this.sendGoAway(t),this._closeMuxer()}catch(e){this.abort(e)}}abort(e,t){if(!this.closeController.signal.aborted){t??=Z.InternalError,this.log?.error(`muxer abort reason=%s error=%s`,t,e);for(let t of this._streams.values())t.abort(e);this.sendGoAway(t),this._closeMuxer()}}isClosed(){return this.closeController.signal.aborted}_closeMuxer(){this.closeController.abort(),this.source.end()}_newStream(e,t,n,r){if(this._streams.get(e)!=null)throw new q(`Stream already exists with that id`);let i=new tc({id:e.toString(),name:t,state:n,direction:r,sendFrame:this.sendFrame.bind(this),onEnd:()=>{this.closeStream(e),this.onStreamEnd?.(i)},log:this.logger.forComponent(`libp2p:yamux:${r}:${e}`),config:this.config,getRTT:this.getRTT.bind(this)});return i}closeStream(e){this.client===(e%2==0)?this.numInboundStreams--:this.numOutboundStreams--,this._streams.delete(e)}async keepAliveLoop(){for(this.log?.trace(`muxer keepalive enabled interval=%s`,this.config.keepAliveInterval);;){let e;try{await V(new Promise(t=>{e=setTimeout(t,this.config.keepAliveInterval)}),this.closeController.signal),this.ping().catch(e=>this.log?.error(`ping error: %s`,e))}catch{clearInterval(e);return}}}async handleFrame(e,t){let{streamID:n,type:r,length:i}=e;if(this.log?.trace(`received frame %o`,e),n===0)switch(r){case Y.Ping:this.handlePing(e);return;case Y.GoAway:this.handleGoAway(i);return;default:throw new K(`Invalid frame type`)}else switch(e.type){case Y.Data:case Y.WindowUpdate:await this.handleStreamMessage(e,t);return;default:throw new K(`Invalid frame type`)}}handlePing(e){if(e.flag===X.SYN)this.log?.trace(`received ping request pingId=%s`,e.length),this.sendPing(e.length,X.ACK);else if(e.flag===X.ACK)this.log?.trace(`received ping response pingId=%s`,e.length),this.handlePingResponse(e.length);else throw new K(`Invalid frame flag`)}handlePingResponse(e){if(this.activePing===void 0)throw new Es(`ping not requested`);if(this.activePing.id!==e)throw new Ds(`ping doesn't match our id`);this.activePing.resolve()}handleGoAway(e){this.log?.trace(`received GoAway reason=%s`,Z[e]??`unknown`),this.remoteGoAway=e;for(let e of this._streams.values())e.reset();this._closeMuxer()}async handleStreamMessage(e,t){let{streamID:n,flag:r,type:i}=e;(r&X.SYN)===X.SYN&&this.incomingStream(n);let a=this._streams.get(n);if(a===void 0){if(i===Y.Data){if(this.log?.(`discarding data for stream id=%s`,n),t===void 0)throw Error(`unreachable`);await t()}else this.log?.trace(`frame for missing stream id=%s`,n);return}switch(i){case Y.WindowUpdate:a.handleWindowUpdate(e);return;case Y.Data:if(t===void 0)throw Error(`unreachable`);await a.handleData(e,t);return;default:throw Error(`unreachable`)}}incomingStream(e){if(this.client!==(e%2==0))throw new q(`Both endpoints are clients`);if(this._streams.has(e))return;if(this.log?.trace(`new incoming stream id=%s`,e),this.localGoAway!==void 0){this.sendFrame({type:Y.WindowUpdate,flag:X.RST,streamID:e,length:0});return}if(this.numInboundStreams>=this.config.maxInboundStreams){this.log?.(`maxIncomingStreams exceeded, forcing stream reset`),this.sendFrame({type:Y.WindowUpdate,flag:X.RST,streamID:e,length:0});return}let t=this._newStream(e,void 0,Q.SYNReceived,`inbound`);this.numInboundStreams++,this._streams.set(e,t),this.onIncomingStream?.(t)}sendFrame(e,t){if(this.log?.trace(`sending frame %o`,e),e.type===Y.Data){if(t===void 0)throw new K(`Invalid frame`);this.source.push(new G(Ws(e),t))}else this.source.push(Ws(e))}sendPing(e,t=X.SYN){t===X.SYN?this.log?.trace(`sending ping request pingId=%s`,e):this.log?.trace(`sending ping response pingId=%s`,e),this.sendFrame({type:Y.Ping,flag:t,streamID:0,length:e})}sendGoAway(e=Z.NormalTermination){this.log?.(`sending GoAway reason=%s`,Z[e]),this.localGoAway=e,this.sendFrame({type:Y.GoAway,flag:0,streamID:0,length:e})}};function ac(e){return e!=null&&typeof e.then==`function`}function oc(e={}){return t=>new rc(t,e)}function sc(){return async function*(e){for await(let t of e)W(t)?yield t.subarray():yield t}}var cc=class{_waiters=new Set;_error;_terminated=!1;get terminated(){return this._terminated}terminate(e){if(this._terminated)return!1;this._terminated=!0,this._error=e;for(let t of this._waiters)t(e);return this._waiters.clear(),!0}async wait(e){if(this._terminated)return{terminated:!0,error:this._error};let t,n=new Promise(e=>{t=t=>e({terminated:!0,error:t}),this._waiters.add(t)}),r=e.then(e=>({result:e}),e=>({error:e}));try{let e=await Promise.race([r,n]);return this._terminated?{terminated:!0,error:this._error}:e}finally{this._waiters.delete(t)}}next(e){return this.wait(e.next())}};function lc(e){if(Symbol.asyncIterator in e)return e[Symbol.asyncIterator]();let t=e[Symbol.iterator]();return{next:async()=>t.next()}}function uc(e){e.return&&Promise.resolve(e.return()).catch(()=>void 0)}function dc(e){let t=new cc;return{close:async()=>{t.terminate()&&await e.close()},abort:n=>{t.terminate(n)&&e.abort(n)},source:(async function*(){let n=H(e,_s(),sc())[Symbol.asyncIterator]();try{for(;;){let e=await t.next(n);if(`terminated`in e){if(e.error)throw e.error;return}if(`error`in e)throw e.error;if(e.result.done)return;yield e.result.value}}finally{uc(n)}})(),sink:async n=>{let r=lc(H(n,gs())),i=(async function*(){for(;;){let e=await t.next(r);if(`terminated`in e){if(e.error)throw e.error;return}if(`error`in e)throw e.error;if(e.result.done||t.terminated)return;yield e.result.value}})();try{let n=await t.wait(e.sink(i));if(`terminated`in n){if(n.error)throw n.error;return}if(`error`in n)throw n.error;await e.closeWrite()}catch(n){let r=n instanceof Error?n:Error(String(n));throw t.terminate(r)&&e.abort(r),r}finally{uc(r)}}}}function fc(e){let t=()=>{};return t.enabled=!1,t.color=``,t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t.debug=t,t.error=t,t.trace=t,t.newScope=()=>t,t}function pc(){return{forComponent:fc}}var mc=class{_muxer;_server;constructor(e,t){e&&(this._server=e);let n=t?.muxerFactory??oc({enableKeepAlive:!1,...t?.yamuxParams})({logger:t?.logger??pc()});this._muxer=n.createStreamMuxer({onIncomingStream:this.handleIncomingStream.bind(this),direction:t?.direction||`outbound`})}get sink(){return this._muxer.sink}get source(){return this._muxer.source}get streams(){return this._muxer.streams}get muxer(){return this._muxer}get server(){return this._server}buildClient(){return new bs(this.openStream.bind(this))}async openStream(){return dc(await this.muxer.newStream())}buildOpenStreamFunc(){return this.openStream.bind(this)}handleIncomingStream(e){let t=this.server;if(!t)return e.abort(Error(`server not implemented`));t.handlePacketStream(dc(e))}close(e){e?this.muxer.abort(e):this.muxer.close()}},hc=async e=>{if(e.readyState>=2)throw Error(`socket closed`);e.readyState!==1&&await new Promise((t,n)=>{function r(){e.removeEventListener(`open`,i),e.removeEventListener(`error`,a)}function i(){r(),t()}function a(t){r(),n(t.error??Error(`connect ECONNREFUSED ${e.url}`))}e.addEventListener(`open`,i),e.addEventListener(`error`,a)})},gc=(e,t)=>(t??={},t.closeOnEnd=t.closeOnEnd!==!1,async n=>{for await(let t of n){try{await hc(e)}catch(e){if(e.message===`socket closed`)break;throw e}if(e.readyState===e.CLOSING||e.readyState===e.CLOSED)break;e.send(t)}t.closeOnEnd!=null&&e.readyState<=1&&await new Promise((t,n)=>{e.addEventListener(`close`,e=>{e.wasClean||e.code===1006?t():n(Object.assign(Error(`ws error`),{event:e}))}),setTimeout(()=>{e.close()})})}),_c=e((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=class{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(e){if(this.isStopped)return;let t={value:e,done:!1};if(this.pullQueue.length){let e=this.pullQueue.shift();e&&e.resolve(t)}else this.pushQueue.push(Promise.resolve(t)),this.highWaterMark!==void 0&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(let e of this.pullQueue)e.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(e){if(!this.isStopped){if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(let t of this.pullQueue)t.reject(e);this.pullQueue.length=0}else{let t=Promise.reject(e);t.catch(()=>{}),this.pushQueue.push(t)}}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:e=>{let t=this.pushQueue.shift();return t?(this.lowWaterMark!==void 0&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),t):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((e,t)=>{this.pullQueue.push({resolve:e,reject:t})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}},n=class{constructor(e,{highWaterMark:n=100,lowWaterMark:r=1}={}){let i=new t;i.highWaterMark=n,i.lowWaterMark=r,i.removeCallback=e({push:e=>i.push(e),stop:()=>i.stop(),fail:e=>i.fail(e),on:(e,t)=>{i.eventHandlers[e]=t}})||(()=>{}),this[Symbol.asyncIterator]=()=>i[Symbol.asyncIterator](),Object.freeze(this)}};e.EventIterator=n,e.default=n})),vc=e((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=_c();e.EventIterator=t.EventIterator,e.default=t.EventIterator}))();function yc(e){return e instanceof ArrayBuffer||e?.constructor?.name===`ArrayBuffer`&&typeof e?.byteLength==`number`}var bc=e=>{e.binaryType=`arraybuffer`;let t=async()=>{await new Promise((t,n)=>{if(r){t();return}if(i!=null){n(i);return}let a=t=>{e.removeEventListener(`open`,o),e.removeEventListener(`error`,s),t()},o=()=>{a(t)},s=t=>{a(()=>{n(t.error??Error(`connect ECONNREFUSED ${e.url}`))})};e.addEventListener(`open`,o),e.addEventListener(`error`,s)})},n=async function*(){let n=new vc.EventIterator(({push:t,stop:n,fail:r})=>{let i=e=>{let n=null;if(typeof e.data==`string`)throw Error(`Unsupported string encoding`);yc(e.data)&&(n=new Uint8Array(e.data)),e.data instanceof Uint8Array&&(n=e.data),n!=null&&t(n)},a=e=>{r(e.error??Error(`Socket error`))};return e.addEventListener(`message`,i),e.addEventListener(`error`,a),e.addEventListener(`close`,n),()=>{e.removeEventListener(`message`,i),e.removeEventListener(`error`,a),e.removeEventListener(`close`,n)}},{highWaterMark:1/0});await t();for await(let e of n)yield yc(e)?new Uint8Array(e):e}(),r=e.readyState===1,i;return e.addEventListener(`open`,()=>{r=!0,i=null}),e.addEventListener(`close`,()=>{r=!1,i=null}),e.addEventListener(`error`,t=>{r||(i=t.error??Error(`connect ECONNREFUSED ${e.url}`))}),Object.assign(n,{connected:t})},xc=(e,t)=>{t??={};let n=bc(e),r=t.remoteAddress,i=t.remotePort;if(e.url!=null)try{let t=new URL(e.url);r=t.hostname,i=parseInt(t.port,10)}catch{}if(r==null||i==null)throw Error(`Remote connection did not have address and/or port`);return{sink:gc(e,t),source:n,connected:async()=>{await n.connected()},close:async()=>{(e.readyState===e.CONNECTING||e.readyState===e.OPEN)&&await new Promise(t=>{e.addEventListener(`close`,()=>{t()}),e.close()})},destroy:()=>{e.terminate==null?e.close():e.terminate()},remoteAddress:r,remotePort:i,socket:e}};function Sc(e,t){let n=ss(e.I);return async(r,i,a)=>{let o=B({objectMode:!0});H(o,cs(e.O),i);let s=H(r,n),c;if(e.kind===N.ClientStreaming||e.kind===N.BiDiStreaming)c=s;else for await(let e of s){c=e;break}if(!c)throw Error(`request object was empty`);try{let n=t(c,a.signal,a);if(!n)throw Error(`return value was undefined`);if(e.kind===N.ServerStreaming||e.kind===N.BiDiStreaming)return es(n,o);{let e=n;if(!e.then)throw Error(`expected return value to be a Promise`);let t=await e;if(!t)throw Error(`expected non-empty response object`);o.push(t),o.end()}}catch(e){let t=e;throw t?.message||(t=Error(`error calling implementation: `+e)),o.end(),t}}}var Cc=class{service;methods;constructor(e,t){this.service=e,this.methods=t}getServiceID(){return this.service}getMethodIDs(){return Object.keys(this.methods)}async lookupMethod(e,t){return e&&e!==this.service?null:this.methods[t]||null}};function wc(e,t,n){n||=e.typeName;let r={};for(let n of Object.values(e.methods)){let e=n.name,i=t[e];i&&(i=i.bind(t),r[e]=Sc(n,i))}return new Cc(n,r)}function Tc(){return new Ec}var Ec=class{services={};lookups=[];get lookupMethod(){return this._lookupMethod.bind(this)}register(e){let t=e?.getServiceID();if(!t)throw Error(`service id cannot be empty`);let n=this.services[t]||{},r=e.getMethodIDs();for(let t of r)n[t]=e;this.services[t]=n}registerLookupMethod(e){this.lookups.push(e)}async _lookupMethod(e,t){if(e){let n=await this.lookupViaMap(e,t);if(n)return n}return await this.lookupViaLookups(e,t)}async lookupViaMap(e,t){let n=this.services[e];if(!n)return null;let r=n[t];return r?await r.lookupMethod(e,t):null}async lookupViaLookups(e,t){for(let n of this.lookups){let r=await n(e,t);if(r)return r}return null}};const Dc=O({typeName:`rpcstream.RpcStreamInit`,fields:[{no:1,name:`component_id`,kind:`scalar`,T:p.STRING}],packedByDefault:!0}),Oc=O({typeName:`rpcstream.RpcAck`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING}],packedByDefault:!0}),kc=O({typeName:`rpcstream.RpcStreamPacket`,fields:[{no:1,name:`init`,kind:`message`,T:()=>Dc,oneof:`body`},{no:2,name:`ack`,kind:`message`,T:()=>Oc,oneof:`body`},{no:3,name:`data`,kind:`scalar`,T:p.BYTES,oneof:`body`}],packedByDefault:!0}),$=O({typeName:`echo.EchoMsg`,fields:[{no:1,name:`body`,kind:`scalar`,T:p.STRING}],packedByDefault:!0}),Ac=k(`google.protobuf.Empty`,!0);({typeName:`echo.Echoer`,methods:{Echo:{name:`Echo`,I:$,O:$,kind:N.Unary},EchoServerStream:{name:`EchoServerStream`,I:$,O:$,kind:N.ServerStreaming},EchoClientStream:{name:`EchoClientStream`,I:$,O:$,kind:N.ClientStreaming},EchoBidiStream:{name:`EchoBidiStream`,I:$,O:$,kind:N.BiDiStreaming},RpcStream:{name:`RpcStream`,I:kc,O:kc,kind:N.BiDiStreaming},DoNothing:{name:`DoNothing`,I:Ac,O:Ac,kind:N.Unary}}}).typeName;function jc(e){let t=!1,n=!1,r=!1,i,a,o=new Promise(e=>{a=e}),s=new ReadableStream({start(e){i=e}});function c(o){t||(t=!0,a(o),n||(n=!0,o?i.error(o):i.close()),r||(r=!0,e.postMessage(null)),e.removeEventListener(`message`,l),e.close())}function l(e){t||n||(e.data===null?(n=!0,i.close(),r&&c()):e.data instanceof Uint8Array?i.enqueue(e.data):c(Error(`Go MessagePort received a non-byte packet`)))}return e.addEventListener(`message`,l),e.start(),{source:(async function*(){let e=s.getReader();try{for(;;){let t=await e.read();if(t.done)return;yield t.value}}finally{e.releaseLock()}})(),sink:async i=>{let a=Symbol.asyncIterator in i?i[Symbol.asyncIterator]():i[Symbol.iterator](),s=o.then(e=>({error:e}));try{for(;;){let n=await Promise.race([Promise.resolve(a.next()),s]);if(`error`in n){if(n.error)throw n.error;break}if(t||n.done)break;e.postMessage(n.value)}r||(r=!0,e.postMessage(null),n&&c())}catch(e){throw c(e instanceof Error?e:Error(String(e))),e}finally{Promise.resolve(a.return?.()).catch(()=>{})}},close:async()=>c(),abort:c}}let Mc=function(e){return e[e.KIND_UNKNOWN=0]=`KIND_UNKNOWN`,e[e.READY=1]=`READY`,e[e.OPEN_STREAM=2]=`OPEN_STREAM`,e[e.CLOSE=3]=`CLOSE`,e[e.CLOSED=4]=`CLOSED`,e[e.FAILED=5]=`FAILED`,e}({});const Nc=b(`core.sync.node.RuntimeMessage.Kind`,Mc),Pc=O({typeName:`core.sync.node.RuntimeInit`,fields:[{no:1,name:`directory`,kind:`scalar`,T:p.STRING}]}),Fc=O({typeName:`core.sync.node.RuntimeMessage`,fields:[{no:1,name:`kind`,kind:`enum`,T:Nc},{no:2,name:`error`,kind:`scalar`,T:p.STRING}]});export{Za as $,Kt as $i,Fr as $n,Yn as $r,Jr as $t,ho as A,Rn as Ai,Gi as An,lr as Ar,Di as At,To as B,sn as Bi,Ti as Bn,Cr as Br,Zi as Bt,xo as C,O as Ca,Cn as Ci,Ca as Cn,xr as Cr,ri as Ct,ko as D,Nn as Di,ji as Dn,hr as Dr,Ni as Dt,Ao as E,n as Ea,Mn as Ei,Xi as En,sr as Er,ra as Et,lo as F,an as Fi,ea as Fn,fr as Fr,da as Ft,ro as G,Yt as Gi,ii as Gn,tr as Gr,Ci as Gt,Eo as H,Xt as Hi,ya as Hn,Tr as Hr,Ji as Ht,uo as I,ln as Ii,ta as In,pr as Ir,Rr as It,to as J,nn as Ji,Wr as Jn,In as Jr,_i as Jt,io as K,Zt as Ki,li as Kn,Qn as Kr,Ki as Kt,so as L,on as Li,jr as Ln,mr as Lr,zr as Lt,Co as M,En as Mi,$r as Mn,ar as Mr,gi as Mt,vo as N,Dn as Ni,ei as Nn,nr as Nr,Lr as Nt,go as O,mn as Oi,Ha as On,gr as Or,Pi as Ot,yo as P,cn as Pi,ti as Pn,rr as Pr,ua as Pt,Qa as Q,qt as Qi,Pr as Qn,Jn as Qr,qr as Qt,co as R,un as Ri,Mr as Rn,ur as Rr,Ea as Rt,bo as S,k as Sa,Sn as Si,Sa as Sn,vr as Sr,ci as St,Oo as T,p as Ta,Zn as Ti,_a as Tn,or as Tr,na as Tt,ao as U,tn as Ui,ai as Un,Er as Ur,Yi as Ut,wo as V,dn as Vi,va as Vn,wr as Vr,Qi as Vt,oo as W,$t as Wi,ui as Wn,er as Wr,Si as Wt,eo as X,Ut as Xi,ja as Xn,Pn as Xr,Oa as Xt,$a as Y,Wt as Yi,Aa as Yn,Ln as Yr,vi as Yt,Ja as Z,en as Zi,Nr as Zn,Fn as Zr,ka as Zt,H as _,kt as _a,yn as _i,Ri as _n,Br as _r,fi as _t,Tc as a,zt as aa,pn as ai,Oi as an,fa as ar,ni as at,po as b,Dt as ba,On as bi,Gr as bn,br,Ua as bt,mc as c,Lt as ca,An as ci,ha as cn,La as cr,ia as ct,lc as d,Pt as da,Un as di,Ai as dn,Ba as dr,bi as dt,Gt as ea,Wn as ei,Vr as en,Ir as er,Xa as et,sc as f,Nt as fa,wn as fi,Mi as fn,Va as fr,wa as ft,cs as g,j as ga,vn as gi,zi as gn,kr as gr,si as gt,ss as h,At as ha,Vn as hi,Li as hn,sa as hr,xa as ht,jc as i,Ht as ia,fn as ii,Fa as in,di as ir,Zr as it,So as j,zn as ji,Qr as jn,ir as jr,hi as jt,_o as k,hn as ki,Wa as kn,cr as kr,Ei as kt,cc as l,It as la,jn as li,Bi as ln,Yr as lr,aa as lt,bs as m,Mt as ma,Bn as mi,Wi as mn,oa as mr,ba as mt,Fc as n,Vt as na,Kn as ni,$i as nn,ca as nr,Ra as nt,wc as o,Rt as oa,gn as oi,ki as on,pa as or,Ma as ot,Ss as p,jt as pa,Tn as pi,Ui as pn,Hr as pr,Ta as pt,no as q,Qt as qi,Ur as qn,$n as qr,qi as qt,Mc as r,Bt as ra,qn as ri,Pa as rn,oi as rr,za as rt,xc as s,F as sa,_n as si,ma as sn,Ia as sr,Na as st,Pc as t,Jt as ta,Gn as ti,Vi as tn,la as tr,Ya as tt,uc as u,N as ua,Hn as ui,Hi as un,Xr as ur,yi as ut,B as v,M as va,bn as vi,Fi as vn,I as vr,pi as vt,Do as w,b as wa,Xn as wi,ga as wn,Sr as wr,xi as wt,mo as x,Et as xa,kn as xi,Kr as xn,_r as xr,Ga as xt,R as y,Ot as ya,xn as yi,Ii as yn,yr,mi as yt,fo as z,rn as zi,wi as zn,dr as zr,Da as zt};