genosdb 0.6.4 → 0.6.6

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/index.js CHANGED
@@ -1 +1 @@
1
- function r6(W){const Q=W.length;let J=0,V=0;while(V<Q){let G=W.charCodeAt(V++);if((G&4294967168)===0){J++;continue}else if((G&4294965248)===0)J+=2;else{if(G>=55296&&G<=56319){if(V<Q){const X=W.charCodeAt(V);if((X&64512)===56320)++V,G=((G&1023)<<10)+(X&1023)+65536}}if((G&4294901760)===0)J+=3;else J+=4}}return J}function SW(W,Q,J){const V=W.length;let G=J,X=0;while(X<V){let Y=W.charCodeAt(X++);if((Y&4294967168)===0){Q[G++]=Y;continue}else if((Y&4294965248)===0)Q[G++]=Y>>6&31|192;else{if(Y>=55296&&Y<=56319){if(X<V){const q=W.charCodeAt(X);if((q&64512)===56320)++X,Y=((Y&1023)<<10)+(q&1023)+65536}}if((Y&4294901760)===0)Q[G++]=Y>>12&15|224,Q[G++]=Y>>6&63|128;else Q[G++]=Y>>18&7|240,Q[G++]=Y>>12&63|128,Q[G++]=Y>>6&63|128}Q[G++]=Y&63|128}}function yW(W,Q,J){TW.encodeInto(W,Q.subarray(J))}function o6(W,Q,J){if(W.length>AW)yW(W,Q,J);else SW(W,Q,J)}function v8(W,Q,J){let V=Q;const G=V+J,X=[];let Y="";while(V<G){const q=W[V++];if((q&128)===0)X.push(q);else if((q&224)===192){const U=W[V++]&63;X.push((q&31)<<6|U)}else if((q&240)===224){const U=W[V++]&63,P=W[V++]&63;X.push((q&31)<<12|U<<6|P)}else if((q&248)===240){const U=W[V++]&63,P=W[V++]&63,F=W[V++]&63;let C=(q&7)<<18|U<<12|P<<6|F;if(C>65535)C-=65536,X.push(C>>>10&1023|55296),C=56320|C&1023;X.push(C)}else X.push(q);if(X.length>=EW)Y+=String.fromCharCode(...X),X.length=0}if(X.length>0)Y+=String.fromCharCode(...X);return Y}function hW(W,Q,J){const V=W.subarray(Q,Q+J);return pW.decode(V)}function n6(W,Q,J){if(J>fW)return hW(W,Q,J);else return v8(W,Q,J)}var TW=new TextEncoder,AW=50,EW=4096,pW=new TextDecoder,fW=200;class W1{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 a6(W,Q,J){const V=J/4294967296,G=J;W.setUint32(Q,V),W.setUint32(Q+4,G)}function o1(W,Q,J){const V=Math.floor(J/4294967296),G=J;W.setUint32(Q,V),W.setUint32(Q+4,G)}function n1(W,Q){const J=W.getInt32(Q),V=W.getUint32(Q+4);return J*4294967296+V}function s6(W,Q){const J=W.getUint32(Q),V=W.getUint32(Q+4);return J*4294967296+V}var J1=4294967295;function dW({sec:W,nsec:Q}){if(W>=0&&Q>=0&&W<=uW)if(Q===0&&W<=mW){const J=new Uint8Array(4);return new DataView(J.buffer).setUint32(0,W),J}else{const J=W/4294967296,V=W&4294967295,G=new Uint8Array(8),X=new DataView(G.buffer);return X.setUint32(0,Q<<2|J&3),X.setUint32(4,V),G}else{const J=new Uint8Array(12),V=new DataView(J.buffer);return V.setUint32(0,Q),o1(V,4,W),J}}function cW(W){const Q=W.getTime(),J=Math.floor(Q/1000),V=(Q-J*1000)*1e6,G=Math.floor(V/1e9);return{sec:J+G,nsec:V-G*1e9}}function _W(W){if(W instanceof Date){const Q=cW(W);return dW(Q)}else return null}function iW(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),V=Q.getUint32(4),G=(J&3)*4294967296+V,X=J>>>2;return{sec:G,nsec:X}}case 12:{const J=n1(Q,4),V=Q.getUint32(0);return{sec:J,nsec:V}}default:throw new e(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${W.length}`)}}function lW(W){const Q=iW(W);return new Date(Q.sec*1000+Q.nsec/1e6)}var bW=-1,mW=4294967295,uW=17179869183,e6={type:bW,encode:_W,decode:lW};class f0{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(e6)}register({type:W,encode:Q,decode:J}){if(W>=0)this.encoders[W]=Q,this.decoders[W]=J;else{const V=-1-W;this.builtInEncoders[V]=Q,this.builtInDecoders[V]=J}}tryToEncode(W,Q){for(let J=0;J<this.builtInEncoders.length;J++){const V=this.builtInEncoders[J];if(V!=null){const G=V(W,Q);if(G!=null){const X=-1-J;return new W1(X,G)}}}for(let J=0;J<this.encoders.length;J++){const V=this.encoders[J];if(V!=null){const G=V(W,Q);if(G!=null)return new W1(J,G)}}if(W instanceof W1)return W;return null}decode(W,Q,J){const V=Q<0?this.builtInDecoders[-1-Q]:this.decoders[Q];if(V)return V(W,Q,J);else return new W1(Q,W)}}f0.defaultCodec=new f0;var rW=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(rW(W))return new Uint8Array(W);else return Uint8Array.from(W)}var oW=100,nW=2048;class a1{constructor(W){this.entered=!1,this.extensionCodec=W?.extensionCodec??f0.defaultCodec,this.context=W?.context,this.useBigInt64=W?.useBigInt64??!1,this.maxDepth=W?.maxDepth??oW,this.initialBufferSize=W?.initialBufferSize??nW,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,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),V=new DataView(Q);J.set(this.bytes),this.view=V,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=r6(W);this.ensureBufferSizeToWrite(5+J),this.writeStringHeader(J),o6(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 V of W)this.doEncode(V,Q+1)}countWithoutUndefined(W,Q){let J=0;for(let V of Q)if(W[V]!==void 0)J++;return J}encodeMap(W,Q){const J=Object.keys(W);if(this.sortKeys)J.sort();const V=this.ignoreUndefined?this.countWithoutUndefined(W,J):J.length;if(V<16)this.writeU8(128+V);else if(V<65536)this.writeU8(222),this.writeU16(V);else if(V<4294967296)this.writeU8(223),this.writeU32(V);else throw new Error(`Too large map object: ${V}`);for(let G of J){const X=W[G];if(!(this.ignoreUndefined&&X===void 0))this.encodeString(G),this.doEncode(X,Q+1)}}encodeExtension(W){if(typeof W.data==="function"){const J=W.data(this.pos+6),V=J.length;if(V>=4294967296)throw new Error(`Too large extension object: ${V}`);this.writeU8(201),this.writeU32(V),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),a6(this.view,this.pos,W),this.pos+=8}writeI64(W){this.ensureBufferSizeToWrite(8),o1(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 g0(W,Q){return new a1(Q).encodeSharedRef(W)}function s1(W){return`${W<0?"-":""}0x${Math.abs(W).toString(16).padStart(2,"0")}`}var aW=16,sW=16;class S8{constructor(W=aW,Q=sW){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 V=this.caches[J-1];W:for(let G of V){const X=G.bytes;for(let Y=0;Y<J;Y++)if(X[Y]!==W[Q+Y])continue W;return G.str}return null}store(W,Q){const J=this.caches[W.length-1],V={bytes:W,str:Q};if(J.length>=this.maxLengthPerKey)J[Math.random()*J.length|0]=V;else J.push(V)}decode(W,Q,J){const V=this.find(W,Q,J);if(V!=null)return this.hit++,V;this.miss++;const G=v8(W,Q,J),X=Uint8Array.prototype.slice.call(W,Q,Q+J);return this.store(X,G),G}}var T8="array",L1="map_key",W5="map_value",eW=(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 J5{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=T8,Q.position=0,Q.size=W,Q.array=new Array(W)}pushMapState(W){const Q=this.getUninitializedStateFromPool();Q.type=L1,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===T8){const J=W;J.size=0,J.array=void 0,J.position=0,J.type=void 0}if(W.type===L1||W.type===W5){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 R1=-1,A8=new DataView(new ArrayBuffer(0)),tW=new Uint8Array(A8.buffer);try{A8.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 t6=new RangeError("Insufficient data"),WJ=new S8;class e1{constructor(W){this.totalPos=0,this.pos=0,this.view=A8,this.bytes=tW,this.headByte=R1,this.stack=new J5,this.entered=!1,this.extensionCodec=W?.extensionCodec??f0.defaultCodec,this.context=W?.context,this.useBigInt64=W?.useBigInt64??!1,this.rawStrings=W?.rawStrings??!1,this.maxStrLength=W?.maxStrLength??J1,this.maxBinLength=W?.maxBinLength??J1,this.maxArrayLength=W?.maxArrayLength??J1,this.maxMapLength=W?.maxMapLength??J1,this.maxExtLength=W?.maxExtLength??J1,this.keyDecoder=W?.keyDecoder!==void 0?W.keyDecoder:WJ,this.mapKeyConverter=W?.mapKeyConverter??eW}clone(){return new e1({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=R1,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===R1&&!this.hasRemaining(1))this.setBuffer(W);else{const Q=this.bytes.subarray(this.pos),J=M1(W),V=new Uint8Array(Q.length+J.length);V.set(Q),V.set(J,Q.length),this.setBuffer(V)}}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 Y of W){if(Q)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(Y);try{J=this.doDecodeSync(),Q=!0}catch(q){if(!(q instanceof RangeError))throw q}this.totalPos+=this.pos}if(Q){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return J}const{headByte:V,pos:G,totalPos:X}=this;throw new RangeError(`Insufficient data in parsing ${s1(V)} at ${X} (${G} 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,V=-1;for await(let G of W){if(Q&&V===0)throw this.createExtraByteError(this.totalPos);if(this.appendBuffer(G),J)V=this.readArraySize(),J=!1,this.complete();try{while(!0)if(yield this.doDecodeSync(),--V===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 Q;if(W>=224)Q=W-256;else if(W<192)if(W<128)Q=W;else if(W<144){const V=W-128;if(V!==0){this.pushMapState(V),this.complete();continue W}else Q={}}else if(W<160){const V=W-144;if(V!==0){this.pushArrayState(V),this.complete();continue W}else Q=[]}else{const V=W-160;Q=this.decodeString(V,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 V=this.lookU8();Q=this.decodeString(V,1)}else if(W===218){const V=this.lookU16();Q=this.decodeString(V,2)}else if(W===219){const V=this.lookU32();Q=this.decodeString(V,4)}else if(W===220){const V=this.readU16();if(V!==0){this.pushArrayState(V),this.complete();continue W}else Q=[]}else if(W===221){const V=this.readU32();if(V!==0){this.pushArrayState(V),this.complete();continue W}else Q=[]}else if(W===222){const V=this.readU16();if(V!==0){this.pushMapState(V),this.complete();continue W}else Q={}}else if(W===223){const V=this.readU32();if(V!==0){this.pushMapState(V),this.complete();continue W}else Q={}}else if(W===196){const V=this.lookU8();Q=this.decodeBinary(V,1)}else if(W===197){const V=this.lookU16();Q=this.decodeBinary(V,2)}else if(W===198){const V=this.lookU32();Q=this.decodeBinary(V,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 V=this.lookU8();Q=this.decodeExtension(V,1)}else if(W===200){const V=this.lookU16();Q=this.decodeExtension(V,2)}else if(W===201){const V=this.lookU32();Q=this.decodeExtension(V,4)}else throw new e(`Unrecognized type byte: ${s1(W)}`);this.complete();const J=this.stack;while(J.length>0){const V=J.top();if(V.type===T8)if(V.array[V.position]=Q,V.position++,V.position===V.size)Q=V.array,J.release(V);else continue W;else if(V.type===L1){if(Q==="__proto__")throw new e("The key __proto__ is not allowed");V.key=this.mapKeyConverter(Q),V.type=W5;continue W}else if(V.map[V.key]=Q,V.readCount++,V.readCount===V.size)Q=V.map,J.release(V);else{V.key=null,V.type=L1;continue W}}return Q}}readHeadByte(){if(this.headByte===R1)this.headByte=this.readU8();return this.headByte}complete(){this.headByte=R1}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: ${s1(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 t6;const J=this.pos+Q;let V;if(this.stateIsMapKey()&&this.keyDecoder?.canBeCached(W))V=this.keyDecoder.decode(this.bytes,J,W);else V=n6(this.bytes,J,W);return this.pos+=Q+W,V}stateIsMapKey(){if(this.stack.length>0)return this.stack.top().type===L1;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 t6;const J=this.pos+Q,V=this.bytes.subarray(J,J+W);return this.pos+=Q+W,V}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),V=this.decodeBinary(W,Q+1);return this.extensionCodec.decode(V,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=s6(this.view,this.pos);return this.pos+=8,W}readI64(){const W=n1(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 t1(W,Q){return new e1(Q).decode(W)}var q1=function(W){let Q=W.length;while(--Q>=0)W[Q]=0},E8=function(W,Q,J,V,G){this.static_tree=W,this.extra_bits=Q,this.extra_base=J,this.elems=V,this.max_length=G,this.has_stree=W&&W.length},p8=function(W,Q){this.dyn_tree=W,this.max_code=0,this.stat_desc=Q},k0=function(W,Q,J,V,G){this.good_length=W,this.max_lazy=Q,this.nice_length=J,this.max_chain=V,this.func=G},Q9=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=U8,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(rJ*2),this.dyn_dtree=new Uint16Array((2*iJ+1)*2),this.bl_tree=new Uint16Array((2*lJ+1)*2),v0(this.dyn_ltree),v0(this.dyn_dtree),v0(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(oJ+1),this.heap=new Uint16Array(2*s8+1),v0(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*s8+1),v0(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},I9=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},b1=function(W){this.options=F8.assign({level:v9,method:T9,chunkSize:16384,windowBits:15,memLevel:8,strategy:S9},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(u0[J]);if(Q.header)w1.deflateSetHeader(this.strm,Q.header);if(Q.dictionary){let V;if(typeof Q.dictionary==="string")V=E1.string2buf(Q.dictionary);else if(P7.call(Q.dictionary)==="[object ArrayBuffer]")V=new Uint8Array(Q.dictionary);else V=Q.dictionary;if(J=w1.deflateSetDictionary(this.strm,V),J!==q8)throw new Error(u0[J]);this._dict_set=!0}},P6=function(W,Q){const J=new b1(Q);if(J.push(W,!0),J.err)throw J.msg||u0[J.err];return J.result},A9=function(W,Q){return Q=Q||{},Q.raw=!0,P6(W,Q)},y9=function(W,Q){return Q=Q||{},Q.gzip=!0,P6(W,Q)},VQ=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},m1=function(W){this.options=F8.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=O0.inflateInit2(this.strm,Q.windowBits);if(J!==p1)throw new Error(u0[J]);if(this.header=new RQ,O0.inflateGetHeader(this.strm,this.header),Q.dictionary){if(typeof Q.dictionary==="string")Q.dictionary=E1.string2buf(Q.dictionary);else if(M7.call(Q.dictionary)==="[object ArrayBuffer]")Q.dictionary=new Uint8Array(Q.dictionary);if(Q.raw){if(J=O0.inflateSetDictionary(this.strm,Q.dictionary),J!==p1)throw new Error(u0[J])}}},U6=function(W,Q){const J=new m1(Q);if(J.push(W),J.err)throw J.msg||u0[J.err];return J.result},xQ=function(W,Q){return Q=Q||{},Q.raw=!0,U6(W,Q)};/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */var JJ=0,m5=1,QJ=2,VJ=3,GJ=258,V6=29,f1=256,g1=f1+1+V6,G1=30,G6=19,u5=2*g1+1,h0=15,y8=16,XJ=7,X6=256,d5=16,c5=17,_5=18,o8=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]),X8=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]),YJ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),i5=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qJ=512,L0=new Array((g1+2)*2);q1(L0);var x1=new Array(G1*2);q1(x1);var v1=new Array(qJ);q1(v1);var S1=new Array(GJ-VJ+1);q1(S1);var Y6=new Array(V6);q1(Y6);var Y8=new Array(G1);q1(Y8);var l5,r5,o5,n5=(W)=>{return W<256?v1[W]:v1[256+(W>>>7)]},T1=(W,Q)=>{W.pending_buf[W.pending++]=Q&255,W.pending_buf[W.pending++]=Q>>>8&255},V0=(W,Q,J)=>{if(W.bi_valid>y8-J)W.bi_buf|=Q<<W.bi_valid&65535,T1(W,W.bi_buf),W.bi_buf=Q>>y8-W.bi_valid,W.bi_valid+=J-y8;else W.bi_buf|=Q<<W.bi_valid&65535,W.bi_valid+=J},H0=(W,Q,J)=>{V0(W,J[Q*2],J[Q*2+1])},a5=(W,Q)=>{let J=0;do J|=W&1,W>>>=1,J<<=1;while(--Q>0);return J>>>1},PJ=(W)=>{if(W.bi_valid===16)T1(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},UJ=(W,Q)=>{const{dyn_tree:J,max_code:V}=Q,G=Q.stat_desc.static_tree,X=Q.stat_desc.has_stree,Y=Q.stat_desc.extra_bits,q=Q.stat_desc.extra_base,U=Q.stat_desc.max_length;let P,F,C,K,z,$,N=0;for(K=0;K<=h0;K++)W.bl_count[K]=0;J[W.heap[W.heap_max]*2+1]=0;for(P=W.heap_max+1;P<u5;P++){if(F=W.heap[P],K=J[J[F*2+1]*2+1]+1,K>U)K=U,N++;if(J[F*2+1]=K,F>V)continue;if(W.bl_count[K]++,z=0,F>=q)z=Y[F-q];if($=J[F*2],W.opt_len+=$*(K+z),X)W.static_len+=$*(G[F*2+1]+z)}if(N===0)return;do{K=U-1;while(W.bl_count[K]===0)K--;W.bl_count[K]--,W.bl_count[K+1]+=2,W.bl_count[U]--,N-=2}while(N>0);for(K=U;K!==0;K--){F=W.bl_count[K];while(F!==0){if(C=W.heap[--P],C>V)continue;if(J[C*2+1]!==K)W.opt_len+=(K-J[C*2+1])*J[C*2],J[C*2+1]=K;F--}}},s5=(W,Q,J)=>{const V=new Array(h0+1);let G=0,X,Y;for(X=1;X<=h0;X++)G=G+J[X-1]<<1,V[X]=G;for(Y=0;Y<=Q;Y++){let q=W[Y*2+1];if(q===0)continue;W[Y*2]=a5(V[q]++,q)}},FJ=()=>{let W,Q,J,V,G;const X=new Array(h0+1);J=0;for(V=0;V<V6-1;V++){Y6[V]=J;for(W=0;W<1<<o8[V];W++)S1[J++]=V}S1[J-1]=V,G=0;for(V=0;V<16;V++){Y8[V]=G;for(W=0;W<1<<X8[V];W++)v1[G++]=V}G>>=7;for(;V<G1;V++){Y8[V]=G<<7;for(W=0;W<1<<X8[V]-7;W++)v1[256+G++]=V}for(Q=0;Q<=h0;Q++)X[Q]=0;W=0;while(W<=143)L0[W*2+1]=8,W++,X[8]++;while(W<=255)L0[W*2+1]=9,W++,X[9]++;while(W<=279)L0[W*2+1]=7,W++,X[7]++;while(W<=287)L0[W*2+1]=8,W++,X[8]++;s5(L0,g1+1,X);for(W=0;W<G1;W++)x1[W*2+1]=5,x1[W*2]=a5(W,5);l5=new E8(L0,o8,f1+1,g1,h0),r5=new E8(x1,X8,0,G1,h0),o5=new E8(new Array(0),YJ,0,G6,XJ)},e5=(W)=>{let Q;for(Q=0;Q<g1;Q++)W.dyn_ltree[Q*2]=0;for(Q=0;Q<G1;Q++)W.dyn_dtree[Q*2]=0;for(Q=0;Q<G6;Q++)W.bl_tree[Q*2]=0;W.dyn_ltree[X6*2]=1,W.opt_len=W.static_len=0,W.sym_next=W.matches=0},t5=(W)=>{if(W.bi_valid>8)T1(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},Q5=(W,Q,J,V)=>{const G=Q*2,X=J*2;return W[G]<W[X]||W[G]===W[X]&&V[Q]<=V[J]},f8=(W,Q,J)=>{const V=W.heap[J];let G=J<<1;while(G<=W.heap_len){if(G<W.heap_len&&Q5(Q,W.heap[G+1],W.heap[G],W.depth))G++;if(Q5(Q,V,W.heap[G],W.depth))break;W.heap[J]=W.heap[G],J=G,G<<=1}W.heap[J]=V},V5=(W,Q,J)=>{let V,G,X=0,Y,q;if(W.sym_next!==0)do if(V=W.pending_buf[W.sym_buf+X++]&255,V+=(W.pending_buf[W.sym_buf+X++]&255)<<8,G=W.pending_buf[W.sym_buf+X++],V===0)H0(W,G,Q);else{if(Y=S1[G],H0(W,Y+f1+1,Q),q=o8[Y],q!==0)G-=Y6[Y],V0(W,G,q);if(V--,Y=n5(V),H0(W,Y,J),q=X8[Y],q!==0)V-=Y8[Y],V0(W,V,q)}while(X<W.sym_next);H0(W,X6,Q)},n8=(W,Q)=>{const J=Q.dyn_tree,V=Q.stat_desc.static_tree,G=Q.stat_desc.has_stree,X=Q.stat_desc.elems;let Y,q,U=-1,P;W.heap_len=0,W.heap_max=u5;for(Y=0;Y<X;Y++)if(J[Y*2]!==0)W.heap[++W.heap_len]=U=Y,W.depth[Y]=0;else J[Y*2+1]=0;while(W.heap_len<2)if(P=W.heap[++W.heap_len]=U<2?++U:0,J[P*2]=1,W.depth[P]=0,W.opt_len--,G)W.static_len-=V[P*2+1];Q.max_code=U;for(Y=W.heap_len>>1;Y>=1;Y--)f8(W,J,Y);P=X;do Y=W.heap[1],W.heap[1]=W.heap[W.heap_len--],f8(W,J,1),q=W.heap[1],W.heap[--W.heap_max]=Y,W.heap[--W.heap_max]=q,J[P*2]=J[Y*2]+J[q*2],W.depth[P]=(W.depth[Y]>=W.depth[q]?W.depth[Y]:W.depth[q])+1,J[Y*2+1]=J[q*2+1]=P,W.heap[1]=P++,f8(W,J,1);while(W.heap_len>=2);W.heap[--W.heap_max]=W.heap[1],UJ(W,Q),s5(J,U,W.bl_count)},G5=(W,Q,J)=>{let V,G=-1,X,Y=Q[1],q=0,U=7,P=4;if(Y===0)U=138,P=3;Q[(J+1)*2+1]=65535;for(V=0;V<=J;V++){if(X=Y,Y=Q[(V+1)*2+1],++q<U&&X===Y)continue;else if(q<P)W.bl_tree[X*2]+=q;else if(X!==0){if(X!==G)W.bl_tree[X*2]++;W.bl_tree[d5*2]++}else if(q<=10)W.bl_tree[c5*2]++;else W.bl_tree[_5*2]++;if(q=0,G=X,Y===0)U=138,P=3;else if(X===Y)U=6,P=3;else U=7,P=4}},X5=(W,Q,J)=>{let V,G=-1,X,Y=Q[1],q=0,U=7,P=4;if(Y===0)U=138,P=3;for(V=0;V<=J;V++){if(X=Y,Y=Q[(V+1)*2+1],++q<U&&X===Y)continue;else if(q<P)do H0(W,X,W.bl_tree);while(--q!==0);else if(X!==0){if(X!==G)H0(W,X,W.bl_tree),q--;H0(W,d5,W.bl_tree),V0(W,q-3,2)}else if(q<=10)H0(W,c5,W.bl_tree),V0(W,q-3,3);else H0(W,_5,W.bl_tree),V0(W,q-11,7);if(q=0,G=X,Y===0)U=138,P=3;else if(X===Y)U=6,P=3;else U=7,P=4}},KJ=(W)=>{let Q;G5(W,W.dyn_ltree,W.l_desc.max_code),G5(W,W.dyn_dtree,W.d_desc.max_code),n8(W,W.bl_desc);for(Q=G6-1;Q>=3;Q--)if(W.bl_tree[i5[Q]*2+1]!==0)break;return W.opt_len+=3*(Q+1)+5+5+4,Q},zJ=(W,Q,J,V)=>{let G;V0(W,Q-257,5),V0(W,J-1,5),V0(W,V-4,4);for(G=0;G<V;G++)V0(W,W.bl_tree[i5[G]*2+1],3);X5(W,W.dyn_ltree,Q-1),X5(W,W.dyn_dtree,J-1)},ZJ=(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<f1;J++)if(W.dyn_ltree[J*2]!==0)return 1;return 0},Y5=!1,kJ=(W)=>{if(!Y5)FJ(),Y5=!0;W.l_desc=new p8(W.dyn_ltree,l5),W.d_desc=new p8(W.dyn_dtree,r5),W.bl_desc=new p8(W.bl_tree,o5),W.bi_buf=0,W.bi_valid=0,e5(W)},W7=(W,Q,J,V)=>{if(V0(W,(JJ<<1)+(V?1:0),3),t5(W),T1(W,J),T1(W,~J),J)W.pending_buf.set(W.window.subarray(Q,Q+J),W.pending);W.pending+=J},HJ=(W)=>{V0(W,m5<<1,3),H0(W,X6,L0),PJ(W)},CJ=(W,Q,J,V)=>{let G,X,Y=0;if(W.level>0){if(W.strm.data_type===2)W.strm.data_type=ZJ(W);if(n8(W,W.l_desc),n8(W,W.d_desc),Y=KJ(W),G=W.opt_len+3+7>>>3,X=W.static_len+3+7>>>3,X<=G)G=X}else G=X=J+5;if(J+4<=G&&Q!==-1)W7(W,Q,J,V);else if(W.strategy===4||X===G)V0(W,(m5<<1)+(V?1:0),3),V5(W,L0,x1);else V0(W,(QJ<<1)+(V?1:0),3),zJ(W,W.l_desc.max_code+1,W.d_desc.max_code+1,Y+1),V5(W,W.dyn_ltree,W.dyn_dtree);if(e5(W),V)t5(W)},$J=(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[(S1[J]+f1+1)*2]++,W.dyn_dtree[n5(Q)*2]++;return W.sym_next===W.sym_end},jJ=kJ,BJ=W7,MJ=CJ,RJ=$J,LJ=HJ,OJ={_tr_init:jJ,_tr_stored_block:BJ,_tr_flush_block:MJ,_tr_tally:RJ,_tr_align:LJ},IJ=(W,Q,J,V)=>{let G=W&65535|0,X=W>>>16&65535|0,Y=0;while(J!==0){Y=J>2000?2000:J,J-=Y;do G=G+Q[V++]|0,X=X+G|0;while(--Y);G%=65521,X%=65521}return G|X<<16|0},A1=IJ,DJ=()=>{let W,Q=[];for(var J=0;J<256;J++){W=J;for(var V=0;V<8;V++)W=W&1?3988292384^W>>>1:W>>>1;Q[J]=W}return Q},xJ=new Uint32Array(DJ()),wJ=(W,Q,J,V)=>{const G=xJ,X=V+J;W^=-1;for(let Y=V;Y<X;Y++)W=W>>>8^G[(W^Q[Y])&255];return W^-1},o=wJ,u0={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"},_0={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:NJ,_tr_stored_block:a8,_tr_flush_block:gJ,_tr_tally:T0,_tr_align:vJ}=OJ,{Z_NO_FLUSH:A0,Z_PARTIAL_FLUSH:SJ,Z_FULL_FLUSH:TJ,Z_FINISH:F0,Z_BLOCK:q5,Z_OK:n,Z_STREAM_END:P5,Z_STREAM_ERROR:C0,Z_DATA_ERROR:AJ,Z_BUF_ERROR:h8,Z_DEFAULT_COMPRESSION:yJ,Z_FILTERED:EJ,Z_HUFFMAN_ONLY:W8,Z_RLE:pJ,Z_FIXED:fJ,Z_DEFAULT_STRATEGY:hJ,Z_UNKNOWN:bJ,Z_DEFLATED:U8}=_0,mJ=9,uJ=15,dJ=8,cJ=29,_J=256,s8=_J+1+cJ,iJ=30,lJ=19,rJ=2*s8+1,oJ=15,u=3,S0=258,$0=S0+u+1,nJ=32,X1=42,q6=57,e8=69,t8=73,W6=91,J6=103,b0=113,I1=666,t=1,P1=2,d0=3,U1=4,aJ=3,m0=(W,Q)=>{return W.msg=u0[Q],Q},U5=(W)=>{return W*2-(W>4?9:0)},v0=(W)=>{let Q=W.length;while(--Q>=0)W[Q]=0},sJ=(W)=>{let Q,J,V,G=W.w_size;Q=W.hash_size,V=Q;do J=W.head[--V],W.head[V]=J>=G?J-G:0;while(--Q);Q=G,V=Q;do J=W.prev[--V],W.prev[V]=J>=G?J-G:0;while(--Q)},eJ=(W,Q,J)=>(Q<<W.hash_shift^J)&W.hash_mask,y0=eJ,X0=(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},Y0=(W,Q)=>{gJ(W,W.block_start>=0?W.block_start:-1,W.strstart-W.block_start,Q),W.block_start=W.strstart,X0(W.strm)},c=(W,Q)=>{W.pending_buf[W.pending++]=Q},O1=(W,Q)=>{W.pending_buf[W.pending++]=Q>>>8&255,W.pending_buf[W.pending++]=Q&255},Q6=(W,Q,J,V)=>{let G=W.avail_in;if(G>V)G=V;if(G===0)return 0;if(W.avail_in-=G,Q.set(W.input.subarray(W.next_in,W.next_in+G),J),W.state.wrap===1)W.adler=A1(W.adler,Q,G,J);else if(W.state.wrap===2)W.adler=o(W.adler,Q,G,J);return W.next_in+=G,W.total_in+=G,G},J7=(W,Q)=>{let{max_chain_length:J,strstart:V}=W,G,X,Y=W.prev_length,q=W.nice_match;const U=W.strstart>W.w_size-$0?W.strstart-(W.w_size-$0):0,P=W.window,F=W.w_mask,C=W.prev,K=W.strstart+S0;let z=P[V+Y-1],$=P[V+Y];if(W.prev_length>=W.good_match)J>>=2;if(q>W.lookahead)q=W.lookahead;do{if(G=Q,P[G+Y]!==$||P[G+Y-1]!==z||P[G]!==P[V]||P[++G]!==P[V+1])continue;V+=2,G++;do;while(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]===P[++G]&&V<K);if(X=S0-(K-V),V=K-S0,X>Y){if(W.match_start=Q,Y=X,X>=q)break;z=P[V+Y-1],$=P[V+Y]}}while((Q=C[Q&F])>U&&--J!==0);if(Y<=W.lookahead)return Y;return W.lookahead},Y1=(W)=>{const Q=W.w_size;let J,V,G;do{if(V=W.window_size-W.lookahead-W.strstart,W.strstart>=Q+(Q-$0)){if(W.window.set(W.window.subarray(Q,Q+Q-V),0),W.match_start-=Q,W.strstart-=Q,W.block_start-=Q,W.insert>W.strstart)W.insert=W.strstart;sJ(W),V+=Q}if(W.strm.avail_in===0)break;if(J=Q6(W.strm,W.window,W.strstart+W.lookahead,V),W.lookahead+=J,W.lookahead+W.insert>=u){G=W.strstart-W.insert,W.ins_h=W.window[G],W.ins_h=y0(W,W.ins_h,W.window[G+1]);while(W.insert)if(W.ins_h=y0(W,W.ins_h,W.window[G+u-1]),W.prev[G&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=G,G++,W.insert--,W.lookahead+W.insert<u)break}}while(W.lookahead<$0&&W.strm.avail_in!==0)},Q7=(W,Q)=>{let J=W.pending_buf_size-5>W.w_size?W.w_size:W.pending_buf_size-5,V,G,X,Y=0,q=W.strm.avail_in;do{if(V=65535,X=W.bi_valid+42>>3,W.strm.avail_out<X)break;if(X=W.strm.avail_out-X,G=W.strstart-W.block_start,V>G+W.strm.avail_in)V=G+W.strm.avail_in;if(V>X)V=X;if(V<J&&(V===0&&Q!==F0||Q===A0||V!==G+W.strm.avail_in))break;if(Y=Q===F0&&V===G+W.strm.avail_in?1:0,a8(W,0,0,Y),W.pending_buf[W.pending-4]=V,W.pending_buf[W.pending-3]=V>>8,W.pending_buf[W.pending-2]=~V,W.pending_buf[W.pending-1]=~V>>8,X0(W.strm),G){if(G>V)G=V;W.strm.output.set(W.window.subarray(W.block_start,W.block_start+G),W.strm.next_out),W.strm.next_out+=G,W.strm.avail_out-=G,W.strm.total_out+=G,W.block_start+=G,V-=G}if(V)Q6(W.strm,W.strm.output,W.strm.next_out,V),W.strm.next_out+=V,W.strm.avail_out-=V,W.strm.total_out+=V}while(Y===0);if(q-=W.strm.avail_in,q){if(q>=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<=q){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-q,W.strm.next_in),W.strstart),W.strstart+=q,W.insert+=q>W.w_size-W.insert?W.w_size-W.insert:q}W.block_start=W.strstart}if(W.high_water<W.strstart)W.high_water=W.strstart;if(Y)return U1;if(Q!==A0&&Q!==F0&&W.strm.avail_in===0&&W.strstart===W.block_start)return P1;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)Q6(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,G=W.strstart-W.block_start,G>=J||(G||Q===F0)&&Q!==A0&&W.strm.avail_in===0&&G<=X)V=G>X?X:G,Y=Q===F0&&W.strm.avail_in===0&&V===G?1:0,a8(W,W.block_start,V,Y),W.block_start+=V,X0(W.strm);return Y?d0:t},b8=(W,Q)=>{let J,V;for(;;){if(W.lookahead<$0){if(Y1(W),W.lookahead<$0&&Q===A0)return t;if(W.lookahead===0)break}if(J=0,W.lookahead>=u)W.ins_h=y0(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-$0)W.match_length=J7(W,J);if(W.match_length>=u)if(V=T0(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=y0(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=y0(W,W.ins_h,W.window[W.strstart+1]);else V=T0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++;if(V){if(Y0(W,!1),W.strm.avail_out===0)return t}}if(W.insert=W.strstart<u-1?W.strstart:u-1,Q===F0){if(Y0(W,!0),W.strm.avail_out===0)return d0;return U1}if(W.sym_next){if(Y0(W,!1),W.strm.avail_out===0)return t}return P1},Q1=(W,Q)=>{let J,V,G;for(;;){if(W.lookahead<$0){if(Y1(W),W.lookahead<$0&&Q===A0)return t;if(W.lookahead===0)break}if(J=0,W.lookahead>=u)W.ins_h=y0(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-$0){if(W.match_length=J7(W,J),W.match_length<=5&&(W.strategy===EJ||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){G=W.strstart+W.lookahead-u,V=T0(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<=G)W.ins_h=y0(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++,V){if(Y0(W,!1),W.strm.avail_out===0)return t}}else if(W.match_available){if(V=T0(W,0,W.window[W.strstart-1]),V)Y0(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)V=T0(W,0,W.window[W.strstart-1]),W.match_available=0;if(W.insert=W.strstart<u-1?W.strstart:u-1,Q===F0){if(Y0(W,!0),W.strm.avail_out===0)return d0;return U1}if(W.sym_next){if(Y0(W,!1),W.strm.avail_out===0)return t}return P1},tJ=(W,Q)=>{let J,V,G,X;const Y=W.window;for(;;){if(W.lookahead<=S0){if(Y1(W),W.lookahead<=S0&&Q===A0)return t;if(W.lookahead===0)break}if(W.match_length=0,W.lookahead>=u&&W.strstart>0){if(G=W.strstart-1,V=Y[G],V===Y[++G]&&V===Y[++G]&&V===Y[++G]){X=W.strstart+S0;do;while(V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&G<X);if(W.match_length=S0-(X-G),W.match_length>W.lookahead)W.match_length=W.lookahead}}if(W.match_length>=u)J=T0(W,1,W.match_length-u),W.lookahead-=W.match_length,W.strstart+=W.match_length,W.match_length=0;else J=T0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++;if(J){if(Y0(W,!1),W.strm.avail_out===0)return t}}if(W.insert=0,Q===F0){if(Y0(W,!0),W.strm.avail_out===0)return d0;return U1}if(W.sym_next){if(Y0(W,!1),W.strm.avail_out===0)return t}return P1},W9=(W,Q)=>{let J;for(;;){if(W.lookahead===0){if(Y1(W),W.lookahead===0){if(Q===A0)return t;break}}if(W.match_length=0,J=T0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++,J){if(Y0(W,!1),W.strm.avail_out===0)return t}}if(W.insert=0,Q===F0){if(Y0(W,!0),W.strm.avail_out===0)return d0;return U1}if(W.sym_next){if(Y0(W,!1),W.strm.avail_out===0)return t}return P1},D1=[new k0(0,0,0,0,Q7),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,Q1),new k0(8,16,32,32,Q1),new k0(8,16,128,128,Q1),new k0(8,32,128,256,Q1),new k0(32,128,258,1024,Q1),new k0(32,258,258,4096,Q1)],J9=(W)=>{W.window_size=2*W.w_size,v0(W.head),W.max_lazy_match=D1[W.level].max_lazy,W.good_match=D1[W.level].good_length,W.nice_match=D1[W.level].nice_length,W.max_chain_length=D1[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},h1=(W)=>{if(!W)return 1;const Q=W.state;if(!Q||Q.strm!==W||Q.status!==X1&&Q.status!==q6&&Q.status!==e8&&Q.status!==t8&&Q.status!==W6&&Q.status!==J6&&Q.status!==b0&&Q.status!==I1)return 1;return 0},V7=(W)=>{if(h1(W))return m0(W,C0);W.total_in=W.total_out=0,W.data_type=bJ;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?q6:Q.wrap?X1:b0,W.adler=Q.wrap===2?0:1,Q.last_flush=-2,NJ(Q),n},G7=(W)=>{const Q=V7(W);if(Q===n)J9(W.state);return Q},V9=(W,Q)=>{if(h1(W)||W.state.wrap!==2)return C0;return W.state.gzhead=Q,n},X7=(W,Q,J,V,G,X)=>{if(!W)return C0;let Y=1;if(Q===yJ)Q=6;if(V<0)Y=0,V=-V;else if(V>15)Y=2,V-=16;if(G<1||G>mJ||J!==U8||V<8||V>15||Q<0||Q>9||X<0||X>fJ||V===8&&Y!==1)return m0(W,C0);if(V===8)V=9;const q=new Q9;return W.state=q,q.strm=W,q.status=X1,q.wrap=Y,q.gzhead=null,q.w_bits=V,q.w_size=1<<q.w_bits,q.w_mask=q.w_size-1,q.hash_bits=G+7,q.hash_size=1<<q.hash_bits,q.hash_mask=q.hash_size-1,q.hash_shift=~~((q.hash_bits+u-1)/u),q.window=new Uint8Array(q.w_size*2),q.head=new Uint16Array(q.hash_size),q.prev=new Uint16Array(q.w_size),q.lit_bufsize=1<<G+6,q.pending_buf_size=q.lit_bufsize*4,q.pending_buf=new Uint8Array(q.pending_buf_size),q.sym_buf=q.lit_bufsize,q.sym_end=(q.lit_bufsize-1)*3,q.level=Q,q.strategy=X,q.method=J,G7(W)},G9=(W,Q)=>{return X7(W,Q,U8,uJ,dJ,hJ)},X9=(W,Q)=>{if(h1(W)||Q>q5||Q<0)return W?m0(W,C0):C0;const J=W.state;if(!W.output||W.avail_in!==0&&!W.input||J.status===I1&&Q!==F0)return m0(W,W.avail_out===0?h8:C0);const V=J.last_flush;if(J.last_flush=Q,J.pending!==0){if(X0(W),W.avail_out===0)return J.last_flush=-1,n}else if(W.avail_in===0&&U5(Q)<=U5(V)&&Q!==F0)return m0(W,h8);if(J.status===I1&&W.avail_in!==0)return m0(W,h8);if(J.status===X1&&J.wrap===0)J.status=b0;if(J.status===X1){let G=U8+(J.w_bits-8<<4)<<8,X=-1;if(J.strategy>=W8||J.level<2)X=0;else if(J.level<6)X=1;else if(J.level===6)X=2;else X=3;if(G|=X<<6,J.strstart!==0)G|=nJ;if(G+=31-G%31,O1(J,G),J.strstart!==0)O1(J,W.adler>>>16),O1(J,W.adler&65535);if(W.adler=1,J.status=b0,X0(W),J.pending!==0)return J.last_flush=-1,n}if(J.status===q6)if(W.adler=0,c(J,31),c(J,139),c(J,8),!J.gzhead){if(c(J,0),c(J,0),c(J,0),c(J,0),c(J,0),c(J,J.level===9?2:J.strategy>=W8||J.level<2?4:0),c(J,aJ),J.status=b0,X0(W),J.pending!==0)return J.last_flush=-1,n}else{if(c(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)),c(J,J.gzhead.time&255),c(J,J.gzhead.time>>8&255),c(J,J.gzhead.time>>16&255),c(J,J.gzhead.time>>24&255),c(J,J.level===9?2:J.strategy>=W8||J.level<2?4:0),c(J,J.gzhead.os&255),J.gzhead.extra&&J.gzhead.extra.length)c(J,J.gzhead.extra.length&255),c(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 G=J.pending,X=(J.gzhead.extra.length&65535)-J.gzindex;while(J.pending+X>J.pending_buf_size){let q=J.pending_buf_size-J.pending;if(J.pending_buf.set(J.gzhead.extra.subarray(J.gzindex,J.gzindex+q),J.pending),J.pending=J.pending_buf_size,J.gzhead.hcrc&&J.pending>G)W.adler=o(W.adler,J.pending_buf,J.pending-G,G);if(J.gzindex+=q,X0(W),J.pending!==0)return J.last_flush=-1,n;G=0,X-=q}let Y=new Uint8Array(J.gzhead.extra);if(J.pending_buf.set(Y.subarray(J.gzindex,J.gzindex+X),J.pending),J.pending+=X,J.gzhead.hcrc&&J.pending>G)W.adler=o(W.adler,J.pending_buf,J.pending-G,G);J.gzindex=0}J.status=t8}if(J.status===t8){if(J.gzhead.name){let G=J.pending,X;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>G)W.adler=o(W.adler,J.pending_buf,J.pending-G,G);if(X0(W),J.pending!==0)return J.last_flush=-1,n;G=0}if(J.gzindex<J.gzhead.name.length)X=J.gzhead.name.charCodeAt(J.gzindex++)&255;else X=0;c(J,X)}while(X!==0);if(J.gzhead.hcrc&&J.pending>G)W.adler=o(W.adler,J.pending_buf,J.pending-G,G);J.gzindex=0}J.status=W6}if(J.status===W6){if(J.gzhead.comment){let G=J.pending,X;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>G)W.adler=o(W.adler,J.pending_buf,J.pending-G,G);if(X0(W),J.pending!==0)return J.last_flush=-1,n;G=0}if(J.gzindex<J.gzhead.comment.length)X=J.gzhead.comment.charCodeAt(J.gzindex++)&255;else X=0;c(J,X)}while(X!==0);if(J.gzhead.hcrc&&J.pending>G)W.adler=o(W.adler,J.pending_buf,J.pending-G,G)}J.status=J6}if(J.status===J6){if(J.gzhead.hcrc){if(J.pending+2>J.pending_buf_size){if(X0(W),J.pending!==0)return J.last_flush=-1,n}c(J,W.adler&255),c(J,W.adler>>8&255),W.adler=0}if(J.status=b0,X0(W),J.pending!==0)return J.last_flush=-1,n}if(W.avail_in!==0||J.lookahead!==0||Q!==A0&&J.status!==I1){let G=J.level===0?Q7(J,Q):J.strategy===W8?W9(J,Q):J.strategy===pJ?tJ(J,Q):D1[J.level].func(J,Q);if(G===d0||G===U1)J.status=I1;if(G===t||G===d0){if(W.avail_out===0)J.last_flush=-1;return n}if(G===P1){if(Q===SJ)vJ(J);else if(Q!==q5){if(a8(J,0,0,!1),Q===TJ){if(v0(J.head),J.lookahead===0)J.strstart=0,J.block_start=0,J.insert=0}}if(X0(W),W.avail_out===0)return J.last_flush=-1,n}}if(Q!==F0)return n;if(J.wrap<=0)return P5;if(J.wrap===2)c(J,W.adler&255),c(J,W.adler>>8&255),c(J,W.adler>>16&255),c(J,W.adler>>24&255),c(J,W.total_in&255),c(J,W.total_in>>8&255),c(J,W.total_in>>16&255),c(J,W.total_in>>24&255);else O1(J,W.adler>>>16),O1(J,W.adler&65535);if(X0(W),J.wrap>0)J.wrap=-J.wrap;return J.pending!==0?n:P5},Y9=(W)=>{if(h1(W))return C0;const Q=W.state.status;return W.state=null,Q===b0?m0(W,AJ):n},q9=(W,Q)=>{let J=Q.length;if(h1(W))return C0;const V=W.state,G=V.wrap;if(G===2||G===1&&V.status!==X1||V.lookahead)return C0;if(G===1)W.adler=A1(W.adler,Q,J,0);if(V.wrap=0,J>=V.w_size){if(G===0)v0(V.head),V.strstart=0,V.block_start=0,V.insert=0;let U=new Uint8Array(V.w_size);U.set(Q.subarray(J-V.w_size,J),0),Q=U,J=V.w_size}const{avail_in:X,next_in:Y,input:q}=W;W.avail_in=J,W.next_in=0,W.input=Q,Y1(V);while(V.lookahead>=u){let U=V.strstart,P=V.lookahead-(u-1);do V.ins_h=y0(V,V.ins_h,V.window[U+u-1]),V.prev[U&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=U,U++;while(--P);V.strstart=U,V.lookahead=u-1,Y1(V)}return V.strstart+=V.lookahead,V.block_start=V.strstart,V.insert=V.lookahead,V.lookahead=0,V.match_length=V.prev_length=u-1,V.match_available=0,W.next_in=Y,W.input=q,W.avail_in=X,V.wrap=G,n},P9=G9,U9=X7,F9=G7,K9=V7,z9=V9,Z9=X9,k9=Y9,H9=q9,C9="pako deflate (from Nodeca project)",w1={deflateInit:P9,deflateInit2:U9,deflateReset:F9,deflateResetKeep:K9,deflateSetHeader:z9,deflate:Z9,deflateEnd:k9,deflateSetDictionary:H9,deflateInfo:C9},$9=(W,Q)=>{return Object.prototype.hasOwnProperty.call(W,Q)},j9=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 V in J)if($9(J,V))W[V]=J[V]}return W},B9=(W)=>{let Q=0;for(let V=0,G=W.length;V<G;V++)Q+=W[V].length;const J=new Uint8Array(Q);for(let V=0,G=0,X=W.length;V<X;V++){let Y=W[V];J.set(Y,G),G+=Y.length}return J},F8={assign:j9,flattenChunks:B9},Y7=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(W){Y7=!1}var y1=new Uint8Array(256);for(let W=0;W<256;W++)y1[W]=W>=252?6:W>=248?5:W>=240?4:W>=224?3:W>=192?2:1;y1[254]=y1[254]=1;var M9=(W)=>{if(typeof TextEncoder==="function"&&TextEncoder.prototype.encode)return(new TextEncoder()).encode(W);let Q,J,V,G,X,Y=W.length,q=0;for(G=0;G<Y;G++){if(J=W.charCodeAt(G),(J&64512)===55296&&G+1<Y){if(V=W.charCodeAt(G+1),(V&64512)===56320)J=65536+(J-55296<<10)+(V-56320),G++}q+=J<128?1:J<2048?2:J<65536?3:4}Q=new Uint8Array(q);for(X=0,G=0;X<q;G++){if(J=W.charCodeAt(G),(J&64512)===55296&&G+1<Y){if(V=W.charCodeAt(G+1),(V&64512)===56320)J=65536+(J-55296<<10)+(V-56320),G++}if(J<128)Q[X++]=J;else if(J<2048)Q[X++]=192|J>>>6,Q[X++]=128|J&63;else if(J<65536)Q[X++]=224|J>>>12,Q[X++]=128|J>>>6&63,Q[X++]=128|J&63;else Q[X++]=240|J>>>18,Q[X++]=128|J>>>12&63,Q[X++]=128|J>>>6&63,Q[X++]=128|J&63}return Q},R9=(W,Q)=>{if(Q<65534){if(W.subarray&&Y7)return String.fromCharCode.apply(null,W.length===Q?W:W.subarray(0,Q))}let J="";for(let V=0;V<Q;V++)J+=String.fromCharCode(W[V]);return J},L9=(W,Q)=>{const J=Q||W.length;if(typeof TextDecoder==="function"&&TextDecoder.prototype.decode)return(new TextDecoder()).decode(W.subarray(0,Q));let V,G;const X=new Array(J*2);for(G=0,V=0;V<J;){let Y=W[V++];if(Y<128){X[G++]=Y;continue}let q=y1[Y];if(q>4){X[G++]=65533,V+=q-1;continue}Y&=q===2?31:q===3?15:7;while(q>1&&V<J)Y=Y<<6|W[V++]&63,q--;if(q>1){X[G++]=65533;continue}if(Y<65536)X[G++]=Y;else Y-=65536,X[G++]=55296|Y>>10&1023,X[G++]=56320|Y&1023}return R9(X,G)},O9=(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+y1[W[J]]>Q?J:Q},E1={string2buf:M9,buf2string:L9,utf8border:O9},q7=I9,P7=Object.prototype.toString,{Z_NO_FLUSH:D9,Z_SYNC_FLUSH:x9,Z_FULL_FLUSH:w9,Z_FINISH:N9,Z_OK:q8,Z_STREAM_END:g9,Z_DEFAULT_COMPRESSION:v9,Z_DEFAULT_STRATEGY:S9,Z_DEFLATED:T9}=_0;b1.prototype.push=function(W,Q){const J=this.strm,V=this.options.chunkSize;let G,X;if(this.ended)return!1;if(Q===~~Q)X=Q;else X=Q===!0?N9:D9;if(typeof W==="string")J.input=E1.string2buf(W);else if(P7.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(V),J.next_out=0,J.avail_out=V;if((X===x9||X===w9)&&J.avail_out<=6){this.onData(J.output.subarray(0,J.next_out)),J.avail_out=0;continue}if(G=w1.deflate(J,X),G===g9){if(J.next_out>0)this.onData(J.output.subarray(0,J.next_out));return G=w1.deflateEnd(this.strm),this.onEnd(G),this.ended=!0,G===q8}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};b1.prototype.onData=function(W){this.chunks.push(W)};b1.prototype.onEnd=function(W){if(W===q8)this.result=F8.flattenChunks(this.chunks);this.chunks=[],this.err=W,this.msg=this.strm.msg};var E9=b1,p9=P6,f9=A9,h9=y9,b9=_0,m9={Deflate:E9,deflate:p9,deflateRaw:f9,gzip:h9,constants:b9},J8=16209,u9=16191,d9=function W(Q,J){let V,G,X,Y,q,U,P,F,C,K,z,$,N,v,y,E,p,x,f,d,I,L,w,Z;const k=Q.state;V=Q.next_in,w=Q.input,G=V+(Q.avail_in-5),X=Q.next_out,Z=Q.output,Y=X-(J-Q.avail_out),q=X+(Q.avail_out-257),U=k.dmax,P=k.wsize,F=k.whave,C=k.wnext,K=k.window,z=k.hold,$=k.bits,N=k.lencode,v=k.distcode,y=(1<<k.lenbits)-1,E=(1<<k.distbits)-1;W:do{if($<15)z+=w[V++]<<$,$+=8,z+=w[V++]<<$,$+=8;p=N[z&y];J:for(;;){if(x=p>>>24,z>>>=x,$-=x,x=p>>>16&255,x===0)Z[X++]=p&65535;else if(x&16){if(f=p&65535,x&=15,x){if($<x)z+=w[V++]<<$,$+=8;f+=z&(1<<x)-1,z>>>=x,$-=x}if($<15)z+=w[V++]<<$,$+=8,z+=w[V++]<<$,$+=8;p=v[z&E];Q:for(;;){if(x=p>>>24,z>>>=x,$-=x,x=p>>>16&255,x&16){if(d=p&65535,x&=15,$<x){if(z+=w[V++]<<$,$+=8,$<x)z+=w[V++]<<$,$+=8}if(d+=z&(1<<x)-1,d>U){Q.msg="invalid distance too far back",k.mode=J8;break W}if(z>>>=x,$-=x,x=X-Y,d>x){if(x=d-x,x>F){if(k.sane){Q.msg="invalid distance too far back",k.mode=J8;break W}}if(I=0,L=K,C===0){if(I+=P-x,x<f){f-=x;do Z[X++]=K[I++];while(--x);I=X-d,L=Z}}else if(C<x){if(I+=P+C-x,x-=C,x<f){f-=x;do Z[X++]=K[I++];while(--x);if(I=0,C<f){x=C,f-=x;do Z[X++]=K[I++];while(--x);I=X-d,L=Z}}}else if(I+=C-x,x<f){f-=x;do Z[X++]=K[I++];while(--x);I=X-d,L=Z}while(f>2)Z[X++]=L[I++],Z[X++]=L[I++],Z[X++]=L[I++],f-=3;if(f){if(Z[X++]=L[I++],f>1)Z[X++]=L[I++]}}else{I=X-d;do Z[X++]=Z[I++],Z[X++]=Z[I++],Z[X++]=Z[I++],f-=3;while(f>2);if(f){if(Z[X++]=Z[I++],f>1)Z[X++]=Z[I++]}}}else if((x&64)===0){p=v[(p&65535)+(z&(1<<x)-1)];continue Q}else{Q.msg="invalid distance code",k.mode=J8;break W}break}}else if((x&64)===0){p=N[(p&65535)+(z&(1<<x)-1)];continue J}else if(x&32){k.mode=u9;break W}else{Q.msg="invalid literal/length code",k.mode=J8;break W}break}}while(V<G&&X<q);f=$>>3,V-=f,$-=f<<3,z&=(1<<$)-1,Q.next_in=V,Q.next_out=X,Q.avail_in=V<G?5+(G-V):5-(V-G),Q.avail_out=X<q?257+(q-X):257-(X-q),k.hold=z,k.bits=$;return},V1=15,F5=852,K5=592,z5=0,m8=1,Z5=2,c9=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]),_9=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]),i9=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]),l9=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]),r9=(W,Q,J,V,G,X,Y,q)=>{const U=q.bits;let P=0,F=0,C=0,K=0,z=0,$=0,N=0,v=0,y=0,E=0,p,x,f,d,I,L=null,w;const Z=new Uint16Array(V1+1),k=new Uint16Array(V1+1);let M=null,H,j,O;for(P=0;P<=V1;P++)Z[P]=0;for(F=0;F<V;F++)Z[Q[J+F]]++;z=U;for(K=V1;K>=1;K--)if(Z[K]!==0)break;if(z>K)z=K;if(K===0)return G[X++]=1<<24|64<<16|0,G[X++]=1<<24|64<<16|0,q.bits=1,0;for(C=1;C<K;C++)if(Z[C]!==0)break;if(z<C)z=C;v=1;for(P=1;P<=V1;P++)if(v<<=1,v-=Z[P],v<0)return-1;if(v>0&&(W===z5||K!==1))return-1;k[1]=0;for(P=1;P<V1;P++)k[P+1]=k[P]+Z[P];for(F=0;F<V;F++)if(Q[J+F]!==0)Y[k[Q[J+F]]++]=F;if(W===z5)L=M=Y,w=20;else if(W===m8)L=c9,M=_9,w=257;else L=i9,M=l9,w=0;if(E=0,F=0,P=C,I=X,$=z,N=0,f=-1,y=1<<z,d=y-1,W===m8&&y>F5||W===Z5&&y>K5)return 1;for(;;){if(H=P-N,Y[F]+1<w)j=0,O=Y[F];else if(Y[F]>=w)j=M[Y[F]-w],O=L[Y[F]-w];else j=96,O=0;p=1<<P-N,x=1<<$,C=x;do x-=p,G[I+(E>>N)+x]=H<<24|j<<16|O|0;while(x!==0);p=1<<P-1;while(E&p)p>>=1;if(p!==0)E&=p-1,E+=p;else E=0;if(F++,--Z[P]===0){if(P===K)break;P=Q[J+Y[F]]}if(P>z&&(E&d)!==f){if(N===0)N=z;I+=C,$=P-N,v=1<<$;while($+N<K){if(v-=Z[$+N],v<=0)break;$++,v<<=1}if(y+=1<<$,W===m8&&y>F5||W===Z5&&y>K5)return 1;f=E&d,G[f]=z<<24|$<<16|I-X|0}}if(E!==0)G[I+E]=P-N<<24|64<<16|0;return q.bits=z,0},N1=r9,o9=0,U7=1,F7=2,{Z_FINISH:k5,Z_BLOCK:n9,Z_TREES:Q8,Z_OK:c0,Z_STREAM_END:a9,Z_NEED_DICT:s9,Z_STREAM_ERROR:K0,Z_DATA_ERROR:K7,Z_MEM_ERROR:z7,Z_BUF_ERROR:e9,Z_DEFLATED:H5}=_0,K8=16180,C5=16181,$5=16182,j5=16183,B5=16184,M5=16185,R5=16186,L5=16187,O5=16188,I5=16189,P8=16190,R0=16191,u8=16192,D5=16193,d8=16194,x5=16195,w5=16196,N5=16197,g5=16198,V8=16199,G8=16200,v5=16201,S5=16202,T5=16203,A5=16204,y5=16205,c8=16206,E5=16207,p5=16208,l=16209,Z7=16210,k7=16211,t9=852,WQ=592,JQ=15,QQ=JQ,f5=(W)=>{return(W>>>24&255)+(W>>>8&65280)+((W&65280)<<8)+((W&255)<<24)},i0=(W)=>{if(!W)return 1;const Q=W.state;if(!Q||Q.strm!==W||Q.mode<K8||Q.mode>k7)return 1;return 0},H7=(W)=>{if(i0(W))return K0;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=K8,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(t9),Q.distcode=Q.distdyn=new Int32Array(WQ),Q.sane=1,Q.back=-1,c0},C7=(W)=>{if(i0(W))return K0;const Q=W.state;return Q.wsize=0,Q.whave=0,Q.wnext=0,H7(W)},$7=(W,Q)=>{let J;if(i0(W))return K0;const V=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 K0;if(V.window!==null&&V.wbits!==Q)V.window=null;return V.wrap=J,V.wbits=Q,C7(W)},j7=(W,Q)=>{if(!W)return K0;const J=new VQ;W.state=J,J.strm=W,J.window=null,J.mode=K8;const V=$7(W,Q);if(V!==c0)W.state=null;return V},GQ=(W)=>{return j7(W,QQ)},h5=!0,_8,i8,XQ=(W)=>{if(h5){_8=new Int32Array(512),i8=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;N1(U7,W.lens,0,288,_8,0,W.work,{bits:9}),Q=0;while(Q<32)W.lens[Q++]=5;N1(F7,W.lens,0,32,i8,0,W.work,{bits:5}),h5=!1}W.lencode=_8,W.lenbits=9,W.distcode=i8,W.distbits=5},B7=(W,Q,J,V)=>{let G;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(V>=X.wsize)X.window.set(Q.subarray(J-X.wsize,J),0),X.wnext=0,X.whave=X.wsize;else{if(G=X.wsize-X.wnext,G>V)G=V;if(X.window.set(Q.subarray(J-V,J-V+G),X.wnext),V-=G,V)X.window.set(Q.subarray(J-V,J),0),X.wnext=V,X.whave=X.wsize;else{if(X.wnext+=G,X.wnext===X.wsize)X.wnext=0;if(X.whave<X.wsize)X.whave+=G}}return 0},YQ=(W,Q)=>{let J,V,G,X,Y,q,U,P,F,C,K,z,$,N,v=0,y,E,p,x,f,d,I,L;const w=new Uint8Array(4);let Z,k;const M=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(i0(W)||!W.output||!W.input&&W.avail_in!==0)return K0;if(J=W.state,J.mode===R0)J.mode=u8;Y=W.next_out,G=W.output,U=W.avail_out,X=W.next_in,V=W.input,q=W.avail_in,P=J.hold,F=J.bits,C=q,K=U,L=c0;W:for(;;)switch(J.mode){case K8:if(J.wrap===0){J.mode=u8;break}while(F<16){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(J.wrap&2&&P===35615){if(J.wbits===0)J.wbits=15;J.check=0,w[0]=P&255,w[1]=P>>>8&255,J.check=o(J.check,w,2,0),P=0,F=0,J.mode=C5;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=l;break}if((P&15)!==H5){W.msg="unknown compression method",J.mode=l;break}if(P>>>=4,F-=4,I=(P&15)+8,J.wbits===0)J.wbits=I;if(I>15||I>J.wbits){W.msg="invalid window size",J.mode=l;break}J.dmax=1<<J.wbits,J.flags=0,W.adler=J.check=1,J.mode=P&512?I5:R0,P=0,F=0;break;case C5:while(F<16){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(J.flags=P,(J.flags&255)!==H5){W.msg="unknown compression method",J.mode=l;break}if(J.flags&57344){W.msg="unknown header flags set",J.mode=l;break}if(J.head)J.head.text=P>>8&1;if(J.flags&512&&J.wrap&4)w[0]=P&255,w[1]=P>>>8&255,J.check=o(J.check,w,2,0);P=0,F=0,J.mode=$5;case $5:while(F<32){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(J.head)J.head.time=P;if(J.flags&512&&J.wrap&4)w[0]=P&255,w[1]=P>>>8&255,w[2]=P>>>16&255,w[3]=P>>>24&255,J.check=o(J.check,w,4,0);P=0,F=0,J.mode=j5;case j5:while(F<16){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(J.head)J.head.xflags=P&255,J.head.os=P>>8;if(J.flags&512&&J.wrap&4)w[0]=P&255,w[1]=P>>>8&255,J.check=o(J.check,w,2,0);P=0,F=0,J.mode=B5;case B5:if(J.flags&1024){while(F<16){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(J.length=P,J.head)J.head.extra_len=P;if(J.flags&512&&J.wrap&4)w[0]=P&255,w[1]=P>>>8&255,J.check=o(J.check,w,2,0);P=0,F=0}else if(J.head)J.head.extra=null;J.mode=M5;case M5:if(J.flags&1024){if(z=J.length,z>q)z=q;if(z){if(J.head){if(I=J.head.extra_len-J.length,!J.head.extra)J.head.extra=new Uint8Array(J.head.extra_len);J.head.extra.set(V.subarray(X,X+z),I)}if(J.flags&512&&J.wrap&4)J.check=o(J.check,V,z,X);q-=z,X+=z,J.length-=z}if(J.length)break W}J.length=0,J.mode=R5;case R5:if(J.flags&2048){if(q===0)break W;z=0;do if(I=V[X+z++],J.head&&I&&J.length<65536)J.head.name+=String.fromCharCode(I);while(I&&z<q);if(J.flags&512&&J.wrap&4)J.check=o(J.check,V,z,X);if(q-=z,X+=z,I)break W}else if(J.head)J.head.name=null;J.length=0,J.mode=L5;case L5:if(J.flags&4096){if(q===0)break W;z=0;do if(I=V[X+z++],J.head&&I&&J.length<65536)J.head.comment+=String.fromCharCode(I);while(I&&z<q);if(J.flags&512&&J.wrap&4)J.check=o(J.check,V,z,X);if(q-=z,X+=z,I)break W}else if(J.head)J.head.comment=null;J.mode=O5;case O5:if(J.flags&512){while(F<16){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(J.wrap&4&&P!==(J.check&65535)){W.msg="header crc mismatch",J.mode=l;break}P=0,F=0}if(J.head)J.head.hcrc=J.flags>>9&1,J.head.done=!0;W.adler=J.check=0,J.mode=R0;break;case I5:while(F<32){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}W.adler=J.check=f5(P),P=0,F=0,J.mode=P8;case P8:if(J.havedict===0)return W.next_out=Y,W.avail_out=U,W.next_in=X,W.avail_in=q,J.hold=P,J.bits=F,s9;W.adler=J.check=1,J.mode=R0;case R0:if(Q===n9||Q===Q8)break W;case u8:if(J.last){P>>>=F&7,F-=F&7,J.mode=c8;break}while(F<3){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}switch(J.last=P&1,P>>>=1,F-=1,P&3){case 0:J.mode=D5;break;case 1:if(XQ(J),J.mode=V8,Q===Q8){P>>>=2,F-=2;break W}break;case 2:J.mode=w5;break;case 3:W.msg="invalid block type",J.mode=l}P>>>=2,F-=2;break;case D5:P>>>=F&7,F-=F&7;while(F<32){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if((P&65535)!==(P>>>16^65535)){W.msg="invalid stored block lengths",J.mode=l;break}if(J.length=P&65535,P=0,F=0,J.mode=d8,Q===Q8)break W;case d8:J.mode=x5;case x5:if(z=J.length,z){if(z>q)z=q;if(z>U)z=U;if(z===0)break W;G.set(V.subarray(X,X+z),Y),q-=z,X+=z,U-=z,Y+=z,J.length-=z;break}J.mode=R0;break;case w5:while(F<14){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(J.nlen=(P&31)+257,P>>>=5,F-=5,J.ndist=(P&31)+1,P>>>=5,F-=5,J.ncode=(P&15)+4,P>>>=4,F-=4,J.nlen>286||J.ndist>30){W.msg="too many length or distance symbols",J.mode=l;break}J.have=0,J.mode=N5;case N5:while(J.have<J.ncode){while(F<3){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}J.lens[M[J.have++]]=P&7,P>>>=3,F-=3}while(J.have<19)J.lens[M[J.have++]]=0;if(J.lencode=J.lendyn,J.lenbits=7,Z={bits:J.lenbits},L=N1(o9,J.lens,0,19,J.lencode,0,J.work,Z),J.lenbits=Z.bits,L){W.msg="invalid code lengths set",J.mode=l;break}J.have=0,J.mode=g5;case g5:while(J.have<J.nlen+J.ndist){for(;;){if(v=J.lencode[P&(1<<J.lenbits)-1],y=v>>>24,E=v>>>16&255,p=v&65535,y<=F)break;if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(p<16)P>>>=y,F-=y,J.lens[J.have++]=p;else{if(p===16){k=y+2;while(F<k){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(P>>>=y,F-=y,J.have===0){W.msg="invalid bit length repeat",J.mode=l;break}I=J.lens[J.have-1],z=3+(P&3),P>>>=2,F-=2}else if(p===17){k=y+3;while(F<k){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}P>>>=y,F-=y,I=0,z=3+(P&7),P>>>=3,F-=3}else{k=y+7;while(F<k){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}P>>>=y,F-=y,I=0,z=11+(P&127),P>>>=7,F-=7}if(J.have+z>J.nlen+J.ndist){W.msg="invalid bit length repeat",J.mode=l;break}while(z--)J.lens[J.have++]=I}}if(J.mode===l)break;if(J.lens[256]===0){W.msg="invalid code -- missing end-of-block",J.mode=l;break}if(J.lenbits=9,Z={bits:J.lenbits},L=N1(U7,J.lens,0,J.nlen,J.lencode,0,J.work,Z),J.lenbits=Z.bits,L){W.msg="invalid literal/lengths set",J.mode=l;break}if(J.distbits=6,J.distcode=J.distdyn,Z={bits:J.distbits},L=N1(F7,J.lens,J.nlen,J.ndist,J.distcode,0,J.work,Z),J.distbits=Z.bits,L){W.msg="invalid distances set",J.mode=l;break}if(J.mode=V8,Q===Q8)break W;case V8:J.mode=G8;case G8:if(q>=6&&U>=258){if(W.next_out=Y,W.avail_out=U,W.next_in=X,W.avail_in=q,J.hold=P,J.bits=F,d9(W,K),Y=W.next_out,G=W.output,U=W.avail_out,X=W.next_in,V=W.input,q=W.avail_in,P=J.hold,F=J.bits,J.mode===R0)J.back=-1;break}J.back=0;for(;;){if(v=J.lencode[P&(1<<J.lenbits)-1],y=v>>>24,E=v>>>16&255,p=v&65535,y<=F)break;if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(E&&(E&240)===0){x=y,f=E,d=p;for(;;){if(v=J.lencode[d+((P&(1<<x+f)-1)>>x)],y=v>>>24,E=v>>>16&255,p=v&65535,x+y<=F)break;if(q===0)break W;q--,P+=V[X++]<<F,F+=8}P>>>=x,F-=x,J.back+=x}if(P>>>=y,F-=y,J.back+=y,J.length=p,E===0){J.mode=y5;break}if(E&32){J.back=-1,J.mode=R0;break}if(E&64){W.msg="invalid literal/length code",J.mode=l;break}J.extra=E&15,J.mode=v5;case v5:if(J.extra){k=J.extra;while(F<k){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}J.length+=P&(1<<J.extra)-1,P>>>=J.extra,F-=J.extra,J.back+=J.extra}J.was=J.length,J.mode=S5;case S5:for(;;){if(v=J.distcode[P&(1<<J.distbits)-1],y=v>>>24,E=v>>>16&255,p=v&65535,y<=F)break;if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if((E&240)===0){x=y,f=E,d=p;for(;;){if(v=J.distcode[d+((P&(1<<x+f)-1)>>x)],y=v>>>24,E=v>>>16&255,p=v&65535,x+y<=F)break;if(q===0)break W;q--,P+=V[X++]<<F,F+=8}P>>>=x,F-=x,J.back+=x}if(P>>>=y,F-=y,J.back+=y,E&64){W.msg="invalid distance code",J.mode=l;break}J.offset=p,J.extra=E&15,J.mode=T5;case T5:if(J.extra){k=J.extra;while(F<k){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}J.offset+=P&(1<<J.extra)-1,P>>>=J.extra,F-=J.extra,J.back+=J.extra}if(J.offset>J.dmax){W.msg="invalid distance too far back",J.mode=l;break}J.mode=A5;case A5:if(U===0)break W;if(z=K-U,J.offset>z){if(z=J.offset-z,z>J.whave){if(J.sane){W.msg="invalid distance too far back",J.mode=l;break}}if(z>J.wnext)z-=J.wnext,$=J.wsize-z;else $=J.wnext-z;if(z>J.length)z=J.length;N=J.window}else N=G,$=Y-J.offset,z=J.length;if(z>U)z=U;U-=z,J.length-=z;do G[Y++]=N[$++];while(--z);if(J.length===0)J.mode=G8;break;case y5:if(U===0)break W;G[Y++]=J.length,U--,J.mode=G8;break;case c8:if(J.wrap){while(F<32){if(q===0)break W;q--,P|=V[X++]<<F,F+=8}if(K-=U,W.total_out+=K,J.total+=K,J.wrap&4&&K)W.adler=J.check=J.flags?o(J.check,G,K,Y-K):A1(J.check,G,K,Y-K);if(K=U,J.wrap&4&&(J.flags?P:f5(P))!==J.check){W.msg="incorrect data check",J.mode=l;break}P=0,F=0}J.mode=E5;case E5:if(J.wrap&&J.flags){while(F<32){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(J.wrap&4&&P!==(J.total&4294967295)){W.msg="incorrect length check",J.mode=l;break}P=0,F=0}J.mode=p5;case p5:L=a9;break W;case l:L=K7;break W;case Z7:return z7;case k7:default:return K0}if(W.next_out=Y,W.avail_out=U,W.next_in=X,W.avail_in=q,J.hold=P,J.bits=F,J.wsize||K!==W.avail_out&&J.mode<l&&(J.mode<c8||Q!==k5)){if(B7(W,W.output,W.next_out,K-W.avail_out));}if(C-=W.avail_in,K-=W.avail_out,W.total_in+=C,W.total_out+=K,J.total+=K,J.wrap&4&&K)W.adler=J.check=J.flags?o(J.check,G,K,W.next_out-K):A1(J.check,G,K,W.next_out-K);if(W.data_type=J.bits+(J.last?64:0)+(J.mode===R0?128:0)+(J.mode===V8||J.mode===d8?256:0),(C===0&&K===0||Q===k5)&&L===c0)L=e9;return L},qQ=(W)=>{if(i0(W))return K0;let Q=W.state;if(Q.window)Q.window=null;return W.state=null,c0},PQ=(W,Q)=>{if(i0(W))return K0;const J=W.state;if((J.wrap&2)===0)return K0;return J.head=Q,Q.done=!1,c0},UQ=(W,Q)=>{const J=Q.length;let V,G,X;if(i0(W))return K0;if(V=W.state,V.wrap!==0&&V.mode!==P8)return K0;if(V.mode===P8){if(G=1,G=A1(G,Q,J,0),G!==V.check)return K7}if(X=B7(W,Q,J,J),X)return V.mode=Z7,z7;return V.havedict=1,c0},FQ=C7,KQ=$7,zQ=H7,ZQ=GQ,kQ=j7,HQ=YQ,CQ=qQ,$Q=PQ,jQ=UQ,BQ="pako inflate (from Nodeca project)",O0={inflateReset:FQ,inflateReset2:KQ,inflateResetKeep:zQ,inflateInit:ZQ,inflateInit2:kQ,inflate:HQ,inflateEnd:CQ,inflateGetHeader:$Q,inflateSetDictionary:jQ,inflateInfo:BQ},RQ=MQ,M7=Object.prototype.toString,{Z_NO_FLUSH:LQ,Z_FINISH:OQ,Z_OK:p1,Z_STREAM_END:l8,Z_NEED_DICT:r8,Z_STREAM_ERROR:IQ,Z_DATA_ERROR:b5,Z_MEM_ERROR:DQ}=_0;m1.prototype.push=function(W,Q){const J=this.strm,V=this.options.chunkSize,G=this.options.dictionary;let X,Y,q;if(this.ended)return!1;if(Q===~~Q)Y=Q;else Y=Q===!0?OQ:LQ;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(V),J.next_out=0,J.avail_out=V;if(X=O0.inflate(J,Y),X===r8&&G){if(X=O0.inflateSetDictionary(J,G),X===p1)X=O0.inflate(J,Y);else if(X===b5)X=r8}while(J.avail_in>0&&X===l8&&J.state.wrap>0&&W[J.next_in]!==0)O0.inflateReset(J),X=O0.inflate(J,Y);switch(X){case IQ:case b5:case r8:case DQ:return this.onEnd(X),this.ended=!0,!1}if(q=J.avail_out,J.next_out){if(J.avail_out===0||X===l8)if(this.options.to==="string"){let U=E1.utf8border(J.output,J.next_out),P=J.next_out-U,F=E1.buf2string(J.output,U);if(J.next_out=P,J.avail_out=V-P,P)J.output.set(J.output.subarray(U,U+P),0);this.onData(F)}else this.onData(J.output.length===J.next_out?J.output:J.output.subarray(0,J.next_out))}if(X===p1&&q===0)continue;if(X===l8)return X=O0.inflateEnd(this.strm),this.onEnd(X),this.ended=!0,!0;if(J.avail_in===0)break}return!0};m1.prototype.onData=function(W){this.chunks.push(W)};m1.prototype.onEnd=function(W){if(W===p1)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=F8.flattenChunks(this.chunks);this.chunks=[],this.err=W,this.msg=this.strm.msg};var wQ=m1,NQ=U6,gQ=xQ,vQ=U6,SQ=_0,TQ={Inflate:wQ,inflate:NQ,inflateRaw:gQ,ungzip:vQ,constants:SQ},{Deflate:AQ,deflate:yQ,deflateRaw:EQ,gzip:pQ}=m9,{Inflate:fQ,inflate:hQ,inflateRaw:bQ,ungzip:mQ}=TQ,uQ=AQ,dQ=yQ,cQ=EQ,_Q=pQ,iQ=fQ,lQ=hQ,rQ=bQ,oQ=mQ,nQ=_0,l0={Deflate:uQ,deflate:dQ,deflateRaw:cQ,gzip:_Q,Inflate:iQ,inflate:lQ,inflateRaw:rQ,ungzip:oQ,constants:nQ};var w8=function(W){return W instanceof Uint8Array||ArrayBuffer.isView(W)&&W.constructor.name==="Uint8Array"},B6=function(W){if(!Number.isSafeInteger(W)||W<0)throw Error("positive integer expected, got "+W)},e0=function(W,...Q){if(!w8(W))throw Error("Uint8Array expected");if(Q.length>0&&!Q.includes(W.length))throw Error("Uint8Array expected of length "+Q+", got length="+W.length)},c7=function(W){if(typeof W!="function"||typeof W.create!="function")throw Error("Hash should be wrapped by utils.createHasher");B6(W.outputLen),B6(W.blockLen)},j8=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")},B8=function(...W){for(let Q=0;Q<W.length;Q++)W[Q].fill(0)},F6=function(W){return new DataView(W.buffer,W.byteOffset,W.byteLength)},j0=function(W,Q){return W<<32-Q|W>>>Q},H1=function(W){if(e0(W),_7)return W.toHex();let Q="";for(let J=0;J<W.length;J++)Q+=aQ[W[J]];return Q},I7=function(W){return W>=R7&&W<=sQ?W-R7:W>=L7&&W<=eQ?W-(L7-10):W>=O7&&W<=tQ?W-(O7-10):void 0},M8=function(W){if(typeof W!="string")throw Error("hex string expected, got "+typeof W);if(_7)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 V=new Uint8Array(J);for(let G=0,X=0;G<J;G++,X+=2){const Y=I7(W.charCodeAt(X)),q=I7(W.charCodeAt(X+1));if(Y===void 0||q===void 0){const U=W[X]+W[X+1];throw Error('hex string expected, got non-hex character "'+U+'" at index '+X)}V[G]=16*Y+q}return V},i7=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=i7(W)),e0(W),W},B0=function(...W){let Q=0;for(let V=0;V<W.length;V++){const G=W[V];e0(G),Q+=G.length}const J=new Uint8Array(Q);for(let V=0,G=0;V<W.length;V++){const X=W[V];J.set(X,G),G+=X.length}return J},WV=function(W){const Q=(V)=>W().update(N6(V)).digest(),J=W();return Q.outputLen=J.outputLen,Q.blockLen=J.blockLen,Q.create=()=>W(),Q},R8=function(W=32){if(F1&&typeof F1.getRandomValues=="function")return F1.getRandomValues(new Uint8Array(W));if(F1&&typeof F1.randomBytes=="function")return Uint8Array.from(F1.randomBytes(W));throw Error("crypto.getRandomValues must be defined")},JV=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},r0=function(W,Q,J=""){const V=w8(W),G=W?.length,X=Q!==void 0;if(!V||X&&G!==Q)throw Error((J&&`"${J}" `)+"expected Uint8Array"+(X?" of length "+Q:"")+", got "+(V?"length="+G:"type="+typeof W));return W},z8=function(W){const Q=W.toString(16);return 1&Q.length?"0"+Q:Q},n7=function(W){if(typeof W!="string")throw Error("hex string expected, got "+typeof W);return W===""?S6:BigInt("0x"+W)},j1=function(W){return n7(H1(W))},a7=function(W){return e0(W),n7(H1(Uint8Array.from(W).reverse()))},N8=function(W,Q){return M8(W.toString(16).padStart(2*Q,"0"))},s7=function(W,Q){return N8(W,Q).reverse()},r=function(W,Q,J){let V;if(typeof Q=="string")try{V=M8(Q)}catch(X){throw Error(W+" must be hex string or Uint8Array, cause: "+X)}else{if(!w8(Q))throw Error(W+" must be hex string or Uint8Array");V=Uint8Array.from(Q)}const G=V.length;if(typeof J=="number"&&G!==J)throw Error(W+" of length "+J+" expected, got "+G);return V},L6=function(W,Q,J){return K6(W)&&K6(Q)&&K6(J)&&Q<=W&&W<J},e7=function(W){let Q;for(Q=0;W>S6;W>>=R6,Q+=1);return Q},T6=function(W,Q,J={}){if(!W||typeof W!="object")throw Error("expected valid options object");function V(G,X,Y){const q=W[G];if(Y&&q===void 0)return;const U=typeof q;if(U!==X||q===null)throw Error(`param "${G}" is invalid: expected ${X}, got ${U}`)}Object.entries(Q).forEach(([G,X])=>V(G,X,!1)),Object.entries(J).forEach(([G,X])=>V(G,X,!0))},D7=function(W){const Q=new WeakMap;return(J,...V)=>{const G=Q.get(J);if(G!==void 0)return G;const X=W(J,...V);return Q.set(J,X),X}},Z0=function(W,Q){const J=W%Q;return J>=G0?J:Q+J},z0=function(W,Q,J){let V=W;for(;Q-- >G0;)V*=V,V%=J;return V},w7=function(W,Q){if(W===G0)throw Error("invert: expected non-zero number");if(Q<=G0)throw Error("invert: expected positive modulus, got "+Q);let J=Z0(W,Q),V=Q,G=G0,X=W0;for(;J!==G0;){const Y=V%J,q=G-X*(V/J);V=J,J=Y,G=X,X=q}if(V!==W0)throw Error("invert: does not exist");return Z0(G,Q)},A6=function(W,Q,J){if(!W.eql(W.sqr(Q),J))throw Error("Cannot find square root")},VW=function(W,Q){const J=(W.ORDER+W0)/WW,V=W.pow(Q,J);return A6(W,V,Q),V},XV=function(W,Q){const J=(W.ORDER-JW)/QW,V=W.mul(Q,n0),G=W.pow(V,J),X=W.mul(Q,G),Y=W.mul(W.mul(X,n0),G),q=W.mul(X,W.sub(Y,W.ONE));return A6(W,q,Q),q},N7=function(W){if(W<t7)throw Error("sqrt is not defined for small field");let Q=W-W0,J=0;for(;Q%n0===G0;)Q/=n0,J++;let V=n0;const G=l1(W);for(;g7(G,V)===1;)if(V++>1000)throw Error("Cannot find square root: probably non-prime P");if(J===1)return VW;let X=G.pow(V,Q);const Y=(Q+W0)/n0;return function(q,U){if(q.is0(U))return U;if(g7(q,U)!==1)throw Error("Cannot find square root");let P=J,F=q.mul(q.ONE,X),C=q.pow(U,Q),K=q.pow(U,Y);for(;!q.eql(C,q.ONE);){if(q.is0(C))return q.ZERO;let z=1,$=q.sqr(C);for(;!q.eql($,q.ONE);)if(z++,$=q.sqr($),z===P)throw Error("Cannot find square root");const N=W0<<BigInt(P-z-1),v=q.pow(F,N);P=z,F=q.sqr(v),C=q.mul(C,F),K=q.mul(K,v)}return K}},YV=function(W){return W%WW===t7?VW:W%QW===JW?XV:W%x7===GV?function(Q){const J=l1(Q),V=N7(Q),G=V(J,J.neg(J.ONE)),X=V(J,G),Y=V(J,J.neg(G)),q=(Q+VV)/x7;return(U,P)=>{let F=U.pow(P,q),C=U.mul(F,G);const K=U.mul(F,X),z=U.mul(F,Y),$=U.eql(U.sqr(C),P),N=U.eql(U.sqr(K),P);F=U.cmov(F,C,$),C=U.cmov(z,K,N);const v=U.eql(U.sqr(C),P),y=U.cmov(F,C,v);return A6(U,y,P),y}}(W):N7(W)},GW=function(W,Q,J=!1){const V=Array(Q.length).fill(J?W.ZERO:void 0),G=Q.reduce((Y,q,U)=>W.is0(q)?Y:(V[U]=Y,W.mul(Y,q)),W.ONE),X=W.inv(G);return Q.reduceRight((Y,q,U)=>W.is0(q)?Y:(V[U]=W.mul(Y,V[U]),W.mul(Y,q)),X),V},g7=function(W,Q){const J=(W.ORDER-W0)/n0,V=W.pow(Q,J),G=W.eql(V,W.ONE),X=W.eql(V,W.ZERO),Y=W.eql(V,W.neg(W.ONE));if(!G&&!X&&!Y)throw Error("invalid Legendre symbol result");return G?1:X?0:-1},XW=function(W,Q){Q!==void 0&&B6(Q);const J=Q!==void 0?Q:W.toString(2).length;return{nBitLength:J,nByteLength:Math.ceil(J/8)}},l1=function(W,Q,J=!1,V={}){if(W<=G0)throw Error("invalid field: expected ORDER > 0, got "+W);let G,X,Y,q=!1;if(typeof Q=="object"&&Q!=null){if(V.sqrt||J)throw Error("cannot specify opts in two arguments");const K=Q;K.BITS&&(G=K.BITS),K.sqrt&&(X=K.sqrt),typeof K.isLE=="boolean"&&(J=K.isLE),typeof K.modFromBytes=="boolean"&&(q=K.modFromBytes),Y=K.allowedLengths}else typeof Q=="number"&&(G=Q),V.sqrt&&(X=V.sqrt);const{nBitLength:U,nByteLength:P}=XW(W,G);if(P>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");let F;const C=Object.freeze({ORDER:W,isLE:J,BITS:U,BYTES:P,MASK:i1(U),ZERO:G0,ONE:W0,allowedLengths:Y,create(K){return Z0(K,W)},isValid(K){if(typeof K!="bigint")throw Error("invalid field element: expected bigint, got "+typeof K);return G0<=K&&K<W},is0(K){return K===G0},isValidNot0(K){return!C.is0(K)&&C.isValid(K)},isOdd(K){return(K&W0)===W0},neg(K){return Z0(-K,W)},eql(K,z){return K===z},sqr(K){return Z0(K*K,W)},add(K,z){return Z0(K+z,W)},sub(K,z){return Z0(K-z,W)},mul(K,z){return Z0(K*z,W)},pow(K,z){return function($,N,v){if(v<G0)throw Error("invalid exponent, negatives unsupported");if(v===G0)return $.ONE;if(v===W0)return N;let y=$.ONE,E=N;for(;v>G0;)v&W0&&(y=$.mul(y,E)),E=$.sqr(E),v>>=W0;return y}(C,K,z)},div(K,z){return Z0(K*w7(z,W),W)},sqrN(K){return K*K},addN(K,z){return K+z},subN(K,z){return K-z},mulN(K,z){return K*z},inv(K){return w7(K,W)},sqrt:X||((K)=>(F||(F=YV(W)),F(C,K))),toBytes(K){return J?s7(K,P):N8(K,P)},fromBytes(K,z=!0){if(Y){if(!Y.includes(K.length)||K.length>P)throw Error("Field.fromBytes: expected "+Y+" bytes, got "+K.length);const N=new Uint8Array(P);N.set(K,J?0:N.length-K.length),K=N}if(K.length!==P)throw Error("Field.fromBytes: expected "+P+" bytes, got "+K.length);let $=J?a7(K):j1(K);if(q&&($=Z0($,W)),!z&&!C.isValid($))throw Error("invalid field element: outside of range 0..ORDER");return $},invertBatch(K){return GW(C,K)},cmov(K,z,$){return $?z:K}});return Object.freeze(C)},YW=function(W){if(typeof W!="bigint")throw Error("field order must be bigint");const Q=W.toString(2).length;return Math.ceil(Q/8)},qW=function(W){const Q=YW(W);return Q+Math.ceil(Q/2)},PW=function(W,Q,J=!1){const V=W.length,G=YW(Q),X=qW(Q);if(V<16||V<X||V>1024)throw Error("expected "+X+"-1024 bytes of input, got "+V);const Y=Z0(J?a7(W):j1(W),Q-W0)+W0;return J?s7(Y,G):N8(Y,G)},O8=function(W,Q){const J=Q.negate();return W?J:Q},z6=function(W,Q){const J=GW(W.Fp,Q.map((V)=>V.Z));return Q.map((V,G)=>W.fromAffine(V.toAffine(J[G])))},UW=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){UW(W,Q);const J=2**W;return{windows:Math.ceil(Q/W)+1,windowSize:2**(W-1),mask:i1(W),maxNumber:J,shiftBy:BigInt(W)}},v7=function(W,Q,J){const{windowSize:V,mask:G,maxNumber:X,shiftBy:Y}=J;let q=Number(W&G),U=W>>Y;q>V&&(q-=X,U+=a0);const P=Q*V;return{nextN:U,offset:P+Math.abs(q)-1,isZero:q===0,isNeg:q<0,isNegF:Q%2!=0,offsetF:P}},H6=function(W){return FW.get(W)||1},S7=function(W){if(W!==C1)throw Error("invalid wNAF")},PV=function(W,Q,J,V){(function(K,z){if(!Array.isArray(K))throw Error("array expected");K.forEach(($,N)=>{if(!($ instanceof z))throw Error("invalid point at index "+N)})})(J,W),function(K,z){if(!Array.isArray(K))throw Error("array of scalars expected");K.forEach(($,N)=>{if(!z.isValid($))throw Error("invalid scalar at index "+N)})}(V,Q);const G=J.length,X=V.length;if(G!==X)throw Error("arrays of points and scalars must have equal length");const Y=W.ZERO,q=e7(BigInt(G));let U=1;q>12?U=q-3:q>4?U=q-2:q>0&&(U=2);const P=i1(U),F=Array(Number(P)+1).fill(Y);let C=Y;for(let K=Math.floor((Q.BITS-1)/U)*U;K>=0;K-=U){F.fill(Y);for(let $=0;$<X;$++){const N=V[$],v=Number(N>>BigInt(K)&P);F[v]=F[v].add(J[$])}let z=Y;for(let $=F.length-1,N=Y;$>0;$--)N=N.add(F[$]),z=z.add(N);if(C=C.add(z),K!==0)for(let $=0;$<U;$++)C=C.double()}return C},T7=function(W,Q,J){if(Q){if(Q.ORDER!==W)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return function(V){T6(V,qV.reduce((G,X)=>(G[X]="function",G),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"}))}(Q),Q}return l1(W,{isLE:J})},O6=function(W){if(!["compact","recovered","der"].includes(W))throw Error('Signature format must be "compact", "recovered", or "der"');return W},C6=function(W,Q){const J={};for(let V of Object.keys(Q))J[V]=W[V]===void 0?Q[V]:W[V];return L8(J.lowS,"lowS"),L8(J.prehash,"prehash"),J.format!==void 0&&O6(J.format),J},o0=function(W,Q){const{BYTES:J}=W;let V;if(typeof Q=="bigint")V=Q;else{let G=r("private key",Q);try{V=W.fromBytes(G)}catch(X){throw Error(`invalid private key: expected ui8a of size ${J}, got ${typeof Q}`)}}if(!W.isValidNot0(V))throw Error("invalid private key: out of range [1..N-1]");return V},FV=function(W,Q={}){const J=function(Z,k,M={},H){if(H===void 0&&(H=Z==="edwards"),!k||typeof k!="object")throw Error(`expected valid ${Z} CURVE object`);for(let D of["p","n","h"]){const B=k[D];if(!(typeof B=="bigint"&&B>C1))throw Error(`CURVE.${D} must be positive bigint`)}const j=T7(k.p,M.Fp,H),O=T7(k.n,M.Fn,H),R=["Gx","Gy","a","b"];for(let D of R)if(!j.isValid(k[D]))throw Error(`CURVE.${D} must be valid field element of CURVE.Fp`);return{CURVE:k=Object.freeze(Object.assign({},k)),Fp:j,Fn:O}}("weierstrass",W,Q),{Fp:V,Fn:G}=J;let X=J.CURVE;const{h:Y,n:q}=X;T6(Q,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:U}=Q;if(U&&(!V.is0(X.a)||typeof U.beta!="bigint"||!Array.isArray(U.basises)))throw Error('invalid endo: expected "beta": bigint and "basises": array');const P=kW(V,G);function F(){if(!V.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}const C=Q.toBytes||function(Z,k,M){const{x:H,y:j}=k.toAffine(),O=V.toBytes(H);if(L8(M,"isCompressed"),M)return F(),B0(ZW(!V.isOdd(j)),O);return B0(Uint8Array.of(4),O,V.toBytes(j))},K=Q.fromBytes||function(Z){r0(Z,void 0,"Point");const{publicKey:k,publicKeyUncompressed:M}=P,H=Z.length,j=Z[0],O=Z.subarray(1);if(H!==k||j!==2&&j!==3){if(H===M&&j===4){const R=V.BYTES,D=V.fromBytes(O.subarray(0,R)),B=V.fromBytes(O.subarray(R,2*R));if(!$(D,B))throw Error("bad point: is not on curve");return{x:D,y:B}}throw Error(`bad point: got length ${H}, expected compressed=${k} or uncompressed=${M}`)}{const R=V.fromBytes(O);if(!V.isValid(R))throw Error("bad point: is not on curve, wrong x");const D=z(R);let B;try{B=V.sqrt(D)}catch(g){const T=g instanceof Error?": "+g.message:"";throw Error("bad point: is not on curve, sqrt error"+T)}return F(),!(1&~j)!==V.isOdd(B)&&(B=V.neg(B)),{x:R,y:B}}};function z(Z){const k=V.sqr(Z),M=V.mul(k,Z);return V.add(V.add(M,V.mul(Z,X.a)),X.b)}function $(Z,k){const M=V.sqr(k),H=z(Z);return V.eql(M,H)}if(!$(X.Gx,X.Gy))throw Error("bad curve params: generator point");const N=V.mul(V.pow(X.a,Z8),UV),v=V.mul(V.sqr(X.b),BigInt(27));if(V.is0(V.add(N,v)))throw Error("bad curve params: a or b");function y(Z,k,M=!1){if(!V.isValid(k)||M&&V.is0(k))throw Error("bad point coordinate "+Z);return k}function E(Z){if(!(Z instanceof I))throw Error("ProjectivePoint expected")}function p(Z){if(!U||!U.basises)throw Error("no endo");return function(k,M,H){const[[j,O],[R,D]]=M,B=A7(D*k,H),g=A7(-O*k,H);let T=k-B*j-g*R,S=-B*O-g*D;const A=T<x0,h=S<x0;A&&(T=-T),h&&(S=-S);const b=i1(Math.ceil(e7(H)/2))+Z1;if(T<x0||T>=b||S<x0||S>=b)throw Error("splitScalar (endomorphism): failed, k="+k);return{k1neg:A,k1:T,k2neg:h,k2:S}}(Z,U.basises,G.ORDER)}const x=D7((Z,k)=>{const{X:M,Y:H,Z:j}=Z;if(V.eql(j,V.ONE))return{x:M,y:H};const O=Z.is0();k==null&&(k=O?V.ONE:V.inv(j));const R=V.mul(M,k),D=V.mul(H,k),B=V.mul(j,k);if(O)return{x:V.ZERO,y:V.ZERO};if(!V.eql(B,V.ONE))throw Error("invZ was invalid");return{x:R,y:D}}),f=D7((Z)=>{if(Z.is0()){if(Q.allowInfinityPoint&&!V.is0(Z.Y))return;throw Error("bad point: ZERO")}const{x:k,y:M}=Z.toAffine();if(!V.isValid(k)||!V.isValid(M))throw Error("bad point: x or y not field elements");if(!$(k,M))throw Error("bad point: equation left != right");if(!Z.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function d(Z,k,M,H,j){return M=new I(V.mul(M.X,Z),M.Y,M.Z),k=O8(H,k),M=O8(j,M),k.add(M)}class I{constructor(Z,k,M){this.X=y("x",Z),this.Y=y("y",k,!0),this.Z=y("z",M),Object.freeze(this)}static CURVE(){return X}static fromAffine(Z){const{x:k,y:M}=Z||{};if(!Z||!V.isValid(k)||!V.isValid(M))throw Error("invalid affine point");if(Z instanceof I)throw Error("projective point not allowed");return V.is0(k)&&V.is0(M)?I.ZERO:new I(k,M,V.ONE)}static fromBytes(Z){const k=I.fromAffine(K(r0(Z,void 0,"point")));return k.assertValidity(),k}static fromHex(Z){return I.fromBytes(r("pointHex",Z))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(Z=8,k=!0){return w.createCache(this,Z),k||this.multiply(Z8),this}assertValidity(){f(this)}hasEvenY(){const{y:Z}=this.toAffine();if(!V.isOdd)throw Error("Field doesn't support isOdd");return!V.isOdd(Z)}equals(Z){E(Z);const{X:k,Y:M,Z:H}=this,{X:j,Y:O,Z:R}=Z,D=V.eql(V.mul(k,R),V.mul(j,H)),B=V.eql(V.mul(M,R),V.mul(O,H));return D&&B}negate(){return new I(this.X,V.neg(this.Y),this.Z)}double(){const{a:Z,b:k}=X,M=V.mul(k,Z8),{X:H,Y:j,Z:O}=this;let{ZERO:R,ZERO:D,ZERO:B}=V,g=V.mul(H,H),T=V.mul(j,j),S=V.mul(O,O),A=V.mul(H,j);return A=V.add(A,A),B=V.mul(H,O),B=V.add(B,B),R=V.mul(Z,B),D=V.mul(M,S),D=V.add(R,D),R=V.sub(T,D),D=V.add(T,D),D=V.mul(R,D),R=V.mul(A,R),B=V.mul(M,B),S=V.mul(Z,S),A=V.sub(g,S),A=V.mul(Z,A),A=V.add(A,B),B=V.add(g,g),g=V.add(B,g),g=V.add(g,S),g=V.mul(g,A),D=V.add(D,g),S=V.mul(j,O),S=V.add(S,S),g=V.mul(S,A),R=V.sub(R,g),B=V.mul(S,T),B=V.add(B,B),B=V.add(B,B),new I(R,D,B)}add(Z){E(Z);const{X:k,Y:M,Z:H}=this,{X:j,Y:O,Z:R}=Z;let{ZERO:D,ZERO:B,ZERO:g}=V;const T=X.a,S=V.mul(X.b,Z8);let A=V.mul(k,j),h=V.mul(M,O),b=V.mul(H,R),m=V.add(k,M),_=V.add(j,O);m=V.mul(m,_),_=V.add(A,h),m=V.sub(m,_),_=V.add(k,H);let i=V.add(j,R);return _=V.mul(_,i),i=V.add(A,b),_=V.sub(_,i),i=V.add(M,H),D=V.add(O,R),i=V.mul(i,D),D=V.add(h,b),i=V.sub(i,D),g=V.mul(T,_),D=V.mul(S,b),g=V.add(D,g),D=V.sub(h,g),g=V.add(h,g),B=V.mul(D,g),h=V.add(A,A),h=V.add(h,A),b=V.mul(T,b),_=V.mul(S,_),h=V.add(h,b),b=V.sub(A,b),b=V.mul(T,b),_=V.add(_,b),A=V.mul(h,_),B=V.add(B,A),A=V.mul(i,_),D=V.mul(m,D),D=V.sub(D,A),A=V.mul(m,h),g=V.mul(i,g),g=V.add(g,A),new I(D,B,g)}subtract(Z){return this.add(Z.negate())}is0(){return this.equals(I.ZERO)}multiply(Z){const{endo:k}=Q;if(!G.isValidNot0(Z))throw Error("invalid scalar: out of range");let M,H;const j=(O)=>w.cached(this,O,(R)=>z6(I,R));if(k){const{k1neg:O,k1:R,k2neg:D,k2:B}=p(Z),{p:g,f:T}=j(R),{p:S,f:A}=j(B);H=T.add(A),M=d(k.beta,g,S,O,D)}else{const{p:O,f:R}=j(Z);M=O,H=R}return z6(I,[M,H])[0]}multiplyUnsafe(Z){const{endo:k}=Q,M=this;if(!G.isValid(Z))throw Error("invalid scalar: out of range");if(Z===x0||M.is0())return I.ZERO;if(Z===Z1)return M;if(w.hasCache(this))return this.multiply(Z);if(k){const{k1neg:H,k1:j,k2neg:O,k2:R}=p(Z),{p1:D,p2:B}=function(g,T,S,A){let h=T,b=g.ZERO,m=g.ZERO;for(;S>C1||A>C1;)S&a0&&(b=b.add(h)),A&a0&&(m=m.add(h)),h=h.double(),S>>=a0,A>>=a0;return{p1:b,p2:m}}(I,M,j,R);return d(k.beta,D,B,H,O)}return w.unsafe(M,Z)}multiplyAndAddUnsafe(Z,k,M){const H=this.multiplyUnsafe(k).add(Z.multiplyUnsafe(M));return H.is0()?void 0:H}toAffine(Z){return x(this,Z)}isTorsionFree(){const{isTorsionFree:Z}=Q;return Y===Z1||(Z?Z(I,this):w.unsafe(this,q).is0())}clearCofactor(){const{clearCofactor:Z}=Q;return Y===Z1?this:Z?Z(I,this):this.multiplyUnsafe(Y)}isSmallOrder(){return this.multiplyUnsafe(Y).is0()}toBytes(Z=!0){return L8(Z,"isCompressed"),this.assertValidity(),C(I,this,Z)}toHex(Z=!0){return H1(this.toBytes(Z))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(Z=!0){return this.toBytes(Z)}_setWindowSize(Z){this.precompute(Z)}static normalizeZ(Z){return z6(I,Z)}static msm(Z,k){return PV(I,G,Z,k)}static fromPrivateKey(Z){return I.BASE.multiply(o0(G,Z))}}I.BASE=new I(X.Gx,X.Gy,V.ONE),I.ZERO=new I(V.ZERO,V.ONE,V.ZERO),I.Fp=V,I.Fn=G;const L=G.BITS,w=new KW(I,Q.endo?Math.ceil(L/2):L);return I.BASE.precompute(8),I},ZW=function(W){return Uint8Array.of(W?2:3)},kW=function(W,Q){return{secretKey:Q.BYTES,publicKey:1+W.BYTES,publicKeyUncompressed:1+2*W.BYTES,publicKeyHasPrefix:!0,signature:2*Q.BYTES}},KV=function(W,Q,J={}){c7(Q),T6(J,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const V=J.randomBytes||R8,G=J.hmac||((L,...w)=>o7(Q,L,B0(...w))),{Fp:X,Fn:Y}=W,{ORDER:q,BITS:U}=Y,{keygen:P,getPublicKey:F,getSharedSecret:C,utils:K,lengths:z}=function(L,w={}){const{Fn:Z}=L,k=w.randomBytes||R8,M=Object.assign(kW(L.Fp,Z),{seed:qW(Z.ORDER)});function H(B){try{return!!o0(Z,B)}catch(g){return!1}}function j(B=k(M.seed)){return PW(r0(B,M.seed,"seed"),Z.ORDER)}function O(B,g=!0){return L.BASE.multiply(o0(Z,B)).toBytes(g)}function R(B){if(typeof B=="bigint")return!1;if(B instanceof L)return!0;const{secretKey:g,publicKey:T,publicKeyUncompressed:S}=M;if(Z.allowedLengths||g===T)return;const A=r("key",B).length;return A===T||A===S}return Object.freeze({getPublicKey:O,getSharedSecret(B,g,T=!0){if(R(B)===!0)throw Error("first arg must be private key");if(R(g)===!1)throw Error("second arg must be public key");const S=o0(Z,B);return L.fromHex(g).multiply(S).toBytes(T)},keygen(B){const g=j(B);return{secretKey:g,publicKey:O(g)}},Point:L,utils:{isValidSecretKey:H,isValidPublicKey(B,g){const{publicKey:T,publicKeyUncompressed:S}=M;try{const A=B.length;return!(g===!0&&A!==T||g===!1&&A!==S||!L.fromBytes(B))}catch(A){return!1}},randomSecretKey:j,isValidPrivateKey:H,randomPrivateKey:j,normPrivateKeyToScalar:(B)=>o0(Z,B),precompute(B=8,g=L.BASE){return g.precompute(B,!1)}},lengths:M})}(W,J),$={prehash:!1,lowS:typeof J.lowS=="boolean"&&J.lowS,format:void 0,extraEntropy:!1},N="compact";function v(L){return L>q>>Z1}function y(L,w){if(!Y.isValidNot0(w))throw Error(`invalid signature ${L}: out of range 1..Point.Fn.ORDER`);return w}class E{constructor(L,w,Z){this.r=y("r",L),this.s=y("s",w),Z!=null&&(this.recovery=Z),Object.freeze(this)}static fromBytes(L,w=N){let Z;if(function(j,O){O6(O);const R=z.signature;r0(j,O==="compact"?R:O==="recovered"?R+1:void 0,O+" signature")}(L,w),w==="der"){const{r:j,s:O}=D0.toSig(r0(L));return new E(j,O)}w==="recovered"&&(Z=L[0],w="compact",L=L.subarray(1));const k=Y.BYTES,M=L.subarray(0,k),H=L.subarray(k,2*k);return new E(Y.fromBytes(M),Y.fromBytes(H),Z)}static fromHex(L,w){return this.fromBytes(M8(L),w)}addRecoveryBit(L){return new E(this.r,this.s,L)}recoverPublicKey(L){const w=X.ORDER,{r:Z,s:k,recovery:M}=this;if(M==null||![0,1,2,3].includes(M))throw Error("recovery id invalid");if(q*zW<w&&M>1)throw Error("recovery id is ambiguous for h>1 curve");const H=M===2||M===3?Z+q:Z;if(!X.isValid(H))throw Error("recovery id 2 or 3 invalid");const j=X.toBytes(H),O=W.fromBytes(B0(ZW(!(1&M)),j)),R=Y.inv(H),D=x(r("msgHash",L)),B=Y.create(-D*R),g=Y.create(k*R),T=W.BASE.multiplyUnsafe(B).add(O.multiplyUnsafe(g));if(T.is0())throw Error("point at infinify");return T.assertValidity(),T}hasHighS(){return v(this.s)}toBytes(L=N){if(O6(L),L==="der")return M8(D0.hexFromSig(this));const w=Y.toBytes(this.r),Z=Y.toBytes(this.s);if(L==="recovered"){if(this.recovery==null)throw Error("recovery bit must be present");return B0(Uint8Array.of(this.recovery),w,Z)}return B0(w,Z)}toHex(L){return H1(this.toBytes(L))}assertValidity(){}static fromCompact(L){return E.fromBytes(r("sig",L),"compact")}static fromDER(L){return E.fromBytes(r("sig",L),"der")}normalizeS(){return this.hasHighS()?new E(this.r,Y.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return H1(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return H1(this.toBytes("compact"))}}const p=J.bits2int||function(L){if(L.length>8192)throw Error("input is too large");const w=j1(L),Z=8*L.length-U;return Z>0?w>>BigInt(Z):w},x=J.bits2int_modN||function(L){return Y.create(p(L))},f=i1(U);function d(L){return function(w,Z,k,M){if(!L6(Z,k,M))throw Error("expected valid "+w+": "+k+" <= n < "+M+", got "+Z)}("num < 2^"+U,L,x0,f),Y.toBytes(L)}function I(L,w){return r0(L,void 0,"message"),w?r0(Q(L),void 0,"prehashed message"):L}return Object.freeze({keygen:P,getPublicKey:F,getSharedSecret:C,utils:K,lengths:z,Point:W,sign(L,w,Z={}){L=r("message",L);const{seed:k,k2sig:M}=function(H,j,O){if(["recovered","canonical"].some((b)=>(b in O)))throw Error("sign() legacy options not supported");const{lowS:R,prehash:D,extraEntropy:B}=C6(O,$);H=I(H,D);const g=x(H),T=o0(Y,j),S=[d(T),d(g)];if(B!=null&&B!==!1){const b=B===!0?V(z.secretKey):B;S.push(r("extraEntropy",b))}const A=B0(...S),h=g;return{seed:A,k2sig(b){const m=p(b);if(!Y.isValidNot0(m))return;const _=Y.inv(m),i=W.BASE.multiply(m).toAffine(),M0=Y.create(i.x);if(M0===x0)return;const J0=Y.create(_*Y.create(h+M0*T));if(J0===x0)return;let P0=(i.x===M0?0:2)|Number(i.y&Z1),U0=J0;return R&&v(J0)&&(U0=Y.neg(J0),P0^=1),new E(M0,U0,P0)}}}(L,w,Z);return function(H,j,O){if(typeof H!="number"||H<2)throw Error("hashLen must be a number");if(typeof j!="number"||j<2)throw Error("qByteLen must be a number");if(typeof O!="function")throw Error("hmacFn must be a function");const R=(m)=>new Uint8Array(m),D=(m)=>Uint8Array.of(m);let B=R(H),g=R(H),T=0;const S=()=>{B.fill(1),g.fill(0),T=0},A=(...m)=>O(g,B,...m),h=(m=R(0))=>{g=A(D(0),m),B=A(),m.length!==0&&(g=A(D(1),m),B=A())},b=()=>{if(T++>=1000)throw Error("drbg: tried 1000 values");let m=0;const _=[];for(;m<j;){B=A();const i=B.slice();_.push(i),m+=B.length}return B0(..._)};return(m,_)=>{let i;for(S(),h(m);!(i=_(b()));)h();return S(),i}}(Q.outputLen,Y.BYTES,G)(k,M)},verify(L,w,Z,k={}){const{lowS:M,prehash:H,format:j}=C6(k,$);if(Z=r("publicKey",Z),w=I(r("message",w),H),("strict"in k))throw Error("options.strict was renamed to lowS");const O=j===void 0?function(R){let D;const B=typeof R=="string"||w8(R),g=!B&&R!==null&&typeof R=="object"&&typeof R.r=="bigint"&&typeof R.s=="bigint";if(!B&&!g)throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(g)D=new E(R.r,R.s);else if(B){try{D=E.fromBytes(r("sig",R),"der")}catch(T){if(!(T instanceof D0.Err))throw T}if(!D)try{D=E.fromBytes(r("sig",R),"compact")}catch(T){return!1}}return D||!1}(L):E.fromBytes(r("sig",L),j);if(O===!1)return!1;try{const R=W.fromBytes(Z);if(M&&O.hasHighS())return!1;const{r:D,s:B}=O,g=x(w),T=Y.inv(B),S=Y.create(g*T),A=Y.create(D*T),h=W.BASE.multiplyUnsafe(S).add(R.multiplyUnsafe(A));if(h.is0())return!1;return Y.create(h.x)===D}catch(R){return!1}},recoverPublicKey(L,w,Z={}){const{prehash:k}=C6(Z,$);return w=I(w,k),E.fromBytes(L,"recovered").recoverPublicKey(w).toBytes()},Signature:E,hash:Q})},zV=function(W){const{CURVE:Q,curveOpts:J}=function(G){const X={a:G.a,b:G.b,p:G.Fp.ORDER,n:G.n,h:G.h,Gx:G.Gx,Gy:G.Gy},Y=G.Fp;let q=G.allowedPrivateKeyLengths?Array.from(new Set(G.allowedPrivateKeyLengths.map((U)=>Math.ceil(U/2)))):void 0;return{CURVE:X,curveOpts:{Fp:Y,Fn:l1(X.n,{BITS:G.nBitLength,allowedLengths:q,modFromBytes:G.wrapPrivateKey}),allowInfinityPoint:G.allowInfinityPoint,endo:G.endo,isTorsionFree:G.isTorsionFree,clearCofactor:G.clearCofactor,fromBytes:G.fromBytes,toBytes:G.toBytes}}}(W),V={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:V}},ZV=function(W){const{CURVE:Q,curveOpts:J,hash:V,ecdsaOpts:G}=zV(W);return function(X,Y){const q=Y.Point;return Object.assign({},Y,{ProjectivePoint:q,CURVE:Object.assign({},X,XW(q.Fn.ORDER,q.Fn.BITS))})}(W,KV(FV(Q,J),V,G))},D8=function(W,...Q){let J=E7[W];if(J===void 0){const V=M6(i7(W));J=B0(V,V),E7[W]=J}return M6(B0(J,...Q))},D6=function(W){const{Fn:Q,BASE:J}=B1,V=o0(Q,W),G=J.multiply(V);return{scalar:E6(G.y)?V:Q.neg(V),bytes:y6(G)}},CW=function(W){const Q=I8;if(!Q.isValidNot0(W))throw Error("invalid x: Fail if x \u2265 p");const J=Q.create(W*W),V=Q.create(J*W+BigInt(7));let G=Q.sqrt(V);E6(G)||(G=Q.neg(G));const X=B1.fromAffine({x:W,y:G});return X.assertValidity(),X},$W=function(...W){return B1.Fn.create(_1(D8("BIP0340/challenge",...W)))},p7=function(W){return D6(W).bytes},CV=function(W,Q,J=R8(32)){const{Fn:V}=B1,G=r("message",W),{bytes:X,scalar:Y}=D6(Q),q=r("auxRand",J,32),U=V.toBytes(Y^_1(D8("BIP0340/aux",q))),P=D8("BIP0340/nonce",U,X,G),{bytes:F,scalar:C}=D6(P),K=$W(F,X,G),z=new Uint8Array(64);if(z.set(F,0),z.set(V.toBytes(V.create(C+K*Y)),32),!jW(z,G,X))throw Error("sign: Invalid signature produced");return z},jW=function(W,Q,J){const{Fn:V,BASE:G}=B1,X=r("signature",W,64),Y=r("message",Q),q=r("publicKey",J,32);try{const U=CW(_1(q)),P=_1(X.subarray(0,32));if(!L6(P,y7,$1.p))return!1;const F=_1(X.subarray(32,64));if(!L6(F,y7,$1.n))return!1;const C=$W(V.toBytes(P),y6(U),Y),K=G.multiplyUnsafe(F).add(U.multiplyUnsafe(V.neg(C))),{x:z,y:$}=K.toAffine();return!(K.is0()||!E6($)||z!==P)}catch(U){return!1}},F1=typeof globalThis=="object"&&("crypto"in globalThis)?globalThis.crypto:void 0,_7=(()=>typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function")(),aQ=Array.from({length:256},(W,Q)=>Q.toString(16).padStart(2,"0")),R7=48,sQ=57,L7=65,eQ=70,O7=97,tQ=102;class g6{}class l7 extends g6{constructor(W,Q,J,V){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=W,this.outputLen=Q,this.padOffset=J,this.isLE=V,this.buffer=new Uint8Array(W),this.view=F6(this.buffer)}update(W){j8(this),e0(W=N6(W));const{view:Q,buffer:J,blockLen:V}=this,G=W.length;for(let X=0;X<G;){const Y=Math.min(V-this.pos,G-X);if(Y!==V)J.set(W.subarray(X,X+Y),this.pos),this.pos+=Y,X+=Y,this.pos===V&&(this.process(Q,0),this.pos=0);else{const q=F6(W);for(;V<=G-X;X+=V)this.process(q,X)}}return this.length+=W.length,this.roundClean(),this}digestInto(W){j8(this),function(F,C){e0(F);const K=C.outputLen;if(F.length<K)throw Error("digestInto() expects output buffer of length at least "+K)}(W,this),this.finished=!0;const{buffer:Q,view:J,blockLen:V,isLE:G}=this;let{pos:X}=this;Q[X++]=128,B8(this.buffer.subarray(X)),this.padOffset>V-X&&(this.process(J,0),X=0);for(let F=X;F<V;F++)Q[F]=0;(function(F,C,K,z){if(typeof F.setBigUint64=="function")return F.setBigUint64(C,K,z);const $=BigInt(32),N=BigInt(4294967295),v=Number(K>>$&N),y=Number(K&N),E=z?4:0,p=z?0:4;F.setUint32(C+E,v,z),F.setUint32(C+p,y,z)})(J,V-8,BigInt(8*this.length),G),this.process(J,0);const Y=F6(W),q=this.outputLen;if(q%4)throw Error("_sha2: outputLen should be aligned to 32bit");const U=q/4,P=this.get();if(U>P.length)throw Error("_sha2: outputLen bigger than state");for(let F=0;F<U;F++)Y.setUint32(4*F,P[F],G)}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:V,finished:G,destroyed:X,pos:Y}=this;return W.destroyed=X,W.finished=G,W.length=V,W.pos=Y,V%Q&&W.buffer.set(J),W}clone(){return this._cloneInto()}}var E0=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),QV=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]),p0=new Uint32Array(64);class r7 extends l7{constructor(W=32){super(64,W,8,!1),this.A=0|E0[0],this.B=0|E0[1],this.C=0|E0[2],this.D=0|E0[3],this.E=0|E0[4],this.F=0|E0[5],this.G=0|E0[6],this.H=0|E0[7]}get(){const{A:W,B:Q,C:J,D:V,E:G,F:X,G:Y,H:q}=this;return[W,Q,J,V,G,X,Y,q]}set(W,Q,J,V,G,X,Y,q){this.A=0|W,this.B=0|Q,this.C=0|J,this.D=0|V,this.E=0|G,this.F=0|X,this.G=0|Y,this.H=0|q}process(W,Q){for(let C=0;C<16;C++,Q+=4)p0[C]=W.getUint32(Q,!1);for(let C=16;C<64;C++){const K=p0[C-15],z=p0[C-2],$=j0(K,7)^j0(K,18)^K>>>3,N=j0(z,17)^j0(z,19)^z>>>10;p0[C]=N+p0[C-7]+$+p0[C-16]|0}let{A:J,B:V,C:G,D:X,E:Y,F:q,G:U,H:P}=this;for(let C=0;C<64;C++){const K=P+(j0(Y,6)^j0(Y,11)^j0(Y,25))+((F=Y)&q^~F&U)+QV[C]+p0[C]|0,z=(j0(J,2)^j0(J,13)^j0(J,22))+JV(J,V,G)|0;P=U,U=q,q=Y,Y=X+K|0,X=G,G=V,V=J,J=K+z|0}var F;J=J+this.A|0,V=V+this.B|0,G=G+this.C|0,X=X+this.D|0,Y=Y+this.E|0,q=q+this.F|0,U=U+this.G|0,P=P+this.H|0,this.set(J,V,G,X,Y,q,U,P)}roundClean(){B8(p0)}destroy(){this.set(0,0,0,0,0,0,0,0),B8(this.buffer)}}var M6=WV(()=>new r7);class v6 extends g6{constructor(W,Q){super(),this.finished=!1,this.destroyed=!1,c7(W);const J=N6(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 V=this.blockLen,G=new Uint8Array(V);G.set(J.length>V?W.create().update(J).digest():J);for(let X=0;X<G.length;X++)G[X]^=54;this.iHash.update(G),this.oHash=W.create();for(let X=0;X<G.length;X++)G[X]^=106;this.oHash.update(G),B8(G)}update(W){return j8(this),this.iHash.update(W),this}digestInto(W){j8(this),e0(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:V,destroyed:G,blockLen:X,outputLen:Y}=this;return W.finished=V,W.destroyed=G,W.blockLen=X,W.outputLen=Y,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 o7=(W,Q,J)=>new v6(W,Q).update(J).digest();o7.create=(W,Q)=>new v6(W,Q);var S6=BigInt(0),R6=BigInt(1),K6=(W)=>typeof W=="bigint"&&S6<=W,i1=(W)=>(R6<<BigInt(W))-R6,G0=BigInt(0),W0=BigInt(1),n0=BigInt(2),t7=BigInt(3),WW=BigInt(4),JW=BigInt(5),VV=BigInt(7),QW=BigInt(8),GV=BigInt(9),x7=BigInt(16),qV=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"],C1=BigInt(0),a0=BigInt(1),k6=new WeakMap,FW=new WeakMap;class KW{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 V=W;for(;Q>C1;)Q&a0&&(J=J.add(V)),V=V.double(),Q>>=a0;return J}precomputeWindow(W,Q){const{windows:J,windowSize:V}=Z6(Q,this.bits),G=[];let X=W,Y=X;for(let q=0;q<J;q++){Y=X,G.push(Y);for(let U=1;U<V;U++)Y=Y.add(X),G.push(Y);X=Y.double()}return G}wNAF(W,Q,J){if(!this.Fn.isValid(J))throw Error("invalid scalar");let V=this.ZERO,G=this.BASE;const X=Z6(W,this.bits);for(let Y=0;Y<X.windows;Y++){const{nextN:q,offset:U,isZero:P,isNeg:F,isNegF:C,offsetF:K}=v7(J,Y,X);J=q,P?G=G.add(O8(C,Q[K])):V=V.add(O8(F,Q[U]))}return S7(J),{p:V,f:G}}wNAFUnsafe(W,Q,J,V=this.ZERO){const G=Z6(W,this.bits);for(let X=0;X<G.windows&&J!==C1;X++){const{nextN:Y,offset:q,isZero:U,isNeg:P}=v7(J,X,G);if(J=Y,!U){const F=Q[q];V=V.add(P?F.negate():F)}}return S7(J),V}getPrecomputes(W,Q,J){let V=k6.get(Q);return V||(V=this.precomputeWindow(Q,W),W!==1&&(typeof J=="function"&&(V=J(V)),k6.set(Q,V))),V}cached(W,Q,J){const V=H6(W);return this.wNAF(V,this.getPrecomputes(V,W,J),Q)}unsafe(W,Q,J,V){const G=H6(W);return G===1?this._unsafeLadder(W,Q,V):this.wNAFUnsafe(G,this.getPrecomputes(G,W,J),Q,V)}createCache(W,Q){UW(Q,this.bits),FW.set(W,Q),k6.delete(W)}hasCache(W){return H6(W)!==1}}var A7=(W,Q)=>(W+(W>=0?Q:-Q)/zW)/Q,D0={Err:class extends Error{constructor(W=""){super(W)}},_tlv:{encode(W,Q){const{Err:J}=D0;if(W<0||W>256)throw new J("tlv.encode: wrong tag");if(1&Q.length)throw new J("tlv.encode: unpadded data");const V=Q.length/2,G=z8(V);if(G.length/2&128)throw new J("tlv.encode: long form length too big");const X=V>127?z8(G.length/2|128):"";return z8(W)+X+G+Q},decode(W,Q){const{Err:J}=D0;let V=0;if(W<0||W>256)throw new J("tlv.encode: wrong tag");if(Q.length<2||Q[V++]!==W)throw new J("tlv.decode: wrong tlv");const G=Q[V++];let X=0;if(128&G){const q=127&G;if(!q)throw new J("tlv.decode(long): indefinite length not supported");if(q>4)throw new J("tlv.decode(long): byte length is too big");const U=Q.subarray(V,V+q);if(U.length!==q)throw new J("tlv.decode: length bytes not complete");if(U[0]===0)throw new J("tlv.decode(long): zero leftmost byte");for(let P of U)X=X<<8|P;if(V+=q,X<128)throw new J("tlv.decode(long): not minimal encoding")}else X=G;const Y=Q.subarray(V,V+X);if(Y.length!==X)throw new J("tlv.decode: wrong value length");return{v:Y,l:Q.subarray(V+X)}}},_int:{encode(W){const{Err:Q}=D0;if(W<x0)throw new Q("integer: negative integers are not allowed");let J=z8(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}=D0;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 j1(W)}},toSig(W){const{Err:Q,_int:J,_tlv:V}=D0,G=r("signature",W),{v:X,l:Y}=V.decode(48,G);if(Y.length)throw new Q("invalid signature: left bytes after parsing");const{v:q,l:U}=V.decode(2,X),{v:P,l:F}=V.decode(2,U);if(F.length)throw new Q("invalid signature: left bytes after parsing");return{r:J.decode(q),s:J.decode(P)}},hexFromSig(W){const{_tlv:Q,_int:J}=D0,V=Q.encode(2,J.encode(W.r))+Q.encode(2,J.encode(W.s));return Q.encode(48,V)}},x0=BigInt(0),Z1=BigInt(1),zW=BigInt(2),Z8=BigInt(3),UV=BigInt(4),$1={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},kV={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},HV=BigInt(0),y7=BigInt(1),I6=BigInt(2),I8=l1($1.p,{sqrt(W){const Q=$1.p,J=BigInt(3),V=BigInt(6),G=BigInt(11),X=BigInt(22),Y=BigInt(23),q=BigInt(44),U=BigInt(88),P=W*W*W%Q,F=P*P*W%Q,C=z0(F,J,Q)*F%Q,K=z0(C,J,Q)*F%Q,z=z0(K,I6,Q)*P%Q,$=z0(z,G,Q)*z%Q,N=z0($,X,Q)*$%Q,v=z0(N,q,Q)*N%Q,y=z0(v,U,Q)*v%Q,E=z0(y,q,Q)*N%Q,p=z0(E,J,Q)*F%Q,x=z0(p,Y,Q)*$%Q,f=z0(x,V,Q)*P%Q,d=z0(f,I6,Q);if(!I8.eql(I8.sqr(d),W))throw Error("Cannot find square root");return d}}),HW=function(W,Q){const J=(V)=>ZV({...W,hash:V});return{...J(Q),create:J}}({...$1,Fp:I8,lowS:!0,endo:kV},M6),E7={},y6=(W)=>W.toBytes(!0).slice(1),B1=(()=>HW.Point)(),E6=(W)=>W%I6===HV,_1=j1,p6=(()=>{const W=(Q=R8(48))=>PW(Q,$1.n);return HW.utils.randomSecretKey,{keygen(Q){const J=W(Q);return{secretKey:J,publicKey:p7(J)}},getPublicKey:p7,sign:CV,verify:jW,Point:B1,utils:{randomSecretKey:W,randomPrivateKey:W,taggedHash:D8,lift_x:CW,pointToBytes:y6,numberToBytesBE:N8,bytesToNumberBE:j1,mod:Z0},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})(),$V=new TextEncoder,jV=new TextDecoder,s0=(W)=>$V.encode(W),c1=(W)=>jV.decode(W),x6=(W)=>Array.from(W,(Q)=>Q.toString(16).padStart(2,"0")).join(""),w0=JSON.stringify,x8=JSON.parse,BW=(W,Q=Number.MAX_SAFE_INTEGER)=>W.split("").reduce((J,V)=>J+V.charCodeAt(0),0)%Q,f6="AES-GCM",BV={},k8=(W)=>BV[W]??=crypto.subtle.digest("SHA-1",s0(W)).then((Q)=>{const J=new Uint8Array(Q);let V="";for(let G of J)V+=G.toString(36);return V}),MV=async(W,Q)=>{const J=crypto.getRandomValues(new Uint8Array(12)),V=await W,G=await crypto.subtle.encrypt({name:f6,iv:J},V,s0(Q));return`${J.join(",")}\$${((X)=>{const Y=new Uint8Array(X);let q="";for(let U=0;U<Y.length;U+=32768)q+=String.fromCharCode(...Y.subarray(U,U+32768));return btoa(q)})(G)}`},RV=async(W,Q)=>{const[J,V]=Q.split("$");if(!J||!V)throw Error("Invalid encrypted payload format");const G=Uint8Array.from(J.split(","),Number),X=await W,Y=await crypto.subtle.decrypt({name:f6,iv:G},X,(q=V,Uint8Array.from(atob(q),(U)=>U.charCodeAt(0)).buffer));var q;return c1(Y)},q0="GenosRTC",h6=(W,Q)=>Array.from({length:W},Q),LV="0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz",w6=(W)=>Array.from(crypto.getRandomValues(new Uint8Array(W)),(Q)=>LV[Q%62]).join(""),K1=w6(20),k1=Promise.all.bind(Promise),OV=typeof window!="undefined",{entries:IV,fromEntries:MW}=Object,DV=()=>{},I0=(W)=>Error(`${q0}: ${W}`),H8=(...W)=>W.join("@"),f7="icegatheringstatechange",h7="offer",xV=[...h6(3,(W,Q)=>`stun:stun${Q||""}.l.google.com:19302`),"stun:stun.cloudflare.com:3478"].map((W)=>({urls:W})),$6=(W,{rtcConfig:Q,rtcPolyfill:J,turnConfig:V})=>{const G=new(J||RTCPeerConnection)({iceServers:[...xV,...V||[]],...Q}),X={};let Y,q=!1,U=!1;const P=(K)=>Object.assign(K,{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)}}),F=()=>Promise.race([new Promise((K)=>{const z=()=>{G.iceGatheringState==="complete"&&(G.removeEventListener(f7,z),K())};G.addEventListener(f7,z),z()}),new Promise((K)=>setTimeout(K,5000))]).then(()=>({type:G.localDescription.type,sdp:G.localDescription.sdp.replace(/a=ice-options:trickle\s\n/g,"")}));W?P(Y=G.createDataChannel("data")):G.ondatachannel=({channel:K})=>P(Y=K),G.onnegotiationneeded=async()=>{try{q=!0,await G.setLocalDescription(),X.signal?.(await F())}catch(K){X.error?.(K)}finally{q=!1}},G.onconnectionstatechange=()=>{["disconnected","failed","closed"].includes(G.connectionState)&&X.close?.()},G.ontrack=(K)=>{X.track?.(K.track,K.streams[0]),X.stream?.(K.streams[0])},G.onremovestream=(K)=>X.stream?.(K.stream),W&&!G.canTrickleIceCandidates&&G.onnegotiationneeded();const C=()=>G.getSenders();return{created:Date.now(),connection:G,get channel(){return Y},get isDead(){return G.connectionState==="closed"},async signal(K){if(Y?.readyState!=="open"||K.sdp?.includes("a=rtpmap"))try{if(K.type===h7){if(q||G.signalingState!=="stable"&&!U){if(W)return;await k1([G.setLocalDescription({type:"rollback"}),G.setRemoteDescription(K)])}else await G.setRemoteDescription(K);await G.setLocalDescription();const z=await F();return X.signal?.(z),z}if(K.type==="answer"){U=!0;try{await G.setRemoteDescription(K)}finally{U=!1}}}catch(z){X.error?.(z)}},sendData(K){return Y.send(K)},destroy(){Y?.close(),G.close(),q=U=!1},setHandlers(K){return Object.assign(X,K)},offerPromise:W?new Promise((K)=>X.signal=(z)=>z.type===h7&&K(z)):Promise.resolve(),addStream(K){return K.getTracks().forEach((z)=>G.addTrack(z,K))},removeStream(K){return C().filter((z)=>K.getTracks().includes(z.track)).forEach((z)=>G.removeTrack(z))},addTrack(K,z){return G.addTrack(K,z)},removeTrack(K){const z=C().find(($)=>$.track===K);z&&G.removeTrack(z)},replaceTrack(K,z){return C().find(($)=>$.track===K)?.replaceTrack(z)}}},wV=Object.getPrototypeOf(Uint8Array),u1=16369,C8=255,j6="bufferedamountlow",z1=(W)=>"@_"+W,NV=(W,Q,J)=>{const V=new Map,G=new Map,X=new Map,Y={},q={},U={},P={},F=new Map,C=(H,...j)=>F.get(H)?.forEach((O)=>O(...j)),K=(H,j)=>{const O=H?Array.isArray(H)?H:[H]:V.keys();return Array.from(O,(R)=>{const D=V.get(R);return D?j(R,D):(console.warn(`${q0}: no peer with id ${R}`),null)}).filter(Boolean)},z=(H)=>{V.has(H)&&(V.delete(H),delete Y[H],delete q[H],delete U[H],delete P[H],C("peer:leave",H),Q(H))},$=(H)=>new Promise((j,O)=>{let R=setTimeout(()=>{H.removeEventListener(j6,D),O(Error(q0+": bufferLow timeout"))},5000);function D(){clearTimeout(R),H.removeEventListener(j6,D),j()}H.addEventListener(j6,D)}),N=(H)=>{if(X.has(H))return X.get(H);if(!H)throw I0("action type is required");const j=s0(H);if(j.byteLength>12)throw I0(`"${H}" exceeds 12 bytes`);const O=new Uint8Array(12).map((T,S)=>j[S]||0);let R=0;const D=new Map([["message",new Set],["progress",new Set]]),B=async(T,S,A,h)=>{if(A&&typeof A!="object")throw I0("meta must be object");if(T===void 0)throw I0("data cannot be undefined");const b=T instanceof Blob,m=b||T instanceof ArrayBuffer||T instanceof wV,_=typeof T!="string";if(A&&!m)throw I0("meta only allowed with binary");const i=m?new Uint8Array(b?await T.arrayBuffer():T):s0(_?w0(T):T),M0=A?s0(w0(A)):null,J0=Math.ceil(i.byteLength/u1)+(A?1:0)||1;if(J0>100)throw I0("Message too large, exceeds max chunks 100");const P0=h6(J0,(U0,s)=>{const Q0=s===J0-1,a=A&&s===0,r1=a?M0:i.subarray(A?(s-1)*u1:s*u1,A?s*u1:(s+1)*u1),N0=new Uint8Array(15+r1.byteLength);return N0.set(O),N0.set([R],12),N0.set([Q0|a<<1|m<<2|_<<3],13),N0.set([Math.round((s+1)/J0*C8)],14),N0.set(r1,15),N0});return R=R+1&C8,k1(K(S,async(U0,s)=>{const{channel:Q0}=s;for(let a=0;a<J0;a++){let r1=0;for(;Q0.bufferedAmount>Q0.bufferedAmountLowThreshold;){if(r1++>3)throw I0(`${q0}: send buffer full, max retries reached for peer ${U0}`);try{await $(Q0)}catch(N0){console.warn(N0.message),await new Promise((vW)=>setTimeout(vW,200))}}if(!V.has(U0))break;s.sendData(P0[a]),h?.(P0[a][14]/C8,U0,A)}}))};G.set(H,{listeners:D,send:B});const g={send:B,on(T,S){return D.get(T)?.add(S)},off(T,S){return D.get(T)?.delete(S)}};return X.set(H,g),g},v=async()=>{try{await k(""),await new Promise((H)=>setTimeout(H,99))}catch(H){console.warn(q0+": error sending leave",H)}for(let[H,j]of V){try{j.destroy()}catch{}V.delete(H)}J()},{send:y,on:E}=N(z1("ping")),{send:p,on:x}=N(z1("pong")),{send:f,on:d}=N(z1("signal")),{send:I,on:L}=N(z1("stream")),{send:w,on:Z}=N(z1("track")),{send:k,on:M}=N(z1("leave"));return W((H,j)=>{V.has(j)||(V.set(j,H),H.setHandlers({data(O){return((R,D)=>{try{const B=new Uint8Array(D),g=c1(B.subarray(0,12)).replace(/\0/g,"");if(!G.has(g))return console.warn(`${q0}: unregistered type (${g})`);const[T]=B.subarray(12,13),[S]=B.subarray(13,14),[A]=B.subarray(14,15),h=B.subarray(15),b=!!(1&S),m=!!(2&S),_=!!(4&S),i=!!(8&S),M0=G.get(g),J0=(Y[R]||={})[g]||={};if(J0[T]?.chunks?.length>100)return void console.warn(`${q0}: peer ${R} sent too many chunks for nonce ${T}, ignoring.`);const P0=J0[T]||={chunks:[]};if(m)try{P0.meta=x8(c1(h))}catch{return void console.warn(`${q0}: failed to parse meta from peer ${R} for type ${g}`)}else P0.chunks.push(h);if(M0.listeners.get("progress").forEach((Q0)=>{try{Q0(A/C8,R,P0.meta)}catch(a){console.error(a)}}),!b)return;const U0=new Uint8Array(P0.chunks.reduce((Q0,a)=>Q0+a.byteLength,0));let s;if(P0.chunks.reduce((Q0,a)=>(U0.set(a,Q0),Q0+a.byteLength),0),delete J0[T],_)s=U0;else if(i)try{s=x8(c1(U0))}catch{return void console.warn(`${q0}: failed to parse JSON message data from peer ${R} for type ${g}`)}else s=c1(U0);M0.listeners.get("message").forEach((Q0)=>{try{Q0(s,R,P0.meta)}catch(a){console.error(a)}})}catch(B){console.error(`${q0}: error handling data from peer ${R}:`,B)}})(j,O)},stream(O){C("stream:add",O,j,U[j]),delete U[j]},track(O,R){C("track:add",O,R,j,P[j]),delete P[j]},signal(O){return f(O,j)},close(){return z(j)},error(O){console.error(`${q0}: peer error for ${j}`,O),z(j)}}),C("peer:join",j))}),E("message",(H,j)=>p("",j)),x("message",(H,j)=>{q[j]?.(),delete q[j]}),d("message",(H,j)=>V.get(j)?.signal(H)),L("message",(H,j)=>U[j]=H),Z("message",(H,j)=>P[j]=H),M("message",(H,j)=>z(j)),OV&&addEventListener("beforeunload",v),{on(H,j){F.has(H)||F.set(H,new Set),F.get(H).add(j)},off(H,j){return F.get(H)?.delete(j)},channel:N,leave:v,async ping(H){if(!H)throw I0("ping() requires target peer ID");const j=Date.now();return y("",H),await new Promise((O)=>q[H]=O),Date.now()-j},getPeers(){return MW(Array.from(V,([H,j])=>[H,j.connection]))},addStream(H,j,O){return K(j,async(R,D)=>{O&&await I(O,R),D.addStream(H)})},removeStream(H,j){return K(j,(O,R)=>R.removeStream(H))},addTrack(H,j,O,R){return K(O,async(D,B)=>{R&&await w(R,D),B.addTrack(H,j)})},removeTrack(H,j){return K(j,(O,R)=>R.removeTrack(H))},replaceTrack(H,j,O,R){return K(O,async(D,B)=>{R&&await w(R,D),B.replaceTrack(H,j)})}}},$8={},RW={};if(typeof window!="undefined"){const W=()=>{console.info("\u26A1 [GenosRTC] Evento de red detectado. Forzando reconexi\xF3n..."),Object.values(RW).forEach((Q)=>{Q.socket&&Q.socket.readyState!==WebSocket.OPEN&&Q.socket.readyState!==WebSocket.CONNECTING&&Q.forceReconnect()})};window.addEventListener("online",()=>{console.info("\u2705 Reconnected to the network."),W()}),window.addEventListener("offline",async()=>{console.info("\u274C Disconnected from the network.")}),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&W()})}var gV=(W,Q,J,V)=>(W.relayUrls??(V?((G,X)=>{const Y=[...G];let q=Y.length;const U=()=>{const P=1e4*Math.sin(X++);return P-Math.floor(P)};for(;q;){const P=Math.floor(U()*q--);[Y[q],Y[P]]=[Y[P],Y[q]]}return Y})(Q,BW(W.appId)):Q)).slice(0,W.relayUrls?.length??W.relayRedundancy??J),LW={},OW="EVENT",IW=p6.utils.randomSecretKey(),vV=x6(p6.getPublicKey(IW)),b6={},d1={},SV={},DW=()=>Math.floor(Date.now()/1000),xW=(W)=>SV[W]??=BW(W,1e4)+20000,b7=async(W,Q)=>{const J={kind:xW(W),content:Q,pubkey:vV,created_at:DW(),tags:[["x",W]]},V=new Uint8Array(await crypto.subtle.digest("SHA-256",s0(w0([0,J.pubkey,J.created_at,J.kind,J.tags,J.content])))),G=p6.sign(V,IW);return w0([OW,{...J,id:x6(V),sig:x6(G)}])},m7=(W,Q)=>(b6[W]=Q,w0(["REQ",W,{kinds:[xW(Q)],since:DW(),"#x":[Q]}])),u7=(W)=>(delete b6[W],w0(["CLOSE",W])),m6=(({init:W,subscribe:Q,announce:J})=>{const V={};let G,X,Y=!1;return(q,U,P)=>{const{appId:F}=q;if(V[F]?.[U])return V[F][U];if(!q||!U||!F&&!q.firebaseApp)throw I0(q?U?"appId missing":"roomId required":"config required");let C=DV;if(!Y){const Z=W(q);X=h6(20,()=>$6(!0,q)),G=Array.isArray(Z)?Z:[Z];const k=setInterval(()=>{X=X.filter((M)=>{const H=Date.now()-M.created<57333;return H||M.destroy(),H})},57333);V.offerCleanupTimer||=k,Y=!0}const K={},z={},$=H8(q0,F,U),N=k8($),v=k8(H8($,K1)),y=(async(Z,k,M)=>{const H=await crypto.subtle.digest("SHA-256",s0(`${Z}:${k}:${M}`));return crypto.subtle.importKey("raw",H,{name:f6},!1,["encrypt","decrypt"])})(q.password||"",F,U),E=(Z)=>async(k)=>({type:k.type,sdp:await Z(y,k.sdp)}),p=E(RV),x=E(MV),f=(Z,k)=>{z[k]!==Z&&(z[k]?.destroy(),z[k]=Z,C(Z,k),K[k]?.forEach((M)=>M!==Z&&M.destroy()),delete K[k])},d=(Z,k)=>{z[k]===Z&&delete z[k]},I=k1(G.map(async(Z,k)=>{return Q(await Z,await N,await v,(M=k,async(H,j,O)=>{const[R,D]=await k1([N,v]);if(H!==R&&H!==D)return;const{peerId:B,offer:g,answer:T}=typeof j=="string"?x8(j):j;if(B!==K1&&!z[B])if(g){if(K[B]?.[M]&&K1>B)return;const S=$6(!1,q);S.setHandlers({connect(){return f(S,B)},close(){return d(S,B)}});try{const A=await p(g);if(S.isDead)return;const[h,b]=await k1([k8(H8($,B)),S.signal(A).then(x)]);O(h,w0({peerId:K1,answer:b}))}catch{P?.({error:"decryption failed (offer)",appId:F,peerId:B,roomId:U})}}else if(T){const S=K[B]?.[M];if(!S||S.isDead)return;S.setHandlers({connect(){return f(S,B)},close(){return d(S,B)}});try{S.signal(await p(T))}catch{P?.({error:"decryption failed (answer)",appId:F,peerId:B,roomId:U})}}else{if(K[B]?.[M])return;const S=X.pop()||$6(!0,q),[A,{offer:h}]=await k1([k8(H8($,B)),S.offerPromise.then(x).then((b)=>({offer:b}))]);K[B]||=[],K[B][M]=S,S.setHandlers({connect(){return f(S,B)},close(){return d(S,B)}}),O(A,w0({peerId:K1,offer:h,peer:S}))}}));var M})),L=[];I.then((Z)=>{G.forEach((k,M)=>{const H=async()=>{const j=await J(await k,await N,await v);L[M]=setTimeout(H,typeof j=="number"?j:5333)};H()}),V[F][U].onCleanup=()=>{delete V[F][U],L.forEach(clearTimeout),Z.forEach((k)=>k()),Object.keys(V).length===0&&(clearInterval(V.offerCleanupTimer),delete V.offerCleanupTimer)}}),V[F]||={};const w=NV((Z)=>C=Z,(Z)=>delete z[Z],()=>w.onCleanup?.());return V[F][U]=w}})({init(W){return gV(W,TV,5,!0).map((Q)=>{const J=((V,G)=>{const X={};let Y=null;const q=()=>{Y&&(clearTimeout(Y),Y=null);const U=new WebSocket(V);U.onclose=()=>{$8[V]??=3333,Y=setTimeout(q,$8[V]),$8[V]*=2},U.onmessage=(P)=>G(P.data),X.socket=U,X.url=U.url,X.ready=new Promise((P)=>{U.onopen=()=>{$8[V]=3333,P(X)}}),X.send=(P)=>{U.readyState===1&&U.send(P)}};return X.forceReconnect=q,q(),RW[V]=X,X})(Q,(V)=>{const[G,X,Y,q]=x8(V);if(G===OW)d1[X]?.(b6[X],Y.content);else{const U=`${q0}: relay failure from ${J.url} - `;G==="NOTICE"?console.warn(U+X):G!=="OK"||Y||console.warn(U+q)}});return LW[Q]=J,J.ready})},subscribe(W,Q,J,V){const G=w6(64),X=w6(64);return d1[G]=d1[X]=(Y,q)=>V(Y,q,async(U,P)=>W.send(await b7(U,P))),W.send(m7(G,Q)),W.send(m7(X,J)),()=>{W.send(u7(G)),W.send(u7(X)),delete d1[G],delete d1[X]}},async announce(W,Q){return W.send(await b7(Q,w0({peerId:K1})))}}),$G=(d7=LW,()=>MW(IV(d7).map(([W,Q])=>[W,Q.socket]))),d7,TV=["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);function wW(W,Q,J){let V=Q.timestamp;if(V?.physical>Date.now()+7200000)V={physical:Date.now()+7200000,logical:V.logical};if(!W?.timestamp)return{resolved:!0,value:Q.value,timestamp:V};if(J.compare(V,W.timestamp)<=0)return{resolved:!1};return{resolved:!0,value:Q.value,timestamp:V}}class u6{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 AV=()=>{const W=new Map,Q=async()=>{try{const U=await navigator.storage.getDirectory(),F=await(await U.getFileHandle("~opfs-sync-test",{create:!0})).createSyncAccessHandle?.();return await F?.close(),await U.removeEntry("~opfs-sync-test"),!!F}catch{return!1}};let J="idb";const V=(async()=>{if(await Q())J="sync";else try{const U=await navigator.storage.getDirectory(),F=await(await U.getFileHandle("~opfs-async-test",{create:!0})).createWritable?.();if(await F?.close(),await U.removeEntry("~opfs-async-test"),F)J="async";else J="idb"}catch{J="idb"}})(),G=async(U,P)=>{if(!W.has(U))W.set(U,[]);const F=W.get(U),C=F[F.length-1]||Promise.resolve();let K;const z=new Promise(($)=>K=$);F.push(z);try{return await C,await P()}finally{if(F.shift(),K(),F.length===0)W.delete(U)}},X=(()=>{let U;const P=async()=>{if(!U)U=new Promise((F,C)=>{const K=indexedDB.open("opfs-fallback-db",1);K.onupgradeneeded=()=>K.result.createObjectStore("files"),K.onsuccess=()=>F(K.result),K.onerror=()=>C(K.error)});return U};return{getDB:P,get:async(F)=>{const C=await P();return new Promise((K,z)=>{const N=C.transaction("files","readonly").objectStore("files").get(F);N.onsuccess=()=>K(N.result||new Uint8Array),N.onerror=()=>z(N.error)})},set:async(F,C)=>{const K=await P();return new Promise((z,$)=>{const v=K.transaction("files","readwrite").objectStore("files").put(C,F);v.onsuccess=()=>z(),v.onerror=()=>$(v.error)})}}})(),Y=async(U)=>{await V;try{if(J==="idb"){const z=await X.get(U);return{type:"loaded",name:U,data:z}}const F=await(await navigator.storage.getDirectory()).getFileHandle(U);if(J==="sync"){let z;try{z=await F.createSyncAccessHandle();const $=z.getSize(),N=new Uint8Array($),v=z.read(N,{at:0});return{type:"loaded",name:U,data:N.slice(0,v)}}finally{z?.close()}}const C=await F.getFile(),K=new Uint8Array(await C.arrayBuffer());return{type:"loaded",name:U,data:K}}catch(P){const F=P.name==="NotFoundError"?"File not found":P.message||"Error reading file";return{type:"error",name:U,message:F}}},q=async(U,P)=>{if(await V,!(P instanceof Uint8Array))return{type:"error",name:U,message:"Content must be a Uint8Array"};return G(U,async()=>{try{if(J==="idb")return await X.set(U,P),{type:"saved",name:U};const C=await(await navigator.storage.getDirectory()).getFileHandle(U,{create:!0});if(J==="sync"){let K;try{K=await C.createSyncAccessHandle(),K.truncate(0),K.write(P,{at:0}),K.flush()}finally{K?.close()}}else{let K;try{K=await C.createWritable(),await K.write(P)}finally{await K?.close()}}return{type:"saved",name:U}}catch(F){return{type:"error",name:U,message:F.message||"Error saving file"}}})};self.onmessage=async({data:U})=>{const{type:P,name:F,content:C}=U;await V;const K={load:()=>Y(F),save:()=>q(F,C)};try{const z=K[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:F,message:z.message||"Unexpected worker error"})}}},NW=AV;var t0={$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)&&(Array.isArray(W)?W.some((J)=>Q.includes(J)):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=(G)=>String(G).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^\w\s]/g,""),V=J(Q);return Object.values(W).some((G)=>typeof G==="object"?null.fieldSearch(G,V):J(G).includes(V))},field:(W,Q)=>{const J=(G)=>String(G).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^\w\s]/g,""),V=J(Q);return Array.isArray(W)?W.some((G)=>J(G).includes(V)):J(W).includes(V)}},$like:(W,Q)=>typeof W==="string"&&typeof Q==="string"&&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((V)=>J.createFilter(V,J.allNodes)(W)),$or:(W,Q,J)=>Q.some((V)=>J.createFilter(V,J.allNodes)(W)),$not:(W,Q,J)=>!J.createFilter(Q,J.allNodes)(W),$edge:(W,Q,J)=>{if(!W.edges?.length||typeof Q!=="object"||Q===null)return!1;const V=J.createFilter(Q,J.allNodes),G=[...W.edges],X=new Set(G).add(W.id),Y=[];while(G.length){const q=G.shift(),U=J.allNodes[q];if(!U)continue;if(V(U))Y.push(U);U.edges?.forEach((P)=>!X.has(P)&&X.add(P)&&G.push(P))}if(Y.length)W._edgeResult=Y;return Y.length>0}},d6=(W,Q)=>Q.split(".").reduce((J,V)=>J&&typeof J==="object"&&(V in J)?J[V]:void 0,W),g8=(W,Q)=>{if(Object.keys(W).length===0)return()=>!0;return(J)=>Object.entries(W).every(([V,G])=>{if(V.startsWith("$"))return t0[V](J,G,{createFilter:g8,allNodes:Q});const X=d6(J.value,V);if(typeof G!=="object"||G===null)return t0.$eq(X,G);return Object.entries(G).every(([Y,q])=>{if(Y==="$text")return t0.$text.field(X,q);if(Y==="$between"&&q.every((U)=>U instanceof Date))return t0.$between(new Date(X),q);return t0[Y]?.(X,q,{createFilter:g8,allNodes:Q})??!1})})},c6=(W,Q)=>{const{$edge:J,...V}=Q.query||{},G=g8(V,W),X=Object.values(W).filter(G);let q=[...J?(()=>{const U=g8({$edge:J},W);X.forEach((F)=>U(F));const P=new Map;return X.forEach((F)=>{if(F._edgeResult)F._edgeResult.forEach((C)=>P.set(C.id,C)),delete F._edgeResult}),Array.from(P.values())})():X];if(q=q.map((U)=>({...U,edges:[...U.edges||[]],value:U.value&&typeof U.value==="object"?JSON.parse(JSON.stringify(U.value)):U.value})),Q.field){const U=Q.order==="asc"?1:-1;q.sort((P,F)=>{const C=d6(P.value,Q.field),K=d6(F.value,Q.field);if(typeof C==="string"&&typeof K==="string")return C.localeCompare(K)*U;return((C??0)-(K??0))*U})}if(Q.$after){const U=q.findIndex((P)=>P.id===Q.$after);q=U>=0?q.slice(U+1):[]}if(Q.$before){const U=q.findIndex((P)=>P.id===Q.$before);q=U>=0?q.slice(0,U):[]}if(Q.$limit)q=q.slice(0,Q.$limit);return q};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 i6=function(W,Q){return W.length===Q.length&&W.every((J,V)=>J===Q[V])};async function yV(){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 gW{constructor(){this.nodes={}}upsert(W,Q,J){const V=this.nodes[W];this.nodes[W]={id:W,value:Q&&typeof Q==="object"?JSON.parse(JSON.stringify(Q)):Q,edges:V?.edges?[...V.edges]:[],timestamp:J}}get(W){return this.nodes[W]||null}link(W,Q,J){const V=this.nodes[W],G=this.nodes[Q];if(V&&G&&!V.edges.includes(Q))this.nodes[W]={...V,edges:[...V.edges,Q],timestamp:J}}getAllNodes(){return Object.values(this.nodes)}serialize(){return l0.deflate(g0(this.nodes))}deserialize(W){this.nodes=t1(l0.inflate(new Uint8Array(W)))}}class l6{constructor(W,{password:Q,securityManager:J=null,relayUrls:V=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=Q,this.globalTimestamp=null,this.graph=new gW,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=t0,this.initWorker(),this.ready=this.loadGraphFromOPFS(),this.loadGlobalTimestamp();const G=`graph-sync-room-${this.name}`,X={appId:"1234",...this.password&&{password:this.password}};if(V)X.relayUrls=V;const Y=m6(X,G),q=Y.channel("syncGraph");this.syncChannel=q,this.room=m6(X,`app-sync-${this.name}`),yV(),Y.on("peer:join",async(U)=>{console.info("\u26A1 New peer connected:",U),this.syncChannel.send([{type:"sync",timestamp:this.globalTimestamp}])}),Y.on("peer:leave",(U)=>{console.info("\u26A1 Peer disconnected:",U)}),this.syncChannel.on("message",async(U)=>{if(this.securityManager&&typeof this.securityManager.verifyIncomingOperations==="function"){const{validatedOperations:P}=await this.securityManager.verifyIncomingOperations(U);if(P&&P.length>0)await this.receiveChanges(P)}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([`(${NW.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 l0.deflate(W)}decompress(W){return l0.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((V)=>V.toString(16).padStart(2,"0")).join("")}async loadGraphFromOPFS(){try{const Q=await((J)=>new Promise((V,G)=>{const X=async({data:Y})=>{if(Y.type==="loaded"&&Y.name===J)this.worker.removeEventListener("message",X),V(new Uint8Array(Y.data));else if(Y.type==="error")this.worker.removeEventListener("message",X),G(new Error(Y.message||"Unknown error"))};this.worker.addEventListener("message",X),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,V)=>new Promise((G,X)=>{const Y=({data:q})=>{if(q.type==="saved"&&q.name===J)this.worker.removeEventListener("message",Y),G();else if(q.type==="error")this.worker.removeEventListener("message",Y),X(new Error(q.message||"Save error"))};this.worker.addEventListener("message",Y),this.worker.postMessage({type:"save",name:J,content:V})}))(`${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.syncChannel.send([{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 V=(Y)=>{if(!Y)return null;const q=Y.value!==null&&typeof Y.value==="object"?{...Y.value}:Y.value;return{...Y,value:q}};if(!Q)return{result:V(J)};let G=J.timestamp;Q(V(J));const X=(Y)=>{const q=Y[W];if(q){if(this.hybridClock.compare(q.timestamp,G)>0)G=q.timestamp,Q(V(q))}else Q(null),this.eventListeners.splice(this.eventListeners.indexOf(X),1)};return this.eventListeners.push(X),{result:V(J),unsubscribe:()=>{const Y=this.eventListeners.indexOf(X);if(Y>-1)this.eventListeners.splice(Y,1)}}}async map(...W){await this.ready;let J={...{realtime:!1,query:{},field:null,order:"asc",$limit:null,$after:null,$before:null}},V=null,G=!1;W.forEach((U)=>typeof U==="function"?V=U:U&&typeof U==="object"&&(G||=("realtime"in U),Object.assign(J,U))),V&&!G&&(J.realtime=!0);let X=c6(this.graph.nodes,J),Y=null;const q=(U)=>{const P=U.filter((z)=>!X.some(($)=>$.id===z.id)),F=X.filter((z)=>!U.some(($)=>$.id===z.id)),C=U.filter((z)=>{const $=X.find((y)=>y.id===z.id),N=[...z.edges||[]],v=[...$?.edges||[]];return $&&(!i6(g0(z.value),g0($.value))||!i6(N,v))}),K=(z,$)=>{const N=$==="removed"?null:z.value,v={id:z.id,value:N,edges:z.edges||[],timestamp:z.timestamp||null,action:$};V(v)};P.forEach((z)=>K(z,"added")),F.forEach((z)=>K(z,"removed")),C.forEach((z)=>K(z,"updated"))};if(V){if(X.forEach((U)=>{V({id:U.id,value:U.value,edges:U.edges,timestamp:U.timestamp,action:"initial"})}),J.realtime)Y=(U)=>{const P=c6(U,J);if(!i6(g0(P),g0(X)))q(P),X=P},this.eventListeners.push(Y)}return{results:X,...J.realtime&&V&&Y&&{unsubscribe:()=>{const U=this.eventListeners.indexOf(Y);U>-1&&this.eventListeners.splice(U,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((V)=>V.edges=V.edges.filter((G)=>G!==W)),await this.saveGraphToOPFS(),this.saveGlobalTimestamp(Q),await this.syncChannel.send([{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.syncChannel.send([{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 V={upsert:(G)=>{const X=this.graph.get(G.id),Y=wW(X,G,this.hybridClock);if(Y.resolved){if(this.graph.upsert(G.id,Y.value,Y.timestamp),this.hybridClock.update(Y.timestamp),this.oplog.add({type:"upsert",id:G.id,timestamp:Y.timestamp}),Q=!0,!J||this.hybridClock.compare(Y.timestamp,J)>0)J=Y.timestamp}},remove:(G)=>{const X=this.graph.get(G.id);if(X&&this.hybridClock.compare(X.timestamp,G.timestamp)<0){if(delete this.graph.nodes[G.id],this.hybridClock.update(G.timestamp),this.oplog.add({type:"remove",id:G.id,timestamp:G.timestamp}),Q=!0,!J||this.hybridClock.compare(G.timestamp,J)>0)J=G.timestamp}},link:(G)=>{const X=this.graph.get(G.sourceId),Y=this.graph.get(G.targetId);if(X&&Y&&this.hybridClock.compare(X.timestamp,G.timestamp)<0){if(this.graph.link(G.sourceId,G.targetId,G.timestamp),this.hybridClock.update(G.timestamp),this.oplog.add({type:"link",sourceId:G.sourceId,targetId:G.targetId,timestamp:G.timestamp}),Q=!0,!J||this.hybridClock.compare(G.timestamp,J)>0)J=G.timestamp}},sync:async(G)=>{const X=G.timestamp;if(X===null){console.info("\uD83D\uDCEC [SYNC REQUEST] from new peer (no timestamp). Sending full graph."),await this.syncChannel.send([{type:"syncReceive",graph:this.graph}]);return}console.info("\uD83D\uDCEC [SYNC REQUEST] since:",new Date(X.physical).toLocaleString());const Y=this.oplog.getOldest();if(Y&&this.hybridClock.compare(X,Y.timestamp)<0){console.info("\uD83D\uDCA5 [FALLBACK TRIGGERED] Peer is too far behind. Sending FULL graph state."),await this.syncChannel.send([{type:"syncReceive",graph:this.graph}]);return}const q=this.oplog.getDelta(X,this.hybridClock.compare);if(q.length>0){const U=q.map((F)=>{if(F.type==="upsert"){const C=this.graph.get(F.id);return{...F,value:C?C.value:null}}return F}),P=l0.deflate(g0(U));console.info(`\uD83D\uDE80 [DELTA SYNC SENDING] Found ${q.length} new operations to send.`),await this.syncChannel.send([{type:"deltaSync",operations:P}])}else console.info("\u2705 [ALREADY SYNCED] Peer is up-to-date. Nothing to send.")},deltaSync:(G)=>{console.info("\uD83D\uDEF0\uFE0F [DELTA SYNC RECEIVED] Applying delta from a peer.");let X=t1(l0.inflate(G.operations));for(let Y of X)V[Y.type]?.(Y)},syncReceive:async(G)=>{if(console.info("\uD83D\uDCE6 [FULL SYNC RECEIVED] Overwriting local state with full graph from a peer."),G.graph&&G.graph.nodes){await this.applyFullGraph(G.graph),this.oplog.clear(),console.info("\uD83D\uDD12 Oplog has been cleared due to full sync."),Q=!0;let X=null;for(let Y in G.graph.nodes){const q=G.graph.nodes[Y];if(q.timestamp&&(!X||this.hybridClock.compare(q.timestamp,X)>0))X=q.timestamp}if(X)console.info("\uD83D\uDCC8 [GLOBAL TIMESTAMP] Updated from full sync."),J=X,this.hybridClock.update(X)}else console.error("\u274C Full sync failed: received graph data is invalid.",G.graph)}};for(let G of W)if(V[G.type])await V[G.type](G);else console.warn(`\uD83E\uDD37\u200D\u2640\uFE0F [UNKNOWN MESSAGE TYPE] Received unhandled message type: "${G.type}"`);if(J){if(!this.globalTimestamp||this.hybridClock.compare(J,this.globalTimestamp)>0)console.info(`\uD83D\uDCC8 [GLOBAL TIMESTAMP] Advanced from ${this.globalTimestamp?.logical} to ${J.logical}.`),this.saveGlobalTimestamp(J)}if(Q)console.info("\uD83D\uDCBE [STATE CHANGED] Saving state and emitting update."),await this.saveGraphToOPFS(),this.emit()}}export{l6 as GDB};
1
+ function r6(W){const Q=W.length;let J=0,V=0;while(V<Q){let G=W.charCodeAt(V++);if((G&4294967168)===0){J++;continue}else if((G&4294965248)===0)J+=2;else{if(G>=55296&&G<=56319){if(V<Q){const X=W.charCodeAt(V);if((X&64512)===56320)++V,G=((G&1023)<<10)+(X&1023)+65536}}if((G&4294901760)===0)J+=3;else J+=4}}return J}function SW(W,Q,J){const V=W.length;let G=J,X=0;while(X<V){let Y=W.charCodeAt(X++);if((Y&4294967168)===0){Q[G++]=Y;continue}else if((Y&4294965248)===0)Q[G++]=Y>>6&31|192;else{if(Y>=55296&&Y<=56319){if(X<V){const q=W.charCodeAt(X);if((q&64512)===56320)++X,Y=((Y&1023)<<10)+(q&1023)+65536}}if((Y&4294901760)===0)Q[G++]=Y>>12&15|224,Q[G++]=Y>>6&63|128;else Q[G++]=Y>>18&7|240,Q[G++]=Y>>12&63|128,Q[G++]=Y>>6&63|128}Q[G++]=Y&63|128}}function yW(W,Q,J){TW.encodeInto(W,Q.subarray(J))}function o6(W,Q,J){if(W.length>AW)yW(W,Q,J);else SW(W,Q,J)}function v8(W,Q,J){let V=Q;const G=V+J,X=[];let Y="";while(V<G){const q=W[V++];if((q&128)===0)X.push(q);else if((q&224)===192){const U=W[V++]&63;X.push((q&31)<<6|U)}else if((q&240)===224){const U=W[V++]&63,P=W[V++]&63;X.push((q&31)<<12|U<<6|P)}else if((q&248)===240){const U=W[V++]&63,P=W[V++]&63,F=W[V++]&63;let C=(q&7)<<18|U<<12|P<<6|F;if(C>65535)C-=65536,X.push(C>>>10&1023|55296),C=56320|C&1023;X.push(C)}else X.push(q);if(X.length>=EW)Y+=String.fromCharCode(...X),X.length=0}if(X.length>0)Y+=String.fromCharCode(...X);return Y}function hW(W,Q,J){const V=W.subarray(Q,Q+J);return pW.decode(V)}function n6(W,Q,J){if(J>fW)return hW(W,Q,J);else return v8(W,Q,J)}var TW=new TextEncoder,AW=50,EW=4096,pW=new TextDecoder,fW=200;class W1{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 a6(W,Q,J){const V=J/4294967296,G=J;W.setUint32(Q,V),W.setUint32(Q+4,G)}function o1(W,Q,J){const V=Math.floor(J/4294967296),G=J;W.setUint32(Q,V),W.setUint32(Q+4,G)}function n1(W,Q){const J=W.getInt32(Q),V=W.getUint32(Q+4);return J*4294967296+V}function s6(W,Q){const J=W.getUint32(Q),V=W.getUint32(Q+4);return J*4294967296+V}var J1=4294967295;function dW({sec:W,nsec:Q}){if(W>=0&&Q>=0&&W<=uW)if(Q===0&&W<=mW){const J=new Uint8Array(4);return new DataView(J.buffer).setUint32(0,W),J}else{const J=W/4294967296,V=W&4294967295,G=new Uint8Array(8),X=new DataView(G.buffer);return X.setUint32(0,Q<<2|J&3),X.setUint32(4,V),G}else{const J=new Uint8Array(12),V=new DataView(J.buffer);return V.setUint32(0,Q),o1(V,4,W),J}}function cW(W){const Q=W.getTime(),J=Math.floor(Q/1000),V=(Q-J*1000)*1e6,G=Math.floor(V/1e9);return{sec:J+G,nsec:V-G*1e9}}function _W(W){if(W instanceof Date){const Q=cW(W);return dW(Q)}else return null}function lW(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),V=Q.getUint32(4),G=(J&3)*4294967296+V,X=J>>>2;return{sec:G,nsec:X}}case 12:{const J=n1(Q,4),V=Q.getUint32(0);return{sec:J,nsec:V}}default:throw new e(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${W.length}`)}}function iW(W){const Q=lW(W);return new Date(Q.sec*1000+Q.nsec/1e6)}var bW=-1,mW=4294967295,uW=17179869183,e6={type:bW,encode:_W,decode:iW};class f0{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(e6)}register({type:W,encode:Q,decode:J}){if(W>=0)this.encoders[W]=Q,this.decoders[W]=J;else{const V=-1-W;this.builtInEncoders[V]=Q,this.builtInDecoders[V]=J}}tryToEncode(W,Q){for(let J=0;J<this.builtInEncoders.length;J++){const V=this.builtInEncoders[J];if(V!=null){const G=V(W,Q);if(G!=null){const X=-1-J;return new W1(X,G)}}}for(let J=0;J<this.encoders.length;J++){const V=this.encoders[J];if(V!=null){const G=V(W,Q);if(G!=null)return new W1(J,G)}}if(W instanceof W1)return W;return null}decode(W,Q,J){const V=Q<0?this.builtInDecoders[-1-Q]:this.decoders[Q];if(V)return V(W,Q,J);else return new W1(Q,W)}}f0.defaultCodec=new f0;var rW=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(rW(W))return new Uint8Array(W);else return Uint8Array.from(W)}var oW=100,nW=2048;class a1{constructor(W){this.entered=!1,this.extensionCodec=W?.extensionCodec??f0.defaultCodec,this.context=W?.context,this.useBigInt64=W?.useBigInt64??!1,this.maxDepth=W?.maxDepth??oW,this.initialBufferSize=W?.initialBufferSize??nW,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,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),V=new DataView(Q);J.set(this.bytes),this.view=V,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=r6(W);this.ensureBufferSizeToWrite(5+J),this.writeStringHeader(J),o6(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 V of W)this.doEncode(V,Q+1)}countWithoutUndefined(W,Q){let J=0;for(let V of Q)if(W[V]!==void 0)J++;return J}encodeMap(W,Q){const J=Object.keys(W);if(this.sortKeys)J.sort();const V=this.ignoreUndefined?this.countWithoutUndefined(W,J):J.length;if(V<16)this.writeU8(128+V);else if(V<65536)this.writeU8(222),this.writeU16(V);else if(V<4294967296)this.writeU8(223),this.writeU32(V);else throw new Error(`Too large map object: ${V}`);for(let G of J){const X=W[G];if(!(this.ignoreUndefined&&X===void 0))this.encodeString(G),this.doEncode(X,Q+1)}}encodeExtension(W){if(typeof W.data==="function"){const J=W.data(this.pos+6),V=J.length;if(V>=4294967296)throw new Error(`Too large extension object: ${V}`);this.writeU8(201),this.writeU32(V),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),a6(this.view,this.pos,W),this.pos+=8}writeI64(W){this.ensureBufferSizeToWrite(8),o1(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 g0(W,Q){return new a1(Q).encodeSharedRef(W)}function s1(W){return`${W<0?"-":""}0x${Math.abs(W).toString(16).padStart(2,"0")}`}var aW=16,sW=16;class S8{constructor(W=aW,Q=sW){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 V=this.caches[J-1];W:for(let G of V){const X=G.bytes;for(let Y=0;Y<J;Y++)if(X[Y]!==W[Q+Y])continue W;return G.str}return null}store(W,Q){const J=this.caches[W.length-1],V={bytes:W,str:Q};if(J.length>=this.maxLengthPerKey)J[Math.random()*J.length|0]=V;else J.push(V)}decode(W,Q,J){const V=this.find(W,Q,J);if(V!=null)return this.hit++,V;this.miss++;const G=v8(W,Q,J),X=Uint8Array.prototype.slice.call(W,Q,Q+J);return this.store(X,G),G}}var T8="array",L1="map_key",W5="map_value",eW=(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 J5{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=T8,Q.position=0,Q.size=W,Q.array=new Array(W)}pushMapState(W){const Q=this.getUninitializedStateFromPool();Q.type=L1,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===T8){const J=W;J.size=0,J.array=void 0,J.position=0,J.type=void 0}if(W.type===L1||W.type===W5){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 R1=-1,A8=new DataView(new ArrayBuffer(0)),tW=new Uint8Array(A8.buffer);try{A8.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 t6=new RangeError("Insufficient data"),WJ=new S8;class e1{constructor(W){this.totalPos=0,this.pos=0,this.view=A8,this.bytes=tW,this.headByte=R1,this.stack=new J5,this.entered=!1,this.extensionCodec=W?.extensionCodec??f0.defaultCodec,this.context=W?.context,this.useBigInt64=W?.useBigInt64??!1,this.rawStrings=W?.rawStrings??!1,this.maxStrLength=W?.maxStrLength??J1,this.maxBinLength=W?.maxBinLength??J1,this.maxArrayLength=W?.maxArrayLength??J1,this.maxMapLength=W?.maxMapLength??J1,this.maxExtLength=W?.maxExtLength??J1,this.keyDecoder=W?.keyDecoder!==void 0?W.keyDecoder:WJ,this.mapKeyConverter=W?.mapKeyConverter??eW}clone(){return new e1({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=R1,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===R1&&!this.hasRemaining(1))this.setBuffer(W);else{const Q=this.bytes.subarray(this.pos),J=M1(W),V=new Uint8Array(Q.length+J.length);V.set(Q),V.set(J,Q.length),this.setBuffer(V)}}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 Y of W){if(Q)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(Y);try{J=this.doDecodeSync(),Q=!0}catch(q){if(!(q instanceof RangeError))throw q}this.totalPos+=this.pos}if(Q){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return J}const{headByte:V,pos:G,totalPos:X}=this;throw new RangeError(`Insufficient data in parsing ${s1(V)} at ${X} (${G} 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,V=-1;for await(let G of W){if(Q&&V===0)throw this.createExtraByteError(this.totalPos);if(this.appendBuffer(G),J)V=this.readArraySize(),J=!1,this.complete();try{while(!0)if(yield this.doDecodeSync(),--V===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 Q;if(W>=224)Q=W-256;else if(W<192)if(W<128)Q=W;else if(W<144){const V=W-128;if(V!==0){this.pushMapState(V),this.complete();continue W}else Q={}}else if(W<160){const V=W-144;if(V!==0){this.pushArrayState(V),this.complete();continue W}else Q=[]}else{const V=W-160;Q=this.decodeString(V,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 V=this.lookU8();Q=this.decodeString(V,1)}else if(W===218){const V=this.lookU16();Q=this.decodeString(V,2)}else if(W===219){const V=this.lookU32();Q=this.decodeString(V,4)}else if(W===220){const V=this.readU16();if(V!==0){this.pushArrayState(V),this.complete();continue W}else Q=[]}else if(W===221){const V=this.readU32();if(V!==0){this.pushArrayState(V),this.complete();continue W}else Q=[]}else if(W===222){const V=this.readU16();if(V!==0){this.pushMapState(V),this.complete();continue W}else Q={}}else if(W===223){const V=this.readU32();if(V!==0){this.pushMapState(V),this.complete();continue W}else Q={}}else if(W===196){const V=this.lookU8();Q=this.decodeBinary(V,1)}else if(W===197){const V=this.lookU16();Q=this.decodeBinary(V,2)}else if(W===198){const V=this.lookU32();Q=this.decodeBinary(V,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 V=this.lookU8();Q=this.decodeExtension(V,1)}else if(W===200){const V=this.lookU16();Q=this.decodeExtension(V,2)}else if(W===201){const V=this.lookU32();Q=this.decodeExtension(V,4)}else throw new e(`Unrecognized type byte: ${s1(W)}`);this.complete();const J=this.stack;while(J.length>0){const V=J.top();if(V.type===T8)if(V.array[V.position]=Q,V.position++,V.position===V.size)Q=V.array,J.release(V);else continue W;else if(V.type===L1){if(Q==="__proto__")throw new e("The key __proto__ is not allowed");V.key=this.mapKeyConverter(Q),V.type=W5;continue W}else if(V.map[V.key]=Q,V.readCount++,V.readCount===V.size)Q=V.map,J.release(V);else{V.key=null,V.type=L1;continue W}}return Q}}readHeadByte(){if(this.headByte===R1)this.headByte=this.readU8();return this.headByte}complete(){this.headByte=R1}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: ${s1(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 t6;const J=this.pos+Q;let V;if(this.stateIsMapKey()&&this.keyDecoder?.canBeCached(W))V=this.keyDecoder.decode(this.bytes,J,W);else V=n6(this.bytes,J,W);return this.pos+=Q+W,V}stateIsMapKey(){if(this.stack.length>0)return this.stack.top().type===L1;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 t6;const J=this.pos+Q,V=this.bytes.subarray(J,J+W);return this.pos+=Q+W,V}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),V=this.decodeBinary(W,Q+1);return this.extensionCodec.decode(V,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=s6(this.view,this.pos);return this.pos+=8,W}readI64(){const W=n1(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 t1(W,Q){return new e1(Q).decode(W)}var q1=function(W){let Q=W.length;while(--Q>=0)W[Q]=0},E8=function(W,Q,J,V,G){this.static_tree=W,this.extra_bits=Q,this.extra_base=J,this.elems=V,this.max_length=G,this.has_stree=W&&W.length},p8=function(W,Q){this.dyn_tree=W,this.max_code=0,this.stat_desc=Q},k0=function(W,Q,J,V,G){this.good_length=W,this.max_lazy=Q,this.nice_length=J,this.max_chain=V,this.func=G},Q9=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=U8,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(rJ*2),this.dyn_dtree=new Uint16Array((2*lJ+1)*2),this.bl_tree=new Uint16Array((2*iJ+1)*2),v0(this.dyn_ltree),v0(this.dyn_dtree),v0(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(oJ+1),this.heap=new Uint16Array(2*s8+1),v0(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*s8+1),v0(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},I9=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},b1=function(W){this.options=F8.assign({level:v9,method:T9,chunkSize:16384,windowBits:15,memLevel:8,strategy:S9},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(u0[J]);if(Q.header)w1.deflateSetHeader(this.strm,Q.header);if(Q.dictionary){let V;if(typeof Q.dictionary==="string")V=E1.string2buf(Q.dictionary);else if(P7.call(Q.dictionary)==="[object ArrayBuffer]")V=new Uint8Array(Q.dictionary);else V=Q.dictionary;if(J=w1.deflateSetDictionary(this.strm,V),J!==q8)throw new Error(u0[J]);this._dict_set=!0}},P6=function(W,Q){const J=new b1(Q);if(J.push(W,!0),J.err)throw J.msg||u0[J.err];return J.result},A9=function(W,Q){return Q=Q||{},Q.raw=!0,P6(W,Q)},y9=function(W,Q){return Q=Q||{},Q.gzip=!0,P6(W,Q)},VQ=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},m1=function(W){this.options=F8.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=O0.inflateInit2(this.strm,Q.windowBits);if(J!==p1)throw new Error(u0[J]);if(this.header=new RQ,O0.inflateGetHeader(this.strm,this.header),Q.dictionary){if(typeof Q.dictionary==="string")Q.dictionary=E1.string2buf(Q.dictionary);else if(M7.call(Q.dictionary)==="[object ArrayBuffer]")Q.dictionary=new Uint8Array(Q.dictionary);if(Q.raw){if(J=O0.inflateSetDictionary(this.strm,Q.dictionary),J!==p1)throw new Error(u0[J])}}},U6=function(W,Q){const J=new m1(Q);if(J.push(W),J.err)throw J.msg||u0[J.err];return J.result},xQ=function(W,Q){return Q=Q||{},Q.raw=!0,U6(W,Q)};/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */var JJ=0,m5=1,QJ=2,VJ=3,GJ=258,V6=29,f1=256,g1=f1+1+V6,G1=30,G6=19,u5=2*g1+1,h0=15,y8=16,XJ=7,X6=256,d5=16,c5=17,_5=18,o8=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]),X8=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]),YJ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),l5=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qJ=512,L0=new Array((g1+2)*2);q1(L0);var x1=new Array(G1*2);q1(x1);var v1=new Array(qJ);q1(v1);var S1=new Array(GJ-VJ+1);q1(S1);var Y6=new Array(V6);q1(Y6);var Y8=new Array(G1);q1(Y8);var i5,r5,o5,n5=(W)=>{return W<256?v1[W]:v1[256+(W>>>7)]},T1=(W,Q)=>{W.pending_buf[W.pending++]=Q&255,W.pending_buf[W.pending++]=Q>>>8&255},V0=(W,Q,J)=>{if(W.bi_valid>y8-J)W.bi_buf|=Q<<W.bi_valid&65535,T1(W,W.bi_buf),W.bi_buf=Q>>y8-W.bi_valid,W.bi_valid+=J-y8;else W.bi_buf|=Q<<W.bi_valid&65535,W.bi_valid+=J},H0=(W,Q,J)=>{V0(W,J[Q*2],J[Q*2+1])},a5=(W,Q)=>{let J=0;do J|=W&1,W>>>=1,J<<=1;while(--Q>0);return J>>>1},PJ=(W)=>{if(W.bi_valid===16)T1(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},UJ=(W,Q)=>{const{dyn_tree:J,max_code:V}=Q,G=Q.stat_desc.static_tree,X=Q.stat_desc.has_stree,Y=Q.stat_desc.extra_bits,q=Q.stat_desc.extra_base,U=Q.stat_desc.max_length;let P,F,C,K,z,$,N=0;for(K=0;K<=h0;K++)W.bl_count[K]=0;J[W.heap[W.heap_max]*2+1]=0;for(P=W.heap_max+1;P<u5;P++){if(F=W.heap[P],K=J[J[F*2+1]*2+1]+1,K>U)K=U,N++;if(J[F*2+1]=K,F>V)continue;if(W.bl_count[K]++,z=0,F>=q)z=Y[F-q];if($=J[F*2],W.opt_len+=$*(K+z),X)W.static_len+=$*(G[F*2+1]+z)}if(N===0)return;do{K=U-1;while(W.bl_count[K]===0)K--;W.bl_count[K]--,W.bl_count[K+1]+=2,W.bl_count[U]--,N-=2}while(N>0);for(K=U;K!==0;K--){F=W.bl_count[K];while(F!==0){if(C=W.heap[--P],C>V)continue;if(J[C*2+1]!==K)W.opt_len+=(K-J[C*2+1])*J[C*2],J[C*2+1]=K;F--}}},s5=(W,Q,J)=>{const V=new Array(h0+1);let G=0,X,Y;for(X=1;X<=h0;X++)G=G+J[X-1]<<1,V[X]=G;for(Y=0;Y<=Q;Y++){let q=W[Y*2+1];if(q===0)continue;W[Y*2]=a5(V[q]++,q)}},FJ=()=>{let W,Q,J,V,G;const X=new Array(h0+1);J=0;for(V=0;V<V6-1;V++){Y6[V]=J;for(W=0;W<1<<o8[V];W++)S1[J++]=V}S1[J-1]=V,G=0;for(V=0;V<16;V++){Y8[V]=G;for(W=0;W<1<<X8[V];W++)v1[G++]=V}G>>=7;for(;V<G1;V++){Y8[V]=G<<7;for(W=0;W<1<<X8[V]-7;W++)v1[256+G++]=V}for(Q=0;Q<=h0;Q++)X[Q]=0;W=0;while(W<=143)L0[W*2+1]=8,W++,X[8]++;while(W<=255)L0[W*2+1]=9,W++,X[9]++;while(W<=279)L0[W*2+1]=7,W++,X[7]++;while(W<=287)L0[W*2+1]=8,W++,X[8]++;s5(L0,g1+1,X);for(W=0;W<G1;W++)x1[W*2+1]=5,x1[W*2]=a5(W,5);i5=new E8(L0,o8,f1+1,g1,h0),r5=new E8(x1,X8,0,G1,h0),o5=new E8(new Array(0),YJ,0,G6,XJ)},e5=(W)=>{let Q;for(Q=0;Q<g1;Q++)W.dyn_ltree[Q*2]=0;for(Q=0;Q<G1;Q++)W.dyn_dtree[Q*2]=0;for(Q=0;Q<G6;Q++)W.bl_tree[Q*2]=0;W.dyn_ltree[X6*2]=1,W.opt_len=W.static_len=0,W.sym_next=W.matches=0},t5=(W)=>{if(W.bi_valid>8)T1(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},Q5=(W,Q,J,V)=>{const G=Q*2,X=J*2;return W[G]<W[X]||W[G]===W[X]&&V[Q]<=V[J]},f8=(W,Q,J)=>{const V=W.heap[J];let G=J<<1;while(G<=W.heap_len){if(G<W.heap_len&&Q5(Q,W.heap[G+1],W.heap[G],W.depth))G++;if(Q5(Q,V,W.heap[G],W.depth))break;W.heap[J]=W.heap[G],J=G,G<<=1}W.heap[J]=V},V5=(W,Q,J)=>{let V,G,X=0,Y,q;if(W.sym_next!==0)do if(V=W.pending_buf[W.sym_buf+X++]&255,V+=(W.pending_buf[W.sym_buf+X++]&255)<<8,G=W.pending_buf[W.sym_buf+X++],V===0)H0(W,G,Q);else{if(Y=S1[G],H0(W,Y+f1+1,Q),q=o8[Y],q!==0)G-=Y6[Y],V0(W,G,q);if(V--,Y=n5(V),H0(W,Y,J),q=X8[Y],q!==0)V-=Y8[Y],V0(W,V,q)}while(X<W.sym_next);H0(W,X6,Q)},n8=(W,Q)=>{const J=Q.dyn_tree,V=Q.stat_desc.static_tree,G=Q.stat_desc.has_stree,X=Q.stat_desc.elems;let Y,q,U=-1,P;W.heap_len=0,W.heap_max=u5;for(Y=0;Y<X;Y++)if(J[Y*2]!==0)W.heap[++W.heap_len]=U=Y,W.depth[Y]=0;else J[Y*2+1]=0;while(W.heap_len<2)if(P=W.heap[++W.heap_len]=U<2?++U:0,J[P*2]=1,W.depth[P]=0,W.opt_len--,G)W.static_len-=V[P*2+1];Q.max_code=U;for(Y=W.heap_len>>1;Y>=1;Y--)f8(W,J,Y);P=X;do Y=W.heap[1],W.heap[1]=W.heap[W.heap_len--],f8(W,J,1),q=W.heap[1],W.heap[--W.heap_max]=Y,W.heap[--W.heap_max]=q,J[P*2]=J[Y*2]+J[q*2],W.depth[P]=(W.depth[Y]>=W.depth[q]?W.depth[Y]:W.depth[q])+1,J[Y*2+1]=J[q*2+1]=P,W.heap[1]=P++,f8(W,J,1);while(W.heap_len>=2);W.heap[--W.heap_max]=W.heap[1],UJ(W,Q),s5(J,U,W.bl_count)},G5=(W,Q,J)=>{let V,G=-1,X,Y=Q[1],q=0,U=7,P=4;if(Y===0)U=138,P=3;Q[(J+1)*2+1]=65535;for(V=0;V<=J;V++){if(X=Y,Y=Q[(V+1)*2+1],++q<U&&X===Y)continue;else if(q<P)W.bl_tree[X*2]+=q;else if(X!==0){if(X!==G)W.bl_tree[X*2]++;W.bl_tree[d5*2]++}else if(q<=10)W.bl_tree[c5*2]++;else W.bl_tree[_5*2]++;if(q=0,G=X,Y===0)U=138,P=3;else if(X===Y)U=6,P=3;else U=7,P=4}},X5=(W,Q,J)=>{let V,G=-1,X,Y=Q[1],q=0,U=7,P=4;if(Y===0)U=138,P=3;for(V=0;V<=J;V++){if(X=Y,Y=Q[(V+1)*2+1],++q<U&&X===Y)continue;else if(q<P)do H0(W,X,W.bl_tree);while(--q!==0);else if(X!==0){if(X!==G)H0(W,X,W.bl_tree),q--;H0(W,d5,W.bl_tree),V0(W,q-3,2)}else if(q<=10)H0(W,c5,W.bl_tree),V0(W,q-3,3);else H0(W,_5,W.bl_tree),V0(W,q-11,7);if(q=0,G=X,Y===0)U=138,P=3;else if(X===Y)U=6,P=3;else U=7,P=4}},KJ=(W)=>{let Q;G5(W,W.dyn_ltree,W.l_desc.max_code),G5(W,W.dyn_dtree,W.d_desc.max_code),n8(W,W.bl_desc);for(Q=G6-1;Q>=3;Q--)if(W.bl_tree[l5[Q]*2+1]!==0)break;return W.opt_len+=3*(Q+1)+5+5+4,Q},zJ=(W,Q,J,V)=>{let G;V0(W,Q-257,5),V0(W,J-1,5),V0(W,V-4,4);for(G=0;G<V;G++)V0(W,W.bl_tree[l5[G]*2+1],3);X5(W,W.dyn_ltree,Q-1),X5(W,W.dyn_dtree,J-1)},ZJ=(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<f1;J++)if(W.dyn_ltree[J*2]!==0)return 1;return 0},Y5=!1,kJ=(W)=>{if(!Y5)FJ(),Y5=!0;W.l_desc=new p8(W.dyn_ltree,i5),W.d_desc=new p8(W.dyn_dtree,r5),W.bl_desc=new p8(W.bl_tree,o5),W.bi_buf=0,W.bi_valid=0,e5(W)},W7=(W,Q,J,V)=>{if(V0(W,(JJ<<1)+(V?1:0),3),t5(W),T1(W,J),T1(W,~J),J)W.pending_buf.set(W.window.subarray(Q,Q+J),W.pending);W.pending+=J},HJ=(W)=>{V0(W,m5<<1,3),H0(W,X6,L0),PJ(W)},CJ=(W,Q,J,V)=>{let G,X,Y=0;if(W.level>0){if(W.strm.data_type===2)W.strm.data_type=ZJ(W);if(n8(W,W.l_desc),n8(W,W.d_desc),Y=KJ(W),G=W.opt_len+3+7>>>3,X=W.static_len+3+7>>>3,X<=G)G=X}else G=X=J+5;if(J+4<=G&&Q!==-1)W7(W,Q,J,V);else if(W.strategy===4||X===G)V0(W,(m5<<1)+(V?1:0),3),V5(W,L0,x1);else V0(W,(QJ<<1)+(V?1:0),3),zJ(W,W.l_desc.max_code+1,W.d_desc.max_code+1,Y+1),V5(W,W.dyn_ltree,W.dyn_dtree);if(e5(W),V)t5(W)},$J=(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[(S1[J]+f1+1)*2]++,W.dyn_dtree[n5(Q)*2]++;return W.sym_next===W.sym_end},jJ=kJ,BJ=W7,MJ=CJ,RJ=$J,LJ=HJ,OJ={_tr_init:jJ,_tr_stored_block:BJ,_tr_flush_block:MJ,_tr_tally:RJ,_tr_align:LJ},IJ=(W,Q,J,V)=>{let G=W&65535|0,X=W>>>16&65535|0,Y=0;while(J!==0){Y=J>2000?2000:J,J-=Y;do G=G+Q[V++]|0,X=X+G|0;while(--Y);G%=65521,X%=65521}return G|X<<16|0},A1=IJ,DJ=()=>{let W,Q=[];for(var J=0;J<256;J++){W=J;for(var V=0;V<8;V++)W=W&1?3988292384^W>>>1:W>>>1;Q[J]=W}return Q},xJ=new Uint32Array(DJ()),wJ=(W,Q,J,V)=>{const G=xJ,X=V+J;W^=-1;for(let Y=V;Y<X;Y++)W=W>>>8^G[(W^Q[Y])&255];return W^-1},o=wJ,u0={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"},_0={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:NJ,_tr_stored_block:a8,_tr_flush_block:gJ,_tr_tally:T0,_tr_align:vJ}=OJ,{Z_NO_FLUSH:A0,Z_PARTIAL_FLUSH:SJ,Z_FULL_FLUSH:TJ,Z_FINISH:F0,Z_BLOCK:q5,Z_OK:n,Z_STREAM_END:P5,Z_STREAM_ERROR:C0,Z_DATA_ERROR:AJ,Z_BUF_ERROR:h8,Z_DEFAULT_COMPRESSION:yJ,Z_FILTERED:EJ,Z_HUFFMAN_ONLY:W8,Z_RLE:pJ,Z_FIXED:fJ,Z_DEFAULT_STRATEGY:hJ,Z_UNKNOWN:bJ,Z_DEFLATED:U8}=_0,mJ=9,uJ=15,dJ=8,cJ=29,_J=256,s8=_J+1+cJ,lJ=30,iJ=19,rJ=2*s8+1,oJ=15,u=3,S0=258,$0=S0+u+1,nJ=32,X1=42,q6=57,e8=69,t8=73,W6=91,J6=103,b0=113,I1=666,t=1,P1=2,d0=3,U1=4,aJ=3,m0=(W,Q)=>{return W.msg=u0[Q],Q},U5=(W)=>{return W*2-(W>4?9:0)},v0=(W)=>{let Q=W.length;while(--Q>=0)W[Q]=0},sJ=(W)=>{let Q,J,V,G=W.w_size;Q=W.hash_size,V=Q;do J=W.head[--V],W.head[V]=J>=G?J-G:0;while(--Q);Q=G,V=Q;do J=W.prev[--V],W.prev[V]=J>=G?J-G:0;while(--Q)},eJ=(W,Q,J)=>(Q<<W.hash_shift^J)&W.hash_mask,y0=eJ,X0=(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},Y0=(W,Q)=>{gJ(W,W.block_start>=0?W.block_start:-1,W.strstart-W.block_start,Q),W.block_start=W.strstart,X0(W.strm)},c=(W,Q)=>{W.pending_buf[W.pending++]=Q},O1=(W,Q)=>{W.pending_buf[W.pending++]=Q>>>8&255,W.pending_buf[W.pending++]=Q&255},Q6=(W,Q,J,V)=>{let G=W.avail_in;if(G>V)G=V;if(G===0)return 0;if(W.avail_in-=G,Q.set(W.input.subarray(W.next_in,W.next_in+G),J),W.state.wrap===1)W.adler=A1(W.adler,Q,G,J);else if(W.state.wrap===2)W.adler=o(W.adler,Q,G,J);return W.next_in+=G,W.total_in+=G,G},J7=(W,Q)=>{let{max_chain_length:J,strstart:V}=W,G,X,Y=W.prev_length,q=W.nice_match;const U=W.strstart>W.w_size-$0?W.strstart-(W.w_size-$0):0,P=W.window,F=W.w_mask,C=W.prev,K=W.strstart+S0;let z=P[V+Y-1],$=P[V+Y];if(W.prev_length>=W.good_match)J>>=2;if(q>W.lookahead)q=W.lookahead;do{if(G=Q,P[G+Y]!==$||P[G+Y-1]!==z||P[G]!==P[V]||P[++G]!==P[V+1])continue;V+=2,G++;do;while(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]===P[++G]&&V<K);if(X=S0-(K-V),V=K-S0,X>Y){if(W.match_start=Q,Y=X,X>=q)break;z=P[V+Y-1],$=P[V+Y]}}while((Q=C[Q&F])>U&&--J!==0);if(Y<=W.lookahead)return Y;return W.lookahead},Y1=(W)=>{const Q=W.w_size;let J,V,G;do{if(V=W.window_size-W.lookahead-W.strstart,W.strstart>=Q+(Q-$0)){if(W.window.set(W.window.subarray(Q,Q+Q-V),0),W.match_start-=Q,W.strstart-=Q,W.block_start-=Q,W.insert>W.strstart)W.insert=W.strstart;sJ(W),V+=Q}if(W.strm.avail_in===0)break;if(J=Q6(W.strm,W.window,W.strstart+W.lookahead,V),W.lookahead+=J,W.lookahead+W.insert>=u){G=W.strstart-W.insert,W.ins_h=W.window[G],W.ins_h=y0(W,W.ins_h,W.window[G+1]);while(W.insert)if(W.ins_h=y0(W,W.ins_h,W.window[G+u-1]),W.prev[G&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=G,G++,W.insert--,W.lookahead+W.insert<u)break}}while(W.lookahead<$0&&W.strm.avail_in!==0)},Q7=(W,Q)=>{let J=W.pending_buf_size-5>W.w_size?W.w_size:W.pending_buf_size-5,V,G,X,Y=0,q=W.strm.avail_in;do{if(V=65535,X=W.bi_valid+42>>3,W.strm.avail_out<X)break;if(X=W.strm.avail_out-X,G=W.strstart-W.block_start,V>G+W.strm.avail_in)V=G+W.strm.avail_in;if(V>X)V=X;if(V<J&&(V===0&&Q!==F0||Q===A0||V!==G+W.strm.avail_in))break;if(Y=Q===F0&&V===G+W.strm.avail_in?1:0,a8(W,0,0,Y),W.pending_buf[W.pending-4]=V,W.pending_buf[W.pending-3]=V>>8,W.pending_buf[W.pending-2]=~V,W.pending_buf[W.pending-1]=~V>>8,X0(W.strm),G){if(G>V)G=V;W.strm.output.set(W.window.subarray(W.block_start,W.block_start+G),W.strm.next_out),W.strm.next_out+=G,W.strm.avail_out-=G,W.strm.total_out+=G,W.block_start+=G,V-=G}if(V)Q6(W.strm,W.strm.output,W.strm.next_out,V),W.strm.next_out+=V,W.strm.avail_out-=V,W.strm.total_out+=V}while(Y===0);if(q-=W.strm.avail_in,q){if(q>=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<=q){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-q,W.strm.next_in),W.strstart),W.strstart+=q,W.insert+=q>W.w_size-W.insert?W.w_size-W.insert:q}W.block_start=W.strstart}if(W.high_water<W.strstart)W.high_water=W.strstart;if(Y)return U1;if(Q!==A0&&Q!==F0&&W.strm.avail_in===0&&W.strstart===W.block_start)return P1;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)Q6(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,G=W.strstart-W.block_start,G>=J||(G||Q===F0)&&Q!==A0&&W.strm.avail_in===0&&G<=X)V=G>X?X:G,Y=Q===F0&&W.strm.avail_in===0&&V===G?1:0,a8(W,W.block_start,V,Y),W.block_start+=V,X0(W.strm);return Y?d0:t},b8=(W,Q)=>{let J,V;for(;;){if(W.lookahead<$0){if(Y1(W),W.lookahead<$0&&Q===A0)return t;if(W.lookahead===0)break}if(J=0,W.lookahead>=u)W.ins_h=y0(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-$0)W.match_length=J7(W,J);if(W.match_length>=u)if(V=T0(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=y0(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=y0(W,W.ins_h,W.window[W.strstart+1]);else V=T0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++;if(V){if(Y0(W,!1),W.strm.avail_out===0)return t}}if(W.insert=W.strstart<u-1?W.strstart:u-1,Q===F0){if(Y0(W,!0),W.strm.avail_out===0)return d0;return U1}if(W.sym_next){if(Y0(W,!1),W.strm.avail_out===0)return t}return P1},Q1=(W,Q)=>{let J,V,G;for(;;){if(W.lookahead<$0){if(Y1(W),W.lookahead<$0&&Q===A0)return t;if(W.lookahead===0)break}if(J=0,W.lookahead>=u)W.ins_h=y0(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-$0){if(W.match_length=J7(W,J),W.match_length<=5&&(W.strategy===EJ||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){G=W.strstart+W.lookahead-u,V=T0(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<=G)W.ins_h=y0(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++,V){if(Y0(W,!1),W.strm.avail_out===0)return t}}else if(W.match_available){if(V=T0(W,0,W.window[W.strstart-1]),V)Y0(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)V=T0(W,0,W.window[W.strstart-1]),W.match_available=0;if(W.insert=W.strstart<u-1?W.strstart:u-1,Q===F0){if(Y0(W,!0),W.strm.avail_out===0)return d0;return U1}if(W.sym_next){if(Y0(W,!1),W.strm.avail_out===0)return t}return P1},tJ=(W,Q)=>{let J,V,G,X;const Y=W.window;for(;;){if(W.lookahead<=S0){if(Y1(W),W.lookahead<=S0&&Q===A0)return t;if(W.lookahead===0)break}if(W.match_length=0,W.lookahead>=u&&W.strstart>0){if(G=W.strstart-1,V=Y[G],V===Y[++G]&&V===Y[++G]&&V===Y[++G]){X=W.strstart+S0;do;while(V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&G<X);if(W.match_length=S0-(X-G),W.match_length>W.lookahead)W.match_length=W.lookahead}}if(W.match_length>=u)J=T0(W,1,W.match_length-u),W.lookahead-=W.match_length,W.strstart+=W.match_length,W.match_length=0;else J=T0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++;if(J){if(Y0(W,!1),W.strm.avail_out===0)return t}}if(W.insert=0,Q===F0){if(Y0(W,!0),W.strm.avail_out===0)return d0;return U1}if(W.sym_next){if(Y0(W,!1),W.strm.avail_out===0)return t}return P1},W9=(W,Q)=>{let J;for(;;){if(W.lookahead===0){if(Y1(W),W.lookahead===0){if(Q===A0)return t;break}}if(W.match_length=0,J=T0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++,J){if(Y0(W,!1),W.strm.avail_out===0)return t}}if(W.insert=0,Q===F0){if(Y0(W,!0),W.strm.avail_out===0)return d0;return U1}if(W.sym_next){if(Y0(W,!1),W.strm.avail_out===0)return t}return P1},D1=[new k0(0,0,0,0,Q7),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,Q1),new k0(8,16,32,32,Q1),new k0(8,16,128,128,Q1),new k0(8,32,128,256,Q1),new k0(32,128,258,1024,Q1),new k0(32,258,258,4096,Q1)],J9=(W)=>{W.window_size=2*W.w_size,v0(W.head),W.max_lazy_match=D1[W.level].max_lazy,W.good_match=D1[W.level].good_length,W.nice_match=D1[W.level].nice_length,W.max_chain_length=D1[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},h1=(W)=>{if(!W)return 1;const Q=W.state;if(!Q||Q.strm!==W||Q.status!==X1&&Q.status!==q6&&Q.status!==e8&&Q.status!==t8&&Q.status!==W6&&Q.status!==J6&&Q.status!==b0&&Q.status!==I1)return 1;return 0},V7=(W)=>{if(h1(W))return m0(W,C0);W.total_in=W.total_out=0,W.data_type=bJ;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?q6:Q.wrap?X1:b0,W.adler=Q.wrap===2?0:1,Q.last_flush=-2,NJ(Q),n},G7=(W)=>{const Q=V7(W);if(Q===n)J9(W.state);return Q},V9=(W,Q)=>{if(h1(W)||W.state.wrap!==2)return C0;return W.state.gzhead=Q,n},X7=(W,Q,J,V,G,X)=>{if(!W)return C0;let Y=1;if(Q===yJ)Q=6;if(V<0)Y=0,V=-V;else if(V>15)Y=2,V-=16;if(G<1||G>mJ||J!==U8||V<8||V>15||Q<0||Q>9||X<0||X>fJ||V===8&&Y!==1)return m0(W,C0);if(V===8)V=9;const q=new Q9;return W.state=q,q.strm=W,q.status=X1,q.wrap=Y,q.gzhead=null,q.w_bits=V,q.w_size=1<<q.w_bits,q.w_mask=q.w_size-1,q.hash_bits=G+7,q.hash_size=1<<q.hash_bits,q.hash_mask=q.hash_size-1,q.hash_shift=~~((q.hash_bits+u-1)/u),q.window=new Uint8Array(q.w_size*2),q.head=new Uint16Array(q.hash_size),q.prev=new Uint16Array(q.w_size),q.lit_bufsize=1<<G+6,q.pending_buf_size=q.lit_bufsize*4,q.pending_buf=new Uint8Array(q.pending_buf_size),q.sym_buf=q.lit_bufsize,q.sym_end=(q.lit_bufsize-1)*3,q.level=Q,q.strategy=X,q.method=J,G7(W)},G9=(W,Q)=>{return X7(W,Q,U8,uJ,dJ,hJ)},X9=(W,Q)=>{if(h1(W)||Q>q5||Q<0)return W?m0(W,C0):C0;const J=W.state;if(!W.output||W.avail_in!==0&&!W.input||J.status===I1&&Q!==F0)return m0(W,W.avail_out===0?h8:C0);const V=J.last_flush;if(J.last_flush=Q,J.pending!==0){if(X0(W),W.avail_out===0)return J.last_flush=-1,n}else if(W.avail_in===0&&U5(Q)<=U5(V)&&Q!==F0)return m0(W,h8);if(J.status===I1&&W.avail_in!==0)return m0(W,h8);if(J.status===X1&&J.wrap===0)J.status=b0;if(J.status===X1){let G=U8+(J.w_bits-8<<4)<<8,X=-1;if(J.strategy>=W8||J.level<2)X=0;else if(J.level<6)X=1;else if(J.level===6)X=2;else X=3;if(G|=X<<6,J.strstart!==0)G|=nJ;if(G+=31-G%31,O1(J,G),J.strstart!==0)O1(J,W.adler>>>16),O1(J,W.adler&65535);if(W.adler=1,J.status=b0,X0(W),J.pending!==0)return J.last_flush=-1,n}if(J.status===q6)if(W.adler=0,c(J,31),c(J,139),c(J,8),!J.gzhead){if(c(J,0),c(J,0),c(J,0),c(J,0),c(J,0),c(J,J.level===9?2:J.strategy>=W8||J.level<2?4:0),c(J,aJ),J.status=b0,X0(W),J.pending!==0)return J.last_flush=-1,n}else{if(c(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)),c(J,J.gzhead.time&255),c(J,J.gzhead.time>>8&255),c(J,J.gzhead.time>>16&255),c(J,J.gzhead.time>>24&255),c(J,J.level===9?2:J.strategy>=W8||J.level<2?4:0),c(J,J.gzhead.os&255),J.gzhead.extra&&J.gzhead.extra.length)c(J,J.gzhead.extra.length&255),c(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 G=J.pending,X=(J.gzhead.extra.length&65535)-J.gzindex;while(J.pending+X>J.pending_buf_size){let q=J.pending_buf_size-J.pending;if(J.pending_buf.set(J.gzhead.extra.subarray(J.gzindex,J.gzindex+q),J.pending),J.pending=J.pending_buf_size,J.gzhead.hcrc&&J.pending>G)W.adler=o(W.adler,J.pending_buf,J.pending-G,G);if(J.gzindex+=q,X0(W),J.pending!==0)return J.last_flush=-1,n;G=0,X-=q}let Y=new Uint8Array(J.gzhead.extra);if(J.pending_buf.set(Y.subarray(J.gzindex,J.gzindex+X),J.pending),J.pending+=X,J.gzhead.hcrc&&J.pending>G)W.adler=o(W.adler,J.pending_buf,J.pending-G,G);J.gzindex=0}J.status=t8}if(J.status===t8){if(J.gzhead.name){let G=J.pending,X;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>G)W.adler=o(W.adler,J.pending_buf,J.pending-G,G);if(X0(W),J.pending!==0)return J.last_flush=-1,n;G=0}if(J.gzindex<J.gzhead.name.length)X=J.gzhead.name.charCodeAt(J.gzindex++)&255;else X=0;c(J,X)}while(X!==0);if(J.gzhead.hcrc&&J.pending>G)W.adler=o(W.adler,J.pending_buf,J.pending-G,G);J.gzindex=0}J.status=W6}if(J.status===W6){if(J.gzhead.comment){let G=J.pending,X;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>G)W.adler=o(W.adler,J.pending_buf,J.pending-G,G);if(X0(W),J.pending!==0)return J.last_flush=-1,n;G=0}if(J.gzindex<J.gzhead.comment.length)X=J.gzhead.comment.charCodeAt(J.gzindex++)&255;else X=0;c(J,X)}while(X!==0);if(J.gzhead.hcrc&&J.pending>G)W.adler=o(W.adler,J.pending_buf,J.pending-G,G)}J.status=J6}if(J.status===J6){if(J.gzhead.hcrc){if(J.pending+2>J.pending_buf_size){if(X0(W),J.pending!==0)return J.last_flush=-1,n}c(J,W.adler&255),c(J,W.adler>>8&255),W.adler=0}if(J.status=b0,X0(W),J.pending!==0)return J.last_flush=-1,n}if(W.avail_in!==0||J.lookahead!==0||Q!==A0&&J.status!==I1){let G=J.level===0?Q7(J,Q):J.strategy===W8?W9(J,Q):J.strategy===pJ?tJ(J,Q):D1[J.level].func(J,Q);if(G===d0||G===U1)J.status=I1;if(G===t||G===d0){if(W.avail_out===0)J.last_flush=-1;return n}if(G===P1){if(Q===SJ)vJ(J);else if(Q!==q5){if(a8(J,0,0,!1),Q===TJ){if(v0(J.head),J.lookahead===0)J.strstart=0,J.block_start=0,J.insert=0}}if(X0(W),W.avail_out===0)return J.last_flush=-1,n}}if(Q!==F0)return n;if(J.wrap<=0)return P5;if(J.wrap===2)c(J,W.adler&255),c(J,W.adler>>8&255),c(J,W.adler>>16&255),c(J,W.adler>>24&255),c(J,W.total_in&255),c(J,W.total_in>>8&255),c(J,W.total_in>>16&255),c(J,W.total_in>>24&255);else O1(J,W.adler>>>16),O1(J,W.adler&65535);if(X0(W),J.wrap>0)J.wrap=-J.wrap;return J.pending!==0?n:P5},Y9=(W)=>{if(h1(W))return C0;const Q=W.state.status;return W.state=null,Q===b0?m0(W,AJ):n},q9=(W,Q)=>{let J=Q.length;if(h1(W))return C0;const V=W.state,G=V.wrap;if(G===2||G===1&&V.status!==X1||V.lookahead)return C0;if(G===1)W.adler=A1(W.adler,Q,J,0);if(V.wrap=0,J>=V.w_size){if(G===0)v0(V.head),V.strstart=0,V.block_start=0,V.insert=0;let U=new Uint8Array(V.w_size);U.set(Q.subarray(J-V.w_size,J),0),Q=U,J=V.w_size}const{avail_in:X,next_in:Y,input:q}=W;W.avail_in=J,W.next_in=0,W.input=Q,Y1(V);while(V.lookahead>=u){let U=V.strstart,P=V.lookahead-(u-1);do V.ins_h=y0(V,V.ins_h,V.window[U+u-1]),V.prev[U&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=U,U++;while(--P);V.strstart=U,V.lookahead=u-1,Y1(V)}return V.strstart+=V.lookahead,V.block_start=V.strstart,V.insert=V.lookahead,V.lookahead=0,V.match_length=V.prev_length=u-1,V.match_available=0,W.next_in=Y,W.input=q,W.avail_in=X,V.wrap=G,n},P9=G9,U9=X7,F9=G7,K9=V7,z9=V9,Z9=X9,k9=Y9,H9=q9,C9="pako deflate (from Nodeca project)",w1={deflateInit:P9,deflateInit2:U9,deflateReset:F9,deflateResetKeep:K9,deflateSetHeader:z9,deflate:Z9,deflateEnd:k9,deflateSetDictionary:H9,deflateInfo:C9},$9=(W,Q)=>{return Object.prototype.hasOwnProperty.call(W,Q)},j9=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 V in J)if($9(J,V))W[V]=J[V]}return W},B9=(W)=>{let Q=0;for(let V=0,G=W.length;V<G;V++)Q+=W[V].length;const J=new Uint8Array(Q);for(let V=0,G=0,X=W.length;V<X;V++){let Y=W[V];J.set(Y,G),G+=Y.length}return J},F8={assign:j9,flattenChunks:B9},Y7=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(W){Y7=!1}var y1=new Uint8Array(256);for(let W=0;W<256;W++)y1[W]=W>=252?6:W>=248?5:W>=240?4:W>=224?3:W>=192?2:1;y1[254]=y1[254]=1;var M9=(W)=>{if(typeof TextEncoder==="function"&&TextEncoder.prototype.encode)return(new TextEncoder()).encode(W);let Q,J,V,G,X,Y=W.length,q=0;for(G=0;G<Y;G++){if(J=W.charCodeAt(G),(J&64512)===55296&&G+1<Y){if(V=W.charCodeAt(G+1),(V&64512)===56320)J=65536+(J-55296<<10)+(V-56320),G++}q+=J<128?1:J<2048?2:J<65536?3:4}Q=new Uint8Array(q);for(X=0,G=0;X<q;G++){if(J=W.charCodeAt(G),(J&64512)===55296&&G+1<Y){if(V=W.charCodeAt(G+1),(V&64512)===56320)J=65536+(J-55296<<10)+(V-56320),G++}if(J<128)Q[X++]=J;else if(J<2048)Q[X++]=192|J>>>6,Q[X++]=128|J&63;else if(J<65536)Q[X++]=224|J>>>12,Q[X++]=128|J>>>6&63,Q[X++]=128|J&63;else Q[X++]=240|J>>>18,Q[X++]=128|J>>>12&63,Q[X++]=128|J>>>6&63,Q[X++]=128|J&63}return Q},R9=(W,Q)=>{if(Q<65534){if(W.subarray&&Y7)return String.fromCharCode.apply(null,W.length===Q?W:W.subarray(0,Q))}let J="";for(let V=0;V<Q;V++)J+=String.fromCharCode(W[V]);return J},L9=(W,Q)=>{const J=Q||W.length;if(typeof TextDecoder==="function"&&TextDecoder.prototype.decode)return(new TextDecoder()).decode(W.subarray(0,Q));let V,G;const X=new Array(J*2);for(G=0,V=0;V<J;){let Y=W[V++];if(Y<128){X[G++]=Y;continue}let q=y1[Y];if(q>4){X[G++]=65533,V+=q-1;continue}Y&=q===2?31:q===3?15:7;while(q>1&&V<J)Y=Y<<6|W[V++]&63,q--;if(q>1){X[G++]=65533;continue}if(Y<65536)X[G++]=Y;else Y-=65536,X[G++]=55296|Y>>10&1023,X[G++]=56320|Y&1023}return R9(X,G)},O9=(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+y1[W[J]]>Q?J:Q},E1={string2buf:M9,buf2string:L9,utf8border:O9},q7=I9,P7=Object.prototype.toString,{Z_NO_FLUSH:D9,Z_SYNC_FLUSH:x9,Z_FULL_FLUSH:w9,Z_FINISH:N9,Z_OK:q8,Z_STREAM_END:g9,Z_DEFAULT_COMPRESSION:v9,Z_DEFAULT_STRATEGY:S9,Z_DEFLATED:T9}=_0;b1.prototype.push=function(W,Q){const J=this.strm,V=this.options.chunkSize;let G,X;if(this.ended)return!1;if(Q===~~Q)X=Q;else X=Q===!0?N9:D9;if(typeof W==="string")J.input=E1.string2buf(W);else if(P7.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(V),J.next_out=0,J.avail_out=V;if((X===x9||X===w9)&&J.avail_out<=6){this.onData(J.output.subarray(0,J.next_out)),J.avail_out=0;continue}if(G=w1.deflate(J,X),G===g9){if(J.next_out>0)this.onData(J.output.subarray(0,J.next_out));return G=w1.deflateEnd(this.strm),this.onEnd(G),this.ended=!0,G===q8}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};b1.prototype.onData=function(W){this.chunks.push(W)};b1.prototype.onEnd=function(W){if(W===q8)this.result=F8.flattenChunks(this.chunks);this.chunks=[],this.err=W,this.msg=this.strm.msg};var E9=b1,p9=P6,f9=A9,h9=y9,b9=_0,m9={Deflate:E9,deflate:p9,deflateRaw:f9,gzip:h9,constants:b9},J8=16209,u9=16191,d9=function W(Q,J){let V,G,X,Y,q,U,P,F,C,K,z,$,N,v,y,E,p,x,f,d,I,L,w,Z;const k=Q.state;V=Q.next_in,w=Q.input,G=V+(Q.avail_in-5),X=Q.next_out,Z=Q.output,Y=X-(J-Q.avail_out),q=X+(Q.avail_out-257),U=k.dmax,P=k.wsize,F=k.whave,C=k.wnext,K=k.window,z=k.hold,$=k.bits,N=k.lencode,v=k.distcode,y=(1<<k.lenbits)-1,E=(1<<k.distbits)-1;W:do{if($<15)z+=w[V++]<<$,$+=8,z+=w[V++]<<$,$+=8;p=N[z&y];J:for(;;){if(x=p>>>24,z>>>=x,$-=x,x=p>>>16&255,x===0)Z[X++]=p&65535;else if(x&16){if(f=p&65535,x&=15,x){if($<x)z+=w[V++]<<$,$+=8;f+=z&(1<<x)-1,z>>>=x,$-=x}if($<15)z+=w[V++]<<$,$+=8,z+=w[V++]<<$,$+=8;p=v[z&E];Q:for(;;){if(x=p>>>24,z>>>=x,$-=x,x=p>>>16&255,x&16){if(d=p&65535,x&=15,$<x){if(z+=w[V++]<<$,$+=8,$<x)z+=w[V++]<<$,$+=8}if(d+=z&(1<<x)-1,d>U){Q.msg="invalid distance too far back",k.mode=J8;break W}if(z>>>=x,$-=x,x=X-Y,d>x){if(x=d-x,x>F){if(k.sane){Q.msg="invalid distance too far back",k.mode=J8;break W}}if(I=0,L=K,C===0){if(I+=P-x,x<f){f-=x;do Z[X++]=K[I++];while(--x);I=X-d,L=Z}}else if(C<x){if(I+=P+C-x,x-=C,x<f){f-=x;do Z[X++]=K[I++];while(--x);if(I=0,C<f){x=C,f-=x;do Z[X++]=K[I++];while(--x);I=X-d,L=Z}}}else if(I+=C-x,x<f){f-=x;do Z[X++]=K[I++];while(--x);I=X-d,L=Z}while(f>2)Z[X++]=L[I++],Z[X++]=L[I++],Z[X++]=L[I++],f-=3;if(f){if(Z[X++]=L[I++],f>1)Z[X++]=L[I++]}}else{I=X-d;do Z[X++]=Z[I++],Z[X++]=Z[I++],Z[X++]=Z[I++],f-=3;while(f>2);if(f){if(Z[X++]=Z[I++],f>1)Z[X++]=Z[I++]}}}else if((x&64)===0){p=v[(p&65535)+(z&(1<<x)-1)];continue Q}else{Q.msg="invalid distance code",k.mode=J8;break W}break}}else if((x&64)===0){p=N[(p&65535)+(z&(1<<x)-1)];continue J}else if(x&32){k.mode=u9;break W}else{Q.msg="invalid literal/length code",k.mode=J8;break W}break}}while(V<G&&X<q);f=$>>3,V-=f,$-=f<<3,z&=(1<<$)-1,Q.next_in=V,Q.next_out=X,Q.avail_in=V<G?5+(G-V):5-(V-G),Q.avail_out=X<q?257+(q-X):257-(X-q),k.hold=z,k.bits=$;return},V1=15,F5=852,K5=592,z5=0,m8=1,Z5=2,c9=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]),_9=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]),l9=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]),i9=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]),r9=(W,Q,J,V,G,X,Y,q)=>{const U=q.bits;let P=0,F=0,C=0,K=0,z=0,$=0,N=0,v=0,y=0,E=0,p,x,f,d,I,L=null,w;const Z=new Uint16Array(V1+1),k=new Uint16Array(V1+1);let M=null,H,j,O;for(P=0;P<=V1;P++)Z[P]=0;for(F=0;F<V;F++)Z[Q[J+F]]++;z=U;for(K=V1;K>=1;K--)if(Z[K]!==0)break;if(z>K)z=K;if(K===0)return G[X++]=1<<24|64<<16|0,G[X++]=1<<24|64<<16|0,q.bits=1,0;for(C=1;C<K;C++)if(Z[C]!==0)break;if(z<C)z=C;v=1;for(P=1;P<=V1;P++)if(v<<=1,v-=Z[P],v<0)return-1;if(v>0&&(W===z5||K!==1))return-1;k[1]=0;for(P=1;P<V1;P++)k[P+1]=k[P]+Z[P];for(F=0;F<V;F++)if(Q[J+F]!==0)Y[k[Q[J+F]]++]=F;if(W===z5)L=M=Y,w=20;else if(W===m8)L=c9,M=_9,w=257;else L=l9,M=i9,w=0;if(E=0,F=0,P=C,I=X,$=z,N=0,f=-1,y=1<<z,d=y-1,W===m8&&y>F5||W===Z5&&y>K5)return 1;for(;;){if(H=P-N,Y[F]+1<w)j=0,O=Y[F];else if(Y[F]>=w)j=M[Y[F]-w],O=L[Y[F]-w];else j=96,O=0;p=1<<P-N,x=1<<$,C=x;do x-=p,G[I+(E>>N)+x]=H<<24|j<<16|O|0;while(x!==0);p=1<<P-1;while(E&p)p>>=1;if(p!==0)E&=p-1,E+=p;else E=0;if(F++,--Z[P]===0){if(P===K)break;P=Q[J+Y[F]]}if(P>z&&(E&d)!==f){if(N===0)N=z;I+=C,$=P-N,v=1<<$;while($+N<K){if(v-=Z[$+N],v<=0)break;$++,v<<=1}if(y+=1<<$,W===m8&&y>F5||W===Z5&&y>K5)return 1;f=E&d,G[f]=z<<24|$<<16|I-X|0}}if(E!==0)G[I+E]=P-N<<24|64<<16|0;return q.bits=z,0},N1=r9,o9=0,U7=1,F7=2,{Z_FINISH:k5,Z_BLOCK:n9,Z_TREES:Q8,Z_OK:c0,Z_STREAM_END:a9,Z_NEED_DICT:s9,Z_STREAM_ERROR:K0,Z_DATA_ERROR:K7,Z_MEM_ERROR:z7,Z_BUF_ERROR:e9,Z_DEFLATED:H5}=_0,K8=16180,C5=16181,$5=16182,j5=16183,B5=16184,M5=16185,R5=16186,L5=16187,O5=16188,I5=16189,P8=16190,R0=16191,u8=16192,D5=16193,d8=16194,x5=16195,w5=16196,N5=16197,g5=16198,V8=16199,G8=16200,v5=16201,S5=16202,T5=16203,A5=16204,y5=16205,c8=16206,E5=16207,p5=16208,i=16209,Z7=16210,k7=16211,t9=852,WQ=592,JQ=15,QQ=JQ,f5=(W)=>{return(W>>>24&255)+(W>>>8&65280)+((W&65280)<<8)+((W&255)<<24)},l0=(W)=>{if(!W)return 1;const Q=W.state;if(!Q||Q.strm!==W||Q.mode<K8||Q.mode>k7)return 1;return 0},H7=(W)=>{if(l0(W))return K0;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=K8,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(t9),Q.distcode=Q.distdyn=new Int32Array(WQ),Q.sane=1,Q.back=-1,c0},C7=(W)=>{if(l0(W))return K0;const Q=W.state;return Q.wsize=0,Q.whave=0,Q.wnext=0,H7(W)},$7=(W,Q)=>{let J;if(l0(W))return K0;const V=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 K0;if(V.window!==null&&V.wbits!==Q)V.window=null;return V.wrap=J,V.wbits=Q,C7(W)},j7=(W,Q)=>{if(!W)return K0;const J=new VQ;W.state=J,J.strm=W,J.window=null,J.mode=K8;const V=$7(W,Q);if(V!==c0)W.state=null;return V},GQ=(W)=>{return j7(W,QQ)},h5=!0,_8,l8,XQ=(W)=>{if(h5){_8=new Int32Array(512),l8=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;N1(U7,W.lens,0,288,_8,0,W.work,{bits:9}),Q=0;while(Q<32)W.lens[Q++]=5;N1(F7,W.lens,0,32,l8,0,W.work,{bits:5}),h5=!1}W.lencode=_8,W.lenbits=9,W.distcode=l8,W.distbits=5},B7=(W,Q,J,V)=>{let G;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(V>=X.wsize)X.window.set(Q.subarray(J-X.wsize,J),0),X.wnext=0,X.whave=X.wsize;else{if(G=X.wsize-X.wnext,G>V)G=V;if(X.window.set(Q.subarray(J-V,J-V+G),X.wnext),V-=G,V)X.window.set(Q.subarray(J-V,J),0),X.wnext=V,X.whave=X.wsize;else{if(X.wnext+=G,X.wnext===X.wsize)X.wnext=0;if(X.whave<X.wsize)X.whave+=G}}return 0},YQ=(W,Q)=>{let J,V,G,X,Y,q,U,P,F,C,K,z,$,N,v=0,y,E,p,x,f,d,I,L;const w=new Uint8Array(4);let Z,k;const M=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(l0(W)||!W.output||!W.input&&W.avail_in!==0)return K0;if(J=W.state,J.mode===R0)J.mode=u8;Y=W.next_out,G=W.output,U=W.avail_out,X=W.next_in,V=W.input,q=W.avail_in,P=J.hold,F=J.bits,C=q,K=U,L=c0;W:for(;;)switch(J.mode){case K8:if(J.wrap===0){J.mode=u8;break}while(F<16){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(J.wrap&2&&P===35615){if(J.wbits===0)J.wbits=15;J.check=0,w[0]=P&255,w[1]=P>>>8&255,J.check=o(J.check,w,2,0),P=0,F=0,J.mode=C5;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)!==H5){W.msg="unknown compression method",J.mode=i;break}if(P>>>=4,F-=4,I=(P&15)+8,J.wbits===0)J.wbits=I;if(I>15||I>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?I5:R0,P=0,F=0;break;case C5:while(F<16){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(J.flags=P,(J.flags&255)!==H5){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)w[0]=P&255,w[1]=P>>>8&255,J.check=o(J.check,w,2,0);P=0,F=0,J.mode=$5;case $5:while(F<32){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(J.head)J.head.time=P;if(J.flags&512&&J.wrap&4)w[0]=P&255,w[1]=P>>>8&255,w[2]=P>>>16&255,w[3]=P>>>24&255,J.check=o(J.check,w,4,0);P=0,F=0,J.mode=j5;case j5:while(F<16){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(J.head)J.head.xflags=P&255,J.head.os=P>>8;if(J.flags&512&&J.wrap&4)w[0]=P&255,w[1]=P>>>8&255,J.check=o(J.check,w,2,0);P=0,F=0,J.mode=B5;case B5:if(J.flags&1024){while(F<16){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(J.length=P,J.head)J.head.extra_len=P;if(J.flags&512&&J.wrap&4)w[0]=P&255,w[1]=P>>>8&255,J.check=o(J.check,w,2,0);P=0,F=0}else if(J.head)J.head.extra=null;J.mode=M5;case M5:if(J.flags&1024){if(z=J.length,z>q)z=q;if(z){if(J.head){if(I=J.head.extra_len-J.length,!J.head.extra)J.head.extra=new Uint8Array(J.head.extra_len);J.head.extra.set(V.subarray(X,X+z),I)}if(J.flags&512&&J.wrap&4)J.check=o(J.check,V,z,X);q-=z,X+=z,J.length-=z}if(J.length)break W}J.length=0,J.mode=R5;case R5:if(J.flags&2048){if(q===0)break W;z=0;do if(I=V[X+z++],J.head&&I&&J.length<65536)J.head.name+=String.fromCharCode(I);while(I&&z<q);if(J.flags&512&&J.wrap&4)J.check=o(J.check,V,z,X);if(q-=z,X+=z,I)break W}else if(J.head)J.head.name=null;J.length=0,J.mode=L5;case L5:if(J.flags&4096){if(q===0)break W;z=0;do if(I=V[X+z++],J.head&&I&&J.length<65536)J.head.comment+=String.fromCharCode(I);while(I&&z<q);if(J.flags&512&&J.wrap&4)J.check=o(J.check,V,z,X);if(q-=z,X+=z,I)break W}else if(J.head)J.head.comment=null;J.mode=O5;case O5:if(J.flags&512){while(F<16){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(J.wrap&4&&P!==(J.check&65535)){W.msg="header crc mismatch",J.mode=i;break}P=0,F=0}if(J.head)J.head.hcrc=J.flags>>9&1,J.head.done=!0;W.adler=J.check=0,J.mode=R0;break;case I5:while(F<32){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}W.adler=J.check=f5(P),P=0,F=0,J.mode=P8;case P8:if(J.havedict===0)return W.next_out=Y,W.avail_out=U,W.next_in=X,W.avail_in=q,J.hold=P,J.bits=F,s9;W.adler=J.check=1,J.mode=R0;case R0:if(Q===n9||Q===Q8)break W;case u8:if(J.last){P>>>=F&7,F-=F&7,J.mode=c8;break}while(F<3){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}switch(J.last=P&1,P>>>=1,F-=1,P&3){case 0:J.mode=D5;break;case 1:if(XQ(J),J.mode=V8,Q===Q8){P>>>=2,F-=2;break W}break;case 2:J.mode=w5;break;case 3:W.msg="invalid block type",J.mode=i}P>>>=2,F-=2;break;case D5:P>>>=F&7,F-=F&7;while(F<32){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if((P&65535)!==(P>>>16^65535)){W.msg="invalid stored block lengths",J.mode=i;break}if(J.length=P&65535,P=0,F=0,J.mode=d8,Q===Q8)break W;case d8:J.mode=x5;case x5:if(z=J.length,z){if(z>q)z=q;if(z>U)z=U;if(z===0)break W;G.set(V.subarray(X,X+z),Y),q-=z,X+=z,U-=z,Y+=z,J.length-=z;break}J.mode=R0;break;case w5:while(F<14){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(J.nlen=(P&31)+257,P>>>=5,F-=5,J.ndist=(P&31)+1,P>>>=5,F-=5,J.ncode=(P&15)+4,P>>>=4,F-=4,J.nlen>286||J.ndist>30){W.msg="too many length or distance symbols",J.mode=i;break}J.have=0,J.mode=N5;case N5:while(J.have<J.ncode){while(F<3){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}J.lens[M[J.have++]]=P&7,P>>>=3,F-=3}while(J.have<19)J.lens[M[J.have++]]=0;if(J.lencode=J.lendyn,J.lenbits=7,Z={bits:J.lenbits},L=N1(o9,J.lens,0,19,J.lencode,0,J.work,Z),J.lenbits=Z.bits,L){W.msg="invalid code lengths set",J.mode=i;break}J.have=0,J.mode=g5;case g5:while(J.have<J.nlen+J.ndist){for(;;){if(v=J.lencode[P&(1<<J.lenbits)-1],y=v>>>24,E=v>>>16&255,p=v&65535,y<=F)break;if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(p<16)P>>>=y,F-=y,J.lens[J.have++]=p;else{if(p===16){k=y+2;while(F<k){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(P>>>=y,F-=y,J.have===0){W.msg="invalid bit length repeat",J.mode=i;break}I=J.lens[J.have-1],z=3+(P&3),P>>>=2,F-=2}else if(p===17){k=y+3;while(F<k){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}P>>>=y,F-=y,I=0,z=3+(P&7),P>>>=3,F-=3}else{k=y+7;while(F<k){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}P>>>=y,F-=y,I=0,z=11+(P&127),P>>>=7,F-=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++]=I}}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,Z={bits:J.lenbits},L=N1(U7,J.lens,0,J.nlen,J.lencode,0,J.work,Z),J.lenbits=Z.bits,L){W.msg="invalid literal/lengths set",J.mode=i;break}if(J.distbits=6,J.distcode=J.distdyn,Z={bits:J.distbits},L=N1(F7,J.lens,J.nlen,J.ndist,J.distcode,0,J.work,Z),J.distbits=Z.bits,L){W.msg="invalid distances set",J.mode=i;break}if(J.mode=V8,Q===Q8)break W;case V8:J.mode=G8;case G8:if(q>=6&&U>=258){if(W.next_out=Y,W.avail_out=U,W.next_in=X,W.avail_in=q,J.hold=P,J.bits=F,d9(W,K),Y=W.next_out,G=W.output,U=W.avail_out,X=W.next_in,V=W.input,q=W.avail_in,P=J.hold,F=J.bits,J.mode===R0)J.back=-1;break}J.back=0;for(;;){if(v=J.lencode[P&(1<<J.lenbits)-1],y=v>>>24,E=v>>>16&255,p=v&65535,y<=F)break;if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(E&&(E&240)===0){x=y,f=E,d=p;for(;;){if(v=J.lencode[d+((P&(1<<x+f)-1)>>x)],y=v>>>24,E=v>>>16&255,p=v&65535,x+y<=F)break;if(q===0)break W;q--,P+=V[X++]<<F,F+=8}P>>>=x,F-=x,J.back+=x}if(P>>>=y,F-=y,J.back+=y,J.length=p,E===0){J.mode=y5;break}if(E&32){J.back=-1,J.mode=R0;break}if(E&64){W.msg="invalid literal/length code",J.mode=i;break}J.extra=E&15,J.mode=v5;case v5:if(J.extra){k=J.extra;while(F<k){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}J.length+=P&(1<<J.extra)-1,P>>>=J.extra,F-=J.extra,J.back+=J.extra}J.was=J.length,J.mode=S5;case S5:for(;;){if(v=J.distcode[P&(1<<J.distbits)-1],y=v>>>24,E=v>>>16&255,p=v&65535,y<=F)break;if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if((E&240)===0){x=y,f=E,d=p;for(;;){if(v=J.distcode[d+((P&(1<<x+f)-1)>>x)],y=v>>>24,E=v>>>16&255,p=v&65535,x+y<=F)break;if(q===0)break W;q--,P+=V[X++]<<F,F+=8}P>>>=x,F-=x,J.back+=x}if(P>>>=y,F-=y,J.back+=y,E&64){W.msg="invalid distance code",J.mode=i;break}J.offset=p,J.extra=E&15,J.mode=T5;case T5:if(J.extra){k=J.extra;while(F<k){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}J.offset+=P&(1<<J.extra)-1,P>>>=J.extra,F-=J.extra,J.back+=J.extra}if(J.offset>J.dmax){W.msg="invalid distance too far back",J.mode=i;break}J.mode=A5;case A5:if(U===0)break W;if(z=K-U,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;N=J.window}else N=G,$=Y-J.offset,z=J.length;if(z>U)z=U;U-=z,J.length-=z;do G[Y++]=N[$++];while(--z);if(J.length===0)J.mode=G8;break;case y5:if(U===0)break W;G[Y++]=J.length,U--,J.mode=G8;break;case c8:if(J.wrap){while(F<32){if(q===0)break W;q--,P|=V[X++]<<F,F+=8}if(K-=U,W.total_out+=K,J.total+=K,J.wrap&4&&K)W.adler=J.check=J.flags?o(J.check,G,K,Y-K):A1(J.check,G,K,Y-K);if(K=U,J.wrap&4&&(J.flags?P:f5(P))!==J.check){W.msg="incorrect data check",J.mode=i;break}P=0,F=0}J.mode=E5;case E5:if(J.wrap&&J.flags){while(F<32){if(q===0)break W;q--,P+=V[X++]<<F,F+=8}if(J.wrap&4&&P!==(J.total&4294967295)){W.msg="incorrect length check",J.mode=i;break}P=0,F=0}J.mode=p5;case p5:L=a9;break W;case i:L=K7;break W;case Z7:return z7;case k7:default:return K0}if(W.next_out=Y,W.avail_out=U,W.next_in=X,W.avail_in=q,J.hold=P,J.bits=F,J.wsize||K!==W.avail_out&&J.mode<i&&(J.mode<c8||Q!==k5)){if(B7(W,W.output,W.next_out,K-W.avail_out));}if(C-=W.avail_in,K-=W.avail_out,W.total_in+=C,W.total_out+=K,J.total+=K,J.wrap&4&&K)W.adler=J.check=J.flags?o(J.check,G,K,W.next_out-K):A1(J.check,G,K,W.next_out-K);if(W.data_type=J.bits+(J.last?64:0)+(J.mode===R0?128:0)+(J.mode===V8||J.mode===d8?256:0),(C===0&&K===0||Q===k5)&&L===c0)L=e9;return L},qQ=(W)=>{if(l0(W))return K0;let Q=W.state;if(Q.window)Q.window=null;return W.state=null,c0},PQ=(W,Q)=>{if(l0(W))return K0;const J=W.state;if((J.wrap&2)===0)return K0;return J.head=Q,Q.done=!1,c0},UQ=(W,Q)=>{const J=Q.length;let V,G,X;if(l0(W))return K0;if(V=W.state,V.wrap!==0&&V.mode!==P8)return K0;if(V.mode===P8){if(G=1,G=A1(G,Q,J,0),G!==V.check)return K7}if(X=B7(W,Q,J,J),X)return V.mode=Z7,z7;return V.havedict=1,c0},FQ=C7,KQ=$7,zQ=H7,ZQ=GQ,kQ=j7,HQ=YQ,CQ=qQ,$Q=PQ,jQ=UQ,BQ="pako inflate (from Nodeca project)",O0={inflateReset:FQ,inflateReset2:KQ,inflateResetKeep:zQ,inflateInit:ZQ,inflateInit2:kQ,inflate:HQ,inflateEnd:CQ,inflateGetHeader:$Q,inflateSetDictionary:jQ,inflateInfo:BQ},RQ=MQ,M7=Object.prototype.toString,{Z_NO_FLUSH:LQ,Z_FINISH:OQ,Z_OK:p1,Z_STREAM_END:i8,Z_NEED_DICT:r8,Z_STREAM_ERROR:IQ,Z_DATA_ERROR:b5,Z_MEM_ERROR:DQ}=_0;m1.prototype.push=function(W,Q){const J=this.strm,V=this.options.chunkSize,G=this.options.dictionary;let X,Y,q;if(this.ended)return!1;if(Q===~~Q)Y=Q;else Y=Q===!0?OQ:LQ;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(V),J.next_out=0,J.avail_out=V;if(X=O0.inflate(J,Y),X===r8&&G){if(X=O0.inflateSetDictionary(J,G),X===p1)X=O0.inflate(J,Y);else if(X===b5)X=r8}while(J.avail_in>0&&X===i8&&J.state.wrap>0&&W[J.next_in]!==0)O0.inflateReset(J),X=O0.inflate(J,Y);switch(X){case IQ:case b5:case r8:case DQ:return this.onEnd(X),this.ended=!0,!1}if(q=J.avail_out,J.next_out){if(J.avail_out===0||X===i8)if(this.options.to==="string"){let U=E1.utf8border(J.output,J.next_out),P=J.next_out-U,F=E1.buf2string(J.output,U);if(J.next_out=P,J.avail_out=V-P,P)J.output.set(J.output.subarray(U,U+P),0);this.onData(F)}else this.onData(J.output.length===J.next_out?J.output:J.output.subarray(0,J.next_out))}if(X===p1&&q===0)continue;if(X===i8)return X=O0.inflateEnd(this.strm),this.onEnd(X),this.ended=!0,!0;if(J.avail_in===0)break}return!0};m1.prototype.onData=function(W){this.chunks.push(W)};m1.prototype.onEnd=function(W){if(W===p1)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=F8.flattenChunks(this.chunks);this.chunks=[],this.err=W,this.msg=this.strm.msg};var wQ=m1,NQ=U6,gQ=xQ,vQ=U6,SQ=_0,TQ={Inflate:wQ,inflate:NQ,inflateRaw:gQ,ungzip:vQ,constants:SQ},{Deflate:AQ,deflate:yQ,deflateRaw:EQ,gzip:pQ}=m9,{Inflate:fQ,inflate:hQ,inflateRaw:bQ,ungzip:mQ}=TQ,uQ=AQ,dQ=yQ,cQ=EQ,_Q=pQ,lQ=fQ,iQ=hQ,rQ=bQ,oQ=mQ,nQ=_0,i0={Deflate:uQ,deflate:dQ,deflateRaw:cQ,gzip:_Q,Inflate:lQ,inflate:iQ,inflateRaw:rQ,ungzip:oQ,constants:nQ};var w8=function(W){return W instanceof Uint8Array||ArrayBuffer.isView(W)&&W.constructor.name==="Uint8Array"},B6=function(W){if(!Number.isSafeInteger(W)||W<0)throw Error("positive integer expected, got "+W)},e0=function(W,...Q){if(!w8(W))throw Error("Uint8Array expected");if(Q.length>0&&!Q.includes(W.length))throw Error("Uint8Array expected of length "+Q+", got length="+W.length)},c7=function(W){if(typeof W!="function"||typeof W.create!="function")throw Error("Hash should be wrapped by utils.createHasher");B6(W.outputLen),B6(W.blockLen)},j8=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")},B8=function(...W){for(let Q=0;Q<W.length;Q++)W[Q].fill(0)},F6=function(W){return new DataView(W.buffer,W.byteOffset,W.byteLength)},j0=function(W,Q){return W<<32-Q|W>>>Q},H1=function(W){if(e0(W),_7)return W.toHex();let Q="";for(let J=0;J<W.length;J++)Q+=aQ[W[J]];return Q},I7=function(W){return W>=R7&&W<=sQ?W-R7:W>=L7&&W<=eQ?W-(L7-10):W>=O7&&W<=tQ?W-(O7-10):void 0},M8=function(W){if(typeof W!="string")throw Error("hex string expected, got "+typeof W);if(_7)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 V=new Uint8Array(J);for(let G=0,X=0;G<J;G++,X+=2){const Y=I7(W.charCodeAt(X)),q=I7(W.charCodeAt(X+1));if(Y===void 0||q===void 0){const U=W[X]+W[X+1];throw Error('hex string expected, got non-hex character "'+U+'" at index '+X)}V[G]=16*Y+q}return V},l7=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=l7(W)),e0(W),W},B0=function(...W){let Q=0;for(let V=0;V<W.length;V++){const G=W[V];e0(G),Q+=G.length}const J=new Uint8Array(Q);for(let V=0,G=0;V<W.length;V++){const X=W[V];J.set(X,G),G+=X.length}return J},WV=function(W){const Q=(V)=>W().update(N6(V)).digest(),J=W();return Q.outputLen=J.outputLen,Q.blockLen=J.blockLen,Q.create=()=>W(),Q},R8=function(W=32){if(F1&&typeof F1.getRandomValues=="function")return F1.getRandomValues(new Uint8Array(W));if(F1&&typeof F1.randomBytes=="function")return Uint8Array.from(F1.randomBytes(W));throw Error("crypto.getRandomValues must be defined")},JV=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},r0=function(W,Q,J=""){const V=w8(W),G=W?.length,X=Q!==void 0;if(!V||X&&G!==Q)throw Error((J&&`"${J}" `)+"expected Uint8Array"+(X?" of length "+Q:"")+", got "+(V?"length="+G:"type="+typeof W));return W},z8=function(W){const Q=W.toString(16);return 1&Q.length?"0"+Q:Q},n7=function(W){if(typeof W!="string")throw Error("hex string expected, got "+typeof W);return W===""?S6:BigInt("0x"+W)},j1=function(W){return n7(H1(W))},a7=function(W){return e0(W),n7(H1(Uint8Array.from(W).reverse()))},N8=function(W,Q){return M8(W.toString(16).padStart(2*Q,"0"))},s7=function(W,Q){return N8(W,Q).reverse()},r=function(W,Q,J){let V;if(typeof Q=="string")try{V=M8(Q)}catch(X){throw Error(W+" must be hex string or Uint8Array, cause: "+X)}else{if(!w8(Q))throw Error(W+" must be hex string or Uint8Array");V=Uint8Array.from(Q)}const G=V.length;if(typeof J=="number"&&G!==J)throw Error(W+" of length "+J+" expected, got "+G);return V},L6=function(W,Q,J){return K6(W)&&K6(Q)&&K6(J)&&Q<=W&&W<J},e7=function(W){let Q;for(Q=0;W>S6;W>>=R6,Q+=1);return Q},T6=function(W,Q,J={}){if(!W||typeof W!="object")throw Error("expected valid options object");function V(G,X,Y){const q=W[G];if(Y&&q===void 0)return;const U=typeof q;if(U!==X||q===null)throw Error(`param "${G}" is invalid: expected ${X}, got ${U}`)}Object.entries(Q).forEach(([G,X])=>V(G,X,!1)),Object.entries(J).forEach(([G,X])=>V(G,X,!0))},D7=function(W){const Q=new WeakMap;return(J,...V)=>{const G=Q.get(J);if(G!==void 0)return G;const X=W(J,...V);return Q.set(J,X),X}},Z0=function(W,Q){const J=W%Q;return J>=G0?J:Q+J},z0=function(W,Q,J){let V=W;for(;Q-- >G0;)V*=V,V%=J;return V},w7=function(W,Q){if(W===G0)throw Error("invert: expected non-zero number");if(Q<=G0)throw Error("invert: expected positive modulus, got "+Q);let J=Z0(W,Q),V=Q,G=G0,X=W0;for(;J!==G0;){const Y=V%J,q=G-X*(V/J);V=J,J=Y,G=X,X=q}if(V!==W0)throw Error("invert: does not exist");return Z0(G,Q)},A6=function(W,Q,J){if(!W.eql(W.sqr(Q),J))throw Error("Cannot find square root")},VW=function(W,Q){const J=(W.ORDER+W0)/WW,V=W.pow(Q,J);return A6(W,V,Q),V},XV=function(W,Q){const J=(W.ORDER-JW)/QW,V=W.mul(Q,n0),G=W.pow(V,J),X=W.mul(Q,G),Y=W.mul(W.mul(X,n0),G),q=W.mul(X,W.sub(Y,W.ONE));return A6(W,q,Q),q},N7=function(W){if(W<t7)throw Error("sqrt is not defined for small field");let Q=W-W0,J=0;for(;Q%n0===G0;)Q/=n0,J++;let V=n0;const G=i1(W);for(;g7(G,V)===1;)if(V++>1000)throw Error("Cannot find square root: probably non-prime P");if(J===1)return VW;let X=G.pow(V,Q);const Y=(Q+W0)/n0;return function(q,U){if(q.is0(U))return U;if(g7(q,U)!==1)throw Error("Cannot find square root");let P=J,F=q.mul(q.ONE,X),C=q.pow(U,Q),K=q.pow(U,Y);for(;!q.eql(C,q.ONE);){if(q.is0(C))return q.ZERO;let z=1,$=q.sqr(C);for(;!q.eql($,q.ONE);)if(z++,$=q.sqr($),z===P)throw Error("Cannot find square root");const N=W0<<BigInt(P-z-1),v=q.pow(F,N);P=z,F=q.sqr(v),C=q.mul(C,F),K=q.mul(K,v)}return K}},YV=function(W){return W%WW===t7?VW:W%QW===JW?XV:W%x7===GV?function(Q){const J=i1(Q),V=N7(Q),G=V(J,J.neg(J.ONE)),X=V(J,G),Y=V(J,J.neg(G)),q=(Q+VV)/x7;return(U,P)=>{let F=U.pow(P,q),C=U.mul(F,G);const K=U.mul(F,X),z=U.mul(F,Y),$=U.eql(U.sqr(C),P),N=U.eql(U.sqr(K),P);F=U.cmov(F,C,$),C=U.cmov(z,K,N);const v=U.eql(U.sqr(C),P),y=U.cmov(F,C,v);return A6(U,y,P),y}}(W):N7(W)},GW=function(W,Q,J=!1){const V=Array(Q.length).fill(J?W.ZERO:void 0),G=Q.reduce((Y,q,U)=>W.is0(q)?Y:(V[U]=Y,W.mul(Y,q)),W.ONE),X=W.inv(G);return Q.reduceRight((Y,q,U)=>W.is0(q)?Y:(V[U]=W.mul(Y,V[U]),W.mul(Y,q)),X),V},g7=function(W,Q){const J=(W.ORDER-W0)/n0,V=W.pow(Q,J),G=W.eql(V,W.ONE),X=W.eql(V,W.ZERO),Y=W.eql(V,W.neg(W.ONE));if(!G&&!X&&!Y)throw Error("invalid Legendre symbol result");return G?1:X?0:-1},XW=function(W,Q){Q!==void 0&&B6(Q);const J=Q!==void 0?Q:W.toString(2).length;return{nBitLength:J,nByteLength:Math.ceil(J/8)}},i1=function(W,Q,J=!1,V={}){if(W<=G0)throw Error("invalid field: expected ORDER > 0, got "+W);let G,X,Y,q=!1;if(typeof Q=="object"&&Q!=null){if(V.sqrt||J)throw Error("cannot specify opts in two arguments");const K=Q;K.BITS&&(G=K.BITS),K.sqrt&&(X=K.sqrt),typeof K.isLE=="boolean"&&(J=K.isLE),typeof K.modFromBytes=="boolean"&&(q=K.modFromBytes),Y=K.allowedLengths}else typeof Q=="number"&&(G=Q),V.sqrt&&(X=V.sqrt);const{nBitLength:U,nByteLength:P}=XW(W,G);if(P>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");let F;const C=Object.freeze({ORDER:W,isLE:J,BITS:U,BYTES:P,MASK:l1(U),ZERO:G0,ONE:W0,allowedLengths:Y,create(K){return Z0(K,W)},isValid(K){if(typeof K!="bigint")throw Error("invalid field element: expected bigint, got "+typeof K);return G0<=K&&K<W},is0(K){return K===G0},isValidNot0(K){return!C.is0(K)&&C.isValid(K)},isOdd(K){return(K&W0)===W0},neg(K){return Z0(-K,W)},eql(K,z){return K===z},sqr(K){return Z0(K*K,W)},add(K,z){return Z0(K+z,W)},sub(K,z){return Z0(K-z,W)},mul(K,z){return Z0(K*z,W)},pow(K,z){return function($,N,v){if(v<G0)throw Error("invalid exponent, negatives unsupported");if(v===G0)return $.ONE;if(v===W0)return N;let y=$.ONE,E=N;for(;v>G0;)v&W0&&(y=$.mul(y,E)),E=$.sqr(E),v>>=W0;return y}(C,K,z)},div(K,z){return Z0(K*w7(z,W),W)},sqrN(K){return K*K},addN(K,z){return K+z},subN(K,z){return K-z},mulN(K,z){return K*z},inv(K){return w7(K,W)},sqrt:X||((K)=>(F||(F=YV(W)),F(C,K))),toBytes(K){return J?s7(K,P):N8(K,P)},fromBytes(K,z=!0){if(Y){if(!Y.includes(K.length)||K.length>P)throw Error("Field.fromBytes: expected "+Y+" bytes, got "+K.length);const N=new Uint8Array(P);N.set(K,J?0:N.length-K.length),K=N}if(K.length!==P)throw Error("Field.fromBytes: expected "+P+" bytes, got "+K.length);let $=J?a7(K):j1(K);if(q&&($=Z0($,W)),!z&&!C.isValid($))throw Error("invalid field element: outside of range 0..ORDER");return $},invertBatch(K){return GW(C,K)},cmov(K,z,$){return $?z:K}});return Object.freeze(C)},YW=function(W){if(typeof W!="bigint")throw Error("field order must be bigint");const Q=W.toString(2).length;return Math.ceil(Q/8)},qW=function(W){const Q=YW(W);return Q+Math.ceil(Q/2)},PW=function(W,Q,J=!1){const V=W.length,G=YW(Q),X=qW(Q);if(V<16||V<X||V>1024)throw Error("expected "+X+"-1024 bytes of input, got "+V);const Y=Z0(J?a7(W):j1(W),Q-W0)+W0;return J?s7(Y,G):N8(Y,G)},O8=function(W,Q){const J=Q.negate();return W?J:Q},z6=function(W,Q){const J=GW(W.Fp,Q.map((V)=>V.Z));return Q.map((V,G)=>W.fromAffine(V.toAffine(J[G])))},UW=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){UW(W,Q);const J=2**W;return{windows:Math.ceil(Q/W)+1,windowSize:2**(W-1),mask:l1(W),maxNumber:J,shiftBy:BigInt(W)}},v7=function(W,Q,J){const{windowSize:V,mask:G,maxNumber:X,shiftBy:Y}=J;let q=Number(W&G),U=W>>Y;q>V&&(q-=X,U+=a0);const P=Q*V;return{nextN:U,offset:P+Math.abs(q)-1,isZero:q===0,isNeg:q<0,isNegF:Q%2!=0,offsetF:P}},H6=function(W){return FW.get(W)||1},S7=function(W){if(W!==C1)throw Error("invalid wNAF")},PV=function(W,Q,J,V){(function(K,z){if(!Array.isArray(K))throw Error("array expected");K.forEach(($,N)=>{if(!($ instanceof z))throw Error("invalid point at index "+N)})})(J,W),function(K,z){if(!Array.isArray(K))throw Error("array of scalars expected");K.forEach(($,N)=>{if(!z.isValid($))throw Error("invalid scalar at index "+N)})}(V,Q);const G=J.length,X=V.length;if(G!==X)throw Error("arrays of points and scalars must have equal length");const Y=W.ZERO,q=e7(BigInt(G));let U=1;q>12?U=q-3:q>4?U=q-2:q>0&&(U=2);const P=l1(U),F=Array(Number(P)+1).fill(Y);let C=Y;for(let K=Math.floor((Q.BITS-1)/U)*U;K>=0;K-=U){F.fill(Y);for(let $=0;$<X;$++){const N=V[$],v=Number(N>>BigInt(K)&P);F[v]=F[v].add(J[$])}let z=Y;for(let $=F.length-1,N=Y;$>0;$--)N=N.add(F[$]),z=z.add(N);if(C=C.add(z),K!==0)for(let $=0;$<U;$++)C=C.double()}return C},T7=function(W,Q,J){if(Q){if(Q.ORDER!==W)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return function(V){T6(V,qV.reduce((G,X)=>(G[X]="function",G),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"}))}(Q),Q}return i1(W,{isLE:J})},O6=function(W){if(!["compact","recovered","der"].includes(W))throw Error('Signature format must be "compact", "recovered", or "der"');return W},C6=function(W,Q){const J={};for(let V of Object.keys(Q))J[V]=W[V]===void 0?Q[V]:W[V];return L8(J.lowS,"lowS"),L8(J.prehash,"prehash"),J.format!==void 0&&O6(J.format),J},o0=function(W,Q){const{BYTES:J}=W;let V;if(typeof Q=="bigint")V=Q;else{let G=r("private key",Q);try{V=W.fromBytes(G)}catch(X){throw Error(`invalid private key: expected ui8a of size ${J}, got ${typeof Q}`)}}if(!W.isValidNot0(V))throw Error("invalid private key: out of range [1..N-1]");return V},FV=function(W,Q={}){const J=function(Z,k,M={},H){if(H===void 0&&(H=Z==="edwards"),!k||typeof k!="object")throw Error(`expected valid ${Z} CURVE object`);for(let D of["p","n","h"]){const B=k[D];if(!(typeof B=="bigint"&&B>C1))throw Error(`CURVE.${D} must be positive bigint`)}const j=T7(k.p,M.Fp,H),O=T7(k.n,M.Fn,H),R=["Gx","Gy","a","b"];for(let D of R)if(!j.isValid(k[D]))throw Error(`CURVE.${D} must be valid field element of CURVE.Fp`);return{CURVE:k=Object.freeze(Object.assign({},k)),Fp:j,Fn:O}}("weierstrass",W,Q),{Fp:V,Fn:G}=J;let X=J.CURVE;const{h:Y,n:q}=X;T6(Q,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:U}=Q;if(U&&(!V.is0(X.a)||typeof U.beta!="bigint"||!Array.isArray(U.basises)))throw Error('invalid endo: expected "beta": bigint and "basises": array');const P=kW(V,G);function F(){if(!V.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}const C=Q.toBytes||function(Z,k,M){const{x:H,y:j}=k.toAffine(),O=V.toBytes(H);if(L8(M,"isCompressed"),M)return F(),B0(ZW(!V.isOdd(j)),O);return B0(Uint8Array.of(4),O,V.toBytes(j))},K=Q.fromBytes||function(Z){r0(Z,void 0,"Point");const{publicKey:k,publicKeyUncompressed:M}=P,H=Z.length,j=Z[0],O=Z.subarray(1);if(H!==k||j!==2&&j!==3){if(H===M&&j===4){const R=V.BYTES,D=V.fromBytes(O.subarray(0,R)),B=V.fromBytes(O.subarray(R,2*R));if(!$(D,B))throw Error("bad point: is not on curve");return{x:D,y:B}}throw Error(`bad point: got length ${H}, expected compressed=${k} or uncompressed=${M}`)}{const R=V.fromBytes(O);if(!V.isValid(R))throw Error("bad point: is not on curve, wrong x");const D=z(R);let B;try{B=V.sqrt(D)}catch(g){const T=g instanceof Error?": "+g.message:"";throw Error("bad point: is not on curve, sqrt error"+T)}return F(),!(1&~j)!==V.isOdd(B)&&(B=V.neg(B)),{x:R,y:B}}};function z(Z){const k=V.sqr(Z),M=V.mul(k,Z);return V.add(V.add(M,V.mul(Z,X.a)),X.b)}function $(Z,k){const M=V.sqr(k),H=z(Z);return V.eql(M,H)}if(!$(X.Gx,X.Gy))throw Error("bad curve params: generator point");const N=V.mul(V.pow(X.a,Z8),UV),v=V.mul(V.sqr(X.b),BigInt(27));if(V.is0(V.add(N,v)))throw Error("bad curve params: a or b");function y(Z,k,M=!1){if(!V.isValid(k)||M&&V.is0(k))throw Error("bad point coordinate "+Z);return k}function E(Z){if(!(Z instanceof I))throw Error("ProjectivePoint expected")}function p(Z){if(!U||!U.basises)throw Error("no endo");return function(k,M,H){const[[j,O],[R,D]]=M,B=A7(D*k,H),g=A7(-O*k,H);let T=k-B*j-g*R,S=-B*O-g*D;const A=T<x0,h=S<x0;A&&(T=-T),h&&(S=-S);const b=l1(Math.ceil(e7(H)/2))+Z1;if(T<x0||T>=b||S<x0||S>=b)throw Error("splitScalar (endomorphism): failed, k="+k);return{k1neg:A,k1:T,k2neg:h,k2:S}}(Z,U.basises,G.ORDER)}const x=D7((Z,k)=>{const{X:M,Y:H,Z:j}=Z;if(V.eql(j,V.ONE))return{x:M,y:H};const O=Z.is0();k==null&&(k=O?V.ONE:V.inv(j));const R=V.mul(M,k),D=V.mul(H,k),B=V.mul(j,k);if(O)return{x:V.ZERO,y:V.ZERO};if(!V.eql(B,V.ONE))throw Error("invZ was invalid");return{x:R,y:D}}),f=D7((Z)=>{if(Z.is0()){if(Q.allowInfinityPoint&&!V.is0(Z.Y))return;throw Error("bad point: ZERO")}const{x:k,y:M}=Z.toAffine();if(!V.isValid(k)||!V.isValid(M))throw Error("bad point: x or y not field elements");if(!$(k,M))throw Error("bad point: equation left != right");if(!Z.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function d(Z,k,M,H,j){return M=new I(V.mul(M.X,Z),M.Y,M.Z),k=O8(H,k),M=O8(j,M),k.add(M)}class I{constructor(Z,k,M){this.X=y("x",Z),this.Y=y("y",k,!0),this.Z=y("z",M),Object.freeze(this)}static CURVE(){return X}static fromAffine(Z){const{x:k,y:M}=Z||{};if(!Z||!V.isValid(k)||!V.isValid(M))throw Error("invalid affine point");if(Z instanceof I)throw Error("projective point not allowed");return V.is0(k)&&V.is0(M)?I.ZERO:new I(k,M,V.ONE)}static fromBytes(Z){const k=I.fromAffine(K(r0(Z,void 0,"point")));return k.assertValidity(),k}static fromHex(Z){return I.fromBytes(r("pointHex",Z))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(Z=8,k=!0){return w.createCache(this,Z),k||this.multiply(Z8),this}assertValidity(){f(this)}hasEvenY(){const{y:Z}=this.toAffine();if(!V.isOdd)throw Error("Field doesn't support isOdd");return!V.isOdd(Z)}equals(Z){E(Z);const{X:k,Y:M,Z:H}=this,{X:j,Y:O,Z:R}=Z,D=V.eql(V.mul(k,R),V.mul(j,H)),B=V.eql(V.mul(M,R),V.mul(O,H));return D&&B}negate(){return new I(this.X,V.neg(this.Y),this.Z)}double(){const{a:Z,b:k}=X,M=V.mul(k,Z8),{X:H,Y:j,Z:O}=this;let{ZERO:R,ZERO:D,ZERO:B}=V,g=V.mul(H,H),T=V.mul(j,j),S=V.mul(O,O),A=V.mul(H,j);return A=V.add(A,A),B=V.mul(H,O),B=V.add(B,B),R=V.mul(Z,B),D=V.mul(M,S),D=V.add(R,D),R=V.sub(T,D),D=V.add(T,D),D=V.mul(R,D),R=V.mul(A,R),B=V.mul(M,B),S=V.mul(Z,S),A=V.sub(g,S),A=V.mul(Z,A),A=V.add(A,B),B=V.add(g,g),g=V.add(B,g),g=V.add(g,S),g=V.mul(g,A),D=V.add(D,g),S=V.mul(j,O),S=V.add(S,S),g=V.mul(S,A),R=V.sub(R,g),B=V.mul(S,T),B=V.add(B,B),B=V.add(B,B),new I(R,D,B)}add(Z){E(Z);const{X:k,Y:M,Z:H}=this,{X:j,Y:O,Z:R}=Z;let{ZERO:D,ZERO:B,ZERO:g}=V;const T=X.a,S=V.mul(X.b,Z8);let A=V.mul(k,j),h=V.mul(M,O),b=V.mul(H,R),m=V.add(k,M),_=V.add(j,O);m=V.mul(m,_),_=V.add(A,h),m=V.sub(m,_),_=V.add(k,H);let l=V.add(j,R);return _=V.mul(_,l),l=V.add(A,b),_=V.sub(_,l),l=V.add(M,H),D=V.add(O,R),l=V.mul(l,D),D=V.add(h,b),l=V.sub(l,D),g=V.mul(T,_),D=V.mul(S,b),g=V.add(D,g),D=V.sub(h,g),g=V.add(h,g),B=V.mul(D,g),h=V.add(A,A),h=V.add(h,A),b=V.mul(T,b),_=V.mul(S,_),h=V.add(h,b),b=V.sub(A,b),b=V.mul(T,b),_=V.add(_,b),A=V.mul(h,_),B=V.add(B,A),A=V.mul(l,_),D=V.mul(m,D),D=V.sub(D,A),A=V.mul(m,h),g=V.mul(l,g),g=V.add(g,A),new I(D,B,g)}subtract(Z){return this.add(Z.negate())}is0(){return this.equals(I.ZERO)}multiply(Z){const{endo:k}=Q;if(!G.isValidNot0(Z))throw Error("invalid scalar: out of range");let M,H;const j=(O)=>w.cached(this,O,(R)=>z6(I,R));if(k){const{k1neg:O,k1:R,k2neg:D,k2:B}=p(Z),{p:g,f:T}=j(R),{p:S,f:A}=j(B);H=T.add(A),M=d(k.beta,g,S,O,D)}else{const{p:O,f:R}=j(Z);M=O,H=R}return z6(I,[M,H])[0]}multiplyUnsafe(Z){const{endo:k}=Q,M=this;if(!G.isValid(Z))throw Error("invalid scalar: out of range");if(Z===x0||M.is0())return I.ZERO;if(Z===Z1)return M;if(w.hasCache(this))return this.multiply(Z);if(k){const{k1neg:H,k1:j,k2neg:O,k2:R}=p(Z),{p1:D,p2:B}=function(g,T,S,A){let h=T,b=g.ZERO,m=g.ZERO;for(;S>C1||A>C1;)S&a0&&(b=b.add(h)),A&a0&&(m=m.add(h)),h=h.double(),S>>=a0,A>>=a0;return{p1:b,p2:m}}(I,M,j,R);return d(k.beta,D,B,H,O)}return w.unsafe(M,Z)}multiplyAndAddUnsafe(Z,k,M){const H=this.multiplyUnsafe(k).add(Z.multiplyUnsafe(M));return H.is0()?void 0:H}toAffine(Z){return x(this,Z)}isTorsionFree(){const{isTorsionFree:Z}=Q;return Y===Z1||(Z?Z(I,this):w.unsafe(this,q).is0())}clearCofactor(){const{clearCofactor:Z}=Q;return Y===Z1?this:Z?Z(I,this):this.multiplyUnsafe(Y)}isSmallOrder(){return this.multiplyUnsafe(Y).is0()}toBytes(Z=!0){return L8(Z,"isCompressed"),this.assertValidity(),C(I,this,Z)}toHex(Z=!0){return H1(this.toBytes(Z))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(Z=!0){return this.toBytes(Z)}_setWindowSize(Z){this.precompute(Z)}static normalizeZ(Z){return z6(I,Z)}static msm(Z,k){return PV(I,G,Z,k)}static fromPrivateKey(Z){return I.BASE.multiply(o0(G,Z))}}I.BASE=new I(X.Gx,X.Gy,V.ONE),I.ZERO=new I(V.ZERO,V.ONE,V.ZERO),I.Fp=V,I.Fn=G;const L=G.BITS,w=new KW(I,Q.endo?Math.ceil(L/2):L);return I.BASE.precompute(8),I},ZW=function(W){return Uint8Array.of(W?2:3)},kW=function(W,Q){return{secretKey:Q.BYTES,publicKey:1+W.BYTES,publicKeyUncompressed:1+2*W.BYTES,publicKeyHasPrefix:!0,signature:2*Q.BYTES}},KV=function(W,Q,J={}){c7(Q),T6(J,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const V=J.randomBytes||R8,G=J.hmac||((L,...w)=>o7(Q,L,B0(...w))),{Fp:X,Fn:Y}=W,{ORDER:q,BITS:U}=Y,{keygen:P,getPublicKey:F,getSharedSecret:C,utils:K,lengths:z}=function(L,w={}){const{Fn:Z}=L,k=w.randomBytes||R8,M=Object.assign(kW(L.Fp,Z),{seed:qW(Z.ORDER)});function H(B){try{return!!o0(Z,B)}catch(g){return!1}}function j(B=k(M.seed)){return PW(r0(B,M.seed,"seed"),Z.ORDER)}function O(B,g=!0){return L.BASE.multiply(o0(Z,B)).toBytes(g)}function R(B){if(typeof B=="bigint")return!1;if(B instanceof L)return!0;const{secretKey:g,publicKey:T,publicKeyUncompressed:S}=M;if(Z.allowedLengths||g===T)return;const A=r("key",B).length;return A===T||A===S}return Object.freeze({getPublicKey:O,getSharedSecret(B,g,T=!0){if(R(B)===!0)throw Error("first arg must be private key");if(R(g)===!1)throw Error("second arg must be public key");const S=o0(Z,B);return L.fromHex(g).multiply(S).toBytes(T)},keygen(B){const g=j(B);return{secretKey:g,publicKey:O(g)}},Point:L,utils:{isValidSecretKey:H,isValidPublicKey(B,g){const{publicKey:T,publicKeyUncompressed:S}=M;try{const A=B.length;return!(g===!0&&A!==T||g===!1&&A!==S||!L.fromBytes(B))}catch(A){return!1}},randomSecretKey:j,isValidPrivateKey:H,randomPrivateKey:j,normPrivateKeyToScalar:(B)=>o0(Z,B),precompute(B=8,g=L.BASE){return g.precompute(B,!1)}},lengths:M})}(W,J),$={prehash:!1,lowS:typeof J.lowS=="boolean"&&J.lowS,format:void 0,extraEntropy:!1},N="compact";function v(L){return L>q>>Z1}function y(L,w){if(!Y.isValidNot0(w))throw Error(`invalid signature ${L}: out of range 1..Point.Fn.ORDER`);return w}class E{constructor(L,w,Z){this.r=y("r",L),this.s=y("s",w),Z!=null&&(this.recovery=Z),Object.freeze(this)}static fromBytes(L,w=N){let Z;if(function(j,O){O6(O);const R=z.signature;r0(j,O==="compact"?R:O==="recovered"?R+1:void 0,O+" signature")}(L,w),w==="der"){const{r:j,s:O}=D0.toSig(r0(L));return new E(j,O)}w==="recovered"&&(Z=L[0],w="compact",L=L.subarray(1));const k=Y.BYTES,M=L.subarray(0,k),H=L.subarray(k,2*k);return new E(Y.fromBytes(M),Y.fromBytes(H),Z)}static fromHex(L,w){return this.fromBytes(M8(L),w)}addRecoveryBit(L){return new E(this.r,this.s,L)}recoverPublicKey(L){const w=X.ORDER,{r:Z,s:k,recovery:M}=this;if(M==null||![0,1,2,3].includes(M))throw Error("recovery id invalid");if(q*zW<w&&M>1)throw Error("recovery id is ambiguous for h>1 curve");const H=M===2||M===3?Z+q:Z;if(!X.isValid(H))throw Error("recovery id 2 or 3 invalid");const j=X.toBytes(H),O=W.fromBytes(B0(ZW(!(1&M)),j)),R=Y.inv(H),D=x(r("msgHash",L)),B=Y.create(-D*R),g=Y.create(k*R),T=W.BASE.multiplyUnsafe(B).add(O.multiplyUnsafe(g));if(T.is0())throw Error("point at infinify");return T.assertValidity(),T}hasHighS(){return v(this.s)}toBytes(L=N){if(O6(L),L==="der")return M8(D0.hexFromSig(this));const w=Y.toBytes(this.r),Z=Y.toBytes(this.s);if(L==="recovered"){if(this.recovery==null)throw Error("recovery bit must be present");return B0(Uint8Array.of(this.recovery),w,Z)}return B0(w,Z)}toHex(L){return H1(this.toBytes(L))}assertValidity(){}static fromCompact(L){return E.fromBytes(r("sig",L),"compact")}static fromDER(L){return E.fromBytes(r("sig",L),"der")}normalizeS(){return this.hasHighS()?new E(this.r,Y.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return H1(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return H1(this.toBytes("compact"))}}const p=J.bits2int||function(L){if(L.length>8192)throw Error("input is too large");const w=j1(L),Z=8*L.length-U;return Z>0?w>>BigInt(Z):w},x=J.bits2int_modN||function(L){return Y.create(p(L))},f=l1(U);function d(L){return function(w,Z,k,M){if(!L6(Z,k,M))throw Error("expected valid "+w+": "+k+" <= n < "+M+", got "+Z)}("num < 2^"+U,L,x0,f),Y.toBytes(L)}function I(L,w){return r0(L,void 0,"message"),w?r0(Q(L),void 0,"prehashed message"):L}return Object.freeze({keygen:P,getPublicKey:F,getSharedSecret:C,utils:K,lengths:z,Point:W,sign(L,w,Z={}){L=r("message",L);const{seed:k,k2sig:M}=function(H,j,O){if(["recovered","canonical"].some((b)=>(b in O)))throw Error("sign() legacy options not supported");const{lowS:R,prehash:D,extraEntropy:B}=C6(O,$);H=I(H,D);const g=x(H),T=o0(Y,j),S=[d(T),d(g)];if(B!=null&&B!==!1){const b=B===!0?V(z.secretKey):B;S.push(r("extraEntropy",b))}const A=B0(...S),h=g;return{seed:A,k2sig(b){const m=p(b);if(!Y.isValidNot0(m))return;const _=Y.inv(m),l=W.BASE.multiply(m).toAffine(),M0=Y.create(l.x);if(M0===x0)return;const J0=Y.create(_*Y.create(h+M0*T));if(J0===x0)return;let P0=(l.x===M0?0:2)|Number(l.y&Z1),U0=J0;return R&&v(J0)&&(U0=Y.neg(J0),P0^=1),new E(M0,U0,P0)}}}(L,w,Z);return function(H,j,O){if(typeof H!="number"||H<2)throw Error("hashLen must be a number");if(typeof j!="number"||j<2)throw Error("qByteLen must be a number");if(typeof O!="function")throw Error("hmacFn must be a function");const R=(m)=>new Uint8Array(m),D=(m)=>Uint8Array.of(m);let B=R(H),g=R(H),T=0;const S=()=>{B.fill(1),g.fill(0),T=0},A=(...m)=>O(g,B,...m),h=(m=R(0))=>{g=A(D(0),m),B=A(),m.length!==0&&(g=A(D(1),m),B=A())},b=()=>{if(T++>=1000)throw Error("drbg: tried 1000 values");let m=0;const _=[];for(;m<j;){B=A();const l=B.slice();_.push(l),m+=B.length}return B0(..._)};return(m,_)=>{let l;for(S(),h(m);!(l=_(b()));)h();return S(),l}}(Q.outputLen,Y.BYTES,G)(k,M)},verify(L,w,Z,k={}){const{lowS:M,prehash:H,format:j}=C6(k,$);if(Z=r("publicKey",Z),w=I(r("message",w),H),("strict"in k))throw Error("options.strict was renamed to lowS");const O=j===void 0?function(R){let D;const B=typeof R=="string"||w8(R),g=!B&&R!==null&&typeof R=="object"&&typeof R.r=="bigint"&&typeof R.s=="bigint";if(!B&&!g)throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(g)D=new E(R.r,R.s);else if(B){try{D=E.fromBytes(r("sig",R),"der")}catch(T){if(!(T instanceof D0.Err))throw T}if(!D)try{D=E.fromBytes(r("sig",R),"compact")}catch(T){return!1}}return D||!1}(L):E.fromBytes(r("sig",L),j);if(O===!1)return!1;try{const R=W.fromBytes(Z);if(M&&O.hasHighS())return!1;const{r:D,s:B}=O,g=x(w),T=Y.inv(B),S=Y.create(g*T),A=Y.create(D*T),h=W.BASE.multiplyUnsafe(S).add(R.multiplyUnsafe(A));if(h.is0())return!1;return Y.create(h.x)===D}catch(R){return!1}},recoverPublicKey(L,w,Z={}){const{prehash:k}=C6(Z,$);return w=I(w,k),E.fromBytes(L,"recovered").recoverPublicKey(w).toBytes()},Signature:E,hash:Q})},zV=function(W){const{CURVE:Q,curveOpts:J}=function(G){const X={a:G.a,b:G.b,p:G.Fp.ORDER,n:G.n,h:G.h,Gx:G.Gx,Gy:G.Gy},Y=G.Fp;let q=G.allowedPrivateKeyLengths?Array.from(new Set(G.allowedPrivateKeyLengths.map((U)=>Math.ceil(U/2)))):void 0;return{CURVE:X,curveOpts:{Fp:Y,Fn:i1(X.n,{BITS:G.nBitLength,allowedLengths:q,modFromBytes:G.wrapPrivateKey}),allowInfinityPoint:G.allowInfinityPoint,endo:G.endo,isTorsionFree:G.isTorsionFree,clearCofactor:G.clearCofactor,fromBytes:G.fromBytes,toBytes:G.toBytes}}}(W),V={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:V}},ZV=function(W){const{CURVE:Q,curveOpts:J,hash:V,ecdsaOpts:G}=zV(W);return function(X,Y){const q=Y.Point;return Object.assign({},Y,{ProjectivePoint:q,CURVE:Object.assign({},X,XW(q.Fn.ORDER,q.Fn.BITS))})}(W,KV(FV(Q,J),V,G))},D8=function(W,...Q){let J=E7[W];if(J===void 0){const V=M6(l7(W));J=B0(V,V),E7[W]=J}return M6(B0(J,...Q))},D6=function(W){const{Fn:Q,BASE:J}=B1,V=o0(Q,W),G=J.multiply(V);return{scalar:E6(G.y)?V:Q.neg(V),bytes:y6(G)}},CW=function(W){const Q=I8;if(!Q.isValidNot0(W))throw Error("invalid x: Fail if x \u2265 p");const J=Q.create(W*W),V=Q.create(J*W+BigInt(7));let G=Q.sqrt(V);E6(G)||(G=Q.neg(G));const X=B1.fromAffine({x:W,y:G});return X.assertValidity(),X},$W=function(...W){return B1.Fn.create(_1(D8("BIP0340/challenge",...W)))},p7=function(W){return D6(W).bytes},CV=function(W,Q,J=R8(32)){const{Fn:V}=B1,G=r("message",W),{bytes:X,scalar:Y}=D6(Q),q=r("auxRand",J,32),U=V.toBytes(Y^_1(D8("BIP0340/aux",q))),P=D8("BIP0340/nonce",U,X,G),{bytes:F,scalar:C}=D6(P),K=$W(F,X,G),z=new Uint8Array(64);if(z.set(F,0),z.set(V.toBytes(V.create(C+K*Y)),32),!jW(z,G,X))throw Error("sign: Invalid signature produced");return z},jW=function(W,Q,J){const{Fn:V,BASE:G}=B1,X=r("signature",W,64),Y=r("message",Q),q=r("publicKey",J,32);try{const U=CW(_1(q)),P=_1(X.subarray(0,32));if(!L6(P,y7,$1.p))return!1;const F=_1(X.subarray(32,64));if(!L6(F,y7,$1.n))return!1;const C=$W(V.toBytes(P),y6(U),Y),K=G.multiplyUnsafe(F).add(U.multiplyUnsafe(V.neg(C))),{x:z,y:$}=K.toAffine();return!(K.is0()||!E6($)||z!==P)}catch(U){return!1}},F1=typeof globalThis=="object"&&("crypto"in globalThis)?globalThis.crypto:void 0,_7=(()=>typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function")(),aQ=Array.from({length:256},(W,Q)=>Q.toString(16).padStart(2,"0")),R7=48,sQ=57,L7=65,eQ=70,O7=97,tQ=102;class g6{}class i7 extends g6{constructor(W,Q,J,V){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=W,this.outputLen=Q,this.padOffset=J,this.isLE=V,this.buffer=new Uint8Array(W),this.view=F6(this.buffer)}update(W){j8(this),e0(W=N6(W));const{view:Q,buffer:J,blockLen:V}=this,G=W.length;for(let X=0;X<G;){const Y=Math.min(V-this.pos,G-X);if(Y!==V)J.set(W.subarray(X,X+Y),this.pos),this.pos+=Y,X+=Y,this.pos===V&&(this.process(Q,0),this.pos=0);else{const q=F6(W);for(;V<=G-X;X+=V)this.process(q,X)}}return this.length+=W.length,this.roundClean(),this}digestInto(W){j8(this),function(F,C){e0(F);const K=C.outputLen;if(F.length<K)throw Error("digestInto() expects output buffer of length at least "+K)}(W,this),this.finished=!0;const{buffer:Q,view:J,blockLen:V,isLE:G}=this;let{pos:X}=this;Q[X++]=128,B8(this.buffer.subarray(X)),this.padOffset>V-X&&(this.process(J,0),X=0);for(let F=X;F<V;F++)Q[F]=0;(function(F,C,K,z){if(typeof F.setBigUint64=="function")return F.setBigUint64(C,K,z);const $=BigInt(32),N=BigInt(4294967295),v=Number(K>>$&N),y=Number(K&N),E=z?4:0,p=z?0:4;F.setUint32(C+E,v,z),F.setUint32(C+p,y,z)})(J,V-8,BigInt(8*this.length),G),this.process(J,0);const Y=F6(W),q=this.outputLen;if(q%4)throw Error("_sha2: outputLen should be aligned to 32bit");const U=q/4,P=this.get();if(U>P.length)throw Error("_sha2: outputLen bigger than state");for(let F=0;F<U;F++)Y.setUint32(4*F,P[F],G)}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:V,finished:G,destroyed:X,pos:Y}=this;return W.destroyed=X,W.finished=G,W.length=V,W.pos=Y,V%Q&&W.buffer.set(J),W}clone(){return this._cloneInto()}}var E0=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),QV=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]),p0=new Uint32Array(64);class r7 extends i7{constructor(W=32){super(64,W,8,!1),this.A=0|E0[0],this.B=0|E0[1],this.C=0|E0[2],this.D=0|E0[3],this.E=0|E0[4],this.F=0|E0[5],this.G=0|E0[6],this.H=0|E0[7]}get(){const{A:W,B:Q,C:J,D:V,E:G,F:X,G:Y,H:q}=this;return[W,Q,J,V,G,X,Y,q]}set(W,Q,J,V,G,X,Y,q){this.A=0|W,this.B=0|Q,this.C=0|J,this.D=0|V,this.E=0|G,this.F=0|X,this.G=0|Y,this.H=0|q}process(W,Q){for(let C=0;C<16;C++,Q+=4)p0[C]=W.getUint32(Q,!1);for(let C=16;C<64;C++){const K=p0[C-15],z=p0[C-2],$=j0(K,7)^j0(K,18)^K>>>3,N=j0(z,17)^j0(z,19)^z>>>10;p0[C]=N+p0[C-7]+$+p0[C-16]|0}let{A:J,B:V,C:G,D:X,E:Y,F:q,G:U,H:P}=this;for(let C=0;C<64;C++){const K=P+(j0(Y,6)^j0(Y,11)^j0(Y,25))+((F=Y)&q^~F&U)+QV[C]+p0[C]|0,z=(j0(J,2)^j0(J,13)^j0(J,22))+JV(J,V,G)|0;P=U,U=q,q=Y,Y=X+K|0,X=G,G=V,V=J,J=K+z|0}var F;J=J+this.A|0,V=V+this.B|0,G=G+this.C|0,X=X+this.D|0,Y=Y+this.E|0,q=q+this.F|0,U=U+this.G|0,P=P+this.H|0,this.set(J,V,G,X,Y,q,U,P)}roundClean(){B8(p0)}destroy(){this.set(0,0,0,0,0,0,0,0),B8(this.buffer)}}var M6=WV(()=>new r7);class v6 extends g6{constructor(W,Q){super(),this.finished=!1,this.destroyed=!1,c7(W);const J=N6(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 V=this.blockLen,G=new Uint8Array(V);G.set(J.length>V?W.create().update(J).digest():J);for(let X=0;X<G.length;X++)G[X]^=54;this.iHash.update(G),this.oHash=W.create();for(let X=0;X<G.length;X++)G[X]^=106;this.oHash.update(G),B8(G)}update(W){return j8(this),this.iHash.update(W),this}digestInto(W){j8(this),e0(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:V,destroyed:G,blockLen:X,outputLen:Y}=this;return W.finished=V,W.destroyed=G,W.blockLen=X,W.outputLen=Y,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 o7=(W,Q,J)=>new v6(W,Q).update(J).digest();o7.create=(W,Q)=>new v6(W,Q);var S6=BigInt(0),R6=BigInt(1),K6=(W)=>typeof W=="bigint"&&S6<=W,l1=(W)=>(R6<<BigInt(W))-R6,G0=BigInt(0),W0=BigInt(1),n0=BigInt(2),t7=BigInt(3),WW=BigInt(4),JW=BigInt(5),VV=BigInt(7),QW=BigInt(8),GV=BigInt(9),x7=BigInt(16),qV=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"],C1=BigInt(0),a0=BigInt(1),k6=new WeakMap,FW=new WeakMap;class KW{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 V=W;for(;Q>C1;)Q&a0&&(J=J.add(V)),V=V.double(),Q>>=a0;return J}precomputeWindow(W,Q){const{windows:J,windowSize:V}=Z6(Q,this.bits),G=[];let X=W,Y=X;for(let q=0;q<J;q++){Y=X,G.push(Y);for(let U=1;U<V;U++)Y=Y.add(X),G.push(Y);X=Y.double()}return G}wNAF(W,Q,J){if(!this.Fn.isValid(J))throw Error("invalid scalar");let V=this.ZERO,G=this.BASE;const X=Z6(W,this.bits);for(let Y=0;Y<X.windows;Y++){const{nextN:q,offset:U,isZero:P,isNeg:F,isNegF:C,offsetF:K}=v7(J,Y,X);J=q,P?G=G.add(O8(C,Q[K])):V=V.add(O8(F,Q[U]))}return S7(J),{p:V,f:G}}wNAFUnsafe(W,Q,J,V=this.ZERO){const G=Z6(W,this.bits);for(let X=0;X<G.windows&&J!==C1;X++){const{nextN:Y,offset:q,isZero:U,isNeg:P}=v7(J,X,G);if(J=Y,!U){const F=Q[q];V=V.add(P?F.negate():F)}}return S7(J),V}getPrecomputes(W,Q,J){let V=k6.get(Q);return V||(V=this.precomputeWindow(Q,W),W!==1&&(typeof J=="function"&&(V=J(V)),k6.set(Q,V))),V}cached(W,Q,J){const V=H6(W);return this.wNAF(V,this.getPrecomputes(V,W,J),Q)}unsafe(W,Q,J,V){const G=H6(W);return G===1?this._unsafeLadder(W,Q,V):this.wNAFUnsafe(G,this.getPrecomputes(G,W,J),Q,V)}createCache(W,Q){UW(Q,this.bits),FW.set(W,Q),k6.delete(W)}hasCache(W){return H6(W)!==1}}var A7=(W,Q)=>(W+(W>=0?Q:-Q)/zW)/Q,D0={Err:class extends Error{constructor(W=""){super(W)}},_tlv:{encode(W,Q){const{Err:J}=D0;if(W<0||W>256)throw new J("tlv.encode: wrong tag");if(1&Q.length)throw new J("tlv.encode: unpadded data");const V=Q.length/2,G=z8(V);if(G.length/2&128)throw new J("tlv.encode: long form length too big");const X=V>127?z8(G.length/2|128):"";return z8(W)+X+G+Q},decode(W,Q){const{Err:J}=D0;let V=0;if(W<0||W>256)throw new J("tlv.encode: wrong tag");if(Q.length<2||Q[V++]!==W)throw new J("tlv.decode: wrong tlv");const G=Q[V++];let X=0;if(128&G){const q=127&G;if(!q)throw new J("tlv.decode(long): indefinite length not supported");if(q>4)throw new J("tlv.decode(long): byte length is too big");const U=Q.subarray(V,V+q);if(U.length!==q)throw new J("tlv.decode: length bytes not complete");if(U[0]===0)throw new J("tlv.decode(long): zero leftmost byte");for(let P of U)X=X<<8|P;if(V+=q,X<128)throw new J("tlv.decode(long): not minimal encoding")}else X=G;const Y=Q.subarray(V,V+X);if(Y.length!==X)throw new J("tlv.decode: wrong value length");return{v:Y,l:Q.subarray(V+X)}}},_int:{encode(W){const{Err:Q}=D0;if(W<x0)throw new Q("integer: negative integers are not allowed");let J=z8(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}=D0;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 j1(W)}},toSig(W){const{Err:Q,_int:J,_tlv:V}=D0,G=r("signature",W),{v:X,l:Y}=V.decode(48,G);if(Y.length)throw new Q("invalid signature: left bytes after parsing");const{v:q,l:U}=V.decode(2,X),{v:P,l:F}=V.decode(2,U);if(F.length)throw new Q("invalid signature: left bytes after parsing");return{r:J.decode(q),s:J.decode(P)}},hexFromSig(W){const{_tlv:Q,_int:J}=D0,V=Q.encode(2,J.encode(W.r))+Q.encode(2,J.encode(W.s));return Q.encode(48,V)}},x0=BigInt(0),Z1=BigInt(1),zW=BigInt(2),Z8=BigInt(3),UV=BigInt(4),$1={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},kV={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},HV=BigInt(0),y7=BigInt(1),I6=BigInt(2),I8=i1($1.p,{sqrt(W){const Q=$1.p,J=BigInt(3),V=BigInt(6),G=BigInt(11),X=BigInt(22),Y=BigInt(23),q=BigInt(44),U=BigInt(88),P=W*W*W%Q,F=P*P*W%Q,C=z0(F,J,Q)*F%Q,K=z0(C,J,Q)*F%Q,z=z0(K,I6,Q)*P%Q,$=z0(z,G,Q)*z%Q,N=z0($,X,Q)*$%Q,v=z0(N,q,Q)*N%Q,y=z0(v,U,Q)*v%Q,E=z0(y,q,Q)*N%Q,p=z0(E,J,Q)*F%Q,x=z0(p,Y,Q)*$%Q,f=z0(x,V,Q)*P%Q,d=z0(f,I6,Q);if(!I8.eql(I8.sqr(d),W))throw Error("Cannot find square root");return d}}),HW=function(W,Q){const J=(V)=>ZV({...W,hash:V});return{...J(Q),create:J}}({...$1,Fp:I8,lowS:!0,endo:kV},M6),E7={},y6=(W)=>W.toBytes(!0).slice(1),B1=(()=>HW.Point)(),E6=(W)=>W%I6===HV,_1=j1,p6=(()=>{const W=(Q=R8(48))=>PW(Q,$1.n);return HW.utils.randomSecretKey,{keygen(Q){const J=W(Q);return{secretKey:J,publicKey:p7(J)}},getPublicKey:p7,sign:CV,verify:jW,Point:B1,utils:{randomSecretKey:W,randomPrivateKey:W,taggedHash:D8,lift_x:CW,pointToBytes:y6,numberToBytesBE:N8,bytesToNumberBE:j1,mod:Z0},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})(),$V=new TextEncoder,jV=new TextDecoder,s0=(W)=>$V.encode(W),c1=(W)=>jV.decode(W),x6=(W)=>Array.from(W,(Q)=>Q.toString(16).padStart(2,"0")).join(""),w0=JSON.stringify,x8=JSON.parse,BW=(W,Q=Number.MAX_SAFE_INTEGER)=>W.split("").reduce((J,V)=>J+V.charCodeAt(0),0)%Q,f6="AES-GCM",BV={},k8=(W)=>BV[W]??=crypto.subtle.digest("SHA-1",s0(W)).then((Q)=>{const J=new Uint8Array(Q);let V="";for(let G of J)V+=G.toString(36);return V}),MV=async(W,Q)=>{const J=crypto.getRandomValues(new Uint8Array(12)),V=await W,G=await crypto.subtle.encrypt({name:f6,iv:J},V,s0(Q));return`${J.join(",")}\$${((X)=>{const Y=new Uint8Array(X);let q="";for(let U=0;U<Y.length;U+=32768)q+=String.fromCharCode(...Y.subarray(U,U+32768));return btoa(q)})(G)}`},RV=async(W,Q)=>{const[J,V]=Q.split("$");if(!J||!V)throw Error("Invalid encrypted payload format");const G=Uint8Array.from(J.split(","),Number),X=await W,Y=await crypto.subtle.decrypt({name:f6,iv:G},X,(q=V,Uint8Array.from(atob(q),(U)=>U.charCodeAt(0)).buffer));var q;return c1(Y)},q0="GenosRTC",h6=(W,Q)=>Array.from({length:W},Q),LV="0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz",w6=(W)=>Array.from(crypto.getRandomValues(new Uint8Array(W)),(Q)=>LV[Q%62]).join(""),K1=w6(20),k1=Promise.all.bind(Promise),OV=typeof window!="undefined",{entries:IV,fromEntries:MW}=Object,DV=()=>{},I0=(W)=>Error(`${q0}: ${W}`),H8=(...W)=>W.join("@"),f7="icegatheringstatechange",h7="offer",xV=[...h6(3,(W,Q)=>`stun:stun${Q||""}.l.google.com:19302`),"stun:stun.cloudflare.com:3478"].map((W)=>({urls:W})),$6=(W,{rtcConfig:Q,rtcPolyfill:J,turnConfig:V})=>{const G=new(J||RTCPeerConnection)({iceServers:[...xV,...V||[]],...Q}),X={};let Y,q=!1,U=!1;const P=(K)=>Object.assign(K,{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)}}),F=()=>Promise.race([new Promise((K)=>{const z=()=>{G.iceGatheringState==="complete"&&(G.removeEventListener(f7,z),K())};G.addEventListener(f7,z),z()}),new Promise((K)=>setTimeout(K,5000))]).then(()=>({type:G.localDescription.type,sdp:G.localDescription.sdp.replace(/a=ice-options:trickle\s\n/g,"")}));W?P(Y=G.createDataChannel("data")):G.ondatachannel=({channel:K})=>P(Y=K),G.onnegotiationneeded=async()=>{try{q=!0,await G.setLocalDescription(),X.signal?.(await F())}catch(K){X.error?.(K)}finally{q=!1}},G.onconnectionstatechange=()=>{["disconnected","failed","closed"].includes(G.connectionState)&&X.close?.()},G.ontrack=(K)=>{X.track?.(K.track,K.streams[0]),X.stream?.(K.streams[0])},G.onremovestream=(K)=>X.stream?.(K.stream),W&&!G.canTrickleIceCandidates&&G.onnegotiationneeded();const C=()=>G.getSenders();return{created:Date.now(),connection:G,get channel(){return Y},get isDead(){return G.connectionState==="closed"},async signal(K){if(Y?.readyState!=="open"||K.sdp?.includes("a=rtpmap"))try{if(K.type===h7){if(q||G.signalingState!=="stable"&&!U){if(W)return;await k1([G.setLocalDescription({type:"rollback"}),G.setRemoteDescription(K)])}else await G.setRemoteDescription(K);await G.setLocalDescription();const z=await F();return X.signal?.(z),z}if(K.type==="answer"){U=!0;try{await G.setRemoteDescription(K)}finally{U=!1}}}catch(z){X.error?.(z)}},sendData(K){return Y.send(K)},destroy(){Y?.close(),G.close(),q=U=!1},setHandlers(K){return Object.assign(X,K)},offerPromise:W?new Promise((K)=>X.signal=(z)=>z.type===h7&&K(z)):Promise.resolve(),addStream(K){return K.getTracks().forEach((z)=>G.addTrack(z,K))},removeStream(K){return C().filter((z)=>K.getTracks().includes(z.track)).forEach((z)=>G.removeTrack(z))},addTrack(K,z){return G.addTrack(K,z)},removeTrack(K){const z=C().find(($)=>$.track===K);z&&G.removeTrack(z)},replaceTrack(K,z){return C().find(($)=>$.track===K)?.replaceTrack(z)}}},wV=Object.getPrototypeOf(Uint8Array),u1=16369,C8=255,j6="bufferedamountlow",z1=(W)=>"@_"+W,NV=(W,Q,J)=>{const V=new Map,G=new Map,X=new Map,Y={},q={},U={},P={},F=new Map,C=(H,...j)=>F.get(H)?.forEach((O)=>O(...j)),K=(H,j)=>{const O=H?Array.isArray(H)?H:[H]:V.keys();return Array.from(O,(R)=>{const D=V.get(R);return D?j(R,D):(console.warn(`${q0}: no peer with id ${R}`),null)}).filter(Boolean)},z=(H)=>{V.has(H)&&(V.delete(H),delete Y[H],delete q[H],delete U[H],delete P[H],C("peer:leave",H),Q(H))},$=(H)=>new Promise((j,O)=>{let R=setTimeout(()=>{H.removeEventListener(j6,D),O(Error(q0+": bufferLow timeout"))},5000);function D(){clearTimeout(R),H.removeEventListener(j6,D),j()}H.addEventListener(j6,D)}),N=(H)=>{if(X.has(H))return X.get(H);if(!H)throw I0("action type is required");const j=s0(H);if(j.byteLength>12)throw I0(`"${H}" exceeds 12 bytes`);const O=new Uint8Array(12).map((T,S)=>j[S]||0);let R=0;const D=new Map([["message",new Set],["progress",new Set]]),B=async(T,S,A,h)=>{if(A&&typeof A!="object")throw I0("meta must be object");if(T===void 0)throw I0("data cannot be undefined");const b=T instanceof Blob,m=b||T instanceof ArrayBuffer||T instanceof wV,_=typeof T!="string";if(A&&!m)throw I0("meta only allowed with binary");const l=m?new Uint8Array(b?await T.arrayBuffer():T):s0(_?w0(T):T),M0=A?s0(w0(A)):null,J0=Math.ceil(l.byteLength/u1)+(A?1:0)||1;if(J0>100)throw I0("Message too large, exceeds max chunks 100");const P0=h6(J0,(U0,s)=>{const Q0=s===J0-1,a=A&&s===0,r1=a?M0:l.subarray(A?(s-1)*u1:s*u1,A?s*u1:(s+1)*u1),N0=new Uint8Array(15+r1.byteLength);return N0.set(O),N0.set([R],12),N0.set([Q0|a<<1|m<<2|_<<3],13),N0.set([Math.round((s+1)/J0*C8)],14),N0.set(r1,15),N0});return R=R+1&C8,k1(K(S,async(U0,s)=>{const{channel:Q0}=s;for(let a=0;a<J0;a++){let r1=0;for(;Q0.bufferedAmount>Q0.bufferedAmountLowThreshold;){if(r1++>3)throw I0(`${q0}: send buffer full, max retries reached for peer ${U0}`);try{await $(Q0)}catch(N0){console.warn(N0.message),await new Promise((vW)=>setTimeout(vW,200))}}if(!V.has(U0))break;s.sendData(P0[a]),h?.(P0[a][14]/C8,U0,A)}}))};G.set(H,{listeners:D,send:B});const g={send:B,on(T,S){return D.get(T)?.add(S)},off(T,S){return D.get(T)?.delete(S)}};return X.set(H,g),g},v=async()=>{try{await k(""),await new Promise((H)=>setTimeout(H,99))}catch(H){console.warn(q0+": error sending leave",H)}for(let[H,j]of V){try{j.destroy()}catch{}V.delete(H)}J()},{send:y,on:E}=N(z1("ping")),{send:p,on:x}=N(z1("pong")),{send:f,on:d}=N(z1("signal")),{send:I,on:L}=N(z1("stream")),{send:w,on:Z}=N(z1("track")),{send:k,on:M}=N(z1("leave"));return W((H,j)=>{V.has(j)||(V.set(j,H),H.setHandlers({data(O){return((R,D)=>{try{const B=new Uint8Array(D),g=c1(B.subarray(0,12)).replace(/\0/g,"");if(!G.has(g))return console.warn(`${q0}: unregistered type (${g})`);const[T]=B.subarray(12,13),[S]=B.subarray(13,14),[A]=B.subarray(14,15),h=B.subarray(15),b=!!(1&S),m=!!(2&S),_=!!(4&S),l=!!(8&S),M0=G.get(g),J0=(Y[R]||={})[g]||={};if(J0[T]?.chunks?.length>100)return void console.warn(`${q0}: peer ${R} sent too many chunks for nonce ${T}, ignoring.`);const P0=J0[T]||={chunks:[]};if(m)try{P0.meta=x8(c1(h))}catch{return void console.warn(`${q0}: failed to parse meta from peer ${R} for type ${g}`)}else P0.chunks.push(h);if(M0.listeners.get("progress").forEach((Q0)=>{try{Q0(A/C8,R,P0.meta)}catch(a){console.error(a)}}),!b)return;const U0=new Uint8Array(P0.chunks.reduce((Q0,a)=>Q0+a.byteLength,0));let s;if(P0.chunks.reduce((Q0,a)=>(U0.set(a,Q0),Q0+a.byteLength),0),delete J0[T],_)s=U0;else if(l)try{s=x8(c1(U0))}catch{return void console.warn(`${q0}: failed to parse JSON message data from peer ${R} for type ${g}`)}else s=c1(U0);M0.listeners.get("message").forEach((Q0)=>{try{Q0(s,R,P0.meta)}catch(a){console.error(a)}})}catch(B){console.error(`${q0}: error handling data from peer ${R}:`,B)}})(j,O)},stream(O){C("stream:add",O,j,U[j]),delete U[j]},track(O,R){C("track:add",O,R,j,P[j]),delete P[j]},signal(O){return f(O,j)},close(){return z(j)},error(O){console.error(`${q0}: peer error for ${j}`,O),z(j)}}),C("peer:join",j))}),E("message",(H,j)=>p("",j)),x("message",(H,j)=>{q[j]?.(),delete q[j]}),d("message",(H,j)=>V.get(j)?.signal(H)),L("message",(H,j)=>U[j]=H),Z("message",(H,j)=>P[j]=H),M("message",(H,j)=>z(j)),OV&&addEventListener("beforeunload",v),{on(H,j){F.has(H)||F.set(H,new Set),F.get(H).add(j)},off(H,j){return F.get(H)?.delete(j)},channel:N,leave:v,async ping(H){if(!H)throw I0("ping() requires target peer ID");const j=Date.now();return y("",H),await new Promise((O)=>q[H]=O),Date.now()-j},getPeers(){return MW(Array.from(V,([H,j])=>[H,j.connection]))},addStream(H,j,O){return K(j,async(R,D)=>{O&&await I(O,R),D.addStream(H)})},removeStream(H,j){return K(j,(O,R)=>R.removeStream(H))},addTrack(H,j,O,R){return K(O,async(D,B)=>{R&&await w(R,D),B.addTrack(H,j)})},removeTrack(H,j){return K(j,(O,R)=>R.removeTrack(H))},replaceTrack(H,j,O,R){return K(O,async(D,B)=>{R&&await w(R,D),B.replaceTrack(H,j)})}}},$8={},RW={};if(typeof window!="undefined"){const W=()=>{console.info("\u26A1 [GenosRTC] Network event detected. Forcing reconnection\u2026"),Object.values(RW).forEach((Q)=>{Q.socket&&Q.socket.readyState!==WebSocket.OPEN&&Q.socket.readyState!==WebSocket.CONNECTING&&Q.forceReconnect()})};window.addEventListener("online",()=>{console.info("\u2705 Reconnected to the network."),W()}),window.addEventListener("offline",async()=>{console.info("\u274C Disconnected from the network.")}),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&W()})}var gV=(W,Q,J,V)=>(W.relayUrls??(V?((G,X)=>{const Y=[...G];let q=Y.length;const U=()=>{const P=1e4*Math.sin(X++);return P-Math.floor(P)};for(;q;){const P=Math.floor(U()*q--);[Y[q],Y[P]]=[Y[P],Y[q]]}return Y})(Q,BW(W.appId)):Q)).slice(0,W.relayUrls?.length??W.relayRedundancy??J),LW={},OW="EVENT",IW=p6.utils.randomSecretKey(),vV=x6(p6.getPublicKey(IW)),b6={},d1={},SV={},DW=()=>Math.floor(Date.now()/1000),xW=(W)=>SV[W]??=BW(W,1e4)+20000,b7=async(W,Q)=>{const J={kind:xW(W),content:Q,pubkey:vV,created_at:DW(),tags:[["x",W]]},V=new Uint8Array(await crypto.subtle.digest("SHA-256",s0(w0([0,J.pubkey,J.created_at,J.kind,J.tags,J.content])))),G=p6.sign(V,IW);return w0([OW,{...J,id:x6(V),sig:x6(G)}])},m7=(W,Q)=>(b6[W]=Q,w0(["REQ",W,{kinds:[xW(Q)],since:DW(),"#x":[Q]}])),u7=(W)=>(delete b6[W],w0(["CLOSE",W])),m6=(({init:W,subscribe:Q,announce:J})=>{const V={};let G,X,Y=!1;return(q,U,P)=>{const{appId:F}=q;if(V[F]?.[U])return V[F][U];if(!q||!U||!F&&!q.firebaseApp)throw I0(q?U?"appId missing":"roomId required":"config required");let C=DV;if(!Y){const Z=W(q);X=h6(20,()=>$6(!0,q)),G=Array.isArray(Z)?Z:[Z];const k=setInterval(()=>{X=X.filter((M)=>{const H=Date.now()-M.created<57333;return H||M.destroy(),H})},57333);V.offerCleanupTimer||=k,Y=!0}const K={},z={},$=H8(q0,F,U),N=k8($),v=k8(H8($,K1)),y=(async(Z,k,M)=>{const H=await crypto.subtle.digest("SHA-256",s0(`${Z}:${k}:${M}`));return crypto.subtle.importKey("raw",H,{name:f6},!1,["encrypt","decrypt"])})(q.password||"",F,U),E=(Z)=>async(k)=>({type:k.type,sdp:await Z(y,k.sdp)}),p=E(RV),x=E(MV),f=(Z,k)=>{z[k]!==Z&&(z[k]?.destroy(),z[k]=Z,C(Z,k),K[k]?.forEach((M)=>M!==Z&&M.destroy()),delete K[k])},d=(Z,k)=>{z[k]===Z&&delete z[k]},I=k1(G.map(async(Z,k)=>{return Q(await Z,await N,await v,(M=k,async(H,j,O)=>{const[R,D]=await k1([N,v]);if(H!==R&&H!==D)return;const{peerId:B,offer:g,answer:T}=typeof j=="string"?x8(j):j;if(B!==K1&&!z[B])if(g){if(K[B]?.[M]&&K1>B)return;const S=$6(!1,q);S.setHandlers({connect(){return f(S,B)},close(){return d(S,B)}});try{const A=await p(g);if(S.isDead)return;const[h,b]=await k1([k8(H8($,B)),S.signal(A).then(x)]);O(h,w0({peerId:K1,answer:b}))}catch{P?.({error:"decryption failed (offer)",appId:F,peerId:B,roomId:U})}}else if(T){const S=K[B]?.[M];if(!S||S.isDead)return;S.setHandlers({connect(){return f(S,B)},close(){return d(S,B)}});try{S.signal(await p(T))}catch{P?.({error:"decryption failed (answer)",appId:F,peerId:B,roomId:U})}}else{if(K[B]?.[M])return;const S=X.pop()||$6(!0,q),[A,{offer:h}]=await k1([k8(H8($,B)),S.offerPromise.then(x).then((b)=>({offer:b}))]);K[B]||=[],K[B][M]=S,S.setHandlers({connect(){return f(S,B)},close(){return d(S,B)}}),O(A,w0({peerId:K1,offer:h,peer:S}))}}));var M})),L=[];I.then((Z)=>{G.forEach((k,M)=>{const H=async()=>{const j=await J(await k,await N,await v);L[M]=setTimeout(H,typeof j=="number"?j:5333)};H()}),V[F][U].onCleanup=()=>{delete V[F][U],L.forEach(clearTimeout),Z.forEach((k)=>k()),Object.keys(V).length===0&&(clearInterval(V.offerCleanupTimer),delete V.offerCleanupTimer)}}),V[F]||={};const w=NV((Z)=>C=Z,(Z)=>delete z[Z],()=>w.onCleanup?.());return V[F][U]=w}})({init(W){return gV(W,TV,5,!0).map((Q)=>{const J=((V,G)=>{const X={};let Y=null;const q=()=>{Y&&(clearTimeout(Y),Y=null);const U=new WebSocket(V);U.onclose=()=>{$8[V]??=3333,Y=setTimeout(q,$8[V]),$8[V]*=2},U.onmessage=(P)=>G(P.data),X.socket=U,X.url=U.url,X.ready=new Promise((P)=>{U.onopen=()=>{$8[V]=3333,P(X)}}),X.send=(P)=>{U.readyState===1&&U.send(P)}};return X.forceReconnect=q,q(),RW[V]=X,X})(Q,(V)=>{const[G,X,Y,q]=x8(V);if(G===OW)d1[X]?.(b6[X],Y.content);else{const U=`${q0}: relay failure from ${J.url} - `;G==="NOTICE"?console.warn(U+X):G!=="OK"||Y||console.warn(U+q)}});return LW[Q]=J,J.ready})},subscribe(W,Q,J,V){const G=w6(64),X=w6(64);return d1[G]=d1[X]=(Y,q)=>V(Y,q,async(U,P)=>W.send(await b7(U,P))),W.send(m7(G,Q)),W.send(m7(X,J)),()=>{W.send(u7(G)),W.send(u7(X)),delete d1[G],delete d1[X]}},async announce(W,Q){return W.send(await b7(Q,w0({peerId:K1})))}}),$G=(d7=LW,()=>MW(IV(d7).map(([W,Q])=>[W,Q.socket]))),d7,TV=["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);function wW(W,Q,J){let V=Q.timestamp;if(V?.physical>Date.now()+7200000)V={physical:Date.now()+7200000,logical:V.logical};if(!W?.timestamp)return{resolved:!0,value:Q.value,timestamp:V};if(J.compare(V,W.timestamp)<=0)return{resolved:!1};return{resolved:!0,value:Q.value,timestamp:V}}class u6{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 AV=()=>{const W=new Map,Q=async()=>{try{const U=await navigator.storage.getDirectory(),F=await(await U.getFileHandle("~opfs-sync-test",{create:!0})).createSyncAccessHandle?.();return await F?.close(),await U.removeEntry("~opfs-sync-test"),!!F}catch{return!1}};let J="idb";const V=(async()=>{if(await Q())J="sync";else try{const U=await navigator.storage.getDirectory(),F=await(await U.getFileHandle("~opfs-async-test",{create:!0})).createWritable?.();if(await F?.close(),await U.removeEntry("~opfs-async-test"),F)J="async";else J="idb"}catch{J="idb"}})(),G=async(U,P)=>{if(!W.has(U))W.set(U,[]);const F=W.get(U),C=F[F.length-1]||Promise.resolve();let K;const z=new Promise(($)=>K=$);F.push(z);try{return await C,await P()}finally{if(F.shift(),K(),F.length===0)W.delete(U)}},X=(()=>{let U;const P=async()=>{if(!U)U=new Promise((F,C)=>{const K=indexedDB.open("opfs-fallback-db",1);K.onupgradeneeded=()=>K.result.createObjectStore("files"),K.onsuccess=()=>F(K.result),K.onerror=()=>C(K.error)});return U};return{getDB:P,get:async(F)=>{const C=await P();return new Promise((K,z)=>{const N=C.transaction("files","readonly").objectStore("files").get(F);N.onsuccess=()=>K(N.result||new Uint8Array),N.onerror=()=>z(N.error)})},set:async(F,C)=>{const K=await P();return new Promise((z,$)=>{const v=K.transaction("files","readwrite").objectStore("files").put(C,F);v.onsuccess=()=>z(),v.onerror=()=>$(v.error)})}}})(),Y=async(U)=>{await V;try{if(J==="idb"){const z=await X.get(U);return{type:"loaded",name:U,data:z}}const F=await(await navigator.storage.getDirectory()).getFileHandle(U);if(J==="sync"){let z;try{z=await F.createSyncAccessHandle();const $=z.getSize(),N=new Uint8Array($),v=z.read(N,{at:0});return{type:"loaded",name:U,data:N.slice(0,v)}}finally{z?.close()}}const C=await F.getFile(),K=new Uint8Array(await C.arrayBuffer());return{type:"loaded",name:U,data:K}}catch(P){const F=P.name==="NotFoundError"?"File not found":P.message||"Error reading file";return{type:"error",name:U,message:F}}},q=async(U,P)=>{if(await V,!(P instanceof Uint8Array))return{type:"error",name:U,message:"Content must be a Uint8Array"};return G(U,async()=>{try{if(J==="idb")return await X.set(U,P),{type:"saved",name:U};const C=await(await navigator.storage.getDirectory()).getFileHandle(U,{create:!0});if(J==="sync"){let K;try{K=await C.createSyncAccessHandle(),K.truncate(0),K.write(P,{at:0}),K.flush()}finally{K?.close()}}else{let K;try{K=await C.createWritable(),await K.write(P)}finally{await K?.close()}}return{type:"saved",name:U}}catch(F){return{type:"error",name:U,message:F.message||"Error saving file"}}})};self.onmessage=async({data:U})=>{const{type:P,name:F,content:C}=U;await V;const K={load:()=>Y(F),save:()=>q(F,C)};try{const z=K[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:F,message:z.message||"Unexpected worker error"})}}},NW=AV;var t0={$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)&&(Array.isArray(W)?W.some((J)=>Q.includes(J)):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=(G)=>String(G).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^\w\s]/g,""),V=J(Q);return Object.values(W).some((G)=>typeof G==="object"?null.fieldSearch(G,V):J(G).includes(V))},field:(W,Q)=>{const J=(G)=>String(G).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^\w\s]/g,""),V=J(Q);return Array.isArray(W)?W.some((G)=>J(G).includes(V)):J(W).includes(V)}},$like:(W,Q)=>typeof W==="string"&&typeof Q==="string"&&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((V)=>J.createFilter(V,J.allNodes)(W)),$or:(W,Q,J)=>Q.some((V)=>J.createFilter(V,J.allNodes)(W)),$not:(W,Q,J)=>!J.createFilter(Q,J.allNodes)(W),$edge:(W,Q,J)=>{if(!W.edges?.length||typeof Q!=="object"||Q===null)return!1;const V=J.createFilter(Q,J.allNodes),G=[...W.edges],X=new Set(G).add(W.id),Y=[];while(G.length){const q=G.shift(),U=J.allNodes[q];if(!U)continue;if(V(U))Y.push(U);U.edges?.forEach((P)=>!X.has(P)&&X.add(P)&&G.push(P))}if(Y.length)W._edgeResult=Y;return Y.length>0}},d6=(W,Q)=>Q.split(".").reduce((J,V)=>J&&typeof J==="object"&&(V in J)?J[V]:void 0,W),g8=(W,Q)=>{if(Object.keys(W).length===0)return()=>!0;return(J)=>Object.entries(W).every(([V,G])=>{if(V.startsWith("$"))return t0[V](J,G,{createFilter:g8,allNodes:Q});const X=d6(J.value,V);if(typeof G!=="object"||G===null)return t0.$eq(X,G);return Object.entries(G).every(([Y,q])=>{if(Y==="$text")return t0.$text.field(X,q);if(Y==="$between"&&q.every((U)=>U instanceof Date))return t0.$between(new Date(X),q);return t0[Y]?.(X,q,{createFilter:g8,allNodes:Q})??!1})})},c6=(W,Q)=>{const{$edge:J,...V}=Q.query||{},G=g8(V,W),X=Object.values(W).filter(G);let q=[...J?(()=>{const U=g8({$edge:J},W);X.forEach((F)=>U(F));const P=new Map;return X.forEach((F)=>{if(F._edgeResult)F._edgeResult.forEach((C)=>P.set(C.id,C)),delete F._edgeResult}),Array.from(P.values())})():X];if(q=q.map((U)=>({...U,edges:[...U.edges||[]],value:U.value&&typeof U.value==="object"?JSON.parse(JSON.stringify(U.value)):U.value})),Q.field){const U=Q.order==="asc"?1:-1;q.sort((P,F)=>{const C=d6(P.value,Q.field),K=d6(F.value,Q.field);if(typeof C==="string"&&typeof K==="string")return C.localeCompare(K)*U;return((C??0)-(K??0))*U})}if(Q.$after){const U=q.findIndex((P)=>P.id===Q.$after);q=U>=0?q.slice(U+1):[]}if(Q.$before){const U=q.findIndex((P)=>P.id===Q.$before);q=U>=0?q.slice(0,U):[]}if(Q.$limit)q=q.slice(0,Q.$limit);return q};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 l6=function(W,Q){return W.length===Q.length&&W.every((J,V)=>J===Q[V])};async function yV(){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 gW{constructor(){this.nodes={}}upsert(W,Q,J){const V=this.nodes[W];this.nodes[W]={id:W,value:Q&&typeof Q==="object"?JSON.parse(JSON.stringify(Q)):Q,edges:V?.edges?[...V.edges]:[],timestamp:J}}get(W){return this.nodes[W]||null}link(W,Q,J){const V=this.nodes[W],G=this.nodes[Q];if(V&&G&&!V.edges.includes(Q))this.nodes[W]={...V,edges:[...V.edges,Q],timestamp:J}}getAllNodes(){return Object.values(this.nodes)}serialize(){return i0.deflate(g0(this.nodes))}deserialize(W){this.nodes=t1(i0.inflate(new Uint8Array(W)))}}class i6{constructor(W,{password:Q,securityManager:J=null,relayUrls:V=null,turnConfig: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 u6(W,20),this.hybridClock=new _6,this.name=W,this.password=Q,this.globalTimestamp=null,this.graph=new gW,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=t0,this.initWorker(),this.ready=this.loadGraphFromOPFS(),this.loadGlobalTimestamp();const X=`graph-sync-room-${this.name}`,Y={appId:"1234",...this.password&&{password:this.password}};if(V)Y.relayUrls=V;if(G)Y.turnConfig=G;const q=m6(Y,X),U=q.channel("syncGraph");this.syncChannel=U,this.room=m6(Y,`app-sync-${this.name}`),yV(),q.on("peer:join",async(P)=>{console.info("\u26A1 New peer connected:",P),this.syncChannel.send([{type:"sync",timestamp:this.globalTimestamp}])}),q.on("peer:leave",(P)=>{console.info("\u26A1 Peer disconnected:",P)}),this.syncChannel.on("message",async(P)=>{if(console.log(this.securityManager),this.securityManager&&typeof this.securityManager.verifyIncomingOperations==="function"){const{validatedOperations:F}=await this.securityManager.verifyIncomingOperations(P);if(F&&F.length>0)await this.receiveChanges(F)}else await this.receiveChanges(P),this.emit()}),this.channel=new BroadcastChannel(`graphdb_sync_${this.name}`),this.channel.onmessage=async(P)=>{if(P.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([`(${NW.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 i0.deflate(W)}decompress(W){return i0.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((V)=>V.toString(16).padStart(2,"0")).join("")}async loadGraphFromOPFS(){try{const Q=await((J)=>new Promise((V,G)=>{const X=async({data:Y})=>{if(Y.type==="loaded"&&Y.name===J)this.worker.removeEventListener("message",X),V(new Uint8Array(Y.data));else if(Y.type==="error")this.worker.removeEventListener("message",X),G(new Error(Y.message||"Unknown error"))};this.worker.addEventListener("message",X),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,V)=>new Promise((G,X)=>{const Y=({data:q})=>{if(q.type==="saved"&&q.name===J)this.worker.removeEventListener("message",Y),G();else if(q.type==="error")this.worker.removeEventListener("message",Y),X(new Error(q.message||"Save error"))};this.worker.addEventListener("message",Y),this.worker.postMessage({type:"save",name:J,content:V})}))(`${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.syncChannel.send([{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 V=(Y)=>{if(!Y)return null;const q=Y.value!==null&&typeof Y.value==="object"?{...Y.value}:Y.value;return{...Y,value:q}};if(!Q)return{result:V(J)};let G=J.timestamp;Q(V(J));const X=(Y)=>{const q=Y[W];if(q){if(this.hybridClock.compare(q.timestamp,G)>0)G=q.timestamp,Q(V(q))}else Q(null),this.eventListeners.splice(this.eventListeners.indexOf(X),1)};return this.eventListeners.push(X),{result:V(J),unsubscribe:()=>{const Y=this.eventListeners.indexOf(X);if(Y>-1)this.eventListeners.splice(Y,1)}}}async map(...W){await this.ready;let J={...{realtime:!1,query:{},field:null,order:"asc",$limit:null,$after:null,$before:null}},V=null,G=!1;W.forEach((U)=>typeof U==="function"?V=U:U&&typeof U==="object"&&(G||=("realtime"in U),Object.assign(J,U))),V&&!G&&(J.realtime=!0);let X=c6(this.graph.nodes,J),Y=null;const q=(U)=>{const P=U.filter((z)=>!X.some(($)=>$.id===z.id)),F=X.filter((z)=>!U.some(($)=>$.id===z.id)),C=U.filter((z)=>{const $=X.find((y)=>y.id===z.id),N=[...z.edges||[]],v=[...$?.edges||[]];return $&&(!l6(g0(z.value),g0($.value))||!l6(N,v))}),K=(z,$)=>{const N=$==="removed"?null:z.value,v={id:z.id,value:N,edges:z.edges||[],timestamp:z.timestamp||null,action:$};V(v)};P.forEach((z)=>K(z,"added")),F.forEach((z)=>K(z,"removed")),C.forEach((z)=>K(z,"updated"))};if(V){if(X.forEach((U)=>{V({id:U.id,value:U.value,edges:U.edges,timestamp:U.timestamp,action:"initial"})}),J.realtime)Y=(U)=>{const P=c6(U,J);if(!l6(g0(P),g0(X)))q(P),X=P},this.eventListeners.push(Y)}return{results:X,...J.realtime&&V&&Y&&{unsubscribe:()=>{const U=this.eventListeners.indexOf(Y);U>-1&&this.eventListeners.splice(U,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((V)=>V.edges=V.edges.filter((G)=>G!==W)),await this.saveGraphToOPFS(),this.saveGlobalTimestamp(Q),await this.syncChannel.send([{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.syncChannel.send([{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 V={upsert:(G)=>{const X=this.graph.get(G.id),Y=wW(X,G,this.hybridClock);if(Y.resolved){if(this.graph.upsert(G.id,Y.value,Y.timestamp),this.hybridClock.update(Y.timestamp),this.oplog.add({type:"upsert",id:G.id,timestamp:Y.timestamp}),Q=!0,!J||this.hybridClock.compare(Y.timestamp,J)>0)J=Y.timestamp}},remove:(G)=>{const X=this.graph.get(G.id);if(X&&this.hybridClock.compare(X.timestamp,G.timestamp)<0){if(delete this.graph.nodes[G.id],this.hybridClock.update(G.timestamp),this.oplog.add({type:"remove",id:G.id,timestamp:G.timestamp}),Q=!0,!J||this.hybridClock.compare(G.timestamp,J)>0)J=G.timestamp}},link:(G)=>{const X=this.graph.get(G.sourceId),Y=this.graph.get(G.targetId);if(X&&Y&&this.hybridClock.compare(X.timestamp,G.timestamp)<0){if(this.graph.link(G.sourceId,G.targetId,G.timestamp),this.hybridClock.update(G.timestamp),this.oplog.add({type:"link",sourceId:G.sourceId,targetId:G.targetId,timestamp:G.timestamp}),Q=!0,!J||this.hybridClock.compare(G.timestamp,J)>0)J=G.timestamp}},sync:async(G)=>{const X=G.timestamp;if(X===null){console.info("\uD83D\uDCEC [SYNC REQUEST] from new peer (no timestamp). Sending full graph."),await this.syncChannel.send([{type:"syncReceive",graph:this.graph}]);return}console.info("\uD83D\uDCEC [SYNC REQUEST] since:",new Date(X.physical).toLocaleString());const Y=this.oplog.getOldest();if(Y&&this.hybridClock.compare(X,Y.timestamp)<0){console.info("\uD83D\uDCA5 [FALLBACK TRIGGERED] Peer is too far behind. Sending FULL graph state."),await this.syncChannel.send([{type:"syncReceive",graph:this.graph}]);return}const q=this.oplog.getDelta(X,this.hybridClock.compare);if(q.length>0){const U=q.map((F)=>{if(F.type==="upsert"){const C=this.graph.get(F.id);return{...F,value:C?C.value:null}}return F}),P=i0.deflate(g0(U));console.info(`\uD83D\uDE80 [DELTA SYNC SENDING] Found ${q.length} new operations to send.`),await this.syncChannel.send([{type:"deltaSync",operations:P}])}else console.info("\u2705 [ALREADY SYNCED] Peer is up-to-date. Nothing to send.")},deltaSync:(G)=>{console.info("\uD83D\uDEF0\uFE0F [DELTA SYNC RECEIVED] Applying delta from a peer.");let X=t1(i0.inflate(G.operations));for(let Y of X)V[Y.type]?.(Y)},syncReceive:async(G)=>{if(console.info("\uD83D\uDCE6 [FULL SYNC RECEIVED] Overwriting local state with full graph from a peer."),G.graph&&G.graph.nodes){await this.applyFullGraph(G.graph),this.oplog.clear(),console.info("\uD83D\uDD12 Oplog has been cleared due to full sync."),Q=!0;let X=null;for(let Y in G.graph.nodes){const q=G.graph.nodes[Y];if(q.timestamp&&(!X||this.hybridClock.compare(q.timestamp,X)>0))X=q.timestamp}if(X)console.info("\uD83D\uDCC8 [GLOBAL TIMESTAMP] Updated from full sync."),J=X,this.hybridClock.update(X)}else console.error("\u274C Full sync failed: received graph data is invalid.",G.graph)}};for(let G of W)if(V[G.type])await V[G.type](G);else console.warn(`\uD83E\uDD37\u200D\u2640\uFE0F [UNKNOWN MESSAGE TYPE] Received unhandled message type: "${G.type}"`);if(J){if(!this.globalTimestamp||this.hybridClock.compare(J,this.globalTimestamp)>0)console.info(`\uD83D\uDCC8 [GLOBAL TIMESTAMP] Advanced from ${this.globalTimestamp?.logical} to ${J.logical}.`),this.saveGlobalTimestamp(J)}if(Q)console.info("\uD83D\uDCBE [STATE CHANGED] Saving state and emitting update."),await this.saveGraphToOPFS(),this.emit()}}export{i6 as GDB};