genosdb 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/gdb.min.js CHANGED
@@ -1 +1 @@
1
- function l6(W){const Q=W.length;let J=0,G=0;while(G<Q){let V=W.charCodeAt(G++);if((V&4294967168)===0){J++;continue}else if((V&4294965248)===0)J+=2;else{if(V>=55296&&V<=56319){if(G<Q){const q=W.charCodeAt(G);if((q&64512)===56320)++G,V=((V&1023)<<10)+(q&1023)+65536}}if((V&4294901760)===0)J+=3;else J+=4}}return J}function AW(W,Q,J){const G=W.length;let V=J,q=0;while(q<G){let X=W.charCodeAt(q++);if((X&4294967168)===0){Q[V++]=X;continue}else if((X&4294965248)===0)Q[V++]=X>>6&31|192;else{if(X>=55296&&X<=56319){if(q<G){const Y=W.charCodeAt(q);if((Y&64512)===56320)++q,X=((X&1023)<<10)+(Y&1023)+65536}}if((X&4294901760)===0)Q[V++]=X>>12&15|224,Q[V++]=X>>6&63|128;else Q[V++]=X>>18&7|240,Q[V++]=X>>12&63|128,Q[V++]=X>>6&63|128}Q[V++]=X&63|128}}function TW(W,Q,J){vW.encodeInto(W,Q.subarray(J))}function i6(W,Q,J){if(W.length>gW)TW(W,Q,J);else AW(W,Q,J)}function A8(W,Q,J){let G=Q;const V=G+J,q=[];let X="";while(G<V){const Y=W[G++];if((Y&128)===0)q.push(Y);else if((Y&224)===192){const K=W[G++]&63;q.push((Y&31)<<6|K)}else if((Y&240)===224){const K=W[G++]&63,P=W[G++]&63;q.push((Y&31)<<12|K<<6|P)}else if((Y&248)===240){const K=W[G++]&63,P=W[G++]&63,U=W[G++]&63;let C=(Y&7)<<18|K<<12|P<<6|U;if(C>65535)C-=65536,q.push(C>>>10&1023|55296),C=56320|C&1023;q.push(C)}else q.push(Y);if(q.length>=SW)X+=String.fromCharCode(...q),q.length=0}if(q.length>0)X+=String.fromCharCode(...q);return X}function pW(W,Q,J){const G=W.subarray(Q,Q+J);return yW.decode(G)}function r6(W,Q,J){if(J>EW)return pW(W,Q,J);else return A8(W,Q,J)}var vW=new TextEncoder,gW=50,SW=4096,yW=new TextDecoder,EW=200;class e0{constructor(W,Q){this.type=W,this.data=Q}}class e extends Error{constructor(W){super(W);const Q=Object.create(e.prototype);Object.setPrototypeOf(this,Q),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:e.name})}}function o6(W,Q,J){const G=J/4294967296,V=J;W.setUint32(Q,G),W.setUint32(Q+4,V)}function i1(W,Q,J){const G=Math.floor(J/4294967296),V=J;W.setUint32(Q,G),W.setUint32(Q+4,V)}function r1(W,Q){const J=W.getInt32(Q),G=W.getUint32(Q+4);return J*4294967296+G}function a6(W,Q){const J=W.getUint32(Q),G=W.getUint32(Q+4);return J*4294967296+G}var t0=4294967295;function mW({sec:W,nsec:Q}){if(W>=0&&Q>=0&&W<=bW)if(Q===0&&W<=hW){const J=new Uint8Array(4);return new DataView(J.buffer).setUint32(0,W),J}else{const J=W/4294967296,G=W&4294967295,V=new Uint8Array(8),q=new DataView(V.buffer);return q.setUint32(0,Q<<2|J&3),q.setUint32(4,G),V}else{const J=new Uint8Array(12),G=new DataView(J.buffer);return G.setUint32(0,Q),i1(G,4,W),J}}function uW(W){const Q=W.getTime(),J=Math.floor(Q/1000),G=(Q-J*1000)*1e6,V=Math.floor(G/1e9);return{sec:J+V,nsec:G-V*1e9}}function dW(W){if(W instanceof Date){const Q=uW(W);return mW(Q)}else return null}function cW(W){const Q=new DataView(W.buffer,W.byteOffset,W.byteLength);switch(W.byteLength){case 4:return{sec:Q.getUint32(0),nsec:0};case 8:{const J=Q.getUint32(0),G=Q.getUint32(4),V=(J&3)*4294967296+G,q=J>>>2;return{sec:V,nsec:q}}case 12:{const J=r1(Q,4),G=Q.getUint32(0);return{sec:J,nsec:G}}default:throw new e(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${W.length}`)}}function _W(W){const Q=cW(W);return new Date(Q.sec*1000+Q.nsec/1e6)}var fW=-1,hW=4294967295,bW=17179869183,n6={type:fW,encode:dW,decode:_W};class S0{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(n6)}register({type:W,encode:Q,decode:J}){if(W>=0)this.encoders[W]=Q,this.decoders[W]=J;else{const G=-1-W;this.builtInEncoders[G]=Q,this.builtInDecoders[G]=J}}tryToEncode(W,Q){for(let J=0;J<this.builtInEncoders.length;J++){const G=this.builtInEncoders[J];if(G!=null){const V=G(W,Q);if(V!=null){const q=-1-J;return new e0(q,V)}}}for(let J=0;J<this.encoders.length;J++){const G=this.encoders[J];if(G!=null){const V=G(W,Q);if(V!=null)return new e0(J,V)}}if(W instanceof e0)return W;return null}decode(W,Q,J){const G=Q<0?this.builtInDecoders[-1-Q]:this.decoders[Q];if(G)return G(W,Q,J);else return new e0(Q,W)}}S0.defaultCodec=new S0;var lW=function(W){return W instanceof ArrayBuffer||typeof SharedArrayBuffer!=="undefined"&&W instanceof SharedArrayBuffer};function M1(W){if(W instanceof Uint8Array)return W;else if(ArrayBuffer.isView(W))return new Uint8Array(W.buffer,W.byteOffset,W.byteLength);else if(lW(W))return new Uint8Array(W);else return Uint8Array.from(W)}var iW=100,rW=2048;class o1{constructor(W){this.entered=!1,this.extensionCodec=W?.extensionCodec??S0.defaultCodec,this.context=W?.context,this.useBigInt64=W?.useBigInt64??!1,this.maxDepth=W?.maxDepth??iW,this.initialBufferSize=W?.initialBufferSize??rW,this.sortKeys=W?.sortKeys??!1,this.forceFloat32=W?.forceFloat32??!1,this.ignoreUndefined=W?.ignoreUndefined??!1,this.forceIntegerToFloat=W?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new o1({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(W){if(this.entered)return this.clone().encodeSharedRef(W);try{return this.entered=!0,this.reinitializeState(),this.doEncode(W,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(W){if(this.entered)return this.clone().encode(W);try{return this.entered=!0,this.reinitializeState(),this.doEncode(W,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(W,Q){if(Q>this.maxDepth)throw new Error(`Too deep objects in depth ${Q}`);if(W==null)this.encodeNil();else if(typeof W==="boolean")this.encodeBoolean(W);else if(typeof W==="number")if(!this.forceIntegerToFloat)this.encodeNumber(W);else this.encodeNumberAsFloat(W);else if(typeof W==="string")this.encodeString(W);else if(this.useBigInt64&&typeof W==="bigint")this.encodeBigInt64(W);else this.encodeObject(W,Q)}ensureBufferSizeToWrite(W){const Q=this.pos+W;if(this.view.byteLength<Q)this.resizeBuffer(Q*2)}resizeBuffer(W){const Q=new ArrayBuffer(W),J=new Uint8Array(Q),G=new DataView(Q);J.set(this.bytes),this.view=G,this.bytes=J}encodeNil(){this.writeU8(192)}encodeBoolean(W){if(W===!1)this.writeU8(194);else this.writeU8(195)}encodeNumber(W){if(!this.forceIntegerToFloat&&Number.isSafeInteger(W))if(W>=0)if(W<128)this.writeU8(W);else if(W<256)this.writeU8(204),this.writeU8(W);else if(W<65536)this.writeU8(205),this.writeU16(W);else if(W<4294967296)this.writeU8(206),this.writeU32(W);else if(!this.useBigInt64)this.writeU8(207),this.writeU64(W);else this.encodeNumberAsFloat(W);else if(W>=-32)this.writeU8(224|W+32);else if(W>=-128)this.writeU8(208),this.writeI8(W);else if(W>=-32768)this.writeU8(209),this.writeI16(W);else if(W>=-2147483648)this.writeU8(210),this.writeI32(W);else if(!this.useBigInt64)this.writeU8(211),this.writeI64(W);else this.encodeNumberAsFloat(W);else this.encodeNumberAsFloat(W)}encodeNumberAsFloat(W){if(this.forceFloat32)this.writeU8(202),this.writeF32(W);else this.writeU8(203),this.writeF64(W)}encodeBigInt64(W){if(W>=BigInt(0))this.writeU8(207),this.writeBigUint64(W);else this.writeU8(211),this.writeBigInt64(W)}writeStringHeader(W){if(W<32)this.writeU8(160+W);else if(W<256)this.writeU8(217),this.writeU8(W);else if(W<65536)this.writeU8(218),this.writeU16(W);else if(W<4294967296)this.writeU8(219),this.writeU32(W);else throw new Error(`Too long string: ${W} bytes in UTF-8`)}encodeString(W){const J=l6(W);this.ensureBufferSizeToWrite(5+J),this.writeStringHeader(J),i6(W,this.bytes,this.pos),this.pos+=J}encodeObject(W,Q){const J=this.extensionCodec.tryToEncode(W,this.context);if(J!=null)this.encodeExtension(J);else if(Array.isArray(W))this.encodeArray(W,Q);else if(ArrayBuffer.isView(W))this.encodeBinary(W);else if(typeof W==="object")this.encodeMap(W,Q);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(W)}`)}encodeBinary(W){const Q=W.byteLength;if(Q<256)this.writeU8(196),this.writeU8(Q);else if(Q<65536)this.writeU8(197),this.writeU16(Q);else if(Q<4294967296)this.writeU8(198),this.writeU32(Q);else throw new Error(`Too large binary: ${Q}`);const J=M1(W);this.writeU8a(J)}encodeArray(W,Q){const J=W.length;if(J<16)this.writeU8(144+J);else if(J<65536)this.writeU8(220),this.writeU16(J);else if(J<4294967296)this.writeU8(221),this.writeU32(J);else throw new Error(`Too large array: ${J}`);for(let G of W)this.doEncode(G,Q+1)}countWithoutUndefined(W,Q){let J=0;for(let G of Q)if(W[G]!==void 0)J++;return J}encodeMap(W,Q){const J=Object.keys(W);if(this.sortKeys)J.sort();const G=this.ignoreUndefined?this.countWithoutUndefined(W,J):J.length;if(G<16)this.writeU8(128+G);else if(G<65536)this.writeU8(222),this.writeU16(G);else if(G<4294967296)this.writeU8(223),this.writeU32(G);else throw new Error(`Too large map object: ${G}`);for(let V of J){const q=W[V];if(!(this.ignoreUndefined&&q===void 0))this.encodeString(V),this.doEncode(q,Q+1)}}encodeExtension(W){if(typeof W.data==="function"){const J=W.data(this.pos+6),G=J.length;if(G>=4294967296)throw new Error(`Too large extension object: ${G}`);this.writeU8(201),this.writeU32(G),this.writeI8(W.type),this.writeU8a(J);return}const Q=W.data.length;if(Q===1)this.writeU8(212);else if(Q===2)this.writeU8(213);else if(Q===4)this.writeU8(214);else if(Q===8)this.writeU8(215);else if(Q===16)this.writeU8(216);else if(Q<256)this.writeU8(199),this.writeU8(Q);else if(Q<65536)this.writeU8(200),this.writeU16(Q);else if(Q<4294967296)this.writeU8(201),this.writeU32(Q);else throw new Error(`Too large extension object: ${Q}`);this.writeI8(W.type),this.writeU8a(W.data)}writeU8(W){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,W),this.pos++}writeU8a(W){const Q=W.length;this.ensureBufferSizeToWrite(Q),this.bytes.set(W,this.pos),this.pos+=Q}writeI8(W){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,W),this.pos++}writeU16(W){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,W),this.pos+=2}writeI16(W){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,W),this.pos+=2}writeU32(W){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,W),this.pos+=4}writeI32(W){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,W),this.pos+=4}writeF32(W){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,W),this.pos+=4}writeF64(W){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,W),this.pos+=8}writeU64(W){this.ensureBufferSizeToWrite(8),o6(this.view,this.pos,W),this.pos+=8}writeI64(W){this.ensureBufferSizeToWrite(8),i1(this.view,this.pos,W),this.pos+=8}writeBigUint64(W){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,W),this.pos+=8}writeBigInt64(W){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,W),this.pos+=8}}function I0(W,Q){return new o1(Q).encodeSharedRef(W)}function a1(W){return`${W<0?"-":""}0x${Math.abs(W).toString(16).padStart(2,"0")}`}var oW=16,aW=16;class v8{constructor(W=oW,Q=aW){this.hit=0,this.miss=0,this.maxKeyLength=W,this.maxLengthPerKey=Q,this.caches=[];for(let J=0;J<this.maxKeyLength;J++)this.caches.push([])}canBeCached(W){return W>0&&W<=this.maxKeyLength}find(W,Q,J){const G=this.caches[J-1];W:for(let V of G){const q=V.bytes;for(let X=0;X<J;X++)if(q[X]!==W[Q+X])continue W;return V.str}return null}store(W,Q){const J=this.caches[W.length-1],G={bytes:W,str:Q};if(J.length>=this.maxLengthPerKey)J[Math.random()*J.length|0]=G;else J.push(G)}decode(W,Q,J){const G=this.find(W,Q,J);if(G!=null)return this.hit++,G;this.miss++;const V=A8(W,Q,J),q=Uint8Array.prototype.slice.call(W,Q,Q+J);return this.store(q,V),V}}var g8="array",j1="map_key",e6="map_value",nW=(W)=>{if(typeof W==="string"||typeof W==="number")return W;throw new e("The type of key must be string or number but "+typeof W)};class t6{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(W){const Q=this.getUninitializedStateFromPool();Q.type=g8,Q.position=0,Q.size=W,Q.array=new Array(W)}pushMapState(W){const Q=this.getUninitializedStateFromPool();Q.type=j1,Q.readCount=0,Q.size=W,Q.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){const W={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(W)}return this.stack[this.stackHeadPosition]}release(W){if(this.stack[this.stackHeadPosition]!==W)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(W.type===g8){const J=W;J.size=0,J.array=void 0,J.position=0,J.type=void 0}if(W.type===j1||W.type===e6){const J=W;J.size=0,J.map=void 0,J.readCount=0,J.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}var B1=-1,T8=new DataView(new ArrayBuffer(0)),sW=new Uint8Array(T8.buffer);try{T8.getInt8(0)}catch(W){if(!(W instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var s6=new RangeError("Insufficient data"),eW=new v8;class n1{constructor(W){this.totalPos=0,this.pos=0,this.view=T8,this.bytes=sW,this.headByte=B1,this.stack=new t6,this.entered=!1,this.extensionCodec=W?.extensionCodec??S0.defaultCodec,this.context=W?.context,this.useBigInt64=W?.useBigInt64??!1,this.rawStrings=W?.rawStrings??!1,this.maxStrLength=W?.maxStrLength??t0,this.maxBinLength=W?.maxBinLength??t0,this.maxArrayLength=W?.maxArrayLength??t0,this.maxMapLength=W?.maxMapLength??t0,this.maxExtLength=W?.maxExtLength??t0,this.keyDecoder=W?.keyDecoder!==void 0?W.keyDecoder:eW,this.mapKeyConverter=W?.mapKeyConverter??nW}clone(){return new n1({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=B1,this.stack.reset()}setBuffer(W){const Q=M1(W);this.bytes=Q,this.view=new DataView(Q.buffer,Q.byteOffset,Q.byteLength),this.pos=0}appendBuffer(W){if(this.headByte===B1&&!this.hasRemaining(1))this.setBuffer(W);else{const Q=this.bytes.subarray(this.pos),J=M1(W),G=new Uint8Array(Q.length+J.length);G.set(Q),G.set(J,Q.length),this.setBuffer(G)}}hasRemaining(W){return this.view.byteLength-this.pos>=W}createExtraByteError(W){const{view:Q,pos:J}=this;return new RangeError(`Extra ${Q.byteLength-J} of ${Q.byteLength} byte(s) found at buffer[${W}]`)}decode(W){if(this.entered)return this.clone().decode(W);try{this.entered=!0,this.reinitializeState(),this.setBuffer(W);const Q=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return Q}finally{this.entered=!1}}*decodeMulti(W){if(this.entered){yield*this.clone().decodeMulti(W);return}try{this.entered=!0,this.reinitializeState(),this.setBuffer(W);while(this.hasRemaining(1))yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(W){if(this.entered)return this.clone().decodeAsync(W);try{this.entered=!0;let Q=!1,J;for await(let X of W){if(Q)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(X);try{J=this.doDecodeSync(),Q=!0}catch(Y){if(!(Y instanceof RangeError))throw Y}this.totalPos+=this.pos}if(Q){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return J}const{headByte:G,pos:V,totalPos:q}=this;throw new RangeError(`Insufficient data in parsing ${a1(G)} at ${q} (${V} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(W){return this.decodeMultiAsync(W,!0)}decodeStream(W){return this.decodeMultiAsync(W,!1)}async*decodeMultiAsync(W,Q){if(this.entered){yield*this.clone().decodeMultiAsync(W,Q);return}try{this.entered=!0;let J=Q,G=-1;for await(let V of W){if(Q&&G===0)throw this.createExtraByteError(this.totalPos);if(this.appendBuffer(V),J)G=this.readArraySize(),J=!1,this.complete();try{while(!0)if(yield this.doDecodeSync(),--G===0)break}catch(q){if(!(q instanceof RangeError))throw q}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){W:while(!0){const W=this.readHeadByte();let Q;if(W>=224)Q=W-256;else if(W<192)if(W<128)Q=W;else if(W<144){const G=W-128;if(G!==0){this.pushMapState(G),this.complete();continue W}else Q={}}else if(W<160){const G=W-144;if(G!==0){this.pushArrayState(G),this.complete();continue W}else Q=[]}else{const G=W-160;Q=this.decodeString(G,0)}else if(W===192)Q=null;else if(W===194)Q=!1;else if(W===195)Q=!0;else if(W===202)Q=this.readF32();else if(W===203)Q=this.readF64();else if(W===204)Q=this.readU8();else if(W===205)Q=this.readU16();else if(W===206)Q=this.readU32();else if(W===207)if(this.useBigInt64)Q=this.readU64AsBigInt();else Q=this.readU64();else if(W===208)Q=this.readI8();else if(W===209)Q=this.readI16();else if(W===210)Q=this.readI32();else if(W===211)if(this.useBigInt64)Q=this.readI64AsBigInt();else Q=this.readI64();else if(W===217){const G=this.lookU8();Q=this.decodeString(G,1)}else if(W===218){const G=this.lookU16();Q=this.decodeString(G,2)}else if(W===219){const G=this.lookU32();Q=this.decodeString(G,4)}else if(W===220){const G=this.readU16();if(G!==0){this.pushArrayState(G),this.complete();continue W}else Q=[]}else if(W===221){const G=this.readU32();if(G!==0){this.pushArrayState(G),this.complete();continue W}else Q=[]}else if(W===222){const G=this.readU16();if(G!==0){this.pushMapState(G),this.complete();continue W}else Q={}}else if(W===223){const G=this.readU32();if(G!==0){this.pushMapState(G),this.complete();continue W}else Q={}}else if(W===196){const G=this.lookU8();Q=this.decodeBinary(G,1)}else if(W===197){const G=this.lookU16();Q=this.decodeBinary(G,2)}else if(W===198){const G=this.lookU32();Q=this.decodeBinary(G,4)}else if(W===212)Q=this.decodeExtension(1,0);else if(W===213)Q=this.decodeExtension(2,0);else if(W===214)Q=this.decodeExtension(4,0);else if(W===215)Q=this.decodeExtension(8,0);else if(W===216)Q=this.decodeExtension(16,0);else if(W===199){const G=this.lookU8();Q=this.decodeExtension(G,1)}else if(W===200){const G=this.lookU16();Q=this.decodeExtension(G,2)}else if(W===201){const G=this.lookU32();Q=this.decodeExtension(G,4)}else throw new e(`Unrecognized type byte: ${a1(W)}`);this.complete();const J=this.stack;while(J.length>0){const G=J.top();if(G.type===g8)if(G.array[G.position]=Q,G.position++,G.position===G.size)Q=G.array,J.release(G);else continue W;else if(G.type===j1){if(Q==="__proto__")throw new e("The key __proto__ is not allowed");G.key=this.mapKeyConverter(Q),G.type=e6;continue W}else if(G.map[G.key]=Q,G.readCount++,G.readCount===G.size)Q=G.map,J.release(G);else{G.key=null,G.type=j1;continue W}}return Q}}readHeadByte(){if(this.headByte===B1)this.headByte=this.readU8();return this.headByte}complete(){this.headByte=B1}readArraySize(){const W=this.readHeadByte();switch(W){case 220:return this.readU16();case 221:return this.readU32();default:if(W<160)return W-144;else throw new e(`Unrecognized array type byte: ${a1(W)}`)}}pushMapState(W){if(W>this.maxMapLength)throw new e(`Max length exceeded: map length (${W}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(W)}pushArrayState(W){if(W>this.maxArrayLength)throw new e(`Max length exceeded: array length (${W}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(W)}decodeString(W,Q){if(!this.rawStrings||this.stateIsMapKey())return this.decodeUtf8String(W,Q);return this.decodeBinary(W,Q)}decodeUtf8String(W,Q){if(W>this.maxStrLength)throw new e(`Max length exceeded: UTF-8 byte length (${W}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+Q+W)throw s6;const J=this.pos+Q;let G;if(this.stateIsMapKey()&&this.keyDecoder?.canBeCached(W))G=this.keyDecoder.decode(this.bytes,J,W);else G=r6(this.bytes,J,W);return this.pos+=Q+W,G}stateIsMapKey(){if(this.stack.length>0)return this.stack.top().type===j1;return!1}decodeBinary(W,Q){if(W>this.maxBinLength)throw new e(`Max length exceeded: bin length (${W}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(W+Q))throw s6;const J=this.pos+Q,G=this.bytes.subarray(J,J+W);return this.pos+=Q+W,G}decodeExtension(W,Q){if(W>this.maxExtLength)throw new e(`Max length exceeded: ext length (${W}) > maxExtLength (${this.maxExtLength})`);const J=this.view.getInt8(this.pos+Q),G=this.decodeBinary(W,Q+1);return this.extensionCodec.decode(G,J,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const W=this.view.getUint8(this.pos);return this.pos++,W}readI8(){const W=this.view.getInt8(this.pos);return this.pos++,W}readU16(){const W=this.view.getUint16(this.pos);return this.pos+=2,W}readI16(){const W=this.view.getInt16(this.pos);return this.pos+=2,W}readU32(){const W=this.view.getUint32(this.pos);return this.pos+=4,W}readI32(){const W=this.view.getInt32(this.pos);return this.pos+=4,W}readU64(){const W=a6(this.view,this.pos);return this.pos+=8,W}readI64(){const W=r1(this.view,this.pos);return this.pos+=8,W}readU64AsBigInt(){const W=this.view.getBigUint64(this.pos);return this.pos+=8,W}readI64AsBigInt(){const W=this.view.getBigInt64(this.pos);return this.pos+=8,W}readF32(){const W=this.view.getFloat32(this.pos);return this.pos+=4,W}readF64(){const W=this.view.getFloat64(this.pos);return this.pos+=8,W}}function s1(W,Q){return new n1(Q).decode(W)}var q1=function(W){let Q=W.length;while(--Q>=0)W[Q]=0},y8=function(W,Q,J,G,V){this.static_tree=W,this.extra_bits=Q,this.extra_base=J,this.elems=G,this.max_length=V,this.has_stree=W&&W.length},E8=function(W,Q){this.dyn_tree=W,this.max_code=0,this.stat_desc=Q},F0=function(W,Q,J,G,V){this.good_length=W,this.max_lazy=Q,this.nice_length=J,this.max_chain=G,this.func=V},W9=function(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Y8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(lJ*2),this.dyn_dtree=new Uint16Array((2*cJ+1)*2),this.bl_tree=new Uint16Array((2*_J+1)*2),w0(this.dyn_ltree),w0(this.dyn_dtree),w0(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(iJ+1),this.heap=new Uint16Array(2*n8+1),w0(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*n8+1),w0(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0},R9=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},f1=function(W){this.options=P8.assign({level:N9,method:v9,chunkSize:16384,windowBits:15,memLevel:8,strategy:A9},W||{});let Q=this.options;if(Q.raw&&Q.windowBits>0)Q.windowBits=-Q.windowBits;else if(Q.gzip&&Q.windowBits>0&&Q.windowBits<16)Q.windowBits+=16;this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new q7,this.strm.avail_out=0;let J=w1.deflateInit2(this.strm,Q.level,Q.method,Q.windowBits,Q.memLevel,Q.strategy);if(J!==q8)throw new Error(f0[J]);if(Q.header)w1.deflateSetHeader(this.strm,Q.header);if(Q.dictionary){let G;if(typeof Q.dictionary==="string")G=S1.string2buf(Q.dictionary);else if(X7.call(Q.dictionary)==="[object ArrayBuffer]")G=new Uint8Array(Q.dictionary);else G=Q.dictionary;if(J=w1.deflateSetDictionary(this.strm,G),J!==q8)throw new Error(f0[J]);this._dict_set=!0}},Y6=function(W,Q){const J=new f1(Q);if(J.push(W,!0),J.err)throw J.msg||f0[J.err];return J.result},g9=function(W,Q){return Q=Q||{},Q.raw=!0,Y6(W,Q)},T9=function(W,Q){return Q=Q||{},Q.gzip=!0,Y6(W,Q)},JQ=function(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0},MQ=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},h1=function(W){this.options=P8.assign({chunkSize:65536,windowBits:15,to:""},W||{});const Q=this.options;if(Q.raw&&Q.windowBits>=0&&Q.windowBits<16){if(Q.windowBits=-Q.windowBits,Q.windowBits===0)Q.windowBits=-15}if(Q.windowBits>=0&&Q.windowBits<16&&!(W&&W.windowBits))Q.windowBits+=32;if(Q.windowBits>15&&Q.windowBits<48){if((Q.windowBits&15)===0)Q.windowBits|=15}this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new q7,this.strm.avail_out=0;let J=j0.inflateInit2(this.strm,Q.windowBits);if(J!==y1)throw new Error(f0[J]);if(this.header=new BQ,j0.inflateGetHeader(this.strm,this.header),Q.dictionary){if(typeof Q.dictionary==="string")Q.dictionary=S1.string2buf(Q.dictionary);else if(M7.call(Q.dictionary)==="[object ArrayBuffer]")Q.dictionary=new Uint8Array(Q.dictionary);if(Q.raw){if(J=j0.inflateSetDictionary(this.strm,Q.dictionary),J!==y1)throw new Error(f0[J])}}},P6=function(W,Q){const J=new h1(Q);if(J.push(W),J.err)throw J.msg||f0[J.err];return J.result},IQ=function(W,Q){return Q=Q||{},Q.raw=!0,P6(W,Q)};/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */var tW=0,h5=1,WJ=2,JJ=3,QJ=258,Q6=29,E1=256,x1=E1+1+Q6,Q1=30,G6=19,b5=2*x1+1,y0=15,S8=16,GJ=7,V6=256,m5=16,u5=17,d5=18,r8=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),G8=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),VJ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),c5=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qJ=512,B0=new Array((x1+2)*2);q1(B0);var I1=new Array(Q1*2);q1(I1);var N1=new Array(qJ);q1(N1);var A1=new Array(QJ-JJ+1);q1(A1);var q6=new Array(Q6);q1(q6);var V8=new Array(Q1);q1(V8);var _5,l5,i5,r5=(W)=>{return W<256?N1[W]:N1[256+(W>>>7)]},v1=(W,Q)=>{W.pending_buf[W.pending++]=Q&255,W.pending_buf[W.pending++]=Q>>>8&255},J0=(W,Q,J)=>{if(W.bi_valid>S8-J)W.bi_buf|=Q<<W.bi_valid&65535,v1(W,W.bi_buf),W.bi_buf=Q>>S8-W.bi_valid,W.bi_valid+=J-S8;else W.bi_buf|=Q<<W.bi_valid&65535,W.bi_valid+=J},K0=(W,Q,J)=>{J0(W,J[Q*2],J[Q*2+1])},o5=(W,Q)=>{let J=0;do J|=W&1,W>>>=1,J<<=1;while(--Q>0);return J>>>1},XJ=(W)=>{if(W.bi_valid===16)v1(W,W.bi_buf),W.bi_buf=0,W.bi_valid=0;else if(W.bi_valid>=8)W.pending_buf[W.pending++]=W.bi_buf&255,W.bi_buf>>=8,W.bi_valid-=8},YJ=(W,Q)=>{const{dyn_tree:J,max_code:G}=Q,V=Q.stat_desc.static_tree,q=Q.stat_desc.has_stree,X=Q.stat_desc.extra_bits,Y=Q.stat_desc.extra_base,K=Q.stat_desc.max_length;let P,U,C,F,z,$,D=0;for(F=0;F<=y0;F++)W.bl_count[F]=0;J[W.heap[W.heap_max]*2+1]=0;for(P=W.heap_max+1;P<b5;P++){if(U=W.heap[P],F=J[J[U*2+1]*2+1]+1,F>K)F=K,D++;if(J[U*2+1]=F,U>G)continue;if(W.bl_count[F]++,z=0,U>=Y)z=X[U-Y];if($=J[U*2],W.opt_len+=$*(F+z),q)W.static_len+=$*(V[U*2+1]+z)}if(D===0)return;do{F=K-1;while(W.bl_count[F]===0)F--;W.bl_count[F]--,W.bl_count[F+1]+=2,W.bl_count[K]--,D-=2}while(D>0);for(F=K;F!==0;F--){U=W.bl_count[F];while(U!==0){if(C=W.heap[--P],C>G)continue;if(J[C*2+1]!==F)W.opt_len+=(F-J[C*2+1])*J[C*2],J[C*2+1]=F;U--}}},a5=(W,Q,J)=>{const G=new Array(y0+1);let V=0,q,X;for(q=1;q<=y0;q++)V=V+J[q-1]<<1,G[q]=V;for(X=0;X<=Q;X++){let Y=W[X*2+1];if(Y===0)continue;W[X*2]=o5(G[Y]++,Y)}},PJ=()=>{let W,Q,J,G,V;const q=new Array(y0+1);J=0;for(G=0;G<Q6-1;G++){q6[G]=J;for(W=0;W<1<<r8[G];W++)A1[J++]=G}A1[J-1]=G,V=0;for(G=0;G<16;G++){V8[G]=V;for(W=0;W<1<<G8[G];W++)N1[V++]=G}V>>=7;for(;G<Q1;G++){V8[G]=V<<7;for(W=0;W<1<<G8[G]-7;W++)N1[256+V++]=G}for(Q=0;Q<=y0;Q++)q[Q]=0;W=0;while(W<=143)B0[W*2+1]=8,W++,q[8]++;while(W<=255)B0[W*2+1]=9,W++,q[9]++;while(W<=279)B0[W*2+1]=7,W++,q[7]++;while(W<=287)B0[W*2+1]=8,W++,q[8]++;a5(B0,x1+1,q);for(W=0;W<Q1;W++)I1[W*2+1]=5,I1[W*2]=o5(W,5);_5=new y8(B0,r8,E1+1,x1,y0),l5=new y8(I1,G8,0,Q1,y0),i5=new y8(new Array(0),VJ,0,G6,GJ)},n5=(W)=>{let Q;for(Q=0;Q<x1;Q++)W.dyn_ltree[Q*2]=0;for(Q=0;Q<Q1;Q++)W.dyn_dtree[Q*2]=0;for(Q=0;Q<G6;Q++)W.bl_tree[Q*2]=0;W.dyn_ltree[V6*2]=1,W.opt_len=W.static_len=0,W.sym_next=W.matches=0},s5=(W)=>{if(W.bi_valid>8)v1(W,W.bi_buf);else if(W.bi_valid>0)W.pending_buf[W.pending++]=W.bi_buf;W.bi_buf=0,W.bi_valid=0},W5=(W,Q,J,G)=>{const V=Q*2,q=J*2;return W[V]<W[q]||W[V]===W[q]&&G[Q]<=G[J]},p8=(W,Q,J)=>{const G=W.heap[J];let V=J<<1;while(V<=W.heap_len){if(V<W.heap_len&&W5(Q,W.heap[V+1],W.heap[V],W.depth))V++;if(W5(Q,G,W.heap[V],W.depth))break;W.heap[J]=W.heap[V],J=V,V<<=1}W.heap[J]=G},J5=(W,Q,J)=>{let G,V,q=0,X,Y;if(W.sym_next!==0)do if(G=W.pending_buf[W.sym_buf+q++]&255,G+=(W.pending_buf[W.sym_buf+q++]&255)<<8,V=W.pending_buf[W.sym_buf+q++],G===0)K0(W,V,Q);else{if(X=A1[V],K0(W,X+E1+1,Q),Y=r8[X],Y!==0)V-=q6[X],J0(W,V,Y);if(G--,X=r5(G),K0(W,X,J),Y=G8[X],Y!==0)G-=V8[X],J0(W,G,Y)}while(q<W.sym_next);K0(W,V6,Q)},o8=(W,Q)=>{const J=Q.dyn_tree,G=Q.stat_desc.static_tree,V=Q.stat_desc.has_stree,q=Q.stat_desc.elems;let X,Y,K=-1,P;W.heap_len=0,W.heap_max=b5;for(X=0;X<q;X++)if(J[X*2]!==0)W.heap[++W.heap_len]=K=X,W.depth[X]=0;else J[X*2+1]=0;while(W.heap_len<2)if(P=W.heap[++W.heap_len]=K<2?++K:0,J[P*2]=1,W.depth[P]=0,W.opt_len--,V)W.static_len-=G[P*2+1];Q.max_code=K;for(X=W.heap_len>>1;X>=1;X--)p8(W,J,X);P=q;do X=W.heap[1],W.heap[1]=W.heap[W.heap_len--],p8(W,J,1),Y=W.heap[1],W.heap[--W.heap_max]=X,W.heap[--W.heap_max]=Y,J[P*2]=J[X*2]+J[Y*2],W.depth[P]=(W.depth[X]>=W.depth[Y]?W.depth[X]:W.depth[Y])+1,J[X*2+1]=J[Y*2+1]=P,W.heap[1]=P++,p8(W,J,1);while(W.heap_len>=2);W.heap[--W.heap_max]=W.heap[1],YJ(W,Q),a5(J,K,W.bl_count)},Q5=(W,Q,J)=>{let G,V=-1,q,X=Q[1],Y=0,K=7,P=4;if(X===0)K=138,P=3;Q[(J+1)*2+1]=65535;for(G=0;G<=J;G++){if(q=X,X=Q[(G+1)*2+1],++Y<K&&q===X)continue;else if(Y<P)W.bl_tree[q*2]+=Y;else if(q!==0){if(q!==V)W.bl_tree[q*2]++;W.bl_tree[m5*2]++}else if(Y<=10)W.bl_tree[u5*2]++;else W.bl_tree[d5*2]++;if(Y=0,V=q,X===0)K=138,P=3;else if(q===X)K=6,P=3;else K=7,P=4}},G5=(W,Q,J)=>{let G,V=-1,q,X=Q[1],Y=0,K=7,P=4;if(X===0)K=138,P=3;for(G=0;G<=J;G++){if(q=X,X=Q[(G+1)*2+1],++Y<K&&q===X)continue;else if(Y<P)do K0(W,q,W.bl_tree);while(--Y!==0);else if(q!==0){if(q!==V)K0(W,q,W.bl_tree),Y--;K0(W,m5,W.bl_tree),J0(W,Y-3,2)}else if(Y<=10)K0(W,u5,W.bl_tree),J0(W,Y-3,3);else K0(W,d5,W.bl_tree),J0(W,Y-11,7);if(Y=0,V=q,X===0)K=138,P=3;else if(q===X)K=6,P=3;else K=7,P=4}},UJ=(W)=>{let Q;Q5(W,W.dyn_ltree,W.l_desc.max_code),Q5(W,W.dyn_dtree,W.d_desc.max_code),o8(W,W.bl_desc);for(Q=G6-1;Q>=3;Q--)if(W.bl_tree[c5[Q]*2+1]!==0)break;return W.opt_len+=3*(Q+1)+5+5+4,Q},FJ=(W,Q,J,G)=>{let V;J0(W,Q-257,5),J0(W,J-1,5),J0(W,G-4,4);for(V=0;V<G;V++)J0(W,W.bl_tree[c5[V]*2+1],3);G5(W,W.dyn_ltree,Q-1),G5(W,W.dyn_dtree,J-1)},KJ=(W)=>{let Q=4093624447,J;for(J=0;J<=31;J++,Q>>>=1)if(Q&1&&W.dyn_ltree[J*2]!==0)return 0;if(W.dyn_ltree[18]!==0||W.dyn_ltree[20]!==0||W.dyn_ltree[26]!==0)return 1;for(J=32;J<E1;J++)if(W.dyn_ltree[J*2]!==0)return 1;return 0},V5=!1,zJ=(W)=>{if(!V5)PJ(),V5=!0;W.l_desc=new E8(W.dyn_ltree,_5),W.d_desc=new E8(W.dyn_dtree,l5),W.bl_desc=new E8(W.bl_tree,i5),W.bi_buf=0,W.bi_valid=0,n5(W)},e5=(W,Q,J,G)=>{if(J0(W,(tW<<1)+(G?1:0),3),s5(W),v1(W,J),v1(W,~J),J)W.pending_buf.set(W.window.subarray(Q,Q+J),W.pending);W.pending+=J},ZJ=(W)=>{J0(W,h5<<1,3),K0(W,V6,B0),XJ(W)},kJ=(W,Q,J,G)=>{let V,q,X=0;if(W.level>0){if(W.strm.data_type===2)W.strm.data_type=KJ(W);if(o8(W,W.l_desc),o8(W,W.d_desc),X=UJ(W),V=W.opt_len+3+7>>>3,q=W.static_len+3+7>>>3,q<=V)V=q}else V=q=J+5;if(J+4<=V&&Q!==-1)e5(W,Q,J,G);else if(W.strategy===4||q===V)J0(W,(h5<<1)+(G?1:0),3),J5(W,B0,I1);else J0(W,(WJ<<1)+(G?1:0),3),FJ(W,W.l_desc.max_code+1,W.d_desc.max_code+1,X+1),J5(W,W.dyn_ltree,W.dyn_dtree);if(n5(W),G)s5(W)},HJ=(W,Q,J)=>{if(W.pending_buf[W.sym_buf+W.sym_next++]=Q,W.pending_buf[W.sym_buf+W.sym_next++]=Q>>8,W.pending_buf[W.sym_buf+W.sym_next++]=J,Q===0)W.dyn_ltree[J*2]++;else W.matches++,Q--,W.dyn_ltree[(A1[J]+E1+1)*2]++,W.dyn_dtree[r5(Q)*2]++;return W.sym_next===W.sym_end},CJ=zJ,$J=e5,MJ=kJ,BJ=HJ,jJ=ZJ,LJ={_tr_init:CJ,_tr_stored_block:$J,_tr_flush_block:MJ,_tr_tally:BJ,_tr_align:jJ},RJ=(W,Q,J,G)=>{let V=W&65535|0,q=W>>>16&65535|0,X=0;while(J!==0){X=J>2000?2000:J,J-=X;do V=V+Q[G++]|0,q=q+V|0;while(--X);V%=65521,q%=65521}return V|q<<16|0},g1=RJ,OJ=()=>{let W,Q=[];for(var J=0;J<256;J++){W=J;for(var G=0;G<8;G++)W=W&1?3988292384^W>>>1:W>>>1;Q[J]=W}return Q},IJ=new Uint32Array(OJ()),wJ=(W,Q,J,G)=>{const V=IJ,q=G+J;W^=-1;for(let X=G;X<q;X++)W=W>>>8^V[(W^Q[X])&255];return W^-1},a=wJ,f0={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},m0={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:DJ,_tr_stored_block:a8,_tr_flush_block:xJ,_tr_tally:x0,_tr_align:NJ}=LJ,{Z_NO_FLUSH:N0,Z_PARTIAL_FLUSH:AJ,Z_FULL_FLUSH:vJ,Z_FINISH:q0,Z_BLOCK:q5,Z_OK:n,Z_STREAM_END:X5,Z_STREAM_ERROR:z0,Z_DATA_ERROR:gJ,Z_BUF_ERROR:f8,Z_DEFAULT_COMPRESSION:TJ,Z_FILTERED:SJ,Z_HUFFMAN_ONLY:e1,Z_RLE:yJ,Z_FIXED:EJ,Z_DEFAULT_STRATEGY:pJ,Z_UNKNOWN:fJ,Z_DEFLATED:Y8}=m0,hJ=9,bJ=15,mJ=8,uJ=29,dJ=256,n8=dJ+1+uJ,cJ=30,_J=19,lJ=2*n8+1,iJ=15,u=3,D0=258,Z0=D0+u+1,rJ=32,G1=42,X6=57,s8=69,e8=73,t8=91,W6=103,E0=113,R1=666,t=1,X1=2,h0=3,Y1=4,oJ=3,p0=(W,Q)=>{return W.msg=f0[Q],Q},Y5=(W)=>{return W*2-(W>4?9:0)},w0=(W)=>{let Q=W.length;while(--Q>=0)W[Q]=0},aJ=(W)=>{let Q,J,G,V=W.w_size;Q=W.hash_size,G=Q;do J=W.head[--G],W.head[G]=J>=V?J-V:0;while(--Q);Q=V,G=Q;do J=W.prev[--G],W.prev[G]=J>=V?J-V:0;while(--Q)},nJ=(W,Q,J)=>(Q<<W.hash_shift^J)&W.hash_mask,A0=nJ,G0=(W)=>{const Q=W.state;let J=Q.pending;if(J>W.avail_out)J=W.avail_out;if(J===0)return;if(W.output.set(Q.pending_buf.subarray(Q.pending_out,Q.pending_out+J),W.next_out),W.next_out+=J,Q.pending_out+=J,W.total_out+=J,W.avail_out-=J,Q.pending-=J,Q.pending===0)Q.pending_out=0},V0=(W,Q)=>{xJ(W,W.block_start>=0?W.block_start:-1,W.strstart-W.block_start,Q),W.block_start=W.strstart,G0(W.strm)},_=(W,Q)=>{W.pending_buf[W.pending++]=Q},L1=(W,Q)=>{W.pending_buf[W.pending++]=Q>>>8&255,W.pending_buf[W.pending++]=Q&255},J6=(W,Q,J,G)=>{let V=W.avail_in;if(V>G)V=G;if(V===0)return 0;if(W.avail_in-=V,Q.set(W.input.subarray(W.next_in,W.next_in+V),J),W.state.wrap===1)W.adler=g1(W.adler,Q,V,J);else if(W.state.wrap===2)W.adler=a(W.adler,Q,V,J);return W.next_in+=V,W.total_in+=V,V},t5=(W,Q)=>{let{max_chain_length:J,strstart:G}=W,V,q,X=W.prev_length,Y=W.nice_match;const K=W.strstart>W.w_size-Z0?W.strstart-(W.w_size-Z0):0,P=W.window,U=W.w_mask,C=W.prev,F=W.strstart+D0;let z=P[G+X-1],$=P[G+X];if(W.prev_length>=W.good_match)J>>=2;if(Y>W.lookahead)Y=W.lookahead;do{if(V=Q,P[V+X]!==$||P[V+X-1]!==z||P[V]!==P[G]||P[++V]!==P[G+1])continue;G+=2,V++;do;while(P[++G]===P[++V]&&P[++G]===P[++V]&&P[++G]===P[++V]&&P[++G]===P[++V]&&P[++G]===P[++V]&&P[++G]===P[++V]&&P[++G]===P[++V]&&P[++G]===P[++V]&&G<F);if(q=D0-(F-G),G=F-D0,q>X){if(W.match_start=Q,X=q,q>=Y)break;z=P[G+X-1],$=P[G+X]}}while((Q=C[Q&U])>K&&--J!==0);if(X<=W.lookahead)return X;return W.lookahead},V1=(W)=>{const Q=W.w_size;let J,G,V;do{if(G=W.window_size-W.lookahead-W.strstart,W.strstart>=Q+(Q-Z0)){if(W.window.set(W.window.subarray(Q,Q+Q-G),0),W.match_start-=Q,W.strstart-=Q,W.block_start-=Q,W.insert>W.strstart)W.insert=W.strstart;aJ(W),G+=Q}if(W.strm.avail_in===0)break;if(J=J6(W.strm,W.window,W.strstart+W.lookahead,G),W.lookahead+=J,W.lookahead+W.insert>=u){V=W.strstart-W.insert,W.ins_h=W.window[V],W.ins_h=A0(W,W.ins_h,W.window[V+1]);while(W.insert)if(W.ins_h=A0(W,W.ins_h,W.window[V+u-1]),W.prev[V&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=V,V++,W.insert--,W.lookahead+W.insert<u)break}}while(W.lookahead<Z0&&W.strm.avail_in!==0)},W7=(W,Q)=>{let J=W.pending_buf_size-5>W.w_size?W.w_size:W.pending_buf_size-5,G,V,q,X=0,Y=W.strm.avail_in;do{if(G=65535,q=W.bi_valid+42>>3,W.strm.avail_out<q)break;if(q=W.strm.avail_out-q,V=W.strstart-W.block_start,G>V+W.strm.avail_in)G=V+W.strm.avail_in;if(G>q)G=q;if(G<J&&(G===0&&Q!==q0||Q===N0||G!==V+W.strm.avail_in))break;if(X=Q===q0&&G===V+W.strm.avail_in?1:0,a8(W,0,0,X),W.pending_buf[W.pending-4]=G,W.pending_buf[W.pending-3]=G>>8,W.pending_buf[W.pending-2]=~G,W.pending_buf[W.pending-1]=~G>>8,G0(W.strm),V){if(V>G)V=G;W.strm.output.set(W.window.subarray(W.block_start,W.block_start+V),W.strm.next_out),W.strm.next_out+=V,W.strm.avail_out-=V,W.strm.total_out+=V,W.block_start+=V,G-=V}if(G)J6(W.strm,W.strm.output,W.strm.next_out,G),W.strm.next_out+=G,W.strm.avail_out-=G,W.strm.total_out+=G}while(X===0);if(Y-=W.strm.avail_in,Y){if(Y>=W.w_size)W.matches=2,W.window.set(W.strm.input.subarray(W.strm.next_in-W.w_size,W.strm.next_in),0),W.strstart=W.w_size,W.insert=W.strstart;else{if(W.window_size-W.strstart<=Y){if(W.strstart-=W.w_size,W.window.set(W.window.subarray(W.w_size,W.w_size+W.strstart),0),W.matches<2)W.matches++;if(W.insert>W.strstart)W.insert=W.strstart}W.window.set(W.strm.input.subarray(W.strm.next_in-Y,W.strm.next_in),W.strstart),W.strstart+=Y,W.insert+=Y>W.w_size-W.insert?W.w_size-W.insert:Y}W.block_start=W.strstart}if(W.high_water<W.strstart)W.high_water=W.strstart;if(X)return Y1;if(Q!==N0&&Q!==q0&&W.strm.avail_in===0&&W.strstart===W.block_start)return X1;if(q=W.window_size-W.strstart,W.strm.avail_in>q&&W.block_start>=W.w_size){if(W.block_start-=W.w_size,W.strstart-=W.w_size,W.window.set(W.window.subarray(W.w_size,W.w_size+W.strstart),0),W.matches<2)W.matches++;if(q+=W.w_size,W.insert>W.strstart)W.insert=W.strstart}if(q>W.strm.avail_in)q=W.strm.avail_in;if(q)J6(W.strm,W.window,W.strstart,q),W.strstart+=q,W.insert+=q>W.w_size-W.insert?W.w_size-W.insert:q;if(W.high_water<W.strstart)W.high_water=W.strstart;if(q=W.bi_valid+42>>3,q=W.pending_buf_size-q>65535?65535:W.pending_buf_size-q,J=q>W.w_size?W.w_size:q,V=W.strstart-W.block_start,V>=J||(V||Q===q0)&&Q!==N0&&W.strm.avail_in===0&&V<=q)G=V>q?q:V,X=Q===q0&&W.strm.avail_in===0&&G===V?1:0,a8(W,W.block_start,G,X),W.block_start+=G,G0(W.strm);return X?h0:t},h8=(W,Q)=>{let J,G;for(;;){if(W.lookahead<Z0){if(V1(W),W.lookahead<Z0&&Q===N0)return t;if(W.lookahead===0)break}if(J=0,W.lookahead>=u)W.ins_h=A0(W,W.ins_h,W.window[W.strstart+u-1]),J=W.prev[W.strstart&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=W.strstart;if(J!==0&&W.strstart-J<=W.w_size-Z0)W.match_length=t5(W,J);if(W.match_length>=u)if(G=x0(W,W.strstart-W.match_start,W.match_length-u),W.lookahead-=W.match_length,W.match_length<=W.max_lazy_match&&W.lookahead>=u){W.match_length--;do W.strstart++,W.ins_h=A0(W,W.ins_h,W.window[W.strstart+u-1]),J=W.prev[W.strstart&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=W.strstart;while(--W.match_length!==0);W.strstart++}else W.strstart+=W.match_length,W.match_length=0,W.ins_h=W.window[W.strstart],W.ins_h=A0(W,W.ins_h,W.window[W.strstart+1]);else G=x0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++;if(G){if(V0(W,!1),W.strm.avail_out===0)return t}}if(W.insert=W.strstart<u-1?W.strstart:u-1,Q===q0){if(V0(W,!0),W.strm.avail_out===0)return h0;return Y1}if(W.sym_next){if(V0(W,!1),W.strm.avail_out===0)return t}return X1},W1=(W,Q)=>{let J,G,V;for(;;){if(W.lookahead<Z0){if(V1(W),W.lookahead<Z0&&Q===N0)return t;if(W.lookahead===0)break}if(J=0,W.lookahead>=u)W.ins_h=A0(W,W.ins_h,W.window[W.strstart+u-1]),J=W.prev[W.strstart&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=W.strstart;if(W.prev_length=W.match_length,W.prev_match=W.match_start,W.match_length=u-1,J!==0&&W.prev_length<W.max_lazy_match&&W.strstart-J<=W.w_size-Z0){if(W.match_length=t5(W,J),W.match_length<=5&&(W.strategy===SJ||W.match_length===u&&W.strstart-W.match_start>4096))W.match_length=u-1}if(W.prev_length>=u&&W.match_length<=W.prev_length){V=W.strstart+W.lookahead-u,G=x0(W,W.strstart-1-W.prev_match,W.prev_length-u),W.lookahead-=W.prev_length-1,W.prev_length-=2;do if(++W.strstart<=V)W.ins_h=A0(W,W.ins_h,W.window[W.strstart+u-1]),J=W.prev[W.strstart&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=W.strstart;while(--W.prev_length!==0);if(W.match_available=0,W.match_length=u-1,W.strstart++,G){if(V0(W,!1),W.strm.avail_out===0)return t}}else if(W.match_available){if(G=x0(W,0,W.window[W.strstart-1]),G)V0(W,!1);if(W.strstart++,W.lookahead--,W.strm.avail_out===0)return t}else W.match_available=1,W.strstart++,W.lookahead--}if(W.match_available)G=x0(W,0,W.window[W.strstart-1]),W.match_available=0;if(W.insert=W.strstart<u-1?W.strstart:u-1,Q===q0){if(V0(W,!0),W.strm.avail_out===0)return h0;return Y1}if(W.sym_next){if(V0(W,!1),W.strm.avail_out===0)return t}return X1},sJ=(W,Q)=>{let J,G,V,q;const X=W.window;for(;;){if(W.lookahead<=D0){if(V1(W),W.lookahead<=D0&&Q===N0)return t;if(W.lookahead===0)break}if(W.match_length=0,W.lookahead>=u&&W.strstart>0){if(V=W.strstart-1,G=X[V],G===X[++V]&&G===X[++V]&&G===X[++V]){q=W.strstart+D0;do;while(G===X[++V]&&G===X[++V]&&G===X[++V]&&G===X[++V]&&G===X[++V]&&G===X[++V]&&G===X[++V]&&G===X[++V]&&V<q);if(W.match_length=D0-(q-V),W.match_length>W.lookahead)W.match_length=W.lookahead}}if(W.match_length>=u)J=x0(W,1,W.match_length-u),W.lookahead-=W.match_length,W.strstart+=W.match_length,W.match_length=0;else J=x0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++;if(J){if(V0(W,!1),W.strm.avail_out===0)return t}}if(W.insert=0,Q===q0){if(V0(W,!0),W.strm.avail_out===0)return h0;return Y1}if(W.sym_next){if(V0(W,!1),W.strm.avail_out===0)return t}return X1},eJ=(W,Q)=>{let J;for(;;){if(W.lookahead===0){if(V1(W),W.lookahead===0){if(Q===N0)return t;break}}if(W.match_length=0,J=x0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++,J){if(V0(W,!1),W.strm.avail_out===0)return t}}if(W.insert=0,Q===q0){if(V0(W,!0),W.strm.avail_out===0)return h0;return Y1}if(W.sym_next){if(V0(W,!1),W.strm.avail_out===0)return t}return X1},O1=[new F0(0,0,0,0,W7),new F0(4,4,8,4,h8),new F0(4,5,16,8,h8),new F0(4,6,32,32,h8),new F0(4,4,16,16,W1),new F0(8,16,32,32,W1),new F0(8,16,128,128,W1),new F0(8,32,128,256,W1),new F0(32,128,258,1024,W1),new F0(32,258,258,4096,W1)],tJ=(W)=>{W.window_size=2*W.w_size,w0(W.head),W.max_lazy_match=O1[W.level].max_lazy,W.good_match=O1[W.level].good_length,W.nice_match=O1[W.level].nice_length,W.max_chain_length=O1[W.level].max_chain,W.strstart=0,W.block_start=0,W.lookahead=0,W.insert=0,W.match_length=W.prev_length=u-1,W.match_available=0,W.ins_h=0},p1=(W)=>{if(!W)return 1;const Q=W.state;if(!Q||Q.strm!==W||Q.status!==G1&&Q.status!==X6&&Q.status!==s8&&Q.status!==e8&&Q.status!==t8&&Q.status!==W6&&Q.status!==E0&&Q.status!==R1)return 1;return 0},J7=(W)=>{if(p1(W))return p0(W,z0);W.total_in=W.total_out=0,W.data_type=fJ;const Q=W.state;if(Q.pending=0,Q.pending_out=0,Q.wrap<0)Q.wrap=-Q.wrap;return Q.status=Q.wrap===2?X6:Q.wrap?G1:E0,W.adler=Q.wrap===2?0:1,Q.last_flush=-2,DJ(Q),n},Q7=(W)=>{const Q=J7(W);if(Q===n)tJ(W.state);return Q},J9=(W,Q)=>{if(p1(W)||W.state.wrap!==2)return z0;return W.state.gzhead=Q,n},G7=(W,Q,J,G,V,q)=>{if(!W)return z0;let X=1;if(Q===TJ)Q=6;if(G<0)X=0,G=-G;else if(G>15)X=2,G-=16;if(V<1||V>hJ||J!==Y8||G<8||G>15||Q<0||Q>9||q<0||q>EJ||G===8&&X!==1)return p0(W,z0);if(G===8)G=9;const Y=new W9;return W.state=Y,Y.strm=W,Y.status=G1,Y.wrap=X,Y.gzhead=null,Y.w_bits=G,Y.w_size=1<<Y.w_bits,Y.w_mask=Y.w_size-1,Y.hash_bits=V+7,Y.hash_size=1<<Y.hash_bits,Y.hash_mask=Y.hash_size-1,Y.hash_shift=~~((Y.hash_bits+u-1)/u),Y.window=new Uint8Array(Y.w_size*2),Y.head=new Uint16Array(Y.hash_size),Y.prev=new Uint16Array(Y.w_size),Y.lit_bufsize=1<<V+6,Y.pending_buf_size=Y.lit_bufsize*4,Y.pending_buf=new Uint8Array(Y.pending_buf_size),Y.sym_buf=Y.lit_bufsize,Y.sym_end=(Y.lit_bufsize-1)*3,Y.level=Q,Y.strategy=q,Y.method=J,Q7(W)},Q9=(W,Q)=>{return G7(W,Q,Y8,bJ,mJ,pJ)},G9=(W,Q)=>{if(p1(W)||Q>q5||Q<0)return W?p0(W,z0):z0;const J=W.state;if(!W.output||W.avail_in!==0&&!W.input||J.status===R1&&Q!==q0)return p0(W,W.avail_out===0?f8:z0);const G=J.last_flush;if(J.last_flush=Q,J.pending!==0){if(G0(W),W.avail_out===0)return J.last_flush=-1,n}else if(W.avail_in===0&&Y5(Q)<=Y5(G)&&Q!==q0)return p0(W,f8);if(J.status===R1&&W.avail_in!==0)return p0(W,f8);if(J.status===G1&&J.wrap===0)J.status=E0;if(J.status===G1){let V=Y8+(J.w_bits-8<<4)<<8,q=-1;if(J.strategy>=e1||J.level<2)q=0;else if(J.level<6)q=1;else if(J.level===6)q=2;else q=3;if(V|=q<<6,J.strstart!==0)V|=rJ;if(V+=31-V%31,L1(J,V),J.strstart!==0)L1(J,W.adler>>>16),L1(J,W.adler&65535);if(W.adler=1,J.status=E0,G0(W),J.pending!==0)return J.last_flush=-1,n}if(J.status===X6)if(W.adler=0,_(J,31),_(J,139),_(J,8),!J.gzhead){if(_(J,0),_(J,0),_(J,0),_(J,0),_(J,0),_(J,J.level===9?2:J.strategy>=e1||J.level<2?4:0),_(J,oJ),J.status=E0,G0(W),J.pending!==0)return J.last_flush=-1,n}else{if(_(J,(J.gzhead.text?1:0)+(J.gzhead.hcrc?2:0)+(!J.gzhead.extra?0:4)+(!J.gzhead.name?0:8)+(!J.gzhead.comment?0:16)),_(J,J.gzhead.time&255),_(J,J.gzhead.time>>8&255),_(J,J.gzhead.time>>16&255),_(J,J.gzhead.time>>24&255),_(J,J.level===9?2:J.strategy>=e1||J.level<2?4:0),_(J,J.gzhead.os&255),J.gzhead.extra&&J.gzhead.extra.length)_(J,J.gzhead.extra.length&255),_(J,J.gzhead.extra.length>>8&255);if(J.gzhead.hcrc)W.adler=a(W.adler,J.pending_buf,J.pending,0);J.gzindex=0,J.status=s8}if(J.status===s8){if(J.gzhead.extra){let V=J.pending,q=(J.gzhead.extra.length&65535)-J.gzindex;while(J.pending+q>J.pending_buf_size){let Y=J.pending_buf_size-J.pending;if(J.pending_buf.set(J.gzhead.extra.subarray(J.gzindex,J.gzindex+Y),J.pending),J.pending=J.pending_buf_size,J.gzhead.hcrc&&J.pending>V)W.adler=a(W.adler,J.pending_buf,J.pending-V,V);if(J.gzindex+=Y,G0(W),J.pending!==0)return J.last_flush=-1,n;V=0,q-=Y}let X=new Uint8Array(J.gzhead.extra);if(J.pending_buf.set(X.subarray(J.gzindex,J.gzindex+q),J.pending),J.pending+=q,J.gzhead.hcrc&&J.pending>V)W.adler=a(W.adler,J.pending_buf,J.pending-V,V);J.gzindex=0}J.status=e8}if(J.status===e8){if(J.gzhead.name){let V=J.pending,q;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>V)W.adler=a(W.adler,J.pending_buf,J.pending-V,V);if(G0(W),J.pending!==0)return J.last_flush=-1,n;V=0}if(J.gzindex<J.gzhead.name.length)q=J.gzhead.name.charCodeAt(J.gzindex++)&255;else q=0;_(J,q)}while(q!==0);if(J.gzhead.hcrc&&J.pending>V)W.adler=a(W.adler,J.pending_buf,J.pending-V,V);J.gzindex=0}J.status=t8}if(J.status===t8){if(J.gzhead.comment){let V=J.pending,q;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>V)W.adler=a(W.adler,J.pending_buf,J.pending-V,V);if(G0(W),J.pending!==0)return J.last_flush=-1,n;V=0}if(J.gzindex<J.gzhead.comment.length)q=J.gzhead.comment.charCodeAt(J.gzindex++)&255;else q=0;_(J,q)}while(q!==0);if(J.gzhead.hcrc&&J.pending>V)W.adler=a(W.adler,J.pending_buf,J.pending-V,V)}J.status=W6}if(J.status===W6){if(J.gzhead.hcrc){if(J.pending+2>J.pending_buf_size){if(G0(W),J.pending!==0)return J.last_flush=-1,n}_(J,W.adler&255),_(J,W.adler>>8&255),W.adler=0}if(J.status=E0,G0(W),J.pending!==0)return J.last_flush=-1,n}if(W.avail_in!==0||J.lookahead!==0||Q!==N0&&J.status!==R1){let V=J.level===0?W7(J,Q):J.strategy===e1?eJ(J,Q):J.strategy===yJ?sJ(J,Q):O1[J.level].func(J,Q);if(V===h0||V===Y1)J.status=R1;if(V===t||V===h0){if(W.avail_out===0)J.last_flush=-1;return n}if(V===X1){if(Q===AJ)NJ(J);else if(Q!==q5){if(a8(J,0,0,!1),Q===vJ){if(w0(J.head),J.lookahead===0)J.strstart=0,J.block_start=0,J.insert=0}}if(G0(W),W.avail_out===0)return J.last_flush=-1,n}}if(Q!==q0)return n;if(J.wrap<=0)return X5;if(J.wrap===2)_(J,W.adler&255),_(J,W.adler>>8&255),_(J,W.adler>>16&255),_(J,W.adler>>24&255),_(J,W.total_in&255),_(J,W.total_in>>8&255),_(J,W.total_in>>16&255),_(J,W.total_in>>24&255);else L1(J,W.adler>>>16),L1(J,W.adler&65535);if(G0(W),J.wrap>0)J.wrap=-J.wrap;return J.pending!==0?n:X5},V9=(W)=>{if(p1(W))return z0;const Q=W.state.status;return W.state=null,Q===E0?p0(W,gJ):n},q9=(W,Q)=>{let J=Q.length;if(p1(W))return z0;const G=W.state,V=G.wrap;if(V===2||V===1&&G.status!==G1||G.lookahead)return z0;if(V===1)W.adler=g1(W.adler,Q,J,0);if(G.wrap=0,J>=G.w_size){if(V===0)w0(G.head),G.strstart=0,G.block_start=0,G.insert=0;let K=new Uint8Array(G.w_size);K.set(Q.subarray(J-G.w_size,J),0),Q=K,J=G.w_size}const{avail_in:q,next_in:X,input:Y}=W;W.avail_in=J,W.next_in=0,W.input=Q,V1(G);while(G.lookahead>=u){let K=G.strstart,P=G.lookahead-(u-1);do G.ins_h=A0(G,G.ins_h,G.window[K+u-1]),G.prev[K&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=K,K++;while(--P);G.strstart=K,G.lookahead=u-1,V1(G)}return G.strstart+=G.lookahead,G.block_start=G.strstart,G.insert=G.lookahead,G.lookahead=0,G.match_length=G.prev_length=u-1,G.match_available=0,W.next_in=X,W.input=Y,W.avail_in=q,G.wrap=V,n},X9=Q9,Y9=G7,P9=Q7,U9=J7,F9=J9,K9=G9,z9=V9,Z9=q9,k9="pako deflate (from Nodeca project)",w1={deflateInit:X9,deflateInit2:Y9,deflateReset:P9,deflateResetKeep:U9,deflateSetHeader:F9,deflate:K9,deflateEnd:z9,deflateSetDictionary:Z9,deflateInfo:k9},H9=(W,Q)=>{return Object.prototype.hasOwnProperty.call(W,Q)},C9=function(W){const Q=Array.prototype.slice.call(arguments,1);while(Q.length){const J=Q.shift();if(!J)continue;if(typeof J!=="object")throw new TypeError(J+"must be non-object");for(let G in J)if(H9(J,G))W[G]=J[G]}return W},$9=(W)=>{let Q=0;for(let G=0,V=W.length;G<V;G++)Q+=W[G].length;const J=new Uint8Array(Q);for(let G=0,V=0,q=W.length;G<q;G++){let X=W[G];J.set(X,V),V+=X.length}return J},P8={assign:C9,flattenChunks:$9},V7=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(W){V7=!1}var T1=new Uint8Array(256);for(let W=0;W<256;W++)T1[W]=W>=252?6:W>=248?5:W>=240?4:W>=224?3:W>=192?2:1;T1[254]=T1[254]=1;var M9=(W)=>{if(typeof TextEncoder==="function"&&TextEncoder.prototype.encode)return(new TextEncoder()).encode(W);let Q,J,G,V,q,X=W.length,Y=0;for(V=0;V<X;V++){if(J=W.charCodeAt(V),(J&64512)===55296&&V+1<X){if(G=W.charCodeAt(V+1),(G&64512)===56320)J=65536+(J-55296<<10)+(G-56320),V++}Y+=J<128?1:J<2048?2:J<65536?3:4}Q=new Uint8Array(Y);for(q=0,V=0;q<Y;V++){if(J=W.charCodeAt(V),(J&64512)===55296&&V+1<X){if(G=W.charCodeAt(V+1),(G&64512)===56320)J=65536+(J-55296<<10)+(G-56320),V++}if(J<128)Q[q++]=J;else if(J<2048)Q[q++]=192|J>>>6,Q[q++]=128|J&63;else if(J<65536)Q[q++]=224|J>>>12,Q[q++]=128|J>>>6&63,Q[q++]=128|J&63;else Q[q++]=240|J>>>18,Q[q++]=128|J>>>12&63,Q[q++]=128|J>>>6&63,Q[q++]=128|J&63}return Q},B9=(W,Q)=>{if(Q<65534){if(W.subarray&&V7)return String.fromCharCode.apply(null,W.length===Q?W:W.subarray(0,Q))}let J="";for(let G=0;G<Q;G++)J+=String.fromCharCode(W[G]);return J},j9=(W,Q)=>{const J=Q||W.length;if(typeof TextDecoder==="function"&&TextDecoder.prototype.decode)return(new TextDecoder()).decode(W.subarray(0,Q));let G,V;const q=new Array(J*2);for(V=0,G=0;G<J;){let X=W[G++];if(X<128){q[V++]=X;continue}let Y=T1[X];if(Y>4){q[V++]=65533,G+=Y-1;continue}X&=Y===2?31:Y===3?15:7;while(Y>1&&G<J)X=X<<6|W[G++]&63,Y--;if(Y>1){q[V++]=65533;continue}if(X<65536)q[V++]=X;else X-=65536,q[V++]=55296|X>>10&1023,q[V++]=56320|X&1023}return B9(q,V)},L9=(W,Q)=>{if(Q=Q||W.length,Q>W.length)Q=W.length;let J=Q-1;while(J>=0&&(W[J]&192)===128)J--;if(J<0)return Q;if(J===0)return Q;return J+T1[W[J]]>Q?J:Q},S1={string2buf:M9,buf2string:j9,utf8border:L9},q7=R9,X7=Object.prototype.toString,{Z_NO_FLUSH:O9,Z_SYNC_FLUSH:I9,Z_FULL_FLUSH:w9,Z_FINISH:D9,Z_OK:q8,Z_STREAM_END:x9,Z_DEFAULT_COMPRESSION:N9,Z_DEFAULT_STRATEGY:A9,Z_DEFLATED:v9}=m0;f1.prototype.push=function(W,Q){const J=this.strm,G=this.options.chunkSize;let V,q;if(this.ended)return!1;if(Q===~~Q)q=Q;else q=Q===!0?D9:O9;if(typeof W==="string")J.input=S1.string2buf(W);else if(X7.call(W)==="[object ArrayBuffer]")J.input=new Uint8Array(W);else J.input=W;J.next_in=0,J.avail_in=J.input.length;for(;;){if(J.avail_out===0)J.output=new Uint8Array(G),J.next_out=0,J.avail_out=G;if((q===I9||q===w9)&&J.avail_out<=6){this.onData(J.output.subarray(0,J.next_out)),J.avail_out=0;continue}if(V=w1.deflate(J,q),V===x9){if(J.next_out>0)this.onData(J.output.subarray(0,J.next_out));return V=w1.deflateEnd(this.strm),this.onEnd(V),this.ended=!0,V===q8}if(J.avail_out===0){this.onData(J.output);continue}if(q>0&&J.next_out>0){this.onData(J.output.subarray(0,J.next_out)),J.avail_out=0;continue}if(J.avail_in===0)break}return!0};f1.prototype.onData=function(W){this.chunks.push(W)};f1.prototype.onEnd=function(W){if(W===q8)this.result=P8.flattenChunks(this.chunks);this.chunks=[],this.err=W,this.msg=this.strm.msg};var S9=f1,y9=Y6,E9=g9,p9=T9,f9=m0,h9={Deflate:S9,deflate:y9,deflateRaw:E9,gzip:p9,constants:f9},t1=16209,b9=16191,m9=function W(Q,J){let G,V,q,X,Y,K,P,U,C,F,z,$,D,g,T,S,E,O,f,d,R,j,I,k;const Z=Q.state;G=Q.next_in,I=Q.input,V=G+(Q.avail_in-5),q=Q.next_out,k=Q.output,X=q-(J-Q.avail_out),Y=q+(Q.avail_out-257),K=Z.dmax,P=Z.wsize,U=Z.whave,C=Z.wnext,F=Z.window,z=Z.hold,$=Z.bits,D=Z.lencode,g=Z.distcode,T=(1<<Z.lenbits)-1,S=(1<<Z.distbits)-1;W:do{if($<15)z+=I[G++]<<$,$+=8,z+=I[G++]<<$,$+=8;E=D[z&T];J:for(;;){if(O=E>>>24,z>>>=O,$-=O,O=E>>>16&255,O===0)k[q++]=E&65535;else if(O&16){if(f=E&65535,O&=15,O){if($<O)z+=I[G++]<<$,$+=8;f+=z&(1<<O)-1,z>>>=O,$-=O}if($<15)z+=I[G++]<<$,$+=8,z+=I[G++]<<$,$+=8;E=g[z&S];Q:for(;;){if(O=E>>>24,z>>>=O,$-=O,O=E>>>16&255,O&16){if(d=E&65535,O&=15,$<O){if(z+=I[G++]<<$,$+=8,$<O)z+=I[G++]<<$,$+=8}if(d+=z&(1<<O)-1,d>K){Q.msg="invalid distance too far back",Z.mode=t1;break W}if(z>>>=O,$-=O,O=q-X,d>O){if(O=d-O,O>U){if(Z.sane){Q.msg="invalid distance too far back",Z.mode=t1;break W}}if(R=0,j=F,C===0){if(R+=P-O,O<f){f-=O;do k[q++]=F[R++];while(--O);R=q-d,j=k}}else if(C<O){if(R+=P+C-O,O-=C,O<f){f-=O;do k[q++]=F[R++];while(--O);if(R=0,C<f){O=C,f-=O;do k[q++]=F[R++];while(--O);R=q-d,j=k}}}else if(R+=C-O,O<f){f-=O;do k[q++]=F[R++];while(--O);R=q-d,j=k}while(f>2)k[q++]=j[R++],k[q++]=j[R++],k[q++]=j[R++],f-=3;if(f){if(k[q++]=j[R++],f>1)k[q++]=j[R++]}}else{R=q-d;do k[q++]=k[R++],k[q++]=k[R++],k[q++]=k[R++],f-=3;while(f>2);if(f){if(k[q++]=k[R++],f>1)k[q++]=k[R++]}}}else if((O&64)===0){E=g[(E&65535)+(z&(1<<O)-1)];continue Q}else{Q.msg="invalid distance code",Z.mode=t1;break W}break}}else if((O&64)===0){E=D[(E&65535)+(z&(1<<O)-1)];continue J}else if(O&32){Z.mode=b9;break W}else{Q.msg="invalid literal/length code",Z.mode=t1;break W}break}}while(G<V&&q<Y);f=$>>3,G-=f,$-=f<<3,z&=(1<<$)-1,Q.next_in=G,Q.next_out=q,Q.avail_in=G<V?5+(V-G):5-(G-V),Q.avail_out=q<Y?257+(Y-q):257-(q-Y),Z.hold=z,Z.bits=$;return},J1=15,P5=852,U5=592,F5=0,b8=1,K5=2,u9=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),d9=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),c9=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),_9=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),l9=(W,Q,J,G,V,q,X,Y)=>{const K=Y.bits;let P=0,U=0,C=0,F=0,z=0,$=0,D=0,g=0,T=0,S=0,E,O,f,d,R,j=null,I;const k=new Uint16Array(J1+1),Z=new Uint16Array(J1+1);let H=null,B,L,v;for(P=0;P<=J1;P++)k[P]=0;for(U=0;U<G;U++)k[Q[J+U]]++;z=K;for(F=J1;F>=1;F--)if(k[F]!==0)break;if(z>F)z=F;if(F===0)return V[q++]=1<<24|64<<16|0,V[q++]=1<<24|64<<16|0,Y.bits=1,0;for(C=1;C<F;C++)if(k[C]!==0)break;if(z<C)z=C;g=1;for(P=1;P<=J1;P++)if(g<<=1,g-=k[P],g<0)return-1;if(g>0&&(W===F5||F!==1))return-1;Z[1]=0;for(P=1;P<J1;P++)Z[P+1]=Z[P]+k[P];for(U=0;U<G;U++)if(Q[J+U]!==0)X[Z[Q[J+U]]++]=U;if(W===F5)j=H=X,I=20;else if(W===b8)j=u9,H=d9,I=257;else j=c9,H=_9,I=0;if(S=0,U=0,P=C,R=q,$=z,D=0,f=-1,T=1<<z,d=T-1,W===b8&&T>P5||W===K5&&T>U5)return 1;for(;;){if(B=P-D,X[U]+1<I)L=0,v=X[U];else if(X[U]>=I)L=H[X[U]-I],v=j[X[U]-I];else L=96,v=0;E=1<<P-D,O=1<<$,C=O;do O-=E,V[R+(S>>D)+O]=B<<24|L<<16|v|0;while(O!==0);E=1<<P-1;while(S&E)E>>=1;if(E!==0)S&=E-1,S+=E;else S=0;if(U++,--k[P]===0){if(P===F)break;P=Q[J+X[U]]}if(P>z&&(S&d)!==f){if(D===0)D=z;R+=C,$=P-D,g=1<<$;while($+D<F){if(g-=k[$+D],g<=0)break;$++,g<<=1}if(T+=1<<$,W===b8&&T>P5||W===K5&&T>U5)return 1;f=S&d,V[f]=z<<24|$<<16|R-q|0}}if(S!==0)V[R+S]=P-D<<24|64<<16|0;return Y.bits=z,0},D1=l9,i9=0,Y7=1,P7=2,{Z_FINISH:z5,Z_BLOCK:r9,Z_TREES:W8,Z_OK:b0,Z_STREAM_END:o9,Z_NEED_DICT:a9,Z_STREAM_ERROR:X0,Z_DATA_ERROR:U7,Z_MEM_ERROR:F7,Z_BUF_ERROR:n9,Z_DEFLATED:Z5}=m0,U8=16180,k5=16181,H5=16182,C5=16183,$5=16184,M5=16185,B5=16186,j5=16187,L5=16188,R5=16189,X8=16190,M0=16191,m8=16192,O5=16193,u8=16194,I5=16195,w5=16196,D5=16197,x5=16198,J8=16199,Q8=16200,N5=16201,A5=16202,v5=16203,g5=16204,T5=16205,d8=16206,S5=16207,y5=16208,i=16209,K7=16210,z7=16211,s9=852,e9=592,t9=15,WQ=t9,E5=(W)=>{return(W>>>24&255)+(W>>>8&65280)+((W&65280)<<8)+((W&255)<<24)},u0=(W)=>{if(!W)return 1;const Q=W.state;if(!Q||Q.strm!==W||Q.mode<U8||Q.mode>z7)return 1;return 0},Z7=(W)=>{if(u0(W))return X0;const Q=W.state;if(W.total_in=W.total_out=Q.total=0,W.msg="",Q.wrap)W.adler=Q.wrap&1;return Q.mode=U8,Q.last=0,Q.havedict=0,Q.flags=-1,Q.dmax=32768,Q.head=null,Q.hold=0,Q.bits=0,Q.lencode=Q.lendyn=new Int32Array(s9),Q.distcode=Q.distdyn=new Int32Array(e9),Q.sane=1,Q.back=-1,b0},k7=(W)=>{if(u0(W))return X0;const Q=W.state;return Q.wsize=0,Q.whave=0,Q.wnext=0,Z7(W)},H7=(W,Q)=>{let J;if(u0(W))return X0;const G=W.state;if(Q<0)J=0,Q=-Q;else if(J=(Q>>4)+5,Q<48)Q&=15;if(Q&&(Q<8||Q>15))return X0;if(G.window!==null&&G.wbits!==Q)G.window=null;return G.wrap=J,G.wbits=Q,k7(W)},C7=(W,Q)=>{if(!W)return X0;const J=new JQ;W.state=J,J.strm=W,J.window=null,J.mode=U8;const G=H7(W,Q);if(G!==b0)W.state=null;return G},QQ=(W)=>{return C7(W,WQ)},p5=!0,c8,_8,GQ=(W)=>{if(p5){c8=new Int32Array(512),_8=new Int32Array(32);let Q=0;while(Q<144)W.lens[Q++]=8;while(Q<256)W.lens[Q++]=9;while(Q<280)W.lens[Q++]=7;while(Q<288)W.lens[Q++]=8;D1(Y7,W.lens,0,288,c8,0,W.work,{bits:9}),Q=0;while(Q<32)W.lens[Q++]=5;D1(P7,W.lens,0,32,_8,0,W.work,{bits:5}),p5=!1}W.lencode=c8,W.lenbits=9,W.distcode=_8,W.distbits=5},$7=(W,Q,J,G)=>{let V;const q=W.state;if(q.window===null)q.wsize=1<<q.wbits,q.wnext=0,q.whave=0,q.window=new Uint8Array(q.wsize);if(G>=q.wsize)q.window.set(Q.subarray(J-q.wsize,J),0),q.wnext=0,q.whave=q.wsize;else{if(V=q.wsize-q.wnext,V>G)V=G;if(q.window.set(Q.subarray(J-G,J-G+V),q.wnext),G-=V,G)q.window.set(Q.subarray(J-G,J),0),q.wnext=G,q.whave=q.wsize;else{if(q.wnext+=V,q.wnext===q.wsize)q.wnext=0;if(q.whave<q.wsize)q.whave+=V}}return 0},VQ=(W,Q)=>{let J,G,V,q,X,Y,K,P,U,C,F,z,$,D,g=0,T,S,E,O,f,d,R,j;const I=new Uint8Array(4);let k,Z;const H=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(u0(W)||!W.output||!W.input&&W.avail_in!==0)return X0;if(J=W.state,J.mode===M0)J.mode=m8;X=W.next_out,V=W.output,K=W.avail_out,q=W.next_in,G=W.input,Y=W.avail_in,P=J.hold,U=J.bits,C=Y,F=K,j=b0;W:for(;;)switch(J.mode){case U8:if(J.wrap===0){J.mode=m8;break}while(U<16){if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}if(J.wrap&2&&P===35615){if(J.wbits===0)J.wbits=15;J.check=0,I[0]=P&255,I[1]=P>>>8&255,J.check=a(J.check,I,2,0),P=0,U=0,J.mode=k5;break}if(J.head)J.head.done=!1;if(!(J.wrap&1)||(((P&255)<<8)+(P>>8))%31){W.msg="incorrect header check",J.mode=i;break}if((P&15)!==Z5){W.msg="unknown compression method",J.mode=i;break}if(P>>>=4,U-=4,R=(P&15)+8,J.wbits===0)J.wbits=R;if(R>15||R>J.wbits){W.msg="invalid window size",J.mode=i;break}J.dmax=1<<J.wbits,J.flags=0,W.adler=J.check=1,J.mode=P&512?R5:M0,P=0,U=0;break;case k5:while(U<16){if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}if(J.flags=P,(J.flags&255)!==Z5){W.msg="unknown compression method",J.mode=i;break}if(J.flags&57344){W.msg="unknown header flags set",J.mode=i;break}if(J.head)J.head.text=P>>8&1;if(J.flags&512&&J.wrap&4)I[0]=P&255,I[1]=P>>>8&255,J.check=a(J.check,I,2,0);P=0,U=0,J.mode=H5;case H5:while(U<32){if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}if(J.head)J.head.time=P;if(J.flags&512&&J.wrap&4)I[0]=P&255,I[1]=P>>>8&255,I[2]=P>>>16&255,I[3]=P>>>24&255,J.check=a(J.check,I,4,0);P=0,U=0,J.mode=C5;case C5:while(U<16){if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}if(J.head)J.head.xflags=P&255,J.head.os=P>>8;if(J.flags&512&&J.wrap&4)I[0]=P&255,I[1]=P>>>8&255,J.check=a(J.check,I,2,0);P=0,U=0,J.mode=$5;case $5:if(J.flags&1024){while(U<16){if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}if(J.length=P,J.head)J.head.extra_len=P;if(J.flags&512&&J.wrap&4)I[0]=P&255,I[1]=P>>>8&255,J.check=a(J.check,I,2,0);P=0,U=0}else if(J.head)J.head.extra=null;J.mode=M5;case M5:if(J.flags&1024){if(z=J.length,z>Y)z=Y;if(z){if(J.head){if(R=J.head.extra_len-J.length,!J.head.extra)J.head.extra=new Uint8Array(J.head.extra_len);J.head.extra.set(G.subarray(q,q+z),R)}if(J.flags&512&&J.wrap&4)J.check=a(J.check,G,z,q);Y-=z,q+=z,J.length-=z}if(J.length)break W}J.length=0,J.mode=B5;case B5:if(J.flags&2048){if(Y===0)break W;z=0;do if(R=G[q+z++],J.head&&R&&J.length<65536)J.head.name+=String.fromCharCode(R);while(R&&z<Y);if(J.flags&512&&J.wrap&4)J.check=a(J.check,G,z,q);if(Y-=z,q+=z,R)break W}else if(J.head)J.head.name=null;J.length=0,J.mode=j5;case j5:if(J.flags&4096){if(Y===0)break W;z=0;do if(R=G[q+z++],J.head&&R&&J.length<65536)J.head.comment+=String.fromCharCode(R);while(R&&z<Y);if(J.flags&512&&J.wrap&4)J.check=a(J.check,G,z,q);if(Y-=z,q+=z,R)break W}else if(J.head)J.head.comment=null;J.mode=L5;case L5:if(J.flags&512){while(U<16){if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}if(J.wrap&4&&P!==(J.check&65535)){W.msg="header crc mismatch",J.mode=i;break}P=0,U=0}if(J.head)J.head.hcrc=J.flags>>9&1,J.head.done=!0;W.adler=J.check=0,J.mode=M0;break;case R5:while(U<32){if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}W.adler=J.check=E5(P),P=0,U=0,J.mode=X8;case X8:if(J.havedict===0)return W.next_out=X,W.avail_out=K,W.next_in=q,W.avail_in=Y,J.hold=P,J.bits=U,a9;W.adler=J.check=1,J.mode=M0;case M0:if(Q===r9||Q===W8)break W;case m8:if(J.last){P>>>=U&7,U-=U&7,J.mode=d8;break}while(U<3){if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}switch(J.last=P&1,P>>>=1,U-=1,P&3){case 0:J.mode=O5;break;case 1:if(GQ(J),J.mode=J8,Q===W8){P>>>=2,U-=2;break W}break;case 2:J.mode=w5;break;case 3:W.msg="invalid block type",J.mode=i}P>>>=2,U-=2;break;case O5:P>>>=U&7,U-=U&7;while(U<32){if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}if((P&65535)!==(P>>>16^65535)){W.msg="invalid stored block lengths",J.mode=i;break}if(J.length=P&65535,P=0,U=0,J.mode=u8,Q===W8)break W;case u8:J.mode=I5;case I5:if(z=J.length,z){if(z>Y)z=Y;if(z>K)z=K;if(z===0)break W;V.set(G.subarray(q,q+z),X),Y-=z,q+=z,K-=z,X+=z,J.length-=z;break}J.mode=M0;break;case w5:while(U<14){if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}if(J.nlen=(P&31)+257,P>>>=5,U-=5,J.ndist=(P&31)+1,P>>>=5,U-=5,J.ncode=(P&15)+4,P>>>=4,U-=4,J.nlen>286||J.ndist>30){W.msg="too many length or distance symbols",J.mode=i;break}J.have=0,J.mode=D5;case D5:while(J.have<J.ncode){while(U<3){if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}J.lens[H[J.have++]]=P&7,P>>>=3,U-=3}while(J.have<19)J.lens[H[J.have++]]=0;if(J.lencode=J.lendyn,J.lenbits=7,k={bits:J.lenbits},j=D1(i9,J.lens,0,19,J.lencode,0,J.work,k),J.lenbits=k.bits,j){W.msg="invalid code lengths set",J.mode=i;break}J.have=0,J.mode=x5;case x5:while(J.have<J.nlen+J.ndist){for(;;){if(g=J.lencode[P&(1<<J.lenbits)-1],T=g>>>24,S=g>>>16&255,E=g&65535,T<=U)break;if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}if(E<16)P>>>=T,U-=T,J.lens[J.have++]=E;else{if(E===16){Z=T+2;while(U<Z){if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}if(P>>>=T,U-=T,J.have===0){W.msg="invalid bit length repeat",J.mode=i;break}R=J.lens[J.have-1],z=3+(P&3),P>>>=2,U-=2}else if(E===17){Z=T+3;while(U<Z){if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}P>>>=T,U-=T,R=0,z=3+(P&7),P>>>=3,U-=3}else{Z=T+7;while(U<Z){if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}P>>>=T,U-=T,R=0,z=11+(P&127),P>>>=7,U-=7}if(J.have+z>J.nlen+J.ndist){W.msg="invalid bit length repeat",J.mode=i;break}while(z--)J.lens[J.have++]=R}}if(J.mode===i)break;if(J.lens[256]===0){W.msg="invalid code -- missing end-of-block",J.mode=i;break}if(J.lenbits=9,k={bits:J.lenbits},j=D1(Y7,J.lens,0,J.nlen,J.lencode,0,J.work,k),J.lenbits=k.bits,j){W.msg="invalid literal/lengths set",J.mode=i;break}if(J.distbits=6,J.distcode=J.distdyn,k={bits:J.distbits},j=D1(P7,J.lens,J.nlen,J.ndist,J.distcode,0,J.work,k),J.distbits=k.bits,j){W.msg="invalid distances set",J.mode=i;break}if(J.mode=J8,Q===W8)break W;case J8:J.mode=Q8;case Q8:if(Y>=6&&K>=258){if(W.next_out=X,W.avail_out=K,W.next_in=q,W.avail_in=Y,J.hold=P,J.bits=U,m9(W,F),X=W.next_out,V=W.output,K=W.avail_out,q=W.next_in,G=W.input,Y=W.avail_in,P=J.hold,U=J.bits,J.mode===M0)J.back=-1;break}J.back=0;for(;;){if(g=J.lencode[P&(1<<J.lenbits)-1],T=g>>>24,S=g>>>16&255,E=g&65535,T<=U)break;if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}if(S&&(S&240)===0){O=T,f=S,d=E;for(;;){if(g=J.lencode[d+((P&(1<<O+f)-1)>>O)],T=g>>>24,S=g>>>16&255,E=g&65535,O+T<=U)break;if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}P>>>=O,U-=O,J.back+=O}if(P>>>=T,U-=T,J.back+=T,J.length=E,S===0){J.mode=T5;break}if(S&32){J.back=-1,J.mode=M0;break}if(S&64){W.msg="invalid literal/length code",J.mode=i;break}J.extra=S&15,J.mode=N5;case N5:if(J.extra){Z=J.extra;while(U<Z){if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}J.length+=P&(1<<J.extra)-1,P>>>=J.extra,U-=J.extra,J.back+=J.extra}J.was=J.length,J.mode=A5;case A5:for(;;){if(g=J.distcode[P&(1<<J.distbits)-1],T=g>>>24,S=g>>>16&255,E=g&65535,T<=U)break;if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}if((S&240)===0){O=T,f=S,d=E;for(;;){if(g=J.distcode[d+((P&(1<<O+f)-1)>>O)],T=g>>>24,S=g>>>16&255,E=g&65535,O+T<=U)break;if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}P>>>=O,U-=O,J.back+=O}if(P>>>=T,U-=T,J.back+=T,S&64){W.msg="invalid distance code",J.mode=i;break}J.offset=E,J.extra=S&15,J.mode=v5;case v5:if(J.extra){Z=J.extra;while(U<Z){if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}J.offset+=P&(1<<J.extra)-1,P>>>=J.extra,U-=J.extra,J.back+=J.extra}if(J.offset>J.dmax){W.msg="invalid distance too far back",J.mode=i;break}J.mode=g5;case g5:if(K===0)break W;if(z=F-K,J.offset>z){if(z=J.offset-z,z>J.whave){if(J.sane){W.msg="invalid distance too far back",J.mode=i;break}}if(z>J.wnext)z-=J.wnext,$=J.wsize-z;else $=J.wnext-z;if(z>J.length)z=J.length;D=J.window}else D=V,$=X-J.offset,z=J.length;if(z>K)z=K;K-=z,J.length-=z;do V[X++]=D[$++];while(--z);if(J.length===0)J.mode=Q8;break;case T5:if(K===0)break W;V[X++]=J.length,K--,J.mode=Q8;break;case d8:if(J.wrap){while(U<32){if(Y===0)break W;Y--,P|=G[q++]<<U,U+=8}if(F-=K,W.total_out+=F,J.total+=F,J.wrap&4&&F)W.adler=J.check=J.flags?a(J.check,V,F,X-F):g1(J.check,V,F,X-F);if(F=K,J.wrap&4&&(J.flags?P:E5(P))!==J.check){W.msg="incorrect data check",J.mode=i;break}P=0,U=0}J.mode=S5;case S5:if(J.wrap&&J.flags){while(U<32){if(Y===0)break W;Y--,P+=G[q++]<<U,U+=8}if(J.wrap&4&&P!==(J.total&4294967295)){W.msg="incorrect length check",J.mode=i;break}P=0,U=0}J.mode=y5;case y5:j=o9;break W;case i:j=U7;break W;case K7:return F7;case z7:default:return X0}if(W.next_out=X,W.avail_out=K,W.next_in=q,W.avail_in=Y,J.hold=P,J.bits=U,J.wsize||F!==W.avail_out&&J.mode<i&&(J.mode<d8||Q!==z5)){if($7(W,W.output,W.next_out,F-W.avail_out));}if(C-=W.avail_in,F-=W.avail_out,W.total_in+=C,W.total_out+=F,J.total+=F,J.wrap&4&&F)W.adler=J.check=J.flags?a(J.check,V,F,W.next_out-F):g1(J.check,V,F,W.next_out-F);if(W.data_type=J.bits+(J.last?64:0)+(J.mode===M0?128:0)+(J.mode===J8||J.mode===u8?256:0),(C===0&&F===0||Q===z5)&&j===b0)j=n9;return j},qQ=(W)=>{if(u0(W))return X0;let Q=W.state;if(Q.window)Q.window=null;return W.state=null,b0},XQ=(W,Q)=>{if(u0(W))return X0;const J=W.state;if((J.wrap&2)===0)return X0;return J.head=Q,Q.done=!1,b0},YQ=(W,Q)=>{const J=Q.length;let G,V,q;if(u0(W))return X0;if(G=W.state,G.wrap!==0&&G.mode!==X8)return X0;if(G.mode===X8){if(V=1,V=g1(V,Q,J,0),V!==G.check)return U7}if(q=$7(W,Q,J,J),q)return G.mode=K7,F7;return G.havedict=1,b0},PQ=k7,UQ=H7,FQ=Z7,KQ=QQ,zQ=C7,ZQ=VQ,kQ=qQ,HQ=XQ,CQ=YQ,$Q="pako inflate (from Nodeca project)",j0={inflateReset:PQ,inflateReset2:UQ,inflateResetKeep:FQ,inflateInit:KQ,inflateInit2:zQ,inflate:ZQ,inflateEnd:kQ,inflateGetHeader:HQ,inflateSetDictionary:CQ,inflateInfo:$Q},BQ=MQ,M7=Object.prototype.toString,{Z_NO_FLUSH:jQ,Z_FINISH:LQ,Z_OK:y1,Z_STREAM_END:l8,Z_NEED_DICT:i8,Z_STREAM_ERROR:RQ,Z_DATA_ERROR:f5,Z_MEM_ERROR:OQ}=m0;h1.prototype.push=function(W,Q){const J=this.strm,G=this.options.chunkSize,V=this.options.dictionary;let q,X,Y;if(this.ended)return!1;if(Q===~~Q)X=Q;else X=Q===!0?LQ:jQ;if(M7.call(W)==="[object ArrayBuffer]")J.input=new Uint8Array(W);else J.input=W;J.next_in=0,J.avail_in=J.input.length;for(;;){if(J.avail_out===0)J.output=new Uint8Array(G),J.next_out=0,J.avail_out=G;if(q=j0.inflate(J,X),q===i8&&V){if(q=j0.inflateSetDictionary(J,V),q===y1)q=j0.inflate(J,X);else if(q===f5)q=i8}while(J.avail_in>0&&q===l8&&J.state.wrap>0&&W[J.next_in]!==0)j0.inflateReset(J),q=j0.inflate(J,X);switch(q){case RQ:case f5:case i8:case OQ:return this.onEnd(q),this.ended=!0,!1}if(Y=J.avail_out,J.next_out){if(J.avail_out===0||q===l8)if(this.options.to==="string"){let K=S1.utf8border(J.output,J.next_out),P=J.next_out-K,U=S1.buf2string(J.output,K);if(J.next_out=P,J.avail_out=G-P,P)J.output.set(J.output.subarray(K,K+P),0);this.onData(U)}else this.onData(J.output.length===J.next_out?J.output:J.output.subarray(0,J.next_out))}if(q===y1&&Y===0)continue;if(q===l8)return q=j0.inflateEnd(this.strm),this.onEnd(q),this.ended=!0,!0;if(J.avail_in===0)break}return!0};h1.prototype.onData=function(W){this.chunks.push(W)};h1.prototype.onEnd=function(W){if(W===y1)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=P8.flattenChunks(this.chunks);this.chunks=[],this.err=W,this.msg=this.strm.msg};var wQ=h1,DQ=P6,xQ=IQ,NQ=P6,AQ=m0,vQ={Inflate:wQ,inflate:DQ,inflateRaw:xQ,ungzip:NQ,constants:AQ},{Deflate:gQ,deflate:TQ,deflateRaw:SQ,gzip:yQ}=h9,{Inflate:EQ,inflate:pQ,inflateRaw:fQ,ungzip:hQ}=vQ,bQ=gQ,mQ=TQ,uQ=SQ,dQ=yQ,cQ=EQ,_Q=pQ,lQ=fQ,iQ=hQ,rQ=m0,d0={Deflate:bQ,deflate:mQ,deflateRaw:uQ,gzip:dQ,Inflate:cQ,inflate:_Q,inflateRaw:lQ,ungzip:iQ,constants:rQ};var D8=function(W){return W instanceof Uint8Array||ArrayBuffer.isView(W)&&W.constructor.name==="Uint8Array"},$6=function(W){if(!Number.isSafeInteger(W)||W<0)throw Error("positive integer expected, got "+W)},n0=function(W,...Q){if(!D8(W))throw Error("Uint8Array expected");if(Q.length>0&&!Q.includes(W.length))throw Error("Uint8Array expected of length "+Q+", got length="+W.length)},d7=function(W){if(typeof W!="function"||typeof W.create!="function")throw Error("Hash should be wrapped by utils.createHasher");$6(W.outputLen),$6(W.blockLen)},$8=function(W,Q=!0){if(W.destroyed)throw Error("Hash instance has been destroyed");if(Q&&W.finished)throw Error("Hash#digest() has already been called")},M8=function(...W){for(let Q=0;Q<W.length;Q++)W[Q].fill(0)},U6=function(W){return new DataView(W.buffer,W.byteOffset,W.byteLength)},k0=function(W,Q){return W<<32-Q|W>>>Q},Z1=function(W){if(n0(W),c7)return W.toHex();let Q="";for(let J=0;J<W.length;J++)Q+=oQ[W[J]];return Q},R7=function(W){return W>=B7&&W<=aQ?W-B7:W>=j7&&W<=nQ?W-(j7-10):W>=L7&&W<=sQ?W-(L7-10):void 0},B8=function(W){if(typeof W!="string")throw Error("hex string expected, got "+typeof W);if(c7)return Uint8Array.fromHex(W);const Q=W.length,J=Q/2;if(Q%2)throw Error("hex string expected, got unpadded hex of length "+Q);const G=new Uint8Array(J);for(let V=0,q=0;V<J;V++,q+=2){const X=R7(W.charCodeAt(q)),Y=R7(W.charCodeAt(q+1));if(X===void 0||Y===void 0){const K=W[q]+W[q+1];throw Error('hex string expected, got non-hex character "'+K+'" at index '+q)}G[V]=16*X+Y}return G},_7=function(W){if(typeof W!="string")throw Error("string expected");return new Uint8Array((new TextEncoder()).encode(W))},x6=function(W){return typeof W=="string"&&(W=_7(W)),n0(W),W},H0=function(...W){let Q=0;for(let G=0;G<W.length;G++){const V=W[G];n0(V),Q+=V.length}const J=new Uint8Array(Q);for(let G=0,V=0;G<W.length;G++){const q=W[G];J.set(q,V),V+=q.length}return J},eQ=function(W){const Q=(G)=>W().update(x6(G)).digest(),J=W();return Q.outputLen=J.outputLen,Q.blockLen=J.blockLen,Q.create=()=>W(),Q},j8=function(W=32){if(P1&&typeof P1.getRandomValues=="function")return P1.getRandomValues(new Uint8Array(W));if(P1&&typeof P1.randomBytes=="function")return Uint8Array.from(P1.randomBytes(W));throw Error("crypto.getRandomValues must be defined")},tQ=function(W,Q,J){return W&Q^W&J^Q&J},L8=function(W,Q=""){if(typeof W!="boolean")throw Error((Q&&`"${Q}"`)+"expected boolean, got type="+typeof W);return W},l0=function(W,Q,J=""){const G=D8(W),V=W?.length,q=Q!==void 0;if(!G||q&&V!==Q)throw Error((J&&`"${J}" `)+"expected Uint8Array"+(q?" of length "+Q:"")+", got "+(G?"length="+V:"type="+typeof W));return W},F8=function(W){const Q=W.toString(16);return 1&Q.length?"0"+Q:Q},o7=function(W){if(typeof W!="string")throw Error("hex string expected, got "+typeof W);return W===""?v6:BigInt("0x"+W)},C1=function(W){return o7(Z1(W))},a7=function(W){return n0(W),o7(Z1(Uint8Array.from(W).reverse()))},x8=function(W,Q){return B8(W.toString(16).padStart(2*Q,"0"))},n7=function(W,Q){return x8(W,Q).reverse()},r=function(W,Q,J){let G;if(typeof Q=="string")try{G=B8(Q)}catch(q){throw Error(W+" must be hex string or Uint8Array, cause: "+q)}else{if(!D8(Q))throw Error(W+" must be hex string or Uint8Array");G=Uint8Array.from(Q)}const V=G.length;if(typeof J=="number"&&V!==J)throw Error(W+" of length "+J+" expected, got "+V);return G},j6=function(W,Q,J){return F6(W)&&F6(Q)&&F6(J)&&Q<=W&&W<J},s7=function(W){let Q;for(Q=0;W>v6;W>>=B6,Q+=1);return Q},g6=function(W,Q,J={}){if(!W||typeof W!="object")throw Error("expected valid options object");function G(V,q,X){const Y=W[V];if(X&&Y===void 0)return;const K=typeof Y;if(K!==q||Y===null)throw Error(`param "${V}" is invalid: expected ${q}, got ${K}`)}Object.entries(Q).forEach(([V,q])=>G(V,q,!1)),Object.entries(J).forEach(([V,q])=>G(V,q,!0))},O7=function(W){const Q=new WeakMap;return(J,...G)=>{const V=Q.get(J);if(V!==void 0)return V;const q=W(J,...G);return Q.set(J,q),q}},P0=function(W,Q){const J=W%Q;return J>=Q0?J:Q+J},Y0=function(W,Q,J){let G=W;for(;Q-- >Q0;)G*=G,G%=J;return G},w7=function(W,Q){if(W===Q0)throw Error("invert: expected non-zero number");if(Q<=Q0)throw Error("invert: expected positive modulus, got "+Q);let J=P0(W,Q),G=Q,V=Q0,q=W0;for(;J!==Q0;){const X=G%J,Y=V-q*(G/J);G=J,J=X,V=q,q=Y}if(G!==W0)throw Error("invert: does not exist");return P0(V,Q)},T6=function(W,Q,J){if(!W.eql(W.sqr(Q),J))throw Error("Cannot find square root")},QW=function(W,Q){const J=(W.ORDER+W0)/t7,G=W.pow(Q,J);return T6(W,G,Q),G},GG=function(W,Q){const J=(W.ORDER-WW)/JW,G=W.mul(Q,r0),V=W.pow(G,J),q=W.mul(Q,V),X=W.mul(W.mul(q,r0),V),Y=W.mul(q,W.sub(X,W.ONE));return T6(W,Y,Q),Y},D7=function(W){if(W<e7)throw Error("sqrt is not defined for small field");let Q=W-W0,J=0;for(;Q%r0===Q0;)Q/=r0,J++;let G=r0;const V=_1(W);for(;x7(V,G)===1;)if(G++>1000)throw Error("Cannot find square root: probably non-prime P");if(J===1)return QW;let q=V.pow(G,Q);const X=(Q+W0)/r0;return function(Y,K){if(Y.is0(K))return K;if(x7(Y,K)!==1)throw Error("Cannot find square root");let P=J,U=Y.mul(Y.ONE,q),C=Y.pow(K,Q),F=Y.pow(K,X);for(;!Y.eql(C,Y.ONE);){if(Y.is0(C))return Y.ZERO;let z=1,$=Y.sqr(C);for(;!Y.eql($,Y.ONE);)if(z++,$=Y.sqr($),z===P)throw Error("Cannot find square root");const D=W0<<BigInt(P-z-1),g=Y.pow(U,D);P=z,U=Y.sqr(g),C=Y.mul(C,U),F=Y.mul(F,g)}return F}},VG=function(W){return W%t7===e7?QW:W%JW===WW?GG:W%I7===QG?function(Q){const J=_1(Q),G=D7(Q),V=G(J,J.neg(J.ONE)),q=G(J,V),X=G(J,J.neg(V)),Y=(Q+JG)/I7;return(K,P)=>{let U=K.pow(P,Y),C=K.mul(U,V);const F=K.mul(U,q),z=K.mul(U,X),$=K.eql(K.sqr(C),P),D=K.eql(K.sqr(F),P);U=K.cmov(U,C,$),C=K.cmov(z,F,D);const g=K.eql(K.sqr(C),P),T=K.cmov(U,C,g);return T6(K,T,P),T}}(W):D7(W)},GW=function(W,Q,J=!1){const G=Array(Q.length).fill(J?W.ZERO:void 0),V=Q.reduce((X,Y,K)=>W.is0(Y)?X:(G[K]=X,W.mul(X,Y)),W.ONE),q=W.inv(V);return Q.reduceRight((X,Y,K)=>W.is0(Y)?X:(G[K]=W.mul(X,G[K]),W.mul(X,Y)),q),G},x7=function(W,Q){const J=(W.ORDER-W0)/r0,G=W.pow(Q,J),V=W.eql(G,W.ONE),q=W.eql(G,W.ZERO),X=W.eql(G,W.neg(W.ONE));if(!V&&!q&&!X)throw Error("invalid Legendre symbol result");return V?1:q?0:-1},VW=function(W,Q){Q!==void 0&&$6(Q);const J=Q!==void 0?Q:W.toString(2).length;return{nBitLength:J,nByteLength:Math.ceil(J/8)}},_1=function(W,Q,J=!1,G={}){if(W<=Q0)throw Error("invalid field: expected ORDER > 0, got "+W);let V,q,X,Y=!1;if(typeof Q=="object"&&Q!=null){if(G.sqrt||J)throw Error("cannot specify opts in two arguments");const F=Q;F.BITS&&(V=F.BITS),F.sqrt&&(q=F.sqrt),typeof F.isLE=="boolean"&&(J=F.isLE),typeof F.modFromBytes=="boolean"&&(Y=F.modFromBytes),X=F.allowedLengths}else typeof Q=="number"&&(V=Q),G.sqrt&&(q=G.sqrt);const{nBitLength:K,nByteLength:P}=VW(W,V);if(P>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");let U;const C=Object.freeze({ORDER:W,isLE:J,BITS:K,BYTES:P,MASK:c1(K),ZERO:Q0,ONE:W0,allowedLengths:X,create(F){return P0(F,W)},isValid(F){if(typeof F!="bigint")throw Error("invalid field element: expected bigint, got "+typeof F);return Q0<=F&&F<W},is0(F){return F===Q0},isValidNot0(F){return!C.is0(F)&&C.isValid(F)},isOdd(F){return(F&W0)===W0},neg(F){return P0(-F,W)},eql(F,z){return F===z},sqr(F){return P0(F*F,W)},add(F,z){return P0(F+z,W)},sub(F,z){return P0(F-z,W)},mul(F,z){return P0(F*z,W)},pow(F,z){return function($,D,g){if(g<Q0)throw Error("invalid exponent, negatives unsupported");if(g===Q0)return $.ONE;if(g===W0)return D;let T=$.ONE,S=D;for(;g>Q0;)g&W0&&(T=$.mul(T,S)),S=$.sqr(S),g>>=W0;return T}(C,F,z)},div(F,z){return P0(F*w7(z,W),W)},sqrN(F){return F*F},addN(F,z){return F+z},subN(F,z){return F-z},mulN(F,z){return F*z},inv(F){return w7(F,W)},sqrt:q||((F)=>(U||(U=VG(W)),U(C,F))),toBytes(F){return J?n7(F,P):x8(F,P)},fromBytes(F,z=!0){if(X){if(!X.includes(F.length)||F.length>P)throw Error("Field.fromBytes: expected "+X+" bytes, got "+F.length);const D=new Uint8Array(P);D.set(F,J?0:D.length-F.length),F=D}if(F.length!==P)throw Error("Field.fromBytes: expected "+P+" bytes, got "+F.length);let $=J?a7(F):C1(F);if(Y&&($=P0($,W)),!z&&!C.isValid($))throw Error("invalid field element: outside of range 0..ORDER");return $},invertBatch(F){return GW(C,F)},cmov(F,z,$){return $?z:F}});return Object.freeze(C)},qW=function(W){if(typeof W!="bigint")throw Error("field order must be bigint");const Q=W.toString(2).length;return Math.ceil(Q/8)},XW=function(W){const Q=qW(W);return Q+Math.ceil(Q/2)},YW=function(W,Q,J=!1){const G=W.length,V=qW(Q),q=XW(Q);if(G<16||G<q||G>1024)throw Error("expected "+q+"-1024 bytes of input, got "+G);const X=P0(J?a7(W):C1(W),Q-W0)+W0;return J?n7(X,V):x8(X,V)},R8=function(W,Q){const J=Q.negate();return W?J:Q},K6=function(W,Q){const J=GW(W.Fp,Q.map((G)=>G.Z));return Q.map((G,V)=>W.fromAffine(G.toAffine(J[V])))},PW=function(W,Q){if(!Number.isSafeInteger(W)||W<=0||W>Q)throw Error("invalid window size, expected [1.."+Q+"], got W="+W)},z6=function(W,Q){PW(W,Q);const J=2**W;return{windows:Math.ceil(Q/W)+1,windowSize:2**(W-1),mask:c1(W),maxNumber:J,shiftBy:BigInt(W)}},N7=function(W,Q,J){const{windowSize:G,mask:V,maxNumber:q,shiftBy:X}=J;let Y=Number(W&V),K=W>>X;Y>G&&(Y-=q,K+=o0);const P=Q*G;return{nextN:K,offset:P+Math.abs(Y)-1,isZero:Y===0,isNeg:Y<0,isNegF:Q%2!=0,offsetF:P}},k6=function(W){return UW.get(W)||1},A7=function(W){if(W!==k1)throw Error("invalid wNAF")},XG=function(W,Q,J,G){(function(F,z){if(!Array.isArray(F))throw Error("array expected");F.forEach(($,D)=>{if(!($ instanceof z))throw Error("invalid point at index "+D)})})(J,W),function(F,z){if(!Array.isArray(F))throw Error("array of scalars expected");F.forEach(($,D)=>{if(!z.isValid($))throw Error("invalid scalar at index "+D)})}(G,Q);const V=J.length,q=G.length;if(V!==q)throw Error("arrays of points and scalars must have equal length");const X=W.ZERO,Y=s7(BigInt(V));let K=1;Y>12?K=Y-3:Y>4?K=Y-2:Y>0&&(K=2);const P=c1(K),U=Array(Number(P)+1).fill(X);let C=X;for(let F=Math.floor((Q.BITS-1)/K)*K;F>=0;F-=K){U.fill(X);for(let $=0;$<q;$++){const D=G[$],g=Number(D>>BigInt(F)&P);U[g]=U[g].add(J[$])}let z=X;for(let $=U.length-1,D=X;$>0;$--)D=D.add(U[$]),z=z.add(D);if(C=C.add(z),F!==0)for(let $=0;$<K;$++)C=C.double()}return C},v7=function(W,Q,J){if(Q){if(Q.ORDER!==W)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return function(G){g6(G,qG.reduce((V,q)=>(V[q]="function",V),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"}))}(Q),Q}return _1(W,{isLE:J})},L6=function(W){if(!["compact","recovered","der"].includes(W))throw Error('Signature format must be "compact", "recovered", or "der"');return W},H6=function(W,Q){const J={};for(let G of Object.keys(Q))J[G]=W[G]===void 0?Q[G]:W[G];return L8(J.lowS,"lowS"),L8(J.prehash,"prehash"),J.format!==void 0&&L6(J.format),J},i0=function(W,Q){const{BYTES:J}=W;let G;if(typeof Q=="bigint")G=Q;else{let V=r("private key",Q);try{G=W.fromBytes(V)}catch(q){throw Error(`invalid private key: expected ui8a of size ${J}, got ${typeof Q}`)}}if(!W.isValidNot0(G))throw Error("invalid private key: out of range [1..N-1]");return G},PG=function(W,Q={}){const J=function(k,Z,H={},B){if(B===void 0&&(B=k==="edwards"),!Z||typeof Z!="object")throw Error(`expected valid ${k} CURVE object`);for(let N of["p","n","h"]){const M=Z[N];if(!(typeof M=="bigint"&&M>k1))throw Error(`CURVE.${N} must be positive bigint`)}const L=v7(Z.p,H.Fp,B),v=v7(Z.n,H.Fn,B),w=["Gx","Gy","a","b"];for(let N of w)if(!L.isValid(Z[N]))throw Error(`CURVE.${N} must be valid field element of CURVE.Fp`);return{CURVE:Z=Object.freeze(Object.assign({},Z)),Fp:L,Fn:v}}("weierstrass",W,Q),{Fp:G,Fn:V}=J;let q=J.CURVE;const{h:X,n:Y}=q;g6(Q,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:K}=Q;if(K&&(!G.is0(q.a)||typeof K.beta!="bigint"||!Array.isArray(K.basises)))throw Error('invalid endo: expected "beta": bigint and "basises": array');const P=ZW(G,V);function U(){if(!G.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}const C=Q.toBytes||function(k,Z,H){const{x:B,y:L}=Z.toAffine(),v=G.toBytes(B);if(L8(H,"isCompressed"),H)return U(),H0(zW(!G.isOdd(L)),v);return H0(Uint8Array.of(4),v,G.toBytes(L))},F=Q.fromBytes||function(k){l0(k,void 0,"Point");const{publicKey:Z,publicKeyUncompressed:H}=P,B=k.length,L=k[0],v=k.subarray(1);if(B!==Z||L!==2&&L!==3){if(B===H&&L===4){const w=G.BYTES,N=G.fromBytes(v.subarray(0,w)),M=G.fromBytes(v.subarray(w,2*w));if(!$(N,M))throw Error("bad point: is not on curve");return{x:N,y:M}}throw Error(`bad point: got length ${B}, expected compressed=${Z} or uncompressed=${H}`)}{const w=G.fromBytes(v);if(!G.isValid(w))throw Error("bad point: is not on curve, wrong x");const N=z(w);let M;try{M=G.sqrt(N)}catch(x){const y=x instanceof Error?": "+x.message:"";throw Error("bad point: is not on curve, sqrt error"+y)}return U(),!(1&~L)!==G.isOdd(M)&&(M=G.neg(M)),{x:w,y:M}}};function z(k){const Z=G.sqr(k),H=G.mul(Z,k);return G.add(G.add(H,G.mul(k,q.a)),q.b)}function $(k,Z){const H=G.sqr(Z),B=z(k);return G.eql(H,B)}if(!$(q.Gx,q.Gy))throw Error("bad curve params: generator point");const D=G.mul(G.pow(q.a,K8),YG),g=G.mul(G.sqr(q.b),BigInt(27));if(G.is0(G.add(D,g)))throw Error("bad curve params: a or b");function T(k,Z,H=!1){if(!G.isValid(Z)||H&&G.is0(Z))throw Error("bad point coordinate "+k);return Z}function S(k){if(!(k instanceof R))throw Error("ProjectivePoint expected")}function E(k){if(!K||!K.basises)throw Error("no endo");return function(Z,H,B){const[[L,v],[w,N]]=H,M=g7(N*Z,B),x=g7(-v*Z,B);let y=Z-M*L-x*w,p=-M*v-x*N;const A=y<R0,b=p<R0;A&&(y=-y),b&&(p=-p);const m=c1(Math.ceil(s7(B)/2))+K1;if(y<R0||y>=m||p<R0||p>=m)throw Error("splitScalar (endomorphism): failed, k="+Z);return{k1neg:A,k1:y,k2neg:b,k2:p}}(k,K.basises,V.ORDER)}const O=O7((k,Z)=>{const{X:H,Y:B,Z:L}=k;if(G.eql(L,G.ONE))return{x:H,y:B};const v=k.is0();Z==null&&(Z=v?G.ONE:G.inv(L));const w=G.mul(H,Z),N=G.mul(B,Z),M=G.mul(L,Z);if(v)return{x:G.ZERO,y:G.ZERO};if(!G.eql(M,G.ONE))throw Error("invZ was invalid");return{x:w,y:N}}),f=O7((k)=>{if(k.is0()){if(Q.allowInfinityPoint&&!G.is0(k.Y))return;throw Error("bad point: ZERO")}const{x:Z,y:H}=k.toAffine();if(!G.isValid(Z)||!G.isValid(H))throw Error("bad point: x or y not field elements");if(!$(Z,H))throw Error("bad point: equation left != right");if(!k.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function d(k,Z,H,B,L){return H=new R(G.mul(H.X,k),H.Y,H.Z),Z=R8(B,Z),H=R8(L,H),Z.add(H)}class R{constructor(k,Z,H){this.X=T("x",k),this.Y=T("y",Z,!0),this.Z=T("z",H),Object.freeze(this)}static CURVE(){return q}static fromAffine(k){const{x:Z,y:H}=k||{};if(!k||!G.isValid(Z)||!G.isValid(H))throw Error("invalid affine point");if(k instanceof R)throw Error("projective point not allowed");return G.is0(Z)&&G.is0(H)?R.ZERO:new R(Z,H,G.ONE)}static fromBytes(k){const Z=R.fromAffine(F(l0(k,void 0,"point")));return Z.assertValidity(),Z}static fromHex(k){return R.fromBytes(r("pointHex",k))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(k=8,Z=!0){return I.createCache(this,k),Z||this.multiply(K8),this}assertValidity(){f(this)}hasEvenY(){const{y:k}=this.toAffine();if(!G.isOdd)throw Error("Field doesn't support isOdd");return!G.isOdd(k)}equals(k){S(k);const{X:Z,Y:H,Z:B}=this,{X:L,Y:v,Z:w}=k,N=G.eql(G.mul(Z,w),G.mul(L,B)),M=G.eql(G.mul(H,w),G.mul(v,B));return N&&M}negate(){return new R(this.X,G.neg(this.Y),this.Z)}double(){const{a:k,b:Z}=q,H=G.mul(Z,K8),{X:B,Y:L,Z:v}=this;let{ZERO:w,ZERO:N,ZERO:M}=G,x=G.mul(B,B),y=G.mul(L,L),p=G.mul(v,v),A=G.mul(B,L);return A=G.add(A,A),M=G.mul(B,v),M=G.add(M,M),w=G.mul(k,M),N=G.mul(H,p),N=G.add(w,N),w=G.sub(y,N),N=G.add(y,N),N=G.mul(w,N),w=G.mul(A,w),M=G.mul(H,M),p=G.mul(k,p),A=G.sub(x,p),A=G.mul(k,A),A=G.add(A,M),M=G.add(x,x),x=G.add(M,x),x=G.add(x,p),x=G.mul(x,A),N=G.add(N,x),p=G.mul(L,v),p=G.add(p,p),x=G.mul(p,A),w=G.sub(w,x),M=G.mul(p,y),M=G.add(M,M),M=G.add(M,M),new R(w,N,M)}add(k){S(k);const{X:Z,Y:H,Z:B}=this,{X:L,Y:v,Z:w}=k;let{ZERO:N,ZERO:M,ZERO:x}=G;const y=q.a,p=G.mul(q.b,K8);let A=G.mul(Z,L),b=G.mul(H,v),m=G.mul(B,w),h=G.add(Z,H),l=G.add(L,v);h=G.mul(h,l),l=G.add(A,b),h=G.sub(h,l),l=G.add(Z,B);let c=G.add(L,w);return l=G.mul(l,c),c=G.add(A,m),l=G.sub(l,c),c=G.add(H,B),N=G.add(v,w),c=G.mul(c,N),N=G.add(b,m),c=G.sub(c,N),x=G.mul(y,l),N=G.mul(p,m),x=G.add(N,x),N=G.sub(b,x),x=G.add(b,x),M=G.mul(N,x),b=G.add(A,A),b=G.add(b,A),m=G.mul(y,m),l=G.mul(p,l),b=G.add(b,m),m=G.sub(A,m),m=G.mul(y,m),l=G.add(l,m),A=G.mul(b,l),M=G.add(M,A),A=G.mul(c,l),N=G.mul(h,N),N=G.sub(N,A),A=G.mul(h,b),x=G.mul(c,x),x=G.add(x,A),new R(N,M,x)}subtract(k){return this.add(k.negate())}is0(){return this.equals(R.ZERO)}multiply(k){const{endo:Z}=Q;if(!V.isValidNot0(k))throw Error("invalid scalar: out of range");let H,B;const L=(v)=>I.cached(this,v,(w)=>K6(R,w));if(Z){const{k1neg:v,k1:w,k2neg:N,k2:M}=E(k),{p:x,f:y}=L(w),{p,f:A}=L(M);B=y.add(A),H=d(Z.beta,x,p,v,N)}else{const{p:v,f:w}=L(k);H=v,B=w}return K6(R,[H,B])[0]}multiplyUnsafe(k){const{endo:Z}=Q,H=this;if(!V.isValid(k))throw Error("invalid scalar: out of range");if(k===R0||H.is0())return R.ZERO;if(k===K1)return H;if(I.hasCache(this))return this.multiply(k);if(Z){const{k1neg:B,k1:L,k2neg:v,k2:w}=E(k),{p1:N,p2:M}=function(x,y,p,A){let b=y,m=x.ZERO,h=x.ZERO;for(;p>k1||A>k1;)p&o0&&(m=m.add(b)),A&o0&&(h=h.add(b)),b=b.double(),p>>=o0,A>>=o0;return{p1:m,p2:h}}(R,H,L,w);return d(Z.beta,N,M,B,v)}return I.unsafe(H,k)}multiplyAndAddUnsafe(k,Z,H){const B=this.multiplyUnsafe(Z).add(k.multiplyUnsafe(H));return B.is0()?void 0:B}toAffine(k){return O(this,k)}isTorsionFree(){const{isTorsionFree:k}=Q;return X===K1||(k?k(R,this):I.unsafe(this,Y).is0())}clearCofactor(){const{clearCofactor:k}=Q;return X===K1?this:k?k(R,this):this.multiplyUnsafe(X)}isSmallOrder(){return this.multiplyUnsafe(X).is0()}toBytes(k=!0){return L8(k,"isCompressed"),this.assertValidity(),C(R,this,k)}toHex(k=!0){return Z1(this.toBytes(k))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(k=!0){return this.toBytes(k)}_setWindowSize(k){this.precompute(k)}static normalizeZ(k){return K6(R,k)}static msm(k,Z){return XG(R,V,k,Z)}static fromPrivateKey(k){return R.BASE.multiply(i0(V,k))}}R.BASE=new R(q.Gx,q.Gy,G.ONE),R.ZERO=new R(G.ZERO,G.ONE,G.ZERO),R.Fp=G,R.Fn=V;const j=V.BITS,I=new FW(R,Q.endo?Math.ceil(j/2):j);return R.BASE.precompute(8),R},zW=function(W){return Uint8Array.of(W?2:3)},ZW=function(W,Q){return{secretKey:Q.BYTES,publicKey:1+W.BYTES,publicKeyUncompressed:1+2*W.BYTES,publicKeyHasPrefix:!0,signature:2*Q.BYTES}},UG=function(W,Q,J={}){d7(Q),g6(J,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const G=J.randomBytes||j8,V=J.hmac||((j,...I)=>r7(Q,j,H0(...I))),{Fp:q,Fn:X}=W,{ORDER:Y,BITS:K}=X,{keygen:P,getPublicKey:U,getSharedSecret:C,utils:F,lengths:z}=function(j,I={}){const{Fn:k}=j,Z=I.randomBytes||j8,H=Object.assign(ZW(j.Fp,k),{seed:XW(k.ORDER)});function B(M){try{return!!i0(k,M)}catch(x){return!1}}function L(M=Z(H.seed)){return YW(l0(M,H.seed,"seed"),k.ORDER)}function v(M,x=!0){return j.BASE.multiply(i0(k,M)).toBytes(x)}function w(M){if(typeof M=="bigint")return!1;if(M instanceof j)return!0;const{secretKey:x,publicKey:y,publicKeyUncompressed:p}=H;if(k.allowedLengths||x===y)return;const A=r("key",M).length;return A===y||A===p}return Object.freeze({getPublicKey:v,getSharedSecret(M,x,y=!0){if(w(M)===!0)throw Error("first arg must be private key");if(w(x)===!1)throw Error("second arg must be public key");const p=i0(k,M);return j.fromHex(x).multiply(p).toBytes(y)},keygen(M){const x=L(M);return{secretKey:x,publicKey:v(x)}},Point:j,utils:{isValidSecretKey:B,isValidPublicKey(M,x){const{publicKey:y,publicKeyUncompressed:p}=H;try{const A=M.length;return!(x===!0&&A!==y||x===!1&&A!==p||!j.fromBytes(M))}catch(A){return!1}},randomSecretKey:L,isValidPrivateKey:B,randomPrivateKey:L,normPrivateKeyToScalar:(M)=>i0(k,M),precompute(M=8,x=j.BASE){return x.precompute(M,!1)}},lengths:H})}(W,J),$={prehash:!1,lowS:typeof J.lowS=="boolean"&&J.lowS,format:void 0,extraEntropy:!1},D="compact";function g(j){return j>Y>>K1}function T(j,I){if(!X.isValidNot0(I))throw Error(`invalid signature ${j}: out of range 1..Point.Fn.ORDER`);return I}class S{constructor(j,I,k){this.r=T("r",j),this.s=T("s",I),k!=null&&(this.recovery=k),Object.freeze(this)}static fromBytes(j,I=D){let k;if(function(L,v){L6(v);const w=z.signature;l0(L,v==="compact"?w:v==="recovered"?w+1:void 0,v+" signature")}(j,I),I==="der"){const{r:L,s:v}=L0.toSig(l0(j));return new S(L,v)}I==="recovered"&&(k=j[0],I="compact",j=j.subarray(1));const Z=X.BYTES,H=j.subarray(0,Z),B=j.subarray(Z,2*Z);return new S(X.fromBytes(H),X.fromBytes(B),k)}static fromHex(j,I){return this.fromBytes(B8(j),I)}addRecoveryBit(j){return new S(this.r,this.s,j)}recoverPublicKey(j){const I=q.ORDER,{r:k,s:Z,recovery:H}=this;if(H==null||![0,1,2,3].includes(H))throw Error("recovery id invalid");if(Y*KW<I&&H>1)throw Error("recovery id is ambiguous for h>1 curve");const B=H===2||H===3?k+Y:k;if(!q.isValid(B))throw Error("recovery id 2 or 3 invalid");const L=q.toBytes(B),v=W.fromBytes(H0(zW(!(1&H)),L)),w=X.inv(B),N=O(r("msgHash",j)),M=X.create(-N*w),x=X.create(Z*w),y=W.BASE.multiplyUnsafe(M).add(v.multiplyUnsafe(x));if(y.is0())throw Error("point at infinify");return y.assertValidity(),y}hasHighS(){return g(this.s)}toBytes(j=D){if(L6(j),j==="der")return B8(L0.hexFromSig(this));const I=X.toBytes(this.r),k=X.toBytes(this.s);if(j==="recovered"){if(this.recovery==null)throw Error("recovery bit must be present");return H0(Uint8Array.of(this.recovery),I,k)}return H0(I,k)}toHex(j){return Z1(this.toBytes(j))}assertValidity(){}static fromCompact(j){return S.fromBytes(r("sig",j),"compact")}static fromDER(j){return S.fromBytes(r("sig",j),"der")}normalizeS(){return this.hasHighS()?new S(this.r,X.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Z1(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Z1(this.toBytes("compact"))}}const E=J.bits2int||function(j){if(j.length>8192)throw Error("input is too large");const I=C1(j),k=8*j.length-K;return k>0?I>>BigInt(k):I},O=J.bits2int_modN||function(j){return X.create(E(j))},f=c1(K);function d(j){return function(I,k,Z,H){if(!j6(k,Z,H))throw Error("expected valid "+I+": "+Z+" <= n < "+H+", got "+k)}("num < 2^"+K,j,R0,f),X.toBytes(j)}function R(j,I){return l0(j,void 0,"message"),I?l0(Q(j),void 0,"prehashed message"):j}return Object.freeze({keygen:P,getPublicKey:U,getSharedSecret:C,utils:F,lengths:z,Point:W,sign(j,I,k={}){j=r("message",j);const{seed:Z,k2sig:H}=function(B,L,v){if(["recovered","canonical"].some((m)=>(m in v)))throw Error("sign() legacy options not supported");const{lowS:w,prehash:N,extraEntropy:M}=H6(v,$);B=R(B,N);const x=O(B),y=i0(X,L),p=[d(y),d(x)];if(M!=null&&M!==!1){const m=M===!0?G(z.secretKey):M;p.push(r("extraEntropy",m))}const A=H0(...p),b=x;return{seed:A,k2sig(m){const h=E(m);if(!X.isValidNot0(h))return;const l=X.inv(h),c=W.BASE.multiply(h).toAffine(),U0=X.create(c.x);if(U0===R0)return;const s=X.create(l*X.create(b+U0*y));if(s===R0)return;let o=(c.x===U0?0:2)|Number(c.y&K1),C0=s;return w&&g(s)&&(C0=X.neg(s),o^=1),new S(U0,C0,o)}}}(j,I,k);return function(B,L,v){if(typeof B!="number"||B<2)throw Error("hashLen must be a number");if(typeof L!="number"||L<2)throw Error("qByteLen must be a number");if(typeof v!="function")throw Error("hmacFn must be a function");const w=(h)=>new Uint8Array(h),N=(h)=>Uint8Array.of(h);let M=w(B),x=w(B),y=0;const p=()=>{M.fill(1),x.fill(0),y=0},A=(...h)=>v(x,M,...h),b=(h=w(0))=>{x=A(N(0),h),M=A(),h.length!==0&&(x=A(N(1),h),M=A())},m=()=>{if(y++>=1000)throw Error("drbg: tried 1000 values");let h=0;const l=[];for(;h<L;){M=A();const c=M.slice();l.push(c),h+=M.length}return H0(...l)};return(h,l)=>{let c;for(p(),b(h);!(c=l(m()));)b();return p(),c}}(Q.outputLen,X.BYTES,V)(Z,H)},verify(j,I,k,Z={}){const{lowS:H,prehash:B,format:L}=H6(Z,$);if(k=r("publicKey",k),I=R(r("message",I),B),("strict"in Z))throw Error("options.strict was renamed to lowS");const v=L===void 0?function(w){let N;const M=typeof w=="string"||D8(w),x=!M&&w!==null&&typeof w=="object"&&typeof w.r=="bigint"&&typeof w.s=="bigint";if(!M&&!x)throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(x)N=new S(w.r,w.s);else if(M){try{N=S.fromBytes(r("sig",w),"der")}catch(y){if(!(y instanceof L0.Err))throw y}if(!N)try{N=S.fromBytes(r("sig",w),"compact")}catch(y){return!1}}return N||!1}(j):S.fromBytes(r("sig",j),L);if(v===!1)return!1;try{const w=W.fromBytes(k);if(H&&v.hasHighS())return!1;const{r:N,s:M}=v,x=O(I),y=X.inv(M),p=X.create(x*y),A=X.create(N*y),b=W.BASE.multiplyUnsafe(p).add(w.multiplyUnsafe(A));if(b.is0())return!1;return X.create(b.x)===N}catch(w){return!1}},recoverPublicKey(j,I,k={}){const{prehash:Z}=H6(k,$);return I=R(I,Z),S.fromBytes(j,"recovered").recoverPublicKey(I).toBytes()},Signature:S,hash:Q})},FG=function(W){const{CURVE:Q,curveOpts:J}=function(V){const q={a:V.a,b:V.b,p:V.Fp.ORDER,n:V.n,h:V.h,Gx:V.Gx,Gy:V.Gy},X=V.Fp;let Y=V.allowedPrivateKeyLengths?Array.from(new Set(V.allowedPrivateKeyLengths.map((K)=>Math.ceil(K/2)))):void 0;return{CURVE:q,curveOpts:{Fp:X,Fn:_1(q.n,{BITS:V.nBitLength,allowedLengths:Y,modFromBytes:V.wrapPrivateKey}),allowInfinityPoint:V.allowInfinityPoint,endo:V.endo,isTorsionFree:V.isTorsionFree,clearCofactor:V.clearCofactor,fromBytes:V.fromBytes,toBytes:V.toBytes}}}(W),G={hmac:W.hmac,randomBytes:W.randomBytes,lowS:W.lowS,bits2int:W.bits2int,bits2int_modN:W.bits2int_modN};return{CURVE:Q,curveOpts:J,hash:W.hash,ecdsaOpts:G}},KG=function(W){const{CURVE:Q,curveOpts:J,hash:G,ecdsaOpts:V}=FG(W);return function(q,X){const Y=X.Point;return Object.assign({},X,{ProjectivePoint:Y,CURVE:Object.assign({},q,VW(Y.Fn.ORDER,Y.Fn.BITS))})}(W,UG(PG(Q,J),G,V))},I8=function(W,...Q){let J=S7[W];if(J===void 0){const G=M6(_7(W));J=H0(G,G),S7[W]=J}return M6(H0(J,...Q))},O6=function(W){const{Fn:Q,BASE:J}=$1,G=i0(Q,W),V=J.multiply(G);return{scalar:y6(V.y)?G:Q.neg(G),bytes:S6(V)}},HW=function(W){const Q=O8;if(!Q.isValidNot0(W))throw Error("invalid x: Fail if x \u2265 p");const J=Q.create(W*W),G=Q.create(J*W+BigInt(7));let V=Q.sqrt(G);y6(V)||(V=Q.neg(V));const q=$1.fromAffine({x:W,y:V});return q.assertValidity(),q},CW=function(...W){return $1.Fn.create(u1(I8("BIP0340/challenge",...W)))},y7=function(W){return O6(W).bytes},kG=function(W,Q,J=j8(32)){const{Fn:G}=$1,V=r("message",W),{bytes:q,scalar:X}=O6(Q),Y=r("auxRand",J,32),K=G.toBytes(X^u1(I8("BIP0340/aux",Y))),P=I8("BIP0340/nonce",K,q,V),{bytes:U,scalar:C}=O6(P),F=CW(U,q,V),z=new Uint8Array(64);if(z.set(U,0),z.set(G.toBytes(G.create(C+F*X)),32),!$W(z,V,q))throw Error("sign: Invalid signature produced");return z},$W=function(W,Q,J){const{Fn:G,BASE:V}=$1,q=r("signature",W,64),X=r("message",Q),Y=r("publicKey",J,32);try{const K=HW(u1(Y)),P=u1(q.subarray(0,32));if(!j6(P,T7,H1.p))return!1;const U=u1(q.subarray(32,64));if(!j6(U,T7,H1.n))return!1;const C=CW(G.toBytes(P),S6(K),X),F=V.multiplyUnsafe(U).add(K.multiplyUnsafe(G.neg(C))),{x:z,y:$}=F.toAffine();return!(F.is0()||!y6($)||z!==P)}catch(K){return!1}},P1=typeof globalThis=="object"&&("crypto"in globalThis)?globalThis.crypto:void 0,c7=(()=>typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function")(),oQ=Array.from({length:256},(W,Q)=>Q.toString(16).padStart(2,"0")),B7=48,aQ=57,j7=65,nQ=70,L7=97,sQ=102;class N6{}class l7 extends N6{constructor(W,Q,J,G){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=W,this.outputLen=Q,this.padOffset=J,this.isLE=G,this.buffer=new Uint8Array(W),this.view=U6(this.buffer)}update(W){$8(this),n0(W=x6(W));const{view:Q,buffer:J,blockLen:G}=this,V=W.length;for(let q=0;q<V;){const X=Math.min(G-this.pos,V-q);if(X!==G)J.set(W.subarray(q,q+X),this.pos),this.pos+=X,q+=X,this.pos===G&&(this.process(Q,0),this.pos=0);else{const Y=U6(W);for(;G<=V-q;q+=G)this.process(Y,q)}}return this.length+=W.length,this.roundClean(),this}digestInto(W){$8(this),function(U,C){n0(U);const F=C.outputLen;if(U.length<F)throw Error("digestInto() expects output buffer of length at least "+F)}(W,this),this.finished=!0;const{buffer:Q,view:J,blockLen:G,isLE:V}=this;let{pos:q}=this;Q[q++]=128,M8(this.buffer.subarray(q)),this.padOffset>G-q&&(this.process(J,0),q=0);for(let U=q;U<G;U++)Q[U]=0;(function(U,C,F,z){if(typeof U.setBigUint64=="function")return U.setBigUint64(C,F,z);const $=BigInt(32),D=BigInt(4294967295),g=Number(F>>$&D),T=Number(F&D),S=z?4:0,E=z?0:4;U.setUint32(C+S,g,z),U.setUint32(C+E,T,z)})(J,G-8,BigInt(8*this.length),V),this.process(J,0);const X=U6(W),Y=this.outputLen;if(Y%4)throw Error("_sha2: outputLen should be aligned to 32bit");const K=Y/4,P=this.get();if(K>P.length)throw Error("_sha2: outputLen bigger than state");for(let U=0;U<K;U++)X.setUint32(4*U,P[U],V)}digest(){const{buffer:W,outputLen:Q}=this;this.digestInto(W);const J=W.slice(0,Q);return this.destroy(),J}_cloneInto(W){W||(W=new this.constructor),W.set(...this.get());const{blockLen:Q,buffer:J,length:G,finished:V,destroyed:q,pos:X}=this;return W.destroyed=q,W.finished=V,W.length=G,W.pos=X,G%Q&&W.buffer.set(J),W}clone(){return this._cloneInto()}}var v0=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),WG=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),g0=new Uint32Array(64);class i7 extends l7{constructor(W=32){super(64,W,8,!1),this.A=0|v0[0],this.B=0|v0[1],this.C=0|v0[2],this.D=0|v0[3],this.E=0|v0[4],this.F=0|v0[5],this.G=0|v0[6],this.H=0|v0[7]}get(){const{A:W,B:Q,C:J,D:G,E:V,F:q,G:X,H:Y}=this;return[W,Q,J,G,V,q,X,Y]}set(W,Q,J,G,V,q,X,Y){this.A=0|W,this.B=0|Q,this.C=0|J,this.D=0|G,this.E=0|V,this.F=0|q,this.G=0|X,this.H=0|Y}process(W,Q){for(let C=0;C<16;C++,Q+=4)g0[C]=W.getUint32(Q,!1);for(let C=16;C<64;C++){const F=g0[C-15],z=g0[C-2],$=k0(F,7)^k0(F,18)^F>>>3,D=k0(z,17)^k0(z,19)^z>>>10;g0[C]=D+g0[C-7]+$+g0[C-16]|0}let{A:J,B:G,C:V,D:q,E:X,F:Y,G:K,H:P}=this;for(let C=0;C<64;C++){const F=P+(k0(X,6)^k0(X,11)^k0(X,25))+((U=X)&Y^~U&K)+WG[C]+g0[C]|0,z=(k0(J,2)^k0(J,13)^k0(J,22))+tQ(J,G,V)|0;P=K,K=Y,Y=X,X=q+F|0,q=V,V=G,G=J,J=F+z|0}var U;J=J+this.A|0,G=G+this.B|0,V=V+this.C|0,q=q+this.D|0,X=X+this.E|0,Y=Y+this.F|0,K=K+this.G|0,P=P+this.H|0,this.set(J,G,V,q,X,Y,K,P)}roundClean(){M8(g0)}destroy(){this.set(0,0,0,0,0,0,0,0),M8(this.buffer)}}var M6=eQ(()=>new i7);class A6 extends N6{constructor(W,Q){super(),this.finished=!1,this.destroyed=!1,d7(W);const J=x6(Q);if(this.iHash=W.create(),typeof this.iHash.update!="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const G=this.blockLen,V=new Uint8Array(G);V.set(J.length>G?W.create().update(J).digest():J);for(let q=0;q<V.length;q++)V[q]^=54;this.iHash.update(V),this.oHash=W.create();for(let q=0;q<V.length;q++)V[q]^=106;this.oHash.update(V),M8(V)}update(W){return $8(this),this.iHash.update(W),this}digestInto(W){$8(this),n0(W,this.outputLen),this.finished=!0,this.iHash.digestInto(W),this.oHash.update(W),this.oHash.digestInto(W),this.destroy()}digest(){const W=new Uint8Array(this.oHash.outputLen);return this.digestInto(W),W}_cloneInto(W){W||(W=Object.create(Object.getPrototypeOf(this),{}));const{oHash:Q,iHash:J,finished:G,destroyed:V,blockLen:q,outputLen:X}=this;return W.finished=G,W.destroyed=V,W.blockLen=q,W.outputLen=X,W.oHash=Q._cloneInto(W.oHash),W.iHash=J._cloneInto(W.iHash),W}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var r7=(W,Q,J)=>new A6(W,Q).update(J).digest();r7.create=(W,Q)=>new A6(W,Q);var v6=BigInt(0),B6=BigInt(1),F6=(W)=>typeof W=="bigint"&&v6<=W,c1=(W)=>(B6<<BigInt(W))-B6,Q0=BigInt(0),W0=BigInt(1),r0=BigInt(2),e7=BigInt(3),t7=BigInt(4),WW=BigInt(5),JG=BigInt(7),JW=BigInt(8),QG=BigInt(9),I7=BigInt(16),qG=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"],k1=BigInt(0),o0=BigInt(1),Z6=new WeakMap,UW=new WeakMap;class FW{constructor(W,Q){this.BASE=W.BASE,this.ZERO=W.ZERO,this.Fn=W.Fn,this.bits=Q}_unsafeLadder(W,Q,J=this.ZERO){let G=W;for(;Q>k1;)Q&o0&&(J=J.add(G)),G=G.double(),Q>>=o0;return J}precomputeWindow(W,Q){const{windows:J,windowSize:G}=z6(Q,this.bits),V=[];let q=W,X=q;for(let Y=0;Y<J;Y++){X=q,V.push(X);for(let K=1;K<G;K++)X=X.add(q),V.push(X);q=X.double()}return V}wNAF(W,Q,J){if(!this.Fn.isValid(J))throw Error("invalid scalar");let G=this.ZERO,V=this.BASE;const q=z6(W,this.bits);for(let X=0;X<q.windows;X++){const{nextN:Y,offset:K,isZero:P,isNeg:U,isNegF:C,offsetF:F}=N7(J,X,q);J=Y,P?V=V.add(R8(C,Q[F])):G=G.add(R8(U,Q[K]))}return A7(J),{p:G,f:V}}wNAFUnsafe(W,Q,J,G=this.ZERO){const V=z6(W,this.bits);for(let q=0;q<V.windows&&J!==k1;q++){const{nextN:X,offset:Y,isZero:K,isNeg:P}=N7(J,q,V);if(J=X,!K){const U=Q[Y];G=G.add(P?U.negate():U)}}return A7(J),G}getPrecomputes(W,Q,J){let G=Z6.get(Q);return G||(G=this.precomputeWindow(Q,W),W!==1&&(typeof J=="function"&&(G=J(G)),Z6.set(Q,G))),G}cached(W,Q,J){const G=k6(W);return this.wNAF(G,this.getPrecomputes(G,W,J),Q)}unsafe(W,Q,J,G){const V=k6(W);return V===1?this._unsafeLadder(W,Q,G):this.wNAFUnsafe(V,this.getPrecomputes(V,W,J),Q,G)}createCache(W,Q){PW(Q,this.bits),UW.set(W,Q),Z6.delete(W)}hasCache(W){return k6(W)!==1}}var g7=(W,Q)=>(W+(W>=0?Q:-Q)/KW)/Q,L0={Err:class extends Error{constructor(W=""){super(W)}},_tlv:{encode(W,Q){const{Err:J}=L0;if(W<0||W>256)throw new J("tlv.encode: wrong tag");if(1&Q.length)throw new J("tlv.encode: unpadded data");const G=Q.length/2,V=F8(G);if(V.length/2&128)throw new J("tlv.encode: long form length too big");const q=G>127?F8(V.length/2|128):"";return F8(W)+q+V+Q},decode(W,Q){const{Err:J}=L0;let G=0;if(W<0||W>256)throw new J("tlv.encode: wrong tag");if(Q.length<2||Q[G++]!==W)throw new J("tlv.decode: wrong tlv");const V=Q[G++];let q=0;if(128&V){const Y=127&V;if(!Y)throw new J("tlv.decode(long): indefinite length not supported");if(Y>4)throw new J("tlv.decode(long): byte length is too big");const K=Q.subarray(G,G+Y);if(K.length!==Y)throw new J("tlv.decode: length bytes not complete");if(K[0]===0)throw new J("tlv.decode(long): zero leftmost byte");for(let P of K)q=q<<8|P;if(G+=Y,q<128)throw new J("tlv.decode(long): not minimal encoding")}else q=V;const X=Q.subarray(G,G+q);if(X.length!==q)throw new J("tlv.decode: wrong value length");return{v:X,l:Q.subarray(G+q)}}},_int:{encode(W){const{Err:Q}=L0;if(W<R0)throw new Q("integer: negative integers are not allowed");let J=F8(W);if(8&Number.parseInt(J[0],16)&&(J="00"+J),1&J.length)throw new Q("unexpected DER parsing assertion: unpadded hex");return J},decode(W){const{Err:Q}=L0;if(128&W[0])throw new Q("invalid signature integer: negative");if(W[0]===0&&!(128&W[1]))throw new Q("invalid signature integer: unnecessary leading zero");return C1(W)}},toSig(W){const{Err:Q,_int:J,_tlv:G}=L0,V=r("signature",W),{v:q,l:X}=G.decode(48,V);if(X.length)throw new Q("invalid signature: left bytes after parsing");const{v:Y,l:K}=G.decode(2,q),{v:P,l:U}=G.decode(2,K);if(U.length)throw new Q("invalid signature: left bytes after parsing");return{r:J.decode(Y),s:J.decode(P)}},hexFromSig(W){const{_tlv:Q,_int:J}=L0,G=Q.encode(2,J.encode(W.r))+Q.encode(2,J.encode(W.s));return Q.encode(48,G)}},R0=BigInt(0),K1=BigInt(1),KW=BigInt(2),K8=BigInt(3),YG=BigInt(4),H1={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},zG={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},ZG=BigInt(0),T7=BigInt(1),R6=BigInt(2),O8=_1(H1.p,{sqrt(W){const Q=H1.p,J=BigInt(3),G=BigInt(6),V=BigInt(11),q=BigInt(22),X=BigInt(23),Y=BigInt(44),K=BigInt(88),P=W*W*W%Q,U=P*P*W%Q,C=Y0(U,J,Q)*U%Q,F=Y0(C,J,Q)*U%Q,z=Y0(F,R6,Q)*P%Q,$=Y0(z,V,Q)*z%Q,D=Y0($,q,Q)*$%Q,g=Y0(D,Y,Q)*D%Q,T=Y0(g,K,Q)*g%Q,S=Y0(T,Y,Q)*D%Q,E=Y0(S,J,Q)*U%Q,O=Y0(E,X,Q)*$%Q,f=Y0(O,G,Q)*P%Q,d=Y0(f,R6,Q);if(!O8.eql(O8.sqr(d),W))throw Error("Cannot find square root");return d}}),kW=function(W,Q){const J=(G)=>KG({...W,hash:G});return{...J(Q),create:J}}({...H1,Fp:O8,lowS:!0,endo:zG},M6),S7={},S6=(W)=>W.toBytes(!0).slice(1),$1=(()=>kW.Point)(),y6=(W)=>W%R6===ZG,u1=C1,E6=(()=>{const W=(Q=j8(48))=>YW(Q,H1.n);return kW.utils.randomSecretKey,{keygen(Q){const J=W(Q);return{secretKey:J,publicKey:y7(J)}},getPublicKey:y7,sign:kG,verify:$W,Point:$1,utils:{randomSecretKey:W,randomPrivateKey:W,taggedHash:I8,lift_x:HW,pointToBytes:S6,numberToBytesBE:x8,bytesToNumberBE:C1,mod:P0},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})(),HG=new TextEncoder,CG=new TextDecoder,a0=(W)=>HG.encode(W),C8=(W)=>CG.decode(W),I6=(W)=>Array.from(W,(Q)=>Q.toString(16).padStart(2,"0")).join(""),O0=JSON.stringify,w8=JSON.parse,MW=(W,Q=Number.MAX_SAFE_INTEGER)=>W.split("").reduce((J,G)=>J+G.charCodeAt(0),0)%Q,p6="AES-GCM",$G={},z8=(W)=>$G[W]??=crypto.subtle.digest("SHA-1",a0(W)).then((Q)=>{const J=new Uint8Array(Q);let G="";for(let V of J)G+=V.toString(36);return G}),MG=async(W,Q)=>{const J=crypto.getRandomValues(new Uint8Array(12)),G=await W,V=await crypto.subtle.encrypt({name:p6,iv:J},G,a0(Q));return`${J.join(",")}\$${((q)=>{const X=new Uint8Array(q);let Y="";for(let K=0;K<X.length;K+=32768)Y+=String.fromCharCode(...X.subarray(K,K+32768));return btoa(Y)})(V)}`},BG=async(W,Q)=>{const[J,G]=Q.split("$");if(!J||!G)throw Error("Invalid encrypted payload format");const V=Uint8Array.from(J.split(","),Number),q=await W,X=await crypto.subtle.decrypt({name:p6,iv:V},q,(Y=G,Uint8Array.from(atob(Y),(K)=>K.charCodeAt(0)).buffer));var Y;return C8(X)},d1="GenosRTC",f6=(W,Q)=>Array.from({length:W},Q),jG="0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz",w6=(W)=>Array.from(crypto.getRandomValues(new Uint8Array(W)),(Q)=>jG[Q%62]).join(""),U1=w6(20),z1=Promise.all.bind(Promise),LG=typeof window!="undefined",{entries:D6,fromEntries:BW,keys:RG}=Object,c0=()=>{},_0=(W)=>Error(`${d1}: ${W}`),Z8=(...W)=>W.join("@"),E7="icegatheringstatechange",p7="offer",OG=[...f6(3,(W,Q)=>`stun:stun${Q||""}.l.google.com:19302`),"stun:stun.cloudflare.com:3478"].map((W)=>({urls:W})),C6=(W,{rtcConfig:Q,rtcPolyfill:J,turnConfig:G})=>{const V=new(J||RTCPeerConnection)({iceServers:[...OG,...G||[]],...Q}),q={};let X,Y=!1,K=!1;const P=(F)=>Object.assign(F,{binaryType:"arraybuffer",bufferedAmountLowThreshold:65535,onmessage(z){return q.data?.(z.data)},onopen(){return q.connect?.()},onclose(){return q.close?.()},onerror(z){return!z?.error?.message?.includes("User-Initiated Abort")&&q.error?.(z)}}),U=()=>Promise.race([new Promise((F)=>{const z=()=>{V.iceGatheringState==="complete"&&(V.removeEventListener(E7,z),F())};V.addEventListener(E7,z),z()}),new Promise((F)=>setTimeout(F,5000))]).then(()=>({type:V.localDescription.type,sdp:V.localDescription.sdp.replace(/a=ice-options:trickle\s\n/g,"")}));W?P(X=V.createDataChannel("data")):V.ondatachannel=({channel:F})=>P(X=F),V.onnegotiationneeded=async()=>{try{Y=!0,await V.setLocalDescription(),q.signal?.(await U())}catch(F){q.error?.(F)}finally{Y=!1}},V.onconnectionstatechange=()=>{["disconnected","failed","closed"].includes(V.connectionState)&&q.close?.()},V.ontrack=(F)=>{q.track?.(F.track,F.streams[0]),q.stream?.(F.streams[0])},V.onremovestream=(F)=>q.stream?.(F.stream),W&&!V.canTrickleIceCandidates&&V.onnegotiationneeded();const C=()=>V.getSenders();return{created:Date.now(),connection:V,get channel(){return X},get isDead(){return V.connectionState==="closed"},async signal(F){if(X?.readyState!=="open"||F.sdp?.includes("a=rtpmap"))try{if(F.type===p7){if(Y||V.signalingState!=="stable"&&!K){if(W)return;await z1([V.setLocalDescription({type:"rollback"}),V.setRemoteDescription(F)])}else await V.setRemoteDescription(F);await V.setLocalDescription();const z=await U();return q.signal?.(z),z}if(F.type==="answer"){K=!0;try{await V.setRemoteDescription(F)}finally{K=!1}}}catch(z){q.error?.(z)}},sendData(F){return X.send(F)},destroy(){X?.close(),V.close(),Y=K=!1},setHandlers(F){return Object.assign(q,F)},offerPromise:W?new Promise((F)=>q.signal=(z)=>z.type===p7&&F(z)):Promise.resolve(),addStream(F){return F.getTracks().forEach((z)=>V.addTrack(z,F))},removeStream(F){return C().filter((z)=>F.getTracks().includes(z.track)).forEach((z)=>V.removeTrack(z))},addTrack(F,z){return V.addTrack(F,z)},removeTrack(F){const z=C().find(($)=>$.track===F);z&&V.removeTrack(z)},replaceTrack(F,z){return C().find(($)=>$.track===F)?.replaceTrack(z)}}},IG=Object.getPrototypeOf(Uint8Array),b1=16369,k8=255,f7="bufferedamountlow",F1=(W)=>"@_"+W,wG=(W,Q,J)=>{const G={},V={},q={},X={},Y={},K={},P={},U={onPeerJoin:c0,onPeerLeave:c0,onPeerStream:c0,onPeerTrack:c0},C=(Z,H)=>(Z?Array.isArray(Z)?Z:[Z]:RG(G)).flatMap((B)=>{const L=G[B];return L?H(B,L):(console.warn(`${d1}: no peer with id ${B} found`),[])}),F=(Z)=>{G[Z]&&(delete G[Z],delete X[Z],delete Y[Z],U.onPeerLeave(Z),Q(Z))},z=(Z)=>{if(V[Z])return q[Z];if(!Z)throw _0("action type argument is required");const H=a0(Z);if(H.byteLength>12)throw _0(`Action type "${Z}" exceeds 12 bytes`);const B=new Uint8Array(12);B.set(H);let L=0;const v=async(M,x,y,p)=>{if(y&&typeof y!="object")throw _0("meta must be an object");if(M===void 0)throw _0("data cannot be undefined");const A=M instanceof Blob,b=A||M instanceof ArrayBuffer||M instanceof IG,m=typeof M!="string";if(y&&!b)throw _0("meta only allowed with binary data");const h=b?new Uint8Array(A?await M.arrayBuffer():M):a0(m?O0(M):M),l=y?a0(O0(y)):null,c=Math.ceil(h.byteLength/b1)+(y?1:0)||1,U0=f6(c,(s,o)=>{const C0=o===c-1,T0=y&&o===0,l1=T0?l:h.subarray(y?(o-1)*b1:o*b1,y?o*b1:(o+1)*b1),$0=new Uint8Array(15+l1.byteLength);return $0.set(B),$0.set([L],12),$0.set([C0|T0<<1|b<<2|m<<3],13),$0.set([Math.round((o+1)/c*k8)],14),$0.set(l1,15),$0});return L=L+1&k8,z1(C(x,async(s,o)=>{const{channel:C0}=o;for(let T0=0;T0<c&&(C0.bufferedAmount>C0.bufferedAmountLowThreshold&&await new Promise((l1)=>{const $0=()=>{C0.removeEventListener(f7,$0),l1()};C0.addEventListener(f7,$0)}),G[s]);T0++)o.sendData(U0[T0]),p?.(U0[T0][14]/k8,s,y)}))},w=(M)=>V[Z]={...V[Z],onComplete:M},N=(M)=>V[Z]={...V[Z],onProgress:M};return V[Z]={onComplete:c0,onProgress:c0,send:v,setOnComplete:w,setOnProgress:N},q[Z]||=[v,w,N]},$=async()=>{await I(""),await new Promise((Z)=>setTimeout(Z,99));for(let[Z,H]of D6(G))H.destroy(),delete G[Z];J()},[D,g]=z(F1("ping")),[T,S]=z(F1("pong")),[E,O]=z(F1("signal")),[f,d]=z(F1("stream")),[R,j]=z(F1("track")),[I,k]=z(F1("leave"));return W((Z,H)=>{G[H]||(G[H]=Z,Z.setHandlers({data(B){return((L,v)=>{const w=new Uint8Array(v),N=C8(w.subarray(0,12)).replaceAll("\0",""),[M]=w.subarray(12,13),[x]=w.subarray(13,14),[y]=w.subarray(14,15),p=w.subarray(15),A=!!(1&x),b=!!(2&x),m=!!(4&x),h=!!(8&x);if(!V[N])return void console.warn(`${d1}: received message with unregistered type (${N})`);const l=(X[L]||={})[N]||={},c=l[M]||={chunks:[]};if(b?c.meta=w8(C8(p)):c.chunks.push(p),V[N].onProgress(y/k8,L,c.meta),!A)return;const U0=new Uint8Array(c.chunks.reduce((s,o)=>s+o.byteLength,0));if(c.chunks.reduce((s,o)=>(U0.set(o,s),s+o.byteLength),0),delete l[M],m)V[N].onComplete(U0,L,c.meta);else{const s=C8(U0);V[N].onComplete(h?w8(s):s,L)}})(H,B)},stream(B){U.onPeerStream(B,H,K[H]),delete K[H]},track(B,L){U.onPeerTrack(B,L,H,P[H]),delete P[H]},signal(B){return E(B,H)},close(){return F(H)},error(B){console.error(B),F(H)}}),U.onPeerJoin(H))}),g((Z,H)=>T("",H)),S((Z,H)=>{Y[H]?.(),delete Y[H]}),O((Z,H)=>G[H]?.signal(Z)),d((Z,H)=>K[H]=Z),j((Z,H)=>P[H]=Z),k((Z,H)=>F(H)),LG&&addEventListener("beforeunload",$),{makeAction:z,leave:$,async ping(Z){if(!Z)throw _0("ping() must be called with target peer ID");const H=Date.now();return D("",Z),await new Promise((B)=>Y[Z]=B),Date.now()-H},getPeers(){return BW(D6(G).map(([Z,H])=>[Z,H.connection]))},addStream(Z,H,B){return C(H,async(L,v)=>{B&&await f(B,L),v.addStream(Z)})},removeStream(Z,H){return C(H,(B,L)=>L.removeStream(Z))},addTrack(Z,H,B,L){return C(B,async(v,w)=>{L&&await R(L,v),w.addTrack(Z,H)})},removeTrack(Z,H){return C(H,(B,L)=>L.removeTrack(Z))},replaceTrack(Z,H,B,L){return C(B,async(v,w)=>{L&&await R(L,v),w.replaceTrack(Z,H)})},onPeerJoin(Z){return U.onPeerJoin=Z},onPeerLeave(Z){return U.onPeerLeave=Z},onPeerStream(Z){return U.onPeerStream=Z},onPeerTrack(Z){return U.onPeerTrack=Z}}},H8={},DG=(W,Q,J,G)=>(W.relayUrls??(G?((V,q)=>{const X=[...V];let Y=X.length;const K=()=>{const P=1e4*Math.sin(q++);return P-Math.floor(P)};for(;Y;){const P=Math.floor(K()*Y--);[X[Y],X[P]]=[X[P],X[Y]]}return X})(Q,MW(W.appId)):Q)).slice(0,W.relayUrls?.length??W.relayRedundancy??J),jW={},LW="EVENT",RW=E6.utils.randomSecretKey(),xG=I6(E6.getPublicKey(RW)),h6={},m1={},NG={},OW=()=>Math.floor(Date.now()/1000),IW=(W)=>NG[W]??=MW(W,1e4)+20000,h7=async(W,Q)=>{const J={kind:IW(W),content:Q,pubkey:xG,created_at:OW(),tags:[["x",W]]},G=new Uint8Array(await crypto.subtle.digest("SHA-256",a0(O0([0,J.pubkey,J.created_at,J.kind,J.tags,J.content])))),V=E6.sign(G,RW);return O0([LW,{...J,id:I6(G),sig:I6(V)}])},b7=(W,Q)=>(h6[W]=Q,O0(["REQ",W,{kinds:[IW(Q)],since:OW(),"#x":[Q]}])),m7=(W)=>(delete h6[W],O0(["CLOSE",W])),b6=(({init:W,subscribe:Q,announce:J})=>{const G={};let V,q,X=!1;return(Y,K,P)=>{const{appId:U}=Y;if(G[U]?.[K])return G[U][K];if(!Y||!K||!U&&!Y.firebaseApp)throw _0(Y?K?"appId missing":"roomId required":"config required");let C=c0;if(!X){const k=W(Y);q=f6(20,()=>C6(!0,Y)),V=Array.isArray(k)?k:[k];const Z=setInterval(()=>{q=q.filter((H)=>{const B=Date.now()-H.created<57333;return B||H.destroy(),B})},57333);G.offerCleanupTimer||=Z,X=!0}const F={},z={},$=Z8(d1,U,K),D=z8($),g=z8(Z8($,U1)),T=(async(k,Z,H)=>{const B=await crypto.subtle.digest("SHA-256",a0(`${k}:${Z}:${H}`));return crypto.subtle.importKey("raw",B,{name:p6},!1,["encrypt","decrypt"])})(Y.password||"",U,K),S=(k)=>async(Z)=>({type:Z.type,sdp:await k(T,Z.sdp)}),E=S(BG),O=S(MG),f=(k,Z)=>{z[Z]!==k&&(z[Z]?.destroy(),z[Z]=k,C(k,Z),F[Z]?.forEach((H)=>H!==k&&H.destroy()),delete F[Z])},d=(k,Z)=>{z[Z]===k&&delete z[Z]},R=z1(V.map(async(k,Z)=>{return Q(await k,await D,await g,(H=Z,async(B,L,v)=>{const[w,N]=await z1([D,g]);if(B!==w&&B!==N)return;const{peerId:M,offer:x,answer:y,peer:p}=typeof L=="string"?w8(L):L;if(M!==U1&&!z[M])if(x){if(F[M]?.[H]&&U1>M)return;const A=C6(!1,Y);A.setHandlers({connect(){return f(A,M)},close(){return d(A,M)}});try{const b=await E(x);if(A.isDead)return;const[m,h]=await z1([z8(Z8($,M)),A.signal(b).then(O)]);v(m,O0({peerId:U1,answer:h}))}catch{P?.({error:"decryption failed (offer)",appId:U,peerId:M,roomId:K})}}else if(y){const A=p||F[M]?.[H];if(!A||A.isDead)return;A.setHandlers({connect(){return f(A,M)},close(){return d(A,M)}});try{A.signal(await E(y))}catch{P?.({error:"decryption failed (answer)",appId:U,peerId:M,roomId:K})}}else{if(F[M]?.[H])return;const A=q.pop()||C6(!0,Y),[b,{offer:m}]=await z1([z8(Z8($,M)),A.offerPromise.then(O).then((h)=>({offer:h}))]);F[M]||=[],F[M][H]=A,A.setHandlers({connect(){return f(A,M)},close(){return d(A,M)}}),v(b,O0({peerId:U1,offer:m,peer:A}))}}));var H})),j=[];R.then((k)=>{V.forEach((Z,H)=>{const B=async()=>{const L=await J(await Z,await D,await g);j[H]=setTimeout(B,typeof L=="number"?L:5333)};B()}),G[U][K].onCleanup=()=>{delete G[U][K],j.forEach(clearTimeout),k.forEach((Z)=>Z()),Object.keys(G).length===0&&(clearInterval(G.offerCleanupTimer),delete G.offerCleanupTimer)}}),G[U]||={};const I=wG((k)=>C=k,(k)=>delete z[k],()=>I.onCleanup?.());return G[U][K]=I}})({init(W){return DG(W,AG,5,!0).map((Q)=>{const J=((G,V)=>{const q={},X=()=>{const Y=new WebSocket(G);Y.onclose=()=>{H8[G]??=3333,setTimeout(X,H8[G]),H8[G]*=2},Y.onmessage=(K)=>V(K.data),q.socket=Y,q.url=Y.url,q.ready=new Promise((K)=>{Y.onopen=()=>{H8[G]=3333,K(q)}}),q.send=(K)=>{Y.readyState===1&&Y.send(K)}};return X(),q})(Q,(G)=>{const[V,q,X,Y]=w8(G);if(V===LW)m1[q]?.(h6[q],X.content);else{const K=`${d1}: relay failure from ${J.url} - `;V==="NOTICE"?console.warn(K+q):V!=="OK"||X||console.warn(K+Y)}});return jW[Q]=J,J.ready})},subscribe(W,Q,J,G){const V=w6(64),q=w6(64);return m1[V]=m1[q]=(X,Y)=>G(X,Y,async(K,P)=>W.send(await h7(K,P))),W.send(b7(V,Q)),W.send(b7(q,J)),()=>{W.send(m7(V)),W.send(m7(q)),delete m1[V],delete m1[q]}},async announce(W,Q){return W.send(await h7(Q,O0({peerId:U1})))}}),kV=(u7=jW,()=>BW(D6(u7).map(([W,Q])=>[W,Q.socket]))),u7,AG=["black.nostrcity.club","eu.purplerelay.com","ftp.halifax.rwth-aachen.de/nostr","nostr.cool110.xyz","nostr.data.haus","nostr.mom","nostr.oxtr.dev","nostr.sathoarder.com","nostr.vulpem.com","playground.nostrcheck.me/relay","relay.agorist.space","relay.binaryrobot.com","relay.fountain.fm","relay.mostro.network","relay.nostraddress.com","relay.nostrdice.com","relay.nostromo.social","relay.oldenburg.cool","relay.snort.social","relay.verified-nostr.com","sendit.nosflare.com","yabu.me/v2","relay.damus.io"].map((W)=>"wss://"+W);var wW=(W,Q,J)=>{let G=Q.timestamp;if(Q.timestamp&&typeof Q.timestamp.physical==="number"){const X=Date.now()+7200000;if(Q.timestamp.physical>X)G={physical:X,logical:Q.timestamp.logical}}if(!W||!W.timestamp)return{resolved:!0,value:Q.value,timestamp:G};const V=W.timestamp;if(J.compare(V,G)<0)return{resolved:!0,value:Q.value,timestamp:G};return{resolved:!1}};class m6{constructor(W,Q=50){this.key=`gdb_oplog_${W}`,this.maxSize=Q,this.log=this._load()}_load(){try{const W=localStorage.getItem(this.key);return W?JSON.parse(W):[]}catch(W){return console.error("Failed to load oplog from localStorage:",W),[]}}_save(){try{localStorage.setItem(this.key,JSON.stringify(this.log))}catch(W){console.error("Failed to save oplog to localStorage:",W)}}add(W){if(this.log.push(W),this.log.length>this.maxSize)this.log.shift();this._save()}getDelta(W,Q){if(!W)return[...this.log];return this.log.filter((J)=>Q(J.timestamp,W)>0)}getOldest(){return this.log[0]}clear(){this.log=[],localStorage.removeItem(this.key)}}var vG=()=>{const W=new Map,Q=async()=>{try{const K=await navigator.storage.getDirectory(),U=await(await K.getFileHandle("~opfs-sync-test",{create:!0})).createSyncAccessHandle?.();return await U?.close(),await K.removeEntry("~opfs-sync-test"),!!U}catch{return!1}};let J="idb";const G=(async()=>{if(await Q())J="sync";else try{const K=await navigator.storage.getDirectory(),U=await(await K.getFileHandle("~opfs-async-test",{create:!0})).createWritable?.();if(await U?.close(),await K.removeEntry("~opfs-async-test"),U)J="async";else J="idb"}catch{J="idb"}})(),V=async(K,P)=>{if(!W.has(K))W.set(K,[]);const U=W.get(K),C=U[U.length-1]||Promise.resolve();let F;const z=new Promise(($)=>F=$);U.push(z);try{return await C,await P()}finally{if(U.shift(),F(),U.length===0)W.delete(K)}},q=(()=>{let K;const P=async()=>{if(!K)K=new Promise((U,C)=>{const F=indexedDB.open("opfs-fallback-db",1);F.onupgradeneeded=()=>F.result.createObjectStore("files"),F.onsuccess=()=>U(F.result),F.onerror=()=>C(F.error)});return K};return{getDB:P,get:async(U)=>{const C=await P();return new Promise((F,z)=>{const D=C.transaction("files","readonly").objectStore("files").get(U);D.onsuccess=()=>F(D.result||new Uint8Array),D.onerror=()=>z(D.error)})},set:async(U,C)=>{const F=await P();return new Promise((z,$)=>{const g=F.transaction("files","readwrite").objectStore("files").put(C,U);g.onsuccess=()=>z(),g.onerror=()=>$(g.error)})}}})(),X=async(K)=>{await G;try{if(J==="idb"){const z=await q.get(K);return{type:"loaded",name:K,data:z}}const U=await(await navigator.storage.getDirectory()).getFileHandle(K);if(J==="sync"){let z;try{z=await U.createSyncAccessHandle();const $=z.getSize(),D=new Uint8Array($),g=z.read(D,{at:0});return{type:"loaded",name:K,data:D.slice(0,g)}}finally{z?.close()}}const C=await U.getFile(),F=new Uint8Array(await C.arrayBuffer());return{type:"loaded",name:K,data:F}}catch(P){const U=P.name==="NotFoundError"?"File not found":P.message||"Error reading file";return{type:"error",name:K,message:U}}},Y=async(K,P)=>{if(await G,!(P instanceof Uint8Array))return{type:"error",name:K,message:"Content must be a Uint8Array"};return V(K,async()=>{try{if(J==="idb")return await q.set(K,P),{type:"saved",name:K};const C=await(await navigator.storage.getDirectory()).getFileHandle(K,{create:!0});if(J==="sync"){let F;try{F=await C.createSyncAccessHandle(),F.truncate(0),F.write(P,{at:0}),F.flush()}finally{F?.close()}}else{let F;try{F=await C.createWritable(),await F.write(P)}finally{await F?.close()}}return{type:"saved",name:K}}catch(U){return{type:"error",name:K,message:U.message||"Error saving file"}}})};self.onmessage=async({data:K})=>{const{type:P,name:U,content:C}=K;await G;const F={load:()=>X(U),save:()=>Y(U,C)};try{const z=F[P],$=z?await z():{type:"error",message:`Unrecognized action type: ${P}`};self.postMessage($)}catch(z){console.error("Worker unexpected error:",z),self.postMessage({type:"error",name:U,message:z.message||"Unexpected worker error"})}}},DW=vG;var s0={$eq:(W,Q)=>W===Q,$ne:(W,Q)=>W!==Q,$gt:(W,Q)=>W>Q,$gte:(W,Q)=>W>=Q,$lt:(W,Q)=>W<Q,$lte:(W,Q)=>W<=Q,$in:(W,Q)=>Array.isArray(Q)&&Q.includes(W),$between:(W,[Q,J])=>W>=Q&&W<=J,$exists:(W,Q)=>Q?W!==void 0:W===void 0,$text:{global:(W,Q)=>{const J=(V)=>String(V).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^\w\s]/g,""),G=J(Q);return Object.values(W).some((V)=>{if(typeof V==="object")return null.fieldSearch(V,G);return J(V).includes(G)})},field:(W,Q)=>{const J=(G)=>String(G).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^\w\s]/g,"");return Array.isArray(W)?W.some((G)=>J(G).includes(J(Q))):J(W).includes(J(Q))}},$like:(W,Q)=>{if(typeof W!=="string"||typeof Q!=="string")return!1;return new RegExp(`^${Q.replace(/%/g,".*").replace(/_/g,".")}\$`,"i").test(W)},$regex:(W,Q)=>typeof W==="string"&&new RegExp(Q.$regex||Q,"i").test(W),$and:(W,Q,J)=>Q.every((G)=>{return J.createFilter(G,J.allNodes)(W)}),$or:(W,Q,J)=>Q.some((G)=>{return J.createFilter(G,J.allNodes)(W)}),$not:(W,Q,J)=>{return!J.createFilter(Q,J.allNodes)(W)},$edge:(W,Q,J)=>{if(!Q||typeof Q.target!=="object")return console.warn('$edge requires a "target" object in its condition.'),!1;if(!W.edges||W.edges.length===0)return!1;if(!J.allNodes)return console.error('The $edge operator requires the "allNodes" context.'),!1;const G=J.createFilter(Q.target,J.allNodes);return W.edges.some((V)=>{const q=J.allNodes[V];return q?G(q):!1})}},u6=(W,Q)=>{const J=Q.split(".");let G=W;for(let V of J)if(G&&typeof G==="object"&&(V in G))G=G[V];else return;return G},d6=(W,Q)=>{const J=(G)=>{if(Object.keys(W).length===0)return!0;return Object.entries(W).every(([V,q])=>{if(V.startsWith("$"))return s0[V](G,q,{filterNode:J,createFilter:d6,allNodes:Q});const X=u6(G.value,V);if(typeof q!=="object"||q===null)return s0.$eq(X,q);return Object.entries(q).every(([Y,K])=>{if(Y==="$text")return s0.$text.field(X,K);if(Y==="$between"&&K.every((P)=>P instanceof Date)){const P=new Date(X);return s0.$between(P,K)}return s0[Y]?.(X,K,{filterNode:J,createFilter:d6,allNodes:Q})??!1})})};return J},c6=(W,Q)=>{const J=d6(Q.query,W);let G=Object.values(W).filter(J);if(Q.field)G.sort((V,q)=>{const X=u6(V.value,Q.field),Y=u6(q.value,Q.field),K=Q.order==="asc"?1:-1;if(typeof X==="string"&&typeof Y==="string")return X.localeCompare(Y)*K;return((X??0)-(Y??0))*K});if(Q.$after){const V=G.findIndex((q)=>q.id===Q.$after);G=V>=0?G.slice(V+1):[]}if(Q.$before){const V=G.findIndex((q)=>q.id===Q.$before);G=V>=0?G.slice(0,V):[]}return Q.$limit?G.slice(0,Q.$limit):G};class _6{constructor(){this.physical=Date.now(),this.logical=0}now(){const W=Date.now();return this.physical=Math.max(this.physical,W),this.logical++,{physical:this.physical,logical:this.logical}}update(W){if(!W||typeof W.physical!=="number"||typeof W.logical!=="number")return;this.physical=Math.max(this.physical,W.physical),this.logical=Math.max(this.logical,W.logical)+1}compare(W,Q){if(!W&&!Q)return 0;if(!W)return-1;if(!Q)return 1;if(W.physical>Q.physical)return 1;if(W.physical<Q.physical)return-1;if(W.logical>Q.logical)return 1;if(W.logical<Q.logical)return-1;return 0}}var xW=function(W,Q){return W.length===Q.length&&W.every((J,G)=>J===Q[G])};async function gG(){console.info(navigator?.storage?.getDirectory?"\u2705 OPFS is enabled.":"\uD83D\uDEAB OPFS is not available."),navigator?.storage?.getDirectory&&await navigator.storage.getDirectory()}if(Symbol.dispose===void 0)Object.defineProperty(Symbol,"dispose",{value:Symbol.for("Symbol.dispose")});class NW{constructor(){this.nodes={}}upsert(W,Q,J){this.nodes[W]={id:W,value:Q,edges:[],timestamp:J}}get(W){return this.nodes[W]||null}link(W,Q,J){const G=this.nodes[W],V=this.nodes[Q];if(G&&V&&!G.edges.includes(Q))G.edges.push(Q),G.timestamp=J}getAllNodes(){return Object.values(this.nodes)}serialize(){return d0.deflate(I0(this.nodes))}deserialize(W){this.nodes=s1(d0.inflate(new Uint8Array(W)))}}class N8{static _listenersInitialized=!1;constructor(W,{password:Q,securityManager:J=null,relayUrls:G=null}={}){if(console.info("\u26A1 GenosDB: Empowering distributed graph databases with real-time synchronization and scalability. Learn more: https://github.com/estebanrfp/gdb \u26A1"),this.oplog=new m6(W,20),this.hybridClock=new _6,this.name=W,this.password=Q,this.globalTimestamp=null,this.graph=new NW,this.securityManager=J,!this.securityManager||typeof this.securityManager.verifyIncomingOperations!=="function")console.info("\u26A0\uFE0F SecurityManager inactive!"),console.info("\u27A1\uFE0F Processing P2P data directly.");else console.info("\uD83D\uDD12 GDB: SecurityManager active!"),console.info("\u27A1\uFE0F Verifying incoming operations with SecurityManager.");this.eventListeners=[],this.operators=s0,this.initWorker(),this.ready=this.loadGraphFromOPFS(),this.loadGlobalTimestamp();const V=`graph-sync-room-${this.name}`,q={appId:"1234",...this.password&&{password:this.password}};if(G)q.relayUrls=G;const X=b6(q,V),[Y,K]=X.makeAction("syncGraph");this.sendData=Y;const P=b6(q,`app-sync-${this.name}`);if(this.room=P,!N8._listenersInitialized)N8._listenersInitialized=!0,window.addEventListener("online",async()=>{console.log("\u2705 Reconnected to the network."),this.sendData([{type:"sync",timestamp:this.globalTimestamp}])}),window.addEventListener("offline",async()=>{console.log("\u274C Disconnected from the network.")}),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="visible")console.log("\uD83D\uDD04 The tab is visible again."),this.sendData([{type:"sync",timestamp:this.globalTimestamp}]);else if(document.visibilityState==="hidden")console.log("\uD83D\uDED1 The tab is no longer visible.")});gG(),X.onPeerJoin(async(U)=>{console.info("\u26A1 New peer connected:",U),this.sendData([{type:"sync",timestamp:this.globalTimestamp}])}),X.onPeerLeave((U)=>{console.info("\u26A1 Peer disconnected:",U)}),K(async(U)=>{if(this.securityManager&&typeof this.securityManager.verifyIncomingOperations==="function"){const{validatedOperations:C}=await this.securityManager.verifyIncomingOperations(U);if(C&&C.length>0)await this.receiveChanges(C)}else await this.receiveChanges(U),this.emit()}),this.channel=new BroadcastChannel(`graphdb_sync_${this.name}`),this.channel.onmessage=async(U)=>{if(U.data==="update")console.info("\uD83D\uDD04 Update received from another tab..."),await this.loadGraphFromOPFS(),this.loadGlobalTimestamp(),this.emit()}}loadGlobalTimestamp(){const W=localStorage.getItem(`${this.name}_time`);this.globalTimestamp=W?JSON.parse(W):null}saveGlobalTimestamp(W){this.globalTimestamp=W,localStorage.setItem(`${this.name}_time`,JSON.stringify(W))}initWorker(){try{const W=URL.createObjectURL(new Blob([`(${DW.toString()})()`],{type:"application/javascript"}));this.worker=new Worker(W),this.worker.addEventListener("message",({data:Q})=>{console.info(`\uD83D\uDCBE ${Q.name} ${Q.type}`),URL.revokeObjectURL(W)}),console.info("\u2699\uFE0F Worker initialized successfully.")}catch({message:W}){console.error("\u274C Failed to initialize worker:",W)}}getWorker(){return this.worker}emit(){this.eventListeners.forEach((W)=>W(this.graph.nodes))}compress(W){return d0.deflate(W)}decompress(W){return d0.inflate(W)}async getAllNodes(){return await this.ready,this.graph.getAllNodes()}async generateHash(){return crypto.randomUUID()}async hashValue(W){const Q=(new TextEncoder()).encode(W),J=await crypto.subtle.digest("SHA-256",Q);return Array.from(new Uint8Array(J)).map((G)=>G.toString(16).padStart(2,"0")).join("")}async loadGraphFromOPFS(){try{const Q=await((J)=>new Promise((G,V)=>{const q=async({data:X})=>{if(X.type==="loaded"&&X.name===J)this.worker.removeEventListener("message",q),G(new Uint8Array(X.data));else if(X.type==="error")this.worker.removeEventListener("message",q),V(new Error(X.message||"Unknown error"))};this.worker.addEventListener("message",q),this.worker.postMessage({type:"load",name:J})}))(`${this.name}_graph.msgpack`).catch(()=>new Uint8Array);Q.byteLength>0?this.graph.deserialize(Q):console.warn("\u26A0\uFE0F The file '_graph.msgpack' is empty or could not be loaded."),console.info(`\u2705 Graph loaded: [ ${this.graph.getAllNodes().length} nodes ]`)}catch({message:W}){console.error("\u274C Error loading the graph:",W)}}async saveGraphToOPFS(){try{const W=this.graph.serialize();return await((J,G)=>new Promise((V,q)=>{const X=({data:Y})=>{if(Y.type==="saved"&&Y.name===J)this.worker.removeEventListener("message",X),V();else if(Y.type==="error")this.worker.removeEventListener("message",X),q(new Error(Y.message||"Save error"))};this.worker.addEventListener("message",X),this.worker.postMessage({type:"save",name:J,content:G})}))(`${this.name}_graph.msgpack`,W),this.channel.postMessage("update"),!0}catch({message:W}){throw console.error("\u274C Save error:",W),new Error("Save failed")}}async put(W,Q){await this.ready;const J=this.hybridClock.now();return this.saveGlobalTimestamp(J),Q??=await this.generateHash(),this.graph.upsert(Q,W,J),this.oplog.add({type:"upsert",id:Q,timestamp:J}),await this.saveGraphToOPFS(),await this.sendData([{type:"upsert",id:Q,value:W,timestamp:J}]),this.emit(),Q}async get(W,Q=null){if(await this.ready,typeof W!=="string")return{result:null};const J=this.graph.get(W);if(!J){if(Q)Q(null);return{result:null}}const G=(X)=>{if(!X)return null;const Y=X.value!==null&&typeof X.value==="object"?{...X.value}:X.value;return{...X,value:Y}};if(!Q)return{result:G(J)};let V=J.timestamp;Q(G(J));const q=(X)=>{const Y=X[W];if(Y){if(this.hybridClock.compare(Y.timestamp,V)>0)V=Y.timestamp,Q(G(Y))}else Q(null),this.eventListeners.splice(this.eventListeners.indexOf(q),1)};return this.eventListeners.push(q),{result:G(J),unsubscribe:()=>{const X=this.eventListeners.indexOf(q);if(X>-1)this.eventListeners.splice(X,1)}}}async map(...W){await this.ready;let J={...{realtime:!1,query:{},field:null,order:"asc",$limit:null,$after:null,$before:null}},G=null,V=!1;W.forEach((K)=>typeof K==="function"?G=K:K&&typeof K==="object"&&(V||=("realtime"in K),Object.assign(J,K))),G&&!V&&(J.realtime=!0);let q=c6(this.graph.nodes,J),X=null;const Y=(K)=>{const P=K.filter((z)=>!q.some(($)=>$.id===z.id)),U=q.filter((z)=>!K.some(($)=>$.id===z.id)),C=K.filter((z)=>{const $=q.find((D)=>D.id===z.id);return $&&!xW(I0(z.value),I0($.value))}),F=(z,$)=>{const D=$==="removed"?null:z.value,g={id:z.id,value:D,edges:z.edges||[],timestamp:z.timestamp||null,action:$};G(g)};P.forEach((z)=>F(z,"added")),U.forEach((z)=>F(z,"removed")),C.forEach((z)=>F(z,"updated"))};if(G){if(q.forEach((K)=>{if(K.value)G({id:K.id,value:K.value,edges:K.edges,timestamp:K.timestamp,action:"initial"})}),J.realtime)X=(K)=>{const P=c6(K,J);if(!xW(I0(P),I0(q)))Y(P),q=P},this.eventListeners.push(X)}return{results:q,...J.realtime&&G&&X&&{unsubscribe:()=>{const K=this.eventListeners.indexOf(X);K>-1&&this.eventListeners.splice(K,1)}}}}async remove(W){await this.ready;const Q=this.hybridClock.now(),J=this.graph.get(W);if(!J)return console.warn(`\u26A0\uFE0F Node with ID '${W}' not found.`);delete this.graph.nodes[W],this.oplog.add({type:"remove",id:W,timestamp:Q}),Object.values(this.graph.nodes).forEach((G)=>G.edges=G.edges.filter((V)=>V!==W)),await this.saveGraphToOPFS(),this.saveGlobalTimestamp(Q),await this.sendData([{type:"remove",id:W,value:J.value,timestamp:Q}]),this.emit()}async clear(){await this.ready,this.graph.nodes={};try{await(await navigator.storage.getDirectory()).removeEntry(`${this.name}_graph.msgpack`)}catch({message:W}){console.warn(`\u26A0\uFE0F Error deleting _graph.msgpack: ${W}`)}this.emit(),console.info("\u2705 All data has been deleted.")}async link(W,Q){await this.ready;const J=this.hybridClock.now();if(!this.graph.nodes[W]||!this.graph.nodes[Q]){console.warn(`\u26A0\uFE0F One or both nodes (${W}, ${Q}) do not exist.`);return}this.graph.link(W,Q,J),this.oplog.add({type:"link",sourceId:W,targetId:Q,timestamp:J}),await this.saveGraphToOPFS(),this.saveGlobalTimestamp(J),await this.sendData([{type:"link",sourceId:W,targetId:Q,timestamp:J}]),this.emit()}async applyFullGraph(W){try{console.info("\uD83D\uDD04 Applying full graph from remote..."),this.graph.nodes={...W.nodes},await this.saveGraphToOPFS()}catch({message:Q}){console.error(`\u274C Error applying the full graph: ${Q}`)}}async receiveChanges(W){let Q=!1,J=null;const G={upsert:(V)=>{const q=this.graph.get(V.id),X=wW(q,V,this.hybridClock);if(X.resolved){if(this.graph.upsert(V.id,X.value,X.timestamp),this.hybridClock.update(X.timestamp),this.oplog.add({type:"upsert",id:V.id,timestamp:X.timestamp}),Q=!0,!J||this.hybridClock.compare(X.timestamp,J)>0)J=X.timestamp}},remove:(V)=>{const q=this.graph.get(V.id);if(q&&this.hybridClock.compare(q.timestamp,V.timestamp)<0){if(delete this.graph.nodes[V.id],this.hybridClock.update(V.timestamp),this.oplog.add({type:"remove",id:V.id,timestamp:V.timestamp}),Q=!0,!J||this.hybridClock.compare(V.timestamp,J)>0)J=V.timestamp}},link:(V)=>{const q=this.graph.get(V.sourceId),X=this.graph.get(V.targetId);if(q&&X&&this.hybridClock.compare(q.timestamp,V.timestamp)<0){if(this.graph.link(V.sourceId,V.targetId,V.timestamp),this.hybridClock.update(V.timestamp),this.oplog.add({type:"link",sourceId:V.sourceId,targetId:V.targetId,timestamp:V.timestamp}),Q=!0,!J||this.hybridClock.compare(V.timestamp,J)>0)J=V.timestamp}},sync:async(V)=>{const q=V.timestamp;console.info("\uD83D\uDCEC [SYNC REQUEST] since:",new Date(q.physical).toLocaleString());const X=this.oplog.getOldest();if(X&&q&&this.hybridClock.compare(q,X.timestamp)<0){console.info("\uD83D\uDCA5 [FALLBACK TRIGGERED] Peer is too far behind. Sending FULL graph state."),await this.sendData([{type:"syncReceive",graph:this.graph}]);return}const Y=this.oplog.getDelta(q,this.hybridClock.compare);if(Y.length>0){const K=Y.map((U)=>{if(U.type==="upsert"){const C=this.graph.get(U.id);return{...U,value:C?C.value:null}}return U}),P=d0.deflate(I0(K));console.info("\uD83D\uDCE6 [DELTA SYNC COMPRESSING] Delta compressed for transport."),console.info(`\uD83D\uDE80 [DELTA SYNC SENDING] Found ${Y.length} new operations to send.`),await this.sendData([{type:"deltaSync",operations:P}])}else console.info("\u2705 [ALREADY SYNCED] Peer is up-to-date. Nothing to send.")},deltaSync:(V)=>{console.info("\uD83D\uDEF0\uFE0F [DELTA SYNC RECEIVED] Compressed delta sync received.");let q=s1(d0.inflate(V.operations));console.info("\uD83D\uDEF0\uFE0F [DELTA SYNC DECOMPRESSING] Decompressing delta..."),console.info(`\uD83D\uDEF0\uFE0F [DELTA SYNC APPLYING] Applying ${q.length} operations from a peer.`);for(let X of q)G[X.type]?.(X)},syncReceive:async(V)=>{if(console.info("\uD83D\uDCE6 [FULL SYNC RECEIVED] Overwriting local state with full graph from a peer."),V.graph)await this.applyFullGraph(V.graph),this.oplog.clear(),console.info("\uD83D\uDD12 Oplog has been cleared due to full sync."),Q=!0;else console.error("\u274C Full sync failed: received graph data is invalid.",V.graph)}};for(let V of W)if(G[V.type])await G[V.type](V);else console.warn(`\uD83E\uDD37\u200D\u2640\uFE0F [UNKNOWN MESSAGE TYPE] Received unhandled message type: "${V.type}"`);if(J)console.info("\uD83D\uDCC8 [LOCAL TIMESTAMP] Updated."),this.saveGlobalTimestamp(J);if(Q)console.info("\uD83D\uDCBE [STATE CHANGED] Saving state and emitting update."),await this.saveGraphToOPFS(),this.emit()}}export{N8 as default};
1
+ function l6(W){const G=W.length;let J=0,Q=0;while(Q<G){let V=W.charCodeAt(Q++);if((V&4294967168)===0){J++;continue}else if((V&4294965248)===0)J+=2;else{if(V>=55296&&V<=56319){if(Q<G){const X=W.charCodeAt(Q);if((X&64512)===56320)++Q,V=((V&1023)<<10)+(X&1023)+65536}}if((V&4294901760)===0)J+=3;else J+=4}}return J}function AW(W,G,J){const Q=W.length;let V=J,X=0;while(X<Q){let q=W.charCodeAt(X++);if((q&4294967168)===0){G[V++]=q;continue}else if((q&4294965248)===0)G[V++]=q>>6&31|192;else{if(q>=55296&&q<=56319){if(X<Q){const Y=W.charCodeAt(X);if((Y&64512)===56320)++X,q=((q&1023)<<10)+(Y&1023)+65536}}if((q&4294901760)===0)G[V++]=q>>12&15|224,G[V++]=q>>6&63|128;else G[V++]=q>>18&7|240,G[V++]=q>>12&63|128,G[V++]=q>>6&63|128}G[V++]=q&63|128}}function TW(W,G,J){vW.encodeInto(W,G.subarray(J))}function i6(W,G,J){if(W.length>gW)TW(W,G,J);else AW(W,G,J)}function v8(W,G,J){let Q=G;const V=Q+J,X=[];let q="";while(Q<V){const Y=W[Q++];if((Y&128)===0)X.push(Y);else if((Y&224)===192){const K=W[Q++]&63;X.push((Y&31)<<6|K)}else if((Y&240)===224){const K=W[Q++]&63,P=W[Q++]&63;X.push((Y&31)<<12|K<<6|P)}else if((Y&248)===240){const K=W[Q++]&63,P=W[Q++]&63,U=W[Q++]&63;let C=(Y&7)<<18|K<<12|P<<6|U;if(C>65535)C-=65536,X.push(C>>>10&1023|55296),C=56320|C&1023;X.push(C)}else X.push(Y);if(X.length>=SW)q+=String.fromCharCode(...X),X.length=0}if(X.length>0)q+=String.fromCharCode(...X);return q}function pW(W,G,J){const Q=W.subarray(G,G+J);return yW.decode(Q)}function r6(W,G,J){if(J>EW)return pW(W,G,J);else return v8(W,G,J)}var vW=new TextEncoder,gW=50,SW=4096,yW=new TextDecoder,EW=200;class e0{constructor(W,G){this.type=W,this.data=G}}class e extends Error{constructor(W){super(W);const G=Object.create(e.prototype);Object.setPrototypeOf(this,G),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:e.name})}}function a6(W,G,J){const Q=J/4294967296,V=J;W.setUint32(G,Q),W.setUint32(G+4,V)}function i1(W,G,J){const Q=Math.floor(J/4294967296),V=J;W.setUint32(G,Q),W.setUint32(G+4,V)}function r1(W,G){const J=W.getInt32(G),Q=W.getUint32(G+4);return J*4294967296+Q}function o6(W,G){const J=W.getUint32(G),Q=W.getUint32(G+4);return J*4294967296+Q}var t0=4294967295;function mW({sec:W,nsec:G}){if(W>=0&&G>=0&&W<=bW)if(G===0&&W<=hW){const J=new Uint8Array(4);return new DataView(J.buffer).setUint32(0,W),J}else{const J=W/4294967296,Q=W&4294967295,V=new Uint8Array(8),X=new DataView(V.buffer);return X.setUint32(0,G<<2|J&3),X.setUint32(4,Q),V}else{const J=new Uint8Array(12),Q=new DataView(J.buffer);return Q.setUint32(0,G),i1(Q,4,W),J}}function uW(W){const G=W.getTime(),J=Math.floor(G/1000),Q=(G-J*1000)*1e6,V=Math.floor(Q/1e9);return{sec:J+V,nsec:Q-V*1e9}}function dW(W){if(W instanceof Date){const G=uW(W);return mW(G)}else return null}function cW(W){const G=new DataView(W.buffer,W.byteOffset,W.byteLength);switch(W.byteLength){case 4:return{sec:G.getUint32(0),nsec:0};case 8:{const J=G.getUint32(0),Q=G.getUint32(4),V=(J&3)*4294967296+Q,X=J>>>2;return{sec:V,nsec:X}}case 12:{const J=r1(G,4),Q=G.getUint32(0);return{sec:J,nsec:Q}}default:throw new e(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${W.length}`)}}function _W(W){const G=cW(W);return new Date(G.sec*1000+G.nsec/1e6)}var fW=-1,hW=4294967295,bW=17179869183,n6={type:fW,encode:dW,decode:_W};class S0{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(n6)}register({type:W,encode:G,decode:J}){if(W>=0)this.encoders[W]=G,this.decoders[W]=J;else{const Q=-1-W;this.builtInEncoders[Q]=G,this.builtInDecoders[Q]=J}}tryToEncode(W,G){for(let J=0;J<this.builtInEncoders.length;J++){const Q=this.builtInEncoders[J];if(Q!=null){const V=Q(W,G);if(V!=null){const X=-1-J;return new e0(X,V)}}}for(let J=0;J<this.encoders.length;J++){const Q=this.encoders[J];if(Q!=null){const V=Q(W,G);if(V!=null)return new e0(J,V)}}if(W instanceof e0)return W;return null}decode(W,G,J){const Q=G<0?this.builtInDecoders[-1-G]:this.decoders[G];if(Q)return Q(W,G,J);else return new e0(G,W)}}S0.defaultCodec=new S0;var lW=function(W){return W instanceof ArrayBuffer||typeof SharedArrayBuffer!=="undefined"&&W instanceof SharedArrayBuffer};function M1(W){if(W instanceof Uint8Array)return W;else if(ArrayBuffer.isView(W))return new Uint8Array(W.buffer,W.byteOffset,W.byteLength);else if(lW(W))return new Uint8Array(W);else return Uint8Array.from(W)}var iW=100,rW=2048;class a1{constructor(W){this.entered=!1,this.extensionCodec=W?.extensionCodec??S0.defaultCodec,this.context=W?.context,this.useBigInt64=W?.useBigInt64??!1,this.maxDepth=W?.maxDepth??iW,this.initialBufferSize=W?.initialBufferSize??rW,this.sortKeys=W?.sortKeys??!1,this.forceFloat32=W?.forceFloat32??!1,this.ignoreUndefined=W?.ignoreUndefined??!1,this.forceIntegerToFloat=W?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new a1({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(W){if(this.entered)return this.clone().encodeSharedRef(W);try{return this.entered=!0,this.reinitializeState(),this.doEncode(W,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(W){if(this.entered)return this.clone().encode(W);try{return this.entered=!0,this.reinitializeState(),this.doEncode(W,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(W,G){if(G>this.maxDepth)throw new Error(`Too deep objects in depth ${G}`);if(W==null)this.encodeNil();else if(typeof W==="boolean")this.encodeBoolean(W);else if(typeof W==="number")if(!this.forceIntegerToFloat)this.encodeNumber(W);else this.encodeNumberAsFloat(W);else if(typeof W==="string")this.encodeString(W);else if(this.useBigInt64&&typeof W==="bigint")this.encodeBigInt64(W);else this.encodeObject(W,G)}ensureBufferSizeToWrite(W){const G=this.pos+W;if(this.view.byteLength<G)this.resizeBuffer(G*2)}resizeBuffer(W){const G=new ArrayBuffer(W),J=new Uint8Array(G),Q=new DataView(G);J.set(this.bytes),this.view=Q,this.bytes=J}encodeNil(){this.writeU8(192)}encodeBoolean(W){if(W===!1)this.writeU8(194);else this.writeU8(195)}encodeNumber(W){if(!this.forceIntegerToFloat&&Number.isSafeInteger(W))if(W>=0)if(W<128)this.writeU8(W);else if(W<256)this.writeU8(204),this.writeU8(W);else if(W<65536)this.writeU8(205),this.writeU16(W);else if(W<4294967296)this.writeU8(206),this.writeU32(W);else if(!this.useBigInt64)this.writeU8(207),this.writeU64(W);else this.encodeNumberAsFloat(W);else if(W>=-32)this.writeU8(224|W+32);else if(W>=-128)this.writeU8(208),this.writeI8(W);else if(W>=-32768)this.writeU8(209),this.writeI16(W);else if(W>=-2147483648)this.writeU8(210),this.writeI32(W);else if(!this.useBigInt64)this.writeU8(211),this.writeI64(W);else this.encodeNumberAsFloat(W);else this.encodeNumberAsFloat(W)}encodeNumberAsFloat(W){if(this.forceFloat32)this.writeU8(202),this.writeF32(W);else this.writeU8(203),this.writeF64(W)}encodeBigInt64(W){if(W>=BigInt(0))this.writeU8(207),this.writeBigUint64(W);else this.writeU8(211),this.writeBigInt64(W)}writeStringHeader(W){if(W<32)this.writeU8(160+W);else if(W<256)this.writeU8(217),this.writeU8(W);else if(W<65536)this.writeU8(218),this.writeU16(W);else if(W<4294967296)this.writeU8(219),this.writeU32(W);else throw new Error(`Too long string: ${W} bytes in UTF-8`)}encodeString(W){const J=l6(W);this.ensureBufferSizeToWrite(5+J),this.writeStringHeader(J),i6(W,this.bytes,this.pos),this.pos+=J}encodeObject(W,G){const J=this.extensionCodec.tryToEncode(W,this.context);if(J!=null)this.encodeExtension(J);else if(Array.isArray(W))this.encodeArray(W,G);else if(ArrayBuffer.isView(W))this.encodeBinary(W);else if(typeof W==="object")this.encodeMap(W,G);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(W)}`)}encodeBinary(W){const G=W.byteLength;if(G<256)this.writeU8(196),this.writeU8(G);else if(G<65536)this.writeU8(197),this.writeU16(G);else if(G<4294967296)this.writeU8(198),this.writeU32(G);else throw new Error(`Too large binary: ${G}`);const J=M1(W);this.writeU8a(J)}encodeArray(W,G){const J=W.length;if(J<16)this.writeU8(144+J);else if(J<65536)this.writeU8(220),this.writeU16(J);else if(J<4294967296)this.writeU8(221),this.writeU32(J);else throw new Error(`Too large array: ${J}`);for(let Q of W)this.doEncode(Q,G+1)}countWithoutUndefined(W,G){let J=0;for(let Q of G)if(W[Q]!==void 0)J++;return J}encodeMap(W,G){const J=Object.keys(W);if(this.sortKeys)J.sort();const Q=this.ignoreUndefined?this.countWithoutUndefined(W,J):J.length;if(Q<16)this.writeU8(128+Q);else if(Q<65536)this.writeU8(222),this.writeU16(Q);else if(Q<4294967296)this.writeU8(223),this.writeU32(Q);else throw new Error(`Too large map object: ${Q}`);for(let V of J){const X=W[V];if(!(this.ignoreUndefined&&X===void 0))this.encodeString(V),this.doEncode(X,G+1)}}encodeExtension(W){if(typeof W.data==="function"){const J=W.data(this.pos+6),Q=J.length;if(Q>=4294967296)throw new Error(`Too large extension object: ${Q}`);this.writeU8(201),this.writeU32(Q),this.writeI8(W.type),this.writeU8a(J);return}const G=W.data.length;if(G===1)this.writeU8(212);else if(G===2)this.writeU8(213);else if(G===4)this.writeU8(214);else if(G===8)this.writeU8(215);else if(G===16)this.writeU8(216);else if(G<256)this.writeU8(199),this.writeU8(G);else if(G<65536)this.writeU8(200),this.writeU16(G);else if(G<4294967296)this.writeU8(201),this.writeU32(G);else throw new Error(`Too large extension object: ${G}`);this.writeI8(W.type),this.writeU8a(W.data)}writeU8(W){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,W),this.pos++}writeU8a(W){const G=W.length;this.ensureBufferSizeToWrite(G),this.bytes.set(W,this.pos),this.pos+=G}writeI8(W){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,W),this.pos++}writeU16(W){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,W),this.pos+=2}writeI16(W){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,W),this.pos+=2}writeU32(W){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,W),this.pos+=4}writeI32(W){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,W),this.pos+=4}writeF32(W){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,W),this.pos+=4}writeF64(W){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,W),this.pos+=8}writeU64(W){this.ensureBufferSizeToWrite(8),a6(this.view,this.pos,W),this.pos+=8}writeI64(W){this.ensureBufferSizeToWrite(8),i1(this.view,this.pos,W),this.pos+=8}writeBigUint64(W){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,W),this.pos+=8}writeBigInt64(W){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,W),this.pos+=8}}function I0(W,G){return new a1(G).encodeSharedRef(W)}function o1(W){return`${W<0?"-":""}0x${Math.abs(W).toString(16).padStart(2,"0")}`}var aW=16,oW=16;class g8{constructor(W=aW,G=oW){this.hit=0,this.miss=0,this.maxKeyLength=W,this.maxLengthPerKey=G,this.caches=[];for(let J=0;J<this.maxKeyLength;J++)this.caches.push([])}canBeCached(W){return W>0&&W<=this.maxKeyLength}find(W,G,J){const Q=this.caches[J-1];W:for(let V of Q){const X=V.bytes;for(let q=0;q<J;q++)if(X[q]!==W[G+q])continue W;return V.str}return null}store(W,G){const J=this.caches[W.length-1],Q={bytes:W,str:G};if(J.length>=this.maxLengthPerKey)J[Math.random()*J.length|0]=Q;else J.push(Q)}decode(W,G,J){const Q=this.find(W,G,J);if(Q!=null)return this.hit++,Q;this.miss++;const V=v8(W,G,J),X=Uint8Array.prototype.slice.call(W,G,G+J);return this.store(X,V),V}}var T8="array",j1="map_key",e6="map_value",nW=(W)=>{if(typeof W==="string"||typeof W==="number")return W;throw new e("The type of key must be string or number but "+typeof W)};class t6{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(W){const G=this.getUninitializedStateFromPool();G.type=T8,G.position=0,G.size=W,G.array=new Array(W)}pushMapState(W){const G=this.getUninitializedStateFromPool();G.type=j1,G.readCount=0,G.size=W,G.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){const W={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(W)}return this.stack[this.stackHeadPosition]}release(W){if(this.stack[this.stackHeadPosition]!==W)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(W.type===T8){const J=W;J.size=0,J.array=void 0,J.position=0,J.type=void 0}if(W.type===j1||W.type===e6){const J=W;J.size=0,J.map=void 0,J.readCount=0,J.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}var B1=-1,S8=new DataView(new ArrayBuffer(0)),sW=new Uint8Array(S8.buffer);try{S8.getInt8(0)}catch(W){if(!(W instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var s6=new RangeError("Insufficient data"),eW=new g8;class n1{constructor(W){this.totalPos=0,this.pos=0,this.view=S8,this.bytes=sW,this.headByte=B1,this.stack=new t6,this.entered=!1,this.extensionCodec=W?.extensionCodec??S0.defaultCodec,this.context=W?.context,this.useBigInt64=W?.useBigInt64??!1,this.rawStrings=W?.rawStrings??!1,this.maxStrLength=W?.maxStrLength??t0,this.maxBinLength=W?.maxBinLength??t0,this.maxArrayLength=W?.maxArrayLength??t0,this.maxMapLength=W?.maxMapLength??t0,this.maxExtLength=W?.maxExtLength??t0,this.keyDecoder=W?.keyDecoder!==void 0?W.keyDecoder:eW,this.mapKeyConverter=W?.mapKeyConverter??nW}clone(){return new n1({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=B1,this.stack.reset()}setBuffer(W){const G=M1(W);this.bytes=G,this.view=new DataView(G.buffer,G.byteOffset,G.byteLength),this.pos=0}appendBuffer(W){if(this.headByte===B1&&!this.hasRemaining(1))this.setBuffer(W);else{const G=this.bytes.subarray(this.pos),J=M1(W),Q=new Uint8Array(G.length+J.length);Q.set(G),Q.set(J,G.length),this.setBuffer(Q)}}hasRemaining(W){return this.view.byteLength-this.pos>=W}createExtraByteError(W){const{view:G,pos:J}=this;return new RangeError(`Extra ${G.byteLength-J} of ${G.byteLength} byte(s) found at buffer[${W}]`)}decode(W){if(this.entered)return this.clone().decode(W);try{this.entered=!0,this.reinitializeState(),this.setBuffer(W);const G=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return G}finally{this.entered=!1}}*decodeMulti(W){if(this.entered){yield*this.clone().decodeMulti(W);return}try{this.entered=!0,this.reinitializeState(),this.setBuffer(W);while(this.hasRemaining(1))yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(W){if(this.entered)return this.clone().decodeAsync(W);try{this.entered=!0;let G=!1,J;for await(let q of W){if(G)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(q);try{J=this.doDecodeSync(),G=!0}catch(Y){if(!(Y instanceof RangeError))throw Y}this.totalPos+=this.pos}if(G){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return J}const{headByte:Q,pos:V,totalPos:X}=this;throw new RangeError(`Insufficient data in parsing ${o1(Q)} at ${X} (${V} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(W){return this.decodeMultiAsync(W,!0)}decodeStream(W){return this.decodeMultiAsync(W,!1)}async*decodeMultiAsync(W,G){if(this.entered){yield*this.clone().decodeMultiAsync(W,G);return}try{this.entered=!0;let J=G,Q=-1;for await(let V of W){if(G&&Q===0)throw this.createExtraByteError(this.totalPos);if(this.appendBuffer(V),J)Q=this.readArraySize(),J=!1,this.complete();try{while(!0)if(yield this.doDecodeSync(),--Q===0)break}catch(X){if(!(X instanceof RangeError))throw X}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){W:while(!0){const W=this.readHeadByte();let G;if(W>=224)G=W-256;else if(W<192)if(W<128)G=W;else if(W<144){const Q=W-128;if(Q!==0){this.pushMapState(Q),this.complete();continue W}else G={}}else if(W<160){const Q=W-144;if(Q!==0){this.pushArrayState(Q),this.complete();continue W}else G=[]}else{const Q=W-160;G=this.decodeString(Q,0)}else if(W===192)G=null;else if(W===194)G=!1;else if(W===195)G=!0;else if(W===202)G=this.readF32();else if(W===203)G=this.readF64();else if(W===204)G=this.readU8();else if(W===205)G=this.readU16();else if(W===206)G=this.readU32();else if(W===207)if(this.useBigInt64)G=this.readU64AsBigInt();else G=this.readU64();else if(W===208)G=this.readI8();else if(W===209)G=this.readI16();else if(W===210)G=this.readI32();else if(W===211)if(this.useBigInt64)G=this.readI64AsBigInt();else G=this.readI64();else if(W===217){const Q=this.lookU8();G=this.decodeString(Q,1)}else if(W===218){const Q=this.lookU16();G=this.decodeString(Q,2)}else if(W===219){const Q=this.lookU32();G=this.decodeString(Q,4)}else if(W===220){const Q=this.readU16();if(Q!==0){this.pushArrayState(Q),this.complete();continue W}else G=[]}else if(W===221){const Q=this.readU32();if(Q!==0){this.pushArrayState(Q),this.complete();continue W}else G=[]}else if(W===222){const Q=this.readU16();if(Q!==0){this.pushMapState(Q),this.complete();continue W}else G={}}else if(W===223){const Q=this.readU32();if(Q!==0){this.pushMapState(Q),this.complete();continue W}else G={}}else if(W===196){const Q=this.lookU8();G=this.decodeBinary(Q,1)}else if(W===197){const Q=this.lookU16();G=this.decodeBinary(Q,2)}else if(W===198){const Q=this.lookU32();G=this.decodeBinary(Q,4)}else if(W===212)G=this.decodeExtension(1,0);else if(W===213)G=this.decodeExtension(2,0);else if(W===214)G=this.decodeExtension(4,0);else if(W===215)G=this.decodeExtension(8,0);else if(W===216)G=this.decodeExtension(16,0);else if(W===199){const Q=this.lookU8();G=this.decodeExtension(Q,1)}else if(W===200){const Q=this.lookU16();G=this.decodeExtension(Q,2)}else if(W===201){const Q=this.lookU32();G=this.decodeExtension(Q,4)}else throw new e(`Unrecognized type byte: ${o1(W)}`);this.complete();const J=this.stack;while(J.length>0){const Q=J.top();if(Q.type===T8)if(Q.array[Q.position]=G,Q.position++,Q.position===Q.size)G=Q.array,J.release(Q);else continue W;else if(Q.type===j1){if(G==="__proto__")throw new e("The key __proto__ is not allowed");Q.key=this.mapKeyConverter(G),Q.type=e6;continue W}else if(Q.map[Q.key]=G,Q.readCount++,Q.readCount===Q.size)G=Q.map,J.release(Q);else{Q.key=null,Q.type=j1;continue W}}return G}}readHeadByte(){if(this.headByte===B1)this.headByte=this.readU8();return this.headByte}complete(){this.headByte=B1}readArraySize(){const W=this.readHeadByte();switch(W){case 220:return this.readU16();case 221:return this.readU32();default:if(W<160)return W-144;else throw new e(`Unrecognized array type byte: ${o1(W)}`)}}pushMapState(W){if(W>this.maxMapLength)throw new e(`Max length exceeded: map length (${W}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(W)}pushArrayState(W){if(W>this.maxArrayLength)throw new e(`Max length exceeded: array length (${W}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(W)}decodeString(W,G){if(!this.rawStrings||this.stateIsMapKey())return this.decodeUtf8String(W,G);return this.decodeBinary(W,G)}decodeUtf8String(W,G){if(W>this.maxStrLength)throw new e(`Max length exceeded: UTF-8 byte length (${W}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+G+W)throw s6;const J=this.pos+G;let Q;if(this.stateIsMapKey()&&this.keyDecoder?.canBeCached(W))Q=this.keyDecoder.decode(this.bytes,J,W);else Q=r6(this.bytes,J,W);return this.pos+=G+W,Q}stateIsMapKey(){if(this.stack.length>0)return this.stack.top().type===j1;return!1}decodeBinary(W,G){if(W>this.maxBinLength)throw new e(`Max length exceeded: bin length (${W}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(W+G))throw s6;const J=this.pos+G,Q=this.bytes.subarray(J,J+W);return this.pos+=G+W,Q}decodeExtension(W,G){if(W>this.maxExtLength)throw new e(`Max length exceeded: ext length (${W}) > maxExtLength (${this.maxExtLength})`);const J=this.view.getInt8(this.pos+G),Q=this.decodeBinary(W,G+1);return this.extensionCodec.decode(Q,J,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const W=this.view.getUint8(this.pos);return this.pos++,W}readI8(){const W=this.view.getInt8(this.pos);return this.pos++,W}readU16(){const W=this.view.getUint16(this.pos);return this.pos+=2,W}readI16(){const W=this.view.getInt16(this.pos);return this.pos+=2,W}readU32(){const W=this.view.getUint32(this.pos);return this.pos+=4,W}readI32(){const W=this.view.getInt32(this.pos);return this.pos+=4,W}readU64(){const W=o6(this.view,this.pos);return this.pos+=8,W}readI64(){const W=r1(this.view,this.pos);return this.pos+=8,W}readU64AsBigInt(){const W=this.view.getBigUint64(this.pos);return this.pos+=8,W}readI64AsBigInt(){const W=this.view.getBigInt64(this.pos);return this.pos+=8,W}readF32(){const W=this.view.getFloat32(this.pos);return this.pos+=4,W}readF64(){const W=this.view.getFloat64(this.pos);return this.pos+=8,W}}function s1(W,G){return new n1(G).decode(W)}var X1=function(W){let G=W.length;while(--G>=0)W[G]=0},E8=function(W,G,J,Q,V){this.static_tree=W,this.extra_bits=G,this.extra_base=J,this.elems=Q,this.max_length=V,this.has_stree=W&&W.length},p8=function(W,G){this.dyn_tree=W,this.max_code=0,this.stat_desc=G},K0=function(W,G,J,Q,V){this.good_length=W,this.max_lazy=G,this.nice_length=J,this.max_chain=Q,this.func=V},W9=function(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Y8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(lJ*2),this.dyn_dtree=new Uint16Array((2*cJ+1)*2),this.bl_tree=new Uint16Array((2*_J+1)*2),w0(this.dyn_ltree),w0(this.dyn_dtree),w0(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(iJ+1),this.heap=new Uint16Array(2*s8+1),w0(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*s8+1),w0(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0},R9=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},f1=function(W){this.options=P8.assign({level:N9,method:v9,chunkSize:16384,windowBits:15,memLevel:8,strategy:A9},W||{});let G=this.options;if(G.raw&&G.windowBits>0)G.windowBits=-G.windowBits;else if(G.gzip&&G.windowBits>0&&G.windowBits<16)G.windowBits+=16;this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new X7,this.strm.avail_out=0;let J=w1.deflateInit2(this.strm,G.level,G.method,G.windowBits,G.memLevel,G.strategy);if(J!==X8)throw new Error(f0[J]);if(G.header)w1.deflateSetHeader(this.strm,G.header);if(G.dictionary){let Q;if(typeof G.dictionary==="string")Q=S1.string2buf(G.dictionary);else if(q7.call(G.dictionary)==="[object ArrayBuffer]")Q=new Uint8Array(G.dictionary);else Q=G.dictionary;if(J=w1.deflateSetDictionary(this.strm,Q),J!==X8)throw new Error(f0[J]);this._dict_set=!0}},P6=function(W,G){const J=new f1(G);if(J.push(W,!0),J.err)throw J.msg||f0[J.err];return J.result},g9=function(W,G){return G=G||{},G.raw=!0,P6(W,G)},T9=function(W,G){return G=G||{},G.gzip=!0,P6(W,G)},JG=function(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0},MG=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},h1=function(W){this.options=P8.assign({chunkSize:65536,windowBits:15,to:""},W||{});const G=this.options;if(G.raw&&G.windowBits>=0&&G.windowBits<16){if(G.windowBits=-G.windowBits,G.windowBits===0)G.windowBits=-15}if(G.windowBits>=0&&G.windowBits<16&&!(W&&W.windowBits))G.windowBits+=32;if(G.windowBits>15&&G.windowBits<48){if((G.windowBits&15)===0)G.windowBits|=15}this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new X7,this.strm.avail_out=0;let J=j0.inflateInit2(this.strm,G.windowBits);if(J!==y1)throw new Error(f0[J]);if(this.header=new BG,j0.inflateGetHeader(this.strm,this.header),G.dictionary){if(typeof G.dictionary==="string")G.dictionary=S1.string2buf(G.dictionary);else if(M7.call(G.dictionary)==="[object ArrayBuffer]")G.dictionary=new Uint8Array(G.dictionary);if(G.raw){if(J=j0.inflateSetDictionary(this.strm,G.dictionary),J!==y1)throw new Error(f0[J])}}},U6=function(W,G){const J=new h1(G);if(J.push(W),J.err)throw J.msg||f0[J.err];return J.result},IG=function(W,G){return G=G||{},G.raw=!0,U6(W,G)};/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */var tW=0,h5=1,WJ=2,JJ=3,GJ=258,Q6=29,E1=256,D1=E1+1+Q6,G1=30,V6=19,b5=2*D1+1,y0=15,y8=16,QJ=7,X6=256,m5=16,u5=17,d5=18,a8=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Q8=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),VJ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),c5=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),XJ=512,B0=new Array((D1+2)*2);X1(B0);var I1=new Array(G1*2);X1(I1);var N1=new Array(XJ);X1(N1);var A1=new Array(GJ-JJ+1);X1(A1);var q6=new Array(Q6);X1(q6);var V8=new Array(G1);X1(V8);var _5,l5,i5,r5=(W)=>{return W<256?N1[W]:N1[256+(W>>>7)]},v1=(W,G)=>{W.pending_buf[W.pending++]=G&255,W.pending_buf[W.pending++]=G>>>8&255},J0=(W,G,J)=>{if(W.bi_valid>y8-J)W.bi_buf|=G<<W.bi_valid&65535,v1(W,W.bi_buf),W.bi_buf=G>>y8-W.bi_valid,W.bi_valid+=J-y8;else W.bi_buf|=G<<W.bi_valid&65535,W.bi_valid+=J},F0=(W,G,J)=>{J0(W,J[G*2],J[G*2+1])},a5=(W,G)=>{let J=0;do J|=W&1,W>>>=1,J<<=1;while(--G>0);return J>>>1},qJ=(W)=>{if(W.bi_valid===16)v1(W,W.bi_buf),W.bi_buf=0,W.bi_valid=0;else if(W.bi_valid>=8)W.pending_buf[W.pending++]=W.bi_buf&255,W.bi_buf>>=8,W.bi_valid-=8},YJ=(W,G)=>{const{dyn_tree:J,max_code:Q}=G,V=G.stat_desc.static_tree,X=G.stat_desc.has_stree,q=G.stat_desc.extra_bits,Y=G.stat_desc.extra_base,K=G.stat_desc.max_length;let P,U,C,F,z,$,x=0;for(F=0;F<=y0;F++)W.bl_count[F]=0;J[W.heap[W.heap_max]*2+1]=0;for(P=W.heap_max+1;P<b5;P++){if(U=W.heap[P],F=J[J[U*2+1]*2+1]+1,F>K)F=K,x++;if(J[U*2+1]=F,U>Q)continue;if(W.bl_count[F]++,z=0,U>=Y)z=q[U-Y];if($=J[U*2],W.opt_len+=$*(F+z),X)W.static_len+=$*(V[U*2+1]+z)}if(x===0)return;do{F=K-1;while(W.bl_count[F]===0)F--;W.bl_count[F]--,W.bl_count[F+1]+=2,W.bl_count[K]--,x-=2}while(x>0);for(F=K;F!==0;F--){U=W.bl_count[F];while(U!==0){if(C=W.heap[--P],C>Q)continue;if(J[C*2+1]!==F)W.opt_len+=(F-J[C*2+1])*J[C*2],J[C*2+1]=F;U--}}},o5=(W,G,J)=>{const Q=new Array(y0+1);let V=0,X,q;for(X=1;X<=y0;X++)V=V+J[X-1]<<1,Q[X]=V;for(q=0;q<=G;q++){let Y=W[q*2+1];if(Y===0)continue;W[q*2]=a5(Q[Y]++,Y)}},PJ=()=>{let W,G,J,Q,V;const X=new Array(y0+1);J=0;for(Q=0;Q<Q6-1;Q++){q6[Q]=J;for(W=0;W<1<<a8[Q];W++)A1[J++]=Q}A1[J-1]=Q,V=0;for(Q=0;Q<16;Q++){V8[Q]=V;for(W=0;W<1<<Q8[Q];W++)N1[V++]=Q}V>>=7;for(;Q<G1;Q++){V8[Q]=V<<7;for(W=0;W<1<<Q8[Q]-7;W++)N1[256+V++]=Q}for(G=0;G<=y0;G++)X[G]=0;W=0;while(W<=143)B0[W*2+1]=8,W++,X[8]++;while(W<=255)B0[W*2+1]=9,W++,X[9]++;while(W<=279)B0[W*2+1]=7,W++,X[7]++;while(W<=287)B0[W*2+1]=8,W++,X[8]++;o5(B0,D1+1,X);for(W=0;W<G1;W++)I1[W*2+1]=5,I1[W*2]=a5(W,5);_5=new E8(B0,a8,E1+1,D1,y0),l5=new E8(I1,Q8,0,G1,y0),i5=new E8(new Array(0),VJ,0,V6,QJ)},n5=(W)=>{let G;for(G=0;G<D1;G++)W.dyn_ltree[G*2]=0;for(G=0;G<G1;G++)W.dyn_dtree[G*2]=0;for(G=0;G<V6;G++)W.bl_tree[G*2]=0;W.dyn_ltree[X6*2]=1,W.opt_len=W.static_len=0,W.sym_next=W.matches=0},s5=(W)=>{if(W.bi_valid>8)v1(W,W.bi_buf);else if(W.bi_valid>0)W.pending_buf[W.pending++]=W.bi_buf;W.bi_buf=0,W.bi_valid=0},W5=(W,G,J,Q)=>{const V=G*2,X=J*2;return W[V]<W[X]||W[V]===W[X]&&Q[G]<=Q[J]},f8=(W,G,J)=>{const Q=W.heap[J];let V=J<<1;while(V<=W.heap_len){if(V<W.heap_len&&W5(G,W.heap[V+1],W.heap[V],W.depth))V++;if(W5(G,Q,W.heap[V],W.depth))break;W.heap[J]=W.heap[V],J=V,V<<=1}W.heap[J]=Q},J5=(W,G,J)=>{let Q,V,X=0,q,Y;if(W.sym_next!==0)do if(Q=W.pending_buf[W.sym_buf+X++]&255,Q+=(W.pending_buf[W.sym_buf+X++]&255)<<8,V=W.pending_buf[W.sym_buf+X++],Q===0)F0(W,V,G);else{if(q=A1[V],F0(W,q+E1+1,G),Y=a8[q],Y!==0)V-=q6[q],J0(W,V,Y);if(Q--,q=r5(Q),F0(W,q,J),Y=Q8[q],Y!==0)Q-=V8[q],J0(W,Q,Y)}while(X<W.sym_next);F0(W,X6,G)},o8=(W,G)=>{const J=G.dyn_tree,Q=G.stat_desc.static_tree,V=G.stat_desc.has_stree,X=G.stat_desc.elems;let q,Y,K=-1,P;W.heap_len=0,W.heap_max=b5;for(q=0;q<X;q++)if(J[q*2]!==0)W.heap[++W.heap_len]=K=q,W.depth[q]=0;else J[q*2+1]=0;while(W.heap_len<2)if(P=W.heap[++W.heap_len]=K<2?++K:0,J[P*2]=1,W.depth[P]=0,W.opt_len--,V)W.static_len-=Q[P*2+1];G.max_code=K;for(q=W.heap_len>>1;q>=1;q--)f8(W,J,q);P=X;do q=W.heap[1],W.heap[1]=W.heap[W.heap_len--],f8(W,J,1),Y=W.heap[1],W.heap[--W.heap_max]=q,W.heap[--W.heap_max]=Y,J[P*2]=J[q*2]+J[Y*2],W.depth[P]=(W.depth[q]>=W.depth[Y]?W.depth[q]:W.depth[Y])+1,J[q*2+1]=J[Y*2+1]=P,W.heap[1]=P++,f8(W,J,1);while(W.heap_len>=2);W.heap[--W.heap_max]=W.heap[1],YJ(W,G),o5(J,K,W.bl_count)},G5=(W,G,J)=>{let Q,V=-1,X,q=G[1],Y=0,K=7,P=4;if(q===0)K=138,P=3;G[(J+1)*2+1]=65535;for(Q=0;Q<=J;Q++){if(X=q,q=G[(Q+1)*2+1],++Y<K&&X===q)continue;else if(Y<P)W.bl_tree[X*2]+=Y;else if(X!==0){if(X!==V)W.bl_tree[X*2]++;W.bl_tree[m5*2]++}else if(Y<=10)W.bl_tree[u5*2]++;else W.bl_tree[d5*2]++;if(Y=0,V=X,q===0)K=138,P=3;else if(X===q)K=6,P=3;else K=7,P=4}},Q5=(W,G,J)=>{let Q,V=-1,X,q=G[1],Y=0,K=7,P=4;if(q===0)K=138,P=3;for(Q=0;Q<=J;Q++){if(X=q,q=G[(Q+1)*2+1],++Y<K&&X===q)continue;else if(Y<P)do F0(W,X,W.bl_tree);while(--Y!==0);else if(X!==0){if(X!==V)F0(W,X,W.bl_tree),Y--;F0(W,m5,W.bl_tree),J0(W,Y-3,2)}else if(Y<=10)F0(W,u5,W.bl_tree),J0(W,Y-3,3);else F0(W,d5,W.bl_tree),J0(W,Y-11,7);if(Y=0,V=X,q===0)K=138,P=3;else if(X===q)K=6,P=3;else K=7,P=4}},UJ=(W)=>{let G;G5(W,W.dyn_ltree,W.l_desc.max_code),G5(W,W.dyn_dtree,W.d_desc.max_code),o8(W,W.bl_desc);for(G=V6-1;G>=3;G--)if(W.bl_tree[c5[G]*2+1]!==0)break;return W.opt_len+=3*(G+1)+5+5+4,G},KJ=(W,G,J,Q)=>{let V;J0(W,G-257,5),J0(W,J-1,5),J0(W,Q-4,4);for(V=0;V<Q;V++)J0(W,W.bl_tree[c5[V]*2+1],3);Q5(W,W.dyn_ltree,G-1),Q5(W,W.dyn_dtree,J-1)},FJ=(W)=>{let G=4093624447,J;for(J=0;J<=31;J++,G>>>=1)if(G&1&&W.dyn_ltree[J*2]!==0)return 0;if(W.dyn_ltree[18]!==0||W.dyn_ltree[20]!==0||W.dyn_ltree[26]!==0)return 1;for(J=32;J<E1;J++)if(W.dyn_ltree[J*2]!==0)return 1;return 0},V5=!1,zJ=(W)=>{if(!V5)PJ(),V5=!0;W.l_desc=new p8(W.dyn_ltree,_5),W.d_desc=new p8(W.dyn_dtree,l5),W.bl_desc=new p8(W.bl_tree,i5),W.bi_buf=0,W.bi_valid=0,n5(W)},e5=(W,G,J,Q)=>{if(J0(W,(tW<<1)+(Q?1:0),3),s5(W),v1(W,J),v1(W,~J),J)W.pending_buf.set(W.window.subarray(G,G+J),W.pending);W.pending+=J},ZJ=(W)=>{J0(W,h5<<1,3),F0(W,X6,B0),qJ(W)},kJ=(W,G,J,Q)=>{let V,X,q=0;if(W.level>0){if(W.strm.data_type===2)W.strm.data_type=FJ(W);if(o8(W,W.l_desc),o8(W,W.d_desc),q=UJ(W),V=W.opt_len+3+7>>>3,X=W.static_len+3+7>>>3,X<=V)V=X}else V=X=J+5;if(J+4<=V&&G!==-1)e5(W,G,J,Q);else if(W.strategy===4||X===V)J0(W,(h5<<1)+(Q?1:0),3),J5(W,B0,I1);else J0(W,(WJ<<1)+(Q?1:0),3),KJ(W,W.l_desc.max_code+1,W.d_desc.max_code+1,q+1),J5(W,W.dyn_ltree,W.dyn_dtree);if(n5(W),Q)s5(W)},HJ=(W,G,J)=>{if(W.pending_buf[W.sym_buf+W.sym_next++]=G,W.pending_buf[W.sym_buf+W.sym_next++]=G>>8,W.pending_buf[W.sym_buf+W.sym_next++]=J,G===0)W.dyn_ltree[J*2]++;else W.matches++,G--,W.dyn_ltree[(A1[J]+E1+1)*2]++,W.dyn_dtree[r5(G)*2]++;return W.sym_next===W.sym_end},CJ=zJ,$J=e5,MJ=kJ,BJ=HJ,jJ=ZJ,LJ={_tr_init:CJ,_tr_stored_block:$J,_tr_flush_block:MJ,_tr_tally:BJ,_tr_align:jJ},RJ=(W,G,J,Q)=>{let V=W&65535|0,X=W>>>16&65535|0,q=0;while(J!==0){q=J>2000?2000:J,J-=q;do V=V+G[Q++]|0,X=X+V|0;while(--q);V%=65521,X%=65521}return V|X<<16|0},g1=RJ,OJ=()=>{let W,G=[];for(var J=0;J<256;J++){W=J;for(var Q=0;Q<8;Q++)W=W&1?3988292384^W>>>1:W>>>1;G[J]=W}return G},IJ=new Uint32Array(OJ()),wJ=(W,G,J,Q)=>{const V=IJ,X=Q+J;W^=-1;for(let q=Q;q<X;q++)W=W>>>8^V[(W^G[q])&255];return W^-1},o=wJ,f0={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},m0={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:xJ,_tr_stored_block:n8,_tr_flush_block:DJ,_tr_tally:D0,_tr_align:NJ}=LJ,{Z_NO_FLUSH:N0,Z_PARTIAL_FLUSH:AJ,Z_FULL_FLUSH:vJ,Z_FINISH:X0,Z_BLOCK:X5,Z_OK:n,Z_STREAM_END:q5,Z_STREAM_ERROR:z0,Z_DATA_ERROR:gJ,Z_BUF_ERROR:h8,Z_DEFAULT_COMPRESSION:TJ,Z_FILTERED:SJ,Z_HUFFMAN_ONLY:e1,Z_RLE:yJ,Z_FIXED:EJ,Z_DEFAULT_STRATEGY:pJ,Z_UNKNOWN:fJ,Z_DEFLATED:Y8}=m0,hJ=9,bJ=15,mJ=8,uJ=29,dJ=256,s8=dJ+1+uJ,cJ=30,_J=19,lJ=2*s8+1,iJ=15,u=3,x0=258,Z0=x0+u+1,rJ=32,Q1=42,Y6=57,e8=69,t8=73,W6=91,J6=103,E0=113,R1=666,t=1,q1=2,h0=3,Y1=4,aJ=3,p0=(W,G)=>{return W.msg=f0[G],G},Y5=(W)=>{return W*2-(W>4?9:0)},w0=(W)=>{let G=W.length;while(--G>=0)W[G]=0},oJ=(W)=>{let G,J,Q,V=W.w_size;G=W.hash_size,Q=G;do J=W.head[--Q],W.head[Q]=J>=V?J-V:0;while(--G);G=V,Q=G;do J=W.prev[--Q],W.prev[Q]=J>=V?J-V:0;while(--G)},nJ=(W,G,J)=>(G<<W.hash_shift^J)&W.hash_mask,A0=nJ,Q0=(W)=>{const G=W.state;let J=G.pending;if(J>W.avail_out)J=W.avail_out;if(J===0)return;if(W.output.set(G.pending_buf.subarray(G.pending_out,G.pending_out+J),W.next_out),W.next_out+=J,G.pending_out+=J,W.total_out+=J,W.avail_out-=J,G.pending-=J,G.pending===0)G.pending_out=0},V0=(W,G)=>{DJ(W,W.block_start>=0?W.block_start:-1,W.strstart-W.block_start,G),W.block_start=W.strstart,Q0(W.strm)},_=(W,G)=>{W.pending_buf[W.pending++]=G},L1=(W,G)=>{W.pending_buf[W.pending++]=G>>>8&255,W.pending_buf[W.pending++]=G&255},G6=(W,G,J,Q)=>{let V=W.avail_in;if(V>Q)V=Q;if(V===0)return 0;if(W.avail_in-=V,G.set(W.input.subarray(W.next_in,W.next_in+V),J),W.state.wrap===1)W.adler=g1(W.adler,G,V,J);else if(W.state.wrap===2)W.adler=o(W.adler,G,V,J);return W.next_in+=V,W.total_in+=V,V},t5=(W,G)=>{let{max_chain_length:J,strstart:Q}=W,V,X,q=W.prev_length,Y=W.nice_match;const K=W.strstart>W.w_size-Z0?W.strstart-(W.w_size-Z0):0,P=W.window,U=W.w_mask,C=W.prev,F=W.strstart+x0;let z=P[Q+q-1],$=P[Q+q];if(W.prev_length>=W.good_match)J>>=2;if(Y>W.lookahead)Y=W.lookahead;do{if(V=G,P[V+q]!==$||P[V+q-1]!==z||P[V]!==P[Q]||P[++V]!==P[Q+1])continue;Q+=2,V++;do;while(P[++Q]===P[++V]&&P[++Q]===P[++V]&&P[++Q]===P[++V]&&P[++Q]===P[++V]&&P[++Q]===P[++V]&&P[++Q]===P[++V]&&P[++Q]===P[++V]&&P[++Q]===P[++V]&&Q<F);if(X=x0-(F-Q),Q=F-x0,X>q){if(W.match_start=G,q=X,X>=Y)break;z=P[Q+q-1],$=P[Q+q]}}while((G=C[G&U])>K&&--J!==0);if(q<=W.lookahead)return q;return W.lookahead},V1=(W)=>{const G=W.w_size;let J,Q,V;do{if(Q=W.window_size-W.lookahead-W.strstart,W.strstart>=G+(G-Z0)){if(W.window.set(W.window.subarray(G,G+G-Q),0),W.match_start-=G,W.strstart-=G,W.block_start-=G,W.insert>W.strstart)W.insert=W.strstart;oJ(W),Q+=G}if(W.strm.avail_in===0)break;if(J=G6(W.strm,W.window,W.strstart+W.lookahead,Q),W.lookahead+=J,W.lookahead+W.insert>=u){V=W.strstart-W.insert,W.ins_h=W.window[V],W.ins_h=A0(W,W.ins_h,W.window[V+1]);while(W.insert)if(W.ins_h=A0(W,W.ins_h,W.window[V+u-1]),W.prev[V&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=V,V++,W.insert--,W.lookahead+W.insert<u)break}}while(W.lookahead<Z0&&W.strm.avail_in!==0)},W7=(W,G)=>{let J=W.pending_buf_size-5>W.w_size?W.w_size:W.pending_buf_size-5,Q,V,X,q=0,Y=W.strm.avail_in;do{if(Q=65535,X=W.bi_valid+42>>3,W.strm.avail_out<X)break;if(X=W.strm.avail_out-X,V=W.strstart-W.block_start,Q>V+W.strm.avail_in)Q=V+W.strm.avail_in;if(Q>X)Q=X;if(Q<J&&(Q===0&&G!==X0||G===N0||Q!==V+W.strm.avail_in))break;if(q=G===X0&&Q===V+W.strm.avail_in?1:0,n8(W,0,0,q),W.pending_buf[W.pending-4]=Q,W.pending_buf[W.pending-3]=Q>>8,W.pending_buf[W.pending-2]=~Q,W.pending_buf[W.pending-1]=~Q>>8,Q0(W.strm),V){if(V>Q)V=Q;W.strm.output.set(W.window.subarray(W.block_start,W.block_start+V),W.strm.next_out),W.strm.next_out+=V,W.strm.avail_out-=V,W.strm.total_out+=V,W.block_start+=V,Q-=V}if(Q)G6(W.strm,W.strm.output,W.strm.next_out,Q),W.strm.next_out+=Q,W.strm.avail_out-=Q,W.strm.total_out+=Q}while(q===0);if(Y-=W.strm.avail_in,Y){if(Y>=W.w_size)W.matches=2,W.window.set(W.strm.input.subarray(W.strm.next_in-W.w_size,W.strm.next_in),0),W.strstart=W.w_size,W.insert=W.strstart;else{if(W.window_size-W.strstart<=Y){if(W.strstart-=W.w_size,W.window.set(W.window.subarray(W.w_size,W.w_size+W.strstart),0),W.matches<2)W.matches++;if(W.insert>W.strstart)W.insert=W.strstart}W.window.set(W.strm.input.subarray(W.strm.next_in-Y,W.strm.next_in),W.strstart),W.strstart+=Y,W.insert+=Y>W.w_size-W.insert?W.w_size-W.insert:Y}W.block_start=W.strstart}if(W.high_water<W.strstart)W.high_water=W.strstart;if(q)return Y1;if(G!==N0&&G!==X0&&W.strm.avail_in===0&&W.strstart===W.block_start)return q1;if(X=W.window_size-W.strstart,W.strm.avail_in>X&&W.block_start>=W.w_size){if(W.block_start-=W.w_size,W.strstart-=W.w_size,W.window.set(W.window.subarray(W.w_size,W.w_size+W.strstart),0),W.matches<2)W.matches++;if(X+=W.w_size,W.insert>W.strstart)W.insert=W.strstart}if(X>W.strm.avail_in)X=W.strm.avail_in;if(X)G6(W.strm,W.window,W.strstart,X),W.strstart+=X,W.insert+=X>W.w_size-W.insert?W.w_size-W.insert:X;if(W.high_water<W.strstart)W.high_water=W.strstart;if(X=W.bi_valid+42>>3,X=W.pending_buf_size-X>65535?65535:W.pending_buf_size-X,J=X>W.w_size?W.w_size:X,V=W.strstart-W.block_start,V>=J||(V||G===X0)&&G!==N0&&W.strm.avail_in===0&&V<=X)Q=V>X?X:V,q=G===X0&&W.strm.avail_in===0&&Q===V?1:0,n8(W,W.block_start,Q,q),W.block_start+=Q,Q0(W.strm);return q?h0:t},b8=(W,G)=>{let J,Q;for(;;){if(W.lookahead<Z0){if(V1(W),W.lookahead<Z0&&G===N0)return t;if(W.lookahead===0)break}if(J=0,W.lookahead>=u)W.ins_h=A0(W,W.ins_h,W.window[W.strstart+u-1]),J=W.prev[W.strstart&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=W.strstart;if(J!==0&&W.strstart-J<=W.w_size-Z0)W.match_length=t5(W,J);if(W.match_length>=u)if(Q=D0(W,W.strstart-W.match_start,W.match_length-u),W.lookahead-=W.match_length,W.match_length<=W.max_lazy_match&&W.lookahead>=u){W.match_length--;do W.strstart++,W.ins_h=A0(W,W.ins_h,W.window[W.strstart+u-1]),J=W.prev[W.strstart&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=W.strstart;while(--W.match_length!==0);W.strstart++}else W.strstart+=W.match_length,W.match_length=0,W.ins_h=W.window[W.strstart],W.ins_h=A0(W,W.ins_h,W.window[W.strstart+1]);else Q=D0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++;if(Q){if(V0(W,!1),W.strm.avail_out===0)return t}}if(W.insert=W.strstart<u-1?W.strstart:u-1,G===X0){if(V0(W,!0),W.strm.avail_out===0)return h0;return Y1}if(W.sym_next){if(V0(W,!1),W.strm.avail_out===0)return t}return q1},W1=(W,G)=>{let J,Q,V;for(;;){if(W.lookahead<Z0){if(V1(W),W.lookahead<Z0&&G===N0)return t;if(W.lookahead===0)break}if(J=0,W.lookahead>=u)W.ins_h=A0(W,W.ins_h,W.window[W.strstart+u-1]),J=W.prev[W.strstart&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=W.strstart;if(W.prev_length=W.match_length,W.prev_match=W.match_start,W.match_length=u-1,J!==0&&W.prev_length<W.max_lazy_match&&W.strstart-J<=W.w_size-Z0){if(W.match_length=t5(W,J),W.match_length<=5&&(W.strategy===SJ||W.match_length===u&&W.strstart-W.match_start>4096))W.match_length=u-1}if(W.prev_length>=u&&W.match_length<=W.prev_length){V=W.strstart+W.lookahead-u,Q=D0(W,W.strstart-1-W.prev_match,W.prev_length-u),W.lookahead-=W.prev_length-1,W.prev_length-=2;do if(++W.strstart<=V)W.ins_h=A0(W,W.ins_h,W.window[W.strstart+u-1]),J=W.prev[W.strstart&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=W.strstart;while(--W.prev_length!==0);if(W.match_available=0,W.match_length=u-1,W.strstart++,Q){if(V0(W,!1),W.strm.avail_out===0)return t}}else if(W.match_available){if(Q=D0(W,0,W.window[W.strstart-1]),Q)V0(W,!1);if(W.strstart++,W.lookahead--,W.strm.avail_out===0)return t}else W.match_available=1,W.strstart++,W.lookahead--}if(W.match_available)Q=D0(W,0,W.window[W.strstart-1]),W.match_available=0;if(W.insert=W.strstart<u-1?W.strstart:u-1,G===X0){if(V0(W,!0),W.strm.avail_out===0)return h0;return Y1}if(W.sym_next){if(V0(W,!1),W.strm.avail_out===0)return t}return q1},sJ=(W,G)=>{let J,Q,V,X;const q=W.window;for(;;){if(W.lookahead<=x0){if(V1(W),W.lookahead<=x0&&G===N0)return t;if(W.lookahead===0)break}if(W.match_length=0,W.lookahead>=u&&W.strstart>0){if(V=W.strstart-1,Q=q[V],Q===q[++V]&&Q===q[++V]&&Q===q[++V]){X=W.strstart+x0;do;while(Q===q[++V]&&Q===q[++V]&&Q===q[++V]&&Q===q[++V]&&Q===q[++V]&&Q===q[++V]&&Q===q[++V]&&Q===q[++V]&&V<X);if(W.match_length=x0-(X-V),W.match_length>W.lookahead)W.match_length=W.lookahead}}if(W.match_length>=u)J=D0(W,1,W.match_length-u),W.lookahead-=W.match_length,W.strstart+=W.match_length,W.match_length=0;else J=D0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++;if(J){if(V0(W,!1),W.strm.avail_out===0)return t}}if(W.insert=0,G===X0){if(V0(W,!0),W.strm.avail_out===0)return h0;return Y1}if(W.sym_next){if(V0(W,!1),W.strm.avail_out===0)return t}return q1},eJ=(W,G)=>{let J;for(;;){if(W.lookahead===0){if(V1(W),W.lookahead===0){if(G===N0)return t;break}}if(W.match_length=0,J=D0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++,J){if(V0(W,!1),W.strm.avail_out===0)return t}}if(W.insert=0,G===X0){if(V0(W,!0),W.strm.avail_out===0)return h0;return Y1}if(W.sym_next){if(V0(W,!1),W.strm.avail_out===0)return t}return q1},O1=[new K0(0,0,0,0,W7),new K0(4,4,8,4,b8),new K0(4,5,16,8,b8),new K0(4,6,32,32,b8),new K0(4,4,16,16,W1),new K0(8,16,32,32,W1),new K0(8,16,128,128,W1),new K0(8,32,128,256,W1),new K0(32,128,258,1024,W1),new K0(32,258,258,4096,W1)],tJ=(W)=>{W.window_size=2*W.w_size,w0(W.head),W.max_lazy_match=O1[W.level].max_lazy,W.good_match=O1[W.level].good_length,W.nice_match=O1[W.level].nice_length,W.max_chain_length=O1[W.level].max_chain,W.strstart=0,W.block_start=0,W.lookahead=0,W.insert=0,W.match_length=W.prev_length=u-1,W.match_available=0,W.ins_h=0},p1=(W)=>{if(!W)return 1;const G=W.state;if(!G||G.strm!==W||G.status!==Q1&&G.status!==Y6&&G.status!==e8&&G.status!==t8&&G.status!==W6&&G.status!==J6&&G.status!==E0&&G.status!==R1)return 1;return 0},J7=(W)=>{if(p1(W))return p0(W,z0);W.total_in=W.total_out=0,W.data_type=fJ;const G=W.state;if(G.pending=0,G.pending_out=0,G.wrap<0)G.wrap=-G.wrap;return G.status=G.wrap===2?Y6:G.wrap?Q1:E0,W.adler=G.wrap===2?0:1,G.last_flush=-2,xJ(G),n},G7=(W)=>{const G=J7(W);if(G===n)tJ(W.state);return G},J9=(W,G)=>{if(p1(W)||W.state.wrap!==2)return z0;return W.state.gzhead=G,n},Q7=(W,G,J,Q,V,X)=>{if(!W)return z0;let q=1;if(G===TJ)G=6;if(Q<0)q=0,Q=-Q;else if(Q>15)q=2,Q-=16;if(V<1||V>hJ||J!==Y8||Q<8||Q>15||G<0||G>9||X<0||X>EJ||Q===8&&q!==1)return p0(W,z0);if(Q===8)Q=9;const Y=new W9;return W.state=Y,Y.strm=W,Y.status=Q1,Y.wrap=q,Y.gzhead=null,Y.w_bits=Q,Y.w_size=1<<Y.w_bits,Y.w_mask=Y.w_size-1,Y.hash_bits=V+7,Y.hash_size=1<<Y.hash_bits,Y.hash_mask=Y.hash_size-1,Y.hash_shift=~~((Y.hash_bits+u-1)/u),Y.window=new Uint8Array(Y.w_size*2),Y.head=new Uint16Array(Y.hash_size),Y.prev=new Uint16Array(Y.w_size),Y.lit_bufsize=1<<V+6,Y.pending_buf_size=Y.lit_bufsize*4,Y.pending_buf=new Uint8Array(Y.pending_buf_size),Y.sym_buf=Y.lit_bufsize,Y.sym_end=(Y.lit_bufsize-1)*3,Y.level=G,Y.strategy=X,Y.method=J,G7(W)},G9=(W,G)=>{return Q7(W,G,Y8,bJ,mJ,pJ)},Q9=(W,G)=>{if(p1(W)||G>X5||G<0)return W?p0(W,z0):z0;const J=W.state;if(!W.output||W.avail_in!==0&&!W.input||J.status===R1&&G!==X0)return p0(W,W.avail_out===0?h8:z0);const Q=J.last_flush;if(J.last_flush=G,J.pending!==0){if(Q0(W),W.avail_out===0)return J.last_flush=-1,n}else if(W.avail_in===0&&Y5(G)<=Y5(Q)&&G!==X0)return p0(W,h8);if(J.status===R1&&W.avail_in!==0)return p0(W,h8);if(J.status===Q1&&J.wrap===0)J.status=E0;if(J.status===Q1){let V=Y8+(J.w_bits-8<<4)<<8,X=-1;if(J.strategy>=e1||J.level<2)X=0;else if(J.level<6)X=1;else if(J.level===6)X=2;else X=3;if(V|=X<<6,J.strstart!==0)V|=rJ;if(V+=31-V%31,L1(J,V),J.strstart!==0)L1(J,W.adler>>>16),L1(J,W.adler&65535);if(W.adler=1,J.status=E0,Q0(W),J.pending!==0)return J.last_flush=-1,n}if(J.status===Y6)if(W.adler=0,_(J,31),_(J,139),_(J,8),!J.gzhead){if(_(J,0),_(J,0),_(J,0),_(J,0),_(J,0),_(J,J.level===9?2:J.strategy>=e1||J.level<2?4:0),_(J,aJ),J.status=E0,Q0(W),J.pending!==0)return J.last_flush=-1,n}else{if(_(J,(J.gzhead.text?1:0)+(J.gzhead.hcrc?2:0)+(!J.gzhead.extra?0:4)+(!J.gzhead.name?0:8)+(!J.gzhead.comment?0:16)),_(J,J.gzhead.time&255),_(J,J.gzhead.time>>8&255),_(J,J.gzhead.time>>16&255),_(J,J.gzhead.time>>24&255),_(J,J.level===9?2:J.strategy>=e1||J.level<2?4:0),_(J,J.gzhead.os&255),J.gzhead.extra&&J.gzhead.extra.length)_(J,J.gzhead.extra.length&255),_(J,J.gzhead.extra.length>>8&255);if(J.gzhead.hcrc)W.adler=o(W.adler,J.pending_buf,J.pending,0);J.gzindex=0,J.status=e8}if(J.status===e8){if(J.gzhead.extra){let V=J.pending,X=(J.gzhead.extra.length&65535)-J.gzindex;while(J.pending+X>J.pending_buf_size){let Y=J.pending_buf_size-J.pending;if(J.pending_buf.set(J.gzhead.extra.subarray(J.gzindex,J.gzindex+Y),J.pending),J.pending=J.pending_buf_size,J.gzhead.hcrc&&J.pending>V)W.adler=o(W.adler,J.pending_buf,J.pending-V,V);if(J.gzindex+=Y,Q0(W),J.pending!==0)return J.last_flush=-1,n;V=0,X-=Y}let q=new Uint8Array(J.gzhead.extra);if(J.pending_buf.set(q.subarray(J.gzindex,J.gzindex+X),J.pending),J.pending+=X,J.gzhead.hcrc&&J.pending>V)W.adler=o(W.adler,J.pending_buf,J.pending-V,V);J.gzindex=0}J.status=t8}if(J.status===t8){if(J.gzhead.name){let V=J.pending,X;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>V)W.adler=o(W.adler,J.pending_buf,J.pending-V,V);if(Q0(W),J.pending!==0)return J.last_flush=-1,n;V=0}if(J.gzindex<J.gzhead.name.length)X=J.gzhead.name.charCodeAt(J.gzindex++)&255;else X=0;_(J,X)}while(X!==0);if(J.gzhead.hcrc&&J.pending>V)W.adler=o(W.adler,J.pending_buf,J.pending-V,V);J.gzindex=0}J.status=W6}if(J.status===W6){if(J.gzhead.comment){let V=J.pending,X;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>V)W.adler=o(W.adler,J.pending_buf,J.pending-V,V);if(Q0(W),J.pending!==0)return J.last_flush=-1,n;V=0}if(J.gzindex<J.gzhead.comment.length)X=J.gzhead.comment.charCodeAt(J.gzindex++)&255;else X=0;_(J,X)}while(X!==0);if(J.gzhead.hcrc&&J.pending>V)W.adler=o(W.adler,J.pending_buf,J.pending-V,V)}J.status=J6}if(J.status===J6){if(J.gzhead.hcrc){if(J.pending+2>J.pending_buf_size){if(Q0(W),J.pending!==0)return J.last_flush=-1,n}_(J,W.adler&255),_(J,W.adler>>8&255),W.adler=0}if(J.status=E0,Q0(W),J.pending!==0)return J.last_flush=-1,n}if(W.avail_in!==0||J.lookahead!==0||G!==N0&&J.status!==R1){let V=J.level===0?W7(J,G):J.strategy===e1?eJ(J,G):J.strategy===yJ?sJ(J,G):O1[J.level].func(J,G);if(V===h0||V===Y1)J.status=R1;if(V===t||V===h0){if(W.avail_out===0)J.last_flush=-1;return n}if(V===q1){if(G===AJ)NJ(J);else if(G!==X5){if(n8(J,0,0,!1),G===vJ){if(w0(J.head),J.lookahead===0)J.strstart=0,J.block_start=0,J.insert=0}}if(Q0(W),W.avail_out===0)return J.last_flush=-1,n}}if(G!==X0)return n;if(J.wrap<=0)return q5;if(J.wrap===2)_(J,W.adler&255),_(J,W.adler>>8&255),_(J,W.adler>>16&255),_(J,W.adler>>24&255),_(J,W.total_in&255),_(J,W.total_in>>8&255),_(J,W.total_in>>16&255),_(J,W.total_in>>24&255);else L1(J,W.adler>>>16),L1(J,W.adler&65535);if(Q0(W),J.wrap>0)J.wrap=-J.wrap;return J.pending!==0?n:q5},V9=(W)=>{if(p1(W))return z0;const G=W.state.status;return W.state=null,G===E0?p0(W,gJ):n},X9=(W,G)=>{let J=G.length;if(p1(W))return z0;const Q=W.state,V=Q.wrap;if(V===2||V===1&&Q.status!==Q1||Q.lookahead)return z0;if(V===1)W.adler=g1(W.adler,G,J,0);if(Q.wrap=0,J>=Q.w_size){if(V===0)w0(Q.head),Q.strstart=0,Q.block_start=0,Q.insert=0;let K=new Uint8Array(Q.w_size);K.set(G.subarray(J-Q.w_size,J),0),G=K,J=Q.w_size}const{avail_in:X,next_in:q,input:Y}=W;W.avail_in=J,W.next_in=0,W.input=G,V1(Q);while(Q.lookahead>=u){let K=Q.strstart,P=Q.lookahead-(u-1);do Q.ins_h=A0(Q,Q.ins_h,Q.window[K+u-1]),Q.prev[K&Q.w_mask]=Q.head[Q.ins_h],Q.head[Q.ins_h]=K,K++;while(--P);Q.strstart=K,Q.lookahead=u-1,V1(Q)}return Q.strstart+=Q.lookahead,Q.block_start=Q.strstart,Q.insert=Q.lookahead,Q.lookahead=0,Q.match_length=Q.prev_length=u-1,Q.match_available=0,W.next_in=q,W.input=Y,W.avail_in=X,Q.wrap=V,n},q9=G9,Y9=Q7,P9=G7,U9=J7,K9=J9,F9=Q9,z9=V9,Z9=X9,k9="pako deflate (from Nodeca project)",w1={deflateInit:q9,deflateInit2:Y9,deflateReset:P9,deflateResetKeep:U9,deflateSetHeader:K9,deflate:F9,deflateEnd:z9,deflateSetDictionary:Z9,deflateInfo:k9},H9=(W,G)=>{return Object.prototype.hasOwnProperty.call(W,G)},C9=function(W){const G=Array.prototype.slice.call(arguments,1);while(G.length){const J=G.shift();if(!J)continue;if(typeof J!=="object")throw new TypeError(J+"must be non-object");for(let Q in J)if(H9(J,Q))W[Q]=J[Q]}return W},$9=(W)=>{let G=0;for(let Q=0,V=W.length;Q<V;Q++)G+=W[Q].length;const J=new Uint8Array(G);for(let Q=0,V=0,X=W.length;Q<X;Q++){let q=W[Q];J.set(q,V),V+=q.length}return J},P8={assign:C9,flattenChunks:$9},V7=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(W){V7=!1}var T1=new Uint8Array(256);for(let W=0;W<256;W++)T1[W]=W>=252?6:W>=248?5:W>=240?4:W>=224?3:W>=192?2:1;T1[254]=T1[254]=1;var M9=(W)=>{if(typeof TextEncoder==="function"&&TextEncoder.prototype.encode)return(new TextEncoder()).encode(W);let G,J,Q,V,X,q=W.length,Y=0;for(V=0;V<q;V++){if(J=W.charCodeAt(V),(J&64512)===55296&&V+1<q){if(Q=W.charCodeAt(V+1),(Q&64512)===56320)J=65536+(J-55296<<10)+(Q-56320),V++}Y+=J<128?1:J<2048?2:J<65536?3:4}G=new Uint8Array(Y);for(X=0,V=0;X<Y;V++){if(J=W.charCodeAt(V),(J&64512)===55296&&V+1<q){if(Q=W.charCodeAt(V+1),(Q&64512)===56320)J=65536+(J-55296<<10)+(Q-56320),V++}if(J<128)G[X++]=J;else if(J<2048)G[X++]=192|J>>>6,G[X++]=128|J&63;else if(J<65536)G[X++]=224|J>>>12,G[X++]=128|J>>>6&63,G[X++]=128|J&63;else G[X++]=240|J>>>18,G[X++]=128|J>>>12&63,G[X++]=128|J>>>6&63,G[X++]=128|J&63}return G},B9=(W,G)=>{if(G<65534){if(W.subarray&&V7)return String.fromCharCode.apply(null,W.length===G?W:W.subarray(0,G))}let J="";for(let Q=0;Q<G;Q++)J+=String.fromCharCode(W[Q]);return J},j9=(W,G)=>{const J=G||W.length;if(typeof TextDecoder==="function"&&TextDecoder.prototype.decode)return(new TextDecoder()).decode(W.subarray(0,G));let Q,V;const X=new Array(J*2);for(V=0,Q=0;Q<J;){let q=W[Q++];if(q<128){X[V++]=q;continue}let Y=T1[q];if(Y>4){X[V++]=65533,Q+=Y-1;continue}q&=Y===2?31:Y===3?15:7;while(Y>1&&Q<J)q=q<<6|W[Q++]&63,Y--;if(Y>1){X[V++]=65533;continue}if(q<65536)X[V++]=q;else q-=65536,X[V++]=55296|q>>10&1023,X[V++]=56320|q&1023}return B9(X,V)},L9=(W,G)=>{if(G=G||W.length,G>W.length)G=W.length;let J=G-1;while(J>=0&&(W[J]&192)===128)J--;if(J<0)return G;if(J===0)return G;return J+T1[W[J]]>G?J:G},S1={string2buf:M9,buf2string:j9,utf8border:L9},X7=R9,q7=Object.prototype.toString,{Z_NO_FLUSH:O9,Z_SYNC_FLUSH:I9,Z_FULL_FLUSH:w9,Z_FINISH:x9,Z_OK:X8,Z_STREAM_END:D9,Z_DEFAULT_COMPRESSION:N9,Z_DEFAULT_STRATEGY:A9,Z_DEFLATED:v9}=m0;f1.prototype.push=function(W,G){const J=this.strm,Q=this.options.chunkSize;let V,X;if(this.ended)return!1;if(G===~~G)X=G;else X=G===!0?x9:O9;if(typeof W==="string")J.input=S1.string2buf(W);else if(q7.call(W)==="[object ArrayBuffer]")J.input=new Uint8Array(W);else J.input=W;J.next_in=0,J.avail_in=J.input.length;for(;;){if(J.avail_out===0)J.output=new Uint8Array(Q),J.next_out=0,J.avail_out=Q;if((X===I9||X===w9)&&J.avail_out<=6){this.onData(J.output.subarray(0,J.next_out)),J.avail_out=0;continue}if(V=w1.deflate(J,X),V===D9){if(J.next_out>0)this.onData(J.output.subarray(0,J.next_out));return V=w1.deflateEnd(this.strm),this.onEnd(V),this.ended=!0,V===X8}if(J.avail_out===0){this.onData(J.output);continue}if(X>0&&J.next_out>0){this.onData(J.output.subarray(0,J.next_out)),J.avail_out=0;continue}if(J.avail_in===0)break}return!0};f1.prototype.onData=function(W){this.chunks.push(W)};f1.prototype.onEnd=function(W){if(W===X8)this.result=P8.flattenChunks(this.chunks);this.chunks=[],this.err=W,this.msg=this.strm.msg};var S9=f1,y9=P6,E9=g9,p9=T9,f9=m0,h9={Deflate:S9,deflate:y9,deflateRaw:E9,gzip:p9,constants:f9},t1=16209,b9=16191,m9=function W(G,J){let Q,V,X,q,Y,K,P,U,C,F,z,$,x,g,T,S,E,O,f,d,R,j,I,k;const Z=G.state;Q=G.next_in,I=G.input,V=Q+(G.avail_in-5),X=G.next_out,k=G.output,q=X-(J-G.avail_out),Y=X+(G.avail_out-257),K=Z.dmax,P=Z.wsize,U=Z.whave,C=Z.wnext,F=Z.window,z=Z.hold,$=Z.bits,x=Z.lencode,g=Z.distcode,T=(1<<Z.lenbits)-1,S=(1<<Z.distbits)-1;W:do{if($<15)z+=I[Q++]<<$,$+=8,z+=I[Q++]<<$,$+=8;E=x[z&T];J:for(;;){if(O=E>>>24,z>>>=O,$-=O,O=E>>>16&255,O===0)k[X++]=E&65535;else if(O&16){if(f=E&65535,O&=15,O){if($<O)z+=I[Q++]<<$,$+=8;f+=z&(1<<O)-1,z>>>=O,$-=O}if($<15)z+=I[Q++]<<$,$+=8,z+=I[Q++]<<$,$+=8;E=g[z&S];G:for(;;){if(O=E>>>24,z>>>=O,$-=O,O=E>>>16&255,O&16){if(d=E&65535,O&=15,$<O){if(z+=I[Q++]<<$,$+=8,$<O)z+=I[Q++]<<$,$+=8}if(d+=z&(1<<O)-1,d>K){G.msg="invalid distance too far back",Z.mode=t1;break W}if(z>>>=O,$-=O,O=X-q,d>O){if(O=d-O,O>U){if(Z.sane){G.msg="invalid distance too far back",Z.mode=t1;break W}}if(R=0,j=F,C===0){if(R+=P-O,O<f){f-=O;do k[X++]=F[R++];while(--O);R=X-d,j=k}}else if(C<O){if(R+=P+C-O,O-=C,O<f){f-=O;do k[X++]=F[R++];while(--O);if(R=0,C<f){O=C,f-=O;do k[X++]=F[R++];while(--O);R=X-d,j=k}}}else if(R+=C-O,O<f){f-=O;do k[X++]=F[R++];while(--O);R=X-d,j=k}while(f>2)k[X++]=j[R++],k[X++]=j[R++],k[X++]=j[R++],f-=3;if(f){if(k[X++]=j[R++],f>1)k[X++]=j[R++]}}else{R=X-d;do k[X++]=k[R++],k[X++]=k[R++],k[X++]=k[R++],f-=3;while(f>2);if(f){if(k[X++]=k[R++],f>1)k[X++]=k[R++]}}}else if((O&64)===0){E=g[(E&65535)+(z&(1<<O)-1)];continue G}else{G.msg="invalid distance code",Z.mode=t1;break W}break}}else if((O&64)===0){E=x[(E&65535)+(z&(1<<O)-1)];continue J}else if(O&32){Z.mode=b9;break W}else{G.msg="invalid literal/length code",Z.mode=t1;break W}break}}while(Q<V&&X<Y);f=$>>3,Q-=f,$-=f<<3,z&=(1<<$)-1,G.next_in=Q,G.next_out=X,G.avail_in=Q<V?5+(V-Q):5-(Q-V),G.avail_out=X<Y?257+(Y-X):257-(X-Y),Z.hold=z,Z.bits=$;return},J1=15,P5=852,U5=592,K5=0,m8=1,F5=2,u9=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),d9=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),c9=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),_9=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),l9=(W,G,J,Q,V,X,q,Y)=>{const K=Y.bits;let P=0,U=0,C=0,F=0,z=0,$=0,x=0,g=0,T=0,S=0,E,O,f,d,R,j=null,I;const k=new Uint16Array(J1+1),Z=new Uint16Array(J1+1);let H=null,B,L,v;for(P=0;P<=J1;P++)k[P]=0;for(U=0;U<Q;U++)k[G[J+U]]++;z=K;for(F=J1;F>=1;F--)if(k[F]!==0)break;if(z>F)z=F;if(F===0)return V[X++]=1<<24|64<<16|0,V[X++]=1<<24|64<<16|0,Y.bits=1,0;for(C=1;C<F;C++)if(k[C]!==0)break;if(z<C)z=C;g=1;for(P=1;P<=J1;P++)if(g<<=1,g-=k[P],g<0)return-1;if(g>0&&(W===K5||F!==1))return-1;Z[1]=0;for(P=1;P<J1;P++)Z[P+1]=Z[P]+k[P];for(U=0;U<Q;U++)if(G[J+U]!==0)q[Z[G[J+U]]++]=U;if(W===K5)j=H=q,I=20;else if(W===m8)j=u9,H=d9,I=257;else j=c9,H=_9,I=0;if(S=0,U=0,P=C,R=X,$=z,x=0,f=-1,T=1<<z,d=T-1,W===m8&&T>P5||W===F5&&T>U5)return 1;for(;;){if(B=P-x,q[U]+1<I)L=0,v=q[U];else if(q[U]>=I)L=H[q[U]-I],v=j[q[U]-I];else L=96,v=0;E=1<<P-x,O=1<<$,C=O;do O-=E,V[R+(S>>x)+O]=B<<24|L<<16|v|0;while(O!==0);E=1<<P-1;while(S&E)E>>=1;if(E!==0)S&=E-1,S+=E;else S=0;if(U++,--k[P]===0){if(P===F)break;P=G[J+q[U]]}if(P>z&&(S&d)!==f){if(x===0)x=z;R+=C,$=P-x,g=1<<$;while($+x<F){if(g-=k[$+x],g<=0)break;$++,g<<=1}if(T+=1<<$,W===m8&&T>P5||W===F5&&T>U5)return 1;f=S&d,V[f]=z<<24|$<<16|R-X|0}}if(S!==0)V[R+S]=P-x<<24|64<<16|0;return Y.bits=z,0},x1=l9,i9=0,Y7=1,P7=2,{Z_FINISH:z5,Z_BLOCK:r9,Z_TREES:W8,Z_OK:b0,Z_STREAM_END:a9,Z_NEED_DICT:o9,Z_STREAM_ERROR:q0,Z_DATA_ERROR:U7,Z_MEM_ERROR:K7,Z_BUF_ERROR:n9,Z_DEFLATED:Z5}=m0,U8=16180,k5=16181,H5=16182,C5=16183,$5=16184,M5=16185,B5=16186,j5=16187,L5=16188,R5=16189,q8=16190,M0=16191,u8=16192,O5=16193,d8=16194,I5=16195,w5=16196,x5=16197,D5=16198,J8=16199,G8=16200,N5=16201,A5=16202,v5=16203,g5=16204,T5=16205,c8=16206,S5=16207,y5=16208,i=16209,F7=16210,z7=16211,s9=852,e9=592,t9=15,WG=t9,E5=(W)=>{return(W>>>24&255)+(W>>>8&65280)+((W&65280)<<8)+((W&255)<<24)},u0=(W)=>{if(!W)return 1;const G=W.state;if(!G||G.strm!==W||G.mode<U8||G.mode>z7)return 1;return 0},Z7=(W)=>{if(u0(W))return q0;const G=W.state;if(W.total_in=W.total_out=G.total=0,W.msg="",G.wrap)W.adler=G.wrap&1;return G.mode=U8,G.last=0,G.havedict=0,G.flags=-1,G.dmax=32768,G.head=null,G.hold=0,G.bits=0,G.lencode=G.lendyn=new Int32Array(s9),G.distcode=G.distdyn=new Int32Array(e9),G.sane=1,G.back=-1,b0},k7=(W)=>{if(u0(W))return q0;const G=W.state;return G.wsize=0,G.whave=0,G.wnext=0,Z7(W)},H7=(W,G)=>{let J;if(u0(W))return q0;const Q=W.state;if(G<0)J=0,G=-G;else if(J=(G>>4)+5,G<48)G&=15;if(G&&(G<8||G>15))return q0;if(Q.window!==null&&Q.wbits!==G)Q.window=null;return Q.wrap=J,Q.wbits=G,k7(W)},C7=(W,G)=>{if(!W)return q0;const J=new JG;W.state=J,J.strm=W,J.window=null,J.mode=U8;const Q=H7(W,G);if(Q!==b0)W.state=null;return Q},GG=(W)=>{return C7(W,WG)},p5=!0,_8,l8,QG=(W)=>{if(p5){_8=new Int32Array(512),l8=new Int32Array(32);let G=0;while(G<144)W.lens[G++]=8;while(G<256)W.lens[G++]=9;while(G<280)W.lens[G++]=7;while(G<288)W.lens[G++]=8;x1(Y7,W.lens,0,288,_8,0,W.work,{bits:9}),G=0;while(G<32)W.lens[G++]=5;x1(P7,W.lens,0,32,l8,0,W.work,{bits:5}),p5=!1}W.lencode=_8,W.lenbits=9,W.distcode=l8,W.distbits=5},$7=(W,G,J,Q)=>{let V;const X=W.state;if(X.window===null)X.wsize=1<<X.wbits,X.wnext=0,X.whave=0,X.window=new Uint8Array(X.wsize);if(Q>=X.wsize)X.window.set(G.subarray(J-X.wsize,J),0),X.wnext=0,X.whave=X.wsize;else{if(V=X.wsize-X.wnext,V>Q)V=Q;if(X.window.set(G.subarray(J-Q,J-Q+V),X.wnext),Q-=V,Q)X.window.set(G.subarray(J-Q,J),0),X.wnext=Q,X.whave=X.wsize;else{if(X.wnext+=V,X.wnext===X.wsize)X.wnext=0;if(X.whave<X.wsize)X.whave+=V}}return 0},VG=(W,G)=>{let J,Q,V,X,q,Y,K,P,U,C,F,z,$,x,g=0,T,S,E,O,f,d,R,j;const I=new Uint8Array(4);let k,Z;const H=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(u0(W)||!W.output||!W.input&&W.avail_in!==0)return q0;if(J=W.state,J.mode===M0)J.mode=u8;q=W.next_out,V=W.output,K=W.avail_out,X=W.next_in,Q=W.input,Y=W.avail_in,P=J.hold,U=J.bits,C=Y,F=K,j=b0;W:for(;;)switch(J.mode){case U8:if(J.wrap===0){J.mode=u8;break}while(U<16){if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}if(J.wrap&2&&P===35615){if(J.wbits===0)J.wbits=15;J.check=0,I[0]=P&255,I[1]=P>>>8&255,J.check=o(J.check,I,2,0),P=0,U=0,J.mode=k5;break}if(J.head)J.head.done=!1;if(!(J.wrap&1)||(((P&255)<<8)+(P>>8))%31){W.msg="incorrect header check",J.mode=i;break}if((P&15)!==Z5){W.msg="unknown compression method",J.mode=i;break}if(P>>>=4,U-=4,R=(P&15)+8,J.wbits===0)J.wbits=R;if(R>15||R>J.wbits){W.msg="invalid window size",J.mode=i;break}J.dmax=1<<J.wbits,J.flags=0,W.adler=J.check=1,J.mode=P&512?R5:M0,P=0,U=0;break;case k5:while(U<16){if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}if(J.flags=P,(J.flags&255)!==Z5){W.msg="unknown compression method",J.mode=i;break}if(J.flags&57344){W.msg="unknown header flags set",J.mode=i;break}if(J.head)J.head.text=P>>8&1;if(J.flags&512&&J.wrap&4)I[0]=P&255,I[1]=P>>>8&255,J.check=o(J.check,I,2,0);P=0,U=0,J.mode=H5;case H5:while(U<32){if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}if(J.head)J.head.time=P;if(J.flags&512&&J.wrap&4)I[0]=P&255,I[1]=P>>>8&255,I[2]=P>>>16&255,I[3]=P>>>24&255,J.check=o(J.check,I,4,0);P=0,U=0,J.mode=C5;case C5:while(U<16){if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}if(J.head)J.head.xflags=P&255,J.head.os=P>>8;if(J.flags&512&&J.wrap&4)I[0]=P&255,I[1]=P>>>8&255,J.check=o(J.check,I,2,0);P=0,U=0,J.mode=$5;case $5:if(J.flags&1024){while(U<16){if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}if(J.length=P,J.head)J.head.extra_len=P;if(J.flags&512&&J.wrap&4)I[0]=P&255,I[1]=P>>>8&255,J.check=o(J.check,I,2,0);P=0,U=0}else if(J.head)J.head.extra=null;J.mode=M5;case M5:if(J.flags&1024){if(z=J.length,z>Y)z=Y;if(z){if(J.head){if(R=J.head.extra_len-J.length,!J.head.extra)J.head.extra=new Uint8Array(J.head.extra_len);J.head.extra.set(Q.subarray(X,X+z),R)}if(J.flags&512&&J.wrap&4)J.check=o(J.check,Q,z,X);Y-=z,X+=z,J.length-=z}if(J.length)break W}J.length=0,J.mode=B5;case B5:if(J.flags&2048){if(Y===0)break W;z=0;do if(R=Q[X+z++],J.head&&R&&J.length<65536)J.head.name+=String.fromCharCode(R);while(R&&z<Y);if(J.flags&512&&J.wrap&4)J.check=o(J.check,Q,z,X);if(Y-=z,X+=z,R)break W}else if(J.head)J.head.name=null;J.length=0,J.mode=j5;case j5:if(J.flags&4096){if(Y===0)break W;z=0;do if(R=Q[X+z++],J.head&&R&&J.length<65536)J.head.comment+=String.fromCharCode(R);while(R&&z<Y);if(J.flags&512&&J.wrap&4)J.check=o(J.check,Q,z,X);if(Y-=z,X+=z,R)break W}else if(J.head)J.head.comment=null;J.mode=L5;case L5:if(J.flags&512){while(U<16){if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}if(J.wrap&4&&P!==(J.check&65535)){W.msg="header crc mismatch",J.mode=i;break}P=0,U=0}if(J.head)J.head.hcrc=J.flags>>9&1,J.head.done=!0;W.adler=J.check=0,J.mode=M0;break;case R5:while(U<32){if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}W.adler=J.check=E5(P),P=0,U=0,J.mode=q8;case q8:if(J.havedict===0)return W.next_out=q,W.avail_out=K,W.next_in=X,W.avail_in=Y,J.hold=P,J.bits=U,o9;W.adler=J.check=1,J.mode=M0;case M0:if(G===r9||G===W8)break W;case u8:if(J.last){P>>>=U&7,U-=U&7,J.mode=c8;break}while(U<3){if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}switch(J.last=P&1,P>>>=1,U-=1,P&3){case 0:J.mode=O5;break;case 1:if(QG(J),J.mode=J8,G===W8){P>>>=2,U-=2;break W}break;case 2:J.mode=w5;break;case 3:W.msg="invalid block type",J.mode=i}P>>>=2,U-=2;break;case O5:P>>>=U&7,U-=U&7;while(U<32){if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}if((P&65535)!==(P>>>16^65535)){W.msg="invalid stored block lengths",J.mode=i;break}if(J.length=P&65535,P=0,U=0,J.mode=d8,G===W8)break W;case d8:J.mode=I5;case I5:if(z=J.length,z){if(z>Y)z=Y;if(z>K)z=K;if(z===0)break W;V.set(Q.subarray(X,X+z),q),Y-=z,X+=z,K-=z,q+=z,J.length-=z;break}J.mode=M0;break;case w5:while(U<14){if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}if(J.nlen=(P&31)+257,P>>>=5,U-=5,J.ndist=(P&31)+1,P>>>=5,U-=5,J.ncode=(P&15)+4,P>>>=4,U-=4,J.nlen>286||J.ndist>30){W.msg="too many length or distance symbols",J.mode=i;break}J.have=0,J.mode=x5;case x5:while(J.have<J.ncode){while(U<3){if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}J.lens[H[J.have++]]=P&7,P>>>=3,U-=3}while(J.have<19)J.lens[H[J.have++]]=0;if(J.lencode=J.lendyn,J.lenbits=7,k={bits:J.lenbits},j=x1(i9,J.lens,0,19,J.lencode,0,J.work,k),J.lenbits=k.bits,j){W.msg="invalid code lengths set",J.mode=i;break}J.have=0,J.mode=D5;case D5:while(J.have<J.nlen+J.ndist){for(;;){if(g=J.lencode[P&(1<<J.lenbits)-1],T=g>>>24,S=g>>>16&255,E=g&65535,T<=U)break;if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}if(E<16)P>>>=T,U-=T,J.lens[J.have++]=E;else{if(E===16){Z=T+2;while(U<Z){if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}if(P>>>=T,U-=T,J.have===0){W.msg="invalid bit length repeat",J.mode=i;break}R=J.lens[J.have-1],z=3+(P&3),P>>>=2,U-=2}else if(E===17){Z=T+3;while(U<Z){if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}P>>>=T,U-=T,R=0,z=3+(P&7),P>>>=3,U-=3}else{Z=T+7;while(U<Z){if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}P>>>=T,U-=T,R=0,z=11+(P&127),P>>>=7,U-=7}if(J.have+z>J.nlen+J.ndist){W.msg="invalid bit length repeat",J.mode=i;break}while(z--)J.lens[J.have++]=R}}if(J.mode===i)break;if(J.lens[256]===0){W.msg="invalid code -- missing end-of-block",J.mode=i;break}if(J.lenbits=9,k={bits:J.lenbits},j=x1(Y7,J.lens,0,J.nlen,J.lencode,0,J.work,k),J.lenbits=k.bits,j){W.msg="invalid literal/lengths set",J.mode=i;break}if(J.distbits=6,J.distcode=J.distdyn,k={bits:J.distbits},j=x1(P7,J.lens,J.nlen,J.ndist,J.distcode,0,J.work,k),J.distbits=k.bits,j){W.msg="invalid distances set",J.mode=i;break}if(J.mode=J8,G===W8)break W;case J8:J.mode=G8;case G8:if(Y>=6&&K>=258){if(W.next_out=q,W.avail_out=K,W.next_in=X,W.avail_in=Y,J.hold=P,J.bits=U,m9(W,F),q=W.next_out,V=W.output,K=W.avail_out,X=W.next_in,Q=W.input,Y=W.avail_in,P=J.hold,U=J.bits,J.mode===M0)J.back=-1;break}J.back=0;for(;;){if(g=J.lencode[P&(1<<J.lenbits)-1],T=g>>>24,S=g>>>16&255,E=g&65535,T<=U)break;if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}if(S&&(S&240)===0){O=T,f=S,d=E;for(;;){if(g=J.lencode[d+((P&(1<<O+f)-1)>>O)],T=g>>>24,S=g>>>16&255,E=g&65535,O+T<=U)break;if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}P>>>=O,U-=O,J.back+=O}if(P>>>=T,U-=T,J.back+=T,J.length=E,S===0){J.mode=T5;break}if(S&32){J.back=-1,J.mode=M0;break}if(S&64){W.msg="invalid literal/length code",J.mode=i;break}J.extra=S&15,J.mode=N5;case N5:if(J.extra){Z=J.extra;while(U<Z){if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}J.length+=P&(1<<J.extra)-1,P>>>=J.extra,U-=J.extra,J.back+=J.extra}J.was=J.length,J.mode=A5;case A5:for(;;){if(g=J.distcode[P&(1<<J.distbits)-1],T=g>>>24,S=g>>>16&255,E=g&65535,T<=U)break;if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}if((S&240)===0){O=T,f=S,d=E;for(;;){if(g=J.distcode[d+((P&(1<<O+f)-1)>>O)],T=g>>>24,S=g>>>16&255,E=g&65535,O+T<=U)break;if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}P>>>=O,U-=O,J.back+=O}if(P>>>=T,U-=T,J.back+=T,S&64){W.msg="invalid distance code",J.mode=i;break}J.offset=E,J.extra=S&15,J.mode=v5;case v5:if(J.extra){Z=J.extra;while(U<Z){if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}J.offset+=P&(1<<J.extra)-1,P>>>=J.extra,U-=J.extra,J.back+=J.extra}if(J.offset>J.dmax){W.msg="invalid distance too far back",J.mode=i;break}J.mode=g5;case g5:if(K===0)break W;if(z=F-K,J.offset>z){if(z=J.offset-z,z>J.whave){if(J.sane){W.msg="invalid distance too far back",J.mode=i;break}}if(z>J.wnext)z-=J.wnext,$=J.wsize-z;else $=J.wnext-z;if(z>J.length)z=J.length;x=J.window}else x=V,$=q-J.offset,z=J.length;if(z>K)z=K;K-=z,J.length-=z;do V[q++]=x[$++];while(--z);if(J.length===0)J.mode=G8;break;case T5:if(K===0)break W;V[q++]=J.length,K--,J.mode=G8;break;case c8:if(J.wrap){while(U<32){if(Y===0)break W;Y--,P|=Q[X++]<<U,U+=8}if(F-=K,W.total_out+=F,J.total+=F,J.wrap&4&&F)W.adler=J.check=J.flags?o(J.check,V,F,q-F):g1(J.check,V,F,q-F);if(F=K,J.wrap&4&&(J.flags?P:E5(P))!==J.check){W.msg="incorrect data check",J.mode=i;break}P=0,U=0}J.mode=S5;case S5:if(J.wrap&&J.flags){while(U<32){if(Y===0)break W;Y--,P+=Q[X++]<<U,U+=8}if(J.wrap&4&&P!==(J.total&4294967295)){W.msg="incorrect length check",J.mode=i;break}P=0,U=0}J.mode=y5;case y5:j=a9;break W;case i:j=U7;break W;case F7:return K7;case z7:default:return q0}if(W.next_out=q,W.avail_out=K,W.next_in=X,W.avail_in=Y,J.hold=P,J.bits=U,J.wsize||F!==W.avail_out&&J.mode<i&&(J.mode<c8||G!==z5)){if($7(W,W.output,W.next_out,F-W.avail_out));}if(C-=W.avail_in,F-=W.avail_out,W.total_in+=C,W.total_out+=F,J.total+=F,J.wrap&4&&F)W.adler=J.check=J.flags?o(J.check,V,F,W.next_out-F):g1(J.check,V,F,W.next_out-F);if(W.data_type=J.bits+(J.last?64:0)+(J.mode===M0?128:0)+(J.mode===J8||J.mode===d8?256:0),(C===0&&F===0||G===z5)&&j===b0)j=n9;return j},XG=(W)=>{if(u0(W))return q0;let G=W.state;if(G.window)G.window=null;return W.state=null,b0},qG=(W,G)=>{if(u0(W))return q0;const J=W.state;if((J.wrap&2)===0)return q0;return J.head=G,G.done=!1,b0},YG=(W,G)=>{const J=G.length;let Q,V,X;if(u0(W))return q0;if(Q=W.state,Q.wrap!==0&&Q.mode!==q8)return q0;if(Q.mode===q8){if(V=1,V=g1(V,G,J,0),V!==Q.check)return U7}if(X=$7(W,G,J,J),X)return Q.mode=F7,K7;return Q.havedict=1,b0},PG=k7,UG=H7,KG=Z7,FG=GG,zG=C7,ZG=VG,kG=XG,HG=qG,CG=YG,$G="pako inflate (from Nodeca project)",j0={inflateReset:PG,inflateReset2:UG,inflateResetKeep:KG,inflateInit:FG,inflateInit2:zG,inflate:ZG,inflateEnd:kG,inflateGetHeader:HG,inflateSetDictionary:CG,inflateInfo:$G},BG=MG,M7=Object.prototype.toString,{Z_NO_FLUSH:jG,Z_FINISH:LG,Z_OK:y1,Z_STREAM_END:i8,Z_NEED_DICT:r8,Z_STREAM_ERROR:RG,Z_DATA_ERROR:f5,Z_MEM_ERROR:OG}=m0;h1.prototype.push=function(W,G){const J=this.strm,Q=this.options.chunkSize,V=this.options.dictionary;let X,q,Y;if(this.ended)return!1;if(G===~~G)q=G;else q=G===!0?LG:jG;if(M7.call(W)==="[object ArrayBuffer]")J.input=new Uint8Array(W);else J.input=W;J.next_in=0,J.avail_in=J.input.length;for(;;){if(J.avail_out===0)J.output=new Uint8Array(Q),J.next_out=0,J.avail_out=Q;if(X=j0.inflate(J,q),X===r8&&V){if(X=j0.inflateSetDictionary(J,V),X===y1)X=j0.inflate(J,q);else if(X===f5)X=r8}while(J.avail_in>0&&X===i8&&J.state.wrap>0&&W[J.next_in]!==0)j0.inflateReset(J),X=j0.inflate(J,q);switch(X){case RG:case f5:case r8:case OG:return this.onEnd(X),this.ended=!0,!1}if(Y=J.avail_out,J.next_out){if(J.avail_out===0||X===i8)if(this.options.to==="string"){let K=S1.utf8border(J.output,J.next_out),P=J.next_out-K,U=S1.buf2string(J.output,K);if(J.next_out=P,J.avail_out=Q-P,P)J.output.set(J.output.subarray(K,K+P),0);this.onData(U)}else this.onData(J.output.length===J.next_out?J.output:J.output.subarray(0,J.next_out))}if(X===y1&&Y===0)continue;if(X===i8)return X=j0.inflateEnd(this.strm),this.onEnd(X),this.ended=!0,!0;if(J.avail_in===0)break}return!0};h1.prototype.onData=function(W){this.chunks.push(W)};h1.prototype.onEnd=function(W){if(W===y1)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=P8.flattenChunks(this.chunks);this.chunks=[],this.err=W,this.msg=this.strm.msg};var wG=h1,xG=U6,DG=IG,NG=U6,AG=m0,vG={Inflate:wG,inflate:xG,inflateRaw:DG,ungzip:NG,constants:AG},{Deflate:gG,deflate:TG,deflateRaw:SG,gzip:yG}=h9,{Inflate:EG,inflate:pG,inflateRaw:fG,ungzip:hG}=vG,bG=gG,mG=TG,uG=SG,dG=yG,cG=EG,_G=pG,lG=fG,iG=hG,rG=m0,d0={Deflate:bG,deflate:mG,deflateRaw:uG,gzip:dG,Inflate:cG,inflate:_G,inflateRaw:lG,ungzip:iG,constants:rG};var x8=function(W){return W instanceof Uint8Array||ArrayBuffer.isView(W)&&W.constructor.name==="Uint8Array"},M6=function(W){if(!Number.isSafeInteger(W)||W<0)throw Error("positive integer expected, got "+W)},n0=function(W,...G){if(!x8(W))throw Error("Uint8Array expected");if(G.length>0&&!G.includes(W.length))throw Error("Uint8Array expected of length "+G+", got length="+W.length)},d7=function(W){if(typeof W!="function"||typeof W.create!="function")throw Error("Hash should be wrapped by utils.createHasher");M6(W.outputLen),M6(W.blockLen)},$8=function(W,G=!0){if(W.destroyed)throw Error("Hash instance has been destroyed");if(G&&W.finished)throw Error("Hash#digest() has already been called")},M8=function(...W){for(let G=0;G<W.length;G++)W[G].fill(0)},K6=function(W){return new DataView(W.buffer,W.byteOffset,W.byteLength)},k0=function(W,G){return W<<32-G|W>>>G},Z1=function(W){if(n0(W),c7)return W.toHex();let G="";for(let J=0;J<W.length;J++)G+=aG[W[J]];return G},R7=function(W){return W>=B7&&W<=oG?W-B7:W>=j7&&W<=nG?W-(j7-10):W>=L7&&W<=sG?W-(L7-10):void 0},B8=function(W){if(typeof W!="string")throw Error("hex string expected, got "+typeof W);if(c7)return Uint8Array.fromHex(W);const G=W.length,J=G/2;if(G%2)throw Error("hex string expected, got unpadded hex of length "+G);const Q=new Uint8Array(J);for(let V=0,X=0;V<J;V++,X+=2){const q=R7(W.charCodeAt(X)),Y=R7(W.charCodeAt(X+1));if(q===void 0||Y===void 0){const K=W[X]+W[X+1];throw Error('hex string expected, got non-hex character "'+K+'" at index '+X)}Q[V]=16*q+Y}return Q},_7=function(W){if(typeof W!="string")throw Error("string expected");return new Uint8Array((new TextEncoder()).encode(W))},N6=function(W){return typeof W=="string"&&(W=_7(W)),n0(W),W},H0=function(...W){let G=0;for(let Q=0;Q<W.length;Q++){const V=W[Q];n0(V),G+=V.length}const J=new Uint8Array(G);for(let Q=0,V=0;Q<W.length;Q++){const X=W[Q];J.set(X,V),V+=X.length}return J},eG=function(W){const G=(Q)=>W().update(N6(Q)).digest(),J=W();return G.outputLen=J.outputLen,G.blockLen=J.blockLen,G.create=()=>W(),G},j8=function(W=32){if(P1&&typeof P1.getRandomValues=="function")return P1.getRandomValues(new Uint8Array(W));if(P1&&typeof P1.randomBytes=="function")return Uint8Array.from(P1.randomBytes(W));throw Error("crypto.getRandomValues must be defined")},tG=function(W,G,J){return W&G^W&J^G&J},L8=function(W,G=""){if(typeof W!="boolean")throw Error((G&&`"${G}"`)+"expected boolean, got type="+typeof W);return W},l0=function(W,G,J=""){const Q=x8(W),V=W?.length,X=G!==void 0;if(!Q||X&&V!==G)throw Error((J&&`"${J}" `)+"expected Uint8Array"+(X?" of length "+G:"")+", got "+(Q?"length="+V:"type="+typeof W));return W},K8=function(W){const G=W.toString(16);return 1&G.length?"0"+G:G},a7=function(W){if(typeof W!="string")throw Error("hex string expected, got "+typeof W);return W===""?g6:BigInt("0x"+W)},C1=function(W){return a7(Z1(W))},o7=function(W){return n0(W),a7(Z1(Uint8Array.from(W).reverse()))},D8=function(W,G){return B8(W.toString(16).padStart(2*G,"0"))},n7=function(W,G){return D8(W,G).reverse()},r=function(W,G,J){let Q;if(typeof G=="string")try{Q=B8(G)}catch(X){throw Error(W+" must be hex string or Uint8Array, cause: "+X)}else{if(!x8(G))throw Error(W+" must be hex string or Uint8Array");Q=Uint8Array.from(G)}const V=Q.length;if(typeof J=="number"&&V!==J)throw Error(W+" of length "+J+" expected, got "+V);return Q},L6=function(W,G,J){return F6(W)&&F6(G)&&F6(J)&&G<=W&&W<J},s7=function(W){let G;for(G=0;W>g6;W>>=j6,G+=1);return G},T6=function(W,G,J={}){if(!W||typeof W!="object")throw Error("expected valid options object");function Q(V,X,q){const Y=W[V];if(q&&Y===void 0)return;const K=typeof Y;if(K!==X||Y===null)throw Error(`param "${V}" is invalid: expected ${X}, got ${K}`)}Object.entries(G).forEach(([V,X])=>Q(V,X,!1)),Object.entries(J).forEach(([V,X])=>Q(V,X,!0))},O7=function(W){const G=new WeakMap;return(J,...Q)=>{const V=G.get(J);if(V!==void 0)return V;const X=W(J,...Q);return G.set(J,X),X}},P0=function(W,G){const J=W%G;return J>=G0?J:G+J},Y0=function(W,G,J){let Q=W;for(;G-- >G0;)Q*=Q,Q%=J;return Q},w7=function(W,G){if(W===G0)throw Error("invert: expected non-zero number");if(G<=G0)throw Error("invert: expected positive modulus, got "+G);let J=P0(W,G),Q=G,V=G0,X=W0;for(;J!==G0;){const q=Q%J,Y=V-X*(Q/J);Q=J,J=q,V=X,X=Y}if(Q!==W0)throw Error("invert: does not exist");return P0(V,G)},S6=function(W,G,J){if(!W.eql(W.sqr(G),J))throw Error("Cannot find square root")},GW=function(W,G){const J=(W.ORDER+W0)/t7,Q=W.pow(G,J);return S6(W,Q,G),Q},QQ=function(W,G){const J=(W.ORDER-WW)/JW,Q=W.mul(G,r0),V=W.pow(Q,J),X=W.mul(G,V),q=W.mul(W.mul(X,r0),V),Y=W.mul(X,W.sub(q,W.ONE));return S6(W,Y,G),Y},x7=function(W){if(W<e7)throw Error("sqrt is not defined for small field");let G=W-W0,J=0;for(;G%r0===G0;)G/=r0,J++;let Q=r0;const V=_1(W);for(;D7(V,Q)===1;)if(Q++>1000)throw Error("Cannot find square root: probably non-prime P");if(J===1)return GW;let X=V.pow(Q,G);const q=(G+W0)/r0;return function(Y,K){if(Y.is0(K))return K;if(D7(Y,K)!==1)throw Error("Cannot find square root");let P=J,U=Y.mul(Y.ONE,X),C=Y.pow(K,G),F=Y.pow(K,q);for(;!Y.eql(C,Y.ONE);){if(Y.is0(C))return Y.ZERO;let z=1,$=Y.sqr(C);for(;!Y.eql($,Y.ONE);)if(z++,$=Y.sqr($),z===P)throw Error("Cannot find square root");const x=W0<<BigInt(P-z-1),g=Y.pow(U,x);P=z,U=Y.sqr(g),C=Y.mul(C,U),F=Y.mul(F,g)}return F}},VQ=function(W){return W%t7===e7?GW:W%JW===WW?QQ:W%I7===GQ?function(G){const J=_1(G),Q=x7(G),V=Q(J,J.neg(J.ONE)),X=Q(J,V),q=Q(J,J.neg(V)),Y=(G+JQ)/I7;return(K,P)=>{let U=K.pow(P,Y),C=K.mul(U,V);const F=K.mul(U,X),z=K.mul(U,q),$=K.eql(K.sqr(C),P),x=K.eql(K.sqr(F),P);U=K.cmov(U,C,$),C=K.cmov(z,F,x);const g=K.eql(K.sqr(C),P),T=K.cmov(U,C,g);return S6(K,T,P),T}}(W):x7(W)},QW=function(W,G,J=!1){const Q=Array(G.length).fill(J?W.ZERO:void 0),V=G.reduce((q,Y,K)=>W.is0(Y)?q:(Q[K]=q,W.mul(q,Y)),W.ONE),X=W.inv(V);return G.reduceRight((q,Y,K)=>W.is0(Y)?q:(Q[K]=W.mul(q,Q[K]),W.mul(q,Y)),X),Q},D7=function(W,G){const J=(W.ORDER-W0)/r0,Q=W.pow(G,J),V=W.eql(Q,W.ONE),X=W.eql(Q,W.ZERO),q=W.eql(Q,W.neg(W.ONE));if(!V&&!X&&!q)throw Error("invalid Legendre symbol result");return V?1:X?0:-1},VW=function(W,G){G!==void 0&&M6(G);const J=G!==void 0?G:W.toString(2).length;return{nBitLength:J,nByteLength:Math.ceil(J/8)}},_1=function(W,G,J=!1,Q={}){if(W<=G0)throw Error("invalid field: expected ORDER > 0, got "+W);let V,X,q,Y=!1;if(typeof G=="object"&&G!=null){if(Q.sqrt||J)throw Error("cannot specify opts in two arguments");const F=G;F.BITS&&(V=F.BITS),F.sqrt&&(X=F.sqrt),typeof F.isLE=="boolean"&&(J=F.isLE),typeof F.modFromBytes=="boolean"&&(Y=F.modFromBytes),q=F.allowedLengths}else typeof G=="number"&&(V=G),Q.sqrt&&(X=Q.sqrt);const{nBitLength:K,nByteLength:P}=VW(W,V);if(P>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");let U;const C=Object.freeze({ORDER:W,isLE:J,BITS:K,BYTES:P,MASK:c1(K),ZERO:G0,ONE:W0,allowedLengths:q,create(F){return P0(F,W)},isValid(F){if(typeof F!="bigint")throw Error("invalid field element: expected bigint, got "+typeof F);return G0<=F&&F<W},is0(F){return F===G0},isValidNot0(F){return!C.is0(F)&&C.isValid(F)},isOdd(F){return(F&W0)===W0},neg(F){return P0(-F,W)},eql(F,z){return F===z},sqr(F){return P0(F*F,W)},add(F,z){return P0(F+z,W)},sub(F,z){return P0(F-z,W)},mul(F,z){return P0(F*z,W)},pow(F,z){return function($,x,g){if(g<G0)throw Error("invalid exponent, negatives unsupported");if(g===G0)return $.ONE;if(g===W0)return x;let T=$.ONE,S=x;for(;g>G0;)g&W0&&(T=$.mul(T,S)),S=$.sqr(S),g>>=W0;return T}(C,F,z)},div(F,z){return P0(F*w7(z,W),W)},sqrN(F){return F*F},addN(F,z){return F+z},subN(F,z){return F-z},mulN(F,z){return F*z},inv(F){return w7(F,W)},sqrt:X||((F)=>(U||(U=VQ(W)),U(C,F))),toBytes(F){return J?n7(F,P):D8(F,P)},fromBytes(F,z=!0){if(q){if(!q.includes(F.length)||F.length>P)throw Error("Field.fromBytes: expected "+q+" bytes, got "+F.length);const x=new Uint8Array(P);x.set(F,J?0:x.length-F.length),F=x}if(F.length!==P)throw Error("Field.fromBytes: expected "+P+" bytes, got "+F.length);let $=J?o7(F):C1(F);if(Y&&($=P0($,W)),!z&&!C.isValid($))throw Error("invalid field element: outside of range 0..ORDER");return $},invertBatch(F){return QW(C,F)},cmov(F,z,$){return $?z:F}});return Object.freeze(C)},XW=function(W){if(typeof W!="bigint")throw Error("field order must be bigint");const G=W.toString(2).length;return Math.ceil(G/8)},qW=function(W){const G=XW(W);return G+Math.ceil(G/2)},YW=function(W,G,J=!1){const Q=W.length,V=XW(G),X=qW(G);if(Q<16||Q<X||Q>1024)throw Error("expected "+X+"-1024 bytes of input, got "+Q);const q=P0(J?o7(W):C1(W),G-W0)+W0;return J?n7(q,V):D8(q,V)},R8=function(W,G){const J=G.negate();return W?J:G},z6=function(W,G){const J=QW(W.Fp,G.map((Q)=>Q.Z));return G.map((Q,V)=>W.fromAffine(Q.toAffine(J[V])))},PW=function(W,G){if(!Number.isSafeInteger(W)||W<=0||W>G)throw Error("invalid window size, expected [1.."+G+"], got W="+W)},Z6=function(W,G){PW(W,G);const J=2**W;return{windows:Math.ceil(G/W)+1,windowSize:2**(W-1),mask:c1(W),maxNumber:J,shiftBy:BigInt(W)}},N7=function(W,G,J){const{windowSize:Q,mask:V,maxNumber:X,shiftBy:q}=J;let Y=Number(W&V),K=W>>q;Y>Q&&(Y-=X,K+=a0);const P=G*Q;return{nextN:K,offset:P+Math.abs(Y)-1,isZero:Y===0,isNeg:Y<0,isNegF:G%2!=0,offsetF:P}},H6=function(W){return UW.get(W)||1},A7=function(W){if(W!==k1)throw Error("invalid wNAF")},qQ=function(W,G,J,Q){(function(F,z){if(!Array.isArray(F))throw Error("array expected");F.forEach(($,x)=>{if(!($ instanceof z))throw Error("invalid point at index "+x)})})(J,W),function(F,z){if(!Array.isArray(F))throw Error("array of scalars expected");F.forEach(($,x)=>{if(!z.isValid($))throw Error("invalid scalar at index "+x)})}(Q,G);const V=J.length,X=Q.length;if(V!==X)throw Error("arrays of points and scalars must have equal length");const q=W.ZERO,Y=s7(BigInt(V));let K=1;Y>12?K=Y-3:Y>4?K=Y-2:Y>0&&(K=2);const P=c1(K),U=Array(Number(P)+1).fill(q);let C=q;for(let F=Math.floor((G.BITS-1)/K)*K;F>=0;F-=K){U.fill(q);for(let $=0;$<X;$++){const x=Q[$],g=Number(x>>BigInt(F)&P);U[g]=U[g].add(J[$])}let z=q;for(let $=U.length-1,x=q;$>0;$--)x=x.add(U[$]),z=z.add(x);if(C=C.add(z),F!==0)for(let $=0;$<K;$++)C=C.double()}return C},v7=function(W,G,J){if(G){if(G.ORDER!==W)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return function(Q){T6(Q,XQ.reduce((V,X)=>(V[X]="function",V),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"}))}(G),G}return _1(W,{isLE:J})},R6=function(W){if(!["compact","recovered","der"].includes(W))throw Error('Signature format must be "compact", "recovered", or "der"');return W},C6=function(W,G){const J={};for(let Q of Object.keys(G))J[Q]=W[Q]===void 0?G[Q]:W[Q];return L8(J.lowS,"lowS"),L8(J.prehash,"prehash"),J.format!==void 0&&R6(J.format),J},i0=function(W,G){const{BYTES:J}=W;let Q;if(typeof G=="bigint")Q=G;else{let V=r("private key",G);try{Q=W.fromBytes(V)}catch(X){throw Error(`invalid private key: expected ui8a of size ${J}, got ${typeof G}`)}}if(!W.isValidNot0(Q))throw Error("invalid private key: out of range [1..N-1]");return Q},PQ=function(W,G={}){const J=function(k,Z,H={},B){if(B===void 0&&(B=k==="edwards"),!Z||typeof Z!="object")throw Error(`expected valid ${k} CURVE object`);for(let N of["p","n","h"]){const M=Z[N];if(!(typeof M=="bigint"&&M>k1))throw Error(`CURVE.${N} must be positive bigint`)}const L=v7(Z.p,H.Fp,B),v=v7(Z.n,H.Fn,B),w=["Gx","Gy","a","b"];for(let N of w)if(!L.isValid(Z[N]))throw Error(`CURVE.${N} must be valid field element of CURVE.Fp`);return{CURVE:Z=Object.freeze(Object.assign({},Z)),Fp:L,Fn:v}}("weierstrass",W,G),{Fp:Q,Fn:V}=J;let X=J.CURVE;const{h:q,n:Y}=X;T6(G,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:K}=G;if(K&&(!Q.is0(X.a)||typeof K.beta!="bigint"||!Array.isArray(K.basises)))throw Error('invalid endo: expected "beta": bigint and "basises": array');const P=ZW(Q,V);function U(){if(!Q.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}const C=G.toBytes||function(k,Z,H){const{x:B,y:L}=Z.toAffine(),v=Q.toBytes(B);if(L8(H,"isCompressed"),H)return U(),H0(zW(!Q.isOdd(L)),v);return H0(Uint8Array.of(4),v,Q.toBytes(L))},F=G.fromBytes||function(k){l0(k,void 0,"Point");const{publicKey:Z,publicKeyUncompressed:H}=P,B=k.length,L=k[0],v=k.subarray(1);if(B!==Z||L!==2&&L!==3){if(B===H&&L===4){const w=Q.BYTES,N=Q.fromBytes(v.subarray(0,w)),M=Q.fromBytes(v.subarray(w,2*w));if(!$(N,M))throw Error("bad point: is not on curve");return{x:N,y:M}}throw Error(`bad point: got length ${B}, expected compressed=${Z} or uncompressed=${H}`)}{const w=Q.fromBytes(v);if(!Q.isValid(w))throw Error("bad point: is not on curve, wrong x");const N=z(w);let M;try{M=Q.sqrt(N)}catch(D){const y=D instanceof Error?": "+D.message:"";throw Error("bad point: is not on curve, sqrt error"+y)}return U(),!(1&~L)!==Q.isOdd(M)&&(M=Q.neg(M)),{x:w,y:M}}};function z(k){const Z=Q.sqr(k),H=Q.mul(Z,k);return Q.add(Q.add(H,Q.mul(k,X.a)),X.b)}function $(k,Z){const H=Q.sqr(Z),B=z(k);return Q.eql(H,B)}if(!$(X.Gx,X.Gy))throw Error("bad curve params: generator point");const x=Q.mul(Q.pow(X.a,F8),YQ),g=Q.mul(Q.sqr(X.b),BigInt(27));if(Q.is0(Q.add(x,g)))throw Error("bad curve params: a or b");function T(k,Z,H=!1){if(!Q.isValid(Z)||H&&Q.is0(Z))throw Error("bad point coordinate "+k);return Z}function S(k){if(!(k instanceof R))throw Error("ProjectivePoint expected")}function E(k){if(!K||!K.basises)throw Error("no endo");return function(Z,H,B){const[[L,v],[w,N]]=H,M=g7(N*Z,B),D=g7(-v*Z,B);let y=Z-M*L-D*w,p=-M*v-D*N;const A=y<R0,b=p<R0;A&&(y=-y),b&&(p=-p);const m=c1(Math.ceil(s7(B)/2))+F1;if(y<R0||y>=m||p<R0||p>=m)throw Error("splitScalar (endomorphism): failed, k="+Z);return{k1neg:A,k1:y,k2neg:b,k2:p}}(k,K.basises,V.ORDER)}const O=O7((k,Z)=>{const{X:H,Y:B,Z:L}=k;if(Q.eql(L,Q.ONE))return{x:H,y:B};const v=k.is0();Z==null&&(Z=v?Q.ONE:Q.inv(L));const w=Q.mul(H,Z),N=Q.mul(B,Z),M=Q.mul(L,Z);if(v)return{x:Q.ZERO,y:Q.ZERO};if(!Q.eql(M,Q.ONE))throw Error("invZ was invalid");return{x:w,y:N}}),f=O7((k)=>{if(k.is0()){if(G.allowInfinityPoint&&!Q.is0(k.Y))return;throw Error("bad point: ZERO")}const{x:Z,y:H}=k.toAffine();if(!Q.isValid(Z)||!Q.isValid(H))throw Error("bad point: x or y not field elements");if(!$(Z,H))throw Error("bad point: equation left != right");if(!k.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function d(k,Z,H,B,L){return H=new R(Q.mul(H.X,k),H.Y,H.Z),Z=R8(B,Z),H=R8(L,H),Z.add(H)}class R{constructor(k,Z,H){this.X=T("x",k),this.Y=T("y",Z,!0),this.Z=T("z",H),Object.freeze(this)}static CURVE(){return X}static fromAffine(k){const{x:Z,y:H}=k||{};if(!k||!Q.isValid(Z)||!Q.isValid(H))throw Error("invalid affine point");if(k instanceof R)throw Error("projective point not allowed");return Q.is0(Z)&&Q.is0(H)?R.ZERO:new R(Z,H,Q.ONE)}static fromBytes(k){const Z=R.fromAffine(F(l0(k,void 0,"point")));return Z.assertValidity(),Z}static fromHex(k){return R.fromBytes(r("pointHex",k))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(k=8,Z=!0){return I.createCache(this,k),Z||this.multiply(F8),this}assertValidity(){f(this)}hasEvenY(){const{y:k}=this.toAffine();if(!Q.isOdd)throw Error("Field doesn't support isOdd");return!Q.isOdd(k)}equals(k){S(k);const{X:Z,Y:H,Z:B}=this,{X:L,Y:v,Z:w}=k,N=Q.eql(Q.mul(Z,w),Q.mul(L,B)),M=Q.eql(Q.mul(H,w),Q.mul(v,B));return N&&M}negate(){return new R(this.X,Q.neg(this.Y),this.Z)}double(){const{a:k,b:Z}=X,H=Q.mul(Z,F8),{X:B,Y:L,Z:v}=this;let{ZERO:w,ZERO:N,ZERO:M}=Q,D=Q.mul(B,B),y=Q.mul(L,L),p=Q.mul(v,v),A=Q.mul(B,L);return A=Q.add(A,A),M=Q.mul(B,v),M=Q.add(M,M),w=Q.mul(k,M),N=Q.mul(H,p),N=Q.add(w,N),w=Q.sub(y,N),N=Q.add(y,N),N=Q.mul(w,N),w=Q.mul(A,w),M=Q.mul(H,M),p=Q.mul(k,p),A=Q.sub(D,p),A=Q.mul(k,A),A=Q.add(A,M),M=Q.add(D,D),D=Q.add(M,D),D=Q.add(D,p),D=Q.mul(D,A),N=Q.add(N,D),p=Q.mul(L,v),p=Q.add(p,p),D=Q.mul(p,A),w=Q.sub(w,D),M=Q.mul(p,y),M=Q.add(M,M),M=Q.add(M,M),new R(w,N,M)}add(k){S(k);const{X:Z,Y:H,Z:B}=this,{X:L,Y:v,Z:w}=k;let{ZERO:N,ZERO:M,ZERO:D}=Q;const y=X.a,p=Q.mul(X.b,F8);let A=Q.mul(Z,L),b=Q.mul(H,v),m=Q.mul(B,w),h=Q.add(Z,H),l=Q.add(L,v);h=Q.mul(h,l),l=Q.add(A,b),h=Q.sub(h,l),l=Q.add(Z,B);let c=Q.add(L,w);return l=Q.mul(l,c),c=Q.add(A,m),l=Q.sub(l,c),c=Q.add(H,B),N=Q.add(v,w),c=Q.mul(c,N),N=Q.add(b,m),c=Q.sub(c,N),D=Q.mul(y,l),N=Q.mul(p,m),D=Q.add(N,D),N=Q.sub(b,D),D=Q.add(b,D),M=Q.mul(N,D),b=Q.add(A,A),b=Q.add(b,A),m=Q.mul(y,m),l=Q.mul(p,l),b=Q.add(b,m),m=Q.sub(A,m),m=Q.mul(y,m),l=Q.add(l,m),A=Q.mul(b,l),M=Q.add(M,A),A=Q.mul(c,l),N=Q.mul(h,N),N=Q.sub(N,A),A=Q.mul(h,b),D=Q.mul(c,D),D=Q.add(D,A),new R(N,M,D)}subtract(k){return this.add(k.negate())}is0(){return this.equals(R.ZERO)}multiply(k){const{endo:Z}=G;if(!V.isValidNot0(k))throw Error("invalid scalar: out of range");let H,B;const L=(v)=>I.cached(this,v,(w)=>z6(R,w));if(Z){const{k1neg:v,k1:w,k2neg:N,k2:M}=E(k),{p:D,f:y}=L(w),{p,f:A}=L(M);B=y.add(A),H=d(Z.beta,D,p,v,N)}else{const{p:v,f:w}=L(k);H=v,B=w}return z6(R,[H,B])[0]}multiplyUnsafe(k){const{endo:Z}=G,H=this;if(!V.isValid(k))throw Error("invalid scalar: out of range");if(k===R0||H.is0())return R.ZERO;if(k===F1)return H;if(I.hasCache(this))return this.multiply(k);if(Z){const{k1neg:B,k1:L,k2neg:v,k2:w}=E(k),{p1:N,p2:M}=function(D,y,p,A){let b=y,m=D.ZERO,h=D.ZERO;for(;p>k1||A>k1;)p&a0&&(m=m.add(b)),A&a0&&(h=h.add(b)),b=b.double(),p>>=a0,A>>=a0;return{p1:m,p2:h}}(R,H,L,w);return d(Z.beta,N,M,B,v)}return I.unsafe(H,k)}multiplyAndAddUnsafe(k,Z,H){const B=this.multiplyUnsafe(Z).add(k.multiplyUnsafe(H));return B.is0()?void 0:B}toAffine(k){return O(this,k)}isTorsionFree(){const{isTorsionFree:k}=G;return q===F1||(k?k(R,this):I.unsafe(this,Y).is0())}clearCofactor(){const{clearCofactor:k}=G;return q===F1?this:k?k(R,this):this.multiplyUnsafe(q)}isSmallOrder(){return this.multiplyUnsafe(q).is0()}toBytes(k=!0){return L8(k,"isCompressed"),this.assertValidity(),C(R,this,k)}toHex(k=!0){return Z1(this.toBytes(k))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(k=!0){return this.toBytes(k)}_setWindowSize(k){this.precompute(k)}static normalizeZ(k){return z6(R,k)}static msm(k,Z){return qQ(R,V,k,Z)}static fromPrivateKey(k){return R.BASE.multiply(i0(V,k))}}R.BASE=new R(X.Gx,X.Gy,Q.ONE),R.ZERO=new R(Q.ZERO,Q.ONE,Q.ZERO),R.Fp=Q,R.Fn=V;const j=V.BITS,I=new KW(R,G.endo?Math.ceil(j/2):j);return R.BASE.precompute(8),R},zW=function(W){return Uint8Array.of(W?2:3)},ZW=function(W,G){return{secretKey:G.BYTES,publicKey:1+W.BYTES,publicKeyUncompressed:1+2*W.BYTES,publicKeyHasPrefix:!0,signature:2*G.BYTES}},UQ=function(W,G,J={}){d7(G),T6(J,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const Q=J.randomBytes||j8,V=J.hmac||((j,...I)=>r7(G,j,H0(...I))),{Fp:X,Fn:q}=W,{ORDER:Y,BITS:K}=q,{keygen:P,getPublicKey:U,getSharedSecret:C,utils:F,lengths:z}=function(j,I={}){const{Fn:k}=j,Z=I.randomBytes||j8,H=Object.assign(ZW(j.Fp,k),{seed:qW(k.ORDER)});function B(M){try{return!!i0(k,M)}catch(D){return!1}}function L(M=Z(H.seed)){return YW(l0(M,H.seed,"seed"),k.ORDER)}function v(M,D=!0){return j.BASE.multiply(i0(k,M)).toBytes(D)}function w(M){if(typeof M=="bigint")return!1;if(M instanceof j)return!0;const{secretKey:D,publicKey:y,publicKeyUncompressed:p}=H;if(k.allowedLengths||D===y)return;const A=r("key",M).length;return A===y||A===p}return Object.freeze({getPublicKey:v,getSharedSecret(M,D,y=!0){if(w(M)===!0)throw Error("first arg must be private key");if(w(D)===!1)throw Error("second arg must be public key");const p=i0(k,M);return j.fromHex(D).multiply(p).toBytes(y)},keygen(M){const D=L(M);return{secretKey:D,publicKey:v(D)}},Point:j,utils:{isValidSecretKey:B,isValidPublicKey(M,D){const{publicKey:y,publicKeyUncompressed:p}=H;try{const A=M.length;return!(D===!0&&A!==y||D===!1&&A!==p||!j.fromBytes(M))}catch(A){return!1}},randomSecretKey:L,isValidPrivateKey:B,randomPrivateKey:L,normPrivateKeyToScalar:(M)=>i0(k,M),precompute(M=8,D=j.BASE){return D.precompute(M,!1)}},lengths:H})}(W,J),$={prehash:!1,lowS:typeof J.lowS=="boolean"&&J.lowS,format:void 0,extraEntropy:!1},x="compact";function g(j){return j>Y>>F1}function T(j,I){if(!q.isValidNot0(I))throw Error(`invalid signature ${j}: out of range 1..Point.Fn.ORDER`);return I}class S{constructor(j,I,k){this.r=T("r",j),this.s=T("s",I),k!=null&&(this.recovery=k),Object.freeze(this)}static fromBytes(j,I=x){let k;if(function(L,v){R6(v);const w=z.signature;l0(L,v==="compact"?w:v==="recovered"?w+1:void 0,v+" signature")}(j,I),I==="der"){const{r:L,s:v}=L0.toSig(l0(j));return new S(L,v)}I==="recovered"&&(k=j[0],I="compact",j=j.subarray(1));const Z=q.BYTES,H=j.subarray(0,Z),B=j.subarray(Z,2*Z);return new S(q.fromBytes(H),q.fromBytes(B),k)}static fromHex(j,I){return this.fromBytes(B8(j),I)}addRecoveryBit(j){return new S(this.r,this.s,j)}recoverPublicKey(j){const I=X.ORDER,{r:k,s:Z,recovery:H}=this;if(H==null||![0,1,2,3].includes(H))throw Error("recovery id invalid");if(Y*FW<I&&H>1)throw Error("recovery id is ambiguous for h>1 curve");const B=H===2||H===3?k+Y:k;if(!X.isValid(B))throw Error("recovery id 2 or 3 invalid");const L=X.toBytes(B),v=W.fromBytes(H0(zW(!(1&H)),L)),w=q.inv(B),N=O(r("msgHash",j)),M=q.create(-N*w),D=q.create(Z*w),y=W.BASE.multiplyUnsafe(M).add(v.multiplyUnsafe(D));if(y.is0())throw Error("point at infinify");return y.assertValidity(),y}hasHighS(){return g(this.s)}toBytes(j=x){if(R6(j),j==="der")return B8(L0.hexFromSig(this));const I=q.toBytes(this.r),k=q.toBytes(this.s);if(j==="recovered"){if(this.recovery==null)throw Error("recovery bit must be present");return H0(Uint8Array.of(this.recovery),I,k)}return H0(I,k)}toHex(j){return Z1(this.toBytes(j))}assertValidity(){}static fromCompact(j){return S.fromBytes(r("sig",j),"compact")}static fromDER(j){return S.fromBytes(r("sig",j),"der")}normalizeS(){return this.hasHighS()?new S(this.r,q.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Z1(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Z1(this.toBytes("compact"))}}const E=J.bits2int||function(j){if(j.length>8192)throw Error("input is too large");const I=C1(j),k=8*j.length-K;return k>0?I>>BigInt(k):I},O=J.bits2int_modN||function(j){return q.create(E(j))},f=c1(K);function d(j){return function(I,k,Z,H){if(!L6(k,Z,H))throw Error("expected valid "+I+": "+Z+" <= n < "+H+", got "+k)}("num < 2^"+K,j,R0,f),q.toBytes(j)}function R(j,I){return l0(j,void 0,"message"),I?l0(G(j),void 0,"prehashed message"):j}return Object.freeze({keygen:P,getPublicKey:U,getSharedSecret:C,utils:F,lengths:z,Point:W,sign(j,I,k={}){j=r("message",j);const{seed:Z,k2sig:H}=function(B,L,v){if(["recovered","canonical"].some((m)=>(m in v)))throw Error("sign() legacy options not supported");const{lowS:w,prehash:N,extraEntropy:M}=C6(v,$);B=R(B,N);const D=O(B),y=i0(q,L),p=[d(y),d(D)];if(M!=null&&M!==!1){const m=M===!0?Q(z.secretKey):M;p.push(r("extraEntropy",m))}const A=H0(...p),b=D;return{seed:A,k2sig(m){const h=E(m);if(!q.isValidNot0(h))return;const l=q.inv(h),c=W.BASE.multiply(h).toAffine(),U0=q.create(c.x);if(U0===R0)return;const s=q.create(l*q.create(b+U0*y));if(s===R0)return;let a=(c.x===U0?0:2)|Number(c.y&F1),C0=s;return w&&g(s)&&(C0=q.neg(s),a^=1),new S(U0,C0,a)}}}(j,I,k);return function(B,L,v){if(typeof B!="number"||B<2)throw Error("hashLen must be a number");if(typeof L!="number"||L<2)throw Error("qByteLen must be a number");if(typeof v!="function")throw Error("hmacFn must be a function");const w=(h)=>new Uint8Array(h),N=(h)=>Uint8Array.of(h);let M=w(B),D=w(B),y=0;const p=()=>{M.fill(1),D.fill(0),y=0},A=(...h)=>v(D,M,...h),b=(h=w(0))=>{D=A(N(0),h),M=A(),h.length!==0&&(D=A(N(1),h),M=A())},m=()=>{if(y++>=1000)throw Error("drbg: tried 1000 values");let h=0;const l=[];for(;h<L;){M=A();const c=M.slice();l.push(c),h+=M.length}return H0(...l)};return(h,l)=>{let c;for(p(),b(h);!(c=l(m()));)b();return p(),c}}(G.outputLen,q.BYTES,V)(Z,H)},verify(j,I,k,Z={}){const{lowS:H,prehash:B,format:L}=C6(Z,$);if(k=r("publicKey",k),I=R(r("message",I),B),("strict"in Z))throw Error("options.strict was renamed to lowS");const v=L===void 0?function(w){let N;const M=typeof w=="string"||x8(w),D=!M&&w!==null&&typeof w=="object"&&typeof w.r=="bigint"&&typeof w.s=="bigint";if(!M&&!D)throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(D)N=new S(w.r,w.s);else if(M){try{N=S.fromBytes(r("sig",w),"der")}catch(y){if(!(y instanceof L0.Err))throw y}if(!N)try{N=S.fromBytes(r("sig",w),"compact")}catch(y){return!1}}return N||!1}(j):S.fromBytes(r("sig",j),L);if(v===!1)return!1;try{const w=W.fromBytes(k);if(H&&v.hasHighS())return!1;const{r:N,s:M}=v,D=O(I),y=q.inv(M),p=q.create(D*y),A=q.create(N*y),b=W.BASE.multiplyUnsafe(p).add(w.multiplyUnsafe(A));if(b.is0())return!1;return q.create(b.x)===N}catch(w){return!1}},recoverPublicKey(j,I,k={}){const{prehash:Z}=C6(k,$);return I=R(I,Z),S.fromBytes(j,"recovered").recoverPublicKey(I).toBytes()},Signature:S,hash:G})},KQ=function(W){const{CURVE:G,curveOpts:J}=function(V){const X={a:V.a,b:V.b,p:V.Fp.ORDER,n:V.n,h:V.h,Gx:V.Gx,Gy:V.Gy},q=V.Fp;let Y=V.allowedPrivateKeyLengths?Array.from(new Set(V.allowedPrivateKeyLengths.map((K)=>Math.ceil(K/2)))):void 0;return{CURVE:X,curveOpts:{Fp:q,Fn:_1(X.n,{BITS:V.nBitLength,allowedLengths:Y,modFromBytes:V.wrapPrivateKey}),allowInfinityPoint:V.allowInfinityPoint,endo:V.endo,isTorsionFree:V.isTorsionFree,clearCofactor:V.clearCofactor,fromBytes:V.fromBytes,toBytes:V.toBytes}}}(W),Q={hmac:W.hmac,randomBytes:W.randomBytes,lowS:W.lowS,bits2int:W.bits2int,bits2int_modN:W.bits2int_modN};return{CURVE:G,curveOpts:J,hash:W.hash,ecdsaOpts:Q}},FQ=function(W){const{CURVE:G,curveOpts:J,hash:Q,ecdsaOpts:V}=KQ(W);return function(X,q){const Y=q.Point;return Object.assign({},q,{ProjectivePoint:Y,CURVE:Object.assign({},X,VW(Y.Fn.ORDER,Y.Fn.BITS))})}(W,UQ(PQ(G,J),Q,V))},I8=function(W,...G){let J=S7[W];if(J===void 0){const Q=B6(_7(W));J=H0(Q,Q),S7[W]=J}return B6(H0(J,...G))},I6=function(W){const{Fn:G,BASE:J}=$1,Q=i0(G,W),V=J.multiply(Q);return{scalar:E6(V.y)?Q:G.neg(Q),bytes:y6(V)}},HW=function(W){const G=O8;if(!G.isValidNot0(W))throw Error("invalid x: Fail if x \u2265 p");const J=G.create(W*W),Q=G.create(J*W+BigInt(7));let V=G.sqrt(Q);E6(V)||(V=G.neg(V));const X=$1.fromAffine({x:W,y:V});return X.assertValidity(),X},CW=function(...W){return $1.Fn.create(u1(I8("BIP0340/challenge",...W)))},y7=function(W){return I6(W).bytes},kQ=function(W,G,J=j8(32)){const{Fn:Q}=$1,V=r("message",W),{bytes:X,scalar:q}=I6(G),Y=r("auxRand",J,32),K=Q.toBytes(q^u1(I8("BIP0340/aux",Y))),P=I8("BIP0340/nonce",K,X,V),{bytes:U,scalar:C}=I6(P),F=CW(U,X,V),z=new Uint8Array(64);if(z.set(U,0),z.set(Q.toBytes(Q.create(C+F*q)),32),!$W(z,V,X))throw Error("sign: Invalid signature produced");return z},$W=function(W,G,J){const{Fn:Q,BASE:V}=$1,X=r("signature",W,64),q=r("message",G),Y=r("publicKey",J,32);try{const K=HW(u1(Y)),P=u1(X.subarray(0,32));if(!L6(P,T7,H1.p))return!1;const U=u1(X.subarray(32,64));if(!L6(U,T7,H1.n))return!1;const C=CW(Q.toBytes(P),y6(K),q),F=V.multiplyUnsafe(U).add(K.multiplyUnsafe(Q.neg(C))),{x:z,y:$}=F.toAffine();return!(F.is0()||!E6($)||z!==P)}catch(K){return!1}},P1=typeof globalThis=="object"&&("crypto"in globalThis)?globalThis.crypto:void 0,c7=(()=>typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function")(),aG=Array.from({length:256},(W,G)=>G.toString(16).padStart(2,"0")),B7=48,oG=57,j7=65,nG=70,L7=97,sG=102;class A6{}class l7 extends A6{constructor(W,G,J,Q){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=W,this.outputLen=G,this.padOffset=J,this.isLE=Q,this.buffer=new Uint8Array(W),this.view=K6(this.buffer)}update(W){$8(this),n0(W=N6(W));const{view:G,buffer:J,blockLen:Q}=this,V=W.length;for(let X=0;X<V;){const q=Math.min(Q-this.pos,V-X);if(q!==Q)J.set(W.subarray(X,X+q),this.pos),this.pos+=q,X+=q,this.pos===Q&&(this.process(G,0),this.pos=0);else{const Y=K6(W);for(;Q<=V-X;X+=Q)this.process(Y,X)}}return this.length+=W.length,this.roundClean(),this}digestInto(W){$8(this),function(U,C){n0(U);const F=C.outputLen;if(U.length<F)throw Error("digestInto() expects output buffer of length at least "+F)}(W,this),this.finished=!0;const{buffer:G,view:J,blockLen:Q,isLE:V}=this;let{pos:X}=this;G[X++]=128,M8(this.buffer.subarray(X)),this.padOffset>Q-X&&(this.process(J,0),X=0);for(let U=X;U<Q;U++)G[U]=0;(function(U,C,F,z){if(typeof U.setBigUint64=="function")return U.setBigUint64(C,F,z);const $=BigInt(32),x=BigInt(4294967295),g=Number(F>>$&x),T=Number(F&x),S=z?4:0,E=z?0:4;U.setUint32(C+S,g,z),U.setUint32(C+E,T,z)})(J,Q-8,BigInt(8*this.length),V),this.process(J,0);const q=K6(W),Y=this.outputLen;if(Y%4)throw Error("_sha2: outputLen should be aligned to 32bit");const K=Y/4,P=this.get();if(K>P.length)throw Error("_sha2: outputLen bigger than state");for(let U=0;U<K;U++)q.setUint32(4*U,P[U],V)}digest(){const{buffer:W,outputLen:G}=this;this.digestInto(W);const J=W.slice(0,G);return this.destroy(),J}_cloneInto(W){W||(W=new this.constructor),W.set(...this.get());const{blockLen:G,buffer:J,length:Q,finished:V,destroyed:X,pos:q}=this;return W.destroyed=X,W.finished=V,W.length=Q,W.pos=q,Q%G&&W.buffer.set(J),W}clone(){return this._cloneInto()}}var v0=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),WQ=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),g0=new Uint32Array(64);class i7 extends l7{constructor(W=32){super(64,W,8,!1),this.A=0|v0[0],this.B=0|v0[1],this.C=0|v0[2],this.D=0|v0[3],this.E=0|v0[4],this.F=0|v0[5],this.G=0|v0[6],this.H=0|v0[7]}get(){const{A:W,B:G,C:J,D:Q,E:V,F:X,G:q,H:Y}=this;return[W,G,J,Q,V,X,q,Y]}set(W,G,J,Q,V,X,q,Y){this.A=0|W,this.B=0|G,this.C=0|J,this.D=0|Q,this.E=0|V,this.F=0|X,this.G=0|q,this.H=0|Y}process(W,G){for(let C=0;C<16;C++,G+=4)g0[C]=W.getUint32(G,!1);for(let C=16;C<64;C++){const F=g0[C-15],z=g0[C-2],$=k0(F,7)^k0(F,18)^F>>>3,x=k0(z,17)^k0(z,19)^z>>>10;g0[C]=x+g0[C-7]+$+g0[C-16]|0}let{A:J,B:Q,C:V,D:X,E:q,F:Y,G:K,H:P}=this;for(let C=0;C<64;C++){const F=P+(k0(q,6)^k0(q,11)^k0(q,25))+((U=q)&Y^~U&K)+WQ[C]+g0[C]|0,z=(k0(J,2)^k0(J,13)^k0(J,22))+tG(J,Q,V)|0;P=K,K=Y,Y=q,q=X+F|0,X=V,V=Q,Q=J,J=F+z|0}var U;J=J+this.A|0,Q=Q+this.B|0,V=V+this.C|0,X=X+this.D|0,q=q+this.E|0,Y=Y+this.F|0,K=K+this.G|0,P=P+this.H|0,this.set(J,Q,V,X,q,Y,K,P)}roundClean(){M8(g0)}destroy(){this.set(0,0,0,0,0,0,0,0),M8(this.buffer)}}var B6=eG(()=>new i7);class v6 extends A6{constructor(W,G){super(),this.finished=!1,this.destroyed=!1,d7(W);const J=N6(G);if(this.iHash=W.create(),typeof this.iHash.update!="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const Q=this.blockLen,V=new Uint8Array(Q);V.set(J.length>Q?W.create().update(J).digest():J);for(let X=0;X<V.length;X++)V[X]^=54;this.iHash.update(V),this.oHash=W.create();for(let X=0;X<V.length;X++)V[X]^=106;this.oHash.update(V),M8(V)}update(W){return $8(this),this.iHash.update(W),this}digestInto(W){$8(this),n0(W,this.outputLen),this.finished=!0,this.iHash.digestInto(W),this.oHash.update(W),this.oHash.digestInto(W),this.destroy()}digest(){const W=new Uint8Array(this.oHash.outputLen);return this.digestInto(W),W}_cloneInto(W){W||(W=Object.create(Object.getPrototypeOf(this),{}));const{oHash:G,iHash:J,finished:Q,destroyed:V,blockLen:X,outputLen:q}=this;return W.finished=Q,W.destroyed=V,W.blockLen=X,W.outputLen=q,W.oHash=G._cloneInto(W.oHash),W.iHash=J._cloneInto(W.iHash),W}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var r7=(W,G,J)=>new v6(W,G).update(J).digest();r7.create=(W,G)=>new v6(W,G);var g6=BigInt(0),j6=BigInt(1),F6=(W)=>typeof W=="bigint"&&g6<=W,c1=(W)=>(j6<<BigInt(W))-j6,G0=BigInt(0),W0=BigInt(1),r0=BigInt(2),e7=BigInt(3),t7=BigInt(4),WW=BigInt(5),JQ=BigInt(7),JW=BigInt(8),GQ=BigInt(9),I7=BigInt(16),XQ=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"],k1=BigInt(0),a0=BigInt(1),k6=new WeakMap,UW=new WeakMap;class KW{constructor(W,G){this.BASE=W.BASE,this.ZERO=W.ZERO,this.Fn=W.Fn,this.bits=G}_unsafeLadder(W,G,J=this.ZERO){let Q=W;for(;G>k1;)G&a0&&(J=J.add(Q)),Q=Q.double(),G>>=a0;return J}precomputeWindow(W,G){const{windows:J,windowSize:Q}=Z6(G,this.bits),V=[];let X=W,q=X;for(let Y=0;Y<J;Y++){q=X,V.push(q);for(let K=1;K<Q;K++)q=q.add(X),V.push(q);X=q.double()}return V}wNAF(W,G,J){if(!this.Fn.isValid(J))throw Error("invalid scalar");let Q=this.ZERO,V=this.BASE;const X=Z6(W,this.bits);for(let q=0;q<X.windows;q++){const{nextN:Y,offset:K,isZero:P,isNeg:U,isNegF:C,offsetF:F}=N7(J,q,X);J=Y,P?V=V.add(R8(C,G[F])):Q=Q.add(R8(U,G[K]))}return A7(J),{p:Q,f:V}}wNAFUnsafe(W,G,J,Q=this.ZERO){const V=Z6(W,this.bits);for(let X=0;X<V.windows&&J!==k1;X++){const{nextN:q,offset:Y,isZero:K,isNeg:P}=N7(J,X,V);if(J=q,!K){const U=G[Y];Q=Q.add(P?U.negate():U)}}return A7(J),Q}getPrecomputes(W,G,J){let Q=k6.get(G);return Q||(Q=this.precomputeWindow(G,W),W!==1&&(typeof J=="function"&&(Q=J(Q)),k6.set(G,Q))),Q}cached(W,G,J){const Q=H6(W);return this.wNAF(Q,this.getPrecomputes(Q,W,J),G)}unsafe(W,G,J,Q){const V=H6(W);return V===1?this._unsafeLadder(W,G,Q):this.wNAFUnsafe(V,this.getPrecomputes(V,W,J),G,Q)}createCache(W,G){PW(G,this.bits),UW.set(W,G),k6.delete(W)}hasCache(W){return H6(W)!==1}}var g7=(W,G)=>(W+(W>=0?G:-G)/FW)/G,L0={Err:class extends Error{constructor(W=""){super(W)}},_tlv:{encode(W,G){const{Err:J}=L0;if(W<0||W>256)throw new J("tlv.encode: wrong tag");if(1&G.length)throw new J("tlv.encode: unpadded data");const Q=G.length/2,V=K8(Q);if(V.length/2&128)throw new J("tlv.encode: long form length too big");const X=Q>127?K8(V.length/2|128):"";return K8(W)+X+V+G},decode(W,G){const{Err:J}=L0;let Q=0;if(W<0||W>256)throw new J("tlv.encode: wrong tag");if(G.length<2||G[Q++]!==W)throw new J("tlv.decode: wrong tlv");const V=G[Q++];let X=0;if(128&V){const Y=127&V;if(!Y)throw new J("tlv.decode(long): indefinite length not supported");if(Y>4)throw new J("tlv.decode(long): byte length is too big");const K=G.subarray(Q,Q+Y);if(K.length!==Y)throw new J("tlv.decode: length bytes not complete");if(K[0]===0)throw new J("tlv.decode(long): zero leftmost byte");for(let P of K)X=X<<8|P;if(Q+=Y,X<128)throw new J("tlv.decode(long): not minimal encoding")}else X=V;const q=G.subarray(Q,Q+X);if(q.length!==X)throw new J("tlv.decode: wrong value length");return{v:q,l:G.subarray(Q+X)}}},_int:{encode(W){const{Err:G}=L0;if(W<R0)throw new G("integer: negative integers are not allowed");let J=K8(W);if(8&Number.parseInt(J[0],16)&&(J="00"+J),1&J.length)throw new G("unexpected DER parsing assertion: unpadded hex");return J},decode(W){const{Err:G}=L0;if(128&W[0])throw new G("invalid signature integer: negative");if(W[0]===0&&!(128&W[1]))throw new G("invalid signature integer: unnecessary leading zero");return C1(W)}},toSig(W){const{Err:G,_int:J,_tlv:Q}=L0,V=r("signature",W),{v:X,l:q}=Q.decode(48,V);if(q.length)throw new G("invalid signature: left bytes after parsing");const{v:Y,l:K}=Q.decode(2,X),{v:P,l:U}=Q.decode(2,K);if(U.length)throw new G("invalid signature: left bytes after parsing");return{r:J.decode(Y),s:J.decode(P)}},hexFromSig(W){const{_tlv:G,_int:J}=L0,Q=G.encode(2,J.encode(W.r))+G.encode(2,J.encode(W.s));return G.encode(48,Q)}},R0=BigInt(0),F1=BigInt(1),FW=BigInt(2),F8=BigInt(3),YQ=BigInt(4),H1={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},zQ={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},ZQ=BigInt(0),T7=BigInt(1),O6=BigInt(2),O8=_1(H1.p,{sqrt(W){const G=H1.p,J=BigInt(3),Q=BigInt(6),V=BigInt(11),X=BigInt(22),q=BigInt(23),Y=BigInt(44),K=BigInt(88),P=W*W*W%G,U=P*P*W%G,C=Y0(U,J,G)*U%G,F=Y0(C,J,G)*U%G,z=Y0(F,O6,G)*P%G,$=Y0(z,V,G)*z%G,x=Y0($,X,G)*$%G,g=Y0(x,Y,G)*x%G,T=Y0(g,K,G)*g%G,S=Y0(T,Y,G)*x%G,E=Y0(S,J,G)*U%G,O=Y0(E,q,G)*$%G,f=Y0(O,Q,G)*P%G,d=Y0(f,O6,G);if(!O8.eql(O8.sqr(d),W))throw Error("Cannot find square root");return d}}),kW=function(W,G){const J=(Q)=>FQ({...W,hash:Q});return{...J(G),create:J}}({...H1,Fp:O8,lowS:!0,endo:zQ},B6),S7={},y6=(W)=>W.toBytes(!0).slice(1),$1=(()=>kW.Point)(),E6=(W)=>W%O6===ZQ,u1=C1,p6=(()=>{const W=(G=j8(48))=>YW(G,H1.n);return kW.utils.randomSecretKey,{keygen(G){const J=W(G);return{secretKey:J,publicKey:y7(J)}},getPublicKey:y7,sign:kQ,verify:$W,Point:$1,utils:{randomSecretKey:W,randomPrivateKey:W,taggedHash:I8,lift_x:HW,pointToBytes:y6,numberToBytesBE:D8,bytesToNumberBE:C1,mod:P0},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})(),HQ=new TextEncoder,CQ=new TextDecoder,o0=(W)=>HQ.encode(W),C8=(W)=>CQ.decode(W),w6=(W)=>Array.from(W,(G)=>G.toString(16).padStart(2,"0")).join(""),O0=JSON.stringify,w8=JSON.parse,MW=(W,G=Number.MAX_SAFE_INTEGER)=>W.split("").reduce((J,Q)=>J+Q.charCodeAt(0),0)%G,f6="AES-GCM",$Q={},z8=(W)=>$Q[W]??=crypto.subtle.digest("SHA-1",o0(W)).then((G)=>{const J=new Uint8Array(G);let Q="";for(let V of J)Q+=V.toString(36);return Q}),MQ=async(W,G)=>{const J=crypto.getRandomValues(new Uint8Array(12)),Q=await W,V=await crypto.subtle.encrypt({name:f6,iv:J},Q,o0(G));return`${J.join(",")}\$${((X)=>{const q=new Uint8Array(X);let Y="";for(let K=0;K<q.length;K+=32768)Y+=String.fromCharCode(...q.subarray(K,K+32768));return btoa(Y)})(V)}`},BQ=async(W,G)=>{const[J,Q]=G.split("$");if(!J||!Q)throw Error("Invalid encrypted payload format");const V=Uint8Array.from(J.split(","),Number),X=await W,q=await crypto.subtle.decrypt({name:f6,iv:V},X,(Y=Q,Uint8Array.from(atob(Y),(K)=>K.charCodeAt(0)).buffer));var Y;return C8(q)},d1="GenosRTC",h6=(W,G)=>Array.from({length:W},G),jQ="0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz",x6=(W)=>Array.from(crypto.getRandomValues(new Uint8Array(W)),(G)=>jQ[G%62]).join(""),U1=x6(20),z1=Promise.all.bind(Promise),LQ=typeof window!="undefined",{entries:D6,fromEntries:BW,keys:RQ}=Object,c0=()=>{},_0=(W)=>Error(`${d1}: ${W}`),Z8=(...W)=>W.join("@"),E7="icegatheringstatechange",p7="offer",OQ=[...h6(3,(W,G)=>`stun:stun${G||""}.l.google.com:19302`),"stun:stun.cloudflare.com:3478"].map((W)=>({urls:W})),$6=(W,{rtcConfig:G,rtcPolyfill:J,turnConfig:Q})=>{const V=new(J||RTCPeerConnection)({iceServers:[...OQ,...Q||[]],...G}),X={};let q,Y=!1,K=!1;const P=(F)=>Object.assign(F,{binaryType:"arraybuffer",bufferedAmountLowThreshold:65535,onmessage(z){return X.data?.(z.data)},onopen(){return X.connect?.()},onclose(){return X.close?.()},onerror(z){return!z?.error?.message?.includes("User-Initiated Abort")&&X.error?.(z)}}),U=()=>Promise.race([new Promise((F)=>{const z=()=>{V.iceGatheringState==="complete"&&(V.removeEventListener(E7,z),F())};V.addEventListener(E7,z),z()}),new Promise((F)=>setTimeout(F,5000))]).then(()=>({type:V.localDescription.type,sdp:V.localDescription.sdp.replace(/a=ice-options:trickle\s\n/g,"")}));W?P(q=V.createDataChannel("data")):V.ondatachannel=({channel:F})=>P(q=F),V.onnegotiationneeded=async()=>{try{Y=!0,await V.setLocalDescription(),X.signal?.(await U())}catch(F){X.error?.(F)}finally{Y=!1}},V.onconnectionstatechange=()=>{["disconnected","failed","closed"].includes(V.connectionState)&&X.close?.()},V.ontrack=(F)=>{X.track?.(F.track,F.streams[0]),X.stream?.(F.streams[0])},V.onremovestream=(F)=>X.stream?.(F.stream),W&&!V.canTrickleIceCandidates&&V.onnegotiationneeded();const C=()=>V.getSenders();return{created:Date.now(),connection:V,get channel(){return q},get isDead(){return V.connectionState==="closed"},async signal(F){if(q?.readyState!=="open"||F.sdp?.includes("a=rtpmap"))try{if(F.type===p7){if(Y||V.signalingState!=="stable"&&!K){if(W)return;await z1([V.setLocalDescription({type:"rollback"}),V.setRemoteDescription(F)])}else await V.setRemoteDescription(F);await V.setLocalDescription();const z=await U();return X.signal?.(z),z}if(F.type==="answer"){K=!0;try{await V.setRemoteDescription(F)}finally{K=!1}}}catch(z){X.error?.(z)}},sendData(F){return q.send(F)},destroy(){q?.close(),V.close(),Y=K=!1},setHandlers(F){return Object.assign(X,F)},offerPromise:W?new Promise((F)=>X.signal=(z)=>z.type===p7&&F(z)):Promise.resolve(),addStream(F){return F.getTracks().forEach((z)=>V.addTrack(z,F))},removeStream(F){return C().filter((z)=>F.getTracks().includes(z.track)).forEach((z)=>V.removeTrack(z))},addTrack(F,z){return V.addTrack(F,z)},removeTrack(F){const z=C().find(($)=>$.track===F);z&&V.removeTrack(z)},replaceTrack(F,z){return C().find(($)=>$.track===F)?.replaceTrack(z)}}},IQ=Object.getPrototypeOf(Uint8Array),b1=16369,k8=255,f7="bufferedamountlow",K1=(W)=>"@_"+W,wQ=(W,G,J)=>{const Q={},V={},X={},q={},Y={},K={},P={},U={onPeerJoin:c0,onPeerLeave:c0,onPeerStream:c0,onPeerTrack:c0},C=(Z,H)=>(Z?Array.isArray(Z)?Z:[Z]:RQ(Q)).flatMap((B)=>{const L=Q[B];return L?H(B,L):(console.warn(`${d1}: no peer with id ${B} found`),[])}),F=(Z)=>{Q[Z]&&(delete Q[Z],delete q[Z],delete Y[Z],U.onPeerLeave(Z),G(Z))},z=(Z)=>{if(V[Z])return X[Z];if(!Z)throw _0("action type argument is required");const H=o0(Z);if(H.byteLength>12)throw _0(`Action type "${Z}" exceeds 12 bytes`);const B=new Uint8Array(12);B.set(H);let L=0;const v=async(M,D,y,p)=>{if(y&&typeof y!="object")throw _0("meta must be an object");if(M===void 0)throw _0("data cannot be undefined");const A=M instanceof Blob,b=A||M instanceof ArrayBuffer||M instanceof IQ,m=typeof M!="string";if(y&&!b)throw _0("meta only allowed with binary data");const h=b?new Uint8Array(A?await M.arrayBuffer():M):o0(m?O0(M):M),l=y?o0(O0(y)):null,c=Math.ceil(h.byteLength/b1)+(y?1:0)||1,U0=h6(c,(s,a)=>{const C0=a===c-1,T0=y&&a===0,l1=T0?l:h.subarray(y?(a-1)*b1:a*b1,y?a*b1:(a+1)*b1),$0=new Uint8Array(15+l1.byteLength);return $0.set(B),$0.set([L],12),$0.set([C0|T0<<1|b<<2|m<<3],13),$0.set([Math.round((a+1)/c*k8)],14),$0.set(l1,15),$0});return L=L+1&k8,z1(C(D,async(s,a)=>{const{channel:C0}=a;for(let T0=0;T0<c&&(C0.bufferedAmount>C0.bufferedAmountLowThreshold&&await new Promise((l1)=>{const $0=()=>{C0.removeEventListener(f7,$0),l1()};C0.addEventListener(f7,$0)}),Q[s]);T0++)a.sendData(U0[T0]),p?.(U0[T0][14]/k8,s,y)}))},w=(M)=>V[Z]={...V[Z],onComplete:M},N=(M)=>V[Z]={...V[Z],onProgress:M};return V[Z]={onComplete:c0,onProgress:c0,send:v,setOnComplete:w,setOnProgress:N},X[Z]||=[v,w,N]},$=async()=>{await I(""),await new Promise((Z)=>setTimeout(Z,99));for(let[Z,H]of D6(Q))H.destroy(),delete Q[Z];J()},[x,g]=z(K1("ping")),[T,S]=z(K1("pong")),[E,O]=z(K1("signal")),[f,d]=z(K1("stream")),[R,j]=z(K1("track")),[I,k]=z(K1("leave"));return W((Z,H)=>{Q[H]||(Q[H]=Z,Z.setHandlers({data(B){return((L,v)=>{const w=new Uint8Array(v),N=C8(w.subarray(0,12)).replaceAll("\0",""),[M]=w.subarray(12,13),[D]=w.subarray(13,14),[y]=w.subarray(14,15),p=w.subarray(15),A=!!(1&D),b=!!(2&D),m=!!(4&D),h=!!(8&D);if(!V[N])return void console.warn(`${d1}: received message with unregistered type (${N})`);const l=(q[L]||={})[N]||={},c=l[M]||={chunks:[]};if(b?c.meta=w8(C8(p)):c.chunks.push(p),V[N].onProgress(y/k8,L,c.meta),!A)return;const U0=new Uint8Array(c.chunks.reduce((s,a)=>s+a.byteLength,0));if(c.chunks.reduce((s,a)=>(U0.set(a,s),s+a.byteLength),0),delete l[M],m)V[N].onComplete(U0,L,c.meta);else{const s=C8(U0);V[N].onComplete(h?w8(s):s,L)}})(H,B)},stream(B){U.onPeerStream(B,H,K[H]),delete K[H]},track(B,L){U.onPeerTrack(B,L,H,P[H]),delete P[H]},signal(B){return E(B,H)},close(){return F(H)},error(B){console.error(B),F(H)}}),U.onPeerJoin(H))}),g((Z,H)=>T("",H)),S((Z,H)=>{Y[H]?.(),delete Y[H]}),O((Z,H)=>Q[H]?.signal(Z)),d((Z,H)=>K[H]=Z),j((Z,H)=>P[H]=Z),k((Z,H)=>F(H)),LQ&&addEventListener("beforeunload",$),{makeAction:z,leave:$,async ping(Z){if(!Z)throw _0("ping() must be called with target peer ID");const H=Date.now();return x("",Z),await new Promise((B)=>Y[Z]=B),Date.now()-H},getPeers(){return BW(D6(Q).map(([Z,H])=>[Z,H.connection]))},addStream(Z,H,B){return C(H,async(L,v)=>{B&&await f(B,L),v.addStream(Z)})},removeStream(Z,H){return C(H,(B,L)=>L.removeStream(Z))},addTrack(Z,H,B,L){return C(B,async(v,w)=>{L&&await R(L,v),w.addTrack(Z,H)})},removeTrack(Z,H){return C(H,(B,L)=>L.removeTrack(Z))},replaceTrack(Z,H,B,L){return C(B,async(v,w)=>{L&&await R(L,v),w.replaceTrack(Z,H)})},onPeerJoin(Z){return U.onPeerJoin=Z},onPeerLeave(Z){return U.onPeerLeave=Z},onPeerStream(Z){return U.onPeerStream=Z},onPeerTrack(Z){return U.onPeerTrack=Z}}},H8={},xQ=(W,G,J,Q)=>(W.relayUrls??(Q?((V,X)=>{const q=[...V];let Y=q.length;const K=()=>{const P=1e4*Math.sin(X++);return P-Math.floor(P)};for(;Y;){const P=Math.floor(K()*Y--);[q[Y],q[P]]=[q[P],q[Y]]}return q})(G,MW(W.appId)):G)).slice(0,W.relayUrls?.length??W.relayRedundancy??J),jW={},LW="EVENT",RW=p6.utils.randomSecretKey(),DQ=w6(p6.getPublicKey(RW)),b6={},m1={},NQ={},OW=()=>Math.floor(Date.now()/1000),IW=(W)=>NQ[W]??=MW(W,1e4)+20000,h7=async(W,G)=>{const J={kind:IW(W),content:G,pubkey:DQ,created_at:OW(),tags:[["x",W]]},Q=new Uint8Array(await crypto.subtle.digest("SHA-256",o0(O0([0,J.pubkey,J.created_at,J.kind,J.tags,J.content])))),V=p6.sign(Q,RW);return O0([LW,{...J,id:w6(Q),sig:w6(V)}])},b7=(W,G)=>(b6[W]=G,O0(["REQ",W,{kinds:[IW(G)],since:OW(),"#x":[G]}])),m7=(W)=>(delete b6[W],O0(["CLOSE",W])),m6=(({init:W,subscribe:G,announce:J})=>{const Q={};let V,X,q=!1;return(Y,K,P)=>{const{appId:U}=Y;if(Q[U]?.[K])return Q[U][K];if(!Y||!K||!U&&!Y.firebaseApp)throw _0(Y?K?"appId missing":"roomId required":"config required");let C=c0;if(!q){const k=W(Y);X=h6(20,()=>$6(!0,Y)),V=Array.isArray(k)?k:[k];const Z=setInterval(()=>{X=X.filter((H)=>{const B=Date.now()-H.created<57333;return B||H.destroy(),B})},57333);Q.offerCleanupTimer||=Z,q=!0}const F={},z={},$=Z8(d1,U,K),x=z8($),g=z8(Z8($,U1)),T=(async(k,Z,H)=>{const B=await crypto.subtle.digest("SHA-256",o0(`${k}:${Z}:${H}`));return crypto.subtle.importKey("raw",B,{name:f6},!1,["encrypt","decrypt"])})(Y.password||"",U,K),S=(k)=>async(Z)=>({type:Z.type,sdp:await k(T,Z.sdp)}),E=S(BQ),O=S(MQ),f=(k,Z)=>{z[Z]!==k&&(z[Z]?.destroy(),z[Z]=k,C(k,Z),F[Z]?.forEach((H)=>H!==k&&H.destroy()),delete F[Z])},d=(k,Z)=>{z[Z]===k&&delete z[Z]},R=z1(V.map(async(k,Z)=>{return G(await k,await x,await g,(H=Z,async(B,L,v)=>{const[w,N]=await z1([x,g]);if(B!==w&&B!==N)return;const{peerId:M,offer:D,answer:y,peer:p}=typeof L=="string"?w8(L):L;if(M!==U1&&!z[M])if(D){if(F[M]?.[H]&&U1>M)return;const A=$6(!1,Y);A.setHandlers({connect(){return f(A,M)},close(){return d(A,M)}});try{const b=await E(D);if(A.isDead)return;const[m,h]=await z1([z8(Z8($,M)),A.signal(b).then(O)]);v(m,O0({peerId:U1,answer:h}))}catch{P?.({error:"decryption failed (offer)",appId:U,peerId:M,roomId:K})}}else if(y){const A=p||F[M]?.[H];if(!A||A.isDead)return;A.setHandlers({connect(){return f(A,M)},close(){return d(A,M)}});try{A.signal(await E(y))}catch{P?.({error:"decryption failed (answer)",appId:U,peerId:M,roomId:K})}}else{if(F[M]?.[H])return;const A=X.pop()||$6(!0,Y),[b,{offer:m}]=await z1([z8(Z8($,M)),A.offerPromise.then(O).then((h)=>({offer:h}))]);F[M]||=[],F[M][H]=A,A.setHandlers({connect(){return f(A,M)},close(){return d(A,M)}}),v(b,O0({peerId:U1,offer:m,peer:A}))}}));var H})),j=[];R.then((k)=>{V.forEach((Z,H)=>{const B=async()=>{const L=await J(await Z,await x,await g);j[H]=setTimeout(B,typeof L=="number"?L:5333)};B()}),Q[U][K].onCleanup=()=>{delete Q[U][K],j.forEach(clearTimeout),k.forEach((Z)=>Z()),Object.keys(Q).length===0&&(clearInterval(Q.offerCleanupTimer),delete Q.offerCleanupTimer)}}),Q[U]||={};const I=wQ((k)=>C=k,(k)=>delete z[k],()=>I.onCleanup?.());return Q[U][K]=I}})({init(W){return xQ(W,AQ,5,!0).map((G)=>{const J=((Q,V)=>{const X={},q=()=>{const Y=new WebSocket(Q);Y.onclose=()=>{H8[Q]??=3333,setTimeout(q,H8[Q]),H8[Q]*=2},Y.onmessage=(K)=>V(K.data),X.socket=Y,X.url=Y.url,X.ready=new Promise((K)=>{Y.onopen=()=>{H8[Q]=3333,K(X)}}),X.send=(K)=>{Y.readyState===1&&Y.send(K)}};return q(),X})(G,(Q)=>{const[V,X,q,Y]=w8(Q);if(V===LW)m1[X]?.(b6[X],q.content);else{const K=`${d1}: relay failure from ${J.url} - `;V==="NOTICE"?console.warn(K+X):V!=="OK"||q||console.warn(K+Y)}});return jW[G]=J,J.ready})},subscribe(W,G,J,Q){const V=x6(64),X=x6(64);return m1[V]=m1[X]=(q,Y)=>Q(q,Y,async(K,P)=>W.send(await h7(K,P))),W.send(b7(V,G)),W.send(b7(X,J)),()=>{W.send(m7(V)),W.send(m7(X)),delete m1[V],delete m1[X]}},async announce(W,G){return W.send(await h7(G,O0({peerId:U1})))}}),HV=(u7=jW,()=>BW(D6(u7).map(([W,G])=>[W,G.socket]))),u7,AQ=["black.nostrcity.club","eu.purplerelay.com","ftp.halifax.rwth-aachen.de/nostr","nostr.cool110.xyz","nostr.data.haus","nostr.mom","nostr.oxtr.dev","nostr.sathoarder.com","nostr.vulpem.com","playground.nostrcheck.me/relay","relay.agorist.space","relay.binaryrobot.com","relay.fountain.fm","relay.mostro.network","relay.nostraddress.com","relay.nostrdice.com","relay.nostromo.social","relay.oldenburg.cool","relay.snort.social","relay.verified-nostr.com","sendit.nosflare.com","yabu.me/v2","relay.damus.io"].map((W)=>"wss://"+W);var wW=(W,G,J)=>{let Q=G.timestamp;if(G.timestamp&&typeof G.timestamp.physical==="number"){const q=Date.now()+7200000;if(G.timestamp.physical>q)Q={physical:q,logical:G.timestamp.logical}}if(!W||!W.timestamp)return{resolved:!0,value:G.value,timestamp:Q};const V=W.timestamp;if(J.compare(V,Q)<0)return{resolved:!0,value:G.value,timestamp:Q};return{resolved:!1}};class u6{constructor(W,G=50){this.key=`gdb_oplog_${W}`,this.maxSize=G,this.log=this._load()}_load(){try{const W=localStorage.getItem(this.key);return W?JSON.parse(W):[]}catch(W){return console.error("Failed to load oplog from localStorage:",W),[]}}_save(){try{localStorage.setItem(this.key,JSON.stringify(this.log))}catch(W){console.error("Failed to save oplog to localStorage:",W)}}add(W){if(this.log.push(W),this.log.length>this.maxSize)this.log.shift();this._save()}getDelta(W,G){if(!W)return[...this.log];return this.log.filter((J)=>G(J.timestamp,W)>0)}getOldest(){return this.log[0]}clear(){this.log=[],localStorage.removeItem(this.key)}}var vQ=()=>{const W=new Map,G=async()=>{try{const K=await navigator.storage.getDirectory(),U=await(await K.getFileHandle("~opfs-sync-test",{create:!0})).createSyncAccessHandle?.();return await U?.close(),await K.removeEntry("~opfs-sync-test"),!!U}catch{return!1}};let J="idb";const Q=(async()=>{if(await G())J="sync";else try{const K=await navigator.storage.getDirectory(),U=await(await K.getFileHandle("~opfs-async-test",{create:!0})).createWritable?.();if(await U?.close(),await K.removeEntry("~opfs-async-test"),U)J="async";else J="idb"}catch{J="idb"}})(),V=async(K,P)=>{if(!W.has(K))W.set(K,[]);const U=W.get(K),C=U[U.length-1]||Promise.resolve();let F;const z=new Promise(($)=>F=$);U.push(z);try{return await C,await P()}finally{if(U.shift(),F(),U.length===0)W.delete(K)}},X=(()=>{let K;const P=async()=>{if(!K)K=new Promise((U,C)=>{const F=indexedDB.open("opfs-fallback-db",1);F.onupgradeneeded=()=>F.result.createObjectStore("files"),F.onsuccess=()=>U(F.result),F.onerror=()=>C(F.error)});return K};return{getDB:P,get:async(U)=>{const C=await P();return new Promise((F,z)=>{const x=C.transaction("files","readonly").objectStore("files").get(U);x.onsuccess=()=>F(x.result||new Uint8Array),x.onerror=()=>z(x.error)})},set:async(U,C)=>{const F=await P();return new Promise((z,$)=>{const g=F.transaction("files","readwrite").objectStore("files").put(C,U);g.onsuccess=()=>z(),g.onerror=()=>$(g.error)})}}})(),q=async(K)=>{await Q;try{if(J==="idb"){const z=await X.get(K);return{type:"loaded",name:K,data:z}}const U=await(await navigator.storage.getDirectory()).getFileHandle(K);if(J==="sync"){let z;try{z=await U.createSyncAccessHandle();const $=z.getSize(),x=new Uint8Array($),g=z.read(x,{at:0});return{type:"loaded",name:K,data:x.slice(0,g)}}finally{z?.close()}}const C=await U.getFile(),F=new Uint8Array(await C.arrayBuffer());return{type:"loaded",name:K,data:F}}catch(P){const U=P.name==="NotFoundError"?"File not found":P.message||"Error reading file";return{type:"error",name:K,message:U}}},Y=async(K,P)=>{if(await Q,!(P instanceof Uint8Array))return{type:"error",name:K,message:"Content must be a Uint8Array"};return V(K,async()=>{try{if(J==="idb")return await X.set(K,P),{type:"saved",name:K};const C=await(await navigator.storage.getDirectory()).getFileHandle(K,{create:!0});if(J==="sync"){let F;try{F=await C.createSyncAccessHandle(),F.truncate(0),F.write(P,{at:0}),F.flush()}finally{F?.close()}}else{let F;try{F=await C.createWritable(),await F.write(P)}finally{await F?.close()}}return{type:"saved",name:K}}catch(U){return{type:"error",name:K,message:U.message||"Error saving file"}}})};self.onmessage=async({data:K})=>{const{type:P,name:U,content:C}=K;await Q;const F={load:()=>q(U),save:()=>Y(U,C)};try{const z=F[P],$=z?await z():{type:"error",message:`Unrecognized action type: ${P}`};self.postMessage($)}catch(z){console.error("Worker unexpected error:",z),self.postMessage({type:"error",name:U,message:z.message||"Unexpected worker error"})}}},xW=vQ;var s0={$eq:(W,G)=>W===G,$ne:(W,G)=>W!==G,$gt:(W,G)=>W>G,$gte:(W,G)=>W>=G,$lt:(W,G)=>W<G,$lte:(W,G)=>W<=G,$in:(W,G)=>Array.isArray(G)&&G.includes(W),$between:(W,[G,J])=>W>=G&&W<=J,$exists:(W,G)=>G?W!==void 0:W===void 0,$text:{global:(W,G)=>{const J=(V)=>String(V).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^\w\s]/g,""),Q=J(G);return Object.values(W).some((V)=>{if(typeof V==="object")return null.fieldSearch(V,Q);return J(V).includes(Q)})},field:(W,G)=>{const J=(Q)=>String(Q).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^\w\s]/g,"");return Array.isArray(W)?W.some((Q)=>J(Q).includes(J(G))):J(W).includes(J(G))}},$like:(W,G)=>{if(typeof W!=="string"||typeof G!=="string")return!1;return new RegExp(`^${G.replace(/%/g,".*").replace(/_/g,".")}\$`,"i").test(W)},$regex:(W,G)=>typeof W==="string"&&new RegExp(G.$regex||G,"i").test(W),$and:(W,G,J)=>G.every((Q)=>{return J.createFilter(Q,J.allNodes)(W)}),$or:(W,G,J)=>G.some((Q)=>{return J.createFilter(Q,J.allNodes)(W)}),$not:(W,G,J)=>{return!J.createFilter(G,J.allNodes)(W)},$edge:(W,G,J)=>{if(typeof G!=="object"||G===null||!W.edges?.length)return!1;const Q=J.createFilter(G,J.allNodes),V=[],X=[...W.edges],q=new Set(X);q.add(W.id);while(X.length>0){const Y=X.shift(),K=J.allNodes[Y];if(!K)continue;if(Q(K))V.push(K);K.edges?.forEach((P)=>{if(!q.has(P))q.add(P),X.push(P)})}if(V.length>0)W._edgeResult=V;return V.length>0}},d6=(W,G)=>{const J=G.split(".");let Q=W;for(let V of J)if(Q&&typeof Q==="object"&&(V in Q))Q=Q[V];else return;return Q},N8=(W,G)=>{const J=(Q)=>{if(Object.keys(W).length===0)return!0;return Object.entries(W).every(([V,X])=>{if(V.startsWith("$"))return s0[V](Q,X,{filterNode:J,createFilter:N8,allNodes:G});const q=d6(Q.value,V);if(typeof X!=="object"||X===null)return s0.$eq(q,X);return Object.entries(X).every(([Y,K])=>{if(Y==="$text")return s0.$text.field(q,K);if(Y==="$between"&&K.every((P)=>P instanceof Date)){const P=new Date(q);return s0.$between(P,K)}return s0[Y]?.(q,K,{filterNode:J,createFilter:N8,allNodes:G})??!1})})};return J},gQ=(W,G)=>{let J=[...W];if(G.field)J.sort((Q,V)=>{const X=d6(Q.value,G.field),q=d6(V.value,G.field),Y=G.order==="asc"?1:-1;if(typeof X==="string"&&typeof q==="string")return X.localeCompare(q)*Y;return((X??0)-(q??0))*Y});if(G.$after){const Q=J.findIndex((V)=>V.id===G.$after);J=Q>=0?J.slice(Q+1):[]}if(G.$before){const Q=J.findIndex((V)=>V.id===G.$before);J=Q>=0?J.slice(0,Q):[]}return G.$limit?J.slice(0,G.$limit):J},c6=(W,G)=>{const{$edge:J,...Q}=G.query||{},V=J!==void 0,X=N8(Q,W),q=Object.values(W).filter(X),Y=V?(()=>{const K=N8({$edge:J},W);q.forEach((U)=>K(U));const P=new Map;return q.forEach((U)=>{if(U._edgeResult)U._edgeResult.forEach((C)=>P.set(C.id,C)),delete U._edgeResult}),Array.from(P.values())})():q;return gQ(Y,G)};class _6{constructor(){this.physical=Date.now(),this.logical=0}now(){const W=Date.now();return this.physical=Math.max(this.physical,W),this.logical++,{physical:this.physical,logical:this.logical}}update(W){if(!W||typeof W.physical!=="number"||typeof W.logical!=="number")return;this.physical=Math.max(this.physical,W.physical),this.logical=Math.max(this.logical,W.logical)+1}compare(W,G){if(!W&&!G)return 0;if(!W)return-1;if(!G)return 1;if(W.physical>G.physical)return 1;if(W.physical<G.physical)return-1;if(W.logical>G.logical)return 1;if(W.logical<G.logical)return-1;return 0}}var DW=function(W,G){return W.length===G.length&&W.every((J,Q)=>J===G[Q])};async function TQ(){console.info(navigator?.storage?.getDirectory?"\u2705 OPFS is enabled.":"\uD83D\uDEAB OPFS is not available."),navigator?.storage?.getDirectory&&await navigator.storage.getDirectory()}if(Symbol.dispose===void 0)Object.defineProperty(Symbol,"dispose",{value:Symbol.for("Symbol.dispose")});class NW{constructor(){this.nodes={}}upsert(W,G,J){this.nodes[W]={id:W,value:G,edges:[],timestamp:J}}get(W){return this.nodes[W]||null}link(W,G,J){const Q=this.nodes[W],V=this.nodes[G];if(Q&&V&&!Q.edges.includes(G))Q.edges.push(G),Q.timestamp=J}getAllNodes(){return Object.values(this.nodes)}serialize(){return d0.deflate(I0(this.nodes))}deserialize(W){this.nodes=s1(d0.inflate(new Uint8Array(W)))}}class A8{static _listenersInitialized=!1;constructor(W,{password:G,securityManager:J=null,relayUrls:Q=null}={}){if(console.info("\u26A1 GenosDB: Empowering distributed graph databases with real-time synchronization and scalability. Learn more: https://github.com/estebanrfp/gdb \u26A1"),this.oplog=new u6(W,20),this.hybridClock=new _6,this.name=W,this.password=G,this.globalTimestamp=null,this.graph=new NW,this.securityManager=J,!this.securityManager||typeof this.securityManager.verifyIncomingOperations!=="function")console.info("\u26A0\uFE0F SecurityManager inactive!"),console.info("\u27A1\uFE0F Processing P2P data directly.");else console.info("\uD83D\uDD12 GDB: SecurityManager active!"),console.info("\u27A1\uFE0F Verifying incoming operations with SecurityManager.");this.eventListeners=[],this.operators=s0,this.initWorker(),this.ready=this.loadGraphFromOPFS(),this.loadGlobalTimestamp();const V=`graph-sync-room-${this.name}`,X={appId:"1234",...this.password&&{password:this.password}};if(Q)X.relayUrls=Q;const q=m6(X,V),[Y,K]=q.makeAction("syncGraph");this.sendData=Y;const P=m6(X,`app-sync-${this.name}`);if(this.room=P,!A8._listenersInitialized)A8._listenersInitialized=!0,window.addEventListener("online",async()=>{console.log("\u2705 Reconnected to the network."),this.sendData([{type:"sync",timestamp:this.globalTimestamp}])}),window.addEventListener("offline",async()=>{console.log("\u274C Disconnected from the network.")}),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="visible")console.log("\uD83D\uDD04 The tab is visible again."),this.sendData([{type:"sync",timestamp:this.globalTimestamp}]);else if(document.visibilityState==="hidden")console.log("\uD83D\uDED1 The tab is no longer visible.")});TQ(),q.onPeerJoin(async(U)=>{console.info("\u26A1 New peer connected:",U),this.sendData([{type:"sync",timestamp:this.globalTimestamp}])}),q.onPeerLeave((U)=>{console.info("\u26A1 Peer disconnected:",U)}),K(async(U)=>{if(this.securityManager&&typeof this.securityManager.verifyIncomingOperations==="function"){const{validatedOperations:C}=await this.securityManager.verifyIncomingOperations(U);if(C&&C.length>0)await this.receiveChanges(C)}else await this.receiveChanges(U),this.emit()}),this.channel=new BroadcastChannel(`graphdb_sync_${this.name}`),this.channel.onmessage=async(U)=>{if(U.data==="update")console.info("\uD83D\uDD04 Update received from another tab..."),await this.loadGraphFromOPFS(),this.loadGlobalTimestamp(),this.emit()}}loadGlobalTimestamp(){const W=localStorage.getItem(`${this.name}_time`);this.globalTimestamp=W?JSON.parse(W):null}saveGlobalTimestamp(W){this.globalTimestamp=W,localStorage.setItem(`${this.name}_time`,JSON.stringify(W))}initWorker(){try{const W=URL.createObjectURL(new Blob([`(${xW.toString()})()`],{type:"application/javascript"}));this.worker=new Worker(W),this.worker.addEventListener("message",({data:G})=>{console.info(`\uD83D\uDCBE ${G.name} ${G.type}`),URL.revokeObjectURL(W)}),console.info("\u2699\uFE0F Worker initialized successfully.")}catch({message:W}){console.error("\u274C Failed to initialize worker:",W)}}getWorker(){return this.worker}emit(){this.eventListeners.forEach((W)=>W(this.graph.nodes))}compress(W){return d0.deflate(W)}decompress(W){return d0.inflate(W)}async getAllNodes(){return await this.ready,this.graph.getAllNodes()}async generateHash(){return crypto.randomUUID()}async hashValue(W){const G=(new TextEncoder()).encode(W),J=await crypto.subtle.digest("SHA-256",G);return Array.from(new Uint8Array(J)).map((Q)=>Q.toString(16).padStart(2,"0")).join("")}async loadGraphFromOPFS(){try{const G=await((J)=>new Promise((Q,V)=>{const X=async({data:q})=>{if(q.type==="loaded"&&q.name===J)this.worker.removeEventListener("message",X),Q(new Uint8Array(q.data));else if(q.type==="error")this.worker.removeEventListener("message",X),V(new Error(q.message||"Unknown error"))};this.worker.addEventListener("message",X),this.worker.postMessage({type:"load",name:J})}))(`${this.name}_graph.msgpack`).catch(()=>new Uint8Array);G.byteLength>0?this.graph.deserialize(G):console.warn("\u26A0\uFE0F The file '_graph.msgpack' is empty or could not be loaded."),console.info(`\u2705 Graph loaded: [ ${this.graph.getAllNodes().length} nodes ]`)}catch({message:W}){console.error("\u274C Error loading the graph:",W)}}async saveGraphToOPFS(){try{const W=this.graph.serialize();return await((J,Q)=>new Promise((V,X)=>{const q=({data:Y})=>{if(Y.type==="saved"&&Y.name===J)this.worker.removeEventListener("message",q),V();else if(Y.type==="error")this.worker.removeEventListener("message",q),X(new Error(Y.message||"Save error"))};this.worker.addEventListener("message",q),this.worker.postMessage({type:"save",name:J,content:Q})}))(`${this.name}_graph.msgpack`,W),this.channel.postMessage("update"),!0}catch({message:W}){throw console.error("\u274C Save error:",W),new Error("Save failed")}}async put(W,G){await this.ready;const J=this.hybridClock.now();return this.saveGlobalTimestamp(J),G??=await this.generateHash(),this.graph.upsert(G,W,J),this.oplog.add({type:"upsert",id:G,timestamp:J}),await this.saveGraphToOPFS(),await this.sendData([{type:"upsert",id:G,value:W,timestamp:J}]),this.emit(),G}async get(W,G=null){if(await this.ready,typeof W!=="string")return{result:null};const J=this.graph.get(W);if(!J){if(G)G(null);return{result:null}}const Q=(q)=>{if(!q)return null;const Y=q.value!==null&&typeof q.value==="object"?{...q.value}:q.value;return{...q,value:Y}};if(!G)return{result:Q(J)};let V=J.timestamp;G(Q(J));const X=(q)=>{const Y=q[W];if(Y){if(this.hybridClock.compare(Y.timestamp,V)>0)V=Y.timestamp,G(Q(Y))}else G(null),this.eventListeners.splice(this.eventListeners.indexOf(X),1)};return this.eventListeners.push(X),{result:Q(J),unsubscribe:()=>{const q=this.eventListeners.indexOf(X);if(q>-1)this.eventListeners.splice(q,1)}}}async map(...W){await this.ready;let J={...{realtime:!1,query:{},field:null,order:"asc",$limit:null,$after:null,$before:null}},Q=null,V=!1;W.forEach((K)=>typeof K==="function"?Q=K:K&&typeof K==="object"&&(V||=("realtime"in K),Object.assign(J,K))),Q&&!V&&(J.realtime=!0);let X=c6(this.graph.nodes,J),q=null;const Y=(K)=>{const P=K.filter((z)=>!X.some(($)=>$.id===z.id)),U=X.filter((z)=>!K.some(($)=>$.id===z.id)),C=K.filter((z)=>{const $=X.find((x)=>x.id===z.id);return $&&!DW(I0(z.value),I0($.value))}),F=(z,$)=>{const x=$==="removed"?null:z.value,g={id:z.id,value:x,edges:z.edges||[],timestamp:z.timestamp||null,action:$};Q(g)};P.forEach((z)=>F(z,"added")),U.forEach((z)=>F(z,"removed")),C.forEach((z)=>F(z,"updated"))};if(Q){if(X.forEach((K)=>{if(K.value)Q({id:K.id,value:K.value,edges:K.edges,timestamp:K.timestamp,action:"initial"})}),J.realtime)q=(K)=>{const P=c6(K,J);if(!DW(I0(P),I0(X)))Y(P),X=P},this.eventListeners.push(q)}return{results:X,...J.realtime&&Q&&q&&{unsubscribe:()=>{const K=this.eventListeners.indexOf(q);K>-1&&this.eventListeners.splice(K,1)}}}}async remove(W){await this.ready;const G=this.hybridClock.now(),J=this.graph.get(W);if(!J)return console.warn(`\u26A0\uFE0F Node with ID '${W}' not found.`);delete this.graph.nodes[W],this.oplog.add({type:"remove",id:W,timestamp:G}),Object.values(this.graph.nodes).forEach((Q)=>Q.edges=Q.edges.filter((V)=>V!==W)),await this.saveGraphToOPFS(),this.saveGlobalTimestamp(G),await this.sendData([{type:"remove",id:W,value:J.value,timestamp:G}]),this.emit()}async clear(){await this.ready,this.graph.nodes={};try{await(await navigator.storage.getDirectory()).removeEntry(`${this.name}_graph.msgpack`)}catch({message:W}){console.warn(`\u26A0\uFE0F Error deleting _graph.msgpack: ${W}`)}this.emit(),console.info("\u2705 All data has been deleted.")}async link(W,G){await this.ready;const J=this.hybridClock.now();if(!this.graph.nodes[W]||!this.graph.nodes[G]){console.warn(`\u26A0\uFE0F One or both nodes (${W}, ${G}) do not exist.`);return}this.graph.link(W,G,J),this.oplog.add({type:"link",sourceId:W,targetId:G,timestamp:J}),await this.saveGraphToOPFS(),this.saveGlobalTimestamp(J),await this.sendData([{type:"link",sourceId:W,targetId:G,timestamp:J}]),this.emit()}async applyFullGraph(W){try{console.info("\uD83D\uDD04 Applying full graph from remote..."),this.graph.nodes={...W.nodes},await this.saveGraphToOPFS()}catch({message:G}){console.error(`\u274C Error applying the full graph: ${G}`)}}async receiveChanges(W){let G=!1,J=null;const Q={upsert:(V)=>{const X=this.graph.get(V.id),q=wW(X,V,this.hybridClock);if(q.resolved){if(this.graph.upsert(V.id,q.value,q.timestamp),this.hybridClock.update(q.timestamp),this.oplog.add({type:"upsert",id:V.id,timestamp:q.timestamp}),G=!0,!J||this.hybridClock.compare(q.timestamp,J)>0)J=q.timestamp}},remove:(V)=>{const X=this.graph.get(V.id);if(X&&this.hybridClock.compare(X.timestamp,V.timestamp)<0){if(delete this.graph.nodes[V.id],this.hybridClock.update(V.timestamp),this.oplog.add({type:"remove",id:V.id,timestamp:V.timestamp}),G=!0,!J||this.hybridClock.compare(V.timestamp,J)>0)J=V.timestamp}},link:(V)=>{const X=this.graph.get(V.sourceId),q=this.graph.get(V.targetId);if(X&&q&&this.hybridClock.compare(X.timestamp,V.timestamp)<0){if(this.graph.link(V.sourceId,V.targetId,V.timestamp),this.hybridClock.update(V.timestamp),this.oplog.add({type:"link",sourceId:V.sourceId,targetId:V.targetId,timestamp:V.timestamp}),G=!0,!J||this.hybridClock.compare(V.timestamp,J)>0)J=V.timestamp}},sync:async(V)=>{const X=V.timestamp;console.info("\uD83D\uDCEC [SYNC REQUEST] since:",new Date(X.physical).toLocaleString());const q=this.oplog.getOldest();if(q&&X&&this.hybridClock.compare(X,q.timestamp)<0){console.info("\uD83D\uDCA5 [FALLBACK TRIGGERED] Peer is too far behind. Sending FULL graph state."),await this.sendData([{type:"syncReceive",graph:this.graph}]);return}const Y=this.oplog.getDelta(X,this.hybridClock.compare);if(Y.length>0){const K=Y.map((U)=>{if(U.type==="upsert"){const C=this.graph.get(U.id);return{...U,value:C?C.value:null}}return U}),P=d0.deflate(I0(K));console.info("\uD83D\uDCE6 [DELTA SYNC COMPRESSING] Delta compressed for transport."),console.info(`\uD83D\uDE80 [DELTA SYNC SENDING] Found ${Y.length} new operations to send.`),await this.sendData([{type:"deltaSync",operations:P}])}else console.info("\u2705 [ALREADY SYNCED] Peer is up-to-date. Nothing to send.")},deltaSync:(V)=>{console.info("\uD83D\uDEF0\uFE0F [DELTA SYNC RECEIVED] Compressed delta sync received.");let X=s1(d0.inflate(V.operations));console.info("\uD83D\uDEF0\uFE0F [DELTA SYNC DECOMPRESSING] Decompressing delta..."),console.info(`\uD83D\uDEF0\uFE0F [DELTA SYNC APPLYING] Applying ${X.length} operations from a peer.`);for(let q of X)Q[q.type]?.(q)},syncReceive:async(V)=>{if(console.info("\uD83D\uDCE6 [FULL SYNC RECEIVED] Overwriting local state with full graph from a peer."),V.graph)await this.applyFullGraph(V.graph),this.oplog.clear(),console.info("\uD83D\uDD12 Oplog has been cleared due to full sync."),G=!0;else console.error("\u274C Full sync failed: received graph data is invalid.",V.graph)}};for(let V of W)if(Q[V.type])await Q[V.type](V);else console.warn(`\uD83E\uDD37\u200D\u2640\uFE0F [UNKNOWN MESSAGE TYPE] Received unhandled message type: "${V.type}"`);if(J)console.info("\uD83D\uDCC8 [LOCAL TIMESTAMP] Updated."),this.saveGlobalTimestamp(J);if(G)console.info("\uD83D\uDCBE [STATE CHANGED] Saving state and emitting update."),await this.saveGraphToOPFS(),this.emit()}}export{A8 as default};