vanilla-party
Version:
An easy to use library for simple multi-user JavaScript apps.
132 lines • 268 kB
JavaScript
var Ac=Object.create;var Hi=Object.defineProperty;var Dc=Object.getOwnPropertyDescriptor;var wc=Object.getOwnPropertyNames,zn=Object.getOwnPropertySymbols,Pc=Object.getPrototypeOf,Zn=Object.prototype.hasOwnProperty,Lc=Object.prototype.propertyIsEnumerable;var to=r=>{throw TypeError(r)},W=Math.pow,Xn=(r,e,t)=>e in r?Hi(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,De=(r,e)=>{for(var t in e||(e={}))Zn.call(e,t)&&Xn(r,t,e[t]);if(zn)for(var t of zn(e))Lc.call(e,t)&&Xn(r,t,e[t]);return r};var Uc=(r=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(r,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):r)(function(r){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var Mc=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(i){throw t=[i],i}};var v=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var Bc=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of wc(e))!Zn.call(r,n)&&n!==t&&Hi(r,n,{get:()=>e[n],enumerable:!(i=Dc(e,n))||i.enumerable});return r};var jr=(r,e,t)=>(t=r!=null?Ac(Pc(r)):{},Bc(e||!r||!r.__esModule?Hi(t,"default",{value:r,enumerable:!0}):t,r));var Gi=(r,e,t)=>e.has(r)||to("Cannot "+t);var O=(r,e,t)=>(Gi(r,e,"read from private field"),t?t.call(r):e.get(r)),z=(r,e,t)=>e.has(r)?to("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),$=(r,e,t,i)=>(Gi(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Dt=(r,e,t)=>(Gi(r,e,"access private method"),t);var _t=(r,e,t)=>new Promise((i,n)=>{var o=c=>{try{a(t.next(c))}catch(l){n(l)}},s=c=>{try{a(t.throw(c))}catch(l){n(l)}},a=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,s);a((t=t.apply(r,e)).next())});var io=v(Vr=>{"use strict";h();Vr.byteLength=xc;Vr.toByteArray=Vc;Vr.fromByteArray=Gc;var Yt=[],wt=[],kc=typeof Uint8Array!="undefined"?Uint8Array:Array,qi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(we=0,eo=qi.length;we<eo;++we)Yt[we]=qi[we],wt[qi.charCodeAt(we)]=we;var we,eo;wt[45]=62;wt[95]=63;function ro(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var i=t===e?0:4-t%4;return[t,i]}function xc(r){var e=ro(r),t=e[0],i=e[1];return(t+i)*3/4-i}function jc(r,e,t){return(e+t)*3/4-t}function Vc(r){var e,t=ro(r),i=t[0],n=t[1],o=new kc(jc(r,i,n)),s=0,a=n>0?i-4:i,c;for(c=0;c<a;c+=4)e=wt[r.charCodeAt(c)]<<18|wt[r.charCodeAt(c+1)]<<12|wt[r.charCodeAt(c+2)]<<6|wt[r.charCodeAt(c+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return n===2&&(e=wt[r.charCodeAt(c)]<<2|wt[r.charCodeAt(c+1)]>>4,o[s++]=e&255),n===1&&(e=wt[r.charCodeAt(c)]<<10|wt[r.charCodeAt(c+1)]<<4|wt[r.charCodeAt(c+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function Fc(r){return Yt[r>>18&63]+Yt[r>>12&63]+Yt[r>>6&63]+Yt[r&63]}function Hc(r,e,t){for(var i,n=[],o=e;o<t;o+=3)i=(r[o]<<16&16711680)+(r[o+1]<<8&65280)+(r[o+2]&255),n.push(Fc(i));return n.join("")}function Gc(r){for(var e,t=r.length,i=t%3,n=[],o=16383,s=0,a=t-i;s<a;s+=o)n.push(Hc(r,s,s+o>a?a:s+o));return i===1?(e=r[t-1],n.push(Yt[e>>2]+Yt[e<<4&63]+"==")):i===2&&(e=(r[t-2]<<8)+r[t-1],n.push(Yt[e>>10]+Yt[e>>4&63]+Yt[e<<2&63]+"=")),n.join("")}});var no=v(Wi=>{h();Wi.read=function(r,e,t,i,n){var o,s,a=n*8-i-1,c=(1<<a)-1,l=c>>1,f=-7,p=t?n-1:0,b=t?-1:1,I=r[e+p];for(p+=b,o=I&(1<<-f)-1,I>>=-f,f+=a;f>0;o=o*256+r[e+p],p+=b,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=i;f>0;s=s*256+r[e+p],p+=b,f-=8);if(o===0)o=1-l;else{if(o===c)return s?NaN:(I?-1:1)*(1/0);s=s+Math.pow(2,i),o=o-l}return(I?-1:1)*s*Math.pow(2,o-i)};Wi.write=function(r,e,t,i,n,o){var s,a,c,l=o*8-n-1,f=(1<<l)-1,p=f>>1,b=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=i?0:o-1,j=i?1:-1,P=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+p>=1?e+=b/c:e+=b*Math.pow(2,1-p),e*c>=2&&(s++,c/=2),s+p>=f?(a=0,s=f):s+p>=1?(a=(e*c-1)*Math.pow(2,n),s=s+p):(a=e*Math.pow(2,p-1)*Math.pow(2,n),s=0));n>=8;r[t+I]=a&255,I+=j,a/=256,n-=8);for(s=s<<n|a,l+=n;l>0;r[t+I]=s&255,I+=j,s/=256,l-=8);r[t+I-j]|=P*128}});var No=v(Ke=>{"use strict";h();var Yi=io(),We=no(),oo=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Ke.Buffer=d;Ke.SlowBuffer=Jc;Ke.INSPECT_MAX_BYTES=50;var Fr=2147483647;Ke.kMaxLength=Fr;d.TYPED_ARRAY_SUPPORT=qc();!d.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function qc(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch(r){return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}});Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function re(r){if(r>Fr)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,d.prototype),e}function d(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Qi(r)}return uo(r,e,t)}d.poolSize=8192;function uo(r,e,t){if(typeof r=="string")return Yc(r,e);if(ArrayBuffer.isView(r))return Kc(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(Kt(r,ArrayBuffer)||r&&Kt(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(Kt(r,SharedArrayBuffer)||r&&Kt(r.buffer,SharedArrayBuffer)))return $i(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let i=r.valueOf&&r.valueOf();if(i!=null&&i!==r)return d.from(i,e,t);let n=$c(r);if(n)return n;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return d.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}d.from=function(r,e,t){return uo(r,e,t)};Object.setPrototypeOf(d.prototype,Uint8Array.prototype);Object.setPrototypeOf(d,Uint8Array);function lo(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function Wc(r,e,t){return lo(r),r<=0?re(r):e!==void 0?typeof t=="string"?re(r).fill(e,t):re(r).fill(e):re(r)}d.alloc=function(r,e,t){return Wc(r,e,t)};function Qi(r){return lo(r),re(r<0?0:zi(r)|0)}d.allocUnsafe=function(r){return Qi(r)};d.allocUnsafeSlow=function(r){return Qi(r)};function Yc(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!d.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=ho(r,e)|0,i=re(t),n=i.write(r,e);return n!==t&&(i=i.slice(0,n)),i}function Ki(r){let e=r.length<0?0:zi(r.length)|0,t=re(e);for(let i=0;i<e;i+=1)t[i]=r[i]&255;return t}function Kc(r){if(Kt(r,Uint8Array)){let e=new Uint8Array(r);return $i(e.buffer,e.byteOffset,e.byteLength)}return Ki(r)}function $i(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let i;return e===void 0&&t===void 0?i=new Uint8Array(r):t===void 0?i=new Uint8Array(r,e):i=new Uint8Array(r,e,t),Object.setPrototypeOf(i,d.prototype),i}function $c(r){if(d.isBuffer(r)){let e=zi(r.length)|0,t=re(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||Zi(r.length)?re(0):Ki(r);if(r.type==="Buffer"&&Array.isArray(r.data))return Ki(r.data)}function zi(r){if(r>=Fr)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Fr.toString(16)+" bytes");return r|0}function Jc(r){return+r!=r&&(r=0),d.alloc(+r)}d.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==d.prototype};d.compare=function(e,t){if(Kt(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),Kt(t,Uint8Array)&&(t=d.from(t,t.offset,t.byteLength)),!d.isBuffer(e)||!d.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let i=e.length,n=t.length;for(let o=0,s=Math.min(i,n);o<s;++o)if(e[o]!==t[o]){i=e[o],n=t[o];break}return i<n?-1:n<i?1:0};d.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};d.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return d.alloc(0);let i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;let n=d.allocUnsafe(t),o=0;for(i=0;i<e.length;++i){let s=e[i];if(Kt(s,Uint8Array))o+s.length>n.length?(d.isBuffer(s)||(s=d.from(s)),s.copy(n,o)):Uint8Array.prototype.set.call(n,s,o);else if(d.isBuffer(s))s.copy(n,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return n};function ho(r,e){if(d.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||Kt(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&t===0)return 0;let n=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Ji(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Oo(r).length;default:if(n)return i?-1:Ji(r).length;e=(""+e).toLowerCase(),n=!0}}d.byteLength=ho;function Qc(r,e,t){let i=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return su(this,e,t);case"utf8":case"utf-8":return po(this,e,t);case"ascii":return nu(this,e,t);case"latin1":case"binary":return ou(this,e,t);case"base64":return ru(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return au(this,e,t);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0}}d.prototype._isBuffer=!0;function Pe(r,e,t){let i=r[e];r[e]=r[t],r[t]=i}d.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)Pe(this,t,t+1);return this};d.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)Pe(this,t,t+3),Pe(this,t+1,t+2);return this};d.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)Pe(this,t,t+7),Pe(this,t+1,t+6),Pe(this,t+2,t+5),Pe(this,t+3,t+4);return this};d.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?po(this,0,e):Qc.apply(this,arguments)};d.prototype.toLocaleString=d.prototype.toString;d.prototype.equals=function(e){if(!d.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:d.compare(this,e)===0};d.prototype.inspect=function(){let e="",t=Ke.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};oo&&(d.prototype[oo]=d.prototype.inspect);d.prototype.compare=function(e,t,i,n,o){if(Kt(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),!d.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),i===void 0&&(i=e?e.length:0),n===void 0&&(n=0),o===void 0&&(o=this.length),t<0||i>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=i)return 0;if(n>=o)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,n>>>=0,o>>>=0,this===e)return 0;let s=o-n,a=i-t,c=Math.min(s,a),l=this.slice(n,o),f=e.slice(t,i);for(let p=0;p<c;++p)if(l[p]!==f[p]){s=l[p],a=f[p];break}return s<a?-1:a<s?1:0};function fo(r,e,t,i,n){if(r.length===0)return-1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Zi(t)&&(t=n?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(n)return-1;t=r.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof e=="string"&&(e=d.from(e,i)),d.isBuffer(e))return e.length===0?-1:so(r,e,t,i,n);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):so(r,[e],t,i,n);throw new TypeError("val must be string, number or Buffer")}function so(r,e,t,i,n){let o=1,s=r.length,a=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||e.length<2)return-1;o=2,s/=2,a/=2,t/=2}function c(f,p){return o===1?f[p]:f.readUInt16BE(p*o)}let l;if(n){let f=-1;for(l=t;l<s;l++)if(c(r,l)===c(e,f===-1?0:l-f)){if(f===-1&&(f=l),l-f+1===a)return f*o}else f!==-1&&(l-=l-f),f=-1}else for(t+a>s&&(t=s-a),l=t;l>=0;l--){let f=!0;for(let p=0;p<a;p++)if(c(r,l+p)!==c(e,p)){f=!1;break}if(f)return l}return-1}d.prototype.includes=function(e,t,i){return this.indexOf(e,t,i)!==-1};d.prototype.indexOf=function(e,t,i){return fo(this,e,t,i,!0)};d.prototype.lastIndexOf=function(e,t,i){return fo(this,e,t,i,!1)};function zc(r,e,t,i){t=Number(t)||0;let n=r.length-t;i?(i=Number(i),i>n&&(i=n)):i=n;let o=e.length;i>o/2&&(i=o/2);let s;for(s=0;s<i;++s){let a=parseInt(e.substr(s*2,2),16);if(Zi(a))return s;r[t+s]=a}return s}function Xc(r,e,t,i){return Hr(Ji(e,r.length-t),r,t,i)}function Zc(r,e,t,i){return Hr(hu(e),r,t,i)}function tu(r,e,t,i){return Hr(Oo(e),r,t,i)}function eu(r,e,t,i){return Hr(fu(e,r.length-t),r,t,i)}d.prototype.write=function(e,t,i,n){if(t===void 0)n="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")n=t,i=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(i)?(i=i>>>0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((i===void 0||i>o)&&(i=o),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let s=!1;for(;;)switch(n){case"hex":return zc(this,e,t,i);case"utf8":case"utf-8":return Xc(this,e,t,i);case"ascii":case"latin1":case"binary":return Zc(this,e,t,i);case"base64":return tu(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return eu(this,e,t,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}};d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ru(r,e,t){return e===0&&t===r.length?Yi.fromByteArray(r):Yi.fromByteArray(r.slice(e,t))}function po(r,e,t){t=Math.min(r.length,t);let i=[],n=e;for(;n<t;){let o=r[n],s=null,a=o>239?4:o>223?3:o>191?2:1;if(n+a<=t){let c,l,f,p;switch(a){case 1:o<128&&(s=o);break;case 2:c=r[n+1],(c&192)===128&&(p=(o&31)<<6|c&63,p>127&&(s=p));break;case 3:c=r[n+1],l=r[n+2],(c&192)===128&&(l&192)===128&&(p=(o&15)<<12|(c&63)<<6|l&63,p>2047&&(p<55296||p>57343)&&(s=p));break;case 4:c=r[n+1],l=r[n+2],f=r[n+3],(c&192)===128&&(l&192)===128&&(f&192)===128&&(p=(o&15)<<18|(c&63)<<12|(l&63)<<6|f&63,p>65535&&p<1114112&&(s=p))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,i.push(s>>>10&1023|55296),s=56320|s&1023),i.push(s),n+=a}return iu(i)}var ao=4096;function iu(r){let e=r.length;if(e<=ao)return String.fromCharCode.apply(String,r);let t="",i=0;for(;i<e;)t+=String.fromCharCode.apply(String,r.slice(i,i+=ao));return t}function nu(r,e,t){let i="";t=Math.min(r.length,t);for(let n=e;n<t;++n)i+=String.fromCharCode(r[n]&127);return i}function ou(r,e,t){let i="";t=Math.min(r.length,t);for(let n=e;n<t;++n)i+=String.fromCharCode(r[n]);return i}function su(r,e,t){let i=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>i)&&(t=i);let n="";for(let o=e;o<t;++o)n+=du[r[o]];return n}function au(r,e,t){let i=r.slice(e,t),n="";for(let o=0;o<i.length-1;o+=2)n+=String.fromCharCode(i[o]+i[o+1]*256);return n}d.prototype.slice=function(e,t){let i=this.length;e=~~e,t=t===void 0?i:~~t,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<e&&(t=e);let n=this.subarray(e,t);return Object.setPrototypeOf(n,d.prototype),n};function ot(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||ot(e,t,this.length);let n=this[e],o=1,s=0;for(;++s<t&&(o*=256);)n+=this[e+s]*o;return n};d.prototype.readUintBE=d.prototype.readUIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||ot(e,t,this.length);let n=this[e+--t],o=1;for(;t>0&&(o*=256);)n+=this[e+--t]*o;return n};d.prototype.readUint8=d.prototype.readUInt8=function(e,t){return e=e>>>0,t||ot(e,1,this.length),this[e]};d.prototype.readUint16LE=d.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||ot(e,2,this.length),this[e]|this[e+1]<<8};d.prototype.readUint16BE=d.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||ot(e,2,this.length),this[e]<<8|this[e+1]};d.prototype.readUint32LE=d.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||ot(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};d.prototype.readUint32BE=d.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||ot(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};d.prototype.readBigUInt64LE=oe(function(e){e=e>>>0,Ye(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&yr(e,this.length-8);let n=t+this[++e]*W(2,8)+this[++e]*W(2,16)+this[++e]*W(2,24),o=this[++e]+this[++e]*W(2,8)+this[++e]*W(2,16)+i*W(2,24);return BigInt(n)+(BigInt(o)<<BigInt(32))});d.prototype.readBigUInt64BE=oe(function(e){e=e>>>0,Ye(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&yr(e,this.length-8);let n=t*W(2,24)+this[++e]*W(2,16)+this[++e]*W(2,8)+this[++e],o=this[++e]*W(2,24)+this[++e]*W(2,16)+this[++e]*W(2,8)+i;return(BigInt(n)<<BigInt(32))+BigInt(o)});d.prototype.readIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||ot(e,t,this.length);let n=this[e],o=1,s=0;for(;++s<t&&(o*=256);)n+=this[e+s]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*t)),n};d.prototype.readIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||ot(e,t,this.length);let n=t,o=1,s=this[e+--n];for(;n>0&&(o*=256);)s+=this[e+--n]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*t)),s};d.prototype.readInt8=function(e,t){return e=e>>>0,t||ot(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};d.prototype.readInt16LE=function(e,t){e=e>>>0,t||ot(e,2,this.length);let i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i};d.prototype.readInt16BE=function(e,t){e=e>>>0,t||ot(e,2,this.length);let i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i};d.prototype.readInt32LE=function(e,t){return e=e>>>0,t||ot(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};d.prototype.readInt32BE=function(e,t){return e=e>>>0,t||ot(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};d.prototype.readBigInt64LE=oe(function(e){e=e>>>0,Ye(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&yr(e,this.length-8);let n=this[e+4]+this[e+5]*W(2,8)+this[e+6]*W(2,16)+(i<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+this[++e]*W(2,8)+this[++e]*W(2,16)+this[++e]*W(2,24))});d.prototype.readBigInt64BE=oe(function(e){e=e>>>0,Ye(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&yr(e,this.length-8);let n=(t<<24)+this[++e]*W(2,16)+this[++e]*W(2,8)+this[++e];return(BigInt(n)<<BigInt(32))+BigInt(this[++e]*W(2,24)+this[++e]*W(2,16)+this[++e]*W(2,8)+i)});d.prototype.readFloatLE=function(e,t){return e=e>>>0,t||ot(e,4,this.length),We.read(this,e,!0,23,4)};d.prototype.readFloatBE=function(e,t){return e=e>>>0,t||ot(e,4,this.length),We.read(this,e,!1,23,4)};d.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||ot(e,8,this.length),We.read(this,e,!0,52,8)};d.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||ot(e,8,this.length),We.read(this,e,!1,52,8)};function vt(r,e,t,i,n,o){if(!d.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<o)throw new RangeError('"value" argument is out of bounds');if(t+i>r.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(e,t,i,n){if(e=+e,t=t>>>0,i=i>>>0,!n){let a=Math.pow(2,8*i)-1;vt(this,e,t,i,a,0)}let o=1,s=0;for(this[t]=e&255;++s<i&&(o*=256);)this[t+s]=e/o&255;return t+i};d.prototype.writeUintBE=d.prototype.writeUIntBE=function(e,t,i,n){if(e=+e,t=t>>>0,i=i>>>0,!n){let a=Math.pow(2,8*i)-1;vt(this,e,t,i,a,0)}let o=i-1,s=1;for(this[t+o]=e&255;--o>=0&&(s*=256);)this[t+o]=e/s&255;return t+i};d.prototype.writeUint8=d.prototype.writeUInt8=function(e,t,i){return e=+e,t=t>>>0,i||vt(this,e,t,1,255,0),this[t]=e&255,t+1};d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||vt(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||vt(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||vt(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||vt(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function Eo(r,e,t,i,n){go(e,i,n,r,t,7);let o=Number(e&BigInt(4294967295));r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,t}function yo(r,e,t,i,n){go(e,i,n,r,t,7);let o=Number(e&BigInt(4294967295));r[t+7]=o,o=o>>8,r[t+6]=o,o=o>>8,r[t+5]=o,o=o>>8,r[t+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=s,s=s>>8,r[t+2]=s,s=s>>8,r[t+1]=s,s=s>>8,r[t]=s,t+8}d.prototype.writeBigUInt64LE=oe(function(e,t=0){return Eo(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});d.prototype.writeBigUInt64BE=oe(function(e,t=0){return yo(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});d.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t=t>>>0,!n){let c=Math.pow(2,8*i-1);vt(this,e,t,i,c-1,-c)}let o=0,s=1,a=0;for(this[t]=e&255;++o<i&&(s*=256);)e<0&&a===0&&this[t+o-1]!==0&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+i};d.prototype.writeIntBE=function(e,t,i,n){if(e=+e,t=t>>>0,!n){let c=Math.pow(2,8*i-1);vt(this,e,t,i,c-1,-c)}let o=i-1,s=1,a=0;for(this[t+o]=e&255;--o>=0&&(s*=256);)e<0&&a===0&&this[t+o+1]!==0&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+i};d.prototype.writeInt8=function(e,t,i){return e=+e,t=t>>>0,i||vt(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};d.prototype.writeInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||vt(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};d.prototype.writeInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||vt(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};d.prototype.writeInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||vt(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};d.prototype.writeInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||vt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};d.prototype.writeBigInt64LE=oe(function(e,t=0){return Eo(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});d.prototype.writeBigInt64BE=oe(function(e,t=0){return yo(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Ro(r,e,t,i,n,o){if(t+i>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function _o(r,e,t,i,n){return e=+e,t=t>>>0,n||Ro(r,e,t,4,34028234663852886e22,-34028234663852886e22),We.write(r,e,t,i,23,4),t+4}d.prototype.writeFloatLE=function(e,t,i){return _o(this,e,t,!0,i)};d.prototype.writeFloatBE=function(e,t,i){return _o(this,e,t,!1,i)};function So(r,e,t,i,n){return e=+e,t=t>>>0,n||Ro(r,e,t,8,17976931348623157e292,-17976931348623157e292),We.write(r,e,t,i,52,8),t+8}d.prototype.writeDoubleLE=function(e,t,i){return So(this,e,t,!0,i)};d.prototype.writeDoubleBE=function(e,t,i){return So(this,e,t,!1,i)};d.prototype.copy=function(e,t,i,n){if(!d.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),!n&&n!==0&&(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<i&&(n=i),n===i||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-i&&(n=e.length-t+i);let o=n-i;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,i,n):Uint8Array.prototype.set.call(e,this.subarray(i,n),t),o};d.prototype.fill=function(e,t,i,n){if(typeof e=="string"){if(typeof t=="string"?(n=t,t=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!d.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(e.length===1){let s=e.charCodeAt(0);(n==="utf8"&&s<128||n==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);let o;if(typeof e=="number")for(o=t;o<i;++o)this[o]=e;else{let s=d.isBuffer(e)?e:d.from(e,n),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<i-t;++o)this[o+t]=s[o%a]}return this};var qe={};function Xi(r,e,t){qe[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(n){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:n,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}Xi("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Xi("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);Xi("ERR_OUT_OF_RANGE",function(r,e,t){let i=`The value of "${r}" is out of range.`,n=t;return Number.isInteger(t)&&Math.abs(t)>W(2,32)?n=co(String(t)):typeof t=="bigint"&&(n=String(t),(t>W(BigInt(2),BigInt(32))||t<-W(BigInt(2),BigInt(32)))&&(n=co(n)),n+="n"),i+=` It must be ${e}. Received ${n}`,i},RangeError);function co(r){let e="",t=r.length,i=r[0]==="-"?1:0;for(;t>=i+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function cu(r,e,t){Ye(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&yr(e,r.length-(t+1))}function go(r,e,t,i,n,o){if(r>t||r<e){let s=typeof e=="bigint"?"n":"",a;throw o>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${t}${s}`,new qe.ERR_OUT_OF_RANGE("value",a,r)}cu(i,n,o)}function Ye(r,e){if(typeof r!="number")throw new qe.ERR_INVALID_ARG_TYPE(e,"number",r)}function yr(r,e,t){throw Math.floor(r)!==r?(Ye(r,t),new qe.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new qe.ERR_BUFFER_OUT_OF_BOUNDS:new qe.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var uu=/[^+/0-9A-Za-z-_]/g;function lu(r){if(r=r.split("=")[0],r=r.trim().replace(uu,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Ji(r,e){e=e||1/0;let t,i=r.length,n=null,o=[];for(let s=0;s<i;++s){if(t=r.charCodeAt(s),t>55295&&t<57344){if(!n){if(t>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===i){(e-=3)>-1&&o.push(239,191,189);continue}n=t;continue}if(t<56320){(e-=3)>-1&&o.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(e-=3)>-1&&o.push(239,191,189);if(n=null,t<128){if((e-=1)<0)break;o.push(t)}else if(t<2048){if((e-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function hu(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function fu(r,e){let t,i,n,o=[];for(let s=0;s<r.length&&!((e-=2)<0);++s)t=r.charCodeAt(s),i=t>>8,n=t%256,o.push(n),o.push(i);return o}function Oo(r){return Yi.toByteArray(lu(r))}function Hr(r,e,t,i){let n;for(n=0;n<i&&!(n+t>=e.length||n>=r.length);++n)e[n+t]=r[n];return n}function Kt(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function Zi(r){return r!==r}var du=(function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let i=t*16;for(let n=0;n<16;++n)e[i+n]=r[t]+r[n]}return e})();function oe(r){return typeof BigInt=="undefined"?pu:r}function pu(){throw new Error("BigInt not supported")}});var E,h=Mc(()=>{"use strict";E=No().Buffer});var bo=v(Je=>{"use strict";h();Object.defineProperty(Je,"__esModule",{value:!0});Je.LOCAL_WINS=Je.REMOTE_WINS=void 0;var Eu=function(r,e,t,i,n){n(null,t)};Je.REMOTE_WINS=Eu;var yu=function(r,e,t,i,n){n(null,r)};Je.LOCAL_WINS=yu});var Io=v(qr=>{"use strict";h();Object.defineProperty(qr,"__esModule",{value:!0});qr.DefaultOptions=void 0;var Ru=bo();qr.DefaultOptions={nativeTimerRegistry:!0,intervalTimerResolution:50,subscriptionInterval:100,heartbeatInterval:3e4,reconnectIntervalIncrement:4e3,maxReconnectInterval:18e4,maxReconnectAttempts:5,subscriptionTimeout:2e3,recordReadAckTimeout:15e3,recordReadTimeout:15e3,recordDeleteTimeout:15e3,offlineBufferTimeout:2e3,recordDiscardTimeout:5e3,offlineEnabled:!1,saveUpdatesOffline:!1,recordReadOnlyMode:!1,recordPrefixWriteWhitelist:[],path:"/deepstream",mergeStrategy:Ru.REMOTE_WINS,recordDeepCopy:!0,dirtyStorageName:"__ds__dirty_records",ignorePrefixes:[],storageName:"indexdb",indexdb:{autoVersion:!1,dbVersion:1,primaryKey:"id",storageDatabaseName:"deepstream",defaultObjectStoreName:"records",objectStoreNames:[],flushTimeout:50},localstorage:{nodeStoragePath:"./local-storage",nodeStorageSize:5},lazyConnect:!1,debug:!1,initialRecordVersion:1}});var mo=v(Wr=>{"use strict";h();Object.defineProperty(Wr,"__esModule",{value:!0});Wr.TOPIC=void 0;var Co;(function(r){r[r.UNKNOWN=0]="UNKNOWN",r[r.PARSER=1]="PARSER",r[r.CONNECTION=2]="CONNECTION",r[r.AUTH=3]="AUTH",r[r.EVENT=4]="EVENT",r[r.RECORD=5]="RECORD",r[r.RPC=6]="RPC",r[r.PRESENCE=7]="PRESENCE",r[r.MONITORING=8]="MONITORING",r[r.CLUSTER=9]="CLUSTER",r[r.LOCK=10]="LOCK",r[r.STATE_REGISTRY=11]="STATE_REGISTRY",r[r.ERROR=100]="ERROR"})(Co||(Wr.TOPIC=Co={}))});var Do=v(Yr=>{"use strict";h();Object.defineProperty(Yr,"__esModule",{value:!0});Yr.RECORD_ACTION=void 0;var Ao;(function(r){r[r.UNKNOWN=0]="UNKNOWN",r[r.ERROR=1]="ERROR",r[r.NOTIFY=2]="NOTIFY",r[r.READ=3]="READ",r[r.READ_RESPONSE=4]="READ_RESPONSE",r[r.HEAD=5]="HEAD",r[r.HEAD_RESPONSE=6]="HEAD_RESPONSE",r[r.HEAD_BULK=7]="HEAD_BULK",r[r.HEAD_RESPONSE_BULK=8]="HEAD_RESPONSE_BULK",r[r.DELETE=9]="DELETE",r[r.DELETE_SUCCESS=10]="DELETE_SUCCESS",r[r.DELETE_BULK=11]="DELETE_BULK",r[r.DELETE_BULK_SUCCESS=12]="DELETE_BULK_SUCCESS",r[r.DELETED=13]="DELETED",r[r.WRITE_ACKNOWLEDGEMENT=14]="WRITE_ACKNOWLEDGEMENT",r[r.CREATE=15]="CREATE",r[r.CREATEANDUPDATE=16]="CREATEANDUPDATE",r[r.CREATEANDPATCH=17]="CREATEANDPATCH",r[r.UPDATE=18]="UPDATE",r[r.PATCH=19]="PATCH",r[r.ERASE=20]="ERASE",r[r.SUBSCRIBEANDHEAD=21]="SUBSCRIBEANDHEAD",r[r.SUBSCRIBEANDREAD=22]="SUBSCRIBEANDREAD",r[r.SUBSCRIBECREATEANDREAD=23]="SUBSCRIBECREATEANDREAD",r[r.SUBSCRIBECREATEANDUPDATE=24]="SUBSCRIBECREATEANDUPDATE",r[r.SUBSCRIBE=25]="SUBSCRIBE",r[r.UNSUBSCRIBE=26]="UNSUBSCRIBE",r[r.LISTEN=27]="LISTEN",r[r.UNLISTEN=28]="UNLISTEN",r[r.LISTEN_ACCEPT=29]="LISTEN_ACCEPT",r[r.LISTEN_REJECT=30]="LISTEN_REJECT",r[r.SUBSCRIPTION_HAS_PROVIDER=31]="SUBSCRIPTION_HAS_PROVIDER",r[r.SUBSCRIPTION_HAS_NO_PROVIDER=32]="SUBSCRIPTION_HAS_NO_PROVIDER",r[r.SUBSCRIPTION_FOR_PATTERN_FOUND=33]="SUBSCRIPTION_FOR_PATTERN_FOUND",r[r.SUBSCRIPTION_FOR_PATTERN_REMOVED=34]="SUBSCRIPTION_FOR_PATTERN_REMOVED",r[r.PATCH_MULTI=35]="PATCH_MULTI",r[r.CACHE_RETRIEVAL_TIMEOUT=100]="CACHE_RETRIEVAL_TIMEOUT",r[r.STORAGE_RETRIEVAL_TIMEOUT=101]="STORAGE_RETRIEVAL_TIMEOUT",r[r.VERSION_EXISTS=102]="VERSION_EXISTS",r[r.RECORD_LOAD_ERROR=103]="RECORD_LOAD_ERROR",r[r.RECORD_CREATE_ERROR=104]="RECORD_CREATE_ERROR",r[r.RECORD_UPDATE_ERROR=105]="RECORD_UPDATE_ERROR",r[r.RECORD_DELETE_ERROR=106]="RECORD_DELETE_ERROR",r[r.RECORD_NOT_FOUND=107]="RECORD_NOT_FOUND",r[r.INVALID_VERSION=108]="INVALID_VERSION",r[r.INVALID_PATCH_ON_HOTPATH=109]="INVALID_PATCH_ON_HOTPATH",r[r.INVALID_LISTEN_REGEX=110]="INVALID_LISTEN_REGEX",r[r.LISTEN_RESPONSE_TIMEOUT=111]="LISTEN_RESPONSE_TIMEOUT",r[r.LISTEN_UNSUCCESSFUL=112]="LISTEN_UNSUCCESSFUL",r[r.RECORD_NOTIFY_ERROR=113]="RECORD_NOTIFY_ERROR",r[r.MESSAGE_PERMISSION_ERROR=114]="MESSAGE_PERMISSION_ERROR",r[r.MESSAGE_DENIED=115]="MESSAGE_DENIED",r[r.INVALID_MESSAGE_DATA=116]="INVALID_MESSAGE_DATA",r[r.MULTIPLE_SUBSCRIPTIONS=117]="MULTIPLE_SUBSCRIPTIONS",r[r.NOT_SUBSCRIBED=118]="NOT_SUBSCRIBED"})(Ao||(Yr.RECORD_ACTION=Ao={}))});var Po=v(Kr=>{"use strict";h();Object.defineProperty(Kr,"__esModule",{value:!0});Kr.AUTH_ACTION=void 0;var wo;(function(r){r[r.UNKNOWN=0]="UNKNOWN",r[r.ERROR=1]="ERROR",r[r.REQUEST=2]="REQUEST",r[r.AUTH_SUCCESSFUL=3]="AUTH_SUCCESSFUL",r[r.AUTH_UNSUCCESSFUL=4]="AUTH_UNSUCCESSFUL",r[r.TOO_MANY_AUTH_ATTEMPTS=100]="TOO_MANY_AUTH_ATTEMPTS",r[r.INVALID_MESSAGE=101]="INVALID_MESSAGE",r[r.INVALID_MESSAGE_DATA=102]="INVALID_MESSAGE_DATA"})(wo||(Kr.AUTH_ACTION=wo={}))});var Uo=v($r=>{"use strict";h();Object.defineProperty($r,"__esModule",{value:!0});$r.EVENT_ACTION=void 0;var Lo;(function(r){r[r.UNKNOWN=0]="UNKNOWN",r[r.ERROR=1]="ERROR",r[r.EMIT=2]="EMIT",r[r.SUBSCRIBE=3]="SUBSCRIBE",r[r.UNSUBSCRIBE=4]="UNSUBSCRIBE",r[r.LISTEN=5]="LISTEN",r[r.UNLISTEN=6]="UNLISTEN",r[r.LISTEN_ACCEPT=7]="LISTEN_ACCEPT",r[r.LISTEN_REJECT=8]="LISTEN_REJECT",r[r.SUBSCRIPTION_HAS_PROVIDER=9]="SUBSCRIPTION_HAS_PROVIDER",r[r.SUBSCRIPTION_HAS_NO_PROVIDER=10]="SUBSCRIPTION_HAS_NO_PROVIDER",r[r.SUBSCRIPTION_FOR_PATTERN_FOUND=11]="SUBSCRIPTION_FOR_PATTERN_FOUND",r[r.SUBSCRIPTION_FOR_PATTERN_REMOVED=12]="SUBSCRIPTION_FOR_PATTERN_REMOVED",r[r.INVALID_LISTEN_REGEX=100]="INVALID_LISTEN_REGEX",r[r.LISTEN_RESPONSE_TIMEOUT=101]="LISTEN_RESPONSE_TIMEOUT",r[r.LISTEN_UNSUCCESSFUL=102]="LISTEN_UNSUCCESSFUL",r[r.MESSAGE_PERMISSION_ERROR=103]="MESSAGE_PERMISSION_ERROR",r[r.MESSAGE_DENIED=104]="MESSAGE_DENIED",r[r.INVALID_MESSAGE_DATA=105]="INVALID_MESSAGE_DATA",r[r.MULTIPLE_SUBSCRIPTIONS=106]="MULTIPLE_SUBSCRIPTIONS",r[r.NOT_SUBSCRIBED=107]="NOT_SUBSCRIBED"})(Lo||($r.EVENT_ACTION=Lo={}))});var Bo=v(Jr=>{"use strict";h();Object.defineProperty(Jr,"__esModule",{value:!0});Jr.RPC_ACTION=void 0;var Mo;(function(r){r[r.UNKNOWN=0]="UNKNOWN",r[r.ERROR=1]="ERROR",r[r.REQUEST=2]="REQUEST",r[r.ACCEPT=4]="ACCEPT",r[r.RESPONSE=5]="RESPONSE",r[r.REJECT=6]="REJECT",r[r.REQUEST_ERROR=7]="REQUEST_ERROR",r[r.PROVIDE=8]="PROVIDE",r[r.UNPROVIDE=9]="UNPROVIDE",r[r.NO_RPC_PROVIDER=100]="NO_RPC_PROVIDER",r[r.ACCEPT_TIMEOUT=101]="ACCEPT_TIMEOUT",r[r.MULTIPLE_ACCEPT=102]="MULTIPLE_ACCEPT",r[r.INVALID_RPC_CORRELATION_ID=103]="INVALID_RPC_CORRELATION_ID",r[r.RESPONSE_TIMEOUT=104]="RESPONSE_TIMEOUT",r[r.MULTIPLE_RESPONSE=105]="MULTIPLE_RESPONSE",r[r.MESSAGE_PERMISSION_ERROR=106]="MESSAGE_PERMISSION_ERROR",r[r.MESSAGE_DENIED=107]="MESSAGE_DENIED",r[r.INVALID_MESSAGE_DATA=108]="INVALID_MESSAGE_DATA",r[r.MULTIPLE_PROVIDERS=109]="MULTIPLE_PROVIDERS",r[r.NOT_PROVIDED=110]="NOT_PROVIDED"})(Mo||(Jr.RPC_ACTION=Mo={}))});var xo=v(Qr=>{"use strict";h();Object.defineProperty(Qr,"__esModule",{value:!0});Qr.PRESENCE_ACTION=void 0;var ko;(function(r){r[r.UNKNOWN=0]="UNKNOWN",r[r.ERROR=1]="ERROR",r[r.QUERY_ALL=2]="QUERY_ALL",r[r.QUERY_ALL_RESPONSE=3]="QUERY_ALL_RESPONSE",r[r.QUERY=4]="QUERY",r[r.QUERY_RESPONSE=5]="QUERY_RESPONSE",r[r.PRESENCE_JOIN=6]="PRESENCE_JOIN",r[r.PRESENCE_JOIN_ALL=7]="PRESENCE_JOIN_ALL",r[r.PRESENCE_LEAVE=8]="PRESENCE_LEAVE",r[r.PRESENCE_LEAVE_ALL=9]="PRESENCE_LEAVE_ALL",r[r.SUBSCRIBE=10]="SUBSCRIBE",r[r.UNSUBSCRIBE=11]="UNSUBSCRIBE",r[r.SUBSCRIBE_ALL=12]="SUBSCRIBE_ALL",r[r.UNSUBSCRIBE_ALL=13]="UNSUBSCRIBE_ALL",r[r.INVALID_PRESENCE_USERS=100]="INVALID_PRESENCE_USERS",r[r.MESSAGE_PERMISSION_ERROR=101]="MESSAGE_PERMISSION_ERROR",r[r.MESSAGE_DENIED=102]="MESSAGE_DENIED",r[r.MULTIPLE_SUBSCRIPTIONS=103]="MULTIPLE_SUBSCRIPTIONS",r[r.NOT_SUBSCRIBED=104]="NOT_SUBSCRIBED"})(ko||(Qr.PRESENCE_ACTION=ko={}))});var Vo=v(zr=>{"use strict";h();Object.defineProperty(zr,"__esModule",{value:!0});zr.CONNECTION_ACTION=void 0;var jo;(function(r){r[r.UNKNOWN=0]="UNKNOWN",r[r.ERROR=1]="ERROR",r[r.PING=2]="PING",r[r.PONG=3]="PONG",r[r.ACCEPT=4]="ACCEPT",r[r.CHALLENGE=5]="CHALLENGE",r[r.REJECT=6]="REJECT",r[r.REDIRECT=7]="REDIRECT",r[r.CLOSING=8]="CLOSING",r[r.CLOSED=9]="CLOSED",r[r.AUTHENTICATION_TIMEOUT=100]="AUTHENTICATION_TIMEOUT",r[r.INVALID_MESSAGE=101]="INVALID_MESSAGE"})(jo||(zr.CONNECTION_ACTION=jo={}))});var Ho=v(Xr=>{"use strict";h();Object.defineProperty(Xr,"__esModule",{value:!0});Xr.CLUSTER_ACTION=void 0;var Fo;(function(r){r[r.REMOVE=1]="REMOVE",r[r.STATUS=2]="STATUS"})(Fo||(Xr.CLUSTER_ACTION=Fo={}))});var qo=v(Zr=>{"use strict";h();Object.defineProperty(Zr,"__esModule",{value:!0});Zr.LOCK_ACTION=void 0;var Go;(function(r){r[r.UNKNOWN=0]="UNKNOWN",r[r.ERROR=1]="ERROR",r[r.REQUEST=2]="REQUEST",r[r.RESPONSE=3]="RESPONSE",r[r.RELEASE=4]="RELEASE"})(Go||(Zr.LOCK_ACTION=Go={}))});var Yo=v(ti=>{"use strict";h();Object.defineProperty(ti,"__esModule",{value:!0});ti.PARSER_ACTION=void 0;var Wo;(function(r){r[r.UNKNOWN=0]="UNKNOWN",r[r.UNKNOWN_TOPIC=1]="UNKNOWN_TOPIC",r[r.UNKNOWN_ACTION=2]="UNKNOWN_ACTION",r[r.INVALID_MESSAGE=3]="INVALID_MESSAGE",r[r.MESSAGE_PARSE_ERROR=4]="MESSAGE_PARSE_ERROR",r[r.MAXIMUM_MESSAGE_SIZE_EXCEEDED=5]="MAXIMUM_MESSAGE_SIZE_EXCEEDED",r[r.ERROR=6]="ERROR",r[r.INVALID_META_PARAMS=7]="INVALID_META_PARAMS"})(Wo||(ti.PARSER_ACTION=Wo={}))});var $o=v(ei=>{"use strict";h();Object.defineProperty(ei,"__esModule",{value:!0});ei.MONITORING_ACTION=void 0;var Ko;Ko||(ei.MONITORING_ACTION=Ko={})});var zo=v(Qe=>{"use strict";h();Object.defineProperty(Qe,"__esModule",{value:!0});Qe.STATE_ACTION=Qe.STATE_REGISTRY_TOPIC=void 0;var Jo;(function(r){r[r.EVENT_SUBSCRIPTIONS=11]="EVENT_SUBSCRIPTIONS",r[r.RECORD_SUBSCRIPTIONS=12]="RECORD_SUBSCRIPTIONS",r[r.SUBSCRIPTIONS=9]="SUBSCRIPTIONS",r[r.ONLINE_USERS=10]="ONLINE_USERS",r[r.MONITORING_SUBSCRIPTIONS=24]="MONITORING_SUBSCRIPTIONS",r[r.RPC_SUBSCRIPTIONS=13]="RPC_SUBSCRIPTIONS",r[r.PRESENCE_SUBSCRIPTIONS=14]="PRESENCE_SUBSCRIPTIONS",r[r.RECORD_LISTEN_PATTERNS=15]="RECORD_LISTEN_PATTERNS",r[r.EVENT_LISTEN_PATTERNS=16]="EVENT_LISTEN_PATTERNS",r[r.RECORD_PUBLISHED_SUBSCRIPTIONS=17]="RECORD_PUBLISHED_SUBSCRIPTIONS",r[r.EVENT_PUBLISHED_SUBSCRIPTIONS=18]="EVENT_PUBLISHED_SUBSCRIPTIONS",r[r.RECORD_LISTENING=19]="RECORD_LISTENING",r[r.EVENT_LISTENING=20]="EVENT_LISTENING",r[r.STATE_REGISTRY=21]="STATE_REGISTRY"})(Jo||(Qe.STATE_REGISTRY_TOPIC=Jo={}));var Qo;(function(r){r[r.UNKNOWN=0]="UNKNOWN",r[r.ERROR=1]="ERROR",r[r.ADD=2]="ADD",r[r.REMOVE=3]="REMOVE",r[r.REQUEST_FULL_STATE=4]="REQUEST_FULL_STATE",r[r.FULL_STATE=5]="FULL_STATE",r[r.CHECKSUM=6]="CHECKSUM"})(Qo||(Qe.STATE_ACTION=Qo={}))});var ze=v(F=>{"use strict";h();Object.defineProperty(F,"__esModule",{value:!0});F.STATE_REGISTRY_TOPIC=F.STATE_ACTION=F.MONITORING_ACTION=F.PARSER_ACTION=F.LOCK_ACTION=F.CLUSTER_ACTION=F.CONNECTION_ACTION=F.PRESENCE_ACTION=F.RPC_ACTION=F.EVENT_ACTION=F.AUTH_ACTION=F.RECORD_ACTION=F.TOPIC=void 0;var _u=mo();Object.defineProperty(F,"TOPIC",{enumerable:!0,get:function(){return _u.TOPIC}});var Su=Do();Object.defineProperty(F,"RECORD_ACTION",{enumerable:!0,get:function(){return Su.RECORD_ACTION}});var gu=Po();Object.defineProperty(F,"AUTH_ACTION",{enumerable:!0,get:function(){return gu.AUTH_ACTION}});var Ou=Uo();Object.defineProperty(F,"EVENT_ACTION",{enumerable:!0,get:function(){return Ou.EVENT_ACTION}});var Nu=Bo();Object.defineProperty(F,"RPC_ACTION",{enumerable:!0,get:function(){return Nu.RPC_ACTION}});var vu=xo();Object.defineProperty(F,"PRESENCE_ACTION",{enumerable:!0,get:function(){return vu.PRESENCE_ACTION}});var Tu=Vo();Object.defineProperty(F,"CONNECTION_ACTION",{enumerable:!0,get:function(){return Tu.CONNECTION_ACTION}});var bu=Ho();Object.defineProperty(F,"CLUSTER_ACTION",{enumerable:!0,get:function(){return bu.CLUSTER_ACTION}});var Iu=qo();Object.defineProperty(F,"LOCK_ACTION",{enumerable:!0,get:function(){return Iu.LOCK_ACTION}});var Cu=Yo();Object.defineProperty(F,"PARSER_ACTION",{enumerable:!0,get:function(){return Cu.PARSER_ACTION}});var mu=$o();Object.defineProperty(F,"MONITORING_ACTION",{enumerable:!0,get:function(){return mu.MONITORING_ACTION}});var Xo=zo();Object.defineProperty(F,"STATE_ACTION",{enumerable:!0,get:function(){return Xo.STATE_ACTION}});Object.defineProperty(F,"STATE_REGISTRY_TOPIC",{enumerable:!0,get:function(){return Xo.STATE_REGISTRY_TOPIC}})});var tn=v(ri=>{"use strict";h();Object.defineProperty(ri,"__esModule",{value:!0});ri.ACTIONS=void 0;var X=ze();ri.ACTIONS={[X.TOPIC.PARSER]:X.PARSER_ACTION,[X.TOPIC.CONNECTION]:X.CONNECTION_ACTION,[X.TOPIC.AUTH]:X.AUTH_ACTION,[X.TOPIC.EVENT]:X.EVENT_ACTION,[X.TOPIC.RECORD]:X.RECORD_ACTION,[X.TOPIC.RPC]:X.RPC_ACTION,[X.TOPIC.PRESENCE]:X.PRESENCE_ACTION,[X.TOPIC.LOCK]:X.LOCK_ACTION,[X.TOPIC.STATE_REGISTRY]:X.STATE_ACTION,[X.TOPIC.CLUSTER]:X.CLUSTER_ACTION,[X.TOPIC.MONITORING]:X.MONITORING_ACTION}});var Q=v(yt=>{"use strict";h();var Au=yt&&yt.__createBinding||(Object.create?(function(r,e,t,i){i===void 0&&(i=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,i,n)}):(function(r,e,t,i){i===void 0&&(i=t),r[i]=e[t]})),Zo=yt&&yt.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Au(e,r,t)},Xe,_r,ii,ni;Object.defineProperty(yt,"__esModule",{value:!0});yt.CONNECTION_STATE=yt.EVENT=yt.RESPONSE_TO_REQUEST=void 0;var st=ze();Zo(ze(),yt);Zo(tn(),yt);yt.RESPONSE_TO_REQUEST=(Xe={},Xe[st.TOPIC.RECORD]=(_r={},_r[st.RECORD_ACTION.HEAD_RESPONSE]=st.RECORD_ACTION.HEAD,_r[st.RECORD_ACTION.READ_RESPONSE]=st.RECORD_ACTION.READ,_r[st.RECORD_ACTION.DELETE_SUCCESS]=st.RECORD_ACTION.DELETE,_r),Xe[st.TOPIC.PRESENCE]=(ii={},ii[st.PRESENCE_ACTION.QUERY_RESPONSE]=st.PRESENCE_ACTION.QUERY,ii[st.PRESENCE_ACTION.QUERY_ALL_RESPONSE]=st.PRESENCE_ACTION.QUERY_ALL,ii),Xe[st.TOPIC.RPC]=(ni={},ni[st.RPC_ACTION.ACCEPT]=st.RPC_ACTION.REQUEST,ni[st.RPC_ACTION.ERROR]=st.RPC_ACTION.REQUEST,ni),Xe[st.TOPIC.EVENT]={},Xe);var Du;(function(r){r.RECORD_READ_ONLY_MODE="RECORD_READ_ONLY_MODE",r.UNSOLICITED_MESSAGE="UNSOLICITED_MESSAGE",r.IS_CLOSED="IS_CLOSED",r.MAX_RECONNECTION_ATTEMPTS_REACHED="MAX_RECONNECTION_ATTEMPTS_REACHED",r.CONNECTION_ERROR="CONNECTION_ERROR",r.ACK_TIMEOUT="ACK_TIMEOUT",r.UNKNOWN_CORRELATION_ID="UNKNOWN_CORRELATION_ID",r.HEARTBEAT_TIMEOUT="HEARTBEAT_TIMEOUT",r.LISTENER_EXISTS="LISTENER_EXISTS",r.NOT_LISTENING="NOT_LISTENING",r.RECORD_ALREADY_DESTROYED="RECORD_ALREADY_DESTROYED",r.RECORD_DELETE_TIMEOUT="RECORD_DELETE_TIMEOUT",r.CLIENT_OFFLINE="client offline",r.INVALID_AUTHENTICATION_DETAILS="INVALID_AUTHENTICATION_DETAILS",r.CONNECTION_LOST="connectionLost",r.CONNECTION_REESTABLISHED="connectionReestablished",r.EXIT_LIMBO="exitLimbo",r.CONNECTION_STATE_CHANGED="connectionStateChanged",r.CLIENT_DATA_CHANGED="clientDataChanged",r.REAUTHENTICATION_FAILURE="reauthenticationFailure",r.AUTHENTICATION_TIMEOUT="AUTHENTICATION_TIMEOUT",r.RECORD_ERROR="error",r.RECORD_READY="ready",r.RECORD_DELETED="delete",r.RECORD_DISCARDED="discard",r.RECORD_VERSION_EXISTS="versionExists",r.RECORD_HAS_PROVIDER_CHANGED="hasProviderChanged",r.RECORD_STATE_CHANGED="onRecordStateChanged",r.ENTRY_ADDED_EVENT="entry-added",r.ENTRY_REMOVED_EVENT="entry-removed",r.ENTRY_MOVED_EVENT="entry-moved"})(Du=yt.EVENT||(yt.EVENT={}));var wu;(function(r){r.CLOSING="CLOSING",r.CLOSED="CLOSED",r.INITIALISING="INITIALISING",r.AWAITING_CONNECTION="AWAITING_CONNECTION",r.CHALLENGING="CHALLENGING",r.AWAITING_AUTHENTICATION="AWAITING_AUTHENTICATION",r.AUTHENTICATING="AUTHENTICATING",r.OPEN="OPEN",r.ERROR="ERROR",r.RECONNECTING="RECONNECTING",r.REDIRECTING="REDIRECTING",r.CHALLENGE_DENIED="CHALLENGE_DENIED",r.TOO_MANY_AUTH_ATTEMPTS="TOO_MANY_AUTH_ATTEMPTS",r.AUTHENTICATION_TIMEOUT="AUTHENTICATION_TIMEOUT",r.PAUSING="PAUSING",r.OFFLINE="OFFLINE"})(wu=yt.CONNECTION_STATE||(yt.CONNECTION_STATE={}))});var es=v(oi=>{"use strict";h();Object.defineProperty(oi,"__esModule",{value:!0});oi.Logger=void 0;var Ze=Q(),ts=tn(),Sr=ze();function Pu(r){return Ze.EVENT[r]!==void 0}var Lu=(function(){function r(e){this.emitter=e}return r.prototype.warn=function(e,t,i){var n="Warning: ".concat(Sr.TOPIC[e.topic]),o=e.action;o&&(n+=" (".concat(ts.ACTIONS[e.topic][o],")")),t&&(n+=": ".concat(Ze.EVENT[t])),i&&(n+=" \u2013 ".concat(typeof i=="string"?i:JSON.stringify(i))),console.warn(n)},r.prototype.error=function(e,t,i){if(Pu(t))t===Ze.EVENT.IS_CLOSED||t===Ze.EVENT.CONNECTION_ERROR?this.emitter.emit("error",i,Ze.EVENT[t],Sr.TOPIC[Sr.TOPIC.CONNECTION]):this.emitter.emit("error",i,Ze.EVENT[t],Sr.TOPIC[e.topic]);else{var n=t||e.action;this.emitter.emit("error",i||e,ts.ACTIONS[e.topic][n],Sr.TOPIC[e.topic])}},r})();oi.Logger=Lu});var xt=v($t=>{"use strict";h();var Uu=$t&&$t.__values||function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},rs=$t&&$t.__read||function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,o=[],s;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(a){s={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return o},Mu=$t&&$t.__spreadArray||function(r,e,t){if(t||arguments.length===2)for(var i=0,n=e.length,o;i<n;i++)(o||!(i in e))&&(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return r.concat(o||Array.prototype.slice.call(e))};Object.defineProperty($t,"__esModule",{value:!0});$t.Emitter=void 0;var Bu=(function(){function r(){this.callbacks=null}return r.prototype.on=function(e,t,i){i===void 0&&(i=this),this.callbacks=this.callbacks||new Map;var n=this.callbacks.get(e);return n?n.push({fn:t,scope:i}):(n=[{fn:t,scope:i}],this.callbacks.set(e,n)),this},r.prototype.once=function(e,t,i){var n=this;i===void 0&&(i=this);var o=function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];n.off(e,o,n),t.apply(n,s)};return o.fn=t,this.on(e,o,i),this},r.prototype.off=function(e,t,i){if(e===void 0&&t===void 0&&i===void 0&&(this.callbacks=null),this.callbacks===null)return this;var n=this.callbacks.get(e);return n?t===void 0&&i===void 0?(this.callbacks.delete(e),this):(n=n.filter(function(o){var s=o.fn,a=o.scope;return!(e!==""&&t===void 0&&i===a||(s===t||s.fn===t)&&(i===void 0||i===a))}),n.length===0?this.callbacks.delete(e):this.callbacks.set(e,n),this):this},r.prototype.removeContext=function(e){var t,i;if(this.callbacks!==null)try{for(var n=Uu(this.callbacks),o=n.next();!o.done;o=n.next()){var s=rs(o.value,2),a=s[0],c=s[1];this.callbacks.set(a,c.filter(function(l){var f=l.scope;return f===e}))}}catch(l){t={error:l}}finally{try{o&&!o.done&&(i=n.return)&&i.call(n)}finally{if(t)throw t.error}}},r.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];if(this.callbacks===null)return this;var n=this.callbacks.get(e);return!n||n.length===0?this:(n=n.slice(0),n.forEach(function(o){var s=o.fn,a=o.scope;return s.apply(a,t)}),this)},r.prototype.hasListeners=function(e){return this.callbacks===null?!1:this.callbacks.has(e)},r.prototype.eventNames=function(){return this.callbacks===null?[]:Mu([],rs(this.callbacks.keys()),!1)},r})();$t.Emitter=Bu});var ns=v(Pt=>{"use strict";h();var ku=Pt&&Pt.__extends||(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),si=Pt&&Pt.__assign||function(){return si=Object.assign||function(r){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r},si.apply(this,arguments)},xu=Pt&&Pt.__values||function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},ju=Pt&&Pt.__read||function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,o=[],s;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(a){s={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return o};Object.defineProperty(Pt,"__esModule",{value:!0});Pt.TimeoutRegistry=void 0;var is=Q(),Vu=xt(),Fu=(function(r){ku(e,r);function e(t,i){var n=r.call(this)||this;return n.services=t,n.options=i,n.register=new Map,n}return e.prototype.add=function(t){if(t.duration===void 0&&(t.duration=this.options.subscriptionTimeout),t.event===void 0&&(t.event=is.EVENT.ACK_TIMEOUT),!this.services.connection.isConnected)return null;this.remove(t.message);var i={timerId:-1,uniqueName:this.getUniqueName(t.message),timeout:t};return i.timerId=this.services.timerRegistry.add({context:this,callback:this.onTimeout,duration:t.duration,data:i}),this.register.set(i.uniqueName,i),i.uniqueName},e.prototype.remove=function(t){var i,n=is.RESPONSE_TO_REQUEST[t.topic][t.action];n?i=si(si({},t),{action:n}):i=t;var o=this.getUniqueName(i);this.clear(o)},e.prototype.clear=function(t){var i=this.register.get(t);i&&(this.register.delete(t),this.services.timerRegistry.remove(i.timerId))},e.prototype.onTimeout=function(t){this.register.delete(t.uniqueName);var i=t.timeout;i.callback?i.callback(i.event,i.message):this.services.logger.warn(i.message,i.event)},e.prototype.getUniqueName=function(t){var i=t.originalAction||t.action,n="".concat(t.topic).concat(i,"_");return t.correlationId?n+=t.correlationId:t.name&&(n+=t.name),n},e.prototype.onConnectionLost=function(){var t,i;try{for(var n=xu(this.register),o=n.next();!o.done;o=n.next()){var s=ju(o.value,2),a=s[0],c=s[1];this.services.timerRegistry.remove(c.timerId),this.register.delete(a)}}catch(l){t={error:l}}finally{try{o&&!o.done&&(i=n.return)&&i.call(n)}finally{if(t)throw t.error}}},e})(Vu.Emitter);Pt.TimeoutRegistry=Fu});var os=v(se=>{"use strict";h();var Hu=se&&se.__values||function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Gu=se&&se.__read||function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,o=[],s;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(a){s={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return o};Object.defineProperty(se,"__esModule",{value:!0});se.IntervalTimerRegistry=void 0;var qu=(function(){function r(e){this.timerResolution=e,this.registry=new Map,this.timerIdCounter=0,this.timerId=setTimeout(this.triggerTimeouts.bind(this),this.timerResolution)}return r.prototype.close=function(){clearInterval(this.timerId)},r.prototype.triggerTimeouts=function(){var e,t,i=Date.now();try{for(var n=Hu(this.registry),o=n.next();!o.done;o=n.next()){var s=Gu(o.value,2),a=s[0],c=s[1];i-c.created>c.duration&&(c.callback.call(c.context,c.data),this.registry.delete(a))}}catch(l){e={error:l}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.timerId=setTimeout(this.triggerTimeouts.bind(this),this.timerResolution)},r.prototype.has=function(e){return this.registry.has(e)},r.prototype.add=function(e){return this.timerIdCounter++,e.created=Date.now(),this.registry.set(this.timerIdCounter,e),this.timerIdCounter},r.prototype.remove=function(e){return this.registry.delete(e)},r.prototype.requestIdleCallback=function(e){setTimeout(e,0)},r})();se.IntervalTimerRegistry=qu});var ss=v(ai=>{"use strict";h();Object.defineProperty(ai,"__esModule",{value:!0});ai.NativeTimerRegistry=void 0;var Wu=(function(){function r(){this.registry=new Set}return r.prototype.close=function(){this.registry.forEach(clearTimeout),this.registry.clear()},r.prototype.has=function(e){return this.registry.has(e)},r.prototype.add=function(e){var t=this,i=setTimeout(function(){t.remove(i),e.callback.call(e.context,e.data)},e.duration);return this.registry.add(i),i},r.prototype.remove=function(e){return clearTimeout(e),this.registry.delete(e)},r.prototype.requestIdleCallback=function(e){setTimeout(e,0)},r})();ai.NativeTimerRegistry=Wu});var cs=v((Od,as)=>{"use strict";h();as.exports=Yu;function Yu(r,e){for(var t=new Array(arguments.length-1),i=0,n=2,o=!0;n<arguments.length;)t[i++]=arguments[n++];return new Promise(function(a,c){t[i]=function(f){if(o)if(o=!1,f)c(f);else{for(var p=new Array(arguments.length-1),b=0;b<p.length;)p[b++]=arguments[b];a.apply(null,p)}};try{r.apply(e||null,t)}catch(l){o&&(o=!1,c(l))}})}});var hs=v(ls=>{"use strict";h();var ci=ls;ci.length=function(e){var t=e.length;if(!t)return 0;for(;t>0&&e.charAt(t-1)==="=";)--t;return Math.floor(t*3/4)};var tr=new Array(64),ui=new Array(123);for(jt=0;jt<64;)ui[tr[jt]=jt<26?jt+65:jt<52?jt+71:jt<62?jt-4:jt-59|43]=jt++;var jt;ui[45]=62;ui[95]=63;ci.encode=function(e,t,i){for(var n=null,o=[],s=0,a=0,c;t<i;){var l=e[t++];switch(a){case 0:o[s++]=tr[l>>2],c=(l&3)<<4,a=1;break;case 1:o[s++]=tr[c|l>>4],c=(l&15)<<2,a=2;break;case 2:o[s++]=tr[c|l>>6],o[s++]=tr[l&63],a=0;break}s>8191&&((n||(n=[])).push(String.fromCharCode.apply(String,o)),s=0)}return a&&(o[s++]=tr[c],o[s++]=61,a===1&&(o[s++]=61)),n?(s&&n.push(String.fromCharCode.apply(String,o.slice(0,s))),n.join("")):String.fromCharCode.apply(String,o.slice(0,s))};var us="invalid encoding";ci.decode=function(e,t,i){for(var n=i,o=0,s,a=0;a<e.length;){var c=e.charCodeAt(a++);if(c===61&&o>1)break;if((c=ui[c])===void 0)throw Error(us);switch(o){case 0:s=c,o=1;break;case 1:t[i++]=s<<2|(c&48)>>4,s=c,o=2;break;case 2:t[i++]=(s&15)<<4|(c&60)>>2,s=c,o=3;break;case 3:t[i++]=(s&3)<<6|c,o=0;break}}if(o===1)throw Error(us);return i-n};var Ku=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,$u=/[-_]/,Ju=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2}(?:==)?|[A-Za-z0-9_-]{3}=?)?$/;ci.test=function(e){return Ku.test(e)||$u.test(e)&&Ju.test(e)}});var ds=v((bd,fs)=>{"use strict";h();fs.exports=li;function li(){this._listeners=Object.create(null)}li.prototype.on=function(e,t,i){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:i||this}),this};li.prototype.off=function(e,t){if(e===void 0)this._listeners=Object.create(null);else if(t===void 0)this._listeners[e]=[];else{var i=this._listeners[e];if(!i)return this;for(var n=0;n<i.length;)i[n].fn===t?i.splice(n,1):++n}return this};li.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var i=[],n=1;n<arguments.length;)i.push(arguments[n++]);for(n=0;n<t.length;)t[n].fn.apply(t[n++].ctx,i)}return this}});var gs=v((Cd,Ss)=>{"use strict";h();Ss.exports=ps(ps);function ps(r){return typeof Float32Array!="undefined"?(function(){var e=new Float32Array([-0]),t=new Uint8Array(e.buffer),i=t[3]===128;function n(c,l,f){e[0]=c,l[f]=t[0],l[f+1]=t[1],l[f+2]=t[2],l[f+3]=t[3]}function o(c,l,f){e[0]=c,l[f]=t[3],l[f+1]=t[2],l[f+2]=t[1],l[f+3]=t[0]}r.writeFloatLE=i?n:o,r.writeFloatBE=i?o:n;function s(c,l){return t[0]=c[l],t[1]=c[l+1],t[2]=c[l+2],t[3]=c[l+3],e[0]}function a(c,l){return t[3]=c[l],t[2]=c[l+1],t[1]=c[l+2],t[0]=c[l+3],e[0]}r.readFloatLE=i?s:a,r.readFloatBE=i?a:s})():(function(){function e(i,n,o,s){var a=n<0?1:0;if(a&&(n=-n),n===0)i(1/n>0?0:2147483648,o,s);else if(isNaN(n))i(2143289344,o,s);else if(n>34028234663852886e22)i((a<<31|2139095040)>>>0,o,s);else if(n<11754943508222875e-54)i((a<<31|Math.round(n/1401298464324817e-60))>>>0,o,s);else{var c=Math.floor(Math.log(n)/Math.LN2),l=Math.round(n*Math.pow(2,-c)*8388608)&8388607;i((a<<31|c+127<<23|l)>>>0,o,s)}}r.writeFloatLE=e.bind(null,Es),r.writeFloatBE=e.bind(null,ys);function t(i,n,o){var s=i(n,o),a=(s>>31)*2+1,c=s>>>23&255,l=s&8388607;return c===255?l?NaN:a*(1/0):c===0?a*1401298464324817e-60*l:a*Math.pow(2,c-150)*(l+8388608)}r.readFloatLE=t.bind(null,Rs),r.readFloatBE=t.bind(null,_s)})(),typeof Float64Array!="undefined"?(function(){var e=new Float64Array([-0]),t=new Uint8Array(e.buffer),i=t[7]===128;function n(c,l,f){e[0]=c,l[f]=t[0],l[f+1]=t[1],l[f+2]=t[2],l[f+3]=t[3],l[f+4]=t[4],l[f+5]=t[5],l[f+6]=t[6],l[f+7]=t[7]}function o(c,l,f){e[0]=c,l[f]=t[7],l[f+1]=t[6],l[f+2]=t[5],l[f+3]=t[4],l[f+4]=t[3],l[f+5]=t[2],l[f+6]=t[1],l[f+7]=t[0]}r.writeDoubleLE=i?n:o,r.writeDoubleBE=i?o:n;function s(c,l){return t[0]=c[l],t[1]=c[l+1],t[2]=c[l+2],t[3]=c[l+3],t[4]=c[l+4],t[5]=c[l+5],t[6]=c[l+6],t[7]=c[l+7],e[0]}function a(c,l){return t[7]=c[l],t[6]=c[l+1],t[5]=c[l+2],t[4]=c[l+3],t[3]=c[l+4],t[2]=c[l+5],t[1]=c[l+6],t[0]=c[l+7],e[0]}r.readDoubleLE=i?s:a,r.readDoubleBE=i?a:s})():(function(){function e(i,n,o,s,a,c){var l=s<0?1:0;if(l&&(s=-s),s===0)i(0,a,c+n),i(1/s>0?0:2147483648,a,c+o);else if(isNaN(s))i(0,a,c+n),i(2146959360,a,c+o);else if(s>17976931348623157e292)i(0,a,c+n),i((l<<31|2146435072)>>>0,a,c+o);else{var f;if(s<22250738585072014e-324)f=s/5e-324,i(f>>>0,a,c+n),i((l<<31|f/4294967296)>>>0,a,c+o);else{var p=Math.floor(Math.log(s)/Math.LN2);p===1024&&(p=1023),f=s*Math.pow(2,-p),i(f*4503599627370496>>>0,a,c+n),i((l<<31|p+1023<<20|f*1048576&1048575)>>>0,a,c+o)}}}r.writeDoubleLE=e.bind(null,Es,0,4),r.writeDoubleBE=e.bind(null,ys,4,0);function t(i,n,o,s,a){var c=i(s,a+n),l=i(s,a+o),f=(l>>31)*2+1,p=l>>>20&2047,b=4294967296*(l&1048575)+c;return p===2047?b?NaN:f*(1/0):p===0?f*5e-324*b:f*Math.pow(2,p-1075)*(b+4503599627370496)}r.readDoubleLE=t.bind(null,Rs,0,4),r.readDoubleBE=t.bind(null,_s,4,0)})(),r}function Es(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function ys(r,e,t){e[t]=r>>>24,e[t+1]=r>>>16&255,e[t+2]=r>>>8&255,e[t+3]=r&255}function Rs(r,e){return(r[e]|r[e+1]<<8|r[e+2]<<16|r[e+3]<<24)>>>0}function _s(r,e){return(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}});var Ts=v(vs=>{"use strict";h();var hi=vs,en="\uFFFD",rn;try{rn=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}catch(r){rn=new TextDecoder("utf-8",{ignoreBOM:!0})}hi.length=function(e){for(var t=0,i=0,n=0;n<e.length;++n)i=e.charCodeAt(n),i<128?t+=1:i<2048?t+=2:(i&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t};function Os(r,e,t,i){for(var n=e;n<t;){var o=r[n++];if(o<=127)i+=String.fromCharCode(o);else if(o>=192&&o<224){var s=(o&31)<<6|r[n++]&63;i+=s>=128?String.fromCharCode(s):en}else if(o>=224&&o<240){var a=(o&15)<<12|(r[n++]&63)<<6|r[n++]&63;i+=a>=2048?String.fromCharCode(a):en}else if(o>=240){var c=(o&7)<<18|(r[n++]&63)<<12|(r[n++]&63)<<6|r[n++]&63;c<65536||c>1114111?i+=en:(c-=65536,i+=String.fromCharCode(55296+(c>>10)),i+=String.fromCharCode(56320+(c&1023)))}}return i}hi.read=function(e,t,i){if(i-t<1)return"";for(var n="",o=t,s,a,c,l,f,p,b,I;o+7<i;o+=8){if(s=e[o],a=e[o+1],c=e[o+2],l=e[o+3],f=e[o+4],p=e[o+5],b=e[o+6],I=e[o+7],(s|a|c|l|f|p|b|I)&128)return Os(e,o,i,n);n+=String.fromCharCode(s,a,c,l,f,p,b,I)}for(;o<i;++o){if(s=e[o],s&128)return Os(e,o,i,n);n+=String.fromCharCode(s)}return n};function Ns(r,e,t){var i=e===0&&t===r.length?r:r.subarray?r.subarray(e,t):r.slice(e,t);return Array.isArray(i)&&(i=Uint8Array.from(i)),rn.decode(i)}hi.readStrict=function(e,t,i){if(i-t<1)return"";for(var n="",o=t,s,a,c,l,f,p,b,I;o+7<i;o+=8){if(s=e[o],a=e[o+1],c=e[o+2],l=e[o+3],f=e[o+4],p=e[o+5],b=e[o+6],I=e[o+7],(s|a|c|l|f|p|b|I)&128)return n+Ns(e,o,i);n+=String.fromCharCode(s,a,c,l,f,p,b,I)}for(;o<i;++o){if(s=e[o],s&128)return n+Ns(e,o,i);n+=String.fromCharCode(s)}return n};hi.write=function(e,t,i){for(var n=i,o,s,a=0;a<e.length;++a)o=e.charCodeAt(a),o<128?t[i++]=o:o<2048?(t[i++]=o>>6|192,t[i++]=o&63|128):(o&64512)===55296&&((s=e.charCodeAt(a+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++a,t[i++]=o>>18|240,t[i++]=o>>12&63|128,t[i++]=o>>6&63|128,t[i++]=o&63|128):(t[i++]=o>>12|224,t[i++]=o>>6&63|128,t[i++]=o&63|128);return i-n}});var Is=v((wd,bs)=>{"use strict";h();bs.exports=Qu;function Qu(r,e,t){var i=t||8192,n=i>>>1,o=null,s=i;return function(c){if(c<1||c>n)return r(c);s+c>i&&(o=r(i),s=0);var l=e.call(o,s,s+=c);return s&7&&(s=(s|7)+1),l}}});var ms=v((Ld,Cs)=>{"use strict";h();Cs.exports=at;var gr=ce();function at(r,e){this.lo=r>>>0,this.hi=e>>>0}var Le=at.zero=new at(0,0);Le.toNumber=function(){return 0};Le.zzEncode=Le.zzDecode=function(){return this};Le.length=function(){return 1};var zu=at.zeroHash="\0\0\0\0\0\0\0\0";at.fromNumber=function(e){if(e===0)return Le;var t=e<0;t&&(e=-e);var i=e>>>0,n=(e-i)/4294967296>>>0;return t&&(n=~n>>>0,i=~i>>>0,++i>4294967295&&(i=0,++n>4294967295&&(n=0))),new at(i,n)};at.from=function(e){if(typeof e=="number")return at.fromNumber(e);if(gr.isString(e))if(gr.Long)e=gr.Long.fromString(e);else return at.fromNumber(parseInt(e,10));return e.low||e.high?new at(e.low>>>0,e.high>>>0):Le};at.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=~this.lo+1>>>0,i=~this.hi>>>0;return t||(i=i+1>>>0),-(t+i*4294967296)}return this.lo+this.hi*4294967296};at.prototype.toLong=function(e){return gr.Long?new gr.Long(this.lo|0,this.hi|0,!!e):{low:this.lo|0,high:this.hi|0,unsigned:!!e}};var ae=String.prototype.charCodeAt;at.fromHash=function(e){return e===zu?Le:new at((ae.call(e,0)|ae.call(e,1)<<8|ae.call(e,2)<<16|ae.call(e,3)<<24)>>>0,(ae.call(e,4)|ae.call(e,5)<<8|ae.call(e,6)<<16|ae.call(e,7)<<24)>>>0)};at.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};at.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this};at.prototype.zzDecode=function(){var e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this};at.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,i=this.hi>>>24;return i===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:i<128?9:10}});var As=v((Or,nn)=>{h();(function(r,e){function t(i){return i.default||i}typeof define=="function"&&define.amd?define([],function(){var i={};return e(i),t(i)}):typeof Or=="object"?(e(Or),typeof nn=="object"&&(nn.exports=t(Or))):(function(){var i={};e(i),r.Long=t(i)})()})(typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:Or,function(r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var e=null;try{e=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(y){}function t(y,u,N){this.low=y|0,this.high=u|0,this.unsigned=!!N}t.prototype.__isLong__,Object.defineProperty(t.prototype,"__isLong__",{value:!0});function i(y){return(y&&y.__isLong__)===!0}function n(y){var u=Math.clz32(y&-y);return y?31-u:u}t.isLong=i;var o={},s={};function a(y,u){var N,k,J;return u?(y>>>=0,(J=0<=y&&y<256)&&(k=s[y],k)?k:(N=l(y,0,!0),J&&(s[y]=N),N)):(y|=0,(J=-128<=y&&y<128)&&(k=o[y],k)?k:(N=l(y,y<0?-1:0,!1),J&&(o[y]=N),N))}t.fromInt=a;function c(y,u){if(isNaN(y))return u?g:ht;if(u){if(y<0)return g;if(y>=pt)return G}else{if(y<=-Rt)return B;if(y+1>=Rt)return x}return y<0?c(-y,u).neg():l(y%P|0,y/P|0,u)}t.fromNumber=c;function l(y,u,N){return new t(y,u,N)}t.fromBits=l;var f=Math.pow;function p(y,u,N){if(y.length===0)throw Error("empty string");if(typeof u=="number"?(N=u,u=!1):u=!!u,y==="NaN"||y==="Infinity"||y==="+Infinity"||y==="-Infinity")return u?g:ht;if(N=N||10,N<2||36<N)throw RangeError("radix");var k;if((k=y.indexOf("-"))>0)throw Error("interior hyphen");if(k===0)return p(y.substring(1),u,N).neg();for(var J=c(f(N,8)),K=ht,it=0;it<y.length;it+=8){var Nt=Math.min(8,y.length-it),mt=parseInt(y.substring(it,it+Nt),N);if(Nt<8){var Et=c(f(N,Nt));K=K.mul(Et).add(c(mt))}else K=K.mul(J),K=K.add(c(mt))}return K.unsigned=u,K}t.fromString=p;function b(y,u){return typeof y=="number"?c(y,u):typeof y=="string"?p(y,u):l(y.low,y.high,typeof u=="boolean"?u:y.unsigned)}t.fromValue=b;var I=65536,j=1<<24,P=I*I,pt=P*P,Rt=pt/2,ee=a(j),ht=a(0);t.ZERO=ht;var g=a(0,!0);t.UZERO=g;var T=a(1);t.ONE=T;var A=a(1,!0);t.UONE=A;var D=a(-1);t.NEG_ONE=D;var x=l(-1,2147483647,!1);t.MAX_VALUE=x;var G=l(-1,-1,!0);t.MAX_UNSIGNED_VALUE=G;var B=l(0,-2147483648,!1);t.MIN_VALUE=B;var R=t.prototype;R.toInt=function(){return this.unsigned?this.low>>>0:this.low},R.toNumber=function(){return this.unsigned?(this.high>>>0)*P+(this.low>>>0):this.high*P+(this.low>>>0)},R.toString=function(u){if(u=u||10,u<2||36<u)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(B)){var N=c(u),k=this.div(N),J=k.mul(N).sub(this);return k.toString(u)+J.toInt().toString(u)}else return"-"+this.neg().toString(u);for(var K=c(f(u,6),this.unsigned),it=this,Nt="";;){var mt=it.div(K),Et=it.sub(mt.mul(K)).toInt()>>>0,tt=Et.toString(u);if(it=mt,it.isZero())return tt+Nt;for(;tt.length<6;)tt="0"+tt;Nt=""+tt+Nt}},R.getHighBits=function(){return this.high},R.getHighBitsUnsigned=function(){return this.high>>>0},R.getLowBits=function(){return this.low},R.getLowBitsUnsigned=function(){return this.low>>>0},R.getNumBitsAbs=function(){if(this.isNegative())return this.eq(B)?64:this.neg().getNumBitsAbs();for(var u=this.high!=0?this.high:this.low,N=31;N>0&&(u&1<<N)==0;N--);return this.high!=0?N+33:N+1},R.isSafeInteger=function(){var u=this.high>>21;return u?this.unsigned?!1:u===-1&&!(this.low===0&&this.high===-2097152):!0},R.isZero=function(){return this.high===0&&this.low===0},R.eqz=R.isZero,R.isNegative=function(){return!this.unsigned&&this.high<0},R.isPositive=function(){return this.unsigned||this.high>=0},R.isOdd=function(){return(this.low&1)===1},R.isEven=function(){return(this.low&1)===0},R.equals=function(u){return i(u)||(u=b(u)),this.unsigned!==u.unsigned&&this.high>>>31===1&&u.high>>>31===1?!1:this.high===u.high&&this.low===u.low},R.eq=R.equals,R.notEquals=function(u){return!this.eq(u)},R.neq=R.notEquals,R.ne=R.notEquals,R.lessThan=function(u){return this.comp(u)<0},R.lt=R.lessThan,R.lessThanOrEqual=function(u){return this.comp(u)<=0},R.lte=R.lessThanOrEqual,R.le=R.lessThanOrEqual,R.greaterThan=function(u){return this.comp(u)>0},R.gt=R.greaterThan,R.greaterThanOrEqual=function(u){return this.comp(u)>=0},R.gte=R.greaterThanOrEqual,R.ge=R.greaterThanOrEqual,R.compare=function(u){if(i(u)||(u=b(u)),this.eq(u))return 0;var N=this.isNegative(),k=u.isNegative();return N&&!k?-1:!N&&k?1:this.unsigned?u.high>>>0>this.high>>>0||u.high===this.high&&u.low>>>0>this.low>>>0?-1:1:this.sub(u).isNegative()?-1:1},R.comp=R.compare,R.negate=function(){return!this.unsigned&&this.eq(B)?B:this.not().add(T)},R.neg=R.negate,R.add=function(u){i(u)||(u=b(u));var N=this.high>>>16,k=this.high&65535,J=this.low>>>16,K=this.low&65535,it=u.high>>>16,Nt=u.high&65535,mt=u.low>>>16,Et=u.low&65535,tt=0,At=0,nt=0,Ct=0;return Ct+=K+Et,nt+=Ct>>>16,Ct&=65535,nt+=J+mt,At+=nt>>>16,nt&=65535,At+=k+Nt,tt+=At>>>16,At&=65535,tt+=N+it,tt&=65535,l(nt<<16|Ct,tt<<16|At,this.unsigned)},R.subtract=function(u){return i(u)||(u=b(u)),this.add(u.neg())},R.sub=R.subtract,R.multiply=function(u){if(this.isZero())return this;if(i(u)||(u=b(u)),e){var N=e.mul(this.low,this.high,u.low,u.high);return l(N,e.get_high(),this.unsigned)}if(u.isZero())return this.unsigned?g:ht;if(this.eq(B))return u.isOdd()?B:ht;if(u.eq(B))return this.isOdd()?B:ht;if(this.isNegative())return u.isNegative()?this.neg().mul(u.neg()):this.neg().mul(u).neg();if(u.isNegative())return this.mul(u.neg()).neg();if(this.lt(ee)&&u.lt(ee))return c(this.toNumber()*u.toNumber(),this.unsigned);var k=this.high>>>16,J=this.high&65535,K=this.low>>>16,it=this.low&65535,Nt=u.high>>>16,mt=u.high&65535,Et=u.low>>>16,tt=u.low&65535,At=0,nt=0,Ct=0,xr=0;return xr+=it*tt,Ct+=xr>>>16,xr&=65535,Ct+=K*tt,nt+=Ct>>>16,Ct&=65535,Ct+=it*Et,nt+=Ct>>>16,Ct&=65535,nt+=J*tt,At+=nt>>>16,nt&=65535,nt+=K*Et,At+=nt>>>16,nt&=65535,nt+=it*mt,At+=nt>>>16,nt&=65535,At+=k*tt+J*Et+K*mt+it*Nt,At&=65535,l(Ct<<16|xr,At<<16|nt,this.unsigned)},R.mul=R.multiply,R.divide=function(u){if(i(u)||(u=b(u)),u.isZero())throw Error("division by zero");if(e){if(!this.unsigned&&this.high===-2147483648&&u.low===-1&&u.high===-1)return this;var N=(this.unsigned?e.div_u:e.div_s)(this.low,this.high,u.low,u.high);return l(N,e.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?g:ht;var k,J,K;if(this.unsigned){if(u.unsigned||(u=u.toUnsigned()),u.gt(this))return g;if(u.gt(this.shru(1)))return A;K=g}else{if(this.eq(B)){if(u.eq(T)||u.eq(D))return B;if(u.eq(B))return T;var it=this.shr(1);return k=it.div(u).shl(1),k.eq(ht)?u.isNegative()?T:D:(J=this.sub(u.mul(k)),K=k.add(J.div(u)),K)}else if(u.eq(B))return this.unsigned?g:ht;if(this.isNegative())return u.isNegative()?this.neg().div(u.neg()):this.neg().div(u).neg();if(u.isNegative())return this.div(u.neg()).neg();K=ht}for(J=this;J.gte(u);){k=Math.max(1,Math.floor(J.toNumber()/u.toNumber()));for(var Nt=Math.ceil(Math.log(k)/Math.LN2),mt=Nt<=48?1:f(2,Nt-48),Et=c(k),tt=Et.mul(u);tt.isNegative()||tt.gt(J);)k-=mt,Et=c(k,this.unsigned),tt=Et.mul(u);Et.isZero()&&(Et=T),K=K.add(Et),J=J.sub(tt)}return K},R.div=R.divide,R.modulo=function(u){if(i(u)||(u=b(u)),e){var N=(this.unsigned?e.rem_u:e.rem_s)(this.low,this.high,u.low,u.high);return l(N,e.get_high(),this.unsigned)}return this.sub(this.div(u).mul(u))},R.mod=R.modulo,R.rem=R.modulo,R.not=function(){return l(~this.low,~this.high,this.unsigned)},R.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},R.clz=R.countLeadingZeros,R.countTrailingZeros=function(){return this.low?n(this.low):n(this.high)+32},R.ctz=R.countTrailingZeros,R.and=function(u){return i(u)||(u=b(u)),l(this.low&u.low,this.high&u.high,this.unsigned)},R.or=function(u){return i(u)||(u=b(u)),l(this.low|u.low,this.high|u.high,this.unsigned)},R.xor=function(u){return i(u)||(u=b(u)),l(this.low^u.low,this.high^u.high,this.unsigned)},R.shiftLeft=function(u){return i(u)&&(u=u.toInt()),(u&=63)===0?this:u<32?l(this.low<<u,this.high<<u|this.low>>>32-u,this.unsigned):l(0,this.low<<u-32,this.unsigned)},R.shl=R.shiftLeft,R.shiftRight=function(u){return i(u)&&(u=u.toInt()),(u&=63)===0?this:u<32?l(this.low>>>u|this.high<<32-u,this.high>>u,this.unsigned):l(this.high>>u-32,this.high>=0?0:-1,this.unsigned)},R.shr=R.shiftRight,R.shiftRightUnsigned=function(u){return i(u)&&(u=u.toInt()),(u&=63)===0?this:u<32?l(this.low>>>u|this.high<<32-u,this.high>>>u,this.unsigned):u===32?l(this.high,0,this.unsigned):l(this.high>>>u-32,0,this.unsigned)},R.shru=R.shiftRightUnsigned,R.shr_u=R.shiftRightUnsigned,R.rotateLeft=function(u){var N;return i(u)&&(u=u.toInt()),(u&=63)===0?this:u===32?l(this.high,this.low,this.unsigned):u<32?(N=32-u,l(this.low<<u|this.high>>>N,this.high<<u|this.low>>>N,this.unsigned)):(u-=32,N=32-u,l(this.high<<u|this.low>>>N,this.low<<u|this.high>>>N,this.unsigned))},R.rotl=R.rotateLeft,R.rotateRight=function(u){var N;return i(u)&&(u=u.toInt()),(u&=63)===0?this:u===32?l(this.high,this.low,this.unsigned):u<32?(N=32-u,l(this.high<<N|this.low>>>u,this.low<<N|this.high>>>u,this.unsigned)):(u-=32,N=32-u,l(this.low<<N|this.high>>>u,this.high<<N|this.low>>>u,this.unsigned))},R.rotr=R.rotateRight,R.toSigned=function(){return this.unsigned?l(this.low,this.high,!1):this},R.toUnsigned=function(){return this.unsigned?this:l(this.low,this.high,!0)},R.toBytes=function(u){return u?this.toBytesLE():this.toBytesBE()},R.toBytesLE=function(){var u=this.high,N=this.low;return[N&255,N>>>8&255,N>>>16&255,N>>>24,u&255,u>>>8&255,u>>>16&255,u>>>24]},R.toBytesBE=function(){var u=this.high,N=this.low;return[u>>>24,u>>>16&255,u>>>8&255,u&255,N>>>24,N>>>16&255,N>>>8&255,N&255]},t.fromBytes=function(u,N,k){return k?t.fromBytesLE(u,N):t.fromBytesBE(u,N)},t.fromBytesLE=function(u,N){return new t(u[0]|u[1]<<8|u[2]<<16|u[3]<<24,u[4]|u[5]<<8|u[6]<<16|u[7]<<24,N)},t.fromBytesBE=function(u,N){return new t(u[4]<<24|u[5]<<16|u[6]<<8|u[7],u[0]<<24|u[1]<<16|u[2]<<8|u[3],N)},typeof BigInt=="function"&&(t.fromBigInt=function(u,N){var k=Number(BigInt.asIntN(32,u)),J=Number(BigInt.asIntN(32,u>>BigInt(32)));return l(k,J,N)},t.fromValue=function(u,N){return typeof u=="bigint"?t.fromBigInt(u,N):b(u,N)},R.toBigInt=function(){var u=BigInt(this.low>>>0),N=BigInt(this.unsigned?this.high>>>0:this.high);return N<<BigInt(32)|u});var Ge=r.default=t})});var ce=v(on=>{"use strict";h();var C=on;C.asPromise=cs();C.base64=hs();C.EventEmitter=ds();C.float=gs();C.utf8=Ts();C.pool=Is();C.LongBits=ms();function Ds(r){return r==="__proto__"||r==="prototype"||r==="constructor"}C.isUnsafeProperty=Ds;C.isNode=!!(typeof window!="undefined"&&window&&window.process&&window.process.versions&&window.process.versions.node);C.global=C.isNode&&window||typeof window!="undefined"&&window||typeof self!="undefined"&&self||on;C.emptyArray=Object.freeze?Object.freeze([]):[];C.emptyObject=Object.freeze?Object.freeze({}):{};C.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};C.isString=function(e){return typeof e=="string"||e instanceof String};C.isObject=function(e){return e&&typeof e=="object"};C.isset=C.isSet=function(e,t){var i=e[t];return i!=null&&Object.hasOwnProperty.call(e,t)?typeof i!="object"||(Array.isArray(i)?i.length:Object.keys(i).length)>0:!1};C.Buffer=(function(){try{var r=C.global.Buffer;return r.prototype.utf8Write?r:null}catch(e){return null}})();C._Buffer_from=null;C._Buffer_allocUnsafe=null;C.newBuffer=function(e){return typeof e=="number"?C.Buffer?C._Buffer_allocUnsafe(e):new C.Array(e):C.Buffer?C._Buffer_from(e):typeof Uint8Array=="undefined"?e:new Uint8Array(e)};C.Array=typeof Uint8Array!="undefined"?Uint8Array:Array;C.Long=C.global.dcodeIO&&C.global.dcodeIO.Long||C.global.Long||(function(){try{var r=As();return r&&r.isLong?r:null}catch(e){return null}})();C.key2Re=/^(?:true|false|0|1)$/;C.key32Re=/^-?(?:0|[1-9][0-9]*)$/;C.key64Re=/^(?:[\x00-\xff]{8}|-?(?:0|[1-9][0-9]*))$/;C.longToHash=function(e){return e?C.LongBits.from(e).toHash():C.LongBits.zeroHash};C.longFromHash=function(e,t){var i=C.LongBits.fromHash(e);return C.Long?C.Long.fromBits(i.lo,i.hi,t):i.toNumber(!!t)};C.longFromKey=function(e,t){return C.key64Re.test(e)&&!C.key32Re.test(e)?C.longFromHash(e,t):e};C.boolFromKey=function(e){return e==="true"||e==="1"};function ws(r){var e=typeof arguments[arguments.length-1]=="boolean",t=e?arguments.length-1:arguments.length;e=e&&arguments[arguments.length-1];for(var i=1;i<t;++i){var n=arguments[i];if(n)for(var o=Object.keys(n),s=0;s<o.length;++s)!Ds(o[s])&&(r[o[s]]===void 0||!e)&&(r[o[s]]=n[o[s]])}return r}C.merge=ws;C.nestingLimit=32;C.recursionLimit=100;C.makeProp=function(e,t,i){Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:i===void 0?!0:i,configurable:!0,writable:!0})};C.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)};function Ps(r){function e(t,i){if(!(this instanceof e))return new e(t,i);Object.defineProperty(this,"message",{get:function(){return t}}),Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:new Error().stack||""}),i&&ws(this,i)}return e.prototype=Object.create(Error.prototype,{constructor:{value:e,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return r},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),e}C.newError=Ps;C.ProtocolError=Ps("ProtocolError");C.oneOfGetter=function(e){for(var t={},i=0;i<e.length;++i)t[e[i]]=1;return function(){for(var n=Object.keys(this),o=n.length-1;o>-1;--o)if(t[n[o]]===1&&this[n[o]]!==void 0&&this[n[o]]!==null)return n[o]}};C.oneOfSetter=function(e){return function(t){for(var i=0;i<e.length;++i)e[i]!==t&&delete this[e[i]]}};C.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};C._configure=function(){var r=C.Buffer;if(!r){C._Buffer_from=C._Buffer_allocUnsafe=null;return}C._Buffer_from=r.from!==Uint8Array.from&&r.from||function(t,i){return new r(t,i)},C._Buffer_allocUnsafe=r.allocUnsafe||function(t){return new r(t)}}});var fn=v((xd,ks)=>{"use strict";h();ks.exports=M;var Lt=ce(),sn,fi=Lt.LongBits,Ls=Lt.base64,Us=Lt.utf8;function Nr(r,e,t){this.fn=r,this.len=e,this.next=void 0,this.val=t}function cn(){}function Xu(r){this.head=r.head,this.tail=r.tail,this.len=r.len,this.next=r.states}function M(){this.len=0,this.head=new Nr(cn,0,0),this.tail=this.head,this.states=null}var Ms=function(){return Lt.Buffer?function(){return(M.create=function(){return new sn})()}:function(){return new M}};M.create=Ms();M.alloc=function(e){return new Lt.Array(e)};Lt.Array!==Array&&(M.alloc=Lt.pool(M.alloc,Lt.Array.prototype.subarray));M.prototype._push=function(e,t,i){return this.tail=this.tail.next=new Nr(e,t,i),this.len+=t,this};function un(r,e,t){e[t]=r&255}function Zu(r,e,t){for(var i=0;i<r.length;)e[t++]=r.charCodeAt(i++)}function tl(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}function ln(r,e){this.len=r,this.next=void 0,this.val=e}ln.prototype=Object.create(Nr.prototype);ln.prototype.fn=tl;M.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new ln((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this};M.prototype.int32=function(e){return(e|=0)<0?this._push(hn,10,fi.fromNumber(e)):this.uint32(e)};M.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)};function hn(r,e,t){for(var i=r.lo,n=r.hi;n;)e[t++]=i&127|128,i=(i>>>7|n<<25)>>>0,n>>>=7;for(;i>127;)e[t++]=i&127|128,i=i>>>7;e[t++]=i}M.prototype.uint64=function(e){var t=fi.from(e);return this._push(hn,t.length(),t)};M.prototype.int64=M.prototype.uint64;M.prototype.sint64=function(e){var t=fi.from(e).zzEncode();return this._push(hn,t.length(),t)};M.prototype.bool=function(e){return this._push(un,1,e?1:0)};function an(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}M.prototype.fixed32=function(e){return this._push(an,4,e>>>0)};M.prototype.sfixed32=M.prototype.fixed32;M.prototype.fixed64=function(e){var t=fi.from(e);return this._push(an,4,t.lo)._push(an,4,t.hi)};M.prototype.sfixed64=M.prototype.fixed64;M.prototype.float=function(e){return this._push(Lt.float.writeFloatLE,4,e)};M.prototype.double=function(e){return this._push(Lt.float.writeDoubleLE,8,e)};var Bs=Lt.Array.prototype.set?function(e,t,i){t.set(e,i)}:function(e,t,i){for(var n=0;n<e.length;++n)t[i+n]=e[n]};M.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(un,1,0);if(Lt.isString(e)){var i=M.alloc(t=Ls.length(e));Ls.decode(e,i,0),e=i}return this.uint32(t)._push(Bs,t,e)};M.prototype.raw=function(e){var t=e.length>>>0;return t?this._push(Bs,t,e):this};M.prototype.string=function(e){var t=Us.length(e);return t?this.uint32(t)._push(t===e.length?Zu:Us.write,t,e):this._push(un,1,0)};M.prototype.fork=function(){return this.states=new Xu(this),this.head=this.tail=new Nr(cn,0,0),this.len=0,this};M.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Nr(cn,0,0),this.len=0),this};M.prototype.ldelim=function(){var e=this.head,t=this.tail,i=this.len;return this.reset().uint32(i),i&&(this.tail.next=e.next,this.tail=t,this.len+=i),this};M.prototype.finish=function(){return this.finishInto(this.constructor.alloc(this.len),0)};M.prototype.finishInto=function(e,t){t===void 0&&(t=0);for(var i=this.head.next,n=t;i;)i.fn(i.val,e,n),n+=i.len,i=i.next;return e};M._configure=function(r){sn=r,M.create=Ms(),sn._configure()}});var Vs=v((Vd,js)=>{"use strict";h();js.exports=Ut;var xs=fn();(Ut.prototype=Object.create(xs.prototype)).constructor=Ut;var ue=ce();function Ut(){xs.call(this)}Ut._configure=function(){Ut.alloc=ue._Buffer_allocUnsafe,Ut.writeBytesBuffer=ue.Buffer&&ue.Buffer.prototype instanceof Uint8Array&&ue.Buffer.prototype.set.name==="set"?function(e,t,i){t.set(e,i)}:function(e,t,i){if(e.copy)e.copy(t,i,0,e.length);else for(var n=0;n<e.length;)t[i++]=e[n++]}};Ut.prototype.bytes=function(e){ue.isString(e)&&(e=ue._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(Ut.writeBytesBuffer,t,e),this};Ut.prototype.raw=function(e){var t=e.length>>>0;return t?this._push(Ut.writeBytesBuffer,t,e):this};function el(r,e,t){for(var i=0;i<r.length;)e[t++]=r.charCodeAt(i++)}function rl(r,e,t){r.length<40?ue.utf8.write(r,e,t):e.utf8Write?e.utf8Write(r,t):e.write(r,t)}Ut.prototype.string=function(e){var t=ue.Buffer.byteLength(e);return this.uint32(t),t&&this._push(t===e.length&&t<40?el:rl,t,e),this};Ut._configure()});var En=v((Hd,Ys)=>{"use strict";h();Ys.exports=H;var Vt=ce(),pn,Gs=Vt.LongBits,qs=Vt.utf8;function St(r,e){return RangeError("index out of range: "+r.pos+" + "+(e||1)+" > "+r.len)}function H(r){this.buf=r,this.pos=0,this.len=r.length,this.discardUnknown=H.discardUnknown}var Fs=typeof Uint8Array!="undefined"?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new H(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new H(e);throw Error("illegal buffer")},Ws=function(){return Vt.Buffer?function(t){return(H.create=function(n){return Vt.Buffer.isBuffer(n)?new pn(n):Fs(n)})(t)}:Fs};H.create=Ws();H.prototype._slice=Vt.Array.prototype.subarray||Vt.Array.prototype.slice;H.prototype.raw=function(e,t){return Array.isArray(this.buf)?this.buf.slice(e,t):e===t?new this.buf.constructor(0):this._slice.call(this.buf,e,t)};H.prototype.uint32=function(){var e=this.buf,t=this.pos,i=(e[t]&127)>>>0;if(e[t++]<128)return this.pos=t,i;if(i=(i|(e[t]&127)<<7)>>>0,e[t++]<128)return this.pos=t,i;if(i=(i|(e[t]&127)<<14)>>>0,e[t++]<128)return this.pos=t,i;if(i=(i|(e[t]&127)<<21)>>>0,e[t++]<128)return this.pos=t,i;if(i=(i|(e[t]&15)<<28)>>>0,e[t++]<128)return this.pos=t,i;for(var n=0;n<5;++n){if(t>=this.len)throw this.pos=t,St(this);if(e[t++]<128)return this.pos=t,i}throw this.pos=t,Error("invalid varint encoding")};H.prototype.tag=function(){var e=this.buf,t=this.pos,i=(e[t]&127)>>>0;if(e[t++]<128)return this.pos=t,i;if(i=(i|(e[t]&127)<<7)>>>0,e[t++]<128)return this.pos=t,i;if(i=(i|(e[t]&127)<<14)>>>0,e[t++]<128)return this.pos=t,i;if(i=(i|(e[t]&127)<<21)>>>0,e[t++]<128)return this.pos=t,i;if(i=(i|(e[t]&15)<<28)>>>0,e[t]<128&&(e[t]&112)===0)return this.pos=t+1,i;throw this.pos=t+1,Error("invalid tag encoding")};H.prototype.int32=function(){return this.uint32()|0};H.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(e&1)|0};function dn(){var r=new Gs(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(r.lo=(r.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return r;if(r.lo=(r.lo|(this.buf[this.pos]&127)<<28)>>>0,r.hi=(r.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return r;e=0}else{for(;e<4;++e){if(this.pos>=this.len)throw St(this);if(r.lo=(r.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return r}throw St(this)}if(this.len-this.pos>4){for(;e<5;++e)if(r.hi=(r.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return r}else for(;e<5;++e){if(this.pos>=this.len)throw St(this);if(r.hi=(r.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return r}throw Error("invalid varint encoding")}H.prototype.bool=function(){for(var e=!1,t,i=0;i<10;++i){if(this.pos>=this.len)throw St(this);if(t=this.buf[this.pos++],t&127&&(e=!0),t<128)return e}throw Error("invalid varint encoding")};function di(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}H.prototype.fixed32=function(){if(this.pos+4>this.len)throw St(this,4);return di(this.buf,this.pos+=4)};H.prototype.sfixed32=function(){if(this.pos+4>this.len)throw St(this,4);return di(this.buf,this.pos+=4)|0};function Hs(){if(this.pos+8>this.len)throw St(this,8);return new Gs(di(this.buf,this.pos+=4),di(this.buf,this.pos+=4))}H.prototype.float=function(){if(this.pos+4>this.len)throw St(this,4);var e=Vt.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e};H.prototype.double=function(){if(this.pos+8>this.len)throw St(this,4);var e=Vt.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e};H.prototype.bytes=function(){var e=this.uint32(),t=this.pos,i=this.pos+e;if(i>this.len)throw St(this,e);return this.pos=i,this.raw(t,i)};H.prototype.string=function(){var e=this.uint32(),t=this.pos,i=this.pos+e;if(i>this.len)throw St(this,e);return this.pos=i,qs.read(this.buf,t,i)};H.prototype.stringVerify=function(){var e=this.uint32(),t=this.pos,i=this.pos+e;if(i>this.len)throw St(this,e);return this.pos=i,qs.readStrict(this.buf,t,i)};H.prototype.skip=function(e){if(typeof e=="number"){if(this.pos+e>this.len)throw St(this,e);this.pos+=e}else do if(this.pos>=this.len)throw St(this);while(this.buf[this.pos++]&128);return this};H.recursionLimit=Vt.recursionLimit;H.discardUnknown=!0;H.prototype.skipType=function(r,e,t){if(e===void 0&&(e=0),e>H.recursionLimit)throw Error("max depth exceeded");if(t===0)throw Error("illegal tag: field number 0");switch(r){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;;){var i=this.tag(),n=i>>>3;if(r=i&7,!n)throw Error("illegal tag: field number 0");if(r===4){if(t!==void 0&&n!==t)throw Error("invalid end group tag");break}this.skipType(r,e+1,n)}break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+r+" at offset "+this.pos)}return this};H._configure=function(r){pn=r,H.create=Ws(),pn._configure();var e=Vt.Long?"toLong":"toNumber";Vt.merge(H.prototype,{int64:function(){return dn.call(this)[e](!1)},uint64:function(){return dn.call(this)[e](!0)},sint64:function(){return dn.call(this).zzDecode()[e](!1)},fixed64:function(){return Hs.call(this)[e](!0)},sfixed64:function(){return Hs.call(this)[e](!1)}})}});var Js=v((qd,$s)=>{"use strict";h();$s.exports=le;var Ks=En();(le.prototype=Object.create(Ks.prototype)).constructor=le;var yn=ce();function le(r){Ks.call(this,r)}le._configure=function(){yn.Buffer&&(le.prototype._slice=yn.Buffer.prototype.slice)};le.prototype.raw=function(e,t){return e===t?yn.Buffer.alloc(0):this._slice.call(this.buf,e,t)};le.prototype.string=function(){var e=this.uint32(),t=this.pos,i=this.pos+e;if(i>this.len)throw RangeError("index out of range: "+this.pos+" + "+e+" > "+this.len);return this.pos=i,this.buf.utf8Slice?this.buf.utf8Slice(t,i):this.buf.toString("utf-8",t,i)};le._configure()});var zs=v((Yd,Qs)=>{"use strict";h();Qs.exports=vr;var Rn=ce();(vr.prototype=Object.create(Rn.EventEmitter.prototype)).constructor=vr;function vr(r,e,t){if(typeof r!="function")throw TypeError("rpcImpl must be a function");Rn.EventEmitter.call(this),this.rpcImpl=r,this.requestDelimited=!!e,this.responseDelimited=!!t}vr.prototype.rpcCall=function r(e,t,i,n,o){if(!n)throw TypeError("request must be specified");var s=this;if(!o)return Rn.asPromise(r,s,e,t,i,n);if(!s.rpcImpl){setTimeout(function(){o(Error("already ended"))},0);return}try{return s.rpcImpl(e,t[s.requestDelimited?"encodeDelimited":"encode"](n).finish(),function(c,l){if(c)return s.emit("error",c,e),o(c);if(l===null){s.end(!0);return}if(!(l instanceof i))try{l=i[s.responseDelimited?"decodeDelimited":"decode"](l)}catch(f){return s.emit("error",f,e),o(f)}return s.emit("data",l,e),o(null,l)})}catch(a){s.emit("error",a,e),setTimeout(function(){o(a)},0);return}};vr.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}});var Zs=v(Xs=>{"use strict";h();var il=Xs;il.Service=zs()});var ea=v((Qd,ta)=>{"use strict";h();ta.exports=Object.create(null)});var ia=v(gt=>{"use strict";h();gt.build="minimal";gt.Writer=fn();gt.BufferWriter=Vs();gt.Reader=En();gt.BufferReader=Js();gt.util=ce();gt.rpc=Zs();gt.roots=ea();gt.configure=ra;function ra(){gt.util._configure(),gt.Writer._configure(gt.BufferWriter),gt.Reader._configure(gt.BufferReader)}ra()});var oa=v((tp,na)=>{"use strict";h();na.exports=ia()});var pi=v((rp,sa)=>{"use strict";h();var Tr=oa(),m=Tr.Reader,Mt=Tr.Writer,ie=Tr.util,L=Tr.roots.default||(Tr.roots.default={});L.AUTH_ACTION=(function(){var r={},e=Object.create(r);return e[r[0]="AUTH_UNKNOWN"]=0,e[r[1]="AUTH_ERROR"]=1,e[r[2]="AUTH_REQUEST"]=2,e[r[3]="AUTH_AUTH_SUCCESSFUL"]=3,e[r[4]="AUTH_AUTH_UNSUCCESSFUL"]=4,e[r[100]="AUTH_TOO_MANY_AUTH_ATTEMPTS"]=100,e[r[101]="AUTH_INVALID_MESSAGE"]=101,e[r[102]="AUTH_INVALID_MESSAGE_DATA"]=102,e})();L.AuthMessage=(function(){function r(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)e[t[i]]!=null&&t[i]!=="__proto__"&&(this[t[i]]=e[t[i]])}return r.prototype.action=0,r.prototype.data="",r.prototype.isError=!1,r.prototype.isAck=!1,r.encode=function(t,i){return i||(i=Mt.create()),t.action!=null&&Object.hasOwnProperty.call(t,"action")&&i.uint32(8).int32(t.action),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&i.uint32(18).string(t.data),t.isError!=null&&Object.hasOwnProperty.call(t,"isError")&&i.uint32(24).bool(t.isError),t.isAck!=null&&Object.hasOwnProperty.call(t,"isAck")&&i.uint32(32).bool(t.isAck),i},r.encodeDelimited=function(t,i){return this.encode(t,i).ldelim()},r.decode=function(t,i,n,o){if(t instanceof m||(t=m.create(t)),o===void 0&&(o=0),o>m.recursionLimit)throw Error("maximum nesting depth exceeded");for(var s=i===void 0?t.len:t.pos+i,a=new L.AuthMessage;t.pos<s;){var c=t.uint32();if(c===n)break;switch(c>>>3){case 1:{a.action=t.int32();break}case 2:{a.data=t.string();break}case 3:{a.isError=t.bool();break}case 4:{a.isAck=t.bool();break}default:t.skipType(c&7,o);break}}return a},r.decodeDelimited=function(t){return t instanceof m||(t=new m(t)),this.decode(t,t.uint32())},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/AuthMessage"},r})();L.CLUSTER_ACTION=(function(){var r={},e=Object.create(r);return e[r[0]="CLUSTER_UNKNOWN"]=0,e[r[1]="CLUSTER_REMOVE"]=1,e[r[2]="CLUSTER_STATUS"]=2,e})();L.ClusterMessage=(function(){function r(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)e[t[i]]!=null&&t[i]!=="__proto__"&&(this[t[i]]=e[t[i]])}return r.prototype.action=0,r.prototype.data="",r.prototype.isError=!1,r.prototype.isAck=!1,r.prototype.leaderScore=0,r.prototype.role="",r.encode=function(t,i){return i||(i=Mt.create()),t.action!=null&&Object.hasOwnProperty.call(t,"action")&&i.uint32(8).int32(t.action),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&i.uint32(18).string(t.data),t.isError!=null&&Object.hasOwnProperty.call(t,"isError")&&i.uint32(24).bool(t.isError),t.isAck!=null&&Object.hasOwnProperty.call(t,"isAck")&&i.uint32(32).bool(t.isAck),t.leaderScore!=null&&Object.hasOwnProperty.call(t,"leaderScore")&&i.uint32(40).int32(t.leaderScore),t.role!=null&&Object.hasOwnProperty.call(t,"role")&&i.uint32(58).string(t.role),i},r.encodeDelimited=function(t,i){return this.encode(t,i).ldelim()},r.decode=function(t,i,n,o){if(t instanceof m||(t=m.create(t)),o===void 0&&(o=0),o>m.recursionLimit)throw Error("maximum nesting depth exceeded");for(var s=i===void 0?t.len:t.pos+i,a=new L.ClusterMessage;t.pos<s;){var c=t.uint32();if(c===n)break;switch(c>>>3){case 1:{a.action=t.int32();break}case 2:{a.data=t.string();break}case 3:{a.isError=t.bool();break}case 4:{a.isAck=t.bool();break}case 5:{a.leaderScore=t.int32();break}case 7:{a.role=t.string();break}default:t.skipType(c&7,o);break}}return a},r.decodeDelimited=function(t){return t instanceof m||(t=new m(t)),this.decode(t,t.uint32())},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/ClusterMessage"},r})();L.CONNECTION_ACTION=(function(){var r={},e=Object.create(r);return e[r[0]="CONNECTION_UNKNOWN"]=0,e[r[1]="CONNECTION_ERROR"]=1,e[r[2]="CONNECTION_PING"]=2,e[r[3]="CONNECTION_PONG"]=3,e[r[4]="CONNECTION_ACCEPT"]=4,e[r[5]="CONNECTION_CHALLENGE"]=5,e[r[6]="CONNECTION_REJECT"]=6,e[r[7]="CONNECTION_REDIRECT"]=7,e[r[8]="CONNECTION_CLOSING"]=8,e[r[9]="CONNECTION_CLOSED"]=9,e[r[100]="CONNECTION_AUTHENTICATION_TIMEOUT"]=100,e[r[101]="CONNECTION_INVALID_MESSAGE"]=101,e})();L.ConnectionMessage=(function(){function r(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)e[t[i]]!=null&&t[i]!=="__proto__"&&(this[t[i]]=e[t[i]])}return r.prototype.action=0,r.prototype.data="",r.prototype.isError=!1,r.prototype.isAck=!1,r.prototype.url="",r.prototype.protocolVersion="",r.prototype.sdkType="",r.prototype.sdkVersion="",r.encode=function(t,i){return i||(i=Mt.create()),t.action!=null&&Object.hasOwnProperty.call(t,"action")&&i.uint32(8).int32(t.action),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&i.uint32(18).string(t.data),t.isError!=null&&Object.hasOwnProperty.call(t,"isError")&&i.uint32(24).bool(t.isError),t.isAck!=null&&Object.hasOwnProperty.call(t,"isAck")&&i.uint32(32).bool(t.isAck),t.url!=null&&Object.hasOwnProperty.call(t,"url")&&i.uint32(42).string(t.url),t.protocolVersion!=null&&Object.hasOwnProperty.call(t,"protocolVersion")&&i.uint32(50).string(t.protocolVersion),t.sdkVersion!=null&&Object.hasOwnProperty.call(t,"sdkVersion")&&i.uint32(58).string(t.sdkVersion),t.sdkType!=null&&Object.hasOwnProperty.call(t,"sdkType")&&i.uint32(66).string(t.sdkType),i},r.encodeDelimited=function(t,i){return this.encode(t,i).ldelim()},r.decode=function(t,i,n,o){if(t instanceof m||(t=m.create(t)),o===void 0&&(o=0),o>m.recursionLimit)throw Error("maximum nesting depth exceeded");for(var s=i===void 0?t.len:t.pos+i,a=new L.ConnectionMessage;t.pos<s;){var c=t.uint32();if(c===n)break;switch(c>>>3){case 1:{a.action=t.int32();break}case 2:{a.data=t.string();break}case 3:{a.isError=t.bool();break}case 4:{a.isAck=t.bool();break}case 5:{a.url=t.string();break}case 6:{a.protocolVersion=t.string();break}case 8:{a.sdkType=t.string();break}case 7:{a.sdkVersion=t.string();break}default:t.skipType(c&7,o);break}}return a},r.decodeDelimited=function(t){return t instanceof m||(t=new m(t)),this.decode(t,t.uint32())},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/ConnectionMessage"},r})();L.EVENT_ACTION=(function(){var r={},e=Object.create(r);return e[r[0]="EVENT_UNKNOWN"]=0,e[r[1]="EVENT_ERROR"]=1,e[r[2]="EVENT_EMIT"]=2,e[r[3]="EVENT_SUBSCRIBE"]=3,e[r[4]="EVENT_UNSUBSCRIBE"]=4,e[r[5]="EVENT_LISTEN"]=5,e[r[6]="EVENT_UNLISTEN"]=6,e[r[7]="EVENT_LISTEN_ACCEPT"]=7,e[r[8]="EVENT_LISTEN_REJECT"]=8,e[r[9]="EVENT_SUBSCRIPTION_HAS_PROVIDER"]=9,e[r[10]="EVENT_SUBSCRIPTION_HAS_NO_PROVIDER"]=10,e[r[11]="EVENT_SUBSCRIPTION_FOR_PATTERN_FOUND"]=11,e[r[12]="EVENT_SUBSCRIPTION_FOR_PATTERN_REMOVED"]=12,e[r[100]="EVENT_INVALID_LISTEN_REGEX"]=100,e[r[101]="EVENT_LISTEN_RESPONSE_TIMEOUT"]=101,e[r[102]="EVENT_LISTEN_UNSUCCESSFUL"]=102,e[r[103]="EVENT_MESSAGE_PERMISSION_ERROR"]=103,e[r[104]="EVENT_MESSAGE_DENIED"]=104,e[r[105]="EVENT_INVALID_MESSAGE_DATA"]=105,e[r[106]="EVENT_MULTIPLE_SUBSCRIPTIONS"]=106,e[r[107]="EVENT_NOT_SUBSCRIBED"]=107,e})();L.EventMessage=(function(){function r(e){if(this.names=[],e)for(var t=Object.keys(e),i=0;i<t.length;++i)e[t[i]]!=null&&t[i]!=="__proto__"&&(this[t[i]]=e[t[i]])}return r.prototype.action=0,r.prototype.data="",r.prototype.correlationId="",r.prototype.isError=!1,r.prototype.isAck=!1,r.prototype.name="",r.prototype.names=ie.emptyArray,r.prototype.subscription="",r.prototype.originalTOPIC=0,r.prototype.originalAction=0,r.encode=function(t,i){if(i||(i=Mt.create()),t.action!=null&&Object.hasOwnProperty.call(t,"action")&&i.uint32(8).int32(t.action),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&i.uint32(18).string(t.data),t.correlationId!=null&&Object.hasOwnProperty.call(t,"correlationId")&&i.uint32(26).string(t.correlationId),t.isError!=null&&Object.hasOwnProperty.call(t,"isError")&&i.uint32(32).bool(t.isError),t.isAck!=null&&Object.hasOwnProperty.call(t,"isAck")&&i.uint32(40).bool(t.isAck),t.name!=null&&Object.hasOwnProperty.call(t,"name")&&i.uint32(50).string(t.name),t.names!=null&&t.names.length)for(var n=0;n<t.names.length;++n)i.uint32(58).string(t.names[n]);return t.subscription!=null&&Object.hasOwnProperty.call(t,"subscription")&&i.uint32(66).string(t.subscription),t.originalTOPIC!=null&&Object.hasOwnProperty.call(t,"originalTOPIC")&&i.uint32(80).int32(t.originalTOPIC),t.originalAction!=null&&Object.hasOwnProperty.call(t,"originalAction")&&i.uint32(88).int32(t.originalAction),i},r.encodeDelimited=function(t,i){return this.encode(t,i).ldelim()},r.decode=function(t,i,n,o){if(t instanceof m||(t=m.create(t)),o===void 0&&(o=0),o>m.recursionLimit)throw Error("maximum nesting depth exceeded");for(var s=i===void 0?t.len:t.pos+i,a=new L.EventMessage;t.pos<s;){var c=t.uint32();if(c===n)break;switch(c>>>3){case 1:{a.action=t.int32();break}case 2:{a.data=t.string();break}case 3:{a.correlationId=t.string();break}case 4:{a.isError=t.bool();break}case 5:{a.isAck=t.bool();break}case 6:{a.name=t.string();break}case 7:{a.names&&a.names.length||(a.names=[]),a.names.push(t.string());break}case 8:{a.subscription=t.string();break}case 10:{a.originalTOPIC=t.int32();break}case 11:{a.originalAction=t.int32();break}default:t.skipType(c&7,o);break}}return a},r.decodeDelimited=function(t){return t instanceof m||(t=new m(t)),this.decode(t,t.uint32())},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/EventMessage"},r})();L.TOPIC=(function(){var r={},e=Object.create(r);return e[r[0]="UNKNOWN"]=0,e[r[1]="PARSER"]=1,e[r[2]="CONNECTION"]=2,e[r[3]="AUTH"]=3,e[r[4]="EVENT"]=4,e[r[5]="RECORD"]=5,e[r[6]="RPC"]=6,e[r[7]="PRESENCE"]=7,e[r[8]="MONITORING"]=8,e[r[9]="CLUSTER"]=9,e[r[10]="LOCK"]=10,e[r[11]="STATE_REGISTRY"]=11,e[r[100]="ERROR"]=100,e})();L.Message=(function(){function r(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)e[t[i]]!=null&&t[i]!=="__proto__"&&(this[t[i]]=e[t[i]])}return r.prototype.topic=0,r.prototype.message=ie.newBuffer([]),r.encode=function(t,i){return i||(i=Mt.create()),t.topic!=null&&Object.hasOwnProperty.call(t,"topic")&&i.uint32(16).int32(t.topic),t.message!=null&&Object.hasOwnProperty.call(t,"message")&&i.uint32(26).bytes(t.message),i},r.encodeDelimited=function(t,i){return this.encode(t,i).ldelim()},r.decode=function(t,i,n,o){if(t instanceof m||(t=m.create(t)),o===void 0&&(o=0),o>m.recursionLimit)throw Error("maximum nesting depth exceeded");for(var s=i===void 0?t.len:t.pos+i,a=new L.Message;t.pos<s;){var c=t.uint32();if(c===n)break;switch(c>>>3){case 2:{a.topic=t.int32();break}case 3:{a.message=t.bytes();break}default:t.skipType(c&7,o);break}}return a},r.decodeDelimited=function(t){return t instanceof m||(t=new m(t)),this.decode(t,t.uint32())},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/Message"},r})();L.LOCK_ACTION=(function(){var r={},e=Object.create(r);return e[r[0]="LOCK_UNKNOWN"]=0,e[r[1]="LOCK_ERROR"]=1,e[r[2]="LOCK_REQUEST"]=2,e[r[3]="LOCK_RESPONSE"]=3,e[r[4]="LOCK_RELEASE"]=4,e})();L.LockMessage=(function(){function r(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)e[t[i]]!=null&&t[i]!=="__proto__"&&(this[t[i]]=e[t[i]])}return r.prototype.action=0,r.prototype.locked=!1,r.encode=function(t,i){return i||(i=Mt.create()),t.action!=null&&Object.hasOwnProperty.call(t,"action")&&i.uint32(8).int32(t.action),t.locked!=null&&Object.hasOwnProperty.call(t,"locked")&&i.uint32(24).bool(t.locked),i},r.encodeDelimited=function(t,i){return this.encode(t,i).ldelim()},r.decode=function(t,i,n,o){if(t instanceof m||(t=m.create(t)),o===void 0&&(o=0),o>m.recursionLimit)throw Error("maximum nesting depth exceeded");for(var s=i===void 0?t.len:t.pos+i,a=new L.LockMessage;t.pos<s;){var c=t.uint32();if(c===n)break;switch(c>>>3){case 1:{a.action=t.int32();break}case 3:{a.locked=t.bool();break}default:t.skipType(c&7,o);break}}return a},r.decodeDelimited=function(t){return t instanceof m||(t=new m(t)),this.decode(t,t.uint32())},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/LockMessage"},r})();L.MONITORING_ACTION=(function(){var r={},e=Object.create(r);return e[r[0]="MONITORING_UNKNOWN"]=0,e})();L.MonitoringMessage=(function(){function r(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)e[t[i]]!=null&&t[i]!=="__proto__"&&(this[t[i]]=e[t[i]])}return r.prototype.action=0,r.prototype.data="",r.prototype.correlationId="",r.prototype.isError=!1,r.prototype.isAck=!1,r.encode=function(t,i){return i||(i=Mt.create()),t.action!=null&&Object.hasOwnProperty.call(t,"action")&&i.uint32(8).int32(t.action),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&i.uint32(18).string(t.data),t.correlationId!=null&&Object.hasOwnProperty.call(t,"correlationId")&&i.uint32(26).string(t.correlationId),t.isError!=null&&Object.hasOwnProperty.call(t,"isError")&&i.uint32(32).bool(t.isError),t.isAck!=null&&Object.hasOwnProperty.call(t,"isAck")&&i.uint32(40).bool(t.isAck),i},r.encodeDelimited=function(t,i){return this.encode(t,i).ldelim()},r.decode=function(t,i,n,o){if(t instanceof m||(t=m.create(t)),o===void 0&&(o=0),o>m.recursionLimit)throw Error("maximum nesting depth exceeded");for(var s=i===void 0?t.len:t.pos+i,a=new L.MonitoringMessage;t.pos<s;){var c=t.uint32();if(c===n)break;switch(c>>>3){case 1:{a.action=t.int32();break}case 2:{a.data=t.string();break}case 3:{a.correlationId=t.string();break}case 4:{a.isError=t.bool();break}case 5:{a.isAck=t.bool();break}default:t.skipType(c&7,o);break}}return a},r.decodeDelimited=function(t){return t instanceof m||(t=new m(t)),this.decode(t,t.uint32())},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/MonitoringMessage"},r})();L.PARSER_ACTION=(function(){var r={},e=Object.create(r);return e[r[0]="PARSER_UNKNOWN"]=0,e[r[1]="PARSER_UNKNOWN_TOPIC"]=1,e[r[2]="PARSER_UNKNOWN_ACTION"]=2,e[r[3]="PARSER_INVALID_MESSAGE"]=3,e[r[4]="PARSER_MESSAGE_PARSE_ERROR"]=4,e[r[5]="PARSER_MAXIMUM_MESSAGE_SIZE_EXCEEDED"]=5,e[r[6]="PARSER_ERROR"]=6,e[r[7]="PARSER_INVALID_META_PARAMS"]=7,e})();L.ParserMessage=(function(){function r(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)e[t[i]]!=null&&t[i]!=="__proto__"&&(this[t[i]]=e[t[i]])}return r.prototype.action=0,r.prototype.data="",r.prototype.originalTOPIC=0,r.prototype.originalAction=0,r.encode=function(t,i){return i||(i=Mt.create()),t.action!=null&&Object.hasOwnProperty.call(t,"action")&&i.uint32(8).int32(t.action),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&i.uint32(18).string(t.data),t.originalTOPIC!=null&&Object.hasOwnProperty.call(t,"originalTOPIC")&&i.uint32(64).int32(t.originalTOPIC),t.originalAction!=null&&Object.hasOwnProperty.call(t,"originalAction")&&i.uint32(72).int32(t.originalAction),i},r.encodeDelimited=function(t,i){return this.encode(t,i).ldelim()},r.decode=function(t,i,n,o){if(t instanceof m||(t=m.create(t)),o===void 0&&(o=0),o>m.recursionLimit)throw Error("maximum nesting depth exceeded");for(var s=i===void 0?t.len:t.pos+i,a=new L.ParserMessage;t.pos<s;){var c=t.uint32();if(c===n)break;switch(c>>>3){case 1:{a.action=t.int32();break}case 2:{a.data=t.string();break}case 8:{a.originalTOPIC=t.int32();break}case 9:{a.originalAction=t.int32();break}default:t.skipType(c&7,o);break}}return a},r.decodeDelimited=function(t){return t instanceof m||(t=new m(t)),this.decode(t,t.uint32())},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/ParserMessage"},r})();L.PRESENCE_ACTION=(function(){var r={},e=Object.create(r);return e[r[0]="PRESENCE_UNKNOWN"]=0,e[r[1]="PRESENCE_ERROR"]=1,e[r[2]="PRESENCE_QUERY_ALL"]=2,e[r[3]="PRESENCE_QUERY_ALL_RESPONSE"]=3,e[r[4]="PRESENCE_QUERY"]=4,e[r[5]="PRESENCE_QUERY_RESPONSE"]=5,e[r[6]="PRESENCE_PRESENCE_JOIN"]=6,e[r[7]="PRESENCE_PRESENCE_JOIN_ALL"]=7,e[r[8]="PRESENCE_PRESENCE_LEAVE"]=8,e[r[9]="PRESENCE_PRESENCE_LEAVE_ALL"]=9,e[r[10]="PRESENCE_SUBSCRIBE"]=10,e[r[11]="PRESENCE_UNSUBSCRIBE"]=11,e[r[12]="PRESENCE_SUBSCRIBE_ALL"]=12,e[r[13]="PRESENCE_UNSUBSCRIBE_ALL"]=13,e[r[100]="PRESENCE_INVALID_PRESENCE_USERS"]=100,e[r[101]="PRESENCE_MESSAGE_PERMISSION_ERROR"]=101,e[r[102]="PRESENCE_MESSAGE_DENIED"]=102,e[r[103]="PRESENCE_MULTIPLE_SUBSCRIPTIONS"]=103,e[r[104]="PRESENCE_NOT_SUBSCRIBED"]=104,e})();L.PresenceMessage=(function(){function r(e){if(this.names=[],e)for(var t=Object.keys(e),i=0;i<t.length;++i)e[t[i]]!=null&&t[i]!=="__proto__"&&(this[t[i]]=e[t[i]])}return r.prototype.action=0,r.prototype.originalTOPIC=0,r.prototype.originalAction=0,r.prototype.data="",r.prototype.correlationId="",r.prototype.isError=!1,r.prototype.isAck=!1,r.prototype.name="",r.prototype.names=ie.emptyArray,r.encode=function(t,i){if(i||(i=Mt.create()),t.action!=null&&Object.hasOwnProperty.call(t,"action")&&i.uint32(8).int32(t.action),t.originalTOPIC!=null&&Object.hasOwnProperty.call(t,"originalTOPIC")&&i.uint32(16).int32(t.originalTOPIC),t.originalAction!=null&&Object.hasOwnProperty.call(t,"originalAction")&&i.uint32(24).int32(t.originalAction),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&i.uint32(34).string(t.data),t.correlationId!=null&&Object.hasOwnProperty.call(t,"correlationId")&&i.uint32(42).string(t.correlationId),t.isError!=null&&Object.hasOwnProperty.call(t,"isError")&&i.uint32(48).bool(t.isError),t.isAck!=null&&Object.hasOwnProperty.call(t,"isAck")&&i.uint32(56).bool(t.isAck),t.name!=null&&Object.hasOwnProperty.call(t,"name")&&i.uint32(66).string(t.name),t.names!=null&&t.names.length)for(var n=0;n<t.names.length;++n)i.uint32(74).string(t.names[n]);return i},r.encodeDelimited=function(t,i){return this.encode(t,i).ldelim()},r.decode=function(t,i,n,o){if(t instanceof m||(t=m.create(t)),o===void 0&&(o=0),o>m.recursionLimit)throw Error("maximum nesting depth exceeded");for(var s=i===void 0?t.len:t.pos+i,a=new L.PresenceMessage;t.pos<s;){var c=t.uint32();if(c===n)break;switch(c>>>3){case 1:{a.action=t.int32();break}case 2:{a.originalTOPIC=t.int32();break}case 3:{a.originalAction=t.int32();break}case 4:{a.data=t.string();break}case 5:{a.correlationId=t.string();break}case 6:{a.isError=t.bool();break}case 7:{a.isAck=t.bool();break}case 8:{a.name=t.string();break}case 9:{a.names&&a.names.length||(a.names=[]),a.names.push(t.string());break}default:t.skipType(c&7,o);break}}return a},r.decodeDelimited=function(t){return t instanceof m||(t=new m(t)),this.decode(t,t.uint32())},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/PresenceMessage"},r})();L.RECORD_ACTION=(function(){var r={},e=Object.create(r);return e[r[0]="RECORD_UNKNOWN"]=0,e[r[1]="RECORD_ERROR"]=1,e[r[2]="RECORD_NOTIFY"]=2,e[r[3]="RECORD_READ"]=3,e[r[4]="RECORD_READ_RESPONSE"]=4,e[r[5]="RECORD_HEAD"]=5,e[r[6]="RECORD_HEAD_RESPONSE"]=6,e[r[7]="RECORD_HEAD_BULK"]=7,e[r[8]="RECORD_HEAD_RESPONSE_BULK"]=8,e[r[9]="RECORD_DELETE"]=9,e[r[10]="RECORD_DELETE_SUCCESS"]=10,e[r[11]="RECORD_DELETE_BULK"]=11,e[r[12]="RECORD_DELETE_BULK_SUCCESS"]=12,e[r[13]="RECORD_DELETED"]=13,e[r[14]="RECORD_WRITE_ACKNOWLEDGEMENT"]=14,e[r[15]="RECORD_CREATE"]=15,e[r[16]="RECORD_CREATEANDUPDATE"]=16,e[r[17]="RECORD_CREATEANDPATCH"]=17,e[r[18]="RECORD_UPDATE"]=18,e[r[19]="RECORD_PATCH"]=19,e[r[20]="RECORD_ERASE"]=20,e[r[21]="RECORD_SUBSCRIBEANDHEAD"]=21,e[r[22]="RECORD_SUBSCRIBEANDREAD"]=22,e[r[23]="RECORD_SUBSCRIBECREATEANDREAD"]=23,e[r[24]="RECORD_SUBSCRIBECREATEANDUPDATE"]=24,e[r[25]="RECORD_SUBSCRIBE"]=25,e[r[26]="RECORD_UNSUBSCRIBE"]=26,e[r[27]="RECORD_LISTEN"]=27,e[r[28]="RECORD_UNLISTEN"]=28,e[r[29]="RECORD_LISTEN_ACCEPT"]=29,e[r[30]="RECORD_LISTEN_REJECT"]=30,e[r[31]="RECORD_SUBSCRIPTION_HAS_PROVIDER"]=31,e[r[32]="RECORD_SUBSCRIPTION_HAS_NO_PROVIDER"]=32,e[r[33]="RECORD_SUBSCRIPTION_FOR_PATTERN_FOUND"]=33,e[r[34]="RECORD_SUBSCRIPTION_FOR_PATTERN_REMOVED"]=34,e[r[35]="RECORD_PATCH_MULTI"]=35,e[r[100]="RECORD_CACHE_RETRIEVAL_TIMEOUT"]=100,e[r[101]="RECORD_STORAGE_RETRIEVAL_TIMEOUT"]=101,e[r[102]="RECORD_VERSION_EXISTS"]=102,e[r[103]="RECORD_RECORD_LOAD_ERROR"]=103,e[r[104]="RECORD_RECORD_CREATE_ERROR"]=104,e[r[105]="RECORD_RECORD_UPDATE_ERROR"]=105,e[r[106]="RECORD_RECORD_DELETE_ERROR"]=106,e[r[107]="RECORD_RECORD_NOT_FOUND"]=107,e[r[108]="RECORD_INVALID_VERSION"]=108,e[r[109]="RECORD_INVALID_PATCH_ON_HOTPATH"]=109,e[r[110]="RECORD_INVALID_LISTEN_REGEX"]=110,e[r[111]="RECORD_LISTEN_RESPONSE_TIMEOUT"]=111,e[r[112]="RECORD_LISTEN_UNSUCCESSFUL"]=112,e[r[113]="RECORD_RECORD_NOTIFY_ERROR"]=113,e[r[114]="RECORD_MESSAGE_PERMISSION_ERROR"]=114,e[r[115]="RECORD_MESSAGE_DENIED"]=115,e[r[116]="RECORD_INVALID_MESSAGE_DATA"]=116,e[r[117]="RECORD_MULTIPLE_SUBSCRIPTIONS"]=117,e[r[118]="RECORD_NOT_SUBSCRIBED"]=118,e})();L.RecordMessage=(function(){function r(e){if(this.names=[],this.versions={},e)for(var t=Object.keys(e),i=0;i<t.length;++i)e[t[i]]!=null&&t[i]!=="__proto__"&&(this[t[i]]=e[t[i]])}return r.prototype.action=0,r.prototype.data="",r.prototype.correlationId="",r.prototype.isError=!1,r.prototype.isAck=!1,r.prototype.name="",r.prototype.names=ie.emptyArray,r.prototype.pattern="",r.prototype.subscription="",r.prototype.originalAction=0,r.prototype.isWriteAck=!1,r.prototype.path="",r.prototype.version=0,r.prototype.versions=ie.emptyObject,r.encode=function(t,i){if(i||(i=Mt.create()),t.action!=null&&Object.hasOwnProperty.call(t,"action")&&i.uint32(8).int32(t.action),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&i.uint32(18).string(t.data),t.correlationId!=null&&Object.hasOwnProperty.call(t,"correlationId")&&i.uint32(26).string(t.correlationId),t.isError!=null&&Object.hasOwnProperty.call(t,"isError")&&i.uint32(32).bool(t.isError),t.isAck!=null&&Object.hasOwnProperty.call(t,"isAck")&&i.uint32(40).bool(t.isAck),t.name!=null&&Object.hasOwnProperty.call(t,"name")&&i.uint32(50).string(t.name),t.names!=null&&t.names.length)for(var n=0;n<t.names.length;++n)i.uint32(58).string(t.names[n]);if(t.pattern!=null&&Object.hasOwnProperty.call(t,"pattern")&&i.uint32(66).string(t.pattern),t.subscription!=null&&Object.hasOwnProperty.call(t,"subscription")&&i.uint32(74).string(t.subscription),t.originalAction!=null&&Object.hasOwnProperty.call(t,"originalAction")&&i.uint32(80).int32(t.originalAction),t.isWriteAck!=null&&Object.hasOwnProperty.call(t,"isWriteAck")&&i.uint32(88).bool(t.isWriteAck),t.path!=null&&Object.hasOwnProperty.call(t,"path")&&i.uint32(98).string(t.path),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&i.uint32(104).int32(t.version),t.versions!=null&&Object.hasOwnProperty.call(t,"versions"))for(var o=Object.keys(t.versions),n=0;n<o.length;++n)i.uint32(114).fork().uint32(10).string(o[n]).uint32(16).int32(t.versions[o[n]]).ldelim();return i},r.encodeDelimited=function(t,i){return this.encode(t,i).ldelim()},r.decode=function(t,i,n,o){if(t instanceof m||(t=m.create(t)),o===void 0&&(o=0),o>m.recursionLimit)throw Error("maximum nesting depth exceeded");for(var s=i===void 0?t.len:t.pos+i,a=new L.RecordMessage,c,l;t.pos<s;){var f=t.uint32();if(f===n)break;switch(f>>>3){case 1:{a.action=t.int32();break}case 2:{a.data=t.string();break}case 3:{a.correlationId=t.string();break}case 4:{a.isError=t.bool();break}case 5:{a.isAck=t.bool();break}case 6:{a.name=t.string();break}case 7:{a.names&&a.names.length||(a.names=[]),a.names.push(t.string());break}case 8:{a.pattern=t.string();break}case 9:{a.subscription=t.string();break}case 10:{a.originalAction=t.int32();break}case 11:{a.isWriteAck=t.bool();break}case 12:{a.path=t.string();break}case 13:{a.version=t.int32();break}case 14:{a.versions===ie.emptyObject&&(a.versions={});var p=t.uint32()+t.pos;for(c="",l=0;t.pos<p;){var b=t.uint32();switch(b>>>3){case 1:c=t.string();break;case 2:l=t.int32();break;default:t.skipType(b&7,o);break}}c==="__proto__"&&ie.makeProp(a.versions,c),a.versions[c]=l;break}default:t.skipType(f&7,o);break}}return a},r.decodeDelimited=function(t){return t instanceof m||(t=new m(t)),this.decode(t,t.uint32())},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/RecordMessage"},r})();L.RPC_ACTION=(function(){var r={},e=Object.create(r);return e[r[0]="RPC_UNKNOWN"]=0,e[r[1]="RPC_ERROR"]=1,e[r[2]="RPC_REQUEST"]=2,e[r[4]="RPC_ACCEPT"]=4,e[r[5]="RPC_RESPONSE"]=5,e[r[6]="RPC_REJECT"]=6,e[r[7]="RPC_REQUEST_ERROR"]=7,e[r[8]="RPC_PROVIDE"]=8,e[r[9]="RPC_UNPROVIDE"]=9,e[r[100]="RPC_NO_RPC_PROVIDER"]=100,e[r[101]="RPC_ACCEPT_TIMEOUT"]=101,e[r[102]="RPC_MULTIPLE_ACCEPT"]=102,e[r[103]="RPC_INVALID_RPC_CORRELATION_ID"]=103,e[r[104]="RPC_RESPONSE_TIMEOUT"]=104,e[r[105]="RPC_MULTIPLE_RESPONSE"]=105,e[r[106]="RPC_MESSAGE_PERMISSION_ERROR"]=106,e[r[107]="RPC_MESSAGE_DENIED"]=107,e[r[108]="RPC_INVALID_MESSAGE_DATA"]=108,e[r[109]="RPC_MULTIPLE_PROVIDERS"]=109,e[r[110]="RPC_NOT_PROVIDED"]=110,e})();L.RpcMessage=(function(){function r(e){if(this.names=[],e)for(var t=Object.keys(e),i=0;i<t.length;++i)e[t[i]]!=null&&t[i]!=="__proto__"&&(this[t[i]]=e[t[i]])}return r.prototype.action=0,r.prototype.data="",r.prototype.correlationId="",r.prototype.isError=!1,r.prototype.isAck=!1,r.prototype.names=ie.emptyArray,r.prototype.name="",r.prototype.originalAction=0,r.prototype.requestorName="",r.prototype.requestorData="",r.encode=function(t,i){if(i||(i=Mt.create()),t.action!=null&&Object.hasOwnProperty.call(t,"action")&&i.uint32(8).int32(t.action),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&i.uint32(18).string(t.data),t.correlationId!=null&&Object.hasOwnProperty.call(t,"correlationId")&&i.uint32(26).string(t.correlationId),t.isError!=null&&Object.hasOwnProperty.call(t,"isError")&&i.uint32(32).bool(t.isError),t.isAck!=null&&Object.hasOwnProperty.call(t,"isAck")&&i.uint32(40).bool(t.isAck),t.names!=null&&t.names.length)for(var n=0;n<t.names.length;++n)i.uint32(50).string(t.names[n]);return t.name!=null&&Object.hasOwnProperty.call(t,"name")&&i.uint32(58).string(t.name),t.originalAction!=null&&Object.hasOwnProperty.call(t,"originalAction")&&i.uint32(72).int32(t.originalAction),t.requestorName!=null&&Object.hasOwnProperty.call(t,"requestorName")&&i.uint32(82).string(t.requestorName),t.requestorData!=null&&Object.hasOwnProperty.call(t,"requestorData")&&i.uint32(90).string(t.requestorData),i},r.encodeDelimited=function(t,i){return this.encode(t,i).ldelim()},r.decode=function(t,i,n,o){if(t instanceof m||(t=m.create(t)),o===void 0&&(o=0),o>m.recursionLimit)throw Error("maximum nesting depth exceeded");for(var s=i===void 0?t.len:t.pos+i,a=new L.RpcMessage;t.pos<s;){var c=t.uint32();if(c===n)break;switch(c>>>3){case 1:{a.action=t.int32();break}case 2:{a.data=t.string();break}case 3:{a.correlationId=t.string();break}case 4:{a.isError=t.bool();break}case 5:{a.isAck=t.bool();break}case 6:{a.names&&a.names.length||(a.names=[]),a.names.push(t.string());break}case 7:{a.name=t.string();break}case 9:{a.originalAction=t.int32();break}case 10:{a.requestorName=t.string();break}case 11:{a.requestorData=t.string();break}default:t.skipType(c&7,o);break}}return a},r.decodeDelimited=function(t){return t instanceof m||(t=new m(t)),this.decode(t,t.uint32())},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/RpcMessage"},r})();L.STATE_REGISTRY_TOPIC=(function(){var r={},e=Object.create(r);return e[r[0]="STATE_REGISTRY_UNKNOWN"]=0,e[r[11]="STATE_REGISTRY_EVENT_SUBSCRIPTIONS"]=11,e[r[12]="STATE_REGISTRY_RECORD_SUBSCRIPTIONS"]=12,e[r[9]="STATE_REGISTRY_SUBSCRIPTIONS"]=9,e[r[10]="STATE_REGISTRY_ONLINE_USERS"]=10,e[r[24]="STATE_REGISTRY_MONITORING_SUBSCRIPTIONS"]=24,e[r[13]="STATE_REGISTRY_RPC_SUBSCRIPTIONS"]=13,e[r[14]="STATE_REGISTRY_PRESENCE_SUBSCRIPTIONS"]=14,e[r[15]="STATE_REGISTRY_RECORD_LISTEN_PATTERNS"]=15,e[r[16]="STATE_REGISTRY_EVENT_LISTEN_PATTERNS"]=16,e[r[17]="STATE_REGISTRY_RECORD_PUBLISHED_SUBSCRIPTIONS"]=17,e[r[18]="STATE_REGISTRY_EVENT_PUBLISHED_SUBSCRIPTIONS"]=18,e[r[19]="STATE_REGISTRY_RECORD_LISTENING"]=19,e[r[20]="STATE_REGISTRY_EVENT_LISTENING"]=20,e[r[21]="STATE_REGISTRY_STATE_REGISTRY"]=21,e})();L.STATE_ACTION=(function(){var r={},e=Object.create(r);return e[r[0]="STATE_UNKNOWN"]=0,e[r[1]="STATE_ERROR"]=1,e[r[2]="STATE_ADD"]=2,e[r[3]="STATE_REMOVE"]=3,e[r[4]="STATE_REQUEST_FULL_STATE"]=4,e[r[5]="STATE_FULL_STATE"]=5,e[r[6]="STATE_CHECKSUM"]=6,e})();L.StateMessage=(function(){function r(e){if(this.fullState=[],e)for(var t=Object.keys(e),i=0;i<t.length;++i)e[t[i]]!=null&&t[i]!=="__proto__"&&(this[t[i]]=e[t[i]])}return r.prototype.action=0,r.prototype.data="",r.prototype.isError=!1,r.prototype.checksum=0,r.prototype.fullState=ie.emptyArray,r.prototype.serverName="",r.prototype.registryTOPIC=0,r.encode=function(t,i){if(i||(i=Mt.create()),t.action!=null&&Object.hasOwnProperty.call(t,"action")&&i.uint32(8).int32(t.action),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&i.uint32(18).string(t.data),t.isError!=null&&Object.hasOwnProperty.call(t,"isError")&&i.uint32(24).bool(t.isError),t.checksum!=null&&Object.hasOwnProperty.call(t,"checksum")&&i.uint32(152).int32(t.checksum),t.fullState!=null&&t.fullState.length)for(var n=0;n<t.fullState.length;++n)i.uint32(162).string(t.fullState[n]);return t.serverName!=null&&Object.hasOwnProperty.call(t,"serverName")&&i.uint32(170).string(t.serverName),t.registryTOPIC!=null&&Object.hasOwnProperty.call(t,"registryTOPIC")&&i.uint32(176).int32(t.registryTOPIC),i},r.encodeDelimited=function(t,i){return this.encode(t,i).ldelim()},r.decode=function(t,i,n,o){if(t instanceof m||(t=m.create(t)),o===void 0&&(o=0),o>m.recursionLimit)throw Error("maximum nesting depth exceeded");for(var s=i===void 0?t.len:t.pos+i,a=new L.StateMessage;t.pos<s;){var c=t.uint32();if(c===n)break;switch(c>>>3){case 1:{a.action=t.int32();break}case 2:{a.data=t.string();break}case 3:{a.isError=t.bool();break}case 19:{a.checksum=t.int32();break}case 20:{a.fullState&&a.fullState.length||(a.fullState=[]),a.fullState.push(t.string());break}case 21:{a.serverName=t.string();break}case 22:{a.registryTOPIC=t.int32();break}default:t.skipType(c&7,o);break}}return a},r.decodeDelimited=function(t){return t instanceof m||(t=new m(t)),this.decode(t,t.uint32())},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/StateMessage"},r})();sa.exports=L});var _n=v(Ei=>{"use strict";h();Object.defineProperty(Ei,"__esModule",{value:!0});Ei.TopicMessage=void 0;var et=pi();Ei.TopicMessage={[et.TOPIC.RECORD]:et.RecordMessage,[et.TOPIC.CLUSTER]:et.ClusterMessage,[et.TOPIC.CONNECTION]:et.ConnectionMessage,[et.TOPIC.AUTH]:et.AuthMessage,[et.TOPIC.EVENT]:et.EventMessage,[et.TOPIC.LOCK]:et.LockMessage,[et.TOPIC.MONITORING]:et.MonitoringMessage,[et.TOPIC.PARSER]:et.ParserMessage,[et.TOPIC.PRESENCE]:et.PresenceMessage,[et.TOPIC.RPC]:et.RpcMessage}});var Sn=v(yi=>{"use strict";h();Object.defineProperty(yi,"__esModule",{value:!0});yi.parse=sl;yi.parseData=al;var nl=_n(),ol=pi(),aa=ze();function sl(r){try{let e=ol.Message.decodeDelimited(r),t=nl.TopicMessage[e.topic].decode(e.message,e.message.length);return[Object.assign({topic:e.topic},t)]}catch(e){return[{topic:aa.TOPIC.PARSER,action:aa.PARSER_ACTION.ERROR}]}}function al(r){return r.requestorData&&(r.requestorData=JSON.parse(r.requestorData)),r.parsedData!==void 0||r.data===void 0?!0:(r.parsedData=JSON.parse(r.data),r.parsedData===void 0?new Error(`unable to parse data ${r.data}`):!0)}});var gn=v(Ri=>{"use strict";h();Object.defineProperty(Ri,"__esModule",{value:!0});Ri.StateMachine=void 0;var cl=(function(){function r(e,t){this.stateMachine=t,this.inEndState=!1,this.transitions=t.transitions,this.state=t.init,this.context=t.context,this.history=[{oldState:"-",newState:this.state,transitionName:"-"}]}return r.prototype.transition=function(e){for(var t,i=0;i<this.transitions.length;i++)if(t=this.transitions[i],e===t.name&&(this.state===t.from||t.from===void 0)){this.history.push({oldState:this.state,transitionName:e,newState:t.to});var n=this.state;this.state=t.to,this.stateMachine.onStateChanged&&this.stateMachine.onStateChanged.call(this.context,this.state,n),t.handler&&t.handler.call(this.context),t.isEndState===!0&&(this.inEndState=!0);return}var o=JSON.stringify({transition:e,fromState:this.state}),s=this.history.reverse().reduce(function(a,c){return a+=`
From `.concat(c.oldState," to ").concat(c.newState," via ").concat(c.transitionName)},"");console.trace(`Invalid state transition.
Details: `.concat(o,`
History: `).concat(s))},r})();Ri.StateMachine=cl});var Jt=v(ct=>{"use strict";h();Object.defineProperty(ct,"__esModule",{value:!0});ct.PromiseDelay=ct.normalizeArguments=ct.normalizeSetArguments=ct.getUid=ct.parseUrl=ct.shallowCopy=ct.deepCopy=ct.deepEquals=void 0;var ul=function(r,e){return r===e?!0:typeof r!="object"||typeof e!="object"?!1:JSON.stringify(r)===JSON.stringify(e)};ct.deepEquals=ul;var ll=function(r){return typeof r=="object"?JSON.parse(JSON.stringify(r)):r};ct.deepCopy=ll;var hl=function(r){if(Array.isArray(r))return r.slice(0);if(typeof r=="object"){for(var e=Object.create(null),t=Object.keys(r),i=0;i<t.length;i++)e[t[i]]=r[t[i]];return e}return r};ct.shallowCopy=hl;var fl=/^wss:|^ws:|^\/\//,dl=/^http:|^https:/,pl=function(r,e){var t=r;if(dl.test(t))throw new Error("Only ws and wss are supported");fl.test(t)?t.indexOf("//")===0&&(t="ws:".concat(t)):t="ws://".concat(t);var i=t.split("//")[0],n=t.split("//")[1];if(!n)throw new Error("Invalid URL: ws://");var o=null;return n.indexOf("/")>-1?(o=n.split("/"),n=o.shift()||"",o="/"+o.join("")):n.indexOf("?")>-1&&(o=n.split("?"),n=o.shift()||"",o=e+"?"+o.join("")),(!o||o==="/")&&(o=e),"".concat(i,"//").concat(n).concat(o)};ct.parseUrl=pl;var El=function(){var r=new Date().getTime().toString(36),e=(Math.random()*1e16).toString(36).replace(".","");return"".concat(r,"-").concat(e)};ct.getUid=El;var yl=function(r,e){e===void 0&&(e=0);var t,i=function(a){return a!==void 0&&typeof a=="object"},n=function(a){return typeof a!="function"},o=function(a){return a!==void 0&&typeof a=="string"},s=function(a){return typeof a=="function"};if(r.length===e+1&&(t={path:void 0,data:i(r[e])?r[e]:void 0,callback:void 0}),r.length===e+2&&(t={path:void 0,data:void 0,callback:void 0},!s(r[e])&&n(r[e])&&(t.path=o(r[e])?r[e]:void 0),o(r[e])?t.data=n(r[e+1])?r[e+1]:void 0:t.data=i(r[e])?r[e]:void 0,o(r[e])||(t.callback=s(r[e+1])?r[e+1]:!1)),r.length===e+3&&(t={path:o(r[e])?r[e]:void 0,data:n(r[e+1])?r[e+1]:void 0,callback:s(r[e+2])?r[e+2]:void 0}),t){if(t.path!==void 0&&t.path.length===0||t.path===void 0&&!t.data)throw Error("Invalid set path argument");if(t.data===void 0&&t.path===void 0)throw Error("Invalid set data argument");if(t.callback!==void 0&&t.callback===!1||t.callback===void 0&&r.length===e+3)throw Error("Invalid set callback argument");return t}throw Error("Invalid set arguments")};ct.normalizeSetArguments=yl;var Rl=function(r){if(r.length===1&&typeof r[0]=="object")return r[0];for(var e=Object.create(null),t=0;t<r.length;t++)typeof r[t]=="string"?e.path=r[t]:typeof r[t]=="function"?e.callback=r[t]:typeof r[t]=="boolean"&&(e.triggerNow=r[t]);return e};ct.normalizeArguments=Rl;var _l=function(r){return new Promise(function(e){return setTimeout(e,r)})};ct.PromiseDelay=_l});var ca=v((fp,Sl)=>{Sl.exports={name:"@deepstream/client",version:"7.1.0",description:"the javascript client for deepstreamIO",keywords:["deepstream","javascript","realtime","client"],mocha:{recursive:!0,reporter:"dot",require:"ts-node/register/transpile-only",exit:!0},main:"dist/src/deepstream.js",types:"dist/src/deepstream-client.d.ts",directories:{test:"src/test"},scripts:{tsc:"rm -rf dist && tsc",build:"npm run tsc && npm run build:dev && npm run build:prod","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js",rebuild:"rimraf dist && webpack",clean:"rimraf dist",lint:"tslint src/*.ts src/**/*.ts -t verbose","lint:fix":"npm run lint -- --fix",test:"mocha src/**/*.spec.ts","test:coverage":"nyc npm test","bundle:analyse":"webpack --config webpack.prod.js --profile --json > ./dist/stats.json && webpack-bundle-analyzer ./dist/stats.json",postinstall:"node scripts/postinstall.js"},repository:{type:"git",url:"https://github.com/deepstreamIO/deepstream.io-client-js.git"},dependencies:{"@deepstream/protobuf":"^1.1.0",protobufjs:"^8.0.3",ws:"^8.20.0"},browser:{net:!1,"./dist/src/connection/socket-factory.js":"./dist/src/connection/socket-factory-browser.js"},devDependencies:{"@istanbuljs/nyc-config-typescript":"^1.0.1","@types/chai":"^4.3.20","@types/mocha":"^8.2.3","@types/node":"^14.18.63","@types/sinon":"^9.0.11","@types/ws":"^8.18.1",buffer:"^6.0.3",chai:"^4.5.0",husky:"^4.3.0",mocha:"^11.7.5","mocha-lcov-reporter":"^1.3.0",nyc:"^18.0.0",rimraf:"^3.0.2",sinon:"^9.2.1","terser-webpack-plugin":"^5.3.16","ts-essentials":"^10.0.4","ts-loader":"^9.5.2","ts-node":"^10.9.2",tslint:"^6.1.3",typescript:"^4.9.5",webpack:"^5.75.0","webpack-bundle-analyzer":"^4.10.2","webpack-cli":"^5.0.1"},author:"deepstreamHub GmbH",license:"MIT",bugs:{url:"https://github.com/deepstreamIO/deepstream.io-client-js/issues"},homepage:"http://deepstreamio.github.io",eslintConfig:{extends:"deepstream"},husky:{hooks:{"pre-commit":"npm t && npm run lint && npm run build","pre-publish":"npm t && npm run build"}},nyc:{extends:"@istanbuljs/nyc-config-typescript",include:["src/**/*.ts"],exclude:["src/**/*.spec.ts"],extension:[".ts"],require:["ts-node/register"],reporter:["lcov"]}}});var la=v(_i=>{"use strict";h();Object.defineProperty(_i,"__esModule",{value:!0});_i.Connection=void 0;var _=Q(),gl=Sn(),Ol=gn(),ua=Jt(),Nl=xt(),vl=ca(),Tl=(function(){function r(e,t,i,n){var o=this;this.services=e,this.options=t,this.reconnectTimeout=null,this.authParams=null,this.handlers=new Map,this.authCallback=null,this.resumeCallback=null,this.emitter=n,this.internalEmitter=new Nl.Emitter,this.isInLimbo=!0,this.clientData=null,this.heartbeatIntervalTimeout=null,this.endpoint=null,this.reconnectionAttempt=0,this.limboTimeout=null;var s=!1,a=!0;this.stateMachine=new Ol.StateMachine(this.services.logger,{init:_.CONNECTION_STATE.CLOSED,onStateChanged:function(c,l){c!==l&&(n.emit(_.EVENT.CONNECTION_STATE_CHANGED,c),c===_.CONNECTION_STATE.RECONNECTING?(o.isInLimbo=!0,s=!0,l!==_.CONNECTION_STATE.CLOSED&&(o.internalEmitter.emit(_.EVENT.CONNECTION_LOST),o.limboTimeout=o.services.timerRegistry.add({duration:o.options.offlineBufferTimeout,context:o,callback:function(){o.isInLimbo=!1,o.internalEmitter.emit(_.EVENT.EXIT_LIMBO)}}))):c===_.CONNECTION_STATE.OPEN&&(s||a)&&(a=!1,o.isInLimbo=!1,o.internalEmitter.emit(_.EVENT.CONNECTION_REESTABLISHED),o.services.timerRegistry.remove(o.limboTimeout)))},transitions:[{name:"initialised",from:_.CONNECTION_STATE.CLOSED,to:_.CONNECTION_STATE.INITIALISING},{name:"connected",from:_.CONNECTION_STATE.INITIALISING,to:_.CONNECTION_STATE.AWAITING_CONNECTION},{name:"connected",from:_.CONNECTION_STATE.REDIRECTING,to:_.CONNECTION_STATE.AWAITING_CONNECTION},{name:"connected",from:_.CONNECTION_STATE.RECONNECTING,to:_.CONNECTION_STATE.AWAITING_CONNECTION},{name:"challenge",from:_.CONNECTION_STATE.AWAITING_CONNECTION,to:_.CONNECTION_STATE.CHALLENGING},{name:"redirected",from:_.CONNECTION_STATE.CHALLENGING,to:_.CONNECTION_STATE.REDIRECTING},{name:"challenge-denied",from:_.CONNECTION_STATE.CHALLENGING,to:_.CONNECTION_STATE.CHALLENGE_DENIED},{name:"accepted",from:_.CONNECTION_STATE.CHALLENGING,to:_.CONNECTION_STATE.AWAITING_AUTHENTICATION,handler:this.onAwaitingAuthentication.bind(this)},{name:"authentication-timeout",from:_.CONNECTION_STATE.AWAITING_CONNECTION,to:_.CONNECTION_STATE.AUTHENTICATION_TIMEOUT},{name:"authentication-timeout",from:_.CONNECTION_STATE.AWAITING_AUTHENTICATION,to:_.CONNECTION_STATE.AUTHENTICATION_TIMEOUT},{name:"authenticate",from:_.CONNECTION_STATE.AWAITING_AUTHENTICATION,to:_.CONNECTION_STATE.AUTHENTICATING},{name:"unsuccesful-login",from:_.CONNECTION_STATE.AUTHENTICATING,to:_.CONNECTION_STATE.AWAITING_AUTHENTICATION},{name:"succesful-login",from:_.CONNECTION_STATE.AUTHENTICATING,to:_.CONNECTION_STATE.OPEN},{name:"too-many-auth-attempts",from:_.CONNECTION_STATE.AUTHENTICATING,to:_.CONNECTION_STATE.TOO_MANY_AUTH_ATTEMPTS},{name:"too-many-auth-attempts",from:_.CONNECTION_STATE.AWAITING_AUTHENTICATION,to:_.CONNECTION_STATE.TOO_MANY_AUTH_ATTEMPTS},{name:"authentication-timeout",from:_.CONNECTION_STATE.AWAITING_AUTHENTICATION,to:_.CONNECTION_STATE.AUTHENTICATION_TIMEOUT},{name:"reconnect",from:_.CONNECTION_STATE.RECONNECTING,to:_.CONNECTION_STATE.RECONNECTING},{name:"closed",from:_.CONNECTION_STATE.CLOSING,to:_.CONNECTION_STATE.CLOSED},{name:"offline",from:_.CONNECTION_STATE.PAUSING,to:_.CONNECTION_STATE.OFFLINE},{name:"error",to:_.CONNECTION_STATE.RECONNECTING},{name:"connection-lost",to:_.CONNECTION_STATE.RECONNECTING},{name:"resume",to:_.CONNECTION_STATE.RECONNECTING},{name:"pause",to:_.CONNECTION_STATE.PAUSING},{name:"close",to:_.CONNECTION_STATE.CLOSING}]}),this.stateMachine.transition("initialised"),this.originalUrl=ua.parseUrl(i,this.options.path),this.url=this.originalUrl,t.lazyConnect||this.createEndpoint()}return Object.defineProperty(r.prototype,"isConnected",{get:function(){return this.stateMachine.state===_.CONNECTION_STATE.OPEN},enumerable:!1,configurable:!0}),r.prototype.onLost=function(e){this.internalEmitter.on(_.EVENT.CONNECTION_LOST,e)},r.prototype.removeOnLost=function(e){this.internalEmitter.off(_.EVENT.CONNECTION_LOST,e)},r.prototype.onReestablished=function(e){this.internalEmitter.on(_.EVENT.CONNECTION_REESTABLISHED,e)},r.prototype.removeOnReestablished=function(e){this.internalEmitter.off(_.EVENT.CONNECTION_REESTABLISHED,e)},r.prototype.onExitLimbo=function(e){this.internalEmitter.on(_.EVENT.EXIT_LIMBO,e)},r.prototype.registerHandler=function(e,t){this.handlers.set(e,t)},r.prototype.sendMessage=function(e){if(!this.isOpen()){this.services.logger.error(e,_.EVENT.IS_CLOSED);return}this.endpoint&&this.endpoint.sendParsedMessage(e)},r.prototype.authenticate=function(e,t){if(e&&typeof e!="object"&&typeof e!="function")throw new Error("invalid argument authParamsOrCallback");if(t&&typeof t!="function")throw new Error("invalid argument callback");if(this.stateMachine.state===_.CONNECTION_STATE.CHALLENGE_DENIED||this.stateMachine.state===_.CONNECTION_STATE.TOO_MANY_AUTH_ATTEMPTS||this.stateMachine.state===_.CONNECTION_STATE.AUTHENTICATION_TIMEOUT){this.services.logger.error({topic:_.TOPIC.CONNECTION},_.EVENT.IS_CLOSED);return}e&&(this.authParams=typeof e=="object"?e:{}),e&&typeof e=="function"?this.authCallback=e:t?this.authCallback=t:this.authCallback=function(){},this.stateMachine.state===_.CONNECTION_STATE.AWAITING_AUTHENTICATION&&this.authParams&&this.sendAuthParams(),this.endpoint||this.createEndpoint()},r.prototype.getConnectionState=function(){return this.stateMachine.state},r.prototype.isOpen=function(){var e=this.getConnectionState();return e!==_.CONNECTION_STATE.CLOSED&&e!==_.CONNECTION_STATE.ERROR&&e!==_.CONNECTION_STATE.CLOSING},r.prototype.close=function(){this.services.timerRegistry.remove(this.heartbeatIntervalTimeout),this.sendMessage({topic:_.TOPIC.CONNECTION,action:_.CONNECTION_ACTION.CLOSING}),this.stateMachine.transition("close")},r.prototype.pause=function(){this.stateMachine.transition("pause"),this.services.timerRegistry.remove(this.heartbeatIntervalTimeout),this.endpoint&&this.endpoint.close()},r.prototype.resume=function(e){this.stateMachine.transition("resume"),this.resumeCallback=e,this.tryReconnect()},r.prototype.createEndpoint=function(){this.endpoint=this.services.socketFactory(this.url,this.options.socketOptions,this.options.heartbeatInterval,this.services.logger),this.endpoint.onopened=this.onOpen.bind(this),this.endpoint.onerror=this.onError.bind(this),this.endpoint.onclosed=this.onClose.bind(this),this.endpoint.onparsedmessages=this.onMessages.bind(this)},r.prototype.onOpen=function(){this.clearReconnect(),this.checkHeartBeat(),this.stateMachine.transition("connected"),this.sendMessage({topic:_.TOPIC.CONNECTION,action:_.CONNECTION_ACTION.CHALLENGE,url:this.originalUrl,protocolVersion:"0.1a",sdkVersion:vl.version,sdkType:"javascript"}),this.stateMachine.transition("challenge")},r.prototype.onError=function(e){var t=this;setTimeout(function(){var i;e.code==="ECONNRESET"||e.code==="ECONNREFUSED"?i="Can't connect! Deepstream server unreachable on ".concat(t.originalUrl):i=e,t.services.logger.error({topic:_.TOPIC.CONNECTION},_.EVENT.CONNECTION_ERROR,i)},1),this.services.timerRegistry.remove(this.heartbeatIntervalTimeout),this.stateMachine.transition("error"),this.tryReconnect()},r.prototype.onClose=function(){if(this.services.timerRegistry.remove(this.heartbeatIntervalTimeout),this.stateMachine.state===_.CONNECTION_STATE.REDIRECTING){this.createEndpoint();return}if(!(this.stateMachine.state===_.CONNECTION_STATE.CHALLENGE_DENIED||this.stateMachine.state===_.CONNECTION_STATE.TOO_MANY_AUTH_ATTEMPTS||this.stateMachine.state===_.CONNECTION_STATE.AUTHENTICATION_TIMEOUT)){if(this.stateMachine.state===_.CONNECTION_STATE.CLOSING){this.stateMachine.transition("closed");return}if(this.stateMachine.state===_.CONNECTION_STATE.PAUSING){this.stateMachine.transition("offline");return}this.stateMachine.transition("connection-lost"),this.tryReconnect()}},r.prototype.onMessages=function(e){var t=this;e.forEach(function(i){if(i.parseError){t.services.logger.error({topic:_.TOPIC.PARSER},i.action,i.raw&&i.raw.toString());return}var n=i,o=(0,gl.parseData)(n);if(o!==!0&&t.services.logger.error({topic:_.TOPIC.PARSER},_.PARSER_ACTION.INVALID_MESSAGE,o),n!==null){if(n.topic===_.TOPIC.CONNECTION){t.handleConnectionResponse(n);return}if(n.topic===_.TOPIC.AUTH){t.handleAuthResponse(n);return}var s=t.handlers.get(n.topic);s&&s(n)}})},r.prototype.sendAuthParams=function(){this.stateMachine.transition("authenticate"),this.sendMessage({topic:_.TOPIC.AUTH,action:_.AUTH_ACTION.REQUEST,parsedData:this.authParams})},r.prototype.checkHeartBeat=function(){var e=this.options.heartbeatInterval*2;if(this.endpoint){if(this.endpoint.getTimeSinceLastMessage()>e){this.services.timerRegistry.remove(this.heartbeatIntervalTimeout),this.services.logger.error({topic:_.TOPIC.CONNECTION},_.EVENT.HEARTBEAT_TIMEOUT),this.endpoint.close();return}this.heartbeatIntervalTimeout=this.services.timerRegistry.add({duration:this.options.heartbeatInterval,callback:this.checkHeartBeat,context:this})}},r.prototype.tryReconnect=function(){if(this.reconnectTimeout===null){if(this.reconnectionAttempt<this.options.maxReconnectAttempts){this.stateMachine.transition("reconnect"),this.reconnectTimeout=this.services.timerRegistry.add({callback:this.tryOpen,context:this,duration:Math.min(this.options.maxReconnectInterval,this.options.reconnectIntervalIncrement*this.reconnectionAttempt)}),this.reconnectionAttempt++;return}this.emitter.emit(_.EVENT[_.EVENT.MAX_RECONNECTION_ATTEMPTS_REACHED],this.reconnectionAttempt),this.clearReconnect(),this.close()}},r.prototype.tryOpen=function(){this.stateMachine.state!==_.CONNECTION_STATE.REDIRECTING&&(this.url=this.originalUrl),this.createEndpoint(),this.reconnectTimeout=null},r.prototype.clearReconnect=function(){this.services.timerRegistry.remove(this.reconnectTimeout),this.reconnectTimeout=null,this.reconnectionAttempt=0},r.prototype.handleConnectionResponse=function(e){if(e.action===_.CONNECTION_ACTION.ACCEPT){this.stateMachine.transition("accepted");return}if(e.action===_.CONNECTION_ACTION.REJECT){this.stateMachine.transition("challenge-denied"),this.endpoint&&this.endpoint.close();return}if(e.action===_.CONNECTION_ACTION.REDIRECT){this.url=e.url,this.stateMachine.transition("redirected"),this.endpoint&&this.endpoint.close();return}e.action===_.CONNECTION_ACTION.AUTHENTICATION_TIMEOUT&&(this.stateMachine.transition("authentication-timeout"),this.services.logger.error(e))},r.prototype.handleAuthResponse=function(e){if(e.action===_.AUTH_ACTION.TOO_MANY_AUTH_ATTEMPTS){this.stateMachine.transition("too-many-auth-attempts"),this.services.logger.error(e);return}if(e.action===_.AUTH_ACTION.AUTH_UNSUCCESSFUL){this.stateMachine.transition("unsuccesful-login"),this.onAuthUnSuccessful(e.parsedData);return}if(e.action===_.AUTH_ACTION.AUTH_SUCCESSFUL){this.stateMachine.transition("succesful-login"),this.onAuthSuccessful(e.parsedData);return}},r.prototype.onAwaitingAuthentication=function(){this.authParams&&this.sendAuthParams()},r.prototype.onAuthSuccessful=function(e){this.updateClientData(e),this.resumeCallback&&(this.resumeCallback(),this.resumeCallback=null),this.authCallback!==null&&(this.authCallback(!0,this.clientData),this.authCallback=null)},r.prototype.onAuthUnSuccessful=function(e){var t={reason:e||_.EVENT[_.EVENT.INVALID_AUTHENTICATION_DETAILS]};if(this.resumeCallback&&(this.resumeCallback(t),this.resumeCallback=null),this.authCallback===null){this.emitter.emit(_.EVENT.REAUTHENTICATION_FAILURE,t);return}this.authCallback(!1,t),this.authCallback=null},r.prototype.updateClientData=function(e){var t=e||null;this.clientData===null&&(t===null||Object.keys(t).length===0)||ua.deepEquals(this.clientData,e)||(this.emitter.emit(_.EVENT.CLIENT_DATA_CHANGED,Object.assign({},t)),this.clientData=t)},r})();_i.Connection=Tl});var ha=v(On=>{"use strict";h();Object.defineProperty(On,"__esModule",{value:!0});On.getMessage=Cl;var bl=_n(),Il=pi();function Cl(r,e){e&&!r.isAck&&(r=Object.assign(Object.assign({},r),{isAck:!0})),r.data===void 0&&r.parsedData!==void 0&&(r.data=JSON.stringify(r.parsedData)),r.requestorData&&(r.requestorData=JSON.stringify(r.requestorData));let t=bl.TopicMessage[r.topic].encode(r).finish();return Il.Message.encodeDelimited({topic:r.topic,message:t}).finish()}});var fa=v(Qt=>{"use strict";h();var Si=Qt&&Qt.__assign||function(){return Si=Object.assign||function(r){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r},Si.apply(this,arguments)},ml=Qt&&Qt.__values||function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Qt,"__esModule",{value:!0});Qt.hasMeaningfulSocketOptions=Qt.wireSocket=void 0;var Al=Sn(),Dl=ha(),er=Q(),wl=function(r,e,t,i){i&&e.jsonTransportMode!==!0&&(r.binaryType="arraybuffer");var n=e.jsonTransportMode!==!0?Dl.getMessage:function(c,l){return JSON.stringify(Si(Si({},c),{isAck:l}))},o=n({topic:er.TOPIC.CONNECTION,action:er.CONNECTION_ACTION.PING},!1),s=null,a=-1;return r.onparsedmessage=function(){},r.onmessage=function(c){a=Date.now();var l;e.jsonTransportMode!==!0?l=(0,Al.parse)(i?new E(new Uint8Array(c.data)):c.data):l=[JSON.parse(c.data)],r.onparsedmessages(l)},r.getTimeSinceLastMessage=function(){return a<0?0:Date.now()-a},r.sendParsedMessage=function(c){if(c.topic===er.TOPIC.CONNECTION&&c.action===er.CONNECTION_ACTION.CLOSING){r.onparsedmessages([{topic:er.TOPIC.CONNECTION,action:er.CONNECTION_ACTION.CLOSED}]),r.close();return}c.parsedData&&(c.data=JSON.stringify(c.parsedData)),c.data===void 0&&delete c.data,r.send(n(c,!1))},r.onclosed=null,r.onclose=function(){clearInterval(s),r.onclosed()},r.onopened=null,r.onopen=function(){s=setInterval(function(){try{r.send(o)}catch(c){clearTimeout(s)}},t),r.onopened()},r};Qt.wireSocket=wl;var Pl=function(r){var e,t;if(!r)return!1;try{for(var i=ml(Object.keys(r)),n=i.next();!n.done;n=i.next()){var o=n.value;if(o!=="jsonTransportMode")return!0}}catch(s){e={error:s}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return!1};Qt.hasMeaningfulSocketOptions=Pl});var pa=v((Sp,da)=>{"use strict";h();da.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var ya=v(gi=>{"use strict";h();Object.defineProperty(gi,"__esModule",{value:!0});gi.socketFactory=void 0;var Nn=fa(),Ea=window.WebSocket,Ll=function(r,e,t){if(e===void 0&&(e={jsonTransportMode:!1}),Ea&&!(0,Nn.hasMeaningfulSocketOptions)(e))return(0,Nn.wireSocket)(new Ea(r,[]),e,t,!0);var i=pa();return(0,Nn.wireSocket)(new i(r,e),e,t,!1)};gi.socketFactory=Ll});var vn=v(Oi=>{"use strict";h();Object.defineProperty(Oi,"__esModule",{value:!0});Oi.Listener=void 0;var Ue=Q(),Ul=(function(){function r(e,t){this.topic=e,this.services=t,this.listeners=new Map,this.stopCallbacks=new Map,e===Ue.TOPIC.RECORD?this.actions=Ue.RECORD_ACTION:e===Ue.TOPIC.EVENT&&(this.actions=Ue.EVENT_ACTION),this.services.connection.onLost(this.onConnectionLost.bind(this)),this.services.connection.onReestablished(this.onConnectionReestablished.bind(this))}return r.prototype.listen=function(e,t){if(typeof e!="string"||e.length===0)throw new Error("invalid argument pattern");if(typeof t!="function")throw new Error("invalid argument callback");if(this.listeners.has(e)){this.services.logger.warn({topic:this.topic,action:this.actions.LISTEN,name:e},Ue.EVENT.LISTENER_EXISTS);return}this.listeners.set(e,t),this.sendListen(e)},r.prototype.unlisten=function(e){if(typeof e!="string"||e.length===0)throw new Error("invalid argument pattern");if(!this.listeners.has(e)){this.services.logger.warn({topic:this.topic,action:this.actions.UNLISTEN,name:e},Ue.EVENT.NOT_LISTENING);return}this.listeners.delete(e),this.sendUnlisten(e)},r.prototype.accept=function(e,t){this.services.connection.sendMessage({topic:this.topic,action:this.actions.LISTEN_ACCEPT,name:e,subscription:t})},r.prototype.reject=function(e,t){this.services.connection.sendMessage({topic:this.topic,action:this.actions.LISTEN_REJECT,name:e,subscription:t})},r.prototype.stop=function(e,t){this.stopCallbacks.set(e,t)},r.prototype.handle=function(e){if(e.isAck){this.services.timeoutRegistry.remove(e);return}if(e.action===this.actions.SUBSCRIPTION_FOR_PATTERN_FOUND){var t=this.listeners.get(e.name);t&&t(e.subscription,{accept:this.accept.bind(this,e.name,e.subscription),reject:this.reject.bind(this,e.name,e.subscription),onStop:this.stop.bind(this,e.subscription)});return}if(e.action===this.actions.SUBSCRIPTION_FOR_PATTERN_REMOVED){var i=this.stopCallbacks.get(e.subscription);i&&(i(e.subscription),this.stopCallbacks.delete(e.subscription));return}this.services.logger.error(e,Ue.EVENT.UNSOLICITED_MESSAGE)},r.prototype.onConnectionLost=function(){this.stopCallbacks.forEach(function(e,t){e(t)}),this.stopCallbacks.clear()},r.prototype.onConnectionReestablished=function(){var e=this;this.listeners.forEach(function(t,i){e.sendListen(i)})},r.prototype.sendListen=function(e){var t={topic:this.topic,action:this.actions.LISTEN,name:e};this.services.timeoutRegistry.add({message:t}),this.services.connection.sendMessage(t)},r.prototype.sendUnlisten=function(e){var t={topic:this.topic,action:this.actions.UNLISTEN,name:e};this.services.timeoutRegistry.add({message:t}),this.services.connection.sendMessage(t)},r})();Oi.Listener=Ul});var br=v(he=>{"use strict";h();var Ra=he&&he.__read||function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,o=[],s;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(a){s={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return o},_a=he&&he.__spreadArray||function(r,e,t){if(t||arguments.length===2)for(var i=0,n=e.length,o;i<n;i++)(o||!(i in e))&&(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return r.concat(o||Array.prototype.slice.call(e))};Object.defineProperty(he,"__esModule",{value:!0});he.BulkSubscriptionService=void 0;var Ml=(function(){function r(e,t,i,n,o,s){s===void 0&&(s=(function(){})),this.services=e,this.subscriptionInterval=t,this.topic=i,this.subscribeBulkAction=n,this.unsubscribeBulkAction=o,this.onSubscriptionSent=s,this.subscribeNames=new Set,this.unsubscribeNames=new Set,this.timerRef=-1,this.correlationId=0,this.services.connection.onLost(this.onLost.bind(this))}return r.prototype.subscribe=function(e){if(this.subscriptionInterval>0){this.unsubscribeNames.has(e)?this.unsubscribeNames.delete(e):(this.subscribeNames.add(e),this.registerFlush());return}var t={topic:this.topic,action:this.subscribeBulkAction,names:[e],correlationId:(this.correlationId++).toString()};this.services.connection.sendMessage(t),this.onSubscriptionSent(t)},r.prototype.subscribeList=function(e){e.forEach(this.subscribe.bind(this))},r.prototype.unsubscribe=function(e){if(this.subscriptionInterval>0){this.subscribeNames.has(e)?this.subscribeNames.delete(e):(this.unsubscribeNames.add(e),this.registerFlush());return}var t={topic:this.topic,action:this.unsubscribeBulkAction,names:[e],correlationId:(this.correlationId++).toString()};this.services.connection.sendMessage(t),this.onSubscriptionSent(t)},r.prototype.unsubscribeList=function(e){e.forEach(this.unsubscribe.bind(this))},r.prototype.registerFlush=function(){this.services.timerRegistry.has(this.timerRef)||(this.timerRef=this.services.timerRegistry.add({callback:this.sendMessages,context:this,duration:this.subscriptionInterval}))},r.prototype.sendMessages=function(){if(!this.services.connection.isConnected){this.onLost();return}if(this.subscribeNames.size>0){var e={topic:this.topic,action:this.subscribeBulkAction,names:_a([],Ra(this.subscribeNames),!1),correlationId:(this.correlationId++).toString()};this.services.connection.sendMessage(e),this.onSubscriptionSent(e),this.subscribeNames.clear()}if(this.unsubscribeNames.size>0){var e={topic:this.topic,action:this.unsubscribeBulkAction,names:_a([],Ra(this.unsubscribeNames),!1),correlationId:(this.correlationId++).toString()};this.services.connection.sendMessage(e),this.onSubscriptionSent(e),this.unsubscribeNames.clear()}},r.prototype.onLost=function(){this.correlationId=0,this.services.timerRegistry.remove(this.timerRef),this.subscribeNames.clear(),this.unsubscribeNames.clear()},r})();he.BulkSubscriptionService=Ml});var Sa=v(rr=>{"use strict";h();var Ni=rr&&rr.__assign||function(){return Ni=Object.assign||function(r){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r},Ni.apply(this,arguments)};Object.defineProperty(rr,"__esModule",{value:!0});rr.EventHandler=void 0;var Z=Q(),Bl=vn(),kl=xt(),xl=br(),jl=(function(){function r(e,t,i){this.services=e,this.emitter=new kl.Emitter,this.limboQueue=[],this.bulkSubscription=new xl.BulkSubscriptionService(this.services,t.subscriptionInterval,Z.TOPIC.EVENT,Z.EVENT_ACTION.SUBSCRIBE,Z.EVENT_ACTION.UNSUBSCRIBE,this.onBulkSubscriptionSent.bind(this)),this.listeners=i||new Bl.Listener(Z.TOPIC.EVENT,e),this.services.connection.registerHandler(Z.TOPIC.EVENT,this.handle.bind(this)),this.services.connection.onExitLimbo(this.onExitLimbo.bind(this)),this.services.connection.onReestablished(this.onConnectionReestablished.bind(this))}return r.prototype.eventNames=function(){return this.emitter.eventNames()},r.prototype.subscribe=function(e,t){if(typeof e!="string"||e.length===0)throw new Error("invalid argument name");if(typeof t!="function")throw new Error("invalid argument callback");this.emitter.hasListeners(e)||this.services.connection.isConnected&&this.bulkSubscription.subscribe(e),this.emitter.on(e,t)},r.prototype.unsubscribe=function(e,t){if(!e||typeof e!="string"||e.length===0)throw new Error("invalid argument name");if(t!==void 0&&typeof t!="function")throw new Error("invalid argument callback");if(!this.emitter.hasListeners(e)){this.services.logger.warn({topic:Z.TOPIC.EVENT,action:Z.EVENT_ACTION.NOT_SUBSCRIBED,name:e});return}this.emitter.off(e,t),this.emitter.hasListeners(e)||this.bulkSubscription.unsubscribe(e)},r.prototype.emit=function(e,t){if(typeof e!="string"||e.length===0)throw new Error("invalid argument name");var i={topic:Z.TOPIC.EVENT,action:Z.EVENT_ACTION.EMIT,name:e,parsedData:t};this.services.connection.isConnected?this.services.connection.sendMessage(i):this.services.connection.isInLimbo&&this.limboQueue.push(i),this.emitter.emit(e,t)},r.prototype.listen=function(e,t){this.listeners.listen(e,t)},r.prototype.unlisten=function(e){this.listeners.unlisten(e)},r.prototype.handle=function(e){if(e.isAck){this.services.timeoutRegistry.remove(e);return}if(e.action===Z.EVENT_ACTION.EMIT){e.parsedData!==void 0?this.emitter.emit(e.name,e.parsedData):this.emitter.emit(e.name,void 0);return}if(e.action===Z.EVENT_ACTION.MESSAGE_DENIED){this.services.logger.error({topic:Z.TOPIC.EVENT},Z.EVENT_ACTION.MESSAGE_DENIED),this.services.timeoutRegistry.remove(e),e.originalAction===Z.EVENT_ACTION.SUBSCRIBE&&this.emitter.off(e.name);return}if(e.action===Z.EVENT_ACTION.MULTIPLE_SUBSCRIPTIONS||e.action===Z.EVENT_ACTION.NOT_SUBSCRIBED){this.services.timeoutRegistry.remove(Ni(Ni({},e),{action:Z.EVENT_ACTION.SUBSCRIBE})),this.services.logger.warn(e);return}if(e.action===Z.EVENT_ACTION.SUBSCRIPTION_FOR_PATTERN_FOUND||e.action===Z.EVENT_ACTION.SUBSCRIPTION_FOR_PATTERN_REMOVED){this.listeners.handle(e);return}if(e.action===Z.EVENT_ACTION.INVALID_LISTEN_REGEX){this.services.logger.error(e);return}this.services.logger.error(e,Z.EVENT.UNSOLICITED_MESSAGE)},r.prototype.onConnectionReestablished=function(){this.bulkSubscription.subscribeList(this.emitter.eventNames());for(var e=0;e<this.limboQueue.length;e++)this.services.connection.sendMessage(this.limboQueue[e]);this.limboQueue=[]},r.prototype.onExitLimbo=function(){this.limboQueue=[]},r.prototype.onBulkSubscriptionSent=function(e){this.services.timeoutRegistry.add({message:e})},r})();rr.EventHandler=jl});var Oa=v(vi=>{"use strict";h();Object.defineProperty(vi,"__esModule",{value:!0});vi.RPC=void 0;var ga=Q(),Vl=(function(){function r(e,t,i,n,o,s){this.response=n,this.services=s;var a={topic:ga.TOPIC.RPC,action:ga.RPC_ACTION.REQUEST,correlationId:t,name:e,parsedData:i};this.services.connection.sendMessage(a)}return r.prototype.accept=function(){},r.prototype.respond=function(e){this.response(null,e)},r.prototype.error=function(e){this.response(e)},r})();vi.RPC=Vl});var Na=v(Ti=>{"use strict";h();Object.defineProperty(Ti,"__esModule",{value:!0});Ti.RPCResponse=void 0;var fe=Q(),Fl=(function(){function r(e,t,i){this.name=e.name,this.correlationId=e.correlationId,this.services=i,this.isAccepted=!1,this.isComplete=!1,this.autoAccept=!0,this.services.timerRegistry.requestIdleCallback(this.performAutoAck.bind(this))}return r.prototype.accept=function(){this.isAccepted===!1&&(this.services.connection.sendMessage({topic:fe.TOPIC.RPC,action:fe.RPC_ACTION.ACCEPT,name:this.name,correlationId:this.correlationId}),this.isAccepted=!0)},r.prototype.reject=function(){if(this.isComplete===!0)throw new Error("Rpc ".concat(this.name," already completed"));this.autoAccept=!1,this.isComplete=!0,this.isAccepted=!0,this.services.connection.sendMessage({topic:fe.TOPIC.RPC,action:fe.RPC_ACTION.REJECT,name:this.name,correlationId:this.correlationId})},r.prototype.error=function(e){if(this.isComplete===!0)throw new Error("Rpc ".concat(this.name," already completed"));this.autoAccept=!1,this.isComplete=!0,this.isAccepted=!0,this.services.connection.sendMessage({topic:fe.TOPIC.RPC,action:fe.RPC_ACTION.REQUEST_ERROR,name:this.name,correlationId:this.correlationId,parsedData:e})},r.prototype.send=function(e){if(this.isComplete===!0)throw new Error("Rpc ".concat(this.name," already completed"));this.accept(),this.services.connection.sendMessage({topic:fe.TOPIC.RPC,action:fe.RPC_ACTION.RESPONSE,name:this.name,correlationId:this.correlationId,parsedData:e}),this.isComplete=!0},r.prototype.performAutoAck=function(){this.autoAccept===!0&&this.accept()},r})();Ti.RPCResponse=Fl});var Ia=v(de=>{"use strict";h();var va=de&&de.__read||function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,o=[],s;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(a){s={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return o},Ta=de&&de.__spreadArray||function(r,e,t){if(t||arguments.length===2)for(var i=0,n=e.length,o;i<n;i++)(o||!(i in e))&&(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return r.concat(o||Array.prototype.slice.call(e))};Object.defineProperty(de,"__esModule",{value:!0});de.RPCHandler=void 0;var q=Q(),Tn=Oa(),ba=Na(),Hl=Jt(),Gl=br(),ql=(function(){function r(e,t){this.services=e,this.options=t,this.rpcs=new Map,this.providers=new Map,this.limboQueue=[],this.bulkSubscription=new Gl.BulkSubscriptionService(this.services,t.subscriptionInterval,q.TOPIC.RPC,q.RPC_ACTION.PROVIDE,q.RPC_ACTION.UNPROVIDE,this.onBulkSubscriptionSent.bind(this)),this.services.connection.registerHandler(q.TOPIC.RPC,this.handle.bind(this)),this.services.connection.onReestablished(this.onConnectionReestablished.bind(this)),this.services.connection.onExitLimbo(this.onExitLimbo.bind(this)),this.services.connection.onLost(this.onConnectionLost.bind(this))}return r.prototype.providerNames=function(){return Ta([],va(this.providers.keys()),!1)},r.prototype.provide=function(e,t){if(typeof e!="string"||e.length===0)throw new Error("invalid argument name");if(this.providers.has(e))throw new Error("RPC ".concat(e," already registered"));if(typeof t!="function")throw new Error("invalid argument callback");this.providers.set(e,t),this.services.connection.isConnected&&this.bulkSubscription.subscribe(e)},r.prototype.unprovide=function(e){if(typeof e!="string"||e.length===0)throw new Error("invalid argument name");if(!this.providers.has(e)){this.services.logger.warn({topic:q.TOPIC.RPC,action:q.RPC_ACTION.NOT_PROVIDED,name:e});return}this.providers.delete(e),this.services.connection.isConnected&&this.bulkSubscription.unsubscribe(e)},r.prototype.make=function(e,t,i){var n=this;if(typeof e!="string"||e.length===0)throw new Error("invalid argument name");if(i&&typeof i!="function")throw new Error("invalid argument callback");var o=(0,Hl.getUid)();if(this.services.connection.isConnected){if(i){this.rpcs.set(o,new Tn.RPC(e,o,t,i,this.options,this.services));return}return new Promise(function(s,a){n.rpcs.set(o,new Tn.RPC(e,o,t,function(c,l){return c?a(c):s(l)},n.options,n.services))})}else if(this.services.connection.isInLimbo)if(i)this.limboQueue.push({correlationId:o,name:e,data:t,callback:i});else return new Promise(function(s,a){n.limboQueue.push({correlationId:o,name:e,data:t,callback:function(c,l){return c?a(c):s(l)}})});else if(i)i(q.EVENT.CLIENT_OFFLINE);else return Promise.reject(q.EVENT.CLIENT_OFFLINE)},r.prototype.respondToRpc=function(e){var t=this.providers.get(e.name);t?e.requestorName||e.requestorData?t(e.parsedData,new ba.RPCResponse(e,this.options,this.services),{requestorName:e.requestorName,requestorData:e.requestorData}):t(e.parsedData,new ba.RPCResponse(e,this.options,this.services)):this.services.connection.sendMessage({topic:q.TOPIC.RPC,action:q.RPC_ACTION.REJECT,name:e.name,correlationId:e.correlationId})},r.prototype.handle=function(e){if(e.action===q.RPC_ACTION.REQUEST){this.respondToRpc(e);return}if(e.isAck){this.services.timeoutRegistry.remove(e);return}if(e.action===q.RPC_ACTION.MESSAGE_PERMISSION_ERROR||e.action===q.RPC_ACTION.MESSAGE_DENIED){if(e.originalAction===q.RPC_ACTION.PROVIDE||e.originalAction===q.RPC_ACTION.UNPROVIDE){this.services.timeoutRegistry.remove(e),this.providers.delete(e.name),this.services.logger.error(e);return}if(e.originalAction===q.RPC_ACTION.REQUEST){var t=this.getRPC(e);if(t){t.error(q.RPC_ACTION[e.action]),this.rpcs.delete(e.correlationId);return}}}var i=this.getRPC(e);if(i){if(e.action===q.RPC_ACTION.ACCEPT){i.accept();return}e.action===q.RPC_ACTION.RESPONSE?i.respond(e.parsedData):e.action===q.RPC_ACTION.REQUEST_ERROR?i.error(e.parsedData):(e.action===q.RPC_ACTION.RESPONSE_TIMEOUT||e.action===q.RPC_ACTION.ACCEPT_TIMEOUT||e.action===q.RPC_ACTION.NO_RPC_PROVIDER)&&i.error(q.RPC_ACTION[e.action]),this.rpcs.delete(e.correlationId)}},r.prototype.getRPC=function(e){var t=this.rpcs.get(e.correlationId);return t===void 0&&this.services.logger.error(e,q.EVENT.UNKNOWN_CORRELATION_ID),t},r.prototype.onConnectionReestablished=function(){this.bulkSubscription.subscribeList(Ta([],va(this.providers.keys()),!1));for(var e=0;e<this.limboQueue.length;e++){var t=this.limboQueue[e],i=t.correlationId,n=t.name,o=t.data,s=t.callback;this.rpcs.set(i,new Tn.RPC(n,i,o,s,this.options,this.services))}this.limboQueue=[]},r.prototype.onExitLimbo=function(){for(var e=0;e<this.limboQueue.length;e++)this.limboQueue[e].callback(q.EVENT.CLIENT_OFFLINE);this.limboQueue=[]},r.prototype.onConnectionLost=function(){this.rpcs.forEach(function(e){e.error(q.EVENT.CLIENT_OFFLINE)}),this.rpcs.clear()},r.prototype.onBulkSubscriptionSent=function(e){this.services.timeoutRegistry.add({message:e})},r})();de.RPCHandler=ql});var ma=v(ir=>{"use strict";h();Object.defineProperty(ir,"__esModule",{value:!0});ir.setValue=ir.get=void 0;var bn=Jt(),Wl=/[[\]]/g;function Yl(r,e,t){t===void 0&&(t=!1);for(var i=Ca(e),n=r,o=0;o<i.length;o++){if(n===void 0)return;if(typeof n!="object")throw new Error("invalid data or path");n=n[i[o]]}return t!==!1?bn.deepCopy(n):n}ir.get=Yl;function Kl(r,e,t){if(e===null)return t;var i=Ca(e),n=bn.deepCopy(r),o=bn.deepCopy(t),s=n,a;for(a=0;a<i.length-1;a++){var c=i[a];if(s[c]!==void 0&&s[c]!==null&&typeof s[c]=="object")s=s[c];else if(typeof i[a+1]=="number"){var l=new Array(i[a+1]);l.fill(null),s=s[c]=l}else s=s[c]={}}return t===void 0?delete s[i[a]]:s[i[a]]=o,n}ir.setValue=Kl;function Ca(r){if(r===null)return[];for(var e=[],t=r.split("."),i=0;i<t.length;i++){var n=t[i].trim();if(n.length!==0){var o=n.split(Wl);if(o.length!==0){e.push(o[0]);for(var s=1;s<o.length;s++)o[s].length!==0&&e.push(Number(o[s]))}}}return e}});var Da=v(Ee=>{"use strict";h();var $l=Ee&&Ee.__extends||(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),pe=Ee&&Ee.__assign||function(){return pe=Object.assign||function(r){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r},pe.apply(this,arguments)};Object.defineProperty(Ee,"__esModule",{value:!0});Ee.RecordCore=void 0;var S=Q(),ne=ma(),Aa=xt(),Me=Jt(),Jl=gn(),ft=(function(r){$l(e,r);function e(t,i,n,o,s){var a=r.call(this)||this;if(a.name=t,a.services=i,a.options=n,a.recordServices=o,a.whenComplete=s,a.isReady=!1,a.hasProvider=!1,a.version=null,a.references=new Set,a.emitter=new Aa.Emitter,a.data=Object.create(null),a.responseTimeout=null,a.discardTimeout=null,a.deletedTimeout=null,a.deleteResponse=null,a.pendingWrites=[],a.readyTimer=-1,a.recordReadOnlyMode=a.options.recordReadOnlyMode&&a.options.recordPrefixWriteWhitelist.every(function(c){return!a.name.startsWith(c)}),a.readyCallbacks=[],typeof t!="string"||t.length===0)throw new Error("invalid argument name");return a.onConnectionLost=a.onConnectionLost.bind(a),a.onConnectionReestablished=a.onConnectionReestablished.bind(a),a.stateMachine=new Jl.StateMachine(a.services.logger,{init:"LOADING_OFFLINE",context:a,onStateChanged:a.onStateChanged,transitions:Ql}),a.recordServices.dirtyService.whenLoaded(a,a.onDirtyServiceLoaded),a}return Object.defineProperty(e.prototype,"recordState",{get:function(){return this.stateMachine.state},enumerable:!1,configurable:!0}),e.prototype.addReference=function(t){this.references.size===0&&this.isReady&&(this.services.timeoutRegistry.clear(this.discardTimeout),this.services.timerRegistry.remove(this.readyTimer),this.readyTimer=-1,this.stateMachine.transition(S.RECORD_ACTION.SUBSCRIBE)),this.references.add(t)},e.prototype.removeReference=function(t){var i=this;this.checkDestroyed("discard")||this.whenReadyInternal(t,function(){i.references.delete(t),i.references.size===0&&i.readyTimer===-1&&(i.readyTimer=i.services.timerRegistry.add({duration:i.options.recordDiscardTimeout,callback:i.stateMachine.transition,context:i.stateMachine,data:"UNSUBSCRIBE_FOR_REAL"}),i.stateMachine.transition(S.RECORD_ACTION.UNSUBSCRIBE))})},e.prototype.onDirtyServiceLoaded=function(){var t=this;this.services.storage.get(this.name,function(i,n,o){if(t.services.connection.onReestablished(t.onConnectionReestablished),t.services.connection.onLost(t.onConnectionLost),!t.services.connection.isConnected){if(n===-1){if(t.recordReadOnlyMode)return;t.version=t.options.initialRecordVersion,t.data=Object.create(null),t.recordServices.dirtyService.setDirty(t.name,!0),t.services.storage.set(t.name,t.version,t.data,function(s){})}else t.version=n,t.data=o;t.stateMachine.transition("LOADED");return}n===-1&&!t.recordServices.dirtyService.isDirty(t.name)?t.stateMachine.transition(S.RECORD_ACTION.SUBSCRIBECREATEANDREAD):(t.version=n,t.data=o,t.stateMachine.transition("RESUBSCRIBE"))})},e.prototype.onStateChanged=function(t,i){this.emitter.emit(S.EVENT.RECORD_STATE_CHANGED,t)},e.prototype.whenReady=function(t,i){var n=this;if(i){this.whenReadyInternal(t,function(o){i(o)});return}return new Promise(function(o){return n.whenReadyInternal(t,function(){return o(t)})})},e.prototype.whenReadyInternal=function(t,i){if(this.isReady===!0){i(t);return}this.readyCallbacks.push({callback:i,context:t})},e.prototype.set=function(t){var i=this,n=t.path,o=t.data,s=t.callback;if(!n&&(o===null||typeof o!="object"))throw new Error("invalid arguments, scalar values cannot be set without path");if(!this.checkDestroyed("set")){if(this.recordReadOnlyMode){this.services.logger.error({topic:S.TOPIC.RECORD},S.EVENT.RECORD_READ_ONLY_MODE,"Attempting to set data when in readonly mode, ignoring");return}if(this.isReady===!1){this.pendingWrites.push({path:n,data:o,callback:s});return}var a=this.data,c=(0,ne.setValue)(a,n||null,o);if(Me.deepEquals(a,c)){s&&this.services.timerRegistry.requestIdleCallback(function(){return s(null,i.name)});return}this.applyChange(c),this.services.connection.isConnected?this.sendUpdate(n,o,s):(s&&s(S.EVENT.CLIENT_OFFLINE,this.name),this.saveUpdate())}},e.prototype.setWithAck=function(t){var i=this;if(t.callback){this.set(t);return}return new Promise(function(n,o){t.callback=function(s){return s===null?n():o(s)},i.set(t)})},e.prototype.setMulti=function(t){var i=this,n=t.patches,o=t.callback;if(!this.checkDestroyed("setMulti")){if(!Array.isArray(n)||n.length===0)throw new Error("setMulti requires a non-empty array of patches");for(var s=0;s<n.length;s++)if(!n[s]||typeof n[s].path!="string"||n[s].path.length===0)throw new Error("setMulti patches must each have a non-empty path string");if(this.recordReadOnlyMode){this.services.logger.error({topic:S.TOPIC.RECORD},S.EVENT.RECORD_READ_ONLY_MODE,"Attempting to set data when in readonly mode, ignoring");return}if(this.isReady===!1){for(var s=0;s<n.length-1;s++)this.pendingWrites.push({path:n[s].path,data:n[s].data});var a=n[n.length-1];this.pendingWrites.push({path:a.path,data:a.data,callback:o});return}for(var c=this.data,l=c,s=0;s<n.length;s++)l=(0,ne.setValue)(l,n[s].path,n[s].data);if(Me.deepEquals(c,l)){o&&this.services.timerRegistry.requestIdleCallback(function(){return o(null,i.name)});return}this.applyChange(l),this.services.connection.isConnected?this.sendPatchMulti(n,o):(o&&o(S.EVENT.CLIENT_OFFLINE,this.name),this.saveUpdate())}},e.prototype.setMultiWithAck=function(t){var i=this;if(t.callback){this.setMulti(t);return}return new Promise(function(n,o){t.callback=function(s){return s===null?n():o(s)},i.setMulti(t)})},e.prototype.get=function(t){return(0,ne.get)(this.data,t||null,this.options.recordDeepCopy)},e.prototype.subscribe=function(t,i){var n=this;if(t.path!==void 0&&(typeof t.path!="string"||t.path.length===0))throw new Error("invalid argument path");if(typeof t.callback!="function")throw new Error("invalid argument callback");this.checkDestroyed("subscribe")||(t.triggerNow?this.whenReadyInternal(null,function(){n.emitter.on(t.path||"",t.callback,i),t.callback(n.get(t.path))}):this.emitter.on(t.path||"",t.callback,i))},e.prototype.unsubscribe=function(t,i){if(t.path!==void 0&&(typeof t.path!="string"||t.path.length===0))throw new Error("invalid argument path");if(t.callback!==void 0&&typeof t.callback!="function")throw new Error("invalid argument callback");this.checkDestroyed("unsubscribe")||this.emitter.off(t.path||"",t.callback,i)},e.prototype.delete=function(t){var i=this;if(!this.services.connection.isConnected){if(t){this.services.timerRegistry.requestIdleCallback(function(){t("Deleting while offline is not supported")});return}return Promise.reject("Deleting while offline is not supported")}if(!this.checkDestroyed("delete"))if(this.stateMachine.transition(S.RECORD_ACTION.DELETE),t&&typeof t=="function")this.deleteResponse={callback:t},this.sendDelete();else return new Promise(function(n,o){i.deleteResponse={resolve:n,reject:o},i.sendDelete()})},e.prototype.setMergeStrategy=function(t){this.recordServices.mergeStrategy.setMergeStrategyByName(this.name,t)},e.prototype.saveRecordToOffline=function(t){t===void 0&&(t=function(){}),this.services.storage.set(this.name,this.version,this.data,t)},e.prototype.onSubscribing=function(){this.recordServices.readRegistry.register(this.name,this,this.handleReadResponse),this.responseTimeout=this.services.timeoutRegistry.add({message:{topic:S.TOPIC.RECORD,action:S.RECORD_ACTION.READ_RESPONSE,name:this.name}}),this.recordReadOnlyMode?this.recordServices.bulkSubscriptionService[S.RECORD_ACTION.SUBSCRIBEANDREAD].subscribe(this.name):this.recordServices.bulkSubscriptionService[S.RECORD_ACTION.SUBSCRIBECREATEANDREAD].subscribe(this.name)},e.prototype.onResubscribing=function(){this.services.timerRegistry.remove(this.readyTimer),this.recordServices.headRegistry.register(this.name,this,this.handleHeadResponse),this.responseTimeout=this.services.timeoutRegistry.add({message:{topic:S.TOPIC.RECORD,action:S.RECORD_ACTION.HEAD,name:this.name}}),this.recordServices.bulkSubscriptionService[S.RECORD_ACTION.SUBSCRIBEANDHEAD].subscribe(this.name)},e.prototype.onReady=function(){this.services.timeoutRegistry.clear(this.responseTimeout),this.applyPendingWrites(),this.isReady=!0,this.applyChange(this.data,!0,!1),this.readyCallbacks.forEach(function(t){var i=t.context,n=t.callback;n.call(i,i)}),this.readyCallbacks=[]},e.prototype.applyPendingWrites=function(){for(var t=this,i=[],n=this.data,o=n,s=0;s<this.pendingWrites.length;s++){var a=this.pendingWrites[s],c=a.callback,l=a.path,f=a.data;c&&i.push(c),o=(0,ne.setValue)(o,l||null,f)}this.pendingWrites=[],this.applyChange(o);var p;if(i.length!==0&&(p=function(b){for(var I=0;I<i.length;I++)i[I](b,t.name)}),Me.deepEquals(n,o)){p&&p(null);return}this.services.connection.isConnected?this.sendUpdate(null,o,p):(p&&p(S.EVENT.CLIENT_OFFLINE),this.saveUpdate())},e.prototype.onUnsubscribed=function(){var t=this;if(this.services.connection.isConnected){var i={topic:S.TOPIC.RECORD,action:S.RECORD_ACTION.UNSUBSCRIBE,names:[this.name],correlationId:this.name};this.discardTimeout=this.services.timeoutRegistry.add({message:i}),this.services.connection.sendMessage(i)}this.emit(S.EVENT.RECORD_DISCARDED),this.saveRecordToOffline(function(){return t.destroy()})},e.prototype.onDeleted=function(){this.services.storage.delete(this.name,function(){}),this.recordServices.dirtyService.setDirty(this.name,!1),this.emit(S.EVENT.RECORD_DELETED),this.destroy()},e.prototype.handle=function(t){if(t.action===S.RECORD_ACTION.PATCH||t.action===S.RECORD_ACTION.UPDATE||t.action===S.RECORD_ACTION.ERASE||t.action===S.RECORD_ACTION.PATCH_MULTI){if(this.stateMachine.state==="MERGING")return;this.applyUpdate(t);return}if(t.action===S.RECORD_ACTION.DELETE_SUCCESS){this.services.timeoutRegistry.clear(this.deletedTimeout),this.stateMachine.transition(S.RECORD_ACTION.DELETE_SUCCESS),this.deleteResponse.callback?this.deleteResponse.callback(null):this.deleteResponse.resolve&&this.deleteResponse.resolve();return}if(t.action===S.RECORD_ACTION.DELETED){this.stateMachine.transition(S.RECORD_ACTION.DELETED);return}if(t.action===S.RECORD_ACTION.VERSION_EXISTS){this.recoverRecordFromMessage(t);return}if(t.action===S.RECORD_ACTION.MESSAGE_DENIED||t.action===S.RECORD_ACTION.MESSAGE_PERMISSION_ERROR||t.action===S.RECORD_ACTION.RECORD_UPDATE_ERROR){if(t.originalAction===S.RECORD_ACTION.SUBSCRIBECREATEANDREAD||t.originalAction===S.RECORD_ACTION.SUBSCRIBEANDHEAD||t.originalAction===S.RECORD_ACTION.SUBSCRIBEANDREAD){var i=pe(pe({},t),{originalAction:S.RECORD_ACTION.SUBSCRIBE}),n=pe(pe({},t),{originalAction:t.originalAction===S.RECORD_ACTION.SUBSCRIBECREATEANDREAD?S.RECORD_ACTION.READ_RESPONSE:S.RECORD_ACTION.HEAD_RESPONSE});this.services.timeoutRegistry.remove(i),this.services.timeoutRegistry.remove(n),this.services.logger.error(t)}if(t.isWriteAck){this.recordServices.writeAckService.recieve(t);return}this.emit(S.EVENT.RECORD_ERROR,S.RECORD_ACTION[t.action],S.RECORD_ACTION[t.originalAction]),t.originalAction===S.RECORD_ACTION.DELETE&&(this.deleteResponse.callback?this.deleteResponse.callback(S.RECORD_ACTION[S.RECORD_ACTION.MESSAGE_DENIED]):this.deleteResponse.reject&&this.deleteResponse.reject(S.RECORD_ACTION[S.RECORD_ACTION.MESSAGE_DENIED]));return}if(t.action===S.RECORD_ACTION.SUBSCRIPTION_HAS_PROVIDER||t.action===S.RECORD_ACTION.SUBSCRIPTION_HAS_NO_PROVIDER){this.hasProvider=t.action===S.RECORD_ACTION.SUBSCRIPTION_HAS_PROVIDER,this.emit(S.EVENT.RECORD_HAS_PROVIDER_CHANGED,this.hasProvider);return}if(t.action===S.RECORD_ACTION.CACHE_RETRIEVAL_TIMEOUT||t.action===S.RECORD_ACTION.STORAGE_RETRIEVAL_TIMEOUT){this.services.logger.error(t);return}},e.prototype.handleReadResponse=function(t){if(this.stateMachine.state==="MERGING"){this.recoverRecordFromMessage(t),this.recordServices.dirtyService.setDirty(this.name,!1);return}this.version=t.version,this.data=t.parsedData,this.stateMachine.state!=="READY"&&this.stateMachine.transition(S.RECORD_ACTION.READ_RESPONSE)},e.prototype.handleHeadResponse=function(t){var i=t.version;this.recordServices.dirtyService.isDirty(this.name)?i===-1&&this.version===this.options.initialRecordVersion?(this.stateMachine.transition("SUBSCRIBED"),this.sendCreateUpdate(this.data)):this.version===i+1?(this.stateMachine.transition("RESUBSCRIBED"),this.sendUpdate(null,this.data)):(this.stateMachine.transition("INVALID_VERSION"),i!==-1?(this.sendRead(),this.recordServices.readRegistry.register(this.name,this,this.handleReadResponse)):this.recoverRecordDeletedRemotely()):this.version===i?this.stateMachine.transition("RESUBSCRIBED"):(this.stateMachine.transition("INVALID_VERSION"),i<this.version?this.recoverRecordDeletedRemotely():(this.sendRead(),this.recordServices.readRegistry.register(this.name,this,this.handleReadResponse)))},e.prototype.sendRead=function(){this.services.connection.sendMessage({topic:S.TOPIC.RECORD,action:S.RECORD_ACTION.READ,name:this.name})},e.prototype.saveUpdate=function(){this.recordServices.dirtyService.isDirty(this.name)||(this.version++,this.recordServices.dirtyService.setDirty(this.name,!0)),this.saveRecordToOffline()},e.prototype.sendUpdate=function(t,i,n){if(t===void 0&&(t=null),this.recordReadOnlyMode){this.services.logger.error({topic:S.TOPIC.RECORD},S.EVENT.RECORD_READ_ONLY_MODE,"Attempting to send updated data, ignoring");return}this.recordServices.dirtyService.isDirty(this.name)?this.recordServices.dirtyService.setDirty(this.name,!1):this.version++;var o={topic:S.TOPIC.RECORD,version:this.version,name:this.name};t?i===void 0?Object.assign(o,{action:S.RECORD_ACTION.ERASE,path:t}):Object.assign(o,{action:S.RECORD_ACTION.PATCH,path:t,parsedData:i}):Object.assign(o,{action:S.RECORD_ACTION.UPDATE,parsedData:i}),n?this.recordServices.writeAckService.send(o,n):this.services.connection.sendMessage(o)},e.prototype.sendPatchMulti=function(t,i){if(this.recordReadOnlyMode){this.services.logger.error({topic:S.TOPIC.RECORD},S.EVENT.RECORD_READ_ONLY_MODE,"Attempting to send updated data, ignoring");return}this.recordServices.dirtyService.isDirty(this.name)?this.recordServices.dirtyService.setDirty(this.name,!1):this.version++;var n={topic:S.TOPIC.RECORD,action:S.RECORD_ACTION.PATCH_MULTI,name:this.name,version:this.version,parsedData:t};i?this.recordServices.writeAckService.send(n,i):this.services.connection.sendMessage(n)},e.prototype.sendCreateUpdate=function(t){this.services.connection.sendMessage({name:this.name,topic:S.TOPIC.RECORD,action:S.RECORD_ACTION.CREATEANDUPDATE,version:this.options.initialRecordVersion,parsedData:t}),this.recordServices.dirtyService.setDirty(this.name,!1)},e.prototype.applyUpdate=function(t){var i=t.version,n=t.parsedData;if(this.version===null)this.version=i;else if(this.version+1!==i){this.stateMachine.transition("INVALID_VERSION"),t.action===S.RECORD_ACTION.PATCH||t.action===S.RECORD_ACTION.PATCH_MULTI?(this.sendRead(),this.recordServices.readRegistry.register(this.name,this,this.handleReadResponse)):this.recoverRecordFromMessage(t);return}this.version=i;var o;if(t.action===S.RECORD_ACTION.PATCH)o=(0,ne.setValue)(this.data,t.path,n);else if(t.action===S.RECORD_ACTION.PATCH_MULTI){var s=n;o=this.data;for(var a=0;a<s.length;a++)o=(0,ne.setValue)(o,s[a].path,s[a].data)}else t.action===S.RECORD_ACTION.ERASE?o=(0,ne.setValue)(this.data,t.path,void 0):o=n;this.applyChange(o)},e.prototype.applyChange=function(t,i,n){if(i===void 0&&(i=!1),n===void 0&&(n=!0),!this.stateMachine.inEndState){var o=this.data;this.data=t,this.options.saveUpdatesOffline&&n&&this.saveRecordToOffline();for(var s=this.emitter.eventNames(),a=0;a<s.length;a++){var c=(0,ne.get)(t,s[a],!1),l=(0,ne.get)(o,s[a],!1);(!Me.deepEquals(c,l)||i&&c)&&this.emitter.emit(s[a],this.get(s[a]))}}},e.prototype.sendDelete=function(){var t=this;this.whenReadyInternal(null,function(){t.services.storage.delete(t.name,function(){if(t.services.connection.isConnected){var i={topic:S.TOPIC.RECORD,action:S.RECORD_ACTION.DELETE,name:t.name};t.deletedTimeout=t.services.timeoutRegistry.add({message:i,event:S.EVENT.RECORD_DELETE_TIMEOUT,duration:t.options.recordDeleteTimeout}),t.services.connection.sendMessage(i)}else t.stateMachine.transition(S.RECORD_ACTION.DELETE_SUCCESS)})})},e.prototype.recoverRecordFromMessage=function(t){this.recordServices.mergeStrategy.merge(t,this.version,this.get(),this.onRecordRecovered,this)},e.prototype.recoverRecordDeletedRemotely=function(){this.recordServices.mergeStrategy.merge({name:this.name,version:-1,parsedData:null},this.version,this.get(),this.onRecordRecovered,this)},e.prototype.onRecordRecovered=function(t,i,n){var o=this,s=i.version,a=i.parsedData;if(t){this.services.logger.error({topic:S.TOPIC.RECORD},S.EVENT.RECORD_VERSION_EXISTS),i.correlationId&&this.recordServices.writeAckService.recieve(pe(pe({},i),{reason:t}));return}if(n===null){s===-1?(this.services.storage.delete(this.name,function(){}),this.stateMachine.transition(S.RECORD_ACTION.DELETED)):this.stateMachine.transition(S.RECORD_ACTION.DELETE);return}this.version=s;var c=this.data;if(Me.deepEquals(c,a)){this.stateMachine.state==="MERGING"&&this.stateMachine.transition("MERGED");return}if(this.stateMachine.state!=="MERGING"){this.services.logger.warn({topic:S.TOPIC.RECORD,action:S.RECORD_ACTION.VERSION_EXISTS});return}var l=n;this.stateMachine.transition("MERGED");var f,p=this.pendingWrites.map(function(b){var I=b.callback;return I}).filter(function(b){return b!==void 0});if(p.length!==0&&(f=function(b){p.forEach(function(I){return I(b,o.name)})}),this.pendingWrites=[],Me.deepEquals(n,a)){this.applyChange(n),f&&f(null);return}if(this.recordReadOnlyMode){this.services.logger.error({topic:S.TOPIC.RECORD},S.EVENT.RECORD_READ_ONLY_MODE,"Attempting to set data after merge when in readonly mode, ignoring");return}this.applyChange(l),this.sendUpdate(null,this.data,f)},e.prototype.checkDestroyed=function(t){return this.stateMachine.inEndState?(this.services.logger.error({topic:S.TOPIC.RECORD},S.EVENT.RECORD_ALREADY_DESTROYED,{methodName:t}),!0):!1},e.prototype.destroy=function(){this.services.timerRegistry.remove(this.readyTimer),this.services.timeoutRegistry.clear(this.responseTimeout),this.services.timeoutRegistry.clear(this.deletedTimeout),this.services.timeoutRegistry.clear(this.discardTimeout),this.services.connection.removeOnReestablished(this.onConnectionReestablished),this.services.connection.removeOnLost(this.onConnectionLost),this.emitter.off(),this.isReady=!1,this.whenComplete(this.name)},e.prototype.onConnectionReestablished=function(){this.stateMachine.transition("RESUBSCRIBE")},e.prototype.onConnectionLost=function(){this.saveRecordToOffline(),this.recordServices.dirtyService.setDirty(this.name,!0)},e.prototype.getDebugId=function(){return this.options.debug?Me.getUid():null},e})(Aa.Emitter);Ee.RecordCore=ft;var Ql=[{name:S.RECORD_ACTION.SUBSCRIBECREATEANDREAD,from:"LOADING_OFFLINE",to:"SUBSCRIBING",handler:ft.prototype.onSubscribing},{name:"LOADED",from:"LOADING_OFFLINE",to:"READY",handler:ft.prototype.onReady},{name:S.RECORD_ACTION.READ_RESPONSE,from:"SUBSCRIBING",to:"READY",handler:ft.prototype.onReady},{name:"SUBSCRIBED",from:"RESUBSCRIBING",to:"READY",handler:ft.prototype.onReady},{name:"RESUBSCRIBE",from:"LOADING_OFFLINE",to:"RESUBSCRIBING",handler:ft.prototype.onResubscribing},{name:"RESUBSCRIBE",from:"READY",to:"RESUBSCRIBING",handler:ft.prototype.onResubscribing},{name:"RESUBSCRIBE",from:"RESUBSCRIBING",to:"RESUBSCRIBING",handler:ft.prototype.onResubscribing},{name:"RESUBSCRIBE",from:"SUBSCRIBING",to:"SUBSCRIBING",handler:ft.prototype.onSubscribing},{name:"RESUBSCRIBE",from:"UNSUBSCRIBING",to:"UNSUBSCRIBING"},{name:"RESUBSCRIBED",from:"RESUBSCRIBING",to:"READY",handler:ft.prototype.onReady},{name:"INVALID_VERSION",from:"RESUBSCRIBING",to:"MERGING"},{name:"MERGED",from:"MERGING",to:"READY",handler:ft.prototype.onReady},{name:S.RECORD_ACTION.DELETED,from:"MERGING",to:"DELETED",handler:ft.prototype.onDeleted,isEndState:!0},{name:S.RECORD_ACTION.DELETE,from:"MERGING",to:"DELETING"},{name:S.RECORD_ACTION.DELETE,from:"READY",to:"DELETING"},{name:S.RECORD_ACTION.DELETED,from:"READY",to:"DELETED",handler:ft.prototype.onDeleted,isEndState:!0},{name:S.RECORD_ACTION.DELETED,from:"UNSUBSCRIBE_FOR_REAL",to:"DELETED",handler:ft.prototype.onDeleted,isEndState:!0},{name:S.RECORD_ACTION.DELETED,from:"UNSUBSCRIBING",to:"DELETED",handler:ft.prototype.onDeleted,isEndState:!0},{name:S.RECORD_ACTION.DELETE_SUCCESS,from:"DELETING",to:"DELETED",handler:ft.prototype.onDeleted,isEndState:!0},{name:S.RECORD_ACTION.UNSUBSCRIBE,from:"READY",to:"UNSUBSCRIBING"},{name:S.RECORD_ACTION.SUBSCRIBE,from:"UNSUBSCRIBING",to:"READY"},{name:"UNSUBSCRIBE_FOR_REAL",from:"UNSUBSCRIBING",to:"UNSUBSCRIBED",handler:ft.prototype.onUnsubscribed,isEndState:!0},{name:"INVALID_VERSION",from:"READY",to:"MERGING"}]});var wa=v(nr=>{"use strict";h();var zl=nr&&nr.__extends||(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})();Object.defineProperty(nr,"__esModule",{value:!0});nr.Record=void 0;var bi=Jt(),ye=Q(),Xl=xt(),Zl=(function(r){zl(e,r);function e(t){var i=r.call(this)||this;return i.record=t,i.debugId=i.record.getDebugId(),i.subscriptions=[],i.record.on(ye.EVENT.RECORD_READY,i.emit.bind(i,ye.EVENT.RECORD_READY,i),i),i.record.on(ye.EVENT.RECORD_DISCARDED,i.emit.bind(i,ye.EVENT.RECORD_DISCARDED),i),i.record.on(ye.EVENT.RECORD_DELETED,i.emit.bind(i,ye.EVENT.RECORD_DELETED),i),i.record.on(ye.EVENT.RECORD_ERROR,i.emit.bind(i,ye.EVENT.RECORD_ERROR),i),i.record.addReference(i),i}return Object.defineProperty(e.prototype,"name",{get:function(){return this.record.name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return this.record.isReady},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return this.record.version},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasProvider",{get:function(){return this.record.hasProvider},enumerable:!1,configurable:!0}),e.prototype.whenReady=function(t){if(t)this.record.whenReady(this,t);else return this.record.whenReady(this)},e.prototype.get=function(t){return this.record.get(t)},e.prototype.set=function(t,i,n){return this.record.set(bi.normalizeSetArguments(arguments))},e.prototype.setWithAck=function(t,i,n){return this.record.setWithAck(bi.normalizeSetArguments(arguments))},e.prototype.setMulti=function(t,i){this.record.setMulti({patches:t,callback:i})},e.prototype.setMultiWithAck=function(t,i){return this.record.setMultiWithAck({patches:t,callback:i})},e.prototype.erase=function(t){if(!t)throw new Error("unable to erase record data without path, consider using `delete`");this.set(t,void 0)},e.prototype.eraseWithAck=function(t,i){if(!t)throw new Error("unable to erase record data without path, consider using `delete`");if(i)this.setWithAck(t,void 0,i);else return this.setWithAck(t,void 0)},e.prototype.subscribe=function(t,i,n){var o=bi.normalizeArguments(arguments);this.subscriptions.push(o),this.record.subscribe(o,this)},e.prototype.unsubscribe=function(t,i){var n=bi.normalizeArguments(arguments);this.subscriptions=this.subscriptions.filter(function(o){return!(!n.callback&&o.path===n.path||n.callback&&o.path===n.path&&o.callback===n.callback)}),this.record.unsubscribe(n,this)},e.prototype.discard=function(){for(var t=0;t<this.subscriptions.length;t++)this.record.unsubscribe(this.subscriptions[t],this);this.record.removeReference(this),this.record.removeContext(this)},e.prototype.delete=function(t){return this.record.delete(t)},e.prototype.setMergeStrategy=function(t){this.record.setMergeStrategy(t)},e})(Xl.Emitter);nr.Record=Zl});var Pa=v(sr=>{"use strict";h();var th=sr&&sr.__extends||(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})();Object.defineProperty(sr,"__esModule",{value:!0});sr.AnonymousRecord=void 0;var or=Jt(),eh=xt(),rh=(function(r){th(e,r);function e(t){var i=r.call(this)||this;return i.record=null,i.subscriptions=[],i.getRecordCore=t,i}return Object.defineProperty(e.prototype,"name",{get:function(){return this.record?this.record.name:""},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return this.record?this.record.isReady:!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return this.record?this.record.version:-1},enumerable:!1,configurable:!0}),e.prototype.whenReady=function(t){if(this.record)if(t)this.record.whenReady(this,t);else return this.record.whenReady(this)},e.prototype.setName=function(t,i){if(this.name!==t){this.discard(),this.record=this.getRecordCore(t),this.record.addReference(this);for(var n=0;n<this.subscriptions.length;n++)this.record.subscribe(this.subscriptions[n],this);if(this.emit("nameChanged",t),i)this.record.whenReady(this,i);else return this.record.whenReady(this)}},e.prototype.get=function(t){if(this.record)return this.record.get(t)},e.prototype.set=function(t,i,n){if(this.record)return this.record.set(or.normalizeSetArguments(arguments))},e.prototype.setWithAck=function(t,i,n){if(this.record)return this.record.setWithAck(or.normalizeSetArguments(arguments))},e.prototype.erase=function(t){if(this.record)return this.record.set(or.normalizeSetArguments(arguments))},e.prototype.eraseWithAck=function(t,i){if(this.record)return this.record.setWithAck(or.normalizeSetArguments(arguments))},e.prototype.subscribe=function(t,i,n){var o=or.normalizeArguments(arguments);this.subscriptions.push(o),this.record&&this.record.subscribe(o,this)},e.prototype.unsubscribe=function(t,i){var n=or.normalizeArguments(arguments);this.subscriptions=this.subscriptions.filter(function(o){return!(!n.callback&&o.path===n.path||n.callback&&o.path===n.path&&o.callback===n.callback)}),this.record&&this.record.unsubscribe(n,this)},e.prototype.discard=function(){if(this.record){for(var t=0;t<this.subscriptions.length;t++)this.record.unsubscribe(this.subscriptions[t],this);return this.record.removeReference(this)}},e.prototype.delete=function(t){if(this.record)return this.record.delete(t)},e.prototype.setMergeStrategy=function(t){this.record&&this.record.setMergeStrategy(t)},e})(eh.Emitter);sr.AnonymousRecord=rh});var Ua=v(zt=>{"use strict";h();var ih=zt&&zt.__extends||(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),nh=zt&&zt.__read||function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,o=[],s;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(a){s={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return o},oh=zt&&zt.__spreadArray||function(r,e,t){if(t||arguments.length===2)for(var i=0,n=e.length,o;i<n;i++)(o||!(i in e))&&(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return r.concat(o||Array.prototype.slice.call(e))};Object.defineProperty(zt,"__esModule",{value:!0});zt.List=void 0;var La=Jt(),Be=Q(),sh=xt(),ah=(function(r){ih(e,r);function e(t){var i=r.call(this)||this;return i.record=t,i.debugId=i.record.getDebugId(),i.wrappedFunctions=new Map,i.hasAddListener=!1,i.hasRemoveListener=!1,i.hasMoveListener=!1,i.subscriptions=[],i.originalApplyUpdate=i.record.applyUpdate.bind(i.record),i.record.applyUpdate=i.applyUpdate.bind(i),i.record.addReference(i),i.record.on("discard",function(){return i.emit("discard",i)},i),i.record.on("delete",function(){return i.emit("delete",i)},i),i.record.on("error",function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return i.emit.apply(i,oh(["error"],nh(n),!1))},i),i}return Object.defineProperty(e.prototype,"name",{get:function(){return this.record.name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return this.record.isReady},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return this.record.version},enumerable:!1,configurable:!0}),e.prototype.whenReady=function(t){if(t)this.record.whenReady(this,t);else return this.record.whenReady(this)},e.prototype.discard=function(){this.destroy(),this.record.removeReference(this)},e.prototype.delete=function(t){return this.destroy(),this.record.delete(t)},e.prototype.getEntries=function(){var t=this.record.get();return t instanceof Array?t:[]},e.prototype.isEmpty=function(){return this.getEntries().length===0},e.prototype.setEntriesWithAck=function(t,i){var n=this;if(!i)return new Promise(function(o,s){n.setEntries(t,function(a){a?s(a):o()})});this.setEntries(t,i)},e.prototype.setEntries=function(t,i){var n="entries must be an array of record names",o;if(!(t instanceof Array))throw new Error(n);for(o=0;o<t.length;o++)if(typeof t[o]!="string")throw new Error(n);this.beforeChange(),this.record.set({data:t,callback:i}),this.afterChange()},e.prototype.removeEntry=function(t,i,n){var o=this.record.get(),s=this.hasIndex(i),a=[],c;for(c=0;c<o.length;c++)(o[c]!==t||s&&i!==c)&&a.push(o[c]);this.beforeChange(),this.record.set({data:a,callback:n}),this.afterChange()},e.prototype.addEntry=function(t,i,n){if(typeof t!="string")throw new Error("Entry must be a recordName");var o=this.hasIndex(i),s=this.getEntries();o?s.splice(i,0,t):s.push(t),this.beforeChange(),this.record.set({data:s,callback:n}),this.afterChange()},e.prototype.subscribe=function(t){var i=La.normalizeArguments(arguments);if(i.path)throw new Error("path is not supported for List.subscribe");var n=function(o,s){s(o.getEntries())}.bind(this,this,i.callback);this.wrappedFunctions.set(i.callback,n),i.callback=n,this.subscriptions.push(i),this.record.subscribe(i,this)},e.prototype.unsubscribe=function(t){var i=La.normalizeArguments(arguments);if(i.path)throw new Error("path is not supported for List.unsubscribe");var n=this.wrappedFunctions.get(i.callback);i.callback=n,this.wrappedFunctions.delete(i.callback),this.subscriptions=this.subscriptions.filter(function(o){return!!(i.callback&&i.callback!==o.callback)}),this.record.unsubscribe(i,this)},e.prototype.applyUpdate=function(t){t.parsedData instanceof Array||(t.parsedData=[]),this.beforeChange(),this.originalApplyUpdate(t),this.afterChange()},e.prototype.hasIndex=function(t){var i=!1,n=this.getEntries();if(t!==void 0){if(isNaN(t))throw new Error("Index must be a number");if(t!==n.length&&(t>=n.length||t<0))throw new Error("Index must be within current entries");i=!0}return i},e.prototype.beforeChange=function(){this.hasAddListener=this.hasListeners(Be.EVENT.ENTRY_ADDED_EVENT),this.hasRemoveListener=this.hasListeners(Be.EVENT.ENTRY_REMOVED_EVENT),this.hasMoveListener=this.hasListeners(Be.EVENT.ENTRY_MOVED_EVENT),this.hasAddListener||this.hasRemoveListener||this.hasMoveListener?this.beforeStructure=this.getStructure():this.beforeStructure=null},e.prototype.afterChange=function(){if(this.beforeStructure!==null){var t=this.getStructure(),i=this.beforeStructure,n,o;if(this.hasRemoveListener)for(n in i)for(o=0;o<i[n].length;o++)(t[n]===void 0||t[n][o]===void 0)&&this.emit(Be.EVENT.ENTRY_REMOVED_EVENT,n,i[n][o]);if(this.hasAddListener||this.hasMoveListener)for(n in t)if(i[n]===void 0)for(o=0;o<t[n].length;o++)this.emit(Be.EVENT.ENTRY_ADDED_EVENT,n,t[n][o]);else for(o=0;o<t[n].length;o++)i[n][o]!==t[n][o]&&(i[n][o]===void 0?this.emit(Be.EVENT.ENTRY_ADDED_EVENT,n,t[n][o]):this.emit(Be.EVENT.ENTRY_MOVED_EVENT,n,t[n][o]))}},e.prototype.getStructure=function(){var t={},i,n=this.getEntries();for(i=0;i<n.length;i++)t[n[i]]===void 0?t[n[i]]=[i]:t[n[i]].push(i);return t},e.prototype.destroy=function(){for(var t=0;t<this.subscriptions.length;t++)this.record.unsubscribe(this.subscriptions[t],this);this.wrappedFunctions.clear(),this.record.removeContext(this)},e})(sh.Emitter);zt.List=ah});var Ba=v(Bt=>{"use strict";h();var ch=Bt&&Bt.__extends||(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),In=Bt&&Bt.__assign||function(){return In=Object.assign||function(r){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r},In.apply(this,arguments)},uh=Bt&&Bt.__read||function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,o=[],s;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(a){s={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return o},lh=Bt&&Bt.__spreadArray||function(r,e,t){if(t||arguments.length===2)for(var i=0,n=e.length,o;i<n;i++)(o||!(i in e))&&(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return r.concat(o||Array.prototype.slice.call(e))};Object.defineProperty(Bt,"__esModule",{value:!0});Bt.Dequeue=void 0;var Ma=Jt(),ke=Q(),hh=xt(),fh=(function(r){ch(e,r);function e(t){var i=r.call(this)||this;return i.record=t,i.debugId=i.record.getDebugId(),i.wrappedFunctions=new Map,i.headPath="h",i.emptyHead={p:"",n:""},i.hasAddListener=!1,i.hasRemoveListener=!1,i.hasMoveListener=!1,i.subscriptions=[],i.lastEntries=[],i.lastVersion=0,i.originalApplyUpdate=i.record.applyUpdate.bind(i.record),i.record.applyUpdate=i.applyUpdate.bind(i),i.record.addReference(i),i.record.on("discard",function(){return i.emit("discard",i)},i),i.record.on("delete",function(){return i.emit("delete",i)},i),i.record.on("error",function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return i.emit.apply(i,lh(["error"],uh(n),!1))},i),i}return Object.defineProperty(e.prototype,"name",{get:function(){return this.record.name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return this.record.isReady},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return this.record.version},enumerable:!1,configurable:!0}),e.prototype.whenReady=function(t){if(t)this.record.whenReady(this,t);else return this.record.whenReady(this)},e.prototype.discard=function(){this.destroy(),this.record.removeReference(this)},e.prototype.delete=function(t){return this.destroy(),this.record.delete(t)},e.prototype.getEntries=function(){if(this.version===this.lastVersion)return this.lastEntries;for(var t=this.record.get(this.headPath)||this.emptyHead,i=t.n,n=[];i;){var o=this.record.get(i);n.push(o.d),i=o.n}return this.lastVersion=this.version,this.lastEntries=n,n},e.prototype.isEmpty=function(){var t=this.record.get(this.headPath)||this.emptyHead;return!t.n&&!t.p},e.prototype.setEntriesWithAck=function(t,i){var n=this;if(!i)return new Promise(function(o,s){n.setEntries(t,function(a){a?s(a):o()})});this.setEntries(t,i)},e.prototype.setEntries=function(t,i){var n,o,s="entries must be an array";if(!(t instanceof Array))throw new Error(s);if(t.length===0){this.record.set({data:(n={},n[this.headPath]=this.emptyHead,n),callback:i});return}for(var a={n:"0",p:"".concat(t.length-1)},c={},l=0;l<t.length;l++)c[l]={d:t[l],n:"".concat(l+1),p:"".concat(l-1)},l===0&&(c[l].p=""),l===t.length-1&&(c[l].n="");this.beforeChange(),this.record.set({data:In((o={},o[this.headPath]=a,o),c),callback:i}),this.afterChange()},e.prototype.getLast=function(){var t=this.record.get(this.headPath)||this.emptyHead;if(!t.p)return"";var i=this.record.get(t.p);return i.d},e.prototype.getFirst=function(){var t=this.record.get(this.headPath)||this.emptyHead;if(!t.n)return"";var i=this.record.get(t.n);return i.d},e.prototype.pop=function(){var t=this.getEntries();if(t.length<3){var i=t.pop()||"";return this.setEntries(t),i}var n=this.record.get(this.headPath)||this.emptyHead;if(!n.p)return"";var o=this.record.get(n.p);return this.beforeChange(),this.record.set({path:"".concat(this.headPath,".p"),data:o.p}),o.p&&this.record.set({path:"".concat(o.p,".n"),data:""}),this.record.set({path:n.p,data:void 0}),this.afterChange(),o.d},e.prototype.shift=function(){var t=this.getEntries();if(t.length<3){var i=t.shift()||"";return this.setEntries(t),i}var n=this.record.get(this.headPath)||this.emptyHead;if(!n.n)return"";var o=this.record.get(n.n);return this.beforeChange(),this.record.set({path:"".concat(this.headPath,".n"),data:o.n}),o.n&&this.record.set({path:"".concat(o.n,".p"),data:""}),this.record.set({path:n.n,data:void 0}),this.afterChange(),o.d},e.prototype.getNodeKey=function(){for(var t=Object.keys(this.record.get()).sort(function(o,s){return Number(o)-Number(s)}),i="".concat(t.length),n=1;n<t.length;n++)if(n!==Number(t[n])){i="".concat(n);break}return i},e.prototype.unshift=function(t,i){if(this.isEmpty()){this.setEntries([t],i);return}var n=this.record.get(this.headPath)||this.emptyHead,o=this.getNodeKey(),s=[{path:o,data:{d:t,p:"",n:n.n}}];n.n&&s.push({path:"".concat(n.n,".p"),data:o}),s.push({path:"".concat(this.headPath,".n"),data:o}),this.beforeChange(),this.record.setMulti({patches:s,callback:i}),this.afterChange()},e.prototype.unshiftWithAck=function(t,i){var n=this;if(!i)return new Promise(function(o,s){n.unshift(t,function(a){return a?s(a):o()})});this.unshift(t,i)},e.prototype.push=function(t,i){if(this.isEmpty()){this.setEntries([t],i);return}var n=this.record.get(this.headPath)||this.emptyHead,o=this.getNodeKey(),s=[{path:o,data:{d:t,p:n.p,n:""}}];n.p&&s.push({path:"".concat(n.p,".n"),data:o}),s.push({path:"".concat(this.headPath,".p"),data:o}),this.beforeChange(),this.record.setMulti({patches:s,callback:i}),this.afterChange()},e.prototype.pushWithAck=function(t,i){var n=this;if(!i)return new Promise(function(o,s){n.push(t,function(a){return a?s(a):o()})});this.push(t,i)},e.prototype.removeNode=function(t,i,n){var o=this.record.get(this.headPath)||this.emptyHead,s=[];i.p&&s.push({path:"".concat(i.p,".n"),data:i.n}),i.n&&s.push({path:"".concat(i.n,".p"),data:i.p}),o.p===t&&s.push({path:"".concat(this.headPath,".p"),data:i.p}),o.n===t&&s.push({path:"".concat(this.headPath,".n"),data:i.n}),s.push({path:t,data:void 0}),this.beforeChange(),this.record.setMulti({patches:s,callback:n}),this.afterChange()},e.prototype.removeEntry=function(t,i){for(var n=this.record.get(this.headPath)||this.emptyHead,o=n.n,s=0;o;){var a=this.record.get(o);if(a.d===t){if(!i){this.removeNode(o,a);break}if(i&&i===s){this.removeNode(o,a);break}}++s,o=a.n}if(!o)throw new Error("no entry removed")},e.prototype.insertEntry=function(t,i,n){var o=this.hasIndex(i);if(i===0){this.unshift(t,n);return}if(o){for(var s=this.record.get(this.headPath)||this.emptyHead,a=s.n,c=0;a;){var l=this.record.get(a);if(i===c){var f=this.getNodeKey(),p=[{path:f,data:{d:t,n:a,p:l.p}},{path:"".concat(a,".p"),data:f}];l.p&&p.push({path:"".concat(l.p,".n"),data:f}),this.beforeChange(),this.record.setMulti({patches:p,callback:n}),this.afterChange();break}++c,a=l.n}if(!a)throw new Error("Index out of range")}},e.prototype.subscribe=function(t,i){var n=Ma.normalizeArguments(arguments);if(n.path)if(n.path==="first")n.path="".concat(this.headPath,".n");else if(n.path==="last")n.path="".concat(this.headPath,".p");else throw new Error('Position must be "first" or "last" element');var o=function(s,a){n.path?(n.path==="".concat(s.headPath,".p")&&a(s.getLast()),n.path==="".concat(s.headPath,".n")&&a(s.getFirst())):a(s.getEntries())}.bind(this,this,n.callback);this.wrappedFunctions.set(n.callback,o),n.callback=o,this.subscriptions.push(n),this.record.subscribe(n,this)},e.prototype.unsubscribe=function(t,i){var n=Ma.normalizeArguments(arguments);if(n.path)if(n.path==="first")n.path="".concat(this.headPath,".n");else if(n.path==="last")n.path="".concat(this.headPath,".p");else throw new Error('Position must be "first" or "last" element');var o=this.wrappedFunctions.get(n.callback);n.callback=o,this.wrappedFunctions.delete(n.callback),this.subscriptions=this.subscriptions.filter(function(s){return!(!n.callback&&s.path===n.path||n.callback&&s.path===n.path&&s.callback===n.callback)}),this.record.unsubscribe(n,this)},e.prototype.applyUpdate=function(t){this.beforeChange(),this.originalApplyUpdate(t),this.afterChange()},e.prototype.hasIndex=function(t){var i=!1,n=this.getEntries();if(t!==void 0){if(isNaN(t))throw new Error("Index must be a number");if(t!==n.length&&(t>=n.length||t<0))throw new Error("Index must be within current entries");i=!0}return i},e.prototype.beforeChange=function(){this.hasAddListener=this.hasListeners(ke.EVENT.ENTRY_ADDED_EVENT),this.hasRemoveListener=this.hasListeners(ke.EVENT.ENTRY_REMOVED_EVENT),this.hasMoveListener=this.hasListeners(ke.EVENT.ENTRY_MOVED_EVENT),this.hasAddListener||this.hasRemoveListener||this.hasMoveListener?this.beforeStructure=this.getStructure():this.beforeStructure=null},e.prototype.afterChange=function(){if(this.beforeStructure!==null){var t=this.getStructure(),i=this.beforeStructure,n,o;if(this.hasRemoveListener)for(n in i)for(o=0;o<i[n].length;o++)(t[n]===void 0||t[n][o]===void 0)&&this.emit(ke.EVENT.ENTRY_REMOVED_EVENT,n,i[n][o]);if(this.hasAddListener||this.hasMoveListener)for(n in t)if(i[n]===void 0)for(o=0;o<t[n].length;o++)this.emit(ke.EVENT.ENTRY_ADDED_EVENT,n,t[n][o]);else for(o=0;o<t[n].length;o++)i[n][o]!==t[n][o]&&(i[n][o]===void 0?this.emit(ke.EVENT.ENTRY_ADDED_EVENT,n,t[n][o]):this.emit(ke.EVENT.ENTRY_MOVED_EVENT,n,t[n][o]))}},e.prototype.getStructure=function(){var t={},i,n=this.getEntries();for(i=0;i<n.length;i++)t[n[i]]===void 0?t[n[i]]=[i]:t[n[i]].push(i);return t},e.prototype.destroy=function(){for(var t=0;t<this.subscriptions.length;t++)this.record.unsubscribe(this.subscriptions[t],this);this.wrappedFunctions.clear(),this.record.removeContext(this)},e})(hh.Emitter);Bt.Dequeue=fh});var ka=v(Ci=>{"use strict";h();Object.defineProperty(Ci,"__esModule",{value:!0});Ci.SingleNotifier=void 0;var Ii=Q(),dh=(function(){function r(e,t,i){this.services=e,this.action=t,this.requests=new Map,this.internalRequests=new Map,this.limboQueue=[],this.services.connection.onLost(this.onConnectionLost.bind(this)),this.services.connection.onExitLimbo(this.onExitLimbo.bind(this)),this.services.connection.onReestablished(this.onConnectionReestablished.bind(this))}return r.prototype.request=function(e,t){var i=this.requests.get(e);if(i){i.push(t);return}this.requests.set(e,[t]);var n={topic:Ii.TOPIC.RECORD,action:this.action,name:e};this.services.connection.isConnected?(this.services.connection.sendMessage(n),this.services.timeoutRegistry.add({message:n})):this.services.connection.isInLimbo?this.limboQueue.push(n):(this.requests.delete(e),t(Ii.EVENT.CLIENT_OFFLINE))},r.prototype.register=function(e,t,i){var n=this.internalRequests.get(e);n?n.push({callback:i,context:t}):this.internalRequests.set(e,[{callback:i,context:t}])},r.prototype.recieve=function(e,t,i){this.services.timeoutRegistry.remove(e);var n=e.name,o=this.requests.get(n)||[],s=this.internalRequests.get(n)||[];if(!(!o&&!s)){for(var a=0;a<s.length;a++)s[a].callback.call(s[a].context,e);this.internalRequests.delete(n);for(var a=0;a<o.length;a++)o[a](t,i);this.requests.delete(n)}},r.prototype.onConnectionLost=function(){this.requests.forEach(function(e){e.forEach(function(t){return t(Ii.EVENT.CLIENT_OFFLINE)})}),this.requests.clear()},r.prototype.onExitLimbo=function(){for(var e=0;e<this.limboQueue.length;e++){var t=this.limboQueue[e],i=this.requests.get(t.name);i&&i.forEach(function(n){return n(Ii.EVENT.CLIENT_OFFLINE)})}this.requests.clear(),this.limboQueue=[]},r.prototype.onConnectionReestablished=function(){for(var e=0;e<this.limboQueue.length;e++){var t=this.limboQueue[e];this.services.connection.sendMessage(t),this.services.timeoutRegistry.add({message:t})}},r})();Ci.SingleNotifier=dh});var xa=v(ar=>{"use strict";h();var mi=ar&&ar.__assign||function(){return mi=Object.assign||function(r){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r},mi.apply(this,arguments)};Object.defineProperty(ar,"__esModule",{value:!0});ar.WriteAcknowledgementService=void 0;var Ir=Q(),ph=(function(){function r(e){this.services=e,this.responses=new Map,this.count=1,this.services.connection.onLost(this.onConnectionLost.bind(this))}return r.prototype.send=function(e,t){if(this.services.connection.isConnected===!1){this.services.timerRegistry.requestIdleCallback(t.bind(this,Ir.EVENT.CLIENT_OFFLINE,e.name));return}var i=this.count.toString();this.responses.set(i,t),this.services.connection.sendMessage(mi(mi({},e),{correlationId:i,isWriteAck:!0})),this.count++},r.prototype.recieve=function(e){var t=e.correlationId,i=this.responses.get(t);!i||e.action!==Ir.RECORD_ACTION.WRITE_ACKNOWLEDGEMENT&&!e.isError&&!e.isWriteAck||(e.action===Ir.RECORD_ACTION.VERSION_EXISTS?i(e.reason||"Write failed due to conflict",e.name):e.isError?i(Ir.RECORD_ACTION[e.action],e.name):i(null,e.name),this.responses.delete(t))},r.prototype.onConnectionLost=function(){this.responses.forEach(function(e){return e(Ir.EVENT.CLIENT_OFFLINE)}),this.responses.clear()},r})();ar.WriteAcknowledgementService=ph});var ja=v(Re=>{"use strict";h();var Eh=Re&&Re.__read||function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,o=[],s;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(a){s={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return o},yh=Re&&Re.__spreadArray||function(r,e,t){if(t||arguments.length===2)for(var i=0,n=e.length,o;i<n;i++)(o||!(i in e))&&(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return r.concat(o||Array.prototype.slice.call(e))};Object.defineProperty(Re,"__esModule",{value:!0});Re.DirtyService=void 0;var Rh=(function(){function r(e,t){this.storage=e,this.dirtyStorageName=t,this.dirtyRecords=new Map,this.loadedCallback=[],this.flushTimeout=null,this.loaded=!1,this.save=this.save.bind(this),this.load()}return r.prototype.isDirty=function(e){return this.dirtyRecords.has(e)},r.prototype.setDirty=function(e,t){var i=!0;t?this.dirtyRecords.set(e,!0):i=this.dirtyRecords.delete(e),!this.flushTimeout&&i&&(this.flushTimeout=setTimeout(this.save,1e3))},r.prototype.save=function(){this.storage.set(this.dirtyStorageName,1,yh([],Eh(this.dirtyRecords),!1),function(){}),this.flushTimeout&&clearTimeout(this.flushTimeout),this.flushTimeout=null},r.prototype.whenLoaded=function(e,t){if(this.loaded){t.call(e);return}this.loadedCallback.push({callback:t,context:e})},r.prototype.getAll=function(){return this.dirtyRecords},r.prototype.load=function(){var e=this;this.loaded||this.storage.get(this.dirtyStorageName,function(t,i,n){e.dirtyRecords=n?new Map(n):new Map,e.loaded=!0,e.loadedCallback.forEach(function(o){var s=o.callback,a=o.context;return s.call(a)})})},r})();Re.DirtyService=Rh});var Fa=v(_e=>{"use strict";h();var _h=_e&&_e.__values||function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Sh=_e&&_e.__read||function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,o=[],s;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(a){s={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return o};Object.defineProperty(_e,"__esModule",{value:!0});_e.MergeStrategyService=void 0;var Va=Q(),gh=(function(){function r(e,t){this.services=e,this.defaultStrategy=t,this.strategiesByRecord=new Map,this.strategiesByPattern=new Map}return r.prototype.setMergeStrategyByName=function(e,t){this.strategiesByRecord.set(e,t)},r.prototype.setMergeStrategyByPattern=function(e,t){this.strategiesByPattern.set(e,t)},r.prototype.merge=function(e,t,i,n,o){var s,a,c=e.name,l=this.strategiesByRecord.get(c);if(l){l(i,t,e.parsedData,e.version,function(P,pt){n.call(o,P,e,pt,t,i)});return}try{for(var f=_h(this.strategiesByPattern),p=f.next();!p.done;p=f.next()){var b=Sh(p.value,2),I=b[0],j=b[1];if(I.test(c)){j(i,t,e.parsedData,e.version,function(P,pt){n.call(o,P,e,pt,t,i)});return}}}catch(P){s={error:P}}finally{try{p&&!p.done&&(a=f.return)&&a.call(f)}finally{if(s)throw s.error}}if(this.defaultStrategy){this.defaultStrategy(i,t,e.parsedData,e.version,function(P,pt){n.call(o,P,e,pt,t,i)});return}this.services.logger.error({topic:Va.TOPIC.RECORD},Va.EVENT.RECORD_VERSION_EXISTS,{remoteVersion:e.version,recordName:c})},r})();_e.MergeStrategyService=gh});var qa=v(Xt=>{"use strict";h();var Ha=Xt&&Xt.__read||function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,o=[],s;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(a){s={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return o},Oh=Xt&&Xt.__spreadArray||function(r,e,t){if(t||arguments.length===2)for(var i=0,n=e.length,o;i<n;i++)(o||!(i in e))&&(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return r.concat(o||Array.prototype.slice.call(e))},Nh=Xt&&Xt.__values||function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Xt,"__esModule",{value:!0});Xt.RecordHandler=void 0;var Cn=Jt(),w=Q(),vh=Da(),Th=wa(),bh=Pa(),Ih=Ua(),Ch=Ba(),mh=vn(),Ga=ka(),Ah=xa(),Dh=ja(),wh=Fa(),Ph=br(),Lh=(function(){function r(e,t,i,n){var o;n===void 0&&(n=new mh.Listener(w.TOPIC.RECORD,e)),this.services=e,this.options=t,this.listener=n,this.recordCores=new Map,this.notifyCallbacks=new Map,this.recordServices=i||{bulkSubscriptionService:(o={},o[w.RECORD_ACTION.SUBSCRIBECREATEANDREAD]=this.getBulkSubscriptionService(w.RECORD_ACTION.SUBSCRIBECREATEANDREAD),o[w.RECORD_ACTION.SUBSCRIBEANDREAD]=this.getBulkSubscriptionService(w.RECORD_ACTION.SUBSCRIBEANDREAD),o[w.RECORD_ACTION.SUBSCRIBEANDHEAD]=this.getBulkSubscriptionService(w.RECORD_ACTION.SUBSCRIBEANDHEAD),o),writeAckService:new Ah.WriteAcknowledgementService(e),readRegistry:new Ga.SingleNotifier(e,w.RECORD_ACTION.READ,t.recordReadTimeout),headRegistry:new Ga.SingleNotifier(e,w.RECORD_ACTION.HEAD,t.recordReadTimeout),dirtyService:new Dh.DirtyService(e.storage,t.dirtyStorageName),mergeStrategy:new wh.MergeStrategyService(e,t.mergeStrategy)},this.dirtyService=this.recordServices.dirtyService,this.sendUpdatedData=this.sendUpdatedData.bind(this),this.onMergeCompleted=this.onMergeCompleted.bind(this),this.getRecordCore=this.getRecordCore.bind(this),this.removeRecord=this.removeRecord.bind(this),this.onBulkSubscriptionSent=this.onBulkSubscriptionSent.bind(this),this.services.connection.registerHandler(w.TOPIC.RECORD,this.handle.bind(this)),this.services.connection.onReestablished(this.syncDirtyRecords.bind(this)),this.services.connection.isConnected&&this.syncDirtyRecords()}return r.prototype.names=function(){return Oh([],Ha(this.recordCores.keys()),!1)},r.prototype.setMergeStrategy=function(e,t){if(typeof t=="function")this.recordServices.mergeStrategy.setMergeStrategyByName(e,t);else throw new Error("Invalid merge strategy: Must be a Function")},r.prototype.setMergeStrategyRegExp=function(e,t){if(typeof t=="function")this.recordServices.mergeStrategy.setMergeStrategyByPattern(e,t);else throw new Error("Invalid merge strategy: Must be a Function")},r.prototype.getRecord=function(e){return new Th.Record(this.getRecordCore(e))},r.prototype.getList=function(e){return new Ih.List(this.getRecordCore(e))},r.prototype.getDq=function(e){return new Ch.Dequeue(this.getRecordCore(e))},r.prototype.getAnonymousRecord=function(){return new bh.AnonymousRecord(this.getRecordCore)},r.prototype.listen=function(e,t){this.listener.listen(e,t)},r.prototype.unlisten=function(e){this.listener.unlisten(e)},r.prototype.snapshot=function(e,t){var i=this;if(typeof e!="string"||e.length===0)throw new Error("invalid argument: name");if(t!==void 0&&typeof t!="function")throw new Error("invalid argument: callback");var n=this.recordCores.get(e);if(n){if(t)n.whenReady(null,function(){t(null,n.get())});else return new Promise(function(o,s){n.whenReady(null,function(){o(n.get())})});return}if(t)this.recordServices.readRegistry.request(e,t);else return new Promise(function(o,s){i.recordServices.readRegistry.request(e,function(a,c){return a?s(a):o(c)})})},r.prototype.has=function(e,t){var i=this;if(typeof e!="string"||e.length===0)throw new Error("invalid argument: name");if(t!==void 0&&typeof t!="function")throw new Error("invalid argument: callback");var n;if(!t)return new Promise(function(o,s){n=function(a,c){return a?s(a):o(c!==-1)},i.head(e,n)});n=function(o,s){return o?t(o,null):t(null,s!==-1)},this.head(e,n)},r.prototype.head=function(e,t){var i=this;if(typeof e!="string"||e.length===0)throw new Error("invalid argument: name");if(t!==void 0&&typeof t!="function")throw new Error("invalid argument: callback");var n=this.recordCores.get(e);if(n){if(t)n.whenReady(null,function(){t(null,n.version)});else return new Promise(function(o,s){n.whenReady(null,function(){o(n.version)})});return}if(t)this.recordServices.headRegistry.request(e,t);else return new Promise(function(o,s){i.recordServices.headRegistry.request(e,function(a,c){return a?s(a):o(c)})})},r.prototype.setDataWithAck=function(e){for(var t=this,i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];var o=Cn.normalizeSetArguments(arguments,1);if(!o.callback)return new Promise(function(s,a){o.callback=function(c){return c===null?s():a(c)},t.sendSetData(e,-1,o)});this.sendSetData(e,-1,o)},r.prototype.setData=function(e){var t=Cn.normalizeSetArguments(arguments,1);this.sendSetData(e,-1,t)},r.prototype.delete=function(e,t){throw Error("Delete is not yet supported without use of a Record")},r.prototype.notify=function(e,t){var i=this;if(!this.services.connection.isConnected){if(t){t(w.EVENT.CLIENT_OFFLINE);return}return new Promise(function(o,s){return s(w.EVENT.CLIENT_OFFLINE)})}var n=Cn.getUid();if(this.services.connection.sendMessage({topic:w.TOPIC.RECORD,action:w.RECORD_ACTION.NOTIFY,names:e,correlationId:n}),t)this.notifyCallbacks.set(n,t);else return new Promise(function(o,s){i.notifyCallbacks.set(n,function(a){return a?s(a):o()})})},r.prototype.sendSetData=function(e,t,i){var n=i.path,o=i.data,s=i.callback;if(!e||typeof e!="string"||e.length===0)throw new Error("invalid argument: recordName must be an non empty string");if(!n&&(o===null||typeof o!="object"))throw new Error("invalid argument: data must be an object when no path is provided");var a=this.recordCores.get(e);if(a){a.set({path:n,data:o,callback:s});return}var c;n?o===void 0?c=w.RECORD_ACTION.ERASE:c=w.RECORD_ACTION.CREATEANDPATCH:c=w.RECORD_ACTION.CREATEANDUPDATE;var l={topic:w.TOPIC.RECORD,action:c,name:e,path:n,version:t,parsedData:o};s?this.recordServices.writeAckService.send(l,s):this.services.connection.sendMessage(l)},r.prototype.saveToOfflineStorage=function(){this.recordCores.forEach(function(e){return e.saveRecordToOffline()})},r.prototype.clearOfflineStorage=function(e){var t=this;if(e)this.services.storage.reset(e);else return new Promise(function(i,n){t.services.storage.reset(function(o){return o?n(o):i()})})},r.prototype.handle=function(e){var t=this;if(e.action===w.RECORD_ACTION.NOTIFY&&e.isAck||e.isError&&e.action===w.RECORD_ACTION.RECORD_NOTIFY_ERROR){var i=this.notifyCallbacks.get(e.correlationId);i?(i(e.data||null),this.notifyCallbacks.delete(e.correlationId)):this.services.logger.error(e,w.RECORD_ACTION.NOTIFY);return}if(e.isAck){this.services.timeoutRegistry.remove(e);return}if(e.action===w.RECORD_ACTION.SUBSCRIPTION_FOR_PATTERN_FOUND||e.action===w.RECORD_ACTION.SUBSCRIPTION_FOR_PATTERN_REMOVED||e.action===w.RECORD_ACTION.LISTEN||e.action===w.RECORD_ACTION.UNLISTEN){this.listener.handle(e);return}if(e.isWriteAck&&e.action!==w.RECORD_ACTION.VERSION_EXISTS){this.recordServices.writeAckService.recieve(e);return}if(e.action===w.RECORD_ACTION.READ_RESPONSE||e.originalAction===w.RECORD_ACTION.READ){e.isError?this.recordServices.readRegistry.recieve(e,w.RECORD_ACTION[e.action]):this.recordServices.readRegistry.recieve(e,null,e.parsedData);return}if(e.action===w.RECORD_ACTION.HEAD_RESPONSE_BULK){Object.keys(e.versions).forEach(function(o){t.recordServices.headRegistry.recieve({topic:w.TOPIC.RECORD,action:w.RECORD_ACTION.HEAD_RESPONSE,originalAction:w.RECORD_ACTION.HEAD,name:o,version:e.versions[o]},null,e.versions[o])});return}if(e.action===w.RECORD_ACTION.HEAD_RESPONSE||e.originalAction===w.RECORD_ACTION.HEAD){e.isError?this.recordServices.headRegistry.recieve(e,w.RECORD_ACTION[e.action]):this.recordServices.headRegistry.recieve(e,null,e.version);return}var n=this.recordCores.get(e.name);if(n){n.handle(e);return}if(e.action!==w.RECORD_ACTION.VERSION_EXISTS&&!(e.action===w.RECORD_ACTION.SUBSCRIPTION_HAS_PROVIDER||e.action===w.RECORD_ACTION.SUBSCRIPTION_HAS_NO_PROVIDER)){if(e.isError){this.services.logger.error(e);return}this.services.logger.error(e,w.EVENT.UNSOLICITED_MESSAGE)}},r.prototype.removeRecord=function(e){this.recordCores.delete(e)},r.prototype.getRecordCore=function(e){var t=this.recordCores.get(e);return t||(t=new vh.RecordCore(e,this.services,this.options,this.recordServices,this.removeRecord),this.recordCores.set(e,t)),t},r.prototype.syncDirtyRecords=function(){this.dirtyService.whenLoaded(this,this._syncDirtyRecords)},r.prototype._syncDirtyRecords=function(){var e,t,i=this.dirtyService.getAll();try{for(var n=Nh(i),o=n.next();!o.done;o=n.next()){var s=Ha(o.value,1),a=s[0],c=this.recordCores.get(a);c&&c.references.size>0||this.services.storage.get(a,this.sendUpdatedData)}}catch(l){e={error:l}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},r.prototype.sendUpdatedData=function(e,t,i){var n=this;if(t===-1){this.services.logger.warn({topic:w.TOPIC.RECORD},w.RECORD_ACTION.DELETE,"Deleted record while offline, can't resolve");return}var o=function(s,a){s?n.recordServices.readRegistry.register(a,n,function(c){n.recordServices.mergeStrategy.merge(c,t,i,n.onMergeCompleted,n)}):n.dirtyService.setDirty(a,!1)};this.sendSetData(e,t,{data:i,callback:o})},r.prototype.onMergeCompleted=function(e,t,i){var n=t.name,o=t.version;this.sendSetData(n,o+1,{data:i})},r.prototype.getBulkSubscriptionService=function(e){return new Ph.BulkSubscriptionService(this.services,this.options.subscriptionInterval,w.TOPIC.RECORD,e,w.RECORD_ACTION.UNSUBSCRIBE,this.onBulkSubscriptionSent)},r.prototype.onBulkSubscriptionSent=function(e){e.names||this.services.timeoutRegistry.add({message:e})},r})();Xt.RecordHandler=Lh});var Wa=v(Di=>{"use strict";h();Object.defineProperty(Di,"__esModule",{value:!0});Di.PresenceHandler=void 0;var Y=Q(),Ai=xt(),Uh=br(),Ft="OE";function Mh(r){var e=null,t=null;if(r.length===1)if(Array.isArray(r[0]))e=r[0];else{if(typeof r[0]!="function")throw new Error('invalid argument: "callback"');t=r[0]}else if(r.length===2&&(e=r[0],t=r[1],!Array.isArray(e)||typeof t!="function"))throw new Error('invalid argument: "users" or "callback"');return{users:e,callback:t}}var Bh=(function(){function r(e,t){this.services=e,this.globalSubscriptionEmitter=new Ai.Emitter,this.subscriptionEmitter=new Ai.Emitter,this.queryEmitter=new Ai.Emitter,this.queryAllEmitter=new Ai.Emitter,this.counter=0,this.limboQueue=[],this.bulkSubscription=new Uh.BulkSubscriptionService(this.services,t.subscriptionInterval,Y.TOPIC.PRESENCE,Y.PRESENCE_ACTION.SUBSCRIBE,Y.PRESENCE_ACTION.UNSUBSCRIBE,this.onBulkSubscriptionSent.bind(this)),this.services.connection.registerHandler(Y.TOPIC.PRESENCE,this.handle.bind(this)),this.services.connection.onExitLimbo(this.onExitLimbo.bind(this)),this.services.connection.onLost(this.onExitLimbo.bind(this)),this.services.connection.onReestablished(this.onConnectionReestablished.bind(this))}return r.prototype.subscribe=function(e,t){if(typeof e=="string"&&e.length>0&&typeof t=="function"){var i=e;this.subscriptionEmitter.hasListeners(i)||this.bulkSubscription.subscribe(i),this.subscriptionEmitter.on(i,t);return}if(typeof e=="function"&&typeof t=="undefined"){this.globalSubscriptionEmitter.hasListeners(Ft)||this.subscribeToAllChanges(),this.globalSubscriptionEmitter.on(Ft,e);return}throw new Error('invalid arguments: "user" or "callback"')},r.prototype.unsubscribe=function(e,t){if(e&&typeof e=="string"&&e.length>0){var i=e;if(t){if(typeof t!="function")throw new Error('invalid argument: "callback"');this.subscriptionEmitter.off(i,t)}else this.subscriptionEmitter.off(i);if(!this.subscriptionEmitter.hasListeners(i)){this.bulkSubscription.unsubscribe(i);return}}if(e&&typeof e=="function"){t=e,this.globalSubscriptionEmitter.off(Ft,t),this.globalSubscriptionEmitter.hasListeners(Ft)||this.unsubscribeToAllChanges();return}if(typeof e=="undefined"&&typeof t=="undefined"){this.subscriptionEmitter.off(),this.globalSubscriptionEmitter.off(),this.bulkSubscription.unsubscribeList(this.subscriptionEmitter.eventNames()),this.unsubscribeToAllChanges();return}throw new Error('invalid argument: "user" or "callback"')},r.prototype.getAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=Mh(e),n=i.callback,o=i.users,s,a,c;if(o){var l=(this.counter++).toString();s={topic:Y.TOPIC.PRESENCE,action:Y.PRESENCE_ACTION.QUERY,correlationId:l,names:o},a=this.queryEmitter,c=l}else s={topic:Y.TOPIC.PRESENCE,action:Y.PRESENCE_ACTION.QUERY_ALL},a=this.queryAllEmitter,c=Ft;if(this.services.connection.isConnected?this.sendQuery(s):this.services.connection.isInLimbo?this.limboQueue.push(s):this.services.timerRegistry.requestIdleCallback(function(){a.emit(c,Y.EVENT.CLIENT_OFFLINE)}),n){a.once(c,n);return}return new Promise(function(f,p){a.once(c,function(b,I){return b?p(b):f(I)})})},r.prototype.handle=function(e){if(e.isAck){this.services.timeoutRegistry.remove(e);return}if(e.action===Y.PRESENCE_ACTION.QUERY_ALL_RESPONSE){this.queryAllEmitter.emit(Ft,null,e.names),this.services.timeoutRegistry.remove(e);return}if(e.action===Y.PRESENCE_ACTION.QUERY_RESPONSE){this.queryEmitter.emit(e.correlationId,null,e.parsedData),this.services.timeoutRegistry.remove(e);return}if(e.action===Y.PRESENCE_ACTION.PRESENCE_JOIN){this.subscriptionEmitter.emit(e.name,e.name,!0);return}if(e.action===Y.PRESENCE_ACTION.PRESENCE_JOIN_ALL){this.globalSubscriptionEmitter.emit(Ft,e.name,!0);return}if(e.action===Y.PRESENCE_ACTION.PRESENCE_LEAVE){this.subscriptionEmitter.emit(e.name,e.name,!1);return}if(e.action===Y.PRESENCE_ACTION.PRESENCE_LEAVE_ALL){this.globalSubscriptionEmitter.emit(Ft,e.name,!1);return}if(e.isError){this.services.timeoutRegistry.remove(e),e.originalAction===Y.PRESENCE_ACTION.QUERY?this.queryEmitter.emit(e.correlationId,Y.PRESENCE_ACTION[e.action]):e.originalAction===Y.PRESENCE_ACTION.QUERY_ALL?this.queryAllEmitter.emit(Ft,Y.PRESENCE_ACTION[e.action]):this.services.logger.error(e);return}this.services.logger.error(e,Y.EVENT.UNSOLICITED_MESSAGE)},r.prototype.sendQuery=function(e){this.services.connection.sendMessage(e),this.services.timeoutRegistry.add({message:e})},r.prototype.subscribeToAllChanges=function(){if(this.services.connection.isConnected){var e={topic:Y.TOPIC.PRESENCE,action:Y.PRESENCE_ACTION.SUBSCRIBE_ALL};this.services.timeoutRegistry.add({message:e}),this.services.connection.sendMessage(e)}},r.prototype.unsubscribeToAllChanges=function(){if(this.services.connection.isConnected){var e={topic:Y.TOPIC.PRESENCE,action:Y.PRESENCE_ACTION.UNSUBSCRIBE_ALL};this.services.timeoutRegistry.add({message:e}),this.services.connection.sendMessage(e)}},r.prototype.onConnectionReestablished=function(){var e=this.subscriptionEmitter.eventNames();e.length>0&&this.bulkSubscription.subscribeList(e);var t=this.globalSubscriptionEmitter.hasListeners(Ft);t&&this.subscribeToAllChanges();for(var i=0;i<this.limboQueue.length;i++)this.sendQuery(this.limboQueue[i]);this.limboQueue=[]},r.prototype.onExitLimbo=function(){var e=this;this.queryEmitter.eventNames().forEach(function(t){e.queryEmitter.emit(t,Y.EVENT.CLIENT_OFFLINE)}),this.queryAllEmitter.emit(Ft,Y.EVENT.CLIENT_OFFLINE),this.limboQueue=[],this.queryAllEmitter.off(),this.queryEmitter.off()},r.prototype.onBulkSubscriptionSent=function(e){this.services.timeoutRegistry.add({message:e})},r})();Di.PresenceHandler=Bh});var Ya=v(ge=>{"use strict";h();var kh=ge&&ge.__values||function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},xh=ge&&ge.__read||function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,o=[],s;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(a){s={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return o};Object.defineProperty(ge,"__esModule",{value:!0});ge.IndexdbStorage=void 0;var Se;(function(r){r[r.GET=0]="GET",r[r.SET=1]="SET",r[r.DELETE=2]="DELETE"})(Se||(Se={}));var jh=(function(){function r(e){var t=this;if(this.options=e,this.isReady=!1,this.queuedRequests=new Map,this.flushTimeout=null,typeof indexedDB=="undefined"||indexedDB===null)throw new Error("IndexDB currently not supported when deepstream in node");this.flush=this.flush.bind(this);var i=e.indexdb,n=i.objectStoreNames,o=i.storageDatabaseName,s=i.defaultObjectStoreName,a=i.primaryKey;n.includes(s)||n.push(s);var c=e.indexdb.dbVersion;if(e.indexdb.autoVersion){var l=localStorage.getItem("deepstream-db/".concat(o));if(l){var f=JSON.parse(l),p=f.objectStoreNames.length!==n.length||f.objectStoreNames.some(function(I){return!n.includes(I)});p?c=f.dbVersion+1:c=f.dbVersion}else c=1}var b=indexedDB.open(o,c);b.onerror=function(I){console.error("Error opening index ".concat(o),I)},b.onsuccess=function(I){t.db=I.target.result,t.onReady()},b.onupgradeneeded=function(){var I=b.result;n.forEach(function(P){I.objectStoreNames.contains(P)||I.createObjectStore(P,{keyPath:a})});for(var j=0;j<I.objectStoreNames.length;j++)n.includes(I.objectStoreNames[j])===!1&&I.deleteObjectStore(I.objectStoreNames[j]);e.indexdb.autoVersion&&localStorage.setItem("deepstream-db/".concat(o),JSON.stringify({dbVersion:c,objectStoreNames:n}))}}return r.prototype.get=function(e,t){var i=this.options.ignorePrefixes.some(function(n){return e.startsWith(n)});if(i){t(e,-1,null);return}this.insertRequest({recordName:e,callback:t,operation:Se.GET})},r.prototype.set=function(e,t,i,n){var o=this.options.ignorePrefixes.some(function(s){return e.startsWith(s)});if(o){n(null,e);return}this.insertRequest({recordName:e,version:t,callback:n,data:i,operation:Se.SET})},r.prototype.delete=function(e,t){var i=this.options.ignorePrefixes.some(function(n){return e.startsWith(n)});if(i){t(null,e);return}this.insertRequest({recordName:e,callback:t,operation:Se.DELETE})},r.prototype.reset=function(e){var t=this;this.db&&(this.db.close(),this.db=null);var i=indexedDB.deleteDatabase(this.options.indexdb.storageDatabaseName);i.onblocked=function(){return setTimeout(function(){return t.reset(e)},1e3)},i.onsuccess=function(){return e(null)},i.onerror=function(n){var o="Error deleting database ".concat(t.options.indexdb.storageDatabaseName);console.error(o,n),e(o)}},r.prototype.registerFlush=function(){this.isReady&&!this.flushTimeout&&(this.flushTimeout=setTimeout(this.flush,this.options.indexdb.flushTimeout))},r.prototype.flush=function(){var e,t,i=this,n=this.db.transaction(this.queuedRequests.keys(),"readwrite"),o=function(p,b){var I=n.objectStore(p);b.forEach(function(j){var P,pt=j.operation,Rt=j.recordName,ee=j.version,ht=j.data,g=j.callback;switch(pt){case Se.GET:{var T=I.get(Rt);T.onerror=function(D){throw new Error("Requesting record ".concat(Rt," failed"))},T.onsuccess=function(){T.result?g(Rt,T.result.version,T.result.data):g(Rt,-1,null)};break}case Se.DELETE:{var A=I.delete(Rt);A.onsuccess=function(){return g(null)},A.onerror=function(D){return g(D.errorCode)};break}case Se.SET:{var A=I.put((P={},P[i.options.indexdb.primaryKey]=Rt,P.version=ee,P.data=ht,P));A.onsuccess=function(){return g(null)},A.onerror=function(x){return g(x.errorCode)};break}}})};try{for(var s=kh(this.queuedRequests),a=s.next();!a.done;a=s.next()){var c=xh(a.value,2),l=c[0],f=c[1];o(l,f)}}catch(p){e={error:p}}finally{try{a&&!a.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}this.queuedRequests.clear(),this.flushTimeout=null},r.prototype.onReady=function(){this.isReady=!0,this.flush()},r.prototype.insertRequest=function(e){var t=e.recordName.indexOf("/"),i;t>-1?(i=e.recordName.substring(0,t),this.options.indexdb.objectStoreNames.indexOf(i)===-1?(console.error("Object store names need to be predefined, missing ".concat(i,". Using default objectStore instead.")),i=this.options.indexdb.defaultObjectStoreName):e.recordName=e.recordName.substring(t+1,e.recordName.length)):i=this.options.indexdb.defaultObjectStoreName;var n=this.queuedRequests.get(i);n===void 0?this.queuedRequests.set(i,[e]):n.push(e),this.registerFlush()},r})();ge.IndexdbStorage=jh});var Ka=v(wi=>{"use strict";h();Object.defineProperty(wi,"__esModule",{value:!0});wi.LocalstorageStorage=void 0;var Vh=(function(){function r(e){if(this.options=e,this.isReady=!0,typeof localStorage=="undefined"||localStorage===null)try{var t=Uc("node-localstorage").LocalStorage;this.storage=new t(e.localstorage.nodeStoragePath,e.localstorage.nodeStorageSize*1024*1024)}catch(i){throw new Error("Attempting to use localStorage outside of browser without node-localstorage polyfill")}else this.storage=localStorage}return r.prototype.get=function(e,t){var i=this.options.ignorePrefixes.some(function(s){return e.startsWith(s)});if(i){t(e,-1,null);return}var n=this.storage.getItem(e);if(n){var o=JSON.parse(n);setTimeout(t.bind(this,e,o.version,o.data),0);return}setTimeout(t.bind(this,e,-1,null),0)},r.prototype.set=function(e,t,i,n){var o=this.options.ignorePrefixes.some(function(s){return e.startsWith(s)});if(o){n(null,e);return}this.storage.setItem(e,JSON.stringify({recordName:e,version:t,data:i})),setTimeout(n,0)},r.prototype.delete=function(e,t){var i=this.options.ignorePrefixes.some(function(n){return e.startsWith(n)});if(i){t(null,e);return}this.storage.removeItem(e),setTimeout(t,0)},r.prototype.reset=function(e){try{this.storage.clear(),e(null)}catch(t){e(t)}},r})();wi.LocalstorageStorage=Vh});var $a=v(Pi=>{"use strict";h();Object.defineProperty(Pi,"__esModule",{value:!0});Pi.NoopStorage=void 0;var Fh=(function(){function r(){this.isReady=!0}return r.prototype.get=function(e,t){setTimeout(t.bind(this,e,-1,null),0)},r.prototype.set=function(e,t,i,n){setTimeout(n,0)},r.prototype.delete=function(e,t){setTimeout(t,0)},r.prototype.reset=function(e){e(null)},r})();Pi.NoopStorage=Fh});var Qa=v(kt=>{"use strict";h();var Hh=kt&&kt.__extends||(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),Li=kt&&kt.__assign||function(){return Li=Object.assign||function(r){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r},Li.apply(this,arguments)};Object.defineProperty(kt,"__esModule",{value:!0});kt.DefaultOptions=kt.C=kt.DeepstreamClient=void 0;var Ja=Io();Object.defineProperty(kt,"DefaultOptions",{enumerable:!0,get:function(){return Ja.DefaultOptions}});var Gh=Q();kt.C=Gh;var qh=es(),Wh=ns(),Yh=os(),Kh=ss(),$h=la(),Jh=ya(),Qh=Sa(),zh=Ia(),Xh=qa(),Zh=Wa(),tf=xt(),ef=Ya(),rf=Ka(),nf=$a(),of=(function(r){Hh(e,r);function e(t,i){i===void 0&&(i={});var n=r.call(this)||this;n.options=Li(Li({},Ja.DefaultOptions),i);var o={};return o.logger=new qh.Logger(n),i.nativeTimerRegistry?o.timerRegistry=new Kh.NativeTimerRegistry:o.timerRegistry=new Yh.IntervalTimerRegistry(n.options.intervalTimerResolution),o.timeoutRegistry=new Wh.TimeoutRegistry(o,n.options),o.socketFactory=n.options.socketFactory||Jh.socketFactory,o.connection=new $h.Connection(o,n.options,t,n),n.options.offlineEnabled?(n.options.storageName==="indexdb"&&(o.storage=new ef.IndexdbStorage(n.options)),n.options.storageName==="localstorage"&&(o.storage=new rf.LocalstorageStorage(n.options)),n.options.storage&&(o.storage=n.options.storage)):o.storage=new nf.NoopStorage,n.services=o,n.services.connection.onLost(o.timeoutRegistry.onConnectionLost.bind(o.timeoutRegistry)),n.event=new Qh.EventHandler(n.services,n.options),n.rpc=new zh.RPCHandler(n.services,n.options),n.record=new Xh.RecordHandler(n.services,n.options),n.presence=new Zh.PresenceHandler(n.services,n.options),n}return e.prototype.login=function(t,i){var n=this;if(t&&typeof t=="object")if(i)this.services.connection.authenticate(t,i);else return new Promise(function(o,s){n.services.connection.authenticate(t,function(a,c){a?o(c):s(c)})});else if(typeof t=="function")this.services.connection.authenticate({},t);else return new Promise(function(o,s){n.services.connection.authenticate({},function(a,c){a?o(c):s(c)})})},e.prototype.getConnectionState=function(){return this.services.connection.getConnectionState()},e.prototype.close=function(){var t=this;Object.keys(this.services).forEach(function(i){t.services[i].close&&t.services[i].close()})},e.prototype.pause=function(){this.services.connection.pause()},e.prototype.resume=function(t){var i=this;if(t){this.services.connection.resume(t);return}return new Promise(function(n,o){i.services.connection.resume(function(s){s?o(s):n()})})},e.prototype.getUid=function(){var t=new Date().getTime().toString(36),i=(Math.random()*1e16).toString(36).replace(".","");return"".concat(t,"-").concat(i)},e})(tf.Emitter);kt.DeepstreamClient=of});var za=v(Oe=>{"use strict";h();Object.defineProperty(Oe,"__esModule",{value:!0});Oe.Options=Oe.C=Oe.DeepstreamClient=void 0;var mn=Qa();Object.defineProperty(Oe,"DeepstreamClient",{enumerable:!0,get:function(){return mn.DeepstreamClient}});Object.defineProperty(Oe,"C",{enumerable:!0,get:function(){return mn.C}});Object.defineProperty(Oe,"Options",{enumerable:!0,get:function(){return mn.DefaultOptions}})});h();h();h();var vo="0.7.0";h();var mf=Rr("log","party-debug","background-color: #888; color: #fff; padding: 2px 5px; border-radius: 2px"),Gr=Rr("log","party-log","background-color: #88F; color: #00ffff; padding: 2px 5px; border-radius: 2px"),Af=Rr("log","party-alert","background-color: #FF0; color: #000; padding: 2px 5px; border-radius: 2px"),Tt=Rr("warn","party-warn","background-color: #FF0; color: #000; padding: 2px 5px; border-radius: 2px"),V=Rr("error","party-error","background-color: #ff0000; color: #ffffff; padding: 2px 5px; border-radius: 2px");function Rr(r,e,t){return typeof window!="undefined"?console[r].bind(window.console,`%c${e}`,t):console.log}var To=typeof window!="undefined"?console.log.bind(window.console,"%cparty-log%c %c%s","background-color: #88F; color: #00ffff; padding: 2px 5px; border-radius: 2px","background: none;"):console.log;h();var cc=jr(za(),1),uc=jr(Q(),1);h();var Dn=jr(Q(),1);function Cr(r,e="unknown"){let t=An(r,"");if(!t){let i="";xe&&(i=`
"${e}${xe.path}" ${xe.message}`),Tt(`User provided data is not JSON serializable.${i}`)}return t}function Ui(r,e){return typeof r!="object"?(Tt("User provided data is not an object."),!1):Cr(r,e)}function Mi(r){return typeof r!="object"?!1:Object.keys(r).length===0}var xe;function An(r,e=""){if(xe=null,["string","number","boolean"].includes(typeof r)||r===null)return!0;if(Array.isArray(r)){for(let[t,i]of Object.entries(r))if(!An(i,`${e}[${t}]`))return!1;return!0}if(typeof r=="object"&&r.constructor===Object){for(let[t,i]of Object.entries(r))if(!An(i,`${e}.${t}`))return!1;return!0}return typeof r=="function"?(xe={path:e,message:"is a function. Functions are not allowed."},!1):typeof r=="symbol"?(xe={path:e,message:"is a symbol. Symbols are not allowed."},!1):typeof r=="object"||typeof r=="undefined"?!0:(xe={path:e,message:"is an unknown type. vanilla-party doesn't know what to do with it."},!1)}h();h();h();var mr=Symbol("target"),wn=Symbol("unsubscribe");h();function Ar(r){return r instanceof Date||r instanceof Set||r instanceof Map||r instanceof WeakSet||r instanceof WeakMap||ArrayBuffer.isView(r)}function Xa(r){return r===null||typeof r!="object"&&typeof r!="function"||r instanceof RegExp||r instanceof ArrayBuffer||typeof SharedArrayBuffer!="undefined"&&r instanceof SharedArrayBuffer}h();h();function Ne(r){return typeof r=="symbol"}var sf={after(r,e){return Array.isArray(r)?r.slice(e.length):e===""?r:r.slice(e.length+1)},concat(r,e){return Array.isArray(r)?(r=[...r],e&&r.push(e),r):e&&e.toString!==void 0?(r!==""&&(r+="."),Ne(e)?r+e.toString():r+e):r},initial(r){if(Array.isArray(r))return r.slice(0,-1);if(r==="")return r;let e=r.lastIndexOf(".");return e===-1?"":r.slice(0,e)},last(r){var t;if(Array.isArray(r))return(t=r.at(-1))!=null?t:"";if(r==="")return r;let e=r.lastIndexOf(".");return e===-1?r:r.slice(e+1)},walk(r,e){if(Array.isArray(r))for(let t of r)e(t);else if(r!==""){let t=0,i=r.indexOf(".");if(i===-1)e(r);else for(;t<r.length;)i===-1&&(i=r.length),e(r.slice(t,i)),t=i+1,i=r.indexOf(".",t)}},get(r,e){return this.walk(e,t=>{r&&(r=r[t])}),r},isSubPath(r,e){if(Array.isArray(r)){if(r.length<e.length)return!1;for(let t=0;t<e.length;t++)if(r[t]!==e[t])return!1;return!0}return r.length<e.length?!1:r===e?!0:r.startsWith(e)?r[e.length]===".":!1},isRootPath(r){return Array.isArray(r)?r.length===0:r===""}},ut=sf;h();function Te(r){return Object.prototype.toString.call(r)==="[object Object]"}h();function Pn(r){return r!==null&&typeof r=="object"&&typeof r.next=="function"}h();function Ln(r,e,t,i,n){let o=r==null?void 0:r.next;if(typeof o!="function")return r;if(e.name==="entries")r.next=function(){let s=o.call(this);return s&&s.done===!1&&(s.value[0]=n(s.value[0],e,s.value[0],i),s.value[1]=n(s.value[1],e,s.value[0],i)),s};else if(e.name==="values"){let s=t[mr].keys();r.next=function(){let a=o.call(this);return a&&a.done===!1&&(a.value=n(a.value,e,s.next().value,i)),a}}else r.next=function(){let s=o.call(this);return s&&s.done===!1&&(s.value=n(s.value,e,s.value,i)),s};return r}h();function Bi(r,e,t){if(r.isUnsubscribed||e.ignoreSymbols&&Ne(t)||e.ignoreUnderscores&&typeof t=="string"&&t.charAt(0)==="_")return!0;let i=e.ignoreKeys;return i?Array.isArray(i)?i.includes(t):i instanceof Set?i.has(t):!1:!1}h();var Dr=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this._allPathsCache=new WeakMap,this.isUnsubscribed=!1}_pathsEqual(e,t){return!Array.isArray(e)||!Array.isArray(t)?e===t:e.length===t.length&&e.every((i,n)=>i===t[n])}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),i=t.get(e);return i===void 0&&(i={},t.set(e,i)),i}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let i=this._getProperties(e),n=i[t];return n===void 0&&(n=Reflect.getOwnPropertyDescriptor(e,t),i[t]=n),n}getProxy(e,t,i,n){if(this.isUnsubscribed)return e;let o=n===void 0?void 0:e[n],s=o!=null?o:e;this._pathCache.set(s,t);let a=this._allPathsCache.get(s);a||(a=[],this._allPathsCache.set(s,a)),a.some(f=>this._pathsEqual(f,t))||a.push(t);let l=this._proxyCache.get(s);return l===void 0&&(l=o===void 0?new Proxy(e,i):e,this._proxyCache.set(s,l)),l}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}getAllPaths(e){if(!this.isUnsubscribed)return this._allPathsCache.get(e)}isDetached(e,t){return!Object.is(e,ut.get(t,this.getPath(e)))}defineProperty(e,t,i){return Reflect.defineProperty(e,t,i)?(this.isUnsubscribed||(this._getProperties(e)[t]=i),!0):!1}setProperty(e,t,i,n,o){if(!this._equals(o,i)||!(t in e)){let s=!1,a=e;for(;a;){let c=Reflect.getOwnPropertyDescriptor(a,t);if(c&&"set"in c){s=!0;break}a=Object.getPrototypeOf(a)}return s?Reflect.set(e,t,i,n):Reflect.set(e,t,i)}return!0}deleteProperty(e,t,i){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let n=this._getDescriptorCache().get(e);n&&(delete n[t],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(e,t,i){let n=this._getOwnPropertyDescriptor(t,i);return e!==void 0&&n!==void 0&&Object.is(e.value,n.value)&&(e.writable||!1)===(n.writable||!1)&&(e.enumerable||!1)===(n.enumerable||!1)&&(e.configurable||!1)===(n.configurable||!1)&&e.get===n.get&&e.set===n.set}isGetInvariant(e,t){let i=this._getOwnPropertyDescriptor(e,t);return i!==void 0&&i.configurable!==!0&&i.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this._allPathsCache=null,this.isUnsubscribed=!0}};h();h();var je=Array.isArray;h();h();h();function cr(){return!0}h();function be(r,e){return r===e?!1:r.length!==e.length||r.some((t,i)=>e[i]!==t)}h();var ki=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var af=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Un={push:cr,pop:cr,shift:cr,unshift:cr,copyWithin:be,reverse:be,sort:be,splice:be,flat:be,fill:be},Za=new Set([...ki,...af,...Object.keys(Un)]);h();h();function ur(r,e){if(r===e)return!1;if(r.size!==e.size)return!0;for(let t of r)if(!e.has(t))return!0;return!1}var Mn=["keys","values","entries"],Bn=new Set(["has","toString"]),kn={add:ur,clear:ur,delete:ur,forEach:ur},tc=new Set([...Bn,...Object.keys(kn),...Mn]);h();h();function lr(r,e){if(r===e)return!1;if(r.size!==e.size)return!0;for(let[t,i]of r){let n=e.get(t);if(n!==i||n===void 0&&!e.has(t))return!0}return!1}var cf=new Set([...Bn,"get"]),xn={set:lr,clear:lr,delete:lr,forEach:lr},ec=new Set([...cf,...Object.keys(xn),...Mn]);var lt=class{constructor(e,t,i,n){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=n,this._changes=n?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return ki.has(e)}_shallowClone(e){let t=e;if(Te(e))t=De({},e);else if(je(e)||ArrayBuffer.isView(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(i=>this._shallowClone(i)));else if(e instanceof Map){t=new Map;for(let[i,n]of e.entries())t.set(i,this._shallowClone(n))}return this._clonedCache.add(t),t}preferredThisArg(e,t,i,n){return e?(je(n)?this._onIsChanged=Un[t]:n instanceof Set?this._onIsChanged=kn[t]:n instanceof Map&&(this._onIsChanged=xn[t]),n):i}update(e,t,i){let n=ut.after(e,this._path);if(t!=="length"){let o=this.clone;ut.walk(n,s=>{o!=null&&o[s]&&(this._clonedCache.has(o[s])||(o[s]=this._shallowClone(o[s])),o=o[s])}),this._hasOnValidate&&this._changes.push({path:n,property:t,previous:i}),o!=null&&o[t]&&(o[t]=i)}this._isChanged=!0}undo(e){let t;for(let i=this._changes.length-1;i!==-1;i--)t=this._changes[i],ut.get(e,t.path)[t.property]=t.previous}isChanged(e,t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}isPathApplicable(e){return ut.isRootPath(this._path)||ut.isSubPath(e,this._path)}};h();var hr=class extends lt{static isHandledMethod(e){return Za.has(e)}undo(e){super.undo(e),e.length=this.clone.length}};h();var wr=class extends lt{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}};h();var fr=class extends lt{static isHandledMethod(e){return tc.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}};h();var dr=class extends lt{static isHandledMethod(e){return ec.has(e)}undo(e){for(let[t,i]of this.clone.entries())e.set(t,i);for(let t of e.keys())this.clone.has(t)||e.delete(t)}};h();var Pr=class extends lt{constructor(e,t,i,n){super(void 0,t,i,n),this._argument1=i[0],this._weakValue=e.has(this._argument1)}isChanged(e,t){return this._weakValue!==e.has(this._argument1)}undo(e){this._weakValue&&!e.has(this._argument1)?e.add(this._argument1):e.delete(this._argument1)}};h();var Lr=class extends lt{constructor(e,t,i,n){super(void 0,t,i,n),this._weakKey=i[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e,t){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}};var Ht=class r{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return Te(e)||je(e)||Ar(e)}static isHandledMethod(e,t){return Te(e)?lt.isHandledMethod(t):je(e)?hr.isHandledMethod(t):e instanceof Set?fr.isHandledMethod(t):e instanceof Map?dr.isHandledMethod(t):Ar(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let n=lt;je(e)?n=hr:e instanceof Date?n=wr:e instanceof Set?n=fr:e instanceof Map?n=dr:e instanceof WeakSet?n=Pr:e instanceof WeakMap&&(n=Lr),this._stack.push(new n(e,t,i,this._hasOnValidate))}update(e,t,i){this._stack.at(-1).update(e,t,i)}preferredThisArg(e,t,i){let{name:n}=e,o=r.isHandledMethod(i,n);return this._stack.at(-1).preferredThisArg(o,n,t,i)}isChanged(e,t){return this._stack.at(-1).isChanged(e,t)}isPartOfClone(e){return this._stack.at(-1).isPathApplicable(e)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var uf=new Set(["values","keys","entries"]),lf=new Set(["indexOf","lastIndexOf","includes"]),hf={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},rc=(r,e)=>r===!1||r===!0||Array.isArray(r)&&r.includes(e),jn=(r,e,t={})=>{t=De(De({},hf),t);let i=Symbol("ProxyTarget"),{equals:n,isShallow:o,ignoreDetached:s,details:a}=t,c=new Dr(n),l=typeof t.onValidate=="function",f=new Ht(l),p=(g,T,A,D,x)=>!l||f.isCloning||t.onValidate(ut.concat(c.getPath(g),T),A,D,x)===!0,b=(g,T,A,D,x)=>{if(Bi(c,t,T)||s&&c.isDetached(g,r))return;let G=c.getAllPaths(g),B=!f.isCloning&&G&&G.length>1?G:[c.getPath(g)];for(let R of B)I(R,T,A,D,x)},I=(g,T,A,D,x)=>{f.isCloning&&f.isPartOfClone(g)?f.update(g,T,D):e(ut.concat(g,T),A,D,x)},j=g=>{var T;return g!==null&&(typeof g=="object"||typeof g=="function")&&(T=g[i])!=null?T:g},P=(g,T,A,D)=>{if(Xa(g)||A==="constructor"||o&&!Ht.isHandledMethod(T,A)||Bi(c,t,A)||c.isGetInvariant(T,A)||s&&c.isDetached(T,r))return g;D===void 0&&(D=c.getPath(T));let x=ut.concat(D,A),G=c.getPath(g);return G&&pt(x,G)?c.getProxy(g,G,ee,i):c.getProxy(g,x,ee,i)},pt=(g,T)=>{if(Ne(g)||g.length<=T.length||Array.isArray(T)&&T.length===0)return!1;let A=Array.isArray(g)?g:g.split("."),D=Array.isArray(T)?T:T.split(".");return A.length<=D.length?!1:!D.some((x,G)=>x!==A[G])},Rt=(g,T,A,D)=>{let x=ut.initial(c.getPath(g)),G=Ht.isHandledMethod(A,g.name);f.start(A,x,D);let B;Array.isArray(A)&&lf.has(g.name)?B=ff({proxyArray:A,methodName:g.name,searchElement:D[0],fromIndex:D[1],getProxyTarget:j}):B=Reflect.apply(g,f.preferredThisArg(g,T,A),G?D.map(y=>j(y)):D);let R=f.isChanged(A,n),Ge=f.stop();if(Ht.isHandledType(B)&&G&&(T instanceof Map&&g.name==="get"&&(x=ut.concat(x,D[0])),B=c.getProxy(B,x,ee)),R){let y=rc(a,g.name)?{name:g.name,args:D,result:B}:void 0,u=f.isCloning?ut.initial(x):x,N=f.isCloning?ut.last(x):"";p(ut.get(r,u),N,A,Ge,y)?I(u,N,A,Ge,y):f.undo(A)}return(T instanceof Map||T instanceof Set)&&Pn(B)?Ln(B,g,T,x,P):B},ee={get(g,T,A){if(Ne(T)){if(T===i||T===mr)return g;if(T===wn&&!c.isUnsubscribed&&c.getPath(g).length===0)return c.unsubscribe(),g}let D=Ar(g)?Reflect.get(g,T):Reflect.get(g,T,A);return P(D,g,T)},set(g,T,A,D){var R;A=j(A);let x=(R=g[i])!=null?R:g,G=x[T];if(n(G,A)&&T in g)return!0;let B=p(g,T,A,G);return B&&c.setProperty(x,T,A,D,G)?(b(g,T,g[T],G),!0):!B},defineProperty(g,T,A){if(!c.isSameDescriptor(A,g,T)){let D=g[T];if(p(g,T,A.value,D)&&c.defineProperty(g,T,A)){let G=Object.hasOwn(A,"value")?A.value:(()=>{try{return g[T]}catch(B){return}})();b(g,T,G,D)}}return!0},deleteProperty(g,T){if(!Reflect.has(g,T))return!0;let A=Reflect.get(g,T),D=p(g,T,void 0,A);return D&&c.deleteProperty(g,T,A)?(b(g,T,void 0,A),!0):!D},apply(g,T,A){var x;let D=(x=T==null?void 0:T[i])!=null?x:T;if(c.isUnsubscribed)return Reflect.apply(g,D,A);if(Ht.isHandledType(D)&&!(Te(D)&&!Ht.isHandledMethod(D,g.name))&&(typeof g.name=="symbol"||uf.has(g.name)||a===!1||Array.isArray(a)&&!a.includes(g.name)))return Rt(g,T,D,A);if(D instanceof Date&&Ht.isHandledMethod(D,g.name)){let G=D.getTime(),B=Reflect.apply(g,D,A),R=D.getTime();if(!n(G,R)){let Ge=c.getPath(D);if(rc(a,g.name)){let y={name:g.name,args:A,result:B},u=new Date(G);p(ut.get(r,Ge),"",D,u,y)?I(Ge,"",D,u,y):D.setTime(G)}}return B}return Reflect.apply(g,T,A)}},ht=c.getProxy(r,t.pathAsArray?[]:"",ee);return e=e.bind(ht),l&&(t.onValidate=t.onValidate.bind(ht)),ht},ff=r=>{let{proxyArray:e,methodName:t,searchElement:i,fromIndex:n,getProxyTarget:o}=r,{length:s}=e;if(s===0)return t==="includes"?!1:-1;let a=t==="lastIndexOf",c=n===void 0?a?s-1:0:Math.trunc(Number(n))||0;c<0?c=Math.max(0,s+c):a&&(c=Math.min(c,s-1));let l=o(i),f=t==="lastIndexOf",p=f?-1:s,b=f?-1:1;for(let I=c;f?I>p:I<p;I+=b){let j=e[I];if(j===i||o(j)===l)return t==="includes"?!0:I}return t==="includes"?!1:-1};jn.target=r=>{var e;return(e=r==null?void 0:r[mr])!=null?e:r};jn.unsubscribe=r=>{var e;return(e=r==null?void 0:r[wn])!=null?e:r};var Vn=jn;var nc=jr(Q(),1);h();function xi(r,e,t=""){if(typeof r!="object"){V("_old is not an object");return}if(typeof e!="object"){V("_new is not an object");return}let i=Object.keys(r).reverse(),n=Object.keys(e);for(let o of i)Object.prototype.hasOwnProperty.call(e,o)||(Array.isArray(r)?r.splice(parseInt(o),1):delete r[o]);for(let o of n)Object.prototype.hasOwnProperty.call(r,o)||(r[o]=e[o]);for(let o of n)if(Object.prototype.hasOwnProperty.call(r,o)){let s=ic(r[o]),a=ic(e[o]);if(a==="unsupported"){V(`${t}.${o} is unsupported type: ${typeof e[o]}`);continue}if(s==="object"&&a==="object"){xi(r[o],e[o],`${t}.${o}`);continue}if(s==="array"&&a==="array"){xi(r[o],e[o],`${t}.${o}`);continue}r[o]!==e[o]&&(r[o]=e[o])}}function ic(r){return r===null?"null":Array.isArray(r)?"array":typeof r=="object"?"object":typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r)||typeof r=="string"?"primitive":"unsupported"}var Fn=new WeakMap,pr,Ot,rt,Ve,Ur,Zt,Ie,oc,sc,ac,Gt=class{constructor(e,t){z(this,Ie);z(this,pr);z(this,Ot);z(this,rt);z(this,Ve);z(this,Ur);z(this,Zt);$(this,pr,e),$(this,Ot,t),$(this,rt,null),$(this,Ve,{}),$(this,Ur,Vn(O(this,Ve),Dt(this,Ie,sc).bind(this),{onValidate:Dt(this,Ie,oc).bind(this)})),$(this,Zt,null),Fn.set(O(this,Ve),this)}load(e,t=!1){return _t(this,null,function*(){if(O(this,Zt))return Tt("Record.load() called twice!",O(this,Ot)),O(this,Zt);if(O(this,pr).getConnectionState()!==nc.CONNECTION_STATE.OPEN){V("Record.load() called before room is connected.",O(this,Ot));return}return $(this,Zt,_t(this,null,function*(){$(this,rt,O(this,pr).record.getRecord(O(this,Ot))),O(this,rt).subscribe(Dt(this,Ie,ac).bind(this),!0),yield O(this,rt).whenReady(),e&&(yield this.initData(e,t))})),O(this,Zt)})}get whenLoaded(){return O(this,Zt)===null?(V("Record.whenLoaded called before load().",O(this,Ot)),Promise.reject(new Error("Record.whenLoaded called before load()."))):O(this,Zt)}initData(e,t=!1){return _t(this,null,function*(){var i;if(!((i=O(this,rt))!=null&&i.isReady)){V("Record.initData() called before record ready.",O(this,Ot));return}!t&&!Mi(O(this,rt).get())||Ui(e,"init-data")&&(yield O(this,rt).setWithAck(e))})}setData(e){var t;if(!((t=O(this,rt))!=null&&t.isReady)){V(`Record.setData() called before record ready. ${O(this,Ot)}
Ignored: ${JSON.stringify(e)}`);return}Ui(e,"set-data")&&O(this,rt).set(e)}watchShared(e,t,i){var n;if(!((n=O(this,rt))!=null&&n.isReady)){Tt(`watchShared() called on '${O(this,Ot)}' before ready.`);return}O(this,rt).subscribe(e,t,i)}get shared(){return O(this,Ur)}get name(){return O(this,Ot)}delete(){return _t(this,null,function*(){var e;if(!((e=O(this,rt))!=null&&e.isReady)){V(`delete() called on ${O(this,Ot)} before ready.`);return}return new Promise(t=>{var i,n;(i=O(this,rt))==null||i.once("delete",t),(n=O(this,rt))==null||n.delete()})})}_set(e,t){return _t(this,null,function*(){var i;yield(i=O(this,rt))==null?void 0:i.setWithAck(e,t)})}_get(e){var t;return(t=O(this,rt))==null?void 0:t.get(e)}static recordForShared(e){let t=Vn.target(e);if(!Fn.has(t)){V("No record found for shared object.");return}return Fn.get(t)}};pr=new WeakMap,Ot=new WeakMap,rt=new WeakMap,Ve=new WeakMap,Ur=new WeakMap,Zt=new WeakMap,Ie=new WeakSet,oc=function(e,t,i){return Cr(t,`${O(this,Ot)}/${e}`)},sc=function(e,t,i){var n;if(!((n=O(this,rt))!=null&&n.isReady)){Tt(`Shared object written to before ready. ${O(this,Ot)}
Ignored: ${e} = ${JSON.stringify(t)}`);return}this._set(e,t)},ac=function(e){Ui(e,"server-data")||V("Incoming server data not valid."),xi(O(this,Ve),e,"shared")};var dt,Mr,Br,qt,Wt,Ce,me,Fe,te,kr,bt,He,It,lc,Hn,hc,fc,Gn,ji=class{constructor(e,t,i){z(this,It);z(this,dt);z(this,Mr);z(this,Br);z(this,qt);z(this,Wt);z(this,Ce);z(this,me);z(this,Fe);z(this,te);z(this,kr);z(this,bt);z(this,He);$(this,dt,new cc.DeepstreamClient(e)),$(this,Mr,t),$(this,Br,i),$(this,qt,`${t}-${i}`),$(this,Wt,`${O(this,qt)}/${O(this,dt).getUid()}`),$(this,Ce,new Map),$(this,me,[]),$(this,Fe,[]),$(this,te,new Gt(O(this,dt),O(this,Wt))),$(this,bt,[]),$(this,He,void 0),$(this,kr,Dt(this,It,lc).call(this))}isConnected(){return O(this,dt).getConnectionState()===uc.CONNECTION_STATE.OPEN}get whenConnected(){return O(this,kr)}disconnect(){this.isConnected()&&O(this,dt).close()}info(){return{appName:O(this,Mr),roomName:O(this,Br),guestNames:O(this,bt),guestName:O(this,Wt),isConnected:this.isConnected(),isHost:this.isHost()}}getRecord(e){return new Gt(O(this,dt),`${O(this,qt)}/${e}`)}subscribe(e,t){O(this,dt).event.subscribe(`${O(this,qt)}/${e}`,t)}unsubscribe(e,t){O(this,dt).event.unsubscribe(`${O(this,qt)}/${e}`,t)}emit(e,t){(t===void 0||Cr(t,"emit-data"))&&O(this,dt).event.emit(`${O(this,qt)}/${e}`,t)}get hostName(){return O(this,He)}get _guestNames(){return[...O(this,bt)]}get myGuestRecord(){return O(this,te)}get guestShareds(){return new Proxy(O(this,Fe),{set(){return V("The guestShared array is read-only."),!0}})}isHost(){return O(this,He)===O(this,Wt)}};dt=new WeakMap,Mr=new WeakMap,Br=new WeakMap,qt=new WeakMap,Wt=new WeakMap,Ce=new WeakMap,me=new WeakMap,Fe=new WeakMap,te=new WeakMap,kr=new WeakMap,bt=new WeakMap,He=new WeakMap,It=new WeakSet,lc=function(){return _t(this,null,function*(){O(this,dt).on("error",(t,i,n)=>{V("ds error",t,i,n),this.emit("party:ds-error",{error:t,event:i,topic:n})}),O(this,dt).presence.subscribe(Dt(this,It,fc).bind(this)),yield O(this,dt).login({username:O(this,Wt)}),O(this,te).load(),yield Dt(this,It,hc).call(this),Dt(this,It,Gn).call(this)})},Hn=function(){$(this,He,O(this,bt)[0])},hc=function(){return _t(this,null,function*(){let e=yield O(this,dt).presence.getAll();$(this,bt,e.filter(t=>t.startsWith(`${O(this,qt)}/`)).concat(O(this,Wt)).sort()),Dt(this,It,Hn).call(this)})},fc=function(e,t){e.startsWith(`${O(this,qt)}/`)&&(t?(O(this,bt).push(e),O(this,bt).sort()):$(this,bt,O(this,bt).filter(i=>i!==e)),Dt(this,It,Hn).call(this),Dt(this,It,Gn).call(this))},Gn=function(){let e=()=>{O(this,Fe).length=0;let t=O(this,me).filter(i=>!Mi(i));O(this,Fe).push(...t)};for(let t of O(this,bt))if(!O(this,Ce).has(t))if(t===O(this,Wt))O(this,Ce).set(t,O(this,te)),O(this,te).whenLoaded.then(()=>{O(this,te).watchShared(e.bind(this),!0)});else{let i=new Gt(O(this,dt),t);O(this,Ce).set(t,i),i.load().then(()=>{i.watchShared(e.bind(this),!0)})}O(this,me).length=0;for(let t of O(this,bt))if(t===O(this,Wt))O(this,me).push(O(this,te).shared);else{let i=O(this,Ce).get(t);i&&O(this,me).push(i.shared)}e()};To("font-weight: bold",`Vanilla Party v${vo}`);var U=null,CR=(r,e,t="main",i)=>{if(U!==null){V("You are already connected. Call partyDisconnect() before calling partyConnect() again!");return}_t(null,null,function*(){U=new ji(r,e,t),yield U.whenConnected,window.addEventListener("beforeunload",()=>{U==null||U.disconnect()}),Gr(`partyConnect() done! You are in the room "${U.info().roomName}"`),i==null||i()})},mR=()=>{if(!U){V("partyDisconnect() called before partyConnect()");return}Tt(`You have been disconnected from room "${U.info().roomName}".`),U.disconnect(),U=null},AR=(r,e,t)=>{if(!U){V("partyLoadShared() called before partyConnect()");return}let i=U.getRecord(r);return _t(null,null,function*(){yield U==null?void 0:U.whenConnected;let o=(U==null?void 0:U.isHost())===!0;yield i.load(e,o),Gr(`partyLoadShared "${r}" done!`),t==null||t(i.shared)}),i.shared},DR=(r={},e)=>{if(!U){V("partyLoadMyShared() called before partyConnect()");return}let t=U.myGuestRecord;return _t(null,null,function*(){yield U==null?void 0:U.whenConnected,yield t.whenLoaded,yield t.initData(r),Gr("partyLoadMyShared done!"),e==null||e(t.shared)}),t.shared},wR=()=>{if(!U){V("partyLoadGuestShareds() called before partyConnect()");return}return U.guestShareds},PR=()=>U?U.isHost():(V("partyIsHost() called before partyConnect()"),!1),LR=(r,e)=>{var t;if(!Gt.recordForShared(r)){Tt("partySetShared() doesn't recognize the provided shared object.",r);return}(t=Gt.recordForShared(r))==null||t.setData(e)},UR=(r,e,t,i)=>{var n;if(!Gt.recordForShared(r)){Tt("partyWatchShared() expected shared (argument 1) to be shared object.",r);return}(n=Gt.recordForShared(r))==null||n.watchShared(e,t,i)},MR=(r,e)=>{if(!U){V("partyEmit() called before partyConnect()");return}U.emit(r,e)},BR=(r,e)=>{if(!U){V("partySubscribe() called before partyConnect()");return}U.subscribe(r,e)},kR=(r,e)=>{if(!U){V("partyUnsubscribe() called before partyConnect()");return}U.unsubscribe(r,e)},xR=()=>{if(!U){V("partyCountGuests() called before partyConnect()");return}return U.info().guestNames.length},dc=()=>(U||V("partyGetRoom() called before partyConnect()"),U);h();h();function Er(r,e,t=document){let i=new CustomEvent(`reef:${r}`,{bubbles:!0,cancelable:!0,detail:e});return t.dispatchEvent(i)}function qn(r){return typeof r=="string"?document.querySelector(r):r}function yc(r){return Object.prototype.toString.call(r).slice(8,-1).toLowerCase()}function Rc(r,e){let t="signal"+(r?`-${r}`:"");return{get:(i,n)=>n==="_isSignal"||(["object","array"].includes(yc(i[n]))&&!i[n]._isSignal&&(i[n]=new Proxy(i[n],Rc(r))),i[n]),set:(i,n,o)=>(i[n]===o||(i[n]=o,Er(t,{prop:n,value:o,action:"set"})),!0),deleteProperty:(i,n)=>(delete i[n],Er(t,{prop:n,value:i[n],action:"delete"}),!0)}}function _c(r={},e=""){return r=["array","object"].includes(yc(r))?r:{value:r},new Proxy(r,Rc(e))}var pc=["input","option","textarea"],Vi=["value","checked","selected"],Sc=["checked","selected"];function gc(r){return["false","null","undefined","0","-0","NaN","0n","-0n"].includes(r)}function Oc(r,e,t,i){if(!e.startsWith("on")||!i||r[e])return;let n=i[t.split("(")[0]];n&&(r[e]=n)}function Nc(r,e){let t=e.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(r)||!t.includes("javascript:")&&!t.includes("data:text/html"))||!!(r.startsWith("on")||r.startsWith("@on")||r.startsWith("#on"))||void 0}function vc(r,e,t,i){Oc(r,e,t,i),Nc(e,t)||(Vi.includes(e)&&(r[e]=e==="value"?t:" "),r.setAttribute(e,t))}function Fi(r,e){Vi.includes(e)&&(r[e]=""),r.removeAttribute(e)}function Wn(r,e){if(r.nodeType===1){for(let{name:t,value:i}of Array.from(r.attributes)){if(Nc(t,i))return Fi(r,t),void Oc(r,t,i,e);if(!t.startsWith("@")&&!t.startsWith("#"))continue;let n=t.slice(1);Fi(r,t),Sc.includes(n)&&gc(i)||vc(r,n,i,e)}if(r.childNodes)for(let t of r.childNodes)Wn(t,e)}}function Ec(r){return r.childNodes&&r.childNodes.length?null:r.textContent}function Yn(r,e,t){let i=r.childNodes,n=e.childNodes;(function(o){let s=o.querySelectorAll("script");for(let a of s)a.remove()})(r)||(i.forEach((function(o,s){if(!n[s]){let f=o.cloneNode(!0);return Wn(f,t),void e.append(f)}if(a=o,c=n[s],typeof a.nodeType=="number"&&a.nodeType!==c.nodeType||typeof a.tagName=="string"&&a.tagName!==c.tagName||typeof a.id=="string"&&a.id&&a.id!==c.id||"getAttribute"in a&&"getAttribute"in c&&a.getAttribute("key")!==c.getAttribute("key")||typeof a.src=="string"&&a.src&&a.src!==c.src){let f=(function(p,b){if(p.nodeType!==1)return;let I=p.getAttribute("id"),j=p.getAttribute("key");if(!I||!j)return;let P=I?`#${I}`:`[key="${j}"]`;return b.querySelector(`:scope > ${P}`)})(o,e);if(!f){let p=o.cloneNode(!0);return Wn(p,t),void n[s].before(p)}n[s].before(f)}var a,c;if(i[s]&&"hasAttribute"in i[s]&&i[s].hasAttribute("reef-ignore")||((function(f,p,b){if(f.nodeType!==1)return;let I=f.attributes,j=p.attributes;for(let{name:P,value:pt}of Array.from(I)){if(P.startsWith("#")||Vi.includes(P)&&pc.includes(f.tagName.toLowerCase()))continue;let Rt=P.startsWith("@")?P.slice(1):P;Sc.includes(Rt)&&gc(pt)?Fi(p,Rt):vc(p,Rt,pt,b)}for(let{name:P,value:pt}of Array.from(j))I[P]||Vi.includes(P)&&pc.includes(p.tagName.toLowerCase())||Fi(p,P)})(o,n[s],t),o.nodeName.includes("-")))return;let l=Ec(o);if(l&&l!==Ec(n[s])&&(n[s].textContent=l),o.childNodes.length||!n[s].childNodes.length){if(!n[s].childNodes.length&&o.childNodes.length){let f=document.createDocumentFragment();return Yn(o,f,t),void n[s].appendChild(f)}o.childNodes.length&&Yn(o,n[s],t)}else n[s].innerHTML=""})),(function(o,s){let a=o.length-s.length;if(!(a<1))for(;a>0;a--)o[o.length-1].remove()})(n,i))}function df(r,e,t){let i=qn(r),n=(function(o){let s=new DOMParser().parseFromString(`<body><template>${o}</template></body>`,"text/html");return s.body?s.body.firstElementChild.content:document.createElement("body")})(e);Er("before-render",null,i)&&(Yn(n,i,t),Er("render",null,i))}var Kn=class{constructor(e,t,i){var n;this.elem=e,this.template=t,this.signals=i.signals?i.signals.map((o=>`reef:signal-${o}`)):["reef:signal"],this.events=i.events,this.handler=(n=this,function(o){n.render()}),this.debounce=null,this.start()}start(){for(let e of this.signals)document.addEventListener(e,this.handler);this.render(),Er("start",null,qn(this.elem))}stop(){for(let e of this.signals)document.removeEventListener(e,this.handler);Er("stop",null,qn(this.elem))}render(){let e=this;e.debounce&&window.cancelAnimationFrame(e.debounce),e.debounce=window.requestAnimationFrame((function(){df(e.elem,e.template(),e.events)}))}};function Tc(r,e,t={}){return new Kn(r,e,t)}var $n=`.vanillaparty_info {
position: fixed;
right: 0;
top: 0;
padding: 10px;
background: rgba(255, 255, 0, 0.1);
font-family: "Courier New", Courier, monospace;
font-size: 18px;
}
.vanillaparty_info .error {
padding: 3px 6px;
background: red;
color: white;
}
.vanillaparty_info button {
display: block;
margin-top: 6px;
padding: 3px 6px;
background: white;
color: black;
border: 1px solid black;
border-radius: 3px;
cursor: pointer;
font-family: "Courier New", Courier, monospace;
font-size: 14px;
}
.vanillaparty_info button:hover {
background: #eee;
}
.vanillaparty_info button:active {
background: #ddd;
}
.vanillaparty_info .checkbox {
appearance: none;
margin: 0;
width: 1em;
height: 1em;
border: 1px solid black;
border-radius: 3px;
background: white;
display: inline-grid;
place-content: center;
}
.vanillaparty_info .checkbox::before {
content: "";
width: 0.65em;
height: 0.65em;
background: black;
border-radius: 2px;
transform: scale(0);
transition: 120ms transform ease-in-out;
}
.vanillaparty_info .checkbox:checked::before {
transform: scale(1);
}
.vanillaparty_info label {
margin: 0;
font-size: 14px;
}
`;var Ae,Ic,Qn,bc=!1,Jn=!1;document.addEventListener("keyup",r=>{r.key==="F1"&&Cc()},!1);function Cc(r){let e=dc();if(!e){V("partyToggleInfo() called before partyConnect()");return}Jn=r!=null?r:!Jn,Jn?mc(e):Ef()}function mc(r){return _t(this,null,function*(){if(yield r.whenConnected,Ae)return;Ae=document.createElement("div"),Ae.className="vanillaparty_info",document.body.append(Ae);let e=_c(De({},r.info()));function t(){let{appName:i,roomName:n,guestNames:o,isHost:s,isConnected:a}=e;return a?`
<style>${$n}</style>
<div>${i}</div>
<div>${n}</div>
<div>guests: ${o.length}</div>
<div>${s?"hosting":""}</div>
<button data-party="reload-others">reload others</button>
<button data-party="disconnect-others">disconnect others</button>
<a href="https://www.notion.so/justinbakse/The-Info-Panel-193b1bb21cec80aaafd8f341f044b3fc">?</a>`:`
<style>${$n}</style>
<div class="error">disconnected</div>`}Qn=Tc(Ae,t),bc||(bc=!0,document.addEventListener("click",i=>{let n=i.target.getAttribute("data-party");if(!n)return;let o=r.info().guestName;n==="reload-others"&&r.emit("party:reload-others",{sender:o}),n==="disconnect-others"&&r.emit("party:disconnect-others",{sender:o})}),r.subscribe("party:reload-others",i=>{r&&i.sender!==r.info().guestName&&(Tt('Received "reload-others" event. Reloading...'),window.location.reload())}),r.subscribe("party:disconnect-others",i=>{r&&i.sender!=r.info().guestName&&(Tt('Received "disconnect-others" event. Disconnecting...'),r.disconnect(),mc(r))})),Ic=window.setInterval(()=>{Object.assign(e,r.info())},100)})}function Ef(){Ae&&(Ae.remove(),Ae=null),Qn&&Qn.stop(),clearInterval(Ic)}export{Gt as PartyRecord,ji as PartyRoom,CR as partyConnect,xR as partyCountGuests,mR as partyDisconnect,MR as partyEmit,dc as partyGetRoom,PR as partyIsHost,wR as partyLoadGuestShareds,DR as partyLoadMyShared,AR as partyLoadShared,LR as partySetShared,BR as partySubscribe,Cc as partyToggleInfo,kR as partyUnsubscribe,UR as partyWatchShared};
//! experimental
//! /experimental
/*! Bundled license information:
ieee754/index.js:
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
buffer/index.js:
(*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*)
long/umd/index.js:
(**
* @license
* Copyright 2009 The Closure Library Authors
* Copyright 2020 Daniel Wirtz / The long.js Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*)
reefjs/dist/reef.es.min.js:
(*! reef v13.0.6 | (c) 2024 Chris Ferdinandi | MIT License | http://github.com/cferdinandi/reef *)
*/
//# sourceMappingURL=vanilla-party.mjs.map