@0xobelisk/client 1.2.0-pre.122 → 1.2.0-pre.124
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("ObeliskClient",[],t):"object"==typeof exports?exports.ObeliskClient=t():e.ObeliskClient=t()}(this,()=>(()=>{var e={20:(e,t,n)=>{"use strict";function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach(function(t){o(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function o(e,t,n){return(t=a(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,a(r.key),r)}}function a(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var u=n(533).Buffer,c=n(541).inspect,l=c&&c.custom||"inspect";function h(e,t,n){u.prototype.copy.call(e,t,n)}e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}var t,n,r;return t=e,(n=[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return u.alloc(0);for(var t=u.allocUnsafe(e>>>0),n=this.head,r=0;n;)h(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:"consume",value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var i=t.data,o=e>i.length?i.length:e;if(o===i.length?r+=i:r+=i.slice(0,e),0===(e-=o)){o===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=u.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var i=n.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0===(e-=o)){o===i.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=i.slice(o));break}++r}return this.length-=r,t}},{key:l,value:function(e,t){return c(this,i(i({},t),{},{depth:0,customInspect:!1}))}}])&&s(t.prototype,n),r&&s(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}()},33:(e,t,n)=>{"use strict";var r;e.exports=T,T.ReadableState=S;n(381).EventEmitter;var i=function(e,t){return e.listeners(t).length},o=n(534),s=n(533).Buffer,a=(void 0!==n.g?n.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var u,c=n(429);u=c&&c.debuglog?c.debuglog("stream"):function(){};var l,h,f,d=n(20),p=n(917),y=n(750).getHighWaterMark,m=n(289).F,g=m.ERR_INVALID_ARG_TYPE,b=m.ERR_STREAM_PUSH_AFTER_EOF,v=m.ERR_METHOD_NOT_IMPLEMENTED,w=m.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(193)(T,o);var E=p.errorOrDestroy,k=["error","close","destroy","pause","resume"];function S(e,t,i){r=r||n(707),e=e||{},"boolean"!=typeof i&&(i=t instanceof r),this.objectMode=!!e.objectMode,i&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=y(this,e,"readableHighWaterMark",i),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(l||(l=n(704).I),this.decoder=new l(e.encoding),this.encoding=e.encoding)}function T(e){if(r=r||n(707),!(this instanceof T))return new T(e);var t=this instanceof r;this._readableState=new S(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),o.call(this)}function _(e,t,n,r,i){u("readableAddChunk",t);var o,c=e._readableState;if(null===t)c.reading=!1,function(e,t){if(u("onEofChunk"),t.ended)return;if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.sync?M(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,C(e)))}(e,c);else if(i||(o=function(e,t){var n;r=t,s.isBuffer(r)||r instanceof a||"string"==typeof t||void 0===t||e.objectMode||(n=new g("chunk",["string","Buffer","Uint8Array"],t));var r;return n}(c,t)),o)E(e,o);else if(c.objectMode||t&&t.length>0)if("string"==typeof t||c.objectMode||Object.getPrototypeOf(t)===s.prototype||(t=function(e){return s.from(e)}(t)),r)c.endEmitted?E(e,new w):O(e,c,t,!0);else if(c.ended)E(e,new b);else{if(c.destroyed)return!1;c.reading=!1,c.decoder&&!n?(t=c.decoder.write(t),c.objectMode||0!==t.length?O(e,c,t,!1):A(e,c)):O(e,c,t,!1)}else r||(c.reading=!1,A(e,c));return!c.ended&&(c.length<c.highWaterMark||0===c.length)}function O(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&M(e)),A(e,t)}Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),T.prototype.destroy=p.destroy,T.prototype._undestroy=p.undestroy,T.prototype._destroy=function(e,t){t(e)},T.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=s.from(e,t),t=""),n=!0),_(this,e,t,!1,n)},T.prototype.unshift=function(e){return _(this,e,null,!0,!1)},T.prototype.isPaused=function(){return!1===this._readableState.flowing},T.prototype.setEncoding=function(e){l||(l=n(704).I);var t=new l(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,i="";null!==r;)i+=t.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var x=1073741824;function I(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=x?e=x:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function M(e){var t=e._readableState;u("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(u("emitReadable",t.flowing),t.emittedReadable=!0,process.nextTick(C,e))}function C(e){var t=e._readableState;u("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,P(e)}function A(e,t){t.readingMore||(t.readingMore=!0,process.nextTick(N,e,t))}function N(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var n=t.length;if(u("maybeReadMore read 0"),e.read(0),n===t.length)break}t.readingMore=!1}function j(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function D(e){u("readable nexttick read 0"),e.read(0)}function R(e,t){u("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),P(e),t.flowing&&!t.reading&&e.read(0)}function P(e){var t=e._readableState;for(u("flow",t.flowing);t.flowing&&null!==e.read(););}function B(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function F(e){var t=e._readableState;u("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,process.nextTick(L,t,e))}function L(e,t){if(u("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}function U(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}T.prototype.read=function(e){u("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return u("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?F(this):M(this),null;if(0===(e=I(e,t))&&t.ended)return 0===t.length&&F(this),null;var r,i=t.needReadable;return u("need readable",i),(0===t.length||t.length-e<t.highWaterMark)&&u("length less than watermark",i=!0),t.ended||t.reading?u("reading or ended",i=!1):i&&(u("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=I(n,t))),null===(r=e>0?B(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&F(this)),null!==r&&this.emit("data",r),r},T.prototype._read=function(e){E(this,new v("_read()"))},T.prototype.pipe=function(e,t){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e)}r.pipesCount+=1,u("pipe count=%d opts=%j",r.pipesCount,t);var o=(!t||!1!==t.end)&&e!==process.stdout&&e!==process.stderr?a:y;function s(t,i){u("onunpipe"),t===n&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,u("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",c),e.removeListener("error",f),e.removeListener("unpipe",s),n.removeListener("end",a),n.removeListener("end",y),n.removeListener("data",h),l=!0,!r.awaitDrain||e._writableState&&!e._writableState.needDrain||c())}function a(){u("onend"),e.end()}r.endEmitted?process.nextTick(o):n.once("end",o),e.on("unpipe",s);var c=function(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&i(e,"data")&&(t.flowing=!0,P(e))}}(n);e.on("drain",c);var l=!1;function h(t){u("ondata");var i=e.write(t);u("dest.write",i),!1===i&&((1===r.pipesCount&&r.pipes===e||r.pipesCount>1&&-1!==U(r.pipes,e))&&!l&&(u("false write response, pause",r.awaitDrain),r.awaitDrain++),n.pause())}function f(t){u("onerror",t),y(),e.removeListener("error",f),0===i(e,"error")&&E(e,t)}function d(){e.removeListener("finish",p),y()}function p(){u("onfinish"),e.removeListener("close",d),y()}function y(){u("unpipe"),n.unpipe(e)}return n.on("data",h),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",f),e.once("close",d),e.once("finish",p),e.emit("pipe",n),r.flowing||(u("pipe resume"),n.resume()),e},T.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)r[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=U(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n)),this},T.prototype.on=function(e,t){var n=o.prototype.on.call(this,e,t),r=this._readableState;return"data"===e?(r.readableListening=this.listenerCount("readable")>0,!1!==r.flowing&&this.resume()):"readable"===e&&(r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,u("on readable",r.length,r.reading),r.length?M(this):r.reading||process.nextTick(D,this))),n},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(e,t){var n=o.prototype.removeListener.call(this,e,t);return"readable"===e&&process.nextTick(j,this),n},T.prototype.removeAllListeners=function(e){var t=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||process.nextTick(j,this),t},T.prototype.resume=function(){var e=this._readableState;return e.flowing||(u("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,process.nextTick(R,e,t))}(this,e)),e.paused=!1,this},T.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},T.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on("end",function(){if(u("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(i){(u("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(t.push(i)||(r=!0,e.pause()))}),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o<k.length;o++)e.on(k[o],this.emit.bind(this,k[o]));return this._read=function(t){u("wrapped _read",t),r&&(r=!1,e.resume())},this},"function"==typeof Symbol&&(T.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=n(536)),h(this)}),Object.defineProperty(T.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(T.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(T.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),T._fromList=B,Object.defineProperty(T.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(T.from=function(e,t){return void 0===f&&(f=n(918)),f(T,e,t)})},94:(e,t,n)=>{(t=e.exports=n(33)).Stream=t,t.Readable=t,t.Writable=n(553),t.Duplex=n(707),t.Transform=n(141),t.PassThrough=n(271),t.finished=n(339),t.pipeline=n(481)},102:(e,t,n)=>{const{Transform:r}=n(94);e.exports=e=>class t extends r{constructor(t,n,r,i){super(i),this._rate=t,this._capacity=n,this._delimitedSuffix=r,this._options=i,this._state=new e,this._state.initialize(t,n),this._finalized=!1}_transform(e,t,n){let r=null;try{this.update(e,t)}catch(e){r=e}n(r)}_flush(){}_read(e){this.push(this.squeeze(e))}update(e,t){if(!Buffer.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Squeeze already called");return Buffer.isBuffer(e)||(e=Buffer.from(e,t)),this._state.absorb(e),this}squeeze(e,t){this._finalized||(this._finalized=!0,this._state.absorbLastFewBits(this._delimitedSuffix));let n=this._state.squeeze(e);return void 0!==t&&(n=n.toString(t)),n}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const e=new t(this._rate,this._capacity,this._delimitedSuffix,this._options);return this._state.copy(e._state),e._finalized=this._finalized,e}}},141:(e,t,n)=>{"use strict";e.exports=l;var r=n(289).F,i=r.ERR_METHOD_NOT_IMPLEMENTED,o=r.ERR_MULTIPLE_CALLBACK,s=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=r.ERR_TRANSFORM_WITH_LENGTH_0,u=n(707);function c(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new o);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function l(e){if(!(this instanceof l))return new l(e);u.call(this,e),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",h)}function h(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?f(this,null,null):this._flush(function(t,n){f(e,t,n)})}function f(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}n(193)(l,u),l.prototype.push=function(e,t){return this._transformState.needTransform=!1,u.prototype.push.call(this,e,t)},l.prototype._transform=function(e,t,n){n(new i("_transform()"))},l.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},l.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},l.prototype._destroy=function(e,t){u.prototype._destroy.call(this,e,function(e){t(e)})}},193:e=>{"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},217:(e,t,n)=>{const r=n(302);function i(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}i.prototype.initialize=function(e,t){for(let e=0;e<50;++e)this.state[e]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1},i.prototype.absorb=function(e){for(let t=0;t<e.length;++t)this.state[~~(this.count/4)]^=e[t]<<this.count%4*8,this.count+=1,this.count===this.blockSize&&(r.p1600(this.state),this.count=0)},i.prototype.absorbLastFewBits=function(e){this.state[~~(this.count/4)]^=e<<this.count%4*8,128&e&&this.count===this.blockSize-1&&r.p1600(this.state),this.state[~~((this.blockSize-1)/4)]^=128<<(this.blockSize-1)%4*8,r.p1600(this.state),this.count=0,this.squeezing=!0},i.prototype.squeeze=function(e){this.squeezing||this.absorbLastFewBits(1);const t=Buffer.alloc(e);for(let n=0;n<e;++n)t[n]=this.state[~~(this.count/4)]>>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(r.p1600(this.state),this.count=0);return t},i.prototype.copy=function(e){for(let t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing},e.exports=i},271:(e,t,n)=>{"use strict";e.exports=i;var r=n(141);function i(e){if(!(this instanceof i))return new i(e);r.call(this,e)}n(193)(i,r),i.prototype._transform=function(e,t,n){n(null,e)}},289:e=>{"use strict";var t={};function n(e,n,r){r||(r=Error);var i=function(e){var t,r;function i(t,r,i){return e.call(this,function(e,t,r){return"string"==typeof n?n:n(e,t,r)}(t,r,i))||this}return r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r,i}(r);i.prototype.name=r.name,i.prototype.code=e,t[e]=i}function r(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map(function(e){return String(e)}),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}n("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError),n("ERR_INVALID_ARG_TYPE",function(e,t,n){var i,o,s,a;if("string"==typeof t&&(o="not ",t.substr(!s||s<0?0:+s,o.length)===o)?(i="must not be",t=t.replace(/^not /,"")):i="must be",function(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}(e," argument"))a="The ".concat(e," ").concat(i," ").concat(r(t,"type"));else{var u=function(e,t,n){return"number"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}(e,".")?"property":"argument";a='The "'.concat(e,'" ').concat(u," ").concat(i," ").concat(r(t,"type"))}return a+=". Received type ".concat(typeof n)},TypeError),n("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),n("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),n("ERR_STREAM_PREMATURE_CLOSE","Premature close"),n("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),n("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),n("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),n("ERR_STREAM_WRITE_AFTER_END","write after end"),n("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),n("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),n("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.F=t},302:(e,t)=>{const n=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648];t.p1600=function(e){for(let t=0;t<24;++t){const r=e[0]^e[10]^e[20]^e[30]^e[40],i=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],s=e[3]^e[13]^e[23]^e[33]^e[43],a=e[4]^e[14]^e[24]^e[34]^e[44],u=e[5]^e[15]^e[25]^e[35]^e[45],c=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],h=e[8]^e[18]^e[28]^e[38]^e[48],f=e[9]^e[19]^e[29]^e[39]^e[49];let d=h^(o<<1|s>>>31),p=f^(s<<1|o>>>31);const y=e[0]^d,m=e[1]^p,g=e[10]^d,b=e[11]^p,v=e[20]^d,w=e[21]^p,E=e[30]^d,k=e[31]^p,S=e[40]^d,T=e[41]^p;d=r^(a<<1|u>>>31),p=i^(u<<1|a>>>31);const _=e[2]^d,O=e[3]^p,x=e[12]^d,I=e[13]^p,M=e[22]^d,C=e[23]^p,A=e[32]^d,N=e[33]^p,j=e[42]^d,D=e[43]^p;d=o^(c<<1|l>>>31),p=s^(l<<1|c>>>31);const R=e[4]^d,P=e[5]^p,B=e[14]^d,F=e[15]^p,L=e[24]^d,U=e[25]^p,$=e[34]^d,q=e[35]^p,V=e[44]^d,z=e[45]^p;d=a^(h<<1|f>>>31),p=u^(f<<1|h>>>31);const K=e[6]^d,W=e[7]^p,Q=e[16]^d,G=e[17]^p,H=e[26]^d,J=e[27]^p,Z=e[36]^d,Y=e[37]^p,X=e[46]^d,ee=e[47]^p;d=c^(r<<1|i>>>31),p=l^(i<<1|r>>>31);const te=e[8]^d,ne=e[9]^p,re=e[18]^d,ie=e[19]^p,oe=e[28]^d,se=e[29]^p,ae=e[38]^d,ue=e[39]^p,ce=e[48]^d,le=e[49]^p,he=y,fe=m,de=b<<4|g>>>28,pe=g<<4|b>>>28,ye=v<<3|w>>>29,me=w<<3|v>>>29,ge=k<<9|E>>>23,be=E<<9|k>>>23,ve=S<<18|T>>>14,we=T<<18|S>>>14,Ee=_<<1|O>>>31,ke=O<<1|_>>>31,Se=I<<12|x>>>20,Te=x<<12|I>>>20,_e=M<<10|C>>>22,Oe=C<<10|M>>>22,xe=N<<13|A>>>19,Ie=A<<13|N>>>19,Me=j<<2|D>>>30,Ce=D<<2|j>>>30,Ae=P<<30|R>>>2,Ne=R<<30|P>>>2,je=B<<6|F>>>26,De=F<<6|B>>>26,Re=U<<11|L>>>21,Pe=L<<11|U>>>21,Be=$<<15|q>>>17,Fe=q<<15|$>>>17,Le=z<<29|V>>>3,Ue=V<<29|z>>>3,$e=K<<28|W>>>4,qe=W<<28|K>>>4,Ve=G<<23|Q>>>9,ze=Q<<23|G>>>9,Ke=H<<25|J>>>7,We=J<<25|H>>>7,Qe=Z<<21|Y>>>11,Ge=Y<<21|Z>>>11,He=ee<<24|X>>>8,Je=X<<24|ee>>>8,Ze=te<<27|ne>>>5,Ye=ne<<27|te>>>5,Xe=re<<20|ie>>>12,et=ie<<20|re>>>12,tt=se<<7|oe>>>25,nt=oe<<7|se>>>25,rt=ae<<8|ue>>>24,it=ue<<8|ae>>>24,ot=ce<<14|le>>>18,st=le<<14|ce>>>18;e[0]=he^~Se&Re,e[1]=fe^~Te&Pe,e[10]=$e^~Xe&ye,e[11]=qe^~et&me,e[20]=Ee^~je&Ke,e[21]=ke^~De&We,e[30]=Ze^~de&_e,e[31]=Ye^~pe&Oe,e[40]=Ae^~Ve&tt,e[41]=Ne^~ze&nt,e[2]=Se^~Re&Qe,e[3]=Te^~Pe&Ge,e[12]=Xe^~ye&xe,e[13]=et^~me&Ie,e[22]=je^~Ke&rt,e[23]=De^~We&it,e[32]=de^~_e&Be,e[33]=pe^~Oe&Fe,e[42]=Ve^~tt&ge,e[43]=ze^~nt&be,e[4]=Re^~Qe&ot,e[5]=Pe^~Ge&st,e[14]=ye^~xe&Le,e[15]=me^~Ie&Ue,e[24]=Ke^~rt&ve,e[25]=We^~it&we,e[34]=_e^~Be&He,e[35]=Oe^~Fe&Je,e[44]=tt^~ge&Me,e[45]=nt^~be&Ce,e[6]=Qe^~ot&he,e[7]=Ge^~st&fe,e[16]=xe^~Le&$e,e[17]=Ie^~Ue&qe,e[26]=rt^~ve&Ee,e[27]=it^~we&ke,e[36]=Be^~He&Ze,e[37]=Fe^~Je&Ye,e[46]=ge^~Me&Ae,e[47]=be^~Ce&Ne,e[8]=ot^~he&Se,e[9]=st^~fe&Te,e[18]=Le^~$e&Xe,e[19]=Ue^~qe&et,e[28]=ve^~Ee&je,e[29]=we^~ke&De,e[38]=He^~Ze&de,e[39]=Je^~Ye&pe,e[48]=Me^~Ae&Ve,e[49]=Ce^~Ne&ze,e[0]^=n[2*t],e[1]^=n[2*t+1]}}},316:(e,t,n)=>{const{Transform:r}=n(94);e.exports=e=>class t extends r{constructor(t,n,r,i,o){super(o),this._rate=t,this._capacity=n,this._delimitedSuffix=r,this._hashBitLength=i,this._options=o,this._state=new e,this._state.initialize(t,n),this._finalized=!1}_transform(e,t,n){let r=null;try{this.update(e,t)}catch(e){r=e}n(r)}_flush(e){let t=null;try{this.push(this.digest())}catch(e){t=e}e(t)}update(e,t){if(!Buffer.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Digest already called");return Buffer.isBuffer(e)||(e=Buffer.from(e,t)),this._state.absorb(e),this}digest(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0,this._delimitedSuffix&&this._state.absorbLastFewBits(this._delimitedSuffix);let t=this._state.squeeze(this._hashBitLength/8);return void 0!==e&&(t=t.toString(e)),this._resetState(),t}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const e=new t(this._rate,this._capacity,this._delimitedSuffix,this._hashBitLength,this._options);return this._state.copy(e._state),e._finalized=this._finalized,e}}},328:(e,t)=>{t.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,u=(1<<a)-1,c=u>>1,l=-7,h=n?i-1:0,f=n?-1:1,d=e[t+h];for(h+=f,o=d&(1<<-l)-1,d>>=-l,l+=a;l>0;o=256*o+e[t+h],h+=f,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=256*s+e[t+h],h+=f,l-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),o-=c}return(d?-1:1)*s*Math.pow(2,o-r)},t.write=function(e,t,n,r,i,o){var s,a,u,c=8*o-i-1,l=(1<<c)-1,h=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,p=r?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+h>=1?f/u:f*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(t*u-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[n+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;e[n+d]=255&s,d+=p,s/=256,c-=8);e[n+d-p]|=128*y}},339:(e,t,n)=>{"use strict";var r=n(289).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}e.exports=function e(t,n,o){if("function"==typeof n)return e(t,null,n);n||(n={}),o=function(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];e.apply(this,r)}}}(o||i);var s=n.readable||!1!==n.readable&&t.readable,a=n.writable||!1!==n.writable&&t.writable,u=function(){t.writable||l()},c=t._writableState&&t._writableState.finished,l=function(){a=!1,c=!0,s||o.call(t)},h=t._readableState&&t._readableState.endEmitted,f=function(){s=!1,h=!0,a||o.call(t)},d=function(e){o.call(t,e)},p=function(){var e;return s&&!h?(t._readableState&&t._readableState.ended||(e=new r),o.call(t,e)):a&&!c?(t._writableState&&t._writableState.ended||(e=new r),o.call(t,e)):void 0},y=function(){t.req.on("finish",l)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(t)?a&&!t._writableState&&(t.on("end",u),t.on("close",u)):(t.on("complete",l),t.on("abort",p),t.req?y():t.on("request",y)),t.on("end",f),t.on("finish",l),!1!==n.error&&t.on("error",d),t.on("close",p),function(){t.removeListener("complete",l),t.removeListener("abort",p),t.removeListener("request",y),t.req&&t.req.removeListener("finish",l),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",l),t.removeListener("end",f),t.removeListener("error",d),t.removeListener("close",p)}}},381:e=>{"use strict";var t,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,o),r(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}y(e,t,o,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&y(e,"error",t,n)}(e,i,{once:!0})})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function c(e,t,n,r){var i,o,s,c;if(a(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]),void 0===s)s=o[t]=n,++e._eventsCount;else if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(i=u(e))>0&&s.length>i&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,c=l,console&&console.warn&&console.warn(c)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=l.bind(r);return i.listener=n,r.wrapFn=i,i}function f(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):p(i,i.length)}function d(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function p(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function y(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function i(o){r.once&&e.removeEventListener(t,i),n(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=o[e];if(void 0===u)return!1;if("function"==typeof u)r(u,this,t);else{var c=u.length,l=p(u,c);for(n=0;n<c;++n)r(l[n],this,t)}return!0},o.prototype.addListener=function(e,t){return c(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return c(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,h(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,h(this,e,t)),this},o.prototype.removeListener=function(e,t){var n,r,i,o,s;if(a(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},o.prototype.listeners=function(e){return f(this,e,!0)},o.prototype.rawListeners=function(e){return f(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},o.prototype.listenerCount=d,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},390:function(e){e.exports=function(){var e=[],t=[],n={},r={},i={};function o(e){return"string"==typeof e?new RegExp("^"+e+"$","i"):e}function s(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function a(e,t){return e.replace(/\$(\d{1,2})/g,function(e,n){return t[n]||""})}function u(e,t){return e.replace(t[0],function(n,r){var i=a(t[1],arguments);return s(""===n?e[r-1]:n,i)})}function c(e,t,r){if(!e.length||n.hasOwnProperty(e))return t;for(var i=r.length;i--;){var o=r[i];if(o[0].test(t))return u(t,o)}return t}function l(e,t,n){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?s(r,i):e.hasOwnProperty(i)?s(r,e[i]):c(i,r,n)}}function h(e,t,n,r){return function(r){var i=r.toLowerCase();return!!t.hasOwnProperty(i)||!e.hasOwnProperty(i)&&c(i,i,n)===i}}function f(e,t,n){return(n?t+" ":"")+(1===t?f.singular(e):f.plural(e))}return f.plural=l(i,r,e),f.isPlural=h(i,r,e),f.singular=l(r,i,t),f.isSingular=h(r,i,t),f.addPluralRule=function(t,n){e.push([o(t),n])},f.addSingularRule=function(e,n){t.push([o(e),n])},f.addUncountableRule=function(e){"string"!=typeof e?(f.addPluralRule(e,"$0"),f.addSingularRule(e,"$0")):n[e.toLowerCase()]=!0},f.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),i[e]=t,r[t]=e},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach(function(e){return f.addIrregularRule(e[0],e[1])}),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach(function(e){return f.addPluralRule(e[0],e[1])}),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/\b((?:tit)?m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach(function(e){return f.addSingularRule(e[0],e[1])}),["adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(f.addUncountableRule),f}()},429:()=>{},481:(e,t,n)=>{"use strict";var r;var i=n(289).F,o=i.ERR_MISSING_ARGS,s=i.ERR_STREAM_DESTROYED;function a(e){if(e)throw e}function u(e){e()}function c(e,t){return e.pipe(t)}e.exports=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];var l,h=function(e){return e.length?"function"!=typeof e[e.length-1]?a:e.pop():a}(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new o("streams");var f=t.map(function(e,i){var o=i<t.length-1;return function(e,t,i,o){o=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(o);var a=!1;e.on("close",function(){a=!0}),void 0===r&&(r=n(339)),r(e,{readable:t,writable:i},function(e){if(e)return o(e);a=!0,o()});var u=!1;return function(t){if(!a&&!u)return u=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void o(t||new s("pipe"))}}(e,o,i>0,function(e){l||(l=e),e&&f.forEach(u),o||(f.forEach(u),h(l))})});return t.reduce(c)}},533:(e,t,n)=>{"use strict";const r=n(933),i=n(328),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=u,t.SlowBuffer=function(e){+e!=e&&(e=0);return u.alloc(+e)},t.INSPECT_MAX_BYTES=50;const s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,u.prototype),t}function u(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return c(e,t,n)}function c(e,t,n){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!u.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const n=0|y(e,t);let r=a(n);const i=r.write(e,t);i!==n&&(r=r.slice(0,i));return r}(e,t);if(ArrayBuffer.isView(e))return function(e){if(H(e,Uint8Array)){const t=new Uint8Array(e);return d(t.buffer,t.byteOffset,t.byteLength)}return f(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(H(e,ArrayBuffer)||e&&H(e.buffer,ArrayBuffer))return d(e,t,n);if("undefined"!=typeof SharedArrayBuffer&&(H(e,SharedArrayBuffer)||e&&H(e.buffer,SharedArrayBuffer)))return d(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return u.from(r,t,n);const i=function(e){if(u.isBuffer(e)){const t=0|p(e.length),n=a(t);return 0===n.length||e.copy(n,0,0,t),n}if(void 0!==e.length)return"number"!=typeof e.length||J(e.length)?a(0):f(e);if("Buffer"===e.type&&Array.isArray(e.data))return f(e.data)}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return u.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return l(e),a(e<0?0:0|p(e))}function f(e){const t=e.length<0?0:0|p(e.length),n=a(t);for(let r=0;r<t;r+=1)n[r]=255&e[r];return n}function d(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===t&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,t):new Uint8Array(e,t,n),Object.setPrototypeOf(r,u.prototype),r}function p(e){if(e>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function y(e,t){if(u.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||H(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const n=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return W(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Q(e).length;default:if(i)return r?-1:W(e).length;t=(""+t).toLowerCase(),i=!0}}function m(e,t,n){let r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,n);case"utf8":case"utf-8":return O(this,t,n);case"ascii":return I(this,t,n);case"latin1":case"binary":return M(this,t,n);case"base64":return _(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function g(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function b(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),J(n=+n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=u.from(t,r)),u.isBuffer(t))return 0===t.length?-1:v(e,t,n,r,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):v(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function v(e,t,n,r,i){let o,s=1,a=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,n/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){let r=-1;for(o=n;o<a;o++)if(c(e,o)===c(t,-1===r?0:o-r)){if(-1===r&&(r=o),o-r+1===u)return r*s}else-1!==r&&(o-=o-r),r=-1}else for(n+u>a&&(n=a-u),o=n;o>=0;o--){let n=!0;for(let r=0;r<u;r++)if(c(e,o+r)!==c(t,r)){n=!1;break}if(n)return o}return-1}function w(e,t,n,r){n=Number(n)||0;const i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;const o=t.length;let s;for(r>o/2&&(r=o/2),s=0;s<r;++s){const r=parseInt(t.substr(2*s,2),16);if(J(r))return s;e[n+s]=r}return s}function E(e,t,n,r){return G(W(t,e.length-n),e,n,r)}function k(e,t,n,r){return G(function(e){const t=[];for(let n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function S(e,t,n,r){return G(Q(t),e,n,r)}function T(e,t,n,r){return G(function(e,t){let n,r,i;const o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)n=e.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function _(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function O(e,t,n){n=Math.min(e.length,n);const r=[];let i=t;for(;i<n;){const t=e[i];let o=null,s=t>239?4:t>223?3:t>191?2:1;if(i+s<=n){let n,r,a,u;switch(s){case 1:t<128&&(o=t);break;case 2:n=e[i+1],128==(192&n)&&(u=(31&t)<<6|63&n,u>127&&(o=u));break;case 3:n=e[i+1],r=e[i+2],128==(192&n)&&128==(192&r)&&(u=(15&t)<<12|(63&n)<<6|63&r,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:n=e[i+1],r=e[i+2],a=e[i+3],128==(192&n)&&128==(192&r)&&128==(192&a)&&(u=(15&t)<<18|(63&n)<<12|(63&r)<<6|63&a,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o),i+=s}return function(e){const t=e.length;if(t<=x)return String.fromCharCode.apply(String,e);let n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=x));return n}(r)}t.kMaxLength=s,u.TYPED_ARRAY_SUPPORT=function(){try{const e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(e,t,n){return c(e,t,n)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(e,t,n){return function(e,t,n){return l(e),e<=0?a(e):void 0!==t?"string"==typeof n?a(e).fill(t,n):a(e).fill(t):a(e)}(e,t,n)},u.allocUnsafe=function(e){return h(e)},u.allocUnsafeSlow=function(e){return h(e)},u.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==u.prototype},u.compare=function(e,t){if(H(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),H(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);let n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;const r=u.allocUnsafe(t);let i=0;for(n=0;n<e.length;++n){let t=e[n];if(H(t,Uint8Array))i+t.length>r.length?(u.isBuffer(t)||(t=u.from(t)),t.copy(r,i)):Uint8Array.prototype.set.call(r,t,i);else{if(!u.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(r,i)}i+=t.length}return r},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)g(this,t,t+1);return this},u.prototype.swap32=function(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},u.prototype.swap64=function(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},u.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?O(this,0,e):m.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){let e="";const n=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(e+=" ... "),"<Buffer "+e+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(e,t,n,r,i){if(H(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;let o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0);const a=Math.min(o,s),c=this.slice(r,i),l=e.slice(t,n);for(let e=0;e<a;++e)if(c[e]!==l[e]){o=c[e],s=l[e];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},u.prototype.indexOf=function(e,t,n){return b(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return b(this,e,t,n,!1)},u.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let o=!1;for(;;)switch(r){case"hex":return w(this,e,t,n);case"utf8":case"utf-8":return E(this,e,t,n);case"ascii":case"latin1":case"binary":return k(this,e,t,n);case"base64":return S(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const x=4096;function I(e,t,n){let r="";n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function M(e,t,n){let r="";n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function C(e,t,n){const r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i="";for(let r=t;r<n;++r)i+=Z[e[r]];return i}function A(e,t,n){const r=e.slice(t,n);let i="";for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+256*r[e+1]);return i}function N(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function j(e,t,n,r,i,o){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function D(e,t,n,r,i){q(t,r,i,e,n,7);let o=Number(t&BigInt(4294967295));e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=s,s>>=8,e[n++]=s,s>>=8,e[n++]=s,s>>=8,e[n++]=s,n}function R(e,t,n,r,i){q(t,r,i,e,n,7);let o=Number(t&BigInt(4294967295));e[n+7]=o,o>>=8,e[n+6]=o,o>>=8,e[n+5]=o,o>>=8,e[n+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=s,s>>=8,e[n+2]=s,s>>=8,e[n+1]=s,s>>=8,e[n]=s,n+8}function P(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function B(e,t,n,r,o){return t=+t,n>>>=0,o||P(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function F(e,t,n,r,o){return t=+t,n>>>=0,o||P(e,0,n,8),i.write(e,t,n,r,52,8),n+8}u.prototype.slice=function(e,t){const n=this.length;(e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e);const r=this.subarray(e,t);return Object.setPrototypeOf(r,u.prototype),r},u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||N(e,t,this.length);let r=this[e],i=1,o=0;for(;++o<t&&(i*=256);)r+=this[e+o]*i;return r},u.prototype.readUintBE=u.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||N(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e>>>=0,t||N(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e>>>=0,t||N(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=Y(function(e){V(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||z(e,this.length-8);const r=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,i=this[++e]+256*this[++e]+65536*this[++e]+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=Y(function(e){V(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||z(e,this.length-8);const r=t*2**24+65536*this[++e]+256*this[++e]+this[++e],i=this[++e]*2**24+65536*this[++e]+256*this[++e]+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||N(e,t,this.length);let r=this[e],i=1,o=0;for(;++o<t&&(i*=256);)r+=this[e+o]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*t)),r},u.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||N(e,t,this.length);let r=t,i=1,o=this[e+--r];for(;r>0&&(i*=256);)o+=this[e+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},u.prototype.readInt8=function(e,t){return e>>>=0,t||N(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||N(e,2,this.length);const n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(e,t){e>>>=0,t||N(e,2,this.length);const n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(e,t){return e>>>=0,t||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e>>>=0,t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=Y(function(e){V(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||z(e,this.length-8);const r=this[e+4]+256*this[e+5]+65536*this[e+6]+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)}),u.prototype.readBigInt64BE=Y(function(e){V(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||z(e,this.length-8);const r=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+n)}),u.prototype.readFloatLE=function(e,t){return e>>>=0,t||N(e,4,this.length),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||N(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||N(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||N(e,8,this.length),i.read(this,e,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){j(this,e,t,n,Math.pow(2,8*n)-1,0)}let i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){j(this,e,t,n,Math.pow(2,8*n)-1,0)}let i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,1,255,0),this[t]=255&e,t+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},u.prototype.writeBigUInt64LE=Y(function(e,t=0){return D(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Y(function(e,t=0){return R(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*n-1);j(this,e,t,n,r-1,-r)}let i=0,o=1,s=0;for(this[t]=255&e;++i<n&&(o*=256);)e<0&&0===s&&0!==this[t+i-1]&&(s=1),this[t+i]=(e/o|0)-s&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*n-1);j(this,e,t,n,r-1,-r)}let i=n-1,o=1,s=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/o|0)-s&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},u.prototype.writeBigInt64LE=Y(function(e,t=0){return D(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Y(function(e,t=0){return R(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeFloatLE=function(e,t,n){return B(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return B(this,e,t,!1,n)},u.prototype.writeDoubleLE=function(e,t,n){return F(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return F(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(!u.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);const i=r-n;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,n,r):Uint8Array.prototype.set.call(e,this.subarray(n,r),t),i},u.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===e.length){const t=e.charCodeAt(0);("utf8"===r&&t<128||"latin1"===r)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;let i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{const o=u.isBuffer(e)?e:u.from(e,r),s=o.length;if(0===s)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<n-t;++i)this[i+t]=o[i%s]}return this};const L={};function U(e,t,n){L[e]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function $(e){let t="",n=e.length;const r="-"===e[0]?1:0;for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function q(e,t,n,r,i,o){if(e>n||e<t){const r="bigint"==typeof t?"n":"";let i;throw i=o>3?0===t||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new L.ERR_OUT_OF_RANGE("value",i,e)}!function(e,t,n){V(t,"offset"),void 0!==e[t]&&void 0!==e[t+n]||z(t,e.length-(n+1))}(r,i,o)}function V(e,t){if("number"!=typeof e)throw new L.ERR_INVALID_ARG_TYPE(t,"number",e)}function z(e,t,n){if(Math.floor(e)!==e)throw V(e,n),new L.ERR_OUT_OF_RANGE(n||"offset","an integer",e);if(t<0)throw new L.ERR_BUFFER_OUT_OF_BOUNDS;throw new L.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${t}`,e)}U("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),U("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),U("ERR_OUT_OF_RANGE",function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=$(String(n)):"bigint"==typeof n&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=$(i)),i+="n"),r+=` It must be ${t}. Received ${i}`,r},RangeError);const K=/[^+/0-9A-Za-z-_]/g;function W(e,t){let n;t=t||1/0;const r=e.length;let i=null;const o=[];for(let s=0;s<r;++s){if(n=e.charCodeAt(s),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function Q(e){return r.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(K,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function G(e,t,n,r){let i;for(i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function H(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function J(e){return e!=e}const Z=function(){const e="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t}();function Y(e){return"undefined"==typeof BigInt?X:e}function X(){throw new Error("BigInt not supported")}},534:(e,t,n)=>{e.exports=n(381).EventEmitter},536:(e,t,n)=>{"use strict";var r;function i(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=n(339),s=Symbol("lastResolve"),a=Symbol("lastReject"),u=Symbol("error"),c=Symbol("ended"),l=Symbol("lastPromise"),h=Symbol("handlePromise"),f=Symbol("stream");function d(e,t){return{value:e,done:t}}function p(e){var t=e[s];if(null!==t){var n=e[f].read();null!==n&&(e[l]=null,e[s]=null,e[a]=null,t(d(n,!1)))}}function y(e){process.nextTick(p,e)}var m=Object.getPrototypeOf(function(){}),g=Object.setPrototypeOf((i(r={get stream(){return this[f]},next:function(){var e=this,t=this[u];if(null!==t)return Promise.reject(t);if(this[c])return Promise.resolve(d(void 0,!0));if(this[f].destroyed)return new Promise(function(t,n){process.nextTick(function(){e[u]?n(e[u]):t(d(void 0,!0))})});var n,r=this[l];if(r)n=new Promise(function(e,t){return function(n,r){e.then(function(){t[c]?n(d(void 0,!0)):t[h](n,r)},r)}}(r,this));else{var i=this[f].read();if(null!==i)return Promise.resolve(d(i,!1));n=new Promise(this[h])}return this[l]=n,n}},Symbol.asyncIterator,function(){return this}),i(r,"return",function(){var e=this;return new Promise(function(t,n){e[f].destroy(null,function(e){e?n(e):t(d(void 0,!0))})})}),r),m);e.exports=function(e){var t,n=Object.create(g,(i(t={},f,{value:e,writable:!0}),i(t,s,{value:null,writable:!0}),i(t,a,{value:null,writable:!0}),i(t,u,{value:null,writable:!0}),i(t,c,{value:e._readableState.endEmitted,writable:!0}),i(t,h,{value:function(e,t){var r=n[f].read();r?(n[l]=null,n[s]=null,n[a]=null,e(d(r,!1))):(n[s]=e,n[a]=t)},writable:!0}),t));return n[l]=null,o(e,function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[a];return null!==t&&(n[l]=null,n[s]=null,n[a]=null,t(e)),void(n[u]=e)}var r=n[s];null!==r&&(n[l]=null,n[s]=null,n[a]=null,r(d(void 0,!0))),n[c]=!0}),e.on("readable",y.bind(null,n)),n}},541:()=>{},553:(e,t,n)=>{"use strict";function r(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;e.entry=null;for(;r;){var i=r.callback;t.pendingcb--,i(n),r=r.next}t.corkedRequestsFree.next=e}(t,e)}}var i;e.exports=T,T.WritableState=S;var o={deprecate:n(947)},s=n(534),a=n(533).Buffer,u=(void 0!==n.g?n.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var c,l=n(917),h=n(750).getHighWaterMark,f=n(289).F,d=f.ERR_INVALID_ARG_TYPE,p=f.ERR_METHOD_NOT_IMPLEMENTED,y=f.ERR_MULTIPLE_CALLBACK,m=f.ERR_STREAM_CANNOT_PIPE,g=f.ERR_STREAM_DESTROYED,b=f.ERR_STREAM_NULL_VALUES,v=f.ERR_STREAM_WRITE_AFTER_END,w=f.ERR_UNKNOWN_ENCODING,E=l.errorOrDestroy;function k(){}function S(e,t,o){i=i||n(707),e=e||{},"boolean"!=typeof o&&(o=t instanceof i),this.objectMode=!!e.objectMode,o&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=h(this,e,"writableHighWaterMark",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if("function"!=typeof i)throw new y;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,i){--t.pendingcb,n?(process.nextTick(i,r),process.nextTick(C,e,t),e._writableState.errorEmitted=!0,E(e,r)):(i(r),e._writableState.errorEmitted=!0,E(e,r),C(e,t))}(e,n,r,t,i);else{var o=I(n)||e.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||x(e,n),r?process.nextTick(O,e,n,o,i):O(e,n,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new r(this)}function T(e){var t=this instanceof(i=i||n(707));if(!t&&!c.call(T,this))return new T(e);this._writableState=new S(e,this,t),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),s.call(this)}function _(e,t,n,r,i,o,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new g("write")):n?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function O(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),C(e,t)}function x(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var i=t.bufferedRequestCount,o=new Array(i),s=t.corkedRequestsFree;s.entry=n;for(var a=0,u=!0;n;)o[a]=n,n.isBuf||(u=!1),n=n.next,a+=1;o.allBuffers=u,_(e,t,!0,t.length,o,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new r(t),t.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,l=n.encoding,h=n.callback;if(_(e,t,!1,t.objectMode?1:c.length,c,l,h),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function I(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function M(e,t){e._final(function(n){t.pendingcb--,n&&E(e,n),t.prefinished=!0,e.emit("prefinish"),C(e,t)})}function C(e,t){var n=I(t);if(n&&(function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,process.nextTick(M,e,t)))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}n(193)(T,s),S.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(S.prototype,"buffer",{get:o.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(c=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(e){return!!c.call(this,e)||this===T&&(e&&e._writableState instanceof S)}})):c=function(e){return e instanceof this},T.prototype.pipe=function(){E(this,new m)},T.prototype.write=function(e,t,n){var r,i=this._writableState,o=!1,s=!i.objectMode&&(r=e,a.isBuffer(r)||r instanceof u);return s&&!a.isBuffer(e)&&(e=function(e){return a.from(e)}(e)),"function"==typeof t&&(n=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=k),i.ending?function(e,t){var n=new v;E(e,n),process.nextTick(t,n)}(this,n):(s||function(e,t,n,r){var i;return null===n?i=new b:"string"==typeof n||t.objectMode||(i=new d("chunk",["string","Buffer"],n)),!i||(E(e,i),process.nextTick(r,i),!1)}(this,i,e,n))&&(i.pendingcb++,o=function(e,t,n,r,i,o){if(!n){var s=function(e,t,n){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=a.from(t,n));return t}(t,r,i);r!==s&&(n=!0,i="buffer",r=s)}var u=t.objectMode?1:r.length;t.length+=u;var c=t.length<t.highWaterMark;c||(t.needDrain=!0);if(t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else _(e,t,!1,u,r,i,o);return c}(this,i,s,e,t,n)),o},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||x(this,e))},T.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new w(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(e,t,n){n(new p("_write()"))},T.prototype._writev=null,T.prototype.end=function(e,t,n){var r=this._writableState;return"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||function(e,t,n){t.ending=!0,C(e,t),n&&(t.finished?process.nextTick(n):e.once("finish",n));t.ended=!0,e.writable=!1}(this,r,n),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),T.prototype.destroy=l.destroy,T.prototype._undestroy=l.undestroy,T.prototype._destroy=function(e,t){t(e)}},608:(e,t,n)=>{var r=n(533),i=r.Buffer;function o(e,t){for(var n in e)t[n]=e[n]}function s(e,t,n){return i(e,t,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,n)},s.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=i(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},704:(e,t,n)=>{"use strict";var r=n(608).Buffer,i=r.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(r.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=l,this.end=h,t=3;break;default:return this.write=f,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,n=function(e,t){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function l(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function f(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}t.I=o,o.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},o.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},o.prototype.text=function(e,t){var n=function(e,t,n){var r=t.length-1;if(r<n)return 0;var i=s(t[r]);if(i>=0)return i>0&&(e.lastNeed=i-1),i;if(--r<n||-2===i)return 0;if(i=s(t[r]),i>=0)return i>0&&(e.lastNeed=i-2),i;if(--r<n||-2===i)return 0;if(i=s(t[r]),i>=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},707:(e,t,n)=>{"use strict";var r=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};e.exports=c;var i=n(33),o=n(553);n(193)(c,i);for(var s=r(o.prototype),a=0;a<s.length;a++){var u=s[a];c.prototype[u]||(c.prototype[u]=o.prototype[u])}function c(e){if(!(this instanceof c))return new c(e);i.call(this,e),o.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",l)))}function l(){this._writableState.ended||process.nextTick(h,this)}function h(e){e.end()}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(c.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})},750:(e,t,n)=>{"use strict";var r=n(289).F.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(e,t,n,i){var o=function(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}(t,i,n);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new r(i?n:"highWaterMark",o);return Math.floor(o)}return e.objectMode?16:16384}}},781:()=>{},787:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const i=r(n(829)),o=r(n(533)),s=r(n(876)),a=o.default.Buffer;function u(e){return e=function(e){if(!a.isBuffer(e))if(Array.isArray(e))e=a.from(e);else if("string"==typeof e)e=function(e,t){if("string"!=typeof e||!e.match(/^0x[0-9A-Fa-f]*$/))return!1;if(t&&e.length!==2+2*t)return!1;return!0}(e)?a.from(c(function(e){if("string"!=typeof e)return e;return function(e){if("string"!=typeof e)throw new Error("value must be type 'string', is currently type "+typeof e+", while checking isHexPrefixed.");return"0x"===e.slice(0,2)}(e)?e.slice(2):e}(e)),"hex"):a.from(e);else if("number"==typeof e)e=function(e){const t=function(e){const t=e.toString(16);return`0x${t}`}(e);return a.from(c(t.slice(2)),"hex")}(e);else if(null==e)e=a.allocUnsafe(0);else if(i.default.isBN(e))e=e.toArrayLike(a);else{if(!e.toArray)throw new Error("invalid type");e=a.from(e.toArray())}return e}(e),(0,s.default)("keccak256").update(e).digest()}function c(e){if("string"!=typeof e)throw new Error(`while padding to even, value must be string, is currently ${typeof e}, while padToEven.`);return e.length%2&&(e=`0${e}`),e}"undefined"!=typeof window&&(window.keccak256=u),e.exports=u},829:function(e,t,n){!function(e,t){"use strict";function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function o(e,t,n){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(n=t,t=10),this._init(e||0,t||10,n||"be"))}var s;"object"==typeof e?e.exports=o:t.BN=o,o.BN=o,o.wordSize=26;try{s="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:n(781).Buffer}catch(e){}function a(e,t){var n=e.charCodeAt(t);return n>=48&&n<=57?n-48:n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:void r(!1,"Invalid character in "+e)}function u(e,t,n){var r=a(e,n);return n-1>=t&&(r|=a(e,n-1)<<4),r}function c(e,t,n,i){for(var o=0,s=0,a=Math.min(e.length,n),u=t;u<a;u++){var c=e.charCodeAt(u)-48;o*=i,s=c>=49?c-49+10:c>=17?c-17+10:c,r(c>=0&&s<i,"Invalid character"),o+=s}return o}function l(e,t){e.words=t.words,e.length=t.length,e.negative=t.negative,e.red=t.red}if(o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<e.length&&(16===t?this._parseHex(e,i,n):(this._parseBase(e,t,i),"le"===n&&this._initArray(this.toArray(),t,n)))},o.prototype._initNumber=function(e,t,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),t,n)},o.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===n)for(i=e.length-1,o=0;i>=0;i-=3)s=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i<e.length;i+=3)s=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},o.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var i,o=0,s=0;if("be"===n)for(r=e.length-1;r>=t;r-=2)i=u(e,t,r)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(r=(e.length-t)%2==0?t+1:t;r<e.length;r+=2)i=u(e,t,r)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this._strip()},o.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,i=1;i<=67108863;i*=t)r++;r--,i=i/t|0;for(var o=e.length-n,s=o%r,a=Math.min(o,o-s)+n,u=0,l=n;l<a;l+=r)u=c(e,l,l+r,t),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var h=1;for(u=c(e,l,e.length,t),l=0;l<s;l++)h*=t;this.imuln(h),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},o.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},o.prototype._move=function(e){l(e,this)},o.prototype.clone=function(){var e=new o(null);return this.copy(e),e},o.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=h}catch(e){o.prototype.inspect=h}else o.prototype.inspect=h;function h(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];o.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],u=(16777215&(a<<i|o)).toString(16);o=a>>>24-i&16777215,(i+=2)>=26&&(i-=26,s--),n=0!==o||s!==this.length-1?f[6-u.length]+u+n:u+n}for(0!==o&&(n=o.toString(16)+n);n.length%t!==0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var c=d[e],l=p[e];n="";var h=this.clone();for(h.negative=0;!h.isZero();){var y=h.modrn(l).toString(e);n=(h=h.idivn(l)).isZero()?y+n:f[c-y.length]+y+n}for(this.isZero()&&(n="0"+n);n.length%t!==0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16,2)},s&&(o.prototype.toBuffer=function(e,t){return this.toArrayLike(s,e,t)}),o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};function y(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var i=0|e.words[0],o=0|t.words[0],s=i*o,a=67108863&s,u=s/67108864|0;n.words[0]=a;for(var c=1;c<r;c++){for(var l=u>>>26,h=67108863&u,f=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=f;d++){var p=c-d|0;l+=(s=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&s}n.words[c]=0|h,u=0|l}return 0!==u?n.words[c]=0|u:n.length--,n._strip()}o.prototype.toArrayLike=function(e,t,n){this._strip();var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var s=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,o);return this["_toArrayLike"+("le"===t?"LE":"BE")](s,i),s},o.prototype._toArrayLikeLE=function(e,t){for(var n=0,r=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|r;e[n++]=255&s,n<e.length&&(e[n++]=s>>8&255),n<e.length&&(e[n++]=s>>16&255),6===o?(n<e.length&&(e[n++]=s>>24&255),r=0,o=0):(r=s>>>24,o+=2)}if(n<e.length)for(e[n++]=r;n<e.length;)e[n++]=0},o.prototype._toArrayLikeBE=function(e,t){for(var n=e.length-1,r=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|r;e[n--]=255&s,n>=0&&(e[n--]=s>>8&255),n>=0&&(e[n--]=s>>16&255),6===o?(n>=0&&(e[n--]=s>>24&255),r=0,o=0):(r=s>>>24,o+=2)}if(n>=0)for(e[n--]=r;n>=0;)e[n--]=0},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 8191&t||(n+=13,t>>>=13),127&t||(n+=7,t>>>=7),15&t||(n+=4,t>>>=4),3&t||(n+=2,t>>>=2),1&t||n++,n},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var n=this._zeroBits(this.words[t]);if(e+=n,26!==n)break}return e},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},o.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this._strip()},o.prototype.ior=function(e){return r(0===(this.negative|e.negative)),this.iuor(e)},o.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;n<t.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=t.length,this._strip()},o.prototype.iand=function(e){return r(0===(this.negative|e.negative)),this.iuand(e)},o.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;r<n.length;r++)this.words[r]=t.words[r]^n.words[r];if(this!==t)for(;r<t.length;r++)this.words[r]=t.words[r];return this.length=t.length,this._strip()},o.prototype.ixor=function(e){return r(0===(this.negative|e.negative)),this.iuxor(e)},o.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var i=0;i<t;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this._strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<<i:this.words[n]&~(1<<i),this._strip()},o.prototype.iadd=function(e){var t,n,r;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(n=this,r=e):(n=e,r=this);for(var i=0,o=0;o<r.length;o++)t=(0|n.words[o])+(0|r.words[o])+i,this.words[o]=67108863&t,i=t>>>26;for(;0!==i&&o<n.length;o++)t=(0|n.words[o])+i,this.words[o]=67108863&t,i=t>>>26;if(this.length=n.length,0!==i)this.words[this.length]=i,this.length++;else if(n!==this)for(;o<n.length;o++)this.words[o]=n.words[o];return this},o.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n,r,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(n=this,r=e):(n=e,r=this);for(var o=0,s=0;s<r.length;s++)o=(t=(0|n.words[s])-(0|r.words[s])+o)>>26,this.words[s]=67108863&t;for(;0!==o&&s<n.length;s++)o=(t=(0|n.words[s])+o)>>26,this.words[s]=67108863&t;if(0===o&&s<n.length&&n!==this)for(;s<n.length;s++)this.words[s]=n.words[s];return this.length=Math.max(this.length,s),n!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(e){return this.clone().isub(e)};var m=function(e,t,n){var r,i,o,s=e.words,a=t.words,u=n.words,c=0,l=0|s[0],h=8191&l,f=l>>>13,d=0|s[1],p=8191&d,y=d>>>13,m=0|s[2],g=8191&m,b=m>>>13,v=0|s[3],w=8191&v,E=v>>>13,k=0|s[4],S=8191&k,T=k>>>13,_=0|s[5],O=8191&_,x=_>>>13,I=0|s[6],M=8191&I,C=I>>>13,A=0|s[7],N=8191&A,j=A>>>13,D=0|s[8],R=8191&D,P=D>>>13,B=0|s[9],F=8191&B,L=B>>>13,U=0|a[0],$=8191&U,q=U>>>13,V=0|a[1],z=8191&V,K=V>>>13,W=0|a[2],Q=8191&W,G=W>>>13,H=0|a[3],J=8191&H,Z=H>>>13,Y=0|a[4],X=8191&Y,ee=Y>>>13,te=0|a[5],ne=8191&te,re=te>>>13,ie=0|a[6],oe=8191&ie,se=ie>>>13,ae=0|a[7],ue=8191&ae,ce=ae>>>13,le=0|a[8],he=8191&le,fe=le>>>13,de=0|a[9],pe=8191&de,ye=de>>>13;n.negative=e.negative^t.negative,n.length=19;var me=(c+(r=Math.imul(h,$))|0)+((8191&(i=(i=Math.imul(h,q))+Math.imul(f,$)|0))<<13)|0;c=((o=Math.imul(f,q))+(i>>>13)|0)+(me>>>26)|0,me&=67108863,r=Math.imul(p,$),i=(i=Math.imul(p,q))+Math.imul(y,$)|0,o=Math.imul(y,q);var ge=(c+(r=r+Math.imul(h,z)|0)|0)+((8191&(i=(i=i+Math.imul(h,K)|0)+Math.imul(f,z)|0))<<13)|0;c=((o=o+Math.imul(f,K)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,r=Math.imul(g,$),i=(i=Math.imul(g,q))+Math.imul(b,$)|0,o=Math.imul(b,q),r=r+Math.imul(p,z)|0,i=(i=i+Math.imul(p,K)|0)+Math.imul(y,z)|0,o=o+Math.imul(y,K)|0;var be=(c+(r=r+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,G)|0)+Math.imul(f,Q)|0))<<13)|0;c=((o=o+Math.imul(f,G)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,r=Math.imul(w,$),i=(i=Math.imul(w,q))+Math.imul(E,$)|0,o=Math.imul(E,q),r=r+Math.imul(g,z)|0,i=(i=i+Math.imul(g,K)|0)+Math.imul(b,z)|0,o=o+Math.imul(b,K)|0,r=r+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(y,Q)|0,o=o+Math.imul(y,G)|0;var ve=(c+(r=r+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,Z)|0)+Math.imul(f,J)|0))<<13)|0;c=((o=o+Math.imul(f,Z)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,r=Math.imul(S,$),i=(i=Math.imul(S,q))+Math.imul(T,$)|0,o=Math.imul(T,q),r=r+Math.imul(w,z)|0,i=(i=i+Math.imul(w,K)|0)+Math.imul(E,z)|0,o=o+Math.imul(E,K)|0,r=r+Math.imul(g,Q)|0,i=(i=i+Math.imul(g,G)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,G)|0,r=r+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(y,J)|0,o=o+Math.imul(y,Z)|0;var we=(c+(r=r+Math.imul(h,X)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(f,X)|0))<<13)|0;c=((o=o+Math.imul(f,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,r=Math.imul(O,$),i=(i=Math.imul(O,q))+Math.imul(x,$)|0,o=Math.imul(x,q),r=r+Math.imul(S,z)|0,i=(i=i+Math.imul(S,K)|0)+Math.imul(T,z)|0,o=o+Math.imul(T,K)|0,r=r+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,G)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,G)|0,r=r+Math.imul(g,J)|0,i=(i=i+Math.imul(g,Z)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,Z)|0,r=r+Math.imul(p,X)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(y,X)|0,o=o+Math.imul(y,ee)|0;var Ee=(c+(r=r+Math.imul(h,ne)|0)|0)+((8191&(i=(i=i+Math.imul(h,re)|0)+Math.imul(f,ne)|0))<<13)|0;c=((o=o+Math.imul(f,re)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,r=Math.imul(M,$),i=(i=Math.imul(M,q))+Math.imul(C,$)|0,o=Math.imul(C,q),r=r+Math.imul(O,z)|0,i=(i=i+Math.imul(O,K)|0)+Math.imul(x,z)|0,o=o+Math.imul(x,K)|0,r=r+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,G)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,G)|0,r=r+Math.imul(w,J)|0,i=(i=i+Math.imul(w,Z)|0)+Math.imul(E,J)|0,o=o+Math.imul(E,Z)|0,r=r+Math.imul(g,X)|0,i=(i=i+Math.imul(g,ee)|0)+Math.imul(b,X)|0,o=o+Math.imul(b,ee)|0,r=r+Math.imul(p,ne)|0,i=(i=i+Math.imul(p,re)|0)+Math.imul(y,ne)|0,o=o+Math.imul(y,re)|0;var ke=(c+(r=r+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,se)|0)+Math.imul(f,oe)|0))<<13)|0;c=((o=o+Math.imul(f,se)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,r=Math.imul(N,$),i=(i=Math.imul(N,q))+Math.imul(j,$)|0,o=Math.imul(j,q),r=r+Math.imul(M,z)|0,i=(i=i+Math.imul(M,K)|0)+Math.imul(C,z)|0,o=o+Math.imul(C,K)|0,r=r+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,G)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,G)|0,r=r+Math.imul(S,J)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(T,J)|0,o=o+Math.imul(T,Z)|0,r=r+Math.imul(w,X)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,ee)|0,r=r+Math.imul(g,ne)|0,i=(i=i+Math.imul(g,re)|0)+Math.imul(b,ne)|0,o=o+Math.imul(b,re)|0,r=r+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,se)|0)+Math.imul(y,oe)|0,o=o+Math.imul(y,se)|0;var Se=(c+(r=r+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(f,ue)|0))<<13)|0;c=((o=o+Math.imul(f,ce)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,r=Math.imul(R,$),i=(i=Math.imul(R,q))+Math.imul(P,$)|0,o=Math.imul(P,q),r=r+Math.imul(N,z)|0,i=(i=i+Math.imul(N,K)|0)+Math.imul(j,z)|0,o=o+Math.imul(j,K)|0,r=r+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,G)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,G)|0,r=r+Math.imul(O,J)|0,i=(i=i+Math.imul(O,Z)|0)+Math.imul(x,J)|0,o=o+Math.imul(x,Z)|0,r=r+Math.imul(S,X)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(T,X)|0,o=o+Math.imul(T,ee)|0,r=r+Math.imul(w,ne)|0,i=(i=i+Math.imul(w,re)|0)+Math.imul(E,ne)|0,o=o+Math.imul(E,re)|0,r=r+Math.imul(g,oe)|0,i=(i=i+Math.imul(g,se)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,se)|0,r=r+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(y,ue)|0,o=o+Math.imul(y,ce)|0;var Te=(c+(r=r+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,fe)|0)+Math.imul(f,he)|0))<<13)|0;c=((o=o+Math.imul(f,fe)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,r=Math.imul(F,$),i=(i=Math.imul(F,q))+Math.imul(L,$)|0,o=Math.imul(L,q),r=r+Math.imul(R,z)|0,i=(i=i+Math.imul(R,K)|0)+Math.imul(P,z)|0,o=o+Math.imul(P,K)|0,r=r+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,G)|0)+Math.imul(j,Q)|0,o=o+Math.imul(j,G)|0,r=r+Math.imul(M,J)|0,i=(i=i+Math.imul(M,Z)|0)+Math.imul(C,J)|0,o=o+Math.imul(C,Z)|0,r=r+Math.imul(O,X)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,ee)|0,r=r+Math.imul(S,ne)|0,i=(i=i+Math.imul(S,re)|0)+Math.imul(T,ne)|0,o=o+Math.imul(T,re)|0,r=r+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,se)|0)+Math.imul(E,oe)|0,o=o+Math.imul(E,se)|0,r=r+Math.imul(g,ue)|0,i=(i=i+Math.imul(g,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0,r=r+Math.imul(p,he)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(y,he)|0,o=o+Math.imul(y,fe)|0;var _e=(c+(r=r+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ye)|0)+Math.imul(f,pe)|0))<<13)|0;c=((o=o+Math.imul(f,ye)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,r=Math.imul(F,z),i=(i=Math.imul(F,K))+Math.imul(L,z)|0,o=Math.imul(L,K),r=r+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,G)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,G)|0,r=r+Math.imul(N,J)|0,i=(i=i+Math.imul(N,Z)|0)+Math.imul(j,J)|0,o=o+Math.imul(j,Z)|0,r=r+Math.imul(M,X)|0,i=(i=i+Math.imul(M,ee)|0)+Math.imul(C,X)|0,o=o+Math.imul(C,ee)|0,r=r+Math.imul(O,ne)|0,i=(i=i+Math.imul(O,re)|0)+Math.imul(x,ne)|0,o=o+Math.imul(x,re)|0,r=r+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,se)|0)+Math.imul(T,oe)|0,o=o+Math.imul(T,se)|0,r=r+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(E,ue)|0,o=o+Math.imul(E,ce)|0,r=r+Math.imul(g,he)|0,i=(i=i+Math.imul(g,fe)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,fe)|0;var Oe=(c+(r=r+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ye)|0)+Math.imul(y,pe)|0))<<13)|0;c=((o=o+Math.imul(y,ye)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,r=Math.imul(F,Q),i=(i=Math.imul(F,G))+Math.imul(L,Q)|0,o=Math.imul(L,G),r=r+Math.imul(R,J)|0,i=(i=i+Math.imul(R,Z)|0)+Math.imul(P,J)|0,o=o+Math.imul(P,Z)|0,r=r+Math.imul(N,X)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(j,X)|0,o=o+Math.imul(j,ee)|0,r=r+Math.imul(M,ne)|0,i=(i=i+Math.imul(M,re)|0)+Math.imul(C,ne)|0,o=o+Math.imul(C,re)|0,r=r+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,se)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,se)|0,r=r+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(T,ue)|0,o=o+Math.imul(T,ce)|0,r=r+Math.imul(w,he)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(E,he)|0,o=o+Math.imul(E,fe)|0;var xe=(c+(r=r+Math.imul(g,pe)|0)|0)+((8191&(i=(i=i+Math.imul(g,ye)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,ye)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,r=Math.imul(F,J),i=(i=Math.imul(F,Z))+Math.imul(L,J)|0,o=Math.imul(L,Z),r=r+Math.imul(R,X)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,ee)|0,r=r+Math.imul(N,ne)|0,i=(i=i+Math.imul(N,re)|0)+Math.imul(j,ne)|0,o=o+Math.imul(j,re)|0,r=r+Math.imul(M,oe)|0,i=(i=i+Math.imul(M,se)|0)+Math.imul(C,oe)|0,o=o+Math.imul(C,se)|0,r=r+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,r=r+Math.imul(S,he)|0,i=(i=i+Math.imul(S,fe)|0)+Math.imul(T,he)|0,o=o+Math.imul(T,fe)|0;var Ie=(c+(r=r+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ye)|0)+Math.imul(E,pe)|0))<<13)|0;c=((o=o+Math.imul(E,ye)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,r=Math.imul(F,X),i=(i=Math.imul(F,ee))+Math.imul(L,X)|0,o=Math.imul(L,ee),r=r+Math.imul(R,ne)|0,i=(i=i+Math.imul(R,re)|0)+Math.imul(P,ne)|0,o=o+Math.imul(P,re)|0,r=r+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,se)|0)+Math.imul(j,oe)|0,o=o+Math.imul(j,se)|0,r=r+Math.imul(M,ue)|0,i=(i=i+Math.imul(M,ce)|0)+Math.imul(C,ue)|0,o=o+Math.imul(C,ce)|0,r=r+Math.imul(O,he)|0,i=(i=i+Math.imul(O,fe)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,fe)|0;var Me=(c+(r=r+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ye)|0)+Math.imul(T,pe)|0))<<13)|0;c=((o=o+Math.imul(T,ye)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,r=Math.imul(F,ne),i=(i=Math.imul(F,re))+Math.imul(L,ne)|0,o=Math.imul(L,re),r=r+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,se)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,se)|0,r=r+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(j,ue)|0,o=o+Math.imul(j,ce)|0,r=r+Math.imul(M,he)|0,i=(i=i+Math.imul(M,fe)|0)+Math.imul(C,he)|0,o=o+Math.imul(C,fe)|0;var Ce=(c+(r=r+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,ye)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,ye)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,r=Math.imul(F,oe),i=(i=Math.imul(F,se))+Math.imul(L,oe)|0,o=Math.imul(L,se),r=r+Math.imul(R,ue)|0,i=(i=i+Math.imul(R,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,r=r+Math.imul(N,he)|0,i=(i=i+Math.imul(N,fe)|0)+Math.imul(j,he)|0,o=o+Math.imul(j,fe)|0;var Ae=(c+(r=r+Math.imul(M,pe)|0)|0)+((8191&(i=(i=i+Math.imul(M,ye)|0)+Math.imul(C,pe)|0))<<13)|0;c=((o=o+Math.imul(C,ye)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,r=Math.imul(F,ue),i=(i=Math.imul(F,ce))+Math.imul(L,ue)|0,o=Math.imul(L,ce),r=r+Math.imul(R,he)|0,i=(i=i+Math.imul(R,fe)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,fe)|0;var Ne=(c+(r=r+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,ye)|0)+Math.imul(j,pe)|0))<<13)|0;c=((o=o+Math.imul(j,ye)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,r=Math.imul(F,he),i=(i=Math.imul(F,fe))+Math.imul(L,he)|0,o=Math.imul(L,fe);var je=(c+(r=r+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,ye)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,ye)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863;var De=(c+(r=Math.imul(F,pe))|0)+((8191&(i=(i=Math.imul(F,ye))+Math.imul(L,pe)|0))<<13)|0;return c=((o=Math.imul(L,ye))+(i>>>13)|0)+(De>>>26)|0,De&=67108863,u[0]=me,u[1]=ge,u[2]=be,u[3]=ve,u[4]=we,u[5]=Ee,u[6]=ke,u[7]=Se,u[8]=Te,u[9]=_e,u[10]=Oe,u[11]=xe,u[12]=Ie,u[13]=Me,u[14]=Ce,u[15]=Ae,u[16]=Ne,u[17]=je,u[18]=De,0!==c&&(u[19]=c,n.length++),n};function g(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,i=0,o=0;o<n.length-1;o++){var s=i;i=0;for(var a=67108863&r,u=Math.min(o,t.length-1),c=Math.max(0,o-e.length+1);c<=u;c++){var l=o-c,h=(0|e.words[l])*(0|t.words[c]),f=67108863&h;a=67108863&(f=f+a|0),i+=(s=(s=s+(h/67108864|0)|0)+(f>>>26)|0)>>>26,s&=67108863}n.words[o]=a,r=s,s=i}return 0!==r?n.words[o]=r:n.length--,n._strip()}function b(e,t,n){return g(e,t,n)}function v(e,t){this.x=e,this.y=t}Math.imul||(m=y),o.prototype.mulTo=function(e,t){var n=this.length+e.length;return 10===this.length&&10===e.length?m(this,e,t):n<63?y(this,e,t):n<1024?g(this,e,t):b(this,e,t)},v.prototype.makeRBT=function(e){for(var t=new Array(e),n=o.prototype._countBits(e)-1,r=0;r<e;r++)t[r]=this.revBin(r,n,e);return t},v.prototype.revBin=function(e,t,n){if(0===e||e===n-1)return e;for(var r=0,i=0;i<t;i++)r|=(1&e)<<t-i-1,e>>=1;return r},v.prototype.permute=function(e,t,n,r,i,o){for(var s=0;s<o;s++)r[s]=t[e[s]],i[s]=n[e[s]]},v.prototype.transform=function(e,t,n,r,i,o){this.permute(o,e,t,n,r,i);for(var s=1;s<i;s<<=1)for(var a=s<<1,u=Math.cos(2*Math.PI/a),c=Math.sin(2*Math.PI/a),l=0;l<i;l+=a)for(var h=u,f=c,d=0;d<s;d++){var p=n[l+d],y=r[l+d],m=n[l+d+s],g=r[l+d+s],b=h*m-f*g;g=h*g+f*m,m=b,n[l+d]=p+m,r[l+d]=y+g,n[l+d+s]=p-m,r[l+d+s]=y-g,d!==a&&(b=u*h-c*f,f=u*f+c*h,h=b)}},v.prototype.guessLen13b=function(e,t){var n=1|Math.max(t,e),r=1&n,i=0;for(n=n/2|0;n;n>>>=1)i++;return 1<<i+1+r},v.prototype.conjugate=function(e,t,n){if(!(n<=1))for(var r=0;r<n/2;r++){var i=e[r];e[r]=e[n-r-1],e[n-r-1]=i,i=t[r],t[r]=-t[n-r-1],t[n-r-1]=-i}},v.prototype.normalize13b=function(e,t){for(var n=0,r=0;r<t/2;r++){var i=8192*Math.round(e[2*r+1]/t)+Math.round(e[2*r]/t)+n;e[r]=67108863&i,n=i<67108864?0:i/67108864|0}return e},v.prototype.convert13b=function(e,t,n,i){for(var o=0,s=0;s<t;s++)o+=0|e[s],n[2*s]=8191&o,o>>>=13,n[2*s+1]=8191&o,o>>>=13;for(s=2*t;s<i;++s)n[s]=0;r(0===o),r(!(-8192&o))},v.prototype.stub=function(e){for(var t=new Array(e),n=0;n<e;n++)t[n]=0;return t},v.prototype.mulp=function(e,t,n){var r=2*this.guessLen13b(e.length,t.length),i=this.makeRBT(r),o=this.stub(r),s=new Array(r),a=new Array(r),u=new Array(r),c=new Array(r),l=new Array(r),h=new Array(r),f=n.words;f.length=r,this.convert13b(e.words,e.length,s,r),this.convert13b(t.words,t.length,c,r),this.transform(s,o,a,u,r,i),this.transform(c,o,l,h,r,i);for(var d=0;d<r;d++){var p=a[d]*l[d]-u[d]*h[d];u[d]=a[d]*h[d]+u[d]*l[d],a[d]=p}return this.conjugate(a,u,r),this.transform(a,u,f,o,r,i),this.conjugate(f,o,r),this.normalize13b(f,r),n.negative=e.negative^t.negative,n.length=e.length+t.length,n._strip()},o.prototype.mul=function(e){var t=new o(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},o.prototype.mulf=function(e){var t=new o(null);return t.words=new Array(this.length+e.length),b(this,e,t)},o.prototype.imul=function(e){return this.clone().mulTo(e,this)},o.prototype.imuln=function(e){var t=e<0;t&&(e=-e),r("number"==typeof e),r(e<67108864);for(var n=0,i=0;i<this.length;i++){var o=(0|this.words[i])*e,s=(67108863&o)+(67108863&n);n>>=26,n+=o/67108864|0,n+=s>>>26,this.words[i]=67108863&s}return 0!==n&&(this.words[i]=n,this.length++),this.length=0===e?1:this.length,t?this.ineg():this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),n=0;n<t.length;n++){var r=n/26|0,i=n%26;t[n]=e.words[r]>>>i&1}return t}(e);if(0===t.length)return new o(1);for(var n=this,r=0;r<t.length&&0===t[r];r++,n=n.sqr());if(++r<t.length)for(var i=n.sqr();r<t.length;r++,i=i.sqr())0!==t[r]&&(n=n.mul(i));return n},o.prototype.iushln=function(e){r("number"==typeof e&&e>=0);var t,n=e%26,i=(e-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(t=0;t<this.length;t++){var a=this.words[t]&o,u=(0|this.words[t])-a<<n;this.words[t]=u|s,s=a>>>26-n}s&&(this.words[t]=s,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t<i;t++)this.words[t]=0;this.length+=i}return this._strip()},o.prototype.ishln=function(e){return r(0===this.negative),this.iushln(e)},o.prototype.iushrn=function(e,t,n){var i;r("number"==typeof e&&e>=0),i=t?(t-t%26)/26:0;var o=e%26,s=Math.min((e-o)/26,this.length),a=67108863^67108863>>>o<<o,u=n;if(i-=s,i=Math.max(0,i),u){for(var c=0;c<s;c++)u.words[c]=this.words[c];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,c=0;c<this.length;c++)this.words[c]=this.words[c+s];else this.words[0]=0,this.length=1;var l=0;for(c=this.length-1;c>=0&&(0!==l||c>=i);c--){var h=0|this.words[c];this.words[c]=l<<26-o|h>>>o,l=h&a}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,i=1<<t;return!(this.length<=n)&&!!(this.words[n]&i)},o.prototype.imaskn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var i=67108863^67108863>>>t<<t;this.words[this.length-1]&=i}return this._strip()},o.prototype.maskn=function(e){return this.clone().imaskn(e)},o.prototype.iaddn=function(e){return r("number"==typeof e),r(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<=e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},o.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(r("number"==typeof e),r(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this._strip()},o.prototype.addn=function(e){return this.clone().iaddn(e)},o.prototype.subn=function(e){return this.clone().isubn(e)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(e,t,n){var i,o,s=e.length+n;this._expand(s);var a=0;for(i=0;i<e.length;i++){o=(0|this.words[i+n])+a;var u=(0|e.words[i])*t;a=((o-=67108863&u)>>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this._strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},o.prototype._wordDiv=function(e,t){var n=(this.length,e.length),r=this.clone(),i=e,s=0|i.words[i.length-1];0!==(n=26-this._countBits(s))&&(i=i.ushln(n),r.iushln(n),s=0|i.words[i.length-1]);var a,u=r.length-i.length;if("mod"!==t){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c<a.length;c++)a.words[c]=0}var l=r.clone()._ishlnsubmul(i,1,u);0===l.negative&&(r=l,a&&(a.words[u]=1));for(var h=u-1;h>=0;h--){var f=67108864*(0|r.words[i.length+h])+(0|r.words[i.length+h-1]);for(f=Math.min(f/s|0,67108863),r._ishlnsubmul(i,f,h);0!==r.negative;)f--,r.negative=0,r._ishlnsubmul(i,1,h),r.isZero()||(r.negative^=1);a&&(a.words[h]=f)}return a&&a._strip(),r._strip(),"div"!==t&&0!==n&&r.iushrn(n),{div:a||null,mod:r}},o.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(i=a.div.neg()),"div"!==t&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(e)),{div:i,mod:s}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(i=a.div.neg()),{div:i,mod:a.mod}):0!==(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(e)),{div:a.div,mod:s}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modrn(e.words[0]))}:this._wordDiv(e,t);var i,s,a},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),i=e.andln(1),o=n.cmp(r);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modrn=function(e){var t=e<0;t&&(e=-e),r(e<=67108863);for(var n=(1<<26)%e,i=0,o=this.length-1;o>=0;o--)i=(n*i+(0|this.words[o]))%e;return t?-i:i},o.prototype.modn=function(e){return this.modrn(e)},o.prototype.idivn=function(e){var t=e<0;t&&(e=-e),r(e<=67108863);for(var n=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*n;this.words[i]=o/e|0,n=o%e}return this._strip(),t?this.ineg():this},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),s=new o(0),a=new o(0),u=new o(1),c=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++c;for(var l=n.clone(),h=t.clone();!t.isZero();){for(var f=0,d=1;0===(t.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(l),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,y=1;0===(n.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(l),u.isub(h)),a.iushrn(1),u.iushrn(1);t.cmp(n)>=0?(t.isub(n),i.isub(a),s.isub(u)):(n.isub(t),a.isub(i),u.isub(s))}return{a,b:u,gcd:n.iushln(c)}},o.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,s=new o(1),a=new o(0),u=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var c=0,l=1;0===(t.words[0]&l)&&c<26;++c,l<<=1);if(c>0)for(t.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var h=0,f=1;0===(n.words[0]&f)&&h<26;++h,f<<=1);if(h>0)for(n.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);t.cmp(n)>=0?(t.isub(n),s.isub(a)):(n.isub(t),a.isub(s))}return(i=0===t.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var i=t.cmp(n);if(i<0){var o=t;t=n,n=o}else if(0===i||0===n.cmpn(1))break;t.isub(n)}return n.iushln(r)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return!(1&this.words[0])},o.prototype.isOdd=function(){return!(1&~this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,i=1<<t;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:i<e?-1:1}return 0!==this.negative?0|-t:t},o.prototype.cmp=function(e){if(0!==this.negative&&0===e.negative)return-1;if(0===this.negative&&0!==e.negative)return 1;var t=this.ucmp(e);return 0!==this.negative?0|-t:t},o.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,n=this.length-1;n>=0;n--){var r=0|this.words[n],i=0|e.words[n];if(r!==i){r<i?t=-1:r>i&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new O(e)},o.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var w={k256:null,p224:null,p192:null,p25519:null};function E(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function k(){E.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function S(){E.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function T(){E.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){E.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function O(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function x(e){O.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}E.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},E.prototype.ireduce=function(e){var t,n=e;do{this.split(n,this.tmp),t=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t<this.n?-1:n.ucmp(this.p);return 0===r?(n.words[0]=0,n.length=1):r>0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},E.prototype.split=function(e,t){e.iushrn(this.n,0,t)},E.prototype.imulK=function(e){return e.imul(this.k)},i(k,E),k.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),i=0;i<r;i++)t.words[i]=e.words[i];if(t.length=r,e.length<=9)return e.words[0]=0,void(e.length=1);var o=e.words[9];for(t.words[t.length++]=o&n,i=10;i<e.length;i++){var s=0|e.words[i];e.words[i-10]=(s&n)<<4|o>>>22,o=s}o>>>=22,e.words[i-10]=o,0===o&&e.length>10?e.length-=10:e.length-=9},k.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n<e.length;n++){var r=0|e.words[n];t+=977*r,e.words[n]=67108863&t,t=64*r+(t/67108864|0)}return 0===e.words[e.length-1]&&(e.length--,0===e.words[e.length-1]&&e.length--),e},i(S,E),i(T,E),i(_,E),_.prototype.imulK=function(e){for(var t=0,n=0;n<e.length;n++){var r=19*(0|e.words[n])+t,i=67108863&r;r>>>=26,e.words[n]=i,t=r}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(w[e])return w[e];var t;if("k256"===e)t=new k;else if("p224"===e)t=new S;else if("p192"===e)t=new T;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return w[e]=t,t},O.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},O.prototype._verify2=function(e,t){r(0===(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},O.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(l(e,e.umod(this.m)._forceRed(this)),e)},O.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},O.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},O.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},O.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},O.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},O.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},O.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},O.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},O.prototype.isqr=function(e){return this.imul(e,e.clone())},O.prototype.sqr=function(e){return this.mul(e,e)},O.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new o(1)).iushrn(2);return this.pow(e,n)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);r(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new o(2*l*l).toRed(this);0!==this.pow(l,c).cmp(u);)l.redIAdd(u);for(var h=this.pow(l,i),f=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=s;0!==d.cmp(a);){for(var y=d,m=0;0!==y.cmp(a);m++)y=y.redSqr();r(m<p);var g=this.pow(h,new o(1).iushln(p-m-1));f=f.redMul(g),h=g.redSqr(),d=d.redMul(h),p=m}return f},O.prototype.invm=function(e){var t=e._invmp(this.m);return 0!==t.negative?(t.negative=0,this.imod(t).redNeg()):this.imod(t)},O.prototype.pow=function(e,t){if(t.isZero())return new o(1).toRed(this);if(0===t.cmpn(1))return e.clone();var n=new Array(16);n[0]=new o(1).toRed(this),n[1]=e;for(var r=2;r<n.length;r++)n[r]=this.mul(n[r-1],e);var i=n[0],s=0,a=0,u=t.bitLength()%26;for(0===u&&(u=26),r=t.length-1;r>=0;r--){for(var c=t.words[r],l=u-1;l>=0;l--){var h=c>>l&1;i!==n[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===r&&0===l)&&(i=this.mul(i,n[s]),a=0,s=0)):a=0}u=26}return i},O.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},O.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new x(e)},i(x,O),x.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},x.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},x.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},x.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},x.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=n.nmd(e),this)},876:(e,t,n)=>{e.exports=n(928)(n(217))},917:e=>{"use strict";function t(e,t){r(e,t),n(e)}function n(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function r(e,t){e.emit("error",t)}e.exports={destroy:function(e,i){var o=this,s=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return s||a?(i?i(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(r,this,e)):process.nextTick(r,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!i&&e?o._writableState?o._writableState.errorEmitted?process.nextTick(n,o):(o._writableState.errorEmitted=!0,process.nextTick(t,o,e)):process.nextTick(t,o,e):i?(process.nextTick(n,o),i(e)):process.nextTick(n,o)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}}},918:e=>{e.exports=function(){throw new Error("Readable.from is not available in the browser")}},928:(e,t,n)=>{const r=n(316),i=n(102);e.exports=function(e){const t=r(e),n=i(e);return function(e,r){switch("string"==typeof e?e.toLowerCase():e){case"keccak224":return new t(1152,448,null,224,r);case"keccak256":return new t(1088,512,null,256,r);case"keccak384":return new t(832,768,null,384,r);case"keccak512":return new t(576,1024,null,512,r);case"sha3-224":return new t(1152,448,6,224,r);case"sha3-256":return new t(1088,512,6,256,r);case"sha3-384":return new t(832,768,6,384,r);case"sha3-512":return new t(576,1024,6,512,r);case"shake128":return new n(1344,256,31,r);case"shake256":return new n(1088,512,31,r);default:throw new Error("Invald algorithm: "+e)}}}},933:(e,t)=>{"use strict";t.byteLength=function(e){var t=a(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,o=a(e),s=o[0],u=o[1],c=new i(function(e,t,n){return 3*(t+n)/4-n}(0,s,u)),l=0,h=u>0?s-4:s;for(n=0;n<h;n+=4)t=r[e.charCodeAt(n)]<<18|r[e.charCodeAt(n+1)]<<12|r[e.charCodeAt(n+2)]<<6|r[e.charCodeAt(n+3)],c[l++]=t>>16&255,c[l++]=t>>8&255,c[l++]=255&t;2===u&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,c[l++]=255&t);1===u&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t);return c},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=16383,a=0,u=r-i;a<u;a+=s)o.push(c(e,a,a+s>u?u:a+s));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)n[s]=o[s],r[o.charCodeAt(s)]=s;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function u(e){return n[e>>18&63]+n[e>>12&63]+n[e>>6&63]+n[63&e]}function c(e,t,n){for(var r,i=[],o=t;o<n;o+=3)r=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),i.push(u(r));return i.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},947:(e,t,n)=>{function r(e){try{if(!n.g.localStorage)return!1}catch(e){return!1}var t=n.g.localStorage[e];return null!=t&&"true"===String(t).toLowerCase()}e.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var r={};return(()=>{"use strict";n.r(r),n.d(r,{createClient:()=>Ew,createClientWithValidation:()=>Tw,isNetworkType:()=>kw,validateClientConfig:()=>Sw});var e=n(787);function t(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}const i=8192;function o(e){if(e.length<i)return btoa(String.fromCharCode(...e));let t="";for(var n=0;n<e.length;n+=i){const r=e.slice(n,n+i);t+=String.fromCharCode(...r)}return btoa(t)}function s(e){const t=e.startsWith("0x")?e.slice(2):e,n=t.length%2==0?t:`0${t}`,r=n.match(/[0-9a-fA-F]{2}/g)?.map(e=>parseInt(e,16))??[];if(r.length!==n.length/2)throw new Error(`Invalid hex string ${e}`);return Uint8Array.from(r)}function a(e){return e.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),"")}function u(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function c(e,...t){if(!u(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function l(e,t){return!!Array.isArray(t)&&(0===t.length||(e?t.every(e=>"string"==typeof e):t.every(e=>Number.isSafeInteger(e))))}function h(e){if("function"!=typeof e)throw new Error("function expected");return!0}function f(e,t){if("string"!=typeof t)throw new Error(`${e}: string expected`);return!0}function d(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function p(e){if(!Array.isArray(e))throw new Error("array expected")}function y(e,t){if(!l(!0,t))throw new Error(`${e}: array of strings expected`)}function m(e,t){if(!l(!1,t))throw new Error(`${e}: array of numbers expected`)}function g(...e){const t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map(e=>e.encode).reduceRight(n,t),decode:e.map(e=>e.decode).reduce(n,t)}}function b(e){const t="string"==typeof e?e.split(""):e,n=t.length;y("alphabet",t);const r=new Map(t.map((e,t)=>[e,t]));return{encode:r=>(p(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${e}`);return t[r]})),decode:t=>(p(t),t.map(t=>{f("alphabet.decode",t);const n=r.get(t);if(void 0===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}function v(e=""){return f("join",e),{encode:t=>(y("join.decode",t),t.join(e)),decode:t=>(f("join.decode",t),t.split(e))}}function w(e,t="="){return d(e),f("padding",t),{encode(n){for(y("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){y("padding.decode",n);let r=n.length;if(r*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--){if((r-1)*e%8==0)throw new Error("padding: invalid, string has too much padding")}return n.slice(0,r)}}}function E(e){return h(e),{encode:e=>e,decode:t=>e(t)}}function k(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(p(e),!e.length)return[];let r=0;const i=[],o=Array.from(e,e=>{if(d(e),e<0||e>=t)throw new Error(`invalid integer: ${e}`);return e}),s=o.length;for(;;){let e=0,a=!0;for(let i=r;i<s;i++){const s=o[i],u=t*e,c=u+s;if(!Number.isSafeInteger(c)||u/t!==e||c-s!==u)throw new Error("convertRadix: carry overflow");const l=c/n;e=c%n;const h=Math.floor(l);if(o[i]=h,!Number.isSafeInteger(h)||h*n+e!==c)throw new Error("convertRadix: carry overflow");a&&(h?a=!1:r=i)}if(i.push(e),a)break}for(let t=0;t<e.length-1&&0===e[t];t++)i.push(0);return i.reverse()}const S=(e,t)=>0===t?e:S(t,e%t),T=(e,t)=>e+(t-S(e,t)),_=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function O(e,t,n,r){if(p(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(T(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${T(t,n)}`);let i=0,o=0;const s=_[t],a=_[n]-1,u=[];for(const r of e){if(d(r),r>=s)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(i=i<<t|r,o+t>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=n;o-=n)u.push((i>>o-n&a)>>>0);const e=_[o];if(void 0===e)throw new Error("invalid carry");i&=e-1}if(i=i<<n-o&a,!r&&o>=t)throw new Error("Excess padding");if(!r&&i>0)throw new Error(`Non-zero padding: ${i}`);return r&&o>0&&u.push(i>>>0),u}function x(e){d(e);return{encode:t=>{if(!u(t))throw new Error("radix.encode input should be Uint8Array");return k(Array.from(t),256,e)},decode:t=>(m("radix.decode",t),Uint8Array.from(k(t,e,256)))}}function I(e,t=!1){if(d(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(T(8,e)>32||T(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!u(n))throw new Error("radix2.encode input should be Uint8Array");return O(Array.from(n),8,e,!t)},decode:n=>(m("radix2.decode",n),Uint8Array.from(O(n,e,8,t)))}}function M(e){return h(e),function(...t){try{return e.apply(null,t)}catch(e){}}}function C(e,t){return d(e),h(t),{encode(n){if(!u(n))throw new Error("checksum.encode: input should be Uint8Array");const r=t(n).slice(0,e),i=new Uint8Array(n.length+e);return i.set(n),i.set(r,n.length),i},decode(n){if(!u(n))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-e),i=n.slice(-e),o=t(r).slice(0,e);for(let t=0;t<e;t++)if(o[t]!==i[t])throw new Error("Invalid checksum");return r}}}const A={alphabet:b,chain:g,checksum:C,convertRadix:k,convertRadix2:O,radix:x,radix2:I,join:v,padding:w},N=g(I(4),b("0123456789ABCDEF"),v("")),j=g(I(5),b("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),w(5),v("")),D=(g(I(5),b("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),v("")),g(I(5),b("0123456789ABCDEFGHIJKLMNOPQRSTUV"),w(5),v("")),g(I(5),b("0123456789ABCDEFGHIJKLMNOPQRSTUV"),v("")),g(I(5),b("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),v(""),E(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)()),R=(e,t)=>{f("base64",e);const n=t?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,r=t?"base64url":"base64";if(e.length>0&&!n.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},P=D?{encode:e=>(c(e),e.toBase64()),decode:e=>R(e,!1)}:g(I(6),b("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),w(6),v("")),B=(g(I(6),b("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),v("")),D?{encode:e=>(c(e),e.toBase64({alphabet:"base64url"})),decode:e=>R(e,!0)}:g(I(6),b("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),w(6),v(""))),F=(g(I(6),b("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),v("")),e=>g(x(58),b(e),v(""))),L=F("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),U=(F("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),F("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"),[0,2,3,5,6,7,9,10,11]),$={encode(e){let t="";for(let n=0;n<e.length;n+=8){const r=e.subarray(n,n+8);t+=L.encode(r).padStart(U[r.length],"1")}return t},decode(e){let t=[];for(let n=0;n<e.length;n+=11){const r=e.slice(n,n+11),i=U.indexOf(r.length),o=L.decode(r);for(let e=0;e<o.length-i;e++)if(0!==o[e])throw new Error("base58xmr: wrong padding");t=t.concat(Array.from(o.slice(o.length-i)))}return Uint8Array.from(t)}},q=g(b("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),v("")),V=[996825010,642813549,513874426,1027748829,705979059];function z(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e<V.length;e++)1==(t>>e&1)&&(n^=V[e]);return n}function K(e,t,n=1){const r=e.length;let i=1;for(let t=0;t<r;t++){const n=e.charCodeAt(t);if(n<33||n>126)throw new Error(`Invalid prefix (${e})`);i=z(i)^n>>5}i=z(i);for(let t=0;t<r;t++)i=z(i)^31&e.charCodeAt(t);for(let e of t)i=z(i)^e;for(let e=0;e<6;e++)i=z(i);return i^=n,q.encode(O([i%_[30]],30,5,!1))}function W(e){const t="bech32"===e?1:734539939,n=I(5),r=n.decode,i=n.encode,o=M(r);function s(e,n,r=90){f("bech32.encode prefix",e),u(n)&&(n=Array.from(n)),m("bech32.encode",n);const i=e.length;if(0===i)throw new TypeError(`Invalid prefix length ${i}`);const o=i+7+n.length;if(!1!==r&&o>r)throw new TypeError(`Length ${o} exceeds limit ${r}`);const s=e.toLowerCase(),a=K(s,n,t);return`${s}1${q.encode(n)}${a}`}function a(e,n=90){f("bech32.decode input",e);const r=e.length;if(r<8||!1!==n&&r>n)throw new TypeError(`invalid string length: ${r} (${e}). Expected (8..${n})`);const i=e.toLowerCase();if(e!==i&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=i.lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const s=i.slice(0,o),a=i.slice(o+1);if(a.length<6)throw new Error("Data must be at least 6 characters long");const u=q.decode(a).slice(0,-6),c=K(s,u,t);if(!a.endsWith(c))throw new Error(`Invalid checksum in ${e}: expected "${c}"`);return{prefix:s,words:u}}return{encode:s,decode:a,encodeFromBytes:function(e,t){return s(e,i(t))},decodeToBytes:function(e){const{prefix:t,words:n}=a(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:M(a),fromWords:r,fromWordsUnsafe:o,toWords:i}}const Q=W("bech32"),G=(W("bech32m"),{encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)}),H=((()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)()||g(I(4),b("0123456789abcdef"),v(""),E(e=>{if("string"!=typeof e||e.length%2!=0)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})),e=>L.encode(e)),J=e=>L.decode(e);function Z(e){const t=[];let n=0;if(0===e)return[0];for(;e>0;)t[n]=127&e,(e>>=7)&&(t[n]|=128),n+=1;return t}class Y{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength)}shift(e){return this.bytePosition+=e,this}read8(){const e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){const e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){const e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){const e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){const e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){const e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){const t=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),n}readULEB(){const e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:n,length:r}=function(e){let t=0,n=0,r=0;for(;;){const i=e[r];if(r+=1,t|=(127&i)<<n,!(128&i))break;n+=7}return{value:t,length:r}}(t);return this.shift(r),n}readVec(e){const t=this.readULEB(),n=[];for(let r=0;r<t;r++)n.push(e(this,r,t));return n}}function X(e,t=["<",">"]){const[n,r]=t,i=[];let o="",s=0;for(let t=0;t<e.length;t++){const a=e[t];a===n&&s++,a===r&&s--,0!==s||","!==a?o+=a:(i.push(o.trim()),o="")}return i.push(o.trim()),i}class ee{constructor({initialSize:e=1024,maxSize:t=1/0,allocateSize:n=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t,this.allocateSize=n,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const n=new ArrayBuffer(this.size);new Uint8Array(n).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(n)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return te(BigInt(e),8).forEach(e=>this.write8(e)),this}write128(e){return te(BigInt(e),16).forEach(e=>this.write8(e)),this}write256(e){return te(BigInt(e),32).forEach(e=>this.write8(e)),this}writeULEB(e){return Z(e).forEach(e=>this.write8(e)),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach((n,r)=>t(this,n,r,e.length)),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return H(e);case"base64":return o(e);case"hex":return a(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function te(e,t){const n=new Uint8Array(t);let r=0;for(;e>0;)n[r]=Number(e%BigInt(256)),e/=BigInt(256),r+=1;return n}var ne,re,ie,oe,se=e=>{throw TypeError(e)},ae=(e,t,n)=>t.has(e)||se("Cannot "+n),ue=(e,t,n)=>(ae(e,t,"read from private field"),n?n.call(e):t.get(e)),ce=(e,t,n)=>t.has(e)?se("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),le=(e,t,n,r)=>(ae(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);ne=new WeakMap,re=new WeakMap;let he=class e{constructor(e){ce(this,ne),ce(this,re),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),le(this,ne,e.write),le(this,re,e.serialize??((e,t)=>{const n=new ee({initialSize:this.serializedSize(e)??void 0,...t});return ue(this,ne).call(this,e,n),n.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),ue(this,ne).call(this,e,t)}serialize(e,t){return this.validate(e),new pe(this,ue(this,re).call(this,e,t))}parse(e){const t=new Y(e);return this.read(t)}fromHex(e){return this.parse(s(e))}fromBase58(e){return this.parse(J(e))}fromBase64(e){return this.parse(t(e))}transform({name:t,input:n,output:r,validate:i}){return new e({name:t??this.name,read:e=>r?r(this.read(e)):this.read(e),write:(e,t)=>ue(this,ne).call(this,n?n(e):e,t),serializedSize:e=>this.serializedSize(n?n(e):e),serialize:(e,t)=>ue(this,re).call(this,n?n(e):e,t),validate:e=>{i?.(e),this.validate(n?n(e):e)}})}};const fe=Symbol.for("@mysten/serialized-bcs");function de(e){return!!e&&"object"==typeof e&&!0===e[fe]}class pe{constructor(e,t){ce(this,ie),ce(this,oe),le(this,ie,e),le(this,oe,t)}get[fe](){return!0}toBytes(){return ue(this,oe)}toHex(){return a(ue(this,oe))}toBase64(){return o(ue(this,oe))}toBase58(){return H(ue(this,oe))}parse(){return ue(this,ie).parse(ue(this,oe))}}function ye({size:e,...t}){return new he({...t,serializedSize:()=>e})}function me({readMethod:e,writeMethod:t,...n}){return ye({...n,read:t=>t[e](),write:(e,n)=>n[t](e),validate:e=>{if(e<0||e>n.maxValue)throw new TypeError(`Invalid ${n.name} value: ${e}. Expected value in range 0-${n.maxValue}`);n.validate?.(e)}})}function ge({readMethod:e,writeMethod:t,...n}){return ye({...n,read:t=>t[e](),write:(e,n)=>n[t](BigInt(e)),validate:e=>{const t=BigInt(e);if(t<0||t>n.maxValue)throw new TypeError(`Invalid ${n.name} value: ${t}. Expected value in range 0-${n.maxValue}`);n.validate?.(t)}})}ie=new WeakMap,oe=new WeakMap;var be,ve,we,Ee;function ke(e){return{lang:e?.lang??be?.lang,message:e?.message,abortEarly:e?.abortEarly??be?.abortEarly,abortPipeEarly:e?.abortPipeEarly??be?.abortPipeEarly}}function Se(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function Te(e,t,n,r,i){const o=i&&"input"in i?i.input:n.value,s=i?.expected??e.expects??null,a=i?.received??Se(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},c="schema"===e.kind,l=i?.message??e.message??(h=e.reference,f=u.lang,Ee?.get(h)?.get(f))??(c?function(e){return we?.get(e)}(u.lang):null)??r.message??function(e){return ve?.get(e)}(u.lang);var h,f;l&&(u.message="function"==typeof l?l(u):l),c&&(n.typed=!1),n.issues?n.issues.push(u):n.issues=[u]}function _e(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}var Oe=class extends Error{issues;constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function xe(e,t){return{kind:"validation",type:"check",reference:xe,async:!1,expects:null,requirement:e,message:t,_run(e,t){return e.typed&&!this.requirement(e.value)&&Te(this,"input",e,t),e}}}function Ie(e){return{kind:"validation",type:"integer",reference:Ie,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(e,t){return e.typed&&!this.requirement(e.value)&&Te(this,"integer",e,t),e}}}function Me(e){return{kind:"transformation",type:"transform",reference:Me,async:!1,operation:e,_run(e){return e.value=this.operation(e.value),e}}}function Ce(e,t,n){return"function"==typeof e.default?e.default(t,n):e.default}function Ae(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function Ne(e,t){return{kind:"schema",type:"array",reference:Ne,expects:"Array",async:!1,item:e,message:t,_run(e,t){const n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){const i=n[r],o=this.item._run({typed:!1,value:i},t);if(o.issues){const s={type:"array",origin:"value",input:n,key:r,value:i};for(const t of o.issues)t.path?t.path.unshift(s):t.path=[s],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value.push(o.value)}}else Te(this,"type",e,t);return e}}}function je(e){return{kind:"schema",type:"bigint",reference:je,expects:"bigint",async:!1,message:e,_run(e,t){return"bigint"==typeof e.value?e.typed=!0:Te(this,"type",e,t),e}}}function De(e){return{kind:"schema",type:"boolean",reference:De,expects:"boolean",async:!1,message:e,_run(e,t){return"boolean"==typeof e.value?e.typed=!0:Te(this,"type",e,t),e}}}function Re(e){return{kind:"schema",type:"lazy",reference:Re,expects:"unknown",async:!1,getter:e,_run(e,t){return this.getter(e.value)._run(e,t)}}}function Pe(e,t){return{kind:"schema",type:"literal",reference:Pe,expects:Se(e),async:!1,literal:e,message:t,_run(e,t){return e.value===this.literal?e.typed=!0:Te(this,"type",e,t),e}}}function Be(e,...t){const n={kind:"schema",type:"nullable",reference:Be,expects:`${e.expects} | null`,async:!1,wrapped:e,_run(e,t){return null===e.value&&("default"in this&&(e.value=Ce(this,e,t)),null===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(n.default=t[0]),n}function Fe(e,...t){const n={kind:"schema",type:"nullish",reference:Fe,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(e,t){return null!==e.value&&void 0!==e.value||("default"in this&&(e.value=Ce(this,e,t)),null!==e.value&&void 0!==e.value)?this.wrapped._run(e,t):(e.typed=!0,e)}};return 0 in t&&(n.default=t[0]),n}function Le(e){return{kind:"schema",type:"number",reference:Le,expects:"number",async:!1,message:e,_run(e,t){return"number"!=typeof e.value||isNaN(e.value)?Te(this,"type",e,t):e.typed=!0,e}}}function Ue(e,t){return{kind:"schema",type:"object",reference:Ue,expects:"Object",async:!1,entries:e,message:t,_run(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const r in this.entries){const i=n[r],o=this.entries[r]._run({typed:!1,value:i},t);if(o.issues){const s={type:"object",origin:"value",input:n,key:r,value:i};for(const t of o.issues)t.path?t.path.unshift(s):t.path=[s],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),(void 0!==o.value||r in n)&&(e.value[r]=o.value)}}else Te(this,"type",e,t);return e}}}function $e(e,...t){const n={kind:"schema",type:"optional",reference:$e,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(e,t){return void 0===e.value&&("default"in this&&(e.value=Ce(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(n.default=t[0]),n}function qe(e,t,n){return{kind:"schema",type:"record",reference:qe,expects:"Object",async:!1,key:e,value:t,message:n,_run(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const r in n)if(_e(n,r)){const i=n[r],o=this.key._run({typed:!1,value:r},t);if(o.issues){const s={type:"object",origin:"key",input:n,key:r,value:i};for(const t of o.issues)t.path=[s],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}const s=this.value._run({typed:!1,value:i},t);if(s.issues){const o={type:"object",origin:"value",input:n,key:r,value:i};for(const t of s.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=s.issues),t.abortEarly){e.typed=!1;break}}o.typed&&s.typed||(e.typed=!1),o.typed&&(e.value[o.value]=s.value)}}else Te(this,"type",e,t);return e}}}function Ve(e){return{kind:"schema",type:"string",reference:Ve,expects:"string",async:!1,message:e,_run(e,t){return"string"==typeof e.value?e.typed=!0:Te(this,"type",e,t),e}}}function ze(e,t){return{kind:"schema",type:"tuple",reference:ze,expects:"Array",async:!1,items:e,message:t,_run(e,t){const n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<this.items.length;r++){const i=n[r],o=this.items[r]._run({typed:!1,value:i},t);if(o.issues){const s={type:"array",origin:"value",input:n,key:r,value:i};for(const t of o.issues)t.path?t.path.unshift(s):t.path=[s],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value.push(o.value)}}else Te(this,"type",e,t);return e}}}function Ke(e){let t;if(e)for(const n of e)t?t.push(...n.issues):t=n.issues;return t}function We(e,t){return{kind:"schema",type:"union",reference:We,expects:[...new Set(e.map(e=>e.expects))].join(" | ")||"never",async:!1,options:e,message:t,_run(e,t){let n,r,i;for(const o of this.options){const s=o._run({typed:!1,value:e.value},t);if(s.typed){if(!s.issues){n=s;break}r?r.push(s):r=[s]}else i?i.push(s):i=[s]}if(n)return n;if(r){if(1===r.length)return r[0];Te(this,"type",e,t,{issues:Ke(r)}),e.typed=!0}else{if(1===i?.length)return i[0];Te(this,"type",e,t,{issues:Ke(i)})}return e}}}function Qe(){return{kind:"schema",type:"unknown",reference:Qe,expects:"unknown",async:!1,_run:e=>(e.typed=!0,e)}}function Ge(e,t,n){const r=e._run({typed:!1,value:t},ke(n));if(r.issues)throw new Oe(r.issues);return r.value}function He(...e){return{...e[0],pipe:e,_run(t,n){for(let r=0;r<e.length;r++){if(t.issues&&("schema"===e[r].kind||"transformation"===e[r].kind)){t.typed=!1;break}t.issues&&(n.abortEarly||n.abortPipeEarly)||(t=e[r]._run(t,n))}return t}}}const Je=/^(?!.*(^(?!@)|[-.@])($|[-.@]))(?:[a-z0-9-]{0,63}(?:\.[a-z0-9-]{0,63})*)?@[a-z0-9-]{0,63}$/i,Ze=/^(?!.*(^|[-.])($|[-.]))(?:[a-z0-9-]{0,63}\.)+sui$/i;const Ye=/^([a-z0-9]+(?:-[a-z0-9]+)*)$/,Xe=/^\d+$/,et=e=>{const t=e.split("/");if(t.length<2||t.length>3)return!1;const[n,r,i]=t;return!(void 0!==i&&!Xe.test(i))&&(!!function(e){return!(e.length>235)&&(e.includes("@")?Je.test(e):Ze.test(e))}(n)&&(Ye.test(r)&&r.length<64))},tt=e=>{const t=e.split(/::|<|>|,/);for(const e of t)if(e.includes("/")&&!et(e))return!1;return!0};function nt(e){try{return 32===J(e).length}catch(e){return!1}}function rt(e){return function(e){return/^(0x|0X)?[a-fA-F0-9]+$/.test(e)&&e.length%2==0}(e)&&32===function(e){return/^(0x|0X)/.test(e)?(e.length-2)/2:e.length/2}(e)}function it(e){return rt(e)}function ot(e){const[t,n]=e.split("::"),r=et(t),i=e.slice(t.length+n.length+4),o=i.includes("<")?i.slice(0,i.indexOf("<")):i,s=i.includes("<")?X(i.slice(i.indexOf("<")+1,i.lastIndexOf(">"))).map(e=>function(e){return e.includes("::")?ot(e):e}(e.trim())):[];return{address:r?t:at(t),module:n,name:o,typeParams:s}}function st(e){const{address:t,module:n,name:r,typeParams:i}="string"==typeof e?ot(e):e;return`${t}::${n}::${r}${i?.length>0?`<${i.map(e=>"string"==typeof e?e:st(e)).join(",")}>`:""}`}function at(e,t=!1){let n=e.toLowerCase();return!t&&n.startsWith("0x")&&(n=n.slice(2)),`0x${n.padStart(64,"0")}`}function ut(e,t=!1){return at(e,t)}function ct(e){const t=Object.entries(e).map(([e,t])=>Ue({[e]:t}));return He(We(t),Me(e=>({...e,$kind:Object.keys(e)[0]})))}const lt=He(Ve(),Me(e=>at(e)),xe(rt)),ht=lt,ft=Ve(),dt=He(We([Ve(),He(Le(),Ie())]),xe(e=>{try{return BigInt(e),BigInt(e)>=0&&BigInt(e)<=18446744073709551615n}catch{return!1}},"Invalid u64")),pt=Ue({objectId:lt,version:dt,digest:Ve()}),yt=He(We([Ue({GasCoin:Pe(!0)}),Ue({Input:He(Le(),Ie()),type:$e(Pe("pure"))}),Ue({Input:He(Le(),Ie()),type:$e(Pe("object"))}),Ue({Result:He(Le(),Ie())}),Ue({NestedResult:ze([He(Le(),Ie()),He(Le(),Ie())])})]),Me(e=>({...e,$kind:Object.keys(e)[0]}))),mt=Ue({budget:Be(dt),price:Be(dt),owner:Be(lt),payment:Be(Ne(pt))}),gt=(Ue({address:Ve(),module:Ve(),name:Ve(),typeParams:Ne(Ve())}),We([Pe("address"),Pe("bool"),Pe("u8"),Pe("u16"),Pe("u32"),Pe("u64"),Pe("u128"),Pe("u256"),Ue({vector:Re(()=>gt)}),Ue({datatype:Ue({package:Ve(),module:Ve(),type:Ve(),typeParameters:Ne(Re(()=>gt))})}),Ue({typeParameter:He(Le(),Ie())})])),bt=Ue({ref:Be(We([Pe("&"),Pe("&mut")])),body:gt}),vt=Ue({package:ht,module:Ve(),function:Ve(),typeArguments:Ne(Ve()),arguments:Ne(yt),_argumentTypes:$e(Be(Ne(bt)))}),wt=Ue({name:Ve(),inputs:qe(Ve(),We([yt,Ne(yt)])),data:qe(Ve(),Qe())}),Et=ct({MoveCall:vt,TransferObjects:Ue({objects:Ne(yt),address:yt}),SplitCoins:Ue({coin:yt,amounts:Ne(yt)}),MergeCoins:Ue({destination:yt,sources:Ne(yt)}),Publish:Ue({modules:Ne(ft),dependencies:Ne(ht)}),MakeMoveVec:Ue({type:Be(Ve()),elements:Ne(yt)}),Upgrade:Ue({modules:Ne(ft),dependencies:Ne(ht),package:ht,ticket:yt}),$Intent:wt}),kt=ct({ImmOrOwnedObject:pt,SharedObject:Ue({objectId:ht,initialSharedVersion:dt,mutable:De()}),Receiving:pt}),St=ct({Object:kt,Pure:Ue({bytes:ft}),UnresolvedPure:Ue({value:Qe()}),UnresolvedObject:Ue({objectId:ht,version:$e(Be(dt)),digest:$e(Be(Ve())),initialSharedVersion:$e(Be(dt))})}),Tt=ct({Object:kt,Pure:Ue({bytes:ft})}),_t=ct({None:Pe(!0),Epoch:dt}),Ot=Ue({version:Pe(2),sender:Fe(lt),expiration:Fe(_t),gasData:mt,inputs:Ne(St),commands:Ne(Et)});const xt={MoveCall(e){const[t,n="",r=""]="target"in e?e.target.split("::"):[e.package,e.module,e.function];return{$kind:"MoveCall",MoveCall:{package:t,module:n,function:r,typeArguments:e.typeArguments??[],arguments:e.arguments??[]}}},TransferObjects:(e,t)=>({$kind:"TransferObjects",TransferObjects:{objects:e.map(e=>Ge(yt,e)),address:Ge(yt,t)}}),SplitCoins:(e,t)=>({$kind:"SplitCoins",SplitCoins:{coin:Ge(yt,e),amounts:t.map(e=>Ge(yt,e))}}),MergeCoins:(e,t)=>({$kind:"MergeCoins",MergeCoins:{destination:Ge(yt,e),sources:t.map(e=>Ge(yt,e))}}),Publish:({modules:e,dependencies:t})=>({$kind:"Publish",Publish:{modules:e.map(e=>"string"==typeof e?e:o(new Uint8Array(e))),dependencies:t.map(e=>ut(e))}}),Upgrade:({modules:e,dependencies:t,package:n,ticket:r})=>({$kind:"Upgrade",Upgrade:{modules:e.map(e=>"string"==typeof e?e:o(new Uint8Array(e))),dependencies:t.map(e=>ut(e)),package:n,ticket:Ge(yt,r)}}),MakeMoveVec:({type:e,elements:t})=>({$kind:"MakeMoveVec",MakeMoveVec:{type:e??null,elements:t.map(e=>Ge(yt,e))}}),Intent:({name:e,inputs:t={},data:n={}})=>({$kind:"$Intent",$Intent:{name:e,inputs:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,Array.isArray(t)?t.map(e=>Ge(yt,e)):Ge(yt,t)])),data:n}})},It=/^vector<(.+)>$/,Mt=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class Ct{static parseFromStr(e,t=!1){if("address"===e)return{address:null};if("bool"===e)return{bool:null};if("u8"===e)return{u8:null};if("u16"===e)return{u16:null};if("u32"===e)return{u32:null};if("u64"===e)return{u64:null};if("u128"===e)return{u128:null};if("u256"===e)return{u256:null};if("signer"===e)return{signer:null};const n=e.match(It);if(n)return{vector:Ct.parseFromStr(n[1],t)};const r=e.match(Mt);if(r){return{struct:{address:t?at(r[1]):r[1],module:r[2],name:r[3],typeParams:void 0===r[5]?[]:Ct.parseStructTypeArgs(r[5],t)}}}throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,t=!1){return X(e).map(e=>Ct.parseFromStr(e,t))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${Ct.tagToString(e.vector)}>`;if("struct"in e){const t=e.struct,n=t.typeParams.map(Ct.tagToString).join(", ");return`${t.address}::${t.module}::${t.name}${n?`<${n}>`:""}`}throw new Error("Invalid TypeTag")}}const At=Ue({digest:Ve(),objectId:Ve(),version:We([He(Le(),Ie()),Ve(),je()])}),Nt=ct({ImmOrOwned:At,Shared:Ue({objectId:ht,initialSharedVersion:dt,mutable:De()}),Receiving:At}),jt=ct({Object:Nt,Pure:Ne(He(Le(),Ie()))}),Dt=We([Ue({kind:Pe("Input"),index:He(Le(),Ie()),value:Qe(),type:$e(Pe("object"))}),Ue({kind:Pe("Input"),index:He(Le(),Ie()),value:Qe(),type:Pe("pure")})]),Rt=We([Ue({Epoch:He(Le(),Ie())}),Ue({None:Be(Pe(!0))})]),Pt=He(We([Le(),Ve(),je()]),xe(e=>{if(!["string","number","bigint"].includes(typeof e))return!1;try{return BigInt(e),!0}catch{return!1}})),Bt=We([Ue({bool:Be(Pe(!0))}),Ue({u8:Be(Pe(!0))}),Ue({u64:Be(Pe(!0))}),Ue({u128:Be(Pe(!0))}),Ue({address:Be(Pe(!0))}),Ue({signer:Be(Pe(!0))}),Ue({vector:Re(()=>Bt)}),Ue({struct:Re(()=>Ft)}),Ue({u16:Be(Pe(!0))}),Ue({u32:Be(Pe(!0))}),Ue({u256:Be(Pe(!0))})]),Ft=Ue({address:Ve(),module:Ve(),name:Ve(),typeParams:Ne(Bt)}),Lt=Ue({budget:$e(Pt),price:$e(Pt),payment:$e(Ne(At)),owner:$e(Ve())}),Ut=We([...[Dt,Ue({kind:Pe("GasCoin")}),Ue({kind:Pe("Result"),index:He(Le(),Ie())}),Ue({kind:Pe("NestedResult"),index:He(Le(),Ie()),resultIndex:He(Le(),Ie())})]]),$t=Ue({kind:Pe("MoveCall"),target:He(Ve(),xe(e=>3===e.split("::").length)),typeArguments:Ne(Ve()),arguments:Ne(Ut)}),qt=Ue({kind:Pe("TransferObjects"),objects:Ne(Ut),address:Ut}),Vt=Ue({kind:Pe("SplitCoins"),coin:Ut,amounts:Ne(Ut)}),zt=Ue({kind:Pe("MergeCoins"),destination:Ut,sources:Ne(Ut)}),Kt=Ue({kind:Pe("MakeMoveVec"),type:We([Ue({Some:Bt}),Ue({None:Be(Pe(!0))})]),objects:Ne(Ut)}),Wt=We([...[$t,qt,Vt,zt,Ue({kind:Pe("Publish"),modules:Ne(Ne(He(Le(),Ie()))),dependencies:Ne(Ve())}),Ue({kind:Pe("Upgrade"),modules:Ne(Ne(He(Le(),Ie()))),dependencies:Ne(Ve()),packageId:Ve(),ticket:Ut}),Kt]]);Ue({version:Pe(1),sender:$e(Ve()),expiration:Fe(Rt),gasConfig:Lt,inputs:Ne(Dt),transactions:Ne(Wt)});function Qt(e){const n=e.inputs.map((e,n)=>{if(e.Object)return{kind:"Input",index:n,value:{Object:e.Object.ImmOrOwnedObject?{ImmOrOwned:e.Object.ImmOrOwnedObject}:e.Object.Receiving?{Receiving:{digest:e.Object.Receiving.digest,version:e.Object.Receiving.version,objectId:e.Object.Receiving.objectId}}:{Shared:{mutable:e.Object.SharedObject.mutable,initialSharedVersion:e.Object.SharedObject.initialSharedVersion,objectId:e.Object.SharedObject.objectId}}},type:"object"};if(e.Pure)return{kind:"Input",index:n,value:{Pure:Array.from(t(e.Pure.bytes))},type:"pure"};if(e.UnresolvedPure)return{kind:"Input",type:"pure",index:n,value:e.UnresolvedPure.value};if(e.UnresolvedObject)return{kind:"Input",type:"object",index:n,value:e.UnresolvedObject.objectId};throw new Error("Invalid input")});return{version:1,sender:e.sender??void 0,expiration:"Epoch"===e.expiration?.$kind?{Epoch:Number(e.expiration.Epoch)}:e.expiration?{None:!0}:null,gasConfig:{owner:e.gasData.owner??void 0,budget:e.gasData.budget??void 0,price:e.gasData.price??void 0,payment:e.gasData.payment??void 0},inputs:n,transactions:e.commands.map(e=>{if(e.MakeMoveVec)return{kind:"MakeMoveVec",type:null===e.MakeMoveVec.type?{None:!0}:{Some:Ct.parseFromStr(e.MakeMoveVec.type)},objects:e.MakeMoveVec.elements.map(e=>Gt(e,n))};if(e.MergeCoins)return{kind:"MergeCoins",destination:Gt(e.MergeCoins.destination,n),sources:e.MergeCoins.sources.map(e=>Gt(e,n))};if(e.MoveCall)return{kind:"MoveCall",target:`${e.MoveCall.package}::${e.MoveCall.module}::${e.MoveCall.function}`,typeArguments:e.MoveCall.typeArguments,arguments:e.MoveCall.arguments.map(e=>Gt(e,n))};if(e.Publish)return{kind:"Publish",modules:e.Publish.modules.map(e=>Array.from(t(e))),dependencies:e.Publish.dependencies};if(e.SplitCoins)return{kind:"SplitCoins",coin:Gt(e.SplitCoins.coin,n),amounts:e.SplitCoins.amounts.map(e=>Gt(e,n))};if(e.TransferObjects)return{kind:"TransferObjects",objects:e.TransferObjects.objects.map(e=>Gt(e,n)),address:Gt(e.TransferObjects.address,n)};if(e.Upgrade)return{kind:"Upgrade",modules:e.Upgrade.modules.map(e=>Array.from(t(e))),dependencies:e.Upgrade.dependencies,packageId:e.Upgrade.package,ticket:Gt(e.Upgrade.ticket,n)};throw new Error(`Unknown transaction ${Object.keys(e)}`)})}}function Gt(e,t){if("GasCoin"===e.$kind)return{kind:"GasCoin"};if("Result"===e.$kind)return{kind:"Result",index:e.Result};if("NestedResult"===e.$kind)return{kind:"NestedResult",index:e.NestedResult[0],resultIndex:e.NestedResult[1]};if("Input"===e.$kind)return t[e.Input];throw new Error(`Invalid argument ${Object.keys(e)}`)}function Ht(e){switch(e.kind){case"GasCoin":return{GasCoin:!0};case"Result":return{Result:e.index};case"NestedResult":return{NestedResult:[e.index,e.resultIndex]};case"Input":return{Input:e.index}}}function Jt(e){return We(Object.entries(e).map(([e,t])=>Ue({[e]:t})))}const Zt=Jt({GasCoin:Pe(!0),Input:He(Le(),Ie()),Result:He(Le(),Ie()),NestedResult:ze([He(Le(),Ie()),He(Le(),Ie())])}),Yt=Ue({budget:Be(dt),price:Be(dt),owner:Be(lt),payment:Be(Ne(pt))}),Xt=Ue({package:ht,module:Ve(),function:Ve(),typeArguments:Ne(Ve()),arguments:Ne(Zt)}),en=Ue({name:Ve(),inputs:qe(Ve(),We([Zt,Ne(Zt)])),data:qe(Ve(),Qe())}),tn=Jt({MoveCall:Xt,TransferObjects:Ue({objects:Ne(Zt),address:Zt}),SplitCoins:Ue({coin:Zt,amounts:Ne(Zt)}),MergeCoins:Ue({destination:Zt,sources:Ne(Zt)}),Publish:Ue({modules:Ne(ft),dependencies:Ne(ht)}),MakeMoveVec:Ue({type:Be(Ve()),elements:Ne(Zt)}),Upgrade:Ue({modules:Ne(ft),dependencies:Ne(ht),package:ht,ticket:Zt}),$Intent:en}),nn=Jt({ImmOrOwnedObject:pt,SharedObject:Ue({objectId:ht,initialSharedVersion:dt,mutable:De()}),Receiving:pt}),rn=Jt({Object:nn,Pure:Ue({bytes:ft}),UnresolvedPure:Ue({value:Qe()}),UnresolvedObject:Ue({objectId:ht,version:$e(Be(dt)),digest:$e(Be(Ve())),initialSharedVersion:$e(Be(dt))})}),on=Jt({None:Pe(!0),Epoch:dt}),sn=Ue({version:Pe(2),sender:Fe(lt),expiration:Fe(on),gasData:Yt,inputs:Ne(rn),commands:Ne(tn),digest:$e(Be(Ve()))});const an={Pure:function(e){return{$kind:"Pure",Pure:{bytes:e instanceof Uint8Array?o(e):e.toBase64()}}},ObjectRef:({objectId:e,digest:t,version:n})=>({$kind:"Object",Object:{$kind:"ImmOrOwnedObject",ImmOrOwnedObject:{digest:t,version:n,objectId:at(e)}}}),SharedObjectRef:({objectId:e,mutable:t,initialSharedVersion:n})=>({$kind:"Object",Object:{$kind:"SharedObject",SharedObject:{mutable:t,initialSharedVersion:n,objectId:at(e)}}}),ReceivingRef:({objectId:e,digest:t,version:n})=>({$kind:"Object",Object:{$kind:"Receiving",Receiving:{digest:t,version:n,objectId:at(e)}}})},un={u8:e=>me({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:255,...e}),u16:e=>me({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:65535,...e}),u32:e=>me({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...e}),u64:e=>ge({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...e}),u128:e=>ge({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...e}),u256:e=>ge({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...e}),bool:e=>ye({name:"bool",size:1,read:e=>1===e.read8(),write:(e,t)=>t.write8(e?1:0),...e,validate:t=>{if(e?.validate?.(t),"boolean"!=typeof t)throw new TypeError("Expected boolean, found "+typeof t)}}),uleb128:e=>function({serialize:e,...t}){const n=new he({...t,serialize:e,write:(e,t)=>{for(const r of n.serialize(e).toBytes())t.write8(r)}});return n}({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(Z(e)),...e}),bytes:(e,t)=>ye({name:`bytes[${e}]`,size:e,read:t=>t.readBytes(e),write:(t,n)=>{const r=new Uint8Array(t);for(let t=0;t<e;t++)n.write8(r[t]??0)},...t,validate:n=>{if(t?.validate?.(n),!n||"object"!=typeof n||!("length"in n))throw new TypeError("Expected array, found "+typeof n);if(n.length!==e)throw new TypeError(`Expected array of length ${e}, found ${n.length}`)}}),byteVector:e=>new he({name:"bytesVector",read:e=>{const t=e.readULEB();return e.readBytes(t)},write:(e,t)=>{const n=new Uint8Array(e);t.writeULEB(n.length);for(let e=0;e<n.length;e++)t.write8(n[e]??0)},...e,serializedSize:e=>{const t="length"in e?e.length:null;return null==t?null:Z(t).length+t},validate:t=>{if(e?.validate?.(t),!t||"object"!=typeof t||!("length"in t))throw new TypeError("Expected array, found "+typeof t)}}),string:e=>function({toBytes:e,fromBytes:t,...n}){return new he({...n,read:e=>{const n=e.readULEB(),r=e.readBytes(n);return t(r)},write:(t,n)=>{const r=e(t);n.writeULEB(r.length);for(let e=0;e<r.length;e++)n.write8(r[e])},serialize:t=>{const n=e(t),r=Z(n.length),i=new Uint8Array(r.length+n.length);return i.set(r,0),i.set(n,r.length),i},validate:e=>{if("string"!=typeof e)throw new TypeError(`Invalid ${n.name} value: ${e}. Expected string`);n.validate?.(e)}})}({name:"string",toBytes:e=>(new TextEncoder).encode(e),fromBytes:e=>(new TextDecoder).decode(e),...e}),fixedArray:(e,t,n)=>new he({name:`${t.name}[${e}]`,read:n=>{const r=new Array(e);for(let i=0;i<e;i++)r[i]=t.read(n);return r},write:(e,n)=>{for(const r of e)t.write(r,n)},...n,validate:t=>{if(n?.validate?.(t),!t||"object"!=typeof t||!("length"in t))throw new TypeError("Expected array, found "+typeof t);if(t.length!==e)throw new TypeError(`Expected array of length ${e}, found ${t.length}`)}}),option:e=>un.enum(`Option<${e.name}>`,{None:null,Some:e}).transform({input:e=>null==e?{None:!0}:{Some:e},output:e=>"Some"===e.$kind?e.Some:null}),vector:(e,t)=>new he({name:`vector<${e.name}>`,read:t=>{const n=t.readULEB(),r=new Array(n);for(let i=0;i<n;i++)r[i]=e.read(t);return r},write:(t,n)=>{n.writeULEB(t.length);for(const r of t)e.write(r,n)},...t,validate:e=>{if(t?.validate?.(e),!e||"object"!=typeof e||!("length"in e))throw new TypeError("Expected array, found "+typeof e)}}),tuple:(e,t)=>new he({name:`(${e.map(e=>e.name).join(", ")})`,serializedSize:t=>{let n=0;for(let r=0;r<e.length;r++){const i=e[r].serializedSize(t[r]);if(null==i)return null;n+=i}return n},read:t=>{const n=[];for(const r of e)n.push(r.read(t));return n},write:(t,n)=>{for(let r=0;r<e.length;r++)e[r].write(t[r],n)},...t,validate:n=>{if(t?.validate?.(n),!Array.isArray(n))throw new TypeError("Expected array, found "+typeof n);if(n.length!==e.length)throw new TypeError(`Expected array of length ${e.length}, found ${n.length}`)}}),struct(e,t,n){const r=Object.entries(t);return new he({name:e,serializedSize:e=>{let t=0;for(const[n,i]of r){const r=i.serializedSize(e[n]);if(null==r)return null;t+=r}return t},read:e=>{const t={};for(const[n,i]of r)t[n]=i.read(e);return t},write:(e,t)=>{for(const[n,i]of r)i.write(e[n],t)},...n,validate:e=>{if(n?.validate?.(e),"object"!=typeof e||null==e)throw new TypeError("Expected object, found "+typeof e)}})},enum(e,t,n){const r=Object.entries(t);return new he({name:e,read:t=>{const n=t.readULEB(),i=r[n];if(!i)throw new TypeError(`Unknown value ${n} for enum ${e}`);const[o,s]=i;return{[o]:s?.read(t)??!0,$kind:o}},write:(e,n)=>{const[i,o]=Object.entries(e).filter(([e])=>Object.hasOwn(t,e))[0];for(let e=0;e<r.length;e++){const[t,s]=r[e];if(t===i)return n.writeULEB(e),void s?.write(o,n)}},...n,validate:r=>{if(n?.validate?.(r),"object"!=typeof r||null==r)throw new TypeError("Expected object, found "+typeof r);const i=Object.keys(r).filter(e=>void 0!==r[e]&&Object.hasOwn(t,e));if(1!==i.length)throw new TypeError(`Expected object with one key, but found ${i.length} for type ${e}}`);const[o]=i;if(!Object.hasOwn(t,o))throw new TypeError(`Invalid enum variant ${o}`)}})},map:(e,t)=>un.vector(un.tuple([e,t])).transform({name:`Map<${e.name}, ${t.name}>`,input:e=>[...e.entries()],output:e=>{const t=new Map;for(const[n,r]of e)t.set(n,r);return t}}),lazy:e=>function(e){let t=null;function n(){return t||(t=e()),t}return new he({name:"lazy",read:e=>n().read(e),serializedSize:e=>n().serializedSize(e),write:(e,t)=>n().write(e,t),serialize:(e,t)=>n().serialize(e,t).toBytes()})}(e)};const cn=un.bytes(32).transform({validate:e=>{const t="string"==typeof e?e:a(e);if(!t||!rt(at(t)))throw new Error(`Invalid Sui address ${t}`)},input:e=>"string"==typeof e?s(at(e)):e,output:e=>at(a(e))}),ln=un.vector(un.u8()).transform({name:"ObjectDigest",input:e=>J(e),output:e=>H(new Uint8Array(e)),validate:e=>{if(32!==J(e).length)throw new Error("ObjectDigest must be 32 bytes")}}),hn=un.struct("SuiObjectRef",{objectId:cn,version:un.u64(),digest:ln}),fn=un.struct("SharedObjectRef",{objectId:cn,initialSharedVersion:un.u64(),mutable:un.bool()}),dn=un.enum("ObjectArg",{ImmOrOwnedObject:hn,SharedObject:fn,Receiving:hn}),pn=un.enum("Owner",{AddressOwner:cn,ObjectOwner:cn,Shared:un.struct("Shared",{initialSharedVersion:un.u64()}),Immutable:null,ConsensusV2:un.struct("ConsensusV2",{authenticator:un.enum("Authenticator",{SingleOwner:cn}),startVersion:un.u64()})}),yn=un.enum("CallArg",{Pure:un.struct("Pure",{bytes:un.vector(un.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>o(new Uint8Array(e))})}),Object:dn}),mn=un.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:un.lazy(()=>mn),struct:un.lazy(()=>On),u16:null,u32:null,u256:null}),gn=mn.transform({input:e=>"string"==typeof e?Ct.parseFromStr(e,!0):e,output:e=>Ct.tagToString(e)}),bn=un.enum("Argument",{GasCoin:null,Input:un.u16(),Result:un.u16(),NestedResult:un.tuple([un.u16(),un.u16()])}),vn=un.struct("ProgrammableMoveCall",{package:cn,module:un.string(),function:un.string(),typeArguments:un.vector(gn),arguments:un.vector(bn)}),wn=un.enum("Command",{MoveCall:vn,TransferObjects:un.struct("TransferObjects",{objects:un.vector(bn),address:bn}),SplitCoins:un.struct("SplitCoins",{coin:bn,amounts:un.vector(bn)}),MergeCoins:un.struct("MergeCoins",{destination:bn,sources:un.vector(bn)}),Publish:un.struct("Publish",{modules:un.vector(un.vector(un.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>o(new Uint8Array(e))})),dependencies:un.vector(cn)}),MakeMoveVec:un.struct("MakeMoveVec",{type:(En=gn,un.enum("Option",{None:null,Some:En})).transform({input:e=>null===e?{None:!0}:{Some:e},output:e=>e.Some??null}),elements:un.vector(bn)}),Upgrade:un.struct("Upgrade",{modules:un.vector(un.vector(un.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>o(new Uint8Array(e))})),dependencies:un.vector(cn),package:cn,ticket:bn})});var En;const kn=un.struct("ProgrammableTransaction",{inputs:un.vector(yn),commands:un.vector(wn)}),Sn=un.enum("TransactionKind",{ProgrammableTransaction:kn,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Tn=un.enum("TransactionExpiration",{None:null,Epoch:un.u64({name:"unsafe_u64",..._n}).transform({input:e=>e,output:e=>Number(e)})});var _n;const On=un.struct("StructTag",{address:cn,module:un.string(),name:un.string(),typeParams:un.vector(mn)}),xn=un.struct("GasData",{payment:un.vector(hn),owner:cn,price:un.u64(),budget:un.u64()}),In=un.struct("TransactionDataV1",{kind:Sn,sender:cn,gasData:xn,expiration:Tn}),Mn=un.enum("TransactionData",{V1:In}),Cn=un.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),An=un.enum("IntentVersion",{V0:null}),Nn=un.enum("AppId",{Sui:null}),jn=un.struct("Intent",{scope:Cn,version:An,appId:Nn});function Dn(e){return un.struct(`IntentMessage<${e.name}>`,{intent:jn,value:e})}const Rn=un.enum("CompressedSignature",{ED25519:un.fixedArray(64,un.u8()),Secp256k1:un.fixedArray(64,un.u8()),Secp256r1:un.fixedArray(64,un.u8()),ZkLogin:un.vector(un.u8())}),Pn=un.enum("PublicKey",{ED25519:un.fixedArray(32,un.u8()),Secp256k1:un.fixedArray(33,un.u8()),Secp256r1:un.fixedArray(33,un.u8()),ZkLogin:un.vector(un.u8())}),Bn=un.struct("MultiSigPkMap",{pubKey:Pn,weight:un.u8()}),Fn=un.struct("MultiSigPublicKey",{pk_map:un.vector(Bn),threshold:un.u16()}),Ln=un.struct("MultiSig",{sigs:un.vector(Rn),bitmap:un.u16(),multisig_pk:Fn}),Un=un.vector(un.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>o(new Uint8Array(e))}),$n=un.struct("SenderSignedTransaction",{intentMessage:Dn(Mn),txSignatures:un.vector(Un)}),qn=un.vector($n,{name:"SenderSignedData"}),Vn=un.struct("PasskeyAuthenticator",{authenticatorData:un.vector(un.u8()),clientDataJson:un.string(),userSignature:un.vector(un.u8())}),zn=un.enum("PackageUpgradeError",{UnableToFetchPackage:un.struct("UnableToFetchPackage",{packageId:cn}),NotAPackage:un.struct("NotAPackage",{objectId:cn}),IncompatibleUpgrade:null,DigestDoesNotMatch:un.struct("DigestDoesNotMatch",{digest:un.vector(un.u8())}),UnknownUpgradePolicy:un.struct("UnknownUpgradePolicy",{policy:un.u8()}),PackageIDDoesNotMatch:un.struct("PackageIDDoesNotMatch",{packageId:cn,ticketId:cn})}),Kn=un.struct("ModuleId",{address:cn,name:un.string()}),Wn=un.struct("MoveLocation",{module:Kn,function:un.u16(),instruction:un.u16(),functionName:un.option(un.string())}),Qn=un.enum("CommandArgumentError",{TypeMismatch:null,InvalidBCSBytes:null,InvalidUsageOfPureArg:null,InvalidArgumentToPrivateEntryFunction:null,IndexOutOfBounds:un.struct("IndexOutOfBounds",{idx:un.u16()}),SecondaryIndexOutOfBounds:un.struct("SecondaryIndexOutOfBounds",{resultIdx:un.u16(),secondaryIdx:un.u16()}),InvalidResultArity:un.struct("InvalidResultArity",{resultIdx:un.u16()}),InvalidGasCoinUsage:null,InvalidValueUsage:null,InvalidObjectByValue:null,InvalidObjectByMutRef:null,SharedObjectOperationNotAllowed:null}),Gn=un.enum("TypeArgumentError",{TypeNotFound:null,ConstraintNotSatisfied:null}),Hn=un.enum("ExecutionFailureStatus",{InsufficientGas:null,InvalidGasObject:null,InvariantViolation:null,FeatureNotYetSupported:null,MoveObjectTooBig:un.struct("MoveObjectTooBig",{objectSize:un.u64(),maxObjectSize:un.u64()}),MovePackageTooBig:un.struct("MovePackageTooBig",{objectSize:un.u64(),maxObjectSize:un.u64()}),CircularObjectOwnership:un.struct("CircularObjectOwnership",{object:cn}),InsufficientCoinBalance:null,CoinBalanceOverflow:null,PublishErrorNonZeroAddress:null,SuiMoveVerificationError:null,MovePrimitiveRuntimeError:un.option(Wn),MoveAbort:un.tuple([Wn,un.u64()]),VMVerificationOrDeserializationError:null,VMInvariantViolation:null,FunctionNotFound:null,ArityMismatch:null,TypeArityMismatch:null,NonEntryFunctionInvoked:null,CommandArgumentError:un.struct("CommandArgumentError",{argIdx:un.u16(),kind:Qn}),TypeArgumentError:un.struct("TypeArgumentError",{argumentIdx:un.u16(),kind:Gn}),UnusedValueWithoutDrop:un.struct("UnusedValueWithoutDrop",{resultIdx:un.u16(),secondaryIdx:un.u16()}),InvalidPublicFunctionReturnType:un.struct("InvalidPublicFunctionReturnType",{idx:un.u16()}),InvalidTransferObject:null,EffectsTooLarge:un.struct("EffectsTooLarge",{currentSize:un.u64(),maxSize:un.u64()}),PublishUpgradeMissingDependency:null,PublishUpgradeDependencyDowngrade:null,PackageUpgradeError:un.struct("PackageUpgradeError",{upgradeError:zn}),WrittenObjectsTooLarge:un.struct("WrittenObjectsTooLarge",{currentSize:un.u64(),maxSize:un.u64()}),CertificateDenied:null,SuiMoveVerificationTimedout:null,SharedObjectOperationNotAllowed:null,InputObjectDeleted:null,ExecutionCancelledDueToSharedObjectCongestion:un.struct("ExecutionCancelledDueToSharedObjectCongestion",{congestedObjects:un.vector(cn)}),AddressDeniedForCoin:un.struct("AddressDeniedForCoin",{address:cn,coinType:un.string()}),CoinTypeGlobalPause:un.struct("CoinTypeGlobalPause",{coinType:un.string()}),ExecutionCancelledDueToRandomnessUnavailable:null}),Jn=un.enum("ExecutionStatus",{Success:null,Failed:un.struct("ExecutionFailed",{error:Hn,command:un.option(un.u64())})}),Zn=un.struct("GasCostSummary",{computationCost:un.u64(),storageCost:un.u64(),storageRebate:un.u64(),nonRefundableStorageFee:un.u64()}),Yn=un.struct("TransactionEffectsV1",{status:Jn,executedEpoch:un.u64(),gasUsed:Zn,modifiedAtVersions:un.vector(un.tuple([cn,un.u64()])),sharedObjects:un.vector(hn),transactionDigest:ln,created:un.vector(un.tuple([hn,pn])),mutated:un.vector(un.tuple([hn,pn])),unwrapped:un.vector(un.tuple([hn,pn])),deleted:un.vector(hn),unwrappedThenDeleted:un.vector(hn),wrapped:un.vector(hn),gasObject:un.tuple([hn,pn]),eventsDigest:un.option(ln),dependencies:un.vector(ln)}),Xn=un.tuple([un.u64(),ln]),er=un.enum("ObjectIn",{NotExist:null,Exist:un.tuple([Xn,pn])}),tr=un.enum("ObjectOut",{NotExist:null,ObjectWrite:un.tuple([ln,pn]),PackageWrite:Xn}),nr=un.enum("IDOperation",{None:null,Created:null,Deleted:null}),rr=un.struct("EffectsObjectChange",{inputState:er,outputState:tr,idOperation:nr}),ir=un.enum("UnchangedSharedKind",{ReadOnlyRoot:Xn,MutateDeleted:un.u64(),ReadDeleted:un.u64(),Cancelled:un.u64(),PerEpochConfig:null}),or=un.struct("TransactionEffectsV2",{status:Jn,executedEpoch:un.u64(),gasUsed:Zn,transactionDigest:ln,gasObjectIndex:un.option(un.u32()),eventsDigest:un.option(ln),dependencies:un.vector(ln),lamportVersion:un.u64(),changedObjects:un.vector(un.tuple([cn,rr])),unchangedSharedObjects:un.vector(un.tuple([cn,ir])),auxDataDigest:un.option(ln)}),sr=un.enum("TransactionEffects",{V1:Yn,V2:or}),ar={...un,U8:un.u8(),U16:un.u16(),U32:un.u32(),U64:un.u64(),U128:un.u128(),U256:un.u256(),ULEB128:un.uleb128(),Bool:un.bool(),String:un.string(),Address:cn,AppId:Nn,Argument:bn,CallArg:yn,Command:wn,CompressedSignature:Rn,GasData:xn,Intent:jn,IntentMessage:Dn,IntentScope:Cn,IntentVersion:An,MultiSig:Ln,MultiSigPkMap:Bn,MultiSigPublicKey:Fn,ObjectArg:dn,ObjectDigest:ln,Owner:pn,PasskeyAuthenticator:Vn,ProgrammableMoveCall:vn,ProgrammableTransaction:kn,PublicKey:Pn,SenderSignedData:qn,SenderSignedTransaction:$n,SharedObjectRef:fn,StructTag:On,SuiObjectRef:hn,TransactionData:Mn,TransactionDataV1:In,TransactionEffects:sr,TransactionExpiration:Tn,TransactionKind:Sn,TypeTag:gn},ur=(BigInt(1e9),ut("0x6"),"0x2::sui::SUI"),cr=ut("0x5");function lr(e){if("string"==typeof e)switch(e){case"address":return ar.Address;case"bool":return ar.Bool;case"u8":return ar.U8;case"u16":return ar.U16;case"u32":return ar.U32;case"u64":return ar.U64;case"u128":return ar.U128;case"u256":return ar.U256;default:throw new Error(`Unknown type signature ${e}`)}if("vector"in e){if("u8"===e.vector)return ar.vector(ar.U8).transform({input:e=>"string"==typeof e?(new TextEncoder).encode(e):e,output:e=>e});const t=lr(e.vector);return t?ar.vector(t):null}if("datatype"in e){const t=at(e.datatype.package);if(t===at("0x1")){if("ascii"===e.datatype.module&&"String"===e.datatype.type)return ar.String;if("string"===e.datatype.module&&"String"===e.datatype.type)return ar.String;if("option"===e.datatype.module&&"Option"===e.datatype.type){const t=lr(e.datatype.typeParameters[0]);return t?ar.vector(t):null}}if(t===at("0x2")&&"object"===e.datatype.module&&"ID"===e.datatype.type)return ar.Address}return null}function hr(e){if("string"==typeof e)switch(e){case"Address":return"address";case"Bool":return"bool";case"U8":return"u8";case"U16":return"u16";case"U32":return"u32";case"U64":return"u64";case"U128":return"u128";case"U256":return"u256";default:throw new Error(`Unexpected type ${e}`)}if("Vector"in e)return{vector:hr(e.Vector)};if("Struct"in e)return{datatype:{package:e.Struct.address,module:e.Struct.module,type:e.Struct.name,typeParameters:e.Struct.typeArguments.map(hr)}};if("TypeParameter"in e)return{typeParameter:e.TypeParameter};throw new Error(`Unexpected type ${JSON.stringify(e)}`)}function fr(e,t){return Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))}const dr=5e10;function pr(e){return async function(t,n,r){return await async function(e,t){const{inputs:n,commands:r}=e,i=[],o=new Set;r.forEach(t=>{if(t.MoveCall){if(t.MoveCall._argumentTypes)return;if(t.MoveCall.arguments.map(t=>"Input"===t.$kind?e.inputs[t.Input]:null).some(e=>e?.UnresolvedPure||e?.UnresolvedObject)){const e=`${t.MoveCall.package}::${t.MoveCall.module}::${t.MoveCall.function}`;o.add(e),i.push(t.MoveCall)}}});const s=new Map;o.size>0&&await Promise.all([...o].map(async e=>{const[n,r,i]=e.split("::"),o=await t.getNormalizedMoveFunction({package:n,module:r,function:i});s.set(e,o.parameters.map(e=>function(e){return"object"==typeof e&&"Reference"in e?{ref:"&",body:hr(e.Reference)}:"object"==typeof e&&"MutableReference"in e?{ref:"&mut",body:hr(e.MutableReference)}:{ref:null,body:hr(e)}}(e)))}));i.length&&await Promise.all(i.map(async e=>{const t=s.get(`${e.package}::${e.module}::${e.function}`);if(!t)return;const n=t.length>0&&function(e){const t="object"==typeof e.body&&"datatype"in e.body?e.body.datatype:null;return!!t&&at(t.package)===at("0x2")&&"tx_context"===t.module&&"TxContext"===t.type}(t.at(-1))?t.slice(0,t.length-1):t;e._argumentTypes=n}));r.forEach(e=>{if(!e.MoveCall)return;const t=e.MoveCall,r=`${t.package}::${t.module}::${t.function}`,i=t._argumentTypes;if(i){if(i.length!==e.MoveCall.arguments.length)throw new Error(`Incorrect number of arguments for ${r}`);i.forEach((e,r)=>{const i=t.arguments[r];if("Input"!==i.$kind)return;const o=n[i.Input];if(!o.UnresolvedPure&&!o.UnresolvedObject)return;const s=o.UnresolvedPure?.value??o.UnresolvedObject?.objectId,a=lr(e.body);if(a)return i.type="pure",void(n[n.indexOf(o)]=an.Pure(a.serialize(s)));if("string"!=typeof s)throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(s,null,2)}`);i.type="object";const u=o.UnresolvedPure?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:s}}:o;n[i.Input]=u})}})}(t,e),await async function(e,t){const n=e.inputs.filter(e=>e.UnresolvedObject&&!(e.UnresolvedObject.version||e.UnresolvedObject?.initialSharedVersion)),r=[...new Set(n.map(e=>ut(e.UnresolvedObject.objectId)))],i=r.length?fr(r,50):[],o=(await Promise.all(i.map(e=>t.multiGetObjects({ids:e,options:{showOwner:!0}})))).flat(),s=new Map(r.map((e,t)=>[e,o[t]])),a=Array.from(s).filter(([e,t])=>t.error).map(([e,t])=>JSON.stringify(t.error));if(a.length)throw new Error(`The following input objects are invalid: ${a.join(", ")}`);const u=o.map(e=>{if(e.error||!e.data)throw new Error(`Failed to fetch object: ${e.error}`);const t=e.data.owner,n=t&&"object"==typeof t&&"Shared"in t?t.Shared.initial_shared_version:null;return{objectId:e.data.objectId,digest:e.data.digest,version:e.data.version,initialSharedVersion:n}}),c=new Map(r.map((e,t)=>[e,u[t]]));for(const[t,n]of e.inputs.entries()){if(!n.UnresolvedObject)continue;let r;const i=at(n.UnresolvedObject.objectId),o=c.get(i);n.UnresolvedObject.initialSharedVersion??o?.initialSharedVersion?r=an.SharedObjectRef({objectId:i,initialSharedVersion:n.UnresolvedObject.initialSharedVersion||o?.initialSharedVersion,mutable:yr(e,t)}):mr(e,t)&&(r=an.ReceivingRef({objectId:i,digest:n.UnresolvedObject.digest??o?.digest,version:n.UnresolvedObject.version??o?.version})),e.inputs[e.inputs.indexOf(n)]=r??an.ObjectRef({objectId:i,digest:n.UnresolvedObject.digest??o?.digest,version:n.UnresolvedObject.version??o?.version})}}(t,e),n.onlyTransactionKind||(await async function(e,t){e.gasConfig.price||(e.gasConfig.price=String(await t.getReferenceGasPrice()))}(t,e),await async function(e,t){if(e.gasConfig.budget)return;const n=await t.dryRunTransactionBlock({transactionBlock:e.build({overrides:{gasData:{budget:String(dr),payment:[]}}})});if("success"!==n.effects.status.status)throw new Error(`Dry run failed, could not automatically determine a budget: ${n.effects.status.error}`,{cause:n});const r=1000n*BigInt(e.gasConfig.price||1n),i=BigInt(n.effects.gasUsed.computationCost)+r,o=i+BigInt(n.effects.gasUsed.storageCost)-BigInt(n.effects.gasUsed.storageRebate);e.gasConfig.budget=String(o>i?o:i)}(t,e),await async function(e,t){if(!e.gasConfig.payment){const n=(await t.getCoins({owner:e.gasConfig.owner||e.sender,coinType:ur})).data.filter(t=>!e.inputs.find(e=>!!e.Object?.ImmOrOwnedObject&&t.coinObjectId===e.Object.ImmOrOwnedObject.objectId)).map(e=>({objectId:e.coinObjectId,digest:e.digest,version:e.version}));if(!n.length)throw new Error("No valid gas coins found for the transaction.");e.gasConfig.payment=n.map(e=>Ge(pt,e))}}(t,e)),await r()}}function yr(e,t){let n=!1;return e.getInputUses(t,(e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const r=t.MoveCall.arguments.indexOf(e);n="&"!==t.MoveCall._argumentTypes[r].ref||n}"MakeMoveVec"!==t.$kind&&"MergeCoins"!==t.$kind&&"SplitCoins"!==t.$kind||(n=!0)}),n}function mr(e,t){let n=!1;return e.getInputUses(t,(e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const r=t.MoveCall.arguments.indexOf(e);n=function(e){if("object"!=typeof e.body||!("datatype"in e.body))return!1;return"0x2"===e.body.datatype.package&&"transfer"===e.body.datatype.module&&"Receiving"===e.body.datatype.type}(t.MoveCall._argumentTypes[r])||n}}),n}function gr(e,t){return!!e.inputs.some(e=>e.UnresolvedObject||e.UnresolvedPure)||!(t.onlyTransactionKind||e.gasConfig.price&&e.gasConfig.budget&&e.gasConfig.payment)}async function br(e,t,n){if(function(e){for(const t of e.commands)switch(t.$kind){case"SplitCoins":t.SplitCoins.amounts.forEach(t=>{wr(t,ar.U64,e)});break;case"TransferObjects":wr(t.TransferObjects.address,ar.Address,e)}}(e),!gr(e,t))return await vr(e),n();const r=function(e){if(!e.client)throw new Error("No sui client passed to Transaction#build, but transaction data was not sufficient to build offline.");return e.client}(t);return(r.core?.resolveTransactionPlugin()??pr(r))(e,t,async()=>{await vr(e),await n()})}function vr(e){e.inputs.forEach((e,t)=>{if("Object"!==e.$kind&&"Pure"!==e.$kind)throw new Error(`Input at index ${t} has not been resolved. Expected a Pure or Object input, but found ${JSON.stringify(e)}`)})}function wr(e,t,n){if("Input"!==e.$kind)return;const r=n.inputs[e.Input];"UnresolvedPure"===r.$kind&&(n.inputs[e.Input]=an.Pure(t.serialize(r.UnresolvedPure.value)))}function Er(e){switch(e){case"u8":return un.u8();case"u16":return un.u16();case"u32":return un.u32();case"u64":return un.u64();case"u128":return un.u128();case"u256":return un.u256();case"bool":return un.bool();case"string":return un.string();case"id":case"address":return cn}const t=e.match(/^(vector|option)<(.+)>$/);if(t){const[e,n]=t.slice(1);return"vector"===e?un.vector(Er(n)):un.option(Er(n))}throw new Error(`Invalid Pure type name: ${e}`)}function kr(e){function t(t,n){if("string"==typeof t)return e(Er(t).serialize(n));if(t instanceof Uint8Array||de(t))return e(t);throw new Error("tx.pure must be called either a bcs type name, or a serialized bcs value")}return t.u8=t=>e(ar.U8.serialize(t)),t.u16=t=>e(ar.U16.serialize(t)),t.u32=t=>e(ar.U32.serialize(t)),t.u64=t=>e(ar.U64.serialize(t)),t.u128=t=>e(ar.U128.serialize(t)),t.u256=t=>e(ar.U256.serialize(t)),t.bool=t=>e(ar.Bool.serialize(t)),t.string=t=>e(ar.String.serialize(t)),t.address=t=>e(ar.Address.serialize(t)),t.id=t.address,t.vector=(t,n)=>e(ar.vector(Er(t)).serialize(n)),t.option=(t,n)=>e(ar.option(Er(t)).serialize(n)),t}const Sr="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function Tr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function _r(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Or(e,...t){if(!Tr(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function xr(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");_r(e.outputLen),_r(e.blockLen)}function Ir(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Mr(e,t){Or(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Cr(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ar(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Nr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function jr(e,t){return e<<32-t|e>>>t}const Dr=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function Rr(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Pr=Dr?e=>e:e=>Rr(e);const Br=Dr?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=Rr(e[t]);return e},Fr=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),Lr=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ur(e){if(Or(e),Fr)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Lr[e[n]];return t}const $r=48,qr=57,Vr=65,zr=70,Kr=97,Wr=102;function Qr(e){return e>=$r&&e<=qr?e-$r:e>=Vr&&e<=zr?e-(Vr-10):e>=Kr&&e<=Wr?e-(Kr-10):void 0}function Gr(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(Fr)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){const n=Qr(e.charCodeAt(i)),o=Qr(e.charCodeAt(i+1));if(void 0===n||void 0===o){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+o}return r}function Hr(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function Jr(e){return"string"==typeof e&&(e=Hr(e)),Or(e),e}function Zr(e){return"string"==typeof e&&(e=Hr(e)),Or(e),e}function Yr(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];Or(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const i=e[t];n.set(i,r),r+=i.length}return n}class Xr{}function ei(e){const t=t=>e().update(Jr(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ti(e){const t=(t,n)=>e(n).update(Jr(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}function ni(e=32){if(Sr&&"function"==typeof Sr.getRandomValues)return Sr.getRandomValues(new Uint8Array(e));if(Sr&&"function"==typeof Sr.randomBytes)return Uint8Array.from(Sr.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const ri=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);function ii(e,t,n){return e&t^~e&n}function oi(e,t,n){return e&t^e&n^t&n}class si extends Xr{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Nr(this.buffer)}update(e){Ir(this),Or(e=Jr(e));const{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let o=0;o<i;){const s=Math.min(r-this.pos,i-o);if(s===r){const t=Nr(e);for(;r<=i-o;o+=r)this.process(t,o);continue}n.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ir(this),Mr(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;t[o++]=128,Ar(this.buffer.subarray(o)),this.padOffset>r-o&&(this.process(n,0),o=0);for(let e=o;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),u=r?4:0,c=r?0:4;e.setUint32(t+u,s,r),e.setUint32(t+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=Nr(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<u;e++)s.setUint32(4*e,c[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return e.destroyed=o,e.finished=i,e.length=r,e.pos=s,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const ai=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ui=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),ci=BigInt(2**32-1),li=BigInt(32);function hi(e,t=!1){return t?{h:Number(e&ci),l:Number(e>>li&ci)}:{h:0|Number(e>>li&ci),l:0|Number(e&ci)}}function fi(e,t=!1){const n=e.length;let r=new Uint32Array(n),i=new Uint32Array(n);for(let o=0;o<n;o++){const{h:n,l:s}=hi(e[o],t);[r[o],i[o]]=[n,s]}return[r,i]}const di=(e,t,n)=>e>>>n,pi=(e,t,n)=>e<<32-n|t>>>n,yi=(e,t,n)=>e>>>n|t<<32-n,mi=(e,t,n)=>e<<32-n|t>>>n,gi=(e,t,n)=>e<<64-n|t>>>n-32,bi=(e,t,n)=>e>>>n-32|t<<64-n,vi=(e,t)=>t,wi=(e,t)=>e;function Ei(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:0|i}}const ki=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Si=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Ti=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),_i=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,Oi=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),xi=(e,t,n,r,i,o)=>t+n+r+i+o+(e/2**32|0)|0,Ii=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Mi=new Uint32Array(32);function Ci(e,t,n,r,i,o){const s=i[o],a=i[o+1];let u=Mi[2*e],c=Mi[2*e+1],l=Mi[2*t],h=Mi[2*t+1],f=Mi[2*n],d=Mi[2*n+1],p=Mi[2*r],y=Mi[2*r+1],m=ki(u,l,s);c=Si(m,c,h,a),u=0|m,({Dh:y,Dl:p}={Dh:y^c,Dl:p^u}),({Dh:y,Dl:p}={Dh:vi(0,p),Dl:wi(y)}),({h:d,l:f}=Ei(d,f,y,p)),({Bh:h,Bl:l}={Bh:h^d,Bl:l^f}),({Bh:h,Bl:l}={Bh:yi(h,l,24),Bl:mi(h,l,24)}),Mi[2*e]=u,Mi[2*e+1]=c,Mi[2*t]=l,Mi[2*t+1]=h,Mi[2*n]=f,Mi[2*n+1]=d,Mi[2*r]=p,Mi[2*r+1]=y}function Ai(e,t,n,r,i,o){const s=i[o],a=i[o+1];let u=Mi[2*e],c=Mi[2*e+1],l=Mi[2*t],h=Mi[2*t+1],f=Mi[2*n],d=Mi[2*n+1],p=Mi[2*r],y=Mi[2*r+1],m=ki(u,l,s);c=Si(m,c,h,a),u=0|m,({Dh:y,Dl:p}={Dh:y^c,Dl:p^u}),({Dh:y,Dl:p}={Dh:yi(y,p,16),Dl:mi(y,p,16)}),({h:d,l:f}=Ei(d,f,y,p)),({Bh:h,Bl:l}={Bh:h^d,Bl:l^f}),({Bh:h,Bl:l}={Bh:gi(h,l,63),Bl:bi(h,l,63)}),Mi[2*e]=u,Mi[2*e+1]=c,Mi[2*t]=l,Mi[2*t+1]=h,Mi[2*n]=f,Mi[2*n+1]=d,Mi[2*r]=p,Mi[2*r+1]=y}function Ni(e,t={},n,r,i){if(_r(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:s,personalization:a}=t;if(void 0!==o&&(o.length<1||o.length>n))throw new Error("key length must be undefined or 1.."+n);if(void 0!==s&&s.length!==r)throw new Error("salt must be undefined or "+r);if(void 0!==a&&a.length!==i)throw new Error("personalization must be undefined or "+i)}class ji extends Xr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,_r(e),_r(t),this.blockLen=e,this.outputLen=t,this.buffer=new Uint8Array(e),this.buffer32=Cr(this.buffer)}update(e){Ir(this),Or(e=Jr(e));const{blockLen:t,buffer:n,buffer32:r}=this,i=e.length,o=e.byteOffset,s=e.buffer;for(let a=0;a<i;){this.pos===t&&(Br(r),this.compress(r,0,!1),Br(r),this.pos=0);const u=Math.min(t-this.pos,i-a),c=o+a;if(u===t&&!(c%4)&&a+u<i){const e=new Uint32Array(s,c,Math.floor((i-a)/4));Br(e);for(let n=0;a+t<i;n+=r.length,a+=t)this.length+=t,this.compress(e,n,!1);Br(e);continue}n.set(e.subarray(a,a+u),this.pos),this.pos+=u,this.length+=u,a+=u}return this}digestInto(e){Ir(this),Mr(e,this);const{pos:t,buffer32:n}=this;this.finished=!0,Ar(this.buffer.subarray(t)),Br(n),this.compress(n,0,!0),Br(n);const r=Cr(e);this.get().forEach((e,t)=>r[t]=Pr(e))}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){const{buffer:t,length:n,finished:r,destroyed:i,outputLen:o,pos:s}=this;return e||(e=new this.constructor({dkLen:o})),e.set(...this.get()),e.buffer.set(t),e.destroyed=i,e.finished=r,e.length=n,e.pos=s,e.outputLen=o,e}clone(){return this._cloneInto()}}class Di extends ji{constructor(e={}){const t=void 0===e.dkLen?64:e.dkLen;super(128,t),this.v0l=0|Ii[0],this.v0h=0|Ii[1],this.v1l=0|Ii[2],this.v1h=0|Ii[3],this.v2l=0|Ii[4],this.v2h=0|Ii[5],this.v3l=0|Ii[6],this.v3h=0|Ii[7],this.v4l=0|Ii[8],this.v4h=0|Ii[9],this.v5l=0|Ii[10],this.v5h=0|Ii[11],this.v6l=0|Ii[12],this.v6h=0|Ii[13],this.v7l=0|Ii[14],this.v7h=0|Ii[15],Ni(t,e,64,16,16);let{key:n,personalization:r,salt:i}=e,o=0;if(void 0!==n&&(n=Jr(n),o=n.length),this.v0l^=this.outputLen|o<<8|65536|1<<24,void 0!==i){i=Jr(i);const e=Cr(i);this.v4l^=Pr(e[0]),this.v4h^=Pr(e[1]),this.v5l^=Pr(e[2]),this.v5h^=Pr(e[3])}if(void 0!==r){r=Jr(r);const e=Cr(r);this.v6l^=Pr(e[0]),this.v6h^=Pr(e[1]),this.v7l^=Pr(e[2]),this.v7h^=Pr(e[3])}if(void 0!==n){const e=new Uint8Array(this.blockLen);e.set(n),this.update(e)}}get(){let{v0l:e,v0h:t,v1l:n,v1h:r,v2l:i,v2h:o,v3l:s,v3h:a,v4l:u,v4h:c,v5l:l,v5h:h,v6l:f,v6h:d,v7l:p,v7h:y}=this;return[e,t,n,r,i,o,s,a,u,c,l,h,f,d,p,y]}set(e,t,n,r,i,o,s,a,u,c,l,h,f,d,p,y){this.v0l=0|e,this.v0h=0|t,this.v1l=0|n,this.v1h=0|r,this.v2l=0|i,this.v2h=0|o,this.v3l=0|s,this.v3h=0|a,this.v4l=0|u,this.v4h=0|c,this.v5l=0|l,this.v5h=0|h,this.v6l=0|f,this.v6h=0|d,this.v7l=0|p,this.v7h=0|y}compress(e,t,n){this.get().forEach((e,t)=>Mi[t]=e),Mi.set(Ii,16);let{h:r,l:i}=hi(BigInt(this.length));Mi[24]=Ii[8]^i,Mi[25]=Ii[9]^r,n&&(Mi[28]=~Mi[28],Mi[29]=~Mi[29]);let o=0;const s=ri;for(let n=0;n<12;n++)Ci(0,4,8,12,e,t+2*s[o++]),Ai(0,4,8,12,e,t+2*s[o++]),Ci(1,5,9,13,e,t+2*s[o++]),Ai(1,5,9,13,e,t+2*s[o++]),Ci(2,6,10,14,e,t+2*s[o++]),Ai(2,6,10,14,e,t+2*s[o++]),Ci(3,7,11,15,e,t+2*s[o++]),Ai(3,7,11,15,e,t+2*s[o++]),Ci(0,5,10,15,e,t+2*s[o++]),Ai(0,5,10,15,e,t+2*s[o++]),Ci(1,6,11,12,e,t+2*s[o++]),Ai(1,6,11,12,e,t+2*s[o++]),Ci(2,7,8,13,e,t+2*s[o++]),Ai(2,7,8,13,e,t+2*s[o++]),Ci(3,4,9,14,e,t+2*s[o++]),Ai(3,4,9,14,e,t+2*s[o++]);this.v0l^=Mi[0]^Mi[16],this.v0h^=Mi[1]^Mi[17],this.v1l^=Mi[2]^Mi[18],this.v1h^=Mi[3]^Mi[19],this.v2l^=Mi[4]^Mi[20],this.v2h^=Mi[5]^Mi[21],this.v3l^=Mi[6]^Mi[22],this.v3h^=Mi[7]^Mi[23],this.v4l^=Mi[8]^Mi[24],this.v4h^=Mi[9]^Mi[25],this.v5l^=Mi[10]^Mi[26],this.v5h^=Mi[11]^Mi[27],this.v6l^=Mi[12]^Mi[28],this.v6h^=Mi[13]^Mi[29],this.v7l^=Mi[14]^Mi[30],this.v7h^=Mi[15]^Mi[31],Ar(Mi)}destroy(){this.destroyed=!0,Ar(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Ri=ti(e=>new Di(e));const Pi=Ri;function Bi(e){return at(e).replace("0x","")}class Fi{constructor(e){this.version=2,this.sender=e?.sender??null,this.expiration=e?.expiration??null,this.inputs=e?.inputs??[],this.commands=e?.commands??[],this.gasData=e?.gasData??{budget:null,price:null,owner:null,payment:null}}static fromKindBytes(e){const t=ar.TransactionKind.parse(e).ProgrammableTransaction;if(!t)throw new Error("Unable to deserialize from bytes.");return Fi.restore({version:2,sender:null,expiration:null,gasData:{budget:null,owner:null,payment:null,price:null},inputs:t.inputs,commands:t.commands})}static fromBytes(e){const t=ar.TransactionData.parse(e),n=t?.V1,r=n.kind.ProgrammableTransaction;if(!n||!r)throw new Error("Unable to deserialize from bytes.");return Fi.restore({version:2,sender:n.sender,expiration:n.expiration,gasData:n.gasData,inputs:r.inputs,commands:r.commands})}static restore(e){return 2===e.version?new Fi(Ge(Ot,e)):new Fi(Ge(Ot,function(e){return Ge(Ot,{version:2,sender:e.sender??null,expiration:e.expiration?"Epoch"in e.expiration?{Epoch:e.expiration.Epoch}:{None:!0}:null,gasData:{owner:e.gasConfig.owner??null,budget:e.gasConfig.budget?.toString()??null,price:e.gasConfig.price?.toString()??null,payment:e.gasConfig.payment?.map(e=>({digest:e.digest,objectId:e.objectId,version:e.version.toString()}))??null},inputs:e.inputs.map(e=>{if("Input"===e.kind){if(Ae(jt,e.value)){const t=Ge(jt,e.value);if(t.Object){if(t.Object.ImmOrOwned)return{Object:{ImmOrOwnedObject:{objectId:t.Object.ImmOrOwned.objectId,version:String(t.Object.ImmOrOwned.version),digest:t.Object.ImmOrOwned.digest}}};if(t.Object.Shared)return{Object:{SharedObject:{mutable:t.Object.Shared.mutable??null,initialSharedVersion:t.Object.Shared.initialSharedVersion,objectId:t.Object.Shared.objectId}}};if(t.Object.Receiving)return{Object:{Receiving:{digest:t.Object.Receiving.digest,version:String(t.Object.Receiving.version),objectId:t.Object.Receiving.objectId}}};throw new Error("Invalid object input")}return{Pure:{bytes:o(new Uint8Array(t.Pure))}}}return"object"===e.type?{UnresolvedObject:{objectId:e.value}}:{UnresolvedPure:{value:e.value}}}throw new Error("Invalid input")}),commands:e.transactions.map(e=>{switch(e.kind){case"MakeMoveVec":return{MakeMoveVec:{type:"Some"in e.type?Ct.tagToString(e.type.Some):null,elements:e.objects.map(e=>Ht(e))}};case"MergeCoins":return{MergeCoins:{destination:Ht(e.destination),sources:e.sources.map(e=>Ht(e))}};case"MoveCall":{const[t,n,r]=e.target.split("::");return{MoveCall:{package:t,module:n,function:r,typeArguments:e.typeArguments,arguments:e.arguments.map(e=>Ht(e))}}}case"Publish":return{Publish:{modules:e.modules.map(e=>o(Uint8Array.from(e))),dependencies:e.dependencies}};case"SplitCoins":return{SplitCoins:{coin:Ht(e.coin),amounts:e.amounts.map(e=>Ht(e))}};case"TransferObjects":return{TransferObjects:{objects:e.objects.map(e=>Ht(e)),address:Ht(e.address)}};case"Upgrade":return{Upgrade:{modules:e.modules.map(e=>o(Uint8Array.from(e))),dependencies:e.dependencies,package:e.packageId,ticket:Ht(e.ticket)}}}throw new Error(`Unknown transaction ${Object.keys(e)}`)})})}(e)))}static getDigestFromBytes(e){const t=function(e,t){const n=Array.from(`${e}::`).map(e=>e.charCodeAt(0)),r=new Uint8Array(n.length+t.length);return r.set(n),r.set(t,n.length),Pi(r,{dkLen:32})}("TransactionData",e);return H(t)}get gasConfig(){return this.gasData}set gasConfig(e){this.gasData=e}build({maxSizeBytes:e=1/0,overrides:t,onlyTransactionKind:n}={}){const r=this.inputs,i=this.commands,o={ProgrammableTransaction:{inputs:r,commands:i}};if(n)return ar.TransactionKind.serialize(o,{maxSize:e}).toBytes();const s=t?.expiration??this.expiration,a=t?.sender??this.sender,u={...this.gasData,...t?.gasConfig,...t?.gasData};if(!a)throw new Error("Missing transaction sender");if(!u.budget)throw new Error("Missing gas budget");if(!u.payment)throw new Error("Missing gas payment");if(!u.price)throw new Error("Missing gas price");const c={sender:Bi(a),expiration:s||{None:!0},gasData:{payment:u.payment,owner:Bi(this.gasData.owner??a),price:BigInt(u.price),budget:BigInt(u.budget)},kind:{ProgrammableTransaction:{inputs:r,commands:i}}};return ar.TransactionData.serialize({V1:c},{maxSize:e}).toBytes()}addInput(e,t){const n=this.inputs.length;return this.inputs.push(t),{Input:n,type:e,$kind:"Input"}}getInputUses(e,t){this.mapArguments((n,r)=>("Input"===n.$kind&&n.Input===e&&t(n,r),n))}mapCommandArguments(e,t){const n=this.commands[e];switch(n.$kind){case"MoveCall":n.MoveCall.arguments=n.MoveCall.arguments.map(r=>t(r,n,e));break;case"TransferObjects":n.TransferObjects.objects=n.TransferObjects.objects.map(r=>t(r,n,e)),n.TransferObjects.address=t(n.TransferObjects.address,n,e);break;case"SplitCoins":n.SplitCoins.coin=t(n.SplitCoins.coin,n,e),n.SplitCoins.amounts=n.SplitCoins.amounts.map(r=>t(r,n,e));break;case"MergeCoins":n.MergeCoins.destination=t(n.MergeCoins.destination,n,e),n.MergeCoins.sources=n.MergeCoins.sources.map(r=>t(r,n,e));break;case"MakeMoveVec":n.MakeMoveVec.elements=n.MakeMoveVec.elements.map(r=>t(r,n,e));break;case"Upgrade":n.Upgrade.ticket=t(n.Upgrade.ticket,n,e);break;case"$Intent":const r=n.$Intent.inputs;n.$Intent.inputs={};for(const[i,o]of Object.entries(r))n.$Intent.inputs[i]=Array.isArray(o)?o.map(r=>t(r,n,e)):t(o,n,e);break;case"Publish":break;default:throw new Error(`Unexpected transaction kind: ${n.$kind}`)}}mapArguments(e){for(const t of this.commands.keys())this.mapCommandArguments(t,e)}replaceCommand(e,t,n=e){if(!Array.isArray(t))return void(this.commands[e]=t);const r=t.length-1;this.commands.splice(e,1,...t),0!==r&&this.mapArguments((i,o,s)=>{if(s<e+t.length)return i;switch(i.$kind){case"Result":i.Result===e&&(i.Result=n),i.Result>e&&(i.Result+=r);break;case"NestedResult":i.NestedResult[0]===e&&(i.NestedResult[0]=n),i.NestedResult[0]>e&&(i.NestedResult[0]+=r)}return i})}getDigest(){const e=this.build({onlyTransactionKind:!1});return Fi.getDigestFromBytes(e)}snapshot(){return Ge(Ot,this)}shallowClone(){return new Fi({version:this.version,sender:this.sender,expiration:this.expiration,gasData:{...this.gasData},inputs:[...this.inputs],commands:[...this.commands]})}}function Li(e){return"string"==typeof e?at(e):e.Object?e.Object.ImmOrOwnedObject?at(e.Object.ImmOrOwnedObject.objectId):e.Object.Receiving?at(e.Object.Receiving.objectId):at(e.Object.SharedObject.objectId):e.UnresolvedObject?at(e.UnresolvedObject.objectId):void 0}var Ui,$i,qi=e=>{throw TypeError(e)},Vi=(e,t,n)=>t.has(e)||qi("Cannot "+n),zi=(e,t,n)=>(Vi(e,t,"read from private field"),n?n.call(e):t.get(e)),Ki=(e,t,n)=>t.has(e)?qi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Wi=(e,t,n,r)=>(Vi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);Ui=new WeakMap,$i=new WeakMap;let Qi=class e{constructor({prefix:e,cache:t}={}){Ki(this,Ui),Ki(this,$i),Wi(this,Ui,e??[]),Wi(this,$i,t??new Map)}read(e,t){const n=[zi(this,Ui),...e].join(":");if(zi(this,$i).has(n))return zi(this,$i).get(n);const r=t();return zi(this,$i).set(n,r),"object"==typeof r&&null!==r&&"then"in r?Promise.resolve(r).then(e=>(zi(this,$i).set(n,e),e)).catch(e=>{throw zi(this,$i).delete(n),e}):r}readSync(e,t){const n=[zi(this,Ui),...e].join(":");if(zi(this,$i).has(n))return zi(this,$i).get(n);const r=t();return zi(this,$i).set(n,r),r}clear(e){const t=[...zi(this,Ui),...e??[]].join(":");if(t)for(const e of zi(this,$i).keys())e.startsWith(t)&&zi(this,$i).delete(e);else zi(this,$i).clear()}scope(t){return new e({prefix:[...zi(this,Ui),...Array.isArray(t)?t:[t]],cache:zi(this,$i)})}};class Gi{constructor(e,t){if("function"!=typeof e)throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but got: ${e}.`);this._batchLoadFn=e,this._maxBatchSize=function(e){const t=!e||!1!==e.batch;if(!t)return 1;const n=e&&e.maxBatchSize;if(void 0===n)return 1/0;if("number"!=typeof n||n<1)throw new TypeError(`maxBatchSize must be a positive number: ${n}`);return n}(t),this._batchScheduleFn=function(e){const t=e&&e.batchScheduleFn;if(void 0===t)return Hi;if("function"!=typeof t)throw new TypeError(`batchScheduleFn must be a function: ${t}`);return t}(t),this._cacheKeyFn=function(e){const t=e&&e.cacheKeyFn;if(void 0===t)return e=>e;if("function"!=typeof t)throw new TypeError(`cacheKeyFn must be a function: ${t}`);return t}(t),this._cacheMap=function(e){const t=!e||!1!==e.cache;if(!t)return null;const n=e&&e.cacheMap;if(void 0===n)return new Map;if(null!==n){const e=["get","set","delete","clear"].filter(e=>n&&"function"!=typeof n[e]);if(0!==e.length)throw new TypeError("Custom cacheMap missing methods: "+e.join(", "))}return n}(t),this._batch=null,this.name=function(e){if(e&&e.name)return e.name;return null}(t)}load(e){if(null==e)throw new TypeError(`The loader.load() function must be called with a value, but got: ${String(e)}.`);const t=function(e){const t=e._batch;if(null!==t&&!t.hasDispatched&&t.keys.length<e._maxBatchSize)return t;const n={hasDispatched:!1,keys:[],callbacks:[]};return e._batch=n,e._batchScheduleFn(()=>{!function(e,t){if(t.hasDispatched=!0,0===t.keys.length)return void Yi(t);let n;try{n=e._batchLoadFn(t.keys)}catch(n){return Zi(e,t,new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function errored synchronously: ${String(n)}.`))}if(!n||"function"!=typeof n.then)return Zi(e,t,new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise: ${String(n)}.`));Promise.resolve(n).then(e=>{if(!Xi(e))throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array: ${String(e)}.`);if(e.length!==t.keys.length)throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys.\n\nKeys:\n${String(t.keys)}\n\nValues:\n${String(e)}`);Yi(t);for(let n=0;n<t.callbacks.length;n++){const r=e[n];r instanceof Error?t.callbacks[n].reject(r):t.callbacks[n].resolve(r)}}).catch(n=>{Zi(e,t,n)})}(e,n)}),n}(this),n=this._cacheMap;let r;if(n){r=this._cacheKeyFn(e);const i=n.get(r);if(i){const e=t.cacheHits||(t.cacheHits=[]);return new Promise(t=>{e.push(()=>{t(i)})})}}t.keys.push(e);const i=new Promise((e,n)=>{t.callbacks.push({resolve:e,reject:n})});return n&&n.set(r,i),i}loadMany(e){if(!Xi(e))throw new TypeError(`The loader.loadMany() function must be called with Array<key>, but got: ${e}.`);const t=[];for(let n=0;n<e.length;n++)t.push(this.load(e[n]).catch(e=>e));return Promise.all(t)}clear(e){const t=this._cacheMap;if(t){const n=this._cacheKeyFn(e);t.delete(n)}return this}clearAll(){const e=this._cacheMap;return e&&e.clear(),this}prime(e,t){const n=this._cacheMap;if(n){const r=this._cacheKeyFn(e);if(void 0===n.get(r)){let e;t instanceof Error?(e=Promise.reject(t),e.catch(()=>{})):e=Promise.resolve(t),n.set(r,e)}}return this}}const Hi="object"==typeof process&&"function"==typeof process.nextTick?function(e){Ji||(Ji=Promise.resolve()),Ji.then(()=>{process.nextTick(e)})}:"function"==typeof setImmediate?function(e){setImmediate(e)}:function(e){setTimeout(e)};let Ji;function Zi(e,t,n){Yi(t);for(let r=0;r<t.keys.length;r++)e.clear(t.keys[r]),t.callbacks[r].reject(n)}function Yi(e){if(e.cacheHits)for(let t=0;t<e.cacheHits.length;t++)e.cacheHits[t]()}function Xi(e){return"object"==typeof e&&null!==e&&"length"in e&&"number"==typeof e.length&&(0===e.length||e.length>0&&Object.prototype.hasOwnProperty.call(e,e.length-1))}const eo="1.35.0";var to,no,ro,io,oo,so,ao,uo,co,lo,ho=e=>{throw TypeError(e)},fo=(e,t,n)=>t.has(e)||ho("Cannot "+n),po=(e,t,n)=>(fo(e,t,"read from private field"),n?n.call(e):t.get(e)),yo=(e,t,n)=>t.has(e)?ho("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),mo=(e,t,n,r)=>(fo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),go=(e,t,n)=>(fo(e,t,"access private method"),n);const bo={"Mvr-Source":`@mysten/sui@${eo}`};class vo{constructor({cache:e,url:t,pageSize:n=50,overrides:r}){yo(this,oo),yo(this,to),yo(this,no),yo(this,ro),yo(this,io),mo(this,to,e),mo(this,no,t),mo(this,ro,n),mo(this,io,{packages:r?.packages,types:r?.types}),function(e){if(e?.packages)for(const[t,n]of Object.entries(e.packages)){if(!et(t))throw new Error(`Invalid package name: ${t}`);if(!rt(at(n)))throw new Error(`Invalid package ID: ${n}`)}if(e?.types)for(const[t,n]of Object.entries(e.types)){if(ot(t).typeParams.length>0)throw new Error("Type overrides must be first-level only. If you want to supply generic types, just pass each type individually.");if(!rt(ot(n).address))throw new Error(`Invalid type: ${n}`)}}(po(this,io))}async resolvePackage({package:e}){return{package:await po(this,oo,so).load(e)}}async resolveType({type:e}){const t=[...wo(e)],n=await po(this,oo,ao).loadMany(t),r={};for(let e=0;e<t.length;e++){const i=n[e];if(i instanceof Error)throw i;r[t[e]]=i}return{type:Eo(e,r)}}async resolve({types:e=[],packages:t=[]}){const n=new Set;for(const t of e??[])wo(t,n);const r=[...n],[i,o]=await Promise.all([r.length>0?po(this,oo,ao).loadMany(r):[],t.length>0?po(this,oo,so).loadMany(t):[]]),s={...po(this,io)?.types};for(const[e,t]of r.entries()){const n=i[e];if(n instanceof Error)throw n;s[t]=n}const a={};for(const t of e??[]){const e=Eo(t,s);a[t]={type:e}}const u={};for(const[e,n]of(t??[]).entries()){const t=po(this,io)?.packages?.[n]??o[e];if(t instanceof Error)throw t;u[n]={package:t}}return{types:a,packages:u}}}function wo(e,t=new Set){if("string"==typeof e&&!ko(e))return t;const n=So(e)?e:ot(e);ko(n.address)&&t.add(`${n.address}::${n.module}::${n.name}`);for(const e of n.typeParams)wo(e,t);return t}function Eo(e,t){const n=So(e)?e:ot(e),r=`${n.address}::${n.module}::${n.name}`,i=t[r];return st({...n,address:i?i.split("::")[0]:n.address,typeParams:n.typeParams.map(e=>Eo(e,t))})}function ko(e){return e.includes("/")||e.includes("@")||e.includes(".sui")}function So(e){return"object"==typeof e&&"address"in e&&"module"in e&&"name"in e&&"typeParams"in e}function To(e){const t=new Set;for(const n of e)if(ko(n)){if(!tt(n))throw new Error(`Invalid type with names: ${n}`);t.add(n)}return t}to=new WeakMap,no=new WeakMap,ro=new WeakMap,io=new WeakMap,oo=new WeakSet,so=function(){return po(this,to).readSync(["#mvrPackageDataLoader",po(this,no)??""],()=>{const e=new Gi(async e=>{if(!po(this,no))throw new Error(`MVR Api URL is not set for the current client (resolving ${e.join(", ")})`);const t=await go(this,oo,uo).call(this,e);return e.map(e=>t[e]??new Error(`Failed to resolve package: ${e}`))}),t=po(this,io)?.packages;if(t)for(const[n,r]of Object.entries(t))e.prime(n,r);return e})},ao=function(){return po(this,to).readSync(["#mvrTypeDataLoader",po(this,no)??""],()=>{const e=new Gi(async e=>{if(!po(this,no))throw new Error(`MVR Api URL is not set for the current client (resolving ${e.join(", ")})`);const t=await go(this,oo,co).call(this,e);return e.map(e=>t[e]??new Error(`Failed to resolve type: ${e}`))}),t=po(this,io)?.types;if(t)for(const[n,r]of Object.entries(t))e.prime(n,r);return e})},uo=async function(e){if(0===e.length)return{};const t=fr(e,po(this,ro)),n={};return await Promise.all(t.map(async e=>{const t=await go(this,oo,lo).call(this,"/v1/resolution/bulk",{names:e});if(t?.resolution)for(const e of Object.keys(t?.resolution)){const r=t.resolution[e]?.package_id;r&&(n[e]=r)}})),n},co=async function(e){if(0===e.length)return{};const t=fr(e,po(this,ro)),n={};return await Promise.all(t.map(async e=>{const t=await go(this,oo,lo).call(this,"/v1/struct-definition/bulk",{types:e});if(t?.resolution)for(const e of Object.keys(t?.resolution)){const r=t.resolution[e]?.type_tag;r&&(n[e]=r)}})),n},lo=async function(e,t){if(!po(this,no))throw new Error("MVR Api URL is not set for the current client");const n=await fetch(`${po(this,no)}${e}`,{method:"POST",headers:{"Content-Type":"application/json",...bo},body:JSON.stringify(t)});if(!n.ok){const e=await n.json().catch(()=>({}));throw new Error(`Failed to resolve types: ${e?.message}`)}return n.json()};const _o=new WeakMap,Oo=e=>{let t;if(e){const n=e.overrides??{packages:{},types:{}};_o.has(n)||_o.set(n,new Qi),t=new vo({cache:_o.get(n),url:e.url,pageSize:e.pageSize,overrides:n})}return async(e,n,r)=>{const i=function(e){const t=new Set,n=new Set;for(const r of e.commands)switch(r.$kind){case"MakeMoveVec":r.MakeMoveVec.type&&To([r.MakeMoveVec.type]).forEach(e=>{n.add(e)});break;case"MoveCall":const e=r.MoveCall,i=e.package.split("::")[0];if(ko(i)){if(!et(i))throw new Error(`Invalid package name: ${i}`);t.add(i)}To(e.typeArguments??[]).forEach(e=>{n.add(e)})}return{packages:[...t],types:[...n]}}(e);if(0===i.types.length&&0===i.packages.length)return r();const o=await(t||function(e){if(!e.client)throw new Error("No sui client passed to Transaction#build, but transaction data was not sufficient to build offline.");return e.client}(n).core.mvr).resolve({types:i.types,packages:i.packages});!function(e,t){for(const n of e.commands){if(n.MakeMoveVec?.type){if(!ko(n.MakeMoveVec.type))continue;if(!t.types[n.MakeMoveVec.type])throw new Error(`No resolution found for type: ${n.MakeMoveVec.type}`);n.MakeMoveVec.type=t.types[n.MakeMoveVec.type].type}const e=n.MoveCall;if(!e)continue;const r=e.package.split("::"),i=r[0];if(ko(i)&&!t.packages[i])throw new Error(`No address found for package: ${i}`);ko(i)&&(r[0]=t.packages[i].package,e.package=r.join("::"));const o=e.typeArguments;if(o){for(let e=0;e<o.length;e++)if(ko(o[e])){if(!t.types[o[e]])throw new Error(`No resolution found for type: ${o[e]}`);o[e]=t.types[o[e]].type}e.typeArguments=o}}}(e,o),await r()}};var xo,Io,Mo,Co,Ao,No,jo,Do,Ro,Po,Bo,Fo,Lo,Uo,$o,qo,Vo,zo,Ko,Wo=e=>{throw TypeError(e)},Qo=(e,t,n)=>t.has(e)||Wo("Cannot "+n),Go=(e,t,n)=>(Qo(e,t,"read from private field"),n?n.call(e):t.get(e)),Ho=(e,t,n)=>t.has(e)?Wo("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Jo=(e,t,n,r)=>(Qo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Zo=(e,t,n)=>(Qo(e,t,"access private method"),n);function Yo(e,t=1/0){const n=[],r=t=>n[t]??(n[t]={$kind:"NestedResult",get NestedResult(){return["function"==typeof e?e():e,t]}});return new Proxy({$kind:"Result",get Result(){return"function"==typeof e?e():e}},{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(e,n){if(n in e)return Reflect.get(e,n);if(n===Symbol.iterator)return function*(){let e=0;for(;e<t;)yield r(e),e++};if("symbol"==typeof n)return;const i=parseInt(n,10);return Number.isNaN(i)||i<0?void 0:r(i)}})}const Xo=Symbol.for("@mysten/transaction");function es(e){return!!e&&"object"==typeof e&&!0===e[Xo]}const ts={buildPlugins:new Map,serializationPlugins:new Map},ns=Symbol.for("@mysten/transaction/registry");function rs(){try{const e=globalThis;return e[ns]||(e[ns]=ts),e[ns]}catch(e){return ts}}const is=class e{constructor(){Ho(this,Po),Ho(this,xo),Ho(this,Io),Ho(this,Mo,new Map),Ho(this,Co,[]),Ho(this,Ao,[]),Ho(this,No,new Set),Ho(this,jo,new Set),Ho(this,Do,new Map),Ho(this,Ro),this.object=function(e){function t(t){return e(t)}return t.system=()=>t("0x5"),t.clock=()=>t("0x6"),t.random=()=>t("0x8"),t.denyList=()=>t("0x403"),t.option=({type:e,value:t})=>n=>n.moveCall({typeArguments:[e],target:"0x1::option::"+(null===t?"none":"some"),arguments:null===t?[]:[n.object(t)]}),t}(e=>{if("function"==typeof e)return this.object(this.add(e));if("object"==typeof e&&Ae(yt,e))return e;const t=Li(e),n=Go(this,Ro).inputs.find(e=>t===Li(e));return n?.Object?.SharedObject&&"object"==typeof e&&e.Object?.SharedObject&&(n.Object.SharedObject.mutable=n.Object.SharedObject.mutable||e.Object.SharedObject.mutable),n?{$kind:"Input",Input:Go(this,Ro).inputs.indexOf(n),type:"object"}:Zo(this,Po,Lo).call(this,"object","string"==typeof e?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:at(e)}}:e)});const e=rs();Jo(this,Ro,new Fi),Jo(this,Io,[...e.buildPlugins.values()]),Jo(this,xo,[...e.serializationPlugins.values()])}static fromKind(n){const r=new e;return Jo(r,Ro,Fi.fromKindBytes("string"==typeof n?t(n):n)),Jo(r,Co,Go(r,Ro).inputs.slice()),Jo(r,Ao,Go(r,Ro).commands.slice()),Jo(r,No,new Set(Go(r,Ao).map((e,t)=>t))),r}static from(n){const r=new e;return es(n)?Jo(r,Ro,new Fi(n.getData())):"string"==typeof n&&n.startsWith("{")?Jo(r,Ro,Fi.restore(JSON.parse(n))):Jo(r,Ro,Fi.fromBytes("string"==typeof n?t(n):n)),Jo(r,Co,Go(r,Ro).inputs.slice()),Jo(r,Ao,Go(r,Ro).commands.slice()),Jo(r,No,new Set(Go(r,Ao).map((e,t)=>t))),r}static registerGlobalSerializationPlugin(e,t){rs().serializationPlugins.set(e,t??e)}static unregisterGlobalSerializationPlugin(e){rs().serializationPlugins.delete(e)}static registerGlobalBuildPlugin(e,t){rs().buildPlugins.set(e,t??e)}static unregisterGlobalBuildPlugin(e){rs().buildPlugins.delete(e)}addSerializationPlugin(e){Go(this,xo).push(e)}addBuildPlugin(e){Go(this,Io).push(e)}addIntentResolver(e,t){if(Go(this,Mo).has(e)&&Go(this,Mo).get(e)!==t)throw new Error(`Intent resolver for ${e} already exists`);Go(this,Mo).set(e,t)}setSender(e){Go(this,Ro).sender=e}setSenderIfNotSet(e){Go(this,Ro).sender||(Go(this,Ro).sender=e)}setExpiration(e){Go(this,Ro).expiration=e?Ge(_t,e):null}setGasPrice(e){Go(this,Ro).gasConfig.price=String(e)}setGasBudget(e){Go(this,Ro).gasConfig.budget=String(e)}setGasBudgetIfNotSet(e){null==Go(this,Ro).gasData.budget&&(Go(this,Ro).gasConfig.budget=String(e))}setGasOwner(e){Go(this,Ro).gasConfig.owner=e}setGasPayment(e){Go(this,Ro).gasConfig.payment=e.map(e=>Ge(pt,e))}get blockData(){return Qt(Go(this,Ro).snapshot())}getData(){return Go(this,Ro).snapshot()}get[Xo](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:kr(e=>de(e)?Zo(this,Po,Lo).call(this,"pure",{$kind:"Pure",Pure:{bytes:e.toBase64()}}):Zo(this,Po,Lo).call(this,"pure",Ae(Tt,e)?Ge(Tt,e):e instanceof Uint8Array?an.Pure(e):{$kind:"UnresolvedPure",UnresolvedPure:{value:e}}))}),this.pure}get gas(){return{$kind:"GasCoin",GasCoin:!0}}objectRef(...e){return this.object(an.ObjectRef(...e))}receivingRef(...e){return this.object(an.ReceivingRef(...e))}sharedObjectRef(...e){return this.object(an.SharedObjectRef(...e))}add(e){if("function"==typeof e){if(Go(this,Do).has(e))return Go(this,Do).get(e);const t=Zo(this,Po,Bo).call(this),n=e(t);if(!n||"object"!=typeof n||!("then"in n))return Jo(this,No,Go(t,No)),Go(this,Do).set(e,n),n;const r=Zo(this,Po,Fo).call(this,{$kind:"$Intent",$Intent:{name:"AsyncTransactionThunk",inputs:{},data:{resultIndex:Go(this,Ro).commands.length,result:null}}});Go(this,jo).add(Promise.resolve(n).then(e=>{r.$Intent.data.result=e}));const i=Yo(()=>r.$Intent.data.resultIndex);return Go(this,Do).set(e,i),i}return Zo(this,Po,Fo).call(this,e),Yo(Go(this,Ro).commands.length-1)}splitCoins(e,t){const n=xt.SplitCoins("string"==typeof e?this.object(e):Zo(this,Po,$o).call(this,e),t.map(e=>"number"==typeof e||"bigint"==typeof e||"string"==typeof e?this.pure.u64(e):Zo(this,Po,Uo).call(this,e)));return Zo(this,Po,Fo).call(this,n),Yo(Go(this,Ro).commands.length-1,t.length)}mergeCoins(e,t){return this.add(xt.MergeCoins(this.object(e),t.map(e=>this.object(e))))}publish({modules:e,dependencies:t}){return this.add(xt.Publish({modules:e,dependencies:t}))}upgrade({modules:e,dependencies:t,package:n,ticket:r}){return this.add(xt.Upgrade({modules:e,dependencies:t,package:n,ticket:this.object(r)}))}moveCall({arguments:e,...t}){return this.add(xt.MoveCall({...t,arguments:e?.map(e=>Zo(this,Po,Uo).call(this,e))}))}transferObjects(e,t){return this.add(xt.TransferObjects(e.map(e=>this.object(e)),"string"==typeof t?this.pure.address(t):Zo(this,Po,Uo).call(this,t)))}makeMoveVec({type:e,elements:t}){return this.add(xt.MakeMoveVec({type:e,elements:t.map(e=>this.object(e))}))}serialize(){return JSON.stringify(Qt(Go(this,Ro).snapshot()))}async toJSON(e={}){await this.prepareForSerialization(e);const t=this.isFullyResolved();return JSON.stringify(Ge(sn,t?{...Go(this,Ro).snapshot(),digest:Go(this,Ro).getDigest()}:Go(this,Ro).snapshot()),(e,t)=>"bigint"==typeof t?t.toString():t,2)}async sign(e){const{signer:t,...n}=e,r=await this.build(n);return t.signTransaction(r)}isFullyResolved(){return!!Go(this,Ro).sender&&(!(Go(this,jo).size>0)&&(!Go(this,Ro).commands.some(e=>e.$Intent)&&!gr(Go(this,Ro),{})))}async build(e={}){return await this.prepareForSerialization(e),await Zo(this,Po,qo).call(this,e),Go(this,Ro).build({onlyTransactionKind:e.onlyTransactionKind})}async getDigest(e={}){return await this.prepareForSerialization(e),await Zo(this,Po,qo).call(this,e),Go(this,Ro).getDigest()}async prepareForSerialization(e){await Zo(this,Po,zo).call(this),Zo(this,Po,Ko).call(this);const t=new Set;for(const e of Go(this,Ro).commands)e.$Intent&&t.add(e.$Intent.name);const n=[...Go(this,xo)];for(const r of t)if(!e.supportedIntents?.includes(r)){if(!Go(this,Mo).has(r))throw new Error(`Missing intent resolver for ${r}`);n.push(Go(this,Mo).get(r))}n.push(Oo()),await Zo(this,Po,Vo).call(this,n,e)}};xo=new WeakMap,Io=new WeakMap,Mo=new WeakMap,Co=new WeakMap,Ao=new WeakMap,No=new WeakMap,jo=new WeakMap,Do=new WeakMap,Ro=new WeakMap,Po=new WeakSet,Bo=function(){const e=new is;return Jo(e,Ro,Go(this,Ro)),Jo(e,xo,Go(this,xo)),Jo(e,Io,Go(this,Io)),Jo(e,Mo,Go(this,Mo)),Jo(e,jo,Go(this,jo)),Jo(e,No,new Set(Go(this,No))),Jo(e,Do,Go(this,Do)),Go(this,Co).push(Go(e,Co)),Go(this,Ao).push(Go(e,Ao)),e},Fo=function(e){const t=Go(this,Ro).commands.length;return Go(this,Ao).push(e),Go(this,No).add(t),Go(this,Ro).commands.push(e),Go(this,Ro).mapCommandArguments(t,e=>{if("Result"===e.$kind&&!Go(this,No).has(e.Result))throw new Error(`Result { Result: ${e.Result} } is not available to use the current transaction`);if("NestedResult"===e.$kind&&!Go(this,No).has(e.NestedResult[0]))throw new Error(`Result { NestedResult: [${e.NestedResult[0]}, ${e.NestedResult[1]}] } is not available to use the current transaction`);if("Input"===e.$kind&&e.Input>=Go(this,Ro).inputs.length)throw new Error(`Input { Input: ${e.Input} } references an input that does not exist in the current transaction`);return e}),e},Lo=function(e,t){return Go(this,Co).push(t),Go(this,Ro).addInput(e,t)},Uo=function(e){return de(e)?this.pure(e):Zo(this,Po,$o).call(this,e)},$o=function(e){if("function"==typeof e){const t=this.add(e);return"function"==typeof t?Zo(this,Po,$o).call(this,t):Ge(yt,t)}return Ge(yt,e)},qo=async function(e){if(!e.onlyTransactionKind&&!Go(this,Ro).sender)throw new Error("Missing transaction sender");await Zo(this,Po,Vo).call(this,[...Go(this,Io),br],e)},Vo=async function(e,t){const n=r=>{if(r>=e.length)return()=>{};const i=e[r];return async()=>{const e=n(r+1);let o=!1,s=!1;if(await i(Go(this,Ro),t,async()=>{if(o)throw new Error(`next() was call multiple times in TransactionPlugin ${r}`);o=!0,await e(),s=!0}),!o)throw new Error(`next() was not called in TransactionPlugin ${r}`);if(!s)throw new Error(`next() was not awaited in TransactionPlugin ${r}`)}};await n(0)(),Jo(this,Co,Go(this,Ro).inputs.slice()),Jo(this,Ao,Go(this,Ro).commands.slice())},zo=async function(){for(;Go(this,jo).size>0;){const e=Promise.all(Go(this,jo));Go(this,jo).clear(),Go(this,jo).add(e),await e,Go(this,jo).delete(e)}},Ko=function(){const e=Go(this,Ro).commands,t=Go(this,Ro).inputs,n=Go(this,Ao).flat(1/0),r=Go(this,Co).flat(1/0);if(n.length!==e.length)throw new Error("Unexpected number of commands found in transaction data");if(r.length!==t.length)throw new Error("Unexpected number of inputs found in transaction data");const i=n.filter(e=>"AsyncTransactionThunk"!==e.$Intent?.name);function o(t){const n=e[t];if("AsyncTransactionThunk"===n.$Intent?.name){const e=n.$Intent.data.result;if(null==e)throw new Error("AsyncTransactionThunk has not been resolved");return o(e.Result)}const r=i.indexOf(n);if(-1===r)throw new Error("Unable to find original index for command");return r}Go(this,Ro).commands=i,Go(this,Ro).inputs=r,Jo(this,Ao,i),Jo(this,Co,r),Jo(this,No,new Set(i.map((e,t)=>t))),Go(this,Ro).mapArguments(e=>{if("Input"===e.$kind){const n=r.indexOf(t[e.Input]);if(-1===n)throw new Error("Input has not been resolved");return{...e,Input:n}}if("Result"===e.$kind){const t=o(e.Result);return{...e,Result:t}}if("NestedResult"===e.$kind){const t=o(e.NestedResult[0]);return{...e,NestedResult:[t,e.NestedResult[1]]}}return e});for(const[t,n]of e.entries())if("AsyncTransactionThunk"===n.$Intent?.name)try{n.$Intent.data.resultIndex=o(t)}catch(e){}};let os=is;const ss=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]),as=new Uint32Array(64);class us extends si{constructor(e=32){super(64,e,8,!1),this.A=0|ai[0],this.B=0|ai[1],this.C=0|ai[2],this.D=0|ai[3],this.E=0|ai[4],this.F=0|ai[5],this.G=0|ai[6],this.H=0|ai[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[e,t,n,r,i,o,s,a]}set(e,t,n,r,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)as[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=as[e-15],n=as[e-2],r=jr(t,7)^jr(t,18)^t>>>3,i=jr(n,17)^jr(n,19)^n>>>10;as[e]=i+as[e-7]+r+as[e-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:u,H:c}=this;for(let e=0;e<64;e++){const t=c+(jr(s,6)^jr(s,11)^jr(s,25))+ii(s,a,u)+ss[e]+as[e]|0,l=(jr(n,2)^jr(n,13)^jr(n,22))+oi(n,r,i)|0;c=u,u=a,a=s,s=o+t|0,o=i,i=r,r=n,n=t+l|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(n,r,i,o,s,a,u,c)}roundClean(){Ar(as)}destroy(){this.set(0,0,0,0,0,0,0,0),Ar(this.buffer)}}const cs=(()=>fi(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))))(),ls=(()=>cs[0])(),hs=(()=>cs[1])(),fs=new Uint32Array(80),ds=new Uint32Array(80);class ps extends si{constructor(e=64){super(128,e,16,!1),this.Ah=0|ui[0],this.Al=0|ui[1],this.Bh=0|ui[2],this.Bl=0|ui[3],this.Ch=0|ui[4],this.Cl=0|ui[5],this.Dh=0|ui[6],this.Dl=0|ui[7],this.Eh=0|ui[8],this.El=0|ui[9],this.Fh=0|ui[10],this.Fl=0|ui[11],this.Gh=0|ui[12],this.Gl=0|ui[13],this.Hh=0|ui[14],this.Hl=0|ui[15]}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:o,Dh:s,Dl:a,Eh:u,El:c,Fh:l,Fl:h,Gh:f,Gl:d,Hh:p,Hl:y}=this;return[e,t,n,r,i,o,s,a,u,c,l,h,f,d,p,y]}set(e,t,n,r,i,o,s,a,u,c,l,h,f,d,p,y){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|u,this.El=0|c,this.Fh=0|l,this.Fl=0|h,this.Gh=0|f,this.Gl=0|d,this.Hh=0|p,this.Hl=0|y}process(e,t){for(let n=0;n<16;n++,t+=4)fs[n]=e.getUint32(t),ds[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|fs[e-15],n=0|ds[e-15],r=yi(t,n,1)^yi(t,n,8)^di(t,0,7),i=mi(t,n,1)^mi(t,n,8)^pi(t,n,7),o=0|fs[e-2],s=0|ds[e-2],a=yi(o,s,19)^gi(o,s,61)^di(o,0,6),u=mi(o,s,19)^bi(o,s,61)^pi(o,s,6),c=Ti(i,u,ds[e-7],ds[e-16]),l=_i(c,r,a,fs[e-7],fs[e-16]);fs[e]=0|l,ds[e]=0|c}let{Ah:n,Al:r,Bh:i,Bl:o,Ch:s,Cl:a,Dh:u,Dl:c,Eh:l,El:h,Fh:f,Fl:d,Gh:p,Gl:y,Hh:m,Hl:g}=this;for(let e=0;e<80;e++){const t=yi(l,h,14)^yi(l,h,18)^gi(l,h,41),b=mi(l,h,14)^mi(l,h,18)^bi(l,h,41),v=l&f^~l&p,w=Oi(g,b,h&d^~h&y,hs[e],ds[e]),E=xi(w,m,t,v,ls[e],fs[e]),k=0|w,S=yi(n,r,28)^gi(n,r,34)^gi(n,r,39),T=mi(n,r,28)^bi(n,r,34)^bi(n,r,39),_=n&i^n&s^i&s,O=r&o^r&a^o&a;m=0|p,g=0|y,p=0|f,y=0|d,f=0|l,d=0|h,({h:l,l:h}=Ei(0|u,0|c,0|E,0|k)),u=0|s,c=0|a,s=0|i,a=0|o,i=0|n,o=0|r;const x=ki(k,T,O);n=Si(x,E,S,_),r=0|x}({h:n,l:r}=Ei(0|this.Ah,0|this.Al,0|n,0|r)),({h:i,l:o}=Ei(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=Ei(0|this.Ch,0|this.Cl,0|s,0|a)),({h:u,l:c}=Ei(0|this.Dh,0|this.Dl,0|u,0|c)),({h:l,l:h}=Ei(0|this.Eh,0|this.El,0|l,0|h)),({h:f,l:d}=Ei(0|this.Fh,0|this.Fl,0|f,0|d)),({h:p,l:y}=Ei(0|this.Gh,0|this.Gl,0|p,0|y)),({h:m,l:g}=Ei(0|this.Hh,0|this.Hl,0|m,0|g)),this.set(n,r,i,o,s,a,u,c,l,h,f,d,p,y,m,g)}roundClean(){Ar(fs,ds)}destroy(){Ar(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ys=ei(()=>new us),ms=ei(()=>new ps),gs=BigInt(0),bs=BigInt(1);function vs(e,t=""){if("boolean"!=typeof e){throw new Error((t&&`"${t}"`)+"expected boolean, got type="+typeof e)}return e}function ws(e,t,n=""){const r=Tr(e),i=e?.length,o=void 0!==t;if(!r||o&&i!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(o?` of length ${t}`:"")+", got "+(r?`length=${i}`:"type="+typeof e))}return e}function Es(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?gs:BigInt("0x"+e)}function ks(e){return Or(e),Es(Ur(Uint8Array.from(e).reverse()))}function Ss(e,t){return Gr(e.toString(16).padStart(2*t,"0"))}function Ts(e,t,n){let r;if("string"==typeof t)try{r=Gr(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!Tr(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(e+" of length "+n+" expected, got "+i);return r}function _s(e){return Uint8Array.from(e)}const Os=e=>"bigint"==typeof e&&gs<=e;function xs(e,t,n,r){if(!function(e,t,n){return Os(e)&&Os(t)&&Os(n)&&t<=e&&e<n}(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}const Is=e=>(bs<<BigInt(e))-bs;function Ms(e,t,n={}){if(!e||"object"!=typeof e)throw new Error("expected valid options object");function r(t,n,r){const i=e[t];if(r&&void 0===i)return;const o=typeof i;if(o!==n||null===i)throw new Error(`param "${t}" is invalid: expected ${n}, got ${o}`)}Object.entries(t).forEach(([e,t])=>r(e,t,!1)),Object.entries(n).forEach(([e,t])=>r(e,t,!0))}const Cs=()=>{throw new Error("not implemented")};function As(e){const t=new WeakMap;return(n,...r)=>{const i=t.get(n);if(void 0!==i)return i;const o=e(n,...r);return t.set(n,o),o}}const Ns=BigInt(0),js=BigInt(1),Ds=BigInt(2),Rs=BigInt(3),Ps=BigInt(4),Bs=BigInt(5),Fs=BigInt(7),Ls=BigInt(8),Us=BigInt(9),$s=BigInt(16);function qs(e,t){const n=e%t;return n>=Ns?n:t+n}function Vs(e,t,n){let r=e;for(;t-- >Ns;)r*=r,r%=n;return r}function zs(e,t){if(e===Ns)throw new Error("invert: expected non-zero number");if(t<=Ns)throw new Error("invert: expected positive modulus, got "+t);let n=qs(e,t),r=t,i=Ns,o=js,s=js,a=Ns;for(;n!==Ns;){const e=r/n,t=r%n,u=i-s*e,c=o-a*e;r=n,n=t,i=s,o=a,s=u,a=c}if(r!==js)throw new Error("invert: does not exist");return qs(i,t)}function Ks(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function Ws(e,t){const n=(e.ORDER+js)/Ps,r=e.pow(t,n);return Ks(e,r,t),r}function Qs(e,t){const n=(e.ORDER-Bs)/Ls,r=e.mul(t,Ds),i=e.pow(r,n),o=e.mul(t,i),s=e.mul(e.mul(o,Ds),i),a=e.mul(o,e.sub(s,e.ONE));return Ks(e,a,t),a}function Gs(e){if(e<Rs)throw new Error("sqrt is not defined for small field");let t=e-js,n=0;for(;t%Ds===Ns;)t/=Ds,n++;let r=Ds;const i=na(e);for(;1===ea(i,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return Ws;let o=i.pow(r,t);const s=(t+js)/Ds;return function(e,r){if(e.is0(r))return r;if(1!==ea(e,r))throw new Error("Cannot find square root");let i=n,a=e.mul(e.ONE,o),u=e.pow(r,t),c=e.pow(r,s);for(;!e.eql(u,e.ONE);){if(e.is0(u))return e.ZERO;let t=1,n=e.sqr(u);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===i)throw new Error("Cannot find square root");const r=js<<BigInt(i-t-1),o=e.pow(a,r);i=t,a=e.sqr(o),u=e.mul(u,a),c=e.mul(c,o)}return c}}function Hs(e){return e%Ps===Rs?Ws:e%Ls===Bs?Qs:e%$s===Us?function(e){const t=na(e),n=Gs(e),r=n(t,t.neg(t.ONE)),i=n(t,r),o=n(t,t.neg(r)),s=(e+Fs)/$s;return(e,t)=>{let n=e.pow(t,s),a=e.mul(n,r);const u=e.mul(n,i),c=e.mul(n,o),l=e.eql(e.sqr(a),t),h=e.eql(e.sqr(u),t);n=e.cmov(n,a,l),a=e.cmov(c,u,h);const f=e.eql(e.sqr(a),t),d=e.cmov(n,a,f);return Ks(e,d,t),d}}(e):Gs(e)}const Js=(e,t)=>(qs(e,t)&js)===js,Zs=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ys(e,t,n){if(n<Ns)throw new Error("invalid exponent, negatives unsupported");if(n===Ns)return e.ONE;if(n===js)return t;let r=e.ONE,i=t;for(;n>Ns;)n&js&&(r=e.mul(r,i)),i=e.sqr(i),n>>=js;return r}function Xs(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),i=t.reduce((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n)),e.ONE),o=e.inv(i);return t.reduceRight((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n)),o),r}function ea(e,t){const n=(e.ORDER-js)/Ds,r=e.pow(t,n),i=e.eql(r,e.ONE),o=e.eql(r,e.ZERO),s=e.eql(r,e.neg(e.ONE));if(!i&&!o&&!s)throw new Error("invalid Legendre symbol result");return i?1:o?0:-1}function ta(e,t){void 0!==t&&_r(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function na(e,t,n=!1,r={}){if(e<=Ns)throw new Error("invalid field: expected ORDER > 0, got "+e);let i,o,s,a=!1;if("object"==typeof t&&null!=t){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const e=t;e.BITS&&(i=e.BITS),e.sqrt&&(o=e.sqrt),"boolean"==typeof e.isLE&&(n=e.isLE),"boolean"==typeof e.modFromBytes&&(a=e.modFromBytes),s=e.allowedLengths}else"number"==typeof t&&(i=t),r.sqrt&&(o=r.sqrt);const{nBitLength:u,nByteLength:c}=ta(e,i);if(c>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let l;const h=Object.freeze({ORDER:e,isLE:n,BITS:u,BYTES:c,MASK:Is(u),ZERO:Ns,ONE:js,allowedLengths:s,create:t=>qs(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return Ns<=t&&t<e},is0:e=>e===Ns,isValidNot0:e=>!h.is0(e)&&h.isValid(e),isOdd:e=>(e&js)===js,neg:t=>qs(-t,e),eql:(e,t)=>e===t,sqr:t=>qs(t*t,e),add:(t,n)=>qs(t+n,e),sub:(t,n)=>qs(t-n,e),mul:(t,n)=>qs(t*n,e),pow:(e,t)=>Ys(h,e,t),div:(t,n)=>qs(t*zs(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>zs(t,e),sqrt:o||(t=>(l||(l=Hs(e)),l(h,t))),toBytes:e=>n?Ss(e,c).reverse():Ss(e,c),fromBytes:(t,r=!0)=>{if(s){if(!s.includes(t.length)||t.length>c)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+t.length);const e=new Uint8Array(c);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==c)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+t.length);let i=n?ks(t):function(e){return Es(Ur(e))}(t);if(a&&(i=qs(i,e)),!r&&!h.isValid(i))throw new Error("invalid field element: outside of range 0..ORDER");return i},invertBatch:e=>Xs(h,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(h)}const ra=BigInt(0),ia=BigInt(1);function oa(e,t){const n=t.negate();return e?n:t}function sa(e,t){const n=Xs(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function aa(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function ua(e,t){aa(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:Is(e),maxNumber:n,shiftBy:BigInt(e)}}function ca(e,t,n){const{windowSize:r,mask:i,maxNumber:o,shiftBy:s}=n;let a=Number(e&i),u=e>>s;a>r&&(a-=o,u+=ia);const c=t*r;return{nextN:u,offset:c+Math.abs(a)-1,isZero:0===a,isNeg:a<0,isNegF:t%2!=0,offsetF:c}}function la(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function ha(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}const fa=new WeakMap,da=new WeakMap;function pa(e){return da.get(e)||1}function ya(e){if(e!==ra)throw new Error("invalid wNAF")}class ma{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>ra;)t&ia&&(n=n.add(r)),r=r.double(),t>>=ia;return n}precomputeWindow(e,t){const{windows:n,windowSize:r}=ua(t,this.bits),i=[];let o=e,s=o;for(let e=0;e<n;e++){s=o,i.push(s);for(let e=1;e<r;e++)s=s.add(o),i.push(s);o=s.double()}return i}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let r=this.ZERO,i=this.BASE;const o=ua(e,this.bits);for(let e=0;e<o.windows;e++){const{nextN:s,offset:a,isZero:u,isNeg:c,isNegF:l,offsetF:h}=ca(n,e,o);n=s,u?i=i.add(oa(l,t[h])):r=r.add(oa(c,t[a]))}return ya(n),{p:r,f:i}}wNAFUnsafe(e,t,n,r=this.ZERO){const i=ua(e,this.bits);for(let e=0;e<i.windows&&n!==ra;e++){const{nextN:o,offset:s,isZero:a,isNeg:u}=ca(n,e,i);if(n=o,!a){const e=t[s];r=r.add(u?e.negate():e)}}return ya(n),r}getPrecomputes(e,t,n){let r=fa.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&("function"==typeof n&&(r=n(r)),fa.set(t,r))),r}cached(e,t,n){const r=pa(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){const i=pa(e);return 1===i?this._unsafeLadder(e,t,r):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,r)}createCache(e,t){aa(t,this.bits),da.set(e,t),fa.delete(e)}hasCache(e){return 1!==pa(e)}}function ga(e,t,n,r){la(n,e),ha(r,t);const i=n.length,o=r.length;if(i!==o)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,a=function(e){let t;for(t=0;e>gs;e>>=bs,t+=1);return t}(BigInt(i));let u=1;a>12?u=a-3:a>4?u=a-2:a>0&&(u=2);const c=Is(u),l=new Array(Number(c)+1).fill(s);let h=s;for(let e=Math.floor((t.BITS-1)/u)*u;e>=0;e-=u){l.fill(s);for(let t=0;t<o;t++){const i=r[t],o=Number(i>>BigInt(e)&c);l[o]=l[o].add(n[t])}let t=s;for(let e=l.length-1,n=s;e>0;e--)n=n.add(l[e]),t=t.add(n);if(h=h.add(t),0!==e)for(let e=0;e<u;e++)h=h.double()}return h}function ba(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return function(e){const t=Zs.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});Ms(e,t)}(t),t}return na(e,{isLE:n})}const va=BigInt(0),wa=BigInt(1),Ea=BigInt(2),ka=BigInt(8);function Sa(e,t={}){const n=function(e,t,n={},r){if(void 0===r&&(r="edwards"===e),!t||"object"!=typeof t)throw new Error(`expected valid ${e} CURVE object`);for(const e of["p","n","h"]){const n=t[e];if(!("bigint"==typeof n&&n>ra))throw new Error(`CURVE.${e} must be positive bigint`)}const i=ba(t.p,n.Fp,r),o=ba(t.n,n.Fn,r),s=["Gx","Gy","a","weierstrass"===e?"b":"d"];for(const e of s)if(!i.isValid(t[e]))throw new Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:i,Fn:o}}("edwards",e,t,t.FpFnLE),{Fp:r,Fn:i}=n;let o=n.CURVE;const{h:s}=o;Ms(t,{},{uvRatio:"function"});const a=Ea<<BigInt(8*i.BYTES)-wa,u=e=>r.create(e),c=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:r.sqrt(r.div(e,t))}}catch(e){return{isValid:!1,value:va}}});if(!function(e,t,n,r){const i=e.sqr(n),o=e.sqr(r),s=e.add(e.mul(t.a,i),o),a=e.add(e.ONE,e.mul(t.d,e.mul(i,o)));return e.eql(s,a)}(r,o,o.Gx,o.Gy))throw new Error("bad curve params: generator point");function l(e,t,n=!1){return xs("coordinate "+e,t,n?wa:va,a),t}function h(e){if(!(e instanceof p))throw new Error("ExtendedPoint expected")}const f=As((e,t)=>{const{X:n,Y:i,Z:o}=e,s=e.is0();null==t&&(t=s?ka:r.inv(o));const a=u(n*t),c=u(i*t),l=r.mul(o,t);if(s)return{x:va,y:wa};if(l!==wa)throw new Error("invZ was invalid");return{x:a,y:c}}),d=As(e=>{const{a:t,d:n}=o;if(e.is0())throw new Error("bad point: ZERO");const{X:r,Y:i,Z:s,T:a}=e,c=u(r*r),l=u(i*i),h=u(s*s),f=u(h*h),d=u(c*t);if(u(h*u(d+l))!==u(f+u(n*u(c*l))))throw new Error("bad point: equation left != right (1)");if(u(r*i)!==u(s*a))throw new Error("bad point: equation left != right (2)");return!0});class p{constructor(e,t,n,r){this.X=l("x",e),this.Y=l("y",t),this.Z=l("z",n,!0),this.T=l("t",r),Object.freeze(this)}static CURVE(){return o}static fromAffine(e){if(e instanceof p)throw new Error("extended point not allowed");const{x:t,y:n}=e||{};return l("x",t),l("y",n),new p(t,n,wa,u(t*n))}static fromBytes(e,t=!1){const n=r.BYTES,{a:i,d:s}=o;e=_s(ws(e,n,"point")),vs(t,"zip215");const l=_s(e),h=e[n-1];l[n-1]=-129&h;const f=ks(l),d=t?a:r.ORDER;xs("point.y",f,va,d);const y=u(f*f),m=u(y-wa),g=u(s*y-i);let{isValid:b,value:v}=c(m,g);if(!b)throw new Error("bad point: invalid y coordinate");const w=(v&wa)===wa,E=!!(128&h);if(!t&&v===va&&E)throw new Error("bad point: x=0 and x_0=1");return E!==w&&(v=u(-v)),p.fromAffine({x:v,y:f})}static fromHex(e,t=!1){return p.fromBytes(Ts("point",e),t)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return y.createCache(this,e),t||this.multiply(Ea),this}assertValidity(){d(this)}equals(e){h(e);const{X:t,Y:n,Z:r}=this,{X:i,Y:o,Z:s}=e,a=u(t*s),c=u(i*r),l=u(n*s),f=u(o*r);return a===c&&l===f}is0(){return this.equals(p.ZERO)}negate(){return new p(u(-this.X),this.Y,this.Z,u(-this.T))}double(){const{a:e}=o,{X:t,Y:n,Z:r}=this,i=u(t*t),s=u(n*n),a=u(Ea*u(r*r)),c=u(e*i),l=t+n,h=u(u(l*l)-i-s),f=c+s,d=f-a,y=c-s,m=u(h*d),g=u(f*y),b=u(h*y),v=u(d*f);return new p(m,g,v,b)}add(e){h(e);const{a:t,d:n}=o,{X:r,Y:i,Z:s,T:a}=this,{X:c,Y:l,Z:f,T:d}=e,y=u(r*c),m=u(i*l),g=u(a*n*d),b=u(s*f),v=u((r+i)*(c+l)-y-m),w=b-g,E=b+g,k=u(m-t*y),S=u(v*w),T=u(E*k),_=u(v*k),O=u(w*E);return new p(S,T,O,_)}subtract(e){return this.add(e.negate())}multiply(e){if(!i.isValidNot0(e))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:t,f:n}=y.cached(this,e,e=>sa(p,e));return sa(p,[t,n])[0]}multiplyUnsafe(e,t=p.ZERO){if(!i.isValid(e))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return e===va?p.ZERO:this.is0()||e===wa?this:y.unsafe(this,e,e=>sa(p,e),t)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return y.unsafe(this,o.n).is0()}toAffine(e){return f(this,e)}clearCofactor(){return s===wa?this:this.multiplyUnsafe(s)}toBytes(){const{x:e,y:t}=this.toAffine(),n=r.toBytes(t);return n[n.length-1]|=e&wa?128:0,n}toHex(){return Ur(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(e){return sa(p,e)}static msm(e,t){return ga(p,i,e,t)}_setWindowSize(e){this.precompute(e)}toRawBytes(){return this.toBytes()}}p.BASE=new p(o.Gx,o.Gy,wa,u(o.Gx*o.Gy)),p.ZERO=new p(va,wa,wa,va),p.Fp=r,p.Fn=i;const y=new ma(p,i.BITS);return p.BASE.precompute(8),p}class Ta{constructor(e){this.ep=e}static fromBytes(e){Cs()}static fromHex(e){Cs()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return Ur(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.init(this.ep.precompute(e,t))}toRawBytes(){return this.toBytes()}}function _a(e,t,n={}){if("function"!=typeof t)throw new Error('"hash" function param is required');Ms(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:r}=n,{BASE:i,Fp:o,Fn:s}=e,a=n.randomBytes||ni,u=n.adjustScalarBytes||(e=>e),c=n.domain||((e,t,n)=>{if(vs(n,"phflag"),t.length||n)throw new Error("Contexts/pre-hash are not supported");return e});function l(e){return s.create(ks(e))}function h(e){const{head:n,prefix:r,scalar:o}=function(e){const n=m.secretKey;e=Ts("private key",e,n);const r=Ts("hashed private key",t(e),2*n),i=u(r.slice(0,n));return{head:i,prefix:r.slice(n,2*n),scalar:l(i)}}(e),s=i.multiply(o),a=s.toBytes();return{head:n,prefix:r,scalar:o,point:s,pointBytes:a}}function f(e){return h(e).pointBytes}function d(e=Uint8Array.of(),...n){const i=Yr(...n);return l(t(c(i,Ts("context",e),!!r)))}const p={zip215:!0};const y=o.BYTES,m={secretKey:y,publicKey:y,signature:2*y,seed:y};function g(e=a(m.seed)){return ws(e,m.seed,"seed")}const b={getExtendedPublicKey:h,randomSecretKey:g,isValidSecretKey:function(e){return Tr(e)&&e.length===s.BYTES},isValidPublicKey:function(t,n){try{return!!e.fromBytes(t,n)}catch(e){return!1}},toMontgomery(t){const{y:n}=e.fromBytes(t),r=m.publicKey,i=32===r;if(!i&&57!==r)throw new Error("only defined for 25519 and 448");const s=i?o.div(wa+n,wa-n):o.div(n-wa,n+wa);return o.toBytes(s)},toMontgomerySecret(e){const n=m.secretKey;ws(e,n);const r=t(e.subarray(0,n));return u(r).subarray(0,n)},randomPrivateKey:g,precompute:(t=8,n=e.BASE)=>n.precompute(t,!1)};return Object.freeze({keygen:function(e){const t=b.randomSecretKey(e);return{secretKey:t,publicKey:f(t)}},getPublicKey:f,sign:function(e,t,n={}){e=Ts("message",e),r&&(e=r(e));const{prefix:o,scalar:a,pointBytes:u}=h(t),c=d(n.context,o,e),l=i.multiply(c).toBytes(),f=d(n.context,l,u,e),p=s.create(c+f*a);if(!s.isValid(p))throw new Error("sign failed: invalid s");return ws(Yr(l,s.toBytes(p)),m.signature,"result")},verify:function(t,n,o,s=p){const{context:a,zip215:u}=s,c=m.signature;t=Ts("signature",t,c),n=Ts("message",n),o=Ts("publicKey",o,m.publicKey),void 0!==u&&vs(u,"zip215"),r&&(n=r(n));const l=c/2,h=t.subarray(0,l),f=ks(t.subarray(l,c));let y,g,b;try{y=e.fromBytes(o,u),g=e.fromBytes(h,u),b=i.multiplyUnsafe(f)}catch(e){return!1}if(!u&&y.isSmallOrder())return!1;const v=d(a,g.toBytes(),y.toBytes(),n);return g.add(y.multiplyUnsafe(v)).subtract(b).clearCofactor().is0()},utils:b,Point:e,lengths:m})}function Oa(e){const{CURVE:t,curveOpts:n,hash:r,eddsaOpts:i}=function(e){const t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n={Fp:e.Fp,Fn:na(t.n,e.nBitLength,!0),uvRatio:e.uvRatio},r={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:n,hash:e.hash,eddsaOpts:r}}(e);return function(e,t){const n=t.Point;return Object.assign({},t,{ExtendedPoint:n,CURVE:e,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}(e,_a(Sa(t,n),r,i))}Hr("HashToScalar-");const xa=BigInt(0),Ia=BigInt(1),Ma=BigInt(2),Ca=(BigInt(3),BigInt(5)),Aa=BigInt(8),Na=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),ja=(()=>({p:Na,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Aa,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function Da(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),o=Na,s=e*e%o*e%o,a=Vs(s,Ma,o)*s%o,u=Vs(a,Ia,o)*e%o,c=Vs(u,Ca,o)*u%o,l=Vs(c,t,o)*c%o,h=Vs(l,n,o)*l%o,f=Vs(h,r,o)*h%o,d=Vs(f,i,o)*f%o,p=Vs(d,i,o)*f%o,y=Vs(p,t,o)*c%o;return{pow_p_5_8:Vs(y,Ma,o)*e%o,b2:s}}function Ra(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}const Pa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Ba(e,t){const n=Na,r=qs(t*t*t,n),i=qs(r*r*t,n);let o=qs(e*r*Da(e*i).pow_p_5_8,n);const s=qs(t*o*o,n),a=o,u=qs(o*Pa,n),c=s===e,l=s===qs(-e,n),h=s===qs(-e*Pa,n);return c&&(o=a),(l||h)&&(o=u),Js(o,n)&&(o=qs(-o,n)),{isValid:c||l,value:o}}const Fa=(()=>na(ja.p,{isLE:!0}))(),La=(()=>na(ja.n,{isLE:!0}))(),Ua=(()=>({...ja,Fp:Fa,hash:ms,adjustScalarBytes:Ra,uvRatio:Ba}))(),$a=(()=>Oa(Ua))();const qa=Pa,Va=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),za=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Ka=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Wa=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Qa=e=>Ba(Ia,e),Ga=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Ha=e=>$a.Point.Fp.create(ks(e)&Ga);function Ja(e){const{d:t}=ja,n=Na,r=e=>Fa.create(e),i=r(qa*e*e),o=r((i+Ia)*Ka);let s=BigInt(-1);const a=r((s-t*i)*r(i+t));let{isValid:u,value:c}=Ba(o,a),l=r(c*e);Js(l,n)||(l=r(-l)),u||(c=l),u||(s=i);const h=r(s*(i-Ia)*Wa-a),f=c*c,d=r((c+c)*a),p=r(h*Va),y=r(Ia-f),m=r(Ia+f);return new $a.Point(r(d*m),r(y*p),r(p*m),r(d*y))}function Za(e){Or(e,64);const t=Ja(Ha(e.subarray(0,32))),n=Ja(Ha(e.subarray(32,64)));return new Ya(t.add(n))}class Ya extends Ta{constructor(e){super(e)}static fromAffine(e){return new Ya($a.Point.fromAffine(e))}assertSame(e){if(!(e instanceof Ya))throw new Error("RistrettoPoint expected")}init(e){return new Ya(e)}static hashToCurve(e){return Za(Ts("ristrettoHash",e,64))}static fromBytes(e){Or(e,32);const{a:t,d:n}=ja,r=Na,i=e=>Fa.create(e),o=Ha(e);if(!function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n}(Fa.toBytes(o),e)||Js(o,r))throw new Error("invalid ristretto255 encoding 1");const s=i(o*o),a=i(Ia+t*s),u=i(Ia-t*s),c=i(a*a),l=i(u*u),h=i(t*n*c-l),{isValid:f,value:d}=Qa(i(h*l)),p=i(d*u),y=i(d*p*h);let m=i((o+o)*p);Js(m,r)&&(m=i(-m));const g=i(a*y),b=i(m*g);if(!f||Js(b,r)||g===xa)throw new Error("invalid ristretto255 encoding 2");return new Ya(new $a.Point(m,g,Ia,b))}static fromHex(e){return Ya.fromBytes(Ts("ristrettoHex",e,32))}static msm(e,t){return ga(Ya,$a.Point.Fn,e,t)}toBytes(){let{X:e,Y:t,Z:n,T:r}=this.ep;const i=Na,o=e=>Fa.create(e),s=o(o(n+t)*o(n-t)),a=o(e*t),u=o(a*a),{value:c}=Qa(o(s*u)),l=o(c*s),h=o(c*a),f=o(l*h*r);let d;if(Js(r*f,i)){let n=o(t*qa),r=o(e*qa);e=n,t=r,d=o(l*za)}else d=h;Js(e*f,i)&&(t=o(-t));let p=o((n-t)*d);return Js(p,i)&&(p=o(-p)),Fa.toBytes(p)}equals(e){this.assertSame(e);const{X:t,Y:n}=this.ep,{X:r,Y:i}=e.ep,o=e=>Fa.create(e),s=o(t*i)===o(n*r),a=o(n*i)===o(t*r);return s||a}is0(){return this.equals(Ya.ZERO)}}Ya.BASE=(()=>new Ya($a.Point.BASE))(),Ya.ZERO=(()=>new Ya($a.Point.ZERO))(),Ya.Fp=(()=>Fa)(),Ya.Fn=(()=>La)();function Xa(e,t){return ar.IntentMessage(ar.fixedArray(t.length,ar.u8())).serialize({intent:{scope:{[e]:!0},version:{V0:!0},appId:{Sui:!0}},value:t}).toBytes()}const eu={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5,Passkey:6},tu={ED25519:32,Secp256k1:33,Secp256r1:33},nu={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin",6:"Passkey"};const ru="suiprivkey";class iu{async signWithIntent(e,t){const n=Xa(t,e),r=Pi(n,{dkLen:32});return{signature:function({signature:e,signatureScheme:t,publicKey:n}){if(!n)throw new Error("`publicKey` is required");const r=n.toRawBytes(),i=new Uint8Array(1+e.length+r.length);return i.set([eu[t]]),i.set(e,1),i.set(r,1+e.length),o(i)}({signature:await this.sign(r),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:o(e)}}async signTransaction(e){return this.signWithIntent(e,"TransactionData")}async signPersonalMessage(e){const{signature:t}=await this.signWithIntent(un.vector(un.u8()).serialize(e).toBytes(),"PersonalMessage");return{bytes:o(e),signature:t}}async signAndExecuteTransaction({transaction:e,client:t}){const n=await e.build({client:t}),{signature:r}=await this.signTransaction(n);return(await t.core.executeTransaction({transaction:n,signatures:[r]})).transaction}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class ou extends iu{}function su(e){const{prefix:t,words:n}=Q.decode(e);if(t!==ru)throw new Error("invalid private key prefix");const r=new Uint8Array(Q.fromWords(n)),i=r.slice(1),o=nu[r[0]];return{scheme:o,schema:o,secretKey:i}}class au extends Xr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,xr(e);const n=Jr(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),Ar(i)}update(e){return Ir(this),this.iHash.update(e),this}digestInto(e){Ir(this),Or(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:o,outputLen:s}=this;return e.finished=r,e.destroyed=i,e.blockLen=o,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const uu=(e,t,n)=>new au(e,t).update(n).digest();function cu(e,t,n,r){xr(e);const i=function(e,t){if(void 0!==t&&"[object Object]"!=={}.toString.call(t))throw new Error("options should be object or undefined");return Object.assign(e,t)}({dkLen:32,asyncTick:10},r),{c:o,dkLen:s,asyncTick:a}=i;if(_r(o),_r(s),_r(a),o<1)throw new Error("iterations (c) should be >= 1");const u=Zr(t),c=Zr(n),l=new Uint8Array(s),h=uu.create(e,u),f=h._cloneInto().update(c);return{c:o,dkLen:s,asyncTick:a,DK:l,PRF:h,PRFSalt:f}}function lu(e,t,n,r,i){return e.destroy(),t.destroy(),r&&r.destroy(),Ar(i),n}uu.create=(e,t)=>new au(e,t);function hu(e){if("string"!=typeof e)throw new TypeError("invalid mnemonic type: "+typeof e);return e.normalize("NFKD")}function fu(e){const t=hu(e),n=t.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:n}}function du(e){Or(e,16,20,24,28,32)}function pu(e,t=128){if(_r(t),t%32!=0||t>256)throw new TypeError("Invalid entropy");return function(e,t){du(e);const n=mu(t).encode(e);return n.join((e=>"あいこくしん"===e[0])(t)?" ":" ")}(ni(t/8),e)}const yu=e=>{const t=8-e.length/4;return new Uint8Array([ys(e)[0]>>t<<t])};function mu(e){if(!Array.isArray(e)||2048!==e.length||"string"!=typeof e[0])throw new Error("Wordlist: expected array of 2048 strings");return e.forEach(e=>{if("string"!=typeof e)throw new Error("wordlist: non-string element: "+e)}),A.chain(A.checksum(1,yu),A.radix2(11,!0),A.alphabet(e))}const gu=e=>hu("mnemonic"+e);function bu(e,t=""){return function(e,t,n,r){const{c:i,dkLen:o,DK:s,PRF:a,PRFSalt:u}=cu(e,t,n,r);let c;const l=new Uint8Array(4),h=Nr(l),f=new Uint8Array(a.outputLen);for(let e=1,t=0;t<o;e++,t+=a.outputLen){const n=s.subarray(t,t+a.outputLen);h.setInt32(0,e,!1),(c=u._cloneInto(c)).update(l).digestInto(f),n.set(f.subarray(0,n.length));for(let e=1;e<i;e++){a._cloneInto(c).update(f).digestInto(f);for(let e=0;e<n.length;e++)n[e]^=f[e]}}return lu(a,u,s,c,f)}(ms,fu(e).nfkd,gu(t),{c:2048,dkLen:64})}function vu(e){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(e)}function wu(e){return a(function(e){return bu(e,"")}(e))}const Eu=ms,ku=new RegExp("^m(\\/[0-9]+')+$"),Su=e=>e.replace("'",""),Tu=(e,t,n=2147483648)=>{if(!(e=>!!ku.test(e)&&!e.split("/").slice(1).map(Su).some(isNaN))(e))throw new Error("Invalid derivation path");const{key:r,chainCode:i}=(e=>{const t=uu.create(Eu,"ed25519 seed").update(s(e)).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}})(t);return e.split("/").slice(1).map(Su).map(e=>parseInt(e,10)).reduce((e,t)=>(({key:e,chainCode:t},n)=>{const r=new ArrayBuffer(4);new DataView(r).setUint32(0,n);const i=new Uint8Array(1+e.length+r.byteLength);i.set(new Uint8Array(1).fill(0)),i.set(e,1),i.set(new Uint8Array(r,0,r.byteLength),e.length+1);const o=uu.create(Eu,t).update(i).digest();return{key:o.slice(0,32),chainCode:o.slice(32)}})(e,t+n),{key:r,chainCode:i})};function _u(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}class Ou{equals(e){return _u(this.toRawBytes(),e.toRawBytes())}toBase64(){return o(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){return o(this.toSuiBytes())}verifyWithIntent(e,t,n){const r=Xa(n,e),i=Pi(r,{dkLen:32});return this.verify(i,t)}verifyPersonalMessage(e,t){return this.verifyWithIntent(ar.vector(ar.u8()).serialize(e).toBytes(),t,"PersonalMessage")}verifyTransaction(e,t){return this.verifyWithIntent(e,t,"TransactionData")}verifyAddress(e){return this.toSuiAddress()===e}toSuiBytes(){const e=this.toRawBytes(),t=new Uint8Array(e.length+1);return t.set([this.flag()]),t.set(e,1),t}toSuiAddress(){return at(Ur(Pi(this.toSuiBytes(),{dkLen:32})).slice(0,64))}}class xu extends Ou{constructor(e){if(super(),"string"==typeof e?this.data=t(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),32!==this.data.length)throw new Error(`Invalid public key input. Expected 32 bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return eu.ED25519}async verify(e,n){let r;if("string"==typeof n){const e=function(e){const n=t(e),r=nu[n[0]];switch(r){case"ED25519":case"Secp256k1":case"Secp256r1":const t=tu[r],i=n.slice(1,n.length-t);return{serializedSignature:e,signatureScheme:r,signature:i,publicKey:n.slice(1+i.length),bytes:n};default:throw new Error("Unsupported signature scheme")}}(n);if("ED25519"!==e.signatureScheme)throw new Error("Invalid signature scheme");if(!_u(this.toRawBytes(),e.publicKey))throw new Error("Signature does not match public key");r=e.signature}else r=n;return $a.verify(r,e,this.toRawBytes())}}xu.SIZE=32;const Iu="m/44'/784'/0'/0'/0'";class Mu extends ou{constructor(e){if(super(),e)this.keypair={publicKey:e.publicKey,secretKey:e.secretKey.slice(0,32)};else{const e=$a.utils.randomPrivateKey();this.keypair={publicKey:$a.getPublicKey(e),secretKey:e}}}getKeyScheme(){return"ED25519"}static generate(){const e=$a.utils.randomPrivateKey();return new Mu({publicKey:$a.getPublicKey(e),secretKey:e})}static fromSecretKey(e,t){if("string"==typeof e){const n=su(e);if("ED25519"!==n.schema)throw new Error(`Expected a ED25519 keypair, got ${n.schema}`);return this.fromSecretKey(n.secretKey,t)}const n=e.length;if(32!==n)throw new Error(`Wrong secretKey size. Expected 32 bytes, got ${n}.`);const r={publicKey:$a.getPublicKey(e),secretKey:e};if(!t||!t.skipValidation){const t=(new TextEncoder).encode("sui validation"),n=$a.sign(t,e);if(!$a.verify(n,t,r.publicKey))throw new Error("provided secretKey is invalid")}return new Mu(r)}getPublicKey(){return new xu(this.keypair.publicKey)}getSecretKey(){return function(e,t){if(32!==e.length)throw new Error("Invalid bytes length");const n=eu[t],r=new Uint8Array(e.length+1);return r.set([n]),r.set(e,1),Q.encode(ru,Q.toWords(r))}(this.keypair.secretKey.slice(0,32),this.getKeyScheme())}async sign(e){return $a.sign(e,this.keypair.secretKey)}static deriveKeypair(e,t){if(null==t&&(t=Iu),!vu(t))throw new Error("Invalid derivation path");const{key:n}=Tu(t,wu(e));return Mu.fromSecretKey(n)}static deriveKeypairFromSeed(e,t){if(null==t&&(t=Iu),!vu(t))throw new Error("Invalid derivation path");const{key:n}=Tu(t,e);return Mu.fromSecretKey(n)}}const Cu=t,Au="abandon\nability\nable\nabout\nabove\nabsent\nabsorb\nabstract\nabsurd\nabuse\naccess\naccident\naccount\naccuse\nachieve\nacid\nacoustic\nacquire\nacross\nact\naction\nactor\nactress\nactual\nadapt\nadd\naddict\naddress\nadjust\nadmit\nadult\nadvance\nadvice\naerobic\naffair\nafford\nafraid\nagain\nage\nagent\nagree\nahead\naim\nair\nairport\naisle\nalarm\nalbum\nalcohol\nalert\nalien\nall\nalley\nallow\nalmost\nalone\nalpha\nalready\nalso\nalter\nalways\namateur\namazing\namong\namount\namused\nanalyst\nanchor\nancient\nanger\nangle\nangry\nanimal\nankle\nannounce\nannual\nanother\nanswer\nantenna\nantique\nanxiety\nany\napart\napology\nappear\napple\napprove\napril\narch\narctic\narea\narena\nargue\narm\narmed\narmor\narmy\naround\narrange\narrest\narrive\narrow\nart\nartefact\nartist\nartwork\nask\naspect\nassault\nasset\nassist\nassume\nasthma\nathlete\natom\nattack\nattend\nattitude\nattract\nauction\naudit\naugust\naunt\nauthor\nauto\nautumn\naverage\navocado\navoid\nawake\naware\naway\nawesome\nawful\nawkward\naxis\nbaby\nbachelor\nbacon\nbadge\nbag\nbalance\nbalcony\nball\nbamboo\nbanana\nbanner\nbar\nbarely\nbargain\nbarrel\nbase\nbasic\nbasket\nbattle\nbeach\nbean\nbeauty\nbecause\nbecome\nbeef\nbefore\nbegin\nbehave\nbehind\nbelieve\nbelow\nbelt\nbench\nbenefit\nbest\nbetray\nbetter\nbetween\nbeyond\nbicycle\nbid\nbike\nbind\nbiology\nbird\nbirth\nbitter\nblack\nblade\nblame\nblanket\nblast\nbleak\nbless\nblind\nblood\nblossom\nblouse\nblue\nblur\nblush\nboard\nboat\nbody\nboil\nbomb\nbone\nbonus\nbook\nboost\nborder\nboring\nborrow\nboss\nbottom\nbounce\nbox\nboy\nbracket\nbrain\nbrand\nbrass\nbrave\nbread\nbreeze\nbrick\nbridge\nbrief\nbright\nbring\nbrisk\nbroccoli\nbroken\nbronze\nbroom\nbrother\nbrown\nbrush\nbubble\nbuddy\nbudget\nbuffalo\nbuild\nbulb\nbulk\nbullet\nbundle\nbunker\nburden\nburger\nburst\nbus\nbusiness\nbusy\nbutter\nbuyer\nbuzz\ncabbage\ncabin\ncable\ncactus\ncage\ncake\ncall\ncalm\ncamera\ncamp\ncan\ncanal\ncancel\ncandy\ncannon\ncanoe\ncanvas\ncanyon\ncapable\ncapital\ncaptain\ncar\ncarbon\ncard\ncargo\ncarpet\ncarry\ncart\ncase\ncash\ncasino\ncastle\ncasual\ncat\ncatalog\ncatch\ncategory\ncattle\ncaught\ncause\ncaution\ncave\nceiling\ncelery\ncement\ncensus\ncentury\ncereal\ncertain\nchair\nchalk\nchampion\nchange\nchaos\nchapter\ncharge\nchase\nchat\ncheap\ncheck\ncheese\nchef\ncherry\nchest\nchicken\nchief\nchild\nchimney\nchoice\nchoose\nchronic\nchuckle\nchunk\nchurn\ncigar\ncinnamon\ncircle\ncitizen\ncity\ncivil\nclaim\nclap\nclarify\nclaw\nclay\nclean\nclerk\nclever\nclick\nclient\ncliff\nclimb\nclinic\nclip\nclock\nclog\nclose\ncloth\ncloud\nclown\nclub\nclump\ncluster\nclutch\ncoach\ncoast\ncoconut\ncode\ncoffee\ncoil\ncoin\ncollect\ncolor\ncolumn\ncombine\ncome\ncomfort\ncomic\ncommon\ncompany\nconcert\nconduct\nconfirm\ncongress\nconnect\nconsider\ncontrol\nconvince\ncook\ncool\ncopper\ncopy\ncoral\ncore\ncorn\ncorrect\ncost\ncotton\ncouch\ncountry\ncouple\ncourse\ncousin\ncover\ncoyote\ncrack\ncradle\ncraft\ncram\ncrane\ncrash\ncrater\ncrawl\ncrazy\ncream\ncredit\ncreek\ncrew\ncricket\ncrime\ncrisp\ncritic\ncrop\ncross\ncrouch\ncrowd\ncrucial\ncruel\ncruise\ncrumble\ncrunch\ncrush\ncry\ncrystal\ncube\nculture\ncup\ncupboard\ncurious\ncurrent\ncurtain\ncurve\ncushion\ncustom\ncute\ncycle\ndad\ndamage\ndamp\ndance\ndanger\ndaring\ndash\ndaughter\ndawn\nday\ndeal\ndebate\ndebris\ndecade\ndecember\ndecide\ndecline\ndecorate\ndecrease\ndeer\ndefense\ndefine\ndefy\ndegree\ndelay\ndeliver\ndemand\ndemise\ndenial\ndentist\ndeny\ndepart\ndepend\ndeposit\ndepth\ndeputy\nderive\ndescribe\ndesert\ndesign\ndesk\ndespair\ndestroy\ndetail\ndetect\ndevelop\ndevice\ndevote\ndiagram\ndial\ndiamond\ndiary\ndice\ndiesel\ndiet\ndiffer\ndigital\ndignity\ndilemma\ndinner\ndinosaur\ndirect\ndirt\ndisagree\ndiscover\ndisease\ndish\ndismiss\ndisorder\ndisplay\ndistance\ndivert\ndivide\ndivorce\ndizzy\ndoctor\ndocument\ndog\ndoll\ndolphin\ndomain\ndonate\ndonkey\ndonor\ndoor\ndose\ndouble\ndove\ndraft\ndragon\ndrama\ndrastic\ndraw\ndream\ndress\ndrift\ndrill\ndrink\ndrip\ndrive\ndrop\ndrum\ndry\nduck\ndumb\ndune\nduring\ndust\ndutch\nduty\ndwarf\ndynamic\neager\neagle\nearly\nearn\nearth\neasily\neast\neasy\necho\necology\neconomy\nedge\nedit\neducate\neffort\negg\neight\neither\nelbow\nelder\nelectric\nelegant\nelement\nelephant\nelevator\nelite\nelse\nembark\nembody\nembrace\nemerge\nemotion\nemploy\nempower\nempty\nenable\nenact\nend\nendless\nendorse\nenemy\nenergy\nenforce\nengage\nengine\nenhance\nenjoy\nenlist\nenough\nenrich\nenroll\nensure\nenter\nentire\nentry\nenvelope\nepisode\nequal\nequip\nera\nerase\nerode\nerosion\nerror\nerupt\nescape\nessay\nessence\nestate\neternal\nethics\nevidence\nevil\nevoke\nevolve\nexact\nexample\nexcess\nexchange\nexcite\nexclude\nexcuse\nexecute\nexercise\nexhaust\nexhibit\nexile\nexist\nexit\nexotic\nexpand\nexpect\nexpire\nexplain\nexpose\nexpress\nextend\nextra\neye\neyebrow\nfabric\nface\nfaculty\nfade\nfaint\nfaith\nfall\nfalse\nfame\nfamily\nfamous\nfan\nfancy\nfantasy\nfarm\nfashion\nfat\nfatal\nfather\nfatigue\nfault\nfavorite\nfeature\nfebruary\nfederal\nfee\nfeed\nfeel\nfemale\nfence\nfestival\nfetch\nfever\nfew\nfiber\nfiction\nfield\nfigure\nfile\nfilm\nfilter\nfinal\nfind\nfine\nfinger\nfinish\nfire\nfirm\nfirst\nfiscal\nfish\nfit\nfitness\nfix\nflag\nflame\nflash\nflat\nflavor\nflee\nflight\nflip\nfloat\nflock\nfloor\nflower\nfluid\nflush\nfly\nfoam\nfocus\nfog\nfoil\nfold\nfollow\nfood\nfoot\nforce\nforest\nforget\nfork\nfortune\nforum\nforward\nfossil\nfoster\nfound\nfox\nfragile\nframe\nfrequent\nfresh\nfriend\nfringe\nfrog\nfront\nfrost\nfrown\nfrozen\nfruit\nfuel\nfun\nfunny\nfurnace\nfury\nfuture\ngadget\ngain\ngalaxy\ngallery\ngame\ngap\ngarage\ngarbage\ngarden\ngarlic\ngarment\ngas\ngasp\ngate\ngather\ngauge\ngaze\ngeneral\ngenius\ngenre\ngentle\ngenuine\ngesture\nghost\ngiant\ngift\ngiggle\nginger\ngiraffe\ngirl\ngive\nglad\nglance\nglare\nglass\nglide\nglimpse\nglobe\ngloom\nglory\nglove\nglow\nglue\ngoat\ngoddess\ngold\ngood\ngoose\ngorilla\ngospel\ngossip\ngovern\ngown\ngrab\ngrace\ngrain\ngrant\ngrape\ngrass\ngravity\ngreat\ngreen\ngrid\ngrief\ngrit\ngrocery\ngroup\ngrow\ngrunt\nguard\nguess\nguide\nguilt\nguitar\ngun\ngym\nhabit\nhair\nhalf\nhammer\nhamster\nhand\nhappy\nharbor\nhard\nharsh\nharvest\nhat\nhave\nhawk\nhazard\nhead\nhealth\nheart\nheavy\nhedgehog\nheight\nhello\nhelmet\nhelp\nhen\nhero\nhidden\nhigh\nhill\nhint\nhip\nhire\nhistory\nhobby\nhockey\nhold\nhole\nholiday\nhollow\nhome\nhoney\nhood\nhope\nhorn\nhorror\nhorse\nhospital\nhost\nhotel\nhour\nhover\nhub\nhuge\nhuman\nhumble\nhumor\nhundred\nhungry\nhunt\nhurdle\nhurry\nhurt\nhusband\nhybrid\nice\nicon\nidea\nidentify\nidle\nignore\nill\nillegal\nillness\nimage\nimitate\nimmense\nimmune\nimpact\nimpose\nimprove\nimpulse\ninch\ninclude\nincome\nincrease\nindex\nindicate\nindoor\nindustry\ninfant\ninflict\ninform\ninhale\ninherit\ninitial\ninject\ninjury\ninmate\ninner\ninnocent\ninput\ninquiry\ninsane\ninsect\ninside\ninspire\ninstall\nintact\ninterest\ninto\ninvest\ninvite\ninvolve\niron\nisland\nisolate\nissue\nitem\nivory\njacket\njaguar\njar\njazz\njealous\njeans\njelly\njewel\njob\njoin\njoke\njourney\njoy\njudge\njuice\njump\njungle\njunior\njunk\njust\nkangaroo\nkeen\nkeep\nketchup\nkey\nkick\nkid\nkidney\nkind\nkingdom\nkiss\nkit\nkitchen\nkite\nkitten\nkiwi\nknee\nknife\nknock\nknow\nlab\nlabel\nlabor\nladder\nlady\nlake\nlamp\nlanguage\nlaptop\nlarge\nlater\nlatin\nlaugh\nlaundry\nlava\nlaw\nlawn\nlawsuit\nlayer\nlazy\nleader\nleaf\nlearn\nleave\nlecture\nleft\nleg\nlegal\nlegend\nleisure\nlemon\nlend\nlength\nlens\nleopard\nlesson\nletter\nlevel\nliar\nliberty\nlibrary\nlicense\nlife\nlift\nlight\nlike\nlimb\nlimit\nlink\nlion\nliquid\nlist\nlittle\nlive\nlizard\nload\nloan\nlobster\nlocal\nlock\nlogic\nlonely\nlong\nloop\nlottery\nloud\nlounge\nlove\nloyal\nlucky\nluggage\nlumber\nlunar\nlunch\nluxury\nlyrics\nmachine\nmad\nmagic\nmagnet\nmaid\nmail\nmain\nmajor\nmake\nmammal\nman\nmanage\nmandate\nmango\nmansion\nmanual\nmaple\nmarble\nmarch\nmargin\nmarine\nmarket\nmarriage\nmask\nmass\nmaster\nmatch\nmaterial\nmath\nmatrix\nmatter\nmaximum\nmaze\nmeadow\nmean\nmeasure\nmeat\nmechanic\nmedal\nmedia\nmelody\nmelt\nmember\nmemory\nmention\nmenu\nmercy\nmerge\nmerit\nmerry\nmesh\nmessage\nmetal\nmethod\nmiddle\nmidnight\nmilk\nmillion\nmimic\nmind\nminimum\nminor\nminute\nmiracle\nmirror\nmisery\nmiss\nmistake\nmix\nmixed\nmixture\nmobile\nmodel\nmodify\nmom\nmoment\nmonitor\nmonkey\nmonster\nmonth\nmoon\nmoral\nmore\nmorning\nmosquito\nmother\nmotion\nmotor\nmountain\nmouse\nmove\nmovie\nmuch\nmuffin\nmule\nmultiply\nmuscle\nmuseum\nmushroom\nmusic\nmust\nmutual\nmyself\nmystery\nmyth\nnaive\nname\nnapkin\nnarrow\nnasty\nnation\nnature\nnear\nneck\nneed\nnegative\nneglect\nneither\nnephew\nnerve\nnest\nnet\nnetwork\nneutral\nnever\nnews\nnext\nnice\nnight\nnoble\nnoise\nnominee\nnoodle\nnormal\nnorth\nnose\nnotable\nnote\nnothing\nnotice\nnovel\nnow\nnuclear\nnumber\nnurse\nnut\noak\nobey\nobject\noblige\nobscure\nobserve\nobtain\nobvious\noccur\nocean\noctober\nodor\noff\noffer\noffice\noften\noil\nokay\nold\nolive\nolympic\nomit\nonce\none\nonion\nonline\nonly\nopen\nopera\nopinion\noppose\noption\norange\norbit\norchard\norder\nordinary\norgan\norient\noriginal\norphan\nostrich\nother\noutdoor\nouter\noutput\noutside\noval\noven\nover\nown\nowner\noxygen\noyster\nozone\npact\npaddle\npage\npair\npalace\npalm\npanda\npanel\npanic\npanther\npaper\nparade\nparent\npark\nparrot\nparty\npass\npatch\npath\npatient\npatrol\npattern\npause\npave\npayment\npeace\npeanut\npear\npeasant\npelican\npen\npenalty\npencil\npeople\npepper\nperfect\npermit\nperson\npet\nphone\nphoto\nphrase\nphysical\npiano\npicnic\npicture\npiece\npig\npigeon\npill\npilot\npink\npioneer\npipe\npistol\npitch\npizza\nplace\nplanet\nplastic\nplate\nplay\nplease\npledge\npluck\nplug\nplunge\npoem\npoet\npoint\npolar\npole\npolice\npond\npony\npool\npopular\nportion\nposition\npossible\npost\npotato\npottery\npoverty\npowder\npower\npractice\npraise\npredict\nprefer\nprepare\npresent\npretty\nprevent\nprice\npride\nprimary\nprint\npriority\nprison\nprivate\nprize\nproblem\nprocess\nproduce\nprofit\nprogram\nproject\npromote\nproof\nproperty\nprosper\nprotect\nproud\nprovide\npublic\npudding\npull\npulp\npulse\npumpkin\npunch\npupil\npuppy\npurchase\npurity\npurpose\npurse\npush\nput\npuzzle\npyramid\nquality\nquantum\nquarter\nquestion\nquick\nquit\nquiz\nquote\nrabbit\nraccoon\nrace\nrack\nradar\nradio\nrail\nrain\nraise\nrally\nramp\nranch\nrandom\nrange\nrapid\nrare\nrate\nrather\nraven\nraw\nrazor\nready\nreal\nreason\nrebel\nrebuild\nrecall\nreceive\nrecipe\nrecord\nrecycle\nreduce\nreflect\nreform\nrefuse\nregion\nregret\nregular\nreject\nrelax\nrelease\nrelief\nrely\nremain\nremember\nremind\nremove\nrender\nrenew\nrent\nreopen\nrepair\nrepeat\nreplace\nreport\nrequire\nrescue\nresemble\nresist\nresource\nresponse\nresult\nretire\nretreat\nreturn\nreunion\nreveal\nreview\nreward\nrhythm\nrib\nribbon\nrice\nrich\nride\nridge\nrifle\nright\nrigid\nring\nriot\nripple\nrisk\nritual\nrival\nriver\nroad\nroast\nrobot\nrobust\nrocket\nromance\nroof\nrookie\nroom\nrose\nrotate\nrough\nround\nroute\nroyal\nrubber\nrude\nrug\nrule\nrun\nrunway\nrural\nsad\nsaddle\nsadness\nsafe\nsail\nsalad\nsalmon\nsalon\nsalt\nsalute\nsame\nsample\nsand\nsatisfy\nsatoshi\nsauce\nsausage\nsave\nsay\nscale\nscan\nscare\nscatter\nscene\nscheme\nschool\nscience\nscissors\nscorpion\nscout\nscrap\nscreen\nscript\nscrub\nsea\nsearch\nseason\nseat\nsecond\nsecret\nsection\nsecurity\nseed\nseek\nsegment\nselect\nsell\nseminar\nsenior\nsense\nsentence\nseries\nservice\nsession\nsettle\nsetup\nseven\nshadow\nshaft\nshallow\nshare\nshed\nshell\nsheriff\nshield\nshift\nshine\nship\nshiver\nshock\nshoe\nshoot\nshop\nshort\nshoulder\nshove\nshrimp\nshrug\nshuffle\nshy\nsibling\nsick\nside\nsiege\nsight\nsign\nsilent\nsilk\nsilly\nsilver\nsimilar\nsimple\nsince\nsing\nsiren\nsister\nsituate\nsix\nsize\nskate\nsketch\nski\nskill\nskin\nskirt\nskull\nslab\nslam\nsleep\nslender\nslice\nslide\nslight\nslim\nslogan\nslot\nslow\nslush\nsmall\nsmart\nsmile\nsmoke\nsmooth\nsnack\nsnake\nsnap\nsniff\nsnow\nsoap\nsoccer\nsocial\nsock\nsoda\nsoft\nsolar\nsoldier\nsolid\nsolution\nsolve\nsomeone\nsong\nsoon\nsorry\nsort\nsoul\nsound\nsoup\nsource\nsouth\nspace\nspare\nspatial\nspawn\nspeak\nspecial\nspeed\nspell\nspend\nsphere\nspice\nspider\nspike\nspin\nspirit\nsplit\nspoil\nsponsor\nspoon\nsport\nspot\nspray\nspread\nspring\nspy\nsquare\nsqueeze\nsquirrel\nstable\nstadium\nstaff\nstage\nstairs\nstamp\nstand\nstart\nstate\nstay\nsteak\nsteel\nstem\nstep\nstereo\nstick\nstill\nsting\nstock\nstomach\nstone\nstool\nstory\nstove\nstrategy\nstreet\nstrike\nstrong\nstruggle\nstudent\nstuff\nstumble\nstyle\nsubject\nsubmit\nsubway\nsuccess\nsuch\nsudden\nsuffer\nsugar\nsuggest\nsuit\nsummer\nsun\nsunny\nsunset\nsuper\nsupply\nsupreme\nsure\nsurface\nsurge\nsurprise\nsurround\nsurvey\nsuspect\nsustain\nswallow\nswamp\nswap\nswarm\nswear\nsweet\nswift\nswim\nswing\nswitch\nsword\nsymbol\nsymptom\nsyrup\nsystem\ntable\ntackle\ntag\ntail\ntalent\ntalk\ntank\ntape\ntarget\ntask\ntaste\ntattoo\ntaxi\nteach\nteam\ntell\nten\ntenant\ntennis\ntent\nterm\ntest\ntext\nthank\nthat\ntheme\nthen\ntheory\nthere\nthey\nthing\nthis\nthought\nthree\nthrive\nthrow\nthumb\nthunder\nticket\ntide\ntiger\ntilt\ntimber\ntime\ntiny\ntip\ntired\ntissue\ntitle\ntoast\ntobacco\ntoday\ntoddler\ntoe\ntogether\ntoilet\ntoken\ntomato\ntomorrow\ntone\ntongue\ntonight\ntool\ntooth\ntop\ntopic\ntopple\ntorch\ntornado\ntortoise\ntoss\ntotal\ntourist\ntoward\ntower\ntown\ntoy\ntrack\ntrade\ntraffic\ntragic\ntrain\ntransfer\ntrap\ntrash\ntravel\ntray\ntreat\ntree\ntrend\ntrial\ntribe\ntrick\ntrigger\ntrim\ntrip\ntrophy\ntrouble\ntruck\ntrue\ntruly\ntrumpet\ntrust\ntruth\ntry\ntube\ntuition\ntumble\ntuna\ntunnel\nturkey\nturn\nturtle\ntwelve\ntwenty\ntwice\ntwin\ntwist\ntwo\ntype\ntypical\nugly\numbrella\nunable\nunaware\nuncle\nuncover\nunder\nundo\nunfair\nunfold\nunhappy\nuniform\nunique\nunit\nuniverse\nunknown\nunlock\nuntil\nunusual\nunveil\nupdate\nupgrade\nuphold\nupon\nupper\nupset\nurban\nurge\nusage\nuse\nused\nuseful\nuseless\nusual\nutility\nvacant\nvacuum\nvague\nvalid\nvalley\nvalve\nvan\nvanish\nvapor\nvarious\nvast\nvault\nvehicle\nvelvet\nvendor\nventure\nvenue\nverb\nverify\nversion\nvery\nvessel\nveteran\nviable\nvibrant\nvicious\nvictory\nvideo\nview\nvillage\nvintage\nviolin\nvirtual\nvirus\nvisa\nvisit\nvisual\nvital\nvivid\nvocal\nvoice\nvoid\nvolcano\nvolume\nvote\nvoyage\nwage\nwagon\nwait\nwalk\nwall\nwalnut\nwant\nwarfare\nwarm\nwarrior\nwash\nwasp\nwaste\nwater\nwave\nway\nwealth\nweapon\nwear\nweasel\nweather\nweb\nwedding\nweekend\nweird\nwelcome\nwest\nwet\nwhale\nwhat\nwheat\nwheel\nwhen\nwhere\nwhip\nwhisper\nwide\nwidth\nwife\nwild\nwill\nwin\nwindow\nwine\nwing\nwink\nwinner\nwinter\nwire\nwisdom\nwise\nwish\nwitness\nwolf\nwoman\nwonder\nwood\nwool\nword\nwork\nworld\nworry\nworth\nwrap\nwreck\nwrestle\nwrist\nwrite\nwrong\nyard\nyear\nyellow\nyou\nyoung\nyouth\nzebra\nzero\nzone\nzoo".split("\n");class Nu{constructor({network:e,base:t}){this.cache=new Qi,this.network=e,this.base=t??this}$extend(...e){return Object.create(this,Object.fromEntries(e.map(e=>{if("experimental_asClientExtension"in e){const{name:t,register:n}=e.experimental_asClientExtension();return[t,{value:n(this)}]}return[e.name,{value:e.register(this)}]})))}}class ju extends Nu{constructor(e){super(e),this.core=this,this.mvr=new vo({cache:this.base.cache.scope("core"),url:e.mvr?.url,pageSize:e.mvr?.pageSize,overrides:e.mvr?.overrides})}async getObject(e){const{objectId:t}=e,{objects:[n]}=await this.getObjects({objectIds:[t],signal:e.signal});if(n instanceof Error)throw n;return{object:n}}async getDynamicField(e){const t=function(e,t,n){const r=ar.Address.serialize(e).toBytes(),i=ar.TypeTag.serialize(t).toBytes(),o=ar.u64().serialize(n.length).toBytes(),s=Pi.create({dkLen:32});return s.update(new Uint8Array([240])),s.update(r),s.update(o),s.update(n),s.update(i),`0x${a(s.digest().slice(0,32))}`}(e.parentId,Ct.parseFromStr(e.name.type),e.name.bcs),{objects:[n]}=await this.getObjects({objectIds:[t],signal:e.signal});if(n instanceof Error)throw n;const r=ot(n.type),i=await n.content;return{dynamicField:{id:n.id,digest:n.digest,version:n.version,type:n.type,name:{type:"string"==typeof r.typeParams[0]?r.typeParams[0]:st(r.typeParams[0]),bcs:e.name.bcs},value:{type:"string"==typeof r.typeParams[1]?r.typeParams[1]:st(r.typeParams[1]),bcs:i.slice(32+e.name.bcs.length)}}}}async waitForTransaction({signal:e,timeout:t=6e4,...n}){const r=e?AbortSignal.any([AbortSignal.timeout(t),e]):AbortSignal.timeout(t),i=new Promise((e,t)=>{r.addEventListener("abort",()=>t(r.reason))});for(i.catch(()=>{});;){r.throwIfAborted();try{return await this.getTransaction({...n,signal:r})}catch(e){await Promise.race([new Promise(e=>setTimeout(e,2e3)),i])}}}}class Du extends Error{}class Ru extends Du{constructor(e,t){super(t),this.code=e}static fromResponse(e,t){switch(e.code){case"notExists":return new Ru(e.code,`Object ${e.object_id} does not exist`);case"dynamicFieldNotFound":return new Ru(e.code,`Dynamic field not found for object ${e.parent_object_id}`);case"deleted":return new Ru(e.code,`Object ${e.object_id} has been deleted`);case"displayError":return new Ru(e.code,`Display error: ${e.error}`);default:return new Ru(e.code,"Unknown error while loading object"+(t?` ${t}`:""))}}}function Pu(e){return{...Fi.fromBytes(e).snapshot(),bcs:e}}function Bu(e){const t=ar.TransactionEffects.parse(e);switch(t.$kind){case"V1":return function(){throw new Error("V1 effects are not supported yet")}(t.V1);case"V2":return function({bytes:e,effects:t}){const n=t.changedObjects.map(([e,n])=>({id:e,inputState:"Exist"===n.inputState.$kind?"Exists":"DoesNotExist",inputVersion:n.inputState.Exist?.[0][0]??null,inputDigest:n.inputState.Exist?.[0][1]??null,inputOwner:n.inputState.Exist?.[1]??null,outputState:"NotExist"===n.outputState.$kind?"DoesNotExist":n.outputState.$kind,outputVersion:"PackageWrite"===n.outputState.$kind?n.outputState.PackageWrite?.[0]:n.outputState.ObjectWrite?t.lamportVersion:null,outputDigest:"PackageWrite"===n.outputState.$kind?n.outputState.PackageWrite?.[1]:n.outputState.ObjectWrite?.[0]??null,outputOwner:n.outputState.ObjectWrite?n.outputState.ObjectWrite[1]:null,idOperation:n.idOperation.$kind}));return{bcs:e,digest:t.transactionDigest,version:2,status:"Success"===t.status.$kind?{success:!0,error:null}:{success:!1,error:t.status.Failed.error.$kind},gasUsed:t.gasUsed,transactionDigest:t.transactionDigest,gasObject:null===t.gasObjectIndex?null:n[t.gasObjectIndex]??null,eventsDigest:t.eventsDigest,dependencies:t.dependencies,lamportVersion:t.lamportVersion,changedObjects:n,unchangedSharedObjects:t.unchangedSharedObjects.map(([e,t])=>({kind:t.$kind,objectId:e,version:"ReadOnlyRoot"===t.$kind?t.ReadOnlyRoot[0]:t[t.$kind],digest:"ReadOnlyRoot"===t.$kind?t.ReadOnlyRoot[1]:null})),auxiliaryDataDigest:t.auxDataDigest}}({bytes:e,effects:t.V2});default:throw new Error(`Unknown transaction effects version: ${t.$kind}`)}}var Fu,Lu=e=>{throw TypeError(e)},Uu=(e,t,n)=>t.has(e)||Lu("Cannot "+n),$u=(e,t,n)=>(Uu(e,t,"read from private field"),n?n.call(e):t.get(e));class qu extends ju{constructor({jsonRpcClient:e,mvr:t}){super({network:e.network,base:e,mvr:t}),((e,t,n)=>{t.has(e)?Lu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n)})(this,Fu),((e,t,n,r)=>{Uu(e,t,"write to private field"),r?r.call(e,n):t.set(e,n)})(this,Fu,e)}async getObjects(e){const t=fr(e.objectIds,50),n=[];for(const r of t){const t=await $u(this,Fu).multiGetObjects({ids:r,options:{showOwner:!0,showType:!0,showBcs:!0},signal:e.signal});for(const[e,i]of t.entries())i.error?n.push(Ru.fromResponse(i.error,r[e])):n.push(Vu(i.data))}return{objects:n}}async getOwnedObjects(e){const t=await $u(this,Fu).getOwnedObjects({owner:e.address,limit:e.limit,cursor:e.cursor,options:{showOwner:!0,showType:!0,showBcs:!0},filter:e.type?{StructType:e.type}:null,signal:e.signal});return{objects:t.data.map(e=>{if(e.error)throw Ru.fromResponse(e.error);return Vu(e.data)}),hasNextPage:t.hasNextPage,cursor:t.nextCursor??null}}async getCoins(e){const t=await $u(this,Fu).getCoins({owner:e.address,coinType:e.coinType,limit:e.limit,cursor:e.cursor,signal:e.signal});return{objects:t.data.map(t=>({id:t.coinObjectId,version:t.version,digest:t.digest,balance:t.balance,type:`0x2::coin::Coin<${t.coinType}>`,content:Promise.resolve(Qu.serialize({id:t.coinObjectId,balance:{value:t.balance}}).toBytes()),owner:{$kind:"ObjectOwner",ObjectOwner:e.address}})),hasNextPage:t.hasNextPage,cursor:t.nextCursor??null}}async getBalance(e){const t=await $u(this,Fu).getBalance({owner:e.address,coinType:e.coinType,signal:e.signal});return{balance:{coinType:t.coinType,balance:t.totalBalance}}}async getAllBalances(e){return{balances:(await $u(this,Fu).getAllBalances({owner:e.address,signal:e.signal})).map(e=>({coinType:e.coinType,balance:e.totalBalance})),hasNextPage:!1,cursor:null}}async getTransaction(e){return{transaction:Ku(await $u(this,Fu).getTransactionBlock({digest:e.digest,options:{showRawInput:!0,showObjectChanges:!0,showRawEffects:!0,showEvents:!0,showEffects:!0},signal:e.signal}))}}async executeTransaction(e){return{transaction:Ku(await $u(this,Fu).executeTransactionBlock({transactionBlock:e.transaction,signature:e.signatures,options:{showRawEffects:!0,showEvents:!0,showObjectChanges:!0,showRawInput:!0,showEffects:!0},signal:e.signal}))}}async dryRunTransaction(e){const t=os.from(e.transaction),n=await $u(this,Fu).dryRunTransactionBlock({transactionBlock:e.transaction,signal:e.signal}),{effects:r,objectTypes:i}=function({bytes:e,effects:t,objectChanges:n}){const r=[],i=[],o={};return n?.forEach(e=>{switch(e.type){case"published":r.push({id:e.packageId,inputState:"DoesNotExist",inputVersion:null,inputDigest:null,inputOwner:null,outputState:"PackageWrite",outputVersion:e.version,outputDigest:e.digest,outputOwner:null,idOperation:"Created"});break;case"transferred":r.push({id:e.objectId,inputState:"Exists",inputVersion:e.version,inputDigest:e.digest,inputOwner:{$kind:"AddressOwner",AddressOwner:e.sender},outputState:"ObjectWrite",outputVersion:e.version,outputDigest:e.digest,outputOwner:zu(e.recipient),idOperation:"None"}),o[e.objectId]=e.objectType;break;case"mutated":r.push({id:e.objectId,inputState:"Exists",inputVersion:e.previousVersion,inputDigest:null,inputOwner:zu(e.owner),outputState:"ObjectWrite",outputVersion:e.version,outputDigest:e.digest,outputOwner:zu(e.owner),idOperation:"None"}),o[e.objectId]=e.objectType;break;case"deleted":r.push({id:e.objectId,inputState:"Exists",inputVersion:e.version,inputDigest:t.deleted?.find(t=>t.objectId===e.objectId)?.digest??null,inputOwner:null,outputState:"DoesNotExist",outputVersion:null,outputDigest:null,outputOwner:null,idOperation:"Deleted"}),o[e.objectId]=e.objectType;break;case"wrapped":r.push({id:e.objectId,inputState:"Exists",inputVersion:e.version,inputDigest:null,inputOwner:{$kind:"AddressOwner",AddressOwner:e.sender},outputState:"ObjectWrite",outputVersion:e.version,outputDigest:t.wrapped?.find(t=>t.objectId===e.objectId)?.digest??null,outputOwner:{$kind:"ObjectOwner",ObjectOwner:e.sender},idOperation:"None"}),o[e.objectId]=e.objectType;break;case"created":r.push({id:e.objectId,inputState:"DoesNotExist",inputVersion:null,inputDigest:null,inputOwner:null,outputState:"ObjectWrite",outputVersion:e.version,outputDigest:e.digest,outputOwner:zu(e.owner),idOperation:"Created"}),o[e.objectId]=e.objectType}}),{objectTypes:o,effects:{bcs:e??null,digest:t.transactionDigest,version:2,status:"success"===t.status.status?{success:!0,error:null}:{success:!1,error:t.status.error},gasUsed:t.gasUsed,transactionDigest:t.transactionDigest,gasObject:{id:t.gasObject?.reference.objectId,inputState:"Exists",inputVersion:null,inputDigest:null,inputOwner:null,outputState:"ObjectWrite",outputVersion:t.gasObject.reference.version,outputDigest:t.gasObject.reference.digest,outputOwner:zu(t.gasObject.owner),idOperation:"None"},eventsDigest:t.eventsDigest??null,dependencies:t.dependencies??[],lamportVersion:t.gasObject.reference.version,changedObjects:r,unchangedSharedObjects:i,auxiliaryDataDigest:null}}}({effects:n.effects,objectChanges:n.objectChanges});return{transaction:{digest:await t.getDigest(),epoch:null,effects:r,objectTypes:Promise.resolve(i),signatures:[],transaction:Pu(e.transaction)}}}async getReferenceGasPrice(e){const t=await $u(this,Fu).getReferenceGasPrice({signal:e?.signal});return{referenceGasPrice:String(t)}}async getDynamicFields(e){const n=await $u(this,Fu).getDynamicFields({parentId:e.parentId,limit:e.limit,cursor:e.cursor});return{dynamicFields:n.data.map(e=>({id:e.objectId,type:e.objectType,name:{type:e.name.type,bcs:t(e.bcsName)}})),hasNextPage:n.hasNextPage,cursor:n.nextCursor}}async verifyZkLoginSignature(e){const t=await $u(this,Fu).verifyZkLoginSignature({bytes:e.bytes,signature:e.signature,intentScope:e.intentScope,author:e.author});return{success:t.success,errors:t.errors}}resolveNameServiceNames(e){return $u(this,Fu).resolveNameServiceNames(e)}resolveTransactionPlugin(){return pr($u(this,Fu))}}function Vu(e){return{id:e.objectId,version:e.version,digest:e.digest,type:e.type,content:Promise.resolve("moveObject"===e.bcs?.dataType?t(e.bcs.bcsBytes):new Uint8Array),owner:zu(e.owner)}}function zu(e){if("Immutable"===e)return{$kind:"Immutable",Immutable:!0};if("ConsensusV2"in e)return{$kind:"ConsensusV2",ConsensusV2:{authenticator:{$kind:"SingleOwner",SingleOwner:e.ConsensusV2.authenticator.SingleOwner},startVersion:e.ConsensusV2.start_version}};if("AddressOwner"in e)return{$kind:"AddressOwner",AddressOwner:e.AddressOwner};if("ObjectOwner"in e)return{$kind:"ObjectOwner",ObjectOwner:e.ObjectOwner};if("Shared"in e)return{$kind:"Shared",Shared:{initialSharedVersion:e.Shared.initial_shared_version}};throw new Error(`Unknown owner type: ${JSON.stringify(e)}`)}function Ku(e){const n=ar.SenderSignedData.parse(t(e.rawTransaction))[0],r={};e.objectChanges?.forEach(e=>{"published"!==e.type&&(r[e.objectId]=e.objectType)});const i=ar.TransactionData.serialize(n.intentMessage.value).toBytes(),o=Fi.restore({version:2,sender:n.intentMessage.value.V1.sender,expiration:n.intentMessage.value.V1.expiration,gasData:n.intentMessage.value.V1.gasData,inputs:n.intentMessage.value.V1.kind.ProgrammableTransaction.inputs,commands:n.intentMessage.value.V1.kind.ProgrammableTransaction.commands});return{digest:e.digest,epoch:e.effects?.executedEpoch??null,effects:Bu(new Uint8Array(e.rawEffects)),objectTypes:Promise.resolve(r),transaction:{...o,bcs:i},signatures:n.txSignatures}}Fu=new WeakMap;const Wu=ar.struct("Balance",{value:ar.u64()}),Qu=ar.struct("Coin",{id:ar.Address,balance:Wu}),Gu={"-32700":"ParseError","-32701":"OversizedRequest","-32702":"OversizedResponse","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError","-32604":"ServerBusy","-32000":"CallExecutionFailed","-32001":"UnknownError","-32003":"SubscriptionClosed","-32004":"SubscriptionClosedWithError","-32005":"BatchesNotSupported","-32006":"TooManySubscriptions","-32050":"TransientError","-32002":"TransactionExecutionClientError"};class Hu extends Error{}class Ju extends Hu{constructor(e,t){super(e),this.code=t,this.type=Gu[t]??"ServerError"}}class Zu extends Hu{constructor(e,t,n){super(e),this.status=t,this.statusText=n}}var Yu,Xu,ec,tc,nc,rc,ic,oc,sc,ac=e=>{throw TypeError(e)},uc=(e,t,n)=>t.has(e)||ac("Cannot "+n),cc=(e,t,n)=>(uc(e,t,"read from private field"),n?n.call(e):t.get(e)),lc=(e,t,n)=>t.has(e)?ac("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),hc=(e,t,n,r)=>(uc(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),fc=(e,t,n)=>(uc(e,t,"access private method"),n);const dc={WebSocketConstructor:"undefined"!=typeof WebSocket?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class pc{constructor(e,t={}){if(lc(this,ic),lc(this,Yu,0),lc(this,Xu,0),lc(this,ec,null),lc(this,tc,null),lc(this,nc,new Set),lc(this,rc,new Map),this.endpoint=e,this.options={...dc,...t},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=function(e){const t=new URL(e);return t.protocol=t.protocol.replace("http","ws"),t.toString()}(this.endpoint))}async makeRequest(e,t,n){const r=await fc(this,ic,oc).call(this);return new Promise((i,o)=>{hc(this,Yu,cc(this,Yu)+1),cc(this,rc).set(cc(this,Yu),{resolve:i,reject:o,timeout:setTimeout(()=>{cc(this,rc).delete(cc(this,Yu)),o(new Error(`Request timeout: ${e}`))},this.options.callTimeout)}),n?.addEventListener("abort",()=>{cc(this,rc).delete(cc(this,Yu)),o(n.reason)}),r.send(JSON.stringify({jsonrpc:"2.0",id:cc(this,Yu),method:e,params:t}))}).then(({error:e,result:t})=>{if(e)throw new Ju(e.message,e.code);return t})}async subscribe(e){const t=new yc(e);return cc(this,nc).add(t),await t.subscribe(this),()=>t.unsubscribe(this)}}Yu=new WeakMap,Xu=new WeakMap,ec=new WeakMap,tc=new WeakMap,nc=new WeakMap,rc=new WeakMap,ic=new WeakSet,oc=function(){return cc(this,tc)||hc(this,tc,new Promise(e=>{cc(this,ec)?.close(),hc(this,ec,new this.options.WebSocketConstructor(this.endpoint)),cc(this,ec).addEventListener("open",()=>{hc(this,Xu,0),e(cc(this,ec))}),cc(this,ec).addEventListener("close",()=>{var e,t,n,r;(e=this,t=Xu,{set _(r){hc(e,t,r,n)},get _(){return cc(e,t,r)}})._++,cc(this,Xu)<=this.options.maxReconnects&&setTimeout(()=>{fc(this,ic,sc).call(this)},this.options.reconnectTimeout)}),cc(this,ec).addEventListener("message",({data:e})=>{let t;try{t=JSON.parse(e)}catch(t){return void console.error(new Error(`Failed to parse RPC message: ${e}`,{cause:t}))}if("id"in t&&null!=t.id&&cc(this,rc).has(t.id)){const{resolve:e,timeout:n}=cc(this,rc).get(t.id);clearTimeout(n),e(t)}else if("params"in t){const{params:e}=t;cc(this,nc).forEach(t=>{t.subscriptionId===e.subscription&&e.subscription===t.subscriptionId&&t.onMessage(e.result)})}})})),cc(this,tc)},sc=async function(){return cc(this,ec)?.close(),hc(this,tc,null),Promise.allSettled([...cc(this,nc)].map(e=>e.subscribe(this)))};class yc{constructor(e){this.subscriptionId=null,this.subscribed=!1,this.input=e}onMessage(e){this.subscribed&&this.input.onMessage(e)}async unsubscribe(e){const{subscriptionId:t}=this;return this.subscribed=!1,null!=t&&(this.subscriptionId=null,e.makeRequest(this.input.unsubscribe,[t]))}async subscribe(e){this.subscriptionId=null,this.subscribed=!0;const t=await e.makeRequest(this.input.method,this.input.params,this.input.signal);this.subscribed&&(this.subscriptionId=t)}}var mc,gc,bc,vc,wc,Ec=e=>{throw TypeError(e)},kc=(e,t,n)=>t.has(e)||Ec("Cannot "+n),Sc=(e,t,n)=>(kc(e,t,"read from private field"),n?n.call(e):t.get(e)),Tc=(e,t,n)=>t.has(e)?Ec("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),_c=(e,t,n,r)=>(kc(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class Oc{constructor(e){Tc(this,vc),Tc(this,mc,0),Tc(this,gc),Tc(this,bc),_c(this,gc,e)}fetch(e,t){const n=Sc(this,gc).fetch??fetch;if(!n)throw new Error("The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.");return n(e,t)}async request(e){_c(this,mc,Sc(this,mc)+1);const t=await this.fetch(Sc(this,gc).rpc?.url??Sc(this,gc).url,{method:"POST",signal:e.signal,headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":eo,"Client-Target-Api-Version":"1.52.0","Client-Request-Method":e.method,...Sc(this,gc).rpc?.headers},body:JSON.stringify({jsonrpc:"2.0",id:Sc(this,mc),method:e.method,params:e.params})});if(!t.ok)throw new Zu(`Unexpected status code: ${t.status}`,t.status,t.statusText);const n=await t.json();if("error"in n&&null!=n.error)throw new Ju(n.error.message,n.error.code);return n.result}async subscribe(e){const t=await(n=this,r=vc,i=wc,kc(n,r,"access private method"),i).call(this).subscribe(e);var n,r,i;return e.signal&&(e.signal.throwIfAborted(),e.signal.addEventListener("abort",()=>{t()})),async()=>!!await t()}}mc=new WeakMap,gc=new WeakMap,bc=new WeakMap,vc=new WeakSet,wc=function(){if(!Sc(this,bc)){const e=Sc(this,gc).WebSocketConstructor??WebSocket;if(!e)throw new Error("The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.");_c(this,bc,new pc(Sc(this,gc).websocket?.url??Sc(this,gc).url,{WebSocketConstructor:e,...Sc(this,gc).websocket}))}return Sc(this,bc)};const xc=Symbol.for("@mysten/SuiClient");class Ic extends Nu{constructor(e){super({network:e.network??"unknown"}),this.jsonRpc=this,this.transport=e.transport??new Oc({url:e.url}),this.core=new qu({jsonRpcClient:this,mvr:e.mvr})}get[xc](){return!0}async getRpcApiVersion({signal:e}={}){return(await this.transport.request({method:"rpc.discover",params:[],signal:e})).info.version}async getCoins({coinType:e,owner:t,cursor:n,limit:r,signal:i}){if(!t||!rt(at(t)))throw new Error("Invalid Sui address");return e&&ko(e)&&(e=(await this.core.mvr.resolveType({type:e})).type),await this.transport.request({method:"suix_getCoins",params:[t,e,n,r],signal:i})}async getAllCoins(e){if(!e.owner||!rt(at(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllCoins",params:[e.owner,e.cursor,e.limit],signal:e.signal})}async getBalance({owner:e,coinType:t,signal:n}){if(!e||!rt(at(e)))throw new Error("Invalid Sui address");return t&&ko(t)&&(t=(await this.core.mvr.resolveType({type:t})).type),await this.transport.request({method:"suix_getBalance",params:[e,t],signal:n})}async getAllBalances(e){if(!e.owner||!rt(at(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllBalances",params:[e.owner],signal:e.signal})}async getCoinMetadata({coinType:e,signal:t}){return e&&ko(e)&&(e=(await this.core.mvr.resolveType({type:e})).type),await this.transport.request({method:"suix_getCoinMetadata",params:[e],signal:t})}async getTotalSupply({coinType:e,signal:t}){return e&&ko(e)&&(e=(await this.core.mvr.resolveType({type:e})).type),await this.transport.request({method:"suix_getTotalSupply",params:[e],signal:t})}async call(e,t,{signal:n}={}){return await this.transport.request({method:e,params:t,signal:n})}async getMoveFunctionArgTypes({package:e,module:t,function:n,signal:r}){return e&&et(e)&&(e=(await this.core.mvr.resolvePackage({package:e})).package),await this.transport.request({method:"sui_getMoveFunctionArgTypes",params:[e,t,n],signal:r})}async getNormalizedMoveModulesByPackage({package:e,signal:t}){return e&&et(e)&&(e=(await this.core.mvr.resolvePackage({package:e})).package),await this.transport.request({method:"sui_getNormalizedMoveModulesByPackage",params:[e],signal:t})}async getNormalizedMoveModule({package:e,module:t,signal:n}){return e&&et(e)&&(e=(await this.core.mvr.resolvePackage({package:e})).package),await this.transport.request({method:"sui_getNormalizedMoveModule",params:[e,t],signal:n})}async getNormalizedMoveFunction({package:e,module:t,function:n,signal:r}){return e&&et(e)&&(e=(await this.core.mvr.resolvePackage({package:e})).package),await this.transport.request({method:"sui_getNormalizedMoveFunction",params:[e,t,n],signal:r})}async getNormalizedMoveStruct({package:e,module:t,struct:n,signal:r}){return e&&et(e)&&(e=(await this.core.mvr.resolvePackage({package:e})).package),await this.transport.request({method:"sui_getNormalizedMoveStruct",params:[e,t,n],signal:r})}async getOwnedObjects(e){if(!e.owner||!rt(at(e.owner)))throw new Error("Invalid Sui address");const t=e.filter?{...e.filter}:void 0;return t&&"MoveModule"in t&&et(t.MoveModule.package)?t.MoveModule={module:t.MoveModule.module,package:(await this.core.mvr.resolvePackage({package:t.MoveModule.package})).package}:t&&"StructType"in t&&ko(t.StructType)&&(t.StructType=(await this.core.mvr.resolveType({type:t.StructType})).type),await this.transport.request({method:"suix_getOwnedObjects",params:[e.owner,{filter:t,options:e.options},e.cursor,e.limit],signal:e.signal})}async getObject(e){if(!e.id||!it(ut(e.id)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"sui_getObject",params:[e.id,e.options],signal:e.signal})}async tryGetPastObject(e){return await this.transport.request({method:"sui_tryGetPastObject",params:[e.id,e.version,e.options],signal:e.signal})}async multiGetObjects(e){e.ids.forEach(e=>{if(!e||!it(ut(e)))throw new Error(`Invalid Sui Object id ${e}`)});if(e.ids.length!==new Set(e.ids).size)throw new Error(`Duplicate object ids in batch call ${e.ids}`);return await this.transport.request({method:"sui_multiGetObjects",params:[e.ids,e.options],signal:e.signal})}async queryTransactionBlocks({filter:e,options:t,cursor:n,limit:r,order:i,signal:o}){return e&&"MoveFunction"in e&&et(e.MoveFunction.package)&&(e={...e,MoveFunction:{package:(await this.core.mvr.resolvePackage({package:e.MoveFunction.package})).package}}),await this.transport.request({method:"suix_queryTransactionBlocks",params:[{filter:e,options:t},n,r,"descending"===(i||"descending")],signal:o})}async getTransactionBlock(e){if(!nt(e.digest))throw new Error("Invalid Transaction digest");return await this.transport.request({method:"sui_getTransactionBlock",params:[e.digest,e.options],signal:e.signal})}async multiGetTransactionBlocks(e){e.digests.forEach(e=>{if(!nt(e))throw new Error(`Invalid Transaction digest ${e}`)});if(e.digests.length!==new Set(e.digests).size)throw new Error(`Duplicate digests in batch call ${e.digests}`);return await this.transport.request({method:"sui_multiGetTransactionBlocks",params:[e.digests,e.options],signal:e.signal})}async executeTransactionBlock({transactionBlock:e,signature:t,options:n,requestType:r,signal:i}){const s=await this.transport.request({method:"sui_executeTransactionBlock",params:["string"==typeof e?e:o(e),Array.isArray(t)?t:[t],n],signal:i});if("WaitForLocalExecution"===r)try{await this.waitForTransaction({digest:s.digest})}catch(e){}return s}async signAndExecuteTransaction({transaction:e,signer:t,...n}){let r;e instanceof Uint8Array?r=e:(e.setSenderIfNotSet(t.toSuiAddress()),r=await e.build({client:this}));const{signature:i,bytes:o}=await t.signTransaction(r);return this.executeTransactionBlock({transactionBlock:o,signature:i,...n})}async getTotalTransactionBlocks({signal:e}={}){const t=await this.transport.request({method:"sui_getTotalTransactionBlocks",params:[],signal:e});return BigInt(t)}async getReferenceGasPrice({signal:e}={}){const t=await this.transport.request({method:"suix_getReferenceGasPrice",params:[],signal:e});return BigInt(t)}async getStakes(e){if(!e.owner||!rt(at(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getStakes",params:[e.owner],signal:e.signal})}async getStakesByIds(e){return e.stakedSuiIds.forEach(e=>{if(!e||!it(ut(e)))throw new Error(`Invalid Sui Stake id ${e}`)}),await this.transport.request({method:"suix_getStakesByIds",params:[e.stakedSuiIds],signal:e.signal})}async getLatestSuiSystemState({signal:e}={}){return await this.transport.request({method:"suix_getLatestSuiSystemState",params:[],signal:e})}async queryEvents({query:e,cursor:t,limit:n,order:r,signal:i}){return e&&"MoveEventType"in e&&ko(e.MoveEventType)&&(e={...e,MoveEventType:(await this.core.mvr.resolveType({type:e.MoveEventType})).type}),e&&"MoveEventModule"in e&&et(e.MoveEventModule.package)&&(e={...e,MoveEventModule:{module:e.MoveEventModule.module,package:(await this.core.mvr.resolvePackage({package:e.MoveEventModule.package})).package}}),"MoveModule"in e&&et(e.MoveModule.package)&&(e={...e,MoveModule:{module:e.MoveModule.module,package:(await this.core.mvr.resolvePackage({package:e.MoveModule.package})).package}}),await this.transport.request({method:"suix_queryEvents",params:[e,t,n,"descending"===(r||"descending")],signal:i})}async subscribeEvent(e){return this.transport.subscribe({method:"suix_subscribeEvent",unsubscribe:"suix_unsubscribeEvent",params:[e.filter],onMessage:e.onMessage,signal:e.signal})}async subscribeTransaction(e){return this.transport.subscribe({method:"suix_subscribeTransaction",unsubscribe:"suix_unsubscribeTransaction",params:[e.filter],onMessage:e.onMessage,signal:e.signal})}async devInspectTransactionBlock(e){let t;if(es(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),t=o(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if("string"==typeof e.transactionBlock)t=e.transactionBlock;else{if(!(e.transactionBlock instanceof Uint8Array))throw new Error("Unknown transaction block format.");t=o(e.transactionBlock)}return e.signal?.throwIfAborted(),await this.transport.request({method:"sui_devInspectTransactionBlock",params:[e.sender,t,e.gasPrice?.toString(),e.epoch],signal:e.signal})}async dryRunTransactionBlock(e){return await this.transport.request({method:"sui_dryRunTransactionBlock",params:["string"==typeof e.transactionBlock?e.transactionBlock:o(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!it(ut(e.parentId)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"suix_getDynamicFields",params:[e.parentId,e.cursor,e.limit],signal:e.signal})}async getDynamicFieldObject(e){return await this.transport.request({method:"suix_getDynamicFieldObject",params:[e.parentId,e.name],signal:e.signal})}async getLatestCheckpointSequenceNumber({signal:e}={}){const t=await this.transport.request({method:"sui_getLatestCheckpointSequenceNumber",params:[],signal:e});return String(t)}async getCheckpoint(e){return await this.transport.request({method:"sui_getCheckpoint",params:[e.id],signal:e.signal})}async getCheckpoints(e){return await this.transport.request({method:"sui_getCheckpoints",params:[e.cursor,e?.limit,e.descendingOrder],signal:e.signal})}async getCommitteeInfo(e){return await this.transport.request({method:"suix_getCommitteeInfo",params:[e?.epoch],signal:e?.signal})}async getNetworkMetrics({signal:e}={}){return await this.transport.request({method:"suix_getNetworkMetrics",params:[],signal:e})}async getAddressMetrics({signal:e}={}){return await this.transport.request({method:"suix_getLatestAddressMetrics",params:[],signal:e})}async getEpochMetrics(e){return await this.transport.request({method:"suix_getEpochMetrics",params:[e?.cursor,e?.limit,e?.descendingOrder],signal:e?.signal})}async getAllEpochAddressMetrics(e){return await this.transport.request({method:"suix_getAllEpochAddressMetrics",params:[e?.descendingOrder],signal:e?.signal})}async getEpochs(e){return await this.transport.request({method:"suix_getEpochs",params:[e?.cursor,e?.limit,e?.descendingOrder],signal:e?.signal})}async getMoveCallMetrics({signal:e}={}){return await this.transport.request({method:"suix_getMoveCallMetrics",params:[],signal:e})}async getCurrentEpoch({signal:e}={}){return await this.transport.request({method:"suix_getCurrentEpoch",params:[],signal:e})}async getValidatorsApy({signal:e}={}){return await this.transport.request({method:"suix_getValidatorsApy",params:[],signal:e})}async getChainIdentifier({signal:e}={}){const t=await this.getCheckpoint({id:"0",signal:e});return a(J(t.digest).slice(0,4))}async resolveNameServiceAddress(e){return await this.transport.request({method:"suix_resolveNameServiceAddress",params:[e.name],signal:e.signal})}async resolveNameServiceNames({format:e="dot",...t}){const{nextCursor:n,hasNextPage:r,data:i}=await this.transport.request({method:"suix_resolveNameServiceNames",params:[t.address,t.cursor,t.limit],signal:t.signal});return{hasNextPage:r,nextCursor:n,data:i.map(t=>function(e,t="at"){const n=e.toLowerCase();let r;if(n.includes("@")){if(!Je.test(n))throw new Error(`Invalid SuiNS name ${e}`);const[t,i]=n.split("@");r=[...t?t.split("."):[],i]}else{if(!Ze.test(n))throw new Error(`Invalid SuiNS name ${e}`);r=n.split(".").slice(0,-1)}return"dot"===t?`${r.join(".")}.sui`:`${r.slice(0,-1).join(".")}@${r[r.length-1]}`}(t,e))}}async getProtocolConfig(e){return await this.transport.request({method:"sui_getProtocolConfig",params:[e?.version],signal:e?.signal})}async verifyZkLoginSignature(e){return await this.transport.request({method:"sui_verifyZkLoginSignature",params:[e.bytes,e.signature,e.intentScope,e.author],signal:e.signal})}async waitForTransaction({signal:e,timeout:t=6e4,pollInterval:n=2e3,...r}){const i=AbortSignal.timeout(t),o=new Promise((e,t)=>{i.addEventListener("abort",()=>t(i.reason))});for(o.catch(()=>{});!i.aborted;){e?.throwIfAborted();try{return await this.getTransactionBlock(r)}catch(e){await Promise.race([new Promise(e=>setTimeout(e,n)),o])}}throw i.throwIfAborted(),new Error("Unexpected error while waiting for transaction block.")}experimental_asClientExtension(){return{name:"jsonRPC",register:()=>this}}}class Mc extends Error{}async function Cc({host:e,path:t,body:n,headers:r,method:i}){const o=new URL(t,e).toString(),s=await fetch(o,{method:i,body:n?JSON.stringify(n):void 0,headers:{"Content-Type":"application/json",...r||{}}});if(429===s.status)throw new Mc("Too many requests from this client have been sent to the faucet. Please retry later");try{return await s.json()}catch(e){throw new Error(`Encountered error when parsing response from faucet, error: ${e}, status ${s.status}, response ${s}`)}}function Ac(e){switch(e){case"testnet":return"https://faucet.testnet.sui.io";case"devnet":return"https://faucet.devnet.sui.io";case"localnet":return"http://127.0.0.1:9123";default:throw new Error(`Unknown network: ${e}`)}}var Nc=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},jc=(e,t,n)=>(Nc(e,t,"read from private field"),n?n.call(e):t.get(e)),Dc=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Rc=(e,t,n)=>(Nc(e,t,"access private method"),n),Pc=(e,t={})=>{const n=((e={})=>{const{accountIndex:t=0,isExternal:n=!1,addressIndex:r=0}=e;return`m/44'/784'/${t}'/${n?1:0}'/${r}'`})(t);return Mu.deriveKeypair(e,n)},Bc=e=>{if((e=>/^0x[0-9a-fA-F]+$|^[0-9a-fA-F]+$/.test(e))(e))return(e=>{if(!e)throw new Error("cannot parse empty string to Uint8Array");const t=e.replace("0x","").match(/.{1,2}/g)?.map(e=>parseInt(e,16));if(!t||0===t.length)throw new Error(`Unable to parse HEX: ${e}`);return Uint8Array.from(t)})(e);if((e=>/^[a-zA-Z0-9+/]+={0,2}$/g.test(e))(e))return Cu(e);throw new Error("The string is not a valid hex or base64 string.")},Fc=e=>{if(64===e.length)e=e.slice(0,32);else{if(33===e.length&&0===e[0])return e.slice(1);if(32===e.length)return e}throw new Error("invalid secret key")},Lc=class{constructor({mnemonics:e,secretKey:t}={}){this.mnemonics=e||"",this.secretKey=t||"",this.mnemonics||this.secretKey||(this.mnemonics=((e=24)=>pu(Au,12===e?128:256))(24)),this.currentKeyPair=this.secretKey?this.parseSecretKey(this.secretKey):Pc(this.mnemonics),this.currentAddress=this.currentKeyPair.getPublicKey().toSuiAddress()}parseSecretKey(e){if(e.startsWith(ru)){const{secretKey:t}=su(e);return Mu.fromSecretKey(Fc(t))}return Mu.fromSecretKey(Fc(Bc(e)))}getKeyPair(e){return e&&this.mnemonics?Pc(this.mnemonics,e):this.currentKeyPair}getAddress(e){return e&&this.mnemonics?Pc(this.mnemonics,e).getPublicKey().toSuiAddress():this.currentAddress}switchAccount(e){this.mnemonics&&(this.currentKeyPair=Pc(this.mnemonics,e),this.currentAddress=this.currentKeyPair.getPublicKey().toSuiAddress())}};function Uc(e,t,n){if(0===t.length)throw new Error("Transaction builder error: Empty array is not allowed");const r=(e=>"string"==typeof e&&it(e)?"object":"number"==typeof e||"bigint"==typeof e?"u64":"boolean"==typeof e?"bool":void 0)(t[0]);if("object"===(n=n||r)){const n=t.map(t=>"string"==typeof t&&it(t)?e.object(ut(t)):Vc(e,t));return e.makeMoveVec({elements:n})}if("string"!=typeof n||/^vector<(.+)>$/.test(n)||/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/.test(n)){const r=t.map(t=>Vc(e,t));return e.makeMoveVec({elements:r,type:n})}{const r=lr(n);return e.pure(un.vector(r).serialize(t))}}function $c(e,t){return t.map(t=>{if(t instanceof pe||de(t))return e.pure(t);if(function(e){return"object"==typeof e&&"vecType"in e&&"value"in e||!!Array.isArray(e)}(t)){return"vecType"in t?Uc(e,t.value,t.vecType):Uc(e,t)}return t})}function qc(e,t){return"string"==typeof t&&rt(t)?e.pure.address(at(t)):$c(e,[t])[0]}function Vc(e,t){if("string"==typeof t)return e.object(t);if("digest"in t&&"version"in t&&"objectId"in t)return e.objectRef(t);if("objectId"in t&&"initialSharedVersion"in t&&"mutable"in t)return e.sharedObjectRef(t);if("Object"in t){if("ImmOrOwnedObject"in t.Object)return e.object(an.ObjectRef(t.Object.ImmOrOwnedObject));if("SharedObject"in t.Object)return e.object(an.SharedObjectRef(t.Object.SharedObject));throw new Error("Invalid argument type")}if("function"==typeof t)return t;if("GasCoin"in t||"Input"in t||"Result"in t||"NestedResult"in t)return t;throw new Error("Invalid argument type")}function zc(e,t){return t.map(t=>"number"==typeof t||"bigint"==typeof t?t:$c(e,[t])[0])}var Kc=class{constructor(e){this.tx=void 0!==e?os.from(e):new os}get gas(){return this.tx.gas}get blockData(){return this.tx.blockData}address(e){return this.tx.pure.address(e)}get pure(){return this.tx.pure}object(e){return this.tx.object(e)}objectRef(e){return this.tx.objectRef(e)}sharedObjectRef(e){return this.tx.sharedObjectRef(e)}setSender(e){return this.tx.setSender(e)}setSenderIfNotSet(e){return this.tx.setSenderIfNotSet(e)}setExpiration(e){return this.tx.setExpiration(e)}setGasPrice(e){return this.tx.setGasPrice(e)}setGasBudget(e){return this.tx.setGasBudget(e)}setGasOwner(e){return this.tx.setGasOwner(e)}setGasPayment(e){return this.tx.setGasPayment(e)}serialize(){return this.tx.serialize()}toJSON(){return this.tx.toJSON()}sign(e){return this.tx.sign(e)}build(e={}){return this.tx.build(e)}getDigest(e={}){return this.tx.getDigest(e)}add(...e){return this.tx.add(...e)}publish({modules:e,dependencies:t}){return this.tx.publish({modules:e,dependencies:t})}upgrade(...e){return this.tx.upgrade(...e)}makeMoveVec(...e){return this.tx.makeMoveVec(...e)}transferObjects(e,t){return this.tx.transferObjects(e.map(e=>Vc(this.tx,e)),qc(this.tx,t))}splitCoins(e,t){const n=this.tx.splitCoins(Vc(this.tx,e),zc(this.tx,t));return t.map((e,t)=>n[t])}mergeCoins(e,t){const n=Vc(this.tx,e),r=t.map(e=>Vc(this.tx,e));return this.tx.mergeCoins(n,r)}moveCall(e,t=[],n=[]){if(null===e.match(/(?<package>[a-zA-Z0-9]+)::(?<module>[a-zA-Z0-9_]+)::(?<function>[a-zA-Z0-9_]+)/))throw new Error("Invalid target format. Expected `${string}::${string}::${string}`");const r=$c(this.tx,t);return this.tx.moveCall({target:e,arguments:r,typeArguments:n})}transferSuiToMany(e,t){if(e.length!==t.length)throw new Error("transferSuiToMany: recipients.length !== amounts.length");const n=this.tx.splitCoins(this.tx.gas,t.map(e=>"number"==typeof e||"bigint"==typeof e?e:$c(this.tx,[e])[0]));return e.map(e=>qc(this.tx,e)).forEach((e,t)=>{this.tx.transferObjects([n[t]],e)}),this}transferSui(e,t){return this.transferSuiToMany([e],[t])}takeAmountFromCoins(e,t){const n=e.map(e=>Vc(this.tx,e)),r=n[0];e.length>1&&this.tx.mergeCoins(r,n.slice(1));const[i]=this.tx.splitCoins(r,zc(this.tx,[t]));return[i,r]}splitSUIFromGas(e){return this.tx.splitCoins(this.tx.gas,zc(this.tx,e))}splitMultiCoins(e,t){const n=e.map(e=>Vc(this.tx,e)),r=n[0];e.length>1&&this.tx.mergeCoins(r,n.slice(1));return{splitedCoins:this.tx.splitCoins(r,zc(this.tx,t)),mergedCoin:r}}transferCoinToMany(e,t,n,r){if(n.length!==r.length)throw new Error("transferSuiToMany: recipients.length !== amounts.length");const i=e.map(e=>Vc(this.tx,e)),{splitedCoins:o,mergedCoin:s}=this.splitMultiCoins(i,r);return n.map(e=>qc(this.tx,e)).forEach((e,t)=>{this.tx.transferObjects([o[t]],e)}),this.tx.transferObjects([s],qc(this.tx,t)),this}transferCoin(e,t,n,r){return this.transferCoinToMany(e,t,[n],[r])}stakeSui(e,t){const[n]=this.tx.splitCoins(this.tx.gas,zc(this.tx,[e]));return this.tx.moveCall({target:"0x3::sui_system::request_add_stake",arguments:$c(this.tx,[this.tx.object(cr),n,qc(this.tx,t)])})}},Wc=class{constructor(e){this.objectId=e.objectId,this.version=e.version,this.digest=e.digest}isFullObject(){return!!this.version&&!!this.digest}asCallArg(){return this.version&&this.digest?{$kind:"Object",Object:{$kind:"ImmOrOwnedObject",ImmOrOwnedObject:{objectId:this.objectId,version:this.version,digest:this.digest}}}:this.objectId}updateFromTxResponse(e){const t=e.objectChanges;if(!t)throw new Error("Bad transaction response!");for(const e of t)if("mutated"===e.type&&e.objectId===this.objectId)return this.digest=e.digest,void(this.version=e.version);throw new Error("Could not find object in transaction response!")}},Qc=class{constructor(e){this.objectId=e.objectId,this.initialSharedVersion=e.initialSharedVersion}asCallArg(e=!1){return this.initialSharedVersion?{$kind:"Object",Object:{$kind:"SharedObject",SharedObject:{objectId:this.objectId,initialSharedVersion:this.initialSharedVersion,mutable:e}}}:this.objectId}},Gc=e=>new Promise(t=>setTimeout(t,e)),Hc=class{constructor(e,t){if(0===e.length)throw new Error("fullNodeUrls must not be empty");this.fullNodes=e,this.clients=e.map(e=>new Ic({url:e})),this.currentFullNode=e[0],this.currentClient=this.clients[0],this.network=t}switchToNextClient(){const e=this.clients.indexOf(this.currentClient);this.currentClient=this.clients[(e+1)%this.clients.length],this.currentFullNode=this.fullNodes[(e+1)%this.clients.length]}async sendTx(e,t){const n={showEvents:!0,showEffects:!0,showObjectChanges:!0,showBalanceChanges:!0};for(const r in this.clients)try{return await this.clients[r].executeTransactionBlock({transactionBlock:e,signature:t,options:n})}catch(e){console.warn(`Failed to send transaction with fullnode ${this.fullNodes[r]}: ${e}`),await Gc(2e3)}throw new Error("Failed to send transaction with all fullnodes")}async waitForTransaction({digest:e,timeout:t=6e4,pollInterval:n=2e3}){for(const r in this.clients)try{const i={showEvents:!0,showEffects:!0,showObjectChanges:!0,showBalanceChanges:!0};return await this.clients[r].waitForTransaction({digest:e,timeout:t,pollInterval:n,options:i})}catch(e){console.warn(`Failed to wait for transaction with fullnode ${this.fullNodes[r]}: ${e}`),await Gc(2e3)}throw new Error("Failed to wait for transaction with all fullnodes")}async getObjects(e,t){const n=t??{showContent:!0,showDisplay:!0,showType:!0,showOwner:!0};for(const t in this.clients)try{const r=(await this.clients[t].multiGetObjects({ids:e,options:n})).map(e=>e.data).filter(e=>null!=e);return r}catch(e){await Gc(2e3),console.warn(`Failed to get objects with fullnode ${this.fullNodes[t]}: ${e}`)}throw new Error("Failed to get objects with all fullnodes")}async getObject(e){return(await this.getObjects([e]))[0]}async getDynamicFieldObject(e,t){for(const n in this.clients)try{return await this.clients[n].getDynamicFieldObject({parentId:e,name:t})}catch(e){await Gc(2e3),console.warn(`Failed to get DynamicFieldObject with fullnode ${this.fullNodes[n]}: ${e}`)}throw new Error("Failed to get DynamicFieldObject with all fullnodes")}async getDynamicFields(e,t,n){for(const r in this.clients)try{return await this.clients[r].getDynamicFields({parentId:e,cursor:t,limit:n})}catch(e){await Gc(2e3),console.warn(`Failed to get DynamicFields with fullnode ${this.fullNodes[r]}: ${e}`)}throw new Error("Failed to get DynamicFields with all fullnodes")}async getTxDetails(e){for(const t in this.clients)try{const n={showEvents:!0,showEffects:!0,showObjectChanges:!0,showBalanceChanges:!0};return await this.clients[t].getTransactionBlock({digest:e,options:n})}catch(e){await Gc(2e3),console.warn(`Failed to get TransactionBlocks with fullnode ${this.fullNodes[t]}: ${e}`)}throw new Error("Failed to get TransactionBlocks with all fullnodes")}async getOwnedObjects(e,t,n){for(const r in this.clients)try{return await this.clients[r].getOwnedObjects({owner:e,cursor:t,limit:n})}catch(e){await Gc(2e3),console.warn(`Failed to get OwnedObjects with fullnode ${this.fullNodes[r]}: ${e}`)}throw new Error("Failed to get OwnedObjects with all fullnodes")}async getNormalizedMoveModulesByPackage(e){for(const t in this.clients)try{return await this.clients[t].getNormalizedMoveModulesByPackage({package:e})}catch(e){await Gc(2e3),console.warn(`Failed to get NormalizedMoveModules with fullnode ${this.fullNodes[t]}: ${e}`)}throw new Error("Failed to get NormalizedMoveModules with all fullnodes")}async updateObjects(e){const t=e.map(e=>e.objectId),n=await this.getObjects(t);for(const t of n){const n=e.find(e=>e.objectId===t?.objectId);n instanceof Qc?t.owner&&"object"==typeof t.owner&&"Shared"in t.owner?n.initialSharedVersion=t.owner.Shared.initial_shared_version:n.initialSharedVersion=void 0:n instanceof Wc&&(n.version=t?.version,n.digest=t?.digest)}}async selectCoins(e,t,n="0x2::SUI::SUI"){const r=[];let i=0,o=!0,s=null;for(;o&&i<t;){const a=await this.currentClient.getCoins({owner:e,coinType:n,cursor:s});a.data.sort((e,t)=>parseInt(t.balance)-parseInt(e.balance));for(const e of a.data)if(r.push({objectId:e.coinObjectId,digest:e.digest,version:e.version,balance:e.balance}),i+=parseInt(e.balance),i>=t)break;s=a.nextCursor,o=a.hasNextPage}if(!r.length)throw new Error("No valid coins found for the transaction.");return r}async selectObjects(e,t){const n=[];let r=!0,i=null;for(;r;){const o=await this.currentClient.getOwnedObjects({owner:e,cursor:i});for(const e of o.data){const r=await this.getObject(e.data.objectId);r.type===t&&n.push(r)}i=o.nextCursor,r=o.hasNextPage}if(!n.length)throw new Error("Not own this object found for the transaction.");return n}async requestFaucet(e,t){await async function(e){const t=await Cc({host:e.host,path:"/v2/gas",body:{FixedAmountRequest:{recipient:e.recipient}},headers:e.headers,method:"POST"});if("Success"!==t.status)throw new Error(`Faucet request failed: ${t.status.Failure.internal}`);return t}({host:Ac(t),recipient:e})}},Jc="0x4177583b1da65b2d508cb10c8d4f463ecddff07faa9f15a8866d3f56c82521b0",Zc="0x42f50aa8ce4ee977f17474b0745b7ae9801eefc73606c173276837b91b54b30d",Yc=(e="testnet")=>{switch(e){case"localnet":return{fullNode:"http://127.0.0.1:9000",graphql:"http://127.0.0.1:9125",network:"localnet",txExplorer:"https://explorer.polymedia.app/txblock/:txHash?network=local",accountExplorer:"https://explorer.polymedia.app/address/:address?network=local",explorer:"https://explorer.polymedia.app?network=local",indexerUrl:"http://127.0.0.1:3001",channelUrl:"http://127.0.0.1:8080"};case"devnet":return{fullNode:"https://fullnode.devnet.sui.io:443",network:"devnet",txExplorer:"https://suiscan.xyz/devnet/tx/:txHash",accountExplorer:"https://suiscan.xyz/devnet/address/:address",explorer:"https://suiscan.xyz/devnet",indexerUrl:"http://127.0.0.1:3001",channelUrl:"http://127.0.0.1:8080"};case"testnet":default:return{fullNode:"https://fullnode.testnet.sui.io:443",graphql:"https://sui-testnet.mystenlabs.com/graphql",network:"testnet",txExplorer:"https://suiscan.xyz/testnet/tx/:txHash",accountExplorer:"https://suiscan.xyz/testnet/address/:address",explorer:"https://suiscan.xyz/testnet",indexerUrl:"http://127.0.0.1:3001",channelUrl:"http://127.0.0.1:8080",frameworkPackageId:Jc,dappHubId:Zc};case"mainnet":return{fullNode:"https://fullnode.mainnet.sui.io:443",graphql:"https://sui-mainnet.mystenlabs.com/graphql",network:"mainnet",txExplorer:"https://suiscan.xyz/mainnet/tx/:txHash",accountExplorer:"https://suiscan.xyz/mainnet/address/:address",explorer:"https://suiscan.xyz/mainnet",indexerUrl:"http://127.0.0.1:3001",channelUrl:"http://127.0.0.1:8080",frameworkPackageId:"0x1a79c1611ab49723b388510813553ad912d96a4f1a9ed5fdbdb57e446c6fe946",dappHubId:"0x49fb15ecac090f2b7e02c83465d240a3f64a52335b848f156277899d070f9829"}}},Xc=class{constructor({packageId:e,metadata:t}={}){this.packageId=e||"",this.metadata=t||void 0}getFuncByModuleName(e){Object.values(this.metadata).forEach(e=>{const t=e;console.log(`moudle name: ${t.name}`),Object.entries(t.exposedFunctions).forEach(([e,t])=>{console.log(`\tfunc name: ${e}`),Object.values(t.parameters).forEach(e=>{})})})}getAllFunc(){Object.values(this.metadata).forEach(e=>{const t=e;console.log(`moudle name: ${t.name}`),Object.entries(t.exposedFunctions).forEach(([e,t])=>{console.log(`\tfunc name: ${e}`),console.log(`\t\t${t.parameters.length}`),Object.values(t.parameters).forEach(e=>{console.log(`\t\targs: ${e}`)})})})}getAllModule(){Object.values(this.metadata).forEach((e,t)=>{const n=e;console.log(`${t}. ${n.name}`)})}},el={address:un.bytes(32).transform({input:e=>s(e),output:e=>a(e)}),u8:un.u8(),u16:un.u16(),u32:un.u32(),u64:un.u64(),u128:un.u128(),u256:un.u256(),bool:un.bool(),"0x1::ascii::String":un.string(),"0x1::string::String":un.string(),"0x1::option::Option<address>":un.option(un.bytes(32).transform({input:e=>s(e),output:e=>a(e)})),"0x1::option::Option<u8>":un.option(un.u8()),"0x1::option::Option<u16>":un.option(un.u16()),"0x1::option::Option<u32>":un.option(un.u32()),"0x1::option::Option<u64>":un.option(un.u64()),"0x1::option::Option<u128>":un.option(un.u128()),"0x1::option::Option<u256>":un.option(un.u256()),"0x1::option::Option<bool>":un.option(un.bool()),"0x1::option::Option<vector<address>>":un.option(un.vector(un.bytes(32).transform({input:e=>s(e),output:e=>a(e)}))),"0x1::option::Option<vector<u8>>":un.option(un.vector(un.u8())),"0x1::option::Option<vector<u16>>":un.option(un.vector(un.u16())),"0x1::option::Option<vector<u32>>":un.option(un.vector(un.u32())),"0x1::option::Option<vector<u64>>":un.option(un.vector(un.u64())),"0x1::option::Option<vector<u128>>":un.option(un.vector(un.u128())),"0x1::option::Option<vector<u256>>":un.option(un.vector(un.u256())),"0x1::option::Option<vector<bool>>":un.option(un.vector(un.bool())),"vector<address>":un.vector(un.bytes(32).transform({input:e=>s(e),output:e=>a(e)})),"vector<u8>":un.vector(un.u8()),"vector<u16>":un.vector(un.u16()),"vector<u32>":un.vector(un.u32()),"vector<u64>":un.vector(un.u64()),"vector<u128>":un.vector(un.u128()),"vector<u256>":un.vector(un.u256()),"vector<bool>":un.vector(un.bool()),"vector<vector<address>>":un.vector(un.vector(un.bytes(32).transform({input:e=>s(e),output:e=>a(e)}))),"vector<vector<u8>>":un.vector(un.vector(un.u8())),"vector<vector<u16>>":un.vector(un.vector(un.u16())),"vector<vector<u32>>":un.vector(un.vector(un.u32())),"vector<vector<u64>>":un.vector(un.vector(un.u64())),"vector<vector<u128>>":un.vector(un.vector(un.u128())),"vector<vector<u256>>":un.vector(un.vector(un.u256())),"vector<vector<bool>>":un.vector(un.vector(un.bool())),"0x2::coin::Coin<T>":un.struct("Coin",{id:un.fixedArray(32,un.u8()).transform({input:e=>s(e),output:e=>a(Uint8Array.from(e))}),balance:un.struct("Balance",{value:un.u64()})}),"0x2::balance::Balance<T>":un.struct("Balance",{value:un.u64()})};function tl(e){return/^(0x)?[0-9a-fA-F]{64}$/.test(e)?e.startsWith("0x")?e:"0x"+e:null}function nl(e){return"0x"+(e.startsWith("0x")?e:"0x"+e).slice(2).replace(/^0+/,"")}function rl(e){return`${e.replace(/^0x/,"").padStart(64,"0")}::dapp_key::DappKey`}var il=class extends Error{constructor(e){const t=e?.effects?.status?.error||"",n=t?t.match(/function_name: Some\("([^"]+)"\)/):null,r=t?t.match(/address: ([a-fA-F0-9]+)/):null,i=n?n[1]:"unknown",o=r?"0x"+r[1]:"unknown",s=e.error?e.error:"UNKNOWN_ERROR";super([`\n- Function: ${i}`,`- Module Address: ${o}`,`- Error Message: ${s}`].join("\n")),this.errorType="ContractDataParsingError",this.functionName=i,this.moduleAddress=o,this.errorMessage=s}},ol=class{constructor(e){this.baseUrl=e.baseUrl.replace(/\/$/,""),this.timeout=e.timeout||3e4,this.activeSubscriptions=new Map}updateConfig(e){void 0!==e.baseUrl&&(this.baseUrl=e.baseUrl.replace(/\/$/,"")),void 0!==e.timeout&&(this.timeout=e.timeout)}async subscribeTable(e,t){const n=this.generateSubscriptionKey(e);if(this.activeSubscriptions.has(n))throw new Error(`Already subscribed to: ${n}`);const r=new AbortController;this.activeSubscriptions.set(n,r);const i=`${this.baseUrl}/subscribe_table`;try{const n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(e),signal:r.signal});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);if(!n.body)throw new Error("Response body is null");this.handleSSEStream(n.body,t,r.signal).catch(e=>{"AbortError"!==e.name&&t?.onError?.(e)}),t?.onOpen?.()}catch(e){throw this.activeSubscriptions.delete(n),"AbortError"!==e.name&&t?.onError?.(e),e}return()=>{r.abort(),this.activeSubscriptions.delete(n),t?.onClose?.()}}async getTable(e){const t=`${this.baseUrl}/get_table`;try{const n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)});if(!n.ok){const e=await n.text();throw new Error(`HTTP error! status: ${n.status}, message: ${e}`)}return await n.json()}catch(e){throw new Error(`Failed to get table data: ${e.message}`)}}async submit(e){const t=`${this.baseUrl}/submit`;try{const n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const e=await n.text();throw new Error(`HTTP error! status: ${n.status}, message: ${e}`)}return await n.json()}catch(e){throw new Error(`Failed to submit transaction: ${e.message}`)}}async getNonce(e){const t=`${this.baseUrl}/nonce`;try{const n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)});if(!n.ok){const e=await n.text();throw new Error(`HTTP error! status: ${n.status}, message: ${e}`)}return await n.json()}catch(e){throw new Error(`Failed to get nonce: ${e.message}`)}}unsubscribe(e){const t=this.generateSubscriptionKey(e),n=this.activeSubscriptions.get(t);n&&(n.abort(),this.activeSubscriptions.delete(t))}unsubscribeAll(){for(const e of this.activeSubscriptions.values())e.abort();this.activeSubscriptions.clear()}getActiveSubscriptionCount(){return this.activeSubscriptions.size}async handleSSEStream(e,t,n){const r=e.getReader(),i=new TextDecoder;let o="";try{for(;!n?.aborted;){const e=await r.read();if(e.done){t?.onClose?.();break}if(e.value){o+=i.decode(e.value,{stream:!0});const n=o.split("\n");o=n.pop()||"";for(const e of n)if(e.startsWith("data:"))try{const n=e.substring(5).trim();if(n){const e=JSON.parse(n),r={dapp_key:e.data_key.dapp_key,account:e.data_key.account,table:e.data_key.table,key:e.data_key.key,value:e.value};t?.onMessage?.(r)}}catch(e){t?.onError?.(new Error(`Failed to parse SSE data: ${e.message}`))}}}}catch(e){"AbortError"!==e.name&&t?.onError?.(e)}finally{r.releaseLock()}}generateSubscriptionKey(e){const t=[e.dapp_key];return e.account&&t.push(e.account),e.table&&t.push(e.table),e.key&&t.push(JSON.stringify(e.key)),t.join(":")}};function sl(e){return void 0===e}function al(e,t){return t.meta=e,t}function ul(e,t){return al(e,async({tx:e,params:n,typeArguments:r,isRaw:i})=>await t(e,n,r,i))}function cl(e,t){return al(e,async({tx:e,params:n,typeArguments:r,isRaw:i,onSuccess:o,onError:s})=>await t(e,n,r,i,o,s))}var ll,hl,fl,dl,pl,yl,ml,gl,bl,vl,wl=class{constructor({mnemonics:e,secretKey:t,networkType:n,fullnodeUrls:r,packageId:i,dappKey:o,metadata:u,channelUrl:c,frameworkPackageId:l,dappStorageId:h,dappHubId:f}={}){Dc(this,bl),Dc(this,ll,{}),Dc(this,hl,{}),Dc(this,fl,el),Dc(this,dl,async(e,t,n,r,i,o,s)=>!0===i?t.moveCall({target:`${this.contractFactory.packageId}::${e.moduleName}::${e.funcName}`,arguments:n,typeArguments:r}):(t.moveCall({target:`${this.contractFactory.packageId}::${e.moduleName}::${e.funcName}`,arguments:n,typeArguments:r}),await this.signAndSendTxn({tx:t,onSuccess:o,onError:s}))),Dc(this,pl,async(e,t,n,r,i)=>!0===i?t.moveCall({target:`${this.contractFactory.packageId}::${e.moduleName}::${e.funcName}`,arguments:n,typeArguments:r}):(t.moveCall({target:`${this.contractFactory.packageId}::${e.moduleName}::${e.funcName}`,arguments:n,typeArguments:r}),await this.inspectTxn(t))),Dc(this,yl,e=>"object"==typeof e&&"Vector"in e?1+jc(this,yl).call(this,e.Vector):0),Dc(this,ml,e=>{let t=!1;const n={};return Object.entries(e.objectType.fields).forEach(([e,r])=>{const i=r.name,o=r.type;switch(typeof o){case"object":for(const[e,r]of Object.entries(o))switch(e){case"Struct":const e=r;if("0x1"===e.address&&"ascii"===e.module&&"String"===e.name)return void(n[i]=un.string());if("0x2"===e.address&&"object"===e.module&&"UID"===e.name)return void(n[i]=un.fixedArray(32,un.u8()).transform({input:e=>s(e),output:e=>a(Uint8Array.from(e))}));if("0x2"===e.address&&"object"===e.module&&"ID"===e.name)return void(n[i]=un.fixedArray(32,un.u8()).transform({input:e=>s(e),output:e=>a(Uint8Array.from(e))}));if("0x2"===e.address&&"bag"===e.module&&"Bag"===e.name)return void(n[i]=un.fixedArray(32,un.u8()).transform({input:e=>s(e),output:e=>a(Uint8Array.from(e))}));if("0x1"===e.address&&"option"===e.module&&"Option"===e.name)switch(e.typeArguments[0]){case"U8":return void(n[i]=un.option(un.u8()));case"U16":return void(n[i]=un.option(un.u16()));case"U32":return void(n[i]=un.option(un.u32()));case"U64":return void(n[i]=un.option(un.u64()));case"U128":return void(n[i]=un.option(un.u128()));case"U256":return void(n[i]=un.option(un.u256()));case"Bool":return void(n[i]=un.option(un.bool()));case"Address":return void(n[i]=un.option(un.bytes(32).transform({input:e=>s(e),output:e=>a(e)})))}else{if(void 0!==this.object[`${e.address}::${e.module}::${e.name}`])return void(n[i]=this.object[`${e.address}::${e.module}::${e.name}`]);t=!0}return;case"Vector":if("string"==typeof r)switch(r){case"U8":return void(n[i]=un.vector(un.u8()));case"U16":return void(n[i]=un.vector(un.u16()));case"U32":return void(n[i]=un.vector(un.u32()));case"U64":return void(n[i]=un.vector(un.u64()));case"U128":return void(n[i]=un.vector(un.u128()));case"U256":return void(n[i]=un.vector(un.u256()));case"Bool":return void(n[i]=un.vector(un.bool()));case"Address":return void(n[i]=un.vector(un.bytes(32).transform({input:e=>s(e),output:e=>a(e)})))}if("object"==typeof r){const e=jc(this,yl).call(this,r);let o=r;for(let t=0;t<e;t++)o=o.Vector;if("object"==typeof o&&null!==o&&"Struct"in o){const r=o.Struct,s=`${r.address}::${r.module}::${r.name}`;let a=jc(this,fl)[s];if(!a)return void(t=!0);let u=a;for(let t=0;t<=e;t++)u=un.vector(u);return void(n[i]=u)}if("string"==typeof o){let t;switch(o){case"U8":t=un.u8();break;case"U16":t=un.u16();break;case"U32":t=un.u32();break;case"U64":t=un.u64();break;case"U128":t=un.u128();break;case"U256":t=un.u256();break;case"Bool":t=un.bool();break;case"Address":t=un.bytes(32).transform({input:e=>s(e),output:e=>a(e)});break;default:return}for(let n=0;n<=e;n++)t=un.vector(t);return void(n[i]=t)}}return;case"TypeParameter":return void(n[i]=un.u128());default:throw new Error("Unsupported type")}return;case"string":switch(o){case"U8":return void(n[i]=un.u8());case"U16":return void(n[i]=un.u16());case"U32":return void(n[i]=un.u32());case"U64":return void(n[i]=un.u64());case"U128":return void(n[i]=un.u128());case"U256":return void(n[i]=un.u256());case"Bool":return void(n[i]=un.bool());case"Address":return void(n[i]=un.bytes(32).transform({input:e=>s(e),output:e=>a(e)}));default:return}default:throw new Error("Unsupported type")}}),{bcs:un.struct(e.objectName,n),loopFlag:t}}),Dc(this,gl,e=>{let t=!1;const n={};return Object.entries(e.objectType.variants).forEach(([e,r])=>{r.length>0?Object.entries(r).forEach(([e,r])=>{const i=r.type,o=r.name;switch(typeof i){case"object":for(const[e,r]of Object.entries(i))switch(e){case"Struct":const e=r;if("0x1"===e.address&&"ascii"===e.module&&"String"===e.name)return void(n[o]=un.string());if("0x2"===e.address&&"object"===e.module&&"UID"===e.name)return void(n[o]=un.fixedArray(32,un.u8()).transform({input:e=>s(e),output:e=>a(Uint8Array.from(e))}));if("0x2"===e.address&&"object"===e.module&&"ID"===e.name)return void(n[o]=un.fixedArray(32,un.u8()).transform({input:e=>s(e),output:e=>a(Uint8Array.from(e))}));if("0x2"===e.address&&"bag"===e.module&&"Bag"===e.name)return void(n[o]=un.fixedArray(32,un.u8()).transform({input:e=>s(e),output:e=>a(Uint8Array.from(e))}));if("0x1"===e.address&&"option"===e.module&&"Option"===e.name)switch(e.typeArguments[0]){case"U8":return void(n[o]=un.option(un.u8()));case"U16":return void(n[o]=un.option(un.u16()));case"U32":return void(n[o]=un.option(un.u32()));case"U64":return void(n[o]=un.option(un.u64()));case"U128":return void(n[o]=un.option(un.u128()));case"U256":return void(n[o]=un.option(un.u256()));case"Bool":return void(n[o]=un.option(un.bool()));case"Address":return void(n[o]=un.option(un.bytes(32).transform({input:e=>s(e),output:e=>a(e)})))}else{if(void 0!==this.object[`${e.address}::${e.module}::${e.name}`])return void(n[o]=this.object[`${e.address}::${e.module}::${e.name}`]);t=!0}return;case"Vector":if("string"==typeof r)switch(r){case"U8":return void(n[o]=un.vector(un.u8()));case"U16":return void(n[o]=un.vector(un.u16()));case"U32":return void(n[o]=un.vector(un.u32()));case"U64":return void(n[o]=un.vector(un.u64()));case"U128":return void(n[o]=un.vector(un.u128()));case"U256":return void(n[o]=un.vector(un.u256()));case"Bool":return void(n[o]=un.vector(un.bool()));case"Address":return void(n[o]=un.vector(un.bytes(32).transform({input:e=>s(e),output:e=>a(e)})))}case"TypeParameter":return void(n[o]=un.u128());default:throw new Error("Unsupported type")}return;case"string":switch(i){case"U8":return void(n[o]=un.u8());case"U16":return void(n[o]=un.u16());case"U32":return void(n[o]=un.u32());case"U64":return void(n[o]=un.u64());case"U128":return void(n[o]=un.u128());case"U256":return void(n[o]=un.u256());case"Bool":return void(n[o]=un.bool());case"Address":return void(n[o]=un.bytes(32).transform({input:e=>s(e),output:e=>a(e)}));default:return}default:throw new Error("Unsupported type")}}):n[e]=null}),{bcs:un.enum(e.objectName,n),loopFlag:t}});const d=Yc(n=n??"mainnet");this.accountManager=new Lc({mnemonics:e,secretKey:t}),r=r||[d.fullNode],this.suiInteractor=new Hc(r,n),this.dubheChannelClient=new ol({baseUrl:c||d.channelUrl}),this.packageId=i?nl(i):void 0,this.dappKey=o;const p=d.frameworkPackageId;if(this.frameworkPackageId=l?nl(l):p?nl(p):void 0,this.dappStorageId=h,this.dappHubId=f,void 0!==u){this.metadata=u;const e=5;let t=0,n=!0;for(;!0===n&&t<=e;){let e=!1;Object.values(u).forEach(t=>{const n=t,r=n.name,i=r;i.endsWith("_genesis")&&(this.projectName=i.replace("_genesis",""));const o=`${this.packageId}::${r}`;n.enums&&Object.entries(n.enums).forEach(([t,n])=>{const r=`${o}::${t}`,i={objectId:r,objectName:t,objectType:n};let s=jc(this,gl).call(this,i);!0===s.loopFlag&&(e=s.loopFlag),void 0===jc(this,fl)[r]&&(jc(this,fl)[r]=s.bcs,jc(this,fl)[`vector<${r}>`]=un.vector(s.bcs),jc(this,fl)[`vector<vector<${r}>>`]=un.vector(un.vector(s.bcs)),jc(this,fl)[`0x1::option::Option<${r}>`]=un.option(s.bcs))}),Object.entries(n.structs).forEach(([t,n])=>{const r=`${o}::${t}`,i={objectId:r,objectName:t,objectType:n};let s=jc(this,ml).call(this,i);!0===s.loopFlag&&(e=s.loopFlag),jc(this,fl)[r]=s.bcs,jc(this,fl)[`vector<${r}>`]=un.vector(s.bcs),jc(this,fl)[`0x1::option::Option<${r}>`]=un.option(s.bcs)}),Object.entries(n.exposedFunctions).forEach(([e,t])=>{const n=t;n.moduleName=r,n.funcName=e,sl(jc(this,ll)[r])&&(jc(this,ll)[r]={}),sl(jc(this,ll)[r][e])&&(jc(this,ll)[r][e]=ul(n,(e,t,r,i)=>jc(this,pl).call(this,n,e,t,r,i))),sl(jc(this,hl)[r])&&(jc(this,hl)[r]={}),sl(jc(this,hl)[r][e])&&(jc(this,hl)[r][e]=cl(n,(e,t,r,i,o,s)=>jc(this,dl).call(this,n,e,t,r,i,o,s)))})}),n=e,t++}}this.contractFactory=new Xc({packageId:this.packageId,metadata:u})}get query(){return jc(this,ll)}get tx(){return jc(this,hl)}get object(){return jc(this,fl)}view(e){let t=[];if("success"===e.effects.status.status){const n=e.results[0].returnValues;for(const e of n){let n=e[0],r=e[1];const i=Uint8Array.from(n),o=r.match(/^.*::storage_value::StorageValue<(.+)>$/);if(o){const e=o[1];if(jc(this,fl)[e]){const n=un.struct("StorageValue",{contents:un.vector(un.struct("Entry",{value:jc(this,fl)[e]}))});t.push(n.parse(i));continue}}const s=r.match(/^.*::storage_map::StorageMap<(.+)>$/);if(s){const e=s[1],[n,r]=e.split(",").map(e=>e.trim());if(jc(this,fl)[n]&&jc(this,fl)[r]){const e=un.struct("StorageMap",{contents:un.vector(un.struct("Entry",{key:jc(this,fl)[n],value:jc(this,fl)[r]}))});t.push(e.parse(i));continue}}const a=r.match(/^.*::storage_double_map::StorageDoubleMap<(.+)>$/);if(a){const e=a[1],[n,r,o]=e.split(",").map(e=>e.trim());if(jc(this,fl)[n]&&jc(this,fl)[r]&&jc(this,fl)[o]){const e=un.struct("StorageDoubleMap",{contents:un.vector(un.struct("Entry",{key1:jc(this,fl)[n],key2:jc(this,fl)[r],value:jc(this,fl)[o]}))});t.push(e.parse(i));continue}}if(jc(this,fl)[r]){t.push(jc(this,fl)[r].parse(i));continue}const u=r.match(/^([^<]+)<(.+)>$/);if(u){const[e,n,r]=u,o=`${n}<T>`;if(jc(this,fl)[o]){t.push(jc(this,fl)[o].parse(i));continue}}throw console.log("\n[41m[37m ERROR [0m [31mUnsupported Type[0m"),console.log("[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m"),console.log(`[95m•[0m Type: [33m"${r}"[0m`),u&&console.log(`[95m•[0m Generic Base Type: [33m"${u[1]}<T>"[0m`),console.log("[95m\n✨ Available Types:[0m"),Object.keys(jc(this,fl)).forEach(e=>{console.log(` [36m◆[0m ${e}`)}),console.log("\n[34m💡 How to Add Custom Type:[0m"),console.log(" You can add custom type by extending the #object map in your code:"),console.log(` [32mdubhe.object["${r}"] = bcs.struct("YourTypeName", {\n field1: bcs.string(),\n field2: bcs.u64(),\n // ... other fields\n });[0m`),console.log("[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m\n"),new Error(`Unsupported type: ${r}`)}return t}throw new il(e)}async state({tx:e,schema:t,params:n,customModuleName:r}){if(!this.metadata)throw new Error("Metadata is not loaded");const i=`${r??this.projectName}_schema`,o=`get_${t}`;let s;try{if(s=await this.query[i][o]({tx:e,params:n}),"success"!==s.effects.status.status)return}catch{return}return this.view(s)}async parseState({schema:e,objectId:t,storageType:n,params:r,customModuleName:i}){const o=new os,s=o.object(t),a=n.match(/^StorageValue<(.+)>$/),u=n.match(/^StorageMap<(.+),\s*(.+)>$/),c=n.match(/^StorageDoubleMap<(.+),\s*(.+),\s*(.+)>$/);let l=[s];if(a)r.length>0&&console.warn("StorageValue does not require additional parameters. Extra parameters will be ignored.");else if(u){if(1!==r.length)throw new Error("StorageMap requires exactly one key parameter");const e=u[1].trim();l.push(Rc(this,bl,vl).call(this,o,e,r[0]))}else{if(!c)throw new Error(`Invalid storage type: ${n}. Must be StorageValue<V>, StorageMap<K,V>, or StorageDoubleMap<K1,K2,V>`);{if(2!==r.length)throw new Error("StorageDoubleMap requires exactly two key parameters");const e=c[1].trim(),t=c[2].trim();l.push(Rc(this,bl,vl).call(this,o,e,r[0])),l.push(Rc(this,bl,vl).call(this,o,t,r[1]))}}return this.state({tx:o,schema:e,params:l,customModuleName:i})}getSigner(e){return this.accountManager.getKeyPair(e)}switchAccount(e){this.accountManager.switchAccount(e)}getAddress(e){return this.accountManager.getAddress(e)}currentAddress(){return this.accountManager.currentAddress}getPackageId(){return this.contractFactory.packageId}getDappKey(){return this.dappKey}getMetadata(){return this.contractFactory.metadata}getNetwork(){return this.suiInteractor.network}getNetworkConfig(){return Yc(this.getNetwork())}getTxExplorerUrl(e){return this.getNetworkConfig().txExplorer.replace(":txHash",e)}getAccountExplorerUrl(e){return this.getNetworkConfig().accountExplorer.replace(":address",e)}getExplorerUrl(){return this.getNetworkConfig().explorer}updateConfig(e){void 0===e.secretKey&&void 0===e.mnemonics||(this.accountManager=new Lc({mnemonics:e.mnemonics,secretKey:e.secretKey}));const t=void 0!==e.networkType&&e.networkType!==this.suiInteractor.network,n=void 0!==e.fullnodeUrls;if(t||n){const t=e.networkType??this.suiInteractor.network,n=Yc(t),r=e.fullnodeUrls||[n.fullNode];this.suiInteractor=new Hc(r,t)}void 0!==e.channelUrl&&this.dubheChannelClient.updateConfig({baseUrl:e.channelUrl});const r=void 0!==e.packageId&&e.packageId!==this.packageId,i=void 0!==e.metadata&&e.metadata!==this.metadata;if(void 0!==e.dappKey&&(this.dappKey=e.dappKey),(r||i)&&(void 0!==e.packageId&&(this.packageId=nl(e.packageId)),void 0!==e.metadata)){this.metadata=e.metadata,Object.keys(jc(this,ll)).forEach(e=>delete jc(this,ll)[e]),Object.keys(jc(this,hl)).forEach(e=>delete jc(this,hl)[e]),Object.keys(jc(this,fl)).forEach(e=>delete jc(this,fl)[e]),Object.assign(jc(this,fl),el);const t=5;let n=0,r=!0;for(;!0===r&&n<=t;){let e=!1;Object.values(this.metadata).forEach(t=>{const n=t,r=n.name,i=r;i.endsWith("_genesis")&&(this.projectName=i.replace("_genesis",""));const o=`${this.packageId}::${r}`;n.enums&&Object.entries(n.enums).forEach(([t,n])=>{const r=`${o}::${t}`,i={objectId:r,objectName:t,objectType:n};let s=jc(this,gl).call(this,i);!0===s.loopFlag&&(e=s.loopFlag),void 0===jc(this,fl)[r]&&(jc(this,fl)[r]=s.bcs,jc(this,fl)[`vector<${r}>`]=un.vector(s.bcs),jc(this,fl)[`vector<vector<${r}>>`]=un.vector(un.vector(s.bcs)),jc(this,fl)[`0x1::option::Option<${r}>`]=un.option(s.bcs))}),Object.entries(n.structs).forEach(([t,n])=>{const r=`${o}::${t}`,i={objectId:r,objectName:t,objectType:n};let s=jc(this,ml).call(this,i);!0===s.loopFlag&&(e=s.loopFlag),jc(this,fl)[r]=s.bcs,jc(this,fl)[`vector<${r}>`]=un.vector(s.bcs),jc(this,fl)[`0x1::option::Option<${r}>`]=un.option(s.bcs)}),Object.entries(n.exposedFunctions).forEach(([e,t])=>{const n=t;n.moduleName=r,n.funcName=e,sl(jc(this,ll)[r])&&(jc(this,ll)[r]={}),sl(jc(this,ll)[r][e])&&(jc(this,ll)[r][e]=ul(n,(e,t,r,i)=>jc(this,pl).call(this,n,e,t,r,i))),sl(jc(this,hl)[r])&&(jc(this,hl)[r]={}),sl(jc(this,hl)[r][e])&&(jc(this,hl)[r][e]=cl(n,(e,t,r,i,o,s)=>jc(this,dl).call(this,n,e,t,r,i,o,s)))})}),r=e,n++}this.contractFactory=new Xc({packageId:this.packageId,metadata:this.metadata})}}async requestFaucet(e,t,n){return void 0===e&&(e=this.accountManager.getAddress(n)),void 0===t&&(t=this.getNetwork()),this.suiInteractor.requestFaucet(e,t)}async getBalance(e,t){const n=this.accountManager.getAddress(t);return this.suiInteractor.currentClient.getBalance({owner:n,coinType:e})}async balanceOf(e,t,n){void 0===e&&(e=this.accountManager.getAddress(n));const r=e;return this.suiInteractor.currentClient.getBalance({owner:r,coinType:t})}client(){return this.suiInteractor.currentClient}async getObject(e){return this.suiInteractor.getObject(e)}async getObjects(e){return this.suiInteractor.getObjects(e)}async signTxn(e,t){(e instanceof Kc||e instanceof os)&&e.setSender(this.getAddress(t));const n=e instanceof Kc?e.tx:e,r=n instanceof os?await n.build({client:this.client()}):n,i=this.getSigner(t);return await i.signTransaction(r)}async signAndSendTxn({tx:e,derivePathParams:t,onSuccess:n,onError:r}){try{const{bytes:i,signature:o}=await this.signTxn(e,t),s=await this.sendTx(i,o);return"success"===s.effects?.status.status?n&&await n(s):r&&await r(new Error(`Transaction failed: ${s.effects?.status.error}`)),s}catch(e){throw r&&await r(e),e}}async sendTx(e,t){return this.suiInteractor.sendTx(e,t)}async waitForTransaction(e){return this.suiInteractor.waitForTransaction({digest:e})}async submitToChannel({tx:e,nonce:t,chainType:n}){const r={chain:n||"sui",sender:this.getAddress(),nonce:t,ptb:e.getData(),signature:"base64_encoded_signature_placeholder"};return this.dubheChannelClient.submit(r)}async queryChannelTable({packageId:e,account:t,table:n,key:r}){e=e||this.packageId,(t=t||this.getAddress())&&t.startsWith("0x")&&(t=t.slice(2));const i={dapp_key:rl(e??""),account:t,table:n,key:r};return this.dubheChannelClient.getTable(i)}async subscribeChannelTable({packageId:e,account:t,table:n,key:r}={},i){void 0!==t&&t.startsWith("0x")&&(t=t.slice(2));const o={dapp_key:this.dappKey};return void 0!==t&&(o.account=t),void 0!==n&&(o.table=n),void 0!==r&&(o.key=r),this.dubheChannelClient.subscribeTable(o,i)}async latestNonce({account:e}={}){const t={sender:e=e||this.getAddress()};return(await this.dubheChannelClient.getNonce(t)).nonce}async transferSui(e,t,n){const r=new Kc;return r.transferSui(e,t),this.signAndSendTxn({tx:r,derivePathParams:n})}async transferSuiToMany(e,t,n){const r=new Kc;return r.transferSuiToMany(e,t),this.signAndSendTxn({tx:r,derivePathParams:n})}async transferCoinToMany(e,t,n,r){const i=new Kc,o=this.accountManager.getAddress(r),s=t.reduce((e,t)=>e+t,0),a=await this.suiInteractor.selectCoins(o,s,n);return i.transferCoinToMany(a.map(e=>e.objectId),o,e,t),this.signAndSendTxn({tx:i,derivePathParams:r})}async transferCoin(e,t,n,r){return this.transferCoinToMany([e],[t],n,r)}async transferObjects(e,t,n){const r=new Kc;return r.transferObjects(e,t),this.signAndSendTxn({tx:r,derivePathParams:n})}async moveCall(e){const{target:t,arguments:n=[],typeArguments:r=[],derivePathParams:i}=e,o=new Kc;return o.moveCall(t,n,r),this.signAndSendTxn({tx:o,derivePathParams:i})}async selectCoinsWithAmount(e,t,n){n=n||this.accountManager.currentAddress;return(await this.suiInteractor.selectCoins(n,e,t)).map(e=>e.objectId)}async selectObjectsWithType(e,t){t=t||this.accountManager.currentAddress;return(await this.suiInteractor.selectObjects(t,e)).map(e=>e.objectId)}async stakeSui(e,t,n){const r=new Kc;return r.stakeSui(e,t),this.signAndSendTxn({tx:r,derivePathParams:n})}async inspectTxn(e,t){const n=e instanceof Kc?e.tx:e;return this.suiInteractor.currentClient.devInspectTransactionBlock({transactionBlock:n,sender:this.getAddress(t)})}async getOwnedObjects(e,t,n){const r=await this.suiInteractor.getOwnedObjects(e,t,n),i=[];for(const e of r.data){const t=await this.getObject(e.data.objectId);t.type.split("::")[0]===this.contractFactory.packageId&&i.push(t)}return i}async entity_key_from_object(e){const t=tl(e);return null!==t?e=t:void 0}async entity_key_from_bytes(t){const n=e(t),r=Array.from(n),i=Uint8Array.from(r);return"0x"+un.bytes(32).transform({input:e=>s(e),output:e=>a(e)}).parse(i)}async entity_key_from_address_with_seed(e,t){const n=tl(e);if(null!==n){e=n;const r=Buffer.from(e.slice(2),"hex"),i=Buffer.concat([r,Buffer.from(t,"utf-8")]);return this.entity_key_from_bytes(i)}}async entity_key_from_address_with_u256(e,t){const n=tl(e);if(null!==n){e=n;const r=Buffer.from(e.slice(2),"hex"),i=un.u256().serialize(t).toBytes();return this.entity_key_from_bytes(Buffer.concat([r,i]))}}async entity_key_from_u256(e){return"0x"+e.toString(16).padStart(64,"0")}async initUserStorage({dappHubId:e,dappStorageId:t,derivePathParams:n,onSuccess:r,onError:i}){const o=t??this.dappStorageId;if(!o)throw new Error("dappStorageId is required for initUserStorage. Pass it directly or set it in the Dubhe constructor.");const s=this.packageId;if(!s)throw new Error("packageId is required for initUserStorage.");const a=new os;return a.moveCall({target:`${s}::user_storage_init::init_user_storage`,arguments:[a.object(e),a.object(o)]}),this.signAndSendTxn({tx:a,derivePathParams:n,onSuccess:r,onError:i})}async activateSession({userStorageId:e,sessionWallet:t,durationMs:n,dappHubId:r,clockObjectId:i,derivePathParams:o,onSuccess:s,onError:a}){const u=this.frameworkPackageId;if(!u)throw new Error('frameworkPackageId is required for activateSession. Set it in the Dubhe constructor ({ frameworkPackageId: "0x..." }).');const c=this.dappKey;if(!c)throw new Error('dappKey is required for activateSession. Set it in the Dubhe constructor ({ packageId: "0x..." }).');const l=r??this.dappHubId;if(!l)throw new Error('dappHubId is required for activateSession. Pass it directly or set it in the Dubhe constructor ({ dappHubId: "0x..." }).');const h=i??"0x0000000000000000000000000000000000000000000000000000000000000006",f=new os;return f.moveCall({target:`${u}::dapp_system::activate_session`,typeArguments:[c],arguments:[f.object(l),f.object(e),f.pure.address(t),f.pure.u64(n),f.object(h)]}),this.signAndSendTxn({tx:f,derivePathParams:o,onSuccess:s,onError:a})}async deactivateSession({userStorageId:e,dappHubId:t,derivePathParams:n,onSuccess:r,onError:i}){const o=this.frameworkPackageId;if(!o)throw new Error('frameworkPackageId is required for deactivateSession. Set it in the Dubhe constructor ({ frameworkPackageId: "0x..." }).');const s=this.dappKey;if(!s)throw new Error('dappKey is required for deactivateSession. Set it in the Dubhe constructor ({ packageId: "0x..." }).');const a=t??this.dappHubId;if(!a)throw new Error('dappHubId is required for deactivateSession. Pass it directly or set it in the Dubhe constructor ({ dappHubId: "0x..." }).');const u=new os;return u.moveCall({target:`${o}::dapp_system::deactivate_session`,typeArguments:[s],arguments:[u.object(a),u.object(e)]}),this.signAndSendTxn({tx:u,derivePathParams:n,onSuccess:r,onError:i})}async getUserStorageId(e){const t=this.packageId,n=this.frameworkPackageId;if(!t||!n)return null;const r=e.startsWith("0x")?e:`0x${e}`,i=`${n}::dapp_service::UserStorage`;let o=null,s=!0;for(;s;){const e=await this.suiInteractor.currentClient.queryTransactionBlocks({filter:{MoveFunction:{package:t,module:"user_storage_init",function:"init_user_storage"}},options:{showObjectChanges:!0},...null!=o?{cursor:o}:{},limit:50});for(const t of e.data){if(!t.objectChanges)continue;const e=t.objectChanges.find(e=>"created"===e.type&&"string"==typeof e.objectType&&e.objectType===i&&e.sender===r);if(e?.objectId)return e.objectId}s=e.hasNextPage,o=e.nextCursor??null}return null}async getUserStorageFields(e){const t=await this.suiInteractor.getObject(e),n=t?.content?.fields??{},r=BigInt(n.write_count??0),i=BigInt(n.settled_count??0),o=BigInt(n.write_bytes??0),s=BigInt(n.settled_bytes??0);return{objectId:e,dapp_key:n.dapp_key??"",canonical_owner:n.canonical_owner??"",session_key:n.session_key??"",session_expires_at:BigInt(n.session_expires_at??0),write_count:r,settled_count:i,write_bytes:o,settled_bytes:s,unsettled_count:r-i,unsettled_bytes:o-s}}async getDappStorageFields(e){const t=await this.suiInteractor.getObject(e),n=t?.content?.fields??{};return{objectId:e,dapp_key:n.dapp_key??"",name:n.name??"",description:n.description??"",website_url:n.website_url??"",admin:n.admin??"",version:Number(n.version??0),paused:Boolean(n.paused),free_credit:BigInt(n.free_credit??0),free_credit_expires_at:BigInt(n.free_credit_expires_at??0),credit_pool:BigInt(n.credit_pool??0),min_credit_to_unsuspend:BigInt(n.min_credit_to_unsuspend??0),suspended:Boolean(n.suspended),total_settled:BigInt(n.total_settled??0),base_fee_per_write:BigInt(n.base_fee_per_write??0),bytes_fee_per_byte:BigInt(n.bytes_fee_per_byte??0)}}async settleWrites({dappHubId:e,dappStorageId:t,userStorageId:n,derivePathParams:r,onSuccess:i,onError:o}){const s=this.frameworkPackageId;if(!s)throw new Error('frameworkPackageId is required for settleWrites. Set it in the Dubhe constructor ({ frameworkPackageId: "0x..." }).');const a=t??this.dappStorageId;if(!a)throw new Error("dappStorageId is required for settleWrites. Pass it directly or set it in the Dubhe constructor.");const u=this.dappKey;if(!u)throw new Error('dappKey is required for settleWrites. Set it in the Dubhe constructor ({ packageId: "0x..." }).');const c=new os;return c.moveCall({target:`${s}::dapp_system::settle_writes`,typeArguments:[u],arguments:[c.object(e),c.object(a),c.object(n)]}),this.signAndSendTxn({tx:c,derivePathParams:r,onSuccess:i,onError:o})}static getDefaultConfig(e){return Yc(e)}};ll=new WeakMap,hl=new WeakMap,fl=new WeakMap,dl=new WeakMap,pl=new WeakMap,yl=new WeakMap,ml=new WeakMap,gl=new WeakMap,bl=new WeakSet,vl=function(e,t,n){switch(t.toLowerCase()){case"u8":return e.pure.u8(n);case"u16":return e.pure.u16(n);case"u32":return e.pure.u32(n);case"u64":return e.pure.u64(n);case"u128":return e.pure.u128(n);case"u256":return e.pure.u256(n);case"bool":return e.pure.bool(n);case"address":return e.pure.address(n);default:if(t.includes("::"))return e.object(n);throw console.log("\n[41m[37m ERROR [0m [31mUnsupported Key Type[0m"),console.log("[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m"),console.log(`[95m•[0m Type: [33m"${t}"[0m`),console.log("[95m•[0m Supported Types:[0m"),console.log(" [36m◆[0m u8, u16, u32, u64, u128, u256"),console.log(" [36m◆[0m bool"),console.log(" [36m◆[0m address"),console.log(" [36m◆[0m object (format: package::module::type)"),console.log("[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m\n"),new Error(`Unsupported key type: ${t}`)}};var El=function(e,t){return El=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},El(e,t)};function kl(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}El(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var Sl=function(){return Sl=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Sl.apply(this,arguments)};function Tl(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function _l(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof n?e:new n(function(t){t(e)})}(e.value).then(s,a)}u((r=r.apply(e,t||[])).next())})}function Ol(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}Object.create;function xl(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}Object.create;"function"==typeof SuppressedError&&SuppressedError;var Il="Invariant Violation",Ml=Object.setPrototypeOf,Cl=void 0===Ml?function(e,t){return e.__proto__=t,e}:Ml,Al=function(e){function t(n){void 0===n&&(n=Il);var r=e.call(this,"number"==typeof n?Il+": "+n+" (see https://github.com/apollographql/invariant-packages)":n)||this;return r.framesToPop=1,r.name=Il,Cl(r,t.prototype),r}return kl(t,e),t}(Error);function Nl(e,t){if(!e)throw new Al(t)}var jl=["debug","log","warn","error","silent"],Dl=jl.indexOf("log");function Rl(e){return function(){if(jl.indexOf(e)>=Dl)return(console[e]||console.log).apply(console,arguments)}}!function(e){e.debug=Rl("debug"),e.log=Rl("log"),e.warn=Rl("warn"),e.error=Rl("error")}(Nl||(Nl={}));var Pl="3.14.0";function Bl(e){try{return e()}catch(e){}}const Fl=Bl(function(){return globalThis})||Bl(function(){return window})||Bl(function(){return self})||Bl(function(){return n.g})||Bl(function(){return Bl.constructor("return this")()});var Ll=new Map;function Ul(e){var t=Ll.get(e)||1;return Ll.set(e,t+1),"".concat(e,":").concat(t,":").concat(Math.random().toString(36).slice(2))}function $l(e,t){void 0===t&&(t=0);var n=Ul("stringifyForDisplay");return JSON.stringify(e,function(e,t){return void 0===t?n:t},t).split(JSON.stringify(n)).join("<undefined>")}function ql(e){return function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];if("number"==typeof t){var i=t;(t=Ql(i))||(t=Gl(i,n),n=[])}e.apply(void 0,[t].concat(n))}}var Vl=Object.assign(function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];e||Nl(e,Ql(t,n)||Gl(t,n))},{debug:ql(Nl.debug),log:ql(Nl.log),warn:ql(Nl.warn),error:ql(Nl.error)});function zl(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return new Al(Ql(e,t)||Gl(e,t))}var Kl=Symbol.for("ApolloErrorMessageHandler_"+Pl);function Wl(e){if("string"==typeof e)return e;try{return $l(e,2).slice(0,1e3)}catch(e){return"<non-serializable>"}}function Ql(e,t){if(void 0===t&&(t=[]),e)return Fl[Kl]&&Fl[Kl](e,t.map(Wl))}function Gl(e,t){if(void 0===t&&(t=[]),e)return"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({version:Pl,message:e,args:t.map(Wl)})))}globalThis.__DEV__;function Hl(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Jl(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Jl(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Jl(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Zl(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Yl(e,t,n){return t&&Zl(e.prototype,t),n&&Zl(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var Xl=function(){return"function"==typeof Symbol},eh=function(e){return Xl()&&Boolean(Symbol[e])},th=function(e){return eh(e)?Symbol[e]:"@@"+e};Xl()&&!eh("observable")&&(Symbol.observable=Symbol("observable"));var nh=th("iterator"),rh=th("observable"),ih=th("species");function oh(e,t){var n=e[t];if(null!=n){if("function"!=typeof n)throw new TypeError(n+" is not a function");return n}}function sh(e){var t=e.constructor;return void 0!==t&&null===(t=t[ih])&&(t=void 0),void 0!==t?t:mh}function ah(e){return e instanceof mh}function uh(e){uh.log?uh.log(e):setTimeout(function(){throw e})}function ch(e){Promise.resolve().then(function(){try{e()}catch(e){uh(e)}})}function lh(e){var t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{var n=oh(t,"unsubscribe");n&&n.call(t)}}catch(e){uh(e)}}function hh(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function fh(e,t,n){e._state="running";var r=e._observer;try{var i=oh(r,t);switch(t){case"next":i&&i.call(r,n);break;case"error":if(hh(e),!i)throw n;i.call(r,n);break;case"complete":hh(e),i&&i.call(r)}}catch(e){uh(e)}"closed"===e._state?lh(e):"running"===e._state&&(e._state="ready")}function dh(e,t,n){if("closed"!==e._state){if("buffering"!==e._state)return"ready"!==e._state?(e._state="buffering",e._queue=[{type:t,value:n}],void ch(function(){return function(e){var t=e._queue;if(t){e._queue=void 0,e._state="ready";for(var n=0;n<t.length&&(fh(e,t[n].type,t[n].value),"closed"!==e._state);++n);}}(e)})):void fh(e,t,n);e._queue.push({type:t,value:n})}}var ph=function(){function e(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";var n=new yh(this);try{this._cleanup=t.call(void 0,n)}catch(e){n.error(e)}"initializing"===this._state&&(this._state="ready")}return e.prototype.unsubscribe=function(){"closed"!==this._state&&(hh(this),lh(this))},Yl(e,[{key:"closed",get:function(){return"closed"===this._state}}]),e}(),yh=function(){function e(e){this._subscription=e}var t=e.prototype;return t.next=function(e){dh(this._subscription,"next",e)},t.error=function(e){dh(this._subscription,"error",e)},t.complete=function(){dh(this._subscription,"complete")},Yl(e,[{key:"closed",get:function(){return"closed"===this._subscription._state}}]),e}(),mh=function(){function e(t){if(!(this instanceof e))throw new TypeError("Observable cannot be called as a function");if("function"!=typeof t)throw new TypeError("Observable initializer must be a function");this._subscriber=t}var t=e.prototype;return t.subscribe=function(e){return"object"==typeof e&&null!==e||(e={next:e,error:arguments[1],complete:arguments[2]}),new ph(e,this._subscriber)},t.forEach=function(e){var t=this;return new Promise(function(n,r){if("function"==typeof e)var i=t.subscribe({next:function(t){try{e(t,o)}catch(e){r(e),i.unsubscribe()}},error:r,complete:n});else r(new TypeError(e+" is not a function"));function o(){i.unsubscribe(),n()}})},t.map=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(sh(this))(function(n){return t.subscribe({next:function(t){try{t=e(t)}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})})},t.filter=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(sh(this))(function(n){return t.subscribe({next:function(t){try{if(!e(t))return}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})})},t.reduce=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var n=sh(this),r=arguments.length>1,i=!1,o=arguments[1];return new n(function(n){return t.subscribe({next:function(t){var s=!i;if(i=!0,!s||r)try{o=e(o,t)}catch(e){return n.error(e)}else o=t},error:function(e){n.error(e)},complete:function(){if(!i&&!r)return n.error(new TypeError("Cannot reduce an empty sequence"));n.next(o),n.complete()}})})},t.concat=function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=sh(this);return new i(function(t){var r,o=0;return function e(s){r=s.subscribe({next:function(e){t.next(e)},error:function(e){t.error(e)},complete:function(){o===n.length?(r=void 0,t.complete()):e(i.from(n[o++]))}})}(e),function(){r&&(r.unsubscribe(),r=void 0)}})},t.flatMap=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var n=sh(this);return new n(function(r){var i=[],o=t.subscribe({next:function(t){if(e)try{t=e(t)}catch(e){return r.error(e)}var o=n.from(t).subscribe({next:function(e){r.next(e)},error:function(e){r.error(e)},complete:function(){var e=i.indexOf(o);e>=0&&i.splice(e,1),s()}});i.push(o)},error:function(e){r.error(e)},complete:function(){s()}});function s(){o.closed&&0===i.length&&r.complete()}return function(){i.forEach(function(e){return e.unsubscribe()}),o.unsubscribe()}})},t[rh]=function(){return this},e.from=function(t){var n="function"==typeof this?this:e;if(null==t)throw new TypeError(t+" is not an object");var r=oh(t,rh);if(r){var i=r.call(t);if(Object(i)!==i)throw new TypeError(i+" is not an object");return ah(i)&&i.constructor===n?i:new n(function(e){return i.subscribe(e)})}if(eh("iterator")&&(r=oh(t,nh)))return new n(function(e){ch(function(){if(!e.closed){for(var n,i=Hl(r.call(t));!(n=i()).done;){var o=n.value;if(e.next(o),e.closed)return}e.complete()}})});if(Array.isArray(t))return new n(function(e){ch(function(){if(!e.closed){for(var n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()}})});throw new TypeError(t+" is not observable")},e.of=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return new("function"==typeof this?this:e)(function(e){ch(function(){if(!e.closed){for(var t=0;t<n.length;++t)if(e.next(n[t]),e.closed)return;e.complete()}})})},Yl(e,null,[{key:ih,get:function(){return this}}]),e}();function gh(e){return null!==e&&"object"==typeof e}Xl()&&Object.defineProperty(mh,Symbol("extensions"),{value:{symbol:rh,hostReportError:uh},configurable:!0});const bh="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):void 0;function vh(e){return vh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},vh(e)}function wh(e){return Eh(e,[])}function Eh(e,t){switch(vh(e)){case"string":return JSON.stringify(e);case"function":return e.name?"[function ".concat(e.name,"]"):"[function]";case"object":return null===e?"null":function(e,t){if(-1!==t.indexOf(e))return"[Circular]";var n=[].concat(t,[e]),r=function(e){var t=e[String(bh)];if("function"==typeof t)return t;if("function"==typeof e.inspect)return e.inspect}(e);if(void 0!==r){var i=r.call(e);if(i!==e)return"string"==typeof i?i:Eh(i,n)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>2)return"[Array]";for(var n=Math.min(10,e.length),r=e.length-n,i=[],o=0;o<n;++o)i.push(Eh(e[o],t));1===r?i.push("... 1 more item"):r>1&&i.push("... ".concat(r," more items"));return"["+i.join(", ")+"]"}(e,n);return function(e,t){var n=Object.keys(e);if(0===n.length)return"{}";if(t.length>2)return"["+function(e){var t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){var n=e.constructor.name;if("string"==typeof n&&""!==n)return n}return t}(e)+"]";var r=n.map(function(n){return n+": "+Eh(e[n],t)});return"{ "+r.join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}function kh(e){var t=e.prototype.toJSON;"function"==typeof t||function(e,t){if(!Boolean(e))throw new Error(null!=t?t:"Unexpected invariant triggered.")}(0),e.prototype.inspect=t,bh&&(e.prototype[bh]=t)}var Sh=function(){function e(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}return e.prototype.toJSON=function(){return{start:this.start,end:this.end}},e}();kh(Sh);var Th=function(){function e(e,t,n,r,i,o,s){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=s,this.prev=o,this.next=null}return e.prototype.toJSON=function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}},e}();function _h(e){return null!=e&&"string"==typeof e.kind}kh(Th);var Oh={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},xh=Object.freeze({});function Ih(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Oh,r=void 0,i=Array.isArray(e),o=[e],s=-1,a=[],u=void 0,c=void 0,l=void 0,h=[],f=[],d=e;do{var p=++s===o.length,y=p&&0!==a.length;if(p){if(c=0===f.length?void 0:h[h.length-1],u=l,l=f.pop(),y){if(i)u=u.slice();else{for(var m={},g=0,b=Object.keys(u);g<b.length;g++){var v=b[g];m[v]=u[v]}u=m}for(var w=0,E=0;E<a.length;E++){var k=a[E][0],S=a[E][1];i&&(k-=w),i&&null===S?(u.splice(k,1),w++):u[k]=S}}s=r.index,o=r.keys,a=r.edits,i=r.inArray,r=r.prev}else{if(c=l?i?s:o[s]:void 0,null==(u=l?l[c]:d))continue;l&&h.push(c)}var T,_=void 0;if(!Array.isArray(u)){if(!_h(u))throw new Error("Invalid AST Node: ".concat(wh(u),"."));var O=Mh(t,u.kind,p);if(O){if((_=O.call(t,u,c,l,h,f))===xh)break;if(!1===_){if(!p){h.pop();continue}}else if(void 0!==_&&(a.push([c,_]),!p)){if(!_h(_)){h.pop();continue}u=_}}}if(void 0===_&&y&&a.push([c,u]),p)h.pop();else r={inArray:i,index:s,keys:o,edits:a,prev:r},o=(i=Array.isArray(u))?u:null!==(T=n[u.kind])&&void 0!==T?T:[],s=-1,a=[],l&&f.push(l),l=u}while(void 0!==r);return 0!==a.length&&(d=a[a.length-1][1]),d}function Mh(e,t,n){var r=e[t];if(r){if(!n&&"function"==typeof r)return r;var i=n?r.leave:r.enter;if("function"==typeof i)return i}else{var o=n?e.leave:e.enter;if(o){if("function"==typeof o)return o;var s=o[t];if("function"==typeof s)return s}}}function Ch(e,t){var n=t,r=[];return e.definitions.forEach(function(e){if("OperationDefinition"===e.kind)throw zl(113,e.operation,e.name?" named '".concat(e.name.value,"'"):"");"FragmentDefinition"===e.kind&&r.push(e)}),void 0===n&&(Vl(1===r.length,114,r.length),n=r[0].name.value),Sl(Sl({},e),{definitions:xl([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:n}}]}}],e.definitions,!0)})}function Ah(e){void 0===e&&(e=[]);var t={};return e.forEach(function(e){t[e.name.value]=e}),t}function Nh(e,t){switch(e.kind){case"InlineFragment":return e;case"FragmentSpread":var n=e.name.value;if("function"==typeof t)return t(n);var r=t&&t[n];return Vl(r,115,n),r||null;default:return null}}function jh(){}const Dh=jh,Rh="undefined"!=typeof WeakRef?WeakRef:function(e){return{deref:()=>e}},Ph="undefined"!=typeof WeakMap?WeakMap:Map,Bh="undefined"!=typeof FinalizationRegistry?FinalizationRegistry:function(){return{register:jh,unregister:jh}};class Fh{constructor(e=1/0,t=Dh){this.max=e,this.dispose=t,this.map=new Ph,this.newest=null,this.oldest=null,this.unfinalizedNodes=new Set,this.finalizationScheduled=!1,this.size=0,this.finalize=()=>{const e=this.unfinalizedNodes.values();for(let t=0;t<10024;t++){const t=e.next().value;if(!t)break;this.unfinalizedNodes.delete(t);const n=t.key;delete t.key,t.keyRef=new Rh(n),this.registry.register(n,t,t)}this.unfinalizedNodes.size>0?queueMicrotask(this.finalize):this.finalizationScheduled=!1},this.registry=new Bh(this.deleteNode.bind(this))}has(e){return this.map.has(e)}get(e){const t=this.getNode(e);return t&&t.value}getNode(e){const t=this.map.get(e);if(t&&t!==this.newest){const{older:e,newer:n}=t;n&&(n.older=e),e&&(e.newer=n),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=n)}return t}set(e,t){let n=this.getNode(e);return n?n.value=t:(n={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=n),this.newest=n,this.oldest=this.oldest||n,this.scheduleFinalization(n),this.map.set(e,n),this.size++,n.value)}clean(){for(;this.oldest&&this.size>this.max;)this.deleteNode(this.oldest)}deleteNode(e){e===this.newest&&(this.newest=e.older),e===this.oldest&&(this.oldest=e.newer),e.newer&&(e.newer.older=e.older),e.older&&(e.older.newer=e.newer),this.size--;const t=e.key||e.keyRef&&e.keyRef.deref();this.dispose(e.value,t),e.keyRef?this.registry.unregister(e):this.unfinalizedNodes.delete(e),t&&this.map.delete(t)}delete(e){const t=this.map.get(e);return!!t&&(this.deleteNode(t),!0)}scheduleFinalization(e){this.unfinalizedNodes.add(e),this.finalizationScheduled||(this.finalizationScheduled=!0,queueMicrotask(this.finalize))}}function Lh(){}class Uh{constructor(e=1/0,t=Lh){this.max=e,this.dispose=t,this.map=new Map,this.newest=null,this.oldest=null}has(e){return this.map.has(e)}get(e){const t=this.getNode(e);return t&&t.value}get size(){return this.map.size}getNode(e){const t=this.map.get(e);if(t&&t!==this.newest){const{older:e,newer:n}=t;n&&(n.older=e),e&&(e.newer=n),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=n)}return t}set(e,t){let n=this.getNode(e);return n?n.value=t:(n={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=n),this.newest=n,this.oldest=this.oldest||n,this.map.set(e,n),n.value)}clean(){for(;this.oldest&&this.map.size>this.max;)this.delete(this.oldest.key)}delete(e){const t=this.map.get(e);return!!t&&(t===this.newest&&(this.newest=t.older),t===this.oldest&&(this.oldest=t.newer),t.newer&&(t.newer.older=t.older),t.older&&(t.older.newer=t.newer),this.map.delete(e),this.dispose(t.value,e),!0)}}var $h=new WeakSet;function qh(e){e.size<=(e.max||-1)||$h.has(e)||($h.add(e),setTimeout(function(){e.clean(),$h.delete(e)},100))}var Vh=function(e,t){var n=new Fh(e,t);return n.set=function(e,t){var n=Fh.prototype.set.call(this,e,t);return qh(this),n},n},zh=function(e,t){var n=new Uh(e,t);return n.set=function(e,t){var n=Uh.prototype.set.call(this,e,t);return qh(this),n},n},Kh=Symbol.for("apollo.cacheSize"),Wh=Sl({},Fl[Kh]),Qh={};function Gh(e,t){Qh[e]=t}var Hh=!1!==globalThis.__DEV__?function(){var e,t,n,r,i;if(!1===globalThis.__DEV__)throw new Error("only supported in development mode");return{limits:Object.fromEntries(Object.entries({parser:1e3,canonicalStringify:1e3,print:2e3,"documentTransform.cache":2e3,"queryManager.getDocumentInfo":2e3,"PersistedQueryLink.persistedQueryHashes":2e3,"fragmentRegistry.transform":2e3,"fragmentRegistry.lookup":1e3,"fragmentRegistry.findFragmentSpreads":4e3,"cache.fragmentQueryDocuments":1e3,"removeTypenameFromVariables.getVariableDefinitions":2e3,"inMemoryCache.maybeBroadcastWatch":5e3,"inMemoryCache.executeSelectionSet":5e4,"inMemoryCache.executeSubSelectedArray":1e4}).map(function(e){var t=e[0],n=e[1];return[t,Wh[t]||n]})),sizes:Sl({print:null===(e=Qh.print)||void 0===e?void 0:e.call(Qh),parser:null===(t=Qh.parser)||void 0===t?void 0:t.call(Qh),canonicalStringify:null===(n=Qh.canonicalStringify)||void 0===n?void 0:n.call(Qh),links:rf(this.link),queryManager:{getDocumentInfo:this.queryManager.transformCache.size,documentTransforms:tf(this.queryManager.documentTransform)}},null===(i=(r=this.cache).getMemoryInternals)||void 0===i?void 0:i.call(r))}}:void 0,Jh=!1!==globalThis.__DEV__?function(){var e=this.config.fragments;return Sl(Sl({},Yh.apply(this)),{addTypenameDocumentTransform:tf(this.addTypenameTransform),inMemoryCache:{executeSelectionSet:Xh(this.storeReader.executeSelectionSet),executeSubSelectedArray:Xh(this.storeReader.executeSubSelectedArray),maybeBroadcastWatch:Xh(this.maybeBroadcastWatch)},fragmentRegistry:{findFragmentSpreads:Xh(null==e?void 0:e.findFragmentSpreads),lookup:Xh(null==e?void 0:e.lookup),transform:Xh(null==e?void 0:e.transform)}})}:void 0,Zh=!1!==globalThis.__DEV__?Yh:void 0;function Yh(){return{cache:{fragmentQueryDocuments:Xh(this.getFragmentDoc)}}}function Xh(e){return function(e){return!!e&&"dirtyKey"in e}(e)?e.size:void 0}function ef(e){return null!=e}function tf(e){return nf(e).map(function(e){return{cache:e}})}function nf(e){return e?xl(xl([Xh(null==e?void 0:e.performWork)],nf(null==e?void 0:e.left),!0),nf(null==e?void 0:e.right),!0).filter(ef):[]}function rf(e){var t;return e?xl(xl([null===(t=null==e?void 0:e.getMemoryInternals)||void 0===t?void 0:t.call(e)],rf(null==e?void 0:e.left),!0),rf(null==e?void 0:e.right),!0).filter(ef):[]}var of,sf=Object.assign(function(e){return JSON.stringify(e,af)},{reset:function(){of=new zh(Wh.canonicalStringify||1e3)}});function af(e,t){if(t&&"object"==typeof t){var n=Object.getPrototypeOf(t);if(n===Object.prototype||null===n){var r=Object.keys(t);if(r.every(uf))return t;var i=JSON.stringify(r),o=of.get(i);if(!o){r.sort();var s=JSON.stringify(r);o=of.get(s)||r,of.set(i,o),of.set(s,o)}var a=Object.create(n);return o.forEach(function(e){a[e]=t[e]}),a}}return t}function uf(e,t,n){return 0===t||n[t-1]<=e}function cf(e){return{__ref:String(e)}}function lf(e){return Boolean(e&&"object"==typeof e&&"string"==typeof e.__ref)}function hf(e,t,n,r){if(function(e){return"IntValue"===e.kind}(n)||function(e){return"FloatValue"===e.kind}(n))e[t.value]=Number(n.value);else if(function(e){return"BooleanValue"===e.kind}(n)||function(e){return"StringValue"===e.kind}(n))e[t.value]=n.value;else if(function(e){return"ObjectValue"===e.kind}(n)){var i={};n.fields.map(function(e){return hf(i,e.name,e.value,r)}),e[t.value]=i}else if(function(e){return"Variable"===e.kind}(n)){var o=(r||{})[n.name.value];e[t.value]=o}else if(function(e){return"ListValue"===e.kind}(n))e[t.value]=n.values.map(function(e){var n={};return hf(n,t,e,r),n[t.value]});else if(function(e){return"EnumValue"===e.kind}(n))e[t.value]=n.value;else{if(!function(e){return"NullValue"===e.kind}(n))throw zl(124,t.value,n.kind);e[t.value]=null}}!1!==globalThis.__DEV__&&Gh("canonicalStringify",function(){return of.size}),sf.reset();var ff=["connection","include","skip","client","rest","export","nonreactive"],df=sf,pf=Object.assign(function(e,t,n){if(t&&n&&n.connection&&n.connection.key){if(n.connection.filter&&n.connection.filter.length>0){var r=n.connection.filter?n.connection.filter:[];r.sort();var i={};return r.forEach(function(e){i[e]=t[e]}),"".concat(n.connection.key,"(").concat(df(i),")")}return n.connection.key}var o=e;if(t){var s=df(t);o+="(".concat(s,")")}return n&&Object.keys(n).forEach(function(e){-1===ff.indexOf(e)&&(n[e]&&Object.keys(n[e]).length?o+="@".concat(e,"(").concat(df(n[e]),")"):o+="@".concat(e))}),o},{setStringify:function(e){var t=df;return df=e,t}});function yf(e,t){if(e.arguments&&e.arguments.length){var n={};return e.arguments.forEach(function(e){var r=e.name,i=e.value;return hf(n,r,i,t)}),n}return null}function mf(e){return e.alias?e.alias.value:e.name.value}function gf(e,t,n){for(var r,i=0,o=t.selections;i<o.length;i++){if(bf(u=o[i])){if("__typename"===u.name.value)return e[mf(u)]}else r?r.push(u):r=[u]}if("string"==typeof e.__typename)return e.__typename;if(r)for(var s=0,a=r;s<a.length;s++){var u,c=gf(e,Nh(u=a[s],n).selectionSet,n);if("string"==typeof c)return c}}function bf(e){return"Field"===e.kind}function vf(e){Vl(e&&"Document"===e.kind,116);var t=e.definitions.filter(function(e){return"FragmentDefinition"!==e.kind}).map(function(e){if("OperationDefinition"!==e.kind)throw zl(117,e.kind);return e});return Vl(t.length<=1,118,t.length),e}function wf(e){return vf(e),e.definitions.filter(function(e){return"OperationDefinition"===e.kind})[0]}function Ef(e){return e.definitions.filter(function(e){return"OperationDefinition"===e.kind&&!!e.name}).map(function(e){return e.name.value})[0]||null}function kf(e){return e.definitions.filter(function(e){return"FragmentDefinition"===e.kind})}function Sf(e){var t=wf(e);return Vl(t&&"query"===t.operation,119),t}function Tf(e){Vl("Document"===e.kind,120),Vl(e.definitions.length<=1,121);var t=e.definitions[0];return Vl("FragmentDefinition"===t.kind,122),t}function _f(e){var t;vf(e);for(var n=0,r=e.definitions;n<r.length;n++){var i=r[n];if("OperationDefinition"===i.kind){var o=i.operation;if("query"===o||"mutation"===o||"subscription"===o)return i}"FragmentDefinition"!==i.kind||t||(t=i)}if(t)return t;throw zl(123)}function Of(e){var t=Object.create(null),n=e&&e.variableDefinitions;return n&&n.length&&n.forEach(function(e){e.defaultValue&&hf(t,e.variable.name,e.defaultValue)}),t}const xf=()=>Object.create(null),{forEach:If,slice:Mf}=Array.prototype,{hasOwnProperty:Cf}=Object.prototype;class Af{constructor(e=!0,t=xf){this.weakness=e,this.makeData=t}lookup(){return this.lookupArray(arguments)}lookupArray(e){let t=this;return If.call(e,e=>t=t.getChildTrie(e)),Cf.call(t,"data")?t.data:t.data=this.makeData(Mf.call(e))}peek(){return this.peekArray(arguments)}peekArray(e){let t=this;for(let n=0,r=e.length;t&&n<r;++n){const r=t.mapFor(e[n],!1);t=r&&r.get(e[n])}return t&&t.data}remove(){return this.removeArray(arguments)}removeArray(e){let t;if(e.length){const n=e[0],r=this.mapFor(n,!1),i=r&&r.get(n);i&&(t=i.removeArray(Mf.call(e,1)),i.data||i.weak||i.strong&&i.strong.size||r.delete(n))}else t=this.data,delete this.data;return t}getChildTrie(e){const t=this.mapFor(e,!0);let n=t.get(e);return n||t.set(e,n=new Af(this.weakness,this.makeData)),n}mapFor(e,t){return this.weakness&&function(e){switch(typeof e){case"object":if(null===e)break;case"function":return!0}return!1}(e)?this.weak||(t?this.weak=new WeakMap:void 0):this.strong||(t?this.strong=new Map:void 0)}}let Nf=null;const jf={};let Df=1;function Rf(e){try{return e()}catch(e){}}const Pf="@wry/context:Slot",Bf=Rf(()=>globalThis)||Rf(()=>n.g)||Object.create(null),Ff=Bf[Pf]||Array[Pf]||function(e){try{Object.defineProperty(Bf,Pf,{value:e,enumerable:!1,writable:!1,configurable:!0})}finally{return e}}(class{constructor(){this.id=["slot",Df++,Date.now(),Math.random().toString(36).slice(2)].join(":")}hasValue(){for(let e=Nf;e;e=e.parent)if(this.id in e.slots){const t=e.slots[this.id];if(t===jf)break;return e!==Nf&&(Nf.slots[this.id]=t),!0}return Nf&&(Nf.slots[this.id]=jf),!1}getValue(){if(this.hasValue())return Nf.slots[this.id]}withValue(e,t,n,r){const i={__proto__:null,[this.id]:e},o=Nf;Nf={parent:o,slots:i};try{return t.apply(r,n)}finally{Nf=o}}static bind(e){const t=Nf;return function(){const n=Nf;try{return Nf=t,e.apply(this,arguments)}finally{Nf=n}}}static noContext(e,t,n){if(!Nf)return e.apply(n,t);{const r=Nf;try{return Nf=null,e.apply(n,t)}finally{Nf=r}}}}),{bind:Lf,noContext:Uf}=Ff;const $f=new Ff;const{hasOwnProperty:qf}=Object.prototype,Vf=Array.from||function(e){const t=[];return e.forEach(e=>t.push(e)),t};function zf(e){const{unsubscribe:t}=e;"function"==typeof t&&(e.unsubscribe=void 0,t())}const Kf=[];function Wf(e,t){if(!e)throw new Error(t||"assertion failure")}function Qf(e,t){const n=e.length;return n>0&&n===t.length&&e[n-1]===t[n-1]}function Gf(e){switch(e.length){case 0:throw new Error("unknown value");case 1:return e[0];case 2:throw e[1]}}function Hf(e){return e.slice(0)}class Jf{constructor(e){this.fn=e,this.parents=new Set,this.childValues=new Map,this.dirtyChildren=null,this.dirty=!0,this.recomputing=!1,this.value=[],this.deps=null,++Jf.count}peek(){if(1===this.value.length&&!Xf(this))return Zf(this),this.value[0]}recompute(e){return Wf(!this.recomputing,"already recomputing"),Zf(this),Xf(this)?function(e,t){sd(e),$f.withValue(e,Yf,[e,t]),function(e,t){if("function"==typeof e.subscribe)try{zf(e),e.unsubscribe=e.subscribe.apply(null,t)}catch(t){return e.setDirty(),!1}return!0}(e,t)&&function(e){if(e.dirty=!1,Xf(e))return;td(e)}(e);return Gf(e.value)}(this,e):Gf(this.value)}setDirty(){this.dirty||(this.dirty=!0,ed(this),zf(this))}dispose(){this.setDirty(),sd(this),nd(this,(e,t)=>{e.setDirty(),ad(e,this)})}forget(){this.dispose()}dependOn(e){e.add(this),this.deps||(this.deps=Kf.pop()||new Set),this.deps.add(e)}forgetDeps(){this.deps&&(Vf(this.deps).forEach(e=>e.delete(this)),this.deps.clear(),Kf.push(this.deps),this.deps=null)}}function Zf(e){const t=$f.getValue();if(t)return e.parents.add(t),t.childValues.has(e)||t.childValues.set(e,[]),Xf(e)?rd(t,e):id(t,e),t}function Yf(e,t){e.recomputing=!0;const{normalizeResult:n}=e;let r;n&&1===e.value.length&&(r=Hf(e.value)),e.value.length=0;try{if(e.value[0]=e.fn.apply(null,t),n&&r&&!Qf(r,e.value))try{e.value[0]=n(e.value[0],r[0])}catch(e){}}catch(t){e.value[1]=t}e.recomputing=!1}function Xf(e){return e.dirty||!(!e.dirtyChildren||!e.dirtyChildren.size)}function ed(e){nd(e,rd)}function td(e){nd(e,id)}function nd(e,t){const n=e.parents.size;if(n){const r=Vf(e.parents);for(let i=0;i<n;++i)t(r[i],e)}}function rd(e,t){Wf(e.childValues.has(t)),Wf(Xf(t));const n=!Xf(e);if(e.dirtyChildren){if(e.dirtyChildren.has(t))return}else e.dirtyChildren=Kf.pop()||new Set;e.dirtyChildren.add(t),n&&ed(e)}function id(e,t){Wf(e.childValues.has(t)),Wf(!Xf(t));const n=e.childValues.get(t);0===n.length?e.childValues.set(t,Hf(t.value)):Qf(n,t.value)||e.setDirty(),od(e,t),Xf(e)||td(e)}function od(e,t){const n=e.dirtyChildren;n&&(n.delete(t),0===n.size&&(Kf.length<100&&Kf.push(n),e.dirtyChildren=null))}function sd(e){e.childValues.size>0&&e.childValues.forEach((t,n)=>{ad(e,n)}),e.forgetDeps(),Wf(null===e.dirtyChildren)}function ad(e,t){t.parents.delete(e),e.childValues.delete(t),od(e,t)}Jf.count=0;const ud={setDirty:!0,dispose:!0,forget:!0};function cd(e){const t=new Map,n=e&&e.subscribe;function r(e){const r=$f.getValue();if(r){let i=t.get(e);i||t.set(e,i=new Set),r.dependOn(i),"function"==typeof n&&(zf(i),i.unsubscribe=n(e))}}return r.dirty=function(e,n){const r=t.get(e);if(r){const i=n&&qf.call(ud,n)?n:"setDirty";Vf(r).forEach(e=>e[i]()),t.delete(e),zf(r)}},r}let ld;function hd(...e){return(ld||(ld=new Af("function"==typeof WeakMap))).lookupArray(e)}const fd=new Set;function dd(e,{max:t=Math.pow(2,16),keyArgs:n,makeCacheKey:r=hd,normalizeResult:i,subscribe:o,cache:s=Uh}=Object.create(null)){const a="function"==typeof s?new s(t,e=>e.dispose()):s,u=function(){const t=r.apply(null,n?n.apply(null,arguments):arguments);if(void 0===t)return e.apply(null,arguments);let s=a.get(t);s||(a.set(t,s=new Jf(e)),s.normalizeResult=i,s.subscribe=o,s.forget=()=>a.delete(t));const u=s.recompute(Array.prototype.slice.call(arguments));return a.set(t,s),fd.add(a),$f.hasValue()||(fd.forEach(e=>e.clean()),fd.clear()),u};function c(e){const t=e&&a.get(e);t&&t.setDirty()}function l(e){const t=e&&a.get(e);if(t)return t.peek()}function h(e){return!!e&&a.delete(e)}return Object.defineProperty(u,"size",{get:()=>a.size,configurable:!1,enumerable:!1}),Object.freeze(u.options={max:t,keyArgs:n,makeCacheKey:r,normalizeResult:i,subscribe:o,cache:a}),u.dirtyKey=c,u.dirty=function(){c(r.apply(null,arguments))},u.peekKey=l,u.peek=function(){return l(r.apply(null,arguments))},u.forgetKey=h,u.forget=function(){return h(r.apply(null,arguments))},u.makeCacheKey=r,u.getKey=n?function(){return r.apply(null,n.apply(null,arguments))}:r,Object.freeze(u)}var pd=Symbol.for("apollo.deprecations"),yd=Fl,md=new Ff;function gd(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return md.withValue.apply(md,xl([Array.isArray(e)?e:[e]],t,!1))}function bd(e,t,n,r){void 0===r&&(r="Please remove this option."),vd(t,function(){t in e&&!1!==globalThis.__DEV__&&Vl.warn(104,n,t,r)})}function vd(e,t){(function(e){return yd[pd]||(md.getValue()||[]).includes(e)})(e)||t()}function wd(e,t){return t?t(e):mh.of()}function Ed(e){return"function"==typeof e?new Sd(e):e}function kd(e){return e.request.length<=1}var Sd=function(){function e(e){e&&(this.request=e)}return e.empty=function(){return new e(function(){return mh.of()})},e.from=function(t){return 0===t.length?e.empty():t.map(Ed).reduce(function(e,t){return e.concat(t)})},e.split=function(t,n,r){var i,o=Ed(n),s=Ed(r||new e(wd));return i=kd(o)&&kd(s)?new e(function(e){return t(e)?o.request(e)||mh.of():s.request(e)||mh.of()}):new e(function(e,n){return t(e)?o.request(e,n)||mh.of():s.request(e,n)||mh.of()}),Object.assign(i,{left:o,right:s})},e.execute=function(e,t){return e.request(function(e,t){var n=Sl({},e);return Object.defineProperty(t,"setContext",{enumerable:!1,value:function(e){n=Sl(Sl({},n),"function"==typeof e?e(n):e)}}),Object.defineProperty(t,"getContext",{enumerable:!1,value:function(){return Sl({},n)}}),t}(t.context,function(e){var t={variables:e.variables||{},extensions:e.extensions||{},operationName:e.operationName,query:e.query};return t.operationName||(t.operationName="string"!=typeof t.query?Ef(t.query)||void 0:""),t}(function(e){for(var t=["query","operationName","variables","extensions","context"],n=0,r=Object.keys(e);n<r.length;n++){var i=r[n];if(t.indexOf(i)<0)throw zl(58,i)}return e}(t))))||mh.of()},e.concat=function(t,n){var r=Ed(t);if(kd(r))return!1!==globalThis.__DEV__&&Vl.warn(47,r),r;var i,o=Ed(n);return i=kd(o)?new e(function(e){return r.request(e,function(e){return o.request(e)||mh.of()})||mh.of()}):new e(function(e,t){return r.request(e,function(e){return o.request(e,t)||mh.of()})||mh.of()}),Object.assign(i,{left:r,right:o})},e.prototype.split=function(t,n,r){return this.concat(e.split(t,n,r||new e(wd)))},e.prototype.concat=function(t){return e.concat(this,t)},e.prototype.request=function(e,t){throw zl(48)},e.prototype.onError=function(e,t){if(!1!==globalThis.__DEV__&&vd("onError",function(){!1!==globalThis.__DEV__&&Vl.warn(49)}),t&&t.error)return t.error(e),!1;throw e},e.prototype.setOnError=function(e){return!1!==globalThis.__DEV__&&!1!==globalThis.__DEV__&&Vl.warn(50),this.onError=e,this},e}(),Td=Object.freeze({NAME:"Name",DOCUMENT:"Document",OPERATION_DEFINITION:"OperationDefinition",VARIABLE_DEFINITION:"VariableDefinition",SELECTION_SET:"SelectionSet",FIELD:"Field",ARGUMENT:"Argument",FRAGMENT_SPREAD:"FragmentSpread",INLINE_FRAGMENT:"InlineFragment",FRAGMENT_DEFINITION:"FragmentDefinition",VARIABLE:"Variable",INT:"IntValue",FLOAT:"FloatValue",STRING:"StringValue",BOOLEAN:"BooleanValue",NULL:"NullValue",ENUM:"EnumValue",LIST:"ListValue",OBJECT:"ObjectValue",OBJECT_FIELD:"ObjectField",DIRECTIVE:"Directive",NAMED_TYPE:"NamedType",LIST_TYPE:"ListType",NON_NULL_TYPE:"NonNullType",SCHEMA_DEFINITION:"SchemaDefinition",OPERATION_TYPE_DEFINITION:"OperationTypeDefinition",SCALAR_TYPE_DEFINITION:"ScalarTypeDefinition",OBJECT_TYPE_DEFINITION:"ObjectTypeDefinition",FIELD_DEFINITION:"FieldDefinition",INPUT_VALUE_DEFINITION:"InputValueDefinition",INTERFACE_TYPE_DEFINITION:"InterfaceTypeDefinition",UNION_TYPE_DEFINITION:"UnionTypeDefinition",ENUM_TYPE_DEFINITION:"EnumTypeDefinition",ENUM_VALUE_DEFINITION:"EnumValueDefinition",INPUT_OBJECT_TYPE_DEFINITION:"InputObjectTypeDefinition",DIRECTIVE_DEFINITION:"DirectiveDefinition",SCHEMA_EXTENSION:"SchemaExtension",SCALAR_TYPE_EXTENSION:"ScalarTypeExtension",OBJECT_TYPE_EXTENSION:"ObjectTypeExtension",INTERFACE_TYPE_EXTENSION:"InterfaceTypeExtension",UNION_TYPE_EXTENSION:"UnionTypeExtension",ENUM_TYPE_EXTENSION:"EnumTypeExtension",INPUT_OBJECT_TYPE_EXTENSION:"InputObjectTypeExtension"});function _d(e,t){var n=e.directives;return!n||!n.length||function(e){var t=[];e&&e.length&&e.forEach(function(e){if(function(e){var t=e.name.value;return"skip"===t||"include"===t}(e)){var n=e.arguments,r=e.name.value;Vl(n&&1===n.length,107,r);var i=n[0];Vl(i.name&&"if"===i.name.value,108,r);var o=i.value;Vl(o&&("Variable"===o.kind||"BooleanValue"===o.kind),109,r),t.push({directive:e,ifArgument:i})}});return t}(n).every(function(e){var n=e.directive,r=e.ifArgument,i=!1;return"Variable"===r.value.kind?(i=t&&t[r.value.name.value],Vl(void 0!==i,106,n.name.value)):i=r.value.value,"skip"===n.name.value?!i:i})}function Od(e,t,n){var r=new Set(e),i=r.size;return Ih(t,{Directive:function(e){if(r.delete(e.name.value)&&(!n||!r.size))return xh}}),n?!r.size:r.size<i}function xd(e){return e&&Od(["client","export"],e,!0)}function Id(e){var t,n,r=null===(t=e.directives)||void 0===t?void 0:t.find(function(e){return"unmask"===e.name.value});if(!r)return"mask";var i=null===(n=r.arguments)||void 0===n?void 0:n.find(function(e){return"mode"===e.name.value});return!1!==globalThis.__DEV__&&i&&(i.value.kind===Td.VARIABLE?!1!==globalThis.__DEV__&&Vl.warn(110):i.value.kind!==Td.STRING?!1!==globalThis.__DEV__&&Vl.warn(111):"migrate"!==i.value.value&&!1!==globalThis.__DEV__&&Vl.warn(112,i.value.value)),i&&"value"in i.value&&"migrate"===i.value.value?"migrate":"unmask"}var Md=function(e,t){var n;try{n=JSON.stringify(e)}catch(e){var r=zl(54,t,e.message);throw r.parseError=e,r}return n},Cd="ReactNative"==Bl(function(){return navigator.product}),Ad="function"==typeof WeakMap&&!(Cd&&!n.g.HermesInternal),Nd="function"==typeof WeakSet,jd="function"==typeof Symbol&&"function"==typeof Symbol.for,Dd=jd&&Symbol.asyncIterator;Bl(function(){return window.document.createElement}),Bl(function(){return navigator.userAgent.indexOf("jsdom")>=0});function Rd(e){var t=null,n=null,r=!1,i=[],o=[];function s(e){if(!n){if(o.length){var t=o.shift();if(Array.isArray(t)&&t[0])return t[0]({value:e,done:!1})}i.push(e)}}function a(e){n=e,o.slice().forEach(function(t){t[1](e)}),!t||t()}function u(){r=!0,o.slice().forEach(function(e){e[0]({value:void 0,done:!0})}),!t||t()}t=function(){t=null,e.removeListener("data",s),e.removeListener("error",a),e.removeListener("end",u),e.removeListener("finish",u),e.removeListener("close",u)},e.on("data",s),e.on("error",a),e.on("end",u),e.on("finish",u),e.on("close",u);var c={next:function(){return new Promise(function(e,t){return n?t(n):i.length?e({value:i.shift(),done:!1}):r?e({value:void 0,done:!0}):void o.push([e,t])})}};return Dd&&(c[Symbol.asyncIterator]=function(){return this}),c}function Pd(e){var t={next:function(){return e.read()}};return Dd&&(t[Symbol.asyncIterator]=function(){return this}),t}function Bd(e){var t=e;if(function(e){return!!e.body}(e)&&(t=e.body),function(e){return!(!Dd||!e[Symbol.asyncIterator])}(t))return function(e){var t,n=e[Symbol.asyncIterator]();return(t={next:function(){return n.next()}})[Symbol.asyncIterator]=function(){return this},t}(t);if(function(e){return!!e.getReader}(t))return Pd(t.getReader());if(function(e){return!!e.stream}(t))return Pd(t.stream().getReader());if(function(e){return!!e.arrayBuffer}(t))return function(e){var t=!1,n={next:function(){return t?Promise.resolve({value:void 0,done:!0}):(t=!0,new Promise(function(t,n){e.then(function(e){t({value:e,done:!1})}).catch(n)}))}};return Dd&&(n[Symbol.asyncIterator]=function(){return this}),n}(t.arrayBuffer());if(function(e){return!!e.pipe}(t))return Rd(t);throw new Error("Unknown body type for responseIterator. Please pass a streamable response.")}var Fd=function(e,t,n){var r=new Error(n);throw r.name="ServerError",r.response=e,r.statusCode=e.status,r.result=t,r},Ld=Symbol();function Ud(e){return!!e.extensions&&Array.isArray(e.extensions[Ld])}function $d(e){return e.hasOwnProperty("graphQLErrors")}var qd=function(e){function t(n){var r,i,o=n.graphQLErrors,s=n.protocolErrors,a=n.clientErrors,u=n.networkError,c=n.errorMessage,l=n.extraInfo,h=e.call(this,c)||this;return h.name="ApolloError",h.graphQLErrors=o||[],h.protocolErrors=s||[],h.clientErrors=a||[],h.networkError=u||null,h.message=c||(i=xl(xl(xl([],(r=h).graphQLErrors,!0),r.clientErrors,!0),r.protocolErrors,!0),r.networkError&&i.push(r.networkError),i.map(function(e){return gh(e)&&e.message||"Error message not found."}).join("\n")),h.extraInfo=l,h.cause=xl(xl(xl([u],o||[],!0),s||[],!0),a||[],!0).find(function(e){return!!e})||null,h.__proto__=t.prototype,h}return kl(t,e),t}(Error),Vd=Array.isArray;function zd(e){return Array.isArray(e)&&e.length>0}var Kd=Object.prototype.hasOwnProperty;function Wd(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Qd(e)}function Qd(e){var t=e[0]||{},n=e.length;if(n>1)for(var r=new Hd,i=1;i<n;++i)t=r.merge(t,e[i]);return t}var Gd=function(e,t,n){return this.merge(e[n],t[n])},Hd=function(){function e(e){void 0===e&&(e=Gd),this.reconciler=e,this.isObject=gh,this.pastCopies=new Set}return e.prototype.merge=function(e,t){for(var n=this,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];return gh(t)&&gh(e)?(Object.keys(t).forEach(function(i){if(Kd.call(e,i)){var o=e[i];if(t[i]!==o){var s=n.reconciler.apply(n,xl([e,t,i],r,!1));s!==o&&((e=n.shallowCopyForMerge(e))[i]=s)}}else(e=n.shallowCopyForMerge(e))[i]=t[i]}),e):t},e.prototype.shallowCopyForMerge=function(e){return gh(e)&&(this.pastCopies.has(e)||(e=Array.isArray(e)?e.slice(0):Sl({__proto__:Object.getPrototypeOf(e)},e),this.pastCopies.add(e))),e},e}();function Jd(e){return"incremental"in e}function Zd(e){return gh(e)&&"payload"in e}function Yd(e,t){var n=e,r=new Hd;return Jd(t)&&zd(t.incremental)&&t.incremental.forEach(function(e){for(var t=e.data,i=e.path,o=i.length-1;o>=0;--o){var s=i[o],a=!isNaN(+s)?[]:{};a[s]=t,t=a}n=r.merge(n,t)}),n}var Xd=Object.prototype.hasOwnProperty;function ep(e){var t={};return e.split("\n").forEach(function(e){var n=e.indexOf(":");if(n>-1){var r=e.slice(0,n).trim().toLowerCase(),i=e.slice(n+1).trim();t[r]=i}}),t}function tp(e,t){if(e.status>=300){Fd(e,function(){try{return JSON.parse(t)}catch(e){return t}}(),"Response not successful: Received status code ".concat(e.status))}try{return JSON.parse(t)}catch(r){var n=r;throw n.name="ServerParseError",n.response=e,n.statusCode=e.status,n.bodyText=t,n}}function np(e){var t=e.split(/\r\n|[\n\r]/g),n=function(e){for(var t,n=!0,r=!0,i=0,o=null,s=0;s<e.length;++s)switch(e.charCodeAt(s)){case 13:10===e.charCodeAt(s+1)&&++s;case 10:n=!1,r=!0,i=0;break;case 9:case 32:++i;break;default:r&&!n&&(null===o||i<o)&&(o=i),r=!1}return null!==(t=o)&&void 0!==t?t:0}(e);if(0!==n)for(var r=1;r<t.length;r++)t[r]=t[r].slice(n);for(var i=0;i<t.length&&rp(t[i]);)++i;for(var o=t.length;o>i&&rp(t[o-1]);)--o;return t.slice(i,o).join("\n")}function rp(e){for(var t=0;t<e.length;++t)if(" "!==e[t]&&"\t"!==e[t])return!1;return!0}var ip,op={Name:function(e){return e.value},Variable:function(e){return"$"+e.name},Document:function(e){return ap(e.definitions,"\n\n")+"\n"},OperationDefinition:function(e){var t=e.operation,n=e.name,r=cp("(",ap(e.variableDefinitions,", "),")"),i=ap(e.directives," "),o=e.selectionSet;return n||i||r||"query"!==t?ap([t,ap([n,r]),i,o]," "):o},VariableDefinition:function(e){var t=e.variable,n=e.type,r=e.defaultValue,i=e.directives;return t+": "+n+cp(" = ",r)+cp(" ",ap(i," "))},SelectionSet:function(e){return up(e.selections)},Field:function(e){var t=e.alias,n=e.name,r=e.arguments,i=e.directives,o=e.selectionSet,s=cp("",t,": ")+n,a=s+cp("(",ap(r,", "),")");return a.length>80&&(a=s+cp("(\n",lp(ap(r,"\n")),"\n)")),ap([a,ap(i," "),o]," ")},Argument:function(e){return e.name+": "+e.value},FragmentSpread:function(e){return"..."+e.name+cp(" ",ap(e.directives," "))},InlineFragment:function(e){var t=e.typeCondition,n=e.directives,r=e.selectionSet;return ap(["...",cp("on ",t),ap(n," "),r]," ")},FragmentDefinition:function(e){var t=e.name,n=e.typeCondition,r=e.variableDefinitions,i=e.directives,o=e.selectionSet;return"fragment ".concat(t).concat(cp("(",ap(r,", "),")")," ")+"on ".concat(n," ").concat(cp("",ap(i," ")," "))+o},IntValue:function(e){return e.value},FloatValue:function(e){return e.value},StringValue:function(e,t){var n=e.value;return e.block?function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=-1===e.indexOf("\n"),i=" "===e[0]||"\t"===e[0],o='"'===e[e.length-1],s="\\"===e[e.length-1],a=!r||o||s||n,u="";return!a||r&&i||(u+="\n"+t),u+=t?e.replace(/\n/g,"\n"+t):e,a&&(u+="\n"),'"""'+u.replace(/"""/g,'\\"""')+'"""'}(n,"description"===t?"":" "):JSON.stringify(n)},BooleanValue:function(e){return e.value?"true":"false"},NullValue:function(){return"null"},EnumValue:function(e){return e.value},ListValue:function(e){return"["+ap(e.values,", ")+"]"},ObjectValue:function(e){return"{"+ap(e.fields,", ")+"}"},ObjectField:function(e){return e.name+": "+e.value},Directive:function(e){return"@"+e.name+cp("(",ap(e.arguments,", "),")")},NamedType:function(e){return e.name},ListType:function(e){return"["+e.type+"]"},NonNullType:function(e){return e.type+"!"},SchemaDefinition:sp(function(e){var t=e.directives,n=e.operationTypes;return ap(["schema",ap(t," "),up(n)]," ")}),OperationTypeDefinition:function(e){return e.operation+": "+e.type},ScalarTypeDefinition:sp(function(e){return ap(["scalar",e.name,ap(e.directives," ")]," ")}),ObjectTypeDefinition:sp(function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return ap(["type",t,cp("implements ",ap(n," & ")),ap(r," "),up(i)]," ")}),FieldDefinition:sp(function(e){var t=e.name,n=e.arguments,r=e.type,i=e.directives;return t+(fp(n)?cp("(\n",lp(ap(n,"\n")),"\n)"):cp("(",ap(n,", "),")"))+": "+r+cp(" ",ap(i," "))}),InputValueDefinition:sp(function(e){var t=e.name,n=e.type,r=e.defaultValue,i=e.directives;return ap([t+": "+n,cp("= ",r),ap(i," ")]," ")}),InterfaceTypeDefinition:sp(function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return ap(["interface",t,cp("implements ",ap(n," & ")),ap(r," "),up(i)]," ")}),UnionTypeDefinition:sp(function(e){var t=e.name,n=e.directives,r=e.types;return ap(["union",t,ap(n," "),r&&0!==r.length?"= "+ap(r," | "):""]," ")}),EnumTypeDefinition:sp(function(e){var t=e.name,n=e.directives,r=e.values;return ap(["enum",t,ap(n," "),up(r)]," ")}),EnumValueDefinition:sp(function(e){return ap([e.name,ap(e.directives," ")]," ")}),InputObjectTypeDefinition:sp(function(e){var t=e.name,n=e.directives,r=e.fields;return ap(["input",t,ap(n," "),up(r)]," ")}),DirectiveDefinition:sp(function(e){var t=e.name,n=e.arguments,r=e.repeatable,i=e.locations;return"directive @"+t+(fp(n)?cp("(\n",lp(ap(n,"\n")),"\n)"):cp("(",ap(n,", "),")"))+(r?" repeatable":"")+" on "+ap(i," | ")}),SchemaExtension:function(e){var t=e.directives,n=e.operationTypes;return ap(["extend schema",ap(t," "),up(n)]," ")},ScalarTypeExtension:function(e){return ap(["extend scalar",e.name,ap(e.directives," ")]," ")},ObjectTypeExtension:function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return ap(["extend type",t,cp("implements ",ap(n," & ")),ap(r," "),up(i)]," ")},InterfaceTypeExtension:function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return ap(["extend interface",t,cp("implements ",ap(n," & ")),ap(r," "),up(i)]," ")},UnionTypeExtension:function(e){var t=e.name,n=e.directives,r=e.types;return ap(["extend union",t,ap(n," "),r&&0!==r.length?"= "+ap(r," | "):""]," ")},EnumTypeExtension:function(e){var t=e.name,n=e.directives,r=e.values;return ap(["extend enum",t,ap(n," "),up(r)]," ")},InputObjectTypeExtension:function(e){var t=e.name,n=e.directives,r=e.fields;return ap(["extend input",t,ap(n," "),up(r)]," ")}};function sp(e){return function(t){return ap([t.description,e(t)],"\n")}}function ap(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return null!==(t=null==e?void 0:e.filter(function(e){return e}).join(n))&&void 0!==t?t:""}function up(e){return cp("{\n",lp(ap(e,"\n")),"\n}")}function cp(e,t){return null!=t&&""!==t?e+t+(arguments.length>2&&void 0!==arguments[2]?arguments[2]:""):""}function lp(e){return cp(" ",e.replace(/\n/g,"\n "))}function hp(e){return-1!==e.indexOf("\n")}function fp(e){return null!=e&&e.some(hp)}var dp=Object.assign(function(e){var t=ip.get(e);return t||(t=function(e){return Ih(e,{leave:op})}(e),ip.set(e,t)),t},{reset:function(){ip=new Vh(Wh.print||2e3)}});dp.reset(),!1!==globalThis.__DEV__&&Gh("print",function(){return ip?ip.size:0});var pp={http:{includeQuery:!0,includeExtensions:!1,preserveHeaderCase:!1},headers:{accept:"*/*","content-type":"application/json"},options:{method:"POST"}},yp=function(e,t){return t(e)};function mp(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i={},o={};n.forEach(function(e){i=Sl(Sl(Sl({},i),e.options),{headers:Sl(Sl({},i.headers),e.headers)}),e.credentials&&(i.credentials=e.credentials),o=Sl(Sl({},o),e.http)}),i.headers&&(i.headers=function(e,t){if(!t){var n={};return Object.keys(Object(e)).forEach(function(t){n[t.toLowerCase()]=e[t]}),n}var r={};Object.keys(Object(e)).forEach(function(t){r[t.toLowerCase()]={originalName:t,value:e[t]}});var i={};return Object.keys(r).forEach(function(e){i[r[e].originalName]=r[e].value}),i}(i.headers,o.preserveHeaderCase));var s=e.operationName,a=e.extensions,u=e.variables,c=e.query,l={operationName:s,variables:u};return o.includeExtensions&&(l.extensions=a),o.includeQuery&&(l.query=t(c,dp)),{options:i,body:l}}function gp(e){return new mh(function(t){t.error(e)})}var bp={kind:Td.FIELD,name:{kind:Td.NAME,value:"__typename"}};function vp(e,t){return!e||e.selectionSet.selections.every(function(e){return e.kind===Td.FRAGMENT_SPREAD&&vp(t[e.name.value],t)})}function wp(e){return vp(wf(e)||Tf(e),Ah(kf(e)))?null:e}function Ep(e){var t=new Map,n=new Map;return e.forEach(function(e){e&&(e.name?t.set(e.name,e):e.test&&n.set(e.test,e))}),function(e){var r=t.get(e.name.value);return!r&&n.size&&n.forEach(function(t,n){n(e)&&(r=t)}),r}}function kp(e){var t=new Map;return function(n){void 0===n&&(n=e);var r=t.get(n);return r||t.set(n,r={variables:new Set,fragmentSpreads:new Set}),r}}function Sp(e,t){vf(t);for(var n=kp(""),r=kp(""),i=function(e){for(var t=0,i=void 0;t<e.length&&(i=e[t]);++t)if(!Vd(i)){if(i.kind===Td.OPERATION_DEFINITION)return n(i.name&&i.name.value);if(i.kind===Td.FRAGMENT_DEFINITION)return r(i.name.value)}return!1!==globalThis.__DEV__&&Vl.error(125),null},o=0,s=t.definitions.length-1;s>=0;--s)t.definitions[s].kind===Td.OPERATION_DEFINITION&&++o;var a=Ep(e),u=function(e){return zd(e)&&e.map(a).some(function(e){return e&&e.remove})},c=new Map,l=!1,h={enter:function(e){if(u(e.directives))return l=!0,null}},f=Ih(t,{Field:h,InlineFragment:h,VariableDefinition:{enter:function(){return!1}},Variable:{enter:function(e,t,n,r,o){var s=i(o);s&&s.variables.add(e.name.value)}},FragmentSpread:{enter:function(e,t,n,r,o){if(u(e.directives))return l=!0,null;var s=i(o);s&&s.fragmentSpreads.add(e.name.value)}},FragmentDefinition:{enter:function(e,t,n,r){c.set(JSON.stringify(r),e)},leave:function(e,t,n,i){return e===c.get(JSON.stringify(i))?e:o>0&&e.selectionSet.selections.every(function(e){return e.kind===Td.FIELD&&"__typename"===e.name.value})?(r(e.name.value).removed=!0,l=!0,null):void 0}},Directive:{leave:function(e){if(a(e))return l=!0,null}}});if(!l)return t;var d=function(e){return e.transitiveVars||(e.transitiveVars=new Set(e.variables),e.removed||e.fragmentSpreads.forEach(function(t){d(r(t)).transitiveVars.forEach(function(t){e.transitiveVars.add(t)})})),e},p=new Set;f.definitions.forEach(function(e){e.kind===Td.OPERATION_DEFINITION?d(n(e.name&&e.name.value)).fragmentSpreads.forEach(function(e){p.add(e)}):e.kind!==Td.FRAGMENT_DEFINITION||0!==o||r(e.name.value).removed||p.add(e.name.value)}),p.forEach(function(e){d(r(e)).fragmentSpreads.forEach(function(e){p.add(e)})});var y={enter:function(e){if(t=e.name.value,!p.has(t)||r(t).removed)return null;var t}};return wp(Ih(f,{FragmentSpread:y,FragmentDefinition:y,OperationDefinition:{leave:function(e){if(e.variableDefinitions){var t=d(n(e.name&&e.name.value)).transitiveVars;if(t.size<e.variableDefinitions.length)return Sl(Sl({},e),{variableDefinitions:e.variableDefinitions.filter(function(e){return t.has(e.variable.name.value)})})}}}}))}var Tp=Object.assign(function(e){return Ih(e,{SelectionSet:{enter:function(e,t,n){if(!n||n.kind!==Td.OPERATION_DEFINITION){var r=e.selections;if(r)if(!r.some(function(e){return bf(e)&&("__typename"===e.name.value||0===e.name.value.lastIndexOf("__",0))})){var i=n;if(!(bf(i)&&i.directives&&i.directives.some(function(e){return"export"===e.name.value})))return Sl(Sl({},e),{selections:xl(xl([],r,!0),[bp],!1)})}}}}})},{added:function(e){return e===bp}});function _p(e){return"query"===_f(e).operation?e:Ih(e,{OperationDefinition:{enter:function(e){return Sl(Sl({},e),{operation:"query"})}}})}function Op(e){return vf(e),Sp([{test:function(e){return"client"===e.name.value},remove:!0}],e)}function xp(e){return vf(e),Ih(e,{FragmentSpread:function(e){var t;if(!(null===(t=e.directives)||void 0===t?void 0:t.some(function(e){return"unmask"===e.name.value})))return Sl(Sl({},e),{directives:xl(xl([],e.directives||[],!0),[{kind:Td.DIRECTIVE,name:{kind:Td.NAME,value:"nonreactive"}}],!1)})}})}var Ip=Bl(function(){return fetch}),Mp=function(e){void 0===e&&(e={});var t=e.uri,n=void 0===t?"/graphql":t,r=e.fetch,i=e.print,o=void 0===i?yp:i,s=e.includeExtensions,a=e.preserveHeaderCase,u=e.useGETForQueries,c=e.includeUnusedVariables,l=void 0!==c&&c,h=Tl(e,["uri","fetch","print","includeExtensions","preserveHeaderCase","useGETForQueries","includeUnusedVariables"]);!1!==globalThis.__DEV__&&function(e){if(!e&&"undefined"==typeof fetch)throw zl(51)}(r||Ip);var f={http:{includeExtensions:s,preserveHeaderCase:a},options:h.fetchOptions,credentials:h.credentials,headers:h.headers};return new Sd(function(e){var t=function(e,t){var n=e.getContext().uri;return n||("function"==typeof t?t(e):t||"/graphql")}(e,n),i=e.getContext(),s={};if(i.clientAwareness){var a=i.clientAwareness,c=a.name,h=a.version;c&&(s["apollographql-client-name"]=c),h&&(s["apollographql-client-version"]=h)}var d=Sl(Sl({},s),i.headers),p={http:i.http,options:i.fetchOptions,credentials:i.credentials,headers:d};if(Od(["client"],e.query)){!1!==globalThis.__DEV__&&!1!==globalThis.__DEV__&&Vl.warn(52);var y=Op(e.query);if(!y)return gp(new Error("HttpLink: Trying to send a client-only query to the server. To send to the server, ensure a non-client field is added to the query or set the `transformOptions.removeClientFields` option to `true`."));e.query=y}var m,g,b,v,w,E=mp(e,o,pp,f,p),k=E.options,S=E.body;S.variables&&!l&&(S.variables=(m=S.variables,g=e.query,b=Sl({},m),v=new Set(Object.keys(m)),Ih(g,{Variable:function(e,t,n){n&&"VariableDefinition"!==n.kind&&v.delete(e.name.value)}}),v.forEach(function(e){delete b[e]}),b)),k.signal||"undefined"==typeof AbortController||(w=new AbortController,k.signal=w.signal);var T,_="OperationDefinition"===(T=_f(e.query)).kind&&"subscription"===T.operation,O=Od(["defer"],e.query);if(u&&!e.query.definitions.some(function(e){return"OperationDefinition"===e.kind&&"mutation"===e.operation})&&(k.method="GET"),O||_){k.headers=k.headers||{};var x="multipart/mixed;";_&&O&&!1!==globalThis.__DEV__&&Vl.warn(53),_?x+="boundary=graphql;subscriptionSpec=1.0,application/json":O&&(x+="deferSpec=20220824,application/json"),k.headers.accept=x}if("GET"===k.method){var I=function(e,t){var n=[],r=function(e,t){n.push("".concat(e,"=").concat(encodeURIComponent(t)))};if("query"in t&&r("query",t.query),t.operationName&&r("operationName",t.operationName),t.variables){var i=void 0;try{i=Md(t.variables,"Variables map")}catch(e){return{parseError:e}}r("variables",i)}if(t.extensions){var o=void 0;try{o=Md(t.extensions,"Extensions map")}catch(e){return{parseError:e}}r("extensions",o)}var s="",a=e,u=e.indexOf("#");-1!==u&&(s=e.substr(u),a=e.substr(0,u));var c=-1===a.indexOf("?")?"?":"&";return{newURI:a+c+n.join("&")+s}}(t,S),M=I.newURI,C=I.parseError;if(C)return gp(C);t=M}else try{k.body=Md(S,"Payload")}catch(C){return gp(C)}return new mh(function(n){var i=r||Bl(function(){return fetch})||Ip,o=n.next.bind(n);return i(t,k).then(function(t){var n;e.setContext({response:t});var r,i=null===(n=t.headers)||void 0===n?void 0:n.get("content-type");return null!==i&&/^multipart\/mixed/i.test(i)?function(e,t){return _l(this,void 0,void 0,function(){var n,r,i,o,s,a,u,c,l,h,f,d,p,y,m,g,b,v,w,E,k,S,T,_;return Ol(this,function(O){switch(O.label){case 0:if(void 0===TextDecoder)throw new Error("TextDecoder must be defined in the environment: please import a polyfill.");n=new TextDecoder("utf-8"),r=null===(_=e.headers)||void 0===_?void 0:_.get("content-type"),i="boundary=",o=(null==r?void 0:r.includes(i))?null==r?void 0:r.substring((null==r?void 0:r.indexOf(i))+9).replace(/['"]/g,"").replace(/\;(.*)/gm,"").trim():"-",s="\r\n--".concat(o),a="",u=Bd(e),c=!0,O.label=1;case 1:return c?[4,u.next()]:[3,3];case 2:for(l=O.sent(),h=l.value,f=l.done,d="string"==typeof h?h:n.decode(h),p=a.length-s.length+1,c=!f,y=(a+=d).indexOf(s,p);y>-1;){if(m=void 0,S=[a.slice(0,y),a.slice(y+s.length)],a=S[1],g=(m=S[0]).indexOf("\r\n\r\n"),b=ep(m.slice(0,g)),(v=b["content-type"])&&-1===v.toLowerCase().indexOf("application/json"))throw new Error("Unsupported patch content type: application/json is required.");if(w=m.slice(g))if(E=tp(e,w),Object.keys(E).length>1||"data"in E||"incremental"in E||"errors"in E||"payload"in E)if(Zd(E)){if(k={},"payload"in E){if(1===Object.keys(E).length&&null===E.payload)return[2];k=Sl({},E.payload)}"errors"in E&&(k=Sl(Sl({},k),{extensions:Sl(Sl({},"extensions"in k?k.extensions:null),(T={},T[Ld]=E.errors,T))})),t(k)}else t(E);else if(1===Object.keys(E).length&&"hasNext"in E&&!E.hasNext)return[2];y=a.indexOf(s)}return[3,1];case 3:return[2]}})})}(t,o):(r=e,function(e){return e.text().then(function(t){return tp(e,t)}).then(function(t){return Array.isArray(t)||Xd.call(t,"data")||Xd.call(t,"errors")||Fd(e,t,"Server response was missing for query '".concat(Array.isArray(r)?r.map(function(e){return e.operationName}):r.operationName,"'.")),t})})(t).then(o)}).then(function(){w=void 0,n.complete()}).catch(function(e){w=void 0,function(e,t){e.result&&e.result.errors&&e.result.data&&t.next(e.result),t.error(e)}(e,n)}),function(){w&&w.abort()}})})},Cp=Sd.from,Ap=Sd.split,Np=Sd.execute,jp=function(e){function t(t){void 0===t&&(t={});var n=e.call(this,Mp(t).request)||this;return n.options=t,n}return kl(t,e),t}(Sd);const{toString:Dp,hasOwnProperty:Rp}=Object.prototype,Pp=Function.prototype.toString,Bp=new Map;function Fp(e,t){try{return Up(e,t)}finally{Bp.clear()}}const Lp=Fp;function Up(e,t){if(e===t)return!0;const n=Dp.call(e);if(n!==Dp.call(t))return!1;switch(n){case"[object Array]":if(e.length!==t.length)return!1;case"[object Object]":{if(zp(e,t))return!0;const n=$p(e),r=$p(t),i=n.length;if(i!==r.length)return!1;for(let e=0;e<i;++e)if(!Rp.call(t,n[e]))return!1;for(let r=0;r<i;++r){const i=n[r];if(!Up(e[i],t[i]))return!1}return!0}case"[object Error]":return e.name===t.name&&e.message===t.message;case"[object Number]":if(e!=e)return t!=t;case"[object Boolean]":case"[object Date]":return+e===+t;case"[object RegExp]":case"[object String]":return e==`${t}`;case"[object Map]":case"[object Set]":{if(e.size!==t.size)return!1;if(zp(e,t))return!0;const r=e.entries(),i="[object Map]"===n;for(;;){const e=r.next();if(e.done)break;const[n,o]=e.value;if(!t.has(n))return!1;if(i&&!Up(o,t.get(n)))return!1}return!0}case"[object Uint16Array]":case"[object Uint8Array]":case"[object Uint32Array]":case"[object Int32Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object ArrayBuffer]":e=new Uint8Array(e),t=new Uint8Array(t);case"[object DataView]":{let n=e.byteLength;if(n===t.byteLength)for(;n--&&e[n]===t[n];);return-1===n}case"[object AsyncFunction]":case"[object GeneratorFunction]":case"[object AsyncGeneratorFunction]":case"[object Function]":{const n=Pp.call(e);return n===Pp.call(t)&&!function(e,t){const n=e.length-t.length;return n>=0&&e.indexOf(t,n)===n}(n,Vp)}}return!1}function $p(e){return Object.keys(e).filter(qp,e)}function qp(e){return void 0!==this[e]}const Vp="{ [native code] }";function zp(e,t){let n=Bp.get(e);if(n){if(n.has(t))return!0}else Bp.set(e,n=new Set);return n.add(t),!1}function Kp(e){return e}var Wp=function(){function e(e,t){void 0===t&&(t=Object.create(null)),this.resultCache=Nd?new WeakSet:new Set,this.transform=e,t.getCacheKey&&(this.getCacheKey=t.getCacheKey),this.cached=!1!==t.cache,this.resetCache()}return e.prototype.getCacheKey=function(e){return[e]},e.identity=function(){return new e(Kp,{cache:!1})},e.split=function(t,n,r){return void 0===r&&(r=e.identity()),Object.assign(new e(function(e){return(t(e)?n:r).transformDocument(e)},{cache:!1}),{left:n,right:r})},e.prototype.resetCache=function(){var t=this;if(this.cached){var n=new Af(Ad);this.performWork=dd(e.prototype.performWork.bind(this),{makeCacheKey:function(e){var r=t.getCacheKey(e);if(r)return Vl(Array.isArray(r),105),n.lookupArray(r)},max:Wh["documentTransform.cache"],cache:Fh})}},e.prototype.performWork=function(e){return vf(e),this.transform(e)},e.prototype.transformDocument=function(e){if(this.resultCache.has(e))return e;var t=this.performWork(e);return this.resultCache.add(t),t},e.prototype.concat=function(t){var n=this;return Object.assign(new e(function(e){return t.transformDocument(n.transformDocument(e))},{cache:!1}),{left:this,right:t})},e}();function Qp(e,t,n){return new mh(function(r){var i={then:function(e){return new Promise(function(t){return t(e())})}};function o(e,t){return function(n){if(e){var o=function(){return r.closed?0:e(n)};i=i.then(o,o).then(function(e){return r.next(e)},function(e){return r.error(e)})}else r[t](n)}}var s={next:o(t,"next"),error:o(n,"error"),complete:function(){i.then(function(){return r.complete()})}},a=e.subscribe(s);return function(){return a.unsubscribe()}})}function Gp(e){return zd(Hp(e))}function Hp(e){var t=zd(e.errors)?e.errors.slice(0):[];return Jd(e)&&zd(e.incremental)&&e.incremental.forEach(function(e){e.errors&&t.push.apply(t,e.errors)}),t}function Jp(e,t,n){var r=[];e.forEach(function(e){return e[t]&&r.push(e)}),r.forEach(function(e){return e[t](n)})}function Zp(e){function t(t){Object.defineProperty(e,t,{value:mh})}return jd&&Symbol.species&&t(Symbol.species),t("@@species"),e}function Yp(e){return e&&"function"==typeof e.then}var Xp,ey=function(e){function t(t){var n=e.call(this,function(e){return n.addObserver(e),function(){return n.removeObserver(e)}})||this;return n.observers=new Set,n.promise=new Promise(function(e,t){n.resolve=e,n.reject=t}),n.handlers={next:function(e){null!==n.sub&&(n.latest=["next",e],n.notify("next",e),Jp(n.observers,"next",e))},error:function(e){var t=n.sub;null!==t&&(t&&setTimeout(function(){return t.unsubscribe()}),n.sub=null,n.latest=["error",e],n.reject(e),n.notify("error",e),Jp(n.observers,"error",e))},complete:function(){var e=n,t=e.sub,r=e.sources;if(null!==t){var i=(void 0===r?[]:r).shift();i?Yp(i)?i.then(function(e){return n.sub=e.subscribe(n.handlers)},n.handlers.error):n.sub=i.subscribe(n.handlers):(t&&setTimeout(function(){return t.unsubscribe()}),n.sub=null,n.latest&&"next"===n.latest[0]?n.resolve(n.latest[1]):n.resolve(),n.notify("complete"),Jp(n.observers,"complete"))}}},n.nextResultListeners=new Set,n.cancel=function(e){n.reject(e),n.sources=[],n.handlers.error(e)},n.promise.catch(function(e){}),"function"==typeof t&&(t=[new mh(t)]),Yp(t)?t.then(function(e){return n.start(e)},n.handlers.error):n.start(t),n}return kl(t,e),t.prototype.start=function(e){void 0===this.sub&&(this.sources=Array.from(e),this.handlers.complete())},t.prototype.deliverLastMessage=function(e){if(this.latest){var t=this.latest[0],n=e[t];n&&n.call(e,this.latest[1]),null===this.sub&&"next"===t&&e.complete&&e.complete()}},t.prototype.addObserver=function(e){this.observers.has(e)||(this.deliverLastMessage(e),this.observers.add(e))},t.prototype.removeObserver=function(e){this.observers.delete(e)&&this.observers.size<1&&this.handlers.complete()},t.prototype.notify=function(e,t){var n=this.nextResultListeners;n.size&&(this.nextResultListeners=new Set,n.forEach(function(n){return n(e,t)}))},t.prototype.beforeNext=function(e){var t=!1;this.nextResultListeners.add(function(n,r){t||(t=!0,e(n,r))})},t}(mh);function ty(e){return!!e&&e<7}function ny(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Object.create(null);return e.forEach(function(e){e&&Object.keys(e).forEach(function(t){var r=e[t];void 0!==r&&(n[t]=r)})}),n}Zp(ey),function(e){e[e.loading=1]="loading",e[e.setVariables=2]="setVariables",e[e.fetchMore=3]="fetchMore",e[e.refetch=4]="refetch",e[e.poll=6]="poll",e[e.ready=7]="ready",e[e.error=8]="error"}(Xp||(Xp={}));var ry=Object.prototype.toString;function iy(e){return oy(e)}function oy(e,t){switch(ry.call(e)){case"[object Array]":if((t=t||new Map).has(e))return t.get(e);var n=e.slice(0);return t.set(e,n),n.forEach(function(e,r){n[r]=oy(e,t)}),n;case"[object Object]":if((t=t||new Map).has(e))return t.get(e);var r=Object.create(Object.getPrototypeOf(e));return t.set(e,r),Object.keys(e).forEach(function(n){r[n]=oy(e[n],t)}),r;default:return e}}function sy(e,t,n,r){var i=t.data,o=Tl(t,["data"]),s=n.data,a=Tl(n,["data"]);return Lp(o,a)&&ay(_f(e).selectionSet,i,s,{fragmentMap:Ah(kf(e)),variables:r})}function ay(e,t,n,r){if(t===n)return!0;var i=new Set;return e.selections.every(function(e){if(i.has(e))return!0;if(i.add(e),!_d(e,r.variables))return!0;if(uy(e))return!0;if(bf(e)){var o=mf(e),s=t&&t[o],a=n&&n[o],u=e.selectionSet;if(!u)return Lp(s,a);var c=Array.isArray(s),l=Array.isArray(a);if(c!==l)return!1;if(c&&l){var h=s.length;if(a.length!==h)return!1;for(var f=0;f<h;++f)if(!ay(u,s[f],a[f],r))return!1;return!0}return ay(u,s,a,r)}var d=Nh(e,r.fragmentMap);return d?!!uy(d)||ay(d.selectionSet,t,n,r):void 0})}function uy(e){return!!e.directives&&e.directives.some(cy)}function cy(e){return"nonreactive"===e.name.value}var ly=Object.assign,hy=Object.hasOwnProperty,fy=function(e){function t(n){var r=n.queryManager,i=n.queryInfo,o=n.options,s=this,a=t.inactiveOnCreation.getValue();(s=e.call(this,function(e){s._getOrCreateQuery();try{var t=e._subscription._observer;t&&!t.error&&(t.error=dy)}catch(e){}var n=!s.observers.size;s.observers.add(e);var r=s.last;return r&&r.error?e.error&&e.error(r.error):r&&r.result&&e.next&&e.next(s.maskResult(r.result)),n&&s.reobserve().catch(function(){}),function(){s.observers.delete(e)&&!s.observers.size&&s.tearDownQuery()}})||this).observers=new Set,s.subscriptions=new Set,s.dirty=!1,s._getOrCreateQuery=function(){return a&&(r.queries.set(s.queryId,i),a=!1),s.queryManager.getOrCreateQuery(s.queryId)},s.queryInfo=i,s.queryManager=r,s.waitForOwnResult=yy(o.fetchPolicy),s.isTornDown=!1,s.subscribeToMore=s.subscribeToMore.bind(s),s.maskResult=s.maskResult.bind(s);var u=r.defaultOptions.watchQuery,c=(void 0===u?{}:u).fetchPolicy,l=void 0===c?"cache-first":c,h=o.fetchPolicy,f=void 0===h?l:h,d=o.initialFetchPolicy,p=void 0===d?"standby"===f?l:f:d;s.options=Sl(Sl({},o),{initialFetchPolicy:p,fetchPolicy:f}),s.queryId=i.queryId||r.generateQueryId();var y=wf(s.query);return s.queryName=y&&y.name&&y.name.value,s}return kl(t,e),Object.defineProperty(t.prototype,"query",{get:function(){return this.lastQuery||this.options.query},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"variables",{get:function(){return this.options.variables},enumerable:!1,configurable:!0}),t.prototype.result=function(){var e=this;return!1!==globalThis.__DEV__&&vd("observableQuery.result",function(){!1!==globalThis.__DEV__&&Vl.warn(23)}),new Promise(function(t,n){var r={next:function(n){t(n),e.observers.delete(r),e.observers.size||e.queryManager.removeQuery(e.queryId),setTimeout(function(){i.unsubscribe()},0)},error:n},i=e.subscribe(r)})},t.prototype.resetDiff=function(){this.queryInfo.resetDiff()},t.prototype.getCurrentFullResult=function(e){var t=this;void 0===e&&(e=!0);var n=gd("getLastResult",function(){return t.getLastResult(!0)}),r=this.queryInfo.networkStatus||n&&n.networkStatus||Xp.ready,i=Sl(Sl({},n),{loading:ty(r),networkStatus:r}),o=this.options.fetchPolicy,s=void 0===o?"cache-first":o;if(yy(s)||this.queryManager.getDocumentInfo(this.query).hasForcedResolvers);else if(this.waitForOwnResult)this.queryInfo.updateWatch();else{var a=this.queryInfo.getDiff();(a.complete||this.options.returnPartialData)&&(i.data=a.result),Fp(i.data,{})&&(i.data=void 0),a.complete?(delete i.partial,!a.complete||i.networkStatus!==Xp.loading||"cache-first"!==s&&"cache-only"!==s||(i.networkStatus=Xp.ready,i.loading=!1)):i.partial=!0,i.networkStatus===Xp.ready&&(i.error||i.errors)&&(i.networkStatus=Xp.error),!1===globalThis.__DEV__||a.complete||this.options.partialRefetch||i.loading||i.data||i.error||py(a.missing)}return e&&this.updateLastResult(i),i},t.prototype.getCurrentResult=function(e){return void 0===e&&(e=!0),this.maskResult(this.getCurrentFullResult(e))},t.prototype.isDifferentFromLastResult=function(e,t){if(!this.last)return!0;var n=this.queryManager.getDocumentInfo(this.query),r=this.queryManager.dataMasking,i=r?n.nonReactiveQuery:this.query;return(r||n.hasNonreactiveDirective?!sy(i,this.last.result,e,this.variables):!Fp(this.last.result,e))||t&&!Fp(this.last.variables,t)},t.prototype.getLast=function(e,t){var n=this.last;if(n&&n[e]&&(!t||Fp(n.variables,this.variables)))return n[e]},t.prototype.getLastResult=function(e){return!1!==globalThis.__DEV__&&vd("getLastResult",function(){!1!==globalThis.__DEV__&&Vl.warn(24)}),this.getLast("result",e)},t.prototype.getLastError=function(e){return!1!==globalThis.__DEV__&&vd("getLastError",function(){!1!==globalThis.__DEV__&&Vl.warn(25)}),this.getLast("error",e)},t.prototype.resetLastResults=function(){!1!==globalThis.__DEV__&&vd("resetLastResults",function(){!1!==globalThis.__DEV__&&Vl.warn(26)}),delete this.last,this.isTornDown=!1},t.prototype.resetQueryStoreErrors=function(){!1!==globalThis.__DEV__&&!1!==globalThis.__DEV__&&Vl.warn(27),this.queryManager.resetErrors(this.queryId)},t.prototype.refetch=function(e){var t,n={pollInterval:0},r=this.options.fetchPolicy;if(n.fetchPolicy="no-cache"===r?"no-cache":"network-only",!1!==globalThis.__DEV__&&e&&hy.call(e,"variables")){var i=Sf(this.query),o=i.variableDefinitions;o&&o.some(function(e){return"variables"===e.variable.name.value})||!1!==globalThis.__DEV__&&Vl.warn(28,e,(null===(t=i.name)||void 0===t?void 0:t.value)||i)}return e&&!Fp(this.options.variables,e)&&(n.variables=this.options.variables=Sl(Sl({},this.options.variables),e)),this.queryInfo.resetLastWrite(),this.reobserve(n,Xp.refetch)},t.prototype.fetchMore=function(e){var t=this,n=Sl(Sl({},e.query?e:Sl(Sl(Sl(Sl({},this.options),{query:this.options.query}),e),{variables:Sl(Sl({},this.options.variables),e.variables)})),{fetchPolicy:"no-cache"});n.query=this.transformDocument(n.query);var r=this.queryManager.generateQueryId();this.lastQuery=e.query?this.transformDocument(this.options.query):n.query;var i=this.queryInfo,o=i.networkStatus;i.networkStatus=Xp.fetchMore,n.notifyOnNetworkStatusChange&&this.observe();var s=new Set,a=null==e?void 0:e.updateQuery,u="no-cache"!==this.options.fetchPolicy;return u||Vl(a,29),this.queryManager.fetchQuery(r,n,Xp.fetchMore).then(function(c){if(t.queryManager.removeQuery(r),i.networkStatus===Xp.fetchMore&&(i.networkStatus=o),u)t.queryManager.cache.batch({update:function(r){var i=e.updateQuery;i?r.updateQuery({query:t.query,variables:t.variables,returnPartialData:!0,optimistic:!1},function(e){return i(e,{fetchMoreResult:c.data,variables:n.variables})}):r.writeQuery({query:n.query,variables:n.variables,data:c.data})},onWatchUpdated:function(e){s.add(e.query)}});else{var l=t.getLast("result"),h=a(l.data,{fetchMoreResult:c.data,variables:n.variables});t.reportResult(Sl(Sl({},l),{networkStatus:o,loading:ty(o),data:h}),t.variables)}return t.maskResult(c)}).finally(function(){u&&!s.has(t.query)&&t.reobserveCacheFirst()})},t.prototype.subscribeToMore=function(e){var t=this,n=this.queryManager.startGraphQLSubscription({query:e.document,variables:e.variables,context:e.context}).subscribe({next:function(n){var r=e.updateQuery;r&&t.updateQuery(function(e,t){return r(e,Sl({subscriptionData:n},t))})},error:function(t){e.onError?e.onError(t):!1!==globalThis.__DEV__&&Vl.error(30,t)}});return this.subscriptions.add(n),function(){t.subscriptions.delete(n)&&n.unsubscribe()}},t.prototype.setOptions=function(e){return!1!==globalThis.__DEV__&&(bd(e,"canonizeResults","setOptions"),vd("setOptions",function(){!1!==globalThis.__DEV__&&Vl.warn(31)})),this.reobserve(e)},t.prototype.silentSetOptions=function(e){var t=ny(this.options,e||{});ly(this.options,t)},t.prototype.setVariables=function(e){var t=this;return Fp(this.variables,e)?this.observers.size?gd("observableQuery.result",function(){return t.result()}):Promise.resolve():(this.options.variables=e,this.observers.size?this.reobserve({fetchPolicy:this.options.initialFetchPolicy,variables:e},Xp.setVariables):Promise.resolve())},t.prototype.updateQuery=function(e){var t=this.queryManager,n=t.cache.diff({query:this.options.query,variables:this.variables,returnPartialData:!0,optimistic:!1}),r=n.result,i=n.complete,o=e(r,{variables:this.variables,complete:!!i,previousData:r});o&&(t.cache.writeQuery({query:this.options.query,data:o,variables:this.variables}),t.broadcastQueries())},t.prototype.startPolling=function(e){this.options.pollInterval=e,this.updatePolling()},t.prototype.stopPolling=function(){this.options.pollInterval=0,this.updatePolling()},t.prototype.applyNextFetchPolicy=function(e,t){if(t.nextFetchPolicy){var n=t.fetchPolicy,r=void 0===n?"cache-first":n,i=t.initialFetchPolicy,o=void 0===i?r:i;"standby"===r||("function"==typeof t.nextFetchPolicy?t.fetchPolicy=t.nextFetchPolicy(r,{reason:e,options:t,observable:this,initialFetchPolicy:o}):t.fetchPolicy="variables-changed"===e?o:t.nextFetchPolicy)}return t.fetchPolicy},t.prototype.fetch=function(e,t,n){var r=this._getOrCreateQuery();return r.setObservableQuery(this),this.queryManager.fetchConcastWithInfo(r,e,t,n)},t.prototype.updatePolling=function(){var e=this;if(!this.queryManager.ssrMode){var t=this.pollingInfo,n=this.options.pollInterval;if(n&&this.hasObservers()){if(!t||t.interval!==n){Vl(n,32),(t||(this.pollingInfo={})).interval=n;var r=function(){var t,n;e.pollingInfo&&(ty(e.queryInfo.networkStatus)||(null===(n=(t=e.options).skipPollAttempt)||void 0===n?void 0:n.call(t))?i():e.reobserve({fetchPolicy:"no-cache"===e.options.initialFetchPolicy?"no-cache":"network-only"},Xp.poll).then(i,i))},i=function(){var t=e.pollingInfo;t&&(clearTimeout(t.timeout),t.timeout=setTimeout(r,t.interval))};i()}}else t&&(clearTimeout(t.timeout),delete this.pollingInfo)}},t.prototype.updateLastResult=function(e,t){var n=this;void 0===t&&(t=this.variables);var r=gd("getLastError",function(){return n.getLastError()});return r&&this.last&&!Fp(t,this.last.variables)&&(r=void 0),this.last=Sl({result:this.queryManager.assumeImmutableResults?e:iy(e),variables:t},r?{error:r}:null)},t.prototype.reobserveAsConcast=function(e,t){var n=this;this.isTornDown=!1;var r=t===Xp.refetch||t===Xp.fetchMore||t===Xp.poll,i=this.options.variables,o=this.options.fetchPolicy,s=ny(this.options,e||{}),a=r?s:ly(this.options,s),u=this.transformDocument(a.query);this.lastQuery=u,r||(this.updatePolling(),!e||!e.variables||Fp(e.variables,i)||"standby"===a.fetchPolicy||a.fetchPolicy!==o&&"function"!=typeof a.nextFetchPolicy||(this.applyNextFetchPolicy("variables-changed",a),void 0===t&&(t=Xp.setVariables))),this.waitForOwnResult&&(this.waitForOwnResult=yy(a.fetchPolicy));var c=function(){n.concast===f&&(n.waitForOwnResult=!1)},l=a.variables&&Sl({},a.variables),h=this.fetch(a,t,u),f=h.concast,d=h.fromLink,p={next:function(e){Fp(n.variables,l)&&(c(),n.reportResult(e,l))},error:function(e){Fp(n.variables,l)&&($d(e)||(e=new qd({networkError:e})),c(),n.reportError(e,l))}};return r||!d&&this.concast||(this.concast&&this.observer&&this.concast.removeObserver(this.observer),this.concast=f,this.observer=p),f.addObserver(p),f},t.prototype.reobserve=function(e,t){return function(e){return e.catch(function(){}),e}(this.reobserveAsConcast(e,t).promise.then(this.maskResult))},t.prototype.resubscribeAfterError=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=this.last;gd("resetLastResults",function(){return e.resetLastResults()});var i=this.subscribe.apply(this,t);return this.last=r,i},t.prototype.observe=function(){this.reportResult(this.getCurrentFullResult(!1),this.variables)},t.prototype.reportResult=function(e,t){var n=this,r=gd("getLastError",function(){return n.getLastError()}),i=this.isDifferentFromLastResult(e,t);(r||!e.partial||this.options.returnPartialData)&&this.updateLastResult(e,t),(r||i)&&Jp(this.observers,"next",this.maskResult(e))},t.prototype.reportError=function(e,t){var n=this,r=Sl(Sl({},gd("getLastResult",function(){return n.getLastResult()})),{error:e,errors:e.graphQLErrors,networkStatus:Xp.error,loading:!1});this.updateLastResult(r,t),Jp(this.observers,"error",this.last.error=e)},t.prototype.hasObservers=function(){return this.observers.size>0},t.prototype.tearDownQuery=function(){this.isTornDown||(this.concast&&this.observer&&(this.concast.removeObserver(this.observer),delete this.concast,delete this.observer),this.stopPolling(),this.subscriptions.forEach(function(e){return e.unsubscribe()}),this.subscriptions.clear(),this.queryManager.stopQuery(this.queryId),this.observers.clear(),this.isTornDown=!0)},t.prototype.transformDocument=function(e){return this.queryManager.transform(e)},t.prototype.maskResult=function(e){return e&&"data"in e?Sl(Sl({},e),{data:this.queryManager.maskOperation({document:this.query,data:e.data,fetchPolicy:this.options.fetchPolicy,id:this.queryId})}):e},t.prototype.resetNotifications=function(){this.cancelNotifyTimeout(),this.dirty=!1},t.prototype.cancelNotifyTimeout=function(){this.notifyTimeout&&(clearTimeout(this.notifyTimeout),this.notifyTimeout=void 0)},t.prototype.scheduleNotify=function(){var e=this;this.dirty||(this.dirty=!0,this.notifyTimeout||(this.notifyTimeout=setTimeout(function(){return e.notify()},0)))},t.prototype.notify=function(){(this.cancelNotifyTimeout(),this.dirty)&&("cache-only"!=this.options.fetchPolicy&&"cache-and-network"!=this.options.fetchPolicy&&ty(this.queryInfo.networkStatus)||(this.queryInfo.getDiff().fromOptimisticTransaction?this.observe():this.reobserveCacheFirst()));this.dirty=!1},t.prototype.reobserveCacheFirst=function(){var e=this.options,t=e.fetchPolicy,n=e.nextFetchPolicy;return"cache-and-network"===t||"network-only"===t?this.reobserve({fetchPolicy:"cache-first",nextFetchPolicy:function(e,r){return this.nextFetchPolicy=n,"function"==typeof this.nextFetchPolicy?this.nextFetchPolicy(e,r):t}}):this.reobserve()},t.inactiveOnCreation=new Ff,t}(mh);function dy(e){!1!==globalThis.__DEV__&&Vl.error(33,e.message,e.stack)}function py(e){!1!==globalThis.__DEV__&&e&&!1!==globalThis.__DEV__&&Vl.debug(34,e)}function yy(e){return"network-only"===e||"no-cache"===e||"standby"===e}Zp(fy);var my=new(Ad?WeakMap:Map);function gy(e,t){var n=e[t];"function"==typeof n&&(e[t]=function(){return my.set(e,(my.get(e)+1)%1e15),n.apply(this,arguments)})}var by=function(){function e(e,t){void 0===t&&(t=e.generateQueryId()),this.queryId=t,this.document=null,this.lastRequestId=1,this.stopped=!1,this.observableQuery=null;var n=this.cache=e.cache;my.has(n)||(my.set(n,0),gy(n,"evict"),gy(n,"modify"),gy(n,"reset"))}return e.prototype.init=function(e){var t=e.networkStatus||Xp.loading;return this.variables&&this.networkStatus!==Xp.loading&&!Fp(this.variables,e.variables)&&(t=Xp.setVariables),Fp(e.variables,this.variables)||(this.lastDiff=void 0,this.cancel()),Object.assign(this,{document:e.document,variables:e.variables,networkError:null,graphQLErrors:this.graphQLErrors||[],networkStatus:t}),e.observableQuery&&this.setObservableQuery(e.observableQuery),e.lastRequestId&&(this.lastRequestId=e.lastRequestId),this},e.prototype.resetDiff=function(){this.lastDiff=void 0},e.prototype.getDiff=function(){var e=this,t=this.getDiffOptions();if(this.lastDiff&&Fp(t,this.lastDiff.options))return this.lastDiff.diff;this.updateWatch(this.variables);var n=this.observableQuery;if(n&&"no-cache"===n.options.fetchPolicy)return{complete:!1};var r=gd("canonizeResults",function(){return e.cache.diff(t)});return this.updateLastDiff(r,t),r},e.prototype.updateLastDiff=function(e,t){this.lastDiff=e?{diff:e,options:t||this.getDiffOptions()}:void 0},e.prototype.getDiffOptions=function(e){var t;return void 0===e&&(e=this.variables),{query:this.document,variables:e,returnPartialData:!0,optimistic:!0,canonizeResults:null===(t=this.observableQuery)||void 0===t?void 0:t.options.canonizeResults}},e.prototype.setDiff=function(e){var t,n=this,r=this.lastDiff&&this.lastDiff.diff;e&&!e.complete&&gd("getLastError",function(){var e;return null===(e=n.observableQuery)||void 0===e?void 0:e.getLastError()})||(this.updateLastDiff(e),Fp(r&&r.result,e&&e.result)||null===(t=this.observableQuery)||void 0===t||t.scheduleNotify())},e.prototype.setObservableQuery=function(e){e!==this.observableQuery&&(this.observableQuery=e,e&&(e.queryInfo=this))},e.prototype.stop=function(){var e;if(!this.stopped){this.stopped=!0,null===(e=this.observableQuery)||void 0===e||e.resetNotifications(),this.cancel();var t=this.observableQuery;t&&t.stopPolling()}},e.prototype.cancel=function(){var e;null===(e=this.cancelWatch)||void 0===e||e.call(this),this.cancelWatch=void 0},e.prototype.updateWatch=function(e){var t=this;void 0===e&&(e=this.variables);var n=this.observableQuery;if(!n||"no-cache"!==n.options.fetchPolicy){var r=Sl(Sl({},this.getDiffOptions(e)),{watcher:this,callback:function(e){return t.setDiff(e)}});this.lastWatch&&Fp(r,this.lastWatch)||(this.cancel(),this.cancelWatch=this.cache.watch(this.lastWatch=r))}},e.prototype.resetLastWrite=function(){this.lastWrite=void 0},e.prototype.shouldWrite=function(e,t){var n=this.lastWrite;return!(n&&n.dmCount===my.get(this.cache)&&Fp(t,n.variables)&&Fp(e.data,n.result.data))},e.prototype.markResult=function(e,t,n,r){var i,o=this,s=new Hd,a=zd(e.errors)?e.errors.slice(0):[];if(null===(i=this.observableQuery)||void 0===i||i.resetNotifications(),"incremental"in e&&zd(e.incremental)){var u=Yd(this.getDiff().result,e);e.data=u}else if("hasNext"in e&&e.hasNext){var c=this.getDiff();e.data=s.merge(c.result,e.data)}this.graphQLErrors=a,"no-cache"===n.fetchPolicy?this.updateLastDiff({result:e.data,complete:!0},this.getDiffOptions(n.variables)):0!==r&&(vy(e,n.errorPolicy)?this.cache.performTransaction(function(i){if(o.shouldWrite(e,n.variables))i.writeQuery({query:t,data:e.data,variables:n.variables,overwrite:1===r}),o.lastWrite={result:e,variables:n.variables,dmCount:my.get(o.cache)};else if(o.lastDiff&&o.lastDiff.diff.complete)return void(e.data=o.lastDiff.diff.result);var s=o.getDiffOptions(n.variables),a=gd("canonizeResults",function(){return i.diff(s)});!o.stopped&&Fp(o.variables,n.variables)&&o.updateWatch(n.variables),o.updateLastDiff(a,s),a.complete&&(e.data=a.result)}):this.lastWrite=void 0)},e.prototype.markReady=function(){return this.networkError=null,this.networkStatus=Xp.ready},e.prototype.markError=function(e){var t;return this.networkStatus=Xp.error,this.lastWrite=void 0,null===(t=this.observableQuery)||void 0===t||t.resetNotifications(),e.graphQLErrors&&(this.graphQLErrors=e.graphQLErrors),e.networkError&&(this.networkError=e.networkError),e},e}();function vy(e,t){void 0===t&&(t="none");var n="ignore"===t||"all"===t,r=!Gp(e);return!r&&n&&e.data&&(r=!0),r}function wy(e){var t=new Set([e]);return t.forEach(function(e){gh(e)&&function(e){if(!1!==globalThis.__DEV__&&!Object.isFrozen(e))try{Object.freeze(e)}catch(e){if(e instanceof TypeError)return null;throw e}return e}(e)===e&&Object.getOwnPropertyNames(e).forEach(function(n){gh(e[n])&&t.add(e[n])})}),e}function Ey(e){return!1!==globalThis.__DEV__&&wy(e),e}var ky=Ad?WeakMap:Map,Sy=Nd?WeakSet:Set,Ty=new Ff,_y=!1;function Oy(){_y||(_y=!0,!1!==globalThis.__DEV__&&Vl.warn(64))}function xy(e,t,n){return Ty.withValue(!0,function(){var r=Iy(e,t,n,!1);return Object.isFrozen(e)&&Ey(r),r})}function Iy(e,t,n,r,i){var o,s=n.knownChanged,a=function(e,t){if(t.has(e))return t.get(e);var n=Array.isArray(e)?[]:Object.create(null);return t.set(e,n),n}(e,n.mutableTargets);if(Array.isArray(e)){for(var u=0,c=Array.from(e.entries());u<c.length;u++){var l=c[u],h=l[0],f=l[1];if(null!==f){var d=Iy(f,t,n,r,!1!==globalThis.__DEV__?"".concat(i||"","[").concat(h,"]"):void 0);s.has(d)&&s.add(a),a[h]=d}else a[h]=null}return s.has(a)?a:e}for(var p=0,y=t.selections;p<y.length;p++){var m=y[p],g=void 0;if(r&&s.add(a),m.kind===Td.FIELD){var b=mf(m),v=m.selectionSet;if(void 0===(g=a[b]||e[b]))continue;if(v&&null!==g){d=Iy(e[b],v,n,r,!1!==globalThis.__DEV__?"".concat(i||"",".").concat(b):void 0);s.has(d)&&(g=d)}!1===globalThis.__DEV__&&(a[b]=g),!1!==globalThis.__DEV__&&(r&&"__typename"!==b&&!(null===(o=Object.getOwnPropertyDescriptor(a,b))||void 0===o?void 0:o.value)?Object.defineProperty(a,b,My(b,g,i||"",n.operationName,n.operationType)):(delete a[b],a[b]=g))}if(m.kind!==Td.INLINE_FRAGMENT||m.typeCondition&&!n.cache.fragmentMatches(m,e.__typename)||(g=Iy(e,m.selectionSet,n,r,i)),m.kind===Td.FRAGMENT_SPREAD){var w=m.name.value,E=n.fragmentMap[w]||(n.fragmentMap[w]=n.cache.lookupFragment(w));Vl(E,59,w);var k=Id(m);"mask"!==k&&(g=Iy(e,E.selectionSet,n,"migrate"===k,i))}s.has(g)&&s.add(a)}return"__typename"in e&&!("__typename"in a)&&(a.__typename=e.__typename),Object.keys(a).length!==Object.keys(e).length&&s.add(a),s.has(a)?a:e}function My(e,t,n,r,i){var o=function(){return Ty.getValue()||(!1!==globalThis.__DEV__&&Vl.warn(60,r?"".concat(i," '").concat(r,"'"):"anonymous ".concat(i),"".concat(n,".").concat(e).replace(/^\./,"")),o=function(){return t}),t};return{get:function(){return o()},set:function(e){o=function(){return e}},enumerable:!0,configurable:!0}}function Cy(e,t,n,r){if(!n.fragmentMatches)return!1!==globalThis.__DEV__&&Oy(),e;var i=t.definitions.filter(function(e){return e.kind===Td.FRAGMENT_DEFINITION});void 0===r&&(Vl(1===i.length,61,i.length),r=i[0].name.value);var o=i.find(function(e){return e.name.value===r});return Vl(!!o,62,r),null==e||Lp(e,{})?e:xy(e,o.selectionSet,{operationType:"fragment",operationName:o.name.value,fragmentMap:Ah(kf(t)),cache:n,mutableTargets:new ky,knownChanged:new Sy})}var Ay=Object.prototype.hasOwnProperty,Ny=Object.create(null),jy=function(){function e(e){var t=this;this.clientAwareness={},this.queries=new Map,this.fetchCancelFns=new Map,this.transformCache=new Vh(Wh["queryManager.getDocumentInfo"]||2e3),this.queryIdCounter=1,this.requestIdCounter=1,this.mutationIdCounter=1,this.inFlightLinkObservables=new Af(!1),this.noCacheWarningsByQueryId=new Set;var n=new Wp(function(e){return t.cache.transformDocument(e)},{cache:!1});this.cache=e.cache,this.link=e.link,this.defaultOptions=e.defaultOptions,this.queryDeduplication=e.queryDeduplication,this.clientAwareness=e.clientAwareness,this.localState=e.localState,this.ssrMode=e.ssrMode,this.assumeImmutableResults=e.assumeImmutableResults,this.dataMasking=e.dataMasking;var r=e.documentTransform;this.documentTransform=r?n.concat(r).concat(n):n,this.defaultContext=e.defaultContext||Object.create(null),(this.onBroadcast=e.onBroadcast)&&(this.mutationStore=Object.create(null))}return e.prototype.stop=function(){var e=this;this.queries.forEach(function(t,n){e.stopQueryNoBroadcast(n)}),this.cancelPendingFetches(zl(35))},e.prototype.cancelPendingFetches=function(e){this.fetchCancelFns.forEach(function(t){return t(e)}),this.fetchCancelFns.clear()},e.prototype.mutate=function(e){return _l(this,arguments,void 0,function(e){var t,n,r,i,o,s,a,u=e.mutation,c=e.variables,l=e.optimisticResponse,h=e.updateQueries,f=e.refetchQueries,d=void 0===f?[]:f,p=e.awaitRefetchQueries,y=void 0!==p&&p,m=e.update,g=e.onQueryUpdated,b=e.fetchPolicy,v=void 0===b?(null===(s=this.defaultOptions.mutate)||void 0===s?void 0:s.fetchPolicy)||"network-only":b,w=e.errorPolicy,E=void 0===w?(null===(a=this.defaultOptions.mutate)||void 0===a?void 0:a.errorPolicy)||"none":w,k=e.keepRootFields,S=e.context;return Ol(this,function(e){switch(e.label){case 0:return Vl(u,36),Vl("network-only"===v||"no-cache"===v,37),t=this.generateMutationId(),u=this.cache.transformForLink(this.transform(u)),n=this.getDocumentInfo(u).hasClientExports,c=this.getVariables(u,c),n?[4,this.localState.addExportedVariables(u,c,S)]:[3,2];case 1:c=e.sent(),e.label=2;case 2:return r=this.mutationStore&&(this.mutationStore[t]={mutation:u,variables:c,loading:!0,error:null}),i=l&&this.markMutationOptimistic(l,{mutationId:t,document:u,variables:c,fetchPolicy:v,errorPolicy:E,context:S,updateQueries:h,update:m,keepRootFields:k}),this.broadcastQueries(),o=this,[2,new Promise(function(e,n){return Qp(o.getObservableFromLink(u,Sl(Sl({},S),{optimisticResponse:i?l:void 0}),c,{},!1),function(e){if(Gp(e)&&"none"===E)throw new qd({graphQLErrors:Hp(e)});r&&(r.loading=!1,r.error=null);var n=Sl({},e);return"function"==typeof d&&(d=d(n)),"ignore"===E&&Gp(n)&&delete n.errors,o.markMutationResult({mutationId:t,result:n,document:u,variables:c,fetchPolicy:v,errorPolicy:E,context:S,update:m,updateQueries:h,awaitRefetchQueries:y,refetchQueries:d,removeOptimistic:i?t:void 0,onQueryUpdated:g,keepRootFields:k})}).subscribe({next:function(n){o.broadcastQueries(),"hasNext"in n&&!1!==n.hasNext||e(Sl(Sl({},n),{data:o.maskOperation({document:u,data:n.data,fetchPolicy:v,id:t})}))},error:function(e){r&&(r.loading=!1,r.error=e),i&&o.cache.removeOptimistic(t),o.broadcastQueries(),n(e instanceof qd?e:new qd({networkError:e}))}})})]}})})},e.prototype.markMutationResult=function(e,t){var n=this;void 0===t&&(t=this.cache);var r=e.result,i=[],o="no-cache"===e.fetchPolicy;if(!o&&vy(r,e.errorPolicy)){if(Jd(r)||i.push({result:r.data,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}),Jd(r)&&zd(r.incremental)){var s=t.diff({id:"ROOT_MUTATION",query:this.getDocumentInfo(e.document).asQuery,variables:e.variables,optimistic:!1,returnPartialData:!0}),a=void 0;s.result&&(a=Yd(s.result,r)),void 0!==a&&(r.data=a,i.push({result:a,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}))}var u=e.updateQueries;u&&this.queries.forEach(function(e,o){var s=e.observableQuery,a=s&&s.queryName;if(a&&Ay.call(u,a)){var c=u[a],l=n.queries.get(o),h=l.document,f=l.variables,d=t.diff({query:h,variables:f,returnPartialData:!0,optimistic:!1}),p=d.result;if(d.complete&&p){var y=c(p,{mutationResult:r,queryName:h&&Ef(h)||void 0,queryVariables:f});y&&i.push({result:y,dataId:"ROOT_QUERY",query:h,variables:f})}}})}if(i.length>0||(e.refetchQueries||"").length>0||e.update||e.onQueryUpdated||e.removeOptimistic){var c=[];if(this.refetchQueries({updateCache:function(t){o||i.forEach(function(e){return t.write(e)});var s=e.update,a=!function(e){return Jd(e)||function(e){return"hasNext"in e&&"data"in e}(e)}(r)||Jd(r)&&!r.hasNext;if(s){if(!o){var u=t.diff({id:"ROOT_MUTATION",query:n.getDocumentInfo(e.document).asQuery,variables:e.variables,optimistic:!1,returnPartialData:!0});u.complete&&("incremental"in(r=Sl(Sl({},r),{data:u.result}))&&delete r.incremental,"hasNext"in r&&delete r.hasNext)}a&&s(t,r,{context:e.context,variables:e.variables})}o||e.keepRootFields||!a||t.modify({id:"ROOT_MUTATION",fields:function(e,t){var n=t.fieldName,r=t.DELETE;return"__typename"===n?e:r}})},include:e.refetchQueries,optimistic:!1,removeOptimistic:e.removeOptimistic,onQueryUpdated:e.onQueryUpdated||null}).forEach(function(e){return c.push(e)}),e.awaitRefetchQueries||e.onQueryUpdated)return Promise.all(c).then(function(){return r})}return Promise.resolve(r)},e.prototype.markMutationOptimistic=function(e,t){var n=this,r="function"==typeof e?e(t.variables,{IGNORE:Ny}):e;return r!==Ny&&(this.cache.recordOptimisticTransaction(function(e){try{n.markMutationResult(Sl(Sl({},t),{result:{data:r}}),e)}catch(e){!1!==globalThis.__DEV__&&Vl.error(e)}},t.mutationId),!0)},e.prototype.fetchQuery=function(e,t,n){return this.fetchConcastWithInfo(this.getOrCreateQuery(e),t,n).concast.promise},e.prototype.getQueryStore=function(){var e=Object.create(null);return this.queries.forEach(function(t,n){e[n]={variables:t.variables,networkStatus:t.networkStatus,networkError:t.networkError,graphQLErrors:t.graphQLErrors}}),e},e.prototype.resetErrors=function(e){var t=this.queries.get(e);t&&(t.networkError=void 0,t.graphQLErrors=[])},e.prototype.transform=function(e){return this.documentTransform.transformDocument(e)},e.prototype.getDocumentInfo=function(e){var t=this.transformCache;if(!t.has(e)){var n={hasClientExports:xd(e),hasForcedResolvers:this.localState.shouldForceResolvers(e),hasNonreactiveDirective:Od(["nonreactive"],e),nonReactiveQuery:xp(e),clientQuery:this.localState.clientQuery(e),serverQuery:Sp([{name:"client",remove:!0},{name:"connection"},{name:"nonreactive"},{name:"unmask"}],e),defaultVars:Of(wf(e)),asQuery:Sl(Sl({},e),{definitions:e.definitions.map(function(e){return"OperationDefinition"===e.kind&&"query"!==e.operation?Sl(Sl({},e),{operation:"query"}):e})})};t.set(e,n)}return t.get(e)},e.prototype.getVariables=function(e,t){return Sl(Sl({},this.getDocumentInfo(e).defaultVars),t)},e.prototype.watchQuery=function(e){var t=this.transform(e.query);void 0===(e=Sl(Sl({},e),{variables:this.getVariables(t,e.variables)})).notifyOnNetworkStatusChange&&(e.notifyOnNetworkStatusChange=!1);var n=new by(this),r=new fy({queryManager:this,queryInfo:n,options:e});return r.lastQuery=t,fy.inactiveOnCreation.getValue()||this.queries.set(r.queryId,n),n.init({document:t,observableQuery:r,variables:r.variables}),r},e.prototype.query=function(e,t){var n=this;void 0===t&&(t=this.generateQueryId()),Vl(e.query,38),Vl("Document"===e.query.kind,39),Vl(!e.returnPartialData,40),Vl(!e.pollInterval,41);var r=this.transform(e.query);return this.fetchQuery(t,Sl(Sl({},e),{query:r})).then(function(i){return i&&Sl(Sl({},i),{data:n.maskOperation({document:r,data:i.data,fetchPolicy:e.fetchPolicy,id:t})})}).finally(function(){return n.stopQuery(t)})},e.prototype.generateQueryId=function(){return String(this.queryIdCounter++)},e.prototype.generateRequestId=function(){return this.requestIdCounter++},e.prototype.generateMutationId=function(){return String(this.mutationIdCounter++)},e.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryInStoreNoBroadcast=function(e){var t=this.queries.get(e);t&&t.stop()},e.prototype.clearStore=function(e){return void 0===e&&(e={discardWatches:!0}),this.cancelPendingFetches(zl(42)),this.queries.forEach(function(e){e.observableQuery?e.networkStatus=Xp.loading:e.stop()}),this.mutationStore&&(this.mutationStore=Object.create(null)),this.cache.reset(e)},e.prototype.getObservableQueries=function(e){var t=this;void 0===e&&(e="active");var n=new Map,r=new Map,i=new Map,o=new Set;return Array.isArray(e)&&e.forEach(function(e){if("string"==typeof e)r.set(e,e),i.set(e,!1);else if(function(e){return gh(e)&&"Document"===e.kind&&Array.isArray(e.definitions)}(e)){var n=dp(t.transform(e));r.set(n,Ef(e)),i.set(n,!1)}else gh(e)&&e.query&&o.add(e)}),this.queries.forEach(function(t,r){var o=t.observableQuery,s=t.document;if(o){if("all"===e)return void n.set(r,o);var a=o.queryName;if("standby"===o.options.fetchPolicy||"active"===e&&!o.hasObservers())return;("active"===e||a&&i.has(a)||s&&i.has(dp(s)))&&(n.set(r,o),a&&i.set(a,!0),s&&i.set(dp(s),!0))}}),o.size&&o.forEach(function(e){var r=Ul("legacyOneTimeQuery"),i=t.getOrCreateQuery(r).init({document:e.query,variables:e.variables}),o=new fy({queryManager:t,queryInfo:i,options:Sl(Sl({},e),{fetchPolicy:"network-only"})});Vl(o.queryId===r),i.setObservableQuery(o),n.set(r,o)}),!1!==globalThis.__DEV__&&i.size&&i.forEach(function(e,t){if(!e){var n=r.get(t);n?!1!==globalThis.__DEV__&&Vl.warn(43,n):!1!==globalThis.__DEV__&&Vl.warn(44)}}),n},e.prototype.reFetchObservableQueries=function(e){var t=this;void 0===e&&(e=!1);var n=[];return this.getObservableQueries(e?"all":"active").forEach(function(r,i){var o=r.options.fetchPolicy;gd("resetLastResults",function(){return r.resetLastResults()}),(e||"standby"!==o&&"cache-only"!==o)&&n.push(r.refetch()),(t.queries.get(i)||r.queryInfo).setDiff(null)}),this.broadcastQueries(),Promise.all(n)},e.prototype.startGraphQLSubscription=function(e){var t=this,n=e.query,r=e.variables,i=e.fetchPolicy,o=e.errorPolicy,s=void 0===o?"none":o,a=e.context,u=void 0===a?{}:a,c=e.extensions,l=void 0===c?{}:c;n=this.transform(n),r=this.getVariables(n,r);var h=function(e){return t.getObservableFromLink(n,u,e,l).map(function(r){"no-cache"!==i&&(vy(r,s)&&t.cache.write({query:n,result:r.data,dataId:"ROOT_SUBSCRIPTION",variables:e}),t.broadcastQueries());var o=Gp(r),a=Ud(r);if(o||a){var u={};if(o&&(u.graphQLErrors=r.errors),a&&(u.protocolErrors=r.extensions[Ld]),"none"===s||a)throw new qd(u)}return"ignore"===s&&delete r.errors,r})};if(this.getDocumentInfo(n).hasClientExports){var f=this.localState.addExportedVariables(n,r,u).then(h);return new mh(function(e){var t=null;return f.then(function(n){return t=n.subscribe(e)},e.error),function(){return t&&t.unsubscribe()}})}return h(r)},e.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},e.prototype.removeQuery=function(e){var t;this.fetchCancelFns.delete(e),this.queries.has(e)&&(null===(t=this.queries.get(e))||void 0===t||t.stop(),this.queries.delete(e))},e.prototype.broadcastQueries=function(){this.onBroadcast&&this.onBroadcast(),this.queries.forEach(function(e){var t;return null===(t=e.observableQuery)||void 0===t?void 0:t.notify()})},e.prototype.getLocalState=function(){return this.localState},e.prototype.getObservableFromLink=function(e,t,n,r,i){var o,s,a=this;void 0===i&&(i=null!==(o=null==t?void 0:t.queryDeduplication)&&void 0!==o?o:this.queryDeduplication);var u=this.getDocumentInfo(e),c=u.serverQuery,l=u.clientQuery;if(c){var h=this.inFlightLinkObservables,f=this.link,d={query:c,variables:n,operationName:Ef(c)||void 0,context:this.prepareContext(Sl(Sl({},t),{forceFetch:!i})),extensions:r};if(t=d.context,i){var p=dp(c),y=sf(n),m=h.lookup(p,y);if(!(s=m.observable)){var g=new ey([Np(f,d)]);s=m.observable=g,g.beforeNext(function e(t,n){"next"===t&&"hasNext"in n&&n.hasNext?g.beforeNext(e):h.remove(p,y)})}}else s=new ey([Np(f,d)])}else s=new ey([mh.of({data:{}})]),t=this.prepareContext(t);return l&&(s=Qp(s,function(e){return a.localState.runResolvers({document:l,remoteResult:e,context:t,variables:n})})),s},e.prototype.getResultsFromLink=function(e,t,n){var r=e.lastRequestId=this.generateRequestId(),i=this.cache.transformForLink(n.query);return Qp(this.getObservableFromLink(i,n.context,n.variables),function(o){var s=Hp(o),a=s.length>0,u=n.errorPolicy;if(r>=e.lastRequestId){if(a&&"none"===u)throw e.markError(new qd({graphQLErrors:s}));e.markResult(o,i,n,t),e.markReady()}var c={data:o.data,loading:!1,networkStatus:Xp.ready};return a&&"none"===u&&(c.data=void 0),a&&"ignore"!==u&&(c.errors=s,c.networkStatus=Xp.error),c},function(t){var n=$d(t)?t:new qd({networkError:t});throw r>=e.lastRequestId&&e.markError(n),n})},e.prototype.fetchConcastWithInfo=function(e,t,n,r){var i=this;void 0===n&&(n=Xp.loading),void 0===r&&(r=t.query);var o,s,a=this.getVariables(r,t.variables),u=this.defaultOptions.watchQuery,c=t.fetchPolicy,l=void 0===c?u&&u.fetchPolicy||"cache-first":c,h=t.errorPolicy,f=void 0===h?u&&u.errorPolicy||"none":h,d=t.returnPartialData,p=void 0!==d&&d,y=t.notifyOnNetworkStatusChange,m=void 0!==y&&y,g=t.context,b=void 0===g?{}:g,v=Object.assign({},t,{query:r,variables:a,fetchPolicy:l,errorPolicy:f,returnPartialData:p,notifyOnNetworkStatusChange:m,context:b}),w=function(r){v.variables=r;var o=i.fetchQueryByPolicy(e,v,n);return"standby"!==v.fetchPolicy&&o.sources.length>0&&e.observableQuery&&e.observableQuery.applyNextFetchPolicy("after-fetch",t),o},E=function(){return i.fetchCancelFns.delete(e.queryId)};if(this.fetchCancelFns.set(e.queryId,function(e){E(),setTimeout(function(){return o.cancel(e)})}),this.getDocumentInfo(v.query).hasClientExports)o=new ey(this.localState.addExportedVariables(v.query,v.variables,v.context).then(w).then(function(e){return e.sources})),s=!0;else{var k=w(v.variables);s=k.fromLink,o=new ey(k.sources)}return o.promise.then(E,E),{concast:o,fromLink:s}},e.prototype.refetchQueries=function(e){var t=this,n=e.updateCache,r=e.include,i=e.optimistic,o=void 0!==i&&i,s=e.removeOptimistic,a=void 0===s?o?Ul("refetchQueries"):void 0:s,u=e.onQueryUpdated,c=new Map;r&&this.getObservableQueries(r).forEach(function(e,n){c.set(n,{oq:e,lastDiff:(t.queries.get(n)||e.queryInfo).getDiff()})});var l=new Map;return n&&this.cache.batch({update:n,optimistic:o&&a||!1,removeOptimistic:a,onWatchUpdated:function(e,t,n){var r=e.watcher instanceof by&&e.watcher.observableQuery;if(r){if(u){c.delete(r.queryId);var i=u(r,t,n);return!0===i&&(i=r.refetch()),!1!==i&&l.set(r,i),i}null!==u&&c.set(r.queryId,{oq:r,lastDiff:n,diff:t})}}}),c.size&&c.forEach(function(e,n){var r,i=e.oq,o=e.lastDiff,s=e.diff;u&&(s||(s=gd("canonizeResults",function(){return t.cache.diff(i.queryInfo.getDiffOptions())})),r=u(i,s,o)),u&&!0!==r||(r=i.refetch()),!1!==r&&l.set(i,r),n.indexOf("legacyOneTimeQuery")>=0&&t.stopQueryNoBroadcast(n)}),a&&this.cache.removeOptimistic(a),l},e.prototype.maskOperation=function(e){var t,n,r,i=e.document,o=e.data;if(!1!==globalThis.__DEV__){var s=e.fetchPolicy,a=e.id,u=null===(t=wf(i))||void 0===t?void 0:t.operation,c=(null!==(n=null==u?void 0:u[0])&&void 0!==n?n:"o")+a;!this.dataMasking||"no-cache"!==s||function(e){var t=!0;return Ih(e,{FragmentSpread:function(e){if(!(t=!!e.directives&&e.directives.some(function(e){return"unmask"===e.name.value})))return xh}}),t}(i)||this.noCacheWarningsByQueryId.has(c)||(this.noCacheWarningsByQueryId.add(c),!1!==globalThis.__DEV__&&Vl.warn(45,null!==(r=Ef(i))&&void 0!==r?r:"Unnamed ".concat(null!=u?u:"operation")))}return this.dataMasking?function(e,t,n){var r;if(!n.fragmentMatches)return!1!==globalThis.__DEV__&&Oy(),e;var i=wf(t);return Vl(i,63),null==e?e:xy(e,i.selectionSet,{operationType:i.operation,operationName:null===(r=i.name)||void 0===r?void 0:r.value,fragmentMap:Ah(kf(t)),cache:n,mutableTargets:new ky,knownChanged:new Sy})}(o,i,this.cache):o},e.prototype.maskFragment=function(e){var t=e.data,n=e.fragment,r=e.fragmentName;return this.dataMasking?Cy(t,n,this.cache,r):t},e.prototype.fetchQueryByPolicy=function(e,t,n){var r=this,i=t.query,o=t.variables,s=t.fetchPolicy,a=t.refetchWritePolicy,u=t.errorPolicy,c=t.returnPartialData,l=t.context,h=t.notifyOnNetworkStatusChange,f=e.networkStatus;e.init({document:i,variables:o,networkStatus:n});var d=function(){return e.getDiff()},p=function(t,n){void 0===n&&(n=e.networkStatus||Xp.loading);var s=t.result;!1===globalThis.__DEV__||c||Fp(s,{})||py(t.missing);var a=function(e){return mh.of(Sl({data:e,loading:ty(n),networkStatus:n},t.complete?null:{partial:!0}))};return s&&r.getDocumentInfo(i).hasForcedResolvers?r.localState.runResolvers({document:i,remoteResult:{data:s},context:l,variables:o,onlyRunForcedResolvers:!0}).then(function(e){return a(e.data||void 0)}):"none"===u&&n===Xp.refetch&&Array.isArray(t.missing)?a(void 0):a(s)},y="no-cache"===s?0:n===Xp.refetch&&"merge"!==a?1:2,m=function(){return r.getResultsFromLink(e,y,{query:i,variables:o,context:l,fetchPolicy:s,errorPolicy:u})},g=h&&"number"==typeof f&&f!==n&&ty(n);switch(s){default:case"cache-first":return(b=d()).complete?{fromLink:!1,sources:[p(b,e.markReady())]}:c||g?{fromLink:!0,sources:[p(b),m()]}:{fromLink:!0,sources:[m()]};case"cache-and-network":var b;return(b=d()).complete||c||g?{fromLink:!0,sources:[p(b),m()]}:{fromLink:!0,sources:[m()]};case"cache-only":return{fromLink:!1,sources:[p(d(),e.markReady())]};case"network-only":return g?{fromLink:!0,sources:[p(d()),m()]}:{fromLink:!0,sources:[m()]};case"no-cache":return g?{fromLink:!0,sources:[p(e.getDiff()),m()]}:{fromLink:!0,sources:[m()]};case"standby":return{fromLink:!1,sources:[]}}},e.prototype.getOrCreateQuery=function(e){return e&&!this.queries.has(e)&&this.queries.set(e,new by(this,e)),this.queries.get(e)},e.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.localState.prepareContext(e);return Sl(Sl(Sl({},this.defaultContext),t),{clientAwareness:this.clientAwareness})},e}();function Dy(e){return e.kind===Td.FIELD||e.kind===Td.FRAGMENT_SPREAD||e.kind===Td.INLINE_FRAGMENT}var Ry=new Ff,Py=new WeakMap;function By(e){var t=Py.get(e);return t||Py.set(e,t={vars:new Set,dep:cd()}),t}function Fy(e){By(e).vars.forEach(function(t){return t.forgetCache(e)})}function Ly(e){var t=new Set,n=new Set,r=function(o){if(arguments.length>0){if(e!==o){e=o,t.forEach(function(e){By(e).dep.dirty(r),function(e){e.broadcastWatches&&e.broadcastWatches()}(e)});var s=Array.from(n);n.clear(),s.forEach(function(t){return t(e)})}}else{var a=Ry.getValue();a&&(i(a),By(a).dep(r))}return e};r.onNextChange=function(e){return n.add(e),function(){n.delete(e)}};var i=r.attachCache=function(e){return t.add(e),By(e).vars.add(r),r};return r.forgetCache=function(e){return t.delete(e)},r}var Uy=function(){function e(e){var t=e.cache,n=e.client,r=e.resolvers,i=e.fragmentMatcher;this.selectionsToResolveCache=new WeakMap,this.cache=t,n&&(this.client=n),r&&this.addResolvers(r),i&&this.setFragmentMatcher(i)}return e.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach(function(e){t.resolvers=Wd(t.resolvers,e)}):this.resolvers=Wd(this.resolvers,e)},e.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},e.prototype.getResolvers=function(){return this.resolvers||{}},e.prototype.runResolvers=function(e){return _l(this,arguments,void 0,function(e){var t=e.document,n=e.remoteResult,r=e.context,i=e.variables,o=e.onlyRunForcedResolvers,s=void 0!==o&&o;return Ol(this,function(e){return t?[2,this.resolveDocument(t,n.data,r,i,this.fragmentMatcher,s).then(function(e){return Sl(Sl({},n),{data:e.result})})]:[2,n]})})},e.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},e.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},e.prototype.clientQuery=function(e){return Od(["client"],e)&&this.resolvers?e:null},e.prototype.serverQuery=function(e){return Op(e)},e.prototype.prepareContext=function(e){var t=this.cache;return Sl(Sl({},e),{cache:t,getCacheKey:function(e){return t.identify(e)}})},e.prototype.addExportedVariables=function(e){return _l(this,arguments,void 0,function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),Ol(this,function(r){return e?[2,this.resolveDocument(e,this.buildRootValueFromCache(e,t)||{},this.prepareContext(n),t).then(function(e){return Sl(Sl({},t),e.exportedVariables)})]:[2,Sl({},t)]})})},e.prototype.shouldForceResolvers=function(e){var t=!1;return Ih(e,{Directive:{enter:function(e){if("client"===e.name.value&&e.arguments&&(t=e.arguments.some(function(e){return"always"===e.name.value&&"BooleanValue"===e.value.kind&&!0===e.value.value})))return xh}}}),t},e.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:_p(e),variables:t,returnPartialData:!0,optimistic:!1}).result},e.prototype.resolveDocument=function(e,t){return _l(this,arguments,void 0,function(e,t,n,r,i,o){var s,a,u,c,l,h,f,d,p,y;return void 0===n&&(n={}),void 0===r&&(r={}),void 0===i&&(i=function(){return!0}),void 0===o&&(o=!1),Ol(this,function(m){return s=_f(e),a=kf(e),u=Ah(a),c=this.collectSelectionsToResolve(s,u),l=s.operation,h=l?l.charAt(0).toUpperCase()+l.slice(1):"Query",d=(f=this).cache,p=f.client,y={fragmentMap:u,context:Sl(Sl({},n),{cache:d,client:p}),variables:r,fragmentMatcher:i,defaultOperationType:h,exportedVariables:{},selectionsToResolve:c,onlyRunForcedResolvers:o},[2,this.resolveSelectionSet(s.selectionSet,false,t,y).then(function(e){return{result:e,exportedVariables:y.exportedVariables}})]})})},e.prototype.resolveSelectionSet=function(e,t,n,r){return _l(this,void 0,void 0,function(){var i,o,s,a,u,c=this;return Ol(this,function(l){return i=r.fragmentMap,o=r.context,s=r.variables,a=[n],u=function(e){return _l(c,void 0,void 0,function(){var u,c;return Ol(this,function(l){return(t||r.selectionsToResolve.has(e))&&_d(e,s)?bf(e)?[2,this.resolveField(e,t,n,r).then(function(t){var n;void 0!==t&&a.push(((n={})[mf(e)]=t,n))})]:(!function(e){return"InlineFragment"===e.kind}(e)?(u=i[e.name.value],Vl(u,21,e.name.value)):u=e,u&&u.typeCondition&&(c=u.typeCondition.name.value,r.fragmentMatcher(n,c,o))?[2,this.resolveSelectionSet(u.selectionSet,t,n,r).then(function(e){a.push(e)})]:[2]):[2]})})},[2,Promise.all(e.selections.map(u)).then(function(){return Qd(a)})]})})},e.prototype.resolveField=function(e,t,n,r){return _l(this,void 0,void 0,function(){var i,o,s,a,u,c,l,h,f,d=this;return Ol(this,function(p){return n?(i=r.variables,o=e.name.value,s=mf(e),a=o!==s,u=n[s]||n[o],c=Promise.resolve(u),r.onlyRunForcedResolvers&&!this.shouldForceResolvers(e)||(l=n.__typename||r.defaultOperationType,(h=this.resolvers&&this.resolvers[l])&&(f=h[a?o:s])&&(c=Promise.resolve(Ry.withValue(this.cache,f,[n,yf(e,i),r.context,{field:e,fragmentMap:r.fragmentMap}])))),[2,c.then(function(n){var i,o;if(void 0===n&&(n=u),e.directives&&e.directives.forEach(function(e){"export"===e.name.value&&e.arguments&&e.arguments.forEach(function(e){"as"===e.name.value&&"StringValue"===e.value.kind&&(r.exportedVariables[e.value.value]=n)})}),!e.selectionSet)return n;if(null==n)return n;var s=null!==(o=null===(i=e.directives)||void 0===i?void 0:i.some(function(e){return"client"===e.name.value}))&&void 0!==o&&o;return Array.isArray(n)?d.resolveSubSelectedArray(e,t||s,n,r):e.selectionSet?d.resolveSelectionSet(e.selectionSet,t||s,n,r):void 0})]):[2,null]})})},e.prototype.resolveSubSelectedArray=function(e,t,n,r){var i=this;return Promise.all(n.map(function(n){return null===n?null:Array.isArray(n)?i.resolveSubSelectedArray(e,t,n,r):e.selectionSet?i.resolveSelectionSet(e.selectionSet,t,n,r):void 0}))},e.prototype.collectSelectionsToResolve=function(e,t){var n=function(e){return!Array.isArray(e)},r=this.selectionsToResolveCache;return function e(i){if(!r.has(i)){var o=new Set;r.set(i,o),Ih(i,{Directive:function(e,t,r,i,s){"client"===e.name.value&&s.forEach(function(e){n(e)&&Dy(e)&&o.add(e)})},FragmentSpread:function(r,i,s,a,u){var c=t[r.name.value];Vl(c,22,r.name.value);var l=e(c);l.size>0&&(u.forEach(function(e){n(e)&&Dy(e)&&o.add(e)}),o.add(r),l.forEach(function(e){o.add(e)}))}})}return r.get(i)}(e)},e}();function $y(e,t){return ny(e,t,t.variables&&{variables:ny(Sl(Sl({},e&&e.variables),t.variables))})}var qy=!1,Vy=function(){function e(e){var t,n,r,i=this;if(this.resetStoreCallbacks=[],this.clearStoreCallbacks=[],!e.cache)throw zl(16);var o=e.uri,s=e.credentials,a=e.headers,u=e.cache,c=e.documentTransform,l=e.ssrMode,h=void 0!==l&&l,f=e.ssrForceFetchDelay,d=void 0===f?0:f,p=e.connectToDevTools,y=e.queryDeduplication,m=void 0===y||y,g=e.defaultOptions,b=e.defaultContext,v=e.assumeImmutableResults,w=void 0===v?u.assumeImmutableResults:v,E=e.resolvers,k=e.typeDefs,S=e.fragmentMatcher,T=e.clientAwareness,_=e.name,O=e.version,x=e.devtools,I=e.dataMasking;!1!==globalThis.__DEV__&&(bd(e,"connectToDevTools","ApolloClient","Please use `devtools.enabled` instead."),bd(e,"uri","ApolloClient","Please initialize an instance of `HttpLink` with `uri` instead."),bd(e,"credentials","ApolloClient","Please initialize an instance of `HttpLink` with `credentials` instead."),bd(e,"headers","ApolloClient","Please initialize an instance of `HttpLink` with `headers` instead."),bd(e,"name","ApolloClient","Please use the `clientAwareness.name` option instead."),bd(e,"version","ApolloClient","Please use the `clientAwareness.version` option instead."),bd(e,"typeDefs","ApolloClient"),e.link||!1!==globalThis.__DEV__&&Vl.warn(17));var M=e.link;M||(M=o?new jp({uri:o,credentials:s,headers:a}):Sd.empty()),this.link=M,this.cache=u,this.disableNetworkFetches=h||d>0,this.queryDeduplication=m,this.defaultOptions=g||Object.create(null),this.typeDefs=k,this.devtoolsConfig=Sl(Sl({},x),{enabled:null!==(t=null==x?void 0:x.enabled)&&void 0!==t?t:p}),void 0===this.devtoolsConfig.enabled&&(this.devtoolsConfig.enabled=!1!==globalThis.__DEV__),d&&setTimeout(function(){return i.disableNetworkFetches=!1},d),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.watchFragment=this.watchFragment.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this),this.version=Pl,this.localState=new Uy({cache:u,client:this,resolvers:E,fragmentMatcher:S}),this.queryManager=new jy({cache:this.cache,link:this.link,defaultOptions:this.defaultOptions,defaultContext:b,documentTransform:c,queryDeduplication:m,ssrMode:h,dataMasking:!!I,clientAwareness:{name:null!==(n=null==T?void 0:T.name)&&void 0!==n?n:_,version:null!==(r=null==T?void 0:T.version)&&void 0!==r?r:O},localState:this.localState,assumeImmutableResults:w,onBroadcast:this.devtoolsConfig.enabled?function(){i.devToolsHookCb&&i.devToolsHookCb({action:{},state:{queries:i.queryManager.getQueryStore(),mutations:i.queryManager.mutationStore||{}},dataWithOptimisticResults:i.cache.extract(!0)})}:void 0}),this.devtoolsConfig.enabled&&this.connectToDevTools()}return Object.defineProperty(e.prototype,"prioritizeCacheValues",{get:function(){return this.disableNetworkFetches},set:function(e){this.disableNetworkFetches=e},enumerable:!1,configurable:!0}),e.prototype.connectToDevTools=function(){if("undefined"!=typeof window){var e=window,t=Symbol.for("apollo.devtools");(e[t]=e[t]||[]).push(this),e.__APOLLO_CLIENT__=this,qy||!1===globalThis.__DEV__||(qy=!0,window.document&&window.top===window.self&&/^(https?|file):$/.test(window.location.protocol)&&setTimeout(function(){if(!window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__){var e=window.navigator,t=e&&e.userAgent,n=void 0;"string"==typeof t&&(t.indexOf("Chrome/")>-1?n="https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm":t.indexOf("Firefox/")>-1&&(n="https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/")),n&&!1!==globalThis.__DEV__&&Vl.log("Download the Apollo DevTools for a better development experience: %s",n)}},1e4))}},Object.defineProperty(e.prototype,"documentTransform",{get:function(){return this.queryManager.documentTransform},enumerable:!1,configurable:!0}),e.prototype.stop=function(){this.queryManager.stop()},e.prototype.watchQuery=function(e){return this.defaultOptions.watchQuery&&(e=$y(this.defaultOptions.watchQuery,e)),!this.disableNetworkFetches||"network-only"!==e.fetchPolicy&&"cache-and-network"!==e.fetchPolicy||(e=Sl(Sl({},e),{fetchPolicy:"cache-first"})),!1!==globalThis.__DEV__&&(bd(e,"canonizeResults","client.watchQuery"),bd(e,"partialRefetch","client.watchQuery")),this.queryManager.watchQuery(e)},e.prototype.query=function(e){return this.defaultOptions.query&&(e=$y(this.defaultOptions.query,e)),Vl("cache-and-network"!==e.fetchPolicy,18),this.disableNetworkFetches&&"network-only"===e.fetchPolicy&&(e=Sl(Sl({},e),{fetchPolicy:"cache-first"})),!1!==globalThis.__DEV__&&(bd(e,"canonizeResults","client.query"),bd(e,"notifyOnNetworkStatusChange","client.query","This option does not affect `client.query` and can be safely removed."),"standby"===e.fetchPolicy&&!1!==globalThis.__DEV__&&Vl.warn(19)),this.queryManager.query(e)},e.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=$y(this.defaultOptions.mutate,e)),this.queryManager.mutate(e)},e.prototype.subscribe=function(e){var t=this,n=this.queryManager.generateQueryId();return this.queryManager.startGraphQLSubscription(e).map(function(r){return Sl(Sl({},r),{data:t.queryManager.maskOperation({document:e.query,data:r.data,fetchPolicy:e.fetchPolicy,id:n})})})},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.cache.readQuery(e,t)},e.prototype.watchFragment=function(e){var t;return this.cache.watchFragment(Sl(Sl({},e),((t={})[Symbol.for("apollo.dataMasking")]=this.queryManager.dataMasking,t)))},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.cache.readFragment(e,t)},e.prototype.writeQuery=function(e){var t=this.cache.writeQuery(e);return!1!==e.broadcast&&this.queryManager.broadcastQueries(),t},e.prototype.writeFragment=function(e){var t=this.cache.writeFragment(e);return!1!==e.broadcast&&this.queryManager.broadcastQueries(),t},e.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},e.prototype.__requestRaw=function(e){return Np(this.link,e)},e.prototype.resetStore=function(){var e=this;return Promise.resolve().then(function(){return e.queryManager.clearStore({discardWatches:!1})}).then(function(){return Promise.all(e.resetStoreCallbacks.map(function(e){return e()}))}).then(function(){return e.reFetchObservableQueries()})},e.prototype.clearStore=function(){var e=this;return Promise.resolve().then(function(){return e.queryManager.clearStore({discardWatches:!0})}).then(function(){return Promise.all(e.clearStoreCallbacks.map(function(e){return e()}))})},e.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter(function(t){return t!==e})}},e.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter(function(t){return t!==e})}},e.prototype.reFetchObservableQueries=function(e){return this.queryManager.reFetchObservableQueries(e)},e.prototype.refetchQueries=function(e){var t=this.queryManager.refetchQueries(e),n=[],r=[];t.forEach(function(e,t){n.push(t),r.push(e)});var i=Promise.all(r);return i.queries=n,i.results=r,i.catch(function(e){!1!==globalThis.__DEV__&&Vl.debug(20,e)}),i},e.prototype.getObservableQueries=function(e){return void 0===e&&(e="active"),this.queryManager.getObservableQueries(e)},e.prototype.extract=function(e){return this.cache.extract(e)},e.prototype.restore=function(e){return this.cache.restore(e)},e.prototype.addResolvers=function(e){this.localState.addResolvers(e)},e.prototype.setResolvers=function(e){this.localState.setResolvers(e)},e.prototype.getResolvers=function(){return this.localState.getResolvers()},e.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},e.prototype.setLink=function(e){this.link=this.queryManager.link=e},Object.defineProperty(e.prototype,"defaultContext",{get:function(){return this.queryManager.defaultContext},enumerable:!1,configurable:!0}),e}();!1!==globalThis.__DEV__&&(Vy.prototype.getMemoryInternals=Hh);var zy=function(){function e(){this.assumeImmutableResults=!1,this.getFragmentDoc=dd(Ch,{max:Wh["cache.fragmentQueryDocuments"]||1e3,cache:Fh})}return e.prototype.lookupFragment=function(e){return null},e.prototype.batch=function(e){var t,n=this,r="string"==typeof e.optimistic?e.optimistic:!1===e.optimistic?null:void 0;return this.performTransaction(function(){return t=e.update(n)},r),t},e.prototype.recordOptimisticTransaction=function(e,t){this.performTransaction(e,t)},e.prototype.transformDocument=function(e){return e},e.prototype.transformForLink=function(e){return e},e.prototype.identify=function(e){},e.prototype.gc=function(){return[]},e.prototype.modify=function(e){return!1},e.prototype.readQuery=function(e,t){var n=this;return void 0===t&&(t=!!e.optimistic),!1!==globalThis.__DEV__&&bd(e,"canonizeResults","cache.readQuery"),gd("canonizeResults",function(){return n.read(Sl(Sl({},e),{rootId:e.id||"ROOT_QUERY",optimistic:t}))})},e.prototype.watchFragment=function(e){var t=this,n=e.fragment,r=e.fragmentName,i=e.from,o=e.optimistic,s=void 0===o||o,a=Tl(e,["fragment","fragmentName","from","optimistic"]),u=this.getFragmentDoc(n,r),c=void 0===i||"string"==typeof i?i:this.identify(i),l=!!e[Symbol.for("apollo.dataMasking")];if(!1!==globalThis.__DEV__){var h=r||Tf(n).name.value;c||!1!==globalThis.__DEV__&&Vl.warn(1,h)}var f,d=Sl(Sl({},a),{returnPartialData:!0,id:c,query:u,optimistic:s});return new mh(function(i){return t.watch(Sl(Sl({},d),{immediate:!0,callback:function(o){var s=l?Cy(o.result,n,t,r):o.result;if(!f||!sy(u,{data:f.result},{data:s},e.variables)){var a={data:s,complete:!!o.complete};o.missing&&(a.missing=Qd(o.missing.map(function(e){return e.missing}))),f=Sl(Sl({},o),{result:s}),i.next(a)}}}))})},e.prototype.readFragment=function(e,t){var n=this;return void 0===t&&(t=!!e.optimistic),!1!==globalThis.__DEV__&&bd(e,"canonizeResults","cache.readFragment"),gd("canonizeResults",function(){return n.read(Sl(Sl({},e),{query:n.getFragmentDoc(e.fragment,e.fragmentName),rootId:e.id,optimistic:t}))})},e.prototype.writeQuery=function(e){var t=e.id,n=e.data,r=Tl(e,["id","data"]);return this.write(Object.assign(r,{dataId:t||"ROOT_QUERY",result:n}))},e.prototype.writeFragment=function(e){var t=e.id,n=e.data,r=e.fragment,i=e.fragmentName,o=Tl(e,["id","data","fragment","fragmentName"]);return this.write(Object.assign(o,{query:this.getFragmentDoc(r,i),dataId:t,result:n}))},e.prototype.updateQuery=function(e,t){return!1!==globalThis.__DEV__&&bd(e,"canonizeResults","cache.updateQuery"),this.batch({update:function(n){var r=gd("canonizeResults",function(){return n.readQuery(e)}),i=t(r);return null==i?r:(n.writeQuery(Sl(Sl({},e),{data:i})),i)}})},e.prototype.updateFragment=function(e,t){return!1!==globalThis.__DEV__&&bd(e,"canonizeResults","cache.updateFragment"),this.batch({update:function(n){var r=gd("canonizeResults",function(){return n.readFragment(e)}),i=t(r);return null==i?r:(n.writeFragment(Sl(Sl({},e),{data:i})),i)}})},e}();!1!==globalThis.__DEV__&&(zy.prototype.getMemoryInternals=Zh);var Ky=function(e){function t(n,r,i,o){var s,a=e.call(this,n)||this;if(a.message=n,a.path=r,a.query=i,a.variables=o,Array.isArray(a.path)){a.missing=a.message;for(var u=a.path.length-1;u>=0;--u)a.missing=((s={})[a.path[u]]=a.missing,s)}else a.missing=a.path;return a.__proto__=t.prototype,a}return kl(t,e),t}(Error),Wy=Object.prototype.hasOwnProperty;function Qy(e){return null==e}function Gy(e,t){var n=e.__typename,r=e.id,i=e._id;if("string"==typeof n&&(t&&(t.keyObject=Qy(r)?Qy(i)?void 0:{_id:i}:{id:r}),Qy(r)&&!Qy(i)&&(r=i),!Qy(r)))return"".concat(n,":").concat("number"==typeof r||"string"==typeof r?r:JSON.stringify(r))}var Hy={dataIdFromObject:Gy,addTypename:!0,resultCaching:!0,canonizeResults:!1};function Jy(e){var t=e.canonizeResults;return void 0===t?Hy.canonizeResults:t}var Zy=/^[_a-z][_0-9a-z]*/i;function Yy(e){var t=e.match(Zy);return t?t[0]:e}function Xy(e,t,n){return!!gh(t)&&(Vd(t)?t.every(function(t){return Xy(e,t,n)}):e.selections.every(function(e){if(bf(e)&&_d(e,n)){var r=mf(e);return Wy.call(t,r)&&(!e.selectionSet||Xy(e.selectionSet,t[r],n))}return!0}))}function em(e){return gh(e)&&!lf(e)&&!Vd(e)}function tm(e,t){var n=Ah(kf(e));return{fragmentMap:n,lookupFragment:function(e){var r=n[e];return!r&&t&&(r=t.lookup(e)),r||null}}}var nm=Object.create(null),rm=function(){return nm},im=Object.create(null),om=function(){function e(e,t){var n=this;this.policies=e,this.group=t,this.data=Object.create(null),this.rootIds=Object.create(null),this.refs=Object.create(null),this.getFieldValue=function(e,t){return Ey(lf(e)?n.get(e.__ref,t):e&&e[t])},this.canRead=function(e){return lf(e)?n.has(e.__ref):"object"==typeof e},this.toReference=function(e,t){if("string"==typeof e)return cf(e);if(lf(e))return e;var r=n.policies.identify(e)[0];if(r){var i=cf(r);return t&&n.merge(r,e),i}}}return e.prototype.toObject=function(){return Sl({},this.data)},e.prototype.has=function(e){return void 0!==this.lookup(e,!0)},e.prototype.get=function(e,t){if(this.group.depend(e,t),Wy.call(this.data,e)){var n=this.data[e];if(n&&Wy.call(n,t))return n[t]}return"__typename"===t&&Wy.call(this.policies.rootTypenamesById,e)?this.policies.rootTypenamesById[e]:this instanceof cm?this.parent.get(e,t):void 0},e.prototype.lookup=function(e,t){return t&&this.group.depend(e,"__exists"),Wy.call(this.data,e)?this.data[e]:this instanceof cm?this.parent.lookup(e,t):this.policies.rootTypenamesById[e]?Object.create(null):void 0},e.prototype.merge=function(e,t){var n,r=this;lf(e)&&(e=e.__ref),lf(t)&&(t=t.__ref);var i="string"==typeof e?this.lookup(n=e):e,o="string"==typeof t?this.lookup(n=t):t;if(o){Vl("string"==typeof n,2);var s=new Hd(hm).merge(i,o);if(this.data[n]=s,s!==i&&(delete this.refs[n],this.group.caching)){var a=Object.create(null);i||(a.__exists=1),Object.keys(o).forEach(function(e){if(!i||i[e]!==s[e]){a[e]=1;var t=Yy(e);t===e||r.policies.hasKeyArgs(s.__typename,t)||(a[t]=1),void 0!==s[e]||r instanceof cm||delete s[e]}}),!a.__typename||i&&i.__typename||this.policies.rootTypenamesById[n]!==s.__typename||delete a.__typename,Object.keys(a).forEach(function(e){return r.group.dirty(n,e)})}}},e.prototype.modify=function(e,t){var n=this,r=this.lookup(e);if(r){var i=Object.create(null),o=!1,s=!0,a={DELETE:nm,INVALIDATE:im,isReference:lf,toReference:this.toReference,canRead:this.canRead,readField:function(t,r){return n.policies.readField("string"==typeof t?{fieldName:t,from:r||cf(e)}:t,{store:n})}};if(Object.keys(r).forEach(function(u){var c=Yy(u),l=r[u];if(void 0!==l){var h="function"==typeof t?t:t[u]||t[c];if(h){var f=h===rm?nm:h(Ey(l),Sl(Sl({},a),{fieldName:c,storeFieldName:u,storage:n.getStorage(e,u)}));if(f===im)n.group.dirty(e,u);else if(f===nm&&(f=void 0),f!==l&&(i[u]=f,o=!0,l=f,!1!==globalThis.__DEV__)){var d=function(e){if(void 0===n.lookup(e.__ref))return!1!==globalThis.__DEV__&&Vl.warn(3,e),!0};if(lf(f))d(f);else if(Array.isArray(f))for(var p=!1,y=void 0,m=0,g=f;m<g.length;m++){var b=g[m];if(lf(b)){if(p=!0,d(b))break}else if("object"==typeof b&&b)n.policies.identify(b)[0]&&(y=b);if(p&&void 0!==y){!1!==globalThis.__DEV__&&Vl.warn(4,y);break}}}}void 0!==l&&(s=!1)}}),o)return this.merge(e,i),s&&(this instanceof cm?this.data[e]=void 0:delete this.data[e],this.group.dirty(e,"__exists")),!0}return!1},e.prototype.delete=function(e,t,n){var r,i=this.lookup(e);if(i){var o=this.getFieldValue(i,"__typename"),s=t&&n?this.policies.getStoreFieldName({typename:o,fieldName:t,args:n}):t;return this.modify(e,s?((r={})[s]=rm,r):rm)}return!1},e.prototype.evict=function(e,t){var n=!1;return e.id&&(Wy.call(this.data,e.id)&&(n=this.delete(e.id,e.fieldName,e.args)),this instanceof cm&&this!==t&&(n=this.parent.evict(e,t)||n),(e.fieldName||n)&&this.group.dirty(e.id,e.fieldName||"__exists")),n},e.prototype.clear=function(){this.replace(null)},e.prototype.extract=function(){var e=this,t=this.toObject(),n=[];return this.getRootIdSet().forEach(function(t){Wy.call(e.policies.rootTypenamesById,t)||n.push(t)}),n.length&&(t.__META={extraRootIds:n.sort()}),t},e.prototype.replace=function(e){var t=this;if(Object.keys(this.data).forEach(function(n){e&&Wy.call(e,n)||t.delete(n)}),e){var n=e.__META,r=Tl(e,["__META"]);Object.keys(r).forEach(function(e){t.merge(e,r[e])}),n&&n.extraRootIds.forEach(this.retain,this)}},e.prototype.retain=function(e){return this.rootIds[e]=(this.rootIds[e]||0)+1},e.prototype.release=function(e){if(this.rootIds[e]>0){var t=--this.rootIds[e];return t||delete this.rootIds[e],t}return 0},e.prototype.getRootIdSet=function(e){return void 0===e&&(e=new Set),Object.keys(this.rootIds).forEach(e.add,e),this instanceof cm?this.parent.getRootIdSet(e):Object.keys(this.policies.rootTypenamesById).forEach(e.add,e),e},e.prototype.gc=function(){var e=this,t=this.getRootIdSet(),n=this.toObject();t.forEach(function(r){Wy.call(n,r)&&(Object.keys(e.findChildRefIds(r)).forEach(t.add,t),delete n[r])});var r=Object.keys(n);if(r.length){for(var i=this;i instanceof cm;)i=i.parent;r.forEach(function(e){return i.delete(e)})}return r},e.prototype.findChildRefIds=function(e){if(!Wy.call(this.refs,e)){var t=this.refs[e]=Object.create(null),n=this.data[e];if(!n)return t;var r=new Set([n]);r.forEach(function(e){lf(e)&&(t[e.__ref]=!0),gh(e)&&Object.keys(e).forEach(function(t){var n=e[t];gh(n)&&r.add(n)})})}return this.refs[e]},e.prototype.makeCacheKey=function(){return this.group.keyMaker.lookupArray(arguments)},e}(),sm=function(){function e(e,t){void 0===t&&(t=null),this.caching=e,this.parent=t,this.d=null,this.resetCaching()}return e.prototype.resetCaching=function(){this.d=this.caching?cd():null,this.keyMaker=new Af(Ad)},e.prototype.depend=function(e,t){if(this.d){this.d(am(e,t));var n=Yy(t);n!==t&&this.d(am(e,n)),this.parent&&this.parent.depend(e,t)}},e.prototype.dirty=function(e,t){this.d&&this.d.dirty(am(e,t),"__exists"===t?"forget":"setDirty")},e}();function am(e,t){return t+"#"+e}function um(e,t){fm(e)&&e.group.depend(t,"__exists")}!function(e){var t=function(e){function t(t){var n=t.policies,r=t.resultCaching,i=void 0===r||r,o=t.seed,s=e.call(this,n,new sm(i))||this;return s.stump=new lm(s),s.storageTrie=new Af(Ad),o&&s.replace(o),s}return kl(t,e),t.prototype.addLayer=function(e,t){return this.stump.addLayer(e,t)},t.prototype.removeLayer=function(){return this},t.prototype.getStorage=function(){return this.storageTrie.lookupArray(arguments)},t}(e);e.Root=t}(om||(om={}));var cm=function(e){function t(t,n,r,i){var o=e.call(this,n.policies,i)||this;return o.id=t,o.parent=n,o.replay=r,o.group=i,r(o),o}return kl(t,e),t.prototype.addLayer=function(e,n){return new t(e,this,n,this.group)},t.prototype.removeLayer=function(e){var t=this,n=this.parent.removeLayer(e);return e===this.id?(this.group.caching&&Object.keys(this.data).forEach(function(e){var r=t.data[e],i=n.lookup(e);i?r?r!==i&&Object.keys(r).forEach(function(n){Fp(r[n],i[n])||t.group.dirty(e,n)}):(t.group.dirty(e,"__exists"),Object.keys(i).forEach(function(n){t.group.dirty(e,n)})):t.delete(e)}),n):n===this.parent?this:n.addLayer(this.id,this.replay)},t.prototype.toObject=function(){return Sl(Sl({},this.parent.toObject()),this.data)},t.prototype.findChildRefIds=function(t){var n=this.parent.findChildRefIds(t);return Wy.call(this.data,t)?Sl(Sl({},n),e.prototype.findChildRefIds.call(this,t)):n},t.prototype.getStorage=function(){for(var e=this.parent;e.parent;)e=e.parent;return e.getStorage.apply(e,arguments)},t}(om),lm=function(e){function t(t){return e.call(this,"EntityStore.Stump",t,function(){},new sm(t.group.caching,t.group))||this}return kl(t,e),t.prototype.removeLayer=function(){return this},t.prototype.merge=function(e,t){return this.parent.merge(e,t)},t}(cm);function hm(e,t,n){var r=e[n],i=t[n];return Fp(r,i)?r:i}function fm(e){return!!(e instanceof om&&e.group.caching)}var dm=function(){function e(){this.known=new(Nd?WeakSet:Set),this.pool=new Af(Ad),this.passes=new WeakMap,this.keysByJSON=new Map,this.empty=this.admit({})}return e.prototype.isKnown=function(e){return gh(e)&&this.known.has(e)},e.prototype.pass=function(e){if(gh(e)){var t=function(e){return gh(e)?Vd(e)?e.slice(0):Sl({__proto__:Object.getPrototypeOf(e)},e):e}(e);return this.passes.set(t,e),t}return e},e.prototype.admit=function(e){var t=this;if(gh(e)){var n=this.passes.get(e);if(n)return n;switch(Object.getPrototypeOf(e)){case Array.prototype:if(this.known.has(e))return e;var r=e.map(this.admit,this);return(a=this.pool.lookupArray(r)).array||(this.known.add(a.array=r),!1!==globalThis.__DEV__&&Object.freeze(r)),a.array;case null:case Object.prototype:if(this.known.has(e))return e;var i=Object.getPrototypeOf(e),o=[i],s=this.sortedKeys(e);o.push(s.json);var a,u=o.length;if(s.sorted.forEach(function(n){o.push(t.admit(e[n]))}),!(a=this.pool.lookupArray(o)).object){var c=a.object=Object.create(i);this.known.add(c),s.sorted.forEach(function(e,t){c[e]=o[u+t]}),!1!==globalThis.__DEV__&&Object.freeze(c)}return a.object}}return e},e.prototype.sortedKeys=function(e){var t=Object.keys(e),n=this.pool.lookupArray(t);if(!n.keys){t.sort();var r=JSON.stringify(t);(n.keys=this.keysByJSON.get(r))||this.keysByJSON.set(r,n.keys={sorted:t,json:r})}return n.keys},e}();function pm(e){return[e.selectionSet,e.objectOrReference,e.context,e.context.canonizeResults]}var ym=function(){function e(e){var t=this;this.knownResults=new(Ad?WeakMap:Map),this.config=ny(e,{addTypename:!1!==e.addTypename,canonizeResults:Jy(e)}),this.canon=e.canon||new dm,this.executeSelectionSet=dd(function(e){var n,r=e.context.canonizeResults,i=pm(e);i[3]=!r;var o=(n=t.executeSelectionSet).peek.apply(n,i);return o?r?Sl(Sl({},o),{result:t.canon.admit(o.result)}):o:(um(e.context.store,e.enclosingRef.__ref),t.execSelectionSetImpl(e))},{max:this.config.resultCacheMaxSize||Wh["inMemoryCache.executeSelectionSet"]||5e4,keyArgs:pm,makeCacheKey:function(e,t,n,r){if(fm(n.store))return n.store.makeCacheKey(e,lf(t)?t.__ref:t,n.varString,r)}}),this.executeSubSelectedArray=dd(function(e){return um(e.context.store,e.enclosingRef.__ref),t.execSubSelectedArrayImpl(e)},{max:this.config.resultCacheMaxSize||Wh["inMemoryCache.executeSubSelectedArray"]||1e4,makeCacheKey:function(e){var t=e.field,n=e.array,r=e.context;if(fm(r.store))return r.store.makeCacheKey(t,n,r.varString)}})}return e.prototype.resetCanon=function(){this.canon=new dm},e.prototype.diffQueryAgainstStore=function(e){var t=e.store,n=e.query,r=e.rootId,i=void 0===r?"ROOT_QUERY":r,o=e.variables,s=e.returnPartialData,a=void 0===s||s,u=e.canonizeResults,c=void 0===u?this.config.canonizeResults:u,l=this.config.cache.policies;o=Sl(Sl({},Of(Sf(n))),o);var h,f=cf(i),d=this.executeSelectionSet({selectionSet:_f(n).selectionSet,objectOrReference:f,enclosingRef:f,context:Sl({store:t,query:n,policies:l,variables:o,varString:sf(o),canonizeResults:c},tm(n,this.config.fragments))});if(d.missing&&(h=[new Ky(mm(d.missing),d.missing,n,o)],!a))throw h[0];return{result:d.result,complete:!h,missing:h}},e.prototype.isFresh=function(e,t,n,r){if(fm(r.store)&&this.knownResults.get(e)===n){var i=this.executeSelectionSet.peek(n,t,r,this.canon.isKnown(e));if(i&&e===i.result)return!0}return!1},e.prototype.execSelectionSetImpl=function(e){var t=this,n=e.selectionSet,r=e.objectOrReference,i=e.enclosingRef,o=e.context;if(lf(r)&&!o.policies.rootTypenamesById[r.__ref]&&!o.store.has(r.__ref))return{result:this.canon.empty,missing:"Dangling reference to missing ".concat(r.__ref," object")};var s,a=o.variables,u=o.policies,c=o.store.getFieldValue(r,"__typename"),l=[],h=new Hd;function f(e,t){var n;return e.missing&&(s=h.merge(s,((n={})[t]=e.missing,n))),e.result}this.config.addTypename&&"string"==typeof c&&!u.rootIdsByTypename[c]&&l.push({__typename:c});var d=new Set(n.selections);d.forEach(function(e){var n,p;if(_d(e,a))if(bf(e)){var y=u.readField({fieldName:e.name.value,field:e,variables:o.variables,from:r},o),m=mf(e);void 0===y?Tp.added(e)||(s=h.merge(s,((n={})[m]="Can't find field '".concat(e.name.value,"' on ").concat(lf(r)?r.__ref+" object":"object "+JSON.stringify(r,null,2)),n))):Vd(y)?y.length>0&&(y=f(t.executeSubSelectedArray({field:e,array:y,enclosingRef:i,context:o}),m)):e.selectionSet?null!=y&&(y=f(t.executeSelectionSet({selectionSet:e.selectionSet,objectOrReference:y,enclosingRef:lf(y)?y:i,context:o}),m)):o.canonizeResults&&(y=t.canon.pass(y)),void 0!==y&&l.push(((p={})[m]=y,p))}else{var g=Nh(e,o.lookupFragment);if(!g&&e.kind===Td.FRAGMENT_SPREAD)throw zl(10,e.name.value);g&&u.fragmentMatches(g,c)&&g.selectionSet.selections.forEach(d.add,d)}});var p={result:Qd(l),missing:s},y=o.canonizeResults?this.canon.admit(p):Ey(p);return y.result&&this.knownResults.set(y.result,n),y},e.prototype.execSubSelectedArrayImpl=function(e){var t,n=this,r=e.field,i=e.array,o=e.enclosingRef,s=e.context,a=new Hd;function u(e,n){var r;return e.missing&&(t=a.merge(t,((r={})[n]=e.missing,r))),e.result}return r.selectionSet&&(i=i.filter(s.store.canRead)),i=i.map(function(e,t){return null===e?null:Vd(e)?u(n.executeSubSelectedArray({field:r,array:e,enclosingRef:o,context:s}),t):r.selectionSet?u(n.executeSelectionSet({selectionSet:r.selectionSet,objectOrReference:e,enclosingRef:lf(e)?e:o,context:s}),t):(!1!==globalThis.__DEV__&&function(e,t,n){if(!t.selectionSet){var r=new Set([n]);r.forEach(function(n){gh(n)&&(Vl(!lf(n),11,function(e,t){return lf(t)?e.get(t.__ref,"__typename"):t&&t.__typename}(e,n),t.name.value),Object.values(n).forEach(r.add,r))})}}(s.store,r,e),e)}),{result:s.canonizeResults?this.canon.admit(i):i,missing:t}},e}();function mm(e){try{JSON.stringify(e,function(e,t){if("string"==typeof t)throw t;return t})}catch(e){return e}}var gm=Object.create(null);function bm(e){var t=JSON.stringify(e);return gm[t]||(gm[t]=Object.create(null))}function vm(e){var t=bm(e);return t.keyFieldsFn||(t.keyFieldsFn=function(t,n){var r=function(e,t){return n.readField(t,e)},i=n.keyObject=Em(e,function(e){var i=Tm(n.storeObject,e,r);return void 0===i&&t!==n.storeObject&&Wy.call(t,e[0])&&(i=Tm(t,e,Sm)),Vl(void 0!==i,5,e.join("."),t),i});return"".concat(n.typename,":").concat(JSON.stringify(i))})}function wm(e){var t=bm(e);return t.keyArgsFn||(t.keyArgsFn=function(t,n){var r=n.field,i=n.variables,o=n.fieldName,s=Em(e,function(e){var n=e[0],o=n.charAt(0);if("@"!==o)if("$"!==o){if(t)return Tm(t,e)}else{var s=n.slice(1);if(i&&Wy.call(i,s)){var a=e.slice(0);return a[0]=s,Tm(i,a)}}else if(r&&zd(r.directives)){var u=n.slice(1),c=r.directives.find(function(e){return e.name.value===u}),l=c&&yf(c,i);return l&&Tm(l,e.slice(1))}}),a=JSON.stringify(s);return(t||"{}"!==a)&&(o+=":"+a),o})}function Em(e,t){var n=new Hd;return km(e).reduce(function(e,r){var i,o=t(r);if(void 0!==o){for(var s=r.length-1;s>=0;--s)(i={})[r[s]]=o,o=i;e=n.merge(e,o)}return e},Object.create(null))}function km(e){var t=bm(e);if(!t.paths){var n=t.paths=[],r=[];e.forEach(function(t,i){Vd(t)?(km(t).forEach(function(e){return n.push(r.concat(e))}),r.length=0):(r.push(t),Vd(e[i+1])||(n.push(r.slice(0)),r.length=0))})}return t.paths}function Sm(e,t){return e[t]}function Tm(e,t,n){return n=n||Sm,_m(t.reduce(function e(t,r){return Vd(t)?t.map(function(t){return e(t,r)}):t&&n(t,r)},e))}function _m(e){return gh(e)?Vd(e)?e.map(_m):Em(Object.keys(e).sort(),function(t){return Tm(e,t)}):e}function Om(e){return void 0!==e.args?e.args:e.field?yf(e.field,e.variables):null}var xm=function(){},Im=function(e,t){return t.fieldName},Mm=function(e,t,n){return(0,n.mergeObjects)(e,t)},Cm=function(e,t){return t},Am=function(){function e(e){this.config=e,this.typePolicies=Object.create(null),this.toBeAdded=Object.create(null),this.supertypeMap=new Map,this.fuzzySubtypes=new Map,this.rootIdsByTypename=Object.create(null),this.rootTypenamesById=Object.create(null),this.usingPossibleTypes=!1,this.config=Sl({dataIdFromObject:Gy},e),this.cache=this.config.cache,this.setRootTypename("Query"),this.setRootTypename("Mutation"),this.setRootTypename("Subscription"),e.possibleTypes&&this.addPossibleTypes(e.possibleTypes),e.typePolicies&&this.addTypePolicies(e.typePolicies)}return e.prototype.identify=function(e,t){var n,r=this,i=t&&(t.typename||(null===(n=t.storeObject)||void 0===n?void 0:n.__typename))||e.__typename;if(i===this.rootTypenamesById.ROOT_QUERY)return["ROOT_QUERY"];var o,s=t&&t.storeObject||e,a=Sl(Sl({},t),{typename:i,storeObject:s,readField:t&&t.readField||function(){var e=jm(arguments,s);return r.readField(e,{store:r.cache.data,variables:e.variables})}}),u=i&&this.getTypePolicy(i),c=u&&u.keyFn||this.config.dataIdFromObject;return Ty.withValue(!0,function(){for(;c;){var t=c(Sl(Sl({},e),s),a);if(!Vd(t)){o=t;break}c=vm(t)}}),o=o?String(o):void 0,a.keyObject?[o,a.keyObject]:[o]},e.prototype.addTypePolicies=function(e){var t=this;Object.keys(e).forEach(function(n){var r=e[n],i=r.queryType,o=r.mutationType,s=r.subscriptionType,a=Tl(r,["queryType","mutationType","subscriptionType"]);i&&t.setRootTypename("Query",n),o&&t.setRootTypename("Mutation",n),s&&t.setRootTypename("Subscription",n),Wy.call(t.toBeAdded,n)?t.toBeAdded[n].push(a):t.toBeAdded[n]=[a]})},e.prototype.updateTypePolicy=function(e,t,n){var r=this.getTypePolicy(e),i=t.keyFields,o=t.fields;function s(e,t){e.merge="function"==typeof t?t:!0===t?Mm:!1===t?Cm:e.merge}s(r,t.merge),r.keyFn=!1===i?xm:Vd(i)?vm(i):"function"==typeof i?i:r.keyFn,o&&Object.keys(o).forEach(function(t){var r=n[t];r&&(null==r?void 0:r.typename)===e||(r=n[t]={typename:e});var i=o[t];if("function"==typeof i)r.read=i;else{var a=i.keyArgs,u=i.read,c=i.merge;r.keyFn=!1===a?Im:Vd(a)?wm(a):"function"==typeof a?a:r.keyFn,"function"==typeof u&&(r.read=u),s(r,c)}r.read&&r.merge&&(r.keyFn=r.keyFn||Im)})},e.prototype.setRootTypename=function(e,t){void 0===t&&(t=e);var n="ROOT_"+e.toUpperCase(),r=this.rootTypenamesById[n];t!==r&&(Vl(!r||r===e,6,e),r&&delete this.rootIdsByTypename[r],this.rootIdsByTypename[t]=n,this.rootTypenamesById[n]=t)},e.prototype.addPossibleTypes=function(e){var t=this;this.usingPossibleTypes=!0,Object.keys(e).forEach(function(n){t.getSupertypeSet(n,!0),e[n].forEach(function(e){t.getSupertypeSet(e,!0).add(n);var r=e.match(Zy);r&&r[0]===e||t.fuzzySubtypes.set(e,new RegExp(e))})})},e.prototype.getTypePolicy=function(e){var t=this;if(!Wy.call(this.typePolicies,e)){var n=this.typePolicies[e]=Object.create(null);n.fields=Object.create(null);var r=this.supertypeMap.get(e);!r&&this.fuzzySubtypes.size&&(r=this.getSupertypeSet(e,!0),this.fuzzySubtypes.forEach(function(n,i){if(n.test(e)){var o=t.supertypeMap.get(i);o&&o.forEach(function(e){return r.add(e)})}})),r&&r.size&&r.forEach(function(e){var r=t.getTypePolicy(e),i=r.fields,o=Tl(r,["fields"]);Object.assign(n,o),Object.assign(n.fields,i)})}var i=this.toBeAdded[e];return i&&i.length&&i.splice(0).forEach(function(n){t.updateTypePolicy(e,n,t.typePolicies[e].fields)}),this.typePolicies[e]},e.prototype.getFieldPolicy=function(e,t){if(e)return this.getTypePolicy(e).fields[t]},e.prototype.getSupertypeSet=function(e,t){var n=this.supertypeMap.get(e);return!n&&t&&this.supertypeMap.set(e,n=new Set),n},e.prototype.fragmentMatches=function(e,t,n,r){var i=this;if(!e.typeCondition)return!0;if(!t)return!1;var o=e.typeCondition.name.value;if(t===o)return!0;if(this.usingPossibleTypes&&this.supertypeMap.has(o))for(var s=this.getSupertypeSet(t,!0),a=[s],u=function(e){var t=i.getSupertypeSet(e,!1);t&&t.size&&a.indexOf(t)<0&&a.push(t)},c=!(!n||!this.fuzzySubtypes.size),l=!1,h=0;h<a.length;++h){var f=a[h];if(f.has(o))return s.has(o)||(l&&!1!==globalThis.__DEV__&&Vl.warn(7,t,o),s.add(o)),!0;f.forEach(u),c&&h===a.length-1&&Xy(e.selectionSet,n,r)&&(c=!1,l=!0,this.fuzzySubtypes.forEach(function(e,n){var r=t.match(e);r&&r[0]===t&&u(n)}))}return!1},e.prototype.hasKeyArgs=function(e,t){var n=this.getFieldPolicy(e,t);return!(!n||!n.keyFn)},e.prototype.getStoreFieldName=function(e){var t,n=e.typename,r=e.fieldName,i=this.getFieldPolicy(n,r),o=i&&i.keyFn;if(o&&n)for(var s={typename:n,fieldName:r,field:e.field||null,variables:e.variables},a=Om(e);o;){var u=o(a,s);if(!Vd(u)){t=u||r;break}o=wm(u)}return void 0===t&&(t=e.field?function(e,t){var n=null;e.directives&&(n={},e.directives.forEach(function(e){n[e.name.value]={},e.arguments&&e.arguments.forEach(function(r){var i=r.name,o=r.value;return hf(n[e.name.value],i,o,t)})}));var r=null;return e.arguments&&e.arguments.length&&(r={},e.arguments.forEach(function(e){var n=e.name,i=e.value;return hf(r,n,i,t)})),pf(e.name.value,r,n)}(e.field,e.variables):pf(r,Om(e))),!1===t?r:r===Yy(t)?t:r+":"+t},e.prototype.readField=function(e,t){var n=e.from;if(n&&(e.field||e.fieldName)){if(void 0===e.typename){var r=t.store.getFieldValue(n,"__typename");r&&(e.typename=r)}var i=this.getStoreFieldName(e),o=Yy(i),s=t.store.getFieldValue(n,i),a=this.getFieldPolicy(e.typename,o),u=a&&a.read;if(u){var c=Nm(this,n,e,t,t.store.getStorage(lf(n)?n.__ref:n,i));return Ry.withValue(this.cache,u,[s,c])}return s}},e.prototype.getReadFunction=function(e,t){var n=this.getFieldPolicy(e,t);return n&&n.read},e.prototype.getMergeFunction=function(e,t,n){var r=this.getFieldPolicy(e,t),i=r&&r.merge;return!i&&n&&(i=(r=this.getTypePolicy(n))&&r.merge),i},e.prototype.runMergeFunction=function(e,t,n,r,i){var o=n.field,s=n.typename,a=n.merge;return a===Mm?Dm(r.store)(e,t):a===Cm?t:(r.overwrite&&(e=void 0),a(e,t,Nm(this,void 0,{typename:s,fieldName:o.name.value,field:o,variables:r.variables},r,i||Object.create(null))))},e}();function Nm(e,t,n,r,i){var o=e.getStoreFieldName(n),s=Yy(o),a=n.variables||r.variables,u=r.store,c=u.toReference,l=u.canRead;return{args:Om(n),field:n.field||null,fieldName:s,storeFieldName:o,variables:a,isReference:lf,toReference:c,storage:i,cache:e.cache,canRead:l,readField:function(){return e.readField(jm(arguments,t,a),r)},mergeObjects:Dm(r.store)}}function jm(e,t,n){var r,i=e[0],o=e[1],s=e.length;return"string"==typeof i?r={fieldName:i,from:s>1?o:t}:(r=Sl({},i),Wy.call(r,"from")||(r.from=t)),!1!==globalThis.__DEV__&&void 0===r.from&&!1!==globalThis.__DEV__&&Vl.warn(8,$l(Array.from(e))),void 0===r.variables&&(r.variables=n),r}function Dm(e){return function(t,n){if(Vd(t)||Vd(n))throw zl(9);if(gh(t)&&gh(n)){var r=e.getFieldValue(t,"__typename"),i=e.getFieldValue(n,"__typename");if(r&&i&&r!==i)return n;if(lf(t)&&em(n))return e.merge(t.__ref,n),t;if(em(t)&&lf(n))return e.merge(t,n.__ref),n;if(em(t)&&em(n))return Sl(Sl({},t),n)}return n}}function Rm(e,t,n){var r="".concat(t).concat(n),i=e.flavors.get(r);return i||e.flavors.set(r,i=e.clientOnly===t&&e.deferred===n?e:Sl(Sl({},e),{clientOnly:t,deferred:n})),i}var Pm=function(){function e(e,t,n){this.cache=e,this.reader=t,this.fragments=n}return e.prototype.writeToStore=function(e,t){var n=this,r=t.query,i=t.result,o=t.dataId,s=t.variables,a=t.overwrite,u=wf(r),c=new Hd;s=Sl(Sl({},Of(u)),s);var l=Sl(Sl({store:e,written:Object.create(null),merge:function(e,t){return c.merge(e,t)},variables:s,varString:sf(s)},tm(r,this.fragments)),{overwrite:!!a,incomingById:new Map,clientOnly:!1,deferred:!1,flavors:new Map}),h=this.processSelectionSet({result:i||Object.create(null),dataId:o,selectionSet:u.selectionSet,mergeTree:{map:new Map},context:l});if(!lf(h))throw zl(12,i);return l.incomingById.forEach(function(t,r){var i=t.storeObject,o=t.mergeTree,s=t.fieldNodeSet,a=cf(r);if(o&&o.map.size){var u=n.applyMerges(o,a,i,l);if(lf(u))return;i=u}if(!1!==globalThis.__DEV__&&!l.overwrite){var c=Object.create(null);s.forEach(function(e){e.selectionSet&&(c[e.name.value]=!0)});Object.keys(i).forEach(function(e){(function(e){return!0===c[Yy(e)]})(e)&&!function(e){var t=o&&o.map.get(e);return Boolean(t&&t.info&&t.info.merge)}(e)&&function(e,t,n,r){var i=function(e){var t=r.getFieldValue(e,n);return"object"==typeof t&&t},o=i(e);if(!o)return;var s=i(t);if(!s)return;if(lf(o))return;if(Fp(o,s))return;if(Object.keys(o).every(function(e){return void 0!==r.getFieldValue(s,e)}))return;var a=r.getFieldValue(e,"__typename")||r.getFieldValue(t,"__typename"),u=Yy(n),c="".concat(a,".").concat(u);if(qm.has(c))return;qm.add(c);var l=[];Vd(o)||Vd(s)||[o,s].forEach(function(e){var t=r.getFieldValue(e,"__typename");"string"!=typeof t||l.includes(t)||l.push(t)});!1!==globalThis.__DEV__&&Vl.warn(15,u,a,l.length?"either ensure all objects of type "+l.join(" and ")+" have an ID or a custom merge function, or ":"",c,Sl({},o),Sl({},s))}(a,i,e,l.store)})}e.merge(r,i)}),e.retain(h.__ref),h},e.prototype.processSelectionSet=function(e){var t=this,n=e.dataId,r=e.result,i=e.selectionSet,o=e.context,s=e.mergeTree,a=this.cache.policies,u=Object.create(null),c=n&&a.rootTypenamesById[n]||gf(r,i,o.fragmentMap)||n&&o.store.get(n,"__typename");"string"==typeof c&&(u.__typename=c);var l=function(){var e=jm(arguments,u,o.variables);if(lf(e.from)){var t=o.incomingById.get(e.from.__ref);if(t){var n=a.readField(Sl(Sl({},e),{from:t.storeObject}),o);if(void 0!==n)return n}}return a.readField(e,o)},h=new Set;this.flattenFields(i,r,o,c).forEach(function(e,n){var i,o=mf(n),f=r[o];if(h.add(n),void 0!==f){var d=a.getStoreFieldName({typename:c,fieldName:n.name.value,field:n,variables:e.variables}),p=Fm(s,d),y=t.processFieldValue(f,n,n.selectionSet?Rm(e,!1,!1):e,p),m=void 0;n.selectionSet&&(lf(y)||em(y))&&(m=l("__typename",y));var g=a.getMergeFunction(c,n.name.value,m);g?p.info={field:n,typename:c,merge:g}:$m(s,d),u=e.merge(u,((i={})[d]=y,i))}else!1===globalThis.__DEV__||e.clientOnly||e.deferred||Tp.added(n)||a.getReadFunction(c,n.name.value)||!1!==globalThis.__DEV__&&Vl.error(13,mf(n),r)});try{var f=a.identify(r,{typename:c,selectionSet:i,fragmentMap:o.fragmentMap,storeObject:u,readField:l}),d=f[0],p=f[1];n=n||d,p&&(u=o.merge(u,p))}catch(e){if(!n)throw e}if("string"==typeof n){var y=cf(n),m=o.written[n]||(o.written[n]=[]);if(m.indexOf(i)>=0)return y;if(m.push(i),this.reader&&this.reader.isFresh(r,y,i,o))return y;var g=o.incomingById.get(n);return g?(g.storeObject=o.merge(g.storeObject,u),g.mergeTree=Lm(g.mergeTree,s),h.forEach(function(e){return g.fieldNodeSet.add(e)})):o.incomingById.set(n,{storeObject:u,mergeTree:Um(s)?void 0:s,fieldNodeSet:h}),y}return u},e.prototype.processFieldValue=function(e,t,n,r){var i=this;return t.selectionSet&&null!==e?Vd(e)?e.map(function(e,o){var s=i.processFieldValue(e,t,n,Fm(r,o));return $m(r,o),s}):this.processSelectionSet({result:e,selectionSet:t.selectionSet,context:n,mergeTree:r}):!1!==globalThis.__DEV__?iy(e):e},e.prototype.flattenFields=function(e,t,n,r){void 0===r&&(r=gf(t,e,n.fragmentMap));var i=new Map,o=this.cache.policies,s=new Af(!1);return function e(a,u){var c=s.lookup(a,u.clientOnly,u.deferred);c.visited||(c.visited=!0,a.selections.forEach(function(s){if(_d(s,n.variables)){var a=u.clientOnly,c=u.deferred;if(a&&c||!zd(s.directives)||s.directives.forEach(function(e){var t=e.name.value;if("client"===t&&(a=!0),"defer"===t){var r=yf(e,n.variables);r&&!1===r.if||(c=!0)}}),bf(s)){var l=i.get(s);l&&(a=a&&l.clientOnly,c=c&&l.deferred),i.set(s,Rm(n,a,c))}else{var h=Nh(s,n.lookupFragment);if(!h&&s.kind===Td.FRAGMENT_SPREAD)throw zl(14,s.name.value);h&&o.fragmentMatches(h,r,t,n.variables)&&e(h.selectionSet,Rm(n,a,c))}}}))}(e,n),i},e.prototype.applyMerges=function(e,t,n,r,i){var o,s=this;if(e.map.size&&!lf(n)){var a,u=Vd(n)||!lf(t)&&!em(t)?void 0:t,c=n;u&&!i&&(i=[lf(u)?u.__ref:u]);var l=function(e,t){return Vd(e)?"number"==typeof t?e[t]:void 0:r.store.getFieldValue(e,String(t))};e.map.forEach(function(e,t){var n=l(u,t),o=l(c,t);if(void 0!==o){i&&i.push(t);var h=s.applyMerges(e,n,o,r,i);h!==o&&(a=a||new Map).set(t,h),i&&Vl(i.pop()===t)}}),a&&(n=Vd(c)?c.slice(0):Sl({},c),a.forEach(function(e,t){n[t]=e}))}return e.info?this.cache.policies.runMergeFunction(t,n,e.info,r,i&&(o=r.store).getStorage.apply(o,i)):n},e}(),Bm=[];function Fm(e,t){var n=e.map;return n.has(t)||n.set(t,Bm.pop()||{map:new Map}),n.get(t)}function Lm(e,t){if(e===t||!t||Um(t))return e;if(!e||Um(e))return t;var n=e.info&&t.info?Sl(Sl({},e.info),t.info):e.info||t.info,r=e.map.size&&t.map.size,i={info:n,map:r?new Map:e.map.size?e.map:t.map};if(r){var o=new Set(t.map.keys());e.map.forEach(function(e,n){i.map.set(n,Lm(e,t.map.get(n))),o.delete(n)}),o.forEach(function(n){i.map.set(n,Lm(t.map.get(n),e.map.get(n)))})}return i}function Um(e){return!e||!(e.info||e.map.size)}function $m(e,t){var n=e.map,r=n.get(t);r&&Um(r)&&(Bm.push(r),n.delete(t))}var qm=new Set;var Vm=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return n.watches=new Set,n.addTypenameTransform=new Wp(Tp),n.assumeImmutableResults=!0,n.makeVar=Ly,n.txCount=0,!1!==globalThis.__DEV__&&(bd(t,"addTypename","InMemoryCache","Please remove the `addTypename` option when initializing `InMemoryCache`."),bd(t,"canonizeResults","InMemoryCache","Please remove the `canonizeResults` option when initializing `InMemoryCache`.")),n.config=function(e){return ny(Hy,e)}(t),n.addTypename=!!n.config.addTypename,n.policies=new Am({cache:n,dataIdFromObject:n.config.dataIdFromObject,possibleTypes:n.config.possibleTypes,typePolicies:n.config.typePolicies}),n.init(),n}return kl(t,e),t.prototype.init=function(){var e=this.data=new om.Root({policies:this.policies,resultCaching:this.config.resultCaching});this.optimisticData=e.stump,this.resetResultCache()},t.prototype.resetResultCache=function(e){var t=this,n=this.storeReader,r=this.config.fragments;this.addTypenameTransform.resetCache(),null==r||r.resetCaches(),this.storeWriter=new Pm(this,this.storeReader=new ym({cache:this,addTypename:this.addTypename,resultCacheMaxSize:this.config.resultCacheMaxSize,canonizeResults:Jy(this.config),canon:e?void 0:n&&n.canon,fragments:r}),r),this.maybeBroadcastWatch=dd(function(e,n){return t.broadcastWatch(e,n)},{max:this.config.resultCacheMaxSize||Wh["inMemoryCache.maybeBroadcastWatch"]||5e3,makeCacheKey:function(e){var n=e.optimistic?t.optimisticData:t.data;if(fm(n)){var r=e.optimistic,i=e.id,o=e.variables;return n.makeCacheKey(e.query,e.callback,sf({optimistic:r,id:i,variables:o}))}}}),new Set([this.data.group,this.optimisticData.group]).forEach(function(e){return e.resetCaching()})},t.prototype.restore=function(e){return this.init(),e&&this.data.replace(e),this},t.prototype.extract=function(e){return void 0===e&&(e=!1),(e?this.optimisticData:this.data).extract()},t.prototype.read=function(e){!1!==globalThis.__DEV__&&bd(e,"canonizeResults","cache.read");var t=e.returnPartialData,n=void 0!==t&&t;try{return this.storeReader.diffQueryAgainstStore(Sl(Sl({},e),{store:e.optimistic?this.optimisticData:this.data,config:this.config,returnPartialData:n})).result||null}catch(e){if(e instanceof Ky)return null;throw e}},t.prototype.write=function(e){try{return++this.txCount,this.storeWriter.writeToStore(this.data,e)}finally{--this.txCount||!1===e.broadcast||this.broadcastWatches()}},t.prototype.modify=function(e){if(Wy.call(e,"id")&&!e.id)return!1;var t=e.optimistic?this.optimisticData:this.data;try{return++this.txCount,t.modify(e.id||"ROOT_QUERY",e.fields)}finally{--this.txCount||!1===e.broadcast||this.broadcastWatches()}},t.prototype.diff=function(e){return!1!==globalThis.__DEV__&&bd(e,"canonizeResults","cache.diff"),this.storeReader.diffQueryAgainstStore(Sl(Sl({},e),{store:e.optimistic?this.optimisticData:this.data,rootId:e.id||"ROOT_QUERY",config:this.config}))},t.prototype.watch=function(e){var t,n=this;return this.watches.size||By(t=this).vars.forEach(function(e){return e.attachCache(t)}),this.watches.add(e),e.immediate&&this.maybeBroadcastWatch(e),function(){n.watches.delete(e)&&!n.watches.size&&Fy(n),n.maybeBroadcastWatch.forget(e)}},t.prototype.gc=function(e){!1!==globalThis.__DEV__&&bd(e||{},"resetResultIdentities","cache.gc","First ensure all usages of `canonizeResults` are removed, then remove this option."),sf.reset(),dp.reset();var t=this.optimisticData.gc();return e&&!this.txCount&&(e.resetResultCache?this.resetResultCache(e.resetResultIdentities):e.resetResultIdentities&&this.storeReader.resetCanon()),t},t.prototype.retain=function(e,t){return(t?this.optimisticData:this.data).retain(e)},t.prototype.release=function(e,t){return(t?this.optimisticData:this.data).release(e)},t.prototype.identify=function(e){if(lf(e))return e.__ref;try{return this.policies.identify(e)[0]}catch(e){!1!==globalThis.__DEV__&&Vl.warn(e)}},t.prototype.evict=function(e){if(!e.id){if(Wy.call(e,"id"))return!1;e=Sl(Sl({},e),{id:"ROOT_QUERY"})}try{return++this.txCount,this.optimisticData.evict(e,this.data)}finally{--this.txCount||!1===e.broadcast||this.broadcastWatches()}},t.prototype.reset=function(e){var t=this;return this.init(),sf.reset(),e&&e.discardWatches?(this.watches.forEach(function(e){return t.maybeBroadcastWatch.forget(e)}),this.watches.clear(),Fy(this)):this.broadcastWatches(),Promise.resolve()},t.prototype.removeOptimistic=function(e){var t=this.optimisticData.removeLayer(e);t!==this.optimisticData&&(this.optimisticData=t,this.broadcastWatches())},t.prototype.batch=function(e){var t,n=this,r=e.update,i=e.optimistic,o=void 0===i||i,s=e.removeOptimistic,a=e.onWatchUpdated,u=function(e){var i=n,o=i.data,s=i.optimisticData;++n.txCount,e&&(n.data=n.optimisticData=e);try{return t=r(n)}finally{--n.txCount,n.data=o,n.optimisticData=s}},c=new Set;return a&&!this.txCount&&this.broadcastWatches(Sl(Sl({},e),{onWatchUpdated:function(e){return c.add(e),!1}})),"string"==typeof o?this.optimisticData=this.optimisticData.addLayer(o,u):!1===o?u(this.data):u(),"string"==typeof s&&(this.optimisticData=this.optimisticData.removeLayer(s)),a&&c.size?(this.broadcastWatches(Sl(Sl({},e),{onWatchUpdated:function(e,t){var n=a.call(this,e,t);return!1!==n&&c.delete(e),n}})),c.size&&c.forEach(function(e){return n.maybeBroadcastWatch.dirty(e)})):this.broadcastWatches(e),t},t.prototype.performTransaction=function(e,t){return this.batch({update:e,optimistic:t||null!==t})},t.prototype.transformDocument=function(e){return this.addTypenameToDocument(this.addFragmentsToDocument(e))},t.prototype.fragmentMatches=function(e,t){return this.policies.fragmentMatches(e,t)},t.prototype.lookupFragment=function(e){var t;return(null===(t=this.config.fragments)||void 0===t?void 0:t.lookup(e))||null},t.prototype.broadcastWatches=function(e){var t=this;this.txCount||this.watches.forEach(function(n){return t.maybeBroadcastWatch(n,e)})},t.prototype.addFragmentsToDocument=function(e){var t=this.config.fragments;return t?t.transform(e):e},t.prototype.addTypenameToDocument=function(e){return this.addTypename?this.addTypenameTransform.transformDocument(e):e},t.prototype.broadcastWatch=function(e,t){var n=this,r=e.lastDiff,i=gd("canonizeResults",function(){return n.diff(e)});t&&(e.optimistic&&"string"==typeof t.optimistic&&(i.fromOptimisticTransaction=!0),t.onWatchUpdated&&!1===t.onWatchUpdated.call(this,e,i,r))||r&&Fp(r.result,i.result)||e.callback(e.lastDiff=i,r)},t}(zy);function zm(e,t){if(!Boolean(e))throw new Error(t)}function Km(e){return Km="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Km(e)}!1!==globalThis.__DEV__&&(Vm.prototype.getMemoryInternals=Jh);"function"==typeof Symbol&&null!=Symbol.iterator&&Symbol.iterator,"function"==typeof Symbol&&null!=Symbol.asyncIterator&&Symbol.asyncIterator;var Wm="function"==typeof Symbol&&null!=Symbol.toStringTag?Symbol.toStringTag:"@@toStringTag";function Qm(e,t){for(var n,r=/\r\n|[\n\r]/g,i=1,o=t+1;(n=r.exec(e.body))&&n.index<t;)i+=1,o=t+1-(n.index+n[0].length);return{line:i,column:o}}function Gm(e){return Hm(e.source,Qm(e.source,e.start))}function Hm(e,t){var n=e.locationOffset.column-1,r=Zm(n)+e.body,i=t.line-1,o=e.locationOffset.line-1,s=t.line+o,a=1===t.line?n:0,u=t.column+a,c="".concat(e.name,":").concat(s,":").concat(u,"\n"),l=r.split(/\r\n|[\n\r]/g),h=l[i];if(h.length>120){for(var f=Math.floor(u/80),d=u%80,p=[],y=0;y<h.length;y+=80)p.push(h.slice(y,y+80));return c+Jm([["".concat(s),p[0]]].concat(p.slice(1,f+1).map(function(e){return["",e]}),[[" ",Zm(d-1)+"^"],["",p[f+1]]]))}return c+Jm([["".concat(s-1),l[i-1]],["".concat(s),h],["",Zm(u-1)+"^"],["".concat(s+1),l[i+1]]])}function Jm(e){var t=e.filter(function(e){e[0];return void 0!==e[1]}),n=Math.max.apply(Math,t.map(function(e){return e[0].length}));return t.map(function(e){var t=e[0],r=e[1];return function(e,t){return Zm(e-t.length)+t}(n,t)+(r?" | "+r:" |")}).join("\n")}function Zm(e){return Array(e+1).join(" ")}function Ym(e){return Ym="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ym(e)}function Xm(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function eg(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tg(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ng(e,t){return!t||"object"!==Ym(t)&&"function"!=typeof t?rg(e):t}function rg(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ig(e){var t="function"==typeof Map?new Map:void 0;return ig=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return og(e,arguments,ug(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),ag(r,e)},ig(e)}function og(e,t,n){return og=sg()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&ag(i,n.prototype),i},og.apply(null,arguments)}function sg(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function ag(e,t){return ag=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},ag(e,t)}function ug(e){return ug=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},ug(e)}var cg=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ag(e,t)}(a,e);var t,n,r,i,o,s=(t=a,n=sg(),function(){var e,r=ug(t);if(n){var i=ug(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return ng(this,e)});function a(e,t,n,r,i,o,u){var c,l,h,f;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(f=s.call(this,e)).name="GraphQLError",f.originalError=null!=o?o:void 0,f.nodes=lg(Array.isArray(t)?t:t?[t]:void 0);for(var d=[],p=0,y=null!==(m=f.nodes)&&void 0!==m?m:[];p<y.length;p++){var m,g=y[p].loc;null!=g&&d.push(g)}d=lg(d),f.source=null!=n?n:null===(c=d)||void 0===c?void 0:c[0].source,f.positions=null!=r?r:null===(l=d)||void 0===l?void 0:l.map(function(e){return e.start}),f.locations=r&&n?r.map(function(e){return Qm(n,e)}):null===(h=d)||void 0===h?void 0:h.map(function(e){return Qm(e.source,e.start)}),f.path=null!=i?i:void 0;var b=null==o?void 0:o.extensions;return null==u&&function(e){return"object"==Km(e)&&null!==e}(b)?f.extensions=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Xm(Object(n),!0).forEach(function(t){eg(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xm(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({},b):f.extensions=null!=u?u:{},Object.defineProperties(rg(f),{message:{enumerable:!0},locations:{enumerable:null!=f.locations},path:{enumerable:null!=f.path},extensions:{enumerable:null!=f.extensions&&Object.keys(f.extensions).length>0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),null!=o&&o.stack?(Object.defineProperty(rg(f),"stack",{value:o.stack,writable:!0,configurable:!0}),ng(f)):(Error.captureStackTrace?Error.captureStackTrace(rg(f),a):Object.defineProperty(rg(f),"stack",{value:Error().stack,writable:!0,configurable:!0}),f)}return r=a,(i=[{key:"toString",value:function(){return function(e){var t=e.message;if(e.nodes)for(var n=0,r=e.nodes;n<r.length;n++){var i=r[n];i.loc&&(t+="\n\n"+Gm(i.loc))}else if(e.source&&e.locations)for(var o=0,s=e.locations;o<s.length;o++){var a=s[o];t+="\n\n"+Hm(e.source,a)}return t}(this)}},{key:"toJSON",value:function(){return function(e){var t;e||zm(0,"Received null or undefined error.");var n=null!==(t=e.message)&&void 0!==t?t:"An unknown error occurred.",r=e.locations,i=e.path,o=e.extensions;return o&&Object.keys(o).length>0?{message:n,locations:r,path:i,extensions:o}:{message:n,locations:r,path:i}}(this)}},{key:Wm,get:function(){return"Object"}}])&&tg(r.prototype,i),o&&tg(r,o),a}(ig(Error));function lg(e){return void 0===e||0===e.length?void 0:e}function hg(e,t,n){return new cg("Syntax Error: ".concat(n),void 0,e,[t])}var fg=Object.freeze({SOF:"<SOF>",EOF:"<EOF>",BANG:"!",DOLLAR:"$",AMP:"&",PAREN_L:"(",PAREN_R:")",SPREAD:"...",COLON:":",EQUALS:"=",AT:"@",BRACKET_L:"[",BRACKET_R:"]",BRACE_L:"{",PIPE:"|",BRACE_R:"}",NAME:"Name",INT:"Int",FLOAT:"Float",STRING:"String",BLOCK_STRING:"BlockString",COMMENT:"Comment"});const dg=function(e,t){return e instanceof t};function pg(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var yg=function(){function e(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GraphQL request",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{line:1,column:1};"string"==typeof e||zm(0,"Body must be a string. Received: ".concat(wh(e),".")),this.body=e,this.name=t,this.locationOffset=n,this.locationOffset.line>0||zm(0,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||zm(0,"column in locationOffset is 1-indexed and must be positive.")}var t,n,r;return t=e,(n=[{key:Wm,get:function(){return"Source"}}])&&pg(t.prototype,n),r&&pg(t,r),e}();var mg=Object.freeze({QUERY:"QUERY",MUTATION:"MUTATION",SUBSCRIPTION:"SUBSCRIPTION",FIELD:"FIELD",FRAGMENT_DEFINITION:"FRAGMENT_DEFINITION",FRAGMENT_SPREAD:"FRAGMENT_SPREAD",INLINE_FRAGMENT:"INLINE_FRAGMENT",VARIABLE_DEFINITION:"VARIABLE_DEFINITION",SCHEMA:"SCHEMA",SCALAR:"SCALAR",OBJECT:"OBJECT",FIELD_DEFINITION:"FIELD_DEFINITION",ARGUMENT_DEFINITION:"ARGUMENT_DEFINITION",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",ENUM_VALUE:"ENUM_VALUE",INPUT_OBJECT:"INPUT_OBJECT",INPUT_FIELD_DEFINITION:"INPUT_FIELD_DEFINITION"}),gg=function(){function e(e){var t=new Th(fg.SOF,0,0,0,0,null);this.source=e,this.lastToken=t,this.token=t,this.line=1,this.lineStart=0}var t=e.prototype;return t.advance=function(){return this.lastToken=this.token,this.token=this.lookahead()},t.lookahead=function(){var e=this.token;if(e.kind!==fg.EOF)do{var t;e=null!==(t=e.next)&&void 0!==t?t:e.next=vg(this,e)}while(e.kind===fg.COMMENT);return e},e}();function bg(e){return isNaN(e)?fg.EOF:e<127?JSON.stringify(String.fromCharCode(e)):'"\\u'.concat(("00"+e.toString(16).toUpperCase()).slice(-4),'"')}function vg(e,t){for(var n=e.source,r=n.body,i=r.length,o=t.end;o<i;){var s=r.charCodeAt(o),a=e.line,u=1+o-e.lineStart;switch(s){case 65279:case 9:case 32:case 44:++o;continue;case 10:++o,++e.line,e.lineStart=o;continue;case 13:10===r.charCodeAt(o+1)?o+=2:++o,++e.line,e.lineStart=o;continue;case 33:return new Th(fg.BANG,o,o+1,a,u,t);case 35:return Eg(n,o,a,u,t);case 36:return new Th(fg.DOLLAR,o,o+1,a,u,t);case 38:return new Th(fg.AMP,o,o+1,a,u,t);case 40:return new Th(fg.PAREN_L,o,o+1,a,u,t);case 41:return new Th(fg.PAREN_R,o,o+1,a,u,t);case 46:if(46===r.charCodeAt(o+1)&&46===r.charCodeAt(o+2))return new Th(fg.SPREAD,o,o+3,a,u,t);break;case 58:return new Th(fg.COLON,o,o+1,a,u,t);case 61:return new Th(fg.EQUALS,o,o+1,a,u,t);case 64:return new Th(fg.AT,o,o+1,a,u,t);case 91:return new Th(fg.BRACKET_L,o,o+1,a,u,t);case 93:return new Th(fg.BRACKET_R,o,o+1,a,u,t);case 123:return new Th(fg.BRACE_L,o,o+1,a,u,t);case 124:return new Th(fg.PIPE,o,o+1,a,u,t);case 125:return new Th(fg.BRACE_R,o,o+1,a,u,t);case 34:return 34===r.charCodeAt(o+1)&&34===r.charCodeAt(o+2)?_g(n,o,a,u,t,e):Tg(n,o,a,u,t);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return kg(n,o,s,a,u,t);case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 95:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:return Ig(n,o,a,u,t)}throw hg(n,o,wg(s))}var c=e.line,l=1+o-e.lineStart;return new Th(fg.EOF,i,i,c,l,t)}function wg(e){return e<32&&9!==e&&10!==e&&13!==e?"Cannot contain the invalid character ".concat(bg(e),"."):39===e?"Unexpected single quote character ('), did you mean to use a double quote (\")?":"Cannot parse the unexpected character ".concat(bg(e),".")}function Eg(e,t,n,r,i){var o,s=e.body,a=t;do{o=s.charCodeAt(++a)}while(!isNaN(o)&&(o>31||9===o));return new Th(fg.COMMENT,t,a,n,r,i,s.slice(t+1,a))}function kg(e,t,n,r,i,o){var s=e.body,a=n,u=t,c=!1;if(45===a&&(a=s.charCodeAt(++u)),48===a){if((a=s.charCodeAt(++u))>=48&&a<=57)throw hg(e,u,"Invalid number, unexpected digit after 0: ".concat(bg(a),"."))}else u=Sg(e,u,a),a=s.charCodeAt(u);if(46===a&&(c=!0,a=s.charCodeAt(++u),u=Sg(e,u,a),a=s.charCodeAt(u)),69!==a&&101!==a||(c=!0,43!==(a=s.charCodeAt(++u))&&45!==a||(a=s.charCodeAt(++u)),u=Sg(e,u,a),a=s.charCodeAt(u)),46===a||function(e){return 95===e||e>=65&&e<=90||e>=97&&e<=122}(a))throw hg(e,u,"Invalid number, expected digit but got: ".concat(bg(a),"."));return new Th(c?fg.FLOAT:fg.INT,t,u,r,i,o,s.slice(t,u))}function Sg(e,t,n){var r=e.body,i=t,o=n;if(o>=48&&o<=57){do{o=r.charCodeAt(++i)}while(o>=48&&o<=57);return i}throw hg(e,i,"Invalid number, expected digit but got: ".concat(bg(o),"."))}function Tg(e,t,n,r,i){for(var o=e.body,s=t+1,a=s,u=0,c="";s<o.length&&!isNaN(u=o.charCodeAt(s))&&10!==u&&13!==u;){if(34===u)return c+=o.slice(a,s),new Th(fg.STRING,t,s+1,n,r,i,c);if(u<32&&9!==u)throw hg(e,s,"Invalid character within String: ".concat(bg(u),"."));if(++s,92===u){switch(c+=o.slice(a,s-1),u=o.charCodeAt(s)){case 34:c+='"';break;case 47:c+="/";break;case 92:c+="\\";break;case 98:c+="\b";break;case 102:c+="\f";break;case 110:c+="\n";break;case 114:c+="\r";break;case 116:c+="\t";break;case 117:var l=Og(o.charCodeAt(s+1),o.charCodeAt(s+2),o.charCodeAt(s+3),o.charCodeAt(s+4));if(l<0){var h=o.slice(s+1,s+5);throw hg(e,s,"Invalid character escape sequence: \\u".concat(h,"."))}c+=String.fromCharCode(l),s+=4;break;default:throw hg(e,s,"Invalid character escape sequence: \\".concat(String.fromCharCode(u),"."))}a=++s}}throw hg(e,s,"Unterminated string.")}function _g(e,t,n,r,i,o){for(var s=e.body,a=t+3,u=a,c=0,l="";a<s.length&&!isNaN(c=s.charCodeAt(a));){if(34===c&&34===s.charCodeAt(a+1)&&34===s.charCodeAt(a+2))return l+=s.slice(u,a),new Th(fg.BLOCK_STRING,t,a+3,n,r,i,np(l));if(c<32&&9!==c&&10!==c&&13!==c)throw hg(e,a,"Invalid character within String: ".concat(bg(c),"."));10===c?(++a,++o.line,o.lineStart=a):13===c?(10===s.charCodeAt(a+1)?a+=2:++a,++o.line,o.lineStart=a):92===c&&34===s.charCodeAt(a+1)&&34===s.charCodeAt(a+2)&&34===s.charCodeAt(a+3)?(l+=s.slice(u,a)+'"""',u=a+=4):++a}throw hg(e,a,"Unterminated string.")}function Og(e,t,n,r){return xg(e)<<12|xg(t)<<8|xg(n)<<4|xg(r)}function xg(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function Ig(e,t,n,r,i){for(var o=e.body,s=o.length,a=t+1,u=0;a!==s&&!isNaN(u=o.charCodeAt(a))&&(95===u||u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122);)++a;return new Th(fg.NAME,t,a,n,r,i,o.slice(t,a))}var Mg=function(){function e(e,t){var n=function(e){return dg(e,yg)}(e)?e:new yg(e);this._lexer=new gg(n),this._options=t}var t=e.prototype;return t.parseName=function(){var e=this.expectToken(fg.NAME);return{kind:Td.NAME,value:e.value,loc:this.loc(e)}},t.parseDocument=function(){var e=this._lexer.token;return{kind:Td.DOCUMENT,definitions:this.many(fg.SOF,this.parseDefinition,fg.EOF),loc:this.loc(e)}},t.parseDefinition=function(){if(this.peek(fg.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek(fg.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},t.parseOperationDefinition=function(){var e=this._lexer.token;if(this.peek(fg.BRACE_L))return{kind:Td.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(e)};var t,n=this.parseOperationType();return this.peek(fg.NAME)&&(t=this.parseName()),{kind:Td.OPERATION_DEFINITION,operation:n,name:t,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseOperationType=function(){var e=this.expectToken(fg.NAME);switch(e.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(e)},t.parseVariableDefinitions=function(){return this.optionalMany(fg.PAREN_L,this.parseVariableDefinition,fg.PAREN_R)},t.parseVariableDefinition=function(){var e=this._lexer.token;return{kind:Td.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(fg.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(fg.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(e)}},t.parseVariable=function(){var e=this._lexer.token;return this.expectToken(fg.DOLLAR),{kind:Td.VARIABLE,name:this.parseName(),loc:this.loc(e)}},t.parseSelectionSet=function(){var e=this._lexer.token;return{kind:Td.SELECTION_SET,selections:this.many(fg.BRACE_L,this.parseSelection,fg.BRACE_R),loc:this.loc(e)}},t.parseSelection=function(){return this.peek(fg.SPREAD)?this.parseFragment():this.parseField()},t.parseField=function(){var e,t,n=this._lexer.token,r=this.parseName();return this.expectOptionalToken(fg.COLON)?(e=r,t=this.parseName()):t=r,{kind:Td.FIELD,alias:e,name:t,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(fg.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(n)}},t.parseArguments=function(e){var t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(fg.PAREN_L,t,fg.PAREN_R)},t.parseArgument=function(){var e=this._lexer.token,t=this.parseName();return this.expectToken(fg.COLON),{kind:Td.ARGUMENT,name:t,value:this.parseValueLiteral(!1),loc:this.loc(e)}},t.parseConstArgument=function(){var e=this._lexer.token;return{kind:Td.ARGUMENT,name:this.parseName(),value:(this.expectToken(fg.COLON),this.parseValueLiteral(!0)),loc:this.loc(e)}},t.parseFragment=function(){var e=this._lexer.token;this.expectToken(fg.SPREAD);var t=this.expectOptionalKeyword("on");return!t&&this.peek(fg.NAME)?{kind:Td.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(e)}:{kind:Td.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentDefinition=function(){var e,t=this._lexer.token;return this.expectKeyword("fragment"),!0===(null===(e=this._options)||void 0===e?void 0:e.experimentalFragmentVariables)?{kind:Td.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(t)}:{kind:Td.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(t)}},t.parseFragmentName=function(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()},t.parseValueLiteral=function(e){var t=this._lexer.token;switch(t.kind){case fg.BRACKET_L:return this.parseList(e);case fg.BRACE_L:return this.parseObject(e);case fg.INT:return this._lexer.advance(),{kind:Td.INT,value:t.value,loc:this.loc(t)};case fg.FLOAT:return this._lexer.advance(),{kind:Td.FLOAT,value:t.value,loc:this.loc(t)};case fg.STRING:case fg.BLOCK_STRING:return this.parseStringLiteral();case fg.NAME:switch(this._lexer.advance(),t.value){case"true":return{kind:Td.BOOLEAN,value:!0,loc:this.loc(t)};case"false":return{kind:Td.BOOLEAN,value:!1,loc:this.loc(t)};case"null":return{kind:Td.NULL,loc:this.loc(t)};default:return{kind:Td.ENUM,value:t.value,loc:this.loc(t)}}case fg.DOLLAR:if(!e)return this.parseVariable()}throw this.unexpected()},t.parseStringLiteral=function(){var e=this._lexer.token;return this._lexer.advance(),{kind:Td.STRING,value:e.value,block:e.kind===fg.BLOCK_STRING,loc:this.loc(e)}},t.parseList=function(e){var t=this,n=this._lexer.token;return{kind:Td.LIST,values:this.any(fg.BRACKET_L,function(){return t.parseValueLiteral(e)},fg.BRACKET_R),loc:this.loc(n)}},t.parseObject=function(e){var t=this,n=this._lexer.token;return{kind:Td.OBJECT,fields:this.any(fg.BRACE_L,function(){return t.parseObjectField(e)},fg.BRACE_R),loc:this.loc(n)}},t.parseObjectField=function(e){var t=this._lexer.token,n=this.parseName();return this.expectToken(fg.COLON),{kind:Td.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e),loc:this.loc(t)}},t.parseDirectives=function(e){for(var t=[];this.peek(fg.AT);)t.push(this.parseDirective(e));return t},t.parseDirective=function(e){var t=this._lexer.token;return this.expectToken(fg.AT),{kind:Td.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e),loc:this.loc(t)}},t.parseTypeReference=function(){var e,t=this._lexer.token;return this.expectOptionalToken(fg.BRACKET_L)?(e=this.parseTypeReference(),this.expectToken(fg.BRACKET_R),e={kind:Td.LIST_TYPE,type:e,loc:this.loc(t)}):e=this.parseNamedType(),this.expectOptionalToken(fg.BANG)?{kind:Td.NON_NULL_TYPE,type:e,loc:this.loc(t)}:e},t.parseNamedType=function(){var e=this._lexer.token;return{kind:Td.NAMED_TYPE,name:this.parseName(),loc:this.loc(e)}},t.parseTypeSystemDefinition=function(){var e=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(e.kind===fg.NAME)switch(e.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}throw this.unexpected(e)},t.peekDescription=function(){return this.peek(fg.STRING)||this.peek(fg.BLOCK_STRING)},t.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},t.parseSchemaDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("schema");var n=this.parseDirectives(!0),r=this.many(fg.BRACE_L,this.parseOperationTypeDefinition,fg.BRACE_R);return{kind:Td.SCHEMA_DEFINITION,description:t,directives:n,operationTypes:r,loc:this.loc(e)}},t.parseOperationTypeDefinition=function(){var e=this._lexer.token,t=this.parseOperationType();this.expectToken(fg.COLON);var n=this.parseNamedType();return{kind:Td.OPERATION_TYPE_DEFINITION,operation:t,type:n,loc:this.loc(e)}},t.parseScalarTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");var n=this.parseName(),r=this.parseDirectives(!0);return{kind:Td.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");var n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseDirectives(!0),o=this.parseFieldsDefinition();return{kind:Td.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o,loc:this.loc(e)}},t.parseImplementsInterfaces=function(){var e;if(!this.expectOptionalKeyword("implements"))return[];if(!0===(null===(e=this._options)||void 0===e?void 0:e.allowLegacySDLImplementsInterfaces)){var t=[];this.expectOptionalToken(fg.AMP);do{t.push(this.parseNamedType())}while(this.expectOptionalToken(fg.AMP)||this.peek(fg.NAME));return t}return this.delimitedMany(fg.AMP,this.parseNamedType)},t.parseFieldsDefinition=function(){var e;return!0===(null===(e=this._options)||void 0===e?void 0:e.allowLegacySDLEmptyFields)&&this.peek(fg.BRACE_L)&&this._lexer.lookahead().kind===fg.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany(fg.BRACE_L,this.parseFieldDefinition,fg.BRACE_R)},t.parseFieldDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(fg.COLON);var i=this.parseTypeReference(),o=this.parseDirectives(!0);return{kind:Td.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:o,loc:this.loc(e)}},t.parseArgumentDefs=function(){return this.optionalMany(fg.PAREN_L,this.parseInputValueDef,fg.PAREN_R)},t.parseInputValueDef=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(fg.COLON);var r,i=this.parseTypeReference();this.expectOptionalToken(fg.EQUALS)&&(r=this.parseValueLiteral(!0));var o=this.parseDirectives(!0);return{kind:Td.INPUT_VALUE_DEFINITION,description:t,name:n,type:i,defaultValue:r,directives:o,loc:this.loc(e)}},t.parseInterfaceTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");var n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseDirectives(!0),o=this.parseFieldsDefinition();return{kind:Td.INTERFACE_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o,loc:this.loc(e)}},t.parseUnionTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseUnionMemberTypes();return{kind:Td.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i,loc:this.loc(e)}},t.parseUnionMemberTypes=function(){return this.expectOptionalToken(fg.EQUALS)?this.delimitedMany(fg.PIPE,this.parseNamedType):[]},t.parseEnumTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseEnumValuesDefinition();return{kind:Td.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i,loc:this.loc(e)}},t.parseEnumValuesDefinition=function(){return this.optionalMany(fg.BRACE_L,this.parseEnumValueDefinition,fg.BRACE_R)},t.parseEnumValueDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseDirectives(!0);return{kind:Td.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseInputObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseInputFieldsDefinition();return{kind:Td.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInputFieldsDefinition=function(){return this.optionalMany(fg.BRACE_L,this.parseInputValueDef,fg.BRACE_R)},t.parseTypeSystemExtension=function(){var e=this._lexer.lookahead();if(e.kind===fg.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)},t.parseSchemaExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.optionalMany(fg.BRACE_L,this.parseOperationTypeDefinition,fg.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return{kind:Td.SCHEMA_EXTENSION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseScalarTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");var t=this.parseName(),n=this.parseDirectives(!0);if(0===n.length)throw this.unexpected();return{kind:Td.SCALAR_TYPE_EXTENSION,name:t,directives:n,loc:this.loc(e)}},t.parseObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return{kind:Td.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInterfaceTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return{kind:Td.INTERFACE_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i,loc:this.loc(e)}},t.parseUnionTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:Td.UNION_TYPE_EXTENSION,name:t,directives:n,types:r,loc:this.loc(e)}},t.parseEnumTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:Td.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r,loc:this.loc(e)}},t.parseInputObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:Td.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseDirectiveDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(fg.AT);var n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var o=this.parseDirectiveLocations();return{kind:Td.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:o,loc:this.loc(e)}},t.parseDirectiveLocations=function(){return this.delimitedMany(fg.PIPE,this.parseDirectiveLocation)},t.parseDirectiveLocation=function(){var e=this._lexer.token,t=this.parseName();if(void 0!==mg[t.value])return t;throw this.unexpected(e)},t.loc=function(e){var t;if(!0!==(null===(t=this._options)||void 0===t?void 0:t.noLocation))return new Sh(e,this._lexer.lastToken,this._lexer.source)},t.peek=function(e){return this._lexer.token.kind===e},t.expectToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t;throw hg(this._lexer.source,t.start,"Expected ".concat(Ag(e),", found ").concat(Cg(t),"."))},t.expectOptionalToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t},t.expectKeyword=function(e){var t=this._lexer.token;if(t.kind!==fg.NAME||t.value!==e)throw hg(this._lexer.source,t.start,'Expected "'.concat(e,'", found ').concat(Cg(t),"."));this._lexer.advance()},t.expectOptionalKeyword=function(e){var t=this._lexer.token;return t.kind===fg.NAME&&t.value===e&&(this._lexer.advance(),!0)},t.unexpected=function(e){var t=null!=e?e:this._lexer.token;return hg(this._lexer.source,t.start,"Unexpected ".concat(Cg(t),"."))},t.any=function(e,t,n){this.expectToken(e);for(var r=[];!this.expectOptionalToken(n);)r.push(t.call(this));return r},t.optionalMany=function(e,t,n){if(this.expectOptionalToken(e)){var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r}return[]},t.many=function(e,t,n){this.expectToken(e);var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r},t.delimitedMany=function(e,t){this.expectOptionalToken(e);var n=[];do{n.push(t.call(this))}while(this.expectOptionalToken(e));return n},e}();function Cg(e){var t=e.value;return Ag(e.kind)+(null!=t?' "'.concat(t,'"'):"")}function Ag(e){return function(e){return e===fg.BANG||e===fg.DOLLAR||e===fg.AMP||e===fg.PAREN_L||e===fg.PAREN_R||e===fg.SPREAD||e===fg.COLON||e===fg.EQUALS||e===fg.AT||e===fg.BRACKET_L||e===fg.BRACKET_R||e===fg.BRACE_L||e===fg.PIPE||e===fg.BRACE_R}(e)?'"'.concat(e,'"'):e}var Ng=new Map,jg=new Map,Dg=!0,Rg=!1;function Pg(e){return e.replace(/[\s,]+/g," ").trim()}function Bg(e){var t=new Set,n=[];return e.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var r=e.name.value,i=Pg((s=e.loc).source.body.substring(s.start,s.end)),o=jg.get(r);o&&!o.has(i)?Dg&&console.warn("Warning: fragment with name "+r+" already exists.\ngraphql-tag enforces all fragment names across your application to be unique; read more about\nthis in the docs: http://dev.apollodata.com/core/fragments.html#unique-names"):o||jg.set(r,o=new Set),o.add(i),t.has(i)||(t.add(i),n.push(e))}else n.push(e);var s}),Sl(Sl({},e),{definitions:n})}function Fg(e){var t=Pg(e);if(!Ng.has(t)){var n=function(e,t){return new Mg(e,t).parseDocument()}(e,{experimentalFragmentVariables:Rg,allowLegacyFragmentVariables:Rg});if(!n||"Document"!==n.kind)throw new Error("Not a valid GraphQL document.");Ng.set(t,function(e){var t=new Set(e.definitions);t.forEach(function(e){e.loc&&delete e.loc,Object.keys(e).forEach(function(n){var r=e[n];r&&"object"==typeof r&&t.add(r)})});var n=e.loc;return n&&(delete n.startToken,delete n.endToken),e}(Bg(n)))}return Ng.get(t)}function Lg(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];"string"==typeof e&&(e=[e]);var r=e[0];return t.forEach(function(t,n){t&&"Document"===t.kind?r+=t.loc.source.body:r+=t,r+=e[n+1]}),Fg(r)}var Ug,$g=Lg,qg=function(){Ng.clear(),jg.clear()},Vg=function(){Dg=!1},zg=function(){Rg=!0},Kg=function(){Rg=!1};(Ug=Lg||(Lg={})).gql=$g,Ug.resetCaches=qg,Ug.disableFragmentWarnings=Vg,Ug.enableExperimentalFragmentVariables=zg,Ug.disableExperimentalFragmentVariables=Kg,Lg.default=Lg;var Wg=function(){function e(e,t,n,r,i){var o=this;this.observer=e,this.operation=t,this.forward=n,this.delayFor=r,this.retryIf=i,this.retryCount=0,this.currentSubscription=null,this.onError=function(e){return _l(o,void 0,void 0,function(){return Ol(this,function(t){switch(t.label){case 0:return this.retryCount+=1,[4,this.retryIf(this.retryCount,this.operation,e)];case 1:return t.sent()?(this.scheduleRetry(this.delayFor(this.retryCount,this.operation,e)),[2]):(this.observer.error(e),[2])}})})},this.try()}return e.prototype.cancel=function(){this.currentSubscription&&this.currentSubscription.unsubscribe(),clearTimeout(this.timerId),this.timerId=void 0,this.currentSubscription=null},e.prototype.try=function(){var e=this;this.currentSubscription=this.forward(this.operation).subscribe({next:function(t){var n;if(Ud(t))return e.onError(new qd({protocolErrors:t.extensions[Ld]})),void(null===(n=e.currentSubscription)||void 0===n||n.unsubscribe());e.observer.next(t)},error:this.onError,complete:this.observer.complete.bind(this.observer)})},e.prototype.scheduleRetry=function(e){var t=this;if(this.timerId)throw new Error("RetryLink BUG! Encountered overlapping retries");this.timerId=setTimeout(function(){t.timerId=void 0,t.try()},e)},e}(),Qg=function(e){function t(t){var n=e.call(this)||this,r=t||{},i=r.attempts,o=r.delay;return n.delayFor="function"==typeof o?o:function(e){var t=e||{},n=t.initial,r=void 0===n?300:n,i=t.jitter,o=void 0===i||i,s=t.max,a=void 0===s?1/0:s,u=o?r:r/2;return function(e){var t=Math.min(a,u*Math.pow(2,e));return o&&(t=Math.random()*t),t}}(o),n.retryIf="function"==typeof i?i:function(e){var t=e||{},n=t.retryIf,r=t.max,i=void 0===r?5:r;return function(e,t,r){return!(e>=i)&&(n?n(r,t):!!r)}}(i),n}return kl(t,e),t.prototype.request=function(e,t){var n=this;return new mh(function(r){var i=new Wg(r,e,t,n.delayFor,n.retryIf);return function(){i.cancel()}})},t}(Sd);var Gg=function(e){function t(t){var n=e.call(this)||this;return n.client=t,n}return kl(t,e),t.prototype.request=function(e){var t=this;return new mh(function(n){return t.client.subscribe(Sl(Sl({},e),{query:dp(e.query)}),{next:n.next.bind(n),complete:n.complete.bind(n),error:function(e){if(e instanceof Error)return n.error(e);var t,r=gh(t=e)&&"code"in t&&"reason"in t;return r||function(e){var t;return gh(e)&&(null===(t=e.target)||void 0===t?void 0:t.readyState)===WebSocket.CLOSED}(e)?n.error(new Error("Socket closed".concat(r?" with event ".concat(e.code):"").concat(r?" ".concat(e.reason):""))):n.error(new qd({graphQLErrors:Array.isArray(e)?e:[e]}))}})})},t}(Sd),Hg=n(390),Jg=Object.defineProperty,Zg=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)(function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),Yg=(e,t,n)=>(((e,t,n)=>{t in e?Jg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!=typeof t?t+"":t,n),n);function Xg(e){return null===e?"null":Array.isArray(e)?"array":typeof e}function eb(e){return"object"===Xg(e)}function tb(e,t){return e.length<124?e:t}var nb=(e=>(e[e.InternalServerError=4500]="InternalServerError",e[e.InternalClientError=4005]="InternalClientError",e[e.BadRequest=4400]="BadRequest",e[e.BadResponse=4004]="BadResponse",e[e.Unauthorized=4401]="Unauthorized",e[e.Forbidden=4403]="Forbidden",e[e.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",e[e.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",e[e.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",e[e.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",e[e.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests",e))(nb||{}),rb=(e=>(e.ConnectionInit="connection_init",e.ConnectionAck="connection_ack",e.Ping="ping",e.Pong="pong",e.Subscribe="subscribe",e.Next="next",e.Error="error",e.Complete="complete",e))(rb||{});function ib(e){if(!eb(e))throw new Error(`Message is expected to be an object, but got ${Xg(e)}`);if(!e.type)throw new Error("Message is missing the 'type' property");if("string"!=typeof e.type)throw new Error(`Message is expects the 'type' property to be a string, but got ${Xg(e.type)}`);switch(e.type){case"connection_init":case"connection_ack":case"ping":case"pong":if(null!=e.payload&&!eb(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${e.payload}"`);break;case"subscribe":if("string"!=typeof e.id)throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${Xg(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!eb(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${Xg(e.payload)}`);if("string"!=typeof e.payload.query)throw new Error(`"${e.type}" message payload expects the 'query' property to be a string, but got ${Xg(e.payload.query)}`);if(null!=e.payload.variables&&!eb(e.payload.variables))throw new Error(`"${e.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${Xg(e.payload.variables)}`);if(null!=e.payload.operationName&&"string"!==Xg(e.payload.operationName))throw new Error(`"${e.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${Xg(e.payload.operationName)}`);if(null!=e.payload.extensions&&!eb(e.payload.extensions))throw new Error(`"${e.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${Xg(e.payload.extensions)}`);break;case"next":if("string"!=typeof e.id)throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${Xg(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!eb(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${Xg(e.payload)}`);break;case"error":if("string"!=typeof e.id)throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${Xg(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(t=e.payload,!(Array.isArray(t)&&t.length>0&&t.every(e=>"message"in e)))throw new Error(`"${e.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(e.payload)}`);break;case"complete":if("string"!=typeof e.id)throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${Xg(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);break;default:throw new Error(`Invalid message 'type' property "${e.type}"`)}var t;return e}function ob(e,t){return ib(e),JSON.stringify(e,t)}function sb(e){const{url:t,connectionParams:r,lazy:i=!0,onNonLazyError:o=console.error,lazyCloseTimeout:s=0,keepAlive:a=0,disablePong:u,connectionAckWaitTimeout:c=0,retryAttempts:l=5,retryWait:h=async function(e){const t=Math.pow(2,e);await new Promise(e=>setTimeout(e,1e3*t+Math.floor(2700*Math.random()+300)))},shouldRetry:f=ub,on:d,webSocketImpl:p,generateID:y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})},jsonMessageReplacer:m,jsonMessageReviver:g}=e;let b;if(p){if(!("function"==typeof(v=p)&&"constructor"in v&&"CLOSED"in v&&"CLOSING"in v&&"CONNECTING"in v&&"OPEN"in v))throw new Error("Invalid WebSocket implementation provided");b=p}else"undefined"!=typeof WebSocket?b=WebSocket:void 0!==n.g?b=n.g.WebSocket||n.g.MozWebSocket:"undefined"!=typeof window&&(b=window.WebSocket||window.MozWebSocket);var v;if(!b)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");const w=b,E=(()=>{const e=(()=>{const e={};return{on:(t,n)=>(e[t]=n,()=>{delete e[t]}),emit(t){"id"in t&&e[t.id]?.(t)}}})(),t={connecting:d?.connecting?[d.connecting]:[],opened:d?.opened?[d.opened]:[],connected:d?.connected?[d.connected]:[],ping:d?.ping?[d.ping]:[],pong:d?.pong?[d.pong]:[],message:d?.message?[e.emit,d.message]:[e.emit],closed:d?.closed?[d.closed]:[],error:d?.error?[d.error]:[]};return{onMessage:e.on,on(e,n){const r=t[e];return r.push(n),()=>{r.splice(r.indexOf(n),1)}},emit(e,...n){for(const r of[...t[e]])r(...n)}}})();function k(e){const t=[E.on("error",n=>{t.forEach(e=>e()),e(n)}),E.on("closed",n=>{t.forEach(e=>e()),e(n)})]}let S,T,_=0,O=!1,x=0,I=!1;async function M(){clearTimeout(T);const[e,n]=await(S??(S=new Promise((e,n)=>(async()=>{if(O){if(await h(x),!_)return S=void 0,n({code:1e3,reason:"All Subscriptions Gone"});x++}E.emit("connecting",O);const i=new w("function"==typeof t?await t():t,"graphql-transport-ws");let o,s;function l(){isFinite(a)&&a>0&&(clearTimeout(s),s=setTimeout(()=>{i.readyState===w.OPEN&&(i.send(ob({type:rb.Ping})),E.emit("ping",!1,void 0))},a))}k(e=>{S=void 0,clearTimeout(o),clearTimeout(s),n(e),e instanceof ab&&(i.close(4499,"Terminated"),i.onerror=null,i.onclose=null)}),i.onerror=e=>E.emit("error",e),i.onclose=e=>E.emit("closed",e),i.onopen=async()=>{try{E.emit("opened",i);const e="function"==typeof r?await r():r;if(i.readyState!==w.OPEN)return;i.send(ob(e?{type:rb.ConnectionInit,payload:e}:{type:rb.ConnectionInit},m)),isFinite(c)&&c>0&&(o=setTimeout(()=>{i.close(nb.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},c)),l()}catch(e){E.emit("error",e),i.close(nb.InternalClientError,tb(e instanceof Error?e.message:String(e),"Internal client error"))}};let f=!1;i.onmessage=({data:t})=>{try{const n=function(e,t){return ib("string"==typeof e?JSON.parse(e,t):e)}(t,g);if(E.emit("message",n),"ping"===n.type||"pong"===n.type)return E.emit(n.type,!0,n.payload),void("pong"===n.type?l():u||(i.send(ob(n.payload?{type:rb.Pong,payload:n.payload}:{type:rb.Pong})),E.emit("pong",!1,n.payload)));if(f)return;if(n.type!==rb.ConnectionAck)throw new Error(`First message cannot be of type ${n.type}`);clearTimeout(o),f=!0,E.emit("connected",i,n.payload,O),O=!1,x=0,e([i,new Promise((e,t)=>k(t))])}catch(e){i.onmessage=null,E.emit("error",e),i.close(nb.BadResponse,tb(e instanceof Error?e.message:String(e),"Bad response"))}}})())));e.readyState===w.CLOSING&&await n;let i=()=>{};const o=new Promise(e=>i=e);return[e,i,Promise.race([o.then(()=>{if(!_){const t=()=>e.close(1e3,"Normal Closure");isFinite(s)&&s>0?T=setTimeout(()=>{e.readyState===w.OPEN&&t()},s):t()}}),n])]}function C(e){if(ub(e)&&(t=e.code,![1e3,1001,1006,1005,1012,1013,1014].includes(t)&&t>=1e3&&t<=1999||[nb.InternalServerError,nb.InternalClientError,nb.BadRequest,nb.BadResponse,nb.Unauthorized,nb.SubprotocolNotAcceptable,nb.SubscriberAlreadyExists,nb.TooManyInitialisationRequests].includes(e.code)))throw e;var t;if(I)return!1;if(ub(e)&&1e3===e.code)return _>0;if(!l||x>=l)throw e;if(!f(e))throw e;return O=!0}function A(e,t){const n=y(e);let r=!1,i=!1,o=()=>{_--,r=!0};return(async()=>{for(_++;;)try{const[s,a,u]=await M();if(r)return a();const c=E.onMessage(n,e=>{switch(e.type){case rb.Next:return void t.next(e.payload);case rb.Error:return i=!0,r=!0,t.error(e.payload),void o();case rb.Complete:return r=!0,void o()}});return s.send(ob({id:n,type:rb.Subscribe,payload:e},m)),o=()=>{r||s.readyState!==w.OPEN||s.send(ob({id:n,type:rb.Complete},m)),_--,r=!0,a()},void await u.finally(c)}catch(e){if(!C(e))return}})().then(()=>{i||t.complete()}).catch(e=>{t.error(e)}),()=>{r||o()}}return i||(async()=>{for(_++;;)try{const[,,e]=await M();await e}catch(e){try{if(!C(e))return}catch(e){return o?.(e)}}})(),{on:E.on,subscribe:A,iterate(e){const t=[],n={done:!1,error:null,resolve:()=>{}},r=A(e,{next(e){t.push(e),n.resolve()},error(e){n.done=!0,n.error=e,n.resolve()},complete(){n.done=!0,n.resolve()}}),i=async function*(){for(;;){for(t.length||await new Promise(e=>n.resolve=e);t.length;)yield t.shift();if(n.error)throw n.error;if(n.done)return}}();return i.throw=async e=>(n.done||(n.done=!0,n.error=e,n.resolve()),{done:!0,value:void 0}),i.return=async()=>(r(),{done:!0,value:void 0}),i},async dispose(){if(I=!0,S){const[e]=await S;e.close(1e3,"Normal Closure")}},terminate(){S&&E.emit("closed",new ab)}}}var ab=class extends Error{constructor(){super(...arguments),Yg(this,"name","TerminatedCloseEvent"),Yg(this,"message","4499: Terminated"),Yg(this,"code",4499),Yg(this,"reason","Terminated"),Yg(this,"wasClean",!1)}};function ub(e){return eb(e)&&"code"in e&&"reason"in e}function cb(e){switch(e){case"cache-first":default:return"cache-first";case"network-only":return"network-only";case"cache-only":return"cache-only";case"no-cache":return"no-cache";case"standby":return"standby"}}var lb=class{constructor(e){this.parsedTables=new Map,this.uniqueTableNames=new Set,this.currentConfig=e,this.dubheMetadata=e.dubheMetadata,this.dubheMetadata&&this.parseTableInfoFromConfig();const t=Mp({uri:e.endpoint,headers:e.headers,fetch:(t,n)=>fetch(t,{...e.fetchOptions,...n})}),r=new Qg({delay:{initial:e.retryOptions?.delay?.initial||300,max:e.retryOptions?.delay?.max||5e3,jitter:!1!==e.retryOptions?.delay?.jitter},attempts:{max:e.retryOptions?.attempts?.max||5,retryIf:e.retryOptions?.attempts?.retryIf||((e,t)=>Boolean(e&&(e.networkError||e.graphQLErrors&&0===e.graphQLErrors.length)))}}),i=Cp([r,t]);let o=i;if(e.subscriptionEndpoint){let t;try{if("undefined"==typeof window&&void 0!==n.g){const e=Zg("ws");t=e.default||e,void 0===n.g.WebSocket&&(n.g.WebSocket=t)}else t=WebSocket}catch(e){}const r={url:e.subscriptionEndpoint,connectionParams:{headers:e.headers}};t&&"undefined"==typeof window&&(r.webSocketImpl=t),this.subscriptionClient=sb(r);const s=new Gg(this.subscriptionClient);o=Ap(({query:e})=>{const t=_f(e);return"OperationDefinition"===t.kind&&"subscription"===t.operation},s,i)}this.apolloClient=new Vy({link:o,cache:e.cacheConfig?.paginatedTables&&e.cacheConfig.paginatedTables.length>0?new Vm({typePolicies:{Query:{fields:this.buildCacheFields(e.cacheConfig)}}}):new Vm,defaultOptions:{watchQuery:{errorPolicy:"all",notifyOnNetworkStatusChange:!0},query:{errorPolicy:"all"}}})}async updateConfig(e){void 0!==e.endpoint&&(this.currentConfig.endpoint=e.endpoint),void 0!==e.subscriptionEndpoint&&(this.currentConfig.subscriptionEndpoint=e.subscriptionEndpoint),void 0!==e.headers&&(this.currentConfig.headers=e.headers),void 0!==e.fetchOptions&&(this.currentConfig.fetchOptions=e.fetchOptions),void 0!==e.retryOptions&&(this.currentConfig.retryOptions=e.retryOptions),void 0!==e.cacheConfig&&(this.currentConfig.cacheConfig=e.cacheConfig),void 0!==e.dubheMetadata&&(this.dubheMetadata=e.dubheMetadata,this.parsedTables.clear(),this.uniqueTableNames.clear(),this.dubheMetadata&&this.parseTableInfoFromConfig());const t=void 0!==e.endpoint,r=void 0!==e.subscriptionEndpoint;if(t||r){if(this.subscriptionClient){try{await this.subscriptionClient.dispose()}catch(e){console.error("Error disposing subscription client:",e)}this.subscriptionClient=void 0}const e=Mp({uri:this.currentConfig.endpoint,headers:this.currentConfig.headers,fetch:(e,t)=>fetch(e,{...this.currentConfig.fetchOptions,...t})}),t=new Qg({delay:{initial:this.currentConfig.retryOptions?.delay?.initial||300,max:this.currentConfig.retryOptions?.delay?.max||5e3,jitter:!1!==this.currentConfig.retryOptions?.delay?.jitter},attempts:{max:this.currentConfig.retryOptions?.attempts?.max||5,retryIf:this.currentConfig.retryOptions?.attempts?.retryIf||((e,t)=>Boolean(e&&(e.networkError||e.graphQLErrors&&0===e.graphQLErrors.length)))}}),r=Cp([t,e]);let i=r;if(this.currentConfig.subscriptionEndpoint){let e;try{if("undefined"==typeof window&&void 0!==n.g){const t=Zg("ws");e=t.default||t,void 0===n.g.WebSocket&&(n.g.WebSocket=e)}else e=WebSocket}catch(e){}const t={url:this.currentConfig.subscriptionEndpoint,connectionParams:{headers:this.currentConfig.headers}};e&&"undefined"==typeof window&&(t.webSocketImpl=e),this.subscriptionClient=sb(t);const o=new Gg(this.subscriptionClient);i=Ap(({query:e})=>{const t=_f(e);return"OperationDefinition"===t.kind&&"subscription"===t.operation},o,r)}const o=this.apolloClient.cache;this.apolloClient=new Vy({link:i,cache:this.currentConfig.cacheConfig?.paginatedTables&&this.currentConfig.cacheConfig.paginatedTables.length>0?new Vm({typePolicies:{Query:{fields:this.buildCacheFields(this.currentConfig.cacheConfig)}}}):new Vm,defaultOptions:{watchQuery:{errorPolicy:"all",notifyOnNetworkStatusChange:!0},query:{errorPolicy:"all"}}});try{this.apolloClient.cache.restore(o.extract())}catch(e){console.error("Error restoring cache:",e)}}}async query(e,t,n){try{const r=await this.apolloClient.query({query:e,variables:t,fetchPolicy:n?.cachePolicy?cb(n.cachePolicy):"no-cache",notifyOnNetworkStatusChange:n?.notifyOnNetworkStatusChange,pollInterval:n?.pollInterval});return{data:r.data,loading:r.loading,error:r.error,networkStatus:r.networkStatus,refetch:()=>this.query(e,t,n)}}catch(r){return{data:void 0,loading:!1,error:r,networkStatus:8,refetch:()=>this.query(e,t,n)}}}subscribe(e,t,n){return new mh(r=>{const i=this.apolloClient.subscribe({query:e,variables:t}).subscribe({next:e=>{const t={data:e.data,loading:!1,error:e.errors?.[0]};r.next(t),n?.onData?.(e.data)},error:e=>{const t={data:void 0,loading:!1,error:e};r.next(t),n?.onError?.(e)},complete:()=>{r.complete(),n?.onComplete?.()}});return()=>i.unsubscribe()})}async getAllTables(e,t){const n=this.getPluralTableName(e),r=hb(t?.orderBy),i=Lg`
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("ObeliskClient",[],t):"object"==typeof exports?exports.ObeliskClient=t():e.ObeliskClient=t()}(this,()=>(()=>{var e={20:(e,t,n)=>{"use strict";function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach(function(t){o(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function o(e,t,n){return(t=a(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,a(r.key),r)}}function a(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var u=n(533).Buffer,c=n(541).inspect,l=c&&c.custom||"inspect";function h(e,t,n){u.prototype.copy.call(e,t,n)}e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}var t,n,r;return t=e,(n=[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return u.alloc(0);for(var t=u.allocUnsafe(e>>>0),n=this.head,r=0;n;)h(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:"consume",value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var i=t.data,o=e>i.length?i.length:e;if(o===i.length?r+=i:r+=i.slice(0,e),0===(e-=o)){o===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=u.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var i=n.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0===(e-=o)){o===i.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=i.slice(o));break}++r}return this.length-=r,t}},{key:l,value:function(e,t){return c(this,i(i({},t),{},{depth:0,customInspect:!1}))}}])&&s(t.prototype,n),r&&s(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}()},33:(e,t,n)=>{"use strict";var r;e.exports=T,T.ReadableState=S;n(381).EventEmitter;var i=function(e,t){return e.listeners(t).length},o=n(534),s=n(533).Buffer,a=(void 0!==n.g?n.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var u,c=n(429);u=c&&c.debuglog?c.debuglog("stream"):function(){};var l,h,f,d=n(20),p=n(917),y=n(750).getHighWaterMark,m=n(289).F,g=m.ERR_INVALID_ARG_TYPE,b=m.ERR_STREAM_PUSH_AFTER_EOF,v=m.ERR_METHOD_NOT_IMPLEMENTED,w=m.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(193)(T,o);var E=p.errorOrDestroy,k=["error","close","destroy","pause","resume"];function S(e,t,i){r=r||n(707),e=e||{},"boolean"!=typeof i&&(i=t instanceof r),this.objectMode=!!e.objectMode,i&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=y(this,e,"readableHighWaterMark",i),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(l||(l=n(704).I),this.decoder=new l(e.encoding),this.encoding=e.encoding)}function T(e){if(r=r||n(707),!(this instanceof T))return new T(e);var t=this instanceof r;this._readableState=new S(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),o.call(this)}function _(e,t,n,r,i){u("readableAddChunk",t);var o,c=e._readableState;if(null===t)c.reading=!1,function(e,t){if(u("onEofChunk"),t.ended)return;if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.sync?C(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,M(e)))}(e,c);else if(i||(o=function(e,t){var n;r=t,s.isBuffer(r)||r instanceof a||"string"==typeof t||void 0===t||e.objectMode||(n=new g("chunk",["string","Buffer","Uint8Array"],t));var r;return n}(c,t)),o)E(e,o);else if(c.objectMode||t&&t.length>0)if("string"==typeof t||c.objectMode||Object.getPrototypeOf(t)===s.prototype||(t=function(e){return s.from(e)}(t)),r)c.endEmitted?E(e,new w):x(e,c,t,!0);else if(c.ended)E(e,new b);else{if(c.destroyed)return!1;c.reading=!1,c.decoder&&!n?(t=c.decoder.write(t),c.objectMode||0!==t.length?x(e,c,t,!1):A(e,c)):x(e,c,t,!1)}else r||(c.reading=!1,A(e,c));return!c.ended&&(c.length<c.highWaterMark||0===c.length)}function x(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&C(e)),A(e,t)}Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),T.prototype.destroy=p.destroy,T.prototype._undestroy=p.undestroy,T.prototype._destroy=function(e,t){t(e)},T.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=s.from(e,t),t=""),n=!0),_(this,e,t,!1,n)},T.prototype.unshift=function(e){return _(this,e,null,!0,!1)},T.prototype.isPaused=function(){return!1===this._readableState.flowing},T.prototype.setEncoding=function(e){l||(l=n(704).I);var t=new l(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,i="";null!==r;)i+=t.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var O=1073741824;function I(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=O?e=O:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function C(e){var t=e._readableState;u("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(u("emitReadable",t.flowing),t.emittedReadable=!0,process.nextTick(M,e))}function M(e){var t=e._readableState;u("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,P(e)}function A(e,t){t.readingMore||(t.readingMore=!0,process.nextTick(N,e,t))}function N(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var n=t.length;if(u("maybeReadMore read 0"),e.read(0),n===t.length)break}t.readingMore=!1}function j(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function D(e){u("readable nexttick read 0"),e.read(0)}function R(e,t){u("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),P(e),t.flowing&&!t.reading&&e.read(0)}function P(e){var t=e._readableState;for(u("flow",t.flowing);t.flowing&&null!==e.read(););}function B(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function F(e){var t=e._readableState;u("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,process.nextTick(U,t,e))}function U(e,t){if(u("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}function L(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}T.prototype.read=function(e){u("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return u("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?F(this):C(this),null;if(0===(e=I(e,t))&&t.ended)return 0===t.length&&F(this),null;var r,i=t.needReadable;return u("need readable",i),(0===t.length||t.length-e<t.highWaterMark)&&u("length less than watermark",i=!0),t.ended||t.reading?u("reading or ended",i=!1):i&&(u("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=I(n,t))),null===(r=e>0?B(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&F(this)),null!==r&&this.emit("data",r),r},T.prototype._read=function(e){E(this,new v("_read()"))},T.prototype.pipe=function(e,t){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e)}r.pipesCount+=1,u("pipe count=%d opts=%j",r.pipesCount,t);var o=(!t||!1!==t.end)&&e!==process.stdout&&e!==process.stderr?a:y;function s(t,i){u("onunpipe"),t===n&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,u("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",c),e.removeListener("error",f),e.removeListener("unpipe",s),n.removeListener("end",a),n.removeListener("end",y),n.removeListener("data",h),l=!0,!r.awaitDrain||e._writableState&&!e._writableState.needDrain||c())}function a(){u("onend"),e.end()}r.endEmitted?process.nextTick(o):n.once("end",o),e.on("unpipe",s);var c=function(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&i(e,"data")&&(t.flowing=!0,P(e))}}(n);e.on("drain",c);var l=!1;function h(t){u("ondata");var i=e.write(t);u("dest.write",i),!1===i&&((1===r.pipesCount&&r.pipes===e||r.pipesCount>1&&-1!==L(r.pipes,e))&&!l&&(u("false write response, pause",r.awaitDrain),r.awaitDrain++),n.pause())}function f(t){u("onerror",t),y(),e.removeListener("error",f),0===i(e,"error")&&E(e,t)}function d(){e.removeListener("finish",p),y()}function p(){u("onfinish"),e.removeListener("close",d),y()}function y(){u("unpipe"),n.unpipe(e)}return n.on("data",h),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",f),e.once("close",d),e.once("finish",p),e.emit("pipe",n),r.flowing||(u("pipe resume"),n.resume()),e},T.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)r[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=L(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n)),this},T.prototype.on=function(e,t){var n=o.prototype.on.call(this,e,t),r=this._readableState;return"data"===e?(r.readableListening=this.listenerCount("readable")>0,!1!==r.flowing&&this.resume()):"readable"===e&&(r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,u("on readable",r.length,r.reading),r.length?C(this):r.reading||process.nextTick(D,this))),n},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(e,t){var n=o.prototype.removeListener.call(this,e,t);return"readable"===e&&process.nextTick(j,this),n},T.prototype.removeAllListeners=function(e){var t=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||process.nextTick(j,this),t},T.prototype.resume=function(){var e=this._readableState;return e.flowing||(u("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,process.nextTick(R,e,t))}(this,e)),e.paused=!1,this},T.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},T.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on("end",function(){if(u("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(i){(u("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(t.push(i)||(r=!0,e.pause()))}),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o<k.length;o++)e.on(k[o],this.emit.bind(this,k[o]));return this._read=function(t){u("wrapped _read",t),r&&(r=!1,e.resume())},this},"function"==typeof Symbol&&(T.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=n(536)),h(this)}),Object.defineProperty(T.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(T.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(T.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),T._fromList=B,Object.defineProperty(T.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(T.from=function(e,t){return void 0===f&&(f=n(918)),f(T,e,t)})},94:(e,t,n)=>{(t=e.exports=n(33)).Stream=t,t.Readable=t,t.Writable=n(553),t.Duplex=n(707),t.Transform=n(141),t.PassThrough=n(271),t.finished=n(339),t.pipeline=n(481)},102:(e,t,n)=>{const{Transform:r}=n(94);e.exports=e=>class t extends r{constructor(t,n,r,i){super(i),this._rate=t,this._capacity=n,this._delimitedSuffix=r,this._options=i,this._state=new e,this._state.initialize(t,n),this._finalized=!1}_transform(e,t,n){let r=null;try{this.update(e,t)}catch(e){r=e}n(r)}_flush(){}_read(e){this.push(this.squeeze(e))}update(e,t){if(!Buffer.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Squeeze already called");return Buffer.isBuffer(e)||(e=Buffer.from(e,t)),this._state.absorb(e),this}squeeze(e,t){this._finalized||(this._finalized=!0,this._state.absorbLastFewBits(this._delimitedSuffix));let n=this._state.squeeze(e);return void 0!==t&&(n=n.toString(t)),n}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const e=new t(this._rate,this._capacity,this._delimitedSuffix,this._options);return this._state.copy(e._state),e._finalized=this._finalized,e}}},141:(e,t,n)=>{"use strict";e.exports=l;var r=n(289).F,i=r.ERR_METHOD_NOT_IMPLEMENTED,o=r.ERR_MULTIPLE_CALLBACK,s=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=r.ERR_TRANSFORM_WITH_LENGTH_0,u=n(707);function c(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new o);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function l(e){if(!(this instanceof l))return new l(e);u.call(this,e),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",h)}function h(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?f(this,null,null):this._flush(function(t,n){f(e,t,n)})}function f(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}n(193)(l,u),l.prototype.push=function(e,t){return this._transformState.needTransform=!1,u.prototype.push.call(this,e,t)},l.prototype._transform=function(e,t,n){n(new i("_transform()"))},l.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},l.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},l.prototype._destroy=function(e,t){u.prototype._destroy.call(this,e,function(e){t(e)})}},193:e=>{"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},217:(e,t,n)=>{const r=n(302);function i(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}i.prototype.initialize=function(e,t){for(let e=0;e<50;++e)this.state[e]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1},i.prototype.absorb=function(e){for(let t=0;t<e.length;++t)this.state[~~(this.count/4)]^=e[t]<<this.count%4*8,this.count+=1,this.count===this.blockSize&&(r.p1600(this.state),this.count=0)},i.prototype.absorbLastFewBits=function(e){this.state[~~(this.count/4)]^=e<<this.count%4*8,128&e&&this.count===this.blockSize-1&&r.p1600(this.state),this.state[~~((this.blockSize-1)/4)]^=128<<(this.blockSize-1)%4*8,r.p1600(this.state),this.count=0,this.squeezing=!0},i.prototype.squeeze=function(e){this.squeezing||this.absorbLastFewBits(1);const t=Buffer.alloc(e);for(let n=0;n<e;++n)t[n]=this.state[~~(this.count/4)]>>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(r.p1600(this.state),this.count=0);return t},i.prototype.copy=function(e){for(let t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing},e.exports=i},271:(e,t,n)=>{"use strict";e.exports=i;var r=n(141);function i(e){if(!(this instanceof i))return new i(e);r.call(this,e)}n(193)(i,r),i.prototype._transform=function(e,t,n){n(null,e)}},289:e=>{"use strict";var t={};function n(e,n,r){r||(r=Error);var i=function(e){var t,r;function i(t,r,i){return e.call(this,function(e,t,r){return"string"==typeof n?n:n(e,t,r)}(t,r,i))||this}return r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r,i}(r);i.prototype.name=r.name,i.prototype.code=e,t[e]=i}function r(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map(function(e){return String(e)}),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}n("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError),n("ERR_INVALID_ARG_TYPE",function(e,t,n){var i,o,s,a;if("string"==typeof t&&(o="not ",t.substr(!s||s<0?0:+s,o.length)===o)?(i="must not be",t=t.replace(/^not /,"")):i="must be",function(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}(e," argument"))a="The ".concat(e," ").concat(i," ").concat(r(t,"type"));else{var u=function(e,t,n){return"number"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}(e,".")?"property":"argument";a='The "'.concat(e,'" ').concat(u," ").concat(i," ").concat(r(t,"type"))}return a+=". Received type ".concat(typeof n)},TypeError),n("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),n("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),n("ERR_STREAM_PREMATURE_CLOSE","Premature close"),n("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),n("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),n("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),n("ERR_STREAM_WRITE_AFTER_END","write after end"),n("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),n("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),n("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.F=t},302:(e,t)=>{const n=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648];t.p1600=function(e){for(let t=0;t<24;++t){const r=e[0]^e[10]^e[20]^e[30]^e[40],i=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],s=e[3]^e[13]^e[23]^e[33]^e[43],a=e[4]^e[14]^e[24]^e[34]^e[44],u=e[5]^e[15]^e[25]^e[35]^e[45],c=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],h=e[8]^e[18]^e[28]^e[38]^e[48],f=e[9]^e[19]^e[29]^e[39]^e[49];let d=h^(o<<1|s>>>31),p=f^(s<<1|o>>>31);const y=e[0]^d,m=e[1]^p,g=e[10]^d,b=e[11]^p,v=e[20]^d,w=e[21]^p,E=e[30]^d,k=e[31]^p,S=e[40]^d,T=e[41]^p;d=r^(a<<1|u>>>31),p=i^(u<<1|a>>>31);const _=e[2]^d,x=e[3]^p,O=e[12]^d,I=e[13]^p,C=e[22]^d,M=e[23]^p,A=e[32]^d,N=e[33]^p,j=e[42]^d,D=e[43]^p;d=o^(c<<1|l>>>31),p=s^(l<<1|c>>>31);const R=e[4]^d,P=e[5]^p,B=e[14]^d,F=e[15]^p,U=e[24]^d,L=e[25]^p,q=e[34]^d,$=e[35]^p,V=e[44]^d,z=e[45]^p;d=a^(h<<1|f>>>31),p=u^(f<<1|h>>>31);const K=e[6]^d,W=e[7]^p,Q=e[16]^d,G=e[17]^p,H=e[26]^d,J=e[27]^p,Z=e[36]^d,Y=e[37]^p,X=e[46]^d,ee=e[47]^p;d=c^(r<<1|i>>>31),p=l^(i<<1|r>>>31);const te=e[8]^d,ne=e[9]^p,re=e[18]^d,ie=e[19]^p,oe=e[28]^d,se=e[29]^p,ae=e[38]^d,ue=e[39]^p,ce=e[48]^d,le=e[49]^p,he=y,fe=m,de=b<<4|g>>>28,pe=g<<4|b>>>28,ye=v<<3|w>>>29,me=w<<3|v>>>29,ge=k<<9|E>>>23,be=E<<9|k>>>23,ve=S<<18|T>>>14,we=T<<18|S>>>14,Ee=_<<1|x>>>31,ke=x<<1|_>>>31,Se=I<<12|O>>>20,Te=O<<12|I>>>20,_e=C<<10|M>>>22,xe=M<<10|C>>>22,Oe=N<<13|A>>>19,Ie=A<<13|N>>>19,Ce=j<<2|D>>>30,Me=D<<2|j>>>30,Ae=P<<30|R>>>2,Ne=R<<30|P>>>2,je=B<<6|F>>>26,De=F<<6|B>>>26,Re=L<<11|U>>>21,Pe=U<<11|L>>>21,Be=q<<15|$>>>17,Fe=$<<15|q>>>17,Ue=z<<29|V>>>3,Le=V<<29|z>>>3,qe=K<<28|W>>>4,$e=W<<28|K>>>4,Ve=G<<23|Q>>>9,ze=Q<<23|G>>>9,Ke=H<<25|J>>>7,We=J<<25|H>>>7,Qe=Z<<21|Y>>>11,Ge=Y<<21|Z>>>11,He=ee<<24|X>>>8,Je=X<<24|ee>>>8,Ze=te<<27|ne>>>5,Ye=ne<<27|te>>>5,Xe=re<<20|ie>>>12,et=ie<<20|re>>>12,tt=se<<7|oe>>>25,nt=oe<<7|se>>>25,rt=ae<<8|ue>>>24,it=ue<<8|ae>>>24,ot=ce<<14|le>>>18,st=le<<14|ce>>>18;e[0]=he^~Se&Re,e[1]=fe^~Te&Pe,e[10]=qe^~Xe&ye,e[11]=$e^~et&me,e[20]=Ee^~je&Ke,e[21]=ke^~De&We,e[30]=Ze^~de&_e,e[31]=Ye^~pe&xe,e[40]=Ae^~Ve&tt,e[41]=Ne^~ze&nt,e[2]=Se^~Re&Qe,e[3]=Te^~Pe&Ge,e[12]=Xe^~ye&Oe,e[13]=et^~me&Ie,e[22]=je^~Ke&rt,e[23]=De^~We&it,e[32]=de^~_e&Be,e[33]=pe^~xe&Fe,e[42]=Ve^~tt&ge,e[43]=ze^~nt&be,e[4]=Re^~Qe&ot,e[5]=Pe^~Ge&st,e[14]=ye^~Oe&Ue,e[15]=me^~Ie&Le,e[24]=Ke^~rt&ve,e[25]=We^~it&we,e[34]=_e^~Be&He,e[35]=xe^~Fe&Je,e[44]=tt^~ge&Ce,e[45]=nt^~be&Me,e[6]=Qe^~ot&he,e[7]=Ge^~st&fe,e[16]=Oe^~Ue&qe,e[17]=Ie^~Le&$e,e[26]=rt^~ve&Ee,e[27]=it^~we&ke,e[36]=Be^~He&Ze,e[37]=Fe^~Je&Ye,e[46]=ge^~Ce&Ae,e[47]=be^~Me&Ne,e[8]=ot^~he&Se,e[9]=st^~fe&Te,e[18]=Ue^~qe&Xe,e[19]=Le^~$e&et,e[28]=ve^~Ee&je,e[29]=we^~ke&De,e[38]=He^~Ze&de,e[39]=Je^~Ye&pe,e[48]=Ce^~Ae&Ve,e[49]=Me^~Ne&ze,e[0]^=n[2*t],e[1]^=n[2*t+1]}}},316:(e,t,n)=>{const{Transform:r}=n(94);e.exports=e=>class t extends r{constructor(t,n,r,i,o){super(o),this._rate=t,this._capacity=n,this._delimitedSuffix=r,this._hashBitLength=i,this._options=o,this._state=new e,this._state.initialize(t,n),this._finalized=!1}_transform(e,t,n){let r=null;try{this.update(e,t)}catch(e){r=e}n(r)}_flush(e){let t=null;try{this.push(this.digest())}catch(e){t=e}e(t)}update(e,t){if(!Buffer.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Digest already called");return Buffer.isBuffer(e)||(e=Buffer.from(e,t)),this._state.absorb(e),this}digest(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0,this._delimitedSuffix&&this._state.absorbLastFewBits(this._delimitedSuffix);let t=this._state.squeeze(this._hashBitLength/8);return void 0!==e&&(t=t.toString(e)),this._resetState(),t}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const e=new t(this._rate,this._capacity,this._delimitedSuffix,this._hashBitLength,this._options);return this._state.copy(e._state),e._finalized=this._finalized,e}}},328:(e,t)=>{t.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,u=(1<<a)-1,c=u>>1,l=-7,h=n?i-1:0,f=n?-1:1,d=e[t+h];for(h+=f,o=d&(1<<-l)-1,d>>=-l,l+=a;l>0;o=256*o+e[t+h],h+=f,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=256*s+e[t+h],h+=f,l-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),o-=c}return(d?-1:1)*s*Math.pow(2,o-r)},t.write=function(e,t,n,r,i,o){var s,a,u,c=8*o-i-1,l=(1<<c)-1,h=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,p=r?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+h>=1?f/u:f*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(t*u-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[n+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;e[n+d]=255&s,d+=p,s/=256,c-=8);e[n+d-p]|=128*y}},339:(e,t,n)=>{"use strict";var r=n(289).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}e.exports=function e(t,n,o){if("function"==typeof n)return e(t,null,n);n||(n={}),o=function(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];e.apply(this,r)}}}(o||i);var s=n.readable||!1!==n.readable&&t.readable,a=n.writable||!1!==n.writable&&t.writable,u=function(){t.writable||l()},c=t._writableState&&t._writableState.finished,l=function(){a=!1,c=!0,s||o.call(t)},h=t._readableState&&t._readableState.endEmitted,f=function(){s=!1,h=!0,a||o.call(t)},d=function(e){o.call(t,e)},p=function(){var e;return s&&!h?(t._readableState&&t._readableState.ended||(e=new r),o.call(t,e)):a&&!c?(t._writableState&&t._writableState.ended||(e=new r),o.call(t,e)):void 0},y=function(){t.req.on("finish",l)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(t)?a&&!t._writableState&&(t.on("end",u),t.on("close",u)):(t.on("complete",l),t.on("abort",p),t.req?y():t.on("request",y)),t.on("end",f),t.on("finish",l),!1!==n.error&&t.on("error",d),t.on("close",p),function(){t.removeListener("complete",l),t.removeListener("abort",p),t.removeListener("request",y),t.req&&t.req.removeListener("finish",l),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",l),t.removeListener("end",f),t.removeListener("error",d),t.removeListener("close",p)}}},381:e=>{"use strict";var t,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,o),r(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}y(e,t,o,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&y(e,"error",t,n)}(e,i,{once:!0})})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function c(e,t,n,r){var i,o,s,c;if(a(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]),void 0===s)s=o[t]=n,++e._eventsCount;else if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(i=u(e))>0&&s.length>i&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,c=l,console&&console.warn&&console.warn(c)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=l.bind(r);return i.listener=n,r.wrapFn=i,i}function f(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):p(i,i.length)}function d(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function p(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function y(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function i(o){r.once&&e.removeEventListener(t,i),n(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=o[e];if(void 0===u)return!1;if("function"==typeof u)r(u,this,t);else{var c=u.length,l=p(u,c);for(n=0;n<c;++n)r(l[n],this,t)}return!0},o.prototype.addListener=function(e,t){return c(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return c(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,h(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,h(this,e,t)),this},o.prototype.removeListener=function(e,t){var n,r,i,o,s;if(a(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},o.prototype.listeners=function(e){return f(this,e,!0)},o.prototype.rawListeners=function(e){return f(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},o.prototype.listenerCount=d,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},390:function(e){e.exports=function(){var e=[],t=[],n={},r={},i={};function o(e){return"string"==typeof e?new RegExp("^"+e+"$","i"):e}function s(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function a(e,t){return e.replace(/\$(\d{1,2})/g,function(e,n){return t[n]||""})}function u(e,t){return e.replace(t[0],function(n,r){var i=a(t[1],arguments);return s(""===n?e[r-1]:n,i)})}function c(e,t,r){if(!e.length||n.hasOwnProperty(e))return t;for(var i=r.length;i--;){var o=r[i];if(o[0].test(t))return u(t,o)}return t}function l(e,t,n){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?s(r,i):e.hasOwnProperty(i)?s(r,e[i]):c(i,r,n)}}function h(e,t,n,r){return function(r){var i=r.toLowerCase();return!!t.hasOwnProperty(i)||!e.hasOwnProperty(i)&&c(i,i,n)===i}}function f(e,t,n){return(n?t+" ":"")+(1===t?f.singular(e):f.plural(e))}return f.plural=l(i,r,e),f.isPlural=h(i,r,e),f.singular=l(r,i,t),f.isSingular=h(r,i,t),f.addPluralRule=function(t,n){e.push([o(t),n])},f.addSingularRule=function(e,n){t.push([o(e),n])},f.addUncountableRule=function(e){"string"!=typeof e?(f.addPluralRule(e,"$0"),f.addSingularRule(e,"$0")):n[e.toLowerCase()]=!0},f.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),i[e]=t,r[t]=e},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach(function(e){return f.addIrregularRule(e[0],e[1])}),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach(function(e){return f.addPluralRule(e[0],e[1])}),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/\b((?:tit)?m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach(function(e){return f.addSingularRule(e[0],e[1])}),["adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(f.addUncountableRule),f}()},429:()=>{},481:(e,t,n)=>{"use strict";var r;var i=n(289).F,o=i.ERR_MISSING_ARGS,s=i.ERR_STREAM_DESTROYED;function a(e){if(e)throw e}function u(e){e()}function c(e,t){return e.pipe(t)}e.exports=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];var l,h=function(e){return e.length?"function"!=typeof e[e.length-1]?a:e.pop():a}(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new o("streams");var f=t.map(function(e,i){var o=i<t.length-1;return function(e,t,i,o){o=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(o);var a=!1;e.on("close",function(){a=!0}),void 0===r&&(r=n(339)),r(e,{readable:t,writable:i},function(e){if(e)return o(e);a=!0,o()});var u=!1;return function(t){if(!a&&!u)return u=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void o(t||new s("pipe"))}}(e,o,i>0,function(e){l||(l=e),e&&f.forEach(u),o||(f.forEach(u),h(l))})});return t.reduce(c)}},533:(e,t,n)=>{"use strict";const r=n(933),i=n(328),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=u,t.SlowBuffer=function(e){+e!=e&&(e=0);return u.alloc(+e)},t.INSPECT_MAX_BYTES=50;const s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,u.prototype),t}function u(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return c(e,t,n)}function c(e,t,n){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!u.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const n=0|y(e,t);let r=a(n);const i=r.write(e,t);i!==n&&(r=r.slice(0,i));return r}(e,t);if(ArrayBuffer.isView(e))return function(e){if(H(e,Uint8Array)){const t=new Uint8Array(e);return d(t.buffer,t.byteOffset,t.byteLength)}return f(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(H(e,ArrayBuffer)||e&&H(e.buffer,ArrayBuffer))return d(e,t,n);if("undefined"!=typeof SharedArrayBuffer&&(H(e,SharedArrayBuffer)||e&&H(e.buffer,SharedArrayBuffer)))return d(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return u.from(r,t,n);const i=function(e){if(u.isBuffer(e)){const t=0|p(e.length),n=a(t);return 0===n.length||e.copy(n,0,0,t),n}if(void 0!==e.length)return"number"!=typeof e.length||J(e.length)?a(0):f(e);if("Buffer"===e.type&&Array.isArray(e.data))return f(e.data)}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return u.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return l(e),a(e<0?0:0|p(e))}function f(e){const t=e.length<0?0:0|p(e.length),n=a(t);for(let r=0;r<t;r+=1)n[r]=255&e[r];return n}function d(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===t&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,t):new Uint8Array(e,t,n),Object.setPrototypeOf(r,u.prototype),r}function p(e){if(e>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function y(e,t){if(u.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||H(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const n=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return W(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Q(e).length;default:if(i)return r?-1:W(e).length;t=(""+t).toLowerCase(),i=!0}}function m(e,t,n){let r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return M(this,t,n);case"utf8":case"utf-8":return x(this,t,n);case"ascii":return I(this,t,n);case"latin1":case"binary":return C(this,t,n);case"base64":return _(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function g(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function b(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),J(n=+n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=u.from(t,r)),u.isBuffer(t))return 0===t.length?-1:v(e,t,n,r,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):v(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function v(e,t,n,r,i){let o,s=1,a=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,n/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){let r=-1;for(o=n;o<a;o++)if(c(e,o)===c(t,-1===r?0:o-r)){if(-1===r&&(r=o),o-r+1===u)return r*s}else-1!==r&&(o-=o-r),r=-1}else for(n+u>a&&(n=a-u),o=n;o>=0;o--){let n=!0;for(let r=0;r<u;r++)if(c(e,o+r)!==c(t,r)){n=!1;break}if(n)return o}return-1}function w(e,t,n,r){n=Number(n)||0;const i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;const o=t.length;let s;for(r>o/2&&(r=o/2),s=0;s<r;++s){const r=parseInt(t.substr(2*s,2),16);if(J(r))return s;e[n+s]=r}return s}function E(e,t,n,r){return G(W(t,e.length-n),e,n,r)}function k(e,t,n,r){return G(function(e){const t=[];for(let n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function S(e,t,n,r){return G(Q(t),e,n,r)}function T(e,t,n,r){return G(function(e,t){let n,r,i;const o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)n=e.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function _(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function x(e,t,n){n=Math.min(e.length,n);const r=[];let i=t;for(;i<n;){const t=e[i];let o=null,s=t>239?4:t>223?3:t>191?2:1;if(i+s<=n){let n,r,a,u;switch(s){case 1:t<128&&(o=t);break;case 2:n=e[i+1],128==(192&n)&&(u=(31&t)<<6|63&n,u>127&&(o=u));break;case 3:n=e[i+1],r=e[i+2],128==(192&n)&&128==(192&r)&&(u=(15&t)<<12|(63&n)<<6|63&r,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:n=e[i+1],r=e[i+2],a=e[i+3],128==(192&n)&&128==(192&r)&&128==(192&a)&&(u=(15&t)<<18|(63&n)<<12|(63&r)<<6|63&a,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o),i+=s}return function(e){const t=e.length;if(t<=O)return String.fromCharCode.apply(String,e);let n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=O));return n}(r)}t.kMaxLength=s,u.TYPED_ARRAY_SUPPORT=function(){try{const e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(e,t,n){return c(e,t,n)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(e,t,n){return function(e,t,n){return l(e),e<=0?a(e):void 0!==t?"string"==typeof n?a(e).fill(t,n):a(e).fill(t):a(e)}(e,t,n)},u.allocUnsafe=function(e){return h(e)},u.allocUnsafeSlow=function(e){return h(e)},u.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==u.prototype},u.compare=function(e,t){if(H(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),H(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);let n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;const r=u.allocUnsafe(t);let i=0;for(n=0;n<e.length;++n){let t=e[n];if(H(t,Uint8Array))i+t.length>r.length?(u.isBuffer(t)||(t=u.from(t)),t.copy(r,i)):Uint8Array.prototype.set.call(r,t,i);else{if(!u.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(r,i)}i+=t.length}return r},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)g(this,t,t+1);return this},u.prototype.swap32=function(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},u.prototype.swap64=function(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},u.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?x(this,0,e):m.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){let e="";const n=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(e+=" ... "),"<Buffer "+e+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(e,t,n,r,i){if(H(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;let o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0);const a=Math.min(o,s),c=this.slice(r,i),l=e.slice(t,n);for(let e=0;e<a;++e)if(c[e]!==l[e]){o=c[e],s=l[e];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},u.prototype.indexOf=function(e,t,n){return b(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return b(this,e,t,n,!1)},u.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let o=!1;for(;;)switch(r){case"hex":return w(this,e,t,n);case"utf8":case"utf-8":return E(this,e,t,n);case"ascii":case"latin1":case"binary":return k(this,e,t,n);case"base64":return S(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const O=4096;function I(e,t,n){let r="";n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function C(e,t,n){let r="";n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function M(e,t,n){const r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i="";for(let r=t;r<n;++r)i+=Z[e[r]];return i}function A(e,t,n){const r=e.slice(t,n);let i="";for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+256*r[e+1]);return i}function N(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function j(e,t,n,r,i,o){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function D(e,t,n,r,i){$(t,r,i,e,n,7);let o=Number(t&BigInt(4294967295));e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=s,s>>=8,e[n++]=s,s>>=8,e[n++]=s,s>>=8,e[n++]=s,n}function R(e,t,n,r,i){$(t,r,i,e,n,7);let o=Number(t&BigInt(4294967295));e[n+7]=o,o>>=8,e[n+6]=o,o>>=8,e[n+5]=o,o>>=8,e[n+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=s,s>>=8,e[n+2]=s,s>>=8,e[n+1]=s,s>>=8,e[n]=s,n+8}function P(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function B(e,t,n,r,o){return t=+t,n>>>=0,o||P(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function F(e,t,n,r,o){return t=+t,n>>>=0,o||P(e,0,n,8),i.write(e,t,n,r,52,8),n+8}u.prototype.slice=function(e,t){const n=this.length;(e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e);const r=this.subarray(e,t);return Object.setPrototypeOf(r,u.prototype),r},u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||N(e,t,this.length);let r=this[e],i=1,o=0;for(;++o<t&&(i*=256);)r+=this[e+o]*i;return r},u.prototype.readUintBE=u.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||N(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e>>>=0,t||N(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e>>>=0,t||N(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=Y(function(e){V(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||z(e,this.length-8);const r=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,i=this[++e]+256*this[++e]+65536*this[++e]+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=Y(function(e){V(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||z(e,this.length-8);const r=t*2**24+65536*this[++e]+256*this[++e]+this[++e],i=this[++e]*2**24+65536*this[++e]+256*this[++e]+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||N(e,t,this.length);let r=this[e],i=1,o=0;for(;++o<t&&(i*=256);)r+=this[e+o]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*t)),r},u.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||N(e,t,this.length);let r=t,i=1,o=this[e+--r];for(;r>0&&(i*=256);)o+=this[e+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},u.prototype.readInt8=function(e,t){return e>>>=0,t||N(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||N(e,2,this.length);const n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(e,t){e>>>=0,t||N(e,2,this.length);const n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(e,t){return e>>>=0,t||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e>>>=0,t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=Y(function(e){V(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||z(e,this.length-8);const r=this[e+4]+256*this[e+5]+65536*this[e+6]+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)}),u.prototype.readBigInt64BE=Y(function(e){V(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||z(e,this.length-8);const r=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+n)}),u.prototype.readFloatLE=function(e,t){return e>>>=0,t||N(e,4,this.length),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||N(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||N(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||N(e,8,this.length),i.read(this,e,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){j(this,e,t,n,Math.pow(2,8*n)-1,0)}let i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){j(this,e,t,n,Math.pow(2,8*n)-1,0)}let i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,1,255,0),this[t]=255&e,t+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},u.prototype.writeBigUInt64LE=Y(function(e,t=0){return D(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Y(function(e,t=0){return R(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*n-1);j(this,e,t,n,r-1,-r)}let i=0,o=1,s=0;for(this[t]=255&e;++i<n&&(o*=256);)e<0&&0===s&&0!==this[t+i-1]&&(s=1),this[t+i]=(e/o|0)-s&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*n-1);j(this,e,t,n,r-1,-r)}let i=n-1,o=1,s=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/o|0)-s&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},u.prototype.writeBigInt64LE=Y(function(e,t=0){return D(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Y(function(e,t=0){return R(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeFloatLE=function(e,t,n){return B(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return B(this,e,t,!1,n)},u.prototype.writeDoubleLE=function(e,t,n){return F(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return F(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(!u.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);const i=r-n;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,n,r):Uint8Array.prototype.set.call(e,this.subarray(n,r),t),i},u.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===e.length){const t=e.charCodeAt(0);("utf8"===r&&t<128||"latin1"===r)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;let i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{const o=u.isBuffer(e)?e:u.from(e,r),s=o.length;if(0===s)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<n-t;++i)this[i+t]=o[i%s]}return this};const U={};function L(e,t,n){U[e]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function q(e){let t="",n=e.length;const r="-"===e[0]?1:0;for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function $(e,t,n,r,i,o){if(e>n||e<t){const r="bigint"==typeof t?"n":"";let i;throw i=o>3?0===t||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new U.ERR_OUT_OF_RANGE("value",i,e)}!function(e,t,n){V(t,"offset"),void 0!==e[t]&&void 0!==e[t+n]||z(t,e.length-(n+1))}(r,i,o)}function V(e,t){if("number"!=typeof e)throw new U.ERR_INVALID_ARG_TYPE(t,"number",e)}function z(e,t,n){if(Math.floor(e)!==e)throw V(e,n),new U.ERR_OUT_OF_RANGE(n||"offset","an integer",e);if(t<0)throw new U.ERR_BUFFER_OUT_OF_BOUNDS;throw new U.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${t}`,e)}L("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),L("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),L("ERR_OUT_OF_RANGE",function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=q(String(n)):"bigint"==typeof n&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=q(i)),i+="n"),r+=` It must be ${t}. Received ${i}`,r},RangeError);const K=/[^+/0-9A-Za-z-_]/g;function W(e,t){let n;t=t||1/0;const r=e.length;let i=null;const o=[];for(let s=0;s<r;++s){if(n=e.charCodeAt(s),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function Q(e){return r.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(K,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function G(e,t,n,r){let i;for(i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function H(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function J(e){return e!=e}const Z=function(){const e="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t}();function Y(e){return"undefined"==typeof BigInt?X:e}function X(){throw new Error("BigInt not supported")}},534:(e,t,n)=>{e.exports=n(381).EventEmitter},536:(e,t,n)=>{"use strict";var r;function i(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=n(339),s=Symbol("lastResolve"),a=Symbol("lastReject"),u=Symbol("error"),c=Symbol("ended"),l=Symbol("lastPromise"),h=Symbol("handlePromise"),f=Symbol("stream");function d(e,t){return{value:e,done:t}}function p(e){var t=e[s];if(null!==t){var n=e[f].read();null!==n&&(e[l]=null,e[s]=null,e[a]=null,t(d(n,!1)))}}function y(e){process.nextTick(p,e)}var m=Object.getPrototypeOf(function(){}),g=Object.setPrototypeOf((i(r={get stream(){return this[f]},next:function(){var e=this,t=this[u];if(null!==t)return Promise.reject(t);if(this[c])return Promise.resolve(d(void 0,!0));if(this[f].destroyed)return new Promise(function(t,n){process.nextTick(function(){e[u]?n(e[u]):t(d(void 0,!0))})});var n,r=this[l];if(r)n=new Promise(function(e,t){return function(n,r){e.then(function(){t[c]?n(d(void 0,!0)):t[h](n,r)},r)}}(r,this));else{var i=this[f].read();if(null!==i)return Promise.resolve(d(i,!1));n=new Promise(this[h])}return this[l]=n,n}},Symbol.asyncIterator,function(){return this}),i(r,"return",function(){var e=this;return new Promise(function(t,n){e[f].destroy(null,function(e){e?n(e):t(d(void 0,!0))})})}),r),m);e.exports=function(e){var t,n=Object.create(g,(i(t={},f,{value:e,writable:!0}),i(t,s,{value:null,writable:!0}),i(t,a,{value:null,writable:!0}),i(t,u,{value:null,writable:!0}),i(t,c,{value:e._readableState.endEmitted,writable:!0}),i(t,h,{value:function(e,t){var r=n[f].read();r?(n[l]=null,n[s]=null,n[a]=null,e(d(r,!1))):(n[s]=e,n[a]=t)},writable:!0}),t));return n[l]=null,o(e,function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[a];return null!==t&&(n[l]=null,n[s]=null,n[a]=null,t(e)),void(n[u]=e)}var r=n[s];null!==r&&(n[l]=null,n[s]=null,n[a]=null,r(d(void 0,!0))),n[c]=!0}),e.on("readable",y.bind(null,n)),n}},541:()=>{},553:(e,t,n)=>{"use strict";function r(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;e.entry=null;for(;r;){var i=r.callback;t.pendingcb--,i(n),r=r.next}t.corkedRequestsFree.next=e}(t,e)}}var i;e.exports=T,T.WritableState=S;var o={deprecate:n(947)},s=n(534),a=n(533).Buffer,u=(void 0!==n.g?n.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var c,l=n(917),h=n(750).getHighWaterMark,f=n(289).F,d=f.ERR_INVALID_ARG_TYPE,p=f.ERR_METHOD_NOT_IMPLEMENTED,y=f.ERR_MULTIPLE_CALLBACK,m=f.ERR_STREAM_CANNOT_PIPE,g=f.ERR_STREAM_DESTROYED,b=f.ERR_STREAM_NULL_VALUES,v=f.ERR_STREAM_WRITE_AFTER_END,w=f.ERR_UNKNOWN_ENCODING,E=l.errorOrDestroy;function k(){}function S(e,t,o){i=i||n(707),e=e||{},"boolean"!=typeof o&&(o=t instanceof i),this.objectMode=!!e.objectMode,o&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=h(this,e,"writableHighWaterMark",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if("function"!=typeof i)throw new y;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,i){--t.pendingcb,n?(process.nextTick(i,r),process.nextTick(M,e,t),e._writableState.errorEmitted=!0,E(e,r)):(i(r),e._writableState.errorEmitted=!0,E(e,r),M(e,t))}(e,n,r,t,i);else{var o=I(n)||e.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||O(e,n),r?process.nextTick(x,e,n,o,i):x(e,n,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new r(this)}function T(e){var t=this instanceof(i=i||n(707));if(!t&&!c.call(T,this))return new T(e);this._writableState=new S(e,this,t),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),s.call(this)}function _(e,t,n,r,i,o,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new g("write")):n?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function x(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),M(e,t)}function O(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var i=t.bufferedRequestCount,o=new Array(i),s=t.corkedRequestsFree;s.entry=n;for(var a=0,u=!0;n;)o[a]=n,n.isBuf||(u=!1),n=n.next,a+=1;o.allBuffers=u,_(e,t,!0,t.length,o,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new r(t),t.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,l=n.encoding,h=n.callback;if(_(e,t,!1,t.objectMode?1:c.length,c,l,h),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function I(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function C(e,t){e._final(function(n){t.pendingcb--,n&&E(e,n),t.prefinished=!0,e.emit("prefinish"),M(e,t)})}function M(e,t){var n=I(t);if(n&&(function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,process.nextTick(C,e,t)))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}n(193)(T,s),S.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(S.prototype,"buffer",{get:o.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(c=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(e){return!!c.call(this,e)||this===T&&(e&&e._writableState instanceof S)}})):c=function(e){return e instanceof this},T.prototype.pipe=function(){E(this,new m)},T.prototype.write=function(e,t,n){var r,i=this._writableState,o=!1,s=!i.objectMode&&(r=e,a.isBuffer(r)||r instanceof u);return s&&!a.isBuffer(e)&&(e=function(e){return a.from(e)}(e)),"function"==typeof t&&(n=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=k),i.ending?function(e,t){var n=new v;E(e,n),process.nextTick(t,n)}(this,n):(s||function(e,t,n,r){var i;return null===n?i=new b:"string"==typeof n||t.objectMode||(i=new d("chunk",["string","Buffer"],n)),!i||(E(e,i),process.nextTick(r,i),!1)}(this,i,e,n))&&(i.pendingcb++,o=function(e,t,n,r,i,o){if(!n){var s=function(e,t,n){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=a.from(t,n));return t}(t,r,i);r!==s&&(n=!0,i="buffer",r=s)}var u=t.objectMode?1:r.length;t.length+=u;var c=t.length<t.highWaterMark;c||(t.needDrain=!0);if(t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else _(e,t,!1,u,r,i,o);return c}(this,i,s,e,t,n)),o},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||O(this,e))},T.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new w(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(e,t,n){n(new p("_write()"))},T.prototype._writev=null,T.prototype.end=function(e,t,n){var r=this._writableState;return"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||function(e,t,n){t.ending=!0,M(e,t),n&&(t.finished?process.nextTick(n):e.once("finish",n));t.ended=!0,e.writable=!1}(this,r,n),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),T.prototype.destroy=l.destroy,T.prototype._undestroy=l.undestroy,T.prototype._destroy=function(e,t){t(e)}},608:(e,t,n)=>{var r=n(533),i=r.Buffer;function o(e,t){for(var n in e)t[n]=e[n]}function s(e,t,n){return i(e,t,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,n)},s.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=i(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},704:(e,t,n)=>{"use strict";var r=n(608).Buffer,i=r.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(r.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=l,this.end=h,t=3;break;default:return this.write=f,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,n=function(e,t){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function l(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function f(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}t.I=o,o.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},o.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},o.prototype.text=function(e,t){var n=function(e,t,n){var r=t.length-1;if(r<n)return 0;var i=s(t[r]);if(i>=0)return i>0&&(e.lastNeed=i-1),i;if(--r<n||-2===i)return 0;if(i=s(t[r]),i>=0)return i>0&&(e.lastNeed=i-2),i;if(--r<n||-2===i)return 0;if(i=s(t[r]),i>=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},707:(e,t,n)=>{"use strict";var r=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};e.exports=c;var i=n(33),o=n(553);n(193)(c,i);for(var s=r(o.prototype),a=0;a<s.length;a++){var u=s[a];c.prototype[u]||(c.prototype[u]=o.prototype[u])}function c(e){if(!(this instanceof c))return new c(e);i.call(this,e),o.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",l)))}function l(){this._writableState.ended||process.nextTick(h,this)}function h(e){e.end()}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(c.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})},750:(e,t,n)=>{"use strict";var r=n(289).F.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(e,t,n,i){var o=function(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}(t,i,n);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new r(i?n:"highWaterMark",o);return Math.floor(o)}return e.objectMode?16:16384}}},781:()=>{},787:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const i=r(n(829)),o=r(n(533)),s=r(n(876)),a=o.default.Buffer;function u(e){return e=function(e){if(!a.isBuffer(e))if(Array.isArray(e))e=a.from(e);else if("string"==typeof e)e=function(e,t){if("string"!=typeof e||!e.match(/^0x[0-9A-Fa-f]*$/))return!1;if(t&&e.length!==2+2*t)return!1;return!0}(e)?a.from(c(function(e){if("string"!=typeof e)return e;return function(e){if("string"!=typeof e)throw new Error("value must be type 'string', is currently type "+typeof e+", while checking isHexPrefixed.");return"0x"===e.slice(0,2)}(e)?e.slice(2):e}(e)),"hex"):a.from(e);else if("number"==typeof e)e=function(e){const t=function(e){const t=e.toString(16);return`0x${t}`}(e);return a.from(c(t.slice(2)),"hex")}(e);else if(null==e)e=a.allocUnsafe(0);else if(i.default.isBN(e))e=e.toArrayLike(a);else{if(!e.toArray)throw new Error("invalid type");e=a.from(e.toArray())}return e}(e),(0,s.default)("keccak256").update(e).digest()}function c(e){if("string"!=typeof e)throw new Error(`while padding to even, value must be string, is currently ${typeof e}, while padToEven.`);return e.length%2&&(e=`0${e}`),e}"undefined"!=typeof window&&(window.keccak256=u),e.exports=u},829:function(e,t,n){!function(e,t){"use strict";function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function o(e,t,n){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(n=t,t=10),this._init(e||0,t||10,n||"be"))}var s;"object"==typeof e?e.exports=o:t.BN=o,o.BN=o,o.wordSize=26;try{s="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:n(781).Buffer}catch(e){}function a(e,t){var n=e.charCodeAt(t);return n>=48&&n<=57?n-48:n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:void r(!1,"Invalid character in "+e)}function u(e,t,n){var r=a(e,n);return n-1>=t&&(r|=a(e,n-1)<<4),r}function c(e,t,n,i){for(var o=0,s=0,a=Math.min(e.length,n),u=t;u<a;u++){var c=e.charCodeAt(u)-48;o*=i,s=c>=49?c-49+10:c>=17?c-17+10:c,r(c>=0&&s<i,"Invalid character"),o+=s}return o}function l(e,t){e.words=t.words,e.length=t.length,e.negative=t.negative,e.red=t.red}if(o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<e.length&&(16===t?this._parseHex(e,i,n):(this._parseBase(e,t,i),"le"===n&&this._initArray(this.toArray(),t,n)))},o.prototype._initNumber=function(e,t,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),t,n)},o.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===n)for(i=e.length-1,o=0;i>=0;i-=3)s=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i<e.length;i+=3)s=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},o.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var i,o=0,s=0;if("be"===n)for(r=e.length-1;r>=t;r-=2)i=u(e,t,r)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(r=(e.length-t)%2==0?t+1:t;r<e.length;r+=2)i=u(e,t,r)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this._strip()},o.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,i=1;i<=67108863;i*=t)r++;r--,i=i/t|0;for(var o=e.length-n,s=o%r,a=Math.min(o,o-s)+n,u=0,l=n;l<a;l+=r)u=c(e,l,l+r,t),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var h=1;for(u=c(e,l,e.length,t),l=0;l<s;l++)h*=t;this.imuln(h),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},o.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},o.prototype._move=function(e){l(e,this)},o.prototype.clone=function(){var e=new o(null);return this.copy(e),e},o.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=h}catch(e){o.prototype.inspect=h}else o.prototype.inspect=h;function h(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];o.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],u=(16777215&(a<<i|o)).toString(16);o=a>>>24-i&16777215,(i+=2)>=26&&(i-=26,s--),n=0!==o||s!==this.length-1?f[6-u.length]+u+n:u+n}for(0!==o&&(n=o.toString(16)+n);n.length%t!==0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var c=d[e],l=p[e];n="";var h=this.clone();for(h.negative=0;!h.isZero();){var y=h.modrn(l).toString(e);n=(h=h.idivn(l)).isZero()?y+n:f[c-y.length]+y+n}for(this.isZero()&&(n="0"+n);n.length%t!==0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16,2)},s&&(o.prototype.toBuffer=function(e,t){return this.toArrayLike(s,e,t)}),o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};function y(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var i=0|e.words[0],o=0|t.words[0],s=i*o,a=67108863&s,u=s/67108864|0;n.words[0]=a;for(var c=1;c<r;c++){for(var l=u>>>26,h=67108863&u,f=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=f;d++){var p=c-d|0;l+=(s=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&s}n.words[c]=0|h,u=0|l}return 0!==u?n.words[c]=0|u:n.length--,n._strip()}o.prototype.toArrayLike=function(e,t,n){this._strip();var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var s=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,o);return this["_toArrayLike"+("le"===t?"LE":"BE")](s,i),s},o.prototype._toArrayLikeLE=function(e,t){for(var n=0,r=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|r;e[n++]=255&s,n<e.length&&(e[n++]=s>>8&255),n<e.length&&(e[n++]=s>>16&255),6===o?(n<e.length&&(e[n++]=s>>24&255),r=0,o=0):(r=s>>>24,o+=2)}if(n<e.length)for(e[n++]=r;n<e.length;)e[n++]=0},o.prototype._toArrayLikeBE=function(e,t){for(var n=e.length-1,r=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|r;e[n--]=255&s,n>=0&&(e[n--]=s>>8&255),n>=0&&(e[n--]=s>>16&255),6===o?(n>=0&&(e[n--]=s>>24&255),r=0,o=0):(r=s>>>24,o+=2)}if(n>=0)for(e[n--]=r;n>=0;)e[n--]=0},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 8191&t||(n+=13,t>>>=13),127&t||(n+=7,t>>>=7),15&t||(n+=4,t>>>=4),3&t||(n+=2,t>>>=2),1&t||n++,n},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var n=this._zeroBits(this.words[t]);if(e+=n,26!==n)break}return e},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},o.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this._strip()},o.prototype.ior=function(e){return r(0===(this.negative|e.negative)),this.iuor(e)},o.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;n<t.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=t.length,this._strip()},o.prototype.iand=function(e){return r(0===(this.negative|e.negative)),this.iuand(e)},o.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;r<n.length;r++)this.words[r]=t.words[r]^n.words[r];if(this!==t)for(;r<t.length;r++)this.words[r]=t.words[r];return this.length=t.length,this._strip()},o.prototype.ixor=function(e){return r(0===(this.negative|e.negative)),this.iuxor(e)},o.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var i=0;i<t;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this._strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<<i:this.words[n]&~(1<<i),this._strip()},o.prototype.iadd=function(e){var t,n,r;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(n=this,r=e):(n=e,r=this);for(var i=0,o=0;o<r.length;o++)t=(0|n.words[o])+(0|r.words[o])+i,this.words[o]=67108863&t,i=t>>>26;for(;0!==i&&o<n.length;o++)t=(0|n.words[o])+i,this.words[o]=67108863&t,i=t>>>26;if(this.length=n.length,0!==i)this.words[this.length]=i,this.length++;else if(n!==this)for(;o<n.length;o++)this.words[o]=n.words[o];return this},o.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n,r,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(n=this,r=e):(n=e,r=this);for(var o=0,s=0;s<r.length;s++)o=(t=(0|n.words[s])-(0|r.words[s])+o)>>26,this.words[s]=67108863&t;for(;0!==o&&s<n.length;s++)o=(t=(0|n.words[s])+o)>>26,this.words[s]=67108863&t;if(0===o&&s<n.length&&n!==this)for(;s<n.length;s++)this.words[s]=n.words[s];return this.length=Math.max(this.length,s),n!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(e){return this.clone().isub(e)};var m=function(e,t,n){var r,i,o,s=e.words,a=t.words,u=n.words,c=0,l=0|s[0],h=8191&l,f=l>>>13,d=0|s[1],p=8191&d,y=d>>>13,m=0|s[2],g=8191&m,b=m>>>13,v=0|s[3],w=8191&v,E=v>>>13,k=0|s[4],S=8191&k,T=k>>>13,_=0|s[5],x=8191&_,O=_>>>13,I=0|s[6],C=8191&I,M=I>>>13,A=0|s[7],N=8191&A,j=A>>>13,D=0|s[8],R=8191&D,P=D>>>13,B=0|s[9],F=8191&B,U=B>>>13,L=0|a[0],q=8191&L,$=L>>>13,V=0|a[1],z=8191&V,K=V>>>13,W=0|a[2],Q=8191&W,G=W>>>13,H=0|a[3],J=8191&H,Z=H>>>13,Y=0|a[4],X=8191&Y,ee=Y>>>13,te=0|a[5],ne=8191&te,re=te>>>13,ie=0|a[6],oe=8191&ie,se=ie>>>13,ae=0|a[7],ue=8191&ae,ce=ae>>>13,le=0|a[8],he=8191&le,fe=le>>>13,de=0|a[9],pe=8191&de,ye=de>>>13;n.negative=e.negative^t.negative,n.length=19;var me=(c+(r=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,$))+Math.imul(f,q)|0))<<13)|0;c=((o=Math.imul(f,$))+(i>>>13)|0)+(me>>>26)|0,me&=67108863,r=Math.imul(p,q),i=(i=Math.imul(p,$))+Math.imul(y,q)|0,o=Math.imul(y,$);var ge=(c+(r=r+Math.imul(h,z)|0)|0)+((8191&(i=(i=i+Math.imul(h,K)|0)+Math.imul(f,z)|0))<<13)|0;c=((o=o+Math.imul(f,K)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,r=Math.imul(g,q),i=(i=Math.imul(g,$))+Math.imul(b,q)|0,o=Math.imul(b,$),r=r+Math.imul(p,z)|0,i=(i=i+Math.imul(p,K)|0)+Math.imul(y,z)|0,o=o+Math.imul(y,K)|0;var be=(c+(r=r+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,G)|0)+Math.imul(f,Q)|0))<<13)|0;c=((o=o+Math.imul(f,G)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,r=Math.imul(w,q),i=(i=Math.imul(w,$))+Math.imul(E,q)|0,o=Math.imul(E,$),r=r+Math.imul(g,z)|0,i=(i=i+Math.imul(g,K)|0)+Math.imul(b,z)|0,o=o+Math.imul(b,K)|0,r=r+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(y,Q)|0,o=o+Math.imul(y,G)|0;var ve=(c+(r=r+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,Z)|0)+Math.imul(f,J)|0))<<13)|0;c=((o=o+Math.imul(f,Z)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,r=Math.imul(S,q),i=(i=Math.imul(S,$))+Math.imul(T,q)|0,o=Math.imul(T,$),r=r+Math.imul(w,z)|0,i=(i=i+Math.imul(w,K)|0)+Math.imul(E,z)|0,o=o+Math.imul(E,K)|0,r=r+Math.imul(g,Q)|0,i=(i=i+Math.imul(g,G)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,G)|0,r=r+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(y,J)|0,o=o+Math.imul(y,Z)|0;var we=(c+(r=r+Math.imul(h,X)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(f,X)|0))<<13)|0;c=((o=o+Math.imul(f,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,r=Math.imul(x,q),i=(i=Math.imul(x,$))+Math.imul(O,q)|0,o=Math.imul(O,$),r=r+Math.imul(S,z)|0,i=(i=i+Math.imul(S,K)|0)+Math.imul(T,z)|0,o=o+Math.imul(T,K)|0,r=r+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,G)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,G)|0,r=r+Math.imul(g,J)|0,i=(i=i+Math.imul(g,Z)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,Z)|0,r=r+Math.imul(p,X)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(y,X)|0,o=o+Math.imul(y,ee)|0;var Ee=(c+(r=r+Math.imul(h,ne)|0)|0)+((8191&(i=(i=i+Math.imul(h,re)|0)+Math.imul(f,ne)|0))<<13)|0;c=((o=o+Math.imul(f,re)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,r=Math.imul(C,q),i=(i=Math.imul(C,$))+Math.imul(M,q)|0,o=Math.imul(M,$),r=r+Math.imul(x,z)|0,i=(i=i+Math.imul(x,K)|0)+Math.imul(O,z)|0,o=o+Math.imul(O,K)|0,r=r+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,G)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,G)|0,r=r+Math.imul(w,J)|0,i=(i=i+Math.imul(w,Z)|0)+Math.imul(E,J)|0,o=o+Math.imul(E,Z)|0,r=r+Math.imul(g,X)|0,i=(i=i+Math.imul(g,ee)|0)+Math.imul(b,X)|0,o=o+Math.imul(b,ee)|0,r=r+Math.imul(p,ne)|0,i=(i=i+Math.imul(p,re)|0)+Math.imul(y,ne)|0,o=o+Math.imul(y,re)|0;var ke=(c+(r=r+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,se)|0)+Math.imul(f,oe)|0))<<13)|0;c=((o=o+Math.imul(f,se)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,r=Math.imul(N,q),i=(i=Math.imul(N,$))+Math.imul(j,q)|0,o=Math.imul(j,$),r=r+Math.imul(C,z)|0,i=(i=i+Math.imul(C,K)|0)+Math.imul(M,z)|0,o=o+Math.imul(M,K)|0,r=r+Math.imul(x,Q)|0,i=(i=i+Math.imul(x,G)|0)+Math.imul(O,Q)|0,o=o+Math.imul(O,G)|0,r=r+Math.imul(S,J)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(T,J)|0,o=o+Math.imul(T,Z)|0,r=r+Math.imul(w,X)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,ee)|0,r=r+Math.imul(g,ne)|0,i=(i=i+Math.imul(g,re)|0)+Math.imul(b,ne)|0,o=o+Math.imul(b,re)|0,r=r+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,se)|0)+Math.imul(y,oe)|0,o=o+Math.imul(y,se)|0;var Se=(c+(r=r+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(f,ue)|0))<<13)|0;c=((o=o+Math.imul(f,ce)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,r=Math.imul(R,q),i=(i=Math.imul(R,$))+Math.imul(P,q)|0,o=Math.imul(P,$),r=r+Math.imul(N,z)|0,i=(i=i+Math.imul(N,K)|0)+Math.imul(j,z)|0,o=o+Math.imul(j,K)|0,r=r+Math.imul(C,Q)|0,i=(i=i+Math.imul(C,G)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,G)|0,r=r+Math.imul(x,J)|0,i=(i=i+Math.imul(x,Z)|0)+Math.imul(O,J)|0,o=o+Math.imul(O,Z)|0,r=r+Math.imul(S,X)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(T,X)|0,o=o+Math.imul(T,ee)|0,r=r+Math.imul(w,ne)|0,i=(i=i+Math.imul(w,re)|0)+Math.imul(E,ne)|0,o=o+Math.imul(E,re)|0,r=r+Math.imul(g,oe)|0,i=(i=i+Math.imul(g,se)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,se)|0,r=r+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(y,ue)|0,o=o+Math.imul(y,ce)|0;var Te=(c+(r=r+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,fe)|0)+Math.imul(f,he)|0))<<13)|0;c=((o=o+Math.imul(f,fe)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,r=Math.imul(F,q),i=(i=Math.imul(F,$))+Math.imul(U,q)|0,o=Math.imul(U,$),r=r+Math.imul(R,z)|0,i=(i=i+Math.imul(R,K)|0)+Math.imul(P,z)|0,o=o+Math.imul(P,K)|0,r=r+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,G)|0)+Math.imul(j,Q)|0,o=o+Math.imul(j,G)|0,r=r+Math.imul(C,J)|0,i=(i=i+Math.imul(C,Z)|0)+Math.imul(M,J)|0,o=o+Math.imul(M,Z)|0,r=r+Math.imul(x,X)|0,i=(i=i+Math.imul(x,ee)|0)+Math.imul(O,X)|0,o=o+Math.imul(O,ee)|0,r=r+Math.imul(S,ne)|0,i=(i=i+Math.imul(S,re)|0)+Math.imul(T,ne)|0,o=o+Math.imul(T,re)|0,r=r+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,se)|0)+Math.imul(E,oe)|0,o=o+Math.imul(E,se)|0,r=r+Math.imul(g,ue)|0,i=(i=i+Math.imul(g,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0,r=r+Math.imul(p,he)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(y,he)|0,o=o+Math.imul(y,fe)|0;var _e=(c+(r=r+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ye)|0)+Math.imul(f,pe)|0))<<13)|0;c=((o=o+Math.imul(f,ye)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,r=Math.imul(F,z),i=(i=Math.imul(F,K))+Math.imul(U,z)|0,o=Math.imul(U,K),r=r+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,G)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,G)|0,r=r+Math.imul(N,J)|0,i=(i=i+Math.imul(N,Z)|0)+Math.imul(j,J)|0,o=o+Math.imul(j,Z)|0,r=r+Math.imul(C,X)|0,i=(i=i+Math.imul(C,ee)|0)+Math.imul(M,X)|0,o=o+Math.imul(M,ee)|0,r=r+Math.imul(x,ne)|0,i=(i=i+Math.imul(x,re)|0)+Math.imul(O,ne)|0,o=o+Math.imul(O,re)|0,r=r+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,se)|0)+Math.imul(T,oe)|0,o=o+Math.imul(T,se)|0,r=r+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(E,ue)|0,o=o+Math.imul(E,ce)|0,r=r+Math.imul(g,he)|0,i=(i=i+Math.imul(g,fe)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,fe)|0;var xe=(c+(r=r+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ye)|0)+Math.imul(y,pe)|0))<<13)|0;c=((o=o+Math.imul(y,ye)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,r=Math.imul(F,Q),i=(i=Math.imul(F,G))+Math.imul(U,Q)|0,o=Math.imul(U,G),r=r+Math.imul(R,J)|0,i=(i=i+Math.imul(R,Z)|0)+Math.imul(P,J)|0,o=o+Math.imul(P,Z)|0,r=r+Math.imul(N,X)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(j,X)|0,o=o+Math.imul(j,ee)|0,r=r+Math.imul(C,ne)|0,i=(i=i+Math.imul(C,re)|0)+Math.imul(M,ne)|0,o=o+Math.imul(M,re)|0,r=r+Math.imul(x,oe)|0,i=(i=i+Math.imul(x,se)|0)+Math.imul(O,oe)|0,o=o+Math.imul(O,se)|0,r=r+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(T,ue)|0,o=o+Math.imul(T,ce)|0,r=r+Math.imul(w,he)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(E,he)|0,o=o+Math.imul(E,fe)|0;var Oe=(c+(r=r+Math.imul(g,pe)|0)|0)+((8191&(i=(i=i+Math.imul(g,ye)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,ye)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,r=Math.imul(F,J),i=(i=Math.imul(F,Z))+Math.imul(U,J)|0,o=Math.imul(U,Z),r=r+Math.imul(R,X)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,ee)|0,r=r+Math.imul(N,ne)|0,i=(i=i+Math.imul(N,re)|0)+Math.imul(j,ne)|0,o=o+Math.imul(j,re)|0,r=r+Math.imul(C,oe)|0,i=(i=i+Math.imul(C,se)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,se)|0,r=r+Math.imul(x,ue)|0,i=(i=i+Math.imul(x,ce)|0)+Math.imul(O,ue)|0,o=o+Math.imul(O,ce)|0,r=r+Math.imul(S,he)|0,i=(i=i+Math.imul(S,fe)|0)+Math.imul(T,he)|0,o=o+Math.imul(T,fe)|0;var Ie=(c+(r=r+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ye)|0)+Math.imul(E,pe)|0))<<13)|0;c=((o=o+Math.imul(E,ye)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,r=Math.imul(F,X),i=(i=Math.imul(F,ee))+Math.imul(U,X)|0,o=Math.imul(U,ee),r=r+Math.imul(R,ne)|0,i=(i=i+Math.imul(R,re)|0)+Math.imul(P,ne)|0,o=o+Math.imul(P,re)|0,r=r+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,se)|0)+Math.imul(j,oe)|0,o=o+Math.imul(j,se)|0,r=r+Math.imul(C,ue)|0,i=(i=i+Math.imul(C,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,r=r+Math.imul(x,he)|0,i=(i=i+Math.imul(x,fe)|0)+Math.imul(O,he)|0,o=o+Math.imul(O,fe)|0;var Ce=(c+(r=r+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ye)|0)+Math.imul(T,pe)|0))<<13)|0;c=((o=o+Math.imul(T,ye)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,r=Math.imul(F,ne),i=(i=Math.imul(F,re))+Math.imul(U,ne)|0,o=Math.imul(U,re),r=r+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,se)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,se)|0,r=r+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(j,ue)|0,o=o+Math.imul(j,ce)|0,r=r+Math.imul(C,he)|0,i=(i=i+Math.imul(C,fe)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,fe)|0;var Me=(c+(r=r+Math.imul(x,pe)|0)|0)+((8191&(i=(i=i+Math.imul(x,ye)|0)+Math.imul(O,pe)|0))<<13)|0;c=((o=o+Math.imul(O,ye)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,r=Math.imul(F,oe),i=(i=Math.imul(F,se))+Math.imul(U,oe)|0,o=Math.imul(U,se),r=r+Math.imul(R,ue)|0,i=(i=i+Math.imul(R,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,r=r+Math.imul(N,he)|0,i=(i=i+Math.imul(N,fe)|0)+Math.imul(j,he)|0,o=o+Math.imul(j,fe)|0;var Ae=(c+(r=r+Math.imul(C,pe)|0)|0)+((8191&(i=(i=i+Math.imul(C,ye)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,ye)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,r=Math.imul(F,ue),i=(i=Math.imul(F,ce))+Math.imul(U,ue)|0,o=Math.imul(U,ce),r=r+Math.imul(R,he)|0,i=(i=i+Math.imul(R,fe)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,fe)|0;var Ne=(c+(r=r+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,ye)|0)+Math.imul(j,pe)|0))<<13)|0;c=((o=o+Math.imul(j,ye)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,r=Math.imul(F,he),i=(i=Math.imul(F,fe))+Math.imul(U,he)|0,o=Math.imul(U,fe);var je=(c+(r=r+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,ye)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,ye)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863;var De=(c+(r=Math.imul(F,pe))|0)+((8191&(i=(i=Math.imul(F,ye))+Math.imul(U,pe)|0))<<13)|0;return c=((o=Math.imul(U,ye))+(i>>>13)|0)+(De>>>26)|0,De&=67108863,u[0]=me,u[1]=ge,u[2]=be,u[3]=ve,u[4]=we,u[5]=Ee,u[6]=ke,u[7]=Se,u[8]=Te,u[9]=_e,u[10]=xe,u[11]=Oe,u[12]=Ie,u[13]=Ce,u[14]=Me,u[15]=Ae,u[16]=Ne,u[17]=je,u[18]=De,0!==c&&(u[19]=c,n.length++),n};function g(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,i=0,o=0;o<n.length-1;o++){var s=i;i=0;for(var a=67108863&r,u=Math.min(o,t.length-1),c=Math.max(0,o-e.length+1);c<=u;c++){var l=o-c,h=(0|e.words[l])*(0|t.words[c]),f=67108863&h;a=67108863&(f=f+a|0),i+=(s=(s=s+(h/67108864|0)|0)+(f>>>26)|0)>>>26,s&=67108863}n.words[o]=a,r=s,s=i}return 0!==r?n.words[o]=r:n.length--,n._strip()}function b(e,t,n){return g(e,t,n)}function v(e,t){this.x=e,this.y=t}Math.imul||(m=y),o.prototype.mulTo=function(e,t){var n=this.length+e.length;return 10===this.length&&10===e.length?m(this,e,t):n<63?y(this,e,t):n<1024?g(this,e,t):b(this,e,t)},v.prototype.makeRBT=function(e){for(var t=new Array(e),n=o.prototype._countBits(e)-1,r=0;r<e;r++)t[r]=this.revBin(r,n,e);return t},v.prototype.revBin=function(e,t,n){if(0===e||e===n-1)return e;for(var r=0,i=0;i<t;i++)r|=(1&e)<<t-i-1,e>>=1;return r},v.prototype.permute=function(e,t,n,r,i,o){for(var s=0;s<o;s++)r[s]=t[e[s]],i[s]=n[e[s]]},v.prototype.transform=function(e,t,n,r,i,o){this.permute(o,e,t,n,r,i);for(var s=1;s<i;s<<=1)for(var a=s<<1,u=Math.cos(2*Math.PI/a),c=Math.sin(2*Math.PI/a),l=0;l<i;l+=a)for(var h=u,f=c,d=0;d<s;d++){var p=n[l+d],y=r[l+d],m=n[l+d+s],g=r[l+d+s],b=h*m-f*g;g=h*g+f*m,m=b,n[l+d]=p+m,r[l+d]=y+g,n[l+d+s]=p-m,r[l+d+s]=y-g,d!==a&&(b=u*h-c*f,f=u*f+c*h,h=b)}},v.prototype.guessLen13b=function(e,t){var n=1|Math.max(t,e),r=1&n,i=0;for(n=n/2|0;n;n>>>=1)i++;return 1<<i+1+r},v.prototype.conjugate=function(e,t,n){if(!(n<=1))for(var r=0;r<n/2;r++){var i=e[r];e[r]=e[n-r-1],e[n-r-1]=i,i=t[r],t[r]=-t[n-r-1],t[n-r-1]=-i}},v.prototype.normalize13b=function(e,t){for(var n=0,r=0;r<t/2;r++){var i=8192*Math.round(e[2*r+1]/t)+Math.round(e[2*r]/t)+n;e[r]=67108863&i,n=i<67108864?0:i/67108864|0}return e},v.prototype.convert13b=function(e,t,n,i){for(var o=0,s=0;s<t;s++)o+=0|e[s],n[2*s]=8191&o,o>>>=13,n[2*s+1]=8191&o,o>>>=13;for(s=2*t;s<i;++s)n[s]=0;r(0===o),r(!(-8192&o))},v.prototype.stub=function(e){for(var t=new Array(e),n=0;n<e;n++)t[n]=0;return t},v.prototype.mulp=function(e,t,n){var r=2*this.guessLen13b(e.length,t.length),i=this.makeRBT(r),o=this.stub(r),s=new Array(r),a=new Array(r),u=new Array(r),c=new Array(r),l=new Array(r),h=new Array(r),f=n.words;f.length=r,this.convert13b(e.words,e.length,s,r),this.convert13b(t.words,t.length,c,r),this.transform(s,o,a,u,r,i),this.transform(c,o,l,h,r,i);for(var d=0;d<r;d++){var p=a[d]*l[d]-u[d]*h[d];u[d]=a[d]*h[d]+u[d]*l[d],a[d]=p}return this.conjugate(a,u,r),this.transform(a,u,f,o,r,i),this.conjugate(f,o,r),this.normalize13b(f,r),n.negative=e.negative^t.negative,n.length=e.length+t.length,n._strip()},o.prototype.mul=function(e){var t=new o(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},o.prototype.mulf=function(e){var t=new o(null);return t.words=new Array(this.length+e.length),b(this,e,t)},o.prototype.imul=function(e){return this.clone().mulTo(e,this)},o.prototype.imuln=function(e){var t=e<0;t&&(e=-e),r("number"==typeof e),r(e<67108864);for(var n=0,i=0;i<this.length;i++){var o=(0|this.words[i])*e,s=(67108863&o)+(67108863&n);n>>=26,n+=o/67108864|0,n+=s>>>26,this.words[i]=67108863&s}return 0!==n&&(this.words[i]=n,this.length++),this.length=0===e?1:this.length,t?this.ineg():this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),n=0;n<t.length;n++){var r=n/26|0,i=n%26;t[n]=e.words[r]>>>i&1}return t}(e);if(0===t.length)return new o(1);for(var n=this,r=0;r<t.length&&0===t[r];r++,n=n.sqr());if(++r<t.length)for(var i=n.sqr();r<t.length;r++,i=i.sqr())0!==t[r]&&(n=n.mul(i));return n},o.prototype.iushln=function(e){r("number"==typeof e&&e>=0);var t,n=e%26,i=(e-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(t=0;t<this.length;t++){var a=this.words[t]&o,u=(0|this.words[t])-a<<n;this.words[t]=u|s,s=a>>>26-n}s&&(this.words[t]=s,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t<i;t++)this.words[t]=0;this.length+=i}return this._strip()},o.prototype.ishln=function(e){return r(0===this.negative),this.iushln(e)},o.prototype.iushrn=function(e,t,n){var i;r("number"==typeof e&&e>=0),i=t?(t-t%26)/26:0;var o=e%26,s=Math.min((e-o)/26,this.length),a=67108863^67108863>>>o<<o,u=n;if(i-=s,i=Math.max(0,i),u){for(var c=0;c<s;c++)u.words[c]=this.words[c];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,c=0;c<this.length;c++)this.words[c]=this.words[c+s];else this.words[0]=0,this.length=1;var l=0;for(c=this.length-1;c>=0&&(0!==l||c>=i);c--){var h=0|this.words[c];this.words[c]=l<<26-o|h>>>o,l=h&a}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,i=1<<t;return!(this.length<=n)&&!!(this.words[n]&i)},o.prototype.imaskn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var i=67108863^67108863>>>t<<t;this.words[this.length-1]&=i}return this._strip()},o.prototype.maskn=function(e){return this.clone().imaskn(e)},o.prototype.iaddn=function(e){return r("number"==typeof e),r(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<=e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},o.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(r("number"==typeof e),r(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this._strip()},o.prototype.addn=function(e){return this.clone().iaddn(e)},o.prototype.subn=function(e){return this.clone().isubn(e)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(e,t,n){var i,o,s=e.length+n;this._expand(s);var a=0;for(i=0;i<e.length;i++){o=(0|this.words[i+n])+a;var u=(0|e.words[i])*t;a=((o-=67108863&u)>>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this._strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},o.prototype._wordDiv=function(e,t){var n=(this.length,e.length),r=this.clone(),i=e,s=0|i.words[i.length-1];0!==(n=26-this._countBits(s))&&(i=i.ushln(n),r.iushln(n),s=0|i.words[i.length-1]);var a,u=r.length-i.length;if("mod"!==t){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c<a.length;c++)a.words[c]=0}var l=r.clone()._ishlnsubmul(i,1,u);0===l.negative&&(r=l,a&&(a.words[u]=1));for(var h=u-1;h>=0;h--){var f=67108864*(0|r.words[i.length+h])+(0|r.words[i.length+h-1]);for(f=Math.min(f/s|0,67108863),r._ishlnsubmul(i,f,h);0!==r.negative;)f--,r.negative=0,r._ishlnsubmul(i,1,h),r.isZero()||(r.negative^=1);a&&(a.words[h]=f)}return a&&a._strip(),r._strip(),"div"!==t&&0!==n&&r.iushrn(n),{div:a||null,mod:r}},o.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(i=a.div.neg()),"div"!==t&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(e)),{div:i,mod:s}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(i=a.div.neg()),{div:i,mod:a.mod}):0!==(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(e)),{div:a.div,mod:s}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modrn(e.words[0]))}:this._wordDiv(e,t);var i,s,a},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),i=e.andln(1),o=n.cmp(r);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modrn=function(e){var t=e<0;t&&(e=-e),r(e<=67108863);for(var n=(1<<26)%e,i=0,o=this.length-1;o>=0;o--)i=(n*i+(0|this.words[o]))%e;return t?-i:i},o.prototype.modn=function(e){return this.modrn(e)},o.prototype.idivn=function(e){var t=e<0;t&&(e=-e),r(e<=67108863);for(var n=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*n;this.words[i]=o/e|0,n=o%e}return this._strip(),t?this.ineg():this},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),s=new o(0),a=new o(0),u=new o(1),c=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++c;for(var l=n.clone(),h=t.clone();!t.isZero();){for(var f=0,d=1;0===(t.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(l),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,y=1;0===(n.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(l),u.isub(h)),a.iushrn(1),u.iushrn(1);t.cmp(n)>=0?(t.isub(n),i.isub(a),s.isub(u)):(n.isub(t),a.isub(i),u.isub(s))}return{a,b:u,gcd:n.iushln(c)}},o.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,s=new o(1),a=new o(0),u=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var c=0,l=1;0===(t.words[0]&l)&&c<26;++c,l<<=1);if(c>0)for(t.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var h=0,f=1;0===(n.words[0]&f)&&h<26;++h,f<<=1);if(h>0)for(n.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);t.cmp(n)>=0?(t.isub(n),s.isub(a)):(n.isub(t),a.isub(s))}return(i=0===t.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var i=t.cmp(n);if(i<0){var o=t;t=n,n=o}else if(0===i||0===n.cmpn(1))break;t.isub(n)}return n.iushln(r)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return!(1&this.words[0])},o.prototype.isOdd=function(){return!(1&~this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,i=1<<t;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:i<e?-1:1}return 0!==this.negative?0|-t:t},o.prototype.cmp=function(e){if(0!==this.negative&&0===e.negative)return-1;if(0===this.negative&&0!==e.negative)return 1;var t=this.ucmp(e);return 0!==this.negative?0|-t:t},o.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,n=this.length-1;n>=0;n--){var r=0|this.words[n],i=0|e.words[n];if(r!==i){r<i?t=-1:r>i&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new x(e)},o.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var w={k256:null,p224:null,p192:null,p25519:null};function E(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function k(){E.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function S(){E.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function T(){E.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){E.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function x(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function O(e){x.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}E.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},E.prototype.ireduce=function(e){var t,n=e;do{this.split(n,this.tmp),t=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t<this.n?-1:n.ucmp(this.p);return 0===r?(n.words[0]=0,n.length=1):r>0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},E.prototype.split=function(e,t){e.iushrn(this.n,0,t)},E.prototype.imulK=function(e){return e.imul(this.k)},i(k,E),k.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),i=0;i<r;i++)t.words[i]=e.words[i];if(t.length=r,e.length<=9)return e.words[0]=0,void(e.length=1);var o=e.words[9];for(t.words[t.length++]=o&n,i=10;i<e.length;i++){var s=0|e.words[i];e.words[i-10]=(s&n)<<4|o>>>22,o=s}o>>>=22,e.words[i-10]=o,0===o&&e.length>10?e.length-=10:e.length-=9},k.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n<e.length;n++){var r=0|e.words[n];t+=977*r,e.words[n]=67108863&t,t=64*r+(t/67108864|0)}return 0===e.words[e.length-1]&&(e.length--,0===e.words[e.length-1]&&e.length--),e},i(S,E),i(T,E),i(_,E),_.prototype.imulK=function(e){for(var t=0,n=0;n<e.length;n++){var r=19*(0|e.words[n])+t,i=67108863&r;r>>>=26,e.words[n]=i,t=r}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(w[e])return w[e];var t;if("k256"===e)t=new k;else if("p224"===e)t=new S;else if("p192"===e)t=new T;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return w[e]=t,t},x.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},x.prototype._verify2=function(e,t){r(0===(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},x.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(l(e,e.umod(this.m)._forceRed(this)),e)},x.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},x.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},x.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},x.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},x.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},x.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},x.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},x.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},x.prototype.isqr=function(e){return this.imul(e,e.clone())},x.prototype.sqr=function(e){return this.mul(e,e)},x.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new o(1)).iushrn(2);return this.pow(e,n)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);r(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new o(2*l*l).toRed(this);0!==this.pow(l,c).cmp(u);)l.redIAdd(u);for(var h=this.pow(l,i),f=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=s;0!==d.cmp(a);){for(var y=d,m=0;0!==y.cmp(a);m++)y=y.redSqr();r(m<p);var g=this.pow(h,new o(1).iushln(p-m-1));f=f.redMul(g),h=g.redSqr(),d=d.redMul(h),p=m}return f},x.prototype.invm=function(e){var t=e._invmp(this.m);return 0!==t.negative?(t.negative=0,this.imod(t).redNeg()):this.imod(t)},x.prototype.pow=function(e,t){if(t.isZero())return new o(1).toRed(this);if(0===t.cmpn(1))return e.clone();var n=new Array(16);n[0]=new o(1).toRed(this),n[1]=e;for(var r=2;r<n.length;r++)n[r]=this.mul(n[r-1],e);var i=n[0],s=0,a=0,u=t.bitLength()%26;for(0===u&&(u=26),r=t.length-1;r>=0;r--){for(var c=t.words[r],l=u-1;l>=0;l--){var h=c>>l&1;i!==n[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===r&&0===l)&&(i=this.mul(i,n[s]),a=0,s=0)):a=0}u=26}return i},x.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},x.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new O(e)},i(O,x),O.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},O.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},O.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},O.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},O.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=n.nmd(e),this)},876:(e,t,n)=>{e.exports=n(928)(n(217))},917:e=>{"use strict";function t(e,t){r(e,t),n(e)}function n(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function r(e,t){e.emit("error",t)}e.exports={destroy:function(e,i){var o=this,s=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return s||a?(i?i(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(r,this,e)):process.nextTick(r,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!i&&e?o._writableState?o._writableState.errorEmitted?process.nextTick(n,o):(o._writableState.errorEmitted=!0,process.nextTick(t,o,e)):process.nextTick(t,o,e):i?(process.nextTick(n,o),i(e)):process.nextTick(n,o)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}}},918:e=>{e.exports=function(){throw new Error("Readable.from is not available in the browser")}},928:(e,t,n)=>{const r=n(316),i=n(102);e.exports=function(e){const t=r(e),n=i(e);return function(e,r){switch("string"==typeof e?e.toLowerCase():e){case"keccak224":return new t(1152,448,null,224,r);case"keccak256":return new t(1088,512,null,256,r);case"keccak384":return new t(832,768,null,384,r);case"keccak512":return new t(576,1024,null,512,r);case"sha3-224":return new t(1152,448,6,224,r);case"sha3-256":return new t(1088,512,6,256,r);case"sha3-384":return new t(832,768,6,384,r);case"sha3-512":return new t(576,1024,6,512,r);case"shake128":return new n(1344,256,31,r);case"shake256":return new n(1088,512,31,r);default:throw new Error("Invald algorithm: "+e)}}}},933:(e,t)=>{"use strict";t.byteLength=function(e){var t=a(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,o=a(e),s=o[0],u=o[1],c=new i(function(e,t,n){return 3*(t+n)/4-n}(0,s,u)),l=0,h=u>0?s-4:s;for(n=0;n<h;n+=4)t=r[e.charCodeAt(n)]<<18|r[e.charCodeAt(n+1)]<<12|r[e.charCodeAt(n+2)]<<6|r[e.charCodeAt(n+3)],c[l++]=t>>16&255,c[l++]=t>>8&255,c[l++]=255&t;2===u&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,c[l++]=255&t);1===u&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t);return c},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=16383,a=0,u=r-i;a<u;a+=s)o.push(c(e,a,a+s>u?u:a+s));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)n[s]=o[s],r[o.charCodeAt(s)]=s;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function u(e){return n[e>>18&63]+n[e>>12&63]+n[e>>6&63]+n[63&e]}function c(e,t,n){for(var r,i=[],o=t;o<n;o+=3)r=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),i.push(u(r));return i.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},947:(e,t,n)=>{function r(e){try{if(!n.g.localStorage)return!1}catch(e){return!1}var t=n.g.localStorage[e];return null!=t&&"true"===String(t).toLowerCase()}e.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var r={};return(()=>{"use strict";n.r(r),n.d(r,{createClient:()=>Aw,createClientWithValidation:()=>Dw,isNetworkType:()=>Nw,validateClientConfig:()=>jw});var e=n(787);function t(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}const i=8192;function o(e){if(e.length<i)return btoa(String.fromCharCode(...e));let t="";for(var n=0;n<e.length;n+=i){const r=e.slice(n,n+i);t+=String.fromCharCode(...r)}return btoa(t)}function s(e){const t=e.startsWith("0x")?e.slice(2):e,n=t.length%2==0?t:`0${t}`,r=n.match(/[0-9a-fA-F]{2}/g)?.map(e=>parseInt(e,16))??[];if(r.length!==n.length/2)throw new Error(`Invalid hex string ${e}`);return Uint8Array.from(r)}function a(e){return e.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),"")}function u(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function c(e,...t){if(!u(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function l(e,t){return!!Array.isArray(t)&&(0===t.length||(e?t.every(e=>"string"==typeof e):t.every(e=>Number.isSafeInteger(e))))}function h(e){if("function"!=typeof e)throw new Error("function expected");return!0}function f(e,t){if("string"!=typeof t)throw new Error(`${e}: string expected`);return!0}function d(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function p(e){if(!Array.isArray(e))throw new Error("array expected")}function y(e,t){if(!l(!0,t))throw new Error(`${e}: array of strings expected`)}function m(e,t){if(!l(!1,t))throw new Error(`${e}: array of numbers expected`)}function g(...e){const t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map(e=>e.encode).reduceRight(n,t),decode:e.map(e=>e.decode).reduce(n,t)}}function b(e){const t="string"==typeof e?e.split(""):e,n=t.length;y("alphabet",t);const r=new Map(t.map((e,t)=>[e,t]));return{encode:r=>(p(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${e}`);return t[r]})),decode:t=>(p(t),t.map(t=>{f("alphabet.decode",t);const n=r.get(t);if(void 0===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}function v(e=""){return f("join",e),{encode:t=>(y("join.decode",t),t.join(e)),decode:t=>(f("join.decode",t),t.split(e))}}function w(e,t="="){return d(e),f("padding",t),{encode(n){for(y("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){y("padding.decode",n);let r=n.length;if(r*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--){if((r-1)*e%8==0)throw new Error("padding: invalid, string has too much padding")}return n.slice(0,r)}}}function E(e){return h(e),{encode:e=>e,decode:t=>e(t)}}function k(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(p(e),!e.length)return[];let r=0;const i=[],o=Array.from(e,e=>{if(d(e),e<0||e>=t)throw new Error(`invalid integer: ${e}`);return e}),s=o.length;for(;;){let e=0,a=!0;for(let i=r;i<s;i++){const s=o[i],u=t*e,c=u+s;if(!Number.isSafeInteger(c)||u/t!==e||c-s!==u)throw new Error("convertRadix: carry overflow");const l=c/n;e=c%n;const h=Math.floor(l);if(o[i]=h,!Number.isSafeInteger(h)||h*n+e!==c)throw new Error("convertRadix: carry overflow");a&&(h?a=!1:r=i)}if(i.push(e),a)break}for(let t=0;t<e.length-1&&0===e[t];t++)i.push(0);return i.reverse()}const S=(e,t)=>0===t?e:S(t,e%t),T=(e,t)=>e+(t-S(e,t)),_=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function x(e,t,n,r){if(p(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(T(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${T(t,n)}`);let i=0,o=0;const s=_[t],a=_[n]-1,u=[];for(const r of e){if(d(r),r>=s)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(i=i<<t|r,o+t>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=n;o-=n)u.push((i>>o-n&a)>>>0);const e=_[o];if(void 0===e)throw new Error("invalid carry");i&=e-1}if(i=i<<n-o&a,!r&&o>=t)throw new Error("Excess padding");if(!r&&i>0)throw new Error(`Non-zero padding: ${i}`);return r&&o>0&&u.push(i>>>0),u}function O(e){d(e);return{encode:t=>{if(!u(t))throw new Error("radix.encode input should be Uint8Array");return k(Array.from(t),256,e)},decode:t=>(m("radix.decode",t),Uint8Array.from(k(t,e,256)))}}function I(e,t=!1){if(d(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(T(8,e)>32||T(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!u(n))throw new Error("radix2.encode input should be Uint8Array");return x(Array.from(n),8,e,!t)},decode:n=>(m("radix2.decode",n),Uint8Array.from(x(n,e,8,t)))}}function C(e){return h(e),function(...t){try{return e.apply(null,t)}catch(e){}}}function M(e,t){return d(e),h(t),{encode(n){if(!u(n))throw new Error("checksum.encode: input should be Uint8Array");const r=t(n).slice(0,e),i=new Uint8Array(n.length+e);return i.set(n),i.set(r,n.length),i},decode(n){if(!u(n))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-e),i=n.slice(-e),o=t(r).slice(0,e);for(let t=0;t<e;t++)if(o[t]!==i[t])throw new Error("Invalid checksum");return r}}}const A={alphabet:b,chain:g,checksum:M,convertRadix:k,convertRadix2:x,radix:O,radix2:I,join:v,padding:w},N=g(I(4),b("0123456789ABCDEF"),v("")),j=g(I(5),b("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),w(5),v("")),D=(g(I(5),b("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),v("")),g(I(5),b("0123456789ABCDEFGHIJKLMNOPQRSTUV"),w(5),v("")),g(I(5),b("0123456789ABCDEFGHIJKLMNOPQRSTUV"),v("")),g(I(5),b("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),v(""),E(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)()),R=(e,t)=>{f("base64",e);const n=t?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,r=t?"base64url":"base64";if(e.length>0&&!n.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},P=D?{encode:e=>(c(e),e.toBase64()),decode:e=>R(e,!1)}:g(I(6),b("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),w(6),v("")),B=(g(I(6),b("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),v("")),D?{encode:e=>(c(e),e.toBase64({alphabet:"base64url"})),decode:e=>R(e,!0)}:g(I(6),b("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),w(6),v(""))),F=(g(I(6),b("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),v("")),e=>g(O(58),b(e),v(""))),U=F("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),L=(F("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),F("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"),[0,2,3,5,6,7,9,10,11]),q={encode(e){let t="";for(let n=0;n<e.length;n+=8){const r=e.subarray(n,n+8);t+=U.encode(r).padStart(L[r.length],"1")}return t},decode(e){let t=[];for(let n=0;n<e.length;n+=11){const r=e.slice(n,n+11),i=L.indexOf(r.length),o=U.decode(r);for(let e=0;e<o.length-i;e++)if(0!==o[e])throw new Error("base58xmr: wrong padding");t=t.concat(Array.from(o.slice(o.length-i)))}return Uint8Array.from(t)}},$=g(b("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),v("")),V=[996825010,642813549,513874426,1027748829,705979059];function z(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e<V.length;e++)1==(t>>e&1)&&(n^=V[e]);return n}function K(e,t,n=1){const r=e.length;let i=1;for(let t=0;t<r;t++){const n=e.charCodeAt(t);if(n<33||n>126)throw new Error(`Invalid prefix (${e})`);i=z(i)^n>>5}i=z(i);for(let t=0;t<r;t++)i=z(i)^31&e.charCodeAt(t);for(let e of t)i=z(i)^e;for(let e=0;e<6;e++)i=z(i);return i^=n,$.encode(x([i%_[30]],30,5,!1))}function W(e){const t="bech32"===e?1:734539939,n=I(5),r=n.decode,i=n.encode,o=C(r);function s(e,n,r=90){f("bech32.encode prefix",e),u(n)&&(n=Array.from(n)),m("bech32.encode",n);const i=e.length;if(0===i)throw new TypeError(`Invalid prefix length ${i}`);const o=i+7+n.length;if(!1!==r&&o>r)throw new TypeError(`Length ${o} exceeds limit ${r}`);const s=e.toLowerCase(),a=K(s,n,t);return`${s}1${$.encode(n)}${a}`}function a(e,n=90){f("bech32.decode input",e);const r=e.length;if(r<8||!1!==n&&r>n)throw new TypeError(`invalid string length: ${r} (${e}). Expected (8..${n})`);const i=e.toLowerCase();if(e!==i&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=i.lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const s=i.slice(0,o),a=i.slice(o+1);if(a.length<6)throw new Error("Data must be at least 6 characters long");const u=$.decode(a).slice(0,-6),c=K(s,u,t);if(!a.endsWith(c))throw new Error(`Invalid checksum in ${e}: expected "${c}"`);return{prefix:s,words:u}}return{encode:s,decode:a,encodeFromBytes:function(e,t){return s(e,i(t))},decodeToBytes:function(e){const{prefix:t,words:n}=a(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:C(a),fromWords:r,fromWordsUnsafe:o,toWords:i}}const Q=W("bech32"),G=(W("bech32m"),{encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)}),H=((()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)()||g(I(4),b("0123456789abcdef"),v(""),E(e=>{if("string"!=typeof e||e.length%2!=0)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})),e=>U.encode(e)),J=e=>U.decode(e);function Z(e){const t=[];let n=0;if(0===e)return[0];for(;e>0;)t[n]=127&e,(e>>=7)&&(t[n]|=128),n+=1;return t}class Y{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength)}shift(e){return this.bytePosition+=e,this}read8(){const e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){const e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){const e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){const e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){const e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){const e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){const t=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),n}readULEB(){const e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:n,length:r}=function(e){let t=0,n=0,r=0;for(;;){const i=e[r];if(r+=1,t|=(127&i)<<n,!(128&i))break;n+=7}return{value:t,length:r}}(t);return this.shift(r),n}readVec(e){const t=this.readULEB(),n=[];for(let r=0;r<t;r++)n.push(e(this,r,t));return n}}function X(e,t=["<",">"]){const[n,r]=t,i=[];let o="",s=0;for(let t=0;t<e.length;t++){const a=e[t];a===n&&s++,a===r&&s--,0!==s||","!==a?o+=a:(i.push(o.trim()),o="")}return i.push(o.trim()),i}class ee{constructor({initialSize:e=1024,maxSize:t=1/0,allocateSize:n=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t,this.allocateSize=n,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const n=new ArrayBuffer(this.size);new Uint8Array(n).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(n)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return te(BigInt(e),8).forEach(e=>this.write8(e)),this}write128(e){return te(BigInt(e),16).forEach(e=>this.write8(e)),this}write256(e){return te(BigInt(e),32).forEach(e=>this.write8(e)),this}writeULEB(e){return Z(e).forEach(e=>this.write8(e)),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach((n,r)=>t(this,n,r,e.length)),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return H(e);case"base64":return o(e);case"hex":return a(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function te(e,t){const n=new Uint8Array(t);let r=0;for(;e>0;)n[r]=Number(e%BigInt(256)),e/=BigInt(256),r+=1;return n}var ne,re,ie,oe,se=e=>{throw TypeError(e)},ae=(e,t,n)=>t.has(e)||se("Cannot "+n),ue=(e,t,n)=>(ae(e,t,"read from private field"),n?n.call(e):t.get(e)),ce=(e,t,n)=>t.has(e)?se("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),le=(e,t,n,r)=>(ae(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);ne=new WeakMap,re=new WeakMap;let he=class e{constructor(e){ce(this,ne),ce(this,re),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),le(this,ne,e.write),le(this,re,e.serialize??((e,t)=>{const n=new ee({initialSize:this.serializedSize(e)??void 0,...t});return ue(this,ne).call(this,e,n),n.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),ue(this,ne).call(this,e,t)}serialize(e,t){return this.validate(e),new pe(this,ue(this,re).call(this,e,t))}parse(e){const t=new Y(e);return this.read(t)}fromHex(e){return this.parse(s(e))}fromBase58(e){return this.parse(J(e))}fromBase64(e){return this.parse(t(e))}transform({name:t,input:n,output:r,validate:i}){return new e({name:t??this.name,read:e=>r?r(this.read(e)):this.read(e),write:(e,t)=>ue(this,ne).call(this,n?n(e):e,t),serializedSize:e=>this.serializedSize(n?n(e):e),serialize:(e,t)=>ue(this,re).call(this,n?n(e):e,t),validate:e=>{i?.(e),this.validate(n?n(e):e)}})}};const fe=Symbol.for("@mysten/serialized-bcs");function de(e){return!!e&&"object"==typeof e&&!0===e[fe]}class pe{constructor(e,t){ce(this,ie),ce(this,oe),le(this,ie,e),le(this,oe,t)}get[fe](){return!0}toBytes(){return ue(this,oe)}toHex(){return a(ue(this,oe))}toBase64(){return o(ue(this,oe))}toBase58(){return H(ue(this,oe))}parse(){return ue(this,ie).parse(ue(this,oe))}}function ye({size:e,...t}){return new he({...t,serializedSize:()=>e})}function me({readMethod:e,writeMethod:t,...n}){return ye({...n,read:t=>t[e](),write:(e,n)=>n[t](e),validate:e=>{if(e<0||e>n.maxValue)throw new TypeError(`Invalid ${n.name} value: ${e}. Expected value in range 0-${n.maxValue}`);n.validate?.(e)}})}function ge({readMethod:e,writeMethod:t,...n}){return ye({...n,read:t=>t[e](),write:(e,n)=>n[t](BigInt(e)),validate:e=>{const t=BigInt(e);if(t<0||t>n.maxValue)throw new TypeError(`Invalid ${n.name} value: ${t}. Expected value in range 0-${n.maxValue}`);n.validate?.(t)}})}ie=new WeakMap,oe=new WeakMap;var be,ve,we,Ee;function ke(e){return{lang:e?.lang??be?.lang,message:e?.message,abortEarly:e?.abortEarly??be?.abortEarly,abortPipeEarly:e?.abortPipeEarly??be?.abortPipeEarly}}function Se(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function Te(e,t,n,r,i){const o=i&&"input"in i?i.input:n.value,s=i?.expected??e.expects??null,a=i?.received??Se(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},c="schema"===e.kind,l=i?.message??e.message??(h=e.reference,f=u.lang,Ee?.get(h)?.get(f))??(c?function(e){return we?.get(e)}(u.lang):null)??r.message??function(e){return ve?.get(e)}(u.lang);var h,f;l&&(u.message="function"==typeof l?l(u):l),c&&(n.typed=!1),n.issues?n.issues.push(u):n.issues=[u]}function _e(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}var xe=class extends Error{issues;constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function Oe(e,t){return{kind:"validation",type:"check",reference:Oe,async:!1,expects:null,requirement:e,message:t,_run(e,t){return e.typed&&!this.requirement(e.value)&&Te(this,"input",e,t),e}}}function Ie(e){return{kind:"validation",type:"integer",reference:Ie,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(e,t){return e.typed&&!this.requirement(e.value)&&Te(this,"integer",e,t),e}}}function Ce(e){return{kind:"transformation",type:"transform",reference:Ce,async:!1,operation:e,_run(e){return e.value=this.operation(e.value),e}}}function Me(e,t,n){return"function"==typeof e.default?e.default(t,n):e.default}function Ae(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function Ne(e,t){return{kind:"schema",type:"array",reference:Ne,expects:"Array",async:!1,item:e,message:t,_run(e,t){const n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){const i=n[r],o=this.item._run({typed:!1,value:i},t);if(o.issues){const s={type:"array",origin:"value",input:n,key:r,value:i};for(const t of o.issues)t.path?t.path.unshift(s):t.path=[s],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value.push(o.value)}}else Te(this,"type",e,t);return e}}}function je(e){return{kind:"schema",type:"bigint",reference:je,expects:"bigint",async:!1,message:e,_run(e,t){return"bigint"==typeof e.value?e.typed=!0:Te(this,"type",e,t),e}}}function De(e){return{kind:"schema",type:"boolean",reference:De,expects:"boolean",async:!1,message:e,_run(e,t){return"boolean"==typeof e.value?e.typed=!0:Te(this,"type",e,t),e}}}function Re(e){return{kind:"schema",type:"lazy",reference:Re,expects:"unknown",async:!1,getter:e,_run(e,t){return this.getter(e.value)._run(e,t)}}}function Pe(e,t){return{kind:"schema",type:"literal",reference:Pe,expects:Se(e),async:!1,literal:e,message:t,_run(e,t){return e.value===this.literal?e.typed=!0:Te(this,"type",e,t),e}}}function Be(e,...t){const n={kind:"schema",type:"nullable",reference:Be,expects:`${e.expects} | null`,async:!1,wrapped:e,_run(e,t){return null===e.value&&("default"in this&&(e.value=Me(this,e,t)),null===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(n.default=t[0]),n}function Fe(e,...t){const n={kind:"schema",type:"nullish",reference:Fe,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(e,t){return null!==e.value&&void 0!==e.value||("default"in this&&(e.value=Me(this,e,t)),null!==e.value&&void 0!==e.value)?this.wrapped._run(e,t):(e.typed=!0,e)}};return 0 in t&&(n.default=t[0]),n}function Ue(e){return{kind:"schema",type:"number",reference:Ue,expects:"number",async:!1,message:e,_run(e,t){return"number"!=typeof e.value||isNaN(e.value)?Te(this,"type",e,t):e.typed=!0,e}}}function Le(e,t){return{kind:"schema",type:"object",reference:Le,expects:"Object",async:!1,entries:e,message:t,_run(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const r in this.entries){const i=n[r],o=this.entries[r]._run({typed:!1,value:i},t);if(o.issues){const s={type:"object",origin:"value",input:n,key:r,value:i};for(const t of o.issues)t.path?t.path.unshift(s):t.path=[s],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),(void 0!==o.value||r in n)&&(e.value[r]=o.value)}}else Te(this,"type",e,t);return e}}}function qe(e,...t){const n={kind:"schema",type:"optional",reference:qe,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(e,t){return void 0===e.value&&("default"in this&&(e.value=Me(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(n.default=t[0]),n}function $e(e,t,n){return{kind:"schema",type:"record",reference:$e,expects:"Object",async:!1,key:e,value:t,message:n,_run(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const r in n)if(_e(n,r)){const i=n[r],o=this.key._run({typed:!1,value:r},t);if(o.issues){const s={type:"object",origin:"key",input:n,key:r,value:i};for(const t of o.issues)t.path=[s],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}const s=this.value._run({typed:!1,value:i},t);if(s.issues){const o={type:"object",origin:"value",input:n,key:r,value:i};for(const t of s.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=s.issues),t.abortEarly){e.typed=!1;break}}o.typed&&s.typed||(e.typed=!1),o.typed&&(e.value[o.value]=s.value)}}else Te(this,"type",e,t);return e}}}function Ve(e){return{kind:"schema",type:"string",reference:Ve,expects:"string",async:!1,message:e,_run(e,t){return"string"==typeof e.value?e.typed=!0:Te(this,"type",e,t),e}}}function ze(e,t){return{kind:"schema",type:"tuple",reference:ze,expects:"Array",async:!1,items:e,message:t,_run(e,t){const n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<this.items.length;r++){const i=n[r],o=this.items[r]._run({typed:!1,value:i},t);if(o.issues){const s={type:"array",origin:"value",input:n,key:r,value:i};for(const t of o.issues)t.path?t.path.unshift(s):t.path=[s],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value.push(o.value)}}else Te(this,"type",e,t);return e}}}function Ke(e){let t;if(e)for(const n of e)t?t.push(...n.issues):t=n.issues;return t}function We(e,t){return{kind:"schema",type:"union",reference:We,expects:[...new Set(e.map(e=>e.expects))].join(" | ")||"never",async:!1,options:e,message:t,_run(e,t){let n,r,i;for(const o of this.options){const s=o._run({typed:!1,value:e.value},t);if(s.typed){if(!s.issues){n=s;break}r?r.push(s):r=[s]}else i?i.push(s):i=[s]}if(n)return n;if(r){if(1===r.length)return r[0];Te(this,"type",e,t,{issues:Ke(r)}),e.typed=!0}else{if(1===i?.length)return i[0];Te(this,"type",e,t,{issues:Ke(i)})}return e}}}function Qe(){return{kind:"schema",type:"unknown",reference:Qe,expects:"unknown",async:!1,_run:e=>(e.typed=!0,e)}}function Ge(e,t,n){const r=e._run({typed:!1,value:t},ke(n));if(r.issues)throw new xe(r.issues);return r.value}function He(...e){return{...e[0],pipe:e,_run(t,n){for(let r=0;r<e.length;r++){if(t.issues&&("schema"===e[r].kind||"transformation"===e[r].kind)){t.typed=!1;break}t.issues&&(n.abortEarly||n.abortPipeEarly)||(t=e[r]._run(t,n))}return t}}}const Je=/^(?!.*(^(?!@)|[-.@])($|[-.@]))(?:[a-z0-9-]{0,63}(?:\.[a-z0-9-]{0,63})*)?@[a-z0-9-]{0,63}$/i,Ze=/^(?!.*(^|[-.])($|[-.]))(?:[a-z0-9-]{0,63}\.)+sui$/i;const Ye=/^([a-z0-9]+(?:-[a-z0-9]+)*)$/,Xe=/^\d+$/,et=e=>{const t=e.split("/");if(t.length<2||t.length>3)return!1;const[n,r,i]=t;return!(void 0!==i&&!Xe.test(i))&&(!!function(e){return!(e.length>235)&&(e.includes("@")?Je.test(e):Ze.test(e))}(n)&&(Ye.test(r)&&r.length<64))},tt=e=>{const t=e.split(/::|<|>|,/);for(const e of t)if(e.includes("/")&&!et(e))return!1;return!0};function nt(e){try{return 32===J(e).length}catch(e){return!1}}function rt(e){return function(e){return/^(0x|0X)?[a-fA-F0-9]+$/.test(e)&&e.length%2==0}(e)&&32===function(e){return/^(0x|0X)/.test(e)?(e.length-2)/2:e.length/2}(e)}function it(e){return rt(e)}function ot(e){const[t,n]=e.split("::"),r=et(t),i=e.slice(t.length+n.length+4),o=i.includes("<")?i.slice(0,i.indexOf("<")):i,s=i.includes("<")?X(i.slice(i.indexOf("<")+1,i.lastIndexOf(">"))).map(e=>function(e){return e.includes("::")?ot(e):e}(e.trim())):[];return{address:r?t:at(t),module:n,name:o,typeParams:s}}function st(e){const{address:t,module:n,name:r,typeParams:i}="string"==typeof e?ot(e):e;return`${t}::${n}::${r}${i?.length>0?`<${i.map(e=>"string"==typeof e?e:st(e)).join(",")}>`:""}`}function at(e,t=!1){let n=e.toLowerCase();return!t&&n.startsWith("0x")&&(n=n.slice(2)),`0x${n.padStart(64,"0")}`}function ut(e,t=!1){return at(e,t)}function ct(e){const t=Object.entries(e).map(([e,t])=>Le({[e]:t}));return He(We(t),Ce(e=>({...e,$kind:Object.keys(e)[0]})))}const lt=He(Ve(),Ce(e=>at(e)),Oe(rt)),ht=lt,ft=Ve(),dt=He(We([Ve(),He(Ue(),Ie())]),Oe(e=>{try{return BigInt(e),BigInt(e)>=0&&BigInt(e)<=18446744073709551615n}catch{return!1}},"Invalid u64")),pt=Le({objectId:lt,version:dt,digest:Ve()}),yt=He(We([Le({GasCoin:Pe(!0)}),Le({Input:He(Ue(),Ie()),type:qe(Pe("pure"))}),Le({Input:He(Ue(),Ie()),type:qe(Pe("object"))}),Le({Result:He(Ue(),Ie())}),Le({NestedResult:ze([He(Ue(),Ie()),He(Ue(),Ie())])})]),Ce(e=>({...e,$kind:Object.keys(e)[0]}))),mt=Le({budget:Be(dt),price:Be(dt),owner:Be(lt),payment:Be(Ne(pt))}),gt=(Le({address:Ve(),module:Ve(),name:Ve(),typeParams:Ne(Ve())}),We([Pe("address"),Pe("bool"),Pe("u8"),Pe("u16"),Pe("u32"),Pe("u64"),Pe("u128"),Pe("u256"),Le({vector:Re(()=>gt)}),Le({datatype:Le({package:Ve(),module:Ve(),type:Ve(),typeParameters:Ne(Re(()=>gt))})}),Le({typeParameter:He(Ue(),Ie())})])),bt=Le({ref:Be(We([Pe("&"),Pe("&mut")])),body:gt}),vt=Le({package:ht,module:Ve(),function:Ve(),typeArguments:Ne(Ve()),arguments:Ne(yt),_argumentTypes:qe(Be(Ne(bt)))}),wt=Le({name:Ve(),inputs:$e(Ve(),We([yt,Ne(yt)])),data:$e(Ve(),Qe())}),Et=ct({MoveCall:vt,TransferObjects:Le({objects:Ne(yt),address:yt}),SplitCoins:Le({coin:yt,amounts:Ne(yt)}),MergeCoins:Le({destination:yt,sources:Ne(yt)}),Publish:Le({modules:Ne(ft),dependencies:Ne(ht)}),MakeMoveVec:Le({type:Be(Ve()),elements:Ne(yt)}),Upgrade:Le({modules:Ne(ft),dependencies:Ne(ht),package:ht,ticket:yt}),$Intent:wt}),kt=ct({ImmOrOwnedObject:pt,SharedObject:Le({objectId:ht,initialSharedVersion:dt,mutable:De()}),Receiving:pt}),St=ct({Object:kt,Pure:Le({bytes:ft}),UnresolvedPure:Le({value:Qe()}),UnresolvedObject:Le({objectId:ht,version:qe(Be(dt)),digest:qe(Be(Ve())),initialSharedVersion:qe(Be(dt))})}),Tt=ct({Object:kt,Pure:Le({bytes:ft})}),_t=ct({None:Pe(!0),Epoch:dt}),xt=Le({version:Pe(2),sender:Fe(lt),expiration:Fe(_t),gasData:mt,inputs:Ne(St),commands:Ne(Et)});const Ot={MoveCall(e){const[t,n="",r=""]="target"in e?e.target.split("::"):[e.package,e.module,e.function];return{$kind:"MoveCall",MoveCall:{package:t,module:n,function:r,typeArguments:e.typeArguments??[],arguments:e.arguments??[]}}},TransferObjects:(e,t)=>({$kind:"TransferObjects",TransferObjects:{objects:e.map(e=>Ge(yt,e)),address:Ge(yt,t)}}),SplitCoins:(e,t)=>({$kind:"SplitCoins",SplitCoins:{coin:Ge(yt,e),amounts:t.map(e=>Ge(yt,e))}}),MergeCoins:(e,t)=>({$kind:"MergeCoins",MergeCoins:{destination:Ge(yt,e),sources:t.map(e=>Ge(yt,e))}}),Publish:({modules:e,dependencies:t})=>({$kind:"Publish",Publish:{modules:e.map(e=>"string"==typeof e?e:o(new Uint8Array(e))),dependencies:t.map(e=>ut(e))}}),Upgrade:({modules:e,dependencies:t,package:n,ticket:r})=>({$kind:"Upgrade",Upgrade:{modules:e.map(e=>"string"==typeof e?e:o(new Uint8Array(e))),dependencies:t.map(e=>ut(e)),package:n,ticket:Ge(yt,r)}}),MakeMoveVec:({type:e,elements:t})=>({$kind:"MakeMoveVec",MakeMoveVec:{type:e??null,elements:t.map(e=>Ge(yt,e))}}),Intent:({name:e,inputs:t={},data:n={}})=>({$kind:"$Intent",$Intent:{name:e,inputs:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,Array.isArray(t)?t.map(e=>Ge(yt,e)):Ge(yt,t)])),data:n}})},It=/^vector<(.+)>$/,Ct=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class Mt{static parseFromStr(e,t=!1){if("address"===e)return{address:null};if("bool"===e)return{bool:null};if("u8"===e)return{u8:null};if("u16"===e)return{u16:null};if("u32"===e)return{u32:null};if("u64"===e)return{u64:null};if("u128"===e)return{u128:null};if("u256"===e)return{u256:null};if("signer"===e)return{signer:null};const n=e.match(It);if(n)return{vector:Mt.parseFromStr(n[1],t)};const r=e.match(Ct);if(r){return{struct:{address:t?at(r[1]):r[1],module:r[2],name:r[3],typeParams:void 0===r[5]?[]:Mt.parseStructTypeArgs(r[5],t)}}}throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,t=!1){return X(e).map(e=>Mt.parseFromStr(e,t))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${Mt.tagToString(e.vector)}>`;if("struct"in e){const t=e.struct,n=t.typeParams.map(Mt.tagToString).join(", ");return`${t.address}::${t.module}::${t.name}${n?`<${n}>`:""}`}throw new Error("Invalid TypeTag")}}const At=Le({digest:Ve(),objectId:Ve(),version:We([He(Ue(),Ie()),Ve(),je()])}),Nt=ct({ImmOrOwned:At,Shared:Le({objectId:ht,initialSharedVersion:dt,mutable:De()}),Receiving:At}),jt=ct({Object:Nt,Pure:Ne(He(Ue(),Ie()))}),Dt=We([Le({kind:Pe("Input"),index:He(Ue(),Ie()),value:Qe(),type:qe(Pe("object"))}),Le({kind:Pe("Input"),index:He(Ue(),Ie()),value:Qe(),type:Pe("pure")})]),Rt=We([Le({Epoch:He(Ue(),Ie())}),Le({None:Be(Pe(!0))})]),Pt=He(We([Ue(),Ve(),je()]),Oe(e=>{if(!["string","number","bigint"].includes(typeof e))return!1;try{return BigInt(e),!0}catch{return!1}})),Bt=We([Le({bool:Be(Pe(!0))}),Le({u8:Be(Pe(!0))}),Le({u64:Be(Pe(!0))}),Le({u128:Be(Pe(!0))}),Le({address:Be(Pe(!0))}),Le({signer:Be(Pe(!0))}),Le({vector:Re(()=>Bt)}),Le({struct:Re(()=>Ft)}),Le({u16:Be(Pe(!0))}),Le({u32:Be(Pe(!0))}),Le({u256:Be(Pe(!0))})]),Ft=Le({address:Ve(),module:Ve(),name:Ve(),typeParams:Ne(Bt)}),Ut=Le({budget:qe(Pt),price:qe(Pt),payment:qe(Ne(At)),owner:qe(Ve())}),Lt=We([...[Dt,Le({kind:Pe("GasCoin")}),Le({kind:Pe("Result"),index:He(Ue(),Ie())}),Le({kind:Pe("NestedResult"),index:He(Ue(),Ie()),resultIndex:He(Ue(),Ie())})]]),qt=Le({kind:Pe("MoveCall"),target:He(Ve(),Oe(e=>3===e.split("::").length)),typeArguments:Ne(Ve()),arguments:Ne(Lt)}),$t=Le({kind:Pe("TransferObjects"),objects:Ne(Lt),address:Lt}),Vt=Le({kind:Pe("SplitCoins"),coin:Lt,amounts:Ne(Lt)}),zt=Le({kind:Pe("MergeCoins"),destination:Lt,sources:Ne(Lt)}),Kt=Le({kind:Pe("MakeMoveVec"),type:We([Le({Some:Bt}),Le({None:Be(Pe(!0))})]),objects:Ne(Lt)}),Wt=We([...[qt,$t,Vt,zt,Le({kind:Pe("Publish"),modules:Ne(Ne(He(Ue(),Ie()))),dependencies:Ne(Ve())}),Le({kind:Pe("Upgrade"),modules:Ne(Ne(He(Ue(),Ie()))),dependencies:Ne(Ve()),packageId:Ve(),ticket:Lt}),Kt]]);Le({version:Pe(1),sender:qe(Ve()),expiration:Fe(Rt),gasConfig:Ut,inputs:Ne(Dt),transactions:Ne(Wt)});function Qt(e){const n=e.inputs.map((e,n)=>{if(e.Object)return{kind:"Input",index:n,value:{Object:e.Object.ImmOrOwnedObject?{ImmOrOwned:e.Object.ImmOrOwnedObject}:e.Object.Receiving?{Receiving:{digest:e.Object.Receiving.digest,version:e.Object.Receiving.version,objectId:e.Object.Receiving.objectId}}:{Shared:{mutable:e.Object.SharedObject.mutable,initialSharedVersion:e.Object.SharedObject.initialSharedVersion,objectId:e.Object.SharedObject.objectId}}},type:"object"};if(e.Pure)return{kind:"Input",index:n,value:{Pure:Array.from(t(e.Pure.bytes))},type:"pure"};if(e.UnresolvedPure)return{kind:"Input",type:"pure",index:n,value:e.UnresolvedPure.value};if(e.UnresolvedObject)return{kind:"Input",type:"object",index:n,value:e.UnresolvedObject.objectId};throw new Error("Invalid input")});return{version:1,sender:e.sender??void 0,expiration:"Epoch"===e.expiration?.$kind?{Epoch:Number(e.expiration.Epoch)}:e.expiration?{None:!0}:null,gasConfig:{owner:e.gasData.owner??void 0,budget:e.gasData.budget??void 0,price:e.gasData.price??void 0,payment:e.gasData.payment??void 0},inputs:n,transactions:e.commands.map(e=>{if(e.MakeMoveVec)return{kind:"MakeMoveVec",type:null===e.MakeMoveVec.type?{None:!0}:{Some:Mt.parseFromStr(e.MakeMoveVec.type)},objects:e.MakeMoveVec.elements.map(e=>Gt(e,n))};if(e.MergeCoins)return{kind:"MergeCoins",destination:Gt(e.MergeCoins.destination,n),sources:e.MergeCoins.sources.map(e=>Gt(e,n))};if(e.MoveCall)return{kind:"MoveCall",target:`${e.MoveCall.package}::${e.MoveCall.module}::${e.MoveCall.function}`,typeArguments:e.MoveCall.typeArguments,arguments:e.MoveCall.arguments.map(e=>Gt(e,n))};if(e.Publish)return{kind:"Publish",modules:e.Publish.modules.map(e=>Array.from(t(e))),dependencies:e.Publish.dependencies};if(e.SplitCoins)return{kind:"SplitCoins",coin:Gt(e.SplitCoins.coin,n),amounts:e.SplitCoins.amounts.map(e=>Gt(e,n))};if(e.TransferObjects)return{kind:"TransferObjects",objects:e.TransferObjects.objects.map(e=>Gt(e,n)),address:Gt(e.TransferObjects.address,n)};if(e.Upgrade)return{kind:"Upgrade",modules:e.Upgrade.modules.map(e=>Array.from(t(e))),dependencies:e.Upgrade.dependencies,packageId:e.Upgrade.package,ticket:Gt(e.Upgrade.ticket,n)};throw new Error(`Unknown transaction ${Object.keys(e)}`)})}}function Gt(e,t){if("GasCoin"===e.$kind)return{kind:"GasCoin"};if("Result"===e.$kind)return{kind:"Result",index:e.Result};if("NestedResult"===e.$kind)return{kind:"NestedResult",index:e.NestedResult[0],resultIndex:e.NestedResult[1]};if("Input"===e.$kind)return t[e.Input];throw new Error(`Invalid argument ${Object.keys(e)}`)}function Ht(e){switch(e.kind){case"GasCoin":return{GasCoin:!0};case"Result":return{Result:e.index};case"NestedResult":return{NestedResult:[e.index,e.resultIndex]};case"Input":return{Input:e.index}}}function Jt(e){return We(Object.entries(e).map(([e,t])=>Le({[e]:t})))}const Zt=Jt({GasCoin:Pe(!0),Input:He(Ue(),Ie()),Result:He(Ue(),Ie()),NestedResult:ze([He(Ue(),Ie()),He(Ue(),Ie())])}),Yt=Le({budget:Be(dt),price:Be(dt),owner:Be(lt),payment:Be(Ne(pt))}),Xt=Le({package:ht,module:Ve(),function:Ve(),typeArguments:Ne(Ve()),arguments:Ne(Zt)}),en=Le({name:Ve(),inputs:$e(Ve(),We([Zt,Ne(Zt)])),data:$e(Ve(),Qe())}),tn=Jt({MoveCall:Xt,TransferObjects:Le({objects:Ne(Zt),address:Zt}),SplitCoins:Le({coin:Zt,amounts:Ne(Zt)}),MergeCoins:Le({destination:Zt,sources:Ne(Zt)}),Publish:Le({modules:Ne(ft),dependencies:Ne(ht)}),MakeMoveVec:Le({type:Be(Ve()),elements:Ne(Zt)}),Upgrade:Le({modules:Ne(ft),dependencies:Ne(ht),package:ht,ticket:Zt}),$Intent:en}),nn=Jt({ImmOrOwnedObject:pt,SharedObject:Le({objectId:ht,initialSharedVersion:dt,mutable:De()}),Receiving:pt}),rn=Jt({Object:nn,Pure:Le({bytes:ft}),UnresolvedPure:Le({value:Qe()}),UnresolvedObject:Le({objectId:ht,version:qe(Be(dt)),digest:qe(Be(Ve())),initialSharedVersion:qe(Be(dt))})}),on=Jt({None:Pe(!0),Epoch:dt}),sn=Le({version:Pe(2),sender:Fe(lt),expiration:Fe(on),gasData:Yt,inputs:Ne(rn),commands:Ne(tn),digest:qe(Be(Ve()))});const an={Pure:function(e){return{$kind:"Pure",Pure:{bytes:e instanceof Uint8Array?o(e):e.toBase64()}}},ObjectRef:({objectId:e,digest:t,version:n})=>({$kind:"Object",Object:{$kind:"ImmOrOwnedObject",ImmOrOwnedObject:{digest:t,version:n,objectId:at(e)}}}),SharedObjectRef:({objectId:e,mutable:t,initialSharedVersion:n})=>({$kind:"Object",Object:{$kind:"SharedObject",SharedObject:{mutable:t,initialSharedVersion:n,objectId:at(e)}}}),ReceivingRef:({objectId:e,digest:t,version:n})=>({$kind:"Object",Object:{$kind:"Receiving",Receiving:{digest:t,version:n,objectId:at(e)}}})},un={u8:e=>me({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:255,...e}),u16:e=>me({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:65535,...e}),u32:e=>me({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...e}),u64:e=>ge({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...e}),u128:e=>ge({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...e}),u256:e=>ge({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...e}),bool:e=>ye({name:"bool",size:1,read:e=>1===e.read8(),write:(e,t)=>t.write8(e?1:0),...e,validate:t=>{if(e?.validate?.(t),"boolean"!=typeof t)throw new TypeError("Expected boolean, found "+typeof t)}}),uleb128:e=>function({serialize:e,...t}){const n=new he({...t,serialize:e,write:(e,t)=>{for(const r of n.serialize(e).toBytes())t.write8(r)}});return n}({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(Z(e)),...e}),bytes:(e,t)=>ye({name:`bytes[${e}]`,size:e,read:t=>t.readBytes(e),write:(t,n)=>{const r=new Uint8Array(t);for(let t=0;t<e;t++)n.write8(r[t]??0)},...t,validate:n=>{if(t?.validate?.(n),!n||"object"!=typeof n||!("length"in n))throw new TypeError("Expected array, found "+typeof n);if(n.length!==e)throw new TypeError(`Expected array of length ${e}, found ${n.length}`)}}),byteVector:e=>new he({name:"bytesVector",read:e=>{const t=e.readULEB();return e.readBytes(t)},write:(e,t)=>{const n=new Uint8Array(e);t.writeULEB(n.length);for(let e=0;e<n.length;e++)t.write8(n[e]??0)},...e,serializedSize:e=>{const t="length"in e?e.length:null;return null==t?null:Z(t).length+t},validate:t=>{if(e?.validate?.(t),!t||"object"!=typeof t||!("length"in t))throw new TypeError("Expected array, found "+typeof t)}}),string:e=>function({toBytes:e,fromBytes:t,...n}){return new he({...n,read:e=>{const n=e.readULEB(),r=e.readBytes(n);return t(r)},write:(t,n)=>{const r=e(t);n.writeULEB(r.length);for(let e=0;e<r.length;e++)n.write8(r[e])},serialize:t=>{const n=e(t),r=Z(n.length),i=new Uint8Array(r.length+n.length);return i.set(r,0),i.set(n,r.length),i},validate:e=>{if("string"!=typeof e)throw new TypeError(`Invalid ${n.name} value: ${e}. Expected string`);n.validate?.(e)}})}({name:"string",toBytes:e=>(new TextEncoder).encode(e),fromBytes:e=>(new TextDecoder).decode(e),...e}),fixedArray:(e,t,n)=>new he({name:`${t.name}[${e}]`,read:n=>{const r=new Array(e);for(let i=0;i<e;i++)r[i]=t.read(n);return r},write:(e,n)=>{for(const r of e)t.write(r,n)},...n,validate:t=>{if(n?.validate?.(t),!t||"object"!=typeof t||!("length"in t))throw new TypeError("Expected array, found "+typeof t);if(t.length!==e)throw new TypeError(`Expected array of length ${e}, found ${t.length}`)}}),option:e=>un.enum(`Option<${e.name}>`,{None:null,Some:e}).transform({input:e=>null==e?{None:!0}:{Some:e},output:e=>"Some"===e.$kind?e.Some:null}),vector:(e,t)=>new he({name:`vector<${e.name}>`,read:t=>{const n=t.readULEB(),r=new Array(n);for(let i=0;i<n;i++)r[i]=e.read(t);return r},write:(t,n)=>{n.writeULEB(t.length);for(const r of t)e.write(r,n)},...t,validate:e=>{if(t?.validate?.(e),!e||"object"!=typeof e||!("length"in e))throw new TypeError("Expected array, found "+typeof e)}}),tuple:(e,t)=>new he({name:`(${e.map(e=>e.name).join(", ")})`,serializedSize:t=>{let n=0;for(let r=0;r<e.length;r++){const i=e[r].serializedSize(t[r]);if(null==i)return null;n+=i}return n},read:t=>{const n=[];for(const r of e)n.push(r.read(t));return n},write:(t,n)=>{for(let r=0;r<e.length;r++)e[r].write(t[r],n)},...t,validate:n=>{if(t?.validate?.(n),!Array.isArray(n))throw new TypeError("Expected array, found "+typeof n);if(n.length!==e.length)throw new TypeError(`Expected array of length ${e.length}, found ${n.length}`)}}),struct(e,t,n){const r=Object.entries(t);return new he({name:e,serializedSize:e=>{let t=0;for(const[n,i]of r){const r=i.serializedSize(e[n]);if(null==r)return null;t+=r}return t},read:e=>{const t={};for(const[n,i]of r)t[n]=i.read(e);return t},write:(e,t)=>{for(const[n,i]of r)i.write(e[n],t)},...n,validate:e=>{if(n?.validate?.(e),"object"!=typeof e||null==e)throw new TypeError("Expected object, found "+typeof e)}})},enum(e,t,n){const r=Object.entries(t);return new he({name:e,read:t=>{const n=t.readULEB(),i=r[n];if(!i)throw new TypeError(`Unknown value ${n} for enum ${e}`);const[o,s]=i;return{[o]:s?.read(t)??!0,$kind:o}},write:(e,n)=>{const[i,o]=Object.entries(e).filter(([e])=>Object.hasOwn(t,e))[0];for(let e=0;e<r.length;e++){const[t,s]=r[e];if(t===i)return n.writeULEB(e),void s?.write(o,n)}},...n,validate:r=>{if(n?.validate?.(r),"object"!=typeof r||null==r)throw new TypeError("Expected object, found "+typeof r);const i=Object.keys(r).filter(e=>void 0!==r[e]&&Object.hasOwn(t,e));if(1!==i.length)throw new TypeError(`Expected object with one key, but found ${i.length} for type ${e}}`);const[o]=i;if(!Object.hasOwn(t,o))throw new TypeError(`Invalid enum variant ${o}`)}})},map:(e,t)=>un.vector(un.tuple([e,t])).transform({name:`Map<${e.name}, ${t.name}>`,input:e=>[...e.entries()],output:e=>{const t=new Map;for(const[n,r]of e)t.set(n,r);return t}}),lazy:e=>function(e){let t=null;function n(){return t||(t=e()),t}return new he({name:"lazy",read:e=>n().read(e),serializedSize:e=>n().serializedSize(e),write:(e,t)=>n().write(e,t),serialize:(e,t)=>n().serialize(e,t).toBytes()})}(e)};const cn=un.bytes(32).transform({validate:e=>{const t="string"==typeof e?e:a(e);if(!t||!rt(at(t)))throw new Error(`Invalid Sui address ${t}`)},input:e=>"string"==typeof e?s(at(e)):e,output:e=>at(a(e))}),ln=un.vector(un.u8()).transform({name:"ObjectDigest",input:e=>J(e),output:e=>H(new Uint8Array(e)),validate:e=>{if(32!==J(e).length)throw new Error("ObjectDigest must be 32 bytes")}}),hn=un.struct("SuiObjectRef",{objectId:cn,version:un.u64(),digest:ln}),fn=un.struct("SharedObjectRef",{objectId:cn,initialSharedVersion:un.u64(),mutable:un.bool()}),dn=un.enum("ObjectArg",{ImmOrOwnedObject:hn,SharedObject:fn,Receiving:hn}),pn=un.enum("Owner",{AddressOwner:cn,ObjectOwner:cn,Shared:un.struct("Shared",{initialSharedVersion:un.u64()}),Immutable:null,ConsensusV2:un.struct("ConsensusV2",{authenticator:un.enum("Authenticator",{SingleOwner:cn}),startVersion:un.u64()})}),yn=un.enum("CallArg",{Pure:un.struct("Pure",{bytes:un.vector(un.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>o(new Uint8Array(e))})}),Object:dn}),mn=un.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:un.lazy(()=>mn),struct:un.lazy(()=>xn),u16:null,u32:null,u256:null}),gn=mn.transform({input:e=>"string"==typeof e?Mt.parseFromStr(e,!0):e,output:e=>Mt.tagToString(e)}),bn=un.enum("Argument",{GasCoin:null,Input:un.u16(),Result:un.u16(),NestedResult:un.tuple([un.u16(),un.u16()])}),vn=un.struct("ProgrammableMoveCall",{package:cn,module:un.string(),function:un.string(),typeArguments:un.vector(gn),arguments:un.vector(bn)}),wn=un.enum("Command",{MoveCall:vn,TransferObjects:un.struct("TransferObjects",{objects:un.vector(bn),address:bn}),SplitCoins:un.struct("SplitCoins",{coin:bn,amounts:un.vector(bn)}),MergeCoins:un.struct("MergeCoins",{destination:bn,sources:un.vector(bn)}),Publish:un.struct("Publish",{modules:un.vector(un.vector(un.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>o(new Uint8Array(e))})),dependencies:un.vector(cn)}),MakeMoveVec:un.struct("MakeMoveVec",{type:(En=gn,un.enum("Option",{None:null,Some:En})).transform({input:e=>null===e?{None:!0}:{Some:e},output:e=>e.Some??null}),elements:un.vector(bn)}),Upgrade:un.struct("Upgrade",{modules:un.vector(un.vector(un.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>o(new Uint8Array(e))})),dependencies:un.vector(cn),package:cn,ticket:bn})});var En;const kn=un.struct("ProgrammableTransaction",{inputs:un.vector(yn),commands:un.vector(wn)}),Sn=un.enum("TransactionKind",{ProgrammableTransaction:kn,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Tn=un.enum("TransactionExpiration",{None:null,Epoch:un.u64({name:"unsafe_u64",..._n}).transform({input:e=>e,output:e=>Number(e)})});var _n;const xn=un.struct("StructTag",{address:cn,module:un.string(),name:un.string(),typeParams:un.vector(mn)}),On=un.struct("GasData",{payment:un.vector(hn),owner:cn,price:un.u64(),budget:un.u64()}),In=un.struct("TransactionDataV1",{kind:Sn,sender:cn,gasData:On,expiration:Tn}),Cn=un.enum("TransactionData",{V1:In}),Mn=un.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),An=un.enum("IntentVersion",{V0:null}),Nn=un.enum("AppId",{Sui:null}),jn=un.struct("Intent",{scope:Mn,version:An,appId:Nn});function Dn(e){return un.struct(`IntentMessage<${e.name}>`,{intent:jn,value:e})}const Rn=un.enum("CompressedSignature",{ED25519:un.fixedArray(64,un.u8()),Secp256k1:un.fixedArray(64,un.u8()),Secp256r1:un.fixedArray(64,un.u8()),ZkLogin:un.vector(un.u8())}),Pn=un.enum("PublicKey",{ED25519:un.fixedArray(32,un.u8()),Secp256k1:un.fixedArray(33,un.u8()),Secp256r1:un.fixedArray(33,un.u8()),ZkLogin:un.vector(un.u8())}),Bn=un.struct("MultiSigPkMap",{pubKey:Pn,weight:un.u8()}),Fn=un.struct("MultiSigPublicKey",{pk_map:un.vector(Bn),threshold:un.u16()}),Un=un.struct("MultiSig",{sigs:un.vector(Rn),bitmap:un.u16(),multisig_pk:Fn}),Ln=un.vector(un.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>o(new Uint8Array(e))}),qn=un.struct("SenderSignedTransaction",{intentMessage:Dn(Cn),txSignatures:un.vector(Ln)}),$n=un.vector(qn,{name:"SenderSignedData"}),Vn=un.struct("PasskeyAuthenticator",{authenticatorData:un.vector(un.u8()),clientDataJson:un.string(),userSignature:un.vector(un.u8())}),zn=un.enum("PackageUpgradeError",{UnableToFetchPackage:un.struct("UnableToFetchPackage",{packageId:cn}),NotAPackage:un.struct("NotAPackage",{objectId:cn}),IncompatibleUpgrade:null,DigestDoesNotMatch:un.struct("DigestDoesNotMatch",{digest:un.vector(un.u8())}),UnknownUpgradePolicy:un.struct("UnknownUpgradePolicy",{policy:un.u8()}),PackageIDDoesNotMatch:un.struct("PackageIDDoesNotMatch",{packageId:cn,ticketId:cn})}),Kn=un.struct("ModuleId",{address:cn,name:un.string()}),Wn=un.struct("MoveLocation",{module:Kn,function:un.u16(),instruction:un.u16(),functionName:un.option(un.string())}),Qn=un.enum("CommandArgumentError",{TypeMismatch:null,InvalidBCSBytes:null,InvalidUsageOfPureArg:null,InvalidArgumentToPrivateEntryFunction:null,IndexOutOfBounds:un.struct("IndexOutOfBounds",{idx:un.u16()}),SecondaryIndexOutOfBounds:un.struct("SecondaryIndexOutOfBounds",{resultIdx:un.u16(),secondaryIdx:un.u16()}),InvalidResultArity:un.struct("InvalidResultArity",{resultIdx:un.u16()}),InvalidGasCoinUsage:null,InvalidValueUsage:null,InvalidObjectByValue:null,InvalidObjectByMutRef:null,SharedObjectOperationNotAllowed:null}),Gn=un.enum("TypeArgumentError",{TypeNotFound:null,ConstraintNotSatisfied:null}),Hn=un.enum("ExecutionFailureStatus",{InsufficientGas:null,InvalidGasObject:null,InvariantViolation:null,FeatureNotYetSupported:null,MoveObjectTooBig:un.struct("MoveObjectTooBig",{objectSize:un.u64(),maxObjectSize:un.u64()}),MovePackageTooBig:un.struct("MovePackageTooBig",{objectSize:un.u64(),maxObjectSize:un.u64()}),CircularObjectOwnership:un.struct("CircularObjectOwnership",{object:cn}),InsufficientCoinBalance:null,CoinBalanceOverflow:null,PublishErrorNonZeroAddress:null,SuiMoveVerificationError:null,MovePrimitiveRuntimeError:un.option(Wn),MoveAbort:un.tuple([Wn,un.u64()]),VMVerificationOrDeserializationError:null,VMInvariantViolation:null,FunctionNotFound:null,ArityMismatch:null,TypeArityMismatch:null,NonEntryFunctionInvoked:null,CommandArgumentError:un.struct("CommandArgumentError",{argIdx:un.u16(),kind:Qn}),TypeArgumentError:un.struct("TypeArgumentError",{argumentIdx:un.u16(),kind:Gn}),UnusedValueWithoutDrop:un.struct("UnusedValueWithoutDrop",{resultIdx:un.u16(),secondaryIdx:un.u16()}),InvalidPublicFunctionReturnType:un.struct("InvalidPublicFunctionReturnType",{idx:un.u16()}),InvalidTransferObject:null,EffectsTooLarge:un.struct("EffectsTooLarge",{currentSize:un.u64(),maxSize:un.u64()}),PublishUpgradeMissingDependency:null,PublishUpgradeDependencyDowngrade:null,PackageUpgradeError:un.struct("PackageUpgradeError",{upgradeError:zn}),WrittenObjectsTooLarge:un.struct("WrittenObjectsTooLarge",{currentSize:un.u64(),maxSize:un.u64()}),CertificateDenied:null,SuiMoveVerificationTimedout:null,SharedObjectOperationNotAllowed:null,InputObjectDeleted:null,ExecutionCancelledDueToSharedObjectCongestion:un.struct("ExecutionCancelledDueToSharedObjectCongestion",{congestedObjects:un.vector(cn)}),AddressDeniedForCoin:un.struct("AddressDeniedForCoin",{address:cn,coinType:un.string()}),CoinTypeGlobalPause:un.struct("CoinTypeGlobalPause",{coinType:un.string()}),ExecutionCancelledDueToRandomnessUnavailable:null}),Jn=un.enum("ExecutionStatus",{Success:null,Failed:un.struct("ExecutionFailed",{error:Hn,command:un.option(un.u64())})}),Zn=un.struct("GasCostSummary",{computationCost:un.u64(),storageCost:un.u64(),storageRebate:un.u64(),nonRefundableStorageFee:un.u64()}),Yn=un.struct("TransactionEffectsV1",{status:Jn,executedEpoch:un.u64(),gasUsed:Zn,modifiedAtVersions:un.vector(un.tuple([cn,un.u64()])),sharedObjects:un.vector(hn),transactionDigest:ln,created:un.vector(un.tuple([hn,pn])),mutated:un.vector(un.tuple([hn,pn])),unwrapped:un.vector(un.tuple([hn,pn])),deleted:un.vector(hn),unwrappedThenDeleted:un.vector(hn),wrapped:un.vector(hn),gasObject:un.tuple([hn,pn]),eventsDigest:un.option(ln),dependencies:un.vector(ln)}),Xn=un.tuple([un.u64(),ln]),er=un.enum("ObjectIn",{NotExist:null,Exist:un.tuple([Xn,pn])}),tr=un.enum("ObjectOut",{NotExist:null,ObjectWrite:un.tuple([ln,pn]),PackageWrite:Xn}),nr=un.enum("IDOperation",{None:null,Created:null,Deleted:null}),rr=un.struct("EffectsObjectChange",{inputState:er,outputState:tr,idOperation:nr}),ir=un.enum("UnchangedSharedKind",{ReadOnlyRoot:Xn,MutateDeleted:un.u64(),ReadDeleted:un.u64(),Cancelled:un.u64(),PerEpochConfig:null}),or=un.struct("TransactionEffectsV2",{status:Jn,executedEpoch:un.u64(),gasUsed:Zn,transactionDigest:ln,gasObjectIndex:un.option(un.u32()),eventsDigest:un.option(ln),dependencies:un.vector(ln),lamportVersion:un.u64(),changedObjects:un.vector(un.tuple([cn,rr])),unchangedSharedObjects:un.vector(un.tuple([cn,ir])),auxDataDigest:un.option(ln)}),sr=un.enum("TransactionEffects",{V1:Yn,V2:or}),ar={...un,U8:un.u8(),U16:un.u16(),U32:un.u32(),U64:un.u64(),U128:un.u128(),U256:un.u256(),ULEB128:un.uleb128(),Bool:un.bool(),String:un.string(),Address:cn,AppId:Nn,Argument:bn,CallArg:yn,Command:wn,CompressedSignature:Rn,GasData:On,Intent:jn,IntentMessage:Dn,IntentScope:Mn,IntentVersion:An,MultiSig:Un,MultiSigPkMap:Bn,MultiSigPublicKey:Fn,ObjectArg:dn,ObjectDigest:ln,Owner:pn,PasskeyAuthenticator:Vn,ProgrammableMoveCall:vn,ProgrammableTransaction:kn,PublicKey:Pn,SenderSignedData:$n,SenderSignedTransaction:qn,SharedObjectRef:fn,StructTag:xn,SuiObjectRef:hn,TransactionData:Cn,TransactionDataV1:In,TransactionEffects:sr,TransactionExpiration:Tn,TransactionKind:Sn,TypeTag:gn},ur=(BigInt(1e9),ut("0x6"),"0x2::sui::SUI"),cr=ut("0x5");function lr(e){if("string"==typeof e)switch(e){case"address":return ar.Address;case"bool":return ar.Bool;case"u8":return ar.U8;case"u16":return ar.U16;case"u32":return ar.U32;case"u64":return ar.U64;case"u128":return ar.U128;case"u256":return ar.U256;default:throw new Error(`Unknown type signature ${e}`)}if("vector"in e){if("u8"===e.vector)return ar.vector(ar.U8).transform({input:e=>"string"==typeof e?(new TextEncoder).encode(e):e,output:e=>e});const t=lr(e.vector);return t?ar.vector(t):null}if("datatype"in e){const t=at(e.datatype.package);if(t===at("0x1")){if("ascii"===e.datatype.module&&"String"===e.datatype.type)return ar.String;if("string"===e.datatype.module&&"String"===e.datatype.type)return ar.String;if("option"===e.datatype.module&&"Option"===e.datatype.type){const t=lr(e.datatype.typeParameters[0]);return t?ar.vector(t):null}}if(t===at("0x2")&&"object"===e.datatype.module&&"ID"===e.datatype.type)return ar.Address}return null}function hr(e){if("string"==typeof e)switch(e){case"Address":return"address";case"Bool":return"bool";case"U8":return"u8";case"U16":return"u16";case"U32":return"u32";case"U64":return"u64";case"U128":return"u128";case"U256":return"u256";default:throw new Error(`Unexpected type ${e}`)}if("Vector"in e)return{vector:hr(e.Vector)};if("Struct"in e)return{datatype:{package:e.Struct.address,module:e.Struct.module,type:e.Struct.name,typeParameters:e.Struct.typeArguments.map(hr)}};if("TypeParameter"in e)return{typeParameter:e.TypeParameter};throw new Error(`Unexpected type ${JSON.stringify(e)}`)}function fr(e,t){return Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))}const dr=5e10;function pr(e){return async function(t,n,r){return await async function(e,t){const{inputs:n,commands:r}=e,i=[],o=new Set;r.forEach(t=>{if(t.MoveCall){if(t.MoveCall._argumentTypes)return;if(t.MoveCall.arguments.map(t=>"Input"===t.$kind?e.inputs[t.Input]:null).some(e=>e?.UnresolvedPure||e?.UnresolvedObject)){const e=`${t.MoveCall.package}::${t.MoveCall.module}::${t.MoveCall.function}`;o.add(e),i.push(t.MoveCall)}}});const s=new Map;o.size>0&&await Promise.all([...o].map(async e=>{const[n,r,i]=e.split("::"),o=await t.getNormalizedMoveFunction({package:n,module:r,function:i});s.set(e,o.parameters.map(e=>function(e){return"object"==typeof e&&"Reference"in e?{ref:"&",body:hr(e.Reference)}:"object"==typeof e&&"MutableReference"in e?{ref:"&mut",body:hr(e.MutableReference)}:{ref:null,body:hr(e)}}(e)))}));i.length&&await Promise.all(i.map(async e=>{const t=s.get(`${e.package}::${e.module}::${e.function}`);if(!t)return;const n=t.length>0&&function(e){const t="object"==typeof e.body&&"datatype"in e.body?e.body.datatype:null;return!!t&&at(t.package)===at("0x2")&&"tx_context"===t.module&&"TxContext"===t.type}(t.at(-1))?t.slice(0,t.length-1):t;e._argumentTypes=n}));r.forEach(e=>{if(!e.MoveCall)return;const t=e.MoveCall,r=`${t.package}::${t.module}::${t.function}`,i=t._argumentTypes;if(i){if(i.length!==e.MoveCall.arguments.length)throw new Error(`Incorrect number of arguments for ${r}`);i.forEach((e,r)=>{const i=t.arguments[r];if("Input"!==i.$kind)return;const o=n[i.Input];if(!o.UnresolvedPure&&!o.UnresolvedObject)return;const s=o.UnresolvedPure?.value??o.UnresolvedObject?.objectId,a=lr(e.body);if(a)return i.type="pure",void(n[n.indexOf(o)]=an.Pure(a.serialize(s)));if("string"!=typeof s)throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(s,null,2)}`);i.type="object";const u=o.UnresolvedPure?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:s}}:o;n[i.Input]=u})}})}(t,e),await async function(e,t){const n=e.inputs.filter(e=>e.UnresolvedObject&&!(e.UnresolvedObject.version||e.UnresolvedObject?.initialSharedVersion)),r=[...new Set(n.map(e=>ut(e.UnresolvedObject.objectId)))],i=r.length?fr(r,50):[],o=(await Promise.all(i.map(e=>t.multiGetObjects({ids:e,options:{showOwner:!0}})))).flat(),s=new Map(r.map((e,t)=>[e,o[t]])),a=Array.from(s).filter(([e,t])=>t.error).map(([e,t])=>JSON.stringify(t.error));if(a.length)throw new Error(`The following input objects are invalid: ${a.join(", ")}`);const u=o.map(e=>{if(e.error||!e.data)throw new Error(`Failed to fetch object: ${e.error}`);const t=e.data.owner,n=t&&"object"==typeof t&&"Shared"in t?t.Shared.initial_shared_version:null;return{objectId:e.data.objectId,digest:e.data.digest,version:e.data.version,initialSharedVersion:n}}),c=new Map(r.map((e,t)=>[e,u[t]]));for(const[t,n]of e.inputs.entries()){if(!n.UnresolvedObject)continue;let r;const i=at(n.UnresolvedObject.objectId),o=c.get(i);n.UnresolvedObject.initialSharedVersion??o?.initialSharedVersion?r=an.SharedObjectRef({objectId:i,initialSharedVersion:n.UnresolvedObject.initialSharedVersion||o?.initialSharedVersion,mutable:yr(e,t)}):mr(e,t)&&(r=an.ReceivingRef({objectId:i,digest:n.UnresolvedObject.digest??o?.digest,version:n.UnresolvedObject.version??o?.version})),e.inputs[e.inputs.indexOf(n)]=r??an.ObjectRef({objectId:i,digest:n.UnresolvedObject.digest??o?.digest,version:n.UnresolvedObject.version??o?.version})}}(t,e),n.onlyTransactionKind||(await async function(e,t){e.gasConfig.price||(e.gasConfig.price=String(await t.getReferenceGasPrice()))}(t,e),await async function(e,t){if(e.gasConfig.budget)return;const n=await t.dryRunTransactionBlock({transactionBlock:e.build({overrides:{gasData:{budget:String(dr),payment:[]}}})});if("success"!==n.effects.status.status)throw new Error(`Dry run failed, could not automatically determine a budget: ${n.effects.status.error}`,{cause:n});const r=1000n*BigInt(e.gasConfig.price||1n),i=BigInt(n.effects.gasUsed.computationCost)+r,o=i+BigInt(n.effects.gasUsed.storageCost)-BigInt(n.effects.gasUsed.storageRebate);e.gasConfig.budget=String(o>i?o:i)}(t,e),await async function(e,t){if(!e.gasConfig.payment){const n=(await t.getCoins({owner:e.gasConfig.owner||e.sender,coinType:ur})).data.filter(t=>!e.inputs.find(e=>!!e.Object?.ImmOrOwnedObject&&t.coinObjectId===e.Object.ImmOrOwnedObject.objectId)).map(e=>({objectId:e.coinObjectId,digest:e.digest,version:e.version}));if(!n.length)throw new Error("No valid gas coins found for the transaction.");e.gasConfig.payment=n.map(e=>Ge(pt,e))}}(t,e)),await r()}}function yr(e,t){let n=!1;return e.getInputUses(t,(e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const r=t.MoveCall.arguments.indexOf(e);n="&"!==t.MoveCall._argumentTypes[r].ref||n}"MakeMoveVec"!==t.$kind&&"MergeCoins"!==t.$kind&&"SplitCoins"!==t.$kind||(n=!0)}),n}function mr(e,t){let n=!1;return e.getInputUses(t,(e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const r=t.MoveCall.arguments.indexOf(e);n=function(e){if("object"!=typeof e.body||!("datatype"in e.body))return!1;return"0x2"===e.body.datatype.package&&"transfer"===e.body.datatype.module&&"Receiving"===e.body.datatype.type}(t.MoveCall._argumentTypes[r])||n}}),n}function gr(e,t){return!!e.inputs.some(e=>e.UnresolvedObject||e.UnresolvedPure)||!(t.onlyTransactionKind||e.gasConfig.price&&e.gasConfig.budget&&e.gasConfig.payment)}async function br(e,t,n){if(function(e){for(const t of e.commands)switch(t.$kind){case"SplitCoins":t.SplitCoins.amounts.forEach(t=>{wr(t,ar.U64,e)});break;case"TransferObjects":wr(t.TransferObjects.address,ar.Address,e)}}(e),!gr(e,t))return await vr(e),n();const r=function(e){if(!e.client)throw new Error("No sui client passed to Transaction#build, but transaction data was not sufficient to build offline.");return e.client}(t);return(r.core?.resolveTransactionPlugin()??pr(r))(e,t,async()=>{await vr(e),await n()})}function vr(e){e.inputs.forEach((e,t)=>{if("Object"!==e.$kind&&"Pure"!==e.$kind)throw new Error(`Input at index ${t} has not been resolved. Expected a Pure or Object input, but found ${JSON.stringify(e)}`)})}function wr(e,t,n){if("Input"!==e.$kind)return;const r=n.inputs[e.Input];"UnresolvedPure"===r.$kind&&(n.inputs[e.Input]=an.Pure(t.serialize(r.UnresolvedPure.value)))}function Er(e){switch(e){case"u8":return un.u8();case"u16":return un.u16();case"u32":return un.u32();case"u64":return un.u64();case"u128":return un.u128();case"u256":return un.u256();case"bool":return un.bool();case"string":return un.string();case"id":case"address":return cn}const t=e.match(/^(vector|option)<(.+)>$/);if(t){const[e,n]=t.slice(1);return"vector"===e?un.vector(Er(n)):un.option(Er(n))}throw new Error(`Invalid Pure type name: ${e}`)}function kr(e){function t(t,n){if("string"==typeof t)return e(Er(t).serialize(n));if(t instanceof Uint8Array||de(t))return e(t);throw new Error("tx.pure must be called either a bcs type name, or a serialized bcs value")}return t.u8=t=>e(ar.U8.serialize(t)),t.u16=t=>e(ar.U16.serialize(t)),t.u32=t=>e(ar.U32.serialize(t)),t.u64=t=>e(ar.U64.serialize(t)),t.u128=t=>e(ar.U128.serialize(t)),t.u256=t=>e(ar.U256.serialize(t)),t.bool=t=>e(ar.Bool.serialize(t)),t.string=t=>e(ar.String.serialize(t)),t.address=t=>e(ar.Address.serialize(t)),t.id=t.address,t.vector=(t,n)=>e(ar.vector(Er(t)).serialize(n)),t.option=(t,n)=>e(ar.option(Er(t)).serialize(n)),t}const Sr="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function Tr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function _r(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function xr(e,...t){if(!Tr(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Or(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");_r(e.outputLen),_r(e.blockLen)}function Ir(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Cr(e,t){xr(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Mr(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ar(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Nr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function jr(e,t){return e<<32-t|e>>>t}const Dr=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function Rr(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Pr=Dr?e=>e:e=>Rr(e);const Br=Dr?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=Rr(e[t]);return e},Fr=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),Ur=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Lr(e){if(xr(e),Fr)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Ur[e[n]];return t}const qr=48,$r=57,Vr=65,zr=70,Kr=97,Wr=102;function Qr(e){return e>=qr&&e<=$r?e-qr:e>=Vr&&e<=zr?e-(Vr-10):e>=Kr&&e<=Wr?e-(Kr-10):void 0}function Gr(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(Fr)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){const n=Qr(e.charCodeAt(i)),o=Qr(e.charCodeAt(i+1));if(void 0===n||void 0===o){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+o}return r}function Hr(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function Jr(e){return"string"==typeof e&&(e=Hr(e)),xr(e),e}function Zr(e){return"string"==typeof e&&(e=Hr(e)),xr(e),e}function Yr(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];xr(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const i=e[t];n.set(i,r),r+=i.length}return n}class Xr{}function ei(e){const t=t=>e().update(Jr(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ti(e){const t=(t,n)=>e(n).update(Jr(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}function ni(e=32){if(Sr&&"function"==typeof Sr.getRandomValues)return Sr.getRandomValues(new Uint8Array(e));if(Sr&&"function"==typeof Sr.randomBytes)return Uint8Array.from(Sr.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const ri=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);function ii(e,t,n){return e&t^~e&n}function oi(e,t,n){return e&t^e&n^t&n}class si extends Xr{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Nr(this.buffer)}update(e){Ir(this),xr(e=Jr(e));const{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let o=0;o<i;){const s=Math.min(r-this.pos,i-o);if(s===r){const t=Nr(e);for(;r<=i-o;o+=r)this.process(t,o);continue}n.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ir(this),Cr(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;t[o++]=128,Ar(this.buffer.subarray(o)),this.padOffset>r-o&&(this.process(n,0),o=0);for(let e=o;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),u=r?4:0,c=r?0:4;e.setUint32(t+u,s,r),e.setUint32(t+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=Nr(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<u;e++)s.setUint32(4*e,c[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return e.destroyed=o,e.finished=i,e.length=r,e.pos=s,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const ai=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ui=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),ci=BigInt(2**32-1),li=BigInt(32);function hi(e,t=!1){return t?{h:Number(e&ci),l:Number(e>>li&ci)}:{h:0|Number(e>>li&ci),l:0|Number(e&ci)}}function fi(e,t=!1){const n=e.length;let r=new Uint32Array(n),i=new Uint32Array(n);for(let o=0;o<n;o++){const{h:n,l:s}=hi(e[o],t);[r[o],i[o]]=[n,s]}return[r,i]}const di=(e,t,n)=>e>>>n,pi=(e,t,n)=>e<<32-n|t>>>n,yi=(e,t,n)=>e>>>n|t<<32-n,mi=(e,t,n)=>e<<32-n|t>>>n,gi=(e,t,n)=>e<<64-n|t>>>n-32,bi=(e,t,n)=>e>>>n-32|t<<64-n,vi=(e,t)=>t,wi=(e,t)=>e;function Ei(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:0|i}}const ki=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Si=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Ti=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),_i=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,xi=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),Oi=(e,t,n,r,i,o)=>t+n+r+i+o+(e/2**32|0)|0,Ii=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Ci=new Uint32Array(32);function Mi(e,t,n,r,i,o){const s=i[o],a=i[o+1];let u=Ci[2*e],c=Ci[2*e+1],l=Ci[2*t],h=Ci[2*t+1],f=Ci[2*n],d=Ci[2*n+1],p=Ci[2*r],y=Ci[2*r+1],m=ki(u,l,s);c=Si(m,c,h,a),u=0|m,({Dh:y,Dl:p}={Dh:y^c,Dl:p^u}),({Dh:y,Dl:p}={Dh:vi(0,p),Dl:wi(y)}),({h:d,l:f}=Ei(d,f,y,p)),({Bh:h,Bl:l}={Bh:h^d,Bl:l^f}),({Bh:h,Bl:l}={Bh:yi(h,l,24),Bl:mi(h,l,24)}),Ci[2*e]=u,Ci[2*e+1]=c,Ci[2*t]=l,Ci[2*t+1]=h,Ci[2*n]=f,Ci[2*n+1]=d,Ci[2*r]=p,Ci[2*r+1]=y}function Ai(e,t,n,r,i,o){const s=i[o],a=i[o+1];let u=Ci[2*e],c=Ci[2*e+1],l=Ci[2*t],h=Ci[2*t+1],f=Ci[2*n],d=Ci[2*n+1],p=Ci[2*r],y=Ci[2*r+1],m=ki(u,l,s);c=Si(m,c,h,a),u=0|m,({Dh:y,Dl:p}={Dh:y^c,Dl:p^u}),({Dh:y,Dl:p}={Dh:yi(y,p,16),Dl:mi(y,p,16)}),({h:d,l:f}=Ei(d,f,y,p)),({Bh:h,Bl:l}={Bh:h^d,Bl:l^f}),({Bh:h,Bl:l}={Bh:gi(h,l,63),Bl:bi(h,l,63)}),Ci[2*e]=u,Ci[2*e+1]=c,Ci[2*t]=l,Ci[2*t+1]=h,Ci[2*n]=f,Ci[2*n+1]=d,Ci[2*r]=p,Ci[2*r+1]=y}function Ni(e,t={},n,r,i){if(_r(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:s,personalization:a}=t;if(void 0!==o&&(o.length<1||o.length>n))throw new Error("key length must be undefined or 1.."+n);if(void 0!==s&&s.length!==r)throw new Error("salt must be undefined or "+r);if(void 0!==a&&a.length!==i)throw new Error("personalization must be undefined or "+i)}class ji extends Xr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,_r(e),_r(t),this.blockLen=e,this.outputLen=t,this.buffer=new Uint8Array(e),this.buffer32=Mr(this.buffer)}update(e){Ir(this),xr(e=Jr(e));const{blockLen:t,buffer:n,buffer32:r}=this,i=e.length,o=e.byteOffset,s=e.buffer;for(let a=0;a<i;){this.pos===t&&(Br(r),this.compress(r,0,!1),Br(r),this.pos=0);const u=Math.min(t-this.pos,i-a),c=o+a;if(u===t&&!(c%4)&&a+u<i){const e=new Uint32Array(s,c,Math.floor((i-a)/4));Br(e);for(let n=0;a+t<i;n+=r.length,a+=t)this.length+=t,this.compress(e,n,!1);Br(e);continue}n.set(e.subarray(a,a+u),this.pos),this.pos+=u,this.length+=u,a+=u}return this}digestInto(e){Ir(this),Cr(e,this);const{pos:t,buffer32:n}=this;this.finished=!0,Ar(this.buffer.subarray(t)),Br(n),this.compress(n,0,!0),Br(n);const r=Mr(e);this.get().forEach((e,t)=>r[t]=Pr(e))}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){const{buffer:t,length:n,finished:r,destroyed:i,outputLen:o,pos:s}=this;return e||(e=new this.constructor({dkLen:o})),e.set(...this.get()),e.buffer.set(t),e.destroyed=i,e.finished=r,e.length=n,e.pos=s,e.outputLen=o,e}clone(){return this._cloneInto()}}class Di extends ji{constructor(e={}){const t=void 0===e.dkLen?64:e.dkLen;super(128,t),this.v0l=0|Ii[0],this.v0h=0|Ii[1],this.v1l=0|Ii[2],this.v1h=0|Ii[3],this.v2l=0|Ii[4],this.v2h=0|Ii[5],this.v3l=0|Ii[6],this.v3h=0|Ii[7],this.v4l=0|Ii[8],this.v4h=0|Ii[9],this.v5l=0|Ii[10],this.v5h=0|Ii[11],this.v6l=0|Ii[12],this.v6h=0|Ii[13],this.v7l=0|Ii[14],this.v7h=0|Ii[15],Ni(t,e,64,16,16);let{key:n,personalization:r,salt:i}=e,o=0;if(void 0!==n&&(n=Jr(n),o=n.length),this.v0l^=this.outputLen|o<<8|65536|1<<24,void 0!==i){i=Jr(i);const e=Mr(i);this.v4l^=Pr(e[0]),this.v4h^=Pr(e[1]),this.v5l^=Pr(e[2]),this.v5h^=Pr(e[3])}if(void 0!==r){r=Jr(r);const e=Mr(r);this.v6l^=Pr(e[0]),this.v6h^=Pr(e[1]),this.v7l^=Pr(e[2]),this.v7h^=Pr(e[3])}if(void 0!==n){const e=new Uint8Array(this.blockLen);e.set(n),this.update(e)}}get(){let{v0l:e,v0h:t,v1l:n,v1h:r,v2l:i,v2h:o,v3l:s,v3h:a,v4l:u,v4h:c,v5l:l,v5h:h,v6l:f,v6h:d,v7l:p,v7h:y}=this;return[e,t,n,r,i,o,s,a,u,c,l,h,f,d,p,y]}set(e,t,n,r,i,o,s,a,u,c,l,h,f,d,p,y){this.v0l=0|e,this.v0h=0|t,this.v1l=0|n,this.v1h=0|r,this.v2l=0|i,this.v2h=0|o,this.v3l=0|s,this.v3h=0|a,this.v4l=0|u,this.v4h=0|c,this.v5l=0|l,this.v5h=0|h,this.v6l=0|f,this.v6h=0|d,this.v7l=0|p,this.v7h=0|y}compress(e,t,n){this.get().forEach((e,t)=>Ci[t]=e),Ci.set(Ii,16);let{h:r,l:i}=hi(BigInt(this.length));Ci[24]=Ii[8]^i,Ci[25]=Ii[9]^r,n&&(Ci[28]=~Ci[28],Ci[29]=~Ci[29]);let o=0;const s=ri;for(let n=0;n<12;n++)Mi(0,4,8,12,e,t+2*s[o++]),Ai(0,4,8,12,e,t+2*s[o++]),Mi(1,5,9,13,e,t+2*s[o++]),Ai(1,5,9,13,e,t+2*s[o++]),Mi(2,6,10,14,e,t+2*s[o++]),Ai(2,6,10,14,e,t+2*s[o++]),Mi(3,7,11,15,e,t+2*s[o++]),Ai(3,7,11,15,e,t+2*s[o++]),Mi(0,5,10,15,e,t+2*s[o++]),Ai(0,5,10,15,e,t+2*s[o++]),Mi(1,6,11,12,e,t+2*s[o++]),Ai(1,6,11,12,e,t+2*s[o++]),Mi(2,7,8,13,e,t+2*s[o++]),Ai(2,7,8,13,e,t+2*s[o++]),Mi(3,4,9,14,e,t+2*s[o++]),Ai(3,4,9,14,e,t+2*s[o++]);this.v0l^=Ci[0]^Ci[16],this.v0h^=Ci[1]^Ci[17],this.v1l^=Ci[2]^Ci[18],this.v1h^=Ci[3]^Ci[19],this.v2l^=Ci[4]^Ci[20],this.v2h^=Ci[5]^Ci[21],this.v3l^=Ci[6]^Ci[22],this.v3h^=Ci[7]^Ci[23],this.v4l^=Ci[8]^Ci[24],this.v4h^=Ci[9]^Ci[25],this.v5l^=Ci[10]^Ci[26],this.v5h^=Ci[11]^Ci[27],this.v6l^=Ci[12]^Ci[28],this.v6h^=Ci[13]^Ci[29],this.v7l^=Ci[14]^Ci[30],this.v7h^=Ci[15]^Ci[31],Ar(Ci)}destroy(){this.destroyed=!0,Ar(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Ri=ti(e=>new Di(e));const Pi=Ri;function Bi(e){return at(e).replace("0x","")}class Fi{constructor(e){this.version=2,this.sender=e?.sender??null,this.expiration=e?.expiration??null,this.inputs=e?.inputs??[],this.commands=e?.commands??[],this.gasData=e?.gasData??{budget:null,price:null,owner:null,payment:null}}static fromKindBytes(e){const t=ar.TransactionKind.parse(e).ProgrammableTransaction;if(!t)throw new Error("Unable to deserialize from bytes.");return Fi.restore({version:2,sender:null,expiration:null,gasData:{budget:null,owner:null,payment:null,price:null},inputs:t.inputs,commands:t.commands})}static fromBytes(e){const t=ar.TransactionData.parse(e),n=t?.V1,r=n.kind.ProgrammableTransaction;if(!n||!r)throw new Error("Unable to deserialize from bytes.");return Fi.restore({version:2,sender:n.sender,expiration:n.expiration,gasData:n.gasData,inputs:r.inputs,commands:r.commands})}static restore(e){return 2===e.version?new Fi(Ge(xt,e)):new Fi(Ge(xt,function(e){return Ge(xt,{version:2,sender:e.sender??null,expiration:e.expiration?"Epoch"in e.expiration?{Epoch:e.expiration.Epoch}:{None:!0}:null,gasData:{owner:e.gasConfig.owner??null,budget:e.gasConfig.budget?.toString()??null,price:e.gasConfig.price?.toString()??null,payment:e.gasConfig.payment?.map(e=>({digest:e.digest,objectId:e.objectId,version:e.version.toString()}))??null},inputs:e.inputs.map(e=>{if("Input"===e.kind){if(Ae(jt,e.value)){const t=Ge(jt,e.value);if(t.Object){if(t.Object.ImmOrOwned)return{Object:{ImmOrOwnedObject:{objectId:t.Object.ImmOrOwned.objectId,version:String(t.Object.ImmOrOwned.version),digest:t.Object.ImmOrOwned.digest}}};if(t.Object.Shared)return{Object:{SharedObject:{mutable:t.Object.Shared.mutable??null,initialSharedVersion:t.Object.Shared.initialSharedVersion,objectId:t.Object.Shared.objectId}}};if(t.Object.Receiving)return{Object:{Receiving:{digest:t.Object.Receiving.digest,version:String(t.Object.Receiving.version),objectId:t.Object.Receiving.objectId}}};throw new Error("Invalid object input")}return{Pure:{bytes:o(new Uint8Array(t.Pure))}}}return"object"===e.type?{UnresolvedObject:{objectId:e.value}}:{UnresolvedPure:{value:e.value}}}throw new Error("Invalid input")}),commands:e.transactions.map(e=>{switch(e.kind){case"MakeMoveVec":return{MakeMoveVec:{type:"Some"in e.type?Mt.tagToString(e.type.Some):null,elements:e.objects.map(e=>Ht(e))}};case"MergeCoins":return{MergeCoins:{destination:Ht(e.destination),sources:e.sources.map(e=>Ht(e))}};case"MoveCall":{const[t,n,r]=e.target.split("::");return{MoveCall:{package:t,module:n,function:r,typeArguments:e.typeArguments,arguments:e.arguments.map(e=>Ht(e))}}}case"Publish":return{Publish:{modules:e.modules.map(e=>o(Uint8Array.from(e))),dependencies:e.dependencies}};case"SplitCoins":return{SplitCoins:{coin:Ht(e.coin),amounts:e.amounts.map(e=>Ht(e))}};case"TransferObjects":return{TransferObjects:{objects:e.objects.map(e=>Ht(e)),address:Ht(e.address)}};case"Upgrade":return{Upgrade:{modules:e.modules.map(e=>o(Uint8Array.from(e))),dependencies:e.dependencies,package:e.packageId,ticket:Ht(e.ticket)}}}throw new Error(`Unknown transaction ${Object.keys(e)}`)})})}(e)))}static getDigestFromBytes(e){const t=function(e,t){const n=Array.from(`${e}::`).map(e=>e.charCodeAt(0)),r=new Uint8Array(n.length+t.length);return r.set(n),r.set(t,n.length),Pi(r,{dkLen:32})}("TransactionData",e);return H(t)}get gasConfig(){return this.gasData}set gasConfig(e){this.gasData=e}build({maxSizeBytes:e=1/0,overrides:t,onlyTransactionKind:n}={}){const r=this.inputs,i=this.commands,o={ProgrammableTransaction:{inputs:r,commands:i}};if(n)return ar.TransactionKind.serialize(o,{maxSize:e}).toBytes();const s=t?.expiration??this.expiration,a=t?.sender??this.sender,u={...this.gasData,...t?.gasConfig,...t?.gasData};if(!a)throw new Error("Missing transaction sender");if(!u.budget)throw new Error("Missing gas budget");if(!u.payment)throw new Error("Missing gas payment");if(!u.price)throw new Error("Missing gas price");const c={sender:Bi(a),expiration:s||{None:!0},gasData:{payment:u.payment,owner:Bi(this.gasData.owner??a),price:BigInt(u.price),budget:BigInt(u.budget)},kind:{ProgrammableTransaction:{inputs:r,commands:i}}};return ar.TransactionData.serialize({V1:c},{maxSize:e}).toBytes()}addInput(e,t){const n=this.inputs.length;return this.inputs.push(t),{Input:n,type:e,$kind:"Input"}}getInputUses(e,t){this.mapArguments((n,r)=>("Input"===n.$kind&&n.Input===e&&t(n,r),n))}mapCommandArguments(e,t){const n=this.commands[e];switch(n.$kind){case"MoveCall":n.MoveCall.arguments=n.MoveCall.arguments.map(r=>t(r,n,e));break;case"TransferObjects":n.TransferObjects.objects=n.TransferObjects.objects.map(r=>t(r,n,e)),n.TransferObjects.address=t(n.TransferObjects.address,n,e);break;case"SplitCoins":n.SplitCoins.coin=t(n.SplitCoins.coin,n,e),n.SplitCoins.amounts=n.SplitCoins.amounts.map(r=>t(r,n,e));break;case"MergeCoins":n.MergeCoins.destination=t(n.MergeCoins.destination,n,e),n.MergeCoins.sources=n.MergeCoins.sources.map(r=>t(r,n,e));break;case"MakeMoveVec":n.MakeMoveVec.elements=n.MakeMoveVec.elements.map(r=>t(r,n,e));break;case"Upgrade":n.Upgrade.ticket=t(n.Upgrade.ticket,n,e);break;case"$Intent":const r=n.$Intent.inputs;n.$Intent.inputs={};for(const[i,o]of Object.entries(r))n.$Intent.inputs[i]=Array.isArray(o)?o.map(r=>t(r,n,e)):t(o,n,e);break;case"Publish":break;default:throw new Error(`Unexpected transaction kind: ${n.$kind}`)}}mapArguments(e){for(const t of this.commands.keys())this.mapCommandArguments(t,e)}replaceCommand(e,t,n=e){if(!Array.isArray(t))return void(this.commands[e]=t);const r=t.length-1;this.commands.splice(e,1,...t),0!==r&&this.mapArguments((i,o,s)=>{if(s<e+t.length)return i;switch(i.$kind){case"Result":i.Result===e&&(i.Result=n),i.Result>e&&(i.Result+=r);break;case"NestedResult":i.NestedResult[0]===e&&(i.NestedResult[0]=n),i.NestedResult[0]>e&&(i.NestedResult[0]+=r)}return i})}getDigest(){const e=this.build({onlyTransactionKind:!1});return Fi.getDigestFromBytes(e)}snapshot(){return Ge(xt,this)}shallowClone(){return new Fi({version:this.version,sender:this.sender,expiration:this.expiration,gasData:{...this.gasData},inputs:[...this.inputs],commands:[...this.commands]})}}function Ui(e){return"string"==typeof e?at(e):e.Object?e.Object.ImmOrOwnedObject?at(e.Object.ImmOrOwnedObject.objectId):e.Object.Receiving?at(e.Object.Receiving.objectId):at(e.Object.SharedObject.objectId):e.UnresolvedObject?at(e.UnresolvedObject.objectId):void 0}var Li,qi,$i=e=>{throw TypeError(e)},Vi=(e,t,n)=>t.has(e)||$i("Cannot "+n),zi=(e,t,n)=>(Vi(e,t,"read from private field"),n?n.call(e):t.get(e)),Ki=(e,t,n)=>t.has(e)?$i("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Wi=(e,t,n,r)=>(Vi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);Li=new WeakMap,qi=new WeakMap;let Qi=class e{constructor({prefix:e,cache:t}={}){Ki(this,Li),Ki(this,qi),Wi(this,Li,e??[]),Wi(this,qi,t??new Map)}read(e,t){const n=[zi(this,Li),...e].join(":");if(zi(this,qi).has(n))return zi(this,qi).get(n);const r=t();return zi(this,qi).set(n,r),"object"==typeof r&&null!==r&&"then"in r?Promise.resolve(r).then(e=>(zi(this,qi).set(n,e),e)).catch(e=>{throw zi(this,qi).delete(n),e}):r}readSync(e,t){const n=[zi(this,Li),...e].join(":");if(zi(this,qi).has(n))return zi(this,qi).get(n);const r=t();return zi(this,qi).set(n,r),r}clear(e){const t=[...zi(this,Li),...e??[]].join(":");if(t)for(const e of zi(this,qi).keys())e.startsWith(t)&&zi(this,qi).delete(e);else zi(this,qi).clear()}scope(t){return new e({prefix:[...zi(this,Li),...Array.isArray(t)?t:[t]],cache:zi(this,qi)})}};class Gi{constructor(e,t){if("function"!=typeof e)throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but got: ${e}.`);this._batchLoadFn=e,this._maxBatchSize=function(e){const t=!e||!1!==e.batch;if(!t)return 1;const n=e&&e.maxBatchSize;if(void 0===n)return 1/0;if("number"!=typeof n||n<1)throw new TypeError(`maxBatchSize must be a positive number: ${n}`);return n}(t),this._batchScheduleFn=function(e){const t=e&&e.batchScheduleFn;if(void 0===t)return Hi;if("function"!=typeof t)throw new TypeError(`batchScheduleFn must be a function: ${t}`);return t}(t),this._cacheKeyFn=function(e){const t=e&&e.cacheKeyFn;if(void 0===t)return e=>e;if("function"!=typeof t)throw new TypeError(`cacheKeyFn must be a function: ${t}`);return t}(t),this._cacheMap=function(e){const t=!e||!1!==e.cache;if(!t)return null;const n=e&&e.cacheMap;if(void 0===n)return new Map;if(null!==n){const e=["get","set","delete","clear"].filter(e=>n&&"function"!=typeof n[e]);if(0!==e.length)throw new TypeError("Custom cacheMap missing methods: "+e.join(", "))}return n}(t),this._batch=null,this.name=function(e){if(e&&e.name)return e.name;return null}(t)}load(e){if(null==e)throw new TypeError(`The loader.load() function must be called with a value, but got: ${String(e)}.`);const t=function(e){const t=e._batch;if(null!==t&&!t.hasDispatched&&t.keys.length<e._maxBatchSize)return t;const n={hasDispatched:!1,keys:[],callbacks:[]};return e._batch=n,e._batchScheduleFn(()=>{!function(e,t){if(t.hasDispatched=!0,0===t.keys.length)return void Yi(t);let n;try{n=e._batchLoadFn(t.keys)}catch(n){return Zi(e,t,new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function errored synchronously: ${String(n)}.`))}if(!n||"function"!=typeof n.then)return Zi(e,t,new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise: ${String(n)}.`));Promise.resolve(n).then(e=>{if(!Xi(e))throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array: ${String(e)}.`);if(e.length!==t.keys.length)throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys.\n\nKeys:\n${String(t.keys)}\n\nValues:\n${String(e)}`);Yi(t);for(let n=0;n<t.callbacks.length;n++){const r=e[n];r instanceof Error?t.callbacks[n].reject(r):t.callbacks[n].resolve(r)}}).catch(n=>{Zi(e,t,n)})}(e,n)}),n}(this),n=this._cacheMap;let r;if(n){r=this._cacheKeyFn(e);const i=n.get(r);if(i){const e=t.cacheHits||(t.cacheHits=[]);return new Promise(t=>{e.push(()=>{t(i)})})}}t.keys.push(e);const i=new Promise((e,n)=>{t.callbacks.push({resolve:e,reject:n})});return n&&n.set(r,i),i}loadMany(e){if(!Xi(e))throw new TypeError(`The loader.loadMany() function must be called with Array<key>, but got: ${e}.`);const t=[];for(let n=0;n<e.length;n++)t.push(this.load(e[n]).catch(e=>e));return Promise.all(t)}clear(e){const t=this._cacheMap;if(t){const n=this._cacheKeyFn(e);t.delete(n)}return this}clearAll(){const e=this._cacheMap;return e&&e.clear(),this}prime(e,t){const n=this._cacheMap;if(n){const r=this._cacheKeyFn(e);if(void 0===n.get(r)){let e;t instanceof Error?(e=Promise.reject(t),e.catch(()=>{})):e=Promise.resolve(t),n.set(r,e)}}return this}}const Hi="object"==typeof process&&"function"==typeof process.nextTick?function(e){Ji||(Ji=Promise.resolve()),Ji.then(()=>{process.nextTick(e)})}:"function"==typeof setImmediate?function(e){setImmediate(e)}:function(e){setTimeout(e)};let Ji;function Zi(e,t,n){Yi(t);for(let r=0;r<t.keys.length;r++)e.clear(t.keys[r]),t.callbacks[r].reject(n)}function Yi(e){if(e.cacheHits)for(let t=0;t<e.cacheHits.length;t++)e.cacheHits[t]()}function Xi(e){return"object"==typeof e&&null!==e&&"length"in e&&"number"==typeof e.length&&(0===e.length||e.length>0&&Object.prototype.hasOwnProperty.call(e,e.length-1))}const eo="1.35.0";var to,no,ro,io,oo,so,ao,uo,co,lo,ho=e=>{throw TypeError(e)},fo=(e,t,n)=>t.has(e)||ho("Cannot "+n),po=(e,t,n)=>(fo(e,t,"read from private field"),n?n.call(e):t.get(e)),yo=(e,t,n)=>t.has(e)?ho("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),mo=(e,t,n,r)=>(fo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),go=(e,t,n)=>(fo(e,t,"access private method"),n);const bo={"Mvr-Source":`@mysten/sui@${eo}`};class vo{constructor({cache:e,url:t,pageSize:n=50,overrides:r}){yo(this,oo),yo(this,to),yo(this,no),yo(this,ro),yo(this,io),mo(this,to,e),mo(this,no,t),mo(this,ro,n),mo(this,io,{packages:r?.packages,types:r?.types}),function(e){if(e?.packages)for(const[t,n]of Object.entries(e.packages)){if(!et(t))throw new Error(`Invalid package name: ${t}`);if(!rt(at(n)))throw new Error(`Invalid package ID: ${n}`)}if(e?.types)for(const[t,n]of Object.entries(e.types)){if(ot(t).typeParams.length>0)throw new Error("Type overrides must be first-level only. If you want to supply generic types, just pass each type individually.");if(!rt(ot(n).address))throw new Error(`Invalid type: ${n}`)}}(po(this,io))}async resolvePackage({package:e}){return{package:await po(this,oo,so).load(e)}}async resolveType({type:e}){const t=[...wo(e)],n=await po(this,oo,ao).loadMany(t),r={};for(let e=0;e<t.length;e++){const i=n[e];if(i instanceof Error)throw i;r[t[e]]=i}return{type:Eo(e,r)}}async resolve({types:e=[],packages:t=[]}){const n=new Set;for(const t of e??[])wo(t,n);const r=[...n],[i,o]=await Promise.all([r.length>0?po(this,oo,ao).loadMany(r):[],t.length>0?po(this,oo,so).loadMany(t):[]]),s={...po(this,io)?.types};for(const[e,t]of r.entries()){const n=i[e];if(n instanceof Error)throw n;s[t]=n}const a={};for(const t of e??[]){const e=Eo(t,s);a[t]={type:e}}const u={};for(const[e,n]of(t??[]).entries()){const t=po(this,io)?.packages?.[n]??o[e];if(t instanceof Error)throw t;u[n]={package:t}}return{types:a,packages:u}}}function wo(e,t=new Set){if("string"==typeof e&&!ko(e))return t;const n=So(e)?e:ot(e);ko(n.address)&&t.add(`${n.address}::${n.module}::${n.name}`);for(const e of n.typeParams)wo(e,t);return t}function Eo(e,t){const n=So(e)?e:ot(e),r=`${n.address}::${n.module}::${n.name}`,i=t[r];return st({...n,address:i?i.split("::")[0]:n.address,typeParams:n.typeParams.map(e=>Eo(e,t))})}function ko(e){return e.includes("/")||e.includes("@")||e.includes(".sui")}function So(e){return"object"==typeof e&&"address"in e&&"module"in e&&"name"in e&&"typeParams"in e}function To(e){const t=new Set;for(const n of e)if(ko(n)){if(!tt(n))throw new Error(`Invalid type with names: ${n}`);t.add(n)}return t}to=new WeakMap,no=new WeakMap,ro=new WeakMap,io=new WeakMap,oo=new WeakSet,so=function(){return po(this,to).readSync(["#mvrPackageDataLoader",po(this,no)??""],()=>{const e=new Gi(async e=>{if(!po(this,no))throw new Error(`MVR Api URL is not set for the current client (resolving ${e.join(", ")})`);const t=await go(this,oo,uo).call(this,e);return e.map(e=>t[e]??new Error(`Failed to resolve package: ${e}`))}),t=po(this,io)?.packages;if(t)for(const[n,r]of Object.entries(t))e.prime(n,r);return e})},ao=function(){return po(this,to).readSync(["#mvrTypeDataLoader",po(this,no)??""],()=>{const e=new Gi(async e=>{if(!po(this,no))throw new Error(`MVR Api URL is not set for the current client (resolving ${e.join(", ")})`);const t=await go(this,oo,co).call(this,e);return e.map(e=>t[e]??new Error(`Failed to resolve type: ${e}`))}),t=po(this,io)?.types;if(t)for(const[n,r]of Object.entries(t))e.prime(n,r);return e})},uo=async function(e){if(0===e.length)return{};const t=fr(e,po(this,ro)),n={};return await Promise.all(t.map(async e=>{const t=await go(this,oo,lo).call(this,"/v1/resolution/bulk",{names:e});if(t?.resolution)for(const e of Object.keys(t?.resolution)){const r=t.resolution[e]?.package_id;r&&(n[e]=r)}})),n},co=async function(e){if(0===e.length)return{};const t=fr(e,po(this,ro)),n={};return await Promise.all(t.map(async e=>{const t=await go(this,oo,lo).call(this,"/v1/struct-definition/bulk",{types:e});if(t?.resolution)for(const e of Object.keys(t?.resolution)){const r=t.resolution[e]?.type_tag;r&&(n[e]=r)}})),n},lo=async function(e,t){if(!po(this,no))throw new Error("MVR Api URL is not set for the current client");const n=await fetch(`${po(this,no)}${e}`,{method:"POST",headers:{"Content-Type":"application/json",...bo},body:JSON.stringify(t)});if(!n.ok){const e=await n.json().catch(()=>({}));throw new Error(`Failed to resolve types: ${e?.message}`)}return n.json()};const _o=new WeakMap,xo=e=>{let t;if(e){const n=e.overrides??{packages:{},types:{}};_o.has(n)||_o.set(n,new Qi),t=new vo({cache:_o.get(n),url:e.url,pageSize:e.pageSize,overrides:n})}return async(e,n,r)=>{const i=function(e){const t=new Set,n=new Set;for(const r of e.commands)switch(r.$kind){case"MakeMoveVec":r.MakeMoveVec.type&&To([r.MakeMoveVec.type]).forEach(e=>{n.add(e)});break;case"MoveCall":const e=r.MoveCall,i=e.package.split("::")[0];if(ko(i)){if(!et(i))throw new Error(`Invalid package name: ${i}`);t.add(i)}To(e.typeArguments??[]).forEach(e=>{n.add(e)})}return{packages:[...t],types:[...n]}}(e);if(0===i.types.length&&0===i.packages.length)return r();const o=await(t||function(e){if(!e.client)throw new Error("No sui client passed to Transaction#build, but transaction data was not sufficient to build offline.");return e.client}(n).core.mvr).resolve({types:i.types,packages:i.packages});!function(e,t){for(const n of e.commands){if(n.MakeMoveVec?.type){if(!ko(n.MakeMoveVec.type))continue;if(!t.types[n.MakeMoveVec.type])throw new Error(`No resolution found for type: ${n.MakeMoveVec.type}`);n.MakeMoveVec.type=t.types[n.MakeMoveVec.type].type}const e=n.MoveCall;if(!e)continue;const r=e.package.split("::"),i=r[0];if(ko(i)&&!t.packages[i])throw new Error(`No address found for package: ${i}`);ko(i)&&(r[0]=t.packages[i].package,e.package=r.join("::"));const o=e.typeArguments;if(o){for(let e=0;e<o.length;e++)if(ko(o[e])){if(!t.types[o[e]])throw new Error(`No resolution found for type: ${o[e]}`);o[e]=t.types[o[e]].type}e.typeArguments=o}}}(e,o),await r()}};var Oo,Io,Co,Mo,Ao,No,jo,Do,Ro,Po,Bo,Fo,Uo,Lo,qo,$o,Vo,zo,Ko,Wo=e=>{throw TypeError(e)},Qo=(e,t,n)=>t.has(e)||Wo("Cannot "+n),Go=(e,t,n)=>(Qo(e,t,"read from private field"),n?n.call(e):t.get(e)),Ho=(e,t,n)=>t.has(e)?Wo("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Jo=(e,t,n,r)=>(Qo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Zo=(e,t,n)=>(Qo(e,t,"access private method"),n);function Yo(e,t=1/0){const n=[],r=t=>n[t]??(n[t]={$kind:"NestedResult",get NestedResult(){return["function"==typeof e?e():e,t]}});return new Proxy({$kind:"Result",get Result(){return"function"==typeof e?e():e}},{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(e,n){if(n in e)return Reflect.get(e,n);if(n===Symbol.iterator)return function*(){let e=0;for(;e<t;)yield r(e),e++};if("symbol"==typeof n)return;const i=parseInt(n,10);return Number.isNaN(i)||i<0?void 0:r(i)}})}const Xo=Symbol.for("@mysten/transaction");function es(e){return!!e&&"object"==typeof e&&!0===e[Xo]}const ts={buildPlugins:new Map,serializationPlugins:new Map},ns=Symbol.for("@mysten/transaction/registry");function rs(){try{const e=globalThis;return e[ns]||(e[ns]=ts),e[ns]}catch(e){return ts}}const is=class e{constructor(){Ho(this,Po),Ho(this,Oo),Ho(this,Io),Ho(this,Co,new Map),Ho(this,Mo,[]),Ho(this,Ao,[]),Ho(this,No,new Set),Ho(this,jo,new Set),Ho(this,Do,new Map),Ho(this,Ro),this.object=function(e){function t(t){return e(t)}return t.system=()=>t("0x5"),t.clock=()=>t("0x6"),t.random=()=>t("0x8"),t.denyList=()=>t("0x403"),t.option=({type:e,value:t})=>n=>n.moveCall({typeArguments:[e],target:"0x1::option::"+(null===t?"none":"some"),arguments:null===t?[]:[n.object(t)]}),t}(e=>{if("function"==typeof e)return this.object(this.add(e));if("object"==typeof e&&Ae(yt,e))return e;const t=Ui(e),n=Go(this,Ro).inputs.find(e=>t===Ui(e));return n?.Object?.SharedObject&&"object"==typeof e&&e.Object?.SharedObject&&(n.Object.SharedObject.mutable=n.Object.SharedObject.mutable||e.Object.SharedObject.mutable),n?{$kind:"Input",Input:Go(this,Ro).inputs.indexOf(n),type:"object"}:Zo(this,Po,Uo).call(this,"object","string"==typeof e?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:at(e)}}:e)});const e=rs();Jo(this,Ro,new Fi),Jo(this,Io,[...e.buildPlugins.values()]),Jo(this,Oo,[...e.serializationPlugins.values()])}static fromKind(n){const r=new e;return Jo(r,Ro,Fi.fromKindBytes("string"==typeof n?t(n):n)),Jo(r,Mo,Go(r,Ro).inputs.slice()),Jo(r,Ao,Go(r,Ro).commands.slice()),Jo(r,No,new Set(Go(r,Ao).map((e,t)=>t))),r}static from(n){const r=new e;return es(n)?Jo(r,Ro,new Fi(n.getData())):"string"==typeof n&&n.startsWith("{")?Jo(r,Ro,Fi.restore(JSON.parse(n))):Jo(r,Ro,Fi.fromBytes("string"==typeof n?t(n):n)),Jo(r,Mo,Go(r,Ro).inputs.slice()),Jo(r,Ao,Go(r,Ro).commands.slice()),Jo(r,No,new Set(Go(r,Ao).map((e,t)=>t))),r}static registerGlobalSerializationPlugin(e,t){rs().serializationPlugins.set(e,t??e)}static unregisterGlobalSerializationPlugin(e){rs().serializationPlugins.delete(e)}static registerGlobalBuildPlugin(e,t){rs().buildPlugins.set(e,t??e)}static unregisterGlobalBuildPlugin(e){rs().buildPlugins.delete(e)}addSerializationPlugin(e){Go(this,Oo).push(e)}addBuildPlugin(e){Go(this,Io).push(e)}addIntentResolver(e,t){if(Go(this,Co).has(e)&&Go(this,Co).get(e)!==t)throw new Error(`Intent resolver for ${e} already exists`);Go(this,Co).set(e,t)}setSender(e){Go(this,Ro).sender=e}setSenderIfNotSet(e){Go(this,Ro).sender||(Go(this,Ro).sender=e)}setExpiration(e){Go(this,Ro).expiration=e?Ge(_t,e):null}setGasPrice(e){Go(this,Ro).gasConfig.price=String(e)}setGasBudget(e){Go(this,Ro).gasConfig.budget=String(e)}setGasBudgetIfNotSet(e){null==Go(this,Ro).gasData.budget&&(Go(this,Ro).gasConfig.budget=String(e))}setGasOwner(e){Go(this,Ro).gasConfig.owner=e}setGasPayment(e){Go(this,Ro).gasConfig.payment=e.map(e=>Ge(pt,e))}get blockData(){return Qt(Go(this,Ro).snapshot())}getData(){return Go(this,Ro).snapshot()}get[Xo](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:kr(e=>de(e)?Zo(this,Po,Uo).call(this,"pure",{$kind:"Pure",Pure:{bytes:e.toBase64()}}):Zo(this,Po,Uo).call(this,"pure",Ae(Tt,e)?Ge(Tt,e):e instanceof Uint8Array?an.Pure(e):{$kind:"UnresolvedPure",UnresolvedPure:{value:e}}))}),this.pure}get gas(){return{$kind:"GasCoin",GasCoin:!0}}objectRef(...e){return this.object(an.ObjectRef(...e))}receivingRef(...e){return this.object(an.ReceivingRef(...e))}sharedObjectRef(...e){return this.object(an.SharedObjectRef(...e))}add(e){if("function"==typeof e){if(Go(this,Do).has(e))return Go(this,Do).get(e);const t=Zo(this,Po,Bo).call(this),n=e(t);if(!n||"object"!=typeof n||!("then"in n))return Jo(this,No,Go(t,No)),Go(this,Do).set(e,n),n;const r=Zo(this,Po,Fo).call(this,{$kind:"$Intent",$Intent:{name:"AsyncTransactionThunk",inputs:{},data:{resultIndex:Go(this,Ro).commands.length,result:null}}});Go(this,jo).add(Promise.resolve(n).then(e=>{r.$Intent.data.result=e}));const i=Yo(()=>r.$Intent.data.resultIndex);return Go(this,Do).set(e,i),i}return Zo(this,Po,Fo).call(this,e),Yo(Go(this,Ro).commands.length-1)}splitCoins(e,t){const n=Ot.SplitCoins("string"==typeof e?this.object(e):Zo(this,Po,qo).call(this,e),t.map(e=>"number"==typeof e||"bigint"==typeof e||"string"==typeof e?this.pure.u64(e):Zo(this,Po,Lo).call(this,e)));return Zo(this,Po,Fo).call(this,n),Yo(Go(this,Ro).commands.length-1,t.length)}mergeCoins(e,t){return this.add(Ot.MergeCoins(this.object(e),t.map(e=>this.object(e))))}publish({modules:e,dependencies:t}){return this.add(Ot.Publish({modules:e,dependencies:t}))}upgrade({modules:e,dependencies:t,package:n,ticket:r}){return this.add(Ot.Upgrade({modules:e,dependencies:t,package:n,ticket:this.object(r)}))}moveCall({arguments:e,...t}){return this.add(Ot.MoveCall({...t,arguments:e?.map(e=>Zo(this,Po,Lo).call(this,e))}))}transferObjects(e,t){return this.add(Ot.TransferObjects(e.map(e=>this.object(e)),"string"==typeof t?this.pure.address(t):Zo(this,Po,Lo).call(this,t)))}makeMoveVec({type:e,elements:t}){return this.add(Ot.MakeMoveVec({type:e,elements:t.map(e=>this.object(e))}))}serialize(){return JSON.stringify(Qt(Go(this,Ro).snapshot()))}async toJSON(e={}){await this.prepareForSerialization(e);const t=this.isFullyResolved();return JSON.stringify(Ge(sn,t?{...Go(this,Ro).snapshot(),digest:Go(this,Ro).getDigest()}:Go(this,Ro).snapshot()),(e,t)=>"bigint"==typeof t?t.toString():t,2)}async sign(e){const{signer:t,...n}=e,r=await this.build(n);return t.signTransaction(r)}isFullyResolved(){return!!Go(this,Ro).sender&&(!(Go(this,jo).size>0)&&(!Go(this,Ro).commands.some(e=>e.$Intent)&&!gr(Go(this,Ro),{})))}async build(e={}){return await this.prepareForSerialization(e),await Zo(this,Po,$o).call(this,e),Go(this,Ro).build({onlyTransactionKind:e.onlyTransactionKind})}async getDigest(e={}){return await this.prepareForSerialization(e),await Zo(this,Po,$o).call(this,e),Go(this,Ro).getDigest()}async prepareForSerialization(e){await Zo(this,Po,zo).call(this),Zo(this,Po,Ko).call(this);const t=new Set;for(const e of Go(this,Ro).commands)e.$Intent&&t.add(e.$Intent.name);const n=[...Go(this,Oo)];for(const r of t)if(!e.supportedIntents?.includes(r)){if(!Go(this,Co).has(r))throw new Error(`Missing intent resolver for ${r}`);n.push(Go(this,Co).get(r))}n.push(xo()),await Zo(this,Po,Vo).call(this,n,e)}};Oo=new WeakMap,Io=new WeakMap,Co=new WeakMap,Mo=new WeakMap,Ao=new WeakMap,No=new WeakMap,jo=new WeakMap,Do=new WeakMap,Ro=new WeakMap,Po=new WeakSet,Bo=function(){const e=new is;return Jo(e,Ro,Go(this,Ro)),Jo(e,Oo,Go(this,Oo)),Jo(e,Io,Go(this,Io)),Jo(e,Co,Go(this,Co)),Jo(e,jo,Go(this,jo)),Jo(e,No,new Set(Go(this,No))),Jo(e,Do,Go(this,Do)),Go(this,Mo).push(Go(e,Mo)),Go(this,Ao).push(Go(e,Ao)),e},Fo=function(e){const t=Go(this,Ro).commands.length;return Go(this,Ao).push(e),Go(this,No).add(t),Go(this,Ro).commands.push(e),Go(this,Ro).mapCommandArguments(t,e=>{if("Result"===e.$kind&&!Go(this,No).has(e.Result))throw new Error(`Result { Result: ${e.Result} } is not available to use the current transaction`);if("NestedResult"===e.$kind&&!Go(this,No).has(e.NestedResult[0]))throw new Error(`Result { NestedResult: [${e.NestedResult[0]}, ${e.NestedResult[1]}] } is not available to use the current transaction`);if("Input"===e.$kind&&e.Input>=Go(this,Ro).inputs.length)throw new Error(`Input { Input: ${e.Input} } references an input that does not exist in the current transaction`);return e}),e},Uo=function(e,t){return Go(this,Mo).push(t),Go(this,Ro).addInput(e,t)},Lo=function(e){return de(e)?this.pure(e):Zo(this,Po,qo).call(this,e)},qo=function(e){if("function"==typeof e){const t=this.add(e);return"function"==typeof t?Zo(this,Po,qo).call(this,t):Ge(yt,t)}return Ge(yt,e)},$o=async function(e){if(!e.onlyTransactionKind&&!Go(this,Ro).sender)throw new Error("Missing transaction sender");await Zo(this,Po,Vo).call(this,[...Go(this,Io),br],e)},Vo=async function(e,t){const n=r=>{if(r>=e.length)return()=>{};const i=e[r];return async()=>{const e=n(r+1);let o=!1,s=!1;if(await i(Go(this,Ro),t,async()=>{if(o)throw new Error(`next() was call multiple times in TransactionPlugin ${r}`);o=!0,await e(),s=!0}),!o)throw new Error(`next() was not called in TransactionPlugin ${r}`);if(!s)throw new Error(`next() was not awaited in TransactionPlugin ${r}`)}};await n(0)(),Jo(this,Mo,Go(this,Ro).inputs.slice()),Jo(this,Ao,Go(this,Ro).commands.slice())},zo=async function(){for(;Go(this,jo).size>0;){const e=Promise.all(Go(this,jo));Go(this,jo).clear(),Go(this,jo).add(e),await e,Go(this,jo).delete(e)}},Ko=function(){const e=Go(this,Ro).commands,t=Go(this,Ro).inputs,n=Go(this,Ao).flat(1/0),r=Go(this,Mo).flat(1/0);if(n.length!==e.length)throw new Error("Unexpected number of commands found in transaction data");if(r.length!==t.length)throw new Error("Unexpected number of inputs found in transaction data");const i=n.filter(e=>"AsyncTransactionThunk"!==e.$Intent?.name);function o(t){const n=e[t];if("AsyncTransactionThunk"===n.$Intent?.name){const e=n.$Intent.data.result;if(null==e)throw new Error("AsyncTransactionThunk has not been resolved");return o(e.Result)}const r=i.indexOf(n);if(-1===r)throw new Error("Unable to find original index for command");return r}Go(this,Ro).commands=i,Go(this,Ro).inputs=r,Jo(this,Ao,i),Jo(this,Mo,r),Jo(this,No,new Set(i.map((e,t)=>t))),Go(this,Ro).mapArguments(e=>{if("Input"===e.$kind){const n=r.indexOf(t[e.Input]);if(-1===n)throw new Error("Input has not been resolved");return{...e,Input:n}}if("Result"===e.$kind){const t=o(e.Result);return{...e,Result:t}}if("NestedResult"===e.$kind){const t=o(e.NestedResult[0]);return{...e,NestedResult:[t,e.NestedResult[1]]}}return e});for(const[t,n]of e.entries())if("AsyncTransactionThunk"===n.$Intent?.name)try{n.$Intent.data.resultIndex=o(t)}catch(e){}};let os=is;const ss=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]),as=new Uint32Array(64);class us extends si{constructor(e=32){super(64,e,8,!1),this.A=0|ai[0],this.B=0|ai[1],this.C=0|ai[2],this.D=0|ai[3],this.E=0|ai[4],this.F=0|ai[5],this.G=0|ai[6],this.H=0|ai[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[e,t,n,r,i,o,s,a]}set(e,t,n,r,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)as[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=as[e-15],n=as[e-2],r=jr(t,7)^jr(t,18)^t>>>3,i=jr(n,17)^jr(n,19)^n>>>10;as[e]=i+as[e-7]+r+as[e-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:u,H:c}=this;for(let e=0;e<64;e++){const t=c+(jr(s,6)^jr(s,11)^jr(s,25))+ii(s,a,u)+ss[e]+as[e]|0,l=(jr(n,2)^jr(n,13)^jr(n,22))+oi(n,r,i)|0;c=u,u=a,a=s,s=o+t|0,o=i,i=r,r=n,n=t+l|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(n,r,i,o,s,a,u,c)}roundClean(){Ar(as)}destroy(){this.set(0,0,0,0,0,0,0,0),Ar(this.buffer)}}const cs=(()=>fi(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))))(),ls=(()=>cs[0])(),hs=(()=>cs[1])(),fs=new Uint32Array(80),ds=new Uint32Array(80);class ps extends si{constructor(e=64){super(128,e,16,!1),this.Ah=0|ui[0],this.Al=0|ui[1],this.Bh=0|ui[2],this.Bl=0|ui[3],this.Ch=0|ui[4],this.Cl=0|ui[5],this.Dh=0|ui[6],this.Dl=0|ui[7],this.Eh=0|ui[8],this.El=0|ui[9],this.Fh=0|ui[10],this.Fl=0|ui[11],this.Gh=0|ui[12],this.Gl=0|ui[13],this.Hh=0|ui[14],this.Hl=0|ui[15]}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:o,Dh:s,Dl:a,Eh:u,El:c,Fh:l,Fl:h,Gh:f,Gl:d,Hh:p,Hl:y}=this;return[e,t,n,r,i,o,s,a,u,c,l,h,f,d,p,y]}set(e,t,n,r,i,o,s,a,u,c,l,h,f,d,p,y){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|u,this.El=0|c,this.Fh=0|l,this.Fl=0|h,this.Gh=0|f,this.Gl=0|d,this.Hh=0|p,this.Hl=0|y}process(e,t){for(let n=0;n<16;n++,t+=4)fs[n]=e.getUint32(t),ds[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|fs[e-15],n=0|ds[e-15],r=yi(t,n,1)^yi(t,n,8)^di(t,0,7),i=mi(t,n,1)^mi(t,n,8)^pi(t,n,7),o=0|fs[e-2],s=0|ds[e-2],a=yi(o,s,19)^gi(o,s,61)^di(o,0,6),u=mi(o,s,19)^bi(o,s,61)^pi(o,s,6),c=Ti(i,u,ds[e-7],ds[e-16]),l=_i(c,r,a,fs[e-7],fs[e-16]);fs[e]=0|l,ds[e]=0|c}let{Ah:n,Al:r,Bh:i,Bl:o,Ch:s,Cl:a,Dh:u,Dl:c,Eh:l,El:h,Fh:f,Fl:d,Gh:p,Gl:y,Hh:m,Hl:g}=this;for(let e=0;e<80;e++){const t=yi(l,h,14)^yi(l,h,18)^gi(l,h,41),b=mi(l,h,14)^mi(l,h,18)^bi(l,h,41),v=l&f^~l&p,w=xi(g,b,h&d^~h&y,hs[e],ds[e]),E=Oi(w,m,t,v,ls[e],fs[e]),k=0|w,S=yi(n,r,28)^gi(n,r,34)^gi(n,r,39),T=mi(n,r,28)^bi(n,r,34)^bi(n,r,39),_=n&i^n&s^i&s,x=r&o^r&a^o&a;m=0|p,g=0|y,p=0|f,y=0|d,f=0|l,d=0|h,({h:l,l:h}=Ei(0|u,0|c,0|E,0|k)),u=0|s,c=0|a,s=0|i,a=0|o,i=0|n,o=0|r;const O=ki(k,T,x);n=Si(O,E,S,_),r=0|O}({h:n,l:r}=Ei(0|this.Ah,0|this.Al,0|n,0|r)),({h:i,l:o}=Ei(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=Ei(0|this.Ch,0|this.Cl,0|s,0|a)),({h:u,l:c}=Ei(0|this.Dh,0|this.Dl,0|u,0|c)),({h:l,l:h}=Ei(0|this.Eh,0|this.El,0|l,0|h)),({h:f,l:d}=Ei(0|this.Fh,0|this.Fl,0|f,0|d)),({h:p,l:y}=Ei(0|this.Gh,0|this.Gl,0|p,0|y)),({h:m,l:g}=Ei(0|this.Hh,0|this.Hl,0|m,0|g)),this.set(n,r,i,o,s,a,u,c,l,h,f,d,p,y,m,g)}roundClean(){Ar(fs,ds)}destroy(){Ar(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ys=ei(()=>new us),ms=ei(()=>new ps),gs=BigInt(0),bs=BigInt(1);function vs(e,t=""){if("boolean"!=typeof e){throw new Error((t&&`"${t}"`)+"expected boolean, got type="+typeof e)}return e}function ws(e,t,n=""){const r=Tr(e),i=e?.length,o=void 0!==t;if(!r||o&&i!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(o?` of length ${t}`:"")+", got "+(r?`length=${i}`:"type="+typeof e))}return e}function Es(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?gs:BigInt("0x"+e)}function ks(e){return xr(e),Es(Lr(Uint8Array.from(e).reverse()))}function Ss(e,t){return Gr(e.toString(16).padStart(2*t,"0"))}function Ts(e,t,n){let r;if("string"==typeof t)try{r=Gr(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!Tr(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(e+" of length "+n+" expected, got "+i);return r}function _s(e){return Uint8Array.from(e)}const xs=e=>"bigint"==typeof e&&gs<=e;function Os(e,t,n,r){if(!function(e,t,n){return xs(e)&&xs(t)&&xs(n)&&t<=e&&e<n}(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}const Is=e=>(bs<<BigInt(e))-bs;function Cs(e,t,n={}){if(!e||"object"!=typeof e)throw new Error("expected valid options object");function r(t,n,r){const i=e[t];if(r&&void 0===i)return;const o=typeof i;if(o!==n||null===i)throw new Error(`param "${t}" is invalid: expected ${n}, got ${o}`)}Object.entries(t).forEach(([e,t])=>r(e,t,!1)),Object.entries(n).forEach(([e,t])=>r(e,t,!0))}const Ms=()=>{throw new Error("not implemented")};function As(e){const t=new WeakMap;return(n,...r)=>{const i=t.get(n);if(void 0!==i)return i;const o=e(n,...r);return t.set(n,o),o}}const Ns=BigInt(0),js=BigInt(1),Ds=BigInt(2),Rs=BigInt(3),Ps=BigInt(4),Bs=BigInt(5),Fs=BigInt(7),Us=BigInt(8),Ls=BigInt(9),qs=BigInt(16);function $s(e,t){const n=e%t;return n>=Ns?n:t+n}function Vs(e,t,n){let r=e;for(;t-- >Ns;)r*=r,r%=n;return r}function zs(e,t){if(e===Ns)throw new Error("invert: expected non-zero number");if(t<=Ns)throw new Error("invert: expected positive modulus, got "+t);let n=$s(e,t),r=t,i=Ns,o=js,s=js,a=Ns;for(;n!==Ns;){const e=r/n,t=r%n,u=i-s*e,c=o-a*e;r=n,n=t,i=s,o=a,s=u,a=c}if(r!==js)throw new Error("invert: does not exist");return $s(i,t)}function Ks(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function Ws(e,t){const n=(e.ORDER+js)/Ps,r=e.pow(t,n);return Ks(e,r,t),r}function Qs(e,t){const n=(e.ORDER-Bs)/Us,r=e.mul(t,Ds),i=e.pow(r,n),o=e.mul(t,i),s=e.mul(e.mul(o,Ds),i),a=e.mul(o,e.sub(s,e.ONE));return Ks(e,a,t),a}function Gs(e){if(e<Rs)throw new Error("sqrt is not defined for small field");let t=e-js,n=0;for(;t%Ds===Ns;)t/=Ds,n++;let r=Ds;const i=na(e);for(;1===ea(i,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return Ws;let o=i.pow(r,t);const s=(t+js)/Ds;return function(e,r){if(e.is0(r))return r;if(1!==ea(e,r))throw new Error("Cannot find square root");let i=n,a=e.mul(e.ONE,o),u=e.pow(r,t),c=e.pow(r,s);for(;!e.eql(u,e.ONE);){if(e.is0(u))return e.ZERO;let t=1,n=e.sqr(u);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===i)throw new Error("Cannot find square root");const r=js<<BigInt(i-t-1),o=e.pow(a,r);i=t,a=e.sqr(o),u=e.mul(u,a),c=e.mul(c,o)}return c}}function Hs(e){return e%Ps===Rs?Ws:e%Us===Bs?Qs:e%qs===Ls?function(e){const t=na(e),n=Gs(e),r=n(t,t.neg(t.ONE)),i=n(t,r),o=n(t,t.neg(r)),s=(e+Fs)/qs;return(e,t)=>{let n=e.pow(t,s),a=e.mul(n,r);const u=e.mul(n,i),c=e.mul(n,o),l=e.eql(e.sqr(a),t),h=e.eql(e.sqr(u),t);n=e.cmov(n,a,l),a=e.cmov(c,u,h);const f=e.eql(e.sqr(a),t),d=e.cmov(n,a,f);return Ks(e,d,t),d}}(e):Gs(e)}const Js=(e,t)=>($s(e,t)&js)===js,Zs=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ys(e,t,n){if(n<Ns)throw new Error("invalid exponent, negatives unsupported");if(n===Ns)return e.ONE;if(n===js)return t;let r=e.ONE,i=t;for(;n>Ns;)n&js&&(r=e.mul(r,i)),i=e.sqr(i),n>>=js;return r}function Xs(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),i=t.reduce((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n)),e.ONE),o=e.inv(i);return t.reduceRight((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n)),o),r}function ea(e,t){const n=(e.ORDER-js)/Ds,r=e.pow(t,n),i=e.eql(r,e.ONE),o=e.eql(r,e.ZERO),s=e.eql(r,e.neg(e.ONE));if(!i&&!o&&!s)throw new Error("invalid Legendre symbol result");return i?1:o?0:-1}function ta(e,t){void 0!==t&&_r(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function na(e,t,n=!1,r={}){if(e<=Ns)throw new Error("invalid field: expected ORDER > 0, got "+e);let i,o,s,a=!1;if("object"==typeof t&&null!=t){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const e=t;e.BITS&&(i=e.BITS),e.sqrt&&(o=e.sqrt),"boolean"==typeof e.isLE&&(n=e.isLE),"boolean"==typeof e.modFromBytes&&(a=e.modFromBytes),s=e.allowedLengths}else"number"==typeof t&&(i=t),r.sqrt&&(o=r.sqrt);const{nBitLength:u,nByteLength:c}=ta(e,i);if(c>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let l;const h=Object.freeze({ORDER:e,isLE:n,BITS:u,BYTES:c,MASK:Is(u),ZERO:Ns,ONE:js,allowedLengths:s,create:t=>$s(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return Ns<=t&&t<e},is0:e=>e===Ns,isValidNot0:e=>!h.is0(e)&&h.isValid(e),isOdd:e=>(e&js)===js,neg:t=>$s(-t,e),eql:(e,t)=>e===t,sqr:t=>$s(t*t,e),add:(t,n)=>$s(t+n,e),sub:(t,n)=>$s(t-n,e),mul:(t,n)=>$s(t*n,e),pow:(e,t)=>Ys(h,e,t),div:(t,n)=>$s(t*zs(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>zs(t,e),sqrt:o||(t=>(l||(l=Hs(e)),l(h,t))),toBytes:e=>n?Ss(e,c).reverse():Ss(e,c),fromBytes:(t,r=!0)=>{if(s){if(!s.includes(t.length)||t.length>c)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+t.length);const e=new Uint8Array(c);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==c)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+t.length);let i=n?ks(t):function(e){return Es(Lr(e))}(t);if(a&&(i=$s(i,e)),!r&&!h.isValid(i))throw new Error("invalid field element: outside of range 0..ORDER");return i},invertBatch:e=>Xs(h,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(h)}const ra=BigInt(0),ia=BigInt(1);function oa(e,t){const n=t.negate();return e?n:t}function sa(e,t){const n=Xs(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function aa(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function ua(e,t){aa(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:Is(e),maxNumber:n,shiftBy:BigInt(e)}}function ca(e,t,n){const{windowSize:r,mask:i,maxNumber:o,shiftBy:s}=n;let a=Number(e&i),u=e>>s;a>r&&(a-=o,u+=ia);const c=t*r;return{nextN:u,offset:c+Math.abs(a)-1,isZero:0===a,isNeg:a<0,isNegF:t%2!=0,offsetF:c}}function la(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function ha(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}const fa=new WeakMap,da=new WeakMap;function pa(e){return da.get(e)||1}function ya(e){if(e!==ra)throw new Error("invalid wNAF")}class ma{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>ra;)t&ia&&(n=n.add(r)),r=r.double(),t>>=ia;return n}precomputeWindow(e,t){const{windows:n,windowSize:r}=ua(t,this.bits),i=[];let o=e,s=o;for(let e=0;e<n;e++){s=o,i.push(s);for(let e=1;e<r;e++)s=s.add(o),i.push(s);o=s.double()}return i}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let r=this.ZERO,i=this.BASE;const o=ua(e,this.bits);for(let e=0;e<o.windows;e++){const{nextN:s,offset:a,isZero:u,isNeg:c,isNegF:l,offsetF:h}=ca(n,e,o);n=s,u?i=i.add(oa(l,t[h])):r=r.add(oa(c,t[a]))}return ya(n),{p:r,f:i}}wNAFUnsafe(e,t,n,r=this.ZERO){const i=ua(e,this.bits);for(let e=0;e<i.windows&&n!==ra;e++){const{nextN:o,offset:s,isZero:a,isNeg:u}=ca(n,e,i);if(n=o,!a){const e=t[s];r=r.add(u?e.negate():e)}}return ya(n),r}getPrecomputes(e,t,n){let r=fa.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&("function"==typeof n&&(r=n(r)),fa.set(t,r))),r}cached(e,t,n){const r=pa(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){const i=pa(e);return 1===i?this._unsafeLadder(e,t,r):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,r)}createCache(e,t){aa(t,this.bits),da.set(e,t),fa.delete(e)}hasCache(e){return 1!==pa(e)}}function ga(e,t,n,r){la(n,e),ha(r,t);const i=n.length,o=r.length;if(i!==o)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,a=function(e){let t;for(t=0;e>gs;e>>=bs,t+=1);return t}(BigInt(i));let u=1;a>12?u=a-3:a>4?u=a-2:a>0&&(u=2);const c=Is(u),l=new Array(Number(c)+1).fill(s);let h=s;for(let e=Math.floor((t.BITS-1)/u)*u;e>=0;e-=u){l.fill(s);for(let t=0;t<o;t++){const i=r[t],o=Number(i>>BigInt(e)&c);l[o]=l[o].add(n[t])}let t=s;for(let e=l.length-1,n=s;e>0;e--)n=n.add(l[e]),t=t.add(n);if(h=h.add(t),0!==e)for(let e=0;e<u;e++)h=h.double()}return h}function ba(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return function(e){const t=Zs.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});Cs(e,t)}(t),t}return na(e,{isLE:n})}const va=BigInt(0),wa=BigInt(1),Ea=BigInt(2),ka=BigInt(8);function Sa(e,t={}){const n=function(e,t,n={},r){if(void 0===r&&(r="edwards"===e),!t||"object"!=typeof t)throw new Error(`expected valid ${e} CURVE object`);for(const e of["p","n","h"]){const n=t[e];if(!("bigint"==typeof n&&n>ra))throw new Error(`CURVE.${e} must be positive bigint`)}const i=ba(t.p,n.Fp,r),o=ba(t.n,n.Fn,r),s=["Gx","Gy","a","weierstrass"===e?"b":"d"];for(const e of s)if(!i.isValid(t[e]))throw new Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:i,Fn:o}}("edwards",e,t,t.FpFnLE),{Fp:r,Fn:i}=n;let o=n.CURVE;const{h:s}=o;Cs(t,{},{uvRatio:"function"});const a=Ea<<BigInt(8*i.BYTES)-wa,u=e=>r.create(e),c=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:r.sqrt(r.div(e,t))}}catch(e){return{isValid:!1,value:va}}});if(!function(e,t,n,r){const i=e.sqr(n),o=e.sqr(r),s=e.add(e.mul(t.a,i),o),a=e.add(e.ONE,e.mul(t.d,e.mul(i,o)));return e.eql(s,a)}(r,o,o.Gx,o.Gy))throw new Error("bad curve params: generator point");function l(e,t,n=!1){return Os("coordinate "+e,t,n?wa:va,a),t}function h(e){if(!(e instanceof p))throw new Error("ExtendedPoint expected")}const f=As((e,t)=>{const{X:n,Y:i,Z:o}=e,s=e.is0();null==t&&(t=s?ka:r.inv(o));const a=u(n*t),c=u(i*t),l=r.mul(o,t);if(s)return{x:va,y:wa};if(l!==wa)throw new Error("invZ was invalid");return{x:a,y:c}}),d=As(e=>{const{a:t,d:n}=o;if(e.is0())throw new Error("bad point: ZERO");const{X:r,Y:i,Z:s,T:a}=e,c=u(r*r),l=u(i*i),h=u(s*s),f=u(h*h),d=u(c*t);if(u(h*u(d+l))!==u(f+u(n*u(c*l))))throw new Error("bad point: equation left != right (1)");if(u(r*i)!==u(s*a))throw new Error("bad point: equation left != right (2)");return!0});class p{constructor(e,t,n,r){this.X=l("x",e),this.Y=l("y",t),this.Z=l("z",n,!0),this.T=l("t",r),Object.freeze(this)}static CURVE(){return o}static fromAffine(e){if(e instanceof p)throw new Error("extended point not allowed");const{x:t,y:n}=e||{};return l("x",t),l("y",n),new p(t,n,wa,u(t*n))}static fromBytes(e,t=!1){const n=r.BYTES,{a:i,d:s}=o;e=_s(ws(e,n,"point")),vs(t,"zip215");const l=_s(e),h=e[n-1];l[n-1]=-129&h;const f=ks(l),d=t?a:r.ORDER;Os("point.y",f,va,d);const y=u(f*f),m=u(y-wa),g=u(s*y-i);let{isValid:b,value:v}=c(m,g);if(!b)throw new Error("bad point: invalid y coordinate");const w=(v&wa)===wa,E=!!(128&h);if(!t&&v===va&&E)throw new Error("bad point: x=0 and x_0=1");return E!==w&&(v=u(-v)),p.fromAffine({x:v,y:f})}static fromHex(e,t=!1){return p.fromBytes(Ts("point",e),t)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return y.createCache(this,e),t||this.multiply(Ea),this}assertValidity(){d(this)}equals(e){h(e);const{X:t,Y:n,Z:r}=this,{X:i,Y:o,Z:s}=e,a=u(t*s),c=u(i*r),l=u(n*s),f=u(o*r);return a===c&&l===f}is0(){return this.equals(p.ZERO)}negate(){return new p(u(-this.X),this.Y,this.Z,u(-this.T))}double(){const{a:e}=o,{X:t,Y:n,Z:r}=this,i=u(t*t),s=u(n*n),a=u(Ea*u(r*r)),c=u(e*i),l=t+n,h=u(u(l*l)-i-s),f=c+s,d=f-a,y=c-s,m=u(h*d),g=u(f*y),b=u(h*y),v=u(d*f);return new p(m,g,v,b)}add(e){h(e);const{a:t,d:n}=o,{X:r,Y:i,Z:s,T:a}=this,{X:c,Y:l,Z:f,T:d}=e,y=u(r*c),m=u(i*l),g=u(a*n*d),b=u(s*f),v=u((r+i)*(c+l)-y-m),w=b-g,E=b+g,k=u(m-t*y),S=u(v*w),T=u(E*k),_=u(v*k),x=u(w*E);return new p(S,T,x,_)}subtract(e){return this.add(e.negate())}multiply(e){if(!i.isValidNot0(e))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:t,f:n}=y.cached(this,e,e=>sa(p,e));return sa(p,[t,n])[0]}multiplyUnsafe(e,t=p.ZERO){if(!i.isValid(e))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return e===va?p.ZERO:this.is0()||e===wa?this:y.unsafe(this,e,e=>sa(p,e),t)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return y.unsafe(this,o.n).is0()}toAffine(e){return f(this,e)}clearCofactor(){return s===wa?this:this.multiplyUnsafe(s)}toBytes(){const{x:e,y:t}=this.toAffine(),n=r.toBytes(t);return n[n.length-1]|=e&wa?128:0,n}toHex(){return Lr(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(e){return sa(p,e)}static msm(e,t){return ga(p,i,e,t)}_setWindowSize(e){this.precompute(e)}toRawBytes(){return this.toBytes()}}p.BASE=new p(o.Gx,o.Gy,wa,u(o.Gx*o.Gy)),p.ZERO=new p(va,wa,wa,va),p.Fp=r,p.Fn=i;const y=new ma(p,i.BITS);return p.BASE.precompute(8),p}class Ta{constructor(e){this.ep=e}static fromBytes(e){Ms()}static fromHex(e){Ms()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return Lr(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.init(this.ep.precompute(e,t))}toRawBytes(){return this.toBytes()}}function _a(e,t,n={}){if("function"!=typeof t)throw new Error('"hash" function param is required');Cs(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:r}=n,{BASE:i,Fp:o,Fn:s}=e,a=n.randomBytes||ni,u=n.adjustScalarBytes||(e=>e),c=n.domain||((e,t,n)=>{if(vs(n,"phflag"),t.length||n)throw new Error("Contexts/pre-hash are not supported");return e});function l(e){return s.create(ks(e))}function h(e){const{head:n,prefix:r,scalar:o}=function(e){const n=m.secretKey;e=Ts("private key",e,n);const r=Ts("hashed private key",t(e),2*n),i=u(r.slice(0,n));return{head:i,prefix:r.slice(n,2*n),scalar:l(i)}}(e),s=i.multiply(o),a=s.toBytes();return{head:n,prefix:r,scalar:o,point:s,pointBytes:a}}function f(e){return h(e).pointBytes}function d(e=Uint8Array.of(),...n){const i=Yr(...n);return l(t(c(i,Ts("context",e),!!r)))}const p={zip215:!0};const y=o.BYTES,m={secretKey:y,publicKey:y,signature:2*y,seed:y};function g(e=a(m.seed)){return ws(e,m.seed,"seed")}const b={getExtendedPublicKey:h,randomSecretKey:g,isValidSecretKey:function(e){return Tr(e)&&e.length===s.BYTES},isValidPublicKey:function(t,n){try{return!!e.fromBytes(t,n)}catch(e){return!1}},toMontgomery(t){const{y:n}=e.fromBytes(t),r=m.publicKey,i=32===r;if(!i&&57!==r)throw new Error("only defined for 25519 and 448");const s=i?o.div(wa+n,wa-n):o.div(n-wa,n+wa);return o.toBytes(s)},toMontgomerySecret(e){const n=m.secretKey;ws(e,n);const r=t(e.subarray(0,n));return u(r).subarray(0,n)},randomPrivateKey:g,precompute:(t=8,n=e.BASE)=>n.precompute(t,!1)};return Object.freeze({keygen:function(e){const t=b.randomSecretKey(e);return{secretKey:t,publicKey:f(t)}},getPublicKey:f,sign:function(e,t,n={}){e=Ts("message",e),r&&(e=r(e));const{prefix:o,scalar:a,pointBytes:u}=h(t),c=d(n.context,o,e),l=i.multiply(c).toBytes(),f=d(n.context,l,u,e),p=s.create(c+f*a);if(!s.isValid(p))throw new Error("sign failed: invalid s");return ws(Yr(l,s.toBytes(p)),m.signature,"result")},verify:function(t,n,o,s=p){const{context:a,zip215:u}=s,c=m.signature;t=Ts("signature",t,c),n=Ts("message",n),o=Ts("publicKey",o,m.publicKey),void 0!==u&&vs(u,"zip215"),r&&(n=r(n));const l=c/2,h=t.subarray(0,l),f=ks(t.subarray(l,c));let y,g,b;try{y=e.fromBytes(o,u),g=e.fromBytes(h,u),b=i.multiplyUnsafe(f)}catch(e){return!1}if(!u&&y.isSmallOrder())return!1;const v=d(a,g.toBytes(),y.toBytes(),n);return g.add(y.multiplyUnsafe(v)).subtract(b).clearCofactor().is0()},utils:b,Point:e,lengths:m})}function xa(e){const{CURVE:t,curveOpts:n,hash:r,eddsaOpts:i}=function(e){const t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n={Fp:e.Fp,Fn:na(t.n,e.nBitLength,!0),uvRatio:e.uvRatio},r={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:n,hash:e.hash,eddsaOpts:r}}(e);return function(e,t){const n=t.Point;return Object.assign({},t,{ExtendedPoint:n,CURVE:e,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}(e,_a(Sa(t,n),r,i))}Hr("HashToScalar-");const Oa=BigInt(0),Ia=BigInt(1),Ca=BigInt(2),Ma=(BigInt(3),BigInt(5)),Aa=BigInt(8),Na=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),ja=(()=>({p:Na,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Aa,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function Da(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),o=Na,s=e*e%o*e%o,a=Vs(s,Ca,o)*s%o,u=Vs(a,Ia,o)*e%o,c=Vs(u,Ma,o)*u%o,l=Vs(c,t,o)*c%o,h=Vs(l,n,o)*l%o,f=Vs(h,r,o)*h%o,d=Vs(f,i,o)*f%o,p=Vs(d,i,o)*f%o,y=Vs(p,t,o)*c%o;return{pow_p_5_8:Vs(y,Ca,o)*e%o,b2:s}}function Ra(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}const Pa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Ba(e,t){const n=Na,r=$s(t*t*t,n),i=$s(r*r*t,n);let o=$s(e*r*Da(e*i).pow_p_5_8,n);const s=$s(t*o*o,n),a=o,u=$s(o*Pa,n),c=s===e,l=s===$s(-e,n),h=s===$s(-e*Pa,n);return c&&(o=a),(l||h)&&(o=u),Js(o,n)&&(o=$s(-o,n)),{isValid:c||l,value:o}}const Fa=(()=>na(ja.p,{isLE:!0}))(),Ua=(()=>na(ja.n,{isLE:!0}))(),La=(()=>({...ja,Fp:Fa,hash:ms,adjustScalarBytes:Ra,uvRatio:Ba}))(),qa=(()=>xa(La))();const $a=Pa,Va=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),za=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Ka=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Wa=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Qa=e=>Ba(Ia,e),Ga=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Ha=e=>qa.Point.Fp.create(ks(e)&Ga);function Ja(e){const{d:t}=ja,n=Na,r=e=>Fa.create(e),i=r($a*e*e),o=r((i+Ia)*Ka);let s=BigInt(-1);const a=r((s-t*i)*r(i+t));let{isValid:u,value:c}=Ba(o,a),l=r(c*e);Js(l,n)||(l=r(-l)),u||(c=l),u||(s=i);const h=r(s*(i-Ia)*Wa-a),f=c*c,d=r((c+c)*a),p=r(h*Va),y=r(Ia-f),m=r(Ia+f);return new qa.Point(r(d*m),r(y*p),r(p*m),r(d*y))}function Za(e){xr(e,64);const t=Ja(Ha(e.subarray(0,32))),n=Ja(Ha(e.subarray(32,64)));return new Ya(t.add(n))}class Ya extends Ta{constructor(e){super(e)}static fromAffine(e){return new Ya(qa.Point.fromAffine(e))}assertSame(e){if(!(e instanceof Ya))throw new Error("RistrettoPoint expected")}init(e){return new Ya(e)}static hashToCurve(e){return Za(Ts("ristrettoHash",e,64))}static fromBytes(e){xr(e,32);const{a:t,d:n}=ja,r=Na,i=e=>Fa.create(e),o=Ha(e);if(!function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n}(Fa.toBytes(o),e)||Js(o,r))throw new Error("invalid ristretto255 encoding 1");const s=i(o*o),a=i(Ia+t*s),u=i(Ia-t*s),c=i(a*a),l=i(u*u),h=i(t*n*c-l),{isValid:f,value:d}=Qa(i(h*l)),p=i(d*u),y=i(d*p*h);let m=i((o+o)*p);Js(m,r)&&(m=i(-m));const g=i(a*y),b=i(m*g);if(!f||Js(b,r)||g===Oa)throw new Error("invalid ristretto255 encoding 2");return new Ya(new qa.Point(m,g,Ia,b))}static fromHex(e){return Ya.fromBytes(Ts("ristrettoHex",e,32))}static msm(e,t){return ga(Ya,qa.Point.Fn,e,t)}toBytes(){let{X:e,Y:t,Z:n,T:r}=this.ep;const i=Na,o=e=>Fa.create(e),s=o(o(n+t)*o(n-t)),a=o(e*t),u=o(a*a),{value:c}=Qa(o(s*u)),l=o(c*s),h=o(c*a),f=o(l*h*r);let d;if(Js(r*f,i)){let n=o(t*$a),r=o(e*$a);e=n,t=r,d=o(l*za)}else d=h;Js(e*f,i)&&(t=o(-t));let p=o((n-t)*d);return Js(p,i)&&(p=o(-p)),Fa.toBytes(p)}equals(e){this.assertSame(e);const{X:t,Y:n}=this.ep,{X:r,Y:i}=e.ep,o=e=>Fa.create(e),s=o(t*i)===o(n*r),a=o(n*i)===o(t*r);return s||a}is0(){return this.equals(Ya.ZERO)}}Ya.BASE=(()=>new Ya(qa.Point.BASE))(),Ya.ZERO=(()=>new Ya(qa.Point.ZERO))(),Ya.Fp=(()=>Fa)(),Ya.Fn=(()=>Ua)();function Xa(e,t){return ar.IntentMessage(ar.fixedArray(t.length,ar.u8())).serialize({intent:{scope:{[e]:!0},version:{V0:!0},appId:{Sui:!0}},value:t}).toBytes()}const eu={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5,Passkey:6},tu={ED25519:32,Secp256k1:33,Secp256r1:33},nu={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin",6:"Passkey"};const ru="suiprivkey";class iu{async signWithIntent(e,t){const n=Xa(t,e),r=Pi(n,{dkLen:32});return{signature:function({signature:e,signatureScheme:t,publicKey:n}){if(!n)throw new Error("`publicKey` is required");const r=n.toRawBytes(),i=new Uint8Array(1+e.length+r.length);return i.set([eu[t]]),i.set(e,1),i.set(r,1+e.length),o(i)}({signature:await this.sign(r),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:o(e)}}async signTransaction(e){return this.signWithIntent(e,"TransactionData")}async signPersonalMessage(e){const{signature:t}=await this.signWithIntent(un.vector(un.u8()).serialize(e).toBytes(),"PersonalMessage");return{bytes:o(e),signature:t}}async signAndExecuteTransaction({transaction:e,client:t}){const n=await e.build({client:t}),{signature:r}=await this.signTransaction(n);return(await t.core.executeTransaction({transaction:n,signatures:[r]})).transaction}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class ou extends iu{}function su(e){const{prefix:t,words:n}=Q.decode(e);if(t!==ru)throw new Error("invalid private key prefix");const r=new Uint8Array(Q.fromWords(n)),i=r.slice(1),o=nu[r[0]];return{scheme:o,schema:o,secretKey:i}}class au extends Xr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Or(e);const n=Jr(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),Ar(i)}update(e){return Ir(this),this.iHash.update(e),this}digestInto(e){Ir(this),xr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:o,outputLen:s}=this;return e.finished=r,e.destroyed=i,e.blockLen=o,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const uu=(e,t,n)=>new au(e,t).update(n).digest();function cu(e,t,n,r){Or(e);const i=function(e,t){if(void 0!==t&&"[object Object]"!=={}.toString.call(t))throw new Error("options should be object or undefined");return Object.assign(e,t)}({dkLen:32,asyncTick:10},r),{c:o,dkLen:s,asyncTick:a}=i;if(_r(o),_r(s),_r(a),o<1)throw new Error("iterations (c) should be >= 1");const u=Zr(t),c=Zr(n),l=new Uint8Array(s),h=uu.create(e,u),f=h._cloneInto().update(c);return{c:o,dkLen:s,asyncTick:a,DK:l,PRF:h,PRFSalt:f}}function lu(e,t,n,r,i){return e.destroy(),t.destroy(),r&&r.destroy(),Ar(i),n}uu.create=(e,t)=>new au(e,t);function hu(e){if("string"!=typeof e)throw new TypeError("invalid mnemonic type: "+typeof e);return e.normalize("NFKD")}function fu(e){const t=hu(e),n=t.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:n}}function du(e){xr(e,16,20,24,28,32)}function pu(e,t=128){if(_r(t),t%32!=0||t>256)throw new TypeError("Invalid entropy");return function(e,t){du(e);const n=mu(t).encode(e);return n.join((e=>"あいこくしん"===e[0])(t)?" ":" ")}(ni(t/8),e)}const yu=e=>{const t=8-e.length/4;return new Uint8Array([ys(e)[0]>>t<<t])};function mu(e){if(!Array.isArray(e)||2048!==e.length||"string"!=typeof e[0])throw new Error("Wordlist: expected array of 2048 strings");return e.forEach(e=>{if("string"!=typeof e)throw new Error("wordlist: non-string element: "+e)}),A.chain(A.checksum(1,yu),A.radix2(11,!0),A.alphabet(e))}const gu=e=>hu("mnemonic"+e);function bu(e,t=""){return function(e,t,n,r){const{c:i,dkLen:o,DK:s,PRF:a,PRFSalt:u}=cu(e,t,n,r);let c;const l=new Uint8Array(4),h=Nr(l),f=new Uint8Array(a.outputLen);for(let e=1,t=0;t<o;e++,t+=a.outputLen){const n=s.subarray(t,t+a.outputLen);h.setInt32(0,e,!1),(c=u._cloneInto(c)).update(l).digestInto(f),n.set(f.subarray(0,n.length));for(let e=1;e<i;e++){a._cloneInto(c).update(f).digestInto(f);for(let e=0;e<n.length;e++)n[e]^=f[e]}}return lu(a,u,s,c,f)}(ms,fu(e).nfkd,gu(t),{c:2048,dkLen:64})}function vu(e){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(e)}function wu(e){return a(function(e){return bu(e,"")}(e))}const Eu=ms,ku=new RegExp("^m(\\/[0-9]+')+$"),Su=e=>e.replace("'",""),Tu=(e,t,n=2147483648)=>{if(!(e=>!!ku.test(e)&&!e.split("/").slice(1).map(Su).some(isNaN))(e))throw new Error("Invalid derivation path");const{key:r,chainCode:i}=(e=>{const t=uu.create(Eu,"ed25519 seed").update(s(e)).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}})(t);return e.split("/").slice(1).map(Su).map(e=>parseInt(e,10)).reduce((e,t)=>(({key:e,chainCode:t},n)=>{const r=new ArrayBuffer(4);new DataView(r).setUint32(0,n);const i=new Uint8Array(1+e.length+r.byteLength);i.set(new Uint8Array(1).fill(0)),i.set(e,1),i.set(new Uint8Array(r,0,r.byteLength),e.length+1);const o=uu.create(Eu,t).update(i).digest();return{key:o.slice(0,32),chainCode:o.slice(32)}})(e,t+n),{key:r,chainCode:i})};function _u(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}class xu{equals(e){return _u(this.toRawBytes(),e.toRawBytes())}toBase64(){return o(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){return o(this.toSuiBytes())}verifyWithIntent(e,t,n){const r=Xa(n,e),i=Pi(r,{dkLen:32});return this.verify(i,t)}verifyPersonalMessage(e,t){return this.verifyWithIntent(ar.vector(ar.u8()).serialize(e).toBytes(),t,"PersonalMessage")}verifyTransaction(e,t){return this.verifyWithIntent(e,t,"TransactionData")}verifyAddress(e){return this.toSuiAddress()===e}toSuiBytes(){const e=this.toRawBytes(),t=new Uint8Array(e.length+1);return t.set([this.flag()]),t.set(e,1),t}toSuiAddress(){return at(Lr(Pi(this.toSuiBytes(),{dkLen:32})).slice(0,64))}}class Ou extends xu{constructor(e){if(super(),"string"==typeof e?this.data=t(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),32!==this.data.length)throw new Error(`Invalid public key input. Expected 32 bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return eu.ED25519}async verify(e,n){let r;if("string"==typeof n){const e=function(e){const n=t(e),r=nu[n[0]];switch(r){case"ED25519":case"Secp256k1":case"Secp256r1":const t=tu[r],i=n.slice(1,n.length-t);return{serializedSignature:e,signatureScheme:r,signature:i,publicKey:n.slice(1+i.length),bytes:n};default:throw new Error("Unsupported signature scheme")}}(n);if("ED25519"!==e.signatureScheme)throw new Error("Invalid signature scheme");if(!_u(this.toRawBytes(),e.publicKey))throw new Error("Signature does not match public key");r=e.signature}else r=n;return qa.verify(r,e,this.toRawBytes())}}Ou.SIZE=32;const Iu="m/44'/784'/0'/0'/0'";class Cu extends ou{constructor(e){if(super(),e)this.keypair={publicKey:e.publicKey,secretKey:e.secretKey.slice(0,32)};else{const e=qa.utils.randomPrivateKey();this.keypair={publicKey:qa.getPublicKey(e),secretKey:e}}}getKeyScheme(){return"ED25519"}static generate(){const e=qa.utils.randomPrivateKey();return new Cu({publicKey:qa.getPublicKey(e),secretKey:e})}static fromSecretKey(e,t){if("string"==typeof e){const n=su(e);if("ED25519"!==n.schema)throw new Error(`Expected a ED25519 keypair, got ${n.schema}`);return this.fromSecretKey(n.secretKey,t)}const n=e.length;if(32!==n)throw new Error(`Wrong secretKey size. Expected 32 bytes, got ${n}.`);const r={publicKey:qa.getPublicKey(e),secretKey:e};if(!t||!t.skipValidation){const t=(new TextEncoder).encode("sui validation"),n=qa.sign(t,e);if(!qa.verify(n,t,r.publicKey))throw new Error("provided secretKey is invalid")}return new Cu(r)}getPublicKey(){return new Ou(this.keypair.publicKey)}getSecretKey(){return function(e,t){if(32!==e.length)throw new Error("Invalid bytes length");const n=eu[t],r=new Uint8Array(e.length+1);return r.set([n]),r.set(e,1),Q.encode(ru,Q.toWords(r))}(this.keypair.secretKey.slice(0,32),this.getKeyScheme())}async sign(e){return qa.sign(e,this.keypair.secretKey)}static deriveKeypair(e,t){if(null==t&&(t=Iu),!vu(t))throw new Error("Invalid derivation path");const{key:n}=Tu(t,wu(e));return Cu.fromSecretKey(n)}static deriveKeypairFromSeed(e,t){if(null==t&&(t=Iu),!vu(t))throw new Error("Invalid derivation path");const{key:n}=Tu(t,e);return Cu.fromSecretKey(n)}}const Mu=t,Au="abandon\nability\nable\nabout\nabove\nabsent\nabsorb\nabstract\nabsurd\nabuse\naccess\naccident\naccount\naccuse\nachieve\nacid\nacoustic\nacquire\nacross\nact\naction\nactor\nactress\nactual\nadapt\nadd\naddict\naddress\nadjust\nadmit\nadult\nadvance\nadvice\naerobic\naffair\nafford\nafraid\nagain\nage\nagent\nagree\nahead\naim\nair\nairport\naisle\nalarm\nalbum\nalcohol\nalert\nalien\nall\nalley\nallow\nalmost\nalone\nalpha\nalready\nalso\nalter\nalways\namateur\namazing\namong\namount\namused\nanalyst\nanchor\nancient\nanger\nangle\nangry\nanimal\nankle\nannounce\nannual\nanother\nanswer\nantenna\nantique\nanxiety\nany\napart\napology\nappear\napple\napprove\napril\narch\narctic\narea\narena\nargue\narm\narmed\narmor\narmy\naround\narrange\narrest\narrive\narrow\nart\nartefact\nartist\nartwork\nask\naspect\nassault\nasset\nassist\nassume\nasthma\nathlete\natom\nattack\nattend\nattitude\nattract\nauction\naudit\naugust\naunt\nauthor\nauto\nautumn\naverage\navocado\navoid\nawake\naware\naway\nawesome\nawful\nawkward\naxis\nbaby\nbachelor\nbacon\nbadge\nbag\nbalance\nbalcony\nball\nbamboo\nbanana\nbanner\nbar\nbarely\nbargain\nbarrel\nbase\nbasic\nbasket\nbattle\nbeach\nbean\nbeauty\nbecause\nbecome\nbeef\nbefore\nbegin\nbehave\nbehind\nbelieve\nbelow\nbelt\nbench\nbenefit\nbest\nbetray\nbetter\nbetween\nbeyond\nbicycle\nbid\nbike\nbind\nbiology\nbird\nbirth\nbitter\nblack\nblade\nblame\nblanket\nblast\nbleak\nbless\nblind\nblood\nblossom\nblouse\nblue\nblur\nblush\nboard\nboat\nbody\nboil\nbomb\nbone\nbonus\nbook\nboost\nborder\nboring\nborrow\nboss\nbottom\nbounce\nbox\nboy\nbracket\nbrain\nbrand\nbrass\nbrave\nbread\nbreeze\nbrick\nbridge\nbrief\nbright\nbring\nbrisk\nbroccoli\nbroken\nbronze\nbroom\nbrother\nbrown\nbrush\nbubble\nbuddy\nbudget\nbuffalo\nbuild\nbulb\nbulk\nbullet\nbundle\nbunker\nburden\nburger\nburst\nbus\nbusiness\nbusy\nbutter\nbuyer\nbuzz\ncabbage\ncabin\ncable\ncactus\ncage\ncake\ncall\ncalm\ncamera\ncamp\ncan\ncanal\ncancel\ncandy\ncannon\ncanoe\ncanvas\ncanyon\ncapable\ncapital\ncaptain\ncar\ncarbon\ncard\ncargo\ncarpet\ncarry\ncart\ncase\ncash\ncasino\ncastle\ncasual\ncat\ncatalog\ncatch\ncategory\ncattle\ncaught\ncause\ncaution\ncave\nceiling\ncelery\ncement\ncensus\ncentury\ncereal\ncertain\nchair\nchalk\nchampion\nchange\nchaos\nchapter\ncharge\nchase\nchat\ncheap\ncheck\ncheese\nchef\ncherry\nchest\nchicken\nchief\nchild\nchimney\nchoice\nchoose\nchronic\nchuckle\nchunk\nchurn\ncigar\ncinnamon\ncircle\ncitizen\ncity\ncivil\nclaim\nclap\nclarify\nclaw\nclay\nclean\nclerk\nclever\nclick\nclient\ncliff\nclimb\nclinic\nclip\nclock\nclog\nclose\ncloth\ncloud\nclown\nclub\nclump\ncluster\nclutch\ncoach\ncoast\ncoconut\ncode\ncoffee\ncoil\ncoin\ncollect\ncolor\ncolumn\ncombine\ncome\ncomfort\ncomic\ncommon\ncompany\nconcert\nconduct\nconfirm\ncongress\nconnect\nconsider\ncontrol\nconvince\ncook\ncool\ncopper\ncopy\ncoral\ncore\ncorn\ncorrect\ncost\ncotton\ncouch\ncountry\ncouple\ncourse\ncousin\ncover\ncoyote\ncrack\ncradle\ncraft\ncram\ncrane\ncrash\ncrater\ncrawl\ncrazy\ncream\ncredit\ncreek\ncrew\ncricket\ncrime\ncrisp\ncritic\ncrop\ncross\ncrouch\ncrowd\ncrucial\ncruel\ncruise\ncrumble\ncrunch\ncrush\ncry\ncrystal\ncube\nculture\ncup\ncupboard\ncurious\ncurrent\ncurtain\ncurve\ncushion\ncustom\ncute\ncycle\ndad\ndamage\ndamp\ndance\ndanger\ndaring\ndash\ndaughter\ndawn\nday\ndeal\ndebate\ndebris\ndecade\ndecember\ndecide\ndecline\ndecorate\ndecrease\ndeer\ndefense\ndefine\ndefy\ndegree\ndelay\ndeliver\ndemand\ndemise\ndenial\ndentist\ndeny\ndepart\ndepend\ndeposit\ndepth\ndeputy\nderive\ndescribe\ndesert\ndesign\ndesk\ndespair\ndestroy\ndetail\ndetect\ndevelop\ndevice\ndevote\ndiagram\ndial\ndiamond\ndiary\ndice\ndiesel\ndiet\ndiffer\ndigital\ndignity\ndilemma\ndinner\ndinosaur\ndirect\ndirt\ndisagree\ndiscover\ndisease\ndish\ndismiss\ndisorder\ndisplay\ndistance\ndivert\ndivide\ndivorce\ndizzy\ndoctor\ndocument\ndog\ndoll\ndolphin\ndomain\ndonate\ndonkey\ndonor\ndoor\ndose\ndouble\ndove\ndraft\ndragon\ndrama\ndrastic\ndraw\ndream\ndress\ndrift\ndrill\ndrink\ndrip\ndrive\ndrop\ndrum\ndry\nduck\ndumb\ndune\nduring\ndust\ndutch\nduty\ndwarf\ndynamic\neager\neagle\nearly\nearn\nearth\neasily\neast\neasy\necho\necology\neconomy\nedge\nedit\neducate\neffort\negg\neight\neither\nelbow\nelder\nelectric\nelegant\nelement\nelephant\nelevator\nelite\nelse\nembark\nembody\nembrace\nemerge\nemotion\nemploy\nempower\nempty\nenable\nenact\nend\nendless\nendorse\nenemy\nenergy\nenforce\nengage\nengine\nenhance\nenjoy\nenlist\nenough\nenrich\nenroll\nensure\nenter\nentire\nentry\nenvelope\nepisode\nequal\nequip\nera\nerase\nerode\nerosion\nerror\nerupt\nescape\nessay\nessence\nestate\neternal\nethics\nevidence\nevil\nevoke\nevolve\nexact\nexample\nexcess\nexchange\nexcite\nexclude\nexcuse\nexecute\nexercise\nexhaust\nexhibit\nexile\nexist\nexit\nexotic\nexpand\nexpect\nexpire\nexplain\nexpose\nexpress\nextend\nextra\neye\neyebrow\nfabric\nface\nfaculty\nfade\nfaint\nfaith\nfall\nfalse\nfame\nfamily\nfamous\nfan\nfancy\nfantasy\nfarm\nfashion\nfat\nfatal\nfather\nfatigue\nfault\nfavorite\nfeature\nfebruary\nfederal\nfee\nfeed\nfeel\nfemale\nfence\nfestival\nfetch\nfever\nfew\nfiber\nfiction\nfield\nfigure\nfile\nfilm\nfilter\nfinal\nfind\nfine\nfinger\nfinish\nfire\nfirm\nfirst\nfiscal\nfish\nfit\nfitness\nfix\nflag\nflame\nflash\nflat\nflavor\nflee\nflight\nflip\nfloat\nflock\nfloor\nflower\nfluid\nflush\nfly\nfoam\nfocus\nfog\nfoil\nfold\nfollow\nfood\nfoot\nforce\nforest\nforget\nfork\nfortune\nforum\nforward\nfossil\nfoster\nfound\nfox\nfragile\nframe\nfrequent\nfresh\nfriend\nfringe\nfrog\nfront\nfrost\nfrown\nfrozen\nfruit\nfuel\nfun\nfunny\nfurnace\nfury\nfuture\ngadget\ngain\ngalaxy\ngallery\ngame\ngap\ngarage\ngarbage\ngarden\ngarlic\ngarment\ngas\ngasp\ngate\ngather\ngauge\ngaze\ngeneral\ngenius\ngenre\ngentle\ngenuine\ngesture\nghost\ngiant\ngift\ngiggle\nginger\ngiraffe\ngirl\ngive\nglad\nglance\nglare\nglass\nglide\nglimpse\nglobe\ngloom\nglory\nglove\nglow\nglue\ngoat\ngoddess\ngold\ngood\ngoose\ngorilla\ngospel\ngossip\ngovern\ngown\ngrab\ngrace\ngrain\ngrant\ngrape\ngrass\ngravity\ngreat\ngreen\ngrid\ngrief\ngrit\ngrocery\ngroup\ngrow\ngrunt\nguard\nguess\nguide\nguilt\nguitar\ngun\ngym\nhabit\nhair\nhalf\nhammer\nhamster\nhand\nhappy\nharbor\nhard\nharsh\nharvest\nhat\nhave\nhawk\nhazard\nhead\nhealth\nheart\nheavy\nhedgehog\nheight\nhello\nhelmet\nhelp\nhen\nhero\nhidden\nhigh\nhill\nhint\nhip\nhire\nhistory\nhobby\nhockey\nhold\nhole\nholiday\nhollow\nhome\nhoney\nhood\nhope\nhorn\nhorror\nhorse\nhospital\nhost\nhotel\nhour\nhover\nhub\nhuge\nhuman\nhumble\nhumor\nhundred\nhungry\nhunt\nhurdle\nhurry\nhurt\nhusband\nhybrid\nice\nicon\nidea\nidentify\nidle\nignore\nill\nillegal\nillness\nimage\nimitate\nimmense\nimmune\nimpact\nimpose\nimprove\nimpulse\ninch\ninclude\nincome\nincrease\nindex\nindicate\nindoor\nindustry\ninfant\ninflict\ninform\ninhale\ninherit\ninitial\ninject\ninjury\ninmate\ninner\ninnocent\ninput\ninquiry\ninsane\ninsect\ninside\ninspire\ninstall\nintact\ninterest\ninto\ninvest\ninvite\ninvolve\niron\nisland\nisolate\nissue\nitem\nivory\njacket\njaguar\njar\njazz\njealous\njeans\njelly\njewel\njob\njoin\njoke\njourney\njoy\njudge\njuice\njump\njungle\njunior\njunk\njust\nkangaroo\nkeen\nkeep\nketchup\nkey\nkick\nkid\nkidney\nkind\nkingdom\nkiss\nkit\nkitchen\nkite\nkitten\nkiwi\nknee\nknife\nknock\nknow\nlab\nlabel\nlabor\nladder\nlady\nlake\nlamp\nlanguage\nlaptop\nlarge\nlater\nlatin\nlaugh\nlaundry\nlava\nlaw\nlawn\nlawsuit\nlayer\nlazy\nleader\nleaf\nlearn\nleave\nlecture\nleft\nleg\nlegal\nlegend\nleisure\nlemon\nlend\nlength\nlens\nleopard\nlesson\nletter\nlevel\nliar\nliberty\nlibrary\nlicense\nlife\nlift\nlight\nlike\nlimb\nlimit\nlink\nlion\nliquid\nlist\nlittle\nlive\nlizard\nload\nloan\nlobster\nlocal\nlock\nlogic\nlonely\nlong\nloop\nlottery\nloud\nlounge\nlove\nloyal\nlucky\nluggage\nlumber\nlunar\nlunch\nluxury\nlyrics\nmachine\nmad\nmagic\nmagnet\nmaid\nmail\nmain\nmajor\nmake\nmammal\nman\nmanage\nmandate\nmango\nmansion\nmanual\nmaple\nmarble\nmarch\nmargin\nmarine\nmarket\nmarriage\nmask\nmass\nmaster\nmatch\nmaterial\nmath\nmatrix\nmatter\nmaximum\nmaze\nmeadow\nmean\nmeasure\nmeat\nmechanic\nmedal\nmedia\nmelody\nmelt\nmember\nmemory\nmention\nmenu\nmercy\nmerge\nmerit\nmerry\nmesh\nmessage\nmetal\nmethod\nmiddle\nmidnight\nmilk\nmillion\nmimic\nmind\nminimum\nminor\nminute\nmiracle\nmirror\nmisery\nmiss\nmistake\nmix\nmixed\nmixture\nmobile\nmodel\nmodify\nmom\nmoment\nmonitor\nmonkey\nmonster\nmonth\nmoon\nmoral\nmore\nmorning\nmosquito\nmother\nmotion\nmotor\nmountain\nmouse\nmove\nmovie\nmuch\nmuffin\nmule\nmultiply\nmuscle\nmuseum\nmushroom\nmusic\nmust\nmutual\nmyself\nmystery\nmyth\nnaive\nname\nnapkin\nnarrow\nnasty\nnation\nnature\nnear\nneck\nneed\nnegative\nneglect\nneither\nnephew\nnerve\nnest\nnet\nnetwork\nneutral\nnever\nnews\nnext\nnice\nnight\nnoble\nnoise\nnominee\nnoodle\nnormal\nnorth\nnose\nnotable\nnote\nnothing\nnotice\nnovel\nnow\nnuclear\nnumber\nnurse\nnut\noak\nobey\nobject\noblige\nobscure\nobserve\nobtain\nobvious\noccur\nocean\noctober\nodor\noff\noffer\noffice\noften\noil\nokay\nold\nolive\nolympic\nomit\nonce\none\nonion\nonline\nonly\nopen\nopera\nopinion\noppose\noption\norange\norbit\norchard\norder\nordinary\norgan\norient\noriginal\norphan\nostrich\nother\noutdoor\nouter\noutput\noutside\noval\noven\nover\nown\nowner\noxygen\noyster\nozone\npact\npaddle\npage\npair\npalace\npalm\npanda\npanel\npanic\npanther\npaper\nparade\nparent\npark\nparrot\nparty\npass\npatch\npath\npatient\npatrol\npattern\npause\npave\npayment\npeace\npeanut\npear\npeasant\npelican\npen\npenalty\npencil\npeople\npepper\nperfect\npermit\nperson\npet\nphone\nphoto\nphrase\nphysical\npiano\npicnic\npicture\npiece\npig\npigeon\npill\npilot\npink\npioneer\npipe\npistol\npitch\npizza\nplace\nplanet\nplastic\nplate\nplay\nplease\npledge\npluck\nplug\nplunge\npoem\npoet\npoint\npolar\npole\npolice\npond\npony\npool\npopular\nportion\nposition\npossible\npost\npotato\npottery\npoverty\npowder\npower\npractice\npraise\npredict\nprefer\nprepare\npresent\npretty\nprevent\nprice\npride\nprimary\nprint\npriority\nprison\nprivate\nprize\nproblem\nprocess\nproduce\nprofit\nprogram\nproject\npromote\nproof\nproperty\nprosper\nprotect\nproud\nprovide\npublic\npudding\npull\npulp\npulse\npumpkin\npunch\npupil\npuppy\npurchase\npurity\npurpose\npurse\npush\nput\npuzzle\npyramid\nquality\nquantum\nquarter\nquestion\nquick\nquit\nquiz\nquote\nrabbit\nraccoon\nrace\nrack\nradar\nradio\nrail\nrain\nraise\nrally\nramp\nranch\nrandom\nrange\nrapid\nrare\nrate\nrather\nraven\nraw\nrazor\nready\nreal\nreason\nrebel\nrebuild\nrecall\nreceive\nrecipe\nrecord\nrecycle\nreduce\nreflect\nreform\nrefuse\nregion\nregret\nregular\nreject\nrelax\nrelease\nrelief\nrely\nremain\nremember\nremind\nremove\nrender\nrenew\nrent\nreopen\nrepair\nrepeat\nreplace\nreport\nrequire\nrescue\nresemble\nresist\nresource\nresponse\nresult\nretire\nretreat\nreturn\nreunion\nreveal\nreview\nreward\nrhythm\nrib\nribbon\nrice\nrich\nride\nridge\nrifle\nright\nrigid\nring\nriot\nripple\nrisk\nritual\nrival\nriver\nroad\nroast\nrobot\nrobust\nrocket\nromance\nroof\nrookie\nroom\nrose\nrotate\nrough\nround\nroute\nroyal\nrubber\nrude\nrug\nrule\nrun\nrunway\nrural\nsad\nsaddle\nsadness\nsafe\nsail\nsalad\nsalmon\nsalon\nsalt\nsalute\nsame\nsample\nsand\nsatisfy\nsatoshi\nsauce\nsausage\nsave\nsay\nscale\nscan\nscare\nscatter\nscene\nscheme\nschool\nscience\nscissors\nscorpion\nscout\nscrap\nscreen\nscript\nscrub\nsea\nsearch\nseason\nseat\nsecond\nsecret\nsection\nsecurity\nseed\nseek\nsegment\nselect\nsell\nseminar\nsenior\nsense\nsentence\nseries\nservice\nsession\nsettle\nsetup\nseven\nshadow\nshaft\nshallow\nshare\nshed\nshell\nsheriff\nshield\nshift\nshine\nship\nshiver\nshock\nshoe\nshoot\nshop\nshort\nshoulder\nshove\nshrimp\nshrug\nshuffle\nshy\nsibling\nsick\nside\nsiege\nsight\nsign\nsilent\nsilk\nsilly\nsilver\nsimilar\nsimple\nsince\nsing\nsiren\nsister\nsituate\nsix\nsize\nskate\nsketch\nski\nskill\nskin\nskirt\nskull\nslab\nslam\nsleep\nslender\nslice\nslide\nslight\nslim\nslogan\nslot\nslow\nslush\nsmall\nsmart\nsmile\nsmoke\nsmooth\nsnack\nsnake\nsnap\nsniff\nsnow\nsoap\nsoccer\nsocial\nsock\nsoda\nsoft\nsolar\nsoldier\nsolid\nsolution\nsolve\nsomeone\nsong\nsoon\nsorry\nsort\nsoul\nsound\nsoup\nsource\nsouth\nspace\nspare\nspatial\nspawn\nspeak\nspecial\nspeed\nspell\nspend\nsphere\nspice\nspider\nspike\nspin\nspirit\nsplit\nspoil\nsponsor\nspoon\nsport\nspot\nspray\nspread\nspring\nspy\nsquare\nsqueeze\nsquirrel\nstable\nstadium\nstaff\nstage\nstairs\nstamp\nstand\nstart\nstate\nstay\nsteak\nsteel\nstem\nstep\nstereo\nstick\nstill\nsting\nstock\nstomach\nstone\nstool\nstory\nstove\nstrategy\nstreet\nstrike\nstrong\nstruggle\nstudent\nstuff\nstumble\nstyle\nsubject\nsubmit\nsubway\nsuccess\nsuch\nsudden\nsuffer\nsugar\nsuggest\nsuit\nsummer\nsun\nsunny\nsunset\nsuper\nsupply\nsupreme\nsure\nsurface\nsurge\nsurprise\nsurround\nsurvey\nsuspect\nsustain\nswallow\nswamp\nswap\nswarm\nswear\nsweet\nswift\nswim\nswing\nswitch\nsword\nsymbol\nsymptom\nsyrup\nsystem\ntable\ntackle\ntag\ntail\ntalent\ntalk\ntank\ntape\ntarget\ntask\ntaste\ntattoo\ntaxi\nteach\nteam\ntell\nten\ntenant\ntennis\ntent\nterm\ntest\ntext\nthank\nthat\ntheme\nthen\ntheory\nthere\nthey\nthing\nthis\nthought\nthree\nthrive\nthrow\nthumb\nthunder\nticket\ntide\ntiger\ntilt\ntimber\ntime\ntiny\ntip\ntired\ntissue\ntitle\ntoast\ntobacco\ntoday\ntoddler\ntoe\ntogether\ntoilet\ntoken\ntomato\ntomorrow\ntone\ntongue\ntonight\ntool\ntooth\ntop\ntopic\ntopple\ntorch\ntornado\ntortoise\ntoss\ntotal\ntourist\ntoward\ntower\ntown\ntoy\ntrack\ntrade\ntraffic\ntragic\ntrain\ntransfer\ntrap\ntrash\ntravel\ntray\ntreat\ntree\ntrend\ntrial\ntribe\ntrick\ntrigger\ntrim\ntrip\ntrophy\ntrouble\ntruck\ntrue\ntruly\ntrumpet\ntrust\ntruth\ntry\ntube\ntuition\ntumble\ntuna\ntunnel\nturkey\nturn\nturtle\ntwelve\ntwenty\ntwice\ntwin\ntwist\ntwo\ntype\ntypical\nugly\numbrella\nunable\nunaware\nuncle\nuncover\nunder\nundo\nunfair\nunfold\nunhappy\nuniform\nunique\nunit\nuniverse\nunknown\nunlock\nuntil\nunusual\nunveil\nupdate\nupgrade\nuphold\nupon\nupper\nupset\nurban\nurge\nusage\nuse\nused\nuseful\nuseless\nusual\nutility\nvacant\nvacuum\nvague\nvalid\nvalley\nvalve\nvan\nvanish\nvapor\nvarious\nvast\nvault\nvehicle\nvelvet\nvendor\nventure\nvenue\nverb\nverify\nversion\nvery\nvessel\nveteran\nviable\nvibrant\nvicious\nvictory\nvideo\nview\nvillage\nvintage\nviolin\nvirtual\nvirus\nvisa\nvisit\nvisual\nvital\nvivid\nvocal\nvoice\nvoid\nvolcano\nvolume\nvote\nvoyage\nwage\nwagon\nwait\nwalk\nwall\nwalnut\nwant\nwarfare\nwarm\nwarrior\nwash\nwasp\nwaste\nwater\nwave\nway\nwealth\nweapon\nwear\nweasel\nweather\nweb\nwedding\nweekend\nweird\nwelcome\nwest\nwet\nwhale\nwhat\nwheat\nwheel\nwhen\nwhere\nwhip\nwhisper\nwide\nwidth\nwife\nwild\nwill\nwin\nwindow\nwine\nwing\nwink\nwinner\nwinter\nwire\nwisdom\nwise\nwish\nwitness\nwolf\nwoman\nwonder\nwood\nwool\nword\nwork\nworld\nworry\nworth\nwrap\nwreck\nwrestle\nwrist\nwrite\nwrong\nyard\nyear\nyellow\nyou\nyoung\nyouth\nzebra\nzero\nzone\nzoo".split("\n");class Nu{constructor({network:e,base:t}){this.cache=new Qi,this.network=e,this.base=t??this}$extend(...e){return Object.create(this,Object.fromEntries(e.map(e=>{if("experimental_asClientExtension"in e){const{name:t,register:n}=e.experimental_asClientExtension();return[t,{value:n(this)}]}return[e.name,{value:e.register(this)}]})))}}class ju extends Nu{constructor(e){super(e),this.core=this,this.mvr=new vo({cache:this.base.cache.scope("core"),url:e.mvr?.url,pageSize:e.mvr?.pageSize,overrides:e.mvr?.overrides})}async getObject(e){const{objectId:t}=e,{objects:[n]}=await this.getObjects({objectIds:[t],signal:e.signal});if(n instanceof Error)throw n;return{object:n}}async getDynamicField(e){const t=function(e,t,n){const r=ar.Address.serialize(e).toBytes(),i=ar.TypeTag.serialize(t).toBytes(),o=ar.u64().serialize(n.length).toBytes(),s=Pi.create({dkLen:32});return s.update(new Uint8Array([240])),s.update(r),s.update(o),s.update(n),s.update(i),`0x${a(s.digest().slice(0,32))}`}(e.parentId,Mt.parseFromStr(e.name.type),e.name.bcs),{objects:[n]}=await this.getObjects({objectIds:[t],signal:e.signal});if(n instanceof Error)throw n;const r=ot(n.type),i=await n.content;return{dynamicField:{id:n.id,digest:n.digest,version:n.version,type:n.type,name:{type:"string"==typeof r.typeParams[0]?r.typeParams[0]:st(r.typeParams[0]),bcs:e.name.bcs},value:{type:"string"==typeof r.typeParams[1]?r.typeParams[1]:st(r.typeParams[1]),bcs:i.slice(32+e.name.bcs.length)}}}}async waitForTransaction({signal:e,timeout:t=6e4,...n}){const r=e?AbortSignal.any([AbortSignal.timeout(t),e]):AbortSignal.timeout(t),i=new Promise((e,t)=>{r.addEventListener("abort",()=>t(r.reason))});for(i.catch(()=>{});;){r.throwIfAborted();try{return await this.getTransaction({...n,signal:r})}catch(e){await Promise.race([new Promise(e=>setTimeout(e,2e3)),i])}}}}class Du extends Error{}class Ru extends Du{constructor(e,t){super(t),this.code=e}static fromResponse(e,t){switch(e.code){case"notExists":return new Ru(e.code,`Object ${e.object_id} does not exist`);case"dynamicFieldNotFound":return new Ru(e.code,`Dynamic field not found for object ${e.parent_object_id}`);case"deleted":return new Ru(e.code,`Object ${e.object_id} has been deleted`);case"displayError":return new Ru(e.code,`Display error: ${e.error}`);default:return new Ru(e.code,"Unknown error while loading object"+(t?` ${t}`:""))}}}function Pu(e){return{...Fi.fromBytes(e).snapshot(),bcs:e}}function Bu(e){const t=ar.TransactionEffects.parse(e);switch(t.$kind){case"V1":return function(){throw new Error("V1 effects are not supported yet")}(t.V1);case"V2":return function({bytes:e,effects:t}){const n=t.changedObjects.map(([e,n])=>({id:e,inputState:"Exist"===n.inputState.$kind?"Exists":"DoesNotExist",inputVersion:n.inputState.Exist?.[0][0]??null,inputDigest:n.inputState.Exist?.[0][1]??null,inputOwner:n.inputState.Exist?.[1]??null,outputState:"NotExist"===n.outputState.$kind?"DoesNotExist":n.outputState.$kind,outputVersion:"PackageWrite"===n.outputState.$kind?n.outputState.PackageWrite?.[0]:n.outputState.ObjectWrite?t.lamportVersion:null,outputDigest:"PackageWrite"===n.outputState.$kind?n.outputState.PackageWrite?.[1]:n.outputState.ObjectWrite?.[0]??null,outputOwner:n.outputState.ObjectWrite?n.outputState.ObjectWrite[1]:null,idOperation:n.idOperation.$kind}));return{bcs:e,digest:t.transactionDigest,version:2,status:"Success"===t.status.$kind?{success:!0,error:null}:{success:!1,error:t.status.Failed.error.$kind},gasUsed:t.gasUsed,transactionDigest:t.transactionDigest,gasObject:null===t.gasObjectIndex?null:n[t.gasObjectIndex]??null,eventsDigest:t.eventsDigest,dependencies:t.dependencies,lamportVersion:t.lamportVersion,changedObjects:n,unchangedSharedObjects:t.unchangedSharedObjects.map(([e,t])=>({kind:t.$kind,objectId:e,version:"ReadOnlyRoot"===t.$kind?t.ReadOnlyRoot[0]:t[t.$kind],digest:"ReadOnlyRoot"===t.$kind?t.ReadOnlyRoot[1]:null})),auxiliaryDataDigest:t.auxDataDigest}}({bytes:e,effects:t.V2});default:throw new Error(`Unknown transaction effects version: ${t.$kind}`)}}var Fu,Uu=e=>{throw TypeError(e)},Lu=(e,t,n)=>t.has(e)||Uu("Cannot "+n),qu=(e,t,n)=>(Lu(e,t,"read from private field"),n?n.call(e):t.get(e));class $u extends ju{constructor({jsonRpcClient:e,mvr:t}){super({network:e.network,base:e,mvr:t}),((e,t,n)=>{t.has(e)?Uu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n)})(this,Fu),((e,t,n,r)=>{Lu(e,t,"write to private field"),r?r.call(e,n):t.set(e,n)})(this,Fu,e)}async getObjects(e){const t=fr(e.objectIds,50),n=[];for(const r of t){const t=await qu(this,Fu).multiGetObjects({ids:r,options:{showOwner:!0,showType:!0,showBcs:!0},signal:e.signal});for(const[e,i]of t.entries())i.error?n.push(Ru.fromResponse(i.error,r[e])):n.push(Vu(i.data))}return{objects:n}}async getOwnedObjects(e){const t=await qu(this,Fu).getOwnedObjects({owner:e.address,limit:e.limit,cursor:e.cursor,options:{showOwner:!0,showType:!0,showBcs:!0},filter:e.type?{StructType:e.type}:null,signal:e.signal});return{objects:t.data.map(e=>{if(e.error)throw Ru.fromResponse(e.error);return Vu(e.data)}),hasNextPage:t.hasNextPage,cursor:t.nextCursor??null}}async getCoins(e){const t=await qu(this,Fu).getCoins({owner:e.address,coinType:e.coinType,limit:e.limit,cursor:e.cursor,signal:e.signal});return{objects:t.data.map(t=>({id:t.coinObjectId,version:t.version,digest:t.digest,balance:t.balance,type:`0x2::coin::Coin<${t.coinType}>`,content:Promise.resolve(Qu.serialize({id:t.coinObjectId,balance:{value:t.balance}}).toBytes()),owner:{$kind:"ObjectOwner",ObjectOwner:e.address}})),hasNextPage:t.hasNextPage,cursor:t.nextCursor??null}}async getBalance(e){const t=await qu(this,Fu).getBalance({owner:e.address,coinType:e.coinType,signal:e.signal});return{balance:{coinType:t.coinType,balance:t.totalBalance}}}async getAllBalances(e){return{balances:(await qu(this,Fu).getAllBalances({owner:e.address,signal:e.signal})).map(e=>({coinType:e.coinType,balance:e.totalBalance})),hasNextPage:!1,cursor:null}}async getTransaction(e){return{transaction:Ku(await qu(this,Fu).getTransactionBlock({digest:e.digest,options:{showRawInput:!0,showObjectChanges:!0,showRawEffects:!0,showEvents:!0,showEffects:!0},signal:e.signal}))}}async executeTransaction(e){return{transaction:Ku(await qu(this,Fu).executeTransactionBlock({transactionBlock:e.transaction,signature:e.signatures,options:{showRawEffects:!0,showEvents:!0,showObjectChanges:!0,showRawInput:!0,showEffects:!0},signal:e.signal}))}}async dryRunTransaction(e){const t=os.from(e.transaction),n=await qu(this,Fu).dryRunTransactionBlock({transactionBlock:e.transaction,signal:e.signal}),{effects:r,objectTypes:i}=function({bytes:e,effects:t,objectChanges:n}){const r=[],i=[],o={};return n?.forEach(e=>{switch(e.type){case"published":r.push({id:e.packageId,inputState:"DoesNotExist",inputVersion:null,inputDigest:null,inputOwner:null,outputState:"PackageWrite",outputVersion:e.version,outputDigest:e.digest,outputOwner:null,idOperation:"Created"});break;case"transferred":r.push({id:e.objectId,inputState:"Exists",inputVersion:e.version,inputDigest:e.digest,inputOwner:{$kind:"AddressOwner",AddressOwner:e.sender},outputState:"ObjectWrite",outputVersion:e.version,outputDigest:e.digest,outputOwner:zu(e.recipient),idOperation:"None"}),o[e.objectId]=e.objectType;break;case"mutated":r.push({id:e.objectId,inputState:"Exists",inputVersion:e.previousVersion,inputDigest:null,inputOwner:zu(e.owner),outputState:"ObjectWrite",outputVersion:e.version,outputDigest:e.digest,outputOwner:zu(e.owner),idOperation:"None"}),o[e.objectId]=e.objectType;break;case"deleted":r.push({id:e.objectId,inputState:"Exists",inputVersion:e.version,inputDigest:t.deleted?.find(t=>t.objectId===e.objectId)?.digest??null,inputOwner:null,outputState:"DoesNotExist",outputVersion:null,outputDigest:null,outputOwner:null,idOperation:"Deleted"}),o[e.objectId]=e.objectType;break;case"wrapped":r.push({id:e.objectId,inputState:"Exists",inputVersion:e.version,inputDigest:null,inputOwner:{$kind:"AddressOwner",AddressOwner:e.sender},outputState:"ObjectWrite",outputVersion:e.version,outputDigest:t.wrapped?.find(t=>t.objectId===e.objectId)?.digest??null,outputOwner:{$kind:"ObjectOwner",ObjectOwner:e.sender},idOperation:"None"}),o[e.objectId]=e.objectType;break;case"created":r.push({id:e.objectId,inputState:"DoesNotExist",inputVersion:null,inputDigest:null,inputOwner:null,outputState:"ObjectWrite",outputVersion:e.version,outputDigest:e.digest,outputOwner:zu(e.owner),idOperation:"Created"}),o[e.objectId]=e.objectType}}),{objectTypes:o,effects:{bcs:e??null,digest:t.transactionDigest,version:2,status:"success"===t.status.status?{success:!0,error:null}:{success:!1,error:t.status.error},gasUsed:t.gasUsed,transactionDigest:t.transactionDigest,gasObject:{id:t.gasObject?.reference.objectId,inputState:"Exists",inputVersion:null,inputDigest:null,inputOwner:null,outputState:"ObjectWrite",outputVersion:t.gasObject.reference.version,outputDigest:t.gasObject.reference.digest,outputOwner:zu(t.gasObject.owner),idOperation:"None"},eventsDigest:t.eventsDigest??null,dependencies:t.dependencies??[],lamportVersion:t.gasObject.reference.version,changedObjects:r,unchangedSharedObjects:i,auxiliaryDataDigest:null}}}({effects:n.effects,objectChanges:n.objectChanges});return{transaction:{digest:await t.getDigest(),epoch:null,effects:r,objectTypes:Promise.resolve(i),signatures:[],transaction:Pu(e.transaction)}}}async getReferenceGasPrice(e){const t=await qu(this,Fu).getReferenceGasPrice({signal:e?.signal});return{referenceGasPrice:String(t)}}async getDynamicFields(e){const n=await qu(this,Fu).getDynamicFields({parentId:e.parentId,limit:e.limit,cursor:e.cursor});return{dynamicFields:n.data.map(e=>({id:e.objectId,type:e.objectType,name:{type:e.name.type,bcs:t(e.bcsName)}})),hasNextPage:n.hasNextPage,cursor:n.nextCursor}}async verifyZkLoginSignature(e){const t=await qu(this,Fu).verifyZkLoginSignature({bytes:e.bytes,signature:e.signature,intentScope:e.intentScope,author:e.author});return{success:t.success,errors:t.errors}}resolveNameServiceNames(e){return qu(this,Fu).resolveNameServiceNames(e)}resolveTransactionPlugin(){return pr(qu(this,Fu))}}function Vu(e){return{id:e.objectId,version:e.version,digest:e.digest,type:e.type,content:Promise.resolve("moveObject"===e.bcs?.dataType?t(e.bcs.bcsBytes):new Uint8Array),owner:zu(e.owner)}}function zu(e){if("Immutable"===e)return{$kind:"Immutable",Immutable:!0};if("ConsensusV2"in e)return{$kind:"ConsensusV2",ConsensusV2:{authenticator:{$kind:"SingleOwner",SingleOwner:e.ConsensusV2.authenticator.SingleOwner},startVersion:e.ConsensusV2.start_version}};if("AddressOwner"in e)return{$kind:"AddressOwner",AddressOwner:e.AddressOwner};if("ObjectOwner"in e)return{$kind:"ObjectOwner",ObjectOwner:e.ObjectOwner};if("Shared"in e)return{$kind:"Shared",Shared:{initialSharedVersion:e.Shared.initial_shared_version}};throw new Error(`Unknown owner type: ${JSON.stringify(e)}`)}function Ku(e){const n=ar.SenderSignedData.parse(t(e.rawTransaction))[0],r={};e.objectChanges?.forEach(e=>{"published"!==e.type&&(r[e.objectId]=e.objectType)});const i=ar.TransactionData.serialize(n.intentMessage.value).toBytes(),o=Fi.restore({version:2,sender:n.intentMessage.value.V1.sender,expiration:n.intentMessage.value.V1.expiration,gasData:n.intentMessage.value.V1.gasData,inputs:n.intentMessage.value.V1.kind.ProgrammableTransaction.inputs,commands:n.intentMessage.value.V1.kind.ProgrammableTransaction.commands});return{digest:e.digest,epoch:e.effects?.executedEpoch??null,effects:Bu(new Uint8Array(e.rawEffects)),objectTypes:Promise.resolve(r),transaction:{...o,bcs:i},signatures:n.txSignatures}}Fu=new WeakMap;const Wu=ar.struct("Balance",{value:ar.u64()}),Qu=ar.struct("Coin",{id:ar.Address,balance:Wu}),Gu={"-32700":"ParseError","-32701":"OversizedRequest","-32702":"OversizedResponse","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError","-32604":"ServerBusy","-32000":"CallExecutionFailed","-32001":"UnknownError","-32003":"SubscriptionClosed","-32004":"SubscriptionClosedWithError","-32005":"BatchesNotSupported","-32006":"TooManySubscriptions","-32050":"TransientError","-32002":"TransactionExecutionClientError"};class Hu extends Error{}class Ju extends Hu{constructor(e,t){super(e),this.code=t,this.type=Gu[t]??"ServerError"}}class Zu extends Hu{constructor(e,t,n){super(e),this.status=t,this.statusText=n}}var Yu,Xu,ec,tc,nc,rc,ic,oc,sc,ac=e=>{throw TypeError(e)},uc=(e,t,n)=>t.has(e)||ac("Cannot "+n),cc=(e,t,n)=>(uc(e,t,"read from private field"),n?n.call(e):t.get(e)),lc=(e,t,n)=>t.has(e)?ac("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),hc=(e,t,n,r)=>(uc(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),fc=(e,t,n)=>(uc(e,t,"access private method"),n);const dc={WebSocketConstructor:"undefined"!=typeof WebSocket?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class pc{constructor(e,t={}){if(lc(this,ic),lc(this,Yu,0),lc(this,Xu,0),lc(this,ec,null),lc(this,tc,null),lc(this,nc,new Set),lc(this,rc,new Map),this.endpoint=e,this.options={...dc,...t},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=function(e){const t=new URL(e);return t.protocol=t.protocol.replace("http","ws"),t.toString()}(this.endpoint))}async makeRequest(e,t,n){const r=await fc(this,ic,oc).call(this);return new Promise((i,o)=>{hc(this,Yu,cc(this,Yu)+1),cc(this,rc).set(cc(this,Yu),{resolve:i,reject:o,timeout:setTimeout(()=>{cc(this,rc).delete(cc(this,Yu)),o(new Error(`Request timeout: ${e}`))},this.options.callTimeout)}),n?.addEventListener("abort",()=>{cc(this,rc).delete(cc(this,Yu)),o(n.reason)}),r.send(JSON.stringify({jsonrpc:"2.0",id:cc(this,Yu),method:e,params:t}))}).then(({error:e,result:t})=>{if(e)throw new Ju(e.message,e.code);return t})}async subscribe(e){const t=new yc(e);return cc(this,nc).add(t),await t.subscribe(this),()=>t.unsubscribe(this)}}Yu=new WeakMap,Xu=new WeakMap,ec=new WeakMap,tc=new WeakMap,nc=new WeakMap,rc=new WeakMap,ic=new WeakSet,oc=function(){return cc(this,tc)||hc(this,tc,new Promise(e=>{cc(this,ec)?.close(),hc(this,ec,new this.options.WebSocketConstructor(this.endpoint)),cc(this,ec).addEventListener("open",()=>{hc(this,Xu,0),e(cc(this,ec))}),cc(this,ec).addEventListener("close",()=>{var e,t,n,r;(e=this,t=Xu,{set _(r){hc(e,t,r,n)},get _(){return cc(e,t,r)}})._++,cc(this,Xu)<=this.options.maxReconnects&&setTimeout(()=>{fc(this,ic,sc).call(this)},this.options.reconnectTimeout)}),cc(this,ec).addEventListener("message",({data:e})=>{let t;try{t=JSON.parse(e)}catch(t){return void console.error(new Error(`Failed to parse RPC message: ${e}`,{cause:t}))}if("id"in t&&null!=t.id&&cc(this,rc).has(t.id)){const{resolve:e,timeout:n}=cc(this,rc).get(t.id);clearTimeout(n),e(t)}else if("params"in t){const{params:e}=t;cc(this,nc).forEach(t=>{t.subscriptionId===e.subscription&&e.subscription===t.subscriptionId&&t.onMessage(e.result)})}})})),cc(this,tc)},sc=async function(){return cc(this,ec)?.close(),hc(this,tc,null),Promise.allSettled([...cc(this,nc)].map(e=>e.subscribe(this)))};class yc{constructor(e){this.subscriptionId=null,this.subscribed=!1,this.input=e}onMessage(e){this.subscribed&&this.input.onMessage(e)}async unsubscribe(e){const{subscriptionId:t}=this;return this.subscribed=!1,null!=t&&(this.subscriptionId=null,e.makeRequest(this.input.unsubscribe,[t]))}async subscribe(e){this.subscriptionId=null,this.subscribed=!0;const t=await e.makeRequest(this.input.method,this.input.params,this.input.signal);this.subscribed&&(this.subscriptionId=t)}}var mc,gc,bc,vc,wc,Ec=e=>{throw TypeError(e)},kc=(e,t,n)=>t.has(e)||Ec("Cannot "+n),Sc=(e,t,n)=>(kc(e,t,"read from private field"),n?n.call(e):t.get(e)),Tc=(e,t,n)=>t.has(e)?Ec("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),_c=(e,t,n,r)=>(kc(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class xc{constructor(e){Tc(this,vc),Tc(this,mc,0),Tc(this,gc),Tc(this,bc),_c(this,gc,e)}fetch(e,t){const n=Sc(this,gc).fetch??fetch;if(!n)throw new Error("The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.");return n(e,t)}async request(e){_c(this,mc,Sc(this,mc)+1);const t=await this.fetch(Sc(this,gc).rpc?.url??Sc(this,gc).url,{method:"POST",signal:e.signal,headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":eo,"Client-Target-Api-Version":"1.52.0","Client-Request-Method":e.method,...Sc(this,gc).rpc?.headers},body:JSON.stringify({jsonrpc:"2.0",id:Sc(this,mc),method:e.method,params:e.params})});if(!t.ok)throw new Zu(`Unexpected status code: ${t.status}`,t.status,t.statusText);const n=await t.json();if("error"in n&&null!=n.error)throw new Ju(n.error.message,n.error.code);return n.result}async subscribe(e){const t=await(n=this,r=vc,i=wc,kc(n,r,"access private method"),i).call(this).subscribe(e);var n,r,i;return e.signal&&(e.signal.throwIfAborted(),e.signal.addEventListener("abort",()=>{t()})),async()=>!!await t()}}mc=new WeakMap,gc=new WeakMap,bc=new WeakMap,vc=new WeakSet,wc=function(){if(!Sc(this,bc)){const e=Sc(this,gc).WebSocketConstructor??WebSocket;if(!e)throw new Error("The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.");_c(this,bc,new pc(Sc(this,gc).websocket?.url??Sc(this,gc).url,{WebSocketConstructor:e,...Sc(this,gc).websocket}))}return Sc(this,bc)};const Oc=Symbol.for("@mysten/SuiClient");class Ic extends Nu{constructor(e){super({network:e.network??"unknown"}),this.jsonRpc=this,this.transport=e.transport??new xc({url:e.url}),this.core=new $u({jsonRpcClient:this,mvr:e.mvr})}get[Oc](){return!0}async getRpcApiVersion({signal:e}={}){return(await this.transport.request({method:"rpc.discover",params:[],signal:e})).info.version}async getCoins({coinType:e,owner:t,cursor:n,limit:r,signal:i}){if(!t||!rt(at(t)))throw new Error("Invalid Sui address");return e&&ko(e)&&(e=(await this.core.mvr.resolveType({type:e})).type),await this.transport.request({method:"suix_getCoins",params:[t,e,n,r],signal:i})}async getAllCoins(e){if(!e.owner||!rt(at(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllCoins",params:[e.owner,e.cursor,e.limit],signal:e.signal})}async getBalance({owner:e,coinType:t,signal:n}){if(!e||!rt(at(e)))throw new Error("Invalid Sui address");return t&&ko(t)&&(t=(await this.core.mvr.resolveType({type:t})).type),await this.transport.request({method:"suix_getBalance",params:[e,t],signal:n})}async getAllBalances(e){if(!e.owner||!rt(at(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllBalances",params:[e.owner],signal:e.signal})}async getCoinMetadata({coinType:e,signal:t}){return e&&ko(e)&&(e=(await this.core.mvr.resolveType({type:e})).type),await this.transport.request({method:"suix_getCoinMetadata",params:[e],signal:t})}async getTotalSupply({coinType:e,signal:t}){return e&&ko(e)&&(e=(await this.core.mvr.resolveType({type:e})).type),await this.transport.request({method:"suix_getTotalSupply",params:[e],signal:t})}async call(e,t,{signal:n}={}){return await this.transport.request({method:e,params:t,signal:n})}async getMoveFunctionArgTypes({package:e,module:t,function:n,signal:r}){return e&&et(e)&&(e=(await this.core.mvr.resolvePackage({package:e})).package),await this.transport.request({method:"sui_getMoveFunctionArgTypes",params:[e,t,n],signal:r})}async getNormalizedMoveModulesByPackage({package:e,signal:t}){return e&&et(e)&&(e=(await this.core.mvr.resolvePackage({package:e})).package),await this.transport.request({method:"sui_getNormalizedMoveModulesByPackage",params:[e],signal:t})}async getNormalizedMoveModule({package:e,module:t,signal:n}){return e&&et(e)&&(e=(await this.core.mvr.resolvePackage({package:e})).package),await this.transport.request({method:"sui_getNormalizedMoveModule",params:[e,t],signal:n})}async getNormalizedMoveFunction({package:e,module:t,function:n,signal:r}){return e&&et(e)&&(e=(await this.core.mvr.resolvePackage({package:e})).package),await this.transport.request({method:"sui_getNormalizedMoveFunction",params:[e,t,n],signal:r})}async getNormalizedMoveStruct({package:e,module:t,struct:n,signal:r}){return e&&et(e)&&(e=(await this.core.mvr.resolvePackage({package:e})).package),await this.transport.request({method:"sui_getNormalizedMoveStruct",params:[e,t,n],signal:r})}async getOwnedObjects(e){if(!e.owner||!rt(at(e.owner)))throw new Error("Invalid Sui address");const t=e.filter?{...e.filter}:void 0;return t&&"MoveModule"in t&&et(t.MoveModule.package)?t.MoveModule={module:t.MoveModule.module,package:(await this.core.mvr.resolvePackage({package:t.MoveModule.package})).package}:t&&"StructType"in t&&ko(t.StructType)&&(t.StructType=(await this.core.mvr.resolveType({type:t.StructType})).type),await this.transport.request({method:"suix_getOwnedObjects",params:[e.owner,{filter:t,options:e.options},e.cursor,e.limit],signal:e.signal})}async getObject(e){if(!e.id||!it(ut(e.id)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"sui_getObject",params:[e.id,e.options],signal:e.signal})}async tryGetPastObject(e){return await this.transport.request({method:"sui_tryGetPastObject",params:[e.id,e.version,e.options],signal:e.signal})}async multiGetObjects(e){e.ids.forEach(e=>{if(!e||!it(ut(e)))throw new Error(`Invalid Sui Object id ${e}`)});if(e.ids.length!==new Set(e.ids).size)throw new Error(`Duplicate object ids in batch call ${e.ids}`);return await this.transport.request({method:"sui_multiGetObjects",params:[e.ids,e.options],signal:e.signal})}async queryTransactionBlocks({filter:e,options:t,cursor:n,limit:r,order:i,signal:o}){return e&&"MoveFunction"in e&&et(e.MoveFunction.package)&&(e={...e,MoveFunction:{package:(await this.core.mvr.resolvePackage({package:e.MoveFunction.package})).package}}),await this.transport.request({method:"suix_queryTransactionBlocks",params:[{filter:e,options:t},n,r,"descending"===(i||"descending")],signal:o})}async getTransactionBlock(e){if(!nt(e.digest))throw new Error("Invalid Transaction digest");return await this.transport.request({method:"sui_getTransactionBlock",params:[e.digest,e.options],signal:e.signal})}async multiGetTransactionBlocks(e){e.digests.forEach(e=>{if(!nt(e))throw new Error(`Invalid Transaction digest ${e}`)});if(e.digests.length!==new Set(e.digests).size)throw new Error(`Duplicate digests in batch call ${e.digests}`);return await this.transport.request({method:"sui_multiGetTransactionBlocks",params:[e.digests,e.options],signal:e.signal})}async executeTransactionBlock({transactionBlock:e,signature:t,options:n,requestType:r,signal:i}){const s=await this.transport.request({method:"sui_executeTransactionBlock",params:["string"==typeof e?e:o(e),Array.isArray(t)?t:[t],n],signal:i});if("WaitForLocalExecution"===r)try{await this.waitForTransaction({digest:s.digest})}catch(e){}return s}async signAndExecuteTransaction({transaction:e,signer:t,...n}){let r;e instanceof Uint8Array?r=e:(e.setSenderIfNotSet(t.toSuiAddress()),r=await e.build({client:this}));const{signature:i,bytes:o}=await t.signTransaction(r);return this.executeTransactionBlock({transactionBlock:o,signature:i,...n})}async getTotalTransactionBlocks({signal:e}={}){const t=await this.transport.request({method:"sui_getTotalTransactionBlocks",params:[],signal:e});return BigInt(t)}async getReferenceGasPrice({signal:e}={}){const t=await this.transport.request({method:"suix_getReferenceGasPrice",params:[],signal:e});return BigInt(t)}async getStakes(e){if(!e.owner||!rt(at(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getStakes",params:[e.owner],signal:e.signal})}async getStakesByIds(e){return e.stakedSuiIds.forEach(e=>{if(!e||!it(ut(e)))throw new Error(`Invalid Sui Stake id ${e}`)}),await this.transport.request({method:"suix_getStakesByIds",params:[e.stakedSuiIds],signal:e.signal})}async getLatestSuiSystemState({signal:e}={}){return await this.transport.request({method:"suix_getLatestSuiSystemState",params:[],signal:e})}async queryEvents({query:e,cursor:t,limit:n,order:r,signal:i}){return e&&"MoveEventType"in e&&ko(e.MoveEventType)&&(e={...e,MoveEventType:(await this.core.mvr.resolveType({type:e.MoveEventType})).type}),e&&"MoveEventModule"in e&&et(e.MoveEventModule.package)&&(e={...e,MoveEventModule:{module:e.MoveEventModule.module,package:(await this.core.mvr.resolvePackage({package:e.MoveEventModule.package})).package}}),"MoveModule"in e&&et(e.MoveModule.package)&&(e={...e,MoveModule:{module:e.MoveModule.module,package:(await this.core.mvr.resolvePackage({package:e.MoveModule.package})).package}}),await this.transport.request({method:"suix_queryEvents",params:[e,t,n,"descending"===(r||"descending")],signal:i})}async subscribeEvent(e){return this.transport.subscribe({method:"suix_subscribeEvent",unsubscribe:"suix_unsubscribeEvent",params:[e.filter],onMessage:e.onMessage,signal:e.signal})}async subscribeTransaction(e){return this.transport.subscribe({method:"suix_subscribeTransaction",unsubscribe:"suix_unsubscribeTransaction",params:[e.filter],onMessage:e.onMessage,signal:e.signal})}async devInspectTransactionBlock(e){let t;if(es(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),t=o(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if("string"==typeof e.transactionBlock)t=e.transactionBlock;else{if(!(e.transactionBlock instanceof Uint8Array))throw new Error("Unknown transaction block format.");t=o(e.transactionBlock)}return e.signal?.throwIfAborted(),await this.transport.request({method:"sui_devInspectTransactionBlock",params:[e.sender,t,e.gasPrice?.toString(),e.epoch],signal:e.signal})}async dryRunTransactionBlock(e){return await this.transport.request({method:"sui_dryRunTransactionBlock",params:["string"==typeof e.transactionBlock?e.transactionBlock:o(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!it(ut(e.parentId)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"suix_getDynamicFields",params:[e.parentId,e.cursor,e.limit],signal:e.signal})}async getDynamicFieldObject(e){return await this.transport.request({method:"suix_getDynamicFieldObject",params:[e.parentId,e.name],signal:e.signal})}async getLatestCheckpointSequenceNumber({signal:e}={}){const t=await this.transport.request({method:"sui_getLatestCheckpointSequenceNumber",params:[],signal:e});return String(t)}async getCheckpoint(e){return await this.transport.request({method:"sui_getCheckpoint",params:[e.id],signal:e.signal})}async getCheckpoints(e){return await this.transport.request({method:"sui_getCheckpoints",params:[e.cursor,e?.limit,e.descendingOrder],signal:e.signal})}async getCommitteeInfo(e){return await this.transport.request({method:"suix_getCommitteeInfo",params:[e?.epoch],signal:e?.signal})}async getNetworkMetrics({signal:e}={}){return await this.transport.request({method:"suix_getNetworkMetrics",params:[],signal:e})}async getAddressMetrics({signal:e}={}){return await this.transport.request({method:"suix_getLatestAddressMetrics",params:[],signal:e})}async getEpochMetrics(e){return await this.transport.request({method:"suix_getEpochMetrics",params:[e?.cursor,e?.limit,e?.descendingOrder],signal:e?.signal})}async getAllEpochAddressMetrics(e){return await this.transport.request({method:"suix_getAllEpochAddressMetrics",params:[e?.descendingOrder],signal:e?.signal})}async getEpochs(e){return await this.transport.request({method:"suix_getEpochs",params:[e?.cursor,e?.limit,e?.descendingOrder],signal:e?.signal})}async getMoveCallMetrics({signal:e}={}){return await this.transport.request({method:"suix_getMoveCallMetrics",params:[],signal:e})}async getCurrentEpoch({signal:e}={}){return await this.transport.request({method:"suix_getCurrentEpoch",params:[],signal:e})}async getValidatorsApy({signal:e}={}){return await this.transport.request({method:"suix_getValidatorsApy",params:[],signal:e})}async getChainIdentifier({signal:e}={}){const t=await this.getCheckpoint({id:"0",signal:e});return a(J(t.digest).slice(0,4))}async resolveNameServiceAddress(e){return await this.transport.request({method:"suix_resolveNameServiceAddress",params:[e.name],signal:e.signal})}async resolveNameServiceNames({format:e="dot",...t}){const{nextCursor:n,hasNextPage:r,data:i}=await this.transport.request({method:"suix_resolveNameServiceNames",params:[t.address,t.cursor,t.limit],signal:t.signal});return{hasNextPage:r,nextCursor:n,data:i.map(t=>function(e,t="at"){const n=e.toLowerCase();let r;if(n.includes("@")){if(!Je.test(n))throw new Error(`Invalid SuiNS name ${e}`);const[t,i]=n.split("@");r=[...t?t.split("."):[],i]}else{if(!Ze.test(n))throw new Error(`Invalid SuiNS name ${e}`);r=n.split(".").slice(0,-1)}return"dot"===t?`${r.join(".")}.sui`:`${r.slice(0,-1).join(".")}@${r[r.length-1]}`}(t,e))}}async getProtocolConfig(e){return await this.transport.request({method:"sui_getProtocolConfig",params:[e?.version],signal:e?.signal})}async verifyZkLoginSignature(e){return await this.transport.request({method:"sui_verifyZkLoginSignature",params:[e.bytes,e.signature,e.intentScope,e.author],signal:e.signal})}async waitForTransaction({signal:e,timeout:t=6e4,pollInterval:n=2e3,...r}){const i=AbortSignal.timeout(t),o=new Promise((e,t)=>{i.addEventListener("abort",()=>t(i.reason))});for(o.catch(()=>{});!i.aborted;){e?.throwIfAborted();try{return await this.getTransactionBlock(r)}catch(e){await Promise.race([new Promise(e=>setTimeout(e,n)),o])}}throw i.throwIfAborted(),new Error("Unexpected error while waiting for transaction block.")}experimental_asClientExtension(){return{name:"jsonRPC",register:()=>this}}}class Cc extends Error{}async function Mc({host:e,path:t,body:n,headers:r,method:i}){const o=new URL(t,e).toString(),s=await fetch(o,{method:i,body:n?JSON.stringify(n):void 0,headers:{"Content-Type":"application/json",...r||{}}});if(429===s.status)throw new Cc("Too many requests from this client have been sent to the faucet. Please retry later");try{return await s.json()}catch(e){throw new Error(`Encountered error when parsing response from faucet, error: ${e}, status ${s.status}, response ${s}`)}}function Ac(e){switch(e){case"testnet":return"https://faucet.testnet.sui.io";case"devnet":return"https://faucet.devnet.sui.io";case"localnet":return"http://127.0.0.1:9123";default:throw new Error(`Unknown network: ${e}`)}}var Nc=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},jc=(e,t,n)=>(Nc(e,t,"read from private field"),n?n.call(e):t.get(e)),Dc=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Rc=(e,t,n)=>(Nc(e,t,"access private method"),n),Pc=(e,t={})=>{const n=((e={})=>{const{accountIndex:t=0,isExternal:n=!1,addressIndex:r=0}=e;return`m/44'/784'/${t}'/${n?1:0}'/${r}'`})(t);return Cu.deriveKeypair(e,n)},Bc=e=>{if((e=>/^0x[0-9a-fA-F]+$|^[0-9a-fA-F]+$/.test(e))(e))return(e=>{if(!e)throw new Error("cannot parse empty string to Uint8Array");const t=e.replace("0x","").match(/.{1,2}/g)?.map(e=>parseInt(e,16));if(!t||0===t.length)throw new Error(`Unable to parse HEX: ${e}`);return Uint8Array.from(t)})(e);if((e=>/^[a-zA-Z0-9+/]+={0,2}$/g.test(e))(e))return Mu(e);throw new Error("The string is not a valid hex or base64 string.")},Fc=e=>{if(64===e.length)e=e.slice(0,32);else{if(33===e.length&&0===e[0])return e.slice(1);if(32===e.length)return e}throw new Error("invalid secret key")},Uc=class{constructor({mnemonics:e,secretKey:t}={}){this.mnemonics=e||"",this.secretKey=t||"",this.mnemonics||this.secretKey||(this.mnemonics=((e=24)=>pu(Au,12===e?128:256))(24)),this.currentKeyPair=this.secretKey?this.parseSecretKey(this.secretKey):Pc(this.mnemonics),this.currentAddress=this.currentKeyPair.getPublicKey().toSuiAddress()}parseSecretKey(e){if(e.startsWith(ru)){const{secretKey:t}=su(e);return Cu.fromSecretKey(Fc(t))}return Cu.fromSecretKey(Fc(Bc(e)))}getKeyPair(e){return e&&this.mnemonics?Pc(this.mnemonics,e):this.currentKeyPair}getAddress(e){return e&&this.mnemonics?Pc(this.mnemonics,e).getPublicKey().toSuiAddress():this.currentAddress}switchAccount(e){this.mnemonics&&(this.currentKeyPair=Pc(this.mnemonics,e),this.currentAddress=this.currentKeyPair.getPublicKey().toSuiAddress())}};function Lc(e,t,n){if(0===t.length)throw new Error("Transaction builder error: Empty array is not allowed");const r=(e=>"string"==typeof e&&it(e)?"object":"number"==typeof e||"bigint"==typeof e?"u64":"boolean"==typeof e?"bool":void 0)(t[0]);if("object"===(n=n||r)){const n=t.map(t=>"string"==typeof t&&it(t)?e.object(ut(t)):Vc(e,t));return e.makeMoveVec({elements:n})}if("string"!=typeof n||/^vector<(.+)>$/.test(n)||/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/.test(n)){const r=t.map(t=>Vc(e,t));return e.makeMoveVec({elements:r,type:n})}{const r=lr(n);return e.pure(un.vector(r).serialize(t))}}function qc(e,t){return t.map(t=>{if(t instanceof pe||de(t))return e.pure(t);if(function(e){return"object"==typeof e&&"vecType"in e&&"value"in e||!!Array.isArray(e)}(t)){return"vecType"in t?Lc(e,t.value,t.vecType):Lc(e,t)}return t})}function $c(e,t){return"string"==typeof t&&rt(t)?e.pure.address(at(t)):qc(e,[t])[0]}function Vc(e,t){if("string"==typeof t)return e.object(t);if("digest"in t&&"version"in t&&"objectId"in t)return e.objectRef(t);if("objectId"in t&&"initialSharedVersion"in t&&"mutable"in t)return e.sharedObjectRef(t);if("Object"in t){if("ImmOrOwnedObject"in t.Object)return e.object(an.ObjectRef(t.Object.ImmOrOwnedObject));if("SharedObject"in t.Object)return e.object(an.SharedObjectRef(t.Object.SharedObject));throw new Error("Invalid argument type")}if("function"==typeof t)return t;if("GasCoin"in t||"Input"in t||"Result"in t||"NestedResult"in t)return t;throw new Error("Invalid argument type")}function zc(e,t){return t.map(t=>"number"==typeof t||"bigint"==typeof t?t:qc(e,[t])[0])}var Kc=class{constructor(e){this.tx=void 0!==e?os.from(e):new os}get gas(){return this.tx.gas}get blockData(){return this.tx.blockData}address(e){return this.tx.pure.address(e)}get pure(){return this.tx.pure}object(e){return this.tx.object(e)}objectRef(e){return this.tx.objectRef(e)}sharedObjectRef(e){return this.tx.sharedObjectRef(e)}setSender(e){return this.tx.setSender(e)}setSenderIfNotSet(e){return this.tx.setSenderIfNotSet(e)}setExpiration(e){return this.tx.setExpiration(e)}setGasPrice(e){return this.tx.setGasPrice(e)}setGasBudget(e){return this.tx.setGasBudget(e)}setGasOwner(e){return this.tx.setGasOwner(e)}setGasPayment(e){return this.tx.setGasPayment(e)}serialize(){return this.tx.serialize()}toJSON(){return this.tx.toJSON()}sign(e){return this.tx.sign(e)}build(e={}){return this.tx.build(e)}getDigest(e={}){return this.tx.getDigest(e)}add(...e){return this.tx.add(...e)}publish({modules:e,dependencies:t}){return this.tx.publish({modules:e,dependencies:t})}upgrade(...e){return this.tx.upgrade(...e)}makeMoveVec(...e){return this.tx.makeMoveVec(...e)}transferObjects(e,t){return this.tx.transferObjects(e.map(e=>Vc(this.tx,e)),$c(this.tx,t))}splitCoins(e,t){const n=this.tx.splitCoins(Vc(this.tx,e),zc(this.tx,t));return t.map((e,t)=>n[t])}mergeCoins(e,t){const n=Vc(this.tx,e),r=t.map(e=>Vc(this.tx,e));return this.tx.mergeCoins(n,r)}moveCall(e,t=[],n=[]){if(null===e.match(/(?<package>[a-zA-Z0-9]+)::(?<module>[a-zA-Z0-9_]+)::(?<function>[a-zA-Z0-9_]+)/))throw new Error("Invalid target format. Expected `${string}::${string}::${string}`");const r=qc(this.tx,t);return this.tx.moveCall({target:e,arguments:r,typeArguments:n})}transferSuiToMany(e,t){if(e.length!==t.length)throw new Error("transferSuiToMany: recipients.length !== amounts.length");const n=this.tx.splitCoins(this.tx.gas,t.map(e=>"number"==typeof e||"bigint"==typeof e?e:qc(this.tx,[e])[0]));return e.map(e=>$c(this.tx,e)).forEach((e,t)=>{this.tx.transferObjects([n[t]],e)}),this}transferSui(e,t){return this.transferSuiToMany([e],[t])}takeAmountFromCoins(e,t){const n=e.map(e=>Vc(this.tx,e)),r=n[0];e.length>1&&this.tx.mergeCoins(r,n.slice(1));const[i]=this.tx.splitCoins(r,zc(this.tx,[t]));return[i,r]}splitSUIFromGas(e){return this.tx.splitCoins(this.tx.gas,zc(this.tx,e))}splitMultiCoins(e,t){const n=e.map(e=>Vc(this.tx,e)),r=n[0];e.length>1&&this.tx.mergeCoins(r,n.slice(1));return{splitedCoins:this.tx.splitCoins(r,zc(this.tx,t)),mergedCoin:r}}transferCoinToMany(e,t,n,r){if(n.length!==r.length)throw new Error("transferSuiToMany: recipients.length !== amounts.length");const i=e.map(e=>Vc(this.tx,e)),{splitedCoins:o,mergedCoin:s}=this.splitMultiCoins(i,r);return n.map(e=>$c(this.tx,e)).forEach((e,t)=>{this.tx.transferObjects([o[t]],e)}),this.tx.transferObjects([s],$c(this.tx,t)),this}transferCoin(e,t,n,r){return this.transferCoinToMany(e,t,[n],[r])}stakeSui(e,t){const[n]=this.tx.splitCoins(this.tx.gas,zc(this.tx,[e]));return this.tx.moveCall({target:"0x3::sui_system::request_add_stake",arguments:qc(this.tx,[this.tx.object(cr),n,$c(this.tx,t)])})}},Wc=class{constructor(e){this.objectId=e.objectId,this.version=e.version,this.digest=e.digest}isFullObject(){return!!this.version&&!!this.digest}asCallArg(){return this.version&&this.digest?{$kind:"Object",Object:{$kind:"ImmOrOwnedObject",ImmOrOwnedObject:{objectId:this.objectId,version:this.version,digest:this.digest}}}:this.objectId}updateFromTxResponse(e){const t=e.objectChanges;if(!t)throw new Error("Bad transaction response!");for(const e of t)if("mutated"===e.type&&e.objectId===this.objectId)return this.digest=e.digest,void(this.version=e.version);throw new Error("Could not find object in transaction response!")}},Qc=class{constructor(e){this.objectId=e.objectId,this.initialSharedVersion=e.initialSharedVersion}asCallArg(e=!1){return this.initialSharedVersion?{$kind:"Object",Object:{$kind:"SharedObject",SharedObject:{objectId:this.objectId,initialSharedVersion:this.initialSharedVersion,mutable:e}}}:this.objectId}},Gc=e=>new Promise(t=>setTimeout(t,e)),Hc=class{constructor(e,t){if(0===e.length)throw new Error("fullNodeUrls must not be empty");this.fullNodes=e,this.clients=e.map(e=>new Ic({url:e})),this.currentFullNode=e[0],this.currentClient=this.clients[0],this.network=t}switchToNextClient(){const e=this.clients.indexOf(this.currentClient);this.currentClient=this.clients[(e+1)%this.clients.length],this.currentFullNode=this.fullNodes[(e+1)%this.clients.length]}async sendTx(e,t){const n={showEvents:!0,showEffects:!0,showObjectChanges:!0,showBalanceChanges:!0};for(const r in this.clients)try{return await this.clients[r].executeTransactionBlock({transactionBlock:e,signature:t,options:n})}catch(e){console.warn(`Failed to send transaction with fullnode ${this.fullNodes[r]}: ${e}`),await Gc(2e3)}throw new Error("Failed to send transaction with all fullnodes")}async waitForTransaction({digest:e,timeout:t=6e4,pollInterval:n=2e3}){for(const r in this.clients)try{const i={showEvents:!0,showEffects:!0,showObjectChanges:!0,showBalanceChanges:!0};return await this.clients[r].waitForTransaction({digest:e,timeout:t,pollInterval:n,options:i})}catch(e){console.warn(`Failed to wait for transaction with fullnode ${this.fullNodes[r]}: ${e}`),await Gc(2e3)}throw new Error("Failed to wait for transaction with all fullnodes")}async getObjects(e,t){const n=t??{showContent:!0,showDisplay:!0,showType:!0,showOwner:!0};for(const t in this.clients)try{const r=(await this.clients[t].multiGetObjects({ids:e,options:n})).map(e=>e.data).filter(e=>null!=e);return r}catch(e){await Gc(2e3),console.warn(`Failed to get objects with fullnode ${this.fullNodes[t]}: ${e}`)}throw new Error("Failed to get objects with all fullnodes")}async getObject(e){return(await this.getObjects([e]))[0]}async getDynamicFieldObject(e,t){for(const n in this.clients)try{return await this.clients[n].getDynamicFieldObject({parentId:e,name:t})}catch(e){await Gc(2e3),console.warn(`Failed to get DynamicFieldObject with fullnode ${this.fullNodes[n]}: ${e}`)}throw new Error("Failed to get DynamicFieldObject with all fullnodes")}async getDynamicFields(e,t,n){for(const r in this.clients)try{return await this.clients[r].getDynamicFields({parentId:e,cursor:t,limit:n})}catch(e){await Gc(2e3),console.warn(`Failed to get DynamicFields with fullnode ${this.fullNodes[r]}: ${e}`)}throw new Error("Failed to get DynamicFields with all fullnodes")}async getTxDetails(e){for(const t in this.clients)try{const n={showEvents:!0,showEffects:!0,showObjectChanges:!0,showBalanceChanges:!0};return await this.clients[t].getTransactionBlock({digest:e,options:n})}catch(e){await Gc(2e3),console.warn(`Failed to get TransactionBlocks with fullnode ${this.fullNodes[t]}: ${e}`)}throw new Error("Failed to get TransactionBlocks with all fullnodes")}async getOwnedObjects(e,t,n){for(const r in this.clients)try{return await this.clients[r].getOwnedObjects({owner:e,cursor:t,limit:n})}catch(e){await Gc(2e3),console.warn(`Failed to get OwnedObjects with fullnode ${this.fullNodes[r]}: ${e}`)}throw new Error("Failed to get OwnedObjects with all fullnodes")}async getNormalizedMoveModulesByPackage(e){for(const t in this.clients)try{return await this.clients[t].getNormalizedMoveModulesByPackage({package:e})}catch(e){await Gc(2e3),console.warn(`Failed to get NormalizedMoveModules with fullnode ${this.fullNodes[t]}: ${e}`)}throw new Error("Failed to get NormalizedMoveModules with all fullnodes")}async updateObjects(e){const t=e.map(e=>e.objectId),n=await this.getObjects(t);for(const t of n){const n=e.find(e=>e.objectId===t?.objectId);n instanceof Qc?t.owner&&"object"==typeof t.owner&&"Shared"in t.owner?n.initialSharedVersion=t.owner.Shared.initial_shared_version:n.initialSharedVersion=void 0:n instanceof Wc&&(n.version=t?.version,n.digest=t?.digest)}}async selectCoins(e,t,n="0x2::SUI::SUI"){const r=[];let i=0,o=!0,s=null;for(;o&&i<t;){const a=await this.currentClient.getCoins({owner:e,coinType:n,cursor:s});a.data.sort((e,t)=>parseInt(t.balance)-parseInt(e.balance));for(const e of a.data)if(r.push({objectId:e.coinObjectId,digest:e.digest,version:e.version,balance:e.balance}),i+=parseInt(e.balance),i>=t)break;s=a.nextCursor,o=a.hasNextPage}if(!r.length)throw new Error("No valid coins found for the transaction.");return r}async selectObjects(e,t){const n=[];let r=!0,i=null;for(;r;){const o=await this.currentClient.getOwnedObjects({owner:e,cursor:i});for(const e of o.data){const r=await this.getObject(e.data.objectId);r.type===t&&n.push(r)}i=o.nextCursor,r=o.hasNextPage}if(!n.length)throw new Error("Not own this object found for the transaction.");return n}async requestFaucet(e,t){await async function(e){const t=await Mc({host:e.host,path:"/v2/gas",body:{FixedAmountRequest:{recipient:e.recipient}},headers:e.headers,method:"POST"});if("Success"!==t.status)throw new Error(`Faucet request failed: ${t.status.Failure.internal}`);return t}({host:Ac(t),recipient:e})}},Jc="0x89302436f6624fb9274ab0126737a599cb154b008687d71f6d8ce9e0d22ec3ce",Zc="0x12a319387cf2d465d4f4181523d089a368e542fccbdd878e70a4db0df007bb78",Yc=(e="testnet")=>{switch(e){case"localnet":{const e=encodeURIComponent("http://127.0.0.1:9000");return{fullNode:"http://127.0.0.1:9000",graphql:"http://127.0.0.1:9125",network:"localnet",txExplorer:`https://custom.suiscan.xyz/custom/tx/:txHash?network=${e}`,accountExplorer:`https://custom.suiscan.xyz/custom/account/:address?network=${e}`,explorer:`https://custom.suiscan.xyz/custom?network=${e}`,indexerUrl:"http://127.0.0.1:3001",channelUrl:"http://127.0.0.1:8080"}}case"devnet":return{fullNode:"https://fullnode.devnet.sui.io:443",network:"devnet",txExplorer:"https://suiscan.xyz/devnet/tx/:txHash",accountExplorer:"https://suiscan.xyz/devnet/address/:address",explorer:"https://suiscan.xyz/devnet",indexerUrl:"http://127.0.0.1:3001",channelUrl:"http://127.0.0.1:8080"};case"testnet":default:return{fullNode:"https://fullnode.testnet.sui.io:443",graphql:"https://sui-testnet.mystenlabs.com/graphql",network:"testnet",txExplorer:"https://suiscan.xyz/testnet/tx/:txHash",accountExplorer:"https://suiscan.xyz/testnet/address/:address",explorer:"https://suiscan.xyz/testnet",indexerUrl:"http://127.0.0.1:3001",channelUrl:"http://127.0.0.1:8080",frameworkPackageId:Jc,dappHubId:Zc};case"mainnet":return{fullNode:"https://fullnode.mainnet.sui.io:443",graphql:"https://sui-mainnet.mystenlabs.com/graphql",network:"mainnet",txExplorer:"https://suiscan.xyz/mainnet/tx/:txHash",accountExplorer:"https://suiscan.xyz/mainnet/address/:address",explorer:"https://suiscan.xyz/mainnet",indexerUrl:"http://127.0.0.1:3001",channelUrl:"http://127.0.0.1:8080",frameworkPackageId:"0x6cb54e8bbcf59cc976584330689073500af755b12d85bf4f56d7eea9f232b8aa",dappHubId:"0x1d1c9e533ff14da8a20fd04b751b5345695fdeb16931d02fa3f7ca5650d90724"}}},Xc=class{constructor({packageId:e,metadata:t}={}){this.packageId=e||"",this.metadata=t||void 0}getFuncByModuleName(e){Object.values(this.metadata).forEach(e=>{const t=e;console.log(`moudle name: ${t.name}`),Object.entries(t.exposedFunctions).forEach(([e,t])=>{console.log(`\tfunc name: ${e}`),Object.values(t.parameters).forEach(e=>{})})})}getAllFunc(){Object.values(this.metadata).forEach(e=>{const t=e;console.log(`moudle name: ${t.name}`),Object.entries(t.exposedFunctions).forEach(([e,t])=>{console.log(`\tfunc name: ${e}`),console.log(`\t\t${t.parameters.length}`),Object.values(t.parameters).forEach(e=>{console.log(`\t\targs: ${e}`)})})})}getAllModule(){Object.values(this.metadata).forEach((e,t)=>{const n=e;console.log(`${t}. ${n.name}`)})}},el={address:un.bytes(32).transform({input:e=>s(e),output:e=>a(e)}),u8:un.u8(),u16:un.u16(),u32:un.u32(),u64:un.u64(),u128:un.u128(),u256:un.u256(),bool:un.bool(),"0x1::ascii::String":un.string(),"0x1::string::String":un.string(),"0x1::option::Option<address>":un.option(un.bytes(32).transform({input:e=>s(e),output:e=>a(e)})),"0x1::option::Option<u8>":un.option(un.u8()),"0x1::option::Option<u16>":un.option(un.u16()),"0x1::option::Option<u32>":un.option(un.u32()),"0x1::option::Option<u64>":un.option(un.u64()),"0x1::option::Option<u128>":un.option(un.u128()),"0x1::option::Option<u256>":un.option(un.u256()),"0x1::option::Option<bool>":un.option(un.bool()),"0x1::option::Option<vector<address>>":un.option(un.vector(un.bytes(32).transform({input:e=>s(e),output:e=>a(e)}))),"0x1::option::Option<vector<u8>>":un.option(un.vector(un.u8())),"0x1::option::Option<vector<u16>>":un.option(un.vector(un.u16())),"0x1::option::Option<vector<u32>>":un.option(un.vector(un.u32())),"0x1::option::Option<vector<u64>>":un.option(un.vector(un.u64())),"0x1::option::Option<vector<u128>>":un.option(un.vector(un.u128())),"0x1::option::Option<vector<u256>>":un.option(un.vector(un.u256())),"0x1::option::Option<vector<bool>>":un.option(un.vector(un.bool())),"vector<address>":un.vector(un.bytes(32).transform({input:e=>s(e),output:e=>a(e)})),"vector<u8>":un.vector(un.u8()),"vector<u16>":un.vector(un.u16()),"vector<u32>":un.vector(un.u32()),"vector<u64>":un.vector(un.u64()),"vector<u128>":un.vector(un.u128()),"vector<u256>":un.vector(un.u256()),"vector<bool>":un.vector(un.bool()),"vector<vector<address>>":un.vector(un.vector(un.bytes(32).transform({input:e=>s(e),output:e=>a(e)}))),"vector<vector<u8>>":un.vector(un.vector(un.u8())),"vector<vector<u16>>":un.vector(un.vector(un.u16())),"vector<vector<u32>>":un.vector(un.vector(un.u32())),"vector<vector<u64>>":un.vector(un.vector(un.u64())),"vector<vector<u128>>":un.vector(un.vector(un.u128())),"vector<vector<u256>>":un.vector(un.vector(un.u256())),"vector<vector<bool>>":un.vector(un.vector(un.bool())),"0x2::coin::Coin<T>":un.struct("Coin",{id:un.fixedArray(32,un.u8()).transform({input:e=>s(e),output:e=>a(Uint8Array.from(e))}),balance:un.struct("Balance",{value:un.u64()})}),"0x2::balance::Balance<T>":un.struct("Balance",{value:un.u64()})};function tl(e){return/^(0x)?[0-9a-fA-F]{64}$/.test(e)?e.startsWith("0x")?e:"0x"+e:null}function nl(e){return"0x"+(e.startsWith("0x")?e:"0x"+e).slice(2).replace(/^0+/,"")}function rl(e){return`${e.replace(/^0x/,"").padStart(64,"0")}::dapp_key::DappKey`}var il=class extends Error{constructor(e){const t=e?.effects?.status?.error||"",n=t?t.match(/function_name: Some\("([^"]+)"\)/):null,r=t?t.match(/address: ([a-fA-F0-9]+)/):null,i=n?n[1]:"unknown",o=r?"0x"+r[1]:"unknown",s=e.error?e.error:"UNKNOWN_ERROR";super([`\n- Function: ${i}`,`- Module Address: ${o}`,`- Error Message: ${s}`].join("\n")),this.errorType="ContractDataParsingError",this.functionName=i,this.moduleAddress=o,this.errorMessage=s}},ol=class{constructor(e){this.baseUrl=e.baseUrl.replace(/\/$/,""),this.timeout=e.timeout||3e4,this.activeSubscriptions=new Map}updateConfig(e){void 0!==e.baseUrl&&(this.baseUrl=e.baseUrl.replace(/\/$/,"")),void 0!==e.timeout&&(this.timeout=e.timeout)}async subscribeTable(e,t){const n=this.generateSubscriptionKey(e);if(this.activeSubscriptions.has(n))throw new Error(`Already subscribed to: ${n}`);const r=new AbortController;this.activeSubscriptions.set(n,r);const i=`${this.baseUrl}/subscribe_table`;try{const n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(e),signal:r.signal});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);if(!n.body)throw new Error("Response body is null");this.handleSSEStream(n.body,t,r.signal).catch(e=>{"AbortError"!==e.name&&t?.onError?.(e)}),t?.onOpen?.()}catch(e){throw this.activeSubscriptions.delete(n),"AbortError"!==e.name&&t?.onError?.(e),e}return()=>{r.abort(),this.activeSubscriptions.delete(n),t?.onClose?.()}}async getTable(e){const t=`${this.baseUrl}/get_table`;try{const n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)});if(!n.ok){const e=await n.text();throw new Error(`HTTP error! status: ${n.status}, message: ${e}`)}return await n.json()}catch(e){throw new Error(`Failed to get table data: ${e.message}`)}}async submit(e){const t=`${this.baseUrl}/submit`;try{const n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const e=await n.text();throw new Error(`HTTP error! status: ${n.status}, message: ${e}`)}return await n.json()}catch(e){throw new Error(`Failed to submit transaction: ${e.message}`)}}async getNonce(e){const t=`${this.baseUrl}/nonce`;try{const n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)});if(!n.ok){const e=await n.text();throw new Error(`HTTP error! status: ${n.status}, message: ${e}`)}return await n.json()}catch(e){throw new Error(`Failed to get nonce: ${e.message}`)}}unsubscribe(e){const t=this.generateSubscriptionKey(e),n=this.activeSubscriptions.get(t);n&&(n.abort(),this.activeSubscriptions.delete(t))}unsubscribeAll(){for(const e of this.activeSubscriptions.values())e.abort();this.activeSubscriptions.clear()}getActiveSubscriptionCount(){return this.activeSubscriptions.size}async handleSSEStream(e,t,n){const r=e.getReader(),i=new TextDecoder;let o="";try{for(;!n?.aborted;){const e=await r.read();if(e.done){t?.onClose?.();break}if(e.value){o+=i.decode(e.value,{stream:!0});const n=o.split("\n");o=n.pop()||"";for(const e of n)if(e.startsWith("data:"))try{const n=e.substring(5).trim();if(n){const e=JSON.parse(n),r={dapp_key:e.data_key.dapp_key,account:e.data_key.account,table:e.data_key.table,key:e.data_key.key,value:e.value};t?.onMessage?.(r)}}catch(e){t?.onError?.(new Error(`Failed to parse SSE data: ${e.message}`))}}}}catch(e){"AbortError"!==e.name&&t?.onError?.(e)}finally{r.releaseLock()}}generateSubscriptionKey(e){const t=[e.dapp_key];return e.account&&t.push(e.account),e.table&&t.push(e.table),e.key&&t.push(JSON.stringify(e.key)),t.join(":")}};function sl(e){return void 0===e}function al(e,t){return t.meta=e,t}function ul(e,t){return al(e,async({tx:e,params:n,typeArguments:r,isRaw:i})=>await t(e,n,r,i))}function cl(e,t){return al(e,async({tx:e,params:n,typeArguments:r,isRaw:i,onSuccess:o,onError:s})=>await t(e,n,r,i,o,s))}var ll,hl,fl,dl,pl,yl,ml,gl,bl,vl,wl=class{constructor({mnemonics:e,secretKey:t,networkType:n,fullnodeUrls:r,packageId:i,dappKey:o,metadata:u,channelUrl:c,frameworkPackageId:l,dappStorageId:h,dappHubId:f}={}){Dc(this,bl),Dc(this,ll,{}),Dc(this,hl,{}),Dc(this,fl,el),Dc(this,dl,async(e,t,n,r,i,o,s)=>!0===i?t.moveCall({target:`${this.contractFactory.packageId}::${e.moduleName}::${e.funcName}`,arguments:n,typeArguments:r}):(t.moveCall({target:`${this.contractFactory.packageId}::${e.moduleName}::${e.funcName}`,arguments:n,typeArguments:r}),await this.signAndSendTxn({tx:t,onSuccess:o,onError:s}))),Dc(this,pl,async(e,t,n,r,i)=>!0===i?t.moveCall({target:`${this.contractFactory.packageId}::${e.moduleName}::${e.funcName}`,arguments:n,typeArguments:r}):(t.moveCall({target:`${this.contractFactory.packageId}::${e.moduleName}::${e.funcName}`,arguments:n,typeArguments:r}),await this.inspectTxn(t))),Dc(this,yl,e=>"object"==typeof e&&"Vector"in e?1+jc(this,yl).call(this,e.Vector):0),Dc(this,ml,e=>{let t=!1;const n={};return Object.entries(e.objectType.fields).forEach(([e,r])=>{const i=r.name,o=r.type;switch(typeof o){case"object":for(const[e,r]of Object.entries(o))switch(e){case"Struct":const e=r;if("0x1"===e.address&&"ascii"===e.module&&"String"===e.name)return void(n[i]=un.string());if("0x2"===e.address&&"object"===e.module&&"UID"===e.name)return void(n[i]=un.fixedArray(32,un.u8()).transform({input:e=>s(e),output:e=>a(Uint8Array.from(e))}));if("0x2"===e.address&&"object"===e.module&&"ID"===e.name)return void(n[i]=un.fixedArray(32,un.u8()).transform({input:e=>s(e),output:e=>a(Uint8Array.from(e))}));if("0x2"===e.address&&"bag"===e.module&&"Bag"===e.name)return void(n[i]=un.fixedArray(32,un.u8()).transform({input:e=>s(e),output:e=>a(Uint8Array.from(e))}));if("0x1"===e.address&&"option"===e.module&&"Option"===e.name)switch(e.typeArguments[0]){case"U8":return void(n[i]=un.option(un.u8()));case"U16":return void(n[i]=un.option(un.u16()));case"U32":return void(n[i]=un.option(un.u32()));case"U64":return void(n[i]=un.option(un.u64()));case"U128":return void(n[i]=un.option(un.u128()));case"U256":return void(n[i]=un.option(un.u256()));case"Bool":return void(n[i]=un.option(un.bool()));case"Address":return void(n[i]=un.option(un.bytes(32).transform({input:e=>s(e),output:e=>a(e)})))}else{if(void 0!==this.object[`${e.address}::${e.module}::${e.name}`])return void(n[i]=this.object[`${e.address}::${e.module}::${e.name}`]);t=!0}return;case"Vector":if("string"==typeof r)switch(r){case"U8":return void(n[i]=un.vector(un.u8()));case"U16":return void(n[i]=un.vector(un.u16()));case"U32":return void(n[i]=un.vector(un.u32()));case"U64":return void(n[i]=un.vector(un.u64()));case"U128":return void(n[i]=un.vector(un.u128()));case"U256":return void(n[i]=un.vector(un.u256()));case"Bool":return void(n[i]=un.vector(un.bool()));case"Address":return void(n[i]=un.vector(un.bytes(32).transform({input:e=>s(e),output:e=>a(e)})))}if("object"==typeof r){const e=jc(this,yl).call(this,r);let o=r;for(let t=0;t<e;t++)o=o.Vector;if("object"==typeof o&&null!==o&&"Struct"in o){const r=o.Struct,s=`${r.address}::${r.module}::${r.name}`;let a=jc(this,fl)[s];if(!a)return void(t=!0);let u=a;for(let t=0;t<=e;t++)u=un.vector(u);return void(n[i]=u)}if("string"==typeof o){let t;switch(o){case"U8":t=un.u8();break;case"U16":t=un.u16();break;case"U32":t=un.u32();break;case"U64":t=un.u64();break;case"U128":t=un.u128();break;case"U256":t=un.u256();break;case"Bool":t=un.bool();break;case"Address":t=un.bytes(32).transform({input:e=>s(e),output:e=>a(e)});break;default:return}for(let n=0;n<=e;n++)t=un.vector(t);return void(n[i]=t)}}return;case"TypeParameter":return void(n[i]=un.u128());default:throw new Error("Unsupported type")}return;case"string":switch(o){case"U8":return void(n[i]=un.u8());case"U16":return void(n[i]=un.u16());case"U32":return void(n[i]=un.u32());case"U64":return void(n[i]=un.u64());case"U128":return void(n[i]=un.u128());case"U256":return void(n[i]=un.u256());case"Bool":return void(n[i]=un.bool());case"Address":return void(n[i]=un.bytes(32).transform({input:e=>s(e),output:e=>a(e)}));default:return}default:throw new Error("Unsupported type")}}),{bcs:un.struct(e.objectName,n),loopFlag:t}}),Dc(this,gl,e=>{let t=!1;const n={};return Object.entries(e.objectType.variants).forEach(([e,r])=>{r.length>0?Object.entries(r).forEach(([e,r])=>{const i=r.type,o=r.name;switch(typeof i){case"object":for(const[e,r]of Object.entries(i))switch(e){case"Struct":const e=r;if("0x1"===e.address&&"ascii"===e.module&&"String"===e.name)return void(n[o]=un.string());if("0x2"===e.address&&"object"===e.module&&"UID"===e.name)return void(n[o]=un.fixedArray(32,un.u8()).transform({input:e=>s(e),output:e=>a(Uint8Array.from(e))}));if("0x2"===e.address&&"object"===e.module&&"ID"===e.name)return void(n[o]=un.fixedArray(32,un.u8()).transform({input:e=>s(e),output:e=>a(Uint8Array.from(e))}));if("0x2"===e.address&&"bag"===e.module&&"Bag"===e.name)return void(n[o]=un.fixedArray(32,un.u8()).transform({input:e=>s(e),output:e=>a(Uint8Array.from(e))}));if("0x1"===e.address&&"option"===e.module&&"Option"===e.name)switch(e.typeArguments[0]){case"U8":return void(n[o]=un.option(un.u8()));case"U16":return void(n[o]=un.option(un.u16()));case"U32":return void(n[o]=un.option(un.u32()));case"U64":return void(n[o]=un.option(un.u64()));case"U128":return void(n[o]=un.option(un.u128()));case"U256":return void(n[o]=un.option(un.u256()));case"Bool":return void(n[o]=un.option(un.bool()));case"Address":return void(n[o]=un.option(un.bytes(32).transform({input:e=>s(e),output:e=>a(e)})))}else{if(void 0!==this.object[`${e.address}::${e.module}::${e.name}`])return void(n[o]=this.object[`${e.address}::${e.module}::${e.name}`]);t=!0}return;case"Vector":if("string"==typeof r)switch(r){case"U8":return void(n[o]=un.vector(un.u8()));case"U16":return void(n[o]=un.vector(un.u16()));case"U32":return void(n[o]=un.vector(un.u32()));case"U64":return void(n[o]=un.vector(un.u64()));case"U128":return void(n[o]=un.vector(un.u128()));case"U256":return void(n[o]=un.vector(un.u256()));case"Bool":return void(n[o]=un.vector(un.bool()));case"Address":return void(n[o]=un.vector(un.bytes(32).transform({input:e=>s(e),output:e=>a(e)})))}case"TypeParameter":return void(n[o]=un.u128());default:throw new Error("Unsupported type")}return;case"string":switch(i){case"U8":return void(n[o]=un.u8());case"U16":return void(n[o]=un.u16());case"U32":return void(n[o]=un.u32());case"U64":return void(n[o]=un.u64());case"U128":return void(n[o]=un.u128());case"U256":return void(n[o]=un.u256());case"Bool":return void(n[o]=un.bool());case"Address":return void(n[o]=un.bytes(32).transform({input:e=>s(e),output:e=>a(e)}));default:return}default:throw new Error("Unsupported type")}}):n[e]=null}),{bcs:un.enum(e.objectName,n),loopFlag:t}});const d=Yc(n=n??"mainnet");this.accountManager=new Uc({mnemonics:e,secretKey:t}),r=r||[d.fullNode],this.suiInteractor=new Hc(r,n),this.dubheChannelClient=new ol({baseUrl:c||d.channelUrl}),this.packageId=i?nl(i):void 0,this.dappKey=o;const p=d.frameworkPackageId;if(this.frameworkPackageId=l?nl(l):p?nl(p):void 0,this.dappStorageId=h,this.dappHubId=f,void 0!==u){this.metadata=u;const e=5;let t=0,n=!0;for(;!0===n&&t<=e;){let e=!1;Object.values(u).forEach(t=>{const n=t,r=n.name,i=r;i.endsWith("_genesis")&&(this.projectName=i.replace("_genesis",""));const o=`${this.packageId}::${r}`;n.enums&&Object.entries(n.enums).forEach(([t,n])=>{const r=`${o}::${t}`,i={objectId:r,objectName:t,objectType:n};let s=jc(this,gl).call(this,i);!0===s.loopFlag&&(e=s.loopFlag),void 0===jc(this,fl)[r]&&(jc(this,fl)[r]=s.bcs,jc(this,fl)[`vector<${r}>`]=un.vector(s.bcs),jc(this,fl)[`vector<vector<${r}>>`]=un.vector(un.vector(s.bcs)),jc(this,fl)[`0x1::option::Option<${r}>`]=un.option(s.bcs))}),Object.entries(n.structs).forEach(([t,n])=>{const r=`${o}::${t}`,i={objectId:r,objectName:t,objectType:n};let s=jc(this,ml).call(this,i);!0===s.loopFlag&&(e=s.loopFlag),jc(this,fl)[r]=s.bcs,jc(this,fl)[`vector<${r}>`]=un.vector(s.bcs),jc(this,fl)[`0x1::option::Option<${r}>`]=un.option(s.bcs)}),Object.entries(n.exposedFunctions).forEach(([e,t])=>{const n=t;n.moduleName=r,n.funcName=e,sl(jc(this,ll)[r])&&(jc(this,ll)[r]={}),sl(jc(this,ll)[r][e])&&(jc(this,ll)[r][e]=ul(n,(e,t,r,i)=>jc(this,pl).call(this,n,e,t,r,i))),sl(jc(this,hl)[r])&&(jc(this,hl)[r]={}),sl(jc(this,hl)[r][e])&&(jc(this,hl)[r][e]=cl(n,(e,t,r,i,o,s)=>jc(this,dl).call(this,n,e,t,r,i,o,s)))})}),n=e,t++}}this.contractFactory=new Xc({packageId:this.packageId,metadata:u})}get query(){return jc(this,ll)}get tx(){return jc(this,hl)}get object(){return jc(this,fl)}view(e){let t=[];if("success"===e.effects.status.status){const n=e.results[0].returnValues;for(const e of n){let n=e[0],r=e[1];const i=Uint8Array.from(n),o=r.match(/^.*::storage_value::StorageValue<(.+)>$/);if(o){const e=o[1];if(jc(this,fl)[e]){const n=un.struct("StorageValue",{contents:un.vector(un.struct("Entry",{value:jc(this,fl)[e]}))});t.push(n.parse(i));continue}}const s=r.match(/^.*::storage_map::StorageMap<(.+)>$/);if(s){const e=s[1],[n,r]=e.split(",").map(e=>e.trim());if(jc(this,fl)[n]&&jc(this,fl)[r]){const e=un.struct("StorageMap",{contents:un.vector(un.struct("Entry",{key:jc(this,fl)[n],value:jc(this,fl)[r]}))});t.push(e.parse(i));continue}}const a=r.match(/^.*::storage_double_map::StorageDoubleMap<(.+)>$/);if(a){const e=a[1],[n,r,o]=e.split(",").map(e=>e.trim());if(jc(this,fl)[n]&&jc(this,fl)[r]&&jc(this,fl)[o]){const e=un.struct("StorageDoubleMap",{contents:un.vector(un.struct("Entry",{key1:jc(this,fl)[n],key2:jc(this,fl)[r],value:jc(this,fl)[o]}))});t.push(e.parse(i));continue}}if(jc(this,fl)[r]){t.push(jc(this,fl)[r].parse(i));continue}const u=r.match(/^([^<]+)<(.+)>$/);if(u){const[e,n,r]=u,o=`${n}<T>`;if(jc(this,fl)[o]){t.push(jc(this,fl)[o].parse(i));continue}}throw console.log("\n[41m[37m ERROR [0m [31mUnsupported Type[0m"),console.log("[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m"),console.log(`[95m•[0m Type: [33m"${r}"[0m`),u&&console.log(`[95m•[0m Generic Base Type: [33m"${u[1]}<T>"[0m`),console.log("[95m\n✨ Available Types:[0m"),Object.keys(jc(this,fl)).forEach(e=>{console.log(` [36m◆[0m ${e}`)}),console.log("\n[34m💡 How to Add Custom Type:[0m"),console.log(" You can add custom type by extending the #object map in your code:"),console.log(` [32mdubhe.object["${r}"] = bcs.struct("YourTypeName", {\n field1: bcs.string(),\n field2: bcs.u64(),\n // ... other fields\n });[0m`),console.log("[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m\n"),new Error(`Unsupported type: ${r}`)}return t}throw new il(e)}async state({tx:e,schema:t,params:n,customModuleName:r}){if(!this.metadata)throw new Error("Metadata is not loaded");const i=`${r??this.projectName}_schema`,o=`get_${t}`;let s;try{if(s=await this.query[i][o]({tx:e,params:n}),"success"!==s.effects.status.status)return}catch{return}return this.view(s)}async parseState({schema:e,objectId:t,storageType:n,params:r,customModuleName:i}){const o=new os,s=o.object(t),a=n.match(/^StorageValue<(.+)>$/),u=n.match(/^StorageMap<(.+),\s*(.+)>$/),c=n.match(/^StorageDoubleMap<(.+),\s*(.+),\s*(.+)>$/);let l=[s];if(a)r.length>0&&console.warn("StorageValue does not require additional parameters. Extra parameters will be ignored.");else if(u){if(1!==r.length)throw new Error("StorageMap requires exactly one key parameter");const e=u[1].trim();l.push(Rc(this,bl,vl).call(this,o,e,r[0]))}else{if(!c)throw new Error(`Invalid storage type: ${n}. Must be StorageValue<V>, StorageMap<K,V>, or StorageDoubleMap<K1,K2,V>`);{if(2!==r.length)throw new Error("StorageDoubleMap requires exactly two key parameters");const e=c[1].trim(),t=c[2].trim();l.push(Rc(this,bl,vl).call(this,o,e,r[0])),l.push(Rc(this,bl,vl).call(this,o,t,r[1]))}}return this.state({tx:o,schema:e,params:l,customModuleName:i})}getSigner(e){return this.accountManager.getKeyPair(e)}switchAccount(e){this.accountManager.switchAccount(e)}getAddress(e){return this.accountManager.getAddress(e)}currentAddress(){return this.accountManager.currentAddress}getPackageId(){return this.contractFactory.packageId}getDappKey(){return this.dappKey}getMetadata(){return this.contractFactory.metadata}getNetwork(){return this.suiInteractor.network}getNetworkConfig(){return Yc(this.getNetwork())}getTxExplorerUrl(e){return this.getNetworkConfig().txExplorer.replace(":txHash",e)}getAccountExplorerUrl(e){return this.getNetworkConfig().accountExplorer.replace(":address",e)}getExplorerUrl(){return this.getNetworkConfig().explorer}updateConfig(e){void 0===e.secretKey&&void 0===e.mnemonics||(this.accountManager=new Uc({mnemonics:e.mnemonics,secretKey:e.secretKey}));const t=void 0!==e.networkType&&e.networkType!==this.suiInteractor.network,n=void 0!==e.fullnodeUrls;if(t||n){const t=e.networkType??this.suiInteractor.network,n=Yc(t),r=e.fullnodeUrls||[n.fullNode];this.suiInteractor=new Hc(r,t)}void 0!==e.channelUrl&&this.dubheChannelClient.updateConfig({baseUrl:e.channelUrl});const r=void 0!==e.packageId&&e.packageId!==this.packageId,i=void 0!==e.metadata&&e.metadata!==this.metadata;if(void 0!==e.dappKey&&(this.dappKey=e.dappKey),(r||i)&&(void 0!==e.packageId&&(this.packageId=nl(e.packageId)),void 0!==e.metadata)){this.metadata=e.metadata,Object.keys(jc(this,ll)).forEach(e=>delete jc(this,ll)[e]),Object.keys(jc(this,hl)).forEach(e=>delete jc(this,hl)[e]),Object.keys(jc(this,fl)).forEach(e=>delete jc(this,fl)[e]),Object.assign(jc(this,fl),el);const t=5;let n=0,r=!0;for(;!0===r&&n<=t;){let e=!1;Object.values(this.metadata).forEach(t=>{const n=t,r=n.name,i=r;i.endsWith("_genesis")&&(this.projectName=i.replace("_genesis",""));const o=`${this.packageId}::${r}`;n.enums&&Object.entries(n.enums).forEach(([t,n])=>{const r=`${o}::${t}`,i={objectId:r,objectName:t,objectType:n};let s=jc(this,gl).call(this,i);!0===s.loopFlag&&(e=s.loopFlag),void 0===jc(this,fl)[r]&&(jc(this,fl)[r]=s.bcs,jc(this,fl)[`vector<${r}>`]=un.vector(s.bcs),jc(this,fl)[`vector<vector<${r}>>`]=un.vector(un.vector(s.bcs)),jc(this,fl)[`0x1::option::Option<${r}>`]=un.option(s.bcs))}),Object.entries(n.structs).forEach(([t,n])=>{const r=`${o}::${t}`,i={objectId:r,objectName:t,objectType:n};let s=jc(this,ml).call(this,i);!0===s.loopFlag&&(e=s.loopFlag),jc(this,fl)[r]=s.bcs,jc(this,fl)[`vector<${r}>`]=un.vector(s.bcs),jc(this,fl)[`0x1::option::Option<${r}>`]=un.option(s.bcs)}),Object.entries(n.exposedFunctions).forEach(([e,t])=>{const n=t;n.moduleName=r,n.funcName=e,sl(jc(this,ll)[r])&&(jc(this,ll)[r]={}),sl(jc(this,ll)[r][e])&&(jc(this,ll)[r][e]=ul(n,(e,t,r,i)=>jc(this,pl).call(this,n,e,t,r,i))),sl(jc(this,hl)[r])&&(jc(this,hl)[r]={}),sl(jc(this,hl)[r][e])&&(jc(this,hl)[r][e]=cl(n,(e,t,r,i,o,s)=>jc(this,dl).call(this,n,e,t,r,i,o,s)))})}),r=e,n++}this.contractFactory=new Xc({packageId:this.packageId,metadata:this.metadata})}}async requestFaucet(e,t,n){return void 0===e&&(e=this.accountManager.getAddress(n)),void 0===t&&(t=this.getNetwork()),this.suiInteractor.requestFaucet(e,t)}async getBalance(e,t){const n=this.accountManager.getAddress(t);return this.suiInteractor.currentClient.getBalance({owner:n,coinType:e})}async balanceOf(e,t,n){void 0===e&&(e=this.accountManager.getAddress(n));const r=e;return this.suiInteractor.currentClient.getBalance({owner:r,coinType:t})}client(){return this.suiInteractor.currentClient}async getObject(e){return this.suiInteractor.getObject(e)}async getObjects(e){return this.suiInteractor.getObjects(e)}async signTxn(e,t){(e instanceof Kc||e instanceof os)&&e.setSender(this.getAddress(t));const n=e instanceof Kc?e.tx:e,r=n instanceof os?await n.build({client:this.client()}):n,i=this.getSigner(t);return await i.signTransaction(r)}async signAndSendTxn({tx:e,derivePathParams:t,onSuccess:n,onError:r}){try{const{bytes:i,signature:o}=await this.signTxn(e,t),s=await this.sendTx(i,o);return"success"===s.effects?.status.status?n&&await n(s):r&&await r(new Error(`Transaction failed: ${s.effects?.status.error}`)),s}catch(e){throw r&&await r(e),e}}async sendTx(e,t){return this.suiInteractor.sendTx(e,t)}async waitForTransaction(e){return this.suiInteractor.waitForTransaction({digest:e})}async submitToChannel({tx:e,nonce:t,chainType:n}){const r={chain:n||"sui",sender:this.getAddress(),nonce:t,ptb:e.getData(),signature:"base64_encoded_signature_placeholder"};return this.dubheChannelClient.submit(r)}async queryChannelTable({packageId:e,account:t,table:n,key:r}){e=e||this.packageId,(t=t||this.getAddress())&&t.startsWith("0x")&&(t=t.slice(2));const i={dapp_key:rl(e??""),account:t,table:n,key:r};return this.dubheChannelClient.getTable(i)}async subscribeChannelTable({packageId:e,account:t,table:n,key:r}={},i){void 0!==t&&t.startsWith("0x")&&(t=t.slice(2));const o={dapp_key:this.dappKey};return void 0!==t&&(o.account=t),void 0!==n&&(o.table=n),void 0!==r&&(o.key=r),this.dubheChannelClient.subscribeTable(o,i)}async latestNonce({account:e}={}){const t={sender:e=e||this.getAddress()};return(await this.dubheChannelClient.getNonce(t)).nonce}async transferSui(e,t,n){const r=new Kc;return r.transferSui(e,t),this.signAndSendTxn({tx:r,derivePathParams:n})}async transferSuiToMany(e,t,n){const r=new Kc;return r.transferSuiToMany(e,t),this.signAndSendTxn({tx:r,derivePathParams:n})}async transferCoinToMany(e,t,n,r){const i=new Kc,o=this.accountManager.getAddress(r),s=t.reduce((e,t)=>e+t,0),a=await this.suiInteractor.selectCoins(o,s,n);return i.transferCoinToMany(a.map(e=>e.objectId),o,e,t),this.signAndSendTxn({tx:i,derivePathParams:r})}async transferCoin(e,t,n,r){return this.transferCoinToMany([e],[t],n,r)}async transferObjects(e,t,n){const r=new Kc;return r.transferObjects(e,t),this.signAndSendTxn({tx:r,derivePathParams:n})}async moveCall(e){const{target:t,arguments:n=[],typeArguments:r=[],derivePathParams:i}=e,o=new Kc;return o.moveCall(t,n,r),this.signAndSendTxn({tx:o,derivePathParams:i})}async selectCoinsWithAmount(e,t,n){n=n||this.accountManager.currentAddress;return(await this.suiInteractor.selectCoins(n,e,t)).map(e=>e.objectId)}async selectObjectsWithType(e,t){t=t||this.accountManager.currentAddress;return(await this.suiInteractor.selectObjects(t,e)).map(e=>e.objectId)}async stakeSui(e,t,n){const r=new Kc;return r.stakeSui(e,t),this.signAndSendTxn({tx:r,derivePathParams:n})}async inspectTxn(e,t){const n=e instanceof Kc?e.tx:e;return this.suiInteractor.currentClient.devInspectTransactionBlock({transactionBlock:n,sender:this.getAddress(t)})}async getOwnedObjects(e,t,n){const r=await this.suiInteractor.getOwnedObjects(e,t,n),i=[];for(const e of r.data){const t=await this.getObject(e.data.objectId);t.type.split("::")[0]===this.contractFactory.packageId&&i.push(t)}return i}async entity_key_from_object(e){const t=tl(e);return null!==t?e=t:void 0}async entity_key_from_bytes(t){const n=e(t),r=Array.from(n),i=Uint8Array.from(r);return"0x"+un.bytes(32).transform({input:e=>s(e),output:e=>a(e)}).parse(i)}async entity_key_from_address_with_seed(e,t){const n=tl(e);if(null!==n){e=n;const r=Buffer.from(e.slice(2),"hex"),i=Buffer.concat([r,Buffer.from(t,"utf-8")]);return this.entity_key_from_bytes(i)}}async entity_key_from_address_with_u256(e,t){const n=tl(e);if(null!==n){e=n;const r=Buffer.from(e.slice(2),"hex"),i=un.u256().serialize(t).toBytes();return this.entity_key_from_bytes(Buffer.concat([r,i]))}}async entity_key_from_u256(e){return"0x"+e.toString(16).padStart(64,"0")}async initUserStorage({dappHubId:e,dappStorageId:t,derivePathParams:n,onSuccess:r,onError:i}){const o=t??this.dappStorageId;if(!o)throw new Error("dappStorageId is required for initUserStorage. Pass it directly or set it in the Dubhe constructor.");const s=this.packageId;if(!s)throw new Error("packageId is required for initUserStorage.");const a=new os;return a.moveCall({target:`${s}::user_storage_init::init_user_storage`,arguments:[a.object(e),a.object(o)]}),this.signAndSendTxn({tx:a,derivePathParams:n,onSuccess:r,onError:i})}async activateSession({userStorageId:e,sessionWallet:t,durationMs:n,dappHubId:r,clockObjectId:i,derivePathParams:o,onSuccess:s,onError:a}){const u=this.frameworkPackageId;if(!u)throw new Error('frameworkPackageId is required for activateSession. Set it in the Dubhe constructor ({ frameworkPackageId: "0x..." }).');const c=this.dappKey;if(!c)throw new Error('dappKey is required for activateSession. Set it in the Dubhe constructor ({ packageId: "0x..." }).');const l=r??this.dappHubId;if(!l)throw new Error('dappHubId is required for activateSession. Pass it directly or set it in the Dubhe constructor ({ dappHubId: "0x..." }).');const h=i??"0x0000000000000000000000000000000000000000000000000000000000000006",f=new os;return f.moveCall({target:`${u}::dapp_system::activate_session`,typeArguments:[c],arguments:[f.object(l),f.object(e),f.pure.address(t),f.pure.u64(n),f.object(h)]}),this.signAndSendTxn({tx:f,derivePathParams:o,onSuccess:s,onError:a})}async deactivateSession({userStorageId:e,dappHubId:t,derivePathParams:n,onSuccess:r,onError:i}){const o=this.frameworkPackageId;if(!o)throw new Error('frameworkPackageId is required for deactivateSession. Set it in the Dubhe constructor ({ frameworkPackageId: "0x..." }).');const s=this.dappKey;if(!s)throw new Error('dappKey is required for deactivateSession. Set it in the Dubhe constructor ({ packageId: "0x..." }).');const a=t??this.dappHubId;if(!a)throw new Error('dappHubId is required for deactivateSession. Pass it directly or set it in the Dubhe constructor ({ dappHubId: "0x..." }).');const u=new os;return u.moveCall({target:`${o}::dapp_system::deactivate_session`,typeArguments:[s],arguments:[u.object(a),u.object(e)]}),this.signAndSendTxn({tx:u,derivePathParams:n,onSuccess:r,onError:i})}async getUserStorageId(e){const t=this.packageId,n=this.frameworkPackageId;if(!t||!n)return null;const r=e.startsWith("0x")?e:`0x${e}`,i=`${n}::dapp_service::UserStorage`;let o=null,s=!0;for(;s;){const e=await this.suiInteractor.currentClient.queryTransactionBlocks({filter:{MoveFunction:{package:t,module:"user_storage_init",function:"init_user_storage"}},options:{showObjectChanges:!0},...null!=o?{cursor:o}:{},limit:50});for(const t of e.data){if(!t.objectChanges)continue;const e=t.objectChanges.find(e=>"created"===e.type&&"string"==typeof e.objectType&&e.objectType===i&&e.sender===r);if(e?.objectId)return e.objectId}s=e.hasNextPage,o=e.nextCursor??null}return null}async getUserStorageFields(e){const t=await this.suiInteractor.getObject(e),n=t?.content?.fields??{},r=BigInt(n.write_count??0),i=BigInt(n.settled_count??0),o=BigInt(n.write_bytes??0),s=BigInt(n.settled_bytes??0);return{objectId:e,dapp_key:n.dapp_key??"",canonical_owner:n.canonical_owner??"",session_key:n.session_key??"",session_expires_at:BigInt(n.session_expires_at??0),write_count:r,settled_count:i,write_bytes:o,settled_bytes:s,unsettled_count:r-i,unsettled_bytes:o-s}}async getDappHubFields(e){const t=await this.suiInteractor.getObject(e),n=t?.content?.fields??{},r=n.fee_config?.fields??n.fee_config??{},i=n.admin_config?.fields??n.admin_config??{};return{objectId:e,version:Number(n.version??0),framework_admin:i.admin??n.framework_admin??"",treasury:r.treasury??n.treasury??"",pending_treasury:r.pending_treasury??n.pending_treasury??""}}async getDappStorageFields(e){const t=await this.suiInteractor.getObject(e),n=t?.content?.fields??{};return{objectId:e,dapp_key:n.dapp_key??"",name:n.name??"",description:n.description??"",website_url:n.website_url??"",admin:n.admin??"",version:Number(n.version??0),paused:Boolean(n.paused),free_credit:BigInt(n.free_credit??0),free_credit_expires_at:BigInt(n.free_credit_expires_at??0),credit_pool:BigInt(n.credit_pool??0),min_credit_to_unsuspend:BigInt(n.min_credit_to_unsuspend??0),suspended:Boolean(n.suspended),total_settled:BigInt(n.total_settled??0),base_fee_per_write:BigInt(n.base_fee_per_write??0),bytes_fee_per_byte:BigInt(n.bytes_fee_per_byte??0),settlement_mode:Number(n.settlement_mode??0),write_fee_dapp_share_bps:Number(n.write_fee_dapp_share_bps??0)}}buildSettleWritesTx(e,{dappHubId:t,dappStorageId:n,userStorageId:r}){const i=this.frameworkPackageId;if(!i)throw new Error('frameworkPackageId is required for buildSettleWritesTx. Set it in the Dubhe constructor ({ frameworkPackageId: "0x..." }).');const o=n??this.dappStorageId;if(!o)throw new Error("dappStorageId is required for buildSettleWritesTx. Pass it directly or set it in the Dubhe constructor.");const s=this.dappKey;if(!s)throw new Error('dappKey is required for buildSettleWritesTx. Set it in the Dubhe constructor ({ packageId: "0x..." }).');e.moveCall({target:`${i}::dapp_system::settle_writes`,typeArguments:[s],arguments:[e.object(t),e.object(o),e.object(r)]})}async settleWrites({dappHubId:e,dappStorageId:t,userStorageId:n,derivePathParams:r,onSuccess:i,onError:o}){const s=new os;return this.buildSettleWritesTx(s,{dappHubId:e,dappStorageId:t,userStorageId:n}),this.signAndSendTxn({tx:s,derivePathParams:r,onSuccess:i,onError:o})}async rechargeCredit({dappHubId:e,dappStorageId:t,coinObjectId:n,coinType:r="0x2::sui::SUI",derivePathParams:i,onSuccess:o,onError:s}){const a=this.frameworkPackageId;if(!a)throw new Error('frameworkPackageId is required for rechargeCredit. Set it in the Dubhe constructor ({ frameworkPackageId: "0x..." }).');const u=t??this.dappStorageId;if(!u)throw new Error("dappStorageId is required for rechargeCredit. Pass it directly or set it in the Dubhe constructor.");const c=this.dappKey;if(!c)throw new Error('dappKey is required for rechargeCredit. Set it in the Dubhe constructor ({ packageId: "0x..." }).');const l=new os;return l.moveCall({target:`${a}::dapp_system::recharge_credit`,typeArguments:[c,r],arguments:[l.object(e),l.object(u),l.object(n)]}),this.signAndSendTxn({tx:l,derivePathParams:i,onSuccess:o,onError:s})}buildSettleWritesUserPaysTx(e,{dappHubId:t,dappStorageId:n,userStorageId:r,maxPaymentMist:i=50000000n,coinType:o="0x2::sui::SUI"}){const s=this.frameworkPackageId;if(!s)throw new Error('frameworkPackageId is required for buildSettleWritesUserPaysTx. Set it in the Dubhe constructor ({ frameworkPackageId: "0x..." }).');const a=n??this.dappStorageId;if(!a)throw new Error("dappStorageId is required for buildSettleWritesUserPaysTx. Pass it directly or set it in the Dubhe constructor.");const u=this.dappKey;if(!u)throw new Error('dappKey is required for buildSettleWritesUserPaysTx. Set it in the Dubhe constructor ({ packageId: "0x..." }).');const[c]=e.splitCoins(e.gas,[e.pure.u64(i)]),l=e.moveCall({target:`${s}::dapp_system::settle_writes_user_pays`,typeArguments:[u,o],arguments:[e.object(t),e.object(a),e.object(r),c]});e.mergeCoins(e.gas,[l])}async settleWritesUserPays({dappHubId:e,dappStorageId:t,userStorageId:n,coinObjectId:r,coinType:i="0x2::sui::SUI",derivePathParams:o,onSuccess:s,onError:a}){const u=this.frameworkPackageId;if(!u)throw new Error('frameworkPackageId is required for settleWritesUserPays. Set it in the Dubhe constructor ({ frameworkPackageId: "0x..." }).');const c=t??this.dappStorageId;if(!c)throw new Error("dappStorageId is required for settleWritesUserPays. Pass it directly or set it in the Dubhe constructor.");const l=this.dappKey;if(!l)throw new Error('dappKey is required for settleWritesUserPays. Set it in the Dubhe constructor ({ packageId: "0x..." }).');const h=new os;return h.moveCall({target:`${u}::dapp_system::settle_writes_user_pays`,typeArguments:[l,i],arguments:[h.object(e),h.object(c),h.object(n),h.object(r)]}),this.signAndSendTxn({tx:h,derivePathParams:o,onSuccess:s,onError:a})}async queryWritesSettledEvents(e=30,t){const n=this.frameworkPackageId;if(!n)return[];try{return((await this.suiInteractor.currentClient.queryEvents({query:{MoveEventType:`${n}::dubhe_events::WritesSettled`},cursor:t,limit:Math.min(e,50),order:"descending"})).data??[]).map(e=>{const t=e.parsedJson??{};return{txDigest:e.id?.txDigest??"",eventSeq:e.id?.eventSeq??"",timestampMs:Number(e.timestampMs??0),dappKey:t.dapp_key??"",account:t.account??"",writes:Number(t.writes??0),bytes:String(t.bytes??"0"),freeCost:String(t.free_cost??"0"),paidCost:String(t.paid_cost??"0")}})}catch{return[]}}async queryMarketplaceFeeSettledEvents(e=30,t){const n=this.frameworkPackageId;if(!n)return[];try{return((await this.suiInteractor.currentClient.queryEvents({query:{MoveEventType:`${n}::dubhe_events::MarketplaceFeeSettled`},cursor:t,limit:Math.min(e,50),order:"descending"})).data??[]).map(e=>{const t=e.parsedJson??{};return{txDigest:e.id?.txDigest??"",eventSeq:e.id?.eventSeq??"",timestampMs:Number(e.timestampMs??0),dappKey:t.dapp_key??"",listingId:t.listing_id??"",coinType:t.coin_type??"",totalFee:String(t.total_fee??"0"),treasuryAmount:String(t.treasury_amount??"0"),dappAmount:String(t.dapp_amount??"0")}})}catch{return[]}}async getDappRevenueBalance(e,t="0x2::sui::SUI"){const n=this.suiInteractor.currentClient,r=t.split("::").slice(-2).join("::");try{let t;do{const i=await n.getDynamicFields({parentId:e,cursor:t,limit:50});for(const t of i.data){const i=t.name?.type??"";if(i.includes("DappRevenueKey")&&i.includes(r)){const r=await n.getDynamicFieldObject({parentId:e,name:t.name}),i=r?.data?.content?.fields??{};return BigInt(i?.value?.fields?.value??i?.value??0)}}if(t=i.nextCursor,!i.hasNextPage)break}while(t)}catch{}return 0n}async withdrawDappRevenue({dappHubId:e,dappStorageId:t,coinType:n="0x2::sui::SUI",derivePathParams:r,onSuccess:i,onError:o}){const s=this.frameworkPackageId;if(!s)throw new Error('frameworkPackageId is required for withdrawDappRevenue. Set it in the Dubhe constructor ({ frameworkPackageId: "0x..." }).');const a=t??this.dappStorageId;if(!a)throw new Error("dappStorageId is required for withdrawDappRevenue. Pass it directly or set it in the Dubhe constructor.");const u=this.dappKey;if(!u)throw new Error('dappKey is required for withdrawDappRevenue. Set it in the Dubhe constructor ({ packageId: "0x..." }).');const c=new os;return c.moveCall({target:`${s}::dapp_system::withdraw_dapp_revenue`,typeArguments:[u,n],arguments:[c.object(e),c.object(a)]}),this.signAndSendTxn({tx:c,derivePathParams:r,onSuccess:i,onError:o})}async getSettlementHealth({userStorageId:e,dappStorageId:t}){const n=(await this.getUserStorageFields(e)).unsettled_count,r=Number(100n*n/2000n),i={unsettledCount:n,writeLimit:2000n,utilizationPct:r,isAtRisk:r>=80,isBlocked:r>=100};if(t){const e=await this.getDappStorageFields(t),n=e.credit_pool,r=e.base_fee_per_write,o=r>0n?n/r:BigInt(Number.MAX_SAFE_INTEGER);i.creditPool=n,i.baseFeePerWrite=r,i.estimatedWritesAffordable=o,i.creditAtRisk=o<500n}return i}static getDefaultConfig(e){return Yc(e)}};ll=new WeakMap,hl=new WeakMap,fl=new WeakMap,dl=new WeakMap,pl=new WeakMap,yl=new WeakMap,ml=new WeakMap,gl=new WeakMap,bl=new WeakSet,vl=function(e,t,n){switch(t.toLowerCase()){case"u8":return e.pure.u8(n);case"u16":return e.pure.u16(n);case"u32":return e.pure.u32(n);case"u64":return e.pure.u64(n);case"u128":return e.pure.u128(n);case"u256":return e.pure.u256(n);case"bool":return e.pure.bool(n);case"address":return e.pure.address(n);default:if(t.includes("::"))return e.object(n);throw console.log("\n[41m[37m ERROR [0m [31mUnsupported Key Type[0m"),console.log("[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m"),console.log(`[95m•[0m Type: [33m"${t}"[0m`),console.log("[95m•[0m Supported Types:[0m"),console.log(" [36m◆[0m u8, u16, u32, u64, u128, u256"),console.log(" [36m◆[0m bool"),console.log(" [36m◆[0m address"),console.log(" [36m◆[0m object (format: package::module::type)"),console.log("[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m\n"),new Error(`Unsupported key type: ${t}`)}};var El=function(e,t){return El=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},El(e,t)};function kl(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}El(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var Sl=function(){return Sl=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Sl.apply(this,arguments)};function Tl(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function _l(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof n?e:new n(function(t){t(e)})}(e.value).then(s,a)}u((r=r.apply(e,t||[])).next())})}function xl(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}Object.create;function Ol(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}Object.create;"function"==typeof SuppressedError&&SuppressedError;var Il="Invariant Violation",Cl=Object.setPrototypeOf,Ml=void 0===Cl?function(e,t){return e.__proto__=t,e}:Cl,Al=function(e){function t(n){void 0===n&&(n=Il);var r=e.call(this,"number"==typeof n?Il+": "+n+" (see https://github.com/apollographql/invariant-packages)":n)||this;return r.framesToPop=1,r.name=Il,Ml(r,t.prototype),r}return kl(t,e),t}(Error);function Nl(e,t){if(!e)throw new Al(t)}var jl=["debug","log","warn","error","silent"],Dl=jl.indexOf("log");function Rl(e){return function(){if(jl.indexOf(e)>=Dl)return(console[e]||console.log).apply(console,arguments)}}!function(e){e.debug=Rl("debug"),e.log=Rl("log"),e.warn=Rl("warn"),e.error=Rl("error")}(Nl||(Nl={}));var Pl="3.14.0";function Bl(e){try{return e()}catch(e){}}const Fl=Bl(function(){return globalThis})||Bl(function(){return window})||Bl(function(){return self})||Bl(function(){return n.g})||Bl(function(){return Bl.constructor("return this")()});var Ul=new Map;function Ll(e){var t=Ul.get(e)||1;return Ul.set(e,t+1),"".concat(e,":").concat(t,":").concat(Math.random().toString(36).slice(2))}function ql(e,t){void 0===t&&(t=0);var n=Ll("stringifyForDisplay");return JSON.stringify(e,function(e,t){return void 0===t?n:t},t).split(JSON.stringify(n)).join("<undefined>")}function $l(e){return function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];if("number"==typeof t){var i=t;(t=Ql(i))||(t=Gl(i,n),n=[])}e.apply(void 0,[t].concat(n))}}var Vl=Object.assign(function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];e||Nl(e,Ql(t,n)||Gl(t,n))},{debug:$l(Nl.debug),log:$l(Nl.log),warn:$l(Nl.warn),error:$l(Nl.error)});function zl(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return new Al(Ql(e,t)||Gl(e,t))}var Kl=Symbol.for("ApolloErrorMessageHandler_"+Pl);function Wl(e){if("string"==typeof e)return e;try{return ql(e,2).slice(0,1e3)}catch(e){return"<non-serializable>"}}function Ql(e,t){if(void 0===t&&(t=[]),e)return Fl[Kl]&&Fl[Kl](e,t.map(Wl))}function Gl(e,t){if(void 0===t&&(t=[]),e)return"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({version:Pl,message:e,args:t.map(Wl)})))}globalThis.__DEV__;function Hl(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Jl(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Jl(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Jl(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Zl(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Yl(e,t,n){return t&&Zl(e.prototype,t),n&&Zl(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var Xl=function(){return"function"==typeof Symbol},eh=function(e){return Xl()&&Boolean(Symbol[e])},th=function(e){return eh(e)?Symbol[e]:"@@"+e};Xl()&&!eh("observable")&&(Symbol.observable=Symbol("observable"));var nh=th("iterator"),rh=th("observable"),ih=th("species");function oh(e,t){var n=e[t];if(null!=n){if("function"!=typeof n)throw new TypeError(n+" is not a function");return n}}function sh(e){var t=e.constructor;return void 0!==t&&null===(t=t[ih])&&(t=void 0),void 0!==t?t:mh}function ah(e){return e instanceof mh}function uh(e){uh.log?uh.log(e):setTimeout(function(){throw e})}function ch(e){Promise.resolve().then(function(){try{e()}catch(e){uh(e)}})}function lh(e){var t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{var n=oh(t,"unsubscribe");n&&n.call(t)}}catch(e){uh(e)}}function hh(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function fh(e,t,n){e._state="running";var r=e._observer;try{var i=oh(r,t);switch(t){case"next":i&&i.call(r,n);break;case"error":if(hh(e),!i)throw n;i.call(r,n);break;case"complete":hh(e),i&&i.call(r)}}catch(e){uh(e)}"closed"===e._state?lh(e):"running"===e._state&&(e._state="ready")}function dh(e,t,n){if("closed"!==e._state){if("buffering"!==e._state)return"ready"!==e._state?(e._state="buffering",e._queue=[{type:t,value:n}],void ch(function(){return function(e){var t=e._queue;if(t){e._queue=void 0,e._state="ready";for(var n=0;n<t.length&&(fh(e,t[n].type,t[n].value),"closed"!==e._state);++n);}}(e)})):void fh(e,t,n);e._queue.push({type:t,value:n})}}var ph=function(){function e(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";var n=new yh(this);try{this._cleanup=t.call(void 0,n)}catch(e){n.error(e)}"initializing"===this._state&&(this._state="ready")}return e.prototype.unsubscribe=function(){"closed"!==this._state&&(hh(this),lh(this))},Yl(e,[{key:"closed",get:function(){return"closed"===this._state}}]),e}(),yh=function(){function e(e){this._subscription=e}var t=e.prototype;return t.next=function(e){dh(this._subscription,"next",e)},t.error=function(e){dh(this._subscription,"error",e)},t.complete=function(){dh(this._subscription,"complete")},Yl(e,[{key:"closed",get:function(){return"closed"===this._subscription._state}}]),e}(),mh=function(){function e(t){if(!(this instanceof e))throw new TypeError("Observable cannot be called as a function");if("function"!=typeof t)throw new TypeError("Observable initializer must be a function");this._subscriber=t}var t=e.prototype;return t.subscribe=function(e){return"object"==typeof e&&null!==e||(e={next:e,error:arguments[1],complete:arguments[2]}),new ph(e,this._subscriber)},t.forEach=function(e){var t=this;return new Promise(function(n,r){if("function"==typeof e)var i=t.subscribe({next:function(t){try{e(t,o)}catch(e){r(e),i.unsubscribe()}},error:r,complete:n});else r(new TypeError(e+" is not a function"));function o(){i.unsubscribe(),n()}})},t.map=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(sh(this))(function(n){return t.subscribe({next:function(t){try{t=e(t)}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})})},t.filter=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(sh(this))(function(n){return t.subscribe({next:function(t){try{if(!e(t))return}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})})},t.reduce=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var n=sh(this),r=arguments.length>1,i=!1,o=arguments[1];return new n(function(n){return t.subscribe({next:function(t){var s=!i;if(i=!0,!s||r)try{o=e(o,t)}catch(e){return n.error(e)}else o=t},error:function(e){n.error(e)},complete:function(){if(!i&&!r)return n.error(new TypeError("Cannot reduce an empty sequence"));n.next(o),n.complete()}})})},t.concat=function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=sh(this);return new i(function(t){var r,o=0;return function e(s){r=s.subscribe({next:function(e){t.next(e)},error:function(e){t.error(e)},complete:function(){o===n.length?(r=void 0,t.complete()):e(i.from(n[o++]))}})}(e),function(){r&&(r.unsubscribe(),r=void 0)}})},t.flatMap=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var n=sh(this);return new n(function(r){var i=[],o=t.subscribe({next:function(t){if(e)try{t=e(t)}catch(e){return r.error(e)}var o=n.from(t).subscribe({next:function(e){r.next(e)},error:function(e){r.error(e)},complete:function(){var e=i.indexOf(o);e>=0&&i.splice(e,1),s()}});i.push(o)},error:function(e){r.error(e)},complete:function(){s()}});function s(){o.closed&&0===i.length&&r.complete()}return function(){i.forEach(function(e){return e.unsubscribe()}),o.unsubscribe()}})},t[rh]=function(){return this},e.from=function(t){var n="function"==typeof this?this:e;if(null==t)throw new TypeError(t+" is not an object");var r=oh(t,rh);if(r){var i=r.call(t);if(Object(i)!==i)throw new TypeError(i+" is not an object");return ah(i)&&i.constructor===n?i:new n(function(e){return i.subscribe(e)})}if(eh("iterator")&&(r=oh(t,nh)))return new n(function(e){ch(function(){if(!e.closed){for(var n,i=Hl(r.call(t));!(n=i()).done;){var o=n.value;if(e.next(o),e.closed)return}e.complete()}})});if(Array.isArray(t))return new n(function(e){ch(function(){if(!e.closed){for(var n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()}})});throw new TypeError(t+" is not observable")},e.of=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return new("function"==typeof this?this:e)(function(e){ch(function(){if(!e.closed){for(var t=0;t<n.length;++t)if(e.next(n[t]),e.closed)return;e.complete()}})})},Yl(e,null,[{key:ih,get:function(){return this}}]),e}();function gh(e){return null!==e&&"object"==typeof e}Xl()&&Object.defineProperty(mh,Symbol("extensions"),{value:{symbol:rh,hostReportError:uh},configurable:!0});const bh="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):void 0;function vh(e){return vh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},vh(e)}function wh(e){return Eh(e,[])}function Eh(e,t){switch(vh(e)){case"string":return JSON.stringify(e);case"function":return e.name?"[function ".concat(e.name,"]"):"[function]";case"object":return null===e?"null":function(e,t){if(-1!==t.indexOf(e))return"[Circular]";var n=[].concat(t,[e]),r=function(e){var t=e[String(bh)];if("function"==typeof t)return t;if("function"==typeof e.inspect)return e.inspect}(e);if(void 0!==r){var i=r.call(e);if(i!==e)return"string"==typeof i?i:Eh(i,n)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>2)return"[Array]";for(var n=Math.min(10,e.length),r=e.length-n,i=[],o=0;o<n;++o)i.push(Eh(e[o],t));1===r?i.push("... 1 more item"):r>1&&i.push("... ".concat(r," more items"));return"["+i.join(", ")+"]"}(e,n);return function(e,t){var n=Object.keys(e);if(0===n.length)return"{}";if(t.length>2)return"["+function(e){var t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){var n=e.constructor.name;if("string"==typeof n&&""!==n)return n}return t}(e)+"]";var r=n.map(function(n){return n+": "+Eh(e[n],t)});return"{ "+r.join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}function kh(e){var t=e.prototype.toJSON;"function"==typeof t||function(e,t){if(!Boolean(e))throw new Error(null!=t?t:"Unexpected invariant triggered.")}(0),e.prototype.inspect=t,bh&&(e.prototype[bh]=t)}var Sh=function(){function e(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}return e.prototype.toJSON=function(){return{start:this.start,end:this.end}},e}();kh(Sh);var Th=function(){function e(e,t,n,r,i,o,s){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=s,this.prev=o,this.next=null}return e.prototype.toJSON=function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}},e}();function _h(e){return null!=e&&"string"==typeof e.kind}kh(Th);var xh={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},Oh=Object.freeze({});function Ih(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:xh,r=void 0,i=Array.isArray(e),o=[e],s=-1,a=[],u=void 0,c=void 0,l=void 0,h=[],f=[],d=e;do{var p=++s===o.length,y=p&&0!==a.length;if(p){if(c=0===f.length?void 0:h[h.length-1],u=l,l=f.pop(),y){if(i)u=u.slice();else{for(var m={},g=0,b=Object.keys(u);g<b.length;g++){var v=b[g];m[v]=u[v]}u=m}for(var w=0,E=0;E<a.length;E++){var k=a[E][0],S=a[E][1];i&&(k-=w),i&&null===S?(u.splice(k,1),w++):u[k]=S}}s=r.index,o=r.keys,a=r.edits,i=r.inArray,r=r.prev}else{if(c=l?i?s:o[s]:void 0,null==(u=l?l[c]:d))continue;l&&h.push(c)}var T,_=void 0;if(!Array.isArray(u)){if(!_h(u))throw new Error("Invalid AST Node: ".concat(wh(u),"."));var x=Ch(t,u.kind,p);if(x){if((_=x.call(t,u,c,l,h,f))===Oh)break;if(!1===_){if(!p){h.pop();continue}}else if(void 0!==_&&(a.push([c,_]),!p)){if(!_h(_)){h.pop();continue}u=_}}}if(void 0===_&&y&&a.push([c,u]),p)h.pop();else r={inArray:i,index:s,keys:o,edits:a,prev:r},o=(i=Array.isArray(u))?u:null!==(T=n[u.kind])&&void 0!==T?T:[],s=-1,a=[],l&&f.push(l),l=u}while(void 0!==r);return 0!==a.length&&(d=a[a.length-1][1]),d}function Ch(e,t,n){var r=e[t];if(r){if(!n&&"function"==typeof r)return r;var i=n?r.leave:r.enter;if("function"==typeof i)return i}else{var o=n?e.leave:e.enter;if(o){if("function"==typeof o)return o;var s=o[t];if("function"==typeof s)return s}}}function Mh(e,t){var n=t,r=[];return e.definitions.forEach(function(e){if("OperationDefinition"===e.kind)throw zl(113,e.operation,e.name?" named '".concat(e.name.value,"'"):"");"FragmentDefinition"===e.kind&&r.push(e)}),void 0===n&&(Vl(1===r.length,114,r.length),n=r[0].name.value),Sl(Sl({},e),{definitions:Ol([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:n}}]}}],e.definitions,!0)})}function Ah(e){void 0===e&&(e=[]);var t={};return e.forEach(function(e){t[e.name.value]=e}),t}function Nh(e,t){switch(e.kind){case"InlineFragment":return e;case"FragmentSpread":var n=e.name.value;if("function"==typeof t)return t(n);var r=t&&t[n];return Vl(r,115,n),r||null;default:return null}}function jh(){}const Dh=jh,Rh="undefined"!=typeof WeakRef?WeakRef:function(e){return{deref:()=>e}},Ph="undefined"!=typeof WeakMap?WeakMap:Map,Bh="undefined"!=typeof FinalizationRegistry?FinalizationRegistry:function(){return{register:jh,unregister:jh}};class Fh{constructor(e=1/0,t=Dh){this.max=e,this.dispose=t,this.map=new Ph,this.newest=null,this.oldest=null,this.unfinalizedNodes=new Set,this.finalizationScheduled=!1,this.size=0,this.finalize=()=>{const e=this.unfinalizedNodes.values();for(let t=0;t<10024;t++){const t=e.next().value;if(!t)break;this.unfinalizedNodes.delete(t);const n=t.key;delete t.key,t.keyRef=new Rh(n),this.registry.register(n,t,t)}this.unfinalizedNodes.size>0?queueMicrotask(this.finalize):this.finalizationScheduled=!1},this.registry=new Bh(this.deleteNode.bind(this))}has(e){return this.map.has(e)}get(e){const t=this.getNode(e);return t&&t.value}getNode(e){const t=this.map.get(e);if(t&&t!==this.newest){const{older:e,newer:n}=t;n&&(n.older=e),e&&(e.newer=n),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=n)}return t}set(e,t){let n=this.getNode(e);return n?n.value=t:(n={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=n),this.newest=n,this.oldest=this.oldest||n,this.scheduleFinalization(n),this.map.set(e,n),this.size++,n.value)}clean(){for(;this.oldest&&this.size>this.max;)this.deleteNode(this.oldest)}deleteNode(e){e===this.newest&&(this.newest=e.older),e===this.oldest&&(this.oldest=e.newer),e.newer&&(e.newer.older=e.older),e.older&&(e.older.newer=e.newer),this.size--;const t=e.key||e.keyRef&&e.keyRef.deref();this.dispose(e.value,t),e.keyRef?this.registry.unregister(e):this.unfinalizedNodes.delete(e),t&&this.map.delete(t)}delete(e){const t=this.map.get(e);return!!t&&(this.deleteNode(t),!0)}scheduleFinalization(e){this.unfinalizedNodes.add(e),this.finalizationScheduled||(this.finalizationScheduled=!0,queueMicrotask(this.finalize))}}function Uh(){}class Lh{constructor(e=1/0,t=Uh){this.max=e,this.dispose=t,this.map=new Map,this.newest=null,this.oldest=null}has(e){return this.map.has(e)}get(e){const t=this.getNode(e);return t&&t.value}get size(){return this.map.size}getNode(e){const t=this.map.get(e);if(t&&t!==this.newest){const{older:e,newer:n}=t;n&&(n.older=e),e&&(e.newer=n),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=n)}return t}set(e,t){let n=this.getNode(e);return n?n.value=t:(n={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=n),this.newest=n,this.oldest=this.oldest||n,this.map.set(e,n),n.value)}clean(){for(;this.oldest&&this.map.size>this.max;)this.delete(this.oldest.key)}delete(e){const t=this.map.get(e);return!!t&&(t===this.newest&&(this.newest=t.older),t===this.oldest&&(this.oldest=t.newer),t.newer&&(t.newer.older=t.older),t.older&&(t.older.newer=t.newer),this.map.delete(e),this.dispose(t.value,e),!0)}}var qh=new WeakSet;function $h(e){e.size<=(e.max||-1)||qh.has(e)||(qh.add(e),setTimeout(function(){e.clean(),qh.delete(e)},100))}var Vh=function(e,t){var n=new Fh(e,t);return n.set=function(e,t){var n=Fh.prototype.set.call(this,e,t);return $h(this),n},n},zh=function(e,t){var n=new Lh(e,t);return n.set=function(e,t){var n=Lh.prototype.set.call(this,e,t);return $h(this),n},n},Kh=Symbol.for("apollo.cacheSize"),Wh=Sl({},Fl[Kh]),Qh={};function Gh(e,t){Qh[e]=t}var Hh=!1!==globalThis.__DEV__?function(){var e,t,n,r,i;if(!1===globalThis.__DEV__)throw new Error("only supported in development mode");return{limits:Object.fromEntries(Object.entries({parser:1e3,canonicalStringify:1e3,print:2e3,"documentTransform.cache":2e3,"queryManager.getDocumentInfo":2e3,"PersistedQueryLink.persistedQueryHashes":2e3,"fragmentRegistry.transform":2e3,"fragmentRegistry.lookup":1e3,"fragmentRegistry.findFragmentSpreads":4e3,"cache.fragmentQueryDocuments":1e3,"removeTypenameFromVariables.getVariableDefinitions":2e3,"inMemoryCache.maybeBroadcastWatch":5e3,"inMemoryCache.executeSelectionSet":5e4,"inMemoryCache.executeSubSelectedArray":1e4}).map(function(e){var t=e[0],n=e[1];return[t,Wh[t]||n]})),sizes:Sl({print:null===(e=Qh.print)||void 0===e?void 0:e.call(Qh),parser:null===(t=Qh.parser)||void 0===t?void 0:t.call(Qh),canonicalStringify:null===(n=Qh.canonicalStringify)||void 0===n?void 0:n.call(Qh),links:rf(this.link),queryManager:{getDocumentInfo:this.queryManager.transformCache.size,documentTransforms:tf(this.queryManager.documentTransform)}},null===(i=(r=this.cache).getMemoryInternals)||void 0===i?void 0:i.call(r))}}:void 0,Jh=!1!==globalThis.__DEV__?function(){var e=this.config.fragments;return Sl(Sl({},Yh.apply(this)),{addTypenameDocumentTransform:tf(this.addTypenameTransform),inMemoryCache:{executeSelectionSet:Xh(this.storeReader.executeSelectionSet),executeSubSelectedArray:Xh(this.storeReader.executeSubSelectedArray),maybeBroadcastWatch:Xh(this.maybeBroadcastWatch)},fragmentRegistry:{findFragmentSpreads:Xh(null==e?void 0:e.findFragmentSpreads),lookup:Xh(null==e?void 0:e.lookup),transform:Xh(null==e?void 0:e.transform)}})}:void 0,Zh=!1!==globalThis.__DEV__?Yh:void 0;function Yh(){return{cache:{fragmentQueryDocuments:Xh(this.getFragmentDoc)}}}function Xh(e){return function(e){return!!e&&"dirtyKey"in e}(e)?e.size:void 0}function ef(e){return null!=e}function tf(e){return nf(e).map(function(e){return{cache:e}})}function nf(e){return e?Ol(Ol([Xh(null==e?void 0:e.performWork)],nf(null==e?void 0:e.left),!0),nf(null==e?void 0:e.right),!0).filter(ef):[]}function rf(e){var t;return e?Ol(Ol([null===(t=null==e?void 0:e.getMemoryInternals)||void 0===t?void 0:t.call(e)],rf(null==e?void 0:e.left),!0),rf(null==e?void 0:e.right),!0).filter(ef):[]}var of,sf=Object.assign(function(e){return JSON.stringify(e,af)},{reset:function(){of=new zh(Wh.canonicalStringify||1e3)}});function af(e,t){if(t&&"object"==typeof t){var n=Object.getPrototypeOf(t);if(n===Object.prototype||null===n){var r=Object.keys(t);if(r.every(uf))return t;var i=JSON.stringify(r),o=of.get(i);if(!o){r.sort();var s=JSON.stringify(r);o=of.get(s)||r,of.set(i,o),of.set(s,o)}var a=Object.create(n);return o.forEach(function(e){a[e]=t[e]}),a}}return t}function uf(e,t,n){return 0===t||n[t-1]<=e}function cf(e){return{__ref:String(e)}}function lf(e){return Boolean(e&&"object"==typeof e&&"string"==typeof e.__ref)}function hf(e,t,n,r){if(function(e){return"IntValue"===e.kind}(n)||function(e){return"FloatValue"===e.kind}(n))e[t.value]=Number(n.value);else if(function(e){return"BooleanValue"===e.kind}(n)||function(e){return"StringValue"===e.kind}(n))e[t.value]=n.value;else if(function(e){return"ObjectValue"===e.kind}(n)){var i={};n.fields.map(function(e){return hf(i,e.name,e.value,r)}),e[t.value]=i}else if(function(e){return"Variable"===e.kind}(n)){var o=(r||{})[n.name.value];e[t.value]=o}else if(function(e){return"ListValue"===e.kind}(n))e[t.value]=n.values.map(function(e){var n={};return hf(n,t,e,r),n[t.value]});else if(function(e){return"EnumValue"===e.kind}(n))e[t.value]=n.value;else{if(!function(e){return"NullValue"===e.kind}(n))throw zl(124,t.value,n.kind);e[t.value]=null}}!1!==globalThis.__DEV__&&Gh("canonicalStringify",function(){return of.size}),sf.reset();var ff=["connection","include","skip","client","rest","export","nonreactive"],df=sf,pf=Object.assign(function(e,t,n){if(t&&n&&n.connection&&n.connection.key){if(n.connection.filter&&n.connection.filter.length>0){var r=n.connection.filter?n.connection.filter:[];r.sort();var i={};return r.forEach(function(e){i[e]=t[e]}),"".concat(n.connection.key,"(").concat(df(i),")")}return n.connection.key}var o=e;if(t){var s=df(t);o+="(".concat(s,")")}return n&&Object.keys(n).forEach(function(e){-1===ff.indexOf(e)&&(n[e]&&Object.keys(n[e]).length?o+="@".concat(e,"(").concat(df(n[e]),")"):o+="@".concat(e))}),o},{setStringify:function(e){var t=df;return df=e,t}});function yf(e,t){if(e.arguments&&e.arguments.length){var n={};return e.arguments.forEach(function(e){var r=e.name,i=e.value;return hf(n,r,i,t)}),n}return null}function mf(e){return e.alias?e.alias.value:e.name.value}function gf(e,t,n){for(var r,i=0,o=t.selections;i<o.length;i++){if(bf(u=o[i])){if("__typename"===u.name.value)return e[mf(u)]}else r?r.push(u):r=[u]}if("string"==typeof e.__typename)return e.__typename;if(r)for(var s=0,a=r;s<a.length;s++){var u,c=gf(e,Nh(u=a[s],n).selectionSet,n);if("string"==typeof c)return c}}function bf(e){return"Field"===e.kind}function vf(e){Vl(e&&"Document"===e.kind,116);var t=e.definitions.filter(function(e){return"FragmentDefinition"!==e.kind}).map(function(e){if("OperationDefinition"!==e.kind)throw zl(117,e.kind);return e});return Vl(t.length<=1,118,t.length),e}function wf(e){return vf(e),e.definitions.filter(function(e){return"OperationDefinition"===e.kind})[0]}function Ef(e){return e.definitions.filter(function(e){return"OperationDefinition"===e.kind&&!!e.name}).map(function(e){return e.name.value})[0]||null}function kf(e){return e.definitions.filter(function(e){return"FragmentDefinition"===e.kind})}function Sf(e){var t=wf(e);return Vl(t&&"query"===t.operation,119),t}function Tf(e){Vl("Document"===e.kind,120),Vl(e.definitions.length<=1,121);var t=e.definitions[0];return Vl("FragmentDefinition"===t.kind,122),t}function _f(e){var t;vf(e);for(var n=0,r=e.definitions;n<r.length;n++){var i=r[n];if("OperationDefinition"===i.kind){var o=i.operation;if("query"===o||"mutation"===o||"subscription"===o)return i}"FragmentDefinition"!==i.kind||t||(t=i)}if(t)return t;throw zl(123)}function xf(e){var t=Object.create(null),n=e&&e.variableDefinitions;return n&&n.length&&n.forEach(function(e){e.defaultValue&&hf(t,e.variable.name,e.defaultValue)}),t}const Of=()=>Object.create(null),{forEach:If,slice:Cf}=Array.prototype,{hasOwnProperty:Mf}=Object.prototype;class Af{constructor(e=!0,t=Of){this.weakness=e,this.makeData=t}lookup(){return this.lookupArray(arguments)}lookupArray(e){let t=this;return If.call(e,e=>t=t.getChildTrie(e)),Mf.call(t,"data")?t.data:t.data=this.makeData(Cf.call(e))}peek(){return this.peekArray(arguments)}peekArray(e){let t=this;for(let n=0,r=e.length;t&&n<r;++n){const r=t.mapFor(e[n],!1);t=r&&r.get(e[n])}return t&&t.data}remove(){return this.removeArray(arguments)}removeArray(e){let t;if(e.length){const n=e[0],r=this.mapFor(n,!1),i=r&&r.get(n);i&&(t=i.removeArray(Cf.call(e,1)),i.data||i.weak||i.strong&&i.strong.size||r.delete(n))}else t=this.data,delete this.data;return t}getChildTrie(e){const t=this.mapFor(e,!0);let n=t.get(e);return n||t.set(e,n=new Af(this.weakness,this.makeData)),n}mapFor(e,t){return this.weakness&&function(e){switch(typeof e){case"object":if(null===e)break;case"function":return!0}return!1}(e)?this.weak||(t?this.weak=new WeakMap:void 0):this.strong||(t?this.strong=new Map:void 0)}}let Nf=null;const jf={};let Df=1;function Rf(e){try{return e()}catch(e){}}const Pf="@wry/context:Slot",Bf=Rf(()=>globalThis)||Rf(()=>n.g)||Object.create(null),Ff=Bf[Pf]||Array[Pf]||function(e){try{Object.defineProperty(Bf,Pf,{value:e,enumerable:!1,writable:!1,configurable:!0})}finally{return e}}(class{constructor(){this.id=["slot",Df++,Date.now(),Math.random().toString(36).slice(2)].join(":")}hasValue(){for(let e=Nf;e;e=e.parent)if(this.id in e.slots){const t=e.slots[this.id];if(t===jf)break;return e!==Nf&&(Nf.slots[this.id]=t),!0}return Nf&&(Nf.slots[this.id]=jf),!1}getValue(){if(this.hasValue())return Nf.slots[this.id]}withValue(e,t,n,r){const i={__proto__:null,[this.id]:e},o=Nf;Nf={parent:o,slots:i};try{return t.apply(r,n)}finally{Nf=o}}static bind(e){const t=Nf;return function(){const n=Nf;try{return Nf=t,e.apply(this,arguments)}finally{Nf=n}}}static noContext(e,t,n){if(!Nf)return e.apply(n,t);{const r=Nf;try{return Nf=null,e.apply(n,t)}finally{Nf=r}}}}),{bind:Uf,noContext:Lf}=Ff;const qf=new Ff;const{hasOwnProperty:$f}=Object.prototype,Vf=Array.from||function(e){const t=[];return e.forEach(e=>t.push(e)),t};function zf(e){const{unsubscribe:t}=e;"function"==typeof t&&(e.unsubscribe=void 0,t())}const Kf=[];function Wf(e,t){if(!e)throw new Error(t||"assertion failure")}function Qf(e,t){const n=e.length;return n>0&&n===t.length&&e[n-1]===t[n-1]}function Gf(e){switch(e.length){case 0:throw new Error("unknown value");case 1:return e[0];case 2:throw e[1]}}function Hf(e){return e.slice(0)}class Jf{constructor(e){this.fn=e,this.parents=new Set,this.childValues=new Map,this.dirtyChildren=null,this.dirty=!0,this.recomputing=!1,this.value=[],this.deps=null,++Jf.count}peek(){if(1===this.value.length&&!Xf(this))return Zf(this),this.value[0]}recompute(e){return Wf(!this.recomputing,"already recomputing"),Zf(this),Xf(this)?function(e,t){sd(e),qf.withValue(e,Yf,[e,t]),function(e,t){if("function"==typeof e.subscribe)try{zf(e),e.unsubscribe=e.subscribe.apply(null,t)}catch(t){return e.setDirty(),!1}return!0}(e,t)&&function(e){if(e.dirty=!1,Xf(e))return;td(e)}(e);return Gf(e.value)}(this,e):Gf(this.value)}setDirty(){this.dirty||(this.dirty=!0,ed(this),zf(this))}dispose(){this.setDirty(),sd(this),nd(this,(e,t)=>{e.setDirty(),ad(e,this)})}forget(){this.dispose()}dependOn(e){e.add(this),this.deps||(this.deps=Kf.pop()||new Set),this.deps.add(e)}forgetDeps(){this.deps&&(Vf(this.deps).forEach(e=>e.delete(this)),this.deps.clear(),Kf.push(this.deps),this.deps=null)}}function Zf(e){const t=qf.getValue();if(t)return e.parents.add(t),t.childValues.has(e)||t.childValues.set(e,[]),Xf(e)?rd(t,e):id(t,e),t}function Yf(e,t){e.recomputing=!0;const{normalizeResult:n}=e;let r;n&&1===e.value.length&&(r=Hf(e.value)),e.value.length=0;try{if(e.value[0]=e.fn.apply(null,t),n&&r&&!Qf(r,e.value))try{e.value[0]=n(e.value[0],r[0])}catch(e){}}catch(t){e.value[1]=t}e.recomputing=!1}function Xf(e){return e.dirty||!(!e.dirtyChildren||!e.dirtyChildren.size)}function ed(e){nd(e,rd)}function td(e){nd(e,id)}function nd(e,t){const n=e.parents.size;if(n){const r=Vf(e.parents);for(let i=0;i<n;++i)t(r[i],e)}}function rd(e,t){Wf(e.childValues.has(t)),Wf(Xf(t));const n=!Xf(e);if(e.dirtyChildren){if(e.dirtyChildren.has(t))return}else e.dirtyChildren=Kf.pop()||new Set;e.dirtyChildren.add(t),n&&ed(e)}function id(e,t){Wf(e.childValues.has(t)),Wf(!Xf(t));const n=e.childValues.get(t);0===n.length?e.childValues.set(t,Hf(t.value)):Qf(n,t.value)||e.setDirty(),od(e,t),Xf(e)||td(e)}function od(e,t){const n=e.dirtyChildren;n&&(n.delete(t),0===n.size&&(Kf.length<100&&Kf.push(n),e.dirtyChildren=null))}function sd(e){e.childValues.size>0&&e.childValues.forEach((t,n)=>{ad(e,n)}),e.forgetDeps(),Wf(null===e.dirtyChildren)}function ad(e,t){t.parents.delete(e),e.childValues.delete(t),od(e,t)}Jf.count=0;const ud={setDirty:!0,dispose:!0,forget:!0};function cd(e){const t=new Map,n=e&&e.subscribe;function r(e){const r=qf.getValue();if(r){let i=t.get(e);i||t.set(e,i=new Set),r.dependOn(i),"function"==typeof n&&(zf(i),i.unsubscribe=n(e))}}return r.dirty=function(e,n){const r=t.get(e);if(r){const i=n&&$f.call(ud,n)?n:"setDirty";Vf(r).forEach(e=>e[i]()),t.delete(e),zf(r)}},r}let ld;function hd(...e){return(ld||(ld=new Af("function"==typeof WeakMap))).lookupArray(e)}const fd=new Set;function dd(e,{max:t=Math.pow(2,16),keyArgs:n,makeCacheKey:r=hd,normalizeResult:i,subscribe:o,cache:s=Lh}=Object.create(null)){const a="function"==typeof s?new s(t,e=>e.dispose()):s,u=function(){const t=r.apply(null,n?n.apply(null,arguments):arguments);if(void 0===t)return e.apply(null,arguments);let s=a.get(t);s||(a.set(t,s=new Jf(e)),s.normalizeResult=i,s.subscribe=o,s.forget=()=>a.delete(t));const u=s.recompute(Array.prototype.slice.call(arguments));return a.set(t,s),fd.add(a),qf.hasValue()||(fd.forEach(e=>e.clean()),fd.clear()),u};function c(e){const t=e&&a.get(e);t&&t.setDirty()}function l(e){const t=e&&a.get(e);if(t)return t.peek()}function h(e){return!!e&&a.delete(e)}return Object.defineProperty(u,"size",{get:()=>a.size,configurable:!1,enumerable:!1}),Object.freeze(u.options={max:t,keyArgs:n,makeCacheKey:r,normalizeResult:i,subscribe:o,cache:a}),u.dirtyKey=c,u.dirty=function(){c(r.apply(null,arguments))},u.peekKey=l,u.peek=function(){return l(r.apply(null,arguments))},u.forgetKey=h,u.forget=function(){return h(r.apply(null,arguments))},u.makeCacheKey=r,u.getKey=n?function(){return r.apply(null,n.apply(null,arguments))}:r,Object.freeze(u)}var pd=Symbol.for("apollo.deprecations"),yd=Fl,md=new Ff;function gd(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return md.withValue.apply(md,Ol([Array.isArray(e)?e:[e]],t,!1))}function bd(e,t,n,r){void 0===r&&(r="Please remove this option."),vd(t,function(){t in e&&!1!==globalThis.__DEV__&&Vl.warn(104,n,t,r)})}function vd(e,t){(function(e){return yd[pd]||(md.getValue()||[]).includes(e)})(e)||t()}function wd(e,t){return t?t(e):mh.of()}function Ed(e){return"function"==typeof e?new Sd(e):e}function kd(e){return e.request.length<=1}var Sd=function(){function e(e){e&&(this.request=e)}return e.empty=function(){return new e(function(){return mh.of()})},e.from=function(t){return 0===t.length?e.empty():t.map(Ed).reduce(function(e,t){return e.concat(t)})},e.split=function(t,n,r){var i,o=Ed(n),s=Ed(r||new e(wd));return i=kd(o)&&kd(s)?new e(function(e){return t(e)?o.request(e)||mh.of():s.request(e)||mh.of()}):new e(function(e,n){return t(e)?o.request(e,n)||mh.of():s.request(e,n)||mh.of()}),Object.assign(i,{left:o,right:s})},e.execute=function(e,t){return e.request(function(e,t){var n=Sl({},e);return Object.defineProperty(t,"setContext",{enumerable:!1,value:function(e){n=Sl(Sl({},n),"function"==typeof e?e(n):e)}}),Object.defineProperty(t,"getContext",{enumerable:!1,value:function(){return Sl({},n)}}),t}(t.context,function(e){var t={variables:e.variables||{},extensions:e.extensions||{},operationName:e.operationName,query:e.query};return t.operationName||(t.operationName="string"!=typeof t.query?Ef(t.query)||void 0:""),t}(function(e){for(var t=["query","operationName","variables","extensions","context"],n=0,r=Object.keys(e);n<r.length;n++){var i=r[n];if(t.indexOf(i)<0)throw zl(58,i)}return e}(t))))||mh.of()},e.concat=function(t,n){var r=Ed(t);if(kd(r))return!1!==globalThis.__DEV__&&Vl.warn(47,r),r;var i,o=Ed(n);return i=kd(o)?new e(function(e){return r.request(e,function(e){return o.request(e)||mh.of()})||mh.of()}):new e(function(e,t){return r.request(e,function(e){return o.request(e,t)||mh.of()})||mh.of()}),Object.assign(i,{left:r,right:o})},e.prototype.split=function(t,n,r){return this.concat(e.split(t,n,r||new e(wd)))},e.prototype.concat=function(t){return e.concat(this,t)},e.prototype.request=function(e,t){throw zl(48)},e.prototype.onError=function(e,t){if(!1!==globalThis.__DEV__&&vd("onError",function(){!1!==globalThis.__DEV__&&Vl.warn(49)}),t&&t.error)return t.error(e),!1;throw e},e.prototype.setOnError=function(e){return!1!==globalThis.__DEV__&&!1!==globalThis.__DEV__&&Vl.warn(50),this.onError=e,this},e}(),Td=Object.freeze({NAME:"Name",DOCUMENT:"Document",OPERATION_DEFINITION:"OperationDefinition",VARIABLE_DEFINITION:"VariableDefinition",SELECTION_SET:"SelectionSet",FIELD:"Field",ARGUMENT:"Argument",FRAGMENT_SPREAD:"FragmentSpread",INLINE_FRAGMENT:"InlineFragment",FRAGMENT_DEFINITION:"FragmentDefinition",VARIABLE:"Variable",INT:"IntValue",FLOAT:"FloatValue",STRING:"StringValue",BOOLEAN:"BooleanValue",NULL:"NullValue",ENUM:"EnumValue",LIST:"ListValue",OBJECT:"ObjectValue",OBJECT_FIELD:"ObjectField",DIRECTIVE:"Directive",NAMED_TYPE:"NamedType",LIST_TYPE:"ListType",NON_NULL_TYPE:"NonNullType",SCHEMA_DEFINITION:"SchemaDefinition",OPERATION_TYPE_DEFINITION:"OperationTypeDefinition",SCALAR_TYPE_DEFINITION:"ScalarTypeDefinition",OBJECT_TYPE_DEFINITION:"ObjectTypeDefinition",FIELD_DEFINITION:"FieldDefinition",INPUT_VALUE_DEFINITION:"InputValueDefinition",INTERFACE_TYPE_DEFINITION:"InterfaceTypeDefinition",UNION_TYPE_DEFINITION:"UnionTypeDefinition",ENUM_TYPE_DEFINITION:"EnumTypeDefinition",ENUM_VALUE_DEFINITION:"EnumValueDefinition",INPUT_OBJECT_TYPE_DEFINITION:"InputObjectTypeDefinition",DIRECTIVE_DEFINITION:"DirectiveDefinition",SCHEMA_EXTENSION:"SchemaExtension",SCALAR_TYPE_EXTENSION:"ScalarTypeExtension",OBJECT_TYPE_EXTENSION:"ObjectTypeExtension",INTERFACE_TYPE_EXTENSION:"InterfaceTypeExtension",UNION_TYPE_EXTENSION:"UnionTypeExtension",ENUM_TYPE_EXTENSION:"EnumTypeExtension",INPUT_OBJECT_TYPE_EXTENSION:"InputObjectTypeExtension"});function _d(e,t){var n=e.directives;return!n||!n.length||function(e){var t=[];e&&e.length&&e.forEach(function(e){if(function(e){var t=e.name.value;return"skip"===t||"include"===t}(e)){var n=e.arguments,r=e.name.value;Vl(n&&1===n.length,107,r);var i=n[0];Vl(i.name&&"if"===i.name.value,108,r);var o=i.value;Vl(o&&("Variable"===o.kind||"BooleanValue"===o.kind),109,r),t.push({directive:e,ifArgument:i})}});return t}(n).every(function(e){var n=e.directive,r=e.ifArgument,i=!1;return"Variable"===r.value.kind?(i=t&&t[r.value.name.value],Vl(void 0!==i,106,n.name.value)):i=r.value.value,"skip"===n.name.value?!i:i})}function xd(e,t,n){var r=new Set(e),i=r.size;return Ih(t,{Directive:function(e){if(r.delete(e.name.value)&&(!n||!r.size))return Oh}}),n?!r.size:r.size<i}function Od(e){return e&&xd(["client","export"],e,!0)}function Id(e){var t,n,r=null===(t=e.directives)||void 0===t?void 0:t.find(function(e){return"unmask"===e.name.value});if(!r)return"mask";var i=null===(n=r.arguments)||void 0===n?void 0:n.find(function(e){return"mode"===e.name.value});return!1!==globalThis.__DEV__&&i&&(i.value.kind===Td.VARIABLE?!1!==globalThis.__DEV__&&Vl.warn(110):i.value.kind!==Td.STRING?!1!==globalThis.__DEV__&&Vl.warn(111):"migrate"!==i.value.value&&!1!==globalThis.__DEV__&&Vl.warn(112,i.value.value)),i&&"value"in i.value&&"migrate"===i.value.value?"migrate":"unmask"}var Cd=function(e,t){var n;try{n=JSON.stringify(e)}catch(e){var r=zl(54,t,e.message);throw r.parseError=e,r}return n},Md=function(e,t){var n=e.getContext().uri;return n||("function"==typeof t?t(e):t||"/graphql")},Ad="ReactNative"==Bl(function(){return navigator.product}),Nd="function"==typeof WeakMap&&!(Ad&&!n.g.HermesInternal),jd="function"==typeof WeakSet,Dd="function"==typeof Symbol&&"function"==typeof Symbol.for,Rd=Dd&&Symbol.asyncIterator;Bl(function(){return window.document.createElement}),Bl(function(){return navigator.userAgent.indexOf("jsdom")>=0});function Pd(e){var t=null,n=null,r=!1,i=[],o=[];function s(e){if(!n){if(o.length){var t=o.shift();if(Array.isArray(t)&&t[0])return t[0]({value:e,done:!1})}i.push(e)}}function a(e){n=e,o.slice().forEach(function(t){t[1](e)}),!t||t()}function u(){r=!0,o.slice().forEach(function(e){e[0]({value:void 0,done:!0})}),!t||t()}t=function(){t=null,e.removeListener("data",s),e.removeListener("error",a),e.removeListener("end",u),e.removeListener("finish",u),e.removeListener("close",u)},e.on("data",s),e.on("error",a),e.on("end",u),e.on("finish",u),e.on("close",u);var c={next:function(){return new Promise(function(e,t){return n?t(n):i.length?e({value:i.shift(),done:!1}):r?e({value:void 0,done:!0}):void o.push([e,t])})}};return Rd&&(c[Symbol.asyncIterator]=function(){return this}),c}function Bd(e){var t={next:function(){return e.read()}};return Rd&&(t[Symbol.asyncIterator]=function(){return this}),t}function Fd(e){var t=e;if(function(e){return!!e.body}(e)&&(t=e.body),function(e){return!(!Rd||!e[Symbol.asyncIterator])}(t))return function(e){var t,n=e[Symbol.asyncIterator]();return(t={next:function(){return n.next()}})[Symbol.asyncIterator]=function(){return this},t}(t);if(function(e){return!!e.getReader}(t))return Bd(t.getReader());if(function(e){return!!e.stream}(t))return Bd(t.stream().getReader());if(function(e){return!!e.arrayBuffer}(t))return function(e){var t=!1,n={next:function(){return t?Promise.resolve({value:void 0,done:!0}):(t=!0,new Promise(function(t,n){e.then(function(e){t({value:e,done:!1})}).catch(n)}))}};return Rd&&(n[Symbol.asyncIterator]=function(){return this}),n}(t.arrayBuffer());if(function(e){return!!e.pipe}(t))return Pd(t);throw new Error("Unknown body type for responseIterator. Please pass a streamable response.")}var Ud=function(e,t,n){var r=new Error(n);throw r.name="ServerError",r.response=e,r.statusCode=e.status,r.result=t,r},Ld=Symbol();function qd(e){return!!e.extensions&&Array.isArray(e.extensions[Ld])}function $d(e){return e.hasOwnProperty("graphQLErrors")}var Vd=function(e){function t(n){var r,i,o=n.graphQLErrors,s=n.protocolErrors,a=n.clientErrors,u=n.networkError,c=n.errorMessage,l=n.extraInfo,h=e.call(this,c)||this;return h.name="ApolloError",h.graphQLErrors=o||[],h.protocolErrors=s||[],h.clientErrors=a||[],h.networkError=u||null,h.message=c||(i=Ol(Ol(Ol([],(r=h).graphQLErrors,!0),r.clientErrors,!0),r.protocolErrors,!0),r.networkError&&i.push(r.networkError),i.map(function(e){return gh(e)&&e.message||"Error message not found."}).join("\n")),h.extraInfo=l,h.cause=Ol(Ol(Ol([u],o||[],!0),s||[],!0),a||[],!0).find(function(e){return!!e})||null,h.__proto__=t.prototype,h}return kl(t,e),t}(Error),zd=Array.isArray;function Kd(e){return Array.isArray(e)&&e.length>0}var Wd=Object.prototype.hasOwnProperty;function Qd(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Gd(e)}function Gd(e){var t=e[0]||{},n=e.length;if(n>1)for(var r=new Jd,i=1;i<n;++i)t=r.merge(t,e[i]);return t}var Hd=function(e,t,n){return this.merge(e[n],t[n])},Jd=function(){function e(e){void 0===e&&(e=Hd),this.reconciler=e,this.isObject=gh,this.pastCopies=new Set}return e.prototype.merge=function(e,t){for(var n=this,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];return gh(t)&&gh(e)?(Object.keys(t).forEach(function(i){if(Wd.call(e,i)){var o=e[i];if(t[i]!==o){var s=n.reconciler.apply(n,Ol([e,t,i],r,!1));s!==o&&((e=n.shallowCopyForMerge(e))[i]=s)}}else(e=n.shallowCopyForMerge(e))[i]=t[i]}),e):t},e.prototype.shallowCopyForMerge=function(e){return gh(e)&&(this.pastCopies.has(e)||(e=Array.isArray(e)?e.slice(0):Sl({__proto__:Object.getPrototypeOf(e)},e),this.pastCopies.add(e))),e},e}();function Zd(e){return"incremental"in e}function Yd(e){return gh(e)&&"payload"in e}function Xd(e,t){var n=e,r=new Jd;return Zd(t)&&Kd(t.incremental)&&t.incremental.forEach(function(e){for(var t=e.data,i=e.path,o=i.length-1;o>=0;--o){var s=i[o],a=!isNaN(+s)?[]:{};a[s]=t,t=a}n=r.merge(n,t)}),n}var ep=Object.prototype.hasOwnProperty;function tp(e){var t={};return e.split("\n").forEach(function(e){var n=e.indexOf(":");if(n>-1){var r=e.slice(0,n).trim().toLowerCase(),i=e.slice(n+1).trim();t[r]=i}}),t}function np(e,t){if(e.status>=300){Ud(e,function(){try{return JSON.parse(t)}catch(e){return t}}(),"Response not successful: Received status code ".concat(e.status))}try{return JSON.parse(t)}catch(r){var n=r;throw n.name="ServerParseError",n.response=e,n.statusCode=e.status,n.bodyText=t,n}}function rp(e){return function(t){return t.text().then(function(e){return np(t,e)}).then(function(n){return Array.isArray(n)||ep.call(n,"data")||ep.call(n,"errors")||Ud(t,n,"Server response was missing for query '".concat(Array.isArray(e)?e.map(function(e){return e.operationName}):e.operationName,"'.")),n})}}var ip=function(e){if(!e&&"undefined"==typeof fetch)throw zl(51)};function op(e){var t=e.split(/\r\n|[\n\r]/g),n=function(e){for(var t,n=!0,r=!0,i=0,o=null,s=0;s<e.length;++s)switch(e.charCodeAt(s)){case 13:10===e.charCodeAt(s+1)&&++s;case 10:n=!1,r=!0,i=0;break;case 9:case 32:++i;break;default:r&&!n&&(null===o||i<o)&&(o=i),r=!1}return null!==(t=o)&&void 0!==t?t:0}(e);if(0!==n)for(var r=1;r<t.length;r++)t[r]=t[r].slice(n);for(var i=0;i<t.length&&sp(t[i]);)++i;for(var o=t.length;o>i&&sp(t[o-1]);)--o;return t.slice(i,o).join("\n")}function sp(e){for(var t=0;t<e.length;++t)if(" "!==e[t]&&"\t"!==e[t])return!1;return!0}var ap,up={Name:function(e){return e.value},Variable:function(e){return"$"+e.name},Document:function(e){return lp(e.definitions,"\n\n")+"\n"},OperationDefinition:function(e){var t=e.operation,n=e.name,r=fp("(",lp(e.variableDefinitions,", "),")"),i=lp(e.directives," "),o=e.selectionSet;return n||i||r||"query"!==t?lp([t,lp([n,r]),i,o]," "):o},VariableDefinition:function(e){var t=e.variable,n=e.type,r=e.defaultValue,i=e.directives;return t+": "+n+fp(" = ",r)+fp(" ",lp(i," "))},SelectionSet:function(e){return hp(e.selections)},Field:function(e){var t=e.alias,n=e.name,r=e.arguments,i=e.directives,o=e.selectionSet,s=fp("",t,": ")+n,a=s+fp("(",lp(r,", "),")");return a.length>80&&(a=s+fp("(\n",dp(lp(r,"\n")),"\n)")),lp([a,lp(i," "),o]," ")},Argument:function(e){return e.name+": "+e.value},FragmentSpread:function(e){return"..."+e.name+fp(" ",lp(e.directives," "))},InlineFragment:function(e){var t=e.typeCondition,n=e.directives,r=e.selectionSet;return lp(["...",fp("on ",t),lp(n," "),r]," ")},FragmentDefinition:function(e){var t=e.name,n=e.typeCondition,r=e.variableDefinitions,i=e.directives,o=e.selectionSet;return"fragment ".concat(t).concat(fp("(",lp(r,", "),")")," ")+"on ".concat(n," ").concat(fp("",lp(i," ")," "))+o},IntValue:function(e){return e.value},FloatValue:function(e){return e.value},StringValue:function(e,t){var n=e.value;return e.block?function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=-1===e.indexOf("\n"),i=" "===e[0]||"\t"===e[0],o='"'===e[e.length-1],s="\\"===e[e.length-1],a=!r||o||s||n,u="";return!a||r&&i||(u+="\n"+t),u+=t?e.replace(/\n/g,"\n"+t):e,a&&(u+="\n"),'"""'+u.replace(/"""/g,'\\"""')+'"""'}(n,"description"===t?"":" "):JSON.stringify(n)},BooleanValue:function(e){return e.value?"true":"false"},NullValue:function(){return"null"},EnumValue:function(e){return e.value},ListValue:function(e){return"["+lp(e.values,", ")+"]"},ObjectValue:function(e){return"{"+lp(e.fields,", ")+"}"},ObjectField:function(e){return e.name+": "+e.value},Directive:function(e){return"@"+e.name+fp("(",lp(e.arguments,", "),")")},NamedType:function(e){return e.name},ListType:function(e){return"["+e.type+"]"},NonNullType:function(e){return e.type+"!"},SchemaDefinition:cp(function(e){var t=e.directives,n=e.operationTypes;return lp(["schema",lp(t," "),hp(n)]," ")}),OperationTypeDefinition:function(e){return e.operation+": "+e.type},ScalarTypeDefinition:cp(function(e){return lp(["scalar",e.name,lp(e.directives," ")]," ")}),ObjectTypeDefinition:cp(function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return lp(["type",t,fp("implements ",lp(n," & ")),lp(r," "),hp(i)]," ")}),FieldDefinition:cp(function(e){var t=e.name,n=e.arguments,r=e.type,i=e.directives;return t+(yp(n)?fp("(\n",dp(lp(n,"\n")),"\n)"):fp("(",lp(n,", "),")"))+": "+r+fp(" ",lp(i," "))}),InputValueDefinition:cp(function(e){var t=e.name,n=e.type,r=e.defaultValue,i=e.directives;return lp([t+": "+n,fp("= ",r),lp(i," ")]," ")}),InterfaceTypeDefinition:cp(function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return lp(["interface",t,fp("implements ",lp(n," & ")),lp(r," "),hp(i)]," ")}),UnionTypeDefinition:cp(function(e){var t=e.name,n=e.directives,r=e.types;return lp(["union",t,lp(n," "),r&&0!==r.length?"= "+lp(r," | "):""]," ")}),EnumTypeDefinition:cp(function(e){var t=e.name,n=e.directives,r=e.values;return lp(["enum",t,lp(n," "),hp(r)]," ")}),EnumValueDefinition:cp(function(e){return lp([e.name,lp(e.directives," ")]," ")}),InputObjectTypeDefinition:cp(function(e){var t=e.name,n=e.directives,r=e.fields;return lp(["input",t,lp(n," "),hp(r)]," ")}),DirectiveDefinition:cp(function(e){var t=e.name,n=e.arguments,r=e.repeatable,i=e.locations;return"directive @"+t+(yp(n)?fp("(\n",dp(lp(n,"\n")),"\n)"):fp("(",lp(n,", "),")"))+(r?" repeatable":"")+" on "+lp(i," | ")}),SchemaExtension:function(e){var t=e.directives,n=e.operationTypes;return lp(["extend schema",lp(t," "),hp(n)]," ")},ScalarTypeExtension:function(e){return lp(["extend scalar",e.name,lp(e.directives," ")]," ")},ObjectTypeExtension:function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return lp(["extend type",t,fp("implements ",lp(n," & ")),lp(r," "),hp(i)]," ")},InterfaceTypeExtension:function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return lp(["extend interface",t,fp("implements ",lp(n," & ")),lp(r," "),hp(i)]," ")},UnionTypeExtension:function(e){var t=e.name,n=e.directives,r=e.types;return lp(["extend union",t,lp(n," "),r&&0!==r.length?"= "+lp(r," | "):""]," ")},EnumTypeExtension:function(e){var t=e.name,n=e.directives,r=e.values;return lp(["extend enum",t,lp(n," "),hp(r)]," ")},InputObjectTypeExtension:function(e){var t=e.name,n=e.directives,r=e.fields;return lp(["extend input",t,lp(n," "),hp(r)]," ")}};function cp(e){return function(t){return lp([t.description,e(t)],"\n")}}function lp(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return null!==(t=null==e?void 0:e.filter(function(e){return e}).join(n))&&void 0!==t?t:""}function hp(e){return fp("{\n",dp(lp(e,"\n")),"\n}")}function fp(e,t){return null!=t&&""!==t?e+t+(arguments.length>2&&void 0!==arguments[2]?arguments[2]:""):""}function dp(e){return fp(" ",e.replace(/\n/g,"\n "))}function pp(e){return-1!==e.indexOf("\n")}function yp(e){return null!=e&&e.some(pp)}var mp=Object.assign(function(e){var t=ap.get(e);return t||(t=function(e){return Ih(e,{leave:up})}(e),ap.set(e,t)),t},{reset:function(){ap=new Vh(Wh.print||2e3)}});mp.reset(),!1!==globalThis.__DEV__&&Gh("print",function(){return ap?ap.size:0});var gp={http:{includeQuery:!0,includeExtensions:!1,preserveHeaderCase:!1},headers:{accept:"*/*","content-type":"application/json"},options:{method:"POST"}},bp=function(e,t){return t(e)};function vp(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i={},o={};n.forEach(function(e){i=Sl(Sl(Sl({},i),e.options),{headers:Sl(Sl({},i.headers),e.headers)}),e.credentials&&(i.credentials=e.credentials),o=Sl(Sl({},o),e.http)}),i.headers&&(i.headers=function(e,t){if(!t){var n={};return Object.keys(Object(e)).forEach(function(t){n[t.toLowerCase()]=e[t]}),n}var r={};Object.keys(Object(e)).forEach(function(t){r[t.toLowerCase()]={originalName:t,value:e[t]}});var i={};return Object.keys(r).forEach(function(e){i[r[e].originalName]=r[e].value}),i}(i.headers,o.preserveHeaderCase));var s=e.operationName,a=e.extensions,u=e.variables,c=e.query,l={operationName:s,variables:u};return o.includeExtensions&&(l.extensions=a),o.includeQuery&&(l.query=t(c,mp)),{options:i,body:l}}function wp(e){return new mh(function(t){t.error(e)})}function Ep(e,t){var n=Sl({},e),r=new Set(Object.keys(e));return Ih(t,{Variable:function(e,t,n){n&&"VariableDefinition"!==n.kind&&r.delete(e.name.value)}}),r.forEach(function(e){delete n[e]}),n}var kp={kind:Td.FIELD,name:{kind:Td.NAME,value:"__typename"}};function Sp(e,t){return!e||e.selectionSet.selections.every(function(e){return e.kind===Td.FRAGMENT_SPREAD&&Sp(t[e.name.value],t)})}function Tp(e){return Sp(wf(e)||Tf(e),Ah(kf(e)))?null:e}function _p(e){var t=new Map,n=new Map;return e.forEach(function(e){e&&(e.name?t.set(e.name,e):e.test&&n.set(e.test,e))}),function(e){var r=t.get(e.name.value);return!r&&n.size&&n.forEach(function(t,n){n(e)&&(r=t)}),r}}function xp(e){var t=new Map;return function(n){void 0===n&&(n=e);var r=t.get(n);return r||t.set(n,r={variables:new Set,fragmentSpreads:new Set}),r}}function Op(e,t){vf(t);for(var n=xp(""),r=xp(""),i=function(e){for(var t=0,i=void 0;t<e.length&&(i=e[t]);++t)if(!zd(i)){if(i.kind===Td.OPERATION_DEFINITION)return n(i.name&&i.name.value);if(i.kind===Td.FRAGMENT_DEFINITION)return r(i.name.value)}return!1!==globalThis.__DEV__&&Vl.error(125),null},o=0,s=t.definitions.length-1;s>=0;--s)t.definitions[s].kind===Td.OPERATION_DEFINITION&&++o;var a=_p(e),u=function(e){return Kd(e)&&e.map(a).some(function(e){return e&&e.remove})},c=new Map,l=!1,h={enter:function(e){if(u(e.directives))return l=!0,null}},f=Ih(t,{Field:h,InlineFragment:h,VariableDefinition:{enter:function(){return!1}},Variable:{enter:function(e,t,n,r,o){var s=i(o);s&&s.variables.add(e.name.value)}},FragmentSpread:{enter:function(e,t,n,r,o){if(u(e.directives))return l=!0,null;var s=i(o);s&&s.fragmentSpreads.add(e.name.value)}},FragmentDefinition:{enter:function(e,t,n,r){c.set(JSON.stringify(r),e)},leave:function(e,t,n,i){return e===c.get(JSON.stringify(i))?e:o>0&&e.selectionSet.selections.every(function(e){return e.kind===Td.FIELD&&"__typename"===e.name.value})?(r(e.name.value).removed=!0,l=!0,null):void 0}},Directive:{leave:function(e){if(a(e))return l=!0,null}}});if(!l)return t;var d=function(e){return e.transitiveVars||(e.transitiveVars=new Set(e.variables),e.removed||e.fragmentSpreads.forEach(function(t){d(r(t)).transitiveVars.forEach(function(t){e.transitiveVars.add(t)})})),e},p=new Set;f.definitions.forEach(function(e){e.kind===Td.OPERATION_DEFINITION?d(n(e.name&&e.name.value)).fragmentSpreads.forEach(function(e){p.add(e)}):e.kind!==Td.FRAGMENT_DEFINITION||0!==o||r(e.name.value).removed||p.add(e.name.value)}),p.forEach(function(e){d(r(e)).fragmentSpreads.forEach(function(e){p.add(e)})});var y={enter:function(e){if(t=e.name.value,!p.has(t)||r(t).removed)return null;var t}};return Tp(Ih(f,{FragmentSpread:y,FragmentDefinition:y,OperationDefinition:{leave:function(e){if(e.variableDefinitions){var t=d(n(e.name&&e.name.value)).transitiveVars;if(t.size<e.variableDefinitions.length)return Sl(Sl({},e),{variableDefinitions:e.variableDefinitions.filter(function(e){return t.has(e.variable.name.value)})})}}}}))}var Ip=Object.assign(function(e){return Ih(e,{SelectionSet:{enter:function(e,t,n){if(!n||n.kind!==Td.OPERATION_DEFINITION){var r=e.selections;if(r)if(!r.some(function(e){return bf(e)&&("__typename"===e.name.value||0===e.name.value.lastIndexOf("__",0))})){var i=n;if(!(bf(i)&&i.directives&&i.directives.some(function(e){return"export"===e.name.value})))return Sl(Sl({},e),{selections:Ol(Ol([],r,!0),[kp],!1)})}}}}})},{added:function(e){return e===kp}});function Cp(e){return"query"===_f(e).operation?e:Ih(e,{OperationDefinition:{enter:function(e){return Sl(Sl({},e),{operation:"query"})}}})}function Mp(e){return vf(e),Op([{test:function(e){return"client"===e.name.value},remove:!0}],e)}function Ap(e){return vf(e),Ih(e,{FragmentSpread:function(e){var t;if(!(null===(t=e.directives)||void 0===t?void 0:t.some(function(e){return"unmask"===e.name.value})))return Sl(Sl({},e),{directives:Ol(Ol([],e.directives||[],!0),[{kind:Td.DIRECTIVE,name:{kind:Td.NAME,value:"nonreactive"}}],!1)})}})}var Np=Bl(function(){return fetch}),jp=function(e){void 0===e&&(e={});var t=e.uri,n=void 0===t?"/graphql":t,r=e.fetch,i=e.print,o=void 0===i?bp:i,s=e.includeExtensions,a=e.preserveHeaderCase,u=e.useGETForQueries,c=e.includeUnusedVariables,l=void 0!==c&&c,h=Tl(e,["uri","fetch","print","includeExtensions","preserveHeaderCase","useGETForQueries","includeUnusedVariables"]);!1!==globalThis.__DEV__&&ip(r||Np);var f={http:{includeExtensions:s,preserveHeaderCase:a},options:h.fetchOptions,credentials:h.credentials,headers:h.headers};return new Sd(function(e){var t=Md(e,n),i=e.getContext(),s={};if(i.clientAwareness){var a=i.clientAwareness,c=a.name,h=a.version;c&&(s["apollographql-client-name"]=c),h&&(s["apollographql-client-version"]=h)}var d=Sl(Sl({},s),i.headers),p={http:i.http,options:i.fetchOptions,credentials:i.credentials,headers:d};if(xd(["client"],e.query)){!1!==globalThis.__DEV__&&!1!==globalThis.__DEV__&&Vl.warn(52);var y=Mp(e.query);if(!y)return wp(new Error("HttpLink: Trying to send a client-only query to the server. To send to the server, ensure a non-client field is added to the query or set the `transformOptions.removeClientFields` option to `true`."));e.query=y}var m,g=vp(e,o,gp,f,p),b=g.options,v=g.body;v.variables&&!l&&(v.variables=Ep(v.variables,e.query)),b.signal||"undefined"==typeof AbortController||(m=new AbortController,b.signal=m.signal);var w,E="OperationDefinition"===(w=_f(e.query)).kind&&"subscription"===w.operation,k=xd(["defer"],e.query);if(u&&!e.query.definitions.some(function(e){return"OperationDefinition"===e.kind&&"mutation"===e.operation})&&(b.method="GET"),k||E){b.headers=b.headers||{};var S="multipart/mixed;";E&&k&&!1!==globalThis.__DEV__&&Vl.warn(53),E?S+="boundary=graphql;subscriptionSpec=1.0,application/json":k&&(S+="deferSpec=20220824,application/json"),b.headers.accept=S}if("GET"===b.method){var T=function(e,t){var n=[],r=function(e,t){n.push("".concat(e,"=").concat(encodeURIComponent(t)))};if("query"in t&&r("query",t.query),t.operationName&&r("operationName",t.operationName),t.variables){var i=void 0;try{i=Cd(t.variables,"Variables map")}catch(e){return{parseError:e}}r("variables",i)}if(t.extensions){var o=void 0;try{o=Cd(t.extensions,"Extensions map")}catch(e){return{parseError:e}}r("extensions",o)}var s="",a=e,u=e.indexOf("#");-1!==u&&(s=e.substr(u),a=e.substr(0,u));var c=-1===a.indexOf("?")?"?":"&";return{newURI:a+c+n.join("&")+s}}(t,v),_=T.newURI,x=T.parseError;if(x)return wp(x);t=_}else try{b.body=Cd(v,"Payload")}catch(x){return wp(x)}return new mh(function(n){var i=r||Bl(function(){return fetch})||Np,o=n.next.bind(n);return i(t,b).then(function(t){var n;e.setContext({response:t});var r=null===(n=t.headers)||void 0===n?void 0:n.get("content-type");return null!==r&&/^multipart\/mixed/i.test(r)?function(e,t){return _l(this,void 0,void 0,function(){var n,r,i,o,s,a,u,c,l,h,f,d,p,y,m,g,b,v,w,E,k,S,T,_;return xl(this,function(x){switch(x.label){case 0:if(void 0===TextDecoder)throw new Error("TextDecoder must be defined in the environment: please import a polyfill.");n=new TextDecoder("utf-8"),r=null===(_=e.headers)||void 0===_?void 0:_.get("content-type"),i="boundary=",o=(null==r?void 0:r.includes(i))?null==r?void 0:r.substring((null==r?void 0:r.indexOf(i))+9).replace(/['"]/g,"").replace(/\;(.*)/gm,"").trim():"-",s="\r\n--".concat(o),a="",u=Fd(e),c=!0,x.label=1;case 1:return c?[4,u.next()]:[3,3];case 2:for(l=x.sent(),h=l.value,f=l.done,d="string"==typeof h?h:n.decode(h),p=a.length-s.length+1,c=!f,y=(a+=d).indexOf(s,p);y>-1;){if(m=void 0,S=[a.slice(0,y),a.slice(y+s.length)],a=S[1],g=(m=S[0]).indexOf("\r\n\r\n"),b=tp(m.slice(0,g)),(v=b["content-type"])&&-1===v.toLowerCase().indexOf("application/json"))throw new Error("Unsupported patch content type: application/json is required.");if(w=m.slice(g))if(E=np(e,w),Object.keys(E).length>1||"data"in E||"incremental"in E||"errors"in E||"payload"in E)if(Yd(E)){if(k={},"payload"in E){if(1===Object.keys(E).length&&null===E.payload)return[2];k=Sl({},E.payload)}"errors"in E&&(k=Sl(Sl({},k),{extensions:Sl(Sl({},"extensions"in k?k.extensions:null),(T={},T[Ld]=E.errors,T))})),t(k)}else t(E);else if(1===Object.keys(E).length&&"hasNext"in E&&!E.hasNext)return[2];y=a.indexOf(s)}return[3,1];case 3:return[2]}})})}(t,o):rp(e)(t).then(o)}).then(function(){m=void 0,n.complete()}).catch(function(e){m=void 0,function(e,t){e.result&&e.result.errors&&e.result.data&&t.next(e.result),t.error(e)}(e,n)}),function(){m&&m.abort()}})})},Dp=Sd.from,Rp=Sd.split,Pp=Sd.execute,Bp=function(e){function t(t){void 0===t&&(t={});var n=e.call(this,jp(t).request)||this;return n.options=t,n}return kl(t,e),t}(Sd);const{toString:Fp,hasOwnProperty:Up}=Object.prototype,Lp=Function.prototype.toString,qp=new Map;function $p(e,t){try{return zp(e,t)}finally{qp.clear()}}const Vp=$p;function zp(e,t){if(e===t)return!0;const n=Fp.call(e);if(n!==Fp.call(t))return!1;switch(n){case"[object Array]":if(e.length!==t.length)return!1;case"[object Object]":{if(Gp(e,t))return!0;const n=Kp(e),r=Kp(t),i=n.length;if(i!==r.length)return!1;for(let e=0;e<i;++e)if(!Up.call(t,n[e]))return!1;for(let r=0;r<i;++r){const i=n[r];if(!zp(e[i],t[i]))return!1}return!0}case"[object Error]":return e.name===t.name&&e.message===t.message;case"[object Number]":if(e!=e)return t!=t;case"[object Boolean]":case"[object Date]":return+e===+t;case"[object RegExp]":case"[object String]":return e==`${t}`;case"[object Map]":case"[object Set]":{if(e.size!==t.size)return!1;if(Gp(e,t))return!0;const r=e.entries(),i="[object Map]"===n;for(;;){const e=r.next();if(e.done)break;const[n,o]=e.value;if(!t.has(n))return!1;if(i&&!zp(o,t.get(n)))return!1}return!0}case"[object Uint16Array]":case"[object Uint8Array]":case"[object Uint32Array]":case"[object Int32Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object ArrayBuffer]":e=new Uint8Array(e),t=new Uint8Array(t);case"[object DataView]":{let n=e.byteLength;if(n===t.byteLength)for(;n--&&e[n]===t[n];);return-1===n}case"[object AsyncFunction]":case"[object GeneratorFunction]":case"[object AsyncGeneratorFunction]":case"[object Function]":{const n=Lp.call(e);return n===Lp.call(t)&&!function(e,t){const n=e.length-t.length;return n>=0&&e.indexOf(t,n)===n}(n,Qp)}}return!1}function Kp(e){return Object.keys(e).filter(Wp,e)}function Wp(e){return void 0!==this[e]}const Qp="{ [native code] }";function Gp(e,t){let n=qp.get(e);if(n){if(n.has(t))return!0}else qp.set(e,n=new Set);return n.add(t),!1}function Hp(e){return e}var Jp=function(){function e(e,t){void 0===t&&(t=Object.create(null)),this.resultCache=jd?new WeakSet:new Set,this.transform=e,t.getCacheKey&&(this.getCacheKey=t.getCacheKey),this.cached=!1!==t.cache,this.resetCache()}return e.prototype.getCacheKey=function(e){return[e]},e.identity=function(){return new e(Hp,{cache:!1})},e.split=function(t,n,r){return void 0===r&&(r=e.identity()),Object.assign(new e(function(e){return(t(e)?n:r).transformDocument(e)},{cache:!1}),{left:n,right:r})},e.prototype.resetCache=function(){var t=this;if(this.cached){var n=new Af(Nd);this.performWork=dd(e.prototype.performWork.bind(this),{makeCacheKey:function(e){var r=t.getCacheKey(e);if(r)return Vl(Array.isArray(r),105),n.lookupArray(r)},max:Wh["documentTransform.cache"],cache:Fh})}},e.prototype.performWork=function(e){return vf(e),this.transform(e)},e.prototype.transformDocument=function(e){if(this.resultCache.has(e))return e;var t=this.performWork(e);return this.resultCache.add(t),t},e.prototype.concat=function(t){var n=this;return Object.assign(new e(function(e){return t.transformDocument(n.transformDocument(e))},{cache:!1}),{left:this,right:t})},e}();function Zp(e,t,n){return new mh(function(r){var i={then:function(e){return new Promise(function(t){return t(e())})}};function o(e,t){return function(n){if(e){var o=function(){return r.closed?0:e(n)};i=i.then(o,o).then(function(e){return r.next(e)},function(e){return r.error(e)})}else r[t](n)}}var s={next:o(t,"next"),error:o(n,"error"),complete:function(){i.then(function(){return r.complete()})}},a=e.subscribe(s);return function(){return a.unsubscribe()}})}function Yp(e){return Kd(Xp(e))}function Xp(e){var t=Kd(e.errors)?e.errors.slice(0):[];return Zd(e)&&Kd(e.incremental)&&e.incremental.forEach(function(e){e.errors&&t.push.apply(t,e.errors)}),t}function ey(e,t,n){var r=[];e.forEach(function(e){return e[t]&&r.push(e)}),r.forEach(function(e){return e[t](n)})}function ty(e){function t(t){Object.defineProperty(e,t,{value:mh})}return Dd&&Symbol.species&&t(Symbol.species),t("@@species"),e}function ny(e){return e&&"function"==typeof e.then}var ry,iy=function(e){function t(t){var n=e.call(this,function(e){return n.addObserver(e),function(){return n.removeObserver(e)}})||this;return n.observers=new Set,n.promise=new Promise(function(e,t){n.resolve=e,n.reject=t}),n.handlers={next:function(e){null!==n.sub&&(n.latest=["next",e],n.notify("next",e),ey(n.observers,"next",e))},error:function(e){var t=n.sub;null!==t&&(t&&setTimeout(function(){return t.unsubscribe()}),n.sub=null,n.latest=["error",e],n.reject(e),n.notify("error",e),ey(n.observers,"error",e))},complete:function(){var e=n,t=e.sub,r=e.sources;if(null!==t){var i=(void 0===r?[]:r).shift();i?ny(i)?i.then(function(e){return n.sub=e.subscribe(n.handlers)},n.handlers.error):n.sub=i.subscribe(n.handlers):(t&&setTimeout(function(){return t.unsubscribe()}),n.sub=null,n.latest&&"next"===n.latest[0]?n.resolve(n.latest[1]):n.resolve(),n.notify("complete"),ey(n.observers,"complete"))}}},n.nextResultListeners=new Set,n.cancel=function(e){n.reject(e),n.sources=[],n.handlers.error(e)},n.promise.catch(function(e){}),"function"==typeof t&&(t=[new mh(t)]),ny(t)?t.then(function(e){return n.start(e)},n.handlers.error):n.start(t),n}return kl(t,e),t.prototype.start=function(e){void 0===this.sub&&(this.sources=Array.from(e),this.handlers.complete())},t.prototype.deliverLastMessage=function(e){if(this.latest){var t=this.latest[0],n=e[t];n&&n.call(e,this.latest[1]),null===this.sub&&"next"===t&&e.complete&&e.complete()}},t.prototype.addObserver=function(e){this.observers.has(e)||(this.deliverLastMessage(e),this.observers.add(e))},t.prototype.removeObserver=function(e){this.observers.delete(e)&&this.observers.size<1&&this.handlers.complete()},t.prototype.notify=function(e,t){var n=this.nextResultListeners;n.size&&(this.nextResultListeners=new Set,n.forEach(function(n){return n(e,t)}))},t.prototype.beforeNext=function(e){var t=!1;this.nextResultListeners.add(function(n,r){t||(t=!0,e(n,r))})},t}(mh);function oy(e){return!!e&&e<7}function sy(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Object.create(null);return e.forEach(function(e){e&&Object.keys(e).forEach(function(t){var r=e[t];void 0!==r&&(n[t]=r)})}),n}ty(iy),function(e){e[e.loading=1]="loading",e[e.setVariables=2]="setVariables",e[e.fetchMore=3]="fetchMore",e[e.refetch=4]="refetch",e[e.poll=6]="poll",e[e.ready=7]="ready",e[e.error=8]="error"}(ry||(ry={}));var ay=Object.prototype.toString;function uy(e){return cy(e)}function cy(e,t){switch(ay.call(e)){case"[object Array]":if((t=t||new Map).has(e))return t.get(e);var n=e.slice(0);return t.set(e,n),n.forEach(function(e,r){n[r]=cy(e,t)}),n;case"[object Object]":if((t=t||new Map).has(e))return t.get(e);var r=Object.create(Object.getPrototypeOf(e));return t.set(e,r),Object.keys(e).forEach(function(n){r[n]=cy(e[n],t)}),r;default:return e}}function ly(e,t,n,r){var i=t.data,o=Tl(t,["data"]),s=n.data,a=Tl(n,["data"]);return Vp(o,a)&&hy(_f(e).selectionSet,i,s,{fragmentMap:Ah(kf(e)),variables:r})}function hy(e,t,n,r){if(t===n)return!0;var i=new Set;return e.selections.every(function(e){if(i.has(e))return!0;if(i.add(e),!_d(e,r.variables))return!0;if(fy(e))return!0;if(bf(e)){var o=mf(e),s=t&&t[o],a=n&&n[o],u=e.selectionSet;if(!u)return Vp(s,a);var c=Array.isArray(s),l=Array.isArray(a);if(c!==l)return!1;if(c&&l){var h=s.length;if(a.length!==h)return!1;for(var f=0;f<h;++f)if(!hy(u,s[f],a[f],r))return!1;return!0}return hy(u,s,a,r)}var d=Nh(e,r.fragmentMap);return d?!!fy(d)||hy(d.selectionSet,t,n,r):void 0})}function fy(e){return!!e.directives&&e.directives.some(dy)}function dy(e){return"nonreactive"===e.name.value}var py=Object.assign,yy=Object.hasOwnProperty,my=function(e){function t(n){var r=n.queryManager,i=n.queryInfo,o=n.options,s=this,a=t.inactiveOnCreation.getValue();(s=e.call(this,function(e){s._getOrCreateQuery();try{var t=e._subscription._observer;t&&!t.error&&(t.error=gy)}catch(e){}var n=!s.observers.size;s.observers.add(e);var r=s.last;return r&&r.error?e.error&&e.error(r.error):r&&r.result&&e.next&&e.next(s.maskResult(r.result)),n&&s.reobserve().catch(function(){}),function(){s.observers.delete(e)&&!s.observers.size&&s.tearDownQuery()}})||this).observers=new Set,s.subscriptions=new Set,s.dirty=!1,s._getOrCreateQuery=function(){return a&&(r.queries.set(s.queryId,i),a=!1),s.queryManager.getOrCreateQuery(s.queryId)},s.queryInfo=i,s.queryManager=r,s.waitForOwnResult=vy(o.fetchPolicy),s.isTornDown=!1,s.subscribeToMore=s.subscribeToMore.bind(s),s.maskResult=s.maskResult.bind(s);var u=r.defaultOptions.watchQuery,c=(void 0===u?{}:u).fetchPolicy,l=void 0===c?"cache-first":c,h=o.fetchPolicy,f=void 0===h?l:h,d=o.initialFetchPolicy,p=void 0===d?"standby"===f?l:f:d;s.options=Sl(Sl({},o),{initialFetchPolicy:p,fetchPolicy:f}),s.queryId=i.queryId||r.generateQueryId();var y=wf(s.query);return s.queryName=y&&y.name&&y.name.value,s}return kl(t,e),Object.defineProperty(t.prototype,"query",{get:function(){return this.lastQuery||this.options.query},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"variables",{get:function(){return this.options.variables},enumerable:!1,configurable:!0}),t.prototype.result=function(){var e=this;return!1!==globalThis.__DEV__&&vd("observableQuery.result",function(){!1!==globalThis.__DEV__&&Vl.warn(23)}),new Promise(function(t,n){var r={next:function(n){t(n),e.observers.delete(r),e.observers.size||e.queryManager.removeQuery(e.queryId),setTimeout(function(){i.unsubscribe()},0)},error:n},i=e.subscribe(r)})},t.prototype.resetDiff=function(){this.queryInfo.resetDiff()},t.prototype.getCurrentFullResult=function(e){var t=this;void 0===e&&(e=!0);var n=gd("getLastResult",function(){return t.getLastResult(!0)}),r=this.queryInfo.networkStatus||n&&n.networkStatus||ry.ready,i=Sl(Sl({},n),{loading:oy(r),networkStatus:r}),o=this.options.fetchPolicy,s=void 0===o?"cache-first":o;if(vy(s)||this.queryManager.getDocumentInfo(this.query).hasForcedResolvers);else if(this.waitForOwnResult)this.queryInfo.updateWatch();else{var a=this.queryInfo.getDiff();(a.complete||this.options.returnPartialData)&&(i.data=a.result),$p(i.data,{})&&(i.data=void 0),a.complete?(delete i.partial,!a.complete||i.networkStatus!==ry.loading||"cache-first"!==s&&"cache-only"!==s||(i.networkStatus=ry.ready,i.loading=!1)):i.partial=!0,i.networkStatus===ry.ready&&(i.error||i.errors)&&(i.networkStatus=ry.error),!1===globalThis.__DEV__||a.complete||this.options.partialRefetch||i.loading||i.data||i.error||by(a.missing)}return e&&this.updateLastResult(i),i},t.prototype.getCurrentResult=function(e){return void 0===e&&(e=!0),this.maskResult(this.getCurrentFullResult(e))},t.prototype.isDifferentFromLastResult=function(e,t){if(!this.last)return!0;var n=this.queryManager.getDocumentInfo(this.query),r=this.queryManager.dataMasking,i=r?n.nonReactiveQuery:this.query;return(r||n.hasNonreactiveDirective?!ly(i,this.last.result,e,this.variables):!$p(this.last.result,e))||t&&!$p(this.last.variables,t)},t.prototype.getLast=function(e,t){var n=this.last;if(n&&n[e]&&(!t||$p(n.variables,this.variables)))return n[e]},t.prototype.getLastResult=function(e){return!1!==globalThis.__DEV__&&vd("getLastResult",function(){!1!==globalThis.__DEV__&&Vl.warn(24)}),this.getLast("result",e)},t.prototype.getLastError=function(e){return!1!==globalThis.__DEV__&&vd("getLastError",function(){!1!==globalThis.__DEV__&&Vl.warn(25)}),this.getLast("error",e)},t.prototype.resetLastResults=function(){!1!==globalThis.__DEV__&&vd("resetLastResults",function(){!1!==globalThis.__DEV__&&Vl.warn(26)}),delete this.last,this.isTornDown=!1},t.prototype.resetQueryStoreErrors=function(){!1!==globalThis.__DEV__&&!1!==globalThis.__DEV__&&Vl.warn(27),this.queryManager.resetErrors(this.queryId)},t.prototype.refetch=function(e){var t,n={pollInterval:0},r=this.options.fetchPolicy;if(n.fetchPolicy="no-cache"===r?"no-cache":"network-only",!1!==globalThis.__DEV__&&e&&yy.call(e,"variables")){var i=Sf(this.query),o=i.variableDefinitions;o&&o.some(function(e){return"variables"===e.variable.name.value})||!1!==globalThis.__DEV__&&Vl.warn(28,e,(null===(t=i.name)||void 0===t?void 0:t.value)||i)}return e&&!$p(this.options.variables,e)&&(n.variables=this.options.variables=Sl(Sl({},this.options.variables),e)),this.queryInfo.resetLastWrite(),this.reobserve(n,ry.refetch)},t.prototype.fetchMore=function(e){var t=this,n=Sl(Sl({},e.query?e:Sl(Sl(Sl(Sl({},this.options),{query:this.options.query}),e),{variables:Sl(Sl({},this.options.variables),e.variables)})),{fetchPolicy:"no-cache"});n.query=this.transformDocument(n.query);var r=this.queryManager.generateQueryId();this.lastQuery=e.query?this.transformDocument(this.options.query):n.query;var i=this.queryInfo,o=i.networkStatus;i.networkStatus=ry.fetchMore,n.notifyOnNetworkStatusChange&&this.observe();var s=new Set,a=null==e?void 0:e.updateQuery,u="no-cache"!==this.options.fetchPolicy;return u||Vl(a,29),this.queryManager.fetchQuery(r,n,ry.fetchMore).then(function(c){if(t.queryManager.removeQuery(r),i.networkStatus===ry.fetchMore&&(i.networkStatus=o),u)t.queryManager.cache.batch({update:function(r){var i=e.updateQuery;i?r.updateQuery({query:t.query,variables:t.variables,returnPartialData:!0,optimistic:!1},function(e){return i(e,{fetchMoreResult:c.data,variables:n.variables})}):r.writeQuery({query:n.query,variables:n.variables,data:c.data})},onWatchUpdated:function(e){s.add(e.query)}});else{var l=t.getLast("result"),h=a(l.data,{fetchMoreResult:c.data,variables:n.variables});t.reportResult(Sl(Sl({},l),{networkStatus:o,loading:oy(o),data:h}),t.variables)}return t.maskResult(c)}).finally(function(){u&&!s.has(t.query)&&t.reobserveCacheFirst()})},t.prototype.subscribeToMore=function(e){var t=this,n=this.queryManager.startGraphQLSubscription({query:e.document,variables:e.variables,context:e.context}).subscribe({next:function(n){var r=e.updateQuery;r&&t.updateQuery(function(e,t){return r(e,Sl({subscriptionData:n},t))})},error:function(t){e.onError?e.onError(t):!1!==globalThis.__DEV__&&Vl.error(30,t)}});return this.subscriptions.add(n),function(){t.subscriptions.delete(n)&&n.unsubscribe()}},t.prototype.setOptions=function(e){return!1!==globalThis.__DEV__&&(bd(e,"canonizeResults","setOptions"),vd("setOptions",function(){!1!==globalThis.__DEV__&&Vl.warn(31)})),this.reobserve(e)},t.prototype.silentSetOptions=function(e){var t=sy(this.options,e||{});py(this.options,t)},t.prototype.setVariables=function(e){var t=this;return $p(this.variables,e)?this.observers.size?gd("observableQuery.result",function(){return t.result()}):Promise.resolve():(this.options.variables=e,this.observers.size?this.reobserve({fetchPolicy:this.options.initialFetchPolicy,variables:e},ry.setVariables):Promise.resolve())},t.prototype.updateQuery=function(e){var t=this.queryManager,n=t.cache.diff({query:this.options.query,variables:this.variables,returnPartialData:!0,optimistic:!1}),r=n.result,i=n.complete,o=e(r,{variables:this.variables,complete:!!i,previousData:r});o&&(t.cache.writeQuery({query:this.options.query,data:o,variables:this.variables}),t.broadcastQueries())},t.prototype.startPolling=function(e){this.options.pollInterval=e,this.updatePolling()},t.prototype.stopPolling=function(){this.options.pollInterval=0,this.updatePolling()},t.prototype.applyNextFetchPolicy=function(e,t){if(t.nextFetchPolicy){var n=t.fetchPolicy,r=void 0===n?"cache-first":n,i=t.initialFetchPolicy,o=void 0===i?r:i;"standby"===r||("function"==typeof t.nextFetchPolicy?t.fetchPolicy=t.nextFetchPolicy(r,{reason:e,options:t,observable:this,initialFetchPolicy:o}):t.fetchPolicy="variables-changed"===e?o:t.nextFetchPolicy)}return t.fetchPolicy},t.prototype.fetch=function(e,t,n){var r=this._getOrCreateQuery();return r.setObservableQuery(this),this.queryManager.fetchConcastWithInfo(r,e,t,n)},t.prototype.updatePolling=function(){var e=this;if(!this.queryManager.ssrMode){var t=this.pollingInfo,n=this.options.pollInterval;if(n&&this.hasObservers()){if(!t||t.interval!==n){Vl(n,32),(t||(this.pollingInfo={})).interval=n;var r=function(){var t,n;e.pollingInfo&&(oy(e.queryInfo.networkStatus)||(null===(n=(t=e.options).skipPollAttempt)||void 0===n?void 0:n.call(t))?i():e.reobserve({fetchPolicy:"no-cache"===e.options.initialFetchPolicy?"no-cache":"network-only"},ry.poll).then(i,i))},i=function(){var t=e.pollingInfo;t&&(clearTimeout(t.timeout),t.timeout=setTimeout(r,t.interval))};i()}}else t&&(clearTimeout(t.timeout),delete this.pollingInfo)}},t.prototype.updateLastResult=function(e,t){var n=this;void 0===t&&(t=this.variables);var r=gd("getLastError",function(){return n.getLastError()});return r&&this.last&&!$p(t,this.last.variables)&&(r=void 0),this.last=Sl({result:this.queryManager.assumeImmutableResults?e:uy(e),variables:t},r?{error:r}:null)},t.prototype.reobserveAsConcast=function(e,t){var n=this;this.isTornDown=!1;var r=t===ry.refetch||t===ry.fetchMore||t===ry.poll,i=this.options.variables,o=this.options.fetchPolicy,s=sy(this.options,e||{}),a=r?s:py(this.options,s),u=this.transformDocument(a.query);this.lastQuery=u,r||(this.updatePolling(),!e||!e.variables||$p(e.variables,i)||"standby"===a.fetchPolicy||a.fetchPolicy!==o&&"function"!=typeof a.nextFetchPolicy||(this.applyNextFetchPolicy("variables-changed",a),void 0===t&&(t=ry.setVariables))),this.waitForOwnResult&&(this.waitForOwnResult=vy(a.fetchPolicy));var c=function(){n.concast===f&&(n.waitForOwnResult=!1)},l=a.variables&&Sl({},a.variables),h=this.fetch(a,t,u),f=h.concast,d=h.fromLink,p={next:function(e){$p(n.variables,l)&&(c(),n.reportResult(e,l))},error:function(e){$p(n.variables,l)&&($d(e)||(e=new Vd({networkError:e})),c(),n.reportError(e,l))}};return r||!d&&this.concast||(this.concast&&this.observer&&this.concast.removeObserver(this.observer),this.concast=f,this.observer=p),f.addObserver(p),f},t.prototype.reobserve=function(e,t){return function(e){return e.catch(function(){}),e}(this.reobserveAsConcast(e,t).promise.then(this.maskResult))},t.prototype.resubscribeAfterError=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=this.last;gd("resetLastResults",function(){return e.resetLastResults()});var i=this.subscribe.apply(this,t);return this.last=r,i},t.prototype.observe=function(){this.reportResult(this.getCurrentFullResult(!1),this.variables)},t.prototype.reportResult=function(e,t){var n=this,r=gd("getLastError",function(){return n.getLastError()}),i=this.isDifferentFromLastResult(e,t);(r||!e.partial||this.options.returnPartialData)&&this.updateLastResult(e,t),(r||i)&&ey(this.observers,"next",this.maskResult(e))},t.prototype.reportError=function(e,t){var n=this,r=Sl(Sl({},gd("getLastResult",function(){return n.getLastResult()})),{error:e,errors:e.graphQLErrors,networkStatus:ry.error,loading:!1});this.updateLastResult(r,t),ey(this.observers,"error",this.last.error=e)},t.prototype.hasObservers=function(){return this.observers.size>0},t.prototype.tearDownQuery=function(){this.isTornDown||(this.concast&&this.observer&&(this.concast.removeObserver(this.observer),delete this.concast,delete this.observer),this.stopPolling(),this.subscriptions.forEach(function(e){return e.unsubscribe()}),this.subscriptions.clear(),this.queryManager.stopQuery(this.queryId),this.observers.clear(),this.isTornDown=!0)},t.prototype.transformDocument=function(e){return this.queryManager.transform(e)},t.prototype.maskResult=function(e){return e&&"data"in e?Sl(Sl({},e),{data:this.queryManager.maskOperation({document:this.query,data:e.data,fetchPolicy:this.options.fetchPolicy,id:this.queryId})}):e},t.prototype.resetNotifications=function(){this.cancelNotifyTimeout(),this.dirty=!1},t.prototype.cancelNotifyTimeout=function(){this.notifyTimeout&&(clearTimeout(this.notifyTimeout),this.notifyTimeout=void 0)},t.prototype.scheduleNotify=function(){var e=this;this.dirty||(this.dirty=!0,this.notifyTimeout||(this.notifyTimeout=setTimeout(function(){return e.notify()},0)))},t.prototype.notify=function(){(this.cancelNotifyTimeout(),this.dirty)&&("cache-only"!=this.options.fetchPolicy&&"cache-and-network"!=this.options.fetchPolicy&&oy(this.queryInfo.networkStatus)||(this.queryInfo.getDiff().fromOptimisticTransaction?this.observe():this.reobserveCacheFirst()));this.dirty=!1},t.prototype.reobserveCacheFirst=function(){var e=this.options,t=e.fetchPolicy,n=e.nextFetchPolicy;return"cache-and-network"===t||"network-only"===t?this.reobserve({fetchPolicy:"cache-first",nextFetchPolicy:function(e,r){return this.nextFetchPolicy=n,"function"==typeof this.nextFetchPolicy?this.nextFetchPolicy(e,r):t}}):this.reobserve()},t.inactiveOnCreation=new Ff,t}(mh);function gy(e){!1!==globalThis.__DEV__&&Vl.error(33,e.message,e.stack)}function by(e){!1!==globalThis.__DEV__&&e&&!1!==globalThis.__DEV__&&Vl.debug(34,e)}function vy(e){return"network-only"===e||"no-cache"===e||"standby"===e}ty(my);var wy=new(Nd?WeakMap:Map);function Ey(e,t){var n=e[t];"function"==typeof n&&(e[t]=function(){return wy.set(e,(wy.get(e)+1)%1e15),n.apply(this,arguments)})}var ky=function(){function e(e,t){void 0===t&&(t=e.generateQueryId()),this.queryId=t,this.document=null,this.lastRequestId=1,this.stopped=!1,this.observableQuery=null;var n=this.cache=e.cache;wy.has(n)||(wy.set(n,0),Ey(n,"evict"),Ey(n,"modify"),Ey(n,"reset"))}return e.prototype.init=function(e){var t=e.networkStatus||ry.loading;return this.variables&&this.networkStatus!==ry.loading&&!$p(this.variables,e.variables)&&(t=ry.setVariables),$p(e.variables,this.variables)||(this.lastDiff=void 0,this.cancel()),Object.assign(this,{document:e.document,variables:e.variables,networkError:null,graphQLErrors:this.graphQLErrors||[],networkStatus:t}),e.observableQuery&&this.setObservableQuery(e.observableQuery),e.lastRequestId&&(this.lastRequestId=e.lastRequestId),this},e.prototype.resetDiff=function(){this.lastDiff=void 0},e.prototype.getDiff=function(){var e=this,t=this.getDiffOptions();if(this.lastDiff&&$p(t,this.lastDiff.options))return this.lastDiff.diff;this.updateWatch(this.variables);var n=this.observableQuery;if(n&&"no-cache"===n.options.fetchPolicy)return{complete:!1};var r=gd("canonizeResults",function(){return e.cache.diff(t)});return this.updateLastDiff(r,t),r},e.prototype.updateLastDiff=function(e,t){this.lastDiff=e?{diff:e,options:t||this.getDiffOptions()}:void 0},e.prototype.getDiffOptions=function(e){var t;return void 0===e&&(e=this.variables),{query:this.document,variables:e,returnPartialData:!0,optimistic:!0,canonizeResults:null===(t=this.observableQuery)||void 0===t?void 0:t.options.canonizeResults}},e.prototype.setDiff=function(e){var t,n=this,r=this.lastDiff&&this.lastDiff.diff;e&&!e.complete&&gd("getLastError",function(){var e;return null===(e=n.observableQuery)||void 0===e?void 0:e.getLastError()})||(this.updateLastDiff(e),$p(r&&r.result,e&&e.result)||null===(t=this.observableQuery)||void 0===t||t.scheduleNotify())},e.prototype.setObservableQuery=function(e){e!==this.observableQuery&&(this.observableQuery=e,e&&(e.queryInfo=this))},e.prototype.stop=function(){var e;if(!this.stopped){this.stopped=!0,null===(e=this.observableQuery)||void 0===e||e.resetNotifications(),this.cancel();var t=this.observableQuery;t&&t.stopPolling()}},e.prototype.cancel=function(){var e;null===(e=this.cancelWatch)||void 0===e||e.call(this),this.cancelWatch=void 0},e.prototype.updateWatch=function(e){var t=this;void 0===e&&(e=this.variables);var n=this.observableQuery;if(!n||"no-cache"!==n.options.fetchPolicy){var r=Sl(Sl({},this.getDiffOptions(e)),{watcher:this,callback:function(e){return t.setDiff(e)}});this.lastWatch&&$p(r,this.lastWatch)||(this.cancel(),this.cancelWatch=this.cache.watch(this.lastWatch=r))}},e.prototype.resetLastWrite=function(){this.lastWrite=void 0},e.prototype.shouldWrite=function(e,t){var n=this.lastWrite;return!(n&&n.dmCount===wy.get(this.cache)&&$p(t,n.variables)&&$p(e.data,n.result.data))},e.prototype.markResult=function(e,t,n,r){var i,o=this,s=new Jd,a=Kd(e.errors)?e.errors.slice(0):[];if(null===(i=this.observableQuery)||void 0===i||i.resetNotifications(),"incremental"in e&&Kd(e.incremental)){var u=Xd(this.getDiff().result,e);e.data=u}else if("hasNext"in e&&e.hasNext){var c=this.getDiff();e.data=s.merge(c.result,e.data)}this.graphQLErrors=a,"no-cache"===n.fetchPolicy?this.updateLastDiff({result:e.data,complete:!0},this.getDiffOptions(n.variables)):0!==r&&(Sy(e,n.errorPolicy)?this.cache.performTransaction(function(i){if(o.shouldWrite(e,n.variables))i.writeQuery({query:t,data:e.data,variables:n.variables,overwrite:1===r}),o.lastWrite={result:e,variables:n.variables,dmCount:wy.get(o.cache)};else if(o.lastDiff&&o.lastDiff.diff.complete)return void(e.data=o.lastDiff.diff.result);var s=o.getDiffOptions(n.variables),a=gd("canonizeResults",function(){return i.diff(s)});!o.stopped&&$p(o.variables,n.variables)&&o.updateWatch(n.variables),o.updateLastDiff(a,s),a.complete&&(e.data=a.result)}):this.lastWrite=void 0)},e.prototype.markReady=function(){return this.networkError=null,this.networkStatus=ry.ready},e.prototype.markError=function(e){var t;return this.networkStatus=ry.error,this.lastWrite=void 0,null===(t=this.observableQuery)||void 0===t||t.resetNotifications(),e.graphQLErrors&&(this.graphQLErrors=e.graphQLErrors),e.networkError&&(this.networkError=e.networkError),e},e}();function Sy(e,t){void 0===t&&(t="none");var n="ignore"===t||"all"===t,r=!Yp(e);return!r&&n&&e.data&&(r=!0),r}function Ty(e){var t=new Set([e]);return t.forEach(function(e){gh(e)&&function(e){if(!1!==globalThis.__DEV__&&!Object.isFrozen(e))try{Object.freeze(e)}catch(e){if(e instanceof TypeError)return null;throw e}return e}(e)===e&&Object.getOwnPropertyNames(e).forEach(function(n){gh(e[n])&&t.add(e[n])})}),e}function _y(e){return!1!==globalThis.__DEV__&&Ty(e),e}var xy=Nd?WeakMap:Map,Oy=jd?WeakSet:Set,Iy=new Ff,Cy=!1;function My(){Cy||(Cy=!0,!1!==globalThis.__DEV__&&Vl.warn(64))}function Ay(e,t,n){return Iy.withValue(!0,function(){var r=Ny(e,t,n,!1);return Object.isFrozen(e)&&_y(r),r})}function Ny(e,t,n,r,i){var o,s=n.knownChanged,a=function(e,t){if(t.has(e))return t.get(e);var n=Array.isArray(e)?[]:Object.create(null);return t.set(e,n),n}(e,n.mutableTargets);if(Array.isArray(e)){for(var u=0,c=Array.from(e.entries());u<c.length;u++){var l=c[u],h=l[0],f=l[1];if(null!==f){var d=Ny(f,t,n,r,!1!==globalThis.__DEV__?"".concat(i||"","[").concat(h,"]"):void 0);s.has(d)&&s.add(a),a[h]=d}else a[h]=null}return s.has(a)?a:e}for(var p=0,y=t.selections;p<y.length;p++){var m=y[p],g=void 0;if(r&&s.add(a),m.kind===Td.FIELD){var b=mf(m),v=m.selectionSet;if(void 0===(g=a[b]||e[b]))continue;if(v&&null!==g){d=Ny(e[b],v,n,r,!1!==globalThis.__DEV__?"".concat(i||"",".").concat(b):void 0);s.has(d)&&(g=d)}!1===globalThis.__DEV__&&(a[b]=g),!1!==globalThis.__DEV__&&(r&&"__typename"!==b&&!(null===(o=Object.getOwnPropertyDescriptor(a,b))||void 0===o?void 0:o.value)?Object.defineProperty(a,b,jy(b,g,i||"",n.operationName,n.operationType)):(delete a[b],a[b]=g))}if(m.kind!==Td.INLINE_FRAGMENT||m.typeCondition&&!n.cache.fragmentMatches(m,e.__typename)||(g=Ny(e,m.selectionSet,n,r,i)),m.kind===Td.FRAGMENT_SPREAD){var w=m.name.value,E=n.fragmentMap[w]||(n.fragmentMap[w]=n.cache.lookupFragment(w));Vl(E,59,w);var k=Id(m);"mask"!==k&&(g=Ny(e,E.selectionSet,n,"migrate"===k,i))}s.has(g)&&s.add(a)}return"__typename"in e&&!("__typename"in a)&&(a.__typename=e.__typename),Object.keys(a).length!==Object.keys(e).length&&s.add(a),s.has(a)?a:e}function jy(e,t,n,r,i){var o=function(){return Iy.getValue()||(!1!==globalThis.__DEV__&&Vl.warn(60,r?"".concat(i," '").concat(r,"'"):"anonymous ".concat(i),"".concat(n,".").concat(e).replace(/^\./,"")),o=function(){return t}),t};return{get:function(){return o()},set:function(e){o=function(){return e}},enumerable:!0,configurable:!0}}function Dy(e,t,n,r){if(!n.fragmentMatches)return!1!==globalThis.__DEV__&&My(),e;var i=t.definitions.filter(function(e){return e.kind===Td.FRAGMENT_DEFINITION});void 0===r&&(Vl(1===i.length,61,i.length),r=i[0].name.value);var o=i.find(function(e){return e.name.value===r});return Vl(!!o,62,r),null==e||Vp(e,{})?e:Ay(e,o.selectionSet,{operationType:"fragment",operationName:o.name.value,fragmentMap:Ah(kf(t)),cache:n,mutableTargets:new xy,knownChanged:new Oy})}var Ry=Object.prototype.hasOwnProperty,Py=Object.create(null),By=function(){function e(e){var t=this;this.clientAwareness={},this.queries=new Map,this.fetchCancelFns=new Map,this.transformCache=new Vh(Wh["queryManager.getDocumentInfo"]||2e3),this.queryIdCounter=1,this.requestIdCounter=1,this.mutationIdCounter=1,this.inFlightLinkObservables=new Af(!1),this.noCacheWarningsByQueryId=new Set;var n=new Jp(function(e){return t.cache.transformDocument(e)},{cache:!1});this.cache=e.cache,this.link=e.link,this.defaultOptions=e.defaultOptions,this.queryDeduplication=e.queryDeduplication,this.clientAwareness=e.clientAwareness,this.localState=e.localState,this.ssrMode=e.ssrMode,this.assumeImmutableResults=e.assumeImmutableResults,this.dataMasking=e.dataMasking;var r=e.documentTransform;this.documentTransform=r?n.concat(r).concat(n):n,this.defaultContext=e.defaultContext||Object.create(null),(this.onBroadcast=e.onBroadcast)&&(this.mutationStore=Object.create(null))}return e.prototype.stop=function(){var e=this;this.queries.forEach(function(t,n){e.stopQueryNoBroadcast(n)}),this.cancelPendingFetches(zl(35))},e.prototype.cancelPendingFetches=function(e){this.fetchCancelFns.forEach(function(t){return t(e)}),this.fetchCancelFns.clear()},e.prototype.mutate=function(e){return _l(this,arguments,void 0,function(e){var t,n,r,i,o,s,a,u=e.mutation,c=e.variables,l=e.optimisticResponse,h=e.updateQueries,f=e.refetchQueries,d=void 0===f?[]:f,p=e.awaitRefetchQueries,y=void 0!==p&&p,m=e.update,g=e.onQueryUpdated,b=e.fetchPolicy,v=void 0===b?(null===(s=this.defaultOptions.mutate)||void 0===s?void 0:s.fetchPolicy)||"network-only":b,w=e.errorPolicy,E=void 0===w?(null===(a=this.defaultOptions.mutate)||void 0===a?void 0:a.errorPolicy)||"none":w,k=e.keepRootFields,S=e.context;return xl(this,function(e){switch(e.label){case 0:return Vl(u,36),Vl("network-only"===v||"no-cache"===v,37),t=this.generateMutationId(),u=this.cache.transformForLink(this.transform(u)),n=this.getDocumentInfo(u).hasClientExports,c=this.getVariables(u,c),n?[4,this.localState.addExportedVariables(u,c,S)]:[3,2];case 1:c=e.sent(),e.label=2;case 2:return r=this.mutationStore&&(this.mutationStore[t]={mutation:u,variables:c,loading:!0,error:null}),i=l&&this.markMutationOptimistic(l,{mutationId:t,document:u,variables:c,fetchPolicy:v,errorPolicy:E,context:S,updateQueries:h,update:m,keepRootFields:k}),this.broadcastQueries(),o=this,[2,new Promise(function(e,n){return Zp(o.getObservableFromLink(u,Sl(Sl({},S),{optimisticResponse:i?l:void 0}),c,{},!1),function(e){if(Yp(e)&&"none"===E)throw new Vd({graphQLErrors:Xp(e)});r&&(r.loading=!1,r.error=null);var n=Sl({},e);return"function"==typeof d&&(d=d(n)),"ignore"===E&&Yp(n)&&delete n.errors,o.markMutationResult({mutationId:t,result:n,document:u,variables:c,fetchPolicy:v,errorPolicy:E,context:S,update:m,updateQueries:h,awaitRefetchQueries:y,refetchQueries:d,removeOptimistic:i?t:void 0,onQueryUpdated:g,keepRootFields:k})}).subscribe({next:function(n){o.broadcastQueries(),"hasNext"in n&&!1!==n.hasNext||e(Sl(Sl({},n),{data:o.maskOperation({document:u,data:n.data,fetchPolicy:v,id:t})}))},error:function(e){r&&(r.loading=!1,r.error=e),i&&o.cache.removeOptimistic(t),o.broadcastQueries(),n(e instanceof Vd?e:new Vd({networkError:e}))}})})]}})})},e.prototype.markMutationResult=function(e,t){var n=this;void 0===t&&(t=this.cache);var r=e.result,i=[],o="no-cache"===e.fetchPolicy;if(!o&&Sy(r,e.errorPolicy)){if(Zd(r)||i.push({result:r.data,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}),Zd(r)&&Kd(r.incremental)){var s=t.diff({id:"ROOT_MUTATION",query:this.getDocumentInfo(e.document).asQuery,variables:e.variables,optimistic:!1,returnPartialData:!0}),a=void 0;s.result&&(a=Xd(s.result,r)),void 0!==a&&(r.data=a,i.push({result:a,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}))}var u=e.updateQueries;u&&this.queries.forEach(function(e,o){var s=e.observableQuery,a=s&&s.queryName;if(a&&Ry.call(u,a)){var c=u[a],l=n.queries.get(o),h=l.document,f=l.variables,d=t.diff({query:h,variables:f,returnPartialData:!0,optimistic:!1}),p=d.result;if(d.complete&&p){var y=c(p,{mutationResult:r,queryName:h&&Ef(h)||void 0,queryVariables:f});y&&i.push({result:y,dataId:"ROOT_QUERY",query:h,variables:f})}}})}if(i.length>0||(e.refetchQueries||"").length>0||e.update||e.onQueryUpdated||e.removeOptimistic){var c=[];if(this.refetchQueries({updateCache:function(t){o||i.forEach(function(e){return t.write(e)});var s=e.update,a=!function(e){return Zd(e)||function(e){return"hasNext"in e&&"data"in e}(e)}(r)||Zd(r)&&!r.hasNext;if(s){if(!o){var u=t.diff({id:"ROOT_MUTATION",query:n.getDocumentInfo(e.document).asQuery,variables:e.variables,optimistic:!1,returnPartialData:!0});u.complete&&("incremental"in(r=Sl(Sl({},r),{data:u.result}))&&delete r.incremental,"hasNext"in r&&delete r.hasNext)}a&&s(t,r,{context:e.context,variables:e.variables})}o||e.keepRootFields||!a||t.modify({id:"ROOT_MUTATION",fields:function(e,t){var n=t.fieldName,r=t.DELETE;return"__typename"===n?e:r}})},include:e.refetchQueries,optimistic:!1,removeOptimistic:e.removeOptimistic,onQueryUpdated:e.onQueryUpdated||null}).forEach(function(e){return c.push(e)}),e.awaitRefetchQueries||e.onQueryUpdated)return Promise.all(c).then(function(){return r})}return Promise.resolve(r)},e.prototype.markMutationOptimistic=function(e,t){var n=this,r="function"==typeof e?e(t.variables,{IGNORE:Py}):e;return r!==Py&&(this.cache.recordOptimisticTransaction(function(e){try{n.markMutationResult(Sl(Sl({},t),{result:{data:r}}),e)}catch(e){!1!==globalThis.__DEV__&&Vl.error(e)}},t.mutationId),!0)},e.prototype.fetchQuery=function(e,t,n){return this.fetchConcastWithInfo(this.getOrCreateQuery(e),t,n).concast.promise},e.prototype.getQueryStore=function(){var e=Object.create(null);return this.queries.forEach(function(t,n){e[n]={variables:t.variables,networkStatus:t.networkStatus,networkError:t.networkError,graphQLErrors:t.graphQLErrors}}),e},e.prototype.resetErrors=function(e){var t=this.queries.get(e);t&&(t.networkError=void 0,t.graphQLErrors=[])},e.prototype.transform=function(e){return this.documentTransform.transformDocument(e)},e.prototype.getDocumentInfo=function(e){var t=this.transformCache;if(!t.has(e)){var n={hasClientExports:Od(e),hasForcedResolvers:this.localState.shouldForceResolvers(e),hasNonreactiveDirective:xd(["nonreactive"],e),nonReactiveQuery:Ap(e),clientQuery:this.localState.clientQuery(e),serverQuery:Op([{name:"client",remove:!0},{name:"connection"},{name:"nonreactive"},{name:"unmask"}],e),defaultVars:xf(wf(e)),asQuery:Sl(Sl({},e),{definitions:e.definitions.map(function(e){return"OperationDefinition"===e.kind&&"query"!==e.operation?Sl(Sl({},e),{operation:"query"}):e})})};t.set(e,n)}return t.get(e)},e.prototype.getVariables=function(e,t){return Sl(Sl({},this.getDocumentInfo(e).defaultVars),t)},e.prototype.watchQuery=function(e){var t=this.transform(e.query);void 0===(e=Sl(Sl({},e),{variables:this.getVariables(t,e.variables)})).notifyOnNetworkStatusChange&&(e.notifyOnNetworkStatusChange=!1);var n=new ky(this),r=new my({queryManager:this,queryInfo:n,options:e});return r.lastQuery=t,my.inactiveOnCreation.getValue()||this.queries.set(r.queryId,n),n.init({document:t,observableQuery:r,variables:r.variables}),r},e.prototype.query=function(e,t){var n=this;void 0===t&&(t=this.generateQueryId()),Vl(e.query,38),Vl("Document"===e.query.kind,39),Vl(!e.returnPartialData,40),Vl(!e.pollInterval,41);var r=this.transform(e.query);return this.fetchQuery(t,Sl(Sl({},e),{query:r})).then(function(i){return i&&Sl(Sl({},i),{data:n.maskOperation({document:r,data:i.data,fetchPolicy:e.fetchPolicy,id:t})})}).finally(function(){return n.stopQuery(t)})},e.prototype.generateQueryId=function(){return String(this.queryIdCounter++)},e.prototype.generateRequestId=function(){return this.requestIdCounter++},e.prototype.generateMutationId=function(){return String(this.mutationIdCounter++)},e.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryInStoreNoBroadcast=function(e){var t=this.queries.get(e);t&&t.stop()},e.prototype.clearStore=function(e){return void 0===e&&(e={discardWatches:!0}),this.cancelPendingFetches(zl(42)),this.queries.forEach(function(e){e.observableQuery?e.networkStatus=ry.loading:e.stop()}),this.mutationStore&&(this.mutationStore=Object.create(null)),this.cache.reset(e)},e.prototype.getObservableQueries=function(e){var t=this;void 0===e&&(e="active");var n=new Map,r=new Map,i=new Map,o=new Set;return Array.isArray(e)&&e.forEach(function(e){if("string"==typeof e)r.set(e,e),i.set(e,!1);else if(function(e){return gh(e)&&"Document"===e.kind&&Array.isArray(e.definitions)}(e)){var n=mp(t.transform(e));r.set(n,Ef(e)),i.set(n,!1)}else gh(e)&&e.query&&o.add(e)}),this.queries.forEach(function(t,r){var o=t.observableQuery,s=t.document;if(o){if("all"===e)return void n.set(r,o);var a=o.queryName;if("standby"===o.options.fetchPolicy||"active"===e&&!o.hasObservers())return;("active"===e||a&&i.has(a)||s&&i.has(mp(s)))&&(n.set(r,o),a&&i.set(a,!0),s&&i.set(mp(s),!0))}}),o.size&&o.forEach(function(e){var r=Ll("legacyOneTimeQuery"),i=t.getOrCreateQuery(r).init({document:e.query,variables:e.variables}),o=new my({queryManager:t,queryInfo:i,options:Sl(Sl({},e),{fetchPolicy:"network-only"})});Vl(o.queryId===r),i.setObservableQuery(o),n.set(r,o)}),!1!==globalThis.__DEV__&&i.size&&i.forEach(function(e,t){if(!e){var n=r.get(t);n?!1!==globalThis.__DEV__&&Vl.warn(43,n):!1!==globalThis.__DEV__&&Vl.warn(44)}}),n},e.prototype.reFetchObservableQueries=function(e){var t=this;void 0===e&&(e=!1);var n=[];return this.getObservableQueries(e?"all":"active").forEach(function(r,i){var o=r.options.fetchPolicy;gd("resetLastResults",function(){return r.resetLastResults()}),(e||"standby"!==o&&"cache-only"!==o)&&n.push(r.refetch()),(t.queries.get(i)||r.queryInfo).setDiff(null)}),this.broadcastQueries(),Promise.all(n)},e.prototype.startGraphQLSubscription=function(e){var t=this,n=e.query,r=e.variables,i=e.fetchPolicy,o=e.errorPolicy,s=void 0===o?"none":o,a=e.context,u=void 0===a?{}:a,c=e.extensions,l=void 0===c?{}:c;n=this.transform(n),r=this.getVariables(n,r);var h=function(e){return t.getObservableFromLink(n,u,e,l).map(function(r){"no-cache"!==i&&(Sy(r,s)&&t.cache.write({query:n,result:r.data,dataId:"ROOT_SUBSCRIPTION",variables:e}),t.broadcastQueries());var o=Yp(r),a=qd(r);if(o||a){var u={};if(o&&(u.graphQLErrors=r.errors),a&&(u.protocolErrors=r.extensions[Ld]),"none"===s||a)throw new Vd(u)}return"ignore"===s&&delete r.errors,r})};if(this.getDocumentInfo(n).hasClientExports){var f=this.localState.addExportedVariables(n,r,u).then(h);return new mh(function(e){var t=null;return f.then(function(n){return t=n.subscribe(e)},e.error),function(){return t&&t.unsubscribe()}})}return h(r)},e.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},e.prototype.removeQuery=function(e){var t;this.fetchCancelFns.delete(e),this.queries.has(e)&&(null===(t=this.queries.get(e))||void 0===t||t.stop(),this.queries.delete(e))},e.prototype.broadcastQueries=function(){this.onBroadcast&&this.onBroadcast(),this.queries.forEach(function(e){var t;return null===(t=e.observableQuery)||void 0===t?void 0:t.notify()})},e.prototype.getLocalState=function(){return this.localState},e.prototype.getObservableFromLink=function(e,t,n,r,i){var o,s,a=this;void 0===i&&(i=null!==(o=null==t?void 0:t.queryDeduplication)&&void 0!==o?o:this.queryDeduplication);var u=this.getDocumentInfo(e),c=u.serverQuery,l=u.clientQuery;if(c){var h=this.inFlightLinkObservables,f=this.link,d={query:c,variables:n,operationName:Ef(c)||void 0,context:this.prepareContext(Sl(Sl({},t),{forceFetch:!i})),extensions:r};if(t=d.context,i){var p=mp(c),y=sf(n),m=h.lookup(p,y);if(!(s=m.observable)){var g=new iy([Pp(f,d)]);s=m.observable=g,g.beforeNext(function e(t,n){"next"===t&&"hasNext"in n&&n.hasNext?g.beforeNext(e):h.remove(p,y)})}}else s=new iy([Pp(f,d)])}else s=new iy([mh.of({data:{}})]),t=this.prepareContext(t);return l&&(s=Zp(s,function(e){return a.localState.runResolvers({document:l,remoteResult:e,context:t,variables:n})})),s},e.prototype.getResultsFromLink=function(e,t,n){var r=e.lastRequestId=this.generateRequestId(),i=this.cache.transformForLink(n.query);return Zp(this.getObservableFromLink(i,n.context,n.variables),function(o){var s=Xp(o),a=s.length>0,u=n.errorPolicy;if(r>=e.lastRequestId){if(a&&"none"===u)throw e.markError(new Vd({graphQLErrors:s}));e.markResult(o,i,n,t),e.markReady()}var c={data:o.data,loading:!1,networkStatus:ry.ready};return a&&"none"===u&&(c.data=void 0),a&&"ignore"!==u&&(c.errors=s,c.networkStatus=ry.error),c},function(t){var n=$d(t)?t:new Vd({networkError:t});throw r>=e.lastRequestId&&e.markError(n),n})},e.prototype.fetchConcastWithInfo=function(e,t,n,r){var i=this;void 0===n&&(n=ry.loading),void 0===r&&(r=t.query);var o,s,a=this.getVariables(r,t.variables),u=this.defaultOptions.watchQuery,c=t.fetchPolicy,l=void 0===c?u&&u.fetchPolicy||"cache-first":c,h=t.errorPolicy,f=void 0===h?u&&u.errorPolicy||"none":h,d=t.returnPartialData,p=void 0!==d&&d,y=t.notifyOnNetworkStatusChange,m=void 0!==y&&y,g=t.context,b=void 0===g?{}:g,v=Object.assign({},t,{query:r,variables:a,fetchPolicy:l,errorPolicy:f,returnPartialData:p,notifyOnNetworkStatusChange:m,context:b}),w=function(r){v.variables=r;var o=i.fetchQueryByPolicy(e,v,n);return"standby"!==v.fetchPolicy&&o.sources.length>0&&e.observableQuery&&e.observableQuery.applyNextFetchPolicy("after-fetch",t),o},E=function(){return i.fetchCancelFns.delete(e.queryId)};if(this.fetchCancelFns.set(e.queryId,function(e){E(),setTimeout(function(){return o.cancel(e)})}),this.getDocumentInfo(v.query).hasClientExports)o=new iy(this.localState.addExportedVariables(v.query,v.variables,v.context).then(w).then(function(e){return e.sources})),s=!0;else{var k=w(v.variables);s=k.fromLink,o=new iy(k.sources)}return o.promise.then(E,E),{concast:o,fromLink:s}},e.prototype.refetchQueries=function(e){var t=this,n=e.updateCache,r=e.include,i=e.optimistic,o=void 0!==i&&i,s=e.removeOptimistic,a=void 0===s?o?Ll("refetchQueries"):void 0:s,u=e.onQueryUpdated,c=new Map;r&&this.getObservableQueries(r).forEach(function(e,n){c.set(n,{oq:e,lastDiff:(t.queries.get(n)||e.queryInfo).getDiff()})});var l=new Map;return n&&this.cache.batch({update:n,optimistic:o&&a||!1,removeOptimistic:a,onWatchUpdated:function(e,t,n){var r=e.watcher instanceof ky&&e.watcher.observableQuery;if(r){if(u){c.delete(r.queryId);var i=u(r,t,n);return!0===i&&(i=r.refetch()),!1!==i&&l.set(r,i),i}null!==u&&c.set(r.queryId,{oq:r,lastDiff:n,diff:t})}}}),c.size&&c.forEach(function(e,n){var r,i=e.oq,o=e.lastDiff,s=e.diff;u&&(s||(s=gd("canonizeResults",function(){return t.cache.diff(i.queryInfo.getDiffOptions())})),r=u(i,s,o)),u&&!0!==r||(r=i.refetch()),!1!==r&&l.set(i,r),n.indexOf("legacyOneTimeQuery")>=0&&t.stopQueryNoBroadcast(n)}),a&&this.cache.removeOptimistic(a),l},e.prototype.maskOperation=function(e){var t,n,r,i=e.document,o=e.data;if(!1!==globalThis.__DEV__){var s=e.fetchPolicy,a=e.id,u=null===(t=wf(i))||void 0===t?void 0:t.operation,c=(null!==(n=null==u?void 0:u[0])&&void 0!==n?n:"o")+a;!this.dataMasking||"no-cache"!==s||function(e){var t=!0;return Ih(e,{FragmentSpread:function(e){if(!(t=!!e.directives&&e.directives.some(function(e){return"unmask"===e.name.value})))return Oh}}),t}(i)||this.noCacheWarningsByQueryId.has(c)||(this.noCacheWarningsByQueryId.add(c),!1!==globalThis.__DEV__&&Vl.warn(45,null!==(r=Ef(i))&&void 0!==r?r:"Unnamed ".concat(null!=u?u:"operation")))}return this.dataMasking?function(e,t,n){var r;if(!n.fragmentMatches)return!1!==globalThis.__DEV__&&My(),e;var i=wf(t);return Vl(i,63),null==e?e:Ay(e,i.selectionSet,{operationType:i.operation,operationName:null===(r=i.name)||void 0===r?void 0:r.value,fragmentMap:Ah(kf(t)),cache:n,mutableTargets:new xy,knownChanged:new Oy})}(o,i,this.cache):o},e.prototype.maskFragment=function(e){var t=e.data,n=e.fragment,r=e.fragmentName;return this.dataMasking?Dy(t,n,this.cache,r):t},e.prototype.fetchQueryByPolicy=function(e,t,n){var r=this,i=t.query,o=t.variables,s=t.fetchPolicy,a=t.refetchWritePolicy,u=t.errorPolicy,c=t.returnPartialData,l=t.context,h=t.notifyOnNetworkStatusChange,f=e.networkStatus;e.init({document:i,variables:o,networkStatus:n});var d=function(){return e.getDiff()},p=function(t,n){void 0===n&&(n=e.networkStatus||ry.loading);var s=t.result;!1===globalThis.__DEV__||c||$p(s,{})||by(t.missing);var a=function(e){return mh.of(Sl({data:e,loading:oy(n),networkStatus:n},t.complete?null:{partial:!0}))};return s&&r.getDocumentInfo(i).hasForcedResolvers?r.localState.runResolvers({document:i,remoteResult:{data:s},context:l,variables:o,onlyRunForcedResolvers:!0}).then(function(e){return a(e.data||void 0)}):"none"===u&&n===ry.refetch&&Array.isArray(t.missing)?a(void 0):a(s)},y="no-cache"===s?0:n===ry.refetch&&"merge"!==a?1:2,m=function(){return r.getResultsFromLink(e,y,{query:i,variables:o,context:l,fetchPolicy:s,errorPolicy:u})},g=h&&"number"==typeof f&&f!==n&&oy(n);switch(s){default:case"cache-first":return(b=d()).complete?{fromLink:!1,sources:[p(b,e.markReady())]}:c||g?{fromLink:!0,sources:[p(b),m()]}:{fromLink:!0,sources:[m()]};case"cache-and-network":var b;return(b=d()).complete||c||g?{fromLink:!0,sources:[p(b),m()]}:{fromLink:!0,sources:[m()]};case"cache-only":return{fromLink:!1,sources:[p(d(),e.markReady())]};case"network-only":return g?{fromLink:!0,sources:[p(d()),m()]}:{fromLink:!0,sources:[m()]};case"no-cache":return g?{fromLink:!0,sources:[p(e.getDiff()),m()]}:{fromLink:!0,sources:[m()]};case"standby":return{fromLink:!1,sources:[]}}},e.prototype.getOrCreateQuery=function(e){return e&&!this.queries.has(e)&&this.queries.set(e,new ky(this,e)),this.queries.get(e)},e.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.localState.prepareContext(e);return Sl(Sl(Sl({},this.defaultContext),t),{clientAwareness:this.clientAwareness})},e}();function Fy(e){return e.kind===Td.FIELD||e.kind===Td.FRAGMENT_SPREAD||e.kind===Td.INLINE_FRAGMENT}var Uy=new Ff,Ly=new WeakMap;function qy(e){var t=Ly.get(e);return t||Ly.set(e,t={vars:new Set,dep:cd()}),t}function $y(e){qy(e).vars.forEach(function(t){return t.forgetCache(e)})}function Vy(e){var t=new Set,n=new Set,r=function(o){if(arguments.length>0){if(e!==o){e=o,t.forEach(function(e){qy(e).dep.dirty(r),function(e){e.broadcastWatches&&e.broadcastWatches()}(e)});var s=Array.from(n);n.clear(),s.forEach(function(t){return t(e)})}}else{var a=Uy.getValue();a&&(i(a),qy(a).dep(r))}return e};r.onNextChange=function(e){return n.add(e),function(){n.delete(e)}};var i=r.attachCache=function(e){return t.add(e),qy(e).vars.add(r),r};return r.forgetCache=function(e){return t.delete(e)},r}var zy=function(){function e(e){var t=e.cache,n=e.client,r=e.resolvers,i=e.fragmentMatcher;this.selectionsToResolveCache=new WeakMap,this.cache=t,n&&(this.client=n),r&&this.addResolvers(r),i&&this.setFragmentMatcher(i)}return e.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach(function(e){t.resolvers=Qd(t.resolvers,e)}):this.resolvers=Qd(this.resolvers,e)},e.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},e.prototype.getResolvers=function(){return this.resolvers||{}},e.prototype.runResolvers=function(e){return _l(this,arguments,void 0,function(e){var t=e.document,n=e.remoteResult,r=e.context,i=e.variables,o=e.onlyRunForcedResolvers,s=void 0!==o&&o;return xl(this,function(e){return t?[2,this.resolveDocument(t,n.data,r,i,this.fragmentMatcher,s).then(function(e){return Sl(Sl({},n),{data:e.result})})]:[2,n]})})},e.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},e.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},e.prototype.clientQuery=function(e){return xd(["client"],e)&&this.resolvers?e:null},e.prototype.serverQuery=function(e){return Mp(e)},e.prototype.prepareContext=function(e){var t=this.cache;return Sl(Sl({},e),{cache:t,getCacheKey:function(e){return t.identify(e)}})},e.prototype.addExportedVariables=function(e){return _l(this,arguments,void 0,function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),xl(this,function(r){return e?[2,this.resolveDocument(e,this.buildRootValueFromCache(e,t)||{},this.prepareContext(n),t).then(function(e){return Sl(Sl({},t),e.exportedVariables)})]:[2,Sl({},t)]})})},e.prototype.shouldForceResolvers=function(e){var t=!1;return Ih(e,{Directive:{enter:function(e){if("client"===e.name.value&&e.arguments&&(t=e.arguments.some(function(e){return"always"===e.name.value&&"BooleanValue"===e.value.kind&&!0===e.value.value})))return Oh}}}),t},e.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:Cp(e),variables:t,returnPartialData:!0,optimistic:!1}).result},e.prototype.resolveDocument=function(e,t){return _l(this,arguments,void 0,function(e,t,n,r,i,o){var s,a,u,c,l,h,f,d,p,y;return void 0===n&&(n={}),void 0===r&&(r={}),void 0===i&&(i=function(){return!0}),void 0===o&&(o=!1),xl(this,function(m){return s=_f(e),a=kf(e),u=Ah(a),c=this.collectSelectionsToResolve(s,u),l=s.operation,h=l?l.charAt(0).toUpperCase()+l.slice(1):"Query",d=(f=this).cache,p=f.client,y={fragmentMap:u,context:Sl(Sl({},n),{cache:d,client:p}),variables:r,fragmentMatcher:i,defaultOperationType:h,exportedVariables:{},selectionsToResolve:c,onlyRunForcedResolvers:o},[2,this.resolveSelectionSet(s.selectionSet,false,t,y).then(function(e){return{result:e,exportedVariables:y.exportedVariables}})]})})},e.prototype.resolveSelectionSet=function(e,t,n,r){return _l(this,void 0,void 0,function(){var i,o,s,a,u,c=this;return xl(this,function(l){return i=r.fragmentMap,o=r.context,s=r.variables,a=[n],u=function(e){return _l(c,void 0,void 0,function(){var u,c;return xl(this,function(l){return(t||r.selectionsToResolve.has(e))&&_d(e,s)?bf(e)?[2,this.resolveField(e,t,n,r).then(function(t){var n;void 0!==t&&a.push(((n={})[mf(e)]=t,n))})]:(!function(e){return"InlineFragment"===e.kind}(e)?(u=i[e.name.value],Vl(u,21,e.name.value)):u=e,u&&u.typeCondition&&(c=u.typeCondition.name.value,r.fragmentMatcher(n,c,o))?[2,this.resolveSelectionSet(u.selectionSet,t,n,r).then(function(e){a.push(e)})]:[2]):[2]})})},[2,Promise.all(e.selections.map(u)).then(function(){return Gd(a)})]})})},e.prototype.resolveField=function(e,t,n,r){return _l(this,void 0,void 0,function(){var i,o,s,a,u,c,l,h,f,d=this;return xl(this,function(p){return n?(i=r.variables,o=e.name.value,s=mf(e),a=o!==s,u=n[s]||n[o],c=Promise.resolve(u),r.onlyRunForcedResolvers&&!this.shouldForceResolvers(e)||(l=n.__typename||r.defaultOperationType,(h=this.resolvers&&this.resolvers[l])&&(f=h[a?o:s])&&(c=Promise.resolve(Uy.withValue(this.cache,f,[n,yf(e,i),r.context,{field:e,fragmentMap:r.fragmentMap}])))),[2,c.then(function(n){var i,o;if(void 0===n&&(n=u),e.directives&&e.directives.forEach(function(e){"export"===e.name.value&&e.arguments&&e.arguments.forEach(function(e){"as"===e.name.value&&"StringValue"===e.value.kind&&(r.exportedVariables[e.value.value]=n)})}),!e.selectionSet)return n;if(null==n)return n;var s=null!==(o=null===(i=e.directives)||void 0===i?void 0:i.some(function(e){return"client"===e.name.value}))&&void 0!==o&&o;return Array.isArray(n)?d.resolveSubSelectedArray(e,t||s,n,r):e.selectionSet?d.resolveSelectionSet(e.selectionSet,t||s,n,r):void 0})]):[2,null]})})},e.prototype.resolveSubSelectedArray=function(e,t,n,r){var i=this;return Promise.all(n.map(function(n){return null===n?null:Array.isArray(n)?i.resolveSubSelectedArray(e,t,n,r):e.selectionSet?i.resolveSelectionSet(e.selectionSet,t,n,r):void 0}))},e.prototype.collectSelectionsToResolve=function(e,t){var n=function(e){return!Array.isArray(e)},r=this.selectionsToResolveCache;return function e(i){if(!r.has(i)){var o=new Set;r.set(i,o),Ih(i,{Directive:function(e,t,r,i,s){"client"===e.name.value&&s.forEach(function(e){n(e)&&Fy(e)&&o.add(e)})},FragmentSpread:function(r,i,s,a,u){var c=t[r.name.value];Vl(c,22,r.name.value);var l=e(c);l.size>0&&(u.forEach(function(e){n(e)&&Fy(e)&&o.add(e)}),o.add(r),l.forEach(function(e){o.add(e)}))}})}return r.get(i)}(e)},e}();function Ky(e,t){return sy(e,t,t.variables&&{variables:sy(Sl(Sl({},e&&e.variables),t.variables))})}var Wy=!1,Qy=function(){function e(e){var t,n,r,i=this;if(this.resetStoreCallbacks=[],this.clearStoreCallbacks=[],!e.cache)throw zl(16);var o=e.uri,s=e.credentials,a=e.headers,u=e.cache,c=e.documentTransform,l=e.ssrMode,h=void 0!==l&&l,f=e.ssrForceFetchDelay,d=void 0===f?0:f,p=e.connectToDevTools,y=e.queryDeduplication,m=void 0===y||y,g=e.defaultOptions,b=e.defaultContext,v=e.assumeImmutableResults,w=void 0===v?u.assumeImmutableResults:v,E=e.resolvers,k=e.typeDefs,S=e.fragmentMatcher,T=e.clientAwareness,_=e.name,x=e.version,O=e.devtools,I=e.dataMasking;!1!==globalThis.__DEV__&&(bd(e,"connectToDevTools","ApolloClient","Please use `devtools.enabled` instead."),bd(e,"uri","ApolloClient","Please initialize an instance of `HttpLink` with `uri` instead."),bd(e,"credentials","ApolloClient","Please initialize an instance of `HttpLink` with `credentials` instead."),bd(e,"headers","ApolloClient","Please initialize an instance of `HttpLink` with `headers` instead."),bd(e,"name","ApolloClient","Please use the `clientAwareness.name` option instead."),bd(e,"version","ApolloClient","Please use the `clientAwareness.version` option instead."),bd(e,"typeDefs","ApolloClient"),e.link||!1!==globalThis.__DEV__&&Vl.warn(17));var C=e.link;C||(C=o?new Bp({uri:o,credentials:s,headers:a}):Sd.empty()),this.link=C,this.cache=u,this.disableNetworkFetches=h||d>0,this.queryDeduplication=m,this.defaultOptions=g||Object.create(null),this.typeDefs=k,this.devtoolsConfig=Sl(Sl({},O),{enabled:null!==(t=null==O?void 0:O.enabled)&&void 0!==t?t:p}),void 0===this.devtoolsConfig.enabled&&(this.devtoolsConfig.enabled=!1!==globalThis.__DEV__),d&&setTimeout(function(){return i.disableNetworkFetches=!1},d),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.watchFragment=this.watchFragment.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this),this.version=Pl,this.localState=new zy({cache:u,client:this,resolvers:E,fragmentMatcher:S}),this.queryManager=new By({cache:this.cache,link:this.link,defaultOptions:this.defaultOptions,defaultContext:b,documentTransform:c,queryDeduplication:m,ssrMode:h,dataMasking:!!I,clientAwareness:{name:null!==(n=null==T?void 0:T.name)&&void 0!==n?n:_,version:null!==(r=null==T?void 0:T.version)&&void 0!==r?r:x},localState:this.localState,assumeImmutableResults:w,onBroadcast:this.devtoolsConfig.enabled?function(){i.devToolsHookCb&&i.devToolsHookCb({action:{},state:{queries:i.queryManager.getQueryStore(),mutations:i.queryManager.mutationStore||{}},dataWithOptimisticResults:i.cache.extract(!0)})}:void 0}),this.devtoolsConfig.enabled&&this.connectToDevTools()}return Object.defineProperty(e.prototype,"prioritizeCacheValues",{get:function(){return this.disableNetworkFetches},set:function(e){this.disableNetworkFetches=e},enumerable:!1,configurable:!0}),e.prototype.connectToDevTools=function(){if("undefined"!=typeof window){var e=window,t=Symbol.for("apollo.devtools");(e[t]=e[t]||[]).push(this),e.__APOLLO_CLIENT__=this,Wy||!1===globalThis.__DEV__||(Wy=!0,window.document&&window.top===window.self&&/^(https?|file):$/.test(window.location.protocol)&&setTimeout(function(){if(!window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__){var e=window.navigator,t=e&&e.userAgent,n=void 0;"string"==typeof t&&(t.indexOf("Chrome/")>-1?n="https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm":t.indexOf("Firefox/")>-1&&(n="https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/")),n&&!1!==globalThis.__DEV__&&Vl.log("Download the Apollo DevTools for a better development experience: %s",n)}},1e4))}},Object.defineProperty(e.prototype,"documentTransform",{get:function(){return this.queryManager.documentTransform},enumerable:!1,configurable:!0}),e.prototype.stop=function(){this.queryManager.stop()},e.prototype.watchQuery=function(e){return this.defaultOptions.watchQuery&&(e=Ky(this.defaultOptions.watchQuery,e)),!this.disableNetworkFetches||"network-only"!==e.fetchPolicy&&"cache-and-network"!==e.fetchPolicy||(e=Sl(Sl({},e),{fetchPolicy:"cache-first"})),!1!==globalThis.__DEV__&&(bd(e,"canonizeResults","client.watchQuery"),bd(e,"partialRefetch","client.watchQuery")),this.queryManager.watchQuery(e)},e.prototype.query=function(e){return this.defaultOptions.query&&(e=Ky(this.defaultOptions.query,e)),Vl("cache-and-network"!==e.fetchPolicy,18),this.disableNetworkFetches&&"network-only"===e.fetchPolicy&&(e=Sl(Sl({},e),{fetchPolicy:"cache-first"})),!1!==globalThis.__DEV__&&(bd(e,"canonizeResults","client.query"),bd(e,"notifyOnNetworkStatusChange","client.query","This option does not affect `client.query` and can be safely removed."),"standby"===e.fetchPolicy&&!1!==globalThis.__DEV__&&Vl.warn(19)),this.queryManager.query(e)},e.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=Ky(this.defaultOptions.mutate,e)),this.queryManager.mutate(e)},e.prototype.subscribe=function(e){var t=this,n=this.queryManager.generateQueryId();return this.queryManager.startGraphQLSubscription(e).map(function(r){return Sl(Sl({},r),{data:t.queryManager.maskOperation({document:e.query,data:r.data,fetchPolicy:e.fetchPolicy,id:n})})})},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.cache.readQuery(e,t)},e.prototype.watchFragment=function(e){var t;return this.cache.watchFragment(Sl(Sl({},e),((t={})[Symbol.for("apollo.dataMasking")]=this.queryManager.dataMasking,t)))},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.cache.readFragment(e,t)},e.prototype.writeQuery=function(e){var t=this.cache.writeQuery(e);return!1!==e.broadcast&&this.queryManager.broadcastQueries(),t},e.prototype.writeFragment=function(e){var t=this.cache.writeFragment(e);return!1!==e.broadcast&&this.queryManager.broadcastQueries(),t},e.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},e.prototype.__requestRaw=function(e){return Pp(this.link,e)},e.prototype.resetStore=function(){var e=this;return Promise.resolve().then(function(){return e.queryManager.clearStore({discardWatches:!1})}).then(function(){return Promise.all(e.resetStoreCallbacks.map(function(e){return e()}))}).then(function(){return e.reFetchObservableQueries()})},e.prototype.clearStore=function(){var e=this;return Promise.resolve().then(function(){return e.queryManager.clearStore({discardWatches:!0})}).then(function(){return Promise.all(e.clearStoreCallbacks.map(function(e){return e()}))})},e.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter(function(t){return t!==e})}},e.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter(function(t){return t!==e})}},e.prototype.reFetchObservableQueries=function(e){return this.queryManager.reFetchObservableQueries(e)},e.prototype.refetchQueries=function(e){var t=this.queryManager.refetchQueries(e),n=[],r=[];t.forEach(function(e,t){n.push(t),r.push(e)});var i=Promise.all(r);return i.queries=n,i.results=r,i.catch(function(e){!1!==globalThis.__DEV__&&Vl.debug(20,e)}),i},e.prototype.getObservableQueries=function(e){return void 0===e&&(e="active"),this.queryManager.getObservableQueries(e)},e.prototype.extract=function(e){return this.cache.extract(e)},e.prototype.restore=function(e){return this.cache.restore(e)},e.prototype.addResolvers=function(e){this.localState.addResolvers(e)},e.prototype.setResolvers=function(e){this.localState.setResolvers(e)},e.prototype.getResolvers=function(){return this.localState.getResolvers()},e.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},e.prototype.setLink=function(e){this.link=this.queryManager.link=e},Object.defineProperty(e.prototype,"defaultContext",{get:function(){return this.queryManager.defaultContext},enumerable:!1,configurable:!0}),e}();!1!==globalThis.__DEV__&&(Qy.prototype.getMemoryInternals=Hh);var Gy=function(){function e(){this.assumeImmutableResults=!1,this.getFragmentDoc=dd(Mh,{max:Wh["cache.fragmentQueryDocuments"]||1e3,cache:Fh})}return e.prototype.lookupFragment=function(e){return null},e.prototype.batch=function(e){var t,n=this,r="string"==typeof e.optimistic?e.optimistic:!1===e.optimistic?null:void 0;return this.performTransaction(function(){return t=e.update(n)},r),t},e.prototype.recordOptimisticTransaction=function(e,t){this.performTransaction(e,t)},e.prototype.transformDocument=function(e){return e},e.prototype.transformForLink=function(e){return e},e.prototype.identify=function(e){},e.prototype.gc=function(){return[]},e.prototype.modify=function(e){return!1},e.prototype.readQuery=function(e,t){var n=this;return void 0===t&&(t=!!e.optimistic),!1!==globalThis.__DEV__&&bd(e,"canonizeResults","cache.readQuery"),gd("canonizeResults",function(){return n.read(Sl(Sl({},e),{rootId:e.id||"ROOT_QUERY",optimistic:t}))})},e.prototype.watchFragment=function(e){var t=this,n=e.fragment,r=e.fragmentName,i=e.from,o=e.optimistic,s=void 0===o||o,a=Tl(e,["fragment","fragmentName","from","optimistic"]),u=this.getFragmentDoc(n,r),c=void 0===i||"string"==typeof i?i:this.identify(i),l=!!e[Symbol.for("apollo.dataMasking")];if(!1!==globalThis.__DEV__){var h=r||Tf(n).name.value;c||!1!==globalThis.__DEV__&&Vl.warn(1,h)}var f,d=Sl(Sl({},a),{returnPartialData:!0,id:c,query:u,optimistic:s});return new mh(function(i){return t.watch(Sl(Sl({},d),{immediate:!0,callback:function(o){var s=l?Dy(o.result,n,t,r):o.result;if(!f||!ly(u,{data:f.result},{data:s},e.variables)){var a={data:s,complete:!!o.complete};o.missing&&(a.missing=Gd(o.missing.map(function(e){return e.missing}))),f=Sl(Sl({},o),{result:s}),i.next(a)}}}))})},e.prototype.readFragment=function(e,t){var n=this;return void 0===t&&(t=!!e.optimistic),!1!==globalThis.__DEV__&&bd(e,"canonizeResults","cache.readFragment"),gd("canonizeResults",function(){return n.read(Sl(Sl({},e),{query:n.getFragmentDoc(e.fragment,e.fragmentName),rootId:e.id,optimistic:t}))})},e.prototype.writeQuery=function(e){var t=e.id,n=e.data,r=Tl(e,["id","data"]);return this.write(Object.assign(r,{dataId:t||"ROOT_QUERY",result:n}))},e.prototype.writeFragment=function(e){var t=e.id,n=e.data,r=e.fragment,i=e.fragmentName,o=Tl(e,["id","data","fragment","fragmentName"]);return this.write(Object.assign(o,{query:this.getFragmentDoc(r,i),dataId:t,result:n}))},e.prototype.updateQuery=function(e,t){return!1!==globalThis.__DEV__&&bd(e,"canonizeResults","cache.updateQuery"),this.batch({update:function(n){var r=gd("canonizeResults",function(){return n.readQuery(e)}),i=t(r);return null==i?r:(n.writeQuery(Sl(Sl({},e),{data:i})),i)}})},e.prototype.updateFragment=function(e,t){return!1!==globalThis.__DEV__&&bd(e,"canonizeResults","cache.updateFragment"),this.batch({update:function(n){var r=gd("canonizeResults",function(){return n.readFragment(e)}),i=t(r);return null==i?r:(n.writeFragment(Sl(Sl({},e),{data:i})),i)}})},e}();!1!==globalThis.__DEV__&&(Gy.prototype.getMemoryInternals=Zh);var Hy=function(e){function t(n,r,i,o){var s,a=e.call(this,n)||this;if(a.message=n,a.path=r,a.query=i,a.variables=o,Array.isArray(a.path)){a.missing=a.message;for(var u=a.path.length-1;u>=0;--u)a.missing=((s={})[a.path[u]]=a.missing,s)}else a.missing=a.path;return a.__proto__=t.prototype,a}return kl(t,e),t}(Error),Jy=Object.prototype.hasOwnProperty;function Zy(e){return null==e}function Yy(e,t){var n=e.__typename,r=e.id,i=e._id;if("string"==typeof n&&(t&&(t.keyObject=Zy(r)?Zy(i)?void 0:{_id:i}:{id:r}),Zy(r)&&!Zy(i)&&(r=i),!Zy(r)))return"".concat(n,":").concat("number"==typeof r||"string"==typeof r?r:JSON.stringify(r))}var Xy={dataIdFromObject:Yy,addTypename:!0,resultCaching:!0,canonizeResults:!1};function em(e){var t=e.canonizeResults;return void 0===t?Xy.canonizeResults:t}var tm=/^[_a-z][_0-9a-z]*/i;function nm(e){var t=e.match(tm);return t?t[0]:e}function rm(e,t,n){return!!gh(t)&&(zd(t)?t.every(function(t){return rm(e,t,n)}):e.selections.every(function(e){if(bf(e)&&_d(e,n)){var r=mf(e);return Jy.call(t,r)&&(!e.selectionSet||rm(e.selectionSet,t[r],n))}return!0}))}function im(e){return gh(e)&&!lf(e)&&!zd(e)}function om(e,t){var n=Ah(kf(e));return{fragmentMap:n,lookupFragment:function(e){var r=n[e];return!r&&t&&(r=t.lookup(e)),r||null}}}var sm=Object.create(null),am=function(){return sm},um=Object.create(null),cm=function(){function e(e,t){var n=this;this.policies=e,this.group=t,this.data=Object.create(null),this.rootIds=Object.create(null),this.refs=Object.create(null),this.getFieldValue=function(e,t){return _y(lf(e)?n.get(e.__ref,t):e&&e[t])},this.canRead=function(e){return lf(e)?n.has(e.__ref):"object"==typeof e},this.toReference=function(e,t){if("string"==typeof e)return cf(e);if(lf(e))return e;var r=n.policies.identify(e)[0];if(r){var i=cf(r);return t&&n.merge(r,e),i}}}return e.prototype.toObject=function(){return Sl({},this.data)},e.prototype.has=function(e){return void 0!==this.lookup(e,!0)},e.prototype.get=function(e,t){if(this.group.depend(e,t),Jy.call(this.data,e)){var n=this.data[e];if(n&&Jy.call(n,t))return n[t]}return"__typename"===t&&Jy.call(this.policies.rootTypenamesById,e)?this.policies.rootTypenamesById[e]:this instanceof dm?this.parent.get(e,t):void 0},e.prototype.lookup=function(e,t){return t&&this.group.depend(e,"__exists"),Jy.call(this.data,e)?this.data[e]:this instanceof dm?this.parent.lookup(e,t):this.policies.rootTypenamesById[e]?Object.create(null):void 0},e.prototype.merge=function(e,t){var n,r=this;lf(e)&&(e=e.__ref),lf(t)&&(t=t.__ref);var i="string"==typeof e?this.lookup(n=e):e,o="string"==typeof t?this.lookup(n=t):t;if(o){Vl("string"==typeof n,2);var s=new Jd(ym).merge(i,o);if(this.data[n]=s,s!==i&&(delete this.refs[n],this.group.caching)){var a=Object.create(null);i||(a.__exists=1),Object.keys(o).forEach(function(e){if(!i||i[e]!==s[e]){a[e]=1;var t=nm(e);t===e||r.policies.hasKeyArgs(s.__typename,t)||(a[t]=1),void 0!==s[e]||r instanceof dm||delete s[e]}}),!a.__typename||i&&i.__typename||this.policies.rootTypenamesById[n]!==s.__typename||delete a.__typename,Object.keys(a).forEach(function(e){return r.group.dirty(n,e)})}}},e.prototype.modify=function(e,t){var n=this,r=this.lookup(e);if(r){var i=Object.create(null),o=!1,s=!0,a={DELETE:sm,INVALIDATE:um,isReference:lf,toReference:this.toReference,canRead:this.canRead,readField:function(t,r){return n.policies.readField("string"==typeof t?{fieldName:t,from:r||cf(e)}:t,{store:n})}};if(Object.keys(r).forEach(function(u){var c=nm(u),l=r[u];if(void 0!==l){var h="function"==typeof t?t:t[u]||t[c];if(h){var f=h===am?sm:h(_y(l),Sl(Sl({},a),{fieldName:c,storeFieldName:u,storage:n.getStorage(e,u)}));if(f===um)n.group.dirty(e,u);else if(f===sm&&(f=void 0),f!==l&&(i[u]=f,o=!0,l=f,!1!==globalThis.__DEV__)){var d=function(e){if(void 0===n.lookup(e.__ref))return!1!==globalThis.__DEV__&&Vl.warn(3,e),!0};if(lf(f))d(f);else if(Array.isArray(f))for(var p=!1,y=void 0,m=0,g=f;m<g.length;m++){var b=g[m];if(lf(b)){if(p=!0,d(b))break}else if("object"==typeof b&&b)n.policies.identify(b)[0]&&(y=b);if(p&&void 0!==y){!1!==globalThis.__DEV__&&Vl.warn(4,y);break}}}}void 0!==l&&(s=!1)}}),o)return this.merge(e,i),s&&(this instanceof dm?this.data[e]=void 0:delete this.data[e],this.group.dirty(e,"__exists")),!0}return!1},e.prototype.delete=function(e,t,n){var r,i=this.lookup(e);if(i){var o=this.getFieldValue(i,"__typename"),s=t&&n?this.policies.getStoreFieldName({typename:o,fieldName:t,args:n}):t;return this.modify(e,s?((r={})[s]=am,r):am)}return!1},e.prototype.evict=function(e,t){var n=!1;return e.id&&(Jy.call(this.data,e.id)&&(n=this.delete(e.id,e.fieldName,e.args)),this instanceof dm&&this!==t&&(n=this.parent.evict(e,t)||n),(e.fieldName||n)&&this.group.dirty(e.id,e.fieldName||"__exists")),n},e.prototype.clear=function(){this.replace(null)},e.prototype.extract=function(){var e=this,t=this.toObject(),n=[];return this.getRootIdSet().forEach(function(t){Jy.call(e.policies.rootTypenamesById,t)||n.push(t)}),n.length&&(t.__META={extraRootIds:n.sort()}),t},e.prototype.replace=function(e){var t=this;if(Object.keys(this.data).forEach(function(n){e&&Jy.call(e,n)||t.delete(n)}),e){var n=e.__META,r=Tl(e,["__META"]);Object.keys(r).forEach(function(e){t.merge(e,r[e])}),n&&n.extraRootIds.forEach(this.retain,this)}},e.prototype.retain=function(e){return this.rootIds[e]=(this.rootIds[e]||0)+1},e.prototype.release=function(e){if(this.rootIds[e]>0){var t=--this.rootIds[e];return t||delete this.rootIds[e],t}return 0},e.prototype.getRootIdSet=function(e){return void 0===e&&(e=new Set),Object.keys(this.rootIds).forEach(e.add,e),this instanceof dm?this.parent.getRootIdSet(e):Object.keys(this.policies.rootTypenamesById).forEach(e.add,e),e},e.prototype.gc=function(){var e=this,t=this.getRootIdSet(),n=this.toObject();t.forEach(function(r){Jy.call(n,r)&&(Object.keys(e.findChildRefIds(r)).forEach(t.add,t),delete n[r])});var r=Object.keys(n);if(r.length){for(var i=this;i instanceof dm;)i=i.parent;r.forEach(function(e){return i.delete(e)})}return r},e.prototype.findChildRefIds=function(e){if(!Jy.call(this.refs,e)){var t=this.refs[e]=Object.create(null),n=this.data[e];if(!n)return t;var r=new Set([n]);r.forEach(function(e){lf(e)&&(t[e.__ref]=!0),gh(e)&&Object.keys(e).forEach(function(t){var n=e[t];gh(n)&&r.add(n)})})}return this.refs[e]},e.prototype.makeCacheKey=function(){return this.group.keyMaker.lookupArray(arguments)},e}(),lm=function(){function e(e,t){void 0===t&&(t=null),this.caching=e,this.parent=t,this.d=null,this.resetCaching()}return e.prototype.resetCaching=function(){this.d=this.caching?cd():null,this.keyMaker=new Af(Nd)},e.prototype.depend=function(e,t){if(this.d){this.d(hm(e,t));var n=nm(t);n!==t&&this.d(hm(e,n)),this.parent&&this.parent.depend(e,t)}},e.prototype.dirty=function(e,t){this.d&&this.d.dirty(hm(e,t),"__exists"===t?"forget":"setDirty")},e}();function hm(e,t){return t+"#"+e}function fm(e,t){mm(e)&&e.group.depend(t,"__exists")}!function(e){var t=function(e){function t(t){var n=t.policies,r=t.resultCaching,i=void 0===r||r,o=t.seed,s=e.call(this,n,new lm(i))||this;return s.stump=new pm(s),s.storageTrie=new Af(Nd),o&&s.replace(o),s}return kl(t,e),t.prototype.addLayer=function(e,t){return this.stump.addLayer(e,t)},t.prototype.removeLayer=function(){return this},t.prototype.getStorage=function(){return this.storageTrie.lookupArray(arguments)},t}(e);e.Root=t}(cm||(cm={}));var dm=function(e){function t(t,n,r,i){var o=e.call(this,n.policies,i)||this;return o.id=t,o.parent=n,o.replay=r,o.group=i,r(o),o}return kl(t,e),t.prototype.addLayer=function(e,n){return new t(e,this,n,this.group)},t.prototype.removeLayer=function(e){var t=this,n=this.parent.removeLayer(e);return e===this.id?(this.group.caching&&Object.keys(this.data).forEach(function(e){var r=t.data[e],i=n.lookup(e);i?r?r!==i&&Object.keys(r).forEach(function(n){$p(r[n],i[n])||t.group.dirty(e,n)}):(t.group.dirty(e,"__exists"),Object.keys(i).forEach(function(n){t.group.dirty(e,n)})):t.delete(e)}),n):n===this.parent?this:n.addLayer(this.id,this.replay)},t.prototype.toObject=function(){return Sl(Sl({},this.parent.toObject()),this.data)},t.prototype.findChildRefIds=function(t){var n=this.parent.findChildRefIds(t);return Jy.call(this.data,t)?Sl(Sl({},n),e.prototype.findChildRefIds.call(this,t)):n},t.prototype.getStorage=function(){for(var e=this.parent;e.parent;)e=e.parent;return e.getStorage.apply(e,arguments)},t}(cm),pm=function(e){function t(t){return e.call(this,"EntityStore.Stump",t,function(){},new lm(t.group.caching,t.group))||this}return kl(t,e),t.prototype.removeLayer=function(){return this},t.prototype.merge=function(e,t){return this.parent.merge(e,t)},t}(dm);function ym(e,t,n){var r=e[n],i=t[n];return $p(r,i)?r:i}function mm(e){return!!(e instanceof cm&&e.group.caching)}var gm=function(){function e(){this.known=new(jd?WeakSet:Set),this.pool=new Af(Nd),this.passes=new WeakMap,this.keysByJSON=new Map,this.empty=this.admit({})}return e.prototype.isKnown=function(e){return gh(e)&&this.known.has(e)},e.prototype.pass=function(e){if(gh(e)){var t=function(e){return gh(e)?zd(e)?e.slice(0):Sl({__proto__:Object.getPrototypeOf(e)},e):e}(e);return this.passes.set(t,e),t}return e},e.prototype.admit=function(e){var t=this;if(gh(e)){var n=this.passes.get(e);if(n)return n;switch(Object.getPrototypeOf(e)){case Array.prototype:if(this.known.has(e))return e;var r=e.map(this.admit,this);return(a=this.pool.lookupArray(r)).array||(this.known.add(a.array=r),!1!==globalThis.__DEV__&&Object.freeze(r)),a.array;case null:case Object.prototype:if(this.known.has(e))return e;var i=Object.getPrototypeOf(e),o=[i],s=this.sortedKeys(e);o.push(s.json);var a,u=o.length;if(s.sorted.forEach(function(n){o.push(t.admit(e[n]))}),!(a=this.pool.lookupArray(o)).object){var c=a.object=Object.create(i);this.known.add(c),s.sorted.forEach(function(e,t){c[e]=o[u+t]}),!1!==globalThis.__DEV__&&Object.freeze(c)}return a.object}}return e},e.prototype.sortedKeys=function(e){var t=Object.keys(e),n=this.pool.lookupArray(t);if(!n.keys){t.sort();var r=JSON.stringify(t);(n.keys=this.keysByJSON.get(r))||this.keysByJSON.set(r,n.keys={sorted:t,json:r})}return n.keys},e}();function bm(e){return[e.selectionSet,e.objectOrReference,e.context,e.context.canonizeResults]}var vm=function(){function e(e){var t=this;this.knownResults=new(Nd?WeakMap:Map),this.config=sy(e,{addTypename:!1!==e.addTypename,canonizeResults:em(e)}),this.canon=e.canon||new gm,this.executeSelectionSet=dd(function(e){var n,r=e.context.canonizeResults,i=bm(e);i[3]=!r;var o=(n=t.executeSelectionSet).peek.apply(n,i);return o?r?Sl(Sl({},o),{result:t.canon.admit(o.result)}):o:(fm(e.context.store,e.enclosingRef.__ref),t.execSelectionSetImpl(e))},{max:this.config.resultCacheMaxSize||Wh["inMemoryCache.executeSelectionSet"]||5e4,keyArgs:bm,makeCacheKey:function(e,t,n,r){if(mm(n.store))return n.store.makeCacheKey(e,lf(t)?t.__ref:t,n.varString,r)}}),this.executeSubSelectedArray=dd(function(e){return fm(e.context.store,e.enclosingRef.__ref),t.execSubSelectedArrayImpl(e)},{max:this.config.resultCacheMaxSize||Wh["inMemoryCache.executeSubSelectedArray"]||1e4,makeCacheKey:function(e){var t=e.field,n=e.array,r=e.context;if(mm(r.store))return r.store.makeCacheKey(t,n,r.varString)}})}return e.prototype.resetCanon=function(){this.canon=new gm},e.prototype.diffQueryAgainstStore=function(e){var t=e.store,n=e.query,r=e.rootId,i=void 0===r?"ROOT_QUERY":r,o=e.variables,s=e.returnPartialData,a=void 0===s||s,u=e.canonizeResults,c=void 0===u?this.config.canonizeResults:u,l=this.config.cache.policies;o=Sl(Sl({},xf(Sf(n))),o);var h,f=cf(i),d=this.executeSelectionSet({selectionSet:_f(n).selectionSet,objectOrReference:f,enclosingRef:f,context:Sl({store:t,query:n,policies:l,variables:o,varString:sf(o),canonizeResults:c},om(n,this.config.fragments))});if(d.missing&&(h=[new Hy(wm(d.missing),d.missing,n,o)],!a))throw h[0];return{result:d.result,complete:!h,missing:h}},e.prototype.isFresh=function(e,t,n,r){if(mm(r.store)&&this.knownResults.get(e)===n){var i=this.executeSelectionSet.peek(n,t,r,this.canon.isKnown(e));if(i&&e===i.result)return!0}return!1},e.prototype.execSelectionSetImpl=function(e){var t=this,n=e.selectionSet,r=e.objectOrReference,i=e.enclosingRef,o=e.context;if(lf(r)&&!o.policies.rootTypenamesById[r.__ref]&&!o.store.has(r.__ref))return{result:this.canon.empty,missing:"Dangling reference to missing ".concat(r.__ref," object")};var s,a=o.variables,u=o.policies,c=o.store.getFieldValue(r,"__typename"),l=[],h=new Jd;function f(e,t){var n;return e.missing&&(s=h.merge(s,((n={})[t]=e.missing,n))),e.result}this.config.addTypename&&"string"==typeof c&&!u.rootIdsByTypename[c]&&l.push({__typename:c});var d=new Set(n.selections);d.forEach(function(e){var n,p;if(_d(e,a))if(bf(e)){var y=u.readField({fieldName:e.name.value,field:e,variables:o.variables,from:r},o),m=mf(e);void 0===y?Ip.added(e)||(s=h.merge(s,((n={})[m]="Can't find field '".concat(e.name.value,"' on ").concat(lf(r)?r.__ref+" object":"object "+JSON.stringify(r,null,2)),n))):zd(y)?y.length>0&&(y=f(t.executeSubSelectedArray({field:e,array:y,enclosingRef:i,context:o}),m)):e.selectionSet?null!=y&&(y=f(t.executeSelectionSet({selectionSet:e.selectionSet,objectOrReference:y,enclosingRef:lf(y)?y:i,context:o}),m)):o.canonizeResults&&(y=t.canon.pass(y)),void 0!==y&&l.push(((p={})[m]=y,p))}else{var g=Nh(e,o.lookupFragment);if(!g&&e.kind===Td.FRAGMENT_SPREAD)throw zl(10,e.name.value);g&&u.fragmentMatches(g,c)&&g.selectionSet.selections.forEach(d.add,d)}});var p={result:Gd(l),missing:s},y=o.canonizeResults?this.canon.admit(p):_y(p);return y.result&&this.knownResults.set(y.result,n),y},e.prototype.execSubSelectedArrayImpl=function(e){var t,n=this,r=e.field,i=e.array,o=e.enclosingRef,s=e.context,a=new Jd;function u(e,n){var r;return e.missing&&(t=a.merge(t,((r={})[n]=e.missing,r))),e.result}return r.selectionSet&&(i=i.filter(s.store.canRead)),i=i.map(function(e,t){return null===e?null:zd(e)?u(n.executeSubSelectedArray({field:r,array:e,enclosingRef:o,context:s}),t):r.selectionSet?u(n.executeSelectionSet({selectionSet:r.selectionSet,objectOrReference:e,enclosingRef:lf(e)?e:o,context:s}),t):(!1!==globalThis.__DEV__&&function(e,t,n){if(!t.selectionSet){var r=new Set([n]);r.forEach(function(n){gh(n)&&(Vl(!lf(n),11,function(e,t){return lf(t)?e.get(t.__ref,"__typename"):t&&t.__typename}(e,n),t.name.value),Object.values(n).forEach(r.add,r))})}}(s.store,r,e),e)}),{result:s.canonizeResults?this.canon.admit(i):i,missing:t}},e}();function wm(e){try{JSON.stringify(e,function(e,t){if("string"==typeof t)throw t;return t})}catch(e){return e}}var Em=Object.create(null);function km(e){var t=JSON.stringify(e);return Em[t]||(Em[t]=Object.create(null))}function Sm(e){var t=km(e);return t.keyFieldsFn||(t.keyFieldsFn=function(t,n){var r=function(e,t){return n.readField(t,e)},i=n.keyObject=_m(e,function(e){var i=Im(n.storeObject,e,r);return void 0===i&&t!==n.storeObject&&Jy.call(t,e[0])&&(i=Im(t,e,Om)),Vl(void 0!==i,5,e.join("."),t),i});return"".concat(n.typename,":").concat(JSON.stringify(i))})}function Tm(e){var t=km(e);return t.keyArgsFn||(t.keyArgsFn=function(t,n){var r=n.field,i=n.variables,o=n.fieldName,s=_m(e,function(e){var n=e[0],o=n.charAt(0);if("@"!==o)if("$"!==o){if(t)return Im(t,e)}else{var s=n.slice(1);if(i&&Jy.call(i,s)){var a=e.slice(0);return a[0]=s,Im(i,a)}}else if(r&&Kd(r.directives)){var u=n.slice(1),c=r.directives.find(function(e){return e.name.value===u}),l=c&&yf(c,i);return l&&Im(l,e.slice(1))}}),a=JSON.stringify(s);return(t||"{}"!==a)&&(o+=":"+a),o})}function _m(e,t){var n=new Jd;return xm(e).reduce(function(e,r){var i,o=t(r);if(void 0!==o){for(var s=r.length-1;s>=0;--s)(i={})[r[s]]=o,o=i;e=n.merge(e,o)}return e},Object.create(null))}function xm(e){var t=km(e);if(!t.paths){var n=t.paths=[],r=[];e.forEach(function(t,i){zd(t)?(xm(t).forEach(function(e){return n.push(r.concat(e))}),r.length=0):(r.push(t),zd(e[i+1])||(n.push(r.slice(0)),r.length=0))})}return t.paths}function Om(e,t){return e[t]}function Im(e,t,n){return n=n||Om,Cm(t.reduce(function e(t,r){return zd(t)?t.map(function(t){return e(t,r)}):t&&n(t,r)},e))}function Cm(e){return gh(e)?zd(e)?e.map(Cm):_m(Object.keys(e).sort(),function(t){return Im(e,t)}):e}function Mm(e){return void 0!==e.args?e.args:e.field?yf(e.field,e.variables):null}var Am=function(){},Nm=function(e,t){return t.fieldName},jm=function(e,t,n){return(0,n.mergeObjects)(e,t)},Dm=function(e,t){return t},Rm=function(){function e(e){this.config=e,this.typePolicies=Object.create(null),this.toBeAdded=Object.create(null),this.supertypeMap=new Map,this.fuzzySubtypes=new Map,this.rootIdsByTypename=Object.create(null),this.rootTypenamesById=Object.create(null),this.usingPossibleTypes=!1,this.config=Sl({dataIdFromObject:Yy},e),this.cache=this.config.cache,this.setRootTypename("Query"),this.setRootTypename("Mutation"),this.setRootTypename("Subscription"),e.possibleTypes&&this.addPossibleTypes(e.possibleTypes),e.typePolicies&&this.addTypePolicies(e.typePolicies)}return e.prototype.identify=function(e,t){var n,r=this,i=t&&(t.typename||(null===(n=t.storeObject)||void 0===n?void 0:n.__typename))||e.__typename;if(i===this.rootTypenamesById.ROOT_QUERY)return["ROOT_QUERY"];var o,s=t&&t.storeObject||e,a=Sl(Sl({},t),{typename:i,storeObject:s,readField:t&&t.readField||function(){var e=Bm(arguments,s);return r.readField(e,{store:r.cache.data,variables:e.variables})}}),u=i&&this.getTypePolicy(i),c=u&&u.keyFn||this.config.dataIdFromObject;return Iy.withValue(!0,function(){for(;c;){var t=c(Sl(Sl({},e),s),a);if(!zd(t)){o=t;break}c=Sm(t)}}),o=o?String(o):void 0,a.keyObject?[o,a.keyObject]:[o]},e.prototype.addTypePolicies=function(e){var t=this;Object.keys(e).forEach(function(n){var r=e[n],i=r.queryType,o=r.mutationType,s=r.subscriptionType,a=Tl(r,["queryType","mutationType","subscriptionType"]);i&&t.setRootTypename("Query",n),o&&t.setRootTypename("Mutation",n),s&&t.setRootTypename("Subscription",n),Jy.call(t.toBeAdded,n)?t.toBeAdded[n].push(a):t.toBeAdded[n]=[a]})},e.prototype.updateTypePolicy=function(e,t,n){var r=this.getTypePolicy(e),i=t.keyFields,o=t.fields;function s(e,t){e.merge="function"==typeof t?t:!0===t?jm:!1===t?Dm:e.merge}s(r,t.merge),r.keyFn=!1===i?Am:zd(i)?Sm(i):"function"==typeof i?i:r.keyFn,o&&Object.keys(o).forEach(function(t){var r=n[t];r&&(null==r?void 0:r.typename)===e||(r=n[t]={typename:e});var i=o[t];if("function"==typeof i)r.read=i;else{var a=i.keyArgs,u=i.read,c=i.merge;r.keyFn=!1===a?Nm:zd(a)?Tm(a):"function"==typeof a?a:r.keyFn,"function"==typeof u&&(r.read=u),s(r,c)}r.read&&r.merge&&(r.keyFn=r.keyFn||Nm)})},e.prototype.setRootTypename=function(e,t){void 0===t&&(t=e);var n="ROOT_"+e.toUpperCase(),r=this.rootTypenamesById[n];t!==r&&(Vl(!r||r===e,6,e),r&&delete this.rootIdsByTypename[r],this.rootIdsByTypename[t]=n,this.rootTypenamesById[n]=t)},e.prototype.addPossibleTypes=function(e){var t=this;this.usingPossibleTypes=!0,Object.keys(e).forEach(function(n){t.getSupertypeSet(n,!0),e[n].forEach(function(e){t.getSupertypeSet(e,!0).add(n);var r=e.match(tm);r&&r[0]===e||t.fuzzySubtypes.set(e,new RegExp(e))})})},e.prototype.getTypePolicy=function(e){var t=this;if(!Jy.call(this.typePolicies,e)){var n=this.typePolicies[e]=Object.create(null);n.fields=Object.create(null);var r=this.supertypeMap.get(e);!r&&this.fuzzySubtypes.size&&(r=this.getSupertypeSet(e,!0),this.fuzzySubtypes.forEach(function(n,i){if(n.test(e)){var o=t.supertypeMap.get(i);o&&o.forEach(function(e){return r.add(e)})}})),r&&r.size&&r.forEach(function(e){var r=t.getTypePolicy(e),i=r.fields,o=Tl(r,["fields"]);Object.assign(n,o),Object.assign(n.fields,i)})}var i=this.toBeAdded[e];return i&&i.length&&i.splice(0).forEach(function(n){t.updateTypePolicy(e,n,t.typePolicies[e].fields)}),this.typePolicies[e]},e.prototype.getFieldPolicy=function(e,t){if(e)return this.getTypePolicy(e).fields[t]},e.prototype.getSupertypeSet=function(e,t){var n=this.supertypeMap.get(e);return!n&&t&&this.supertypeMap.set(e,n=new Set),n},e.prototype.fragmentMatches=function(e,t,n,r){var i=this;if(!e.typeCondition)return!0;if(!t)return!1;var o=e.typeCondition.name.value;if(t===o)return!0;if(this.usingPossibleTypes&&this.supertypeMap.has(o))for(var s=this.getSupertypeSet(t,!0),a=[s],u=function(e){var t=i.getSupertypeSet(e,!1);t&&t.size&&a.indexOf(t)<0&&a.push(t)},c=!(!n||!this.fuzzySubtypes.size),l=!1,h=0;h<a.length;++h){var f=a[h];if(f.has(o))return s.has(o)||(l&&!1!==globalThis.__DEV__&&Vl.warn(7,t,o),s.add(o)),!0;f.forEach(u),c&&h===a.length-1&&rm(e.selectionSet,n,r)&&(c=!1,l=!0,this.fuzzySubtypes.forEach(function(e,n){var r=t.match(e);r&&r[0]===t&&u(n)}))}return!1},e.prototype.hasKeyArgs=function(e,t){var n=this.getFieldPolicy(e,t);return!(!n||!n.keyFn)},e.prototype.getStoreFieldName=function(e){var t,n=e.typename,r=e.fieldName,i=this.getFieldPolicy(n,r),o=i&&i.keyFn;if(o&&n)for(var s={typename:n,fieldName:r,field:e.field||null,variables:e.variables},a=Mm(e);o;){var u=o(a,s);if(!zd(u)){t=u||r;break}o=Tm(u)}return void 0===t&&(t=e.field?function(e,t){var n=null;e.directives&&(n={},e.directives.forEach(function(e){n[e.name.value]={},e.arguments&&e.arguments.forEach(function(r){var i=r.name,o=r.value;return hf(n[e.name.value],i,o,t)})}));var r=null;return e.arguments&&e.arguments.length&&(r={},e.arguments.forEach(function(e){var n=e.name,i=e.value;return hf(r,n,i,t)})),pf(e.name.value,r,n)}(e.field,e.variables):pf(r,Mm(e))),!1===t?r:r===nm(t)?t:r+":"+t},e.prototype.readField=function(e,t){var n=e.from;if(n&&(e.field||e.fieldName)){if(void 0===e.typename){var r=t.store.getFieldValue(n,"__typename");r&&(e.typename=r)}var i=this.getStoreFieldName(e),o=nm(i),s=t.store.getFieldValue(n,i),a=this.getFieldPolicy(e.typename,o),u=a&&a.read;if(u){var c=Pm(this,n,e,t,t.store.getStorage(lf(n)?n.__ref:n,i));return Uy.withValue(this.cache,u,[s,c])}return s}},e.prototype.getReadFunction=function(e,t){var n=this.getFieldPolicy(e,t);return n&&n.read},e.prototype.getMergeFunction=function(e,t,n){var r=this.getFieldPolicy(e,t),i=r&&r.merge;return!i&&n&&(i=(r=this.getTypePolicy(n))&&r.merge),i},e.prototype.runMergeFunction=function(e,t,n,r,i){var o=n.field,s=n.typename,a=n.merge;return a===jm?Fm(r.store)(e,t):a===Dm?t:(r.overwrite&&(e=void 0),a(e,t,Pm(this,void 0,{typename:s,fieldName:o.name.value,field:o,variables:r.variables},r,i||Object.create(null))))},e}();function Pm(e,t,n,r,i){var o=e.getStoreFieldName(n),s=nm(o),a=n.variables||r.variables,u=r.store,c=u.toReference,l=u.canRead;return{args:Mm(n),field:n.field||null,fieldName:s,storeFieldName:o,variables:a,isReference:lf,toReference:c,storage:i,cache:e.cache,canRead:l,readField:function(){return e.readField(Bm(arguments,t,a),r)},mergeObjects:Fm(r.store)}}function Bm(e,t,n){var r,i=e[0],o=e[1],s=e.length;return"string"==typeof i?r={fieldName:i,from:s>1?o:t}:(r=Sl({},i),Jy.call(r,"from")||(r.from=t)),!1!==globalThis.__DEV__&&void 0===r.from&&!1!==globalThis.__DEV__&&Vl.warn(8,ql(Array.from(e))),void 0===r.variables&&(r.variables=n),r}function Fm(e){return function(t,n){if(zd(t)||zd(n))throw zl(9);if(gh(t)&&gh(n)){var r=e.getFieldValue(t,"__typename"),i=e.getFieldValue(n,"__typename");if(r&&i&&r!==i)return n;if(lf(t)&&im(n))return e.merge(t.__ref,n),t;if(im(t)&&lf(n))return e.merge(t,n.__ref),n;if(im(t)&&im(n))return Sl(Sl({},t),n)}return n}}function Um(e,t,n){var r="".concat(t).concat(n),i=e.flavors.get(r);return i||e.flavors.set(r,i=e.clientOnly===t&&e.deferred===n?e:Sl(Sl({},e),{clientOnly:t,deferred:n})),i}var Lm=function(){function e(e,t,n){this.cache=e,this.reader=t,this.fragments=n}return e.prototype.writeToStore=function(e,t){var n=this,r=t.query,i=t.result,o=t.dataId,s=t.variables,a=t.overwrite,u=wf(r),c=new Jd;s=Sl(Sl({},xf(u)),s);var l=Sl(Sl({store:e,written:Object.create(null),merge:function(e,t){return c.merge(e,t)},variables:s,varString:sf(s)},om(r,this.fragments)),{overwrite:!!a,incomingById:new Map,clientOnly:!1,deferred:!1,flavors:new Map}),h=this.processSelectionSet({result:i||Object.create(null),dataId:o,selectionSet:u.selectionSet,mergeTree:{map:new Map},context:l});if(!lf(h))throw zl(12,i);return l.incomingById.forEach(function(t,r){var i=t.storeObject,o=t.mergeTree,s=t.fieldNodeSet,a=cf(r);if(o&&o.map.size){var u=n.applyMerges(o,a,i,l);if(lf(u))return;i=u}if(!1!==globalThis.__DEV__&&!l.overwrite){var c=Object.create(null);s.forEach(function(e){e.selectionSet&&(c[e.name.value]=!0)});Object.keys(i).forEach(function(e){(function(e){return!0===c[nm(e)]})(e)&&!function(e){var t=o&&o.map.get(e);return Boolean(t&&t.info&&t.info.merge)}(e)&&function(e,t,n,r){var i=function(e){var t=r.getFieldValue(e,n);return"object"==typeof t&&t},o=i(e);if(!o)return;var s=i(t);if(!s)return;if(lf(o))return;if($p(o,s))return;if(Object.keys(o).every(function(e){return void 0!==r.getFieldValue(s,e)}))return;var a=r.getFieldValue(e,"__typename")||r.getFieldValue(t,"__typename"),u=nm(n),c="".concat(a,".").concat(u);if(Wm.has(c))return;Wm.add(c);var l=[];zd(o)||zd(s)||[o,s].forEach(function(e){var t=r.getFieldValue(e,"__typename");"string"!=typeof t||l.includes(t)||l.push(t)});!1!==globalThis.__DEV__&&Vl.warn(15,u,a,l.length?"either ensure all objects of type "+l.join(" and ")+" have an ID or a custom merge function, or ":"",c,Sl({},o),Sl({},s))}(a,i,e,l.store)})}e.merge(r,i)}),e.retain(h.__ref),h},e.prototype.processSelectionSet=function(e){var t=this,n=e.dataId,r=e.result,i=e.selectionSet,o=e.context,s=e.mergeTree,a=this.cache.policies,u=Object.create(null),c=n&&a.rootTypenamesById[n]||gf(r,i,o.fragmentMap)||n&&o.store.get(n,"__typename");"string"==typeof c&&(u.__typename=c);var l=function(){var e=Bm(arguments,u,o.variables);if(lf(e.from)){var t=o.incomingById.get(e.from.__ref);if(t){var n=a.readField(Sl(Sl({},e),{from:t.storeObject}),o);if(void 0!==n)return n}}return a.readField(e,o)},h=new Set;this.flattenFields(i,r,o,c).forEach(function(e,n){var i,o=mf(n),f=r[o];if(h.add(n),void 0!==f){var d=a.getStoreFieldName({typename:c,fieldName:n.name.value,field:n,variables:e.variables}),p=$m(s,d),y=t.processFieldValue(f,n,n.selectionSet?Um(e,!1,!1):e,p),m=void 0;n.selectionSet&&(lf(y)||im(y))&&(m=l("__typename",y));var g=a.getMergeFunction(c,n.name.value,m);g?p.info={field:n,typename:c,merge:g}:Km(s,d),u=e.merge(u,((i={})[d]=y,i))}else!1===globalThis.__DEV__||e.clientOnly||e.deferred||Ip.added(n)||a.getReadFunction(c,n.name.value)||!1!==globalThis.__DEV__&&Vl.error(13,mf(n),r)});try{var f=a.identify(r,{typename:c,selectionSet:i,fragmentMap:o.fragmentMap,storeObject:u,readField:l}),d=f[0],p=f[1];n=n||d,p&&(u=o.merge(u,p))}catch(e){if(!n)throw e}if("string"==typeof n){var y=cf(n),m=o.written[n]||(o.written[n]=[]);if(m.indexOf(i)>=0)return y;if(m.push(i),this.reader&&this.reader.isFresh(r,y,i,o))return y;var g=o.incomingById.get(n);return g?(g.storeObject=o.merge(g.storeObject,u),g.mergeTree=Vm(g.mergeTree,s),h.forEach(function(e){return g.fieldNodeSet.add(e)})):o.incomingById.set(n,{storeObject:u,mergeTree:zm(s)?void 0:s,fieldNodeSet:h}),y}return u},e.prototype.processFieldValue=function(e,t,n,r){var i=this;return t.selectionSet&&null!==e?zd(e)?e.map(function(e,o){var s=i.processFieldValue(e,t,n,$m(r,o));return Km(r,o),s}):this.processSelectionSet({result:e,selectionSet:t.selectionSet,context:n,mergeTree:r}):!1!==globalThis.__DEV__?uy(e):e},e.prototype.flattenFields=function(e,t,n,r){void 0===r&&(r=gf(t,e,n.fragmentMap));var i=new Map,o=this.cache.policies,s=new Af(!1);return function e(a,u){var c=s.lookup(a,u.clientOnly,u.deferred);c.visited||(c.visited=!0,a.selections.forEach(function(s){if(_d(s,n.variables)){var a=u.clientOnly,c=u.deferred;if(a&&c||!Kd(s.directives)||s.directives.forEach(function(e){var t=e.name.value;if("client"===t&&(a=!0),"defer"===t){var r=yf(e,n.variables);r&&!1===r.if||(c=!0)}}),bf(s)){var l=i.get(s);l&&(a=a&&l.clientOnly,c=c&&l.deferred),i.set(s,Um(n,a,c))}else{var h=Nh(s,n.lookupFragment);if(!h&&s.kind===Td.FRAGMENT_SPREAD)throw zl(14,s.name.value);h&&o.fragmentMatches(h,r,t,n.variables)&&e(h.selectionSet,Um(n,a,c))}}}))}(e,n),i},e.prototype.applyMerges=function(e,t,n,r,i){var o,s=this;if(e.map.size&&!lf(n)){var a,u=zd(n)||!lf(t)&&!im(t)?void 0:t,c=n;u&&!i&&(i=[lf(u)?u.__ref:u]);var l=function(e,t){return zd(e)?"number"==typeof t?e[t]:void 0:r.store.getFieldValue(e,String(t))};e.map.forEach(function(e,t){var n=l(u,t),o=l(c,t);if(void 0!==o){i&&i.push(t);var h=s.applyMerges(e,n,o,r,i);h!==o&&(a=a||new Map).set(t,h),i&&Vl(i.pop()===t)}}),a&&(n=zd(c)?c.slice(0):Sl({},c),a.forEach(function(e,t){n[t]=e}))}return e.info?this.cache.policies.runMergeFunction(t,n,e.info,r,i&&(o=r.store).getStorage.apply(o,i)):n},e}(),qm=[];function $m(e,t){var n=e.map;return n.has(t)||n.set(t,qm.pop()||{map:new Map}),n.get(t)}function Vm(e,t){if(e===t||!t||zm(t))return e;if(!e||zm(e))return t;var n=e.info&&t.info?Sl(Sl({},e.info),t.info):e.info||t.info,r=e.map.size&&t.map.size,i={info:n,map:r?new Map:e.map.size?e.map:t.map};if(r){var o=new Set(t.map.keys());e.map.forEach(function(e,n){i.map.set(n,Vm(e,t.map.get(n))),o.delete(n)}),o.forEach(function(n){i.map.set(n,Vm(t.map.get(n),e.map.get(n)))})}return i}function zm(e){return!e||!(e.info||e.map.size)}function Km(e,t){var n=e.map,r=n.get(t);r&&zm(r)&&(qm.push(r),n.delete(t))}var Wm=new Set;var Qm=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return n.watches=new Set,n.addTypenameTransform=new Jp(Ip),n.assumeImmutableResults=!0,n.makeVar=Vy,n.txCount=0,!1!==globalThis.__DEV__&&(bd(t,"addTypename","InMemoryCache","Please remove the `addTypename` option when initializing `InMemoryCache`."),bd(t,"canonizeResults","InMemoryCache","Please remove the `canonizeResults` option when initializing `InMemoryCache`.")),n.config=function(e){return sy(Xy,e)}(t),n.addTypename=!!n.config.addTypename,n.policies=new Rm({cache:n,dataIdFromObject:n.config.dataIdFromObject,possibleTypes:n.config.possibleTypes,typePolicies:n.config.typePolicies}),n.init(),n}return kl(t,e),t.prototype.init=function(){var e=this.data=new cm.Root({policies:this.policies,resultCaching:this.config.resultCaching});this.optimisticData=e.stump,this.resetResultCache()},t.prototype.resetResultCache=function(e){var t=this,n=this.storeReader,r=this.config.fragments;this.addTypenameTransform.resetCache(),null==r||r.resetCaches(),this.storeWriter=new Lm(this,this.storeReader=new vm({cache:this,addTypename:this.addTypename,resultCacheMaxSize:this.config.resultCacheMaxSize,canonizeResults:em(this.config),canon:e?void 0:n&&n.canon,fragments:r}),r),this.maybeBroadcastWatch=dd(function(e,n){return t.broadcastWatch(e,n)},{max:this.config.resultCacheMaxSize||Wh["inMemoryCache.maybeBroadcastWatch"]||5e3,makeCacheKey:function(e){var n=e.optimistic?t.optimisticData:t.data;if(mm(n)){var r=e.optimistic,i=e.id,o=e.variables;return n.makeCacheKey(e.query,e.callback,sf({optimistic:r,id:i,variables:o}))}}}),new Set([this.data.group,this.optimisticData.group]).forEach(function(e){return e.resetCaching()})},t.prototype.restore=function(e){return this.init(),e&&this.data.replace(e),this},t.prototype.extract=function(e){return void 0===e&&(e=!1),(e?this.optimisticData:this.data).extract()},t.prototype.read=function(e){!1!==globalThis.__DEV__&&bd(e,"canonizeResults","cache.read");var t=e.returnPartialData,n=void 0!==t&&t;try{return this.storeReader.diffQueryAgainstStore(Sl(Sl({},e),{store:e.optimistic?this.optimisticData:this.data,config:this.config,returnPartialData:n})).result||null}catch(e){if(e instanceof Hy)return null;throw e}},t.prototype.write=function(e){try{return++this.txCount,this.storeWriter.writeToStore(this.data,e)}finally{--this.txCount||!1===e.broadcast||this.broadcastWatches()}},t.prototype.modify=function(e){if(Jy.call(e,"id")&&!e.id)return!1;var t=e.optimistic?this.optimisticData:this.data;try{return++this.txCount,t.modify(e.id||"ROOT_QUERY",e.fields)}finally{--this.txCount||!1===e.broadcast||this.broadcastWatches()}},t.prototype.diff=function(e){return!1!==globalThis.__DEV__&&bd(e,"canonizeResults","cache.diff"),this.storeReader.diffQueryAgainstStore(Sl(Sl({},e),{store:e.optimistic?this.optimisticData:this.data,rootId:e.id||"ROOT_QUERY",config:this.config}))},t.prototype.watch=function(e){var t,n=this;return this.watches.size||qy(t=this).vars.forEach(function(e){return e.attachCache(t)}),this.watches.add(e),e.immediate&&this.maybeBroadcastWatch(e),function(){n.watches.delete(e)&&!n.watches.size&&$y(n),n.maybeBroadcastWatch.forget(e)}},t.prototype.gc=function(e){!1!==globalThis.__DEV__&&bd(e||{},"resetResultIdentities","cache.gc","First ensure all usages of `canonizeResults` are removed, then remove this option."),sf.reset(),mp.reset();var t=this.optimisticData.gc();return e&&!this.txCount&&(e.resetResultCache?this.resetResultCache(e.resetResultIdentities):e.resetResultIdentities&&this.storeReader.resetCanon()),t},t.prototype.retain=function(e,t){return(t?this.optimisticData:this.data).retain(e)},t.prototype.release=function(e,t){return(t?this.optimisticData:this.data).release(e)},t.prototype.identify=function(e){if(lf(e))return e.__ref;try{return this.policies.identify(e)[0]}catch(e){!1!==globalThis.__DEV__&&Vl.warn(e)}},t.prototype.evict=function(e){if(!e.id){if(Jy.call(e,"id"))return!1;e=Sl(Sl({},e),{id:"ROOT_QUERY"})}try{return++this.txCount,this.optimisticData.evict(e,this.data)}finally{--this.txCount||!1===e.broadcast||this.broadcastWatches()}},t.prototype.reset=function(e){var t=this;return this.init(),sf.reset(),e&&e.discardWatches?(this.watches.forEach(function(e){return t.maybeBroadcastWatch.forget(e)}),this.watches.clear(),$y(this)):this.broadcastWatches(),Promise.resolve()},t.prototype.removeOptimistic=function(e){var t=this.optimisticData.removeLayer(e);t!==this.optimisticData&&(this.optimisticData=t,this.broadcastWatches())},t.prototype.batch=function(e){var t,n=this,r=e.update,i=e.optimistic,o=void 0===i||i,s=e.removeOptimistic,a=e.onWatchUpdated,u=function(e){var i=n,o=i.data,s=i.optimisticData;++n.txCount,e&&(n.data=n.optimisticData=e);try{return t=r(n)}finally{--n.txCount,n.data=o,n.optimisticData=s}},c=new Set;return a&&!this.txCount&&this.broadcastWatches(Sl(Sl({},e),{onWatchUpdated:function(e){return c.add(e),!1}})),"string"==typeof o?this.optimisticData=this.optimisticData.addLayer(o,u):!1===o?u(this.data):u(),"string"==typeof s&&(this.optimisticData=this.optimisticData.removeLayer(s)),a&&c.size?(this.broadcastWatches(Sl(Sl({},e),{onWatchUpdated:function(e,t){var n=a.call(this,e,t);return!1!==n&&c.delete(e),n}})),c.size&&c.forEach(function(e){return n.maybeBroadcastWatch.dirty(e)})):this.broadcastWatches(e),t},t.prototype.performTransaction=function(e,t){return this.batch({update:e,optimistic:t||null!==t})},t.prototype.transformDocument=function(e){return this.addTypenameToDocument(this.addFragmentsToDocument(e))},t.prototype.fragmentMatches=function(e,t){return this.policies.fragmentMatches(e,t)},t.prototype.lookupFragment=function(e){var t;return(null===(t=this.config.fragments)||void 0===t?void 0:t.lookup(e))||null},t.prototype.broadcastWatches=function(e){var t=this;this.txCount||this.watches.forEach(function(n){return t.maybeBroadcastWatch(n,e)})},t.prototype.addFragmentsToDocument=function(e){var t=this.config.fragments;return t?t.transform(e):e},t.prototype.addTypenameToDocument=function(e){return this.addTypename?this.addTypenameTransform.transformDocument(e):e},t.prototype.broadcastWatch=function(e,t){var n=this,r=e.lastDiff,i=gd("canonizeResults",function(){return n.diff(e)});t&&(e.optimistic&&"string"==typeof t.optimistic&&(i.fromOptimisticTransaction=!0),t.onWatchUpdated&&!1===t.onWatchUpdated.call(this,e,i,r))||r&&$p(r.result,i.result)||e.callback(e.lastDiff=i,r)},t}(Gy);function Gm(e,t){if(!Boolean(e))throw new Error(t)}function Hm(e){return Hm="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Hm(e)}!1!==globalThis.__DEV__&&(Qm.prototype.getMemoryInternals=Jh);"function"==typeof Symbol&&null!=Symbol.iterator&&Symbol.iterator,"function"==typeof Symbol&&null!=Symbol.asyncIterator&&Symbol.asyncIterator;var Jm="function"==typeof Symbol&&null!=Symbol.toStringTag?Symbol.toStringTag:"@@toStringTag";function Zm(e,t){for(var n,r=/\r\n|[\n\r]/g,i=1,o=t+1;(n=r.exec(e.body))&&n.index<t;)i+=1,o=t+1-(n.index+n[0].length);return{line:i,column:o}}function Ym(e){return Xm(e.source,Zm(e.source,e.start))}function Xm(e,t){var n=e.locationOffset.column-1,r=tg(n)+e.body,i=t.line-1,o=e.locationOffset.line-1,s=t.line+o,a=1===t.line?n:0,u=t.column+a,c="".concat(e.name,":").concat(s,":").concat(u,"\n"),l=r.split(/\r\n|[\n\r]/g),h=l[i];if(h.length>120){for(var f=Math.floor(u/80),d=u%80,p=[],y=0;y<h.length;y+=80)p.push(h.slice(y,y+80));return c+eg([["".concat(s),p[0]]].concat(p.slice(1,f+1).map(function(e){return["",e]}),[[" ",tg(d-1)+"^"],["",p[f+1]]]))}return c+eg([["".concat(s-1),l[i-1]],["".concat(s),h],["",tg(u-1)+"^"],["".concat(s+1),l[i+1]]])}function eg(e){var t=e.filter(function(e){e[0];return void 0!==e[1]}),n=Math.max.apply(Math,t.map(function(e){return e[0].length}));return t.map(function(e){var t=e[0],r=e[1];return function(e,t){return tg(e-t.length)+t}(n,t)+(r?" | "+r:" |")}).join("\n")}function tg(e){return Array(e+1).join(" ")}function ng(e){return ng="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ng(e)}function rg(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ig(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function og(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function sg(e,t){return!t||"object"!==ng(t)&&"function"!=typeof t?ag(e):t}function ag(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ug(e){var t="function"==typeof Map?new Map:void 0;return ug=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return cg(e,arguments,fg(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),hg(r,e)},ug(e)}function cg(e,t,n){return cg=lg()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&hg(i,n.prototype),i},cg.apply(null,arguments)}function lg(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function hg(e,t){return hg=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},hg(e,t)}function fg(e){return fg=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},fg(e)}var dg=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&hg(e,t)}(a,e);var t,n,r,i,o,s=(t=a,n=lg(),function(){var e,r=fg(t);if(n){var i=fg(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return sg(this,e)});function a(e,t,n,r,i,o,u){var c,l,h,f;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(f=s.call(this,e)).name="GraphQLError",f.originalError=null!=o?o:void 0,f.nodes=pg(Array.isArray(t)?t:t?[t]:void 0);for(var d=[],p=0,y=null!==(m=f.nodes)&&void 0!==m?m:[];p<y.length;p++){var m,g=y[p].loc;null!=g&&d.push(g)}d=pg(d),f.source=null!=n?n:null===(c=d)||void 0===c?void 0:c[0].source,f.positions=null!=r?r:null===(l=d)||void 0===l?void 0:l.map(function(e){return e.start}),f.locations=r&&n?r.map(function(e){return Zm(n,e)}):null===(h=d)||void 0===h?void 0:h.map(function(e){return Zm(e.source,e.start)}),f.path=null!=i?i:void 0;var b=null==o?void 0:o.extensions;return null==u&&function(e){return"object"==Hm(e)&&null!==e}(b)?f.extensions=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rg(Object(n),!0).forEach(function(t){ig(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rg(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({},b):f.extensions=null!=u?u:{},Object.defineProperties(ag(f),{message:{enumerable:!0},locations:{enumerable:null!=f.locations},path:{enumerable:null!=f.path},extensions:{enumerable:null!=f.extensions&&Object.keys(f.extensions).length>0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),null!=o&&o.stack?(Object.defineProperty(ag(f),"stack",{value:o.stack,writable:!0,configurable:!0}),sg(f)):(Error.captureStackTrace?Error.captureStackTrace(ag(f),a):Object.defineProperty(ag(f),"stack",{value:Error().stack,writable:!0,configurable:!0}),f)}return r=a,(i=[{key:"toString",value:function(){return function(e){var t=e.message;if(e.nodes)for(var n=0,r=e.nodes;n<r.length;n++){var i=r[n];i.loc&&(t+="\n\n"+Ym(i.loc))}else if(e.source&&e.locations)for(var o=0,s=e.locations;o<s.length;o++){var a=s[o];t+="\n\n"+Xm(e.source,a)}return t}(this)}},{key:"toJSON",value:function(){return function(e){var t;e||Gm(0,"Received null or undefined error.");var n=null!==(t=e.message)&&void 0!==t?t:"An unknown error occurred.",r=e.locations,i=e.path,o=e.extensions;return o&&Object.keys(o).length>0?{message:n,locations:r,path:i,extensions:o}:{message:n,locations:r,path:i}}(this)}},{key:Jm,get:function(){return"Object"}}])&&og(r.prototype,i),o&&og(r,o),a}(ug(Error));function pg(e){return void 0===e||0===e.length?void 0:e}function yg(e,t,n){return new dg("Syntax Error: ".concat(n),void 0,e,[t])}var mg=Object.freeze({SOF:"<SOF>",EOF:"<EOF>",BANG:"!",DOLLAR:"$",AMP:"&",PAREN_L:"(",PAREN_R:")",SPREAD:"...",COLON:":",EQUALS:"=",AT:"@",BRACKET_L:"[",BRACKET_R:"]",BRACE_L:"{",PIPE:"|",BRACE_R:"}",NAME:"Name",INT:"Int",FLOAT:"Float",STRING:"String",BLOCK_STRING:"BlockString",COMMENT:"Comment"});const gg=function(e,t){return e instanceof t};function bg(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var vg=function(){function e(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GraphQL request",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{line:1,column:1};"string"==typeof e||Gm(0,"Body must be a string. Received: ".concat(wh(e),".")),this.body=e,this.name=t,this.locationOffset=n,this.locationOffset.line>0||Gm(0,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||Gm(0,"column in locationOffset is 1-indexed and must be positive.")}var t,n,r;return t=e,(n=[{key:Jm,get:function(){return"Source"}}])&&bg(t.prototype,n),r&&bg(t,r),e}();var wg=Object.freeze({QUERY:"QUERY",MUTATION:"MUTATION",SUBSCRIPTION:"SUBSCRIPTION",FIELD:"FIELD",FRAGMENT_DEFINITION:"FRAGMENT_DEFINITION",FRAGMENT_SPREAD:"FRAGMENT_SPREAD",INLINE_FRAGMENT:"INLINE_FRAGMENT",VARIABLE_DEFINITION:"VARIABLE_DEFINITION",SCHEMA:"SCHEMA",SCALAR:"SCALAR",OBJECT:"OBJECT",FIELD_DEFINITION:"FIELD_DEFINITION",ARGUMENT_DEFINITION:"ARGUMENT_DEFINITION",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",ENUM_VALUE:"ENUM_VALUE",INPUT_OBJECT:"INPUT_OBJECT",INPUT_FIELD_DEFINITION:"INPUT_FIELD_DEFINITION"}),Eg=function(){function e(e){var t=new Th(mg.SOF,0,0,0,0,null);this.source=e,this.lastToken=t,this.token=t,this.line=1,this.lineStart=0}var t=e.prototype;return t.advance=function(){return this.lastToken=this.token,this.token=this.lookahead()},t.lookahead=function(){var e=this.token;if(e.kind!==mg.EOF)do{var t;e=null!==(t=e.next)&&void 0!==t?t:e.next=Sg(this,e)}while(e.kind===mg.COMMENT);return e},e}();function kg(e){return isNaN(e)?mg.EOF:e<127?JSON.stringify(String.fromCharCode(e)):'"\\u'.concat(("00"+e.toString(16).toUpperCase()).slice(-4),'"')}function Sg(e,t){for(var n=e.source,r=n.body,i=r.length,o=t.end;o<i;){var s=r.charCodeAt(o),a=e.line,u=1+o-e.lineStart;switch(s){case 65279:case 9:case 32:case 44:++o;continue;case 10:++o,++e.line,e.lineStart=o;continue;case 13:10===r.charCodeAt(o+1)?o+=2:++o,++e.line,e.lineStart=o;continue;case 33:return new Th(mg.BANG,o,o+1,a,u,t);case 35:return _g(n,o,a,u,t);case 36:return new Th(mg.DOLLAR,o,o+1,a,u,t);case 38:return new Th(mg.AMP,o,o+1,a,u,t);case 40:return new Th(mg.PAREN_L,o,o+1,a,u,t);case 41:return new Th(mg.PAREN_R,o,o+1,a,u,t);case 46:if(46===r.charCodeAt(o+1)&&46===r.charCodeAt(o+2))return new Th(mg.SPREAD,o,o+3,a,u,t);break;case 58:return new Th(mg.COLON,o,o+1,a,u,t);case 61:return new Th(mg.EQUALS,o,o+1,a,u,t);case 64:return new Th(mg.AT,o,o+1,a,u,t);case 91:return new Th(mg.BRACKET_L,o,o+1,a,u,t);case 93:return new Th(mg.BRACKET_R,o,o+1,a,u,t);case 123:return new Th(mg.BRACE_L,o,o+1,a,u,t);case 124:return new Th(mg.PIPE,o,o+1,a,u,t);case 125:return new Th(mg.BRACE_R,o,o+1,a,u,t);case 34:return 34===r.charCodeAt(o+1)&&34===r.charCodeAt(o+2)?Cg(n,o,a,u,t,e):Ig(n,o,a,u,t);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return xg(n,o,s,a,u,t);case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 95:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:return Ng(n,o,a,u,t)}throw yg(n,o,Tg(s))}var c=e.line,l=1+o-e.lineStart;return new Th(mg.EOF,i,i,c,l,t)}function Tg(e){return e<32&&9!==e&&10!==e&&13!==e?"Cannot contain the invalid character ".concat(kg(e),"."):39===e?"Unexpected single quote character ('), did you mean to use a double quote (\")?":"Cannot parse the unexpected character ".concat(kg(e),".")}function _g(e,t,n,r,i){var o,s=e.body,a=t;do{o=s.charCodeAt(++a)}while(!isNaN(o)&&(o>31||9===o));return new Th(mg.COMMENT,t,a,n,r,i,s.slice(t+1,a))}function xg(e,t,n,r,i,o){var s=e.body,a=n,u=t,c=!1;if(45===a&&(a=s.charCodeAt(++u)),48===a){if((a=s.charCodeAt(++u))>=48&&a<=57)throw yg(e,u,"Invalid number, unexpected digit after 0: ".concat(kg(a),"."))}else u=Og(e,u,a),a=s.charCodeAt(u);if(46===a&&(c=!0,a=s.charCodeAt(++u),u=Og(e,u,a),a=s.charCodeAt(u)),69!==a&&101!==a||(c=!0,43!==(a=s.charCodeAt(++u))&&45!==a||(a=s.charCodeAt(++u)),u=Og(e,u,a),a=s.charCodeAt(u)),46===a||function(e){return 95===e||e>=65&&e<=90||e>=97&&e<=122}(a))throw yg(e,u,"Invalid number, expected digit but got: ".concat(kg(a),"."));return new Th(c?mg.FLOAT:mg.INT,t,u,r,i,o,s.slice(t,u))}function Og(e,t,n){var r=e.body,i=t,o=n;if(o>=48&&o<=57){do{o=r.charCodeAt(++i)}while(o>=48&&o<=57);return i}throw yg(e,i,"Invalid number, expected digit but got: ".concat(kg(o),"."))}function Ig(e,t,n,r,i){for(var o=e.body,s=t+1,a=s,u=0,c="";s<o.length&&!isNaN(u=o.charCodeAt(s))&&10!==u&&13!==u;){if(34===u)return c+=o.slice(a,s),new Th(mg.STRING,t,s+1,n,r,i,c);if(u<32&&9!==u)throw yg(e,s,"Invalid character within String: ".concat(kg(u),"."));if(++s,92===u){switch(c+=o.slice(a,s-1),u=o.charCodeAt(s)){case 34:c+='"';break;case 47:c+="/";break;case 92:c+="\\";break;case 98:c+="\b";break;case 102:c+="\f";break;case 110:c+="\n";break;case 114:c+="\r";break;case 116:c+="\t";break;case 117:var l=Mg(o.charCodeAt(s+1),o.charCodeAt(s+2),o.charCodeAt(s+3),o.charCodeAt(s+4));if(l<0){var h=o.slice(s+1,s+5);throw yg(e,s,"Invalid character escape sequence: \\u".concat(h,"."))}c+=String.fromCharCode(l),s+=4;break;default:throw yg(e,s,"Invalid character escape sequence: \\".concat(String.fromCharCode(u),"."))}a=++s}}throw yg(e,s,"Unterminated string.")}function Cg(e,t,n,r,i,o){for(var s=e.body,a=t+3,u=a,c=0,l="";a<s.length&&!isNaN(c=s.charCodeAt(a));){if(34===c&&34===s.charCodeAt(a+1)&&34===s.charCodeAt(a+2))return l+=s.slice(u,a),new Th(mg.BLOCK_STRING,t,a+3,n,r,i,op(l));if(c<32&&9!==c&&10!==c&&13!==c)throw yg(e,a,"Invalid character within String: ".concat(kg(c),"."));10===c?(++a,++o.line,o.lineStart=a):13===c?(10===s.charCodeAt(a+1)?a+=2:++a,++o.line,o.lineStart=a):92===c&&34===s.charCodeAt(a+1)&&34===s.charCodeAt(a+2)&&34===s.charCodeAt(a+3)?(l+=s.slice(u,a)+'"""',u=a+=4):++a}throw yg(e,a,"Unterminated string.")}function Mg(e,t,n,r){return Ag(e)<<12|Ag(t)<<8|Ag(n)<<4|Ag(r)}function Ag(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function Ng(e,t,n,r,i){for(var o=e.body,s=o.length,a=t+1,u=0;a!==s&&!isNaN(u=o.charCodeAt(a))&&(95===u||u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122);)++a;return new Th(mg.NAME,t,a,n,r,i,o.slice(t,a))}var jg=function(){function e(e,t){var n=function(e){return gg(e,vg)}(e)?e:new vg(e);this._lexer=new Eg(n),this._options=t}var t=e.prototype;return t.parseName=function(){var e=this.expectToken(mg.NAME);return{kind:Td.NAME,value:e.value,loc:this.loc(e)}},t.parseDocument=function(){var e=this._lexer.token;return{kind:Td.DOCUMENT,definitions:this.many(mg.SOF,this.parseDefinition,mg.EOF),loc:this.loc(e)}},t.parseDefinition=function(){if(this.peek(mg.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek(mg.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},t.parseOperationDefinition=function(){var e=this._lexer.token;if(this.peek(mg.BRACE_L))return{kind:Td.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(e)};var t,n=this.parseOperationType();return this.peek(mg.NAME)&&(t=this.parseName()),{kind:Td.OPERATION_DEFINITION,operation:n,name:t,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseOperationType=function(){var e=this.expectToken(mg.NAME);switch(e.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(e)},t.parseVariableDefinitions=function(){return this.optionalMany(mg.PAREN_L,this.parseVariableDefinition,mg.PAREN_R)},t.parseVariableDefinition=function(){var e=this._lexer.token;return{kind:Td.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(mg.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(mg.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(e)}},t.parseVariable=function(){var e=this._lexer.token;return this.expectToken(mg.DOLLAR),{kind:Td.VARIABLE,name:this.parseName(),loc:this.loc(e)}},t.parseSelectionSet=function(){var e=this._lexer.token;return{kind:Td.SELECTION_SET,selections:this.many(mg.BRACE_L,this.parseSelection,mg.BRACE_R),loc:this.loc(e)}},t.parseSelection=function(){return this.peek(mg.SPREAD)?this.parseFragment():this.parseField()},t.parseField=function(){var e,t,n=this._lexer.token,r=this.parseName();return this.expectOptionalToken(mg.COLON)?(e=r,t=this.parseName()):t=r,{kind:Td.FIELD,alias:e,name:t,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(mg.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(n)}},t.parseArguments=function(e){var t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(mg.PAREN_L,t,mg.PAREN_R)},t.parseArgument=function(){var e=this._lexer.token,t=this.parseName();return this.expectToken(mg.COLON),{kind:Td.ARGUMENT,name:t,value:this.parseValueLiteral(!1),loc:this.loc(e)}},t.parseConstArgument=function(){var e=this._lexer.token;return{kind:Td.ARGUMENT,name:this.parseName(),value:(this.expectToken(mg.COLON),this.parseValueLiteral(!0)),loc:this.loc(e)}},t.parseFragment=function(){var e=this._lexer.token;this.expectToken(mg.SPREAD);var t=this.expectOptionalKeyword("on");return!t&&this.peek(mg.NAME)?{kind:Td.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(e)}:{kind:Td.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentDefinition=function(){var e,t=this._lexer.token;return this.expectKeyword("fragment"),!0===(null===(e=this._options)||void 0===e?void 0:e.experimentalFragmentVariables)?{kind:Td.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(t)}:{kind:Td.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(t)}},t.parseFragmentName=function(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()},t.parseValueLiteral=function(e){var t=this._lexer.token;switch(t.kind){case mg.BRACKET_L:return this.parseList(e);case mg.BRACE_L:return this.parseObject(e);case mg.INT:return this._lexer.advance(),{kind:Td.INT,value:t.value,loc:this.loc(t)};case mg.FLOAT:return this._lexer.advance(),{kind:Td.FLOAT,value:t.value,loc:this.loc(t)};case mg.STRING:case mg.BLOCK_STRING:return this.parseStringLiteral();case mg.NAME:switch(this._lexer.advance(),t.value){case"true":return{kind:Td.BOOLEAN,value:!0,loc:this.loc(t)};case"false":return{kind:Td.BOOLEAN,value:!1,loc:this.loc(t)};case"null":return{kind:Td.NULL,loc:this.loc(t)};default:return{kind:Td.ENUM,value:t.value,loc:this.loc(t)}}case mg.DOLLAR:if(!e)return this.parseVariable()}throw this.unexpected()},t.parseStringLiteral=function(){var e=this._lexer.token;return this._lexer.advance(),{kind:Td.STRING,value:e.value,block:e.kind===mg.BLOCK_STRING,loc:this.loc(e)}},t.parseList=function(e){var t=this,n=this._lexer.token;return{kind:Td.LIST,values:this.any(mg.BRACKET_L,function(){return t.parseValueLiteral(e)},mg.BRACKET_R),loc:this.loc(n)}},t.parseObject=function(e){var t=this,n=this._lexer.token;return{kind:Td.OBJECT,fields:this.any(mg.BRACE_L,function(){return t.parseObjectField(e)},mg.BRACE_R),loc:this.loc(n)}},t.parseObjectField=function(e){var t=this._lexer.token,n=this.parseName();return this.expectToken(mg.COLON),{kind:Td.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e),loc:this.loc(t)}},t.parseDirectives=function(e){for(var t=[];this.peek(mg.AT);)t.push(this.parseDirective(e));return t},t.parseDirective=function(e){var t=this._lexer.token;return this.expectToken(mg.AT),{kind:Td.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e),loc:this.loc(t)}},t.parseTypeReference=function(){var e,t=this._lexer.token;return this.expectOptionalToken(mg.BRACKET_L)?(e=this.parseTypeReference(),this.expectToken(mg.BRACKET_R),e={kind:Td.LIST_TYPE,type:e,loc:this.loc(t)}):e=this.parseNamedType(),this.expectOptionalToken(mg.BANG)?{kind:Td.NON_NULL_TYPE,type:e,loc:this.loc(t)}:e},t.parseNamedType=function(){var e=this._lexer.token;return{kind:Td.NAMED_TYPE,name:this.parseName(),loc:this.loc(e)}},t.parseTypeSystemDefinition=function(){var e=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(e.kind===mg.NAME)switch(e.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}throw this.unexpected(e)},t.peekDescription=function(){return this.peek(mg.STRING)||this.peek(mg.BLOCK_STRING)},t.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},t.parseSchemaDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("schema");var n=this.parseDirectives(!0),r=this.many(mg.BRACE_L,this.parseOperationTypeDefinition,mg.BRACE_R);return{kind:Td.SCHEMA_DEFINITION,description:t,directives:n,operationTypes:r,loc:this.loc(e)}},t.parseOperationTypeDefinition=function(){var e=this._lexer.token,t=this.parseOperationType();this.expectToken(mg.COLON);var n=this.parseNamedType();return{kind:Td.OPERATION_TYPE_DEFINITION,operation:t,type:n,loc:this.loc(e)}},t.parseScalarTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");var n=this.parseName(),r=this.parseDirectives(!0);return{kind:Td.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");var n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseDirectives(!0),o=this.parseFieldsDefinition();return{kind:Td.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o,loc:this.loc(e)}},t.parseImplementsInterfaces=function(){var e;if(!this.expectOptionalKeyword("implements"))return[];if(!0===(null===(e=this._options)||void 0===e?void 0:e.allowLegacySDLImplementsInterfaces)){var t=[];this.expectOptionalToken(mg.AMP);do{t.push(this.parseNamedType())}while(this.expectOptionalToken(mg.AMP)||this.peek(mg.NAME));return t}return this.delimitedMany(mg.AMP,this.parseNamedType)},t.parseFieldsDefinition=function(){var e;return!0===(null===(e=this._options)||void 0===e?void 0:e.allowLegacySDLEmptyFields)&&this.peek(mg.BRACE_L)&&this._lexer.lookahead().kind===mg.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany(mg.BRACE_L,this.parseFieldDefinition,mg.BRACE_R)},t.parseFieldDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(mg.COLON);var i=this.parseTypeReference(),o=this.parseDirectives(!0);return{kind:Td.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:o,loc:this.loc(e)}},t.parseArgumentDefs=function(){return this.optionalMany(mg.PAREN_L,this.parseInputValueDef,mg.PAREN_R)},t.parseInputValueDef=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(mg.COLON);var r,i=this.parseTypeReference();this.expectOptionalToken(mg.EQUALS)&&(r=this.parseValueLiteral(!0));var o=this.parseDirectives(!0);return{kind:Td.INPUT_VALUE_DEFINITION,description:t,name:n,type:i,defaultValue:r,directives:o,loc:this.loc(e)}},t.parseInterfaceTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");var n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseDirectives(!0),o=this.parseFieldsDefinition();return{kind:Td.INTERFACE_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o,loc:this.loc(e)}},t.parseUnionTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseUnionMemberTypes();return{kind:Td.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i,loc:this.loc(e)}},t.parseUnionMemberTypes=function(){return this.expectOptionalToken(mg.EQUALS)?this.delimitedMany(mg.PIPE,this.parseNamedType):[]},t.parseEnumTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseEnumValuesDefinition();return{kind:Td.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i,loc:this.loc(e)}},t.parseEnumValuesDefinition=function(){return this.optionalMany(mg.BRACE_L,this.parseEnumValueDefinition,mg.BRACE_R)},t.parseEnumValueDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseDirectives(!0);return{kind:Td.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseInputObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseInputFieldsDefinition();return{kind:Td.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInputFieldsDefinition=function(){return this.optionalMany(mg.BRACE_L,this.parseInputValueDef,mg.BRACE_R)},t.parseTypeSystemExtension=function(){var e=this._lexer.lookahead();if(e.kind===mg.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)},t.parseSchemaExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.optionalMany(mg.BRACE_L,this.parseOperationTypeDefinition,mg.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return{kind:Td.SCHEMA_EXTENSION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseScalarTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");var t=this.parseName(),n=this.parseDirectives(!0);if(0===n.length)throw this.unexpected();return{kind:Td.SCALAR_TYPE_EXTENSION,name:t,directives:n,loc:this.loc(e)}},t.parseObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return{kind:Td.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInterfaceTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return{kind:Td.INTERFACE_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i,loc:this.loc(e)}},t.parseUnionTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:Td.UNION_TYPE_EXTENSION,name:t,directives:n,types:r,loc:this.loc(e)}},t.parseEnumTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:Td.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r,loc:this.loc(e)}},t.parseInputObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:Td.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseDirectiveDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(mg.AT);var n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var o=this.parseDirectiveLocations();return{kind:Td.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:o,loc:this.loc(e)}},t.parseDirectiveLocations=function(){return this.delimitedMany(mg.PIPE,this.parseDirectiveLocation)},t.parseDirectiveLocation=function(){var e=this._lexer.token,t=this.parseName();if(void 0!==wg[t.value])return t;throw this.unexpected(e)},t.loc=function(e){var t;if(!0!==(null===(t=this._options)||void 0===t?void 0:t.noLocation))return new Sh(e,this._lexer.lastToken,this._lexer.source)},t.peek=function(e){return this._lexer.token.kind===e},t.expectToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t;throw yg(this._lexer.source,t.start,"Expected ".concat(Rg(e),", found ").concat(Dg(t),"."))},t.expectOptionalToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t},t.expectKeyword=function(e){var t=this._lexer.token;if(t.kind!==mg.NAME||t.value!==e)throw yg(this._lexer.source,t.start,'Expected "'.concat(e,'", found ').concat(Dg(t),"."));this._lexer.advance()},t.expectOptionalKeyword=function(e){var t=this._lexer.token;return t.kind===mg.NAME&&t.value===e&&(this._lexer.advance(),!0)},t.unexpected=function(e){var t=null!=e?e:this._lexer.token;return yg(this._lexer.source,t.start,"Unexpected ".concat(Dg(t),"."))},t.any=function(e,t,n){this.expectToken(e);for(var r=[];!this.expectOptionalToken(n);)r.push(t.call(this));return r},t.optionalMany=function(e,t,n){if(this.expectOptionalToken(e)){var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r}return[]},t.many=function(e,t,n){this.expectToken(e);var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r},t.delimitedMany=function(e,t){this.expectOptionalToken(e);var n=[];do{n.push(t.call(this))}while(this.expectOptionalToken(e));return n},e}();function Dg(e){var t=e.value;return Rg(e.kind)+(null!=t?' "'.concat(t,'"'):"")}function Rg(e){return function(e){return e===mg.BANG||e===mg.DOLLAR||e===mg.AMP||e===mg.PAREN_L||e===mg.PAREN_R||e===mg.SPREAD||e===mg.COLON||e===mg.EQUALS||e===mg.AT||e===mg.BRACKET_L||e===mg.BRACKET_R||e===mg.BRACE_L||e===mg.PIPE||e===mg.BRACE_R}(e)?'"'.concat(e,'"'):e}var Pg=new Map,Bg=new Map,Fg=!0,Ug=!1;function Lg(e){return e.replace(/[\s,]+/g," ").trim()}function qg(e){var t=new Set,n=[];return e.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var r=e.name.value,i=Lg((s=e.loc).source.body.substring(s.start,s.end)),o=Bg.get(r);o&&!o.has(i)?Fg&&console.warn("Warning: fragment with name "+r+" already exists.\ngraphql-tag enforces all fragment names across your application to be unique; read more about\nthis in the docs: http://dev.apollodata.com/core/fragments.html#unique-names"):o||Bg.set(r,o=new Set),o.add(i),t.has(i)||(t.add(i),n.push(e))}else n.push(e);var s}),Sl(Sl({},e),{definitions:n})}function $g(e){var t=Lg(e);if(!Pg.has(t)){var n=function(e,t){return new jg(e,t).parseDocument()}(e,{experimentalFragmentVariables:Ug,allowLegacyFragmentVariables:Ug});if(!n||"Document"!==n.kind)throw new Error("Not a valid GraphQL document.");Pg.set(t,function(e){var t=new Set(e.definitions);t.forEach(function(e){e.loc&&delete e.loc,Object.keys(e).forEach(function(n){var r=e[n];r&&"object"==typeof r&&t.add(r)})});var n=e.loc;return n&&(delete n.startToken,delete n.endToken),e}(qg(n)))}return Pg.get(t)}function Vg(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];"string"==typeof e&&(e=[e]);var r=e[0];return t.forEach(function(t,n){t&&"Document"===t.kind?r+=t.loc.source.body:r+=t,r+=e[n+1]}),$g(r)}var zg,Kg=Vg,Wg=function(){Pg.clear(),Bg.clear()},Qg=function(){Fg=!1},Gg=function(){Ug=!0},Hg=function(){Ug=!1};(zg=Vg||(Vg={})).gql=Kg,zg.resetCaches=Wg,zg.disableFragmentWarnings=Qg,zg.enableExperimentalFragmentVariables=Gg,zg.disableExperimentalFragmentVariables=Hg,Vg.default=Vg;var Jg=function(){function e(e){var t=e.batchDebounce,n=e.batchInterval,r=e.batchMax,i=e.batchHandler,o=e.batchKey;this.batchesByKey=new Map,this.scheduledBatchTimerByKey=new Map,this.batchDebounce=t,this.batchInterval=n,this.batchMax=r||0,this.batchHandler=i,this.batchKey=o||function(){return""}}return e.prototype.enqueueRequest=function(e){var t=this,n=Sl(Sl({},e),{next:[],error:[],complete:[],subscribers:new Set}),r=this.batchKey(e.operation);return n.observable||(n.observable=new mh(function(e){var i=t.batchesByKey.get(r);i||t.batchesByKey.set(r,i=new Set);var o=0===i.size,s=0===n.subscribers.size;return n.subscribers.add(e),s&&i.add(n),e.next&&n.next.push(e.next.bind(e)),e.error&&n.error.push(e.error.bind(e)),e.complete&&n.complete.push(e.complete.bind(e)),(o||t.batchDebounce)&&t.scheduleQueueConsumption(r),i.size===t.batchMax&&t.consumeQueue(r),function(){var o;n.subscribers.delete(e)&&n.subscribers.size<1&&i.delete(n)&&i.size<1&&(t.consumeQueue(r),null===(o=i.subscription)||void 0===o||o.unsubscribe())}})),n.observable},e.prototype.consumeQueue=function(e){void 0===e&&(e="");var t=this.batchesByKey.get(e);if(this.batchesByKey.delete(e),t&&t.size){var n=[],r=[],i=[],o=[],s=[],a=[];t.forEach(function(e){n.push(e.operation),r.push(e.forward),i.push(e.observable),o.push(e.next),s.push(e.error),a.push(e.complete)});var u=this.batchHandler(n,r)||mh.of(),c=function(e){s.forEach(function(t){t&&t.forEach(function(t){return t(e)})})};return t.subscription=u.subscribe({next:function(e){if(Array.isArray(e)||(e=[e]),o.length!==e.length){var t=new Error("server returned results with length ".concat(e.length,", expected length of ").concat(o.length));return t.result=e,c(t)}e.forEach(function(e,t){o[t]&&o[t].forEach(function(t){return t(e)})})},error:c,complete:function(){a.forEach(function(e){e&&e.forEach(function(e){return e()})})}}),i}},e.prototype.scheduleQueueConsumption=function(e){var t=this;clearTimeout(this.scheduledBatchTimerByKey.get(e)),this.scheduledBatchTimerByKey.set(e,setTimeout(function(){t.consumeQueue(e),t.scheduledBatchTimerByKey.delete(e)},this.batchInterval))},e}(),Zg=function(e){function t(t){var n=e.call(this)||this,r=t||{},i=r.batchDebounce,o=r.batchInterval,s=void 0===o?10:o,a=r.batchMax,u=void 0===a?0:a,c=r.batchHandler,l=void 0===c?function(){return null}:c,h=r.batchKey,f=void 0===h?function(){return""}:h;return n.batcher=new Jg({batchDebounce:i,batchInterval:s,batchMax:u,batchHandler:l,batchKey:f}),t.batchHandler.length<=1&&(n.request=function(e){return n.batcher.enqueueRequest({operation:e})}),n}return kl(t,e),t.prototype.request=function(e,t){return this.batcher.enqueueRequest({operation:e,forward:t})},t}(Sd),Yg=Bl(function(){return fetch}),Xg=function(e){function t(t){var n=e.call(this)||this,r=t||{},i=r.uri,o=void 0===i?"/graphql":i,s=r.fetch,a=r.print,u=void 0===a?bp:a,c=r.includeExtensions,l=r.preserveHeaderCase,h=r.batchInterval,f=r.batchDebounce,d=r.batchMax,p=r.batchKey,y=r.includeUnusedVariables,m=void 0!==y&&y,g=Tl(r,["uri","fetch","print","includeExtensions","preserveHeaderCase","batchInterval","batchDebounce","batchMax","batchKey","includeUnusedVariables"]);!1!==globalThis.__DEV__&&ip(s||Yg);var b={http:{includeExtensions:c,preserveHeaderCase:l},options:g.fetchOptions,credentials:g.credentials,headers:g.headers};n.batchDebounce=f,n.batchInterval=h||10,n.batchMax=d||10;return p=p||function(e){var t=e.getContext(),n={http:t.http,options:t.fetchOptions,credentials:t.credentials,headers:t.headers};return Md(e,o)+JSON.stringify(n)},n.batcher=new Zg({batchDebounce:n.batchDebounce,batchInterval:n.batchInterval,batchMax:n.batchMax,batchKey:p,batchHandler:function(e){var t=Md(e[0],o),n=e[0].getContext(),r={};if(n.clientAwareness){var i=n.clientAwareness,a=i.name,c=i.version;a&&(r["apollographql-client-name"]=a),c&&(r["apollographql-client-version"]=c)}var l={http:n.http,options:n.fetchOptions,credentials:n.credentials,headers:Sl(Sl({},r),n.headers)};!1!==globalThis.__DEV__&&e.some(function(e){return xd(["client"],e.query)})&&!1!==globalThis.__DEV__&&Vl.warn(46);var h=e.map(function(e){var t=e.query;return xd(["client"],t)?Mp(t):t});if(h.some(function(e){return!e}))return wp(new Error("BatchHttpLink: Trying to send a client-only query to the server. To send to the server, ensure a non-client field is added to the query or enable the `transformOptions.removeClientFields` option."));var f,d=e.map(function(e,t){var n=vp(Sl(Sl({},e),{query:h[t]}),u,gp,b,l);return n.body.variables&&!m&&(n.body.variables=Ep(n.body.variables,e.query)),n}),p=d.map(function(e){return e.body}),y=d[0].options;if("GET"===y.method)return wp(new Error("apollo-link-batch-http does not support GET requests"));try{y.body=Cd(p,"Payload")}catch(e){return wp(e)}return y.signal||"undefined"==typeof AbortController||(f=new AbortController,y.signal=f.signal),new mh(function(n){return(s||Bl(function(){return fetch})||Yg)(t,y).then(function(t){return e.forEach(function(e){return e.setContext({response:t})}),t}).then(rp(e)).then(function(e){return f=void 0,n.next(e),n.complete(),e}).catch(function(e){f=void 0,e.result&&e.result.errors&&e.result.data&&n.next(e.result),n.error(e)}),function(){f&&f.abort()}})}}),n}return kl(t,e),t.prototype.request=function(e){return this.batcher.request(e)},t}(Sd);var eb=function(){function e(e,t,n,r,i){var o=this;this.observer=e,this.operation=t,this.forward=n,this.delayFor=r,this.retryIf=i,this.retryCount=0,this.currentSubscription=null,this.onError=function(e){return _l(o,void 0,void 0,function(){return xl(this,function(t){switch(t.label){case 0:return this.retryCount+=1,[4,this.retryIf(this.retryCount,this.operation,e)];case 1:return t.sent()?(this.scheduleRetry(this.delayFor(this.retryCount,this.operation,e)),[2]):(this.observer.error(e),[2])}})})},this.try()}return e.prototype.cancel=function(){this.currentSubscription&&this.currentSubscription.unsubscribe(),clearTimeout(this.timerId),this.timerId=void 0,this.currentSubscription=null},e.prototype.try=function(){var e=this;this.currentSubscription=this.forward(this.operation).subscribe({next:function(t){var n;if(qd(t))return e.onError(new Vd({protocolErrors:t.extensions[Ld]})),void(null===(n=e.currentSubscription)||void 0===n||n.unsubscribe());e.observer.next(t)},error:this.onError,complete:this.observer.complete.bind(this.observer)})},e.prototype.scheduleRetry=function(e){var t=this;if(this.timerId)throw new Error("RetryLink BUG! Encountered overlapping retries");this.timerId=setTimeout(function(){t.timerId=void 0,t.try()},e)},e}(),tb=function(e){function t(t){var n=e.call(this)||this,r=t||{},i=r.attempts,o=r.delay;return n.delayFor="function"==typeof o?o:function(e){var t=e||{},n=t.initial,r=void 0===n?300:n,i=t.jitter,o=void 0===i||i,s=t.max,a=void 0===s?1/0:s,u=o?r:r/2;return function(e){var t=Math.min(a,u*Math.pow(2,e));return o&&(t=Math.random()*t),t}}(o),n.retryIf="function"==typeof i?i:function(e){var t=e||{},n=t.retryIf,r=t.max,i=void 0===r?5:r;return function(e,t,r){return!(e>=i)&&(n?n(r,t):!!r)}}(i),n}return kl(t,e),t.prototype.request=function(e,t){var n=this;return new mh(function(r){var i=new eb(r,e,t,n.delayFor,n.retryIf);return function(){i.cancel()}})},t}(Sd);var nb=function(e){function t(t){var n=e.call(this)||this;return n.client=t,n}return kl(t,e),t.prototype.request=function(e){var t=this;return new mh(function(n){return t.client.subscribe(Sl(Sl({},e),{query:mp(e.query)}),{next:n.next.bind(n),complete:n.complete.bind(n),error:function(e){if(e instanceof Error)return n.error(e);var t,r=gh(t=e)&&"code"in t&&"reason"in t;return r||function(e){var t;return gh(e)&&(null===(t=e.target)||void 0===t?void 0:t.readyState)===WebSocket.CLOSED}(e)?n.error(new Error("Socket closed".concat(r?" with event ".concat(e.code):"").concat(r?" ".concat(e.reason):""))):n.error(new Vd({graphQLErrors:Array.isArray(e)?e:[e]}))}})})},t}(Sd),rb=n(390),ib=Object.defineProperty,ob=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)(function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),sb=(e,t,n)=>(((e,t,n)=>{t in e?ib(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!=typeof t?t+"":t,n),n);function ab(e){return null===e?"null":Array.isArray(e)?"array":typeof e}function ub(e){return"object"===ab(e)}function cb(e,t){return e.length<124?e:t}var lb=(e=>(e[e.InternalServerError=4500]="InternalServerError",e[e.InternalClientError=4005]="InternalClientError",e[e.BadRequest=4400]="BadRequest",e[e.BadResponse=4004]="BadResponse",e[e.Unauthorized=4401]="Unauthorized",e[e.Forbidden=4403]="Forbidden",e[e.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",e[e.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",e[e.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",e[e.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",e[e.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests",e))(lb||{}),hb=(e=>(e.ConnectionInit="connection_init",e.ConnectionAck="connection_ack",e.Ping="ping",e.Pong="pong",e.Subscribe="subscribe",e.Next="next",e.Error="error",e.Complete="complete",e))(hb||{});function fb(e){if(!ub(e))throw new Error(`Message is expected to be an object, but got ${ab(e)}`);if(!e.type)throw new Error("Message is missing the 'type' property");if("string"!=typeof e.type)throw new Error(`Message is expects the 'type' property to be a string, but got ${ab(e.type)}`);switch(e.type){case"connection_init":case"connection_ack":case"ping":case"pong":if(null!=e.payload&&!ub(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${e.payload}"`);break;case"subscribe":if("string"!=typeof e.id)throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${ab(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!ub(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${ab(e.payload)}`);if("string"!=typeof e.payload.query)throw new Error(`"${e.type}" message payload expects the 'query' property to be a string, but got ${ab(e.payload.query)}`);if(null!=e.payload.variables&&!ub(e.payload.variables))throw new Error(`"${e.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${ab(e.payload.variables)}`);if(null!=e.payload.operationName&&"string"!==ab(e.payload.operationName))throw new Error(`"${e.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${ab(e.payload.operationName)}`);if(null!=e.payload.extensions&&!ub(e.payload.extensions))throw new Error(`"${e.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${ab(e.payload.extensions)}`);break;case"next":if("string"!=typeof e.id)throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${ab(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!ub(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${ab(e.payload)}`);break;case"error":if("string"!=typeof e.id)throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${ab(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(t=e.payload,!(Array.isArray(t)&&t.length>0&&t.every(e=>"message"in e)))throw new Error(`"${e.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(e.payload)}`);break;case"complete":if("string"!=typeof e.id)throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${ab(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);break;default:throw new Error(`Invalid message 'type' property "${e.type}"`)}var t;return e}function db(e,t){return fb(e),JSON.stringify(e,t)}function pb(e){const{url:t,connectionParams:r,lazy:i=!0,onNonLazyError:o=console.error,lazyCloseTimeout:s=0,keepAlive:a=0,disablePong:u,connectionAckWaitTimeout:c=0,retryAttempts:l=5,retryWait:h=async function(e){const t=Math.pow(2,e);await new Promise(e=>setTimeout(e,1e3*t+Math.floor(2700*Math.random()+300)))},shouldRetry:f=mb,on:d,webSocketImpl:p,generateID:y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})},jsonMessageReplacer:m,jsonMessageReviver:g}=e;let b;if(p){if(!("function"==typeof(v=p)&&"constructor"in v&&"CLOSED"in v&&"CLOSING"in v&&"CONNECTING"in v&&"OPEN"in v))throw new Error("Invalid WebSocket implementation provided");b=p}else"undefined"!=typeof WebSocket?b=WebSocket:void 0!==n.g?b=n.g.WebSocket||n.g.MozWebSocket:"undefined"!=typeof window&&(b=window.WebSocket||window.MozWebSocket);var v;if(!b)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");const w=b,E=(()=>{const e=(()=>{const e={};return{on:(t,n)=>(e[t]=n,()=>{delete e[t]}),emit(t){"id"in t&&e[t.id]?.(t)}}})(),t={connecting:d?.connecting?[d.connecting]:[],opened:d?.opened?[d.opened]:[],connected:d?.connected?[d.connected]:[],ping:d?.ping?[d.ping]:[],pong:d?.pong?[d.pong]:[],message:d?.message?[e.emit,d.message]:[e.emit],closed:d?.closed?[d.closed]:[],error:d?.error?[d.error]:[]};return{onMessage:e.on,on(e,n){const r=t[e];return r.push(n),()=>{r.splice(r.indexOf(n),1)}},emit(e,...n){for(const r of[...t[e]])r(...n)}}})();function k(e){const t=[E.on("error",n=>{t.forEach(e=>e()),e(n)}),E.on("closed",n=>{t.forEach(e=>e()),e(n)})]}let S,T,_=0,x=!1,O=0,I=!1;async function C(){clearTimeout(T);const[e,n]=await(S??(S=new Promise((e,n)=>(async()=>{if(x){if(await h(O),!_)return S=void 0,n({code:1e3,reason:"All Subscriptions Gone"});O++}E.emit("connecting",x);const i=new w("function"==typeof t?await t():t,"graphql-transport-ws");let o,s;function l(){isFinite(a)&&a>0&&(clearTimeout(s),s=setTimeout(()=>{i.readyState===w.OPEN&&(i.send(db({type:hb.Ping})),E.emit("ping",!1,void 0))},a))}k(e=>{S=void 0,clearTimeout(o),clearTimeout(s),n(e),e instanceof yb&&(i.close(4499,"Terminated"),i.onerror=null,i.onclose=null)}),i.onerror=e=>E.emit("error",e),i.onclose=e=>E.emit("closed",e),i.onopen=async()=>{try{E.emit("opened",i);const e="function"==typeof r?await r():r;if(i.readyState!==w.OPEN)return;i.send(db(e?{type:hb.ConnectionInit,payload:e}:{type:hb.ConnectionInit},m)),isFinite(c)&&c>0&&(o=setTimeout(()=>{i.close(lb.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},c)),l()}catch(e){E.emit("error",e),i.close(lb.InternalClientError,cb(e instanceof Error?e.message:String(e),"Internal client error"))}};let f=!1;i.onmessage=({data:t})=>{try{const n=function(e,t){return fb("string"==typeof e?JSON.parse(e,t):e)}(t,g);if(E.emit("message",n),"ping"===n.type||"pong"===n.type)return E.emit(n.type,!0,n.payload),void("pong"===n.type?l():u||(i.send(db(n.payload?{type:hb.Pong,payload:n.payload}:{type:hb.Pong})),E.emit("pong",!1,n.payload)));if(f)return;if(n.type!==hb.ConnectionAck)throw new Error(`First message cannot be of type ${n.type}`);clearTimeout(o),f=!0,E.emit("connected",i,n.payload,x),x=!1,O=0,e([i,new Promise((e,t)=>k(t))])}catch(e){i.onmessage=null,E.emit("error",e),i.close(lb.BadResponse,cb(e instanceof Error?e.message:String(e),"Bad response"))}}})())));e.readyState===w.CLOSING&&await n;let i=()=>{};const o=new Promise(e=>i=e);return[e,i,Promise.race([o.then(()=>{if(!_){const t=()=>e.close(1e3,"Normal Closure");isFinite(s)&&s>0?T=setTimeout(()=>{e.readyState===w.OPEN&&t()},s):t()}}),n])]}function M(e){if(mb(e)&&(t=e.code,![1e3,1001,1006,1005,1012,1013,1014].includes(t)&&t>=1e3&&t<=1999||[lb.InternalServerError,lb.InternalClientError,lb.BadRequest,lb.BadResponse,lb.Unauthorized,lb.SubprotocolNotAcceptable,lb.SubscriberAlreadyExists,lb.TooManyInitialisationRequests].includes(e.code)))throw e;var t;if(I)return!1;if(mb(e)&&1e3===e.code)return _>0;if(!l||O>=l)throw e;if(!f(e))throw e;return x=!0}function A(e,t){const n=y(e);let r=!1,i=!1,o=()=>{_--,r=!0};return(async()=>{for(_++;;)try{const[s,a,u]=await C();if(r)return a();const c=E.onMessage(n,e=>{switch(e.type){case hb.Next:return void t.next(e.payload);case hb.Error:return i=!0,r=!0,t.error(e.payload),void o();case hb.Complete:return r=!0,void o()}});return s.send(db({id:n,type:hb.Subscribe,payload:e},m)),o=()=>{r||s.readyState!==w.OPEN||s.send(db({id:n,type:hb.Complete},m)),_--,r=!0,a()},void await u.finally(c)}catch(e){if(!M(e))return}})().then(()=>{i||t.complete()}).catch(e=>{t.error(e)}),()=>{r||o()}}return i||(async()=>{for(_++;;)try{const[,,e]=await C();await e}catch(e){try{if(!M(e))return}catch(e){return o?.(e)}}})(),{on:E.on,subscribe:A,iterate(e){const t=[],n={done:!1,error:null,resolve:()=>{}},r=A(e,{next(e){t.push(e),n.resolve()},error(e){n.done=!0,n.error=e,n.resolve()},complete(){n.done=!0,n.resolve()}}),i=async function*(){for(;;){for(t.length||await new Promise(e=>n.resolve=e);t.length;)yield t.shift();if(n.error)throw n.error;if(n.done)return}}();return i.throw=async e=>(n.done||(n.done=!0,n.error=e,n.resolve()),{done:!0,value:void 0}),i.return=async()=>(r(),{done:!0,value:void 0}),i},async dispose(){if(I=!0,S){const[e]=await S;e.close(1e3,"Normal Closure")}},terminate(){S&&E.emit("closed",new yb)}}}var yb=class extends Error{constructor(){super(...arguments),sb(this,"name","TerminatedCloseEvent"),sb(this,"message","4499: Terminated"),sb(this,"code",4499),sb(this,"reason","Terminated"),sb(this,"wasClean",!1)}};function mb(e){return ub(e)&&"code"in e&&"reason"in e}var gb={dubheDappMarketplaceFees:["dappKey","listingId","coinType","totalFee","treasuryAmount","dappAmount","updatedAtCheckpoint","lastUpdateDigest"],dubheDappRuntimeState:["dappKey","admin","paused","settlementMode","creditPool","writeFeeShareBps","lastRuntimeEvent","lastRuntimeActor","lastRuntimeAmount","updatedAtCheckpoint","lastUpdateDigest"],dubheDappFeeState:["entityId","baseFeePerWrite","bytesFeePerByte","freeCredit","creditPool","totalSettled","updatedAtTimestampMs","lastUpdateDigest"],dubheDappRevenueState:["entityId","dappRevenue","coinType","updatedAtTimestampMs","lastUpdateDigest"],dubheMarketplaceListings:["dappKey","listingId","seller","recordType","price","coinType","isFungible","listedUntil","status","updatedAtCheckpoint","lastUpdateDigest"],dubheSessions:["dappKey","canonical","sessionWallet","expiresAt","active","updatedAtCheckpoint","lastUpdateDigest"],dubheUserStorages:["dappKey","canonicalOwner","userStorageId","updatedAtCheckpoint","lastUpdateDigest"]};function bb(e){switch(e){case"cache-first":default:return"cache-first";case"network-only":return"network-only";case"cache-only":return"cache-only";case"no-cache":return"no-cache";case"standby":return"standby"}}function vb(e){const t=(t,n)=>fetch(t,{...e.fetchOptions,...n??{}});return e.batchRequests?new Xg({uri:e.endpoint,headers:e.headers,fetch:t,batchInterval:e.batchInterval??10,batchMax:e.batchMax??20}):jp({uri:e.endpoint,headers:e.headers,fetch:t})}var wb=class{constructor(e){this.parsedTables=new Map,this.uniqueTableNames=new Set,this.currentConfig=e,this.dubheMetadata=e.dubheMetadata,this.dubheMetadata&&this.parseTableInfoFromConfig();const t=vb(e),r=new tb({delay:{initial:e.retryOptions?.delay?.initial||300,max:e.retryOptions?.delay?.max||5e3,jitter:!1!==e.retryOptions?.delay?.jitter},attempts:{max:e.retryOptions?.attempts?.max||5,retryIf:e.retryOptions?.attempts?.retryIf||((e,t)=>Boolean(e&&(e.networkError||e.graphQLErrors&&0===e.graphQLErrors.length)))}}),i=Dp([r,t]);let o=i;if(e.subscriptionEndpoint){let t;try{if("undefined"==typeof window&&void 0!==n.g){const e=ob("ws");t=e.default||e,void 0===n.g.WebSocket&&(n.g.WebSocket=t)}else t=WebSocket}catch(e){}const r={url:e.subscriptionEndpoint,connectionParams:{headers:e.headers}};t&&"undefined"==typeof window&&(r.webSocketImpl=t),this.subscriptionClient=pb(r);const s=new nb(this.subscriptionClient);o=Rp(({query:e})=>{const t=_f(e);return"OperationDefinition"===t.kind&&"subscription"===t.operation},s,i)}this.apolloClient=new Qy({link:o,cache:e.cacheConfig?.paginatedTables&&e.cacheConfig.paginatedTables.length>0?new Qm({typePolicies:{Query:{fields:this.buildCacheFields(e.cacheConfig)}}}):new Qm,defaultOptions:{watchQuery:{errorPolicy:"all",notifyOnNetworkStatusChange:!0},query:{errorPolicy:"all"}}})}async updateConfig(e){void 0!==e.endpoint&&(this.currentConfig.endpoint=e.endpoint),void 0!==e.subscriptionEndpoint&&(this.currentConfig.subscriptionEndpoint=e.subscriptionEndpoint),void 0!==e.headers&&(this.currentConfig.headers=e.headers),void 0!==e.fetchOptions&&(this.currentConfig.fetchOptions=e.fetchOptions),void 0!==e.retryOptions&&(this.currentConfig.retryOptions=e.retryOptions),void 0!==e.cacheConfig&&(this.currentConfig.cacheConfig=e.cacheConfig),void 0!==e.dubheMetadata&&(this.dubheMetadata=e.dubheMetadata,this.parsedTables.clear(),this.uniqueTableNames.clear(),this.dubheMetadata&&this.parseTableInfoFromConfig());const t=void 0!==e.endpoint,r=void 0!==e.subscriptionEndpoint;if(t||r){if(this.subscriptionClient){try{await this.subscriptionClient.dispose()}catch(e){console.error("Error disposing subscription client:",e)}this.subscriptionClient=void 0}const e=vb(this.currentConfig),t=new tb({delay:{initial:this.currentConfig.retryOptions?.delay?.initial||300,max:this.currentConfig.retryOptions?.delay?.max||5e3,jitter:!1!==this.currentConfig.retryOptions?.delay?.jitter},attempts:{max:this.currentConfig.retryOptions?.attempts?.max||5,retryIf:this.currentConfig.retryOptions?.attempts?.retryIf||((e,t)=>Boolean(e&&(e.networkError||e.graphQLErrors&&0===e.graphQLErrors.length)))}}),r=Dp([t,e]);let i=r;if(this.currentConfig.subscriptionEndpoint){let e;try{if("undefined"==typeof window&&void 0!==n.g){const t=ob("ws");e=t.default||t,void 0===n.g.WebSocket&&(n.g.WebSocket=e)}else e=WebSocket}catch(e){}const t={url:this.currentConfig.subscriptionEndpoint,connectionParams:{headers:this.currentConfig.headers}};e&&"undefined"==typeof window&&(t.webSocketImpl=e),this.subscriptionClient=pb(t);const o=new nb(this.subscriptionClient);i=Rp(({query:e})=>{const t=_f(e);return"OperationDefinition"===t.kind&&"subscription"===t.operation},o,r)}const o=this.apolloClient.cache;this.apolloClient=new Qy({link:i,cache:this.currentConfig.cacheConfig?.paginatedTables&&this.currentConfig.cacheConfig.paginatedTables.length>0?new Qm({typePolicies:{Query:{fields:this.buildCacheFields(this.currentConfig.cacheConfig)}}}):new Qm,defaultOptions:{watchQuery:{errorPolicy:"all",notifyOnNetworkStatusChange:!0},query:{errorPolicy:"all"}}});try{this.apolloClient.cache.restore(o.extract())}catch(e){console.error("Error restoring cache:",e)}}}async query(e,t,n){try{const r=await this.apolloClient.query({query:e,variables:t,fetchPolicy:n?.cachePolicy?bb(n.cachePolicy):"no-cache",notifyOnNetworkStatusChange:n?.notifyOnNetworkStatusChange,pollInterval:n?.pollInterval});return{data:r.data,loading:r.loading,error:r.error,networkStatus:r.networkStatus,refetch:()=>this.query(e,t,n)}}catch(r){return{data:void 0,loading:!1,error:r,networkStatus:8,refetch:()=>this.query(e,t,n)}}}subscribe(e,t,n){return new mh(r=>{const i=this.apolloClient.subscribe({query:e,variables:t}).subscribe({next:e=>{const t={data:e.data,loading:!1,error:e.errors?.[0]};r.next(t),n?.onData?.(e.data)},error:e=>{const t={data:void 0,loading:!1,error:e};r.next(t),n?.onError?.(e)},complete:()=>{r.complete(),n?.onComplete?.()}});return()=>i.unsubscribe()})}async getAllTables(e,t){const n=this.getPluralTableName(e),r=Eb(t?.orderBy),i=Vg`
|
|
2
2
|
query GetAllTables(
|
|
3
3
|
$first: Int
|
|
4
4
|
$last: Int
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
`,o={first:t?.first,last:t?.last,after:t?.after,before:t?.before,filter:t?.filter,orderBy:r},s=await this.query(i,o);if(s.error)throw s.error;return s.data?.[n]||{edges:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1}}}getGraphQLType(e){return"uniqueResourceId"===e?"Int!":"String!"}async getTableByCondition(e,t,n){const r=Object.keys(t),i=this.getSingularTableName(e),o=
|
|
33
|
+
`,o={first:t?.first,last:t?.last,after:t?.after,before:t?.before,filter:t?.filter,orderBy:r},s=await this.query(i,o);if(s.error)throw s.error;return s.data?.[n]||{edges:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1}}}getGraphQLType(e){return"uniqueResourceId"===e?"Int!":"String!"}async getTableByCondition(e,t,n){const r=Object.keys(t),i=this.getSingularTableName(e),o=Vg`
|
|
34
34
|
query GetTableByCondition(${r.map(e=>`$${e}: ${this.getGraphQLType(e)}`).join(", ")}) {
|
|
35
35
|
${i}(${r.map(e=>`${e}: $${e}`).join(", ")}) {
|
|
36
36
|
${this.convertTableFields(e,n)}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
`,s=await this.query(o,t);if(s.error)throw s.error;return s.data?.[i]||null}subscribeToTableChanges(e,t){const n=t?.topicPrefix?`${t.topicPrefix}${e}`:`store_${this.getSingularTableName(e)}`,r=this.getPluralTableName(e),i=this.convertTableFields(e,t?.fields),o=
|
|
39
|
+
`,s=await this.query(o,t);if(s.error)throw s.error;return s.data?.[i]||null}subscribeToTableChanges(e,t){const n=t?.topicPrefix?`${t.topicPrefix}${e}`:`store_${this.getSingularTableName(e)}`,r=this.getPluralTableName(e),i=this.convertTableFields(e,t?.fields),o=Eb(t?.orderBy),s=t?.first||10,a=Vg`
|
|
40
40
|
subscription ListenToTableChanges(
|
|
41
41
|
$topic: String!,
|
|
42
42
|
$initialEvent: Boolean,
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
`;return this.subscribe(a,{topic:n,initialEvent:t?.initialEvent||!1,filter:t?.filter,orderBy:o,first:s},t)}subscribeWithListen(e,t,n){const r=
|
|
66
|
+
`;return this.subscribe(a,{topic:n,initialEvent:t?.initialEvent||!1,filter:t?.filter,orderBy:o,first:s},t)}subscribeWithListen(e,t,n){const r=Vg`
|
|
67
67
|
subscription CustomListenSubscription($topic: String!, $initialEvent: Boolean) {
|
|
68
68
|
listen(topic: $topic, initialEvent: $initialEvent) {
|
|
69
69
|
query {
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
`;return this.subscribe(r,{topic:e,initialEvent:n?.initialEvent||!1,...n?.variables},n)}subscribeToMultipleTables(e,t){return new mh(n=>{const r=[],i={};e.forEach(({tableName:e,options:o})=>{const s=this.subscribeToTableChanges(e,{...o,onData:r=>{i[e]=r,o?.onData&&o.onData(r),t?.onData&&t.onData(i),n.next({...i})},onError:e=>{o?.onError&&o.onError(e),t?.onError&&t.onError(e),n.error(e)}});r.push({tableName:e,subscription:s})});const o=r.map(({subscription:e})=>e.subscribe());return()=>{o.forEach(e=>e.unsubscribe()),t?.onComplete&&t.onComplete()}})}subscribeToTableList(e,t){const n=e.map(e=>({tableName:e,options:{...t,fields:t?.fields,filter:t?.filter,initialEvent:t?.initialEvent,first:t?.first,topicPrefix:t?.topicPrefix}}));return this.subscribeToMultipleTables(n,t)}buildQuery(e,t,n){const r=this.getPluralTableName(e),i=t.join("\n ");return
|
|
74
|
+
`;return this.subscribe(r,{topic:e,initialEvent:n?.initialEvent||!1,...n?.variables},n)}subscribeToMultipleTables(e,t){return new mh(n=>{const r=[],i={};e.forEach(({tableName:e,options:o})=>{const s=this.subscribeToTableChanges(e,{...o,onData:r=>{i[e]=r,o?.onData&&o.onData(r),t?.onData&&t.onData(i),n.next({...i})},onError:e=>{o?.onError&&o.onError(e),t?.onError&&t.onError(e),n.error(e)}});r.push({tableName:e,subscription:s})});const o=r.map(({subscription:e})=>e.subscribe());return()=>{o.forEach(e=>e.unsubscribe()),t?.onComplete&&t.onComplete()}})}subscribeToTableList(e,t){const n=e.map(e=>({tableName:e,options:{...t,fields:t?.fields,filter:t?.filter,initialEvent:t?.initialEvent,first:t?.first,topicPrefix:t?.topicPrefix}}));return this.subscribeToMultipleTables(n,t)}buildQuery(e,t,n){const r=this.getPluralTableName(e),i=t.join("\n ");return Vg`
|
|
75
75
|
query DynamicQuery(
|
|
76
76
|
$first: Int
|
|
77
77
|
$after: Cursor
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
`}async batchQuery(e){const t=e.map(async({key:e,tableName:t,params:n})=>({key:e,result:await this.getAllTables(t,n)}));return(await Promise.all(t)).reduce((e,{key:t,result:n})=>(e[t]=n,e),{})}createRealTimeDataStream(e,t){return new mh(n=>{this.getAllTables(e,t).then(e=>{n.next(e)}).catch(e=>n.error(e));const r=this.subscribeToTableChanges(e,{onData:()=>{this.getAllTables(e,t).then(e=>{n.next(e)}).catch(e=>n.error(e))},onError:e=>n.error(e)});return()=>r.subscribe().unsubscribe()})}async getMarketplaceListings(e){const t={};e?.dappKey&&(t.dappKey={equalTo:e.dappKey}),void 0!==e?.status&&(t.status={equalTo:e.status}),e?.recordType&&(t.recordType={equalTo:e.recordType}),e?.seller&&(t.seller={equalTo:e.seller});const n=
|
|
100
|
+
`}async batchQuery(e){const t=e.map(async({key:e,tableName:t,params:n})=>({key:e,result:await this.getAllTables(t,n)}));return(await Promise.all(t)).reduce((e,{key:t,result:n})=>(e[t]=n,e),{})}createRealTimeDataStream(e,t){return new mh(n=>{this.getAllTables(e,t).then(e=>{n.next(e)}).catch(e=>n.error(e));const r=this.subscribeToTableChanges(e,{onData:()=>{this.getAllTables(e,t).then(e=>{n.next(e)}).catch(e=>n.error(e))},onError:e=>n.error(e)});return()=>r.subscribe().unsubscribe()})}async getMarketplaceListings(e){const t={};e?.dappKey&&(t.dappKey={equalTo:e.dappKey}),void 0!==e?.status&&(t.status={equalTo:e.status}),e?.recordType&&(t.recordType={equalTo:e.recordType}),e?.seller&&(t.seller={equalTo:e.seller});const n=Vg`
|
|
101
101
|
query GetMarketplaceListings(
|
|
102
102
|
$first: Int
|
|
103
103
|
$after: Cursor
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
`,r=await this.apolloClient.query({query:n,variables:{first:e?.first??100,after:e?.after,filter:Object.keys(t).length>0?t:void 0,orderBy:["CREATED_AT_CHECKPOINT_DESC"]},fetchPolicy:"network-only"});if(r.error)throw r.error;return r.data?.dubheMarketplaceListings??{edges:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1},totalCount:0}}async getDubheSessions(e){const t={};e?.dappKey&&(t.dappKey={equalTo:e.dappKey}),e?.canonical&&(t.canonical={equalTo:e.canonical}),void 0!==e?.active&&(t.active={equalTo:e.active});const n=
|
|
136
|
+
`,r=await this.apolloClient.query({query:n,variables:{first:e?.first??100,after:e?.after,filter:Object.keys(t).length>0?t:void 0,orderBy:["CREATED_AT_CHECKPOINT_DESC"]},fetchPolicy:"network-only"});if(r.error)throw r.error;return r.data?.dubheMarketplaceListings??{edges:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1},totalCount:0}}async getDubheSessions(e){const t={};e?.dappKey&&(t.dappKey={equalTo:e.dappKey}),e?.canonical&&(t.canonical={equalTo:e.canonical}),void 0!==e?.active&&(t.active={equalTo:e.active});const n=Vg`
|
|
137
137
|
query GetDubheSessions(
|
|
138
138
|
$first: Int
|
|
139
139
|
$after: Cursor
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
`,r=await this.apolloClient.query({query:n,variables:{first:e?.first??100,after:e?.after,filter:Object.keys(t).length>0?t:void 0,orderBy:["UPDATED_AT_CHECKPOINT_DESC"]},fetchPolicy:"network-only"});if(r.error)throw r.error;return r.data?.dubheSessions??{edges:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1},totalCount:0}}async getDubheUserStorages(e){const t={};e?.dappKey&&(t.dappKey={equalTo:e.dappKey}),e?.canonicalOwner&&(t.canonicalOwner={equalTo:e.canonicalOwner});const n=
|
|
166
|
+
`,r=await this.apolloClient.query({query:n,variables:{first:e?.first??100,after:e?.after,filter:Object.keys(t).length>0?t:void 0,orderBy:["UPDATED_AT_CHECKPOINT_DESC"]},fetchPolicy:"network-only"});if(r.error)throw r.error;return r.data?.dubheSessions??{edges:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1},totalCount:0}}async getDubheUserStorages(e){const t={};e?.dappKey&&(t.dappKey={equalTo:e.dappKey}),e?.canonicalOwner&&(t.canonicalOwner={equalTo:e.canonicalOwner});const n=Vg`
|
|
167
167
|
query GetDubheUserStorages(
|
|
168
168
|
$first: Int
|
|
169
169
|
$after: Cursor
|
|
@@ -192,7 +192,7 @@
|
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
`,r=await this.apolloClient.query({query:n,variables:{first:e?.first??100,after:e?.after,filter:Object.keys(t).length>0?t:void 0,orderBy:["CREATED_AT_CHECKPOINT_DESC"]},fetchPolicy:"network-only"});if(r.error)throw r.error;return r.data?.dubheUserStorages??{edges:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1},totalCount:0}}async getDubheDappRuntimeState(e){const t=
|
|
195
|
+
`,r=await this.apolloClient.query({query:n,variables:{first:e?.first??100,after:e?.after,filter:Object.keys(t).length>0?t:void 0,orderBy:["CREATED_AT_CHECKPOINT_DESC"]},fetchPolicy:"network-only"});if(r.error)throw r.error;return r.data?.dubheUserStorages??{edges:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1},totalCount:0}}async getDubheDappRuntimeState(e){const t=Vg`
|
|
196
196
|
query GetDubheDappRuntimeState($filter: StoreDubheDappRuntimeStateFilter) {
|
|
197
197
|
dubheDappRuntimeStates(first: 1, filter: $filter) {
|
|
198
198
|
edges {
|
|
@@ -214,5 +214,5 @@
|
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
`,n=await this.apolloClient.query({query:t,variables:{filter:{dappKey:{equalTo:e}}},fetchPolicy:"network-only"});if(n.error)throw n.error;const r=n.data?.dubheDappRuntimeStates?.edges??[];return r[0]?.node??null}getFilterTypeName(e){const t=this.getSingularTableName(e),n=this.toPascalCase(t);return n.startsWith("Store")?`${n}Filter`:`Store${n}Filter`}getOrderByTypeName(e){const t=this.getPluralTableName(e),n=this.toPascalCase(t);return n.startsWith("Store")?`${n}OrderBy`:`Store${n}OrderBy`}getPluralTableName(e){const t=this.toCamelCase(e);return Hg.plural(t)}getSingularTableName(e){const t=this.toCamelCase(e);return Hg.singular(t)}toCamelCase(e){return e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}toPascalCase(e){const t=this.toCamelCase(e);return t.charAt(0).toUpperCase()+t.slice(1)}toSnakeCase(e){return e.includes("_")?e.toUpperCase():e.replace(/([A-Z])/g,"_$1").toLowerCase().replace(/^_/,"").toUpperCase()}async clearCache(){await this.apolloClient.clearStore()}async resetCache(){await this.apolloClient.resetStore()}getApolloClient(){return this.apolloClient}close(){this.subscriptionClient&&this.subscriptionClient.dispose()}getDubheMetadata(){return this.dubheMetadata}buildCacheFields(e){const t={};return e?(e.paginatedTables&&e.paginatedTables.forEach(n=>{const r=this.getPluralTableName(n),i=e.customMergeStrategies?.[r];t[r]={keyArgs:i?.keyArgs||["filter","orderBy"],merge:i?.merge||this.defaultMergeStrategy}}),e.customMergeStrategies&&Object.entries(e.customMergeStrategies).forEach(([e,n])=>{t[e]||(t[e]={keyArgs:n.keyArgs||["filter","orderBy"],merge:n.merge||this.defaultMergeStrategy})}),t):t}defaultMergeStrategy(e={edges:[]},t){return t&&Array.isArray(t.edges)?{...t,edges:[...e.edges||[],...t.edges]}:e}parseTableInfoFromConfig(){if(!this.dubheMetadata)return;const{components:e=[],resources:t=[],enums:n=[]}=this.dubheMetadata;e.forEach(e=>{Object.entries(e).forEach(([e,t])=>{this.processTableData(e,t,n)})}),t.forEach(e=>{Object.entries(e).forEach(([e,t])=>{this.processTableData(e,t,n)})})}processTableData(e,t,n){const r=e.includes("_")?this.toCamelCase(e):e,i=[];t.fields&&Array.isArray(t.fields)&&t.fields.forEach(e=>{Object.entries(e).forEach(([e,t])=>{const n=this.toCamelCase(e);i.push(n)})}),i.push("createdAtTimestampMs","updatedAtTimestampMs","isDeleted","lastUpdateDigest");const o=t.keys.map(e=>this.toCamelCase(e)),s={tableName:r,fields:[...new Set(i)],primaryKeys:o,enumFields:{}};this.uniqueTableNames.add(e),this.parsedTables.set(e,s),this.parsedTables.set(r,s),e!==r&&this.parsedTables.set(this.toSnakeCase(r),s)}findTableInfo(e){let t=this.parsedTables.get(e);if(t)return t;const n=this.toCamelCase(e);return t=this.parsedTables.get(n),t||(e.includes("_")&&(t=this.parsedTables.get(e.toLowerCase()),t)?t:void 0)}getTableFields(e){return this.getMinimalFields(e)}getTablePrimaryKeys(e){const t=this.findTableInfo(e);return t?.primaryKeys||[]}getTableEnumFields(e){const t=this.findTableInfo(e);return t?.enumFields||{}}getAllTableInfo(){const e=new Map;return this.uniqueTableNames.forEach(t=>{const n=this.parsedTables.get(t);n&&e.set(t,n)}),e}getMinimalFields(e){const t=this.findTableInfo(e);return t?t.fields:["createdAtTimestampMs","updatedAtTimestampMs","isDeleted","lastUpdateDigest"]}convertTableFields(e,t){let n;if(t&&t.length>0)n=t;else{const t=this.getTableFields(e);n=t.length>0?t:["createdAtTimestampMs","updatedAtTimestampMs","isDeleted","lastUpdateDigest"]}return n.join("\n ")}};function hb(e){return e&&0!==e.length?e.map(e=>{const t=function(e){if(e.includes("_"))return e.toUpperCase();return e.replace(/([A-Z])/g,"_$1").toLowerCase().replace(/^_/,"").toUpperCase()}(e.field);return`${t}_${"DESC"===e.direction?"DESC":"ASC"}`}):["UPDATED_AT_TIMESTAMP_MS_DESC"]}function fb(e,t){const{idFields:n=["nodeId","entityId"],composite:r=!1}=t||{};return e.edges.map(e=>{const t=e.node;if(r){return n.map(e=>t[e]||"").filter(Boolean).join("|")}for(const e of n)if(void 0!==t[e]&&null!==t[e])return t[e];return Object.values(t)[0]||""}).filter(Boolean)}function db(e,t){return{entityIds:fb(e,t),items:e.edges.map(e=>e.node),pageInfo:{hasNextPage:e.pageInfo.hasNextPage,hasPreviousPage:e.pageInfo.hasPreviousPage,startCursor:e.pageInfo.startCursor,endCursor:e.pageInfo.endCursor},totalCount:e.totalCount||0}}function pb(e,t,n){const r=t.map(t=>{const r=e[t];return r?fb(r,n):[]});return function(e){return 0===e.length?[]:1===e.length?e[0]:e.reduce((e,t)=>{const n=new Set(t);return e.filter(e=>n.has(e))})}(r)}function yb(e,t,n){const r=t.map(t=>{const r=e[t];return r?fb(r,n):[]});return function(e){const t=new Set;return e.forEach(e=>{e.forEach(e=>t.add(e))}),Array.from(t)}(r)}function mb(e,t){let n=null;return(...r)=>{n&&clearTimeout(n),n=setTimeout(()=>{e(...r),n=null},t)}}function gb(e,t,n){const r=[...t].sort(),i=n?JSON.stringify(n):"";return`${e}:${r.join(",")}:${i}`}function bb(e){return"string"==typeof e&&e.length>0}function vb(e){return"string"==typeof e&&e.length>0}function wb(e){return e instanceof Error?e.message:"string"==typeof e?e:JSON.stringify(e)}var Eb=class{constructor(e,t){this.queryCache=new Map,this.cacheTimeout=5e3,this.availableComponents=[],this.componentDiscoverer=null,this.componentPrimaryKeys=new Map,this.graphqlClient=e,this.componentDiscoverer=t||null}setAvailableComponents(e){this.availableComponents=e}initializeComponentMetadata(e){this.componentPrimaryKeys.clear();for(const t of e)1===t.primaryKeys.length&&this.componentPrimaryKeys.set(t.name,t.primaryKeys[0])}getComponentPrimaryKeyField(e){if(this.componentPrimaryKeys.has(e))return this.componentPrimaryKeys.get(e);const t=e.replace(/([A-Z])/g,"_$1").toLowerCase();if(t!==e&&this.componentPrimaryKeys.has(t))return this.componentPrimaryKeys.get(t);const n=e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase());return n!==e&&this.componentPrimaryKeys.has(n)?this.componentPrimaryKeys.get(n):"entityId"}setComponentDiscoverer(e){this.componentDiscoverer=e}buildPaginationParams(e){const t={};return void 0!==e?.first?t.first=e.first:void 0!==e?.limit&&(t.first=e.limit,void 0!==e?.offset&&console.warn("ECS Query: offset parameter is not supported with GraphQL cursor-based pagination. Use after/before instead.")),void 0!==e?.last&&(t.last=e.last),void 0!==e?.after&&(t.after=e.after),void 0!==e?.before&&(t.before=e.before),t}async getComponentFields(e){if(this.componentDiscoverer)try{const t=this.componentDiscoverer.getComponentMetadata(e);if(t)return t.fields.map(e=>e.name)}catch(e){}throw new Error(`Unable to get field information for component ${e}. Please explicitly specify fields in QueryOptions or ensure component discoverer is properly configured.`)}async getComponentPrimaryKeys(e){if(this.componentDiscoverer)try{const t=this.componentDiscoverer.getComponentMetadata(e);if(t&&t.primaryKeys.length>0)return t.primaryKeys}catch(e){}throw new Error(`Unable to get primary key information for component ${e}. Please explicitly specify idFields in QueryOptions or ensure component discoverer is properly configured.`)}async getQueryFields(e,t){return t&&t.length>0?t:this.getComponentFields(e)}async hasEntity(e){if(!bb(e))return!1;try{const t=await this.getAvailableComponents();for(const n of t)try{const t=this.buildEntityCondition(n,e);if(await this.graphqlClient.getTableByCondition(n,t))return!0}catch(e){}return!1}catch(e){return!1}}async getAllEntities(){try{const e=await this.getAvailableComponents(),t=await Promise.all(e.map(async e=>({key:e,tableName:e,params:{fields:await this.getQueryFields(e),filter:{}},primaryKey:this.componentPrimaryKeys.get(e)||"entityId"})));return yb(await this.graphqlClient.batchQuery(t.map(e=>({key:e.key,tableName:e.tableName,params:e.params}))),e,{idFields:void 0,composite:!1})}catch(e){return[]}}async getEntityCount(){return(await this.getAllEntities()).length}async hasComponent(e,t){if(!bb(e)||!vb(t))return!1;if(!this.isECSComponent(t))return!1;try{const n=this.buildEntityCondition(t,e);return null!==await this.graphqlClient.getTableByCondition(t,n)}catch(e){return!1}}async getComponent(e,t){if(!bb(e)||!vb(t))return null;if(!this.isECSComponent(t))return null;try{const n=this.buildEntityCondition(t,e),r=await this.graphqlClient.getTableByCondition(t,n);return r&&!0===r.isDeleted?null:r}catch(e){return null}}async getComponents(e){if(!bb(e))return[];try{const t=await this.getAvailableComponents(),n=[];return await Promise.all(t.map(async t=>{await this.hasComponent(e,t)&&n.push(t)})),n}catch(e){return[]}}isECSComponent(e){if(this.availableComponents.includes(e))return!0;const t=e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase());if(t!==e&&this.availableComponents.includes(t))return!0;const n=e.replace(/([A-Z])/g,"_$1").toLowerCase();return!(n===e||!this.availableComponents.includes(n))}resolveComponentType(e){if(this.componentPrimaryKeys.has(e))return e;const t=e.replace(/([A-Z])/g,"_$1").toLowerCase();if(t!==e&&this.componentPrimaryKeys.has(t))return t;const n=e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase());return n!==e&&this.componentPrimaryKeys.has(n)?n:e}buildEntityCondition(e,t){const n=this.resolveComponentType(e),r=this.componentPrimaryKeys.get(n);return r?{[r]:t}:{entityId:t}}filterValidECSComponents(e){return e.filter(e=>!!vb(e)&&!!this.isECSComponent(e))}async queryWithFullPagination(e,t){const n={entityIds:[],items:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1},totalCount:0};if(!vb(e))return n;if(!this.isECSComponent(e))return n;try{const n=await this.getQueryFields(e,t?.fields),r=await this.getComponentPrimaryKeys(e),i=this.buildPaginationParams(t);return db(await this.graphqlClient.getAllTables(e,{...i,fields:n,orderBy:t?.orderBy}),{idFields:t?.idFields||r,composite:t?.compositeId})}catch(e){return n}}async queryWith(e,t){return this.queryWithFullPagination(e,t)}async queryWithAll(e,t){if(0===e.length)return[];if(1===e.length){return(await this.queryWith(e[0],t)).entityIds}const n=this.filterValidECSComponents(e);if(0===n.length)return[];const r=gb("queryWithAll",n,t),i=this.getCachedResult(r);if(i&&!1!==t?.cache)return i;try{const e=this.buildPaginationParams(t),i=await Promise.all(n.map(async n=>({key:n,tableName:n,params:{fields:await this.getQueryFields(n,t?.fields),...e,orderBy:t?.orderBy}}))),o=await this.graphqlClient.batchQuery(i);let s=t?.idFields;if(!s&&n.length>0)try{s=await this.getComponentPrimaryKeys(n[0])}catch(e){}const a=pb(o,n,{idFields:s,composite:t?.compositeId});return this.setCachedResult(r,a),a}catch(e){return[]}}async queryWithAny(e,t){if(0===e.length)return[];if(1===e.length){return(await this.queryWith(e[0],t)).entityIds}const n=this.filterValidECSComponents(e);if(0===n.length)return[];const r=gb("queryWithAny",n,t),i=this.getCachedResult(r);if(i&&!1!==t?.cache)return i;try{const e=this.buildPaginationParams(t),i=await Promise.all(n.map(async n=>({key:n,tableName:n,params:{fields:await this.getQueryFields(n,t?.fields),...e,orderBy:t?.orderBy}}))),o=await this.graphqlClient.batchQuery(i);let s=t?.idFields;if(!s&&n.length>0)try{s=await this.getComponentPrimaryKeys(n[0])}catch(e){}const a=yb(o,n,{idFields:s,composite:t?.compositeId});return this.setCachedResult(r,a),a}catch(e){return[]}}async queryWithout(e,t,n){if(0===e.length)return[];const r=this.filterValidECSComponents(e);if(0===r.length)return[];const i=this.filterValidECSComponents(t);try{const e=await this.queryWithAll(r,n);if(0===i.length)return e;const t=await this.queryWithAny(i),o=new Set(t);return e.filter(e=>!o.has(e))}catch(e){return[]}}async queryWhereFullPagination(e,t,n){const r={entityIds:[],items:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1},totalCount:0};if(!vb(e))return r;if(!this.isECSComponent(e))return r;try{const r=await this.getQueryFields(e,n?.fields),i=await this.getComponentPrimaryKeys(e),o=this.buildPaginationParams(n);return db(await this.graphqlClient.getAllTables(e,{filter:t,...o,fields:r,orderBy:n?.orderBy}),{idFields:n?.idFields||i,composite:n?.compositeId})}catch(e){return r}}async queryWhere(e,t,n){return(await this.queryWhereFullPagination(e,t,n)).entityIds}async queryRange(e,t,n,r,i){if(!vb(e))return[];if(!this.isECSComponent(e))return[];const o={[t]:{greaterThanOrEqualTo:n,lessThanOrEqualTo:r}};return this.queryWhere(e,o,i)}async queryPaged(e,t,n){try{return function(e,t,n){const r=(t-1)*n,i=r+n;return{items:e.slice(r,i),totalCount:e.length,hasMore:i<e.length,page:t,pageSize:n}}(1===e.length?(await this.queryWith(e[0])).entityIds:await this.queryWithAll(e),t,n)}catch(e){return{items:[],totalCount:0,hasMore:!1,page:t,pageSize:n}}}query(){return new kb(this)}getCachedResult(e){const t=this.queryCache.get(e);return t&&Date.now()-t.timestamp<this.cacheTimeout?t.result:null}setCachedResult(e,t){this.queryCache.set(e,{result:t,timestamp:Date.now()})}cleanExpiredCache(){const e=Date.now();for(const[t,n]of this.queryCache.entries())e-n.timestamp>=this.cacheTimeout&&this.queryCache.delete(t)}async getAvailableComponents(){return this.availableComponents.length>0?this.availableComponents:[]}dispose(){this.queryCache.clear()}},kb=class{constructor(e){this.includeTypes=[],this.excludeTypes=[],this.whereConditions=[],this.orderByOptions=[],this.ecsQuery=e}with(...e){return this.includeTypes.push(...e),this}without(...e){return this.excludeTypes.push(...e),this}where(e,t){return this.whereConditions.push({componentType:e,predicate:t}),this}orderBy(e,t,n="ASC"){return this.orderByOptions.push({componentType:e,field:t,direction:n}),this}limit(e){return this.limitValue=e,this}offset(e){return this.offsetValue=e,this}async execute(){try{const e={limit:this.limitValue,offset:this.offsetValue,orderBy:this.orderByOptions.map(e=>({field:e.field,direction:e.direction}))};if(this.whereConditions.length>0){const t=[];for(const n of this.whereConditions){const r=await this.ecsQuery.queryWhere(n.componentType,n.predicate,e);t.push(r)}return t.reduce((e,t)=>{const n=new Set(t);return e.filter(e=>n.has(e))})}return this.excludeTypes.length>0?this.ecsQuery.queryWithout(this.includeTypes,this.excludeTypes,e):this.ecsQuery.queryWithAll(this.includeTypes,e)}catch(e){return[]}}},Sb=class{constructor(e,t){this.subscriptions=new Map,this.queryWatchers=new Map,this.componentDiscoverer=null,this.availableComponents=[],this.componentPrimaryKeys=new Map,this.graphqlClient=e,this.componentDiscoverer=t||null}setAvailableComponents(e){this.availableComponents=e}initializeComponentMetadata(e){this.componentPrimaryKeys.clear();for(const t of e)1===t.primaryKeys.length&&this.componentPrimaryKeys.set(t.name,t.primaryKeys[0])}getComponentPrimaryKeyField(e){if(this.componentPrimaryKeys.has(e))return this.componentPrimaryKeys.get(e);const t=e.replace(/([A-Z])/g,"_$1").toLowerCase();if(t!==e&&this.componentPrimaryKeys.has(t))return this.componentPrimaryKeys.get(t);const n=e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase());return n!==e&&this.componentPrimaryKeys.has(n)?this.componentPrimaryKeys.get(n):"entityId"}setComponentDiscoverer(e){this.componentDiscoverer=e}isECSComponent(e){if(this.availableComponents.includes(e))return!0;const t=e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase());if(t!==e&&this.availableComponents.includes(t))return!0;const n=e.replace(/([A-Z])/g,"_$1").toLowerCase();return!(n===e||!this.availableComponents.includes(n))}async getComponentFields(e){if(this.componentDiscoverer)try{const t=this.componentDiscoverer.getComponentMetadata(e);if(t)return t.fields.map(e=>e.name)}catch(e){}return["createdAtTimestampMs","updatedAtTimestampMs","isDeleted","lastUpdateDigest"]}async getQueryFields(e,t){return t&&t.length>0?t:this.getComponentFields(e)}onComponentAdded(e,t){return vb(e)?this.isECSComponent(e)?new mh(n=>{let r=null;return this.getQueryFields(e,t?.fields).then(i=>{const o=t?.debounceMs?mb(e=>n.next(e),t.debounceMs):e=>n.next(e),s=this.graphqlClient.subscribeToTableChanges(e,{initialEvent:t?.initialEvent??!1,fields:i,onData:t=>{try{const n=this.getPluralTableName(e),r=t?.listen?.query?.[n]?.nodes;r&&Array.isArray(r)&&r.forEach(t=>{if(t){const n=t.entityId||this.extractEntityId(t,e);if(n){const e={entityId:n,data:t,changeType:"added",timestamp:Date.now()};o(e)}}})}catch(e){n.error(e)}},onError:e=>{n.error(e)},onComplete:()=>{n.complete()}});r=s.subscribe({})}).catch(e=>{n.error(e)}),()=>{r&&r.unsubscribe()}}):new mh(t=>{t.error(new Error(`Component type ${e} is not ECS-compliant or not available`))}):new mh(t=>{t.error(new Error(`Invalid component type: ${e}`))})}onComponentRemoved(e,t){return vb(e)?this.isECSComponent(e)?new mh(n=>{let r=null,i=new Set;try{const o=t?.debounceMs?mb(e=>n.next(e),t.debounceMs):e=>n.next(e);this.initializeLastKnownEntities(e,i);const s=this.graphqlClient.subscribeToTableChanges(e,{initialEvent:!1,fields:["updatedAtTimestampMs"],onData:t=>{try{const n=this.getPluralTableName(e),r=new Set((t?.listen?.query?.[n]?.nodes||[]).map(t=>t.entityId||this.extractEntityId(t,e)).filter(Boolean));Array.from(i).filter(e=>!r.has(e)).forEach(e=>{const t={entityId:e,data:null,changeType:"removed",timestamp:Date.now()};o(t)}),i=r}catch(e){n.error(e)}},onError:e=>{n.error(e)},onComplete:()=>{n.complete()}});r=s.subscribe({})}catch(e){n.error(e)}return()=>{r&&r.unsubscribe()}}):new mh(t=>{t.error(new Error(`Component type ${e} is not ECS-compliant or not available`))}):new mh(t=>{t.error(new Error(`Invalid component type: ${e}`))})}onComponentChanged(e,t){return vb(e)?this.isECSComponent(e)?new mh(n=>{let r=null;return this.getQueryFields(e,t?.fields).then(i=>{const o=t?.debounceMs?mb(e=>n.next(e),t.debounceMs):e=>n.next(e),s=this.graphqlClient.subscribeToTableChanges(e,{initialEvent:t?.initialEvent??!1,fields:i,onData:t=>{try{const n=this.getPluralTableName(e),r=t?.listen?.query?.[n]?.nodes;r&&Array.isArray(r)&&r.forEach(t=>{if(t){const n=t.entityId||this.extractEntityId(t,e);if(n){const e={entityId:n,data:t,changeType:"updated",timestamp:Date.now()};o(e)}}})}catch(e){n.error(e)}},onError:e=>{n.error(e)},onComplete:()=>{n.complete()}});r=s.subscribe({})}).catch(e=>{n.error(e)}),()=>{r&&r.unsubscribe()}}):new mh(t=>{t.error(new Error(`Component type ${e} is not ECS-compliant or not available`))}):new mh(t=>{t.error(new Error(`Invalid component type: ${e}`))})}onEntityComponent(e,t,n){return vb(e)?this.isECSComponent(e)?new mh(r=>{let i=null;return this.getQueryFields(e,n?.fields).then(o=>{const s=n?.debounceMs?mb(e=>r.next(e),n.debounceMs):e=>r.next(e),a=this.getComponentPrimaryKeyField(e),u={[a]:{equalTo:t}},c=this.graphqlClient.subscribeToTableChanges(e,{initialEvent:n?.initialEvent??!1,fields:o,filter:u,onData:t=>{try{const n=this.getPluralTableName(e);(t?.listen?.query?.[n]?.nodes||[]).forEach(t=>{if(t){const n=t.entityId||this.extractEntityId(t,e);if(n){const e={entityId:n,data:t,changeType:"updated",timestamp:Date.now()};s(e)}}})}catch(e){r.error(e)}},onError:e=>{r.error(e)},onComplete:()=>{r.complete()}});i=c.subscribe({})}).catch(e=>{r.error(e)}),()=>{i&&i.unsubscribe()}}):new mh(t=>{t.error(new Error(`Component type ${e} is not ECS-compliant or not available`))}):new mh(t=>{t.error(new Error(`Invalid component type: ${e}`))})}watchQuery(e,t){const n=e.filter(vb);return 0===n.length?new mh(e=>{e.error(new Error("No valid component types for query watching"))}):new mh(e=>{const r=new Tb(this.graphqlClient,n,n=>{const r={changes:n};if(t?.debounceMs){mb(()=>e.next(r),t.debounceMs)()}else e.next(r)},t);return()=>{r.dispose()}})}createRealTimeStream(e,t){return vb(e)?new mh(n=>{try{const r=this.graphqlClient.createRealTimeDataStream(e,{filter:t}).subscribe({next:e=>{const t=e.edges.map(e=>{const t=e.node;return{entityId:t.nodeId||t.entityId||Object.values(t)[0]||"",data:t}}).filter(e=>e.entityId);n.next(t)},error:e=>{n.error(e)},complete:()=>{n.complete()}});return()=>{r.unsubscribe()}}catch(e){n.error(e)}}):new mh(t=>{t.error(new Error(`Invalid component type: ${e}`))})}async initializeLastKnownEntities(e,t){try{(await this.graphqlClient.getAllTables(e,{fields:["updatedAtTimestampMs"]})).edges.forEach(e=>{const n=e.node,r=n.nodeId||n.entityId||Object.values(n)[0];r&&t.add(r)})}catch(e){}}getPluralTableName(e){const t=this.toCamelCase(e);return Hg.plural(t)}toCamelCase(e){return e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}extractEntityId(e,t){if(!e||"object"!=typeof e)return"";const n=this.getComponentPrimaryKeyField(t);if(e[n]&&"string"==typeof e[n])return e[n];if("entityId"!==n&&e.entityId&&"string"==typeof e.entityId)return e.entityId;const r=Object.values(e);for(const e of r)if("string"==typeof e&&e.length>0)return e;return""}unsubscribeAll(){this.subscriptions.forEach(e=>{try{e?.unsubscribe()}catch(e){}}),this.subscriptions.clear(),this.queryWatchers.forEach(e=>{try{e.dispose()}catch(e){}}),this.queryWatchers.clear()}dispose(){this.unsubscribeAll()}},Tb=class{constructor(e,t,n,r){this.subscriptions=[],this.currentResults=[],this.isInitialized=!1,this.graphqlClient=e,this.componentTypes=t,this.callback=n,this.options=r,this.initialize()}async initialize(){try{await this.updateCurrentResults(),this.componentTypes.forEach(e=>{const t=this.graphqlClient.subscribeToTableChanges(e,{initialEvent:!1,onData:()=>{this.handleDataChange()},onError:e=>{}}).subscribe({});this.subscriptions.push(t)}),this.isInitialized=!0,this.options?.initialEvent&&this.currentResults.length>0&&this.callback({added:this.currentResults,removed:[],current:this.currentResults})}catch(e){}}async handleDataChange(){if(this.isInitialized)try{const e=[...this.currentResults];await this.updateCurrentResults();const t=function(e,t){const n=new Set(e),r=new Set(t);return{added:t.filter(e=>!n.has(e)),removed:e.filter(e=>!r.has(e)),current:t}}(e,this.currentResults);if(t.added.length>0||t.removed.length>0){(this.options?.debounceMs?mb(this.callback,this.options.debounceMs):this.callback)(t)}}catch(e){}}async updateCurrentResults(){try{if(1===this.componentTypes.length){const e=await this.graphqlClient.getAllTables(this.componentTypes[0],{fields:["updatedAtTimestampMs"]});this.currentResults=e.edges.map(e=>{const t=e.node;return t.nodeId||t.entityId||Object.values(t)[0]||""}).filter(Boolean)}else{const e=this.componentTypes.map(e=>({key:e,tableName:e,params:{fields:["updatedAtTimestampMs"],filter:{}}})),t=await this.graphqlClient.batchQuery(e),n=this.componentTypes.map(e=>{const n=t[e];return n?n.edges.map(e=>{const t=e.node;return t.nodeId||t.entityId||Object.values(t)[0]||""}).filter(Boolean):[]});this.currentResults=n.reduce((e,t)=>{const n=new Set(t);return e.filter(e=>n.has(e))})}}catch(e){this.currentResults=[]}}getCurrentResults(){return[...this.currentResults]}dispose(){this.subscriptions.forEach(e=>{try{e?.unsubscribe()}catch(e){}}),this.subscriptions=[]}},_b=class{constructor(e,t){this.componentMetadataMap=new Map,this.componentTypes=[],this.graphqlClient=e,this.dubheMetadata=t;const n=[],r=[];this.parseFromDubheMetadata(n,r);const i={components:n,discoveredAt:Date.now(),errors:r.length>0?r:void 0,totalDiscovered:n.length,fromDubheMetadata:!0};this.discoveryResult=i,this.componentTypes=n.map(e=>e.name),n.forEach(e=>{this.componentMetadataMap.set(e.name,e)})}parseFromDubheMetadata(e,t){const n=[];if(this.dubheMetadata?.components)for(const e of this.dubheMetadata.components)n.push(...Object.entries(e));if(this.dubheMetadata?.resources)for(const e of this.dubheMetadata.resources)for(const[t,r]of Object.entries(e))r.keys&&1===r.keys.length&&"entity_id"===r.keys[0]&&n.push([t,r]);for(const[r,i]of n){const n=this.tableNameToComponentName(r);try{const t=[],o=[],s=[];if(i.fields&&Array.isArray(i.fields))for(const e of i.fields)for(const[n,r]of Object.entries(e)){const e=this.snakeToCamel(n),a=String(r),u=i.keys&&i.keys.includes(n);t.push({name:e,type:this.dubheTypeToGraphQLType(a),nullable:!u,isPrimaryKey:u,isEnum:this.isEnumType(a)}),u&&o.push(e),this.isEnumType(a)&&s.push(e)}if(0===o.length&&(t.unshift({name:"entityId",type:"String",nullable:!1,isPrimaryKey:!0,isEnum:!1}),o.push("entityId")),t.push({name:"createdAtTimestampMs",type:"BigInt",nullable:!1,isPrimaryKey:!1,isEnum:!1},{name:"updatedAtTimestampMs",type:"BigInt",nullable:!1,isPrimaryKey:!1,isEnum:!1},{name:"isDeleted",type:"Boolean",nullable:!1,isPrimaryKey:!1,isEnum:!1},{name:"lastUpdateDigest",type:"String",nullable:!1,isPrimaryKey:!1,isEnum:!1}),1!==o.length)continue;const a={name:n,tableName:r,fields:t,primaryKeys:o,hasDefaultId:o.includes("entityId"),enumFields:s,lastUpdated:Date.now(),description:`Auto-discovered component: ${r}`};e.push(a)}catch(e){const r=`Component ${n} validation failed: ${wb(e)}`;t.push(r)}}}getComponentTypes(){return this.componentTypes}getComponentMetadata(e){const t=this.componentMetadataMap.get(e);if(t)return t;const n=e.replace(/([A-Z])/g,"_$1").toLowerCase();if(n!==e){const e=this.componentMetadataMap.get(n);if(e)return e}const r=e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase());if(r!==e){const e=this.componentMetadataMap.get(r);if(e)return e}return null}snakeToCamel(e){return e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}dubheTypeToGraphQLType(e){if(e.startsWith("vector<")&&e.endsWith(">"))return"String";switch(e){case"u8":case"u16":case"u32":case"u64":case"u128":case"i8":case"i16":case"i32":case"i64":case"i128":return"Int";case"address":case"string":case"enum":default:return"String";case"bool":return"Boolean"}}componentNameToTableName(e){return e.endsWith("s")?e:e+"s"}tableNameToComponentName(e){return e.endsWith("s")&&e.length>1?e.slice(0,-1):e}isEnumType(e){return this.dubheMetadata.enums.some(t=>"object"==typeof t&&t[e])}},Ob=class{constructor(e,t){this.resourceMetadataMap=new Map,this.resourceTypes=[],this.graphqlClient=e,this.dubheMetadata=t;const n=[],r=[];this.parseFromDubheMetadata(n,r);const i={resources:n,discoveredAt:Date.now(),errors:r.length>0?r:void 0,totalDiscovered:n.length,fromDubheMetadata:!0};this.discoveryResult=i,this.resourceTypes=n.map(e=>e.name),n.forEach(e=>{this.resourceMetadataMap.set(e.name,e)})}parseFromDubheMetadata(e,t){if(this.dubheMetadata?.resources)for(const n of this.dubheMetadata.resources)for(const[r,i]of Object.entries(n))try{const t=[],n=[],o=[];if(i.fields&&Array.isArray(i.fields))for(const e of i.fields)for(const[r,s]of Object.entries(e)){const e=this.snakeToCamel(r),a=String(s),u=i.keys&&i.keys.includes(r);t.push({name:e,type:this.dubheTypeToGraphQLType(a),nullable:!u,isPrimaryKey:u,isEnum:this.isEnumType(a)}),u&&n.push(e),this.isEnumType(a)&&o.push(e)}t.push({name:"createdAtTimestampMs",type:"BigInt",nullable:!1,isPrimaryKey:!1,isEnum:!1},{name:"updatedAtTimestampMs",type:"BigInt",nullable:!1,isPrimaryKey:!1,isEnum:!1},{name:"isDeleted",type:"Boolean",nullable:!1,isPrimaryKey:!1,isEnum:!1},{name:"lastUpdateDigest",type:"String",nullable:!1,isPrimaryKey:!1,isEnum:!1});const s={name:r,tableName:r,fields:t,primaryKeys:n,hasCompositeKeys:n.length>1,hasNoKeys:0===n.length,enumFields:o,lastUpdated:Date.now(),description:`Auto-discovered resource: ${r}`};e.push(s)}catch(e){const n=`Resource ${r} validation failed: ${wb(e)}`;t.push(n)}}getResourceTypes(){return this.resourceTypes}getResourceMetadata(e){const t=this.resourceMetadataMap.get(e);if(t)return t;const n=this.snakeToCamel(e);if(n!==e)return this.resourceMetadataMap.get(n)||null;const r=e.replace(/([A-Z])/g,"_$1").toLowerCase();return r!==e&&this.resourceMetadataMap.get(r)||null}snakeToCamel(e){return e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}dubheTypeToGraphQLType(e){if(e.startsWith("vector<")&&e.endsWith(">"))return"String";switch(e){case"u8":case"u16":case"u32":case"u64":case"u128":case"i8":case"i16":case"i32":case"i64":case"i128":return"Int";case"address":case"string":case"enum":default:return"String";case"bool":return"Boolean"}}isEnumType(e){return this.dubheMetadata.enums.some(t=>"object"==typeof t&&t[e])}},xb=class{constructor(e,t){this.graphqlClient=e,this.config={queryConfig:{defaultCacheTimeout:3e5,maxConcurrentQueries:10,enableBatchOptimization:!0},subscriptionConfig:{defaultDebounceMs:100,maxSubscriptions:50,reconnectOnError:!0},...t};let n=this.config.dubheMetadata;if(!n&&(n=this.graphqlClient.getDubheMetadata(),!n))throw new Error("DubheMetadata is required for ECS World initialization. Please provide it either in ECSWorldConfig or in GraphQL client configuration.");this.dubheMetadata=n,this.componentDiscoverer=new _b(e,this.dubheMetadata),this.resourceDiscoverer=new Ob(e,this.dubheMetadata),this.querySystem=new Eb(e,this.componentDiscoverer),this.subscriptionSystem=new Sb(e,this.componentDiscoverer),this.initializeWithConfig()}initializeWithConfig(){try{const e=this.componentDiscoverer.discoveryResult.components.filter(e=>1===e.primaryKeys.length);this.resourceDiscoverer.discoveryResult.resources;this.querySystem.setAvailableComponents(e.map(e=>e.name)),this.querySystem.initializeComponentMetadata(e.map(e=>({name:e.name,primaryKeys:e.primaryKeys}))),this.subscriptionSystem.setAvailableComponents(e.map(e=>e.name)),this.subscriptionSystem.initializeComponentMetadata(e.map(e=>({name:e.name,primaryKeys:e.primaryKeys}))),this.config.queryConfig,this.config.subscriptionConfig}catch(e){throw new Error(`Failed to initialize ECS World: ${wb(e)}`)}}configure(e){this.config={...this.config,...e},e.dubheMetadata&&(this.dubheMetadata=e.dubheMetadata,this.componentDiscoverer=new _b(this.graphqlClient,this.dubheMetadata),this.resourceDiscoverer=new Ob(this.graphqlClient,this.dubheMetadata),this.querySystem.setComponentDiscoverer(this.componentDiscoverer),this.subscriptionSystem.setComponentDiscoverer(this.componentDiscoverer),this.initializeWithConfig())}discoverComponents(){return this.componentDiscoverer.getComponentTypes()}getAvailableComponents(){return this.componentDiscoverer.getComponentTypes()}getComponentMetadata(e){return this.componentDiscoverer.getComponentMetadata(e)}getAvailableResources(){return this.resourceDiscoverer.getResourceTypes()}getResourceMetadata(e){return this.resourceDiscoverer.getResourceMetadata(e)}async hasEntity(e){return this.querySystem.hasEntity(e)}async getAllEntities(){return this.querySystem.getAllEntities()}async getEntityCount(){return this.querySystem.getEntityCount()}async getEntity(e){try{if(!await this.hasEntity(e))return null;const t=await this.getComponents(e);if(0===t.length)return null;const n={entityId:e,components:{}};for(const r of t){const t=await this.getComponent(e,r);t&&(n.components[r]=t)}return n}catch(t){return console.error(`Failed to get entity ${e}:`,wb(t)),null}}async getEntities(){return this.getAllEntities()}async getEntitiesByComponent(e){return this.queryWith(e)}async hasComponent(e,t){return this.querySystem.hasComponent(e,t)}async getComponent(e,t){return this.querySystem.getComponent(e,t)}async getComponents(e){return this.querySystem.getComponents(e)}async queryWith(e,t){return this.querySystem.queryWith(e,t)}async queryWithAll(e,t){return this.querySystem.queryWithAll(e,t)}async queryWithAny(e,t){return this.querySystem.queryWithAny(e,t)}async queryWithout(e,t,n){return this.querySystem.queryWithout(e,t,n)}async queryWhere(e,t,n){return this.querySystem.queryWhere(e,t,n)}async queryRange(e,t,n,r,i){return this.querySystem.queryRange(e,t,n,r,i)}async queryPaged(e,t,n){return this.querySystem.queryPaged(e,t,n)}async queryWithPagination(e,t){return this.querySystem.queryWith(e,t)}async queryWherePagination(e,t,n){return this.querySystem.queryWhereFullPagination(e,t,n)}query(){return this.querySystem.query()}onComponentAdded(e,t){return this.subscriptionSystem.onComponentAdded(e,t)}onComponentRemoved(e,t){return this.subscriptionSystem.onComponentRemoved(e,t)}onComponentChanged(e,t){return this.subscriptionSystem.onComponentChanged(e,t)}onEntityComponent(e,t,n){return this.subscriptionSystem.onEntityComponent(e,t,n)}watchQuery(e,t){return this.subscriptionSystem.watchQuery(e,t)}createRealTimeStream(e,t){return this.subscriptionSystem.createRealTimeStream(e,t)}async queryWithComponentData(e,t){try{const n=await this.queryWith(e,t),r=[];for(const t of n.entityIds){const n=await this.getComponent(t,e);n&&r.push({entityId:t,data:n})}return r}catch(e){return[]}}async queryMultiComponentData(e,t,n){try{const r=await this.queryWithAll([e,t],n),i=[];for(const n of r){const[r,o]=await Promise.all([this.getComponent(n,e),this.getComponent(n,t)]);r&&o&&i.push({entityId:n,data1:r,data2:o})}return i}catch(e){return[]}}async getEntityState(e){try{const t=await this.getComponents(e);if(0===t.length)return null;const n={};for(const r of t){const t=await this.getComponent(e,r);t&&(n[r]=t)}return{entityId:e,components:n}}catch(e){return null}}async getComponentStats(){try{const e={},t=await this.getAvailableComponents();return await Promise.all(t.map(async t=>{try{const n=await this.queryWith(t);e[t]=n.totalCount}catch(n){e[t]=0}})),e}catch(e){return{}}}async findOrphanEntities(){try{const e=await this.getAllEntities(),t=[];for(const n of e){1===(await this.getComponents(n)).length&&t.push(n)}return t}catch(e){return[]}}unsubscribeAll(){this.subscriptionSystem.unsubscribeAll()}clearCache(){this.querySystem.dispose()}dispose(){this.querySystem.dispose(),this.subscriptionSystem.dispose()}getGraphQLClient(){return this.graphqlClient}getQuerySystem(){return this.querySystem}getSubscriptionSystem(){return this.subscriptionSystem}getConfig(){return{...this.config}}updateConfig(e){void 0!==e.dubheMetadata&&(this.dubheMetadata=e.dubheMetadata,this.config.dubheMetadata=e.dubheMetadata,this.componentDiscoverer=new _b(this.graphqlClient,this.dubheMetadata),this.resourceDiscoverer=new Ob(this.graphqlClient,this.dubheMetadata),this.querySystem.setComponentDiscoverer(this.componentDiscoverer),this.subscriptionSystem.setComponentDiscoverer(this.componentDiscoverer),this.initializeWithConfig()),e.queryConfig&&(this.config.queryConfig={...this.config.queryConfig,...e.queryConfig},void 0!==e.queryConfig.defaultCacheTimeout&&(this.querySystem.cacheTimeout=e.queryConfig.defaultCacheTimeout)),e.subscriptionConfig&&(this.config.subscriptionConfig={...this.config.subscriptionConfig,...e.subscriptionConfig})}getDubheMetadata(){return this.dubheMetadata}async getResource(e,t,n){try{const r=this.resourceDiscoverer.getResourceMetadata(e);if(!r)return null;t=t||{};const i={};for(const[e,n]of Object.entries(t))i[e]={equalTo:n};const o={first:n?.first??n?.limit??1,last:n?.last,after:n?.after,before:n?.before},s=await this.graphqlClient.getAllTables(e,{...o,filter:i,fields:n?.fields||r.fields.map(e=>e.name),orderBy:n?.orderBy}),a=s.edges[0]?.node;return a||null}catch(e){return null}}async getResources(e,t){try{const n=this.resourceDiscoverer.getResourceMetadata(e);if(!n)return{entityIds:[],items:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1},totalCount:0};const r={isDeleted:{equalTo:!1}};if(t?.filters)for(const[e,n]of Object.entries(t.filters))r[e]="object"==typeof n&&null!==n?n:{equalTo:n};const i={first:t?.first??t?.limit,last:t?.last,after:t?.after,before:t?.before},o=await this.graphqlClient.getAllTables(e,{...i,filter:Object.keys(r).length>0?r:void 0,fields:t?.fields||n.fields.map(e=>e.name),orderBy:t?.orderBy});return{entityIds:[],items:o.edges.map(e=>e.node),pageInfo:{hasNextPage:o.pageInfo.hasNextPage,hasPreviousPage:o.pageInfo.hasPreviousPage,startCursor:o.pageInfo.startCursor,endCursor:o.pageInfo.endCursor},totalCount:o.totalCount||0}}catch(e){return{entityIds:[],items:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1},totalCount:0}}}async hasResource(e,t){return null!==await this.getResource(e,t)}async getResourceCount(e){try{return(await this.graphqlClient.getAllTables(e,{first:1})).totalCount||0}catch(e){return 0}}subscribeToResourceChanges(e,t){const n=this.resourceDiscoverer.getResourceMetadata(e);if(!n)throw new Error(`Unknown resource type: ${e}. Available resources: [${this.getAvailableResources().join(", ")}]`);const r=t?.fields||n.fields.map(e=>e.name);return this.graphqlClient.subscribeToTableChanges(e,{...t,fields:r})}};function Ib(e){let t=!1;const n=[];for(let r=0;r<e.length;r++){let i=e.charAt(r);"_"==i?t=!0:/\d/.test(i)?(n.push(i),t=!0):t?(n.push(i.toUpperCase()),t=!1):0==r?n.push(i.toLowerCase()):n.push(i)}return n.join("")}const Mb=Symbol.for("protobuf-ts/message-type");var Cb,Ab,Nb;function jb(e){var t,n,r,i;return e.localName=null!==(t=e.localName)&&void 0!==t?t:Ib(e.name),e.jsonName=null!==(n=e.jsonName)&&void 0!==n?n:Ib(e.name),e.repeat=null!==(r=e.repeat)&&void 0!==r?r:Nb.NO,e.opt=null!==(i=e.opt)&&void 0!==i?i:!e.repeat&&(!e.oneof&&"message"==e.kind),e}function Db(e){if("object"!=typeof e||null===e||!e.hasOwnProperty("oneofKind"))return!1;switch(typeof e.oneofKind){case"string":return void 0!==e[e.oneofKind]&&2==Object.keys(e).length;case"undefined":return 1==Object.keys(e).length;default:return!1}}!function(e){e[e.DOUBLE=1]="DOUBLE",e[e.FLOAT=2]="FLOAT",e[e.INT64=3]="INT64",e[e.UINT64=4]="UINT64",e[e.INT32=5]="INT32",e[e.FIXED64=6]="FIXED64",e[e.FIXED32=7]="FIXED32",e[e.BOOL=8]="BOOL",e[e.STRING=9]="STRING",e[e.BYTES=12]="BYTES",e[e.UINT32=13]="UINT32",e[e.SFIXED32=15]="SFIXED32",e[e.SFIXED64=16]="SFIXED64",e[e.SINT32=17]="SINT32",e[e.SINT64=18]="SINT64"}(Cb||(Cb={})),function(e){e[e.BIGINT=0]="BIGINT",e[e.STRING=1]="STRING",e[e.NUMBER=2]="NUMBER"}(Ab||(Ab={})),function(e){e[e.NO=0]="NO",e[e.PACKED=1]="PACKED",e[e.UNPACKED=2]="UNPACKED"}(Nb||(Nb={}));class Rb{constructor(e){var t;this.fields=null!==(t=e.fields)&&void 0!==t?t:[]}prepare(){if(this.data)return;const e=[],t=[],n=[];for(let r of this.fields)if(r.oneof)n.includes(r.oneof)||(n.push(r.oneof),e.push(r.oneof),t.push(r.oneof));else switch(t.push(r.localName),r.kind){case"scalar":case"enum":r.opt&&!r.repeat||e.push(r.localName);break;case"message":r.repeat&&e.push(r.localName);break;case"map":e.push(r.localName)}this.data={req:e,known:t,oneofs:Object.values(n)}}is(e,t,n=!1){if(t<0)return!0;if(null==e||"object"!=typeof e)return!1;this.prepare();let r=Object.keys(e),i=this.data;if(r.length<i.req.length||i.req.some(e=>!r.includes(e)))return!1;if(!n&&r.some(e=>!i.known.includes(e)))return!1;if(t<1)return!0;for(const r of i.oneofs){const i=e[r];if(!Db(i))return!1;if(void 0===i.oneofKind)continue;const o=this.fields.find(e=>e.localName===i.oneofKind);if(!o)return!1;if(!this.field(i[i.oneofKind],o,n,t))return!1}for(const r of this.fields)if(void 0===r.oneof&&!this.field(e[r.localName],r,n,t))return!1;return!0}field(e,t,n,r){let i=t.repeat;switch(t.kind){case"scalar":return void 0===e?t.opt:i?this.scalars(e,t.T,r,t.L):this.scalar(e,t.T,t.L);case"enum":return void 0===e?t.opt:i?this.scalars(e,Cb.INT32,r):this.scalar(e,Cb.INT32);case"message":return void 0===e||(i?this.messages(e,t.T(),n,r):this.message(e,t.T(),n,r));case"map":if("object"!=typeof e||null===e)return!1;if(r<2)return!0;if(!this.mapKeys(e,t.K,r))return!1;switch(t.V.kind){case"scalar":return this.scalars(Object.values(e),t.V.T,r,t.V.L);case"enum":return this.scalars(Object.values(e),Cb.INT32,r);case"message":return this.messages(Object.values(e),t.V.T(),n,r)}}return!0}message(e,t,n,r){return n?t.isAssignable(e,r):t.is(e,r)}messages(e,t,n,r){if(!Array.isArray(e))return!1;if(r<2)return!0;if(n){for(let n=0;n<e.length&&n<r;n++)if(!t.isAssignable(e[n],r-1))return!1}else for(let n=0;n<e.length&&n<r;n++)if(!t.is(e[n],r-1))return!1;return!0}scalar(e,t,n){let r=typeof e;switch(t){case Cb.UINT64:case Cb.FIXED64:case Cb.INT64:case Cb.SFIXED64:case Cb.SINT64:switch(n){case Ab.BIGINT:return"bigint"==r;case Ab.NUMBER:return"number"==r&&!isNaN(e);default:return"string"==r}case Cb.BOOL:return"boolean"==r;case Cb.STRING:return"string"==r;case Cb.BYTES:return e instanceof Uint8Array;case Cb.DOUBLE:case Cb.FLOAT:return"number"==r&&!isNaN(e);default:return"number"==r&&Number.isInteger(e)}}scalars(e,t,n,r){if(!Array.isArray(e))return!1;if(n<2)return!0;if(Array.isArray(e))for(let i=0;i<e.length&&i<n;i++)if(!this.scalar(e[i],t,r))return!1;return!0}mapKeys(e,t,n){let r=Object.keys(e);switch(t){case Cb.INT32:case Cb.FIXED32:case Cb.SFIXED32:case Cb.SINT32:case Cb.UINT32:return this.scalars(r.slice(0,n).map(e=>parseInt(e)),t,n);case Cb.BOOL:return this.scalars(r.slice(0,n).map(e=>"true"==e||"false"!=e&&e),t,n);default:return this.scalars(r,t,n,Ab.STRING)}}}function Pb(e){let t=typeof e;if("object"==t){if(Array.isArray(e))return"array";if(null===e)return"null"}return t}function Bb(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}let Fb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Lb=[];for(let e=0;e<Fb.length;e++)Lb[Fb[e].charCodeAt(0)]=e;function Ub(e){let t=3*e.length/4;"="==e[e.length-2]?t-=2:"="==e[e.length-1]&&(t-=1);let n,r=new Uint8Array(t),i=0,o=0,s=0;for(let t=0;t<e.length;t++){if(n=Lb[e.charCodeAt(t)],void 0===n)switch(e[t]){case"=":o=0;case"\n":case"\r":case"\t":case" ":continue;default:throw Error("invalid base64 string.")}switch(o){case 0:s=n,o=1;break;case 1:r[i++]=s<<2|(48&n)>>4,s=n,o=2;break;case 2:r[i++]=(15&s)<<4|(60&n)>>2,s=n,o=3;break;case 3:r[i++]=(3&s)<<6|n,o=0}}if(1==o)throw Error("invalid base64 string.");return r.subarray(0,i)}function $b(e){let t,n="",r=0,i=0;for(let o=0;o<e.length;o++)switch(t=e[o],r){case 0:n+=Fb[t>>2],i=(3&t)<<4,r=1;break;case 1:n+=Fb[i|t>>4],i=(15&t)<<2,r=2;break;case 2:n+=Fb[i|t>>6],n+=Fb[63&t],r=0}return r&&(n+=Fb[i],n+="=",1==r&&(n+="=")),n}function qb(){let e=0,t=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(e|=(127&r)<<n,!(128&r))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(15&n)<<28,t=(112&n)>>4,!(128&n))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(t|=(127&r)<<n,!(128&r))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function Vb(e,t,n){for(let r=0;r<28;r+=7){const i=e>>>r,o=!(i>>>7==0&&0==t),s=255&(o?128|i:i);if(n.push(s),!o)return}const r=e>>>28&15|(7&t)<<4,i=!!(t>>3);if(n.push(255&(i?128|r:r)),i){for(let e=3;e<31;e+=7){const r=t>>>e,i=!(r>>>7==0),o=255&(i?128|r:r);if(n.push(o),!i)return}n.push(t>>>31&1)}}Lb["-".charCodeAt(0)]=Fb.indexOf("+"),Lb["_".charCodeAt(0)]=Fb.indexOf("/");const zb=4294967296;function Kb(e){let t="-"==e[0];t&&(e=e.slice(1));const n=1e6;let r=0,i=0;function o(t,o){const s=Number(e.slice(t,o));i*=n,r=r*n+s,r>=zb&&(i+=r/zb|0,r%=zb)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),[t,r,i]}function Wb(e,t){if(t>>>0<=2097151)return""+(zb*t+(e>>>0));let n=(e>>>24|t<<8)>>>0&16777215,r=t>>16&65535,i=(16777215&e)+6777216*n+6710656*r,o=n+8147497*r,s=2*r,a=1e7;function u(e,t){let n=e?String(e):"";return t?"0000000".slice(n.length)+n:n}return i>=a&&(o+=Math.floor(i/a),i%=a),o>=a&&(s+=Math.floor(o/a),o%=a),u(s,0)+u(o,s)+u(i,1)}function Qb(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(127&e|128),e>>=7;t.push(1)}}function Gb(){let e=this.buf[this.pos++],t=127&e;if(!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,!(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let t=5;128&e&&t<10;t++)e=this.buf[this.pos++];if(128&e)throw new Error("invalid varint");return this.assertBounds(),t>>>0}let Hb;function Jb(e){if(!e)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}!function(){const e=new DataView(new ArrayBuffer(8)),t=void 0!==globalThis.BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64;Hb=t?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:e}:void 0}();const Zb=/^-?[0-9]+$/,Yb=4294967296,Xb=2147483648;class ev{constructor(e,t){this.lo=0|e,this.hi=0|t}isZero(){return 0==this.lo&&0==this.hi}toNumber(){let e=this.hi*Yb+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}}class tv extends ev{static from(e){if(Hb)switch(typeof e){case"string":if("0"==e)return this.ZERO;if(""==e)throw new Error("string is no integer");e=Hb.C(e);case"number":if(0===e)return this.ZERO;e=Hb.C(e);case"bigint":if(!e)return this.ZERO;if(e<Hb.UMIN)throw new Error("signed value for ulong");if(e>Hb.UMAX)throw new Error("ulong too large");return Hb.V.setBigUint64(0,e,!0),new tv(Hb.V.getInt32(0,!0),Hb.V.getInt32(4,!0))}else switch(typeof e){case"string":if("0"==e)return this.ZERO;if(e=e.trim(),!Zb.test(e))throw new Error("string is no integer");let[t,n,r]=Kb(e);if(t)throw new Error("signed value for ulong");return new tv(n,r);case"number":if(0==e)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new tv(e,e/Yb)}throw new Error("unknown value "+typeof e)}toString(){return Hb?this.toBigInt().toString():Wb(this.lo,this.hi)}toBigInt(){return Jb(Hb),Hb.V.setInt32(0,this.lo,!0),Hb.V.setInt32(4,this.hi,!0),Hb.V.getBigUint64(0,!0)}}tv.ZERO=new tv(0,0);class nv extends ev{static from(e){if(Hb)switch(typeof e){case"string":if("0"==e)return this.ZERO;if(""==e)throw new Error("string is no integer");e=Hb.C(e);case"number":if(0===e)return this.ZERO;e=Hb.C(e);case"bigint":if(!e)return this.ZERO;if(e<Hb.MIN)throw new Error("signed long too small");if(e>Hb.MAX)throw new Error("signed long too large");return Hb.V.setBigInt64(0,e,!0),new nv(Hb.V.getInt32(0,!0),Hb.V.getInt32(4,!0))}else switch(typeof e){case"string":if("0"==e)return this.ZERO;if(e=e.trim(),!Zb.test(e))throw new Error("string is no integer");let[t,n,r]=Kb(e);if(t){if(r>Xb||r==Xb&&0!=n)throw new Error("signed long too small")}else if(r>=Xb)throw new Error("signed long too large");let i=new nv(n,r);return t?i.negate():i;case"number":if(0==e)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new nv(e,e/Yb):new nv(-e,-e/Yb).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return 0!==(this.hi&Xb)}negate(){let e=~this.hi,t=this.lo;return t?t=1+~t:e+=1,new nv(t,e)}toString(){if(Hb)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+Wb(e.lo,e.hi)}return Wb(this.lo,this.hi)}toBigInt(){return Jb(Hb),Hb.V.setInt32(0,this.lo,!0),Hb.V.setInt32(4,this.hi,!0),Hb.V.getBigInt64(0,!0)}}function rv(e,t){if(!e)throw new Error(t)}nv.ZERO=new nv(0,0);function iv(e){if("number"!=typeof e)throw new Error("invalid int 32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int 32: "+e)}function ov(e){if("number"!=typeof e)throw new Error("invalid uint 32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint 32: "+e)}function sv(e){if("number"!=typeof e)throw new Error("invalid float 32: "+typeof e);if(Number.isFinite(e)&&(e>34028234663852886e22||e<-34028234663852886e22))throw new Error("invalid float 32: "+e)}function av(e,t){switch(t){case Ab.BIGINT:return e.toBigInt();case Ab.NUMBER:return e.toNumber();default:return e.toString()}}class uv{constructor(e){this.info=e}prepare(){var e;if(void 0===this.fMap){this.fMap={};const t=null!==(e=this.info.fields)&&void 0!==e?e:[];for(const e of t)this.fMap[e.name]=e,this.fMap[e.jsonName]=e,this.fMap[e.localName]=e}}assert(e,t,n){if(!e){let e=Pb(n);throw"number"!=e&&"boolean"!=e||(e=n.toString()),new Error(`Cannot parse JSON ${e} for ${this.info.typeName}#${t}`)}}read(e,t,n){this.prepare();const r=[];for(const[i,o]of Object.entries(e)){const e=this.fMap[i];if(!e){if(!n.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${i}`);continue}const s=e.localName;let a;if(e.oneof){if(null===o&&("enum"!==e.kind||"google.protobuf.NullValue"!==e.T()[0]))continue;if(r.includes(e.oneof))throw new Error(`Multiple members of the oneof group "${e.oneof}" of ${this.info.typeName} are present in JSON.`);r.push(e.oneof),a=t[e.oneof]={oneofKind:s}}else a=t;if("map"==e.kind){if(null===o)continue;this.assert(Bb(o),e.name,o);const t=a[s];for(const[r,i]of Object.entries(o)){let o;switch(this.assert(null!==i,e.name+" map value",null),e.V.kind){case"message":o=e.V.T().internalJsonRead(i,n);break;case"enum":if(o=this.enum(e.V.T(),i,e.name,n.ignoreUnknownFields),!1===o)continue;break;case"scalar":o=this.scalar(i,e.V.T,e.V.L,e.name)}this.assert(void 0!==o,e.name+" map value",i);let s=r;e.K==Cb.BOOL&&(s="true"==s||"false"!=s&&s),s=this.scalar(s,e.K,Ab.STRING,e.name).toString(),t[s]=o}}else if(e.repeat){if(null===o)continue;this.assert(Array.isArray(o),e.name,o);const t=a[s];for(const r of o){let i;switch(this.assert(null!==r,e.name,null),e.kind){case"message":i=e.T().internalJsonRead(r,n);break;case"enum":if(i=this.enum(e.T(),r,e.name,n.ignoreUnknownFields),!1===i)continue;break;case"scalar":i=this.scalar(r,e.T,e.L,e.name)}this.assert(void 0!==i,e.name,o),t.push(i)}}else switch(e.kind){case"message":if(null===o&&"google.protobuf.Value"!=e.T().typeName){this.assert(void 0===e.oneof,e.name+" (oneof member)",null);continue}a[s]=e.T().internalJsonRead(o,n,a[s]);break;case"enum":if(null===o)continue;let t=this.enum(e.T(),o,e.name,n.ignoreUnknownFields);if(!1===t)continue;a[s]=t;break;case"scalar":if(null===o)continue;a[s]=this.scalar(o,e.T,e.L,e.name)}}}enum(e,t,n,r){if("google.protobuf.NullValue"==e[0]&&rv(null===t||"NULL_VALUE"===t,`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} only accepts null.`),null===t)return 0;switch(typeof t){case"number":return rv(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${n}, enum can only be integral number, got ${t}.`),t;case"string":let i=t;e[2]&&t.substring(0,e[2].length)===e[2]&&(i=t.substring(e[2].length));let o=e[1][i];return(void 0!==o||!r)&&(rv("number"==typeof o,`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} has no value for "${t}".`),o)}rv(!1,`Unable to parse field ${this.info.typeName}#${n}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,n,r){let i;try{switch(t){case Cb.DOUBLE:case Cb.FLOAT:if(null===e)return 0;if("NaN"===e)return Number.NaN;if("Infinity"===e)return Number.POSITIVE_INFINITY;if("-Infinity"===e)return Number.NEGATIVE_INFINITY;if(""===e){i="empty string";break}if("string"==typeof e&&e.trim().length!==e.length){i="extra whitespace";break}if("string"!=typeof e&&"number"!=typeof e)break;let r=Number(e);if(Number.isNaN(r)){i="not a number";break}if(!Number.isFinite(r)){i="too large or small";break}return t==Cb.FLOAT&&sv(r),r;case Cb.INT32:case Cb.FIXED32:case Cb.SFIXED32:case Cb.SINT32:case Cb.UINT32:if(null===e)return 0;let o;if("number"==typeof e?o=e:""===e?i="empty string":"string"==typeof e&&(e.trim().length!==e.length?i="extra whitespace":o=Number(e)),void 0===o)break;return t==Cb.UINT32?ov(o):iv(o),o;case Cb.INT64:case Cb.SFIXED64:case Cb.SINT64:if(null===e)return av(nv.ZERO,n);if("number"!=typeof e&&"string"!=typeof e)break;return av(nv.from(e),n);case Cb.FIXED64:case Cb.UINT64:if(null===e)return av(tv.ZERO,n);if("number"!=typeof e&&"string"!=typeof e)break;return av(tv.from(e),n);case Cb.BOOL:if(null===e)return!1;if("boolean"!=typeof e)break;return e;case Cb.STRING:if(null===e)return"";if("string"!=typeof e){i="extra whitespace";break}try{encodeURIComponent(e)}catch(i){i="invalid UTF8";break}return e;case Cb.BYTES:if(null===e||""===e)return new Uint8Array(0);if("string"!=typeof e)break;return Ub(e)}}catch(e){i=e.message}this.assert(!1,r+(i?" - "+i:""),e)}}class cv{constructor(e){var t;this.fields=null!==(t=e.fields)&&void 0!==t?t:[]}write(e,t){const n={},r=e;for(const e of this.fields){if(!e.oneof){let i=this.field(e,r[e.localName],t);void 0!==i&&(n[t.useProtoFieldName?e.name:e.jsonName]=i);continue}const i=r[e.oneof];if(i.oneofKind!==e.localName)continue;const o="scalar"==e.kind||"enum"==e.kind?Object.assign(Object.assign({},t),{emitDefaultValues:!0}):t;let s=this.field(e,i[e.localName],o);rv(void 0!==s),n[t.useProtoFieldName?e.name:e.jsonName]=s}return n}field(e,t,n){let r;if("map"==e.kind){rv("object"==typeof t&&null!==t);const i={};switch(e.V.kind){case"scalar":for(const[n,r]of Object.entries(t)){const t=this.scalar(e.V.T,r,e.name,!1,!0);rv(void 0!==t),i[n.toString()]=t}break;case"message":const r=e.V.T();for(const[o,s]of Object.entries(t)){const t=this.message(r,s,e.name,n);rv(void 0!==t),i[o.toString()]=t}break;case"enum":const o=e.V.T();for(const[r,s]of Object.entries(t)){rv(void 0===s||"number"==typeof s);const t=this.enum(o,s,e.name,!1,!0,n.enumAsInteger);rv(void 0!==t),i[r.toString()]=t}}(n.emitDefaultValues||Object.keys(i).length>0)&&(r=i)}else if(e.repeat){rv(Array.isArray(t));const i=[];switch(e.kind){case"scalar":for(let n=0;n<t.length;n++){const r=this.scalar(e.T,t[n],e.name,e.opt,!0);rv(void 0!==r),i.push(r)}break;case"enum":const r=e.T();for(let o=0;o<t.length;o++){rv(void 0===t[o]||"number"==typeof t[o]);const s=this.enum(r,t[o],e.name,e.opt,!0,n.enumAsInteger);rv(void 0!==s),i.push(s)}break;case"message":const o=e.T();for(let r=0;r<t.length;r++){const s=this.message(o,t[r],e.name,n);rv(void 0!==s),i.push(s)}}(n.emitDefaultValues||i.length>0||n.emitDefaultValues)&&(r=i)}else switch(e.kind){case"scalar":r=this.scalar(e.T,t,e.name,e.opt,n.emitDefaultValues);break;case"enum":r=this.enum(e.T(),t,e.name,e.opt,n.emitDefaultValues,n.enumAsInteger);break;case"message":r=this.message(e.T(),t,e.name,n)}return r}enum(e,t,n,r,i,o){if("google.protobuf.NullValue"==e[0])return i||r?null:void 0;if(void 0!==t){if(0!==t||i||r)return rv("number"==typeof t),rv(Number.isInteger(t)),o||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}else rv(r)}message(e,t,n,r){return void 0===t?r.emitDefaultValues?null:void 0:e.internalJsonWrite(t,r)}scalar(e,t,n,r,i){if(void 0===t)return void rv(r);const o=i||r;switch(e){case Cb.INT32:case Cb.SFIXED32:case Cb.SINT32:return 0===t?o?0:void 0:(iv(t),t);case Cb.FIXED32:case Cb.UINT32:return 0===t?o?0:void 0:(ov(t),t);case Cb.FLOAT:sv(t);case Cb.DOUBLE:return 0===t?o?0:void 0:(rv("number"==typeof t),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case Cb.STRING:return""===t?o?"":void 0:(rv("string"==typeof t),t);case Cb.BOOL:return!1===t?!o&&void 0:(rv("boolean"==typeof t),t);case Cb.UINT64:case Cb.FIXED64:rv("number"==typeof t||"string"==typeof t||"bigint"==typeof t);let e=tv.from(t);if(e.isZero()&&!o)return;return e.toString();case Cb.INT64:case Cb.SFIXED64:case Cb.SINT64:rv("number"==typeof t||"string"==typeof t||"bigint"==typeof t);let n=nv.from(t);if(n.isZero()&&!o)return;return n.toString();case Cb.BYTES:return rv(t instanceof Uint8Array),t.byteLength?$b(t):o?"":void 0}}}var lv,hv;function fv(e,t){return Object.assign(Object.assign({},e),t)}function dv(e,t=Ab.STRING){switch(e){case Cb.BOOL:return!1;case Cb.UINT64:case Cb.FIXED64:return av(tv.ZERO,t);case Cb.INT64:case Cb.SFIXED64:case Cb.SINT64:return av(nv.ZERO,t);case Cb.DOUBLE:case Cb.FLOAT:return 0;case Cb.BYTES:return new Uint8Array(0);case Cb.STRING:return"";default:return 0}}!function(e){e.symbol=Symbol.for("protobuf-ts/unknown"),e.onRead=(n,r,i,o,s)=>{(t(r)?r[e.symbol]:r[e.symbol]=[]).push({no:i,wireType:o,data:s})},e.onWrite=(t,n,r)=>{for(let{no:t,wireType:i,data:o}of e.list(n))r.tag(t,i).raw(o)},e.list=(n,r)=>{if(t(n)){let t=n[e.symbol];return r?t.filter(e=>e.no==r):t}return[]},e.last=(t,n)=>e.list(t,n).slice(-1)[0];const t=t=>t&&Array.isArray(t[e.symbol])}(lv||(lv={})),function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"}(hv||(hv={}));class pv{constructor(e){this.info=e}prepare(){var e;if(!this.fieldNoToField){const t=null!==(e=this.info.fields)&&void 0!==e?e:[];this.fieldNoToField=new Map(t.map(e=>[e.no,e]))}}read(e,t,n,r){this.prepare();const i=void 0===r?e.len:e.pos+r;for(;e.pos<i;){const[r,i]=e.tag(),o=this.fieldNoToField.get(r);if(!o){let o=n.readUnknownField;if("throw"==o)throw new Error(`Unknown field ${r} (wire type ${i}) for ${this.info.typeName}`);let s=e.skip(i);!1!==o&&(!0===o?lv.onRead:o)(this.info.typeName,t,r,i,s);continue}let s=t,a=o.repeat,u=o.localName;switch(o.oneof&&(s=s[o.oneof],s.oneofKind!==u&&(s=t[o.oneof]={oneofKind:u})),o.kind){case"scalar":case"enum":let t="enum"==o.kind?Cb.INT32:o.T,r="scalar"==o.kind?o.L:void 0;if(a){let n=s[u];if(i==hv.LengthDelimited&&t!=Cb.STRING&&t!=Cb.BYTES){let i=e.uint32()+e.pos;for(;e.pos<i;)n.push(this.scalar(e,t,r))}else n.push(this.scalar(e,t,r))}else s[u]=this.scalar(e,t,r);break;case"message":if(a){let t=s[u],r=o.T().internalBinaryRead(e,e.uint32(),n);t.push(r)}else s[u]=o.T().internalBinaryRead(e,e.uint32(),n,s[u]);break;case"map":let[c,l]=this.mapEntry(o,e,n);s[u][c]=l}}}mapEntry(e,t,n){let r,i,o=t.uint32(),s=t.pos+o;for(;t.pos<s;){let[o,s]=t.tag();switch(o){case 1:r=e.K==Cb.BOOL?t.bool().toString():this.scalar(t,e.K,Ab.STRING);break;case 2:switch(e.V.kind){case"scalar":i=this.scalar(t,e.V.T,e.V.L);break;case"enum":i=t.int32();break;case"message":i=e.V.T().internalBinaryRead(t,t.uint32(),n)}break;default:throw new Error(`Unknown field ${o} (wire type ${s}) in map entry for ${this.info.typeName}#${e.name}`)}}if(void 0===r){let t=dv(e.K);r=e.K==Cb.BOOL?t.toString():t}if(void 0===i)switch(e.V.kind){case"scalar":i=dv(e.V.T,e.V.L);break;case"enum":i=0;break;case"message":i=e.V.T().create()}return[r,i]}scalar(e,t,n){switch(t){case Cb.INT32:return e.int32();case Cb.STRING:return e.string();case Cb.BOOL:return e.bool();case Cb.DOUBLE:return e.double();case Cb.FLOAT:return e.float();case Cb.INT64:return av(e.int64(),n);case Cb.UINT64:return av(e.uint64(),n);case Cb.FIXED64:return av(e.fixed64(),n);case Cb.FIXED32:return e.fixed32();case Cb.BYTES:return e.bytes();case Cb.UINT32:return e.uint32();case Cb.SFIXED32:return e.sfixed32();case Cb.SFIXED64:return av(e.sfixed64(),n);case Cb.SINT32:return e.sint32();case Cb.SINT64:return av(e.sint64(),n)}}}class yv{constructor(e){this.info=e}prepare(){if(!this.fields){const e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort((e,t)=>e.no-t.no)}}write(e,t,n){this.prepare();for(const r of this.fields){let i,o,s=r.repeat,a=r.localName;if(r.oneof){const t=e[r.oneof];if(t.oneofKind!==a)continue;i=t[a],o=!0}else i=e[a],o=!1;switch(r.kind){case"scalar":case"enum":let e="enum"==r.kind?Cb.INT32:r.T;if(s)if(rv(Array.isArray(i)),s==Nb.PACKED)this.packed(t,e,r.no,i);else for(const n of i)this.scalar(t,e,r.no,n,!0);else void 0===i?rv(r.opt):this.scalar(t,e,r.no,i,o||r.opt);break;case"message":if(s){rv(Array.isArray(i));for(const e of i)this.message(t,n,r.T(),r.no,e)}else this.message(t,n,r.T(),r.no,i);break;case"map":rv("object"==typeof i&&null!==i);for(const[e,o]of Object.entries(i))this.mapEntry(t,n,r,e,o)}}let r=n.writeUnknownFields;!1!==r&&(!0===r?lv.onWrite:r)(this.info.typeName,e,t)}mapEntry(e,t,n,r,i){e.tag(n.no,hv.LengthDelimited),e.fork();let o=r;switch(n.K){case Cb.INT32:case Cb.FIXED32:case Cb.UINT32:case Cb.SFIXED32:case Cb.SINT32:o=Number.parseInt(r);break;case Cb.BOOL:rv("true"==r||"false"==r),o="true"==r}switch(this.scalar(e,n.K,1,o,!0),n.V.kind){case"scalar":this.scalar(e,n.V.T,2,i,!0);break;case"enum":this.scalar(e,Cb.INT32,2,i,!0);break;case"message":this.message(e,t,n.V.T(),2,i)}e.join()}message(e,t,n,r,i){void 0!==i&&(n.internalBinaryWrite(i,e.tag(r,hv.LengthDelimited).fork(),t),e.join())}scalar(e,t,n,r,i){let[o,s,a]=this.scalarInfo(t,r);a&&!i||(e.tag(n,o),e[s](r))}packed(e,t,n,r){if(!r.length)return;rv(t!==Cb.BYTES&&t!==Cb.STRING),e.tag(n,hv.LengthDelimited),e.fork();let[,i]=this.scalarInfo(t);for(let t=0;t<r.length;t++)e[i](r[t]);e.join()}scalarInfo(e,t){let n,r=hv.Varint,i=void 0===t,o=0===t;switch(e){case Cb.INT32:n="int32";break;case Cb.STRING:o=i||!t.length,r=hv.LengthDelimited,n="string";break;case Cb.BOOL:o=!1===t,n="bool";break;case Cb.UINT32:n="uint32";break;case Cb.DOUBLE:r=hv.Bit64,n="double";break;case Cb.FLOAT:r=hv.Bit32,n="float";break;case Cb.INT64:o=i||nv.from(t).isZero(),n="int64";break;case Cb.UINT64:o=i||tv.from(t).isZero(),n="uint64";break;case Cb.FIXED64:o=i||tv.from(t).isZero(),r=hv.Bit64,n="fixed64";break;case Cb.BYTES:o=i||!t.byteLength,r=hv.LengthDelimited,n="bytes";break;case Cb.FIXED32:r=hv.Bit32,n="fixed32";break;case Cb.SFIXED32:r=hv.Bit32,n="sfixed32";break;case Cb.SFIXED64:o=i||nv.from(t).isZero(),r=hv.Bit64,n="sfixed64";break;case Cb.SINT32:n="sint32";break;case Cb.SINT64:o=i||nv.from(t).isZero(),n="sint64"}return[r,n,i||o]}}function mv(e,t,n){let r,i,o=n;for(let n of e.fields){let e=n.localName;if(n.oneof){const s=o[n.oneof];if(null==(null==s?void 0:s.oneofKind))continue;if(r=s[e],i=t[n.oneof],i.oneofKind=s.oneofKind,null==r){delete i[e];continue}}else if(r=o[e],i=t,null==r)continue;switch(n.repeat&&(i[e].length=r.length),n.kind){case"scalar":case"enum":if(n.repeat)for(let t=0;t<r.length;t++)i[e][t]=r[t];else i[e]=r;break;case"message":let t=n.T();if(n.repeat)for(let n=0;n<r.length;n++)i[e][n]=t.create(r[n]);else void 0===i[e]?i[e]=t.create(r):t.mergePartial(i[e],r);break;case"map":switch(n.V.kind){case"scalar":case"enum":Object.assign(i[e],r);break;case"message":let t=n.V.T();for(let n of Object.keys(r))i[e][n]=t.create(r[n])}}}}const gv={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},bv={ignoreUnknownFields:!1};function vv(e,t){var n,r;let i=Object.assign(Object.assign({},e),t);return i.typeRegistry=[...null!==(n=null==e?void 0:e.typeRegistry)&&void 0!==n?n:[],...null!==(r=null==t?void 0:t.typeRegistry)&&void 0!==r?r:[]],i}const wv=Object.values;function Ev(e,t,n){if(t===n)return!0;if(e!==Cb.BYTES)return!1;let r=t,i=n;if(r.length!==i.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!=i[e])return!1;return!0}function kv(e,t,n){if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!Ev(e,t[r],n[r]))return!1;return!0}function Sv(e,t,n){if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e.equals(t[r],n[r]))return!1;return!0}const Tv={writeUnknownFields:!0,writerFactory:()=>new _v};class _v{constructor(e){this.stack=[],this.textEncoder=null!=e?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),n=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],n),n+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(ov(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return iv(e),Qb(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){sv(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){ov(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){iv(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return iv(e),Qb(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=nv.from(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=tv.from(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=nv.from(e);return Vb(t.lo,t.hi,this.buf),this}sint64(e){let t=nv.from(e),n=t.hi>>31;return Vb(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=tv.from(e);return Vb(t.lo,t.hi,this.buf),this}}const Ov={readUnknownField:!0,readerFactory:e=>new xv(e)};class xv{constructor(e,t){this.varint64=qb,this.uint32=Gb,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=null!=t?t:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let e=this.uint32(),t=e>>>3,n=7&e;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e){let t=this.pos;switch(e){case hv.Varint:for(;128&this.buf[this.pos++];);break;case hv.Bit64:this.pos+=4;case hv.Bit32:this.pos+=4;break;case hv.LengthDelimited:let t=this.uint32();this.pos+=t;break;case hv.StartGroup:let n;for(;(n=this.tag()[1])!==hv.EndGroup;)this.skip(n);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return new nv(...this.varint64())}uint64(){return new tv(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(1&e);return e=(e>>>1|(1&t)<<31)^n,t=t>>>1^n,new nv(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new tv(this.sfixed32(),this.sfixed32())}sfixed64(){return new nv(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}const Iv=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({})),Mv=Iv[Mb]={};class Cv{constructor(e,t,n){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(jb),this.options=null!=n?n:{},Mv.value=this,this.messagePrototype=Object.create(null,Iv),this.refTypeCheck=new Rb(this),this.refJsonReader=new uv(this),this.refJsonWriter=new cv(this),this.refBinReader=new pv(this),this.refBinWriter=new yv(this)}create(e){let t=function(e){const t=e.messagePrototype?Object.create(e.messagePrototype):Object.defineProperty({},Mb,{value:e});for(let n of e.fields){let e=n.localName;if(!n.opt)if(n.oneof)t[n.oneof]={oneofKind:void 0};else if(n.repeat)t[e]=[];else switch(n.kind){case"scalar":t[e]=dv(n.T,n.L);break;case"enum":t[e]=0;break;case"map":t[e]={}}}return t}(this);return void 0!==e&&mv(this,t,e),t}clone(e){let t=this.create();return mv(this,t,e),t}equals(e,t){return function(e,t,n){if(t===n)return!0;if(!t||!n)return!1;for(let r of e.fields){let e=r.localName,i=r.oneof?t[r.oneof][e]:t[e],o=r.oneof?n[r.oneof][e]:n[e];switch(r.kind){case"enum":case"scalar":let e="enum"==r.kind?Cb.INT32:r.T;if(!(r.repeat?kv(e,i,o):Ev(e,i,o)))return!1;break;case"map":if(!("message"==r.V.kind?Sv(r.V.T(),wv(i),wv(o)):kv("enum"==r.V.kind?Cb.INT32:r.V.T,wv(i),wv(o))))return!1;break;case"message":let t=r.T();if(!(r.repeat?Sv(t,i,o):t.equals(i,o)))return!1}}return!0}(this,e,t)}is(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!1)}isAssignable(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!0)}mergePartial(e,t){mv(this,e,t)}fromBinary(e,t){let n=function(e){return e?Object.assign(Object.assign({},Ov),e):Ov}(t);return this.internalBinaryRead(n.readerFactory(e),e.byteLength,n)}fromJson(e,t){return this.internalJsonRead(e,function(e){return e?Object.assign(Object.assign({},bv),e):bv}(t))}fromJsonString(e,t){let n=JSON.parse(e);return this.fromJson(n,t)}toJson(e,t){return this.internalJsonWrite(e,function(e){return e?Object.assign(Object.assign({},gv),e):gv}(t))}toJsonString(e,t){var n;let r=this.toJson(e,t);return JSON.stringify(r,null,null!==(n=null==t?void 0:t.prettySpaces)&&void 0!==n?n:0)}toBinary(e,t){let n=function(e){return e?Object.assign(Object.assign({},Tv),e):Tv}(t);return this.internalBinaryWrite(e,n.writerFactory(),n).finish()}internalJsonRead(e,t,n){if(null!==e&&"object"==typeof e&&!Array.isArray(e)){let r=null!=n?n:this.create();return this.refJsonReader.read(e,r,t),r}throw new Error(`Unable to parse message ${this.typeName} from JSON ${Pb(e)}.`)}internalJsonWrite(e,t){return this.refJsonWriter.write(e,t)}internalBinaryWrite(e,t,n){return this.refBinWriter.write(e,t,n),t}internalBinaryRead(e,t,n,r){let i=null!=r?r:this.create();return this.refBinReader.read(e,i,n,t),i}}function Av(e,t,n,r,i){var o,s,a,u;if("unary"==e){let e=(e,n,r)=>t.unary(e,n,r);for(const t of(null!==(o=r.interceptors)&&void 0!==o?o:[]).filter(e=>e.interceptUnary).reverse()){const n=e;e=(e,r,i)=>t.interceptUnary(n,e,r,i)}return e(n,i,r)}if("serverStreaming"==e){let e=(e,n,r)=>t.serverStreaming(e,n,r);for(const t of(null!==(s=r.interceptors)&&void 0!==s?s:[]).filter(e=>e.interceptServerStreaming).reverse()){const n=e;e=(e,r,i)=>t.interceptServerStreaming(n,e,r,i)}return e(n,i,r)}if("clientStreaming"==e){let e=(e,n)=>t.clientStreaming(e,n);for(const t of(null!==(a=r.interceptors)&&void 0!==a?a:[]).filter(e=>e.interceptClientStreaming).reverse()){const n=e;e=(e,r)=>t.interceptClientStreaming(n,e,r)}return e(n,r)}if("duplex"==e){let e=(e,n)=>t.duplex(e,n);for(const t of(null!==(u=r.interceptors)&&void 0!==u?u:[]).filter(e=>e.interceptDuplex).reverse()){const n=e;e=(e,r)=>t.interceptDuplex(n,e,r)}return e(n,r)}!function(e,t){throw new Error(null!=t?t:"Unexpected object: "+e)}(e)}function Nv(e,t){if(!e)return;let n=t;for(let[t,r]of Object.entries(e))r instanceof Date?n[t]=new Date(r.getTime()):Array.isArray(r)?n[t]=r.concat():n[t]=r}class jv extends Error{constructor(e,t="UNKNOWN",n){super(e),this.name="RpcError",Object.setPrototypeOf(this,new.target.prototype),this.code=t,this.meta=null!=n?n:{}}toString(){const e=[this.name+": "+this.message];this.code&&(e.push(""),e.push("Code: "+this.code)),this.serviceName&&this.methodName&&e.push("Method: "+this.serviceName+"/"+this.methodName);let t=Object.entries(this.meta);if(t.length){e.push(""),e.push("Meta:");for(let[n,r]of t)e.push(` ${n}: ${r}`)}return e.join("\n")}}var Dv;!function(e){e[e.PENDING=0]="PENDING",e[e.REJECTED=1]="REJECTED",e[e.RESOLVED=2]="RESOLVED"}(Dv||(Dv={}));class Rv{constructor(e=!0){this._state=Dv.PENDING,this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t}),e&&this._promise.catch(e=>{})}get state(){return this._state}get promise(){return this._promise}resolve(e){if(this.state!==Dv.PENDING)throw new Error(`cannot resolve ${Dv[this.state].toLowerCase()}`);this._resolve(e),this._state=Dv.RESOLVED}reject(e){if(this.state!==Dv.PENDING)throw new Error(`cannot reject ${Dv[this.state].toLowerCase()}`);this._reject(e),this._state=Dv.REJECTED}resolvePending(e){this._state===Dv.PENDING&&this.resolve(e)}rejectPending(e){this._state===Dv.PENDING&&this.reject(e)}}class Pv{constructor(){this._lis={nxt:[],msg:[],err:[],cmp:[]},this._closed=!1,this._itState={q:[]}}onNext(e){return this.addLis(e,this._lis.nxt)}onMessage(e){return this.addLis(e,this._lis.msg)}onError(e){return this.addLis(e,this._lis.err)}onComplete(e){return this.addLis(e,this._lis.cmp)}addLis(e,t){return t.push(e),()=>{let n=t.indexOf(e);n>=0&&t.splice(n,1)}}clearLis(){for(let e of Object.values(this._lis))e.splice(0,e.length)}get closed(){return!1!==this._closed}notifyNext(e,t,n){rv((e?1:0)+(t?1:0)+(n?1:0)<=1,"only one emission at a time"),e&&this.notifyMessage(e),t&&this.notifyError(t),n&&this.notifyComplete()}notifyMessage(e){rv(!this.closed,"stream is closed"),this.pushIt({value:e,done:!1}),this._lis.msg.forEach(t=>t(e)),this._lis.nxt.forEach(t=>t(e,void 0,!1))}notifyError(e){rv(!this.closed,"stream is closed"),this._closed=e,this.pushIt(e),this._lis.err.forEach(t=>t(e)),this._lis.nxt.forEach(t=>t(void 0,e,!1)),this.clearLis()}notifyComplete(){rv(!this.closed,"stream is closed"),this._closed=!0,this.pushIt({value:null,done:!0}),this._lis.cmp.forEach(e=>e()),this._lis.nxt.forEach(e=>e(void 0,void 0,!0)),this.clearLis()}[Symbol.asyncIterator](){return!0===this._closed?this.pushIt({value:null,done:!0}):!1!==this._closed&&this.pushIt(this._closed),{next:()=>{let e=this._itState;rv(e,"bad state"),rv(!e.p,"iterator contract broken");let t=e.q.shift();return t?"value"in t?Promise.resolve(t):Promise.reject(t):(e.p=new Rv,e.p.promise)}}}pushIt(e){let t=this._itState;if(t.p){const n=t.p;rv(n.state==Dv.PENDING,"iterator contract broken"),"value"in e?n.resolve(e):n.reject(e),delete t.p}else t.q.push(e)}}var Bv=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof n?e:new n(function(t){t(e)})}(e.value).then(s,a)}u((r=r.apply(e,t||[])).next())})};class Fv{constructor(e,t,n,r,i,o,s){this.method=e,this.requestHeaders=t,this.request=n,this.headers=r,this.responses=i,this.status=o,this.trailers=s}then(e,t){return this.promiseFinished().then(t=>e?Promise.resolve(e(t)):t,e=>t?Promise.resolve(t(e)):Promise.reject(e))}promiseFinished(){return Bv(this,void 0,void 0,function*(){let[e,t,n]=yield Promise.all([this.headers,this.status,this.trailers]);return{method:this.method,requestHeaders:this.requestHeaders,request:this.request,headers:e,status:t,trailers:n}})}}var Lv,Uv=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof n?e:new n(function(t){t(e)})}(e.value).then(s,a)}u((r=r.apply(e,t||[])).next())})};class $v{constructor(e,t,n,r,i,o,s){this.method=e,this.requestHeaders=t,this.request=n,this.headers=r,this.response=i,this.status=o,this.trailers=s}then(e,t){return this.promiseFinished().then(t=>e?Promise.resolve(e(t)):t,e=>t?Promise.resolve(t(e)):Promise.reject(e))}promiseFinished(){return Uv(this,void 0,void 0,function*(){let[e,t,n,r]=yield Promise.all([this.headers,this.response,this.status,this.trailers]);return{method:this.method,requestHeaders:this.requestHeaders,request:this.request,headers:e,response:t,status:n,trailers:r}})}}!function(e){e[e.OK=0]="OK",e[e.CANCELLED=1]="CANCELLED",e[e.UNKNOWN=2]="UNKNOWN",e[e.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",e[e.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",e[e.NOT_FOUND=5]="NOT_FOUND",e[e.ALREADY_EXISTS=6]="ALREADY_EXISTS",e[e.PERMISSION_DENIED=7]="PERMISSION_DENIED",e[e.UNAUTHENTICATED=16]="UNAUTHENTICATED",e[e.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",e[e.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",e[e.ABORTED=10]="ABORTED",e[e.OUT_OF_RANGE=11]="OUT_OF_RANGE",e[e.UNIMPLEMENTED=12]="UNIMPLEMENTED",e[e.INTERNAL=13]="INTERNAL",e[e.UNAVAILABLE=14]="UNAVAILABLE",e[e.DATA_LOSS=15]="DATA_LOSS"}(Lv||(Lv={}));var qv,Vv=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof n?e:new n(function(t){t(e)})}(e.value).then(s,a)}u((r=r.apply(e,t||[])).next())})};function zv(e,t,n,r,i){if(r)for(let[t,n]of Object.entries(r))if("string"==typeof n)e.append(t,n);else for(let r of n)e.append(t,r);if(e.set("Content-Type","text"===t?"application/grpc-web-text":"application/grpc-web+proto"),"text"==t&&e.set("Accept","application/grpc-web-text"),e.set("X-Grpc-Web","1"),i&&e.set("X-User-Agent",i),"number"==typeof n){if(n<=0)throw new jv(`timeout ${n} ms exceeded`,Lv[Lv.DEADLINE_EXCEEDED]);e.set("grpc-timeout",`${n}m`)}else if(n){const t=n.getTime(),r=Date.now();if(t<=r)throw new jv(`deadline ${n} exceeded`,Lv[Lv.DEADLINE_EXCEEDED]);e.set("grpc-timeout",t-r+"m")}return e}function Kv(e,t){let n=new Uint8Array(5+e.length);n[0]=qv.DATA;for(let t=e.length,r=4;r>0;r--)n[r]=t%256,t>>>=8;return n.set(e,5),"binary"===t?n:$b(n)}function Wv(e,t,n){if(1===arguments.length){let t,n=e;try{t=n.type}catch(e){}switch(t){case"error":case"opaque":case"opaqueredirect":throw new jv(`fetch response type ${n.type}`,Lv[Lv.UNKNOWN])}return Wv(function(e){let t={};return e.forEach((e,n)=>{let r=t[n];"string"==typeof r?t[n]=[r,e]:Array.isArray(r)?r.push(e):t[n]=e}),t}(n.headers),n.status,n.statusText)}let r=e,i=t>=200&&t<300,o=Yv(r),[s,a]=Zv(r);return void 0!==s&&s!==Lv.OK||i||(s=function(e){switch(e){case 200:return Lv.OK;case 400:return Lv.INVALID_ARGUMENT;case 401:return Lv.UNAUTHENTICATED;case 403:return Lv.PERMISSION_DENIED;case 404:return Lv.NOT_FOUND;case 409:return Lv.ABORTED;case 412:return Lv.FAILED_PRECONDITION;case 429:return Lv.RESOURCE_EXHAUSTED;case 499:return Lv.CANCELLED;case 500:default:return Lv.UNKNOWN;case 501:return Lv.UNIMPLEMENTED;case 503:return Lv.UNAVAILABLE;case 504:return Lv.DEADLINE_EXCEEDED}}(t),a=n),[s,a,o]}function Qv(e){let t=function(e){let t={};for(let n of String.fromCharCode.apply(String,e).trim().split("\r\n")){if(""==n)continue;let[e,...r]=n.split(":");const i=r.join(":").trim();e=e.trim();let o=t[e];"string"==typeof o?t[e]=[o,i]:Array.isArray(o)?o.push(i):t[e]=i}return t}(e),[n,r]=Zv(t),i=Yv(t);return[null!=n?n:Lv.OK,r,i]}function Gv(e,t,n){return Vv(this,void 0,void 0,function*(){let r,i="",o=new Uint8Array(0),s=function(e){switch(e){case"application/grpc-web-text":case"application/grpc-web-text+proto":return"text";case"application/grpc-web":case"application/grpc-web+proto":return"binary";case void 0:case null:throw new jv("missing response content type",Lv[Lv.INTERNAL]);default:throw new jv("unexpected response content type: "+e,Lv[Lv.INTERNAL])}}(t);if(Hv(e)){let t=e.getReader();r={next:()=>t.read()}}else r=e[Symbol.asyncIterator]();for(;;){let e=yield r.next();if(void 0!==e.value){if("text"===s){for(let t=0;t<e.value.length;t++)i+=String.fromCharCode(e.value[t]);let t=i.length-i.length%4;if(0===t)continue;o=Jv(o,Ub(i.substring(0,t))),i=i.substring(t)}else o=Jv(o,e.value);for(;o.length>=5&&o[0]===qv.DATA;){let e=0;for(let t=1;t<5;t++)e=(e<<8)+o[t];if(!(o.length-5>=e))break;n(qv.DATA,o.subarray(5,5+e)),o=o.subarray(5+e)}}if(e.done){if(0===o.length)break;if(o[0]!==qv.TRAILER||o.length<5)throw new jv("premature EOF",Lv[Lv.DATA_LOSS]);n(qv.TRAILER,o.subarray(5));break}}})}!function(e){e[e.DATA=0]="DATA",e[e.TRAILER=128]="TRAILER"}(qv||(qv={}));const Hv=e=>"function"==typeof e.getReader;function Jv(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function Zv(e){let t,n,r=e["grpc-message"];if(void 0!==r){if(Array.isArray(r))return[Lv.INTERNAL,"invalid grpc-web message"];n=r}let i=e["grpc-status"];if(void 0!==i){if(Array.isArray(i))return[Lv.INTERNAL,"invalid grpc-web status"];if(t=parseInt(i,10),void 0===Lv[t])return[Lv.INTERNAL,"invalid grpc-web status"]}return[t,n]}function Yv(e){let t={};for(let[n,r]of Object.entries(e))switch(n){case"grpc-message":case"grpc-status":case"content-type":break;default:t[n]=r}return t}class Xv{constructor(e){this.defaultOptions=e}mergeOptions(e){return function(e,t){if(!t)return e;let n={};Nv(e,n),Nv(t,n);for(let r of Object.keys(t)){let i=t[r];switch(r){case"jsonOptions":n.jsonOptions=vv(e.jsonOptions,n.jsonOptions);break;case"binaryOptions":n.binaryOptions=fv(e.binaryOptions,n.binaryOptions);break;case"meta":n.meta={},Nv(e.meta,n.meta),Nv(t.meta,n.meta);break;case"interceptors":n.interceptors=e.interceptors?e.interceptors.concat(i):i.concat()}}return n}(this.defaultOptions,e)}makeUrl(e,t){let n=t.baseUrl;return n.endsWith("/")&&(n=n.substring(0,n.length-1)),`${n}/${e.service.typeName}/${e.name}`}clientStreaming(e){const t=new jv("Client streaming is not supported by grpc-web",Lv[Lv.UNIMPLEMENTED]);throw t.methodName=e.name,t.serviceName=e.service.typeName,t}duplex(e){const t=new jv("Duplex streaming is not supported by grpc-web",Lv[Lv.UNIMPLEMENTED]);throw t.methodName=e.name,t.serviceName=e.service.typeName,t}serverStreaming(e,t,n){var r,i,o,s,a;let u,c,l=n,h=null!==(r=l.format)&&void 0!==r?r:"text",f=null!==(i=l.fetch)&&void 0!==i?i:globalThis.fetch,d=null!==(o=l.fetchInit)&&void 0!==o?o:{},p=this.makeUrl(e,l),y=e.I.toBinary(t,l.binaryOptions),m=new Rv,g=new Pv,b=!0,v=new Rv,w=new Rv;return f(p,Object.assign(Object.assign({},d),{method:"POST",headers:zv(new globalThis.Headers,h,l.timeout,l.meta),body:Kv(y,h),signal:null!==(s=n.abort)&&void 0!==s?s:null})).then(e=>{let[t,n,r]=Wv(e);if(m.resolve(r),null!=t&&t!==Lv.OK)throw new jv(null!=n?n:Lv[t],Lv[t],r);return null!=t&&(u={code:Lv[t],detail:null!=n?n:Lv[t]}),e}).then(t=>{if(!t.body)throw new jv("missing response body",Lv[Lv.INTERNAL]);return Gv(t.body,t.headers.get("content-type"),(t,n)=>{switch(t){case qv.DATA:g.notifyMessage(e.O.fromBinary(n,l.binaryOptions)),b=!1;break;case qv.TRAILER:let t,r;[t,r,c]=Qv(n),u={code:Lv[t],detail:null!=r?r:Lv[t]}}})}).then(()=>{if(!c&&!b)throw new jv("missing trailers",Lv[Lv.DATA_LOSS]);if(!u)throw new jv("missing status",Lv[Lv.INTERNAL]);if("OK"!==u.code)throw new jv(u.detail,u.code,c);g.notifyComplete(),v.resolve(u),w.resolve(c||{})}).catch(t=>{let n;n=t instanceof jv?t:t instanceof Error&&"AbortError"===t.name?new jv(t.message,Lv[Lv.CANCELLED]):new jv(t instanceof Error?t.message:""+t,Lv[Lv.INTERNAL]),n.methodName=e.name,n.serviceName=e.service.typeName,m.rejectPending(n),g.notifyError(n),v.rejectPending(n),w.rejectPending(n)}),new Fv(e,null!==(a=l.meta)&&void 0!==a?a:{},t,m.promise,g,v.promise,w.promise)}unary(e,t,n){var r,i,o,s,a;let u,c,l,h=n,f=null!==(r=h.format)&&void 0!==r?r:"text",d=null!==(i=h.fetch)&&void 0!==i?i:globalThis.fetch,p=null!==(o=h.fetchInit)&&void 0!==o?o:{},y=this.makeUrl(e,h),m=e.I.toBinary(t,h.binaryOptions),g=new Rv,b=new Rv,v=new Rv,w=new Rv;return d(y,Object.assign(Object.assign({},p),{method:"POST",headers:zv(new globalThis.Headers,f,h.timeout,h.meta),body:Kv(m,f),signal:null!==(s=n.abort)&&void 0!==s?s:null})).then(e=>{let[t,n,r]=Wv(e);if(g.resolve(r),null!=t&&t!==Lv.OK)throw new jv(null!=n?n:Lv[t],Lv[t],r);return null!=t&&(c={code:Lv[t],detail:null!=n?n:Lv[t]}),e}).then(t=>{if(!t.body)throw new jv("missing response body",Lv[Lv.INTERNAL]);return Gv(t.body,t.headers.get("content-type"),(t,n)=>{switch(t){case qv.DATA:if(u)throw new jv("unary call received 2nd message",Lv[Lv.DATA_LOSS]);u=e.O.fromBinary(n,h.binaryOptions);break;case qv.TRAILER:let t,r;[t,r,l]=Qv(n),c={code:Lv[t],detail:null!=r?r:Lv[t]}}})}).then(()=>{if(!l&&u)throw new jv("missing trailers",Lv[Lv.DATA_LOSS]);if(!c)throw new jv("missing status",Lv[Lv.INTERNAL]);if(!u&&"OK"===c.code)throw new jv("expected error status",Lv[Lv.DATA_LOSS]);if(!u)throw new jv(c.detail,c.code,l);if(b.resolve(u),"OK"!==c.code)throw new jv(c.detail,c.code,l);v.resolve(c),w.resolve(l||{})}).catch(t=>{let n;n=t instanceof jv?t:t instanceof Error&&"AbortError"===t.name?new jv(t.message,Lv[Lv.CANCELLED]):new jv(t instanceof Error?t.message:""+t,Lv[Lv.INTERNAL]),n.methodName=e.name,n.serviceName=e.service.typeName,g.rejectPending(n),b.rejectPending(n),v.rejectPending(n),w.rejectPending(n)}),new $v(e,null!==(a=h.meta)&&void 0!==a?a:{},t,g.promise,b.promise,v.promise,w.promise)}}var ew=(e=>(e[e.NULL_VALUE=0]="NULL_VALUE",e))(ew||{}),tw=new class extends Cv{constructor(){super("google.protobuf.Struct",[{no:1,name:"fields",kind:"map",K:9,V:{kind:"message",T:()=>nw}}])}internalJsonWrite(e,t){let n={};for(let[t,r]of Object.entries(e.fields))n[t]=nw.toJson(r);return n}internalJsonRead(e,t,n){if(!Bb(e))throw new globalThis.Error("Unable to parse message "+this.typeName+" from JSON "+Pb(e)+".");n||(n=this.create());for(let[t,r]of globalThis.Object.entries(e))n.fields[t]=nw.fromJson(r);return n}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.fields={},void 0!==e&&mv(this,t,e),t}internalBinaryRead(e,t,n,r){let i=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[t,r]=e.tag();if(1===t)this.binaryReadMap1(i.fields,e,n);else{let o=n.readUnknownField;if("throw"===o)throw new globalThis.Error(`Unknown field ${t} (wire type ${r}) for ${this.typeName}`);let s=e.skip(r);!1!==o&&(!0===o?lv.onRead:o)(this.typeName,i,t,r,s)}}return i}binaryReadMap1(e,t,n){let r,i,o=t.uint32(),s=t.pos+o;for(;t.pos<s;){let[e,o]=t.tag();switch(e){case 1:r=t.string();break;case 2:i=nw.internalBinaryRead(t,t.uint32(),n);break;default:throw new globalThis.Error("unknown map entry field for google.protobuf.Struct.fields")}}e[r??""]=i??nw.create()}internalBinaryWrite(e,t,n){for(let r of globalThis.Object.keys(e.fields))t.tag(1,hv.LengthDelimited).fork().tag(1,hv.LengthDelimited).string(r),t.tag(2,hv.LengthDelimited).fork(),nw.internalBinaryWrite(e.fields[r],t,n),t.join().join();let r=n.writeUnknownFields;return!1!==r&&(1==r?lv.onWrite:r)(this.typeName,e,t),t}},nw=new class extends Cv{constructor(){super("google.protobuf.Value",[{no:1,name:"null_value",kind:"enum",oneof:"kind",T:()=>["google.protobuf.NullValue",ew]},{no:2,name:"number_value",kind:"scalar",oneof:"kind",T:1},{no:3,name:"string_value",kind:"scalar",oneof:"kind",T:9},{no:4,name:"bool_value",kind:"scalar",oneof:"kind",T:8},{no:5,name:"struct_value",kind:"message",oneof:"kind",T:()=>tw},{no:6,name:"list_value",kind:"message",oneof:"kind",T:()=>rw}])}internalJsonWrite(e,t){if(void 0===e.kind.oneofKind)throw new globalThis.Error;switch(e.kind.oneofKind){case void 0:throw new globalThis.Error;case"boolValue":return e.kind.boolValue;case"nullValue":return null;case"numberValue":let t=e.kind.numberValue;if("number"==typeof t&&!Number.isFinite(t))throw new globalThis.Error;return t;case"stringValue":return e.kind.stringValue;case"listValue":let n=this.fields.find(e=>6===e.no);if("message"!==n?.kind)throw new globalThis.Error;return n.T().toJson(e.kind.listValue);case"structValue":let r=this.fields.find(e=>5===e.no);if("message"!==r?.kind)throw new globalThis.Error;return r.T().toJson(e.kind.structValue)}}internalJsonRead(e,t,n){switch(n||(n=this.create()),typeof e){case"number":n.kind={oneofKind:"numberValue",numberValue:e};break;case"string":n.kind={oneofKind:"stringValue",stringValue:e};break;case"boolean":n.kind={oneofKind:"boolValue",boolValue:e};break;case"object":null===e?n.kind={oneofKind:"nullValue",nullValue:0}:globalThis.Array.isArray(e)?n.kind={oneofKind:"listValue",listValue:rw.fromJson(e)}:n.kind={oneofKind:"structValue",structValue:tw.fromJson(e)};break;default:throw new globalThis.Error("Unable to parse "+this.typeName+" from JSON "+Pb(e))}return n}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.kind={oneofKind:void 0},void 0!==e&&mv(this,t,e),t}internalBinaryRead(e,t,n,r){let i=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[t,r]=e.tag();switch(t){case 1:i.kind={oneofKind:"nullValue",nullValue:e.int32()};break;case 2:i.kind={oneofKind:"numberValue",numberValue:e.double()};break;case 3:i.kind={oneofKind:"stringValue",stringValue:e.string()};break;case 4:i.kind={oneofKind:"boolValue",boolValue:e.bool()};break;case 5:i.kind={oneofKind:"structValue",structValue:tw.internalBinaryRead(e,e.uint32(),n,i.kind.structValue)};break;case 6:i.kind={oneofKind:"listValue",listValue:rw.internalBinaryRead(e,e.uint32(),n,i.kind.listValue)};break;default:let o=n.readUnknownField;if("throw"===o)throw new globalThis.Error(`Unknown field ${t} (wire type ${r}) for ${this.typeName}`);let s=e.skip(r);!1!==o&&(!0===o?lv.onRead:o)(this.typeName,i,t,r,s)}}return i}internalBinaryWrite(e,t,n){"nullValue"===e.kind.oneofKind&&t.tag(1,hv.Varint).int32(e.kind.nullValue),"numberValue"===e.kind.oneofKind&&t.tag(2,hv.Bit64).double(e.kind.numberValue),"stringValue"===e.kind.oneofKind&&t.tag(3,hv.LengthDelimited).string(e.kind.stringValue),"boolValue"===e.kind.oneofKind&&t.tag(4,hv.Varint).bool(e.kind.boolValue),"structValue"===e.kind.oneofKind&&tw.internalBinaryWrite(e.kind.structValue,t.tag(5,hv.LengthDelimited).fork(),n).join(),"listValue"===e.kind.oneofKind&&rw.internalBinaryWrite(e.kind.listValue,t.tag(6,hv.LengthDelimited).fork(),n).join();let r=n.writeUnknownFields;return!1!==r&&(1==r?lv.onWrite:r)(this.typeName,e,t),t}},rw=new class extends Cv{constructor(){super("google.protobuf.ListValue",[{no:1,name:"values",kind:"message",repeat:2,T:()=>nw}])}internalJsonWrite(e,t){return e.values.map(e=>nw.toJson(e))}internalJsonRead(e,t,n){if(!globalThis.Array.isArray(e))throw new globalThis.Error("Unable to parse "+this.typeName+" from JSON "+Pb(e));n||(n=this.create());let r=e.map(e=>nw.fromJson(e));return n.values.push(...r),n}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.values=[],void 0!==e&&mv(this,t,e),t}internalBinaryRead(e,t,n,r){let i=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[t,r]=e.tag();if(1===t)i.values.push(nw.internalBinaryRead(e,e.uint32(),n));else{let o=n.readUnknownField;if("throw"===o)throw new globalThis.Error(`Unknown field ${t} (wire type ${r}) for ${this.typeName}`);let s=e.skip(r);!1!==o&&(!0===o?lv.onRead:o)(this.typeName,i,t,r,s)}}return i}internalBinaryWrite(e,t,n){for(let r=0;r<e.values.length;r++)nw.internalBinaryWrite(e.values[r],t.tag(1,hv.LengthDelimited).fork(),n).join();let r=n.writeUnknownFields;return!1!==r&&(1==r?lv.onWrite:r)(this.typeName,e,t),t}},iw=(e=>(e[e.EQUALS=0]="EQUALS",e[e.NOT_EQUALS=1]="NOT_EQUALS",e[e.GREATER_THAN=2]="GREATER_THAN",e[e.GREATER_THAN_EQUAL=3]="GREATER_THAN_EQUAL",e[e.LESS_THAN=4]="LESS_THAN",e[e.LESS_THAN_EQUAL=5]="LESS_THAN_EQUAL",e[e.LIKE=6]="LIKE",e[e.NOT_LIKE=7]="NOT_LIKE",e[e.IN=8]="IN",e[e.NOT_IN=9]="NOT_IN",e[e.IS_NULL=10]="IS_NULL",e[e.IS_NOT_NULL=11]="IS_NOT_NULL",e[e.BETWEEN=12]="BETWEEN",e[e.NOT_BETWEEN=13]="NOT_BETWEEN",e))(iw||{}),ow=(e=>(e[e.ASCENDING=0]="ASCENDING",e[e.DESCENDING=1]="DESCENDING",e))(ow||{}),sw=new class extends Cv{constructor(){super("dubhe_grpc.QueryRequest",[{no:1,name:"table_name",kind:"scalar",T:9},{no:2,name:"select_fields",kind:"scalar",repeat:2,T:9},{no:3,name:"filters",kind:"message",repeat:2,T:()=>aw},{no:4,name:"sorts",kind:"message",repeat:2,T:()=>fw},{no:5,name:"pagination",kind:"message",T:()=>dw},{no:6,name:"include_total_count",kind:"scalar",T:8}])}},aw=new class extends Cv{constructor(){super("dubhe_grpc.FilterCondition",[{no:1,name:"field_name",kind:"scalar",T:9},{no:2,name:"operator",kind:"enum",T:()=>["dubhe_grpc.FilterOperator",iw]},{no:3,name:"value",kind:"message",T:()=>uw}])}},uw=new class extends Cv{constructor(){super("dubhe_grpc.FilterValue",[{no:1,name:"string_value",kind:"scalar",oneof:"value",T:9},{no:2,name:"int_value",kind:"scalar",oneof:"value",T:3,L:0},{no:3,name:"float_value",kind:"scalar",oneof:"value",T:1},{no:4,name:"bool_value",kind:"scalar",oneof:"value",T:8},{no:5,name:"string_list",kind:"message",oneof:"value",T:()=>cw},{no:6,name:"int_list",kind:"message",oneof:"value",T:()=>lw},{no:7,name:"range",kind:"message",oneof:"value",T:()=>hw},{no:8,name:"null_value",kind:"scalar",oneof:"value",T:8}])}},cw=new class extends Cv{constructor(){super("dubhe_grpc.StringList",[{no:1,name:"values",kind:"scalar",repeat:2,T:9}])}},lw=new class extends Cv{constructor(){super("dubhe_grpc.IntList",[{no:1,name:"values",kind:"scalar",repeat:1,T:3,L:0}])}},hw=new class extends Cv{constructor(){super("dubhe_grpc.ValueRange",[{no:1,name:"string_start",kind:"scalar",oneof:"start",T:9},{no:2,name:"int_start",kind:"scalar",oneof:"start",T:3,L:0},{no:3,name:"float_start",kind:"scalar",oneof:"start",T:1},{no:4,name:"string_end",kind:"scalar",oneof:"end",T:9},{no:5,name:"int_end",kind:"scalar",oneof:"end",T:3,L:0},{no:6,name:"float_end",kind:"scalar",oneof:"end",T:1}])}},fw=new class extends Cv{constructor(){super("dubhe_grpc.SortSpecification",[{no:1,name:"field_name",kind:"scalar",T:9},{no:2,name:"direction",kind:"enum",T:()=>["dubhe_grpc.SortDirection",ow]},{no:3,name:"priority",kind:"scalar",opt:!0,T:5}])}},dw=new class extends Cv{constructor(){super("dubhe_grpc.PaginationRequest",[{no:1,name:"page",kind:"scalar",T:5},{no:2,name:"page_size",kind:"scalar",T:5},{no:3,name:"offset",kind:"scalar",opt:!0,T:5}])}},pw=new class extends Cv{constructor(){super("dubhe_grpc.QueryResponse",[{no:1,name:"rows",kind:"message",repeat:2,T:()=>tw},{no:2,name:"pagination",kind:"message",T:()=>yw}])}},yw=new class extends Cv{constructor(){super("dubhe_grpc.PaginationResponse",[{no:1,name:"current_page",kind:"scalar",T:5},{no:2,name:"page_size",kind:"scalar",T:5},{no:3,name:"total_items",kind:"scalar",T:3,L:0},{no:4,name:"total_pages",kind:"scalar",T:5},{no:5,name:"has_next_page",kind:"scalar",T:8},{no:6,name:"has_previous_page",kind:"scalar",T:8}])}},mw=new class extends Cv{constructor(){super("dubhe_grpc.SubscribeRequest",[{no:1,name:"table_ids",kind:"scalar",repeat:2,T:9}])}},gw=new class extends Cv{constructor(){super("dubhe_grpc.TableChange",[{no:1,name:"table_id",kind:"scalar",T:9},{no:2,name:"data",kind:"message",T:()=>tw}])}},bw=new class{constructor(e,t,n){this.typeName=e,this.methods=t.map(e=>function(e,t){var n,r,i;let o=e;return o.service=t,o.localName=null!==(n=o.localName)&&void 0!==n?n:Ib(o.name),o.serverStreaming=!!o.serverStreaming,o.clientStreaming=!!o.clientStreaming,o.options=null!==(r=o.options)&&void 0!==r?r:{},o.idempotency=null!==(i=o.idempotency)&&void 0!==i?i:void 0,o}(e,this)),this.options=null!=n?n:{}}}("dubhe_grpc.DubheGrpc",[{name:"QueryTable",options:{},I:sw,O:pw},{name:"SubscribeTable",serverStreaming:!0,options:{},I:mw,O:gw}]),vw=class{constructor(e){this._transport=e,this.typeName=bw.typeName,this.methods=bw.methods,this.options=bw.options}queryTable(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return Av("unary",this._transport,n,r,e)}subscribeTable(e,t){const n=this.methods[1],r=this._transport.mergeOptions(t);return Av("serverStreaming",this._transport,n,r,e)}};var ww=class{constructor(e){this.currentOptions=e,this.dubheGrpcClient=new vw(new Xv(e))}updateConfig(e){this.currentOptions={...this.currentOptions,...e},this.dubheGrpcClient=new vw(new Xv(this.currentOptions))}};function Ew(e){if(!e.network)throw new Error("ClientConfig: network is required");if(!e.packageId)throw new Error("ClientConfig: packageId is required");if(!e.metadata)throw new Error("ClientConfig: metadata is required");const t=new wl({networkType:e.network,packageId:e.packageId,metadata:e.metadata,secretKey:e.credentials?.secretKey,mnemonics:e.credentials?.mnemonics,fullnodeUrls:e.endpoints?.fullnodeUrls,channelUrl:e.endpoints?.channelUrl,dappStorageId:e.dappStorageId,frameworkPackageId:e.frameworkPackageId}),n=function(e){return new lb(e)}({endpoint:e.endpoints?.graphql||"http://localhost:4000/graphql",subscriptionEndpoint:e.endpoints?.websocket||"ws://localhost:4000/graphql",dubheMetadata:e.dubheMetadata}),r=new ww({baseUrl:e.endpoints?.grpc||"http://localhost:8080"}),i=function(e,t){return new xb(e,t)}(n,{dubheMetadata:e.dubheMetadata,queryConfig:{enableBatchOptimization:e.options?.enableBatchOptimization??!0,defaultCacheTimeout:e.options?.cacheTimeout??5e3},subscriptionConfig:{defaultDebounceMs:e.options?.debounceMs??100,reconnectOnError:e.options?.reconnectOnError??!0}}),o=t.getAddress();return{contract:t,graphqlClient:n,grpcClient:r,ecsWorld:i,metadata:e.metadata,network:e.network,packageId:e.packageId,dappHubId:e.dappHubId,dappStorageId:e.dappStorageId,frameworkPackageId:e.frameworkPackageId,address:o,options:e.options}}function kw(e){return["mainnet","testnet","devnet","localnet"].includes(e)}function Sw(e){if(!e.network)throw new Error("ClientConfig validation failed: network is required");if(!kw(e.network))throw new Error(`ClientConfig validation failed: invalid network type "${e.network}". Must be one of: mainnet, testnet, devnet, localnet`);if(!e.packageId)throw new Error("ClientConfig validation failed: packageId is required");if("string"!=typeof e.packageId||""===e.packageId.trim())throw new Error("ClientConfig validation failed: packageId must be a non-empty string");if(!e.metadata)throw new Error("ClientConfig validation failed: metadata is required")}function Tw(e){return Sw(e),Ew(e)}})(),r})());
|
|
217
|
+
`,n=await this.apolloClient.query({query:t,variables:{filter:{dappKey:{equalTo:e}}},fetchPolicy:"network-only"});if(n.error)throw n.error;const r=n.data?.dubheDappRuntimeStates?.edges??[];return r[0]?.node??null}getFilterTypeName(e){const t=this.getSingularTableName(e),n=this.toPascalCase(t);return n.startsWith("Store")?`${n}Filter`:`Store${n}Filter`}getOrderByTypeName(e){const t=this.getPluralTableName(e),n=this.toPascalCase(t);return n.startsWith("Store")?`${n}OrderBy`:`Store${n}OrderBy`}getPluralTableName(e){const t=this.toCamelCase(e);return rb.plural(t)}getSingularTableName(e){const t=this.toCamelCase(e);return rb.singular(t)}toCamelCase(e){return e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}toPascalCase(e){const t=this.toCamelCase(e);return t.charAt(0).toUpperCase()+t.slice(1)}toSnakeCase(e){return e.includes("_")?e.toUpperCase():e.replace(/([A-Z])/g,"_$1").toLowerCase().replace(/^_/,"").toUpperCase()}async clearCache(){await this.apolloClient.clearStore()}async resetCache(){await this.apolloClient.resetStore()}getApolloClient(){return this.apolloClient}close(){this.subscriptionClient&&this.subscriptionClient.dispose()}getDubheMetadata(){return this.dubheMetadata}buildCacheFields(e){const t={};return e?(e.paginatedTables&&e.paginatedTables.forEach(n=>{const r=this.getPluralTableName(n),i=e.customMergeStrategies?.[r];t[r]={keyArgs:i?.keyArgs||["filter","orderBy"],merge:i?.merge||this.defaultMergeStrategy}}),e.customMergeStrategies&&Object.entries(e.customMergeStrategies).forEach(([e,n])=>{t[e]||(t[e]={keyArgs:n.keyArgs||["filter","orderBy"],merge:n.merge||this.defaultMergeStrategy})}),t):t}defaultMergeStrategy(e={edges:[]},t){return t&&Array.isArray(t.edges)?{...t,edges:[...e.edges||[],...t.edges]}:e}parseTableInfoFromConfig(){if(!this.dubheMetadata)return;const{components:e=[],resources:t=[],enums:n=[]}=this.dubheMetadata;e.forEach(e=>{Object.entries(e).forEach(([e,t])=>{this.processTableData(e,t,n)})}),t.forEach(e=>{Object.entries(e).forEach(([e,t])=>{this.processTableData(e,t,n)})})}processTableData(e,t,n){const r=e.includes("_")?this.toCamelCase(e):e,i=[];t.fields&&Array.isArray(t.fields)&&t.fields.forEach(e=>{Object.entries(e).forEach(([e,t])=>{const n=this.toCamelCase(e);i.push(n)})}),i.push("createdAtTimestampMs","updatedAtTimestampMs","isDeleted","lastUpdateDigest");const o=t.keys.map(e=>this.toCamelCase(e)),s={tableName:r,fields:[...new Set(i)],primaryKeys:o,enumFields:{}};this.uniqueTableNames.add(e),this.parsedTables.set(e,s),this.parsedTables.set(r,s),e!==r&&this.parsedTables.set(this.toSnakeCase(r),s)}findTableInfo(e){let t=this.parsedTables.get(e);if(t)return t;const n=this.toCamelCase(e);return t=this.parsedTables.get(n),t||(e.includes("_")&&(t=this.parsedTables.get(e.toLowerCase()),t)?t:void 0)}getTableFields(e){return this.getMinimalFields(e)}getTablePrimaryKeys(e){const t=this.findTableInfo(e);return t?.primaryKeys||[]}getTableEnumFields(e){const t=this.findTableInfo(e);return t?.enumFields||{}}getAllTableInfo(){const e=new Map;return this.uniqueTableNames.forEach(t=>{const n=this.parsedTables.get(t);n&&e.set(t,n)}),e}getMinimalFields(e){const t=this.findTableInfo(e);return t?t.fields:["createdAtTimestampMs","updatedAtTimestampMs","isDeleted","lastUpdateDigest"]}convertTableFields(e,t){let n;if(t&&t.length>0)n=t;else{const t=gb[e];if(t)n=t;else{const t=this.getTableFields(e);n=t.length>0?t:["createdAtTimestampMs","updatedAtTimestampMs","isDeleted","lastUpdateDigest"]}}return n.join("\n ")}async getDappFeeState(){const e=await this.getAllTables("dubheDappFeeState",{first:1}).catch(()=>null);return e?.edges?.[0]?.node??null}async getDappRevenueState(){const e=await this.getAllTables("dubheDappRevenueState",{first:1}).catch(()=>null);return e?.edges?.[0]?.node??null}async getDappRuntimeState(){const e=await this.getAllTables("dubheDappRuntimeState",{first:1}).catch(()=>null);return e?.edges?.[0]?.node??null}async getDappMarketplaceFees(e){return this.getAllTables("dubheDappMarketplaceFees",{first:e?.first??20,after:e?.after,orderBy:[{field:"updatedAtCheckpoint",direction:"DESC"}]})}};function Eb(e){return e&&0!==e.length?e.map(e=>{const t=function(e){if(e.includes("_"))return e.toUpperCase();return e.replace(/([A-Z])/g,"_$1").toLowerCase().replace(/^_/,"").toUpperCase()}(e.field);return`${t}_${"DESC"===e.direction?"DESC":"ASC"}`}):["UPDATED_AT_TIMESTAMP_MS_DESC"]}function kb(e,t){const{idFields:n=["nodeId","entityId"],composite:r=!1}=t||{};return e.edges.map(e=>{const t=e.node;if(r){return n.map(e=>t[e]||"").filter(Boolean).join("|")}for(const e of n)if(void 0!==t[e]&&null!==t[e])return t[e];return Object.values(t)[0]||""}).filter(Boolean)}function Sb(e,t){return{entityIds:kb(e,t),items:e.edges.map(e=>e.node),pageInfo:{hasNextPage:e.pageInfo.hasNextPage,hasPreviousPage:e.pageInfo.hasPreviousPage,startCursor:e.pageInfo.startCursor,endCursor:e.pageInfo.endCursor},totalCount:e.totalCount||0}}function Tb(e,t,n){const r=t.map(t=>{const r=e[t];return r?kb(r,n):[]});return function(e){return 0===e.length?[]:1===e.length?e[0]:e.reduce((e,t)=>{const n=new Set(t);return e.filter(e=>n.has(e))})}(r)}function _b(e,t,n){const r=t.map(t=>{const r=e[t];return r?kb(r,n):[]});return function(e){const t=new Set;return e.forEach(e=>{e.forEach(e=>t.add(e))}),Array.from(t)}(r)}function xb(e,t){let n=null;return(...r)=>{n&&clearTimeout(n),n=setTimeout(()=>{e(...r),n=null},t)}}function Ob(e,t,n){const r=[...t].sort(),i=n?JSON.stringify(n):"";return`${e}:${r.join(",")}:${i}`}function Ib(e){return"string"==typeof e&&e.length>0}function Cb(e){return"string"==typeof e&&e.length>0}function Mb(e){return e instanceof Error?e.message:"string"==typeof e?e:JSON.stringify(e)}var Ab=class{constructor(e,t){this.queryCache=new Map,this.cacheTimeout=5e3,this.availableComponents=[],this.componentDiscoverer=null,this.componentPrimaryKeys=new Map,this.graphqlClient=e,this.componentDiscoverer=t||null}setAvailableComponents(e){this.availableComponents=e}initializeComponentMetadata(e){this.componentPrimaryKeys.clear();for(const t of e)1===t.primaryKeys.length&&this.componentPrimaryKeys.set(t.name,t.primaryKeys[0])}getComponentPrimaryKeyField(e){if(this.componentPrimaryKeys.has(e))return this.componentPrimaryKeys.get(e);const t=e.replace(/([A-Z])/g,"_$1").toLowerCase();if(t!==e&&this.componentPrimaryKeys.has(t))return this.componentPrimaryKeys.get(t);const n=e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase());return n!==e&&this.componentPrimaryKeys.has(n)?this.componentPrimaryKeys.get(n):"entityId"}setComponentDiscoverer(e){this.componentDiscoverer=e}buildPaginationParams(e){const t={};return void 0!==e?.first?t.first=e.first:void 0!==e?.limit&&(t.first=e.limit,void 0!==e?.offset&&console.warn("ECS Query: offset parameter is not supported with GraphQL cursor-based pagination. Use after/before instead.")),void 0!==e?.last&&(t.last=e.last),void 0!==e?.after&&(t.after=e.after),void 0!==e?.before&&(t.before=e.before),t}async getComponentFields(e){if(this.componentDiscoverer)try{const t=this.componentDiscoverer.getComponentMetadata(e);if(t)return t.fields.map(e=>e.name)}catch(e){}throw new Error(`Unable to get field information for component ${e}. Please explicitly specify fields in QueryOptions or ensure component discoverer is properly configured.`)}async getComponentPrimaryKeys(e){if(this.componentDiscoverer)try{const t=this.componentDiscoverer.getComponentMetadata(e);if(t&&t.primaryKeys.length>0)return t.primaryKeys}catch(e){}throw new Error(`Unable to get primary key information for component ${e}. Please explicitly specify idFields in QueryOptions or ensure component discoverer is properly configured.`)}async getQueryFields(e,t){return t&&t.length>0?t:this.getComponentFields(e)}async hasEntity(e){if(!Ib(e))return!1;try{const t=await this.getAvailableComponents();for(const n of t)try{const t=this.buildEntityCondition(n,e);if(await this.graphqlClient.getTableByCondition(n,t))return!0}catch(e){}return!1}catch(e){return!1}}async getAllEntities(){try{const e=await this.getAvailableComponents(),t=await Promise.all(e.map(async e=>({key:e,tableName:e,params:{fields:await this.getQueryFields(e),filter:{}},primaryKey:this.componentPrimaryKeys.get(e)||"entityId"})));return _b(await this.graphqlClient.batchQuery(t.map(e=>({key:e.key,tableName:e.tableName,params:e.params}))),e,{idFields:void 0,composite:!1})}catch(e){return[]}}async getEntityCount(){return(await this.getAllEntities()).length}async hasComponent(e,t){if(!Ib(e)||!Cb(t))return!1;if(!this.isECSComponent(t))return!1;try{const n=this.buildEntityCondition(t,e);return null!==await this.graphqlClient.getTableByCondition(t,n)}catch(e){return!1}}async getComponent(e,t){if(!Ib(e)||!Cb(t))return null;if(!this.isECSComponent(t))return null;try{const n=this.buildEntityCondition(t,e),r=await this.graphqlClient.getTableByCondition(t,n);return r&&!0===r.isDeleted?null:r}catch(e){return null}}async getComponents(e){if(!Ib(e))return[];try{const t=await this.getAvailableComponents(),n=[];return await Promise.all(t.map(async t=>{await this.hasComponent(e,t)&&n.push(t)})),n}catch(e){return[]}}isECSComponent(e){if(this.availableComponents.includes(e))return!0;const t=e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase());if(t!==e&&this.availableComponents.includes(t))return!0;const n=e.replace(/([A-Z])/g,"_$1").toLowerCase();return!(n===e||!this.availableComponents.includes(n))}resolveComponentType(e){if(this.componentPrimaryKeys.has(e))return e;const t=e.replace(/([A-Z])/g,"_$1").toLowerCase();if(t!==e&&this.componentPrimaryKeys.has(t))return t;const n=e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase());return n!==e&&this.componentPrimaryKeys.has(n)?n:e}buildEntityCondition(e,t){const n=this.resolveComponentType(e),r=this.componentPrimaryKeys.get(n);return r?{[r]:t}:{entityId:t}}filterValidECSComponents(e){return e.filter(e=>!!Cb(e)&&!!this.isECSComponent(e))}async queryWithFullPagination(e,t){const n={entityIds:[],items:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1},totalCount:0};if(!Cb(e))return n;if(!this.isECSComponent(e))return n;try{const n=await this.getQueryFields(e,t?.fields),r=await this.getComponentPrimaryKeys(e),i=this.buildPaginationParams(t);return Sb(await this.graphqlClient.getAllTables(e,{...i,fields:n,orderBy:t?.orderBy}),{idFields:t?.idFields||r,composite:t?.compositeId})}catch(e){return n}}async queryWith(e,t){return this.queryWithFullPagination(e,t)}async queryWithAll(e,t){if(0===e.length)return[];if(1===e.length){return(await this.queryWith(e[0],t)).entityIds}const n=this.filterValidECSComponents(e);if(0===n.length)return[];const r=Ob("queryWithAll",n,t),i=this.getCachedResult(r);if(i&&!1!==t?.cache)return i;try{const e=this.buildPaginationParams(t),i=await Promise.all(n.map(async n=>({key:n,tableName:n,params:{fields:await this.getQueryFields(n,t?.fields),...e,orderBy:t?.orderBy}}))),o=await this.graphqlClient.batchQuery(i);let s=t?.idFields;if(!s&&n.length>0)try{s=await this.getComponentPrimaryKeys(n[0])}catch(e){}const a=Tb(o,n,{idFields:s,composite:t?.compositeId});return this.setCachedResult(r,a),a}catch(e){return[]}}async queryWithAny(e,t){if(0===e.length)return[];if(1===e.length){return(await this.queryWith(e[0],t)).entityIds}const n=this.filterValidECSComponents(e);if(0===n.length)return[];const r=Ob("queryWithAny",n,t),i=this.getCachedResult(r);if(i&&!1!==t?.cache)return i;try{const e=this.buildPaginationParams(t),i=await Promise.all(n.map(async n=>({key:n,tableName:n,params:{fields:await this.getQueryFields(n,t?.fields),...e,orderBy:t?.orderBy}}))),o=await this.graphqlClient.batchQuery(i);let s=t?.idFields;if(!s&&n.length>0)try{s=await this.getComponentPrimaryKeys(n[0])}catch(e){}const a=_b(o,n,{idFields:s,composite:t?.compositeId});return this.setCachedResult(r,a),a}catch(e){return[]}}async queryWithout(e,t,n){if(0===e.length)return[];const r=this.filterValidECSComponents(e);if(0===r.length)return[];const i=this.filterValidECSComponents(t);try{const e=await this.queryWithAll(r,n);if(0===i.length)return e;const t=await this.queryWithAny(i),o=new Set(t);return e.filter(e=>!o.has(e))}catch(e){return[]}}async queryWhereFullPagination(e,t,n){const r={entityIds:[],items:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1},totalCount:0};if(!Cb(e))return r;if(!this.isECSComponent(e))return r;try{const r=await this.getQueryFields(e,n?.fields),i=await this.getComponentPrimaryKeys(e),o=this.buildPaginationParams(n);return Sb(await this.graphqlClient.getAllTables(e,{filter:t,...o,fields:r,orderBy:n?.orderBy}),{idFields:n?.idFields||i,composite:n?.compositeId})}catch(e){return r}}async queryWhere(e,t,n){return(await this.queryWhereFullPagination(e,t,n)).entityIds}async queryRange(e,t,n,r,i){if(!Cb(e))return[];if(!this.isECSComponent(e))return[];const o={[t]:{greaterThanOrEqualTo:n,lessThanOrEqualTo:r}};return this.queryWhere(e,o,i)}async queryPaged(e,t,n){try{return function(e,t,n){const r=(t-1)*n,i=r+n;return{items:e.slice(r,i),totalCount:e.length,hasMore:i<e.length,page:t,pageSize:n}}(1===e.length?(await this.queryWith(e[0])).entityIds:await this.queryWithAll(e),t,n)}catch(e){return{items:[],totalCount:0,hasMore:!1,page:t,pageSize:n}}}query(){return new Nb(this)}getCachedResult(e){const t=this.queryCache.get(e);return t&&Date.now()-t.timestamp<this.cacheTimeout?t.result:null}setCachedResult(e,t){this.queryCache.set(e,{result:t,timestamp:Date.now()})}cleanExpiredCache(){const e=Date.now();for(const[t,n]of this.queryCache.entries())e-n.timestamp>=this.cacheTimeout&&this.queryCache.delete(t)}async getAvailableComponents(){return this.availableComponents.length>0?this.availableComponents:[]}dispose(){this.queryCache.clear()}},Nb=class{constructor(e){this.includeTypes=[],this.excludeTypes=[],this.whereConditions=[],this.orderByOptions=[],this.ecsQuery=e}with(...e){return this.includeTypes.push(...e),this}without(...e){return this.excludeTypes.push(...e),this}where(e,t){return this.whereConditions.push({componentType:e,predicate:t}),this}orderBy(e,t,n="ASC"){return this.orderByOptions.push({componentType:e,field:t,direction:n}),this}limit(e){return this.limitValue=e,this}offset(e){return this.offsetValue=e,this}async execute(){try{const e={limit:this.limitValue,offset:this.offsetValue,orderBy:this.orderByOptions.map(e=>({field:e.field,direction:e.direction}))};if(this.whereConditions.length>0){const t=[];for(const n of this.whereConditions){const r=await this.ecsQuery.queryWhere(n.componentType,n.predicate,e);t.push(r)}return t.reduce((e,t)=>{const n=new Set(t);return e.filter(e=>n.has(e))})}return this.excludeTypes.length>0?this.ecsQuery.queryWithout(this.includeTypes,this.excludeTypes,e):this.ecsQuery.queryWithAll(this.includeTypes,e)}catch(e){return[]}}},jb=class{constructor(e,t){this.subscriptions=new Map,this.queryWatchers=new Map,this.componentDiscoverer=null,this.availableComponents=[],this.componentPrimaryKeys=new Map,this.graphqlClient=e,this.componentDiscoverer=t||null}setAvailableComponents(e){this.availableComponents=e}initializeComponentMetadata(e){this.componentPrimaryKeys.clear();for(const t of e)1===t.primaryKeys.length&&this.componentPrimaryKeys.set(t.name,t.primaryKeys[0])}getComponentPrimaryKeyField(e){if(this.componentPrimaryKeys.has(e))return this.componentPrimaryKeys.get(e);const t=e.replace(/([A-Z])/g,"_$1").toLowerCase();if(t!==e&&this.componentPrimaryKeys.has(t))return this.componentPrimaryKeys.get(t);const n=e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase());return n!==e&&this.componentPrimaryKeys.has(n)?this.componentPrimaryKeys.get(n):"entityId"}setComponentDiscoverer(e){this.componentDiscoverer=e}isECSComponent(e){if(this.availableComponents.includes(e))return!0;const t=e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase());if(t!==e&&this.availableComponents.includes(t))return!0;const n=e.replace(/([A-Z])/g,"_$1").toLowerCase();return!(n===e||!this.availableComponents.includes(n))}async getComponentFields(e){if(this.componentDiscoverer)try{const t=this.componentDiscoverer.getComponentMetadata(e);if(t)return t.fields.map(e=>e.name)}catch(e){}return["createdAtTimestampMs","updatedAtTimestampMs","isDeleted","lastUpdateDigest"]}async getQueryFields(e,t){return t&&t.length>0?t:this.getComponentFields(e)}onComponentAdded(e,t){return Cb(e)?this.isECSComponent(e)?new mh(n=>{let r=null;return this.getQueryFields(e,t?.fields).then(i=>{const o=t?.debounceMs?xb(e=>n.next(e),t.debounceMs):e=>n.next(e),s=this.graphqlClient.subscribeToTableChanges(e,{initialEvent:t?.initialEvent??!1,fields:i,onData:t=>{try{const n=this.getPluralTableName(e),r=t?.listen?.query?.[n]?.nodes;r&&Array.isArray(r)&&r.forEach(t=>{if(t){const n=t.entityId||this.extractEntityId(t,e);if(n){const e={entityId:n,data:t,changeType:"added",timestamp:Date.now()};o(e)}}})}catch(e){n.error(e)}},onError:e=>{n.error(e)},onComplete:()=>{n.complete()}});r=s.subscribe({})}).catch(e=>{n.error(e)}),()=>{r&&r.unsubscribe()}}):new mh(t=>{t.error(new Error(`Component type ${e} is not ECS-compliant or not available`))}):new mh(t=>{t.error(new Error(`Invalid component type: ${e}`))})}onComponentRemoved(e,t){return Cb(e)?this.isECSComponent(e)?new mh(n=>{let r=null,i=new Set;try{const o=t?.debounceMs?xb(e=>n.next(e),t.debounceMs):e=>n.next(e);this.initializeLastKnownEntities(e,i);const s=this.graphqlClient.subscribeToTableChanges(e,{initialEvent:!1,fields:["updatedAtTimestampMs"],onData:t=>{try{const n=this.getPluralTableName(e),r=new Set((t?.listen?.query?.[n]?.nodes||[]).map(t=>t.entityId||this.extractEntityId(t,e)).filter(Boolean));Array.from(i).filter(e=>!r.has(e)).forEach(e=>{const t={entityId:e,data:null,changeType:"removed",timestamp:Date.now()};o(t)}),i=r}catch(e){n.error(e)}},onError:e=>{n.error(e)},onComplete:()=>{n.complete()}});r=s.subscribe({})}catch(e){n.error(e)}return()=>{r&&r.unsubscribe()}}):new mh(t=>{t.error(new Error(`Component type ${e} is not ECS-compliant or not available`))}):new mh(t=>{t.error(new Error(`Invalid component type: ${e}`))})}onComponentChanged(e,t){return Cb(e)?this.isECSComponent(e)?new mh(n=>{let r=null;return this.getQueryFields(e,t?.fields).then(i=>{const o=t?.debounceMs?xb(e=>n.next(e),t.debounceMs):e=>n.next(e),s=this.graphqlClient.subscribeToTableChanges(e,{initialEvent:t?.initialEvent??!1,fields:i,onData:t=>{try{const n=this.getPluralTableName(e),r=t?.listen?.query?.[n]?.nodes;r&&Array.isArray(r)&&r.forEach(t=>{if(t){const n=t.entityId||this.extractEntityId(t,e);if(n){const e={entityId:n,data:t,changeType:"updated",timestamp:Date.now()};o(e)}}})}catch(e){n.error(e)}},onError:e=>{n.error(e)},onComplete:()=>{n.complete()}});r=s.subscribe({})}).catch(e=>{n.error(e)}),()=>{r&&r.unsubscribe()}}):new mh(t=>{t.error(new Error(`Component type ${e} is not ECS-compliant or not available`))}):new mh(t=>{t.error(new Error(`Invalid component type: ${e}`))})}onEntityComponent(e,t,n){return Cb(e)?this.isECSComponent(e)?new mh(r=>{let i=null;return this.getQueryFields(e,n?.fields).then(o=>{const s=n?.debounceMs?xb(e=>r.next(e),n.debounceMs):e=>r.next(e),a=this.getComponentPrimaryKeyField(e),u={[a]:{equalTo:t}},c=this.graphqlClient.subscribeToTableChanges(e,{initialEvent:n?.initialEvent??!1,fields:o,filter:u,onData:t=>{try{const n=this.getPluralTableName(e);(t?.listen?.query?.[n]?.nodes||[]).forEach(t=>{if(t){const n=t.entityId||this.extractEntityId(t,e);if(n){const e={entityId:n,data:t,changeType:"updated",timestamp:Date.now()};s(e)}}})}catch(e){r.error(e)}},onError:e=>{r.error(e)},onComplete:()=>{r.complete()}});i=c.subscribe({})}).catch(e=>{r.error(e)}),()=>{i&&i.unsubscribe()}}):new mh(t=>{t.error(new Error(`Component type ${e} is not ECS-compliant or not available`))}):new mh(t=>{t.error(new Error(`Invalid component type: ${e}`))})}watchQuery(e,t){const n=e.filter(Cb);return 0===n.length?new mh(e=>{e.error(new Error("No valid component types for query watching"))}):new mh(e=>{const r=new Db(this.graphqlClient,n,n=>{const r={changes:n};if(t?.debounceMs){xb(()=>e.next(r),t.debounceMs)()}else e.next(r)},t);return()=>{r.dispose()}})}createRealTimeStream(e,t){return Cb(e)?new mh(n=>{try{const r=this.graphqlClient.createRealTimeDataStream(e,{filter:t}).subscribe({next:e=>{const t=e.edges.map(e=>{const t=e.node;return{entityId:t.nodeId||t.entityId||Object.values(t)[0]||"",data:t}}).filter(e=>e.entityId);n.next(t)},error:e=>{n.error(e)},complete:()=>{n.complete()}});return()=>{r.unsubscribe()}}catch(e){n.error(e)}}):new mh(t=>{t.error(new Error(`Invalid component type: ${e}`))})}async initializeLastKnownEntities(e,t){try{(await this.graphqlClient.getAllTables(e,{fields:["updatedAtTimestampMs"]})).edges.forEach(e=>{const n=e.node,r=n.nodeId||n.entityId||Object.values(n)[0];r&&t.add(r)})}catch(e){}}getPluralTableName(e){const t=this.toCamelCase(e);return rb.plural(t)}toCamelCase(e){return e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}extractEntityId(e,t){if(!e||"object"!=typeof e)return"";const n=this.getComponentPrimaryKeyField(t);if(e[n]&&"string"==typeof e[n])return e[n];if("entityId"!==n&&e.entityId&&"string"==typeof e.entityId)return e.entityId;const r=Object.values(e);for(const e of r)if("string"==typeof e&&e.length>0)return e;return""}unsubscribeAll(){this.subscriptions.forEach(e=>{try{e?.unsubscribe()}catch(e){}}),this.subscriptions.clear(),this.queryWatchers.forEach(e=>{try{e.dispose()}catch(e){}}),this.queryWatchers.clear()}dispose(){this.unsubscribeAll()}},Db=class{constructor(e,t,n,r){this.subscriptions=[],this.currentResults=[],this.isInitialized=!1,this.graphqlClient=e,this.componentTypes=t,this.callback=n,this.options=r,this.initialize()}async initialize(){try{await this.updateCurrentResults(),this.componentTypes.forEach(e=>{const t=this.graphqlClient.subscribeToTableChanges(e,{initialEvent:!1,onData:()=>{this.handleDataChange()},onError:e=>{}}).subscribe({});this.subscriptions.push(t)}),this.isInitialized=!0,this.options?.initialEvent&&this.currentResults.length>0&&this.callback({added:this.currentResults,removed:[],current:this.currentResults})}catch(e){}}async handleDataChange(){if(this.isInitialized)try{const e=[...this.currentResults];await this.updateCurrentResults();const t=function(e,t){const n=new Set(e),r=new Set(t);return{added:t.filter(e=>!n.has(e)),removed:e.filter(e=>!r.has(e)),current:t}}(e,this.currentResults);if(t.added.length>0||t.removed.length>0){(this.options?.debounceMs?xb(this.callback,this.options.debounceMs):this.callback)(t)}}catch(e){}}async updateCurrentResults(){try{if(1===this.componentTypes.length){const e=await this.graphqlClient.getAllTables(this.componentTypes[0],{fields:["updatedAtTimestampMs"]});this.currentResults=e.edges.map(e=>{const t=e.node;return t.nodeId||t.entityId||Object.values(t)[0]||""}).filter(Boolean)}else{const e=this.componentTypes.map(e=>({key:e,tableName:e,params:{fields:["updatedAtTimestampMs"],filter:{}}})),t=await this.graphqlClient.batchQuery(e),n=this.componentTypes.map(e=>{const n=t[e];return n?n.edges.map(e=>{const t=e.node;return t.nodeId||t.entityId||Object.values(t)[0]||""}).filter(Boolean):[]});this.currentResults=n.reduce((e,t)=>{const n=new Set(t);return e.filter(e=>n.has(e))})}}catch(e){this.currentResults=[]}}getCurrentResults(){return[...this.currentResults]}dispose(){this.subscriptions.forEach(e=>{try{e?.unsubscribe()}catch(e){}}),this.subscriptions=[]}},Rb=class{constructor(e,t){this.componentMetadataMap=new Map,this.componentTypes=[],this.graphqlClient=e,this.dubheMetadata=t;const n=[],r=[];this.parseFromDubheMetadata(n,r);const i={components:n,discoveredAt:Date.now(),errors:r.length>0?r:void 0,totalDiscovered:n.length,fromDubheMetadata:!0};this.discoveryResult=i,this.componentTypes=n.map(e=>e.name),n.forEach(e=>{this.componentMetadataMap.set(e.name,e)})}parseFromDubheMetadata(e,t){const n=[];if(this.dubheMetadata?.components)for(const e of this.dubheMetadata.components)n.push(...Object.entries(e));if(this.dubheMetadata?.resources)for(const e of this.dubheMetadata.resources)for(const[t,r]of Object.entries(e))r.keys&&1===r.keys.length&&"entity_id"===r.keys[0]&&n.push([t,r]);for(const[r,i]of n){const n=this.tableNameToComponentName(r);try{const t=[],o=[],s=[];if(i.fields&&Array.isArray(i.fields))for(const e of i.fields)for(const[n,r]of Object.entries(e)){const e=this.snakeToCamel(n),a=String(r),u=i.keys&&i.keys.includes(n);t.push({name:e,type:this.dubheTypeToGraphQLType(a),nullable:!u,isPrimaryKey:u,isEnum:this.isEnumType(a)}),u&&o.push(e),this.isEnumType(a)&&s.push(e)}if(0===o.length&&(t.unshift({name:"entityId",type:"String",nullable:!1,isPrimaryKey:!0,isEnum:!1}),o.push("entityId")),t.push({name:"createdAtTimestampMs",type:"BigInt",nullable:!1,isPrimaryKey:!1,isEnum:!1},{name:"updatedAtTimestampMs",type:"BigInt",nullable:!1,isPrimaryKey:!1,isEnum:!1},{name:"isDeleted",type:"Boolean",nullable:!1,isPrimaryKey:!1,isEnum:!1},{name:"lastUpdateDigest",type:"String",nullable:!1,isPrimaryKey:!1,isEnum:!1}),1!==o.length)continue;const a={name:n,tableName:r,fields:t,primaryKeys:o,hasDefaultId:o.includes("entityId"),enumFields:s,lastUpdated:Date.now(),description:`Auto-discovered component: ${r}`};e.push(a)}catch(e){const r=`Component ${n} validation failed: ${Mb(e)}`;t.push(r)}}}getComponentTypes(){return this.componentTypes}getComponentMetadata(e){const t=this.componentMetadataMap.get(e);if(t)return t;const n=e.replace(/([A-Z])/g,"_$1").toLowerCase();if(n!==e){const e=this.componentMetadataMap.get(n);if(e)return e}const r=e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase());if(r!==e){const e=this.componentMetadataMap.get(r);if(e)return e}return null}snakeToCamel(e){return e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}dubheTypeToGraphQLType(e){if(e.startsWith("vector<")&&e.endsWith(">"))return"String";switch(e){case"u8":case"u16":case"u32":case"u64":case"u128":case"i8":case"i16":case"i32":case"i64":case"i128":return"Int";case"address":case"string":case"enum":default:return"String";case"bool":return"Boolean"}}componentNameToTableName(e){return e.endsWith("s")?e:e+"s"}tableNameToComponentName(e){return e.endsWith("s")&&e.length>1?e.slice(0,-1):e}isEnumType(e){return this.dubheMetadata.enums.some(t=>"object"==typeof t&&t[e])}},Pb=class{constructor(e,t){this.resourceMetadataMap=new Map,this.resourceTypes=[],this.graphqlClient=e,this.dubheMetadata=t;const n=[],r=[];this.parseFromDubheMetadata(n,r);const i={resources:n,discoveredAt:Date.now(),errors:r.length>0?r:void 0,totalDiscovered:n.length,fromDubheMetadata:!0};this.discoveryResult=i,this.resourceTypes=n.map(e=>e.name),n.forEach(e=>{this.resourceMetadataMap.set(e.name,e)})}parseFromDubheMetadata(e,t){if(this.dubheMetadata?.resources)for(const n of this.dubheMetadata.resources)for(const[r,i]of Object.entries(n))try{const t=[],n=[],o=[];if(i.fields&&Array.isArray(i.fields))for(const e of i.fields)for(const[r,s]of Object.entries(e)){const e=this.snakeToCamel(r),a=String(s),u=i.keys&&i.keys.includes(r);t.push({name:e,type:this.dubheTypeToGraphQLType(a),nullable:!u,isPrimaryKey:u,isEnum:this.isEnumType(a)}),u&&n.push(e),this.isEnumType(a)&&o.push(e)}t.push({name:"createdAtTimestampMs",type:"BigInt",nullable:!1,isPrimaryKey:!1,isEnum:!1},{name:"updatedAtTimestampMs",type:"BigInt",nullable:!1,isPrimaryKey:!1,isEnum:!1},{name:"isDeleted",type:"Boolean",nullable:!1,isPrimaryKey:!1,isEnum:!1},{name:"lastUpdateDigest",type:"String",nullable:!1,isPrimaryKey:!1,isEnum:!1});const s={name:r,tableName:r,fields:t,primaryKeys:n,hasCompositeKeys:n.length>1,hasNoKeys:0===n.length,enumFields:o,lastUpdated:Date.now(),description:`Auto-discovered resource: ${r}`};e.push(s)}catch(e){const n=`Resource ${r} validation failed: ${Mb(e)}`;t.push(n)}}getResourceTypes(){return this.resourceTypes}getResourceMetadata(e){const t=this.resourceMetadataMap.get(e);if(t)return t;const n=this.snakeToCamel(e);if(n!==e)return this.resourceMetadataMap.get(n)||null;const r=e.replace(/([A-Z])/g,"_$1").toLowerCase();return r!==e&&this.resourceMetadataMap.get(r)||null}snakeToCamel(e){return e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}dubheTypeToGraphQLType(e){if(e.startsWith("vector<")&&e.endsWith(">"))return"String";switch(e){case"u8":case"u16":case"u32":case"u64":case"u128":case"i8":case"i16":case"i32":case"i64":case"i128":return"Int";case"address":case"string":case"enum":default:return"String";case"bool":return"Boolean"}}isEnumType(e){return this.dubheMetadata.enums.some(t=>"object"==typeof t&&t[e])}},Bb=class{constructor(e,t){this.graphqlClient=e,this.config={queryConfig:{defaultCacheTimeout:3e5,maxConcurrentQueries:10,enableBatchOptimization:!0},subscriptionConfig:{defaultDebounceMs:100,maxSubscriptions:50,reconnectOnError:!0},...t};let n=this.config.dubheMetadata;if(!n&&(n=this.graphqlClient.getDubheMetadata(),!n))throw new Error("DubheMetadata is required for ECS World initialization. Please provide it either in ECSWorldConfig or in GraphQL client configuration.");this.dubheMetadata=n,this.componentDiscoverer=new Rb(e,this.dubheMetadata),this.resourceDiscoverer=new Pb(e,this.dubheMetadata),this.querySystem=new Ab(e,this.componentDiscoverer),this.subscriptionSystem=new jb(e,this.componentDiscoverer),this.initializeWithConfig()}initializeWithConfig(){try{const e=this.componentDiscoverer.discoveryResult.components.filter(e=>1===e.primaryKeys.length);this.resourceDiscoverer.discoveryResult.resources;this.querySystem.setAvailableComponents(e.map(e=>e.name)),this.querySystem.initializeComponentMetadata(e.map(e=>({name:e.name,primaryKeys:e.primaryKeys}))),this.subscriptionSystem.setAvailableComponents(e.map(e=>e.name)),this.subscriptionSystem.initializeComponentMetadata(e.map(e=>({name:e.name,primaryKeys:e.primaryKeys}))),this.config.queryConfig,this.config.subscriptionConfig}catch(e){throw new Error(`Failed to initialize ECS World: ${Mb(e)}`)}}configure(e){this.config={...this.config,...e},e.dubheMetadata&&(this.dubheMetadata=e.dubheMetadata,this.componentDiscoverer=new Rb(this.graphqlClient,this.dubheMetadata),this.resourceDiscoverer=new Pb(this.graphqlClient,this.dubheMetadata),this.querySystem.setComponentDiscoverer(this.componentDiscoverer),this.subscriptionSystem.setComponentDiscoverer(this.componentDiscoverer),this.initializeWithConfig())}discoverComponents(){return this.componentDiscoverer.getComponentTypes()}getAvailableComponents(){return this.componentDiscoverer.getComponentTypes()}getComponentMetadata(e){return this.componentDiscoverer.getComponentMetadata(e)}getAvailableResources(){return this.resourceDiscoverer.getResourceTypes()}getResourceMetadata(e){return this.resourceDiscoverer.getResourceMetadata(e)}async hasEntity(e){return this.querySystem.hasEntity(e)}async getAllEntities(){return this.querySystem.getAllEntities()}async getEntityCount(){return this.querySystem.getEntityCount()}async getEntity(e){try{if(!await this.hasEntity(e))return null;const t=await this.getComponents(e);if(0===t.length)return null;const n={entityId:e,components:{}};for(const r of t){const t=await this.getComponent(e,r);t&&(n.components[r]=t)}return n}catch(t){return console.error(`Failed to get entity ${e}:`,Mb(t)),null}}async getEntities(){return this.getAllEntities()}async getEntitiesByComponent(e){return this.queryWith(e)}async hasComponent(e,t){return this.querySystem.hasComponent(e,t)}async getComponent(e,t){return this.querySystem.getComponent(e,t)}async getComponents(e){return this.querySystem.getComponents(e)}async queryWith(e,t){return this.querySystem.queryWith(e,t)}async queryWithAll(e,t){return this.querySystem.queryWithAll(e,t)}async queryWithAny(e,t){return this.querySystem.queryWithAny(e,t)}async queryWithout(e,t,n){return this.querySystem.queryWithout(e,t,n)}async queryWhere(e,t,n){return this.querySystem.queryWhere(e,t,n)}async queryRange(e,t,n,r,i){return this.querySystem.queryRange(e,t,n,r,i)}async queryPaged(e,t,n){return this.querySystem.queryPaged(e,t,n)}async queryWithPagination(e,t){return this.querySystem.queryWith(e,t)}async queryWherePagination(e,t,n){return this.querySystem.queryWhereFullPagination(e,t,n)}query(){return this.querySystem.query()}onComponentAdded(e,t){return this.subscriptionSystem.onComponentAdded(e,t)}onComponentRemoved(e,t){return this.subscriptionSystem.onComponentRemoved(e,t)}onComponentChanged(e,t){return this.subscriptionSystem.onComponentChanged(e,t)}onEntityComponent(e,t,n){return this.subscriptionSystem.onEntityComponent(e,t,n)}watchQuery(e,t){return this.subscriptionSystem.watchQuery(e,t)}createRealTimeStream(e,t){return this.subscriptionSystem.createRealTimeStream(e,t)}async queryWithComponentData(e,t){try{const n=await this.queryWith(e,t),r=[];for(const t of n.entityIds){const n=await this.getComponent(t,e);n&&r.push({entityId:t,data:n})}return r}catch(e){return[]}}async queryMultiComponentData(e,t,n){try{const r=await this.queryWithAll([e,t],n),i=[];for(const n of r){const[r,o]=await Promise.all([this.getComponent(n,e),this.getComponent(n,t)]);r&&o&&i.push({entityId:n,data1:r,data2:o})}return i}catch(e){return[]}}async getEntityState(e){try{const t=await this.getComponents(e);if(0===t.length)return null;const n={};for(const r of t){const t=await this.getComponent(e,r);t&&(n[r]=t)}return{entityId:e,components:n}}catch(e){return null}}async getComponentStats(){try{const e={},t=await this.getAvailableComponents();return await Promise.all(t.map(async t=>{try{const n=await this.queryWith(t);e[t]=n.totalCount}catch(n){e[t]=0}})),e}catch(e){return{}}}async findOrphanEntities(){try{const e=await this.getAllEntities(),t=[];for(const n of e){1===(await this.getComponents(n)).length&&t.push(n)}return t}catch(e){return[]}}unsubscribeAll(){this.subscriptionSystem.unsubscribeAll()}clearCache(){this.querySystem.dispose()}dispose(){this.querySystem.dispose(),this.subscriptionSystem.dispose()}getGraphQLClient(){return this.graphqlClient}getQuerySystem(){return this.querySystem}getSubscriptionSystem(){return this.subscriptionSystem}getConfig(){return{...this.config}}updateConfig(e){void 0!==e.dubheMetadata&&(this.dubheMetadata=e.dubheMetadata,this.config.dubheMetadata=e.dubheMetadata,this.componentDiscoverer=new Rb(this.graphqlClient,this.dubheMetadata),this.resourceDiscoverer=new Pb(this.graphqlClient,this.dubheMetadata),this.querySystem.setComponentDiscoverer(this.componentDiscoverer),this.subscriptionSystem.setComponentDiscoverer(this.componentDiscoverer),this.initializeWithConfig()),e.queryConfig&&(this.config.queryConfig={...this.config.queryConfig,...e.queryConfig},void 0!==e.queryConfig.defaultCacheTimeout&&(this.querySystem.cacheTimeout=e.queryConfig.defaultCacheTimeout)),e.subscriptionConfig&&(this.config.subscriptionConfig={...this.config.subscriptionConfig,...e.subscriptionConfig})}getDubheMetadata(){return this.dubheMetadata}async getResource(e,t,n){try{const r=this.resourceDiscoverer.getResourceMetadata(e);if(!r)return null;t=t||{};const i={};for(const[e,n]of Object.entries(t))i[e]={equalTo:n};const o={first:n?.first??n?.limit??1,last:n?.last,after:n?.after,before:n?.before},s=await this.graphqlClient.getAllTables(e,{...o,filter:i,fields:n?.fields||r.fields.map(e=>e.name),orderBy:n?.orderBy}),a=s.edges[0]?.node;return a||null}catch(e){return null}}async getResources(e,t){try{const n=this.resourceDiscoverer.getResourceMetadata(e);if(!n)return{entityIds:[],items:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1},totalCount:0};const r={isDeleted:{equalTo:!1}};if(t?.filters)for(const[e,n]of Object.entries(t.filters))r[e]="object"==typeof n&&null!==n?n:{equalTo:n};const i={first:t?.first??t?.limit,last:t?.last,after:t?.after,before:t?.before},o=await this.graphqlClient.getAllTables(e,{...i,filter:Object.keys(r).length>0?r:void 0,fields:t?.fields||n.fields.map(e=>e.name),orderBy:t?.orderBy});return{entityIds:[],items:o.edges.map(e=>e.node),pageInfo:{hasNextPage:o.pageInfo.hasNextPage,hasPreviousPage:o.pageInfo.hasPreviousPage,startCursor:o.pageInfo.startCursor,endCursor:o.pageInfo.endCursor},totalCount:o.totalCount||0}}catch(e){return{entityIds:[],items:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1},totalCount:0}}}async hasResource(e,t){return null!==await this.getResource(e,t)}async getResourceCount(e){try{return(await this.graphqlClient.getAllTables(e,{first:1})).totalCount||0}catch(e){return 0}}subscribeToResourceChanges(e,t){const n=this.resourceDiscoverer.getResourceMetadata(e);if(!n)throw new Error(`Unknown resource type: ${e}. Available resources: [${this.getAvailableResources().join(", ")}]`);const r=t?.fields||n.fields.map(e=>e.name);return this.graphqlClient.subscribeToTableChanges(e,{...t,fields:r})}};function Fb(e){let t=!1;const n=[];for(let r=0;r<e.length;r++){let i=e.charAt(r);"_"==i?t=!0:/\d/.test(i)?(n.push(i),t=!0):t?(n.push(i.toUpperCase()),t=!1):0==r?n.push(i.toLowerCase()):n.push(i)}return n.join("")}const Ub=Symbol.for("protobuf-ts/message-type");var Lb,qb,$b;function Vb(e){var t,n,r,i;return e.localName=null!==(t=e.localName)&&void 0!==t?t:Fb(e.name),e.jsonName=null!==(n=e.jsonName)&&void 0!==n?n:Fb(e.name),e.repeat=null!==(r=e.repeat)&&void 0!==r?r:$b.NO,e.opt=null!==(i=e.opt)&&void 0!==i?i:!e.repeat&&(!e.oneof&&"message"==e.kind),e}function zb(e){if("object"!=typeof e||null===e||!e.hasOwnProperty("oneofKind"))return!1;switch(typeof e.oneofKind){case"string":return void 0!==e[e.oneofKind]&&2==Object.keys(e).length;case"undefined":return 1==Object.keys(e).length;default:return!1}}!function(e){e[e.DOUBLE=1]="DOUBLE",e[e.FLOAT=2]="FLOAT",e[e.INT64=3]="INT64",e[e.UINT64=4]="UINT64",e[e.INT32=5]="INT32",e[e.FIXED64=6]="FIXED64",e[e.FIXED32=7]="FIXED32",e[e.BOOL=8]="BOOL",e[e.STRING=9]="STRING",e[e.BYTES=12]="BYTES",e[e.UINT32=13]="UINT32",e[e.SFIXED32=15]="SFIXED32",e[e.SFIXED64=16]="SFIXED64",e[e.SINT32=17]="SINT32",e[e.SINT64=18]="SINT64"}(Lb||(Lb={})),function(e){e[e.BIGINT=0]="BIGINT",e[e.STRING=1]="STRING",e[e.NUMBER=2]="NUMBER"}(qb||(qb={})),function(e){e[e.NO=0]="NO",e[e.PACKED=1]="PACKED",e[e.UNPACKED=2]="UNPACKED"}($b||($b={}));class Kb{constructor(e){var t;this.fields=null!==(t=e.fields)&&void 0!==t?t:[]}prepare(){if(this.data)return;const e=[],t=[],n=[];for(let r of this.fields)if(r.oneof)n.includes(r.oneof)||(n.push(r.oneof),e.push(r.oneof),t.push(r.oneof));else switch(t.push(r.localName),r.kind){case"scalar":case"enum":r.opt&&!r.repeat||e.push(r.localName);break;case"message":r.repeat&&e.push(r.localName);break;case"map":e.push(r.localName)}this.data={req:e,known:t,oneofs:Object.values(n)}}is(e,t,n=!1){if(t<0)return!0;if(null==e||"object"!=typeof e)return!1;this.prepare();let r=Object.keys(e),i=this.data;if(r.length<i.req.length||i.req.some(e=>!r.includes(e)))return!1;if(!n&&r.some(e=>!i.known.includes(e)))return!1;if(t<1)return!0;for(const r of i.oneofs){const i=e[r];if(!zb(i))return!1;if(void 0===i.oneofKind)continue;const o=this.fields.find(e=>e.localName===i.oneofKind);if(!o)return!1;if(!this.field(i[i.oneofKind],o,n,t))return!1}for(const r of this.fields)if(void 0===r.oneof&&!this.field(e[r.localName],r,n,t))return!1;return!0}field(e,t,n,r){let i=t.repeat;switch(t.kind){case"scalar":return void 0===e?t.opt:i?this.scalars(e,t.T,r,t.L):this.scalar(e,t.T,t.L);case"enum":return void 0===e?t.opt:i?this.scalars(e,Lb.INT32,r):this.scalar(e,Lb.INT32);case"message":return void 0===e||(i?this.messages(e,t.T(),n,r):this.message(e,t.T(),n,r));case"map":if("object"!=typeof e||null===e)return!1;if(r<2)return!0;if(!this.mapKeys(e,t.K,r))return!1;switch(t.V.kind){case"scalar":return this.scalars(Object.values(e),t.V.T,r,t.V.L);case"enum":return this.scalars(Object.values(e),Lb.INT32,r);case"message":return this.messages(Object.values(e),t.V.T(),n,r)}}return!0}message(e,t,n,r){return n?t.isAssignable(e,r):t.is(e,r)}messages(e,t,n,r){if(!Array.isArray(e))return!1;if(r<2)return!0;if(n){for(let n=0;n<e.length&&n<r;n++)if(!t.isAssignable(e[n],r-1))return!1}else for(let n=0;n<e.length&&n<r;n++)if(!t.is(e[n],r-1))return!1;return!0}scalar(e,t,n){let r=typeof e;switch(t){case Lb.UINT64:case Lb.FIXED64:case Lb.INT64:case Lb.SFIXED64:case Lb.SINT64:switch(n){case qb.BIGINT:return"bigint"==r;case qb.NUMBER:return"number"==r&&!isNaN(e);default:return"string"==r}case Lb.BOOL:return"boolean"==r;case Lb.STRING:return"string"==r;case Lb.BYTES:return e instanceof Uint8Array;case Lb.DOUBLE:case Lb.FLOAT:return"number"==r&&!isNaN(e);default:return"number"==r&&Number.isInteger(e)}}scalars(e,t,n,r){if(!Array.isArray(e))return!1;if(n<2)return!0;if(Array.isArray(e))for(let i=0;i<e.length&&i<n;i++)if(!this.scalar(e[i],t,r))return!1;return!0}mapKeys(e,t,n){let r=Object.keys(e);switch(t){case Lb.INT32:case Lb.FIXED32:case Lb.SFIXED32:case Lb.SINT32:case Lb.UINT32:return this.scalars(r.slice(0,n).map(e=>parseInt(e)),t,n);case Lb.BOOL:return this.scalars(r.slice(0,n).map(e=>"true"==e||"false"!=e&&e),t,n);default:return this.scalars(r,t,n,qb.STRING)}}}function Wb(e){let t=typeof e;if("object"==t){if(Array.isArray(e))return"array";if(null===e)return"null"}return t}function Qb(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}let Gb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Hb=[];for(let e=0;e<Gb.length;e++)Hb[Gb[e].charCodeAt(0)]=e;function Jb(e){let t=3*e.length/4;"="==e[e.length-2]?t-=2:"="==e[e.length-1]&&(t-=1);let n,r=new Uint8Array(t),i=0,o=0,s=0;for(let t=0;t<e.length;t++){if(n=Hb[e.charCodeAt(t)],void 0===n)switch(e[t]){case"=":o=0;case"\n":case"\r":case"\t":case" ":continue;default:throw Error("invalid base64 string.")}switch(o){case 0:s=n,o=1;break;case 1:r[i++]=s<<2|(48&n)>>4,s=n,o=2;break;case 2:r[i++]=(15&s)<<4|(60&n)>>2,s=n,o=3;break;case 3:r[i++]=(3&s)<<6|n,o=0}}if(1==o)throw Error("invalid base64 string.");return r.subarray(0,i)}function Zb(e){let t,n="",r=0,i=0;for(let o=0;o<e.length;o++)switch(t=e[o],r){case 0:n+=Gb[t>>2],i=(3&t)<<4,r=1;break;case 1:n+=Gb[i|t>>4],i=(15&t)<<2,r=2;break;case 2:n+=Gb[i|t>>6],n+=Gb[63&t],r=0}return r&&(n+=Gb[i],n+="=",1==r&&(n+="=")),n}function Yb(){let e=0,t=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(e|=(127&r)<<n,!(128&r))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(15&n)<<28,t=(112&n)>>4,!(128&n))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(t|=(127&r)<<n,!(128&r))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function Xb(e,t,n){for(let r=0;r<28;r+=7){const i=e>>>r,o=!(i>>>7==0&&0==t),s=255&(o?128|i:i);if(n.push(s),!o)return}const r=e>>>28&15|(7&t)<<4,i=!!(t>>3);if(n.push(255&(i?128|r:r)),i){for(let e=3;e<31;e+=7){const r=t>>>e,i=!(r>>>7==0),o=255&(i?128|r:r);if(n.push(o),!i)return}n.push(t>>>31&1)}}Hb["-".charCodeAt(0)]=Gb.indexOf("+"),Hb["_".charCodeAt(0)]=Gb.indexOf("/");const ev=4294967296;function tv(e){let t="-"==e[0];t&&(e=e.slice(1));const n=1e6;let r=0,i=0;function o(t,o){const s=Number(e.slice(t,o));i*=n,r=r*n+s,r>=ev&&(i+=r/ev|0,r%=ev)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),[t,r,i]}function nv(e,t){if(t>>>0<=2097151)return""+(ev*t+(e>>>0));let n=(e>>>24|t<<8)>>>0&16777215,r=t>>16&65535,i=(16777215&e)+6777216*n+6710656*r,o=n+8147497*r,s=2*r,a=1e7;function u(e,t){let n=e?String(e):"";return t?"0000000".slice(n.length)+n:n}return i>=a&&(o+=Math.floor(i/a),i%=a),o>=a&&(s+=Math.floor(o/a),o%=a),u(s,0)+u(o,s)+u(i,1)}function rv(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(127&e|128),e>>=7;t.push(1)}}function iv(){let e=this.buf[this.pos++],t=127&e;if(!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,!(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let t=5;128&e&&t<10;t++)e=this.buf[this.pos++];if(128&e)throw new Error("invalid varint");return this.assertBounds(),t>>>0}let ov;function sv(e){if(!e)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}!function(){const e=new DataView(new ArrayBuffer(8)),t=void 0!==globalThis.BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64;ov=t?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:e}:void 0}();const av=/^-?[0-9]+$/,uv=4294967296,cv=2147483648;class lv{constructor(e,t){this.lo=0|e,this.hi=0|t}isZero(){return 0==this.lo&&0==this.hi}toNumber(){let e=this.hi*uv+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}}class hv extends lv{static from(e){if(ov)switch(typeof e){case"string":if("0"==e)return this.ZERO;if(""==e)throw new Error("string is no integer");e=ov.C(e);case"number":if(0===e)return this.ZERO;e=ov.C(e);case"bigint":if(!e)return this.ZERO;if(e<ov.UMIN)throw new Error("signed value for ulong");if(e>ov.UMAX)throw new Error("ulong too large");return ov.V.setBigUint64(0,e,!0),new hv(ov.V.getInt32(0,!0),ov.V.getInt32(4,!0))}else switch(typeof e){case"string":if("0"==e)return this.ZERO;if(e=e.trim(),!av.test(e))throw new Error("string is no integer");let[t,n,r]=tv(e);if(t)throw new Error("signed value for ulong");return new hv(n,r);case"number":if(0==e)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new hv(e,e/uv)}throw new Error("unknown value "+typeof e)}toString(){return ov?this.toBigInt().toString():nv(this.lo,this.hi)}toBigInt(){return sv(ov),ov.V.setInt32(0,this.lo,!0),ov.V.setInt32(4,this.hi,!0),ov.V.getBigUint64(0,!0)}}hv.ZERO=new hv(0,0);class fv extends lv{static from(e){if(ov)switch(typeof e){case"string":if("0"==e)return this.ZERO;if(""==e)throw new Error("string is no integer");e=ov.C(e);case"number":if(0===e)return this.ZERO;e=ov.C(e);case"bigint":if(!e)return this.ZERO;if(e<ov.MIN)throw new Error("signed long too small");if(e>ov.MAX)throw new Error("signed long too large");return ov.V.setBigInt64(0,e,!0),new fv(ov.V.getInt32(0,!0),ov.V.getInt32(4,!0))}else switch(typeof e){case"string":if("0"==e)return this.ZERO;if(e=e.trim(),!av.test(e))throw new Error("string is no integer");let[t,n,r]=tv(e);if(t){if(r>cv||r==cv&&0!=n)throw new Error("signed long too small")}else if(r>=cv)throw new Error("signed long too large");let i=new fv(n,r);return t?i.negate():i;case"number":if(0==e)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new fv(e,e/uv):new fv(-e,-e/uv).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return 0!==(this.hi&cv)}negate(){let e=~this.hi,t=this.lo;return t?t=1+~t:e+=1,new fv(t,e)}toString(){if(ov)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+nv(e.lo,e.hi)}return nv(this.lo,this.hi)}toBigInt(){return sv(ov),ov.V.setInt32(0,this.lo,!0),ov.V.setInt32(4,this.hi,!0),ov.V.getBigInt64(0,!0)}}function dv(e,t){if(!e)throw new Error(t)}fv.ZERO=new fv(0,0);function pv(e){if("number"!=typeof e)throw new Error("invalid int 32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int 32: "+e)}function yv(e){if("number"!=typeof e)throw new Error("invalid uint 32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint 32: "+e)}function mv(e){if("number"!=typeof e)throw new Error("invalid float 32: "+typeof e);if(Number.isFinite(e)&&(e>34028234663852886e22||e<-34028234663852886e22))throw new Error("invalid float 32: "+e)}function gv(e,t){switch(t){case qb.BIGINT:return e.toBigInt();case qb.NUMBER:return e.toNumber();default:return e.toString()}}class bv{constructor(e){this.info=e}prepare(){var e;if(void 0===this.fMap){this.fMap={};const t=null!==(e=this.info.fields)&&void 0!==e?e:[];for(const e of t)this.fMap[e.name]=e,this.fMap[e.jsonName]=e,this.fMap[e.localName]=e}}assert(e,t,n){if(!e){let e=Wb(n);throw"number"!=e&&"boolean"!=e||(e=n.toString()),new Error(`Cannot parse JSON ${e} for ${this.info.typeName}#${t}`)}}read(e,t,n){this.prepare();const r=[];for(const[i,o]of Object.entries(e)){const e=this.fMap[i];if(!e){if(!n.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${i}`);continue}const s=e.localName;let a;if(e.oneof){if(null===o&&("enum"!==e.kind||"google.protobuf.NullValue"!==e.T()[0]))continue;if(r.includes(e.oneof))throw new Error(`Multiple members of the oneof group "${e.oneof}" of ${this.info.typeName} are present in JSON.`);r.push(e.oneof),a=t[e.oneof]={oneofKind:s}}else a=t;if("map"==e.kind){if(null===o)continue;this.assert(Qb(o),e.name,o);const t=a[s];for(const[r,i]of Object.entries(o)){let o;switch(this.assert(null!==i,e.name+" map value",null),e.V.kind){case"message":o=e.V.T().internalJsonRead(i,n);break;case"enum":if(o=this.enum(e.V.T(),i,e.name,n.ignoreUnknownFields),!1===o)continue;break;case"scalar":o=this.scalar(i,e.V.T,e.V.L,e.name)}this.assert(void 0!==o,e.name+" map value",i);let s=r;e.K==Lb.BOOL&&(s="true"==s||"false"!=s&&s),s=this.scalar(s,e.K,qb.STRING,e.name).toString(),t[s]=o}}else if(e.repeat){if(null===o)continue;this.assert(Array.isArray(o),e.name,o);const t=a[s];for(const r of o){let i;switch(this.assert(null!==r,e.name,null),e.kind){case"message":i=e.T().internalJsonRead(r,n);break;case"enum":if(i=this.enum(e.T(),r,e.name,n.ignoreUnknownFields),!1===i)continue;break;case"scalar":i=this.scalar(r,e.T,e.L,e.name)}this.assert(void 0!==i,e.name,o),t.push(i)}}else switch(e.kind){case"message":if(null===o&&"google.protobuf.Value"!=e.T().typeName){this.assert(void 0===e.oneof,e.name+" (oneof member)",null);continue}a[s]=e.T().internalJsonRead(o,n,a[s]);break;case"enum":if(null===o)continue;let t=this.enum(e.T(),o,e.name,n.ignoreUnknownFields);if(!1===t)continue;a[s]=t;break;case"scalar":if(null===o)continue;a[s]=this.scalar(o,e.T,e.L,e.name)}}}enum(e,t,n,r){if("google.protobuf.NullValue"==e[0]&&dv(null===t||"NULL_VALUE"===t,`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} only accepts null.`),null===t)return 0;switch(typeof t){case"number":return dv(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${n}, enum can only be integral number, got ${t}.`),t;case"string":let i=t;e[2]&&t.substring(0,e[2].length)===e[2]&&(i=t.substring(e[2].length));let o=e[1][i];return(void 0!==o||!r)&&(dv("number"==typeof o,`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} has no value for "${t}".`),o)}dv(!1,`Unable to parse field ${this.info.typeName}#${n}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,n,r){let i;try{switch(t){case Lb.DOUBLE:case Lb.FLOAT:if(null===e)return 0;if("NaN"===e)return Number.NaN;if("Infinity"===e)return Number.POSITIVE_INFINITY;if("-Infinity"===e)return Number.NEGATIVE_INFINITY;if(""===e){i="empty string";break}if("string"==typeof e&&e.trim().length!==e.length){i="extra whitespace";break}if("string"!=typeof e&&"number"!=typeof e)break;let r=Number(e);if(Number.isNaN(r)){i="not a number";break}if(!Number.isFinite(r)){i="too large or small";break}return t==Lb.FLOAT&&mv(r),r;case Lb.INT32:case Lb.FIXED32:case Lb.SFIXED32:case Lb.SINT32:case Lb.UINT32:if(null===e)return 0;let o;if("number"==typeof e?o=e:""===e?i="empty string":"string"==typeof e&&(e.trim().length!==e.length?i="extra whitespace":o=Number(e)),void 0===o)break;return t==Lb.UINT32?yv(o):pv(o),o;case Lb.INT64:case Lb.SFIXED64:case Lb.SINT64:if(null===e)return gv(fv.ZERO,n);if("number"!=typeof e&&"string"!=typeof e)break;return gv(fv.from(e),n);case Lb.FIXED64:case Lb.UINT64:if(null===e)return gv(hv.ZERO,n);if("number"!=typeof e&&"string"!=typeof e)break;return gv(hv.from(e),n);case Lb.BOOL:if(null===e)return!1;if("boolean"!=typeof e)break;return e;case Lb.STRING:if(null===e)return"";if("string"!=typeof e){i="extra whitespace";break}try{encodeURIComponent(e)}catch(i){i="invalid UTF8";break}return e;case Lb.BYTES:if(null===e||""===e)return new Uint8Array(0);if("string"!=typeof e)break;return Jb(e)}}catch(e){i=e.message}this.assert(!1,r+(i?" - "+i:""),e)}}class vv{constructor(e){var t;this.fields=null!==(t=e.fields)&&void 0!==t?t:[]}write(e,t){const n={},r=e;for(const e of this.fields){if(!e.oneof){let i=this.field(e,r[e.localName],t);void 0!==i&&(n[t.useProtoFieldName?e.name:e.jsonName]=i);continue}const i=r[e.oneof];if(i.oneofKind!==e.localName)continue;const o="scalar"==e.kind||"enum"==e.kind?Object.assign(Object.assign({},t),{emitDefaultValues:!0}):t;let s=this.field(e,i[e.localName],o);dv(void 0!==s),n[t.useProtoFieldName?e.name:e.jsonName]=s}return n}field(e,t,n){let r;if("map"==e.kind){dv("object"==typeof t&&null!==t);const i={};switch(e.V.kind){case"scalar":for(const[n,r]of Object.entries(t)){const t=this.scalar(e.V.T,r,e.name,!1,!0);dv(void 0!==t),i[n.toString()]=t}break;case"message":const r=e.V.T();for(const[o,s]of Object.entries(t)){const t=this.message(r,s,e.name,n);dv(void 0!==t),i[o.toString()]=t}break;case"enum":const o=e.V.T();for(const[r,s]of Object.entries(t)){dv(void 0===s||"number"==typeof s);const t=this.enum(o,s,e.name,!1,!0,n.enumAsInteger);dv(void 0!==t),i[r.toString()]=t}}(n.emitDefaultValues||Object.keys(i).length>0)&&(r=i)}else if(e.repeat){dv(Array.isArray(t));const i=[];switch(e.kind){case"scalar":for(let n=0;n<t.length;n++){const r=this.scalar(e.T,t[n],e.name,e.opt,!0);dv(void 0!==r),i.push(r)}break;case"enum":const r=e.T();for(let o=0;o<t.length;o++){dv(void 0===t[o]||"number"==typeof t[o]);const s=this.enum(r,t[o],e.name,e.opt,!0,n.enumAsInteger);dv(void 0!==s),i.push(s)}break;case"message":const o=e.T();for(let r=0;r<t.length;r++){const s=this.message(o,t[r],e.name,n);dv(void 0!==s),i.push(s)}}(n.emitDefaultValues||i.length>0||n.emitDefaultValues)&&(r=i)}else switch(e.kind){case"scalar":r=this.scalar(e.T,t,e.name,e.opt,n.emitDefaultValues);break;case"enum":r=this.enum(e.T(),t,e.name,e.opt,n.emitDefaultValues,n.enumAsInteger);break;case"message":r=this.message(e.T(),t,e.name,n)}return r}enum(e,t,n,r,i,o){if("google.protobuf.NullValue"==e[0])return i||r?null:void 0;if(void 0!==t){if(0!==t||i||r)return dv("number"==typeof t),dv(Number.isInteger(t)),o||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}else dv(r)}message(e,t,n,r){return void 0===t?r.emitDefaultValues?null:void 0:e.internalJsonWrite(t,r)}scalar(e,t,n,r,i){if(void 0===t)return void dv(r);const o=i||r;switch(e){case Lb.INT32:case Lb.SFIXED32:case Lb.SINT32:return 0===t?o?0:void 0:(pv(t),t);case Lb.FIXED32:case Lb.UINT32:return 0===t?o?0:void 0:(yv(t),t);case Lb.FLOAT:mv(t);case Lb.DOUBLE:return 0===t?o?0:void 0:(dv("number"==typeof t),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case Lb.STRING:return""===t?o?"":void 0:(dv("string"==typeof t),t);case Lb.BOOL:return!1===t?!o&&void 0:(dv("boolean"==typeof t),t);case Lb.UINT64:case Lb.FIXED64:dv("number"==typeof t||"string"==typeof t||"bigint"==typeof t);let e=hv.from(t);if(e.isZero()&&!o)return;return e.toString();case Lb.INT64:case Lb.SFIXED64:case Lb.SINT64:dv("number"==typeof t||"string"==typeof t||"bigint"==typeof t);let n=fv.from(t);if(n.isZero()&&!o)return;return n.toString();case Lb.BYTES:return dv(t instanceof Uint8Array),t.byteLength?Zb(t):o?"":void 0}}}var wv,Ev;function kv(e,t){return Object.assign(Object.assign({},e),t)}function Sv(e,t=qb.STRING){switch(e){case Lb.BOOL:return!1;case Lb.UINT64:case Lb.FIXED64:return gv(hv.ZERO,t);case Lb.INT64:case Lb.SFIXED64:case Lb.SINT64:return gv(fv.ZERO,t);case Lb.DOUBLE:case Lb.FLOAT:return 0;case Lb.BYTES:return new Uint8Array(0);case Lb.STRING:return"";default:return 0}}!function(e){e.symbol=Symbol.for("protobuf-ts/unknown"),e.onRead=(n,r,i,o,s)=>{(t(r)?r[e.symbol]:r[e.symbol]=[]).push({no:i,wireType:o,data:s})},e.onWrite=(t,n,r)=>{for(let{no:t,wireType:i,data:o}of e.list(n))r.tag(t,i).raw(o)},e.list=(n,r)=>{if(t(n)){let t=n[e.symbol];return r?t.filter(e=>e.no==r):t}return[]},e.last=(t,n)=>e.list(t,n).slice(-1)[0];const t=t=>t&&Array.isArray(t[e.symbol])}(wv||(wv={})),function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"}(Ev||(Ev={}));class Tv{constructor(e){this.info=e}prepare(){var e;if(!this.fieldNoToField){const t=null!==(e=this.info.fields)&&void 0!==e?e:[];this.fieldNoToField=new Map(t.map(e=>[e.no,e]))}}read(e,t,n,r){this.prepare();const i=void 0===r?e.len:e.pos+r;for(;e.pos<i;){const[r,i]=e.tag(),o=this.fieldNoToField.get(r);if(!o){let o=n.readUnknownField;if("throw"==o)throw new Error(`Unknown field ${r} (wire type ${i}) for ${this.info.typeName}`);let s=e.skip(i);!1!==o&&(!0===o?wv.onRead:o)(this.info.typeName,t,r,i,s);continue}let s=t,a=o.repeat,u=o.localName;switch(o.oneof&&(s=s[o.oneof],s.oneofKind!==u&&(s=t[o.oneof]={oneofKind:u})),o.kind){case"scalar":case"enum":let t="enum"==o.kind?Lb.INT32:o.T,r="scalar"==o.kind?o.L:void 0;if(a){let n=s[u];if(i==Ev.LengthDelimited&&t!=Lb.STRING&&t!=Lb.BYTES){let i=e.uint32()+e.pos;for(;e.pos<i;)n.push(this.scalar(e,t,r))}else n.push(this.scalar(e,t,r))}else s[u]=this.scalar(e,t,r);break;case"message":if(a){let t=s[u],r=o.T().internalBinaryRead(e,e.uint32(),n);t.push(r)}else s[u]=o.T().internalBinaryRead(e,e.uint32(),n,s[u]);break;case"map":let[c,l]=this.mapEntry(o,e,n);s[u][c]=l}}}mapEntry(e,t,n){let r,i,o=t.uint32(),s=t.pos+o;for(;t.pos<s;){let[o,s]=t.tag();switch(o){case 1:r=e.K==Lb.BOOL?t.bool().toString():this.scalar(t,e.K,qb.STRING);break;case 2:switch(e.V.kind){case"scalar":i=this.scalar(t,e.V.T,e.V.L);break;case"enum":i=t.int32();break;case"message":i=e.V.T().internalBinaryRead(t,t.uint32(),n)}break;default:throw new Error(`Unknown field ${o} (wire type ${s}) in map entry for ${this.info.typeName}#${e.name}`)}}if(void 0===r){let t=Sv(e.K);r=e.K==Lb.BOOL?t.toString():t}if(void 0===i)switch(e.V.kind){case"scalar":i=Sv(e.V.T,e.V.L);break;case"enum":i=0;break;case"message":i=e.V.T().create()}return[r,i]}scalar(e,t,n){switch(t){case Lb.INT32:return e.int32();case Lb.STRING:return e.string();case Lb.BOOL:return e.bool();case Lb.DOUBLE:return e.double();case Lb.FLOAT:return e.float();case Lb.INT64:return gv(e.int64(),n);case Lb.UINT64:return gv(e.uint64(),n);case Lb.FIXED64:return gv(e.fixed64(),n);case Lb.FIXED32:return e.fixed32();case Lb.BYTES:return e.bytes();case Lb.UINT32:return e.uint32();case Lb.SFIXED32:return e.sfixed32();case Lb.SFIXED64:return gv(e.sfixed64(),n);case Lb.SINT32:return e.sint32();case Lb.SINT64:return gv(e.sint64(),n)}}}class _v{constructor(e){this.info=e}prepare(){if(!this.fields){const e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort((e,t)=>e.no-t.no)}}write(e,t,n){this.prepare();for(const r of this.fields){let i,o,s=r.repeat,a=r.localName;if(r.oneof){const t=e[r.oneof];if(t.oneofKind!==a)continue;i=t[a],o=!0}else i=e[a],o=!1;switch(r.kind){case"scalar":case"enum":let e="enum"==r.kind?Lb.INT32:r.T;if(s)if(dv(Array.isArray(i)),s==$b.PACKED)this.packed(t,e,r.no,i);else for(const n of i)this.scalar(t,e,r.no,n,!0);else void 0===i?dv(r.opt):this.scalar(t,e,r.no,i,o||r.opt);break;case"message":if(s){dv(Array.isArray(i));for(const e of i)this.message(t,n,r.T(),r.no,e)}else this.message(t,n,r.T(),r.no,i);break;case"map":dv("object"==typeof i&&null!==i);for(const[e,o]of Object.entries(i))this.mapEntry(t,n,r,e,o)}}let r=n.writeUnknownFields;!1!==r&&(!0===r?wv.onWrite:r)(this.info.typeName,e,t)}mapEntry(e,t,n,r,i){e.tag(n.no,Ev.LengthDelimited),e.fork();let o=r;switch(n.K){case Lb.INT32:case Lb.FIXED32:case Lb.UINT32:case Lb.SFIXED32:case Lb.SINT32:o=Number.parseInt(r);break;case Lb.BOOL:dv("true"==r||"false"==r),o="true"==r}switch(this.scalar(e,n.K,1,o,!0),n.V.kind){case"scalar":this.scalar(e,n.V.T,2,i,!0);break;case"enum":this.scalar(e,Lb.INT32,2,i,!0);break;case"message":this.message(e,t,n.V.T(),2,i)}e.join()}message(e,t,n,r,i){void 0!==i&&(n.internalBinaryWrite(i,e.tag(r,Ev.LengthDelimited).fork(),t),e.join())}scalar(e,t,n,r,i){let[o,s,a]=this.scalarInfo(t,r);a&&!i||(e.tag(n,o),e[s](r))}packed(e,t,n,r){if(!r.length)return;dv(t!==Lb.BYTES&&t!==Lb.STRING),e.tag(n,Ev.LengthDelimited),e.fork();let[,i]=this.scalarInfo(t);for(let t=0;t<r.length;t++)e[i](r[t]);e.join()}scalarInfo(e,t){let n,r=Ev.Varint,i=void 0===t,o=0===t;switch(e){case Lb.INT32:n="int32";break;case Lb.STRING:o=i||!t.length,r=Ev.LengthDelimited,n="string";break;case Lb.BOOL:o=!1===t,n="bool";break;case Lb.UINT32:n="uint32";break;case Lb.DOUBLE:r=Ev.Bit64,n="double";break;case Lb.FLOAT:r=Ev.Bit32,n="float";break;case Lb.INT64:o=i||fv.from(t).isZero(),n="int64";break;case Lb.UINT64:o=i||hv.from(t).isZero(),n="uint64";break;case Lb.FIXED64:o=i||hv.from(t).isZero(),r=Ev.Bit64,n="fixed64";break;case Lb.BYTES:o=i||!t.byteLength,r=Ev.LengthDelimited,n="bytes";break;case Lb.FIXED32:r=Ev.Bit32,n="fixed32";break;case Lb.SFIXED32:r=Ev.Bit32,n="sfixed32";break;case Lb.SFIXED64:o=i||fv.from(t).isZero(),r=Ev.Bit64,n="sfixed64";break;case Lb.SINT32:n="sint32";break;case Lb.SINT64:o=i||fv.from(t).isZero(),n="sint64"}return[r,n,i||o]}}function xv(e,t,n){let r,i,o=n;for(let n of e.fields){let e=n.localName;if(n.oneof){const s=o[n.oneof];if(null==(null==s?void 0:s.oneofKind))continue;if(r=s[e],i=t[n.oneof],i.oneofKind=s.oneofKind,null==r){delete i[e];continue}}else if(r=o[e],i=t,null==r)continue;switch(n.repeat&&(i[e].length=r.length),n.kind){case"scalar":case"enum":if(n.repeat)for(let t=0;t<r.length;t++)i[e][t]=r[t];else i[e]=r;break;case"message":let t=n.T();if(n.repeat)for(let n=0;n<r.length;n++)i[e][n]=t.create(r[n]);else void 0===i[e]?i[e]=t.create(r):t.mergePartial(i[e],r);break;case"map":switch(n.V.kind){case"scalar":case"enum":Object.assign(i[e],r);break;case"message":let t=n.V.T();for(let n of Object.keys(r))i[e][n]=t.create(r[n])}}}}const Ov={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},Iv={ignoreUnknownFields:!1};function Cv(e,t){var n,r;let i=Object.assign(Object.assign({},e),t);return i.typeRegistry=[...null!==(n=null==e?void 0:e.typeRegistry)&&void 0!==n?n:[],...null!==(r=null==t?void 0:t.typeRegistry)&&void 0!==r?r:[]],i}const Mv=Object.values;function Av(e,t,n){if(t===n)return!0;if(e!==Lb.BYTES)return!1;let r=t,i=n;if(r.length!==i.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!=i[e])return!1;return!0}function Nv(e,t,n){if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!Av(e,t[r],n[r]))return!1;return!0}function jv(e,t,n){if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e.equals(t[r],n[r]))return!1;return!0}const Dv={writeUnknownFields:!0,writerFactory:()=>new Rv};class Rv{constructor(e){this.stack=[],this.textEncoder=null!=e?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),n=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],n),n+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(yv(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return pv(e),rv(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){mv(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){yv(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){pv(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return pv(e),rv(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=fv.from(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=hv.from(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=fv.from(e);return Xb(t.lo,t.hi,this.buf),this}sint64(e){let t=fv.from(e),n=t.hi>>31;return Xb(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=hv.from(e);return Xb(t.lo,t.hi,this.buf),this}}const Pv={readUnknownField:!0,readerFactory:e=>new Bv(e)};class Bv{constructor(e,t){this.varint64=Yb,this.uint32=iv,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=null!=t?t:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let e=this.uint32(),t=e>>>3,n=7&e;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e){let t=this.pos;switch(e){case Ev.Varint:for(;128&this.buf[this.pos++];);break;case Ev.Bit64:this.pos+=4;case Ev.Bit32:this.pos+=4;break;case Ev.LengthDelimited:let t=this.uint32();this.pos+=t;break;case Ev.StartGroup:let n;for(;(n=this.tag()[1])!==Ev.EndGroup;)this.skip(n);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return new fv(...this.varint64())}uint64(){return new hv(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(1&e);return e=(e>>>1|(1&t)<<31)^n,t=t>>>1^n,new fv(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new hv(this.sfixed32(),this.sfixed32())}sfixed64(){return new fv(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}const Fv=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({})),Uv=Fv[Ub]={};class Lv{constructor(e,t,n){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(Vb),this.options=null!=n?n:{},Uv.value=this,this.messagePrototype=Object.create(null,Fv),this.refTypeCheck=new Kb(this),this.refJsonReader=new bv(this),this.refJsonWriter=new vv(this),this.refBinReader=new Tv(this),this.refBinWriter=new _v(this)}create(e){let t=function(e){const t=e.messagePrototype?Object.create(e.messagePrototype):Object.defineProperty({},Ub,{value:e});for(let n of e.fields){let e=n.localName;if(!n.opt)if(n.oneof)t[n.oneof]={oneofKind:void 0};else if(n.repeat)t[e]=[];else switch(n.kind){case"scalar":t[e]=Sv(n.T,n.L);break;case"enum":t[e]=0;break;case"map":t[e]={}}}return t}(this);return void 0!==e&&xv(this,t,e),t}clone(e){let t=this.create();return xv(this,t,e),t}equals(e,t){return function(e,t,n){if(t===n)return!0;if(!t||!n)return!1;for(let r of e.fields){let e=r.localName,i=r.oneof?t[r.oneof][e]:t[e],o=r.oneof?n[r.oneof][e]:n[e];switch(r.kind){case"enum":case"scalar":let e="enum"==r.kind?Lb.INT32:r.T;if(!(r.repeat?Nv(e,i,o):Av(e,i,o)))return!1;break;case"map":if(!("message"==r.V.kind?jv(r.V.T(),Mv(i),Mv(o)):Nv("enum"==r.V.kind?Lb.INT32:r.V.T,Mv(i),Mv(o))))return!1;break;case"message":let t=r.T();if(!(r.repeat?jv(t,i,o):t.equals(i,o)))return!1}}return!0}(this,e,t)}is(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!1)}isAssignable(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!0)}mergePartial(e,t){xv(this,e,t)}fromBinary(e,t){let n=function(e){return e?Object.assign(Object.assign({},Pv),e):Pv}(t);return this.internalBinaryRead(n.readerFactory(e),e.byteLength,n)}fromJson(e,t){return this.internalJsonRead(e,function(e){return e?Object.assign(Object.assign({},Iv),e):Iv}(t))}fromJsonString(e,t){let n=JSON.parse(e);return this.fromJson(n,t)}toJson(e,t){return this.internalJsonWrite(e,function(e){return e?Object.assign(Object.assign({},Ov),e):Ov}(t))}toJsonString(e,t){var n;let r=this.toJson(e,t);return JSON.stringify(r,null,null!==(n=null==t?void 0:t.prettySpaces)&&void 0!==n?n:0)}toBinary(e,t){let n=function(e){return e?Object.assign(Object.assign({},Dv),e):Dv}(t);return this.internalBinaryWrite(e,n.writerFactory(),n).finish()}internalJsonRead(e,t,n){if(null!==e&&"object"==typeof e&&!Array.isArray(e)){let r=null!=n?n:this.create();return this.refJsonReader.read(e,r,t),r}throw new Error(`Unable to parse message ${this.typeName} from JSON ${Wb(e)}.`)}internalJsonWrite(e,t){return this.refJsonWriter.write(e,t)}internalBinaryWrite(e,t,n){return this.refBinWriter.write(e,t,n),t}internalBinaryRead(e,t,n,r){let i=null!=r?r:this.create();return this.refBinReader.read(e,i,n,t),i}}function qv(e,t,n,r,i){var o,s,a,u;if("unary"==e){let e=(e,n,r)=>t.unary(e,n,r);for(const t of(null!==(o=r.interceptors)&&void 0!==o?o:[]).filter(e=>e.interceptUnary).reverse()){const n=e;e=(e,r,i)=>t.interceptUnary(n,e,r,i)}return e(n,i,r)}if("serverStreaming"==e){let e=(e,n,r)=>t.serverStreaming(e,n,r);for(const t of(null!==(s=r.interceptors)&&void 0!==s?s:[]).filter(e=>e.interceptServerStreaming).reverse()){const n=e;e=(e,r,i)=>t.interceptServerStreaming(n,e,r,i)}return e(n,i,r)}if("clientStreaming"==e){let e=(e,n)=>t.clientStreaming(e,n);for(const t of(null!==(a=r.interceptors)&&void 0!==a?a:[]).filter(e=>e.interceptClientStreaming).reverse()){const n=e;e=(e,r)=>t.interceptClientStreaming(n,e,r)}return e(n,r)}if("duplex"==e){let e=(e,n)=>t.duplex(e,n);for(const t of(null!==(u=r.interceptors)&&void 0!==u?u:[]).filter(e=>e.interceptDuplex).reverse()){const n=e;e=(e,r)=>t.interceptDuplex(n,e,r)}return e(n,r)}!function(e,t){throw new Error(null!=t?t:"Unexpected object: "+e)}(e)}function $v(e,t){if(!e)return;let n=t;for(let[t,r]of Object.entries(e))r instanceof Date?n[t]=new Date(r.getTime()):Array.isArray(r)?n[t]=r.concat():n[t]=r}class Vv extends Error{constructor(e,t="UNKNOWN",n){super(e),this.name="RpcError",Object.setPrototypeOf(this,new.target.prototype),this.code=t,this.meta=null!=n?n:{}}toString(){const e=[this.name+": "+this.message];this.code&&(e.push(""),e.push("Code: "+this.code)),this.serviceName&&this.methodName&&e.push("Method: "+this.serviceName+"/"+this.methodName);let t=Object.entries(this.meta);if(t.length){e.push(""),e.push("Meta:");for(let[n,r]of t)e.push(` ${n}: ${r}`)}return e.join("\n")}}var zv;!function(e){e[e.PENDING=0]="PENDING",e[e.REJECTED=1]="REJECTED",e[e.RESOLVED=2]="RESOLVED"}(zv||(zv={}));class Kv{constructor(e=!0){this._state=zv.PENDING,this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t}),e&&this._promise.catch(e=>{})}get state(){return this._state}get promise(){return this._promise}resolve(e){if(this.state!==zv.PENDING)throw new Error(`cannot resolve ${zv[this.state].toLowerCase()}`);this._resolve(e),this._state=zv.RESOLVED}reject(e){if(this.state!==zv.PENDING)throw new Error(`cannot reject ${zv[this.state].toLowerCase()}`);this._reject(e),this._state=zv.REJECTED}resolvePending(e){this._state===zv.PENDING&&this.resolve(e)}rejectPending(e){this._state===zv.PENDING&&this.reject(e)}}class Wv{constructor(){this._lis={nxt:[],msg:[],err:[],cmp:[]},this._closed=!1,this._itState={q:[]}}onNext(e){return this.addLis(e,this._lis.nxt)}onMessage(e){return this.addLis(e,this._lis.msg)}onError(e){return this.addLis(e,this._lis.err)}onComplete(e){return this.addLis(e,this._lis.cmp)}addLis(e,t){return t.push(e),()=>{let n=t.indexOf(e);n>=0&&t.splice(n,1)}}clearLis(){for(let e of Object.values(this._lis))e.splice(0,e.length)}get closed(){return!1!==this._closed}notifyNext(e,t,n){dv((e?1:0)+(t?1:0)+(n?1:0)<=1,"only one emission at a time"),e&&this.notifyMessage(e),t&&this.notifyError(t),n&&this.notifyComplete()}notifyMessage(e){dv(!this.closed,"stream is closed"),this.pushIt({value:e,done:!1}),this._lis.msg.forEach(t=>t(e)),this._lis.nxt.forEach(t=>t(e,void 0,!1))}notifyError(e){dv(!this.closed,"stream is closed"),this._closed=e,this.pushIt(e),this._lis.err.forEach(t=>t(e)),this._lis.nxt.forEach(t=>t(void 0,e,!1)),this.clearLis()}notifyComplete(){dv(!this.closed,"stream is closed"),this._closed=!0,this.pushIt({value:null,done:!0}),this._lis.cmp.forEach(e=>e()),this._lis.nxt.forEach(e=>e(void 0,void 0,!0)),this.clearLis()}[Symbol.asyncIterator](){return!0===this._closed?this.pushIt({value:null,done:!0}):!1!==this._closed&&this.pushIt(this._closed),{next:()=>{let e=this._itState;dv(e,"bad state"),dv(!e.p,"iterator contract broken");let t=e.q.shift();return t?"value"in t?Promise.resolve(t):Promise.reject(t):(e.p=new Kv,e.p.promise)}}}pushIt(e){let t=this._itState;if(t.p){const n=t.p;dv(n.state==zv.PENDING,"iterator contract broken"),"value"in e?n.resolve(e):n.reject(e),delete t.p}else t.q.push(e)}}var Qv=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof n?e:new n(function(t){t(e)})}(e.value).then(s,a)}u((r=r.apply(e,t||[])).next())})};class Gv{constructor(e,t,n,r,i,o,s){this.method=e,this.requestHeaders=t,this.request=n,this.headers=r,this.responses=i,this.status=o,this.trailers=s}then(e,t){return this.promiseFinished().then(t=>e?Promise.resolve(e(t)):t,e=>t?Promise.resolve(t(e)):Promise.reject(e))}promiseFinished(){return Qv(this,void 0,void 0,function*(){let[e,t,n]=yield Promise.all([this.headers,this.status,this.trailers]);return{method:this.method,requestHeaders:this.requestHeaders,request:this.request,headers:e,status:t,trailers:n}})}}var Hv,Jv=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof n?e:new n(function(t){t(e)})}(e.value).then(s,a)}u((r=r.apply(e,t||[])).next())})};class Zv{constructor(e,t,n,r,i,o,s){this.method=e,this.requestHeaders=t,this.request=n,this.headers=r,this.response=i,this.status=o,this.trailers=s}then(e,t){return this.promiseFinished().then(t=>e?Promise.resolve(e(t)):t,e=>t?Promise.resolve(t(e)):Promise.reject(e))}promiseFinished(){return Jv(this,void 0,void 0,function*(){let[e,t,n,r]=yield Promise.all([this.headers,this.response,this.status,this.trailers]);return{method:this.method,requestHeaders:this.requestHeaders,request:this.request,headers:e,response:t,status:n,trailers:r}})}}!function(e){e[e.OK=0]="OK",e[e.CANCELLED=1]="CANCELLED",e[e.UNKNOWN=2]="UNKNOWN",e[e.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",e[e.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",e[e.NOT_FOUND=5]="NOT_FOUND",e[e.ALREADY_EXISTS=6]="ALREADY_EXISTS",e[e.PERMISSION_DENIED=7]="PERMISSION_DENIED",e[e.UNAUTHENTICATED=16]="UNAUTHENTICATED",e[e.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",e[e.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",e[e.ABORTED=10]="ABORTED",e[e.OUT_OF_RANGE=11]="OUT_OF_RANGE",e[e.UNIMPLEMENTED=12]="UNIMPLEMENTED",e[e.INTERNAL=13]="INTERNAL",e[e.UNAVAILABLE=14]="UNAVAILABLE",e[e.DATA_LOSS=15]="DATA_LOSS"}(Hv||(Hv={}));var Yv,Xv=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof n?e:new n(function(t){t(e)})}(e.value).then(s,a)}u((r=r.apply(e,t||[])).next())})};function ew(e,t,n,r,i){if(r)for(let[t,n]of Object.entries(r))if("string"==typeof n)e.append(t,n);else for(let r of n)e.append(t,r);if(e.set("Content-Type","text"===t?"application/grpc-web-text":"application/grpc-web+proto"),"text"==t&&e.set("Accept","application/grpc-web-text"),e.set("X-Grpc-Web","1"),i&&e.set("X-User-Agent",i),"number"==typeof n){if(n<=0)throw new Vv(`timeout ${n} ms exceeded`,Hv[Hv.DEADLINE_EXCEEDED]);e.set("grpc-timeout",`${n}m`)}else if(n){const t=n.getTime(),r=Date.now();if(t<=r)throw new Vv(`deadline ${n} exceeded`,Hv[Hv.DEADLINE_EXCEEDED]);e.set("grpc-timeout",t-r+"m")}return e}function tw(e,t){let n=new Uint8Array(5+e.length);n[0]=Yv.DATA;for(let t=e.length,r=4;r>0;r--)n[r]=t%256,t>>>=8;return n.set(e,5),"binary"===t?n:Zb(n)}function nw(e,t,n){if(1===arguments.length){let t,n=e;try{t=n.type}catch(e){}switch(t){case"error":case"opaque":case"opaqueredirect":throw new Vv(`fetch response type ${n.type}`,Hv[Hv.UNKNOWN])}return nw(function(e){let t={};return e.forEach((e,n)=>{let r=t[n];"string"==typeof r?t[n]=[r,e]:Array.isArray(r)?r.push(e):t[n]=e}),t}(n.headers),n.status,n.statusText)}let r=e,i=t>=200&&t<300,o=uw(r),[s,a]=aw(r);return void 0!==s&&s!==Hv.OK||i||(s=function(e){switch(e){case 200:return Hv.OK;case 400:return Hv.INVALID_ARGUMENT;case 401:return Hv.UNAUTHENTICATED;case 403:return Hv.PERMISSION_DENIED;case 404:return Hv.NOT_FOUND;case 409:return Hv.ABORTED;case 412:return Hv.FAILED_PRECONDITION;case 429:return Hv.RESOURCE_EXHAUSTED;case 499:return Hv.CANCELLED;case 500:default:return Hv.UNKNOWN;case 501:return Hv.UNIMPLEMENTED;case 503:return Hv.UNAVAILABLE;case 504:return Hv.DEADLINE_EXCEEDED}}(t),a=n),[s,a,o]}function rw(e){let t=function(e){let t={};for(let n of String.fromCharCode.apply(String,e).trim().split("\r\n")){if(""==n)continue;let[e,...r]=n.split(":");const i=r.join(":").trim();e=e.trim();let o=t[e];"string"==typeof o?t[e]=[o,i]:Array.isArray(o)?o.push(i):t[e]=i}return t}(e),[n,r]=aw(t),i=uw(t);return[null!=n?n:Hv.OK,r,i]}function iw(e,t,n){return Xv(this,void 0,void 0,function*(){let r,i="",o=new Uint8Array(0),s=function(e){switch(e){case"application/grpc-web-text":case"application/grpc-web-text+proto":return"text";case"application/grpc-web":case"application/grpc-web+proto":return"binary";case void 0:case null:throw new Vv("missing response content type",Hv[Hv.INTERNAL]);default:throw new Vv("unexpected response content type: "+e,Hv[Hv.INTERNAL])}}(t);if(ow(e)){let t=e.getReader();r={next:()=>t.read()}}else r=e[Symbol.asyncIterator]();for(;;){let e=yield r.next();if(void 0!==e.value){if("text"===s){for(let t=0;t<e.value.length;t++)i+=String.fromCharCode(e.value[t]);let t=i.length-i.length%4;if(0===t)continue;o=sw(o,Jb(i.substring(0,t))),i=i.substring(t)}else o=sw(o,e.value);for(;o.length>=5&&o[0]===Yv.DATA;){let e=0;for(let t=1;t<5;t++)e=(e<<8)+o[t];if(!(o.length-5>=e))break;n(Yv.DATA,o.subarray(5,5+e)),o=o.subarray(5+e)}}if(e.done){if(0===o.length)break;if(o[0]!==Yv.TRAILER||o.length<5)throw new Vv("premature EOF",Hv[Hv.DATA_LOSS]);n(Yv.TRAILER,o.subarray(5));break}}})}!function(e){e[e.DATA=0]="DATA",e[e.TRAILER=128]="TRAILER"}(Yv||(Yv={}));const ow=e=>"function"==typeof e.getReader;function sw(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function aw(e){let t,n,r=e["grpc-message"];if(void 0!==r){if(Array.isArray(r))return[Hv.INTERNAL,"invalid grpc-web message"];n=r}let i=e["grpc-status"];if(void 0!==i){if(Array.isArray(i))return[Hv.INTERNAL,"invalid grpc-web status"];if(t=parseInt(i,10),void 0===Hv[t])return[Hv.INTERNAL,"invalid grpc-web status"]}return[t,n]}function uw(e){let t={};for(let[n,r]of Object.entries(e))switch(n){case"grpc-message":case"grpc-status":case"content-type":break;default:t[n]=r}return t}class cw{constructor(e){this.defaultOptions=e}mergeOptions(e){return function(e,t){if(!t)return e;let n={};$v(e,n),$v(t,n);for(let r of Object.keys(t)){let i=t[r];switch(r){case"jsonOptions":n.jsonOptions=Cv(e.jsonOptions,n.jsonOptions);break;case"binaryOptions":n.binaryOptions=kv(e.binaryOptions,n.binaryOptions);break;case"meta":n.meta={},$v(e.meta,n.meta),$v(t.meta,n.meta);break;case"interceptors":n.interceptors=e.interceptors?e.interceptors.concat(i):i.concat()}}return n}(this.defaultOptions,e)}makeUrl(e,t){let n=t.baseUrl;return n.endsWith("/")&&(n=n.substring(0,n.length-1)),`${n}/${e.service.typeName}/${e.name}`}clientStreaming(e){const t=new Vv("Client streaming is not supported by grpc-web",Hv[Hv.UNIMPLEMENTED]);throw t.methodName=e.name,t.serviceName=e.service.typeName,t}duplex(e){const t=new Vv("Duplex streaming is not supported by grpc-web",Hv[Hv.UNIMPLEMENTED]);throw t.methodName=e.name,t.serviceName=e.service.typeName,t}serverStreaming(e,t,n){var r,i,o,s,a;let u,c,l=n,h=null!==(r=l.format)&&void 0!==r?r:"text",f=null!==(i=l.fetch)&&void 0!==i?i:globalThis.fetch,d=null!==(o=l.fetchInit)&&void 0!==o?o:{},p=this.makeUrl(e,l),y=e.I.toBinary(t,l.binaryOptions),m=new Kv,g=new Wv,b=!0,v=new Kv,w=new Kv;return f(p,Object.assign(Object.assign({},d),{method:"POST",headers:ew(new globalThis.Headers,h,l.timeout,l.meta),body:tw(y,h),signal:null!==(s=n.abort)&&void 0!==s?s:null})).then(e=>{let[t,n,r]=nw(e);if(m.resolve(r),null!=t&&t!==Hv.OK)throw new Vv(null!=n?n:Hv[t],Hv[t],r);return null!=t&&(u={code:Hv[t],detail:null!=n?n:Hv[t]}),e}).then(t=>{if(!t.body)throw new Vv("missing response body",Hv[Hv.INTERNAL]);return iw(t.body,t.headers.get("content-type"),(t,n)=>{switch(t){case Yv.DATA:g.notifyMessage(e.O.fromBinary(n,l.binaryOptions)),b=!1;break;case Yv.TRAILER:let t,r;[t,r,c]=rw(n),u={code:Hv[t],detail:null!=r?r:Hv[t]}}})}).then(()=>{if(!c&&!b)throw new Vv("missing trailers",Hv[Hv.DATA_LOSS]);if(!u)throw new Vv("missing status",Hv[Hv.INTERNAL]);if("OK"!==u.code)throw new Vv(u.detail,u.code,c);g.notifyComplete(),v.resolve(u),w.resolve(c||{})}).catch(t=>{let n;n=t instanceof Vv?t:t instanceof Error&&"AbortError"===t.name?new Vv(t.message,Hv[Hv.CANCELLED]):new Vv(t instanceof Error?t.message:""+t,Hv[Hv.INTERNAL]),n.methodName=e.name,n.serviceName=e.service.typeName,m.rejectPending(n),g.notifyError(n),v.rejectPending(n),w.rejectPending(n)}),new Gv(e,null!==(a=l.meta)&&void 0!==a?a:{},t,m.promise,g,v.promise,w.promise)}unary(e,t,n){var r,i,o,s,a;let u,c,l,h=n,f=null!==(r=h.format)&&void 0!==r?r:"text",d=null!==(i=h.fetch)&&void 0!==i?i:globalThis.fetch,p=null!==(o=h.fetchInit)&&void 0!==o?o:{},y=this.makeUrl(e,h),m=e.I.toBinary(t,h.binaryOptions),g=new Kv,b=new Kv,v=new Kv,w=new Kv;return d(y,Object.assign(Object.assign({},p),{method:"POST",headers:ew(new globalThis.Headers,f,h.timeout,h.meta),body:tw(m,f),signal:null!==(s=n.abort)&&void 0!==s?s:null})).then(e=>{let[t,n,r]=nw(e);if(g.resolve(r),null!=t&&t!==Hv.OK)throw new Vv(null!=n?n:Hv[t],Hv[t],r);return null!=t&&(c={code:Hv[t],detail:null!=n?n:Hv[t]}),e}).then(t=>{if(!t.body)throw new Vv("missing response body",Hv[Hv.INTERNAL]);return iw(t.body,t.headers.get("content-type"),(t,n)=>{switch(t){case Yv.DATA:if(u)throw new Vv("unary call received 2nd message",Hv[Hv.DATA_LOSS]);u=e.O.fromBinary(n,h.binaryOptions);break;case Yv.TRAILER:let t,r;[t,r,l]=rw(n),c={code:Hv[t],detail:null!=r?r:Hv[t]}}})}).then(()=>{if(!l&&u)throw new Vv("missing trailers",Hv[Hv.DATA_LOSS]);if(!c)throw new Vv("missing status",Hv[Hv.INTERNAL]);if(!u&&"OK"===c.code)throw new Vv("expected error status",Hv[Hv.DATA_LOSS]);if(!u)throw new Vv(c.detail,c.code,l);if(b.resolve(u),"OK"!==c.code)throw new Vv(c.detail,c.code,l);v.resolve(c),w.resolve(l||{})}).catch(t=>{let n;n=t instanceof Vv?t:t instanceof Error&&"AbortError"===t.name?new Vv(t.message,Hv[Hv.CANCELLED]):new Vv(t instanceof Error?t.message:""+t,Hv[Hv.INTERNAL]),n.methodName=e.name,n.serviceName=e.service.typeName,g.rejectPending(n),b.rejectPending(n),v.rejectPending(n),w.rejectPending(n)}),new Zv(e,null!==(a=h.meta)&&void 0!==a?a:{},t,g.promise,b.promise,v.promise,w.promise)}}var lw=(e=>(e[e.NULL_VALUE=0]="NULL_VALUE",e))(lw||{}),hw=new class extends Lv{constructor(){super("google.protobuf.Struct",[{no:1,name:"fields",kind:"map",K:9,V:{kind:"message",T:()=>fw}}])}internalJsonWrite(e,t){let n={};for(let[t,r]of Object.entries(e.fields))n[t]=fw.toJson(r);return n}internalJsonRead(e,t,n){if(!Qb(e))throw new globalThis.Error("Unable to parse message "+this.typeName+" from JSON "+Wb(e)+".");n||(n=this.create());for(let[t,r]of globalThis.Object.entries(e))n.fields[t]=fw.fromJson(r);return n}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.fields={},void 0!==e&&xv(this,t,e),t}internalBinaryRead(e,t,n,r){let i=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[t,r]=e.tag();if(1===t)this.binaryReadMap1(i.fields,e,n);else{let o=n.readUnknownField;if("throw"===o)throw new globalThis.Error(`Unknown field ${t} (wire type ${r}) for ${this.typeName}`);let s=e.skip(r);!1!==o&&(!0===o?wv.onRead:o)(this.typeName,i,t,r,s)}}return i}binaryReadMap1(e,t,n){let r,i,o=t.uint32(),s=t.pos+o;for(;t.pos<s;){let[e,o]=t.tag();switch(e){case 1:r=t.string();break;case 2:i=fw.internalBinaryRead(t,t.uint32(),n);break;default:throw new globalThis.Error("unknown map entry field for google.protobuf.Struct.fields")}}e[r??""]=i??fw.create()}internalBinaryWrite(e,t,n){for(let r of globalThis.Object.keys(e.fields))t.tag(1,Ev.LengthDelimited).fork().tag(1,Ev.LengthDelimited).string(r),t.tag(2,Ev.LengthDelimited).fork(),fw.internalBinaryWrite(e.fields[r],t,n),t.join().join();let r=n.writeUnknownFields;return!1!==r&&(1==r?wv.onWrite:r)(this.typeName,e,t),t}},fw=new class extends Lv{constructor(){super("google.protobuf.Value",[{no:1,name:"null_value",kind:"enum",oneof:"kind",T:()=>["google.protobuf.NullValue",lw]},{no:2,name:"number_value",kind:"scalar",oneof:"kind",T:1},{no:3,name:"string_value",kind:"scalar",oneof:"kind",T:9},{no:4,name:"bool_value",kind:"scalar",oneof:"kind",T:8},{no:5,name:"struct_value",kind:"message",oneof:"kind",T:()=>hw},{no:6,name:"list_value",kind:"message",oneof:"kind",T:()=>dw}])}internalJsonWrite(e,t){if(void 0===e.kind.oneofKind)throw new globalThis.Error;switch(e.kind.oneofKind){case void 0:throw new globalThis.Error;case"boolValue":return e.kind.boolValue;case"nullValue":return null;case"numberValue":let t=e.kind.numberValue;if("number"==typeof t&&!Number.isFinite(t))throw new globalThis.Error;return t;case"stringValue":return e.kind.stringValue;case"listValue":let n=this.fields.find(e=>6===e.no);if("message"!==n?.kind)throw new globalThis.Error;return n.T().toJson(e.kind.listValue);case"structValue":let r=this.fields.find(e=>5===e.no);if("message"!==r?.kind)throw new globalThis.Error;return r.T().toJson(e.kind.structValue)}}internalJsonRead(e,t,n){switch(n||(n=this.create()),typeof e){case"number":n.kind={oneofKind:"numberValue",numberValue:e};break;case"string":n.kind={oneofKind:"stringValue",stringValue:e};break;case"boolean":n.kind={oneofKind:"boolValue",boolValue:e};break;case"object":null===e?n.kind={oneofKind:"nullValue",nullValue:0}:globalThis.Array.isArray(e)?n.kind={oneofKind:"listValue",listValue:dw.fromJson(e)}:n.kind={oneofKind:"structValue",structValue:hw.fromJson(e)};break;default:throw new globalThis.Error("Unable to parse "+this.typeName+" from JSON "+Wb(e))}return n}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.kind={oneofKind:void 0},void 0!==e&&xv(this,t,e),t}internalBinaryRead(e,t,n,r){let i=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[t,r]=e.tag();switch(t){case 1:i.kind={oneofKind:"nullValue",nullValue:e.int32()};break;case 2:i.kind={oneofKind:"numberValue",numberValue:e.double()};break;case 3:i.kind={oneofKind:"stringValue",stringValue:e.string()};break;case 4:i.kind={oneofKind:"boolValue",boolValue:e.bool()};break;case 5:i.kind={oneofKind:"structValue",structValue:hw.internalBinaryRead(e,e.uint32(),n,i.kind.structValue)};break;case 6:i.kind={oneofKind:"listValue",listValue:dw.internalBinaryRead(e,e.uint32(),n,i.kind.listValue)};break;default:let o=n.readUnknownField;if("throw"===o)throw new globalThis.Error(`Unknown field ${t} (wire type ${r}) for ${this.typeName}`);let s=e.skip(r);!1!==o&&(!0===o?wv.onRead:o)(this.typeName,i,t,r,s)}}return i}internalBinaryWrite(e,t,n){"nullValue"===e.kind.oneofKind&&t.tag(1,Ev.Varint).int32(e.kind.nullValue),"numberValue"===e.kind.oneofKind&&t.tag(2,Ev.Bit64).double(e.kind.numberValue),"stringValue"===e.kind.oneofKind&&t.tag(3,Ev.LengthDelimited).string(e.kind.stringValue),"boolValue"===e.kind.oneofKind&&t.tag(4,Ev.Varint).bool(e.kind.boolValue),"structValue"===e.kind.oneofKind&&hw.internalBinaryWrite(e.kind.structValue,t.tag(5,Ev.LengthDelimited).fork(),n).join(),"listValue"===e.kind.oneofKind&&dw.internalBinaryWrite(e.kind.listValue,t.tag(6,Ev.LengthDelimited).fork(),n).join();let r=n.writeUnknownFields;return!1!==r&&(1==r?wv.onWrite:r)(this.typeName,e,t),t}},dw=new class extends Lv{constructor(){super("google.protobuf.ListValue",[{no:1,name:"values",kind:"message",repeat:2,T:()=>fw}])}internalJsonWrite(e,t){return e.values.map(e=>fw.toJson(e))}internalJsonRead(e,t,n){if(!globalThis.Array.isArray(e))throw new globalThis.Error("Unable to parse "+this.typeName+" from JSON "+Wb(e));n||(n=this.create());let r=e.map(e=>fw.fromJson(e));return n.values.push(...r),n}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.values=[],void 0!==e&&xv(this,t,e),t}internalBinaryRead(e,t,n,r){let i=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[t,r]=e.tag();if(1===t)i.values.push(fw.internalBinaryRead(e,e.uint32(),n));else{let o=n.readUnknownField;if("throw"===o)throw new globalThis.Error(`Unknown field ${t} (wire type ${r}) for ${this.typeName}`);let s=e.skip(r);!1!==o&&(!0===o?wv.onRead:o)(this.typeName,i,t,r,s)}}return i}internalBinaryWrite(e,t,n){for(let r=0;r<e.values.length;r++)fw.internalBinaryWrite(e.values[r],t.tag(1,Ev.LengthDelimited).fork(),n).join();let r=n.writeUnknownFields;return!1!==r&&(1==r?wv.onWrite:r)(this.typeName,e,t),t}},pw=(e=>(e[e.EQUALS=0]="EQUALS",e[e.NOT_EQUALS=1]="NOT_EQUALS",e[e.GREATER_THAN=2]="GREATER_THAN",e[e.GREATER_THAN_EQUAL=3]="GREATER_THAN_EQUAL",e[e.LESS_THAN=4]="LESS_THAN",e[e.LESS_THAN_EQUAL=5]="LESS_THAN_EQUAL",e[e.LIKE=6]="LIKE",e[e.NOT_LIKE=7]="NOT_LIKE",e[e.IN=8]="IN",e[e.NOT_IN=9]="NOT_IN",e[e.IS_NULL=10]="IS_NULL",e[e.IS_NOT_NULL=11]="IS_NOT_NULL",e[e.BETWEEN=12]="BETWEEN",e[e.NOT_BETWEEN=13]="NOT_BETWEEN",e))(pw||{}),yw=(e=>(e[e.ASCENDING=0]="ASCENDING",e[e.DESCENDING=1]="DESCENDING",e))(yw||{}),mw=new class extends Lv{constructor(){super("dubhe_grpc.QueryRequest",[{no:1,name:"table_name",kind:"scalar",T:9},{no:2,name:"select_fields",kind:"scalar",repeat:2,T:9},{no:3,name:"filters",kind:"message",repeat:2,T:()=>gw},{no:4,name:"sorts",kind:"message",repeat:2,T:()=>kw},{no:5,name:"pagination",kind:"message",T:()=>Sw},{no:6,name:"include_total_count",kind:"scalar",T:8}])}},gw=new class extends Lv{constructor(){super("dubhe_grpc.FilterCondition",[{no:1,name:"field_name",kind:"scalar",T:9},{no:2,name:"operator",kind:"enum",T:()=>["dubhe_grpc.FilterOperator",pw]},{no:3,name:"value",kind:"message",T:()=>bw}])}},bw=new class extends Lv{constructor(){super("dubhe_grpc.FilterValue",[{no:1,name:"string_value",kind:"scalar",oneof:"value",T:9},{no:2,name:"int_value",kind:"scalar",oneof:"value",T:3,L:0},{no:3,name:"float_value",kind:"scalar",oneof:"value",T:1},{no:4,name:"bool_value",kind:"scalar",oneof:"value",T:8},{no:5,name:"string_list",kind:"message",oneof:"value",T:()=>vw},{no:6,name:"int_list",kind:"message",oneof:"value",T:()=>ww},{no:7,name:"range",kind:"message",oneof:"value",T:()=>Ew},{no:8,name:"null_value",kind:"scalar",oneof:"value",T:8}])}},vw=new class extends Lv{constructor(){super("dubhe_grpc.StringList",[{no:1,name:"values",kind:"scalar",repeat:2,T:9}])}},ww=new class extends Lv{constructor(){super("dubhe_grpc.IntList",[{no:1,name:"values",kind:"scalar",repeat:1,T:3,L:0}])}},Ew=new class extends Lv{constructor(){super("dubhe_grpc.ValueRange",[{no:1,name:"string_start",kind:"scalar",oneof:"start",T:9},{no:2,name:"int_start",kind:"scalar",oneof:"start",T:3,L:0},{no:3,name:"float_start",kind:"scalar",oneof:"start",T:1},{no:4,name:"string_end",kind:"scalar",oneof:"end",T:9},{no:5,name:"int_end",kind:"scalar",oneof:"end",T:3,L:0},{no:6,name:"float_end",kind:"scalar",oneof:"end",T:1}])}},kw=new class extends Lv{constructor(){super("dubhe_grpc.SortSpecification",[{no:1,name:"field_name",kind:"scalar",T:9},{no:2,name:"direction",kind:"enum",T:()=>["dubhe_grpc.SortDirection",yw]},{no:3,name:"priority",kind:"scalar",opt:!0,T:5}])}},Sw=new class extends Lv{constructor(){super("dubhe_grpc.PaginationRequest",[{no:1,name:"page",kind:"scalar",T:5},{no:2,name:"page_size",kind:"scalar",T:5},{no:3,name:"offset",kind:"scalar",opt:!0,T:5}])}},Tw=new class extends Lv{constructor(){super("dubhe_grpc.QueryResponse",[{no:1,name:"rows",kind:"message",repeat:2,T:()=>hw},{no:2,name:"pagination",kind:"message",T:()=>_w}])}},_w=new class extends Lv{constructor(){super("dubhe_grpc.PaginationResponse",[{no:1,name:"current_page",kind:"scalar",T:5},{no:2,name:"page_size",kind:"scalar",T:5},{no:3,name:"total_items",kind:"scalar",T:3,L:0},{no:4,name:"total_pages",kind:"scalar",T:5},{no:5,name:"has_next_page",kind:"scalar",T:8},{no:6,name:"has_previous_page",kind:"scalar",T:8}])}},xw=new class extends Lv{constructor(){super("dubhe_grpc.SubscribeRequest",[{no:1,name:"table_ids",kind:"scalar",repeat:2,T:9}])}},Ow=new class extends Lv{constructor(){super("dubhe_grpc.TableChange",[{no:1,name:"table_id",kind:"scalar",T:9},{no:2,name:"data",kind:"message",T:()=>hw}])}},Iw=new class{constructor(e,t,n){this.typeName=e,this.methods=t.map(e=>function(e,t){var n,r,i;let o=e;return o.service=t,o.localName=null!==(n=o.localName)&&void 0!==n?n:Fb(o.name),o.serverStreaming=!!o.serverStreaming,o.clientStreaming=!!o.clientStreaming,o.options=null!==(r=o.options)&&void 0!==r?r:{},o.idempotency=null!==(i=o.idempotency)&&void 0!==i?i:void 0,o}(e,this)),this.options=null!=n?n:{}}}("dubhe_grpc.DubheGrpc",[{name:"QueryTable",options:{},I:mw,O:Tw},{name:"SubscribeTable",serverStreaming:!0,options:{},I:xw,O:Ow}]),Cw=class{constructor(e){this._transport=e,this.typeName=Iw.typeName,this.methods=Iw.methods,this.options=Iw.options}queryTable(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return qv("unary",this._transport,n,r,e)}subscribeTable(e,t){const n=this.methods[1],r=this._transport.mergeOptions(t);return qv("serverStreaming",this._transport,n,r,e)}};var Mw=class{constructor(e){this.currentOptions=e,this.dubheGrpcClient=new Cw(new cw(e))}updateConfig(e){this.currentOptions={...this.currentOptions,...e},this.dubheGrpcClient=new Cw(new cw(this.currentOptions))}};function Aw(e){if(!e.network)throw new Error("ClientConfig: network is required");if(!e.packageId)throw new Error("ClientConfig: packageId is required");if(!e.metadata)throw new Error("ClientConfig: metadata is required");const t=new wl({networkType:e.network,packageId:e.packageId,metadata:e.metadata,secretKey:e.credentials?.secretKey,mnemonics:e.credentials?.mnemonics,fullnodeUrls:e.endpoints?.fullnodeUrls,channelUrl:e.endpoints?.channelUrl,dappStorageId:e.dappStorageId,frameworkPackageId:e.frameworkPackageId}),n=function(e){return new wb(e)}({endpoint:e.endpoints?.graphql||"http://localhost:4000/graphql",subscriptionEndpoint:e.endpoints?.websocket||"ws://localhost:4000/graphql",dubheMetadata:e.dubheMetadata}),r=new Mw({baseUrl:e.endpoints?.grpc||"http://localhost:8080"}),i=function(e,t){return new Bb(e,t)}(n,{dubheMetadata:e.dubheMetadata,queryConfig:{enableBatchOptimization:e.options?.enableBatchOptimization??!0,defaultCacheTimeout:e.options?.cacheTimeout??5e3},subscriptionConfig:{defaultDebounceMs:e.options?.debounceMs??100,reconnectOnError:e.options?.reconnectOnError??!0}}),o=t.getAddress();return{contract:t,graphqlClient:n,grpcClient:r,ecsWorld:i,metadata:e.metadata,network:e.network,packageId:e.packageId,dappHubId:e.dappHubId,dappStorageId:e.dappStorageId,frameworkPackageId:e.frameworkPackageId,address:o,options:e.options}}function Nw(e){return["mainnet","testnet","devnet","localnet"].includes(e)}function jw(e){if(!e.network)throw new Error("ClientConfig validation failed: network is required");if(!Nw(e.network))throw new Error(`ClientConfig validation failed: invalid network type "${e.network}". Must be one of: mainnet, testnet, devnet, localnet`);if(!e.packageId)throw new Error("ClientConfig validation failed: packageId is required");if("string"!=typeof e.packageId||""===e.packageId.trim())throw new Error("ClientConfig validation failed: packageId must be a non-empty string");if(!e.metadata)throw new Error("ClientConfig validation failed: metadata is required")}function Dw(e){return jw(e),Aw(e)}})(),r})());
|
|
218
218
|
//# sourceMappingURL=obelisk-client.min.js.map
|