diff --git a/dist/index.js b/dist/index.js index 1792c6a6..c1ecaa76 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(t=>(()=>{"use strict";var e={764:(t,e,r)=>{const n=r(238),o=r(665),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const a=2147483647;function c(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=c(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=c(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?c(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),c(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=c(e);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return V(t).length;default:if(o)return n?-1:z(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,c=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,c/=2,u/=2,r/=2}function s(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;ic&&(r=c-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,c,u;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],c=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&c)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&c,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const c=Math.min(i,a),s=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function _(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function T(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){D(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){J(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||_(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||_(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||_(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||_(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||_(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||_(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||_(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return T(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);_(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);_(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||_(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||_(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||_(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||_(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||_(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return T(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function D(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new M.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){J(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||$(e,t.length-(r+1))}(n,o,i)}function J(t,e){if("number"!=typeof t)throw new M.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,r){if(Math.floor(t)!==t)throw J(t,r),new M.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new M.ERR_BUFFER_OUT_OF_BOUNDS;throw new M.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),q("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=G(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=G(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const K=/[^+/0-9A-Za-z-_]/g;function z(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function V(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(K,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function W(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},238:t=>{t.exports=require("base64-js")},665:t=>{t.exports=require("ieee754")},359:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{CommitButton:()=>ln,EthersProviderContext:()=>_n,Widget:()=>pi,useAccount:()=>Ee,useAccountId:()=>xe,useCache:()=>xr,useInitNear:()=>Zt,useNear:()=>ee,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>N,ErrorScopes:()=>C,Loading:()=>A,MaxGasPerTransaction:()=>S,OneNear:()=>P,ReactKey:()=>ut,StorageCostPerByte:()=>k,TGas:()=>x,availableNearBalance:()=>z,bigMax:()=>q,bigMin:()=>M,bigToString:()=>G,computeSrcOrCode:()=>pt,computeWritePermission:()=>at,convertToStringLeaves:()=>tt,dateToString:()=>$,deepCopy:()=>lt,deepEqual:()=>ht,deepFreeze:()=>ct,displayGas:()=>J,displayNear:()=>D,displayTime:()=>K,estimateDataSize:()=>H,extractKeys:()=>Y,filterValues:()=>ft,indexMatch:()=>ot,ipfsUpload:()=>W,ipfsUrl:()=>X,isArray:()=>T,isFunction:()=>R,isObject:()=>B,isReactObject:()=>st,isString:()=>U,isValidAccountId:()=>_,isoDate:()=>V,keysToCamel:()=>F,patternMatch:()=>nt,removeDuplicates:()=>Z});var e=n(359),r=n.n(e);const i=require("react-singleton-hook"),a=require("near-api-js"),c=require("big.js");var u=n.n(c);const s=require("deep-equal");var l=n.n(s);const f=require("ethers"),h=require("bn.js");var p=n.n(h),d=n(764).lW;function y(t){return function(t){if(Array.isArray(t))return b(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||g(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function m(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||g(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(t,e){if(t){if("string"==typeof t)return b(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(t,e):void 0}}function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function E(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var x=u()(10).pow(12),S=x.mul(250),k=u()(10).pow(19),O=2,j=64,I=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,P=u()(10).pow(24),L=P.div(2),C={Boundary:"Component triggered an Error Boundary",Compilation:"Compilation error",Execution:"Execution error",Render:"Render error",Source:"Source code not found"},A=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",style:{animationDelay:"2s"},role:"status","aria-hidden":"true"}),N=function(t){var e=t.error;return r().createElement("div",{role:"alert"},r().createElement("p",null,"Something went wrong:"),r().createElement("pre",null,e.message))};function _(t){return t&&t.length>=O&&t.length<=j&&t.match(I)}var T=function(t){return Array.isArray(t)},B=function(t){return t===Object(t)&&!T(t)&&"function"!=typeof t},U=function(t){return"string"==typeof t},R=function(t){return"function"==typeof t},F=function t(e){if(B(e)){var r={};return Object.keys(e).forEach((function(n){var o;r[(o=n,o.replace(/([-_][a-z])/gi,(function(t){return t.toUpperCase().replace("-","").replace("_","")})))]=t(e[n])})),r}return T(e)?e.map((function(e){return t(e)})):e},M=function(t,e){return t&&e?t.lt(e)?t:e:t||e},q=function(t,e){return t&&e?t.gt(e)?t:e:t||e},G=function(t,e,r){if(null===t)return"???";var n=t.toFixed(),o=n.indexOf(".");if(e=e||6,r=r||7,o>0){var i=Math.min(e,Math.max(r-o,0));i>0&&(i+=1),o+i=0;a-=3)n=n.slice(0,a+1)+","+n.slice(a+1);return"0.000000"===n&&6===e&&7===r?"<0.000001":n},D=function(t){return t?t.eq(1)?r().createElement(r().Fragment,null,"1 ",r().createElement("span",{className:"text-secondary"},"yoctoNEAR")):r().createElement(r().Fragment,null,G(t.div(P))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},J=function(t){return t?r().createElement(r().Fragment,null,G(t.div(x))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},$=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},K=function(t){return t.toLocaleString()},z=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(k)));if(e.gt(L))return e.sub(L)}return u()(0)},V=function(t){return t?new Date(t).toISOString().substring(0,10):""},W=function(){var t,e=(t=w().mark((function t(e){var r;return w().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});case 2:return r=t.sent,t.next=5,r.json();case 5:return t.abrupt("return",t.sent.cid);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){E(i,n,o,a,c,"next",t)}function c(t){E(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),X=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},H=function t(e,r){return B(e)?Object.entries(e).reduce((function(e,n){var o=m(n,2),i=o[0],a=o[1],c=B(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),B(r)?0:98):((null==e?void 0:e.length)||8)-(U(r)?r.length:0)},Y=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=m(e,2),o=n[0],i=n[1];return B(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},Z=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=m(n,2),i=o[0],a=o[1],c=B(r)?r[i]:void 0;if(B(a)){var u=B(c)?t(a,c):a;void 0!==u&&(e[i]=u)}else a!==c&&(e[i]=a);return e}),{});return Object.keys(n).length?n:void 0},Q=function(t){return U(t)||null===t?t:JSON.stringify(t)},tt=function t(e){return B(e)?Object.entries(e).reduce((function(e,r){var n=m(r,2),o=n[0],i=n[1];return e[Q(o)]=t(i),e}),{}):Q(e)},et=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):e.hasOwnProperty(n)?[e[n]]:[]).some((function(e){return B(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},rt=function t(e,r){var n=r[0];return("*"===n?Object.values(e):e.hasOwnProperty(n)?[e[n]]:[]).some((function(e){return 1===r.length||B(e)&&t(e,r.slice(1))}))},nt=function(t,e,r){var n=e.split("/");return"get"===t?et(r,n):"keys"===t&&rt(r,n)},ot=function(t,e,r){return Object.values(r).some((function(r){var n,o=null==r||null===(n=r.index)||void 0===n?void 0:n[t];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(e)}catch(t){return!1}}))},it={graph:!0,post:!0,index:!0,settings:!0},at=function(t,e){var r=B(t)?JSON.parse(JSON.stringify(t)):{};return B(e)&&Object.entries(e).forEach((function(t){var e=m(t,2),n=e[0],o=e[1];if(it.hasOwnProperty(n))if(B(o)){var i=r[n]=r[n]||{};Object.keys(o).forEach((function(t){i[t]=!0}))}else r[n]=!0;else r[n]=!0})),r},ct=function t(e){return Object.freeze(e),Object.keys(e).forEach((function(r){(function(t,e){return!!Object.getOwnPropertyDescriptor(t,e).get})(e,r)||"object"!==v(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},ut="$$typeof",st=function(t){return null!==t&&"object"===v(t)&&!!t[ut]},lt=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(y(e.entries()).map((function(e){var r=m(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(y(e).map((function(e){return t(e)}))):d.isBuffer(e)?d.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof f.ethers.BigNumber||e instanceof h.BN||e instanceof u()?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:B(e)?st(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=m(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ft=function(t){return B(t)?Object.fromEntries(Object.entries(t).filter((function(t){var e=m(t,2);return e[0],void 0!==e[1]}))):t},ht=l(),pt=function(t,e,r){var n,o=t?{src:t}:e?{code:e}:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=g(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r||[]);try{for(i.s();!(n=i.n()).done;){var a,c=n.value;if(null!==(a=o)&&void 0!==a&&a.src){var u,s=o.src,l=B(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=R(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(U(l))o={src:l};else if(U(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o},dt=n(764).lW;function yt(t){return yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yt(t)}function vt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function mt(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function xt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function St(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){xt(i,n,o,a,c,"next",t)}function c(t){xt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var kt="PENDING_TRANSACTION_AFTER_SIGNIN",Ot=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},jt={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},It={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},Pt={get:!0,keys:!0},Lt=function(){var t=St(Et().mark((function t(e,r,n,o,i){return Et().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&Pt.hasOwnProperty(r)){t.next=2;break}return t.abrupt("return",i());case 2:return n=n||{},o&&(n.blockHeight=o),t.prev=4,t.next=7,fetch("".concat(e.apiUrl,"/").concat(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});case 7:return t.next=9,t.sent.json();case 9:return t.abrupt("return",t.sent);case 12:return t.prev=12,t.t0=t.catch(4),console.log("API call failed",r,n),console.error(t.t0),t.abrupt("return",i());case 17:case"end":return t.stop()}}),t,null,[[4,12]])})));return function(e,r,n,o,i){return t.apply(this,arguments)}}();function Ct(t){return new a.keyStores.BrowserLocalStorageKeyStore(window.localStorage,"".concat(t,":keystore:"))}function At(t,e){return Nt.apply(this,arguments)}function Nt(){return(Nt=St(Et().mark((function t(e,r){var n,o,i,c;return Et().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Ct(r),t.next=3,e.selector;case 3:if(!(o=t.sent)){t.next=12;break}return t.next=7,o.wallet();case 7:return i=t.sent,t.next=10,a.connect({keyStore:n,walletUrl:i.metadata.walletUrl,networkId:e.config.networkId,nodeUrl:e.config.nodeUrl,headers:{}});case 10:return c=t.sent,t.abrupt("return",new a.WalletConnection(c,r));case 12:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function _t(t,e){return Tt.apply(this,arguments)}function Tt(){return(Tt=St(Et().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p;return Et().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.contractName,t.next=3,At(e,n);case 3:if(!(o=t.sent)._walletBaseUrl){t.next=9;break}sessionStorage.setItem(kt,JSON.stringify(r)),o.requestSignIn({contractId:n,methodNames:[]}),t.next=27;break;case 9:return i=a.utils.KeyPair.fromRandom("ed25519"),c=a.transactions.functionCallAccessKey(n,[]),u=i.getPublicKey(),t.next=14,e.selector.then((function(t){return t.wallet()}));case 14:return s=t.sent,t.next=17,s.getAccounts();case 17:return l=t.sent[0],f=l.accountId,t.next=21,s.signAndSendTransactions({transactions:[{receiverId:f,actions:[{type:"AddKey",params:{publicKey:u.toString(),accessKey:{permission:c.permission.functionCall}}}],gas:x.mul(30)},(void 0,void 0,void 0,m=void 0,g=void 0,d=r.contractName,y=r.methodName,v=r.args,m=r.gas,g=r.deposit,{receiverId:d,actions:[Ot(y,v,m.toFixed(0),g.toFixed(0))]})]});case 21:return h=t.sent,p=Ct(n),t.next=25,p.setKey(e.config.networkId,f,i);case 25:return localStorage.setItem("".concat(n,"_wallet_auth_key"),JSON.stringify({accountId:f,allKeys:[l.publicKey]})),t.abrupt("return",h);case 27:case"end":return t.stop()}var d,y,v,m,g}),t)})))).apply(this,arguments)}function Bt(t,e){return Ut.apply(this,arguments)}function Ut(){return(Ut=St(Et().mark((function t(e,r){var n;return Et().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,At(e,r);case 2:return n=t.sent,t.abrupt("return",n.isSignedIn());case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Rt(t,e,r,n,o,i){return Ft.apply(this,arguments)}function Ft(){return(Ft=St(Et().mark((function t(e,r,n,o,i,a){var c,u,s,l;return Et().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.selector;case 3:return t.next=5,t.sent.wallet();case 5:if(c=t.sent,r===e.contract.contractId){t.next=16;break}return t.next=9,At(e,r);case 9:if(!(u=t.sent).isSignedIn()){t.next=16;break}return s=u.account(),t.next=14,s.functionCall({contractId:r,methodName:n,args:o,gas:i});case 14:return l=t.sent,t.abrupt("return",l);case 16:return t.next=18,c.signAndSendTransaction({receiverId:r,actions:[Ot(n,o,null!=i?i:x.mul(30).toFixed(0),null!=a?a:"0")]});case 18:return t.abrupt("return",t.sent);case 21:throw t.prev=21,t.t0=t.catch(0),t.t0;case 24:case"end":return t.stop()}}),t,null,[[0,21]])})))).apply(this,arguments)}function Mt(t,e){return qt.apply(this,arguments)}function qt(){return(qt=St(Et().mark((function t(e,r){var n;return Et().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a.Account(e.nearConnection.connection,r),t.next=3,n.state();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Gt(t,e){return Dt.apply(this,arguments)}function Dt(){return(Dt=St(Et().mark((function t(e,r){var n,o,i,a,c,s,l,f,h;return Et().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(1!==r.length){t.next=6;break}if(n=r[0],o=n.contractName,i=n.methodName,a=n.args,c=n.gas,(s=n.deposit)&&"0"!==s.toString()){t.next=6;break}return t.next=5,Rt(e,o,i,a,null==c?void 0:c.toString());case 5:case 17:return t.abrupt("return",t.sent);case 6:return t.prev=6,t.next=9,e.selector;case 9:return t.next=11,t.sent.wallet();case 11:return l=t.sent,f=[],h=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,o=t.args,i=t.gas,a=t.deposit,c=h.add(i),u=Ot(n,o,i.toFixed(0),a.toFixed(0));(null===(e=f[f.length-1])||void 0===e?void 0:e.receiverId)!==r||c.gt(S)?(f.push({receiverId:r,actions:[]}),h=i):h=c,f[f.length-1].actions.push(u)})),t.next=17,l.signAndSendTransactions({transactions:f});case 20:throw t.prev=20,t.t0=t.catch(6),t.t0;case 23:case"end":return t.stop()}}),t,null,[[6,20]])})))).apply(this,arguments)}function Jt(t,e,r){var n=r.viewMethods,o=void 0===n?[]:n,i=r.changeMethods,a=void 0===i?[]:i,c={near:t,contractId:e};return o.forEach((function(r){c[r]=function(n){return t.viewCall(e,r,n)}})),a.forEach((function(r){c[r]=function(n,o,i){return t.functionCall(e,r,n,o,i)}})),c}function $t(t,e){return Kt.apply(this,arguments)}function Kt(){return(Kt=St(Et().mark((function t(e,r){var n;return Et().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return n=t.sent,t.abrupt("return",n.signMessage(r));case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function zt(t,e,r,n,o,i){return Vt.apply(this,arguments)}function Vt(){return(Vt=St(Et().mark((function t(e,r,n,o,i,a){var c;return Et().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=i||{},t.next=3,e.query({request_type:"call_function",account_id:n,method_name:o,args_base64:dt.from(JSON.stringify(i)).toString("base64"),block_id:r,finality:a});case 3:return c=t.sent,t.abrupt("return",c.result&&c.result.length>0&&JSON.parse(dt.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Wt(t,e,r,n){return Xt.apply(this,arguments)}function Xt(){return(Xt=St(Et().mark((function t(e,r,n,o){var i;return Et().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=n||{},i=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(r)),Object.entries(n).forEach((function(t){var e=bt(t,2),r=e[0],n=e[1];void 0!==n&&i.searchParams.append("".concat(r,".json"),JSON.stringify(n))})),t.prev=3,t.next=6,fetch(i.toString());case 6:return t.next=8,t.sent.json();case 8:return t.abrupt("return",t.sent);case 11:return t.prev=11,t.t0=t.catch(3),console.log("Web4 view call failed",i.toString()),console.error(t.t0),t.abrupt("return",o());case 16:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function Ht(t){return Yt.apply(this,arguments)}function Yt(){return Yt=St(Et().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d,y,v,m,g,b;return Et().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.errorCallback,c=void 0===i?function(){}:i,u=e.keyStore,s=e.selector,l=e.walletConnectCallback,f=void 0===l?function(){}:l,h=e.customElements,p=void 0===h?{}:h,d=e.features,y=void 0===d?{}:d,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},It,o):"testnet"===o.networkId&&(o=Object.assign({},jt,o)),o.walletConnectCallback=f,o.errorCallback=c,o.customElements=Object.assign({},o.customElements,p),u=null!==(r=u)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=10,a.connect(Object.assign({deps:{keyStore:u}},o));case 10:if(v=t.sent,(m={config:o,selector:s,keyStore:u,nearConnection:v,features:y}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:u}}),g=function(t){var e;return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:null!==(e=o.defaultFinality)&&void 0!==e?e:"optimistic",blockId:void 0}},m.signMessage=function(t){return $t(m,t)},m.viewCall=function(t,e,r,n){var i=g(n),a=i.blockId,c=i.finality,u=function(){return zt(a?m.nearArchivalConnection.provider:m.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?Wt(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():Lt(o,e,r,a,s)},m.block=function(t){var e=g(t);return(e.blockId?m.nearArchivalConnection.provider:m.nearConnection.connection.provider).block(e)},m.functionCall=function(t,e,r,n,o){return Rt(m,t,e,r,n,o)},m.sendTransactions=function(t){return Gt(m,t)},m.isSignedIntoContract=function(){var t=St(Et().mark((function t(e){return Et().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Bt(m,e));case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),m.signInAndSetPendingTransaction=function(){var t=St(Et().mark((function t(e){return Et().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",_t(m,e));case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),m.contract=Jt(m,o.contractName,{viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]}),m.accountState=function(t){return Mt(m,t)},!(b=JSON.parse(sessionStorage.getItem(kt)))){t.next=40;break}return console.log("found pending transaction",b),t.next=28,At(m,b.contractName);case 28:if(!t.sent){t.next=40;break}return console.log("sending pending transaction",b),t.prev=31,t.next=34,Gt(m,[b]);case 34:t.next=39;break;case 36:t.prev=36,t.t0=t.catch(31),console.error("error sending pending transaction",t.t0);case 39:sessionStorage.removeItem(kt);case 40:return t.abrupt("return",m);case 41:case"end":return t.stop()}}),t,null,[[31,36]])}))),Yt.apply(this,arguments)}var Zt=(0,i.singletonHook)({},(function(){var t=bt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){var e,r=(null===(e=t.config)||void 0===e?void 0:e.networkId)||t.networkId,o="mainnet"!==r&&"testnet"!==r,i="testnet"===r?t:mt(mt({},t),{},{networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0}),a="mainnet"===r?t:mt(mt({},t),{},{networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0});return n(Promise.all([i,a].concat(o?t:[]).map(Ht)).then((function(t){return t.map((function(t){return mt(mt({},t),{},{default:t.config.networkId===r})}))})))}}),[])}})),Qt=[],te=(0,i.singletonHook)(Qt,(function(){var t=bt((0,e.useState)(Qt),2),r=t[0],n=t[1],o=Zt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r?{default:r.find((function(t){return t.default})),testnet:r.find((function(t){return"testnet"===t.config.networkId})),mainnet:r.find((function(t){return"mainnet"===t.config.networkId}))}:r})),ee=function(t){return te()[t||"default"]||null};const re=require("local-storage");var ne,oe,ie,ae,ce=n.n(re);function ue(t){return ue="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ue(t)}function se(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return le(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?le(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function le(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function he(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function pe(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){he(i,n,o,a,c,"next",t)}function c(t){he(i,n,o,a,c,"throw",t)}a(void 0)}))}}var de="near-social-vm:v01:",ye=de+":accountId:",ve=de+":pretendAccountId:",me={loading:!0,signedAccountId:null!==(ne=ce().get(ye))&&void 0!==ne?ne:void 0,pretendAccountId:null!==(oe=ce().get(ve))&&void 0!==oe?oe:void 0,accountId:null!==(ie=null!==(ae=ce().get(ve))&&void 0!==ae?ae:ce().get(ye))&&void 0!==ie?ie:void 0,state:null,near:null};function ge(t,e){return be.apply(this,arguments)}function be(){return(be=pe(fe().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return fe().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.connectedContractId=null===(n=r)||void 0===n||null===(o=n.contract)||void 0===o?void 0:o.contractId,!e.connectedContractId||e.connectedContractId===e.config.contractName||e.connectedContractId===e.config.allowExternalContract){t.next=12;break}return t.next=4,e.selector;case 4:return l=t.sent,t.next=7,l.wallet();case 7:return f=t.sent,t.next=10,f.signOut();case 10:e.connectedContractId=null,r=l.store.getState();case 12:if(e.accountId=null!==(i=null===(c=r)||void 0===c||null===(u=c.accounts)||void 0===u||null===(s=u[0])||void 0===s?void 0:s.accountId)&&void 0!==i?i:null,e.accountId){e.publicKey=null;try{"here-wallet"===(null===(h=r)||void 0===h?void 0:h.selectedWalletId)&&(p=ce().get("herewallet:keystore"),e.publicKey=a.KeyPair.fromString(p[e.config.networkId].accounts[e.accountId]).getPublicKey())}catch(t){console.error(t)}if(!e.publicKey)try{e.publicKey=a.KeyPair.fromString(ce().get("meteor-wallet"===(null===(d=r)||void 0===d?void 0:d.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(t){console.error(t)}}case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var we=function(){var t=pe(fe().mark((function t(e,r){var n,o,i,a,c,u,s,l;return fe().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(ce().set(ye,o),e.config.walletConnectCallback(o)):ce().remove(ye),i=null!==(n=ce().get(ve))&&void 0!==n?n:void 0,a={loading:!1,signedAccountId:o,pretendAccountId:i,accountId:null!=i?i:o,state:null,near:e,refresh:function(){var t=pe(fe().mark((function t(){return fe().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,we(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),startPretending:function(){var t=pe(fe().mark((function t(n){return fe().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?ce().set(ve,n):ce().remove(ve),t.next=3,we(e,r);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},!o){t.next=13;break}return t.next=7,Promise.all([e.contract.storage_balance_of({account_id:o}),e.accountState(o)]);case 7:c=t.sent,u=se(c,2),s=u[0],l=u[1],a.storageBalance=s,a.state=l;case 13:r(a);case 14:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),Ee=(0,i.singletonHook)(me,(function(){var t=se((0,e.useState)(me),2),r=t[0],n=t[1],o=ee();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=pe(fe().mark((function t(e){return fe().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ge(o,e);case 2:return t.prev=2,t.next=5,we(o,n);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),console.error(t.t0);case 10:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}())}))}),[o]),r})),xe=function(t){var e=ee(),r=Ee();if(e&&(!t||e.config.networkId===t))return r.accountId};const Se=require("react-bootstrap/Modal");var ke=n.n(Se);const Oe=require("react-bootstrap/Alert");var je=n.n(Oe);const Ie=require("react-bootstrap/Toast");var Pe=n.n(Ie);const Le=require("react-bootstrap/ToastContainer");var Ce=n.n(Le);const Ae=require("remark-gfm");var Ne=n.n(Ae);const _e=require("react-markdown");var Te=n.n(_e);const Be=require("react-syntax-highlighter"),Ue=require("react-syntax-highlighter/dist/esm/styles/prism"),Re=require("mdast-util-find-and-replace");var Fe=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function Me(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length))||e.length<2||e.length>64)return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{accountId:e}}}}return function(e){return(0,Re.findAndReplace)(e,Fe,t),e}}var qe=/#(\w+)/gi;function Ge(){function t(t,e,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+t.length)))return!1;var n={type:"text",value:t};return{type:"strong",children:[n],data:{hProperties:{hashtag:e}}}}return function(e){return(0,Re.findAndReplace)(e,qe,t),e}}function De(t){return De="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},De(t)}var Je=["node","children"],$e=["node"],Ke=["node"],ze=["node"],Ve=["node"],We=["node","inline","className","children"];function Xe(){return Xe=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var tr=function(t){var e=t.onLink,n=t.onLinkClick,o=t.text,i=t.onMention,a=t.onHashtag,c=t.onImage,u=t.syntaxHighlighterProps;return r().createElement(Te(),{plugins:[],rehypePlugins:[],remarkPlugins:[Ne(),Me,Ge],children:o,components:{strong:function(t){var e,n,o,c,u=t.node,s=t.children,l=Qe(t,Je);return i&&null!==(e=u.properties)&&void 0!==e&&e.accountId?i(null===(o=u.properties)||void 0===o?void 0:o.accountId):a&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?a(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){var o,i=t.node,a=Qe(t,$e);return e?e(Ye(Ye({},a),{},{href:null===(o=i.properties)||void 0===o?void 0:o.href})):n?r().createElement("a",Xe({onClick:n},a)):r().createElement("a",Xe({target:"_blank"},a))},img:function(t){t.node;var e=Qe(t,Ke);return c?c(Ye({},e)):r().createElement("img",Xe({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Qe(t,ze);return r().createElement("blockquote",Xe({className:"blockquote"},e))},table:function(t){t.node;var e=Qe(t,Ve);return r().createElement("table",Xe({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Qe(t,We),a=/language-(\w+)/.exec(n||""),c=null!=u?u:{},s=c.wrapLines,l=c.lineProps,f=c.showLineNumbers,h=c.lineNumberStyle;return!e&&a?r().createElement(Be.Prism,Xe({children:String(o).replace(/\n$/,""),style:Ue.tomorrow,language:a[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",Xe({className:n},i),o)}}})};const er=require("idb");function rr(t){return rr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rr(t)}function nr(t,e){if(t){if("string"==typeof t)return or(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?or(t,e):void 0}}function or(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function ar(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function cr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){ar(i,n,o,a,c,"next",t)}function c(t){ar(i,n,o,a,c,"throw",t)}a(void 0)}))}}function ur(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"cacheDb",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,er.openDB)(e,1,{upgrade:function(t){t.createObjectStore(vr)}}),this.cache={},this.finalSynchronizationDelayMs=r}var e,r,n,o,i;return e=t,r=[{key:"invalidateCallbacks",value:function(t,e){var r;if(null!==(r=t.invalidationCallbacks)&&void 0!==r&&r.length){var n=t.invalidationCallbacks;t.invalidationCallbacks=[],setTimeout((function(){n.forEach((function(t){try{t()}catch(t){}}))}),e?this.finalSynchronizationDelayMs+50:50)}}},{key:"innerGet",value:(i=cr(ir().mark((function t(e){return ir().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.get(vr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=cr(ir().mark((function t(e,r){return ir().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dbPromise;case 2:return t.abrupt("return",t.sent.put(vr,r,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"cachedPromise",value:function(t,e,r,n){var o=this;t=JSON.stringify(t);var i=this.cache[t]||{status:hr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,B(r)||(r={onInvalidate:r}),r.onInvalidate&&i.invalidationCallbacks.push(r.onInvalidate),!i.subscription&&r.subscribe&&function t(){i.subscription=setTimeout((function(){document.hidden?t():(i.subscription=null,i.status=yr,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===pr||i.status===dr&&i.time+3e5>(new Date).getTime()||(i.status!==hr||null!=n&&n.ignoreCache||this.innerGet(t).then((function(t){(t||null!=n&&n.forceCachedValue)&&i.status===pr&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=pr,e&&e().then((function(e){i.status=dr,i.time=(new Date).getTime(),JSON.stringify(e)!==JSON.stringify(i.result)&&(i.result=e,o.innerSet(t,e),o.invalidateCallbacks(i,!1))})).catch((function(e){console.error(e),i.status=dr;var r=void 0;i.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(i.result)&&(i.result=r,o.innerSet(t,r),o.invalidateCallbacks(i,!1))}))),i.result}},{key:"invalidateCache",value:function(t,e){var r=this,n=[],o="".concat(t.config.apiUrl,"/index");Object.keys(this.cache).forEach((function(r){var i;try{i=JSON.parse(r)}catch(t){return void console.error("Key deserialization failed",r)}if(i.action!==sr||i.contractId!==t.config.contractName||i.blockId&&"optimistic"!==i.blockId&&"final"!==i.blockId)i.action===sr&&i.contractId===e&&n.push([r,"final"===i.blockId]);else try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return nt(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===lr&&i.url===o)try{var c,u=JSON.parse(null===(c=i.options)||void 0===c?void 0:c.body),s=u.action,l=u.key;s&&l&&ot(s,l,e)&&n.push([r,!0])}catch(t){}})),console.log("Cache invalidation",n),n.forEach((function(t){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,n)||nr(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],c=r.cache[i];c.status=yr,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r,n){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r,n)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i,a){return this.cachedPromise({action:sr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i,a)}},{key:"asyncFetch",value:(n=cr(ir().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return ir().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=null===(n=r)||void 0===n||null===(o=n.responseType)||void 0===o?void 0:o.toLowerCase(),r={method:null===(i=r)||void 0===i?void 0:i.method,headers:null===(a=r)||void 0===a?void 0:a.headers,body:null===(c=r)||void 0===c?void 0:c.body},t.prev=2,t.next=5,fetch(e,r);case 5:if(s=t.sent,l=s.status,f=s.ok,h=s.headers.get("content-type"),!f){t.next=15;break}return t.next=12,"arraybuffer"===u?s.arrayBuffer():"blob"===u?s.blob():"formdata"===u?s.formData():"json"===u?s.json():"text"===u?s.text():h&&-1!==h.indexOf("application/json")?s.json():s.text();case 12:t.t0=t.sent,t.next=16;break;case 15:t.t0=void 0;case 16:return p=t.t0,t.abrupt("return",{ok:f,status:l,contentType:h,body:p});case 20:return t.prev=20,t.t1=t.catch(2),t.abrupt("return",{ok:!1,error:t.t1.message});case 23:case"end":return t.stop()}}),t,null,[[2,20]])}))),function(t,e){return n.apply(this,arguments)})},{key:"cachedFetch",value:function(t,e,r,n){var o=this;return this.cachedPromise({action:lr,url:t,options:e},(function(){return o.asyncFetch(t,e)}),r,n)}},{key:"cachedCustomPromise",value:function(t,e,r,n){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r,n)}},{key:"socialGet",value:function(t,e,r,n,o,i,a){if(!t)return null;var c={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},u=this.cachedViewCall(t,t.config.contractName,"get",c,n,i,a);if(null===u)return null;if(1===e.length)for(var s=e[0].split("/"),l=0;l=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Ir(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Pr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Ir(i,n,o,a,c,"next",t)}function c(t){Ir(i,n,o,a,c,"throw",t)}a(void 0)}))}}function Lr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Cr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Cr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Cr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function Gr(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Dr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Gr(i,n,o,a,c,"next",t)}function c(t){Gr(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Jr=k.mul(2e3),$r=k.mul(500),Kr=k.mul(500),zr=k.mul(500),Vr=function(){var t=Dr(qr().mark((function t(e,r){var n;return qr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Y(r),t.next=3,e.contract.get({keys:n});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),Wr=function(){var t=Dr(qr().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return qr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:if(i=e.accountId){t.next=6;break}return alert("You're not logged in. Sign in to commit data."),t.abrupt("return");case 6:return t.next=8,Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:i}),i!==r?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:i,key:r}):Promise.resolve(!0)]);case 8:if(a=t.sent,w=2,c=function(t){if(Array.isArray(t))return t}(b=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(b,w)||function(t,e){if(t){if("string"==typeof t)return Mr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Mr(t,e):void 0}}(b,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],l=c[1],f=u()((null==s?void 0:s.available_bytes)||"0"),v={},m=r,g=tt(n),(m=function(t){var e=function(t,e){if("object"!==Fr(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==Fr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===Fr(e)?e:String(e)}(m))in v?Object.defineProperty(v,m,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[m]=g,h=v,p={},o){t.next=20;break}return t.next=18,Vr(e,h);case 18:p=t.sent,h=Z(h,p);case 20:return d=k.mul(H(h,p)).add(s?u()(0):$r).add(l?u()(0):zr).add(Kr),y=q(d.sub(f.mul(k)),s?l?u()(0):u()(1):Jr),t.abrupt("return",{originalData:n,accountId:r,accountStorage:s,availableBytes:f,currentData:p,data:h,expectedDataBalance:d,deposit:y,permissionGranted:l});case 23:case"end":return t.stop()}var v,m,g,b,w}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),Xr=function(){var t=Dr(qr().mark((function t(e,r,n){return qr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Committing data",r),t.next=3,e.contract.set({data:r},x.mul(100).toFixed(0),n.toFixed(0));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),Hr=function(){var t=Dr(qr().mark((function t(e,r,n){var o,i;return qr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selector;case 2:return t.next=4,t.sent.wallet();case 4:return o=t.sent,i=[],e.publicKey&&(i.push(Ot("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},x.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(Ot("set",{data:r},x.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),t.next=10,o.signAndSendTransaction({receiverId:e.config.contractName,actions:i});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}();const Yr=require("react-bootstrap");function Zr(t){return Zr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Zr(t)}var Qr=["data","children","onClick","onCommit","onCancel","disabled","widgetSrc","force"];function tn(){return tn=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function rn(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function nn(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return on(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?on(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function on(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r-1||!!K&&W.sources.indexOf(K.split("@")[0])>-1,Y=!V&&H,Z=!!C&&M&&!m&&null!==T,Q=Z&&!Y;return(0,e.useEffect)((function(){Z&&Y&&!S&&z()}),[Z,Y,S]),r().createElement(ke(),{size:"xl",centered:!0,scrollable:!0,show:Q,onHide:G},r().createElement(ke().Header,{closeButton:!0},r().createElement(ke().Title,null,"Saving data")),r().createElement(ke().Body,null,V?r().createElement("div",null,r().createElement("h5",null,"Can't commit, because the account ",p.accountId," doesn't have permission to write under pretended account ",d)):C?r().createElement("div",null,r().createElement("div",null,C.data?r().createElement(tr,{text:an(C.data)}):r().createElement("h5",null,"No new data to save")),C.data&&(null==C||null===(h=C.deposit)||void 0===h?void 0:h.gt(0))&&r().createElement("div",null,r().createElement("h6",null,"Required storage deposit"," ",r().createElement("small",{className:"text-secondary"},"(can be recovered later)")),r().createElement("div",{className:"mb-2"},C.deposit.div(k).toFixed(0)," bytes ="," ",D(C.deposit)),r().createElement("h6",null,"Optional storage deposit"," ",r().createElement("small",{className:"text-secondary"},"(can be used to avoid future wallet TX confirmation)")),r().createElement("div",null,r().createElement(Yr.ToggleButtonGroup,{type:"radio",name:"storageDeposit",value:w,onChange:E,disabled:S},r().createElement(Yr.ToggleButton,{id:"esd-0",variant:"outline-success",value:0},"No Deposit"),r().createElement(Yr.ToggleButton,{id:"esd-5000",variant:"outline-success",value:5e3},"0.05 NEAR (5Kb)"),r().createElement(Yr.ToggleButton,{id:"esd-20000",variant:"outline-success",value:2e4},"0.2 NEAR (20Kb)"),r().createElement(Yr.ToggleButton,{id:"esd-100000",variant:"outline-success",value:1e5},"1 NEAR (100Kb)")))),!V&&K&&C.data&&r().createElement("div",{className:"form-check form-switch"},r().createElement("input",{className:"form-check-input",type:"checkbox",role:"switch",id:"dont-ask-for-widget",checked:R,onChange:function(t){F(t.target.checked)}}),r().createElement("label",{className:"form-check-label",htmlFor:"dont-ask-for-widget"},"Don't ask again for saving similar data by"," ",r().createElement("span",{className:"font-monospace"},K)))):A),r().createElement(ke().Footer,null,r().createElement("button",{className:"btn btn-success",disabled:!(null!=C&&C.data)||S||V,onClick:function(t){t.preventDefault(),z()}},S&&A," Save Data"),r().createElement("button",{className:"btn btn-secondary",onClick:G,disabled:S},"Close")))},ln=function(t){var n=xe(t.networkId),o=t.data,i=t.children,a=t.onClick,c=t.onCommit,u=t.onCancel,s=t.disabled,l=t.widgetSrc,f=t.force,h=function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Qr),p=nn((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",tn({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&A,i),r().createElement(sn,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const fn=require("react-bootstrap-typeahead"),hn=require("styled-components");var pn=n.n(hn);const dn=require("elliptic"),yn=require("tweetnacl"),vn=require("iframe-resizer-react");var mn=n.n(vn);function gn(){return gn=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function po(t,e,r){return po=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&yo(o,r.prototype),o},po.apply(null,arguments)}function yo(t,e){return yo=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},yo(t,e)}function vo(){return vo=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?(c[u]={uploading:!0,cid:null},i.vm.setReactState(i.vm.state.state),W(t[0]).then((function(t){if(i.vm.alive){var e=i.vm.vmStack.resolveMemberExpression(n.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},i.vm.setReactState(i.vm.state.state)}}))):(c[u]=null,i.vm.setReactState(i.vm.state.state))}}}else{var s=i.resolveMemberExpression(n.expression,{requireState:!0,left:!0}),l=s.obj,p=s.key;f.value=(null==l?void 0:l[p])||"",f.onChange=function(t){t.preventDefault(),l[p]=t.target.value,i.vm.setReactState(i.vm.state.state)}}})),f.key=null!==(e=f.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(a,"-").concat(this.vm.gIndex),1==(null===(n=this.vm.near)||void 0===n||null===(o=n.features)||void 0===o?void 0:o.enableComponentSrcDataKey)&&(f["data-component"]=null!==(p=f["data-component"])&&void 0!==p?p:this.vm.widgetSrc),delete f.dangerouslySetInnerHTML,delete f.is;var y,v=(0,hn.isStyledComponent)(l)&&(null==l?void 0:l.target)||a;if(f.as&&!Bo[f.as]&&delete f.as,f.forwardedAs&&!Bo[f.forwardedAs]&&delete f.forwardedAs,"img"===v)f.alt=null!==(y=f.alt)&&void 0!==y?y:"not defined";else if("a"===v||"use"===v)Object.entries(f).forEach((function(t){var e=Eo(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(f[r]=U(n)&&(0,Bn.isValidAttribute)("a","href",n)?n:"about:blank")}));else if("set"===v){if("href"===f.attributeName||"xlink:href"===f.attributeName||"is"===f.attributeName)return r().createElement(r().Fragment,null)}else"Widget"===a?(f.depth=this.vm.depth+1,f.config=[f.config].concat(mo(this.vm.widgetConfigs)).filter(Boolean)):"CommitButton"===a&&(f.networkId=this.vm.networkId);if(!1===c&&t.children.length)throw new Error("And element '"+a+"' contains children, but shouldn't");var m,g,b,w,E=t.children.map((function(t,e){return i.vm.gIndex=e,i.executeExpression(t)}));if(u)return u(jo(jo({},f),{},{children:E}));if(l)return(0,hn.isStyledComponent)(l)?r().createElement.apply(r(),[l,jo({},f)].concat(mo(E))):l(jo({children:E},f));if("Widget"===a)return r().createElement(pi,f);if("CommitButton"===a)return r().createElement(ln,vo({},f,{widgetSrc:this.vm.widgetSrc}),E);if("InfiniteScroll"===a)return r().createElement(Rr(),f,E);if("Tooltip"===a)return r().createElement(Yr.Tooltip,f,E);if("OverlayTrigger"===a)return r().createElement(Yr.OverlayTrigger,f,E.filter((function(t){return!U(t)||!!t.trim()}))[0]);if("Typeahead"===a)return r().createElement(fn.Typeahead,f);if("Markdown"===a)return r().createElement(tr,f);if("Fragment"===a){var x=f,S=(x["data-component"],function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(x,fo));return r().createElement(r().Fragment,S,E)}if("IpfsImageUpload"===a)return r().createElement("div",{className:"d-inline-block",key:f.key},(null===(m=h.img)||void 0===m?void 0:m.cid)&&r().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},r().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:X(null===(g=h.img)||void 0===g?void 0:g.cid),alt:"upload preview"})),r().createElement(Br(),vo({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},ei(f)),null!==(b=h.img)&&void 0!==b&&b.uploading?r().createElement(r().Fragment,null,A," Uploading"):null!==(w=h.img)&&void 0!==w&&w.cid?"Replace":"Upload an Image"));if("Files"===a)return r().createElement(Br(),ei(f),E);if("iframe"===a)return r().createElement(On,f);if("Web3Connect"===a)return r().createElement(Tn,f);if(s){if(a.includes("Portal"))throw new Error("Radix's \"".concat(a,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var k=E;return Array.isArray(k)&&(1===(k=k.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?k=k[0]:0===k.length&&(k=void 0)),r().createElement(s,f,k)}if(!0===c)return r().createElement.apply(r(),[a,jo({},f)].concat(mo(E)));if(!1===c)return r().createElement(a,jo({},f));throw new Error("Unsupported element: "+a)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return $o(r),r}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if($o(n),null!=e&&e.requireState&&n!==Lo)throw new Error("The top object should be ".concat(Lo));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(zo(o),o===this.stack.state&&Fo.hasOwnProperty(n)){if(null!=e&&e.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=e&&e.left&&(!o||!o.hasOwnProperty(n)))throw new Error("Accessing undeclared identifier '".concat(t.name,"'"));return{obj:o,key:n}}if("MemberExpression"===t.type||"JSXMemberExpression"===t.type){var i,a;if("Identifier"===(null===(i=t.object)||void 0===i?void 0:i.type)||"JSXIdentifier"===(null===(a=t.object)||void 0===a?void 0:a.type)){var c=t.object.name;if(Fo.hasOwnProperty(c)){if(null==e||!e.callee)throw new Error("Cannot dereference keyword '"+c+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(t.property,t.computed),keyword:c}}}var u=this.executeExpression(t.object);return zo(u),{obj:u,key:this.resolveKey(t.property,t.computed)}}throw new Error("Unsupported member type: '"+t.type+"'")}},{key:"getArray",value:function(t){var e=this,r=[];return t.forEach((function(t){"SpreadElement"===t.type?r.push.apply(r,mo(e.executeExpression(t.argument))):r.push(e.executeExpression(t))})),r}},{key:"executeExpressionInternal",value:function(t){var e=this;if(!t)return null;var r=null==t?void 0:t.type;if("AssignmentExpression"===r){var n,o=this.resolveMemberExpression(t.left,{left:!0}),i=o.obj,a=o.key,c=this.executeExpression(t.right);if("="===t.operator)return i[a]=c;if("+="===t.operator)return i[a]+=c;if("-="===t.operator)return i[a]-=c;if("*="===t.operator)return i[a]*=c;if("/="===t.operator)return i[a]/=c;if("??="===t.operator)return null!==(n=i[a])&&void 0!==n?n:i[a]=c;throw new Error("Unknown AssignmentExpression operator '"+t.operator+"'")}if("ChainExpression"===r)return this.executeExpression(t.expression);if("MemberExpression"===r||"JSXMemberExpression"===r){var u=this.resolveMemberExpression(t),s=u.obj,l=u.key;return null==s?void 0:s[l]}if("Identifier"===r||"JSXIdentifier"===r)return this.stack.get(t.name);if("JSXExpressionContainer"===r)return this.executeExpression(t.expression);if("TemplateLiteral"===r){for(var f=[],h=0;h"===t.operator)return E>x;if("<="===t.operator)return E<=x;if(">="===t.operator)return E>=x;if("==="===t.operator||"=="===t.operator)return E===x;if("!=="===t.operator||"!="===t.operator)return E!==x;if("in"===t.operator)return E in x;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var S=this.resolveMemberExpression(t.argument,{left:!0}),k=S.obj,O=S.key;return null==k||delete k[O]}var j=this.executeExpression(t.argument);if("-"===t.operator)return-j;if("!"===t.operator)return!j;if("typeof"===t.operator)return ko(j);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var I=this.executeExpression(t.left);if("||"===t.operator)return I||this.executeExpression(t.right);if("&&"===t.operator)return I&&this.executeExpression(t.right);if("??"===t.operator)return null!=I?I:this.executeExpression(t.right);throw new Error("Unknown LogicalExpression operator '"+t.operator+"'")}if("ConditionalExpression"===r)return this.executeExpression(t.test)?this.executeExpression(t.consequent):this.executeExpression(t.alternate);if("UpdateExpression"===r){var P=this.resolveMemberExpression(t.argument,{left:!0}),L=P.obj,C=P.key;if("++"===t.operator)return t.prefix?++L[C]:L[C]++;if("--"===t.operator)return t.prefix?--L[C]:L[C]--;throw new Error("Unknown UpdateExpression operator '"+t.operator+"'")}if("ObjectExpression"===r)return t.properties.reduce((function(t,r){if("Property"===r.type)t[e.resolveKey(r.key,r.computed)]=e.executeExpression(r.value);else{if("SpreadElement"!==r.type)throw new Error("Unknown property type: "+r.type);var n=e.executeExpression(r.argument);zo(n),Object.assign(t,n)}return t}),{});if("ArrayExpression"===r)return this.getArray(t.elements);if("JSXEmptyExpression"===r)return null;if("ArrowFunctionExpression"===r)return this.createFunction(t.params,t.body,t.expression);if("TaggedTemplateExpression"===r){var A,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var _=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),T=_.key;if("styled"!==_.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var B,U=this.getArray(t.tag.arguments),R=null==U?void 0:U[0],F=Wo(R),M=this.vm.near.config.customElements[R];if(!(0,hn.isStyledComponent)(R)&&!F&&!M)throw new Error('styled() can only take `styled` components, Radix component names (EG: "Accordion.Trigger"), or a customElement name (EG: "Link")');A=pn()(null!==(B=null!=M?M:F)&&void 0!==B?B:R)}else{if("keyframes"===T)A=hn.keyframes;else{if(!Bo.hasOwnProperty(T))throw new Error("Unsupported styled tag: "+T);A=pn()(T)}N=T}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var q=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),G=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,D=JSON.stringify([N].concat(mo(q)));if(G&&this.vm.cachedStyledComponents.has(D))return this.vm.cachedStyledComponents.get(D);var J=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(A instanceof Function){var $=A.apply(void 0,[q].concat(mo(J)));return G&&this.vm.cachedStyledComponents.set(D,$),$}throw new Error("styled error")}throw console.log(t),new Error("Unknown expression type '"+r+"'")}},{key:"createFunction",value:function(t,e,r){var n=this;return t=t.map(Qo),function(){for(var o,i,a,c=arguments.length,u=new Array(c),s=0;s0&&(!t.test||a.executeExpression(t.test));){var c=a.executeStatement(t.body);if(c){if(c.break)break;if(!c.continue)return c}a.executeExpression(t.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===t.type){var u=this.newStack(),s=u.executeExpression(t.right);zo(s);var l,f=ho(s);try{var h=function(){var r=l.value;if(e.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===t.left.type){if(1!==t.left.declarations.length)throw new Error("Invalid for-of statement");t.left.declarations.forEach((function(t){if("VariableDeclarator"!==t.type)throw new Error("Unknown variable declaration type '"+t.type+"'");e.stackDeclare(Qo(t.id),r)}))}else{var n=e.resolveMemberExpression(t.left,{left:!0});n.obj[n.key]=r}var o=u.executeStatement(t.body);if(o){if(o.break)return"break";if(!o.continue)return{v:o}}};for(f.s();!(l=f.n()).done;){var p=h();if("break"===p)break;if("object"===ko(p))return p.v}}catch(t){f.e(t)}finally{f.f()}}else if("WhileStatement"===t.type){for(var d=this.newStack();this.vm.loopLimit-- >0&&d.executeExpression(t.test);){var y=d.executeStatement(t.body);if(y){if(y.break)break;if(!y.continue)return y}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===t.type){var v=this.executeExpression(t.test),m=this.newStack(),g=v?m.executeStatement(t.consequent):m.executeStatement(t.alternate);if(g)return g}else{if("BreakStatement"===t.type)return{break:!0};if("ContinueStatement"===t.type)return{continue:!0};if("ThrowStatement"===t.type)throw this.executeExpression(t.argument);if("TryStatement"===t.type)try{var b=this.newStack().executeStatement(t.block);if(b)return b}catch(e){if(!this.vm.alive||!t.handler)return null;if("CatchClause"!==t.handler.type)throw new Error("Unknown try statement handler type '"+t.handler.type+"'");var w=this.newStack();t.handler.param&&w.stackDeclare(Ho(t.handler.param),lt(e instanceof Error?{name:null==e?void 0:e.name,message:null==e?void 0:e.message,toString:function(){return e.toString()}}:e));var E=w.executeStatement(t.handler.body);if(E)return E}finally{this.vm.alive&&this.newStack().executeStatement(t.finalizer)}else{if("SwitchStatement"!==t.type)throw new Error("Unknown token type '"+t.type+"'");var x,S=this.executeExpression(t.discriminant),k=this.newStack(),O=!1,j=ho(t.cases);try{for(j.s();!(x=j.n()).done;){var I=x.value;if("SwitchCase"!==I.type)throw new Error("Unknown switch case type '"+I.type+"'");if(O||null===I.test||k.executeExpression(I.test)===S){O=!0;var P,L=!1,C=ho(I.consequent);try{for(C.s();!(P=C.n()).done;){var A=P.value,N=k.executeStatement(A);if(N){if(N.break){L=!0;break}return N}}}catch(t){C.e(t)}finally{C.f()}if(L)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),oi=function(){function t(e){var r,n=this;go(this,t);var o=e.near,i=e.rawCode,a=e.setReactState,c=e.cache,u=e.refreshCache,s=e.confirmTransactions,l=e.depth,h=e.widgetSrc,p=e.requestCommit,d=e.version,y=e.widgetConfigs,v=e.ethersProviderContext,m=e.isModule;this.alive=!0,this.isModule=m,this.rawCode=i,this.near=o;try{this.code=function(t){if(Do.has(t))return Do.get(t);var e=Jo.parse(t,Go);return Do.set(t,e),e}(i),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=a?function(t){return a({hooks:n.hooks,state:B(t)?Object.assign({},t):t})}:function(){throw new Error("State is unavailable for modules")},this.setReactHook=a?function(t,e){n.hooks[t]=e,a({hooks:n.hooks,state:n.state.state})}:function(){throw new Error("State is unavailable for modules")},this.cache=c,this.refreshCache=u,this.confirmTransactions=s,this.depth=null!=l?l:0,this.widgetSrc=h,this.requestCommit=p,this.version=d,this.cachedStyledComponents=new Map,this.widgetConfigs=y,this.ethersProviderContext=v,this.ethersProvider=null!=v&&v.provider?new f.ethers.providers.Web3Provider(v.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(r=y.findLast((function(t){return t&&t.networkId})))||void 0===r?void 0:r.networkId)||o.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}return wo(t,[{key:"stop",value:function(){this.alive&&(this.alive=!1,this.timeouts.forEach((function(t){return clearTimeout(t)})),this.intervals.forEach((function(t){return clearInterval(t)})),this.websockets.forEach((function(t){return t.close()})),this.vmInstances.forEach((function(t){return t.stop()})))}},{key:"initGlobalFunctions",value:function(){var t=this,e={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return t.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return t.cachedSocialKeys.apply(t,arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return t.cachedIndex.apply(t,arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return t.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={signMessage:function(){for(var e=arguments.length,r=new Array(e),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return t.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(e=arguments.length<=2?void 0:arguments[2])&&void 0!==e?e:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return zo(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var t=JSON.parse(arguments.length<=0?void 0:arguments[0]);return Vo(t),t}catch(t){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return zo(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return zo(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return zo(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var t=arguments.length,e=new Array(t),r=0;r=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var e=arguments.length,r=new Array(e),n=0;n=32)return"Too deep";this.gIndex=0;var i=null!=n?n:{},a=i.hooks,c=i.state;this.hooks=a,this.state=jo(jo(jo({},Mo),this.globalFunctions),{},{window:{location:{get hash(){return window.location.hash},set hash(t){if(""!==t)throw new Error("Set `window.location.hash` only accepts an empty string as a value.");history.pushState(t,document.title,window.location.pathname+window.location.search)}}},props:B(e)?Object.assign({},e):e,context:r,state:c,get elliptic(){return delete this.elliptic,this.elliptic=Pn()(dn),delete this.elliptic.utils.cachedProperty,this.elliptic}}),this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new ni(this,void 0,this.state);var u=this.vmStack.executeStatement(this.code);if(null!=u&&u.break)throw new Error("BreakStatement outside of a loop");if(null!=u&&u.continue)throw new Error("ContinueStatement outside of a loop");return null==u?void 0:u.result}}]),t}();const ii=require("react-error-boundary");function ai(t){return ai="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ai(t)}var ci=["loading","src","code","depth","config","props"];function ui(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function si(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,ci),p=fi((0,e.useState)(0),2),d=p[0],y=p[1],v=fi((0,e.useState)(null),2),m=v[0],g=v[1],b=fi((0,e.useState)(null),2),w=b[0],E=b[1],S=fi((0,e.useState)({hooks:[],state:void 0}),2),k=S[0],O=S[1],j=fi((0,e.useState)(0),2),I=j[0],P=j[1],L=fi((0,e.useState)({}),2),_=L[0],T=L[1],B=fi((0,e.useState)(null),2),U=B[0],R=B[1],F=fi((0,e.useState)(null),2),M=F[0],q=F[1],G=fi((0,e.useState)(null),2),D=G[0],J=G[1],$=fi((0,e.useState)(null),2),K=$[0],z=$[1],V=fi((0,e.useState)(null),2),W=V[0],X=V[1],H=fi((0,e.useState)(null),2),Y=H[0],Z=H[1],Q=(0,e.useContext)(_n),tt=W&&(null===(o=W.findLast((function(t){return t&&t.networkId})))||void 0===o?void 0:o.networkId),et=xr(tt),rt=ee(tt),nt=xe(tt),ot=fi((0,e.useState)(null),2),it=ot[0],at=ot[1];(0,e.useEffect)((function(){var t=l?Array.isArray(l)?l:[l]:[];ht(t,W)||X(t)}),[l,W]),(0,e.useEffect)((function(){var t=pt(a,c,W);ht(t,Y)||Z(t)}),[a,c,W,Y]),(0,e.useEffect)((function(){if(rt)if(null!=Y&&Y.src){var t=Y.src,e=fi(t.split("@"),2),r=e[0],n=e[1],o=et.socialGet(rt,r.toString(),!1,n,void 0,(function(){y(d+1)}));g(o),E(t)}else if(null!=Y&&Y.code){var i;g(Y.code),E(null!=rt&&null!==(i=rt.features)&&void 0!==i&&i.enableWidgetSrcWithCodeOverride?a:null)}}),[rt,Y,d]),(0,e.useEffect)((function(){R(null),at(null),m||void 0===m&&(rt.config.errorCallback({scope:C.Source,message:w}),at(r().createElement("div",{className:"alert alert-danger"},'Source code for "',w,'" is not found')))}),[m,w]);var ct=(0,e.useCallback)((function(t){if(!rt||!t||0===t.length)return null;t=t.map((function(t){return{contractName:t.contractName,methodName:t.methodName,args:t.args||{},deposit:t.deposit?u()(t.deposit):u()(0),gas:t.gas?u()(t.gas):x.mul(30)}})),console.log("confirm txs",t),q(t)}),[rt]),ut=(0,e.useCallback)((function(t){if(!rt)return null;console.log("commit requested",t),J(t)}),[rt]);(0,e.useEffect)((function(){if(rt&&m){O({hooks:[],state:void 0});var t=new oi({near:rt,rawCode:m,setReactState:O,cache:et,refreshCache:function(){P((function(t){return t+1}))},confirmTransactions:ct,depth:s,widgetSrc:w,requestCommit:ut,version:kr()(),widgetConfigs:W,ethersProviderContext:Q});return R(t),function(){t.stop()}}}),[w,rt,m,s,ut,ct,W,Q]),(0,e.useEffect)((function(){rt&&T({loading:!1,accountId:null!=nt?nt:null,widgetSrc:w,networkId:rt.config.networkId})}),[rt,nt,w]),(0,e.useLayoutEffect)((function(){if(U){var t={props:f||{},context:_,reactState:k,cacheNonce:I,version:U.version,forwardedProps:si(si({},h),{},{ref:n})};if(!ht(t,K)){z(lt(t));try{var e;at(null!==(e=U.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){var o=w?"".concat(w,": ").concat(t.message):t.message;rt.config.errorCallback({scope:C.Execution,message:o}),at(r().createElement("div",{className:"alert alert-danger"},w?r().createElement(r().Fragment,null,"Src: ",w,r().createElement("br",null)):"","Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[U,f,_,k,I,K,n,h]);var st=null!=it?r().createElement(ii.ErrorBoundary,{FallbackComponent:function(t){rt.config.errorCallback({scope:C.Boundary,message:w});var e=t.error,n=void 0===e?{message:C.Boundary}:e;return r().createElement(N,{error:n})},onReset:function(){at(null)},resetKeys:[it]},r().createElement(r().Fragment,null,it,M&&r().createElement(_r,{transactions:M,widgetSrc:w,onHide:function(t){q(null),t&&t.transaction&&et.invalidateCache(rt,t.transaction.receiver_id)},networkId:tt}),D&&r().createElement(sn,{show:!0,widgetSrc:w,data:D.data,force:D.force,onHide:function(){return J(null)},onCommit:D.onCommit,onCancel:D.onCancel,networkId:tt}))):null!=i?i:A;return st}))})(),o})())); \ No newline at end of file +!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(global,(()=>(()=>{"use strict";var e={686:(e,t,r)=>{const n=r(661),o=r(876),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=c,t.IS=50;const a=2147483647;function s(e){if(e>a)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return d(e)}return l(e,t,r)}function l(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|g(e,t);let n=s(r);const o=n.write(e,t);return o!==r&&(n=n.slice(0,o)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(X(e,Uint8Array)){const t=new Uint8Array(e);return h(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(X(e,ArrayBuffer)||e&&X(e.buffer,ArrayBuffer))return h(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(X(e,SharedArrayBuffer)||e&&X(e.buffer,SharedArrayBuffer)))return h(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return c.from(n,t,r);const o=function(e){if(c.isBuffer(e)){const t=0|p(e.length),r=s(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||H(e.length)?s(0):f(e):"Buffer"===e.type&&Array.isArray(e.data)?f(e.data):void 0}(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(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 d(e){return u(e),s(e<0?0:0|p(e))}function f(e){const t=e.length<0?0:0|p(e.length),r=s(t);for(let n=0;n=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|e}function g(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||X(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 r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(e).length;default:if(o)return n?-1:V(e).length;t=(""+t).toLowerCase(),o=!0}}function m(e,t,r){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return A(this,t,r);case"utf8":case"utf-8":return C(this,t,r);case"ascii":return O(this,t,r);case"latin1":case"binary":return B(this,t,r);case"base64":return I(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function w(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:v(e,t,r,n,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,n,o){let i,a=1,s=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,c/=2,r/=2}function l(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(o){let n=-1;for(i=r;is&&(r=s-c),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=t.length;let a;for(n>i/2&&(n=i/2),a=0;a>8,o=r%256,i.push(o),i.push(n);return i}(t,e.length-r),e,r,n)}function I(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function C(e,t,r){r=Math.min(e.length,r);const n=[];let o=t;for(;o239?4:t>223?3:t>191?2:1;if(o+a<=r){let r,n,s,c;switch(a){case 1:t<128&&(i=t);break;case 2:r=e[o+1],128==(192&r)&&(c=(31&t)<<6|63&r,c>127&&(i=c));break;case 3:r=e[o+1],n=e[o+2],128==(192&r)&&128==(192&n)&&(c=(15&t)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(i=c));break;case 4:r=e[o+1],n=e[o+2],s=e[o+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(c=(15&t)<<18|(63&r)<<12|(63&n)<<6|63&s,c>65535&&c<1114112&&(i=c))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(e){const t=e.length;if(t<=N)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nn.length?(c.isBuffer(t)||(t=c.from(t)),t.copy(n,o)):Uint8Array.prototype.set.call(n,t,o);else{if(!c.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(n,o)}o+=t.length}return n},c.byteLength=g,c.prototype._isBuffer=!0,c.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;tr&&(e+=" ... "),""},i&&(c.prototype[i]=c.prototype.inspect),c.prototype.compare=function(e,t,r,n,o){if(X(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.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===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0);const s=Math.min(i,a),l=this.slice(n,o),u=e.slice(t,r);for(let e=0;e>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return E(this,e,t,r);case"ascii":case"latin1":case"binary":return S(this,e,t,r);case"base64":return k(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const N=4096;function O(e,t,r){let n="";r=Math.min(e.length,r);for(let o=t;on)&&(r=n);let o="";for(let n=t;nr)throw new RangeError("Trying to access beyond buffer length")}function U(e,t,r,n,o,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function R(e,t,r,n,o){J(t,n,o,e,r,7);let i=Number(t&BigInt(4294967295));e[r++]=i,i>>=8,e[r++]=i,i>>=8,e[r++]=i,i>>=8,e[r++]=i;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=a,a>>=8,e[r++]=a,a>>=8,e[r++]=a,a>>=8,e[r++]=a,r}function j(e,t,r,n,o){J(t,n,o,e,r,7);let i=Number(t&BigInt(4294967295));e[r+7]=i,i>>=8,e[r+6]=i,i>>=8,e[r+5]=i,i>>=8,e[r+4]=i;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=a,a>>=8,e[r+2]=a,a>>=8,e[r+1]=a,a>>=8,e[r]=a,r+8}function M(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _(e,t,r,n,i){return t=+t,r>>>=0,i||M(e,0,r,4),o.write(e,t,r,n,23,4),r+4}function q(e,t,r,n,i){return t=+t,r>>>=0,i||M(e,0,r,8),o.write(e,t,r,n,52,8),r+8}c.prototype.slice=function(e,t){const r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||P(e,t,this.length);let n=this[e],o=1,i=0;for(;++i>>=0,t>>>=0,r||P(e,t,this.length);let n=this[e+--t],o=1;for(;t>0&&(o*=256);)n+=this[e+--t]*o;return n},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||P(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readBigUInt64LE=Z((function(e){G(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||K(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,o=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||K(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],o=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(n)<>>=0,t>>>=0,r||P(e,t,this.length);let n=this[e],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||P(e,t,this.length);let n=t,o=1,i=this[e+--n];for(;n>0&&(o*=256);)i+=this[e+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i},c.prototype.readInt8=function(e,t){return e>>>=0,t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||P(e,2,this.length);const r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){e>>>=0,t||P(e,2,this.length);const r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readBigInt64LE=Z((function(e){G(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||K(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||K(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<>>=0,t||P(e,4,this.length),o.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||P(e,4,this.length),o.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||P(e,8,this.length),o.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||P(e,8,this.length),o.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||U(this,e,t,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[t]=255&e;++i>>=0,r>>>=0,n||U(this,e,t,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||U(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},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||U(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},c.prototype.writeBigUInt64LE=Z((function(e,t=0){return R(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeBigUInt64BE=Z((function(e,t=0){return j(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);U(this,e,t,r,n-1,-n)}let o=0,i=1,a=0;for(this[t]=255&e;++o>>=0,!n){const n=Math.pow(2,8*r-1);U(this,e,t,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[t+o]=255&e;--o>=0&&(i*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/i|0)-a&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||U(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},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||U(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},c.prototype.writeBigInt64LE=Z((function(e,t=0){return R(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeBigInt64BE=Z((function(e,t=0){return j(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeFloatLE=function(e,t,r){return _(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return _(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return q(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return q(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,n){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function J(e,t,r,n,o,i){if(e>r||e3?0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${t}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,e)}!function(e,t,r){G(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||K(t,e.length-(r+1))}(n,o,i)}function G(e,t){if("number"!=typeof e)throw new F.ERR_INVALID_ARG_TYPE(t,"number",e)}function K(e,t,r){if(Math.floor(e)!==e)throw G(e,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",e);if(t<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?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,r){let n=`The value of "${e}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=D(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=D(o)),o+="n"),n+=` It must be ${t}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(e,t){let r;t=t||1/0;const n=e.length;let o=null;const i=[];for(let a=0;a55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function $(e,t,r,n){let o;for(o=0;o=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function X(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function H(e){return e!=e}const Y=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)t[n+o]=e[r]+e[o]}return t}();function Z(e){return"undefined"==typeof BigInt?Q:e}function Q(){throw new Error("BigInt not supported")}},661:e=>{e.exports=require("base64-js")},876:e=>{e.exports=require("ieee754")}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};r.r(n),r.d(n,{CommitButton:()=>Ft,EthersProviderContext:()=>tr,Widget:()=>dn,useAccount:()=>je,useAccountId:()=>Me,useCache:()=>wt,useInitNear:()=>be,useNear:()=>ke,utils:()=>o});var o={};r.r(o),r.d(o,{ErrorFallback:()=>N,ErrorScopes:()=>I,Loading:()=>C,MaxGasPerTransaction:()=>w,OneNear:()=>k,ReactKey:()=>ne,StorageCostPerByte:()=>v,TGas:()=>y,availableNearBalance:()=>D,bigMax:()=>j,bigMin:()=>R,bigToString:()=>M,computeSrcOrCode:()=>ce,computeWritePermission:()=>te,convertToStringLeaves:()=>X,dateToString:()=>F,deepCopy:()=>ie,deepEqual:()=>se,deepFreeze:()=>re,displayGas:()=>q,displayNear:()=>_,displayTime:()=>L,estimateDataSize:()=>z,extractKeys:()=>V,filterValues:()=>ae,indexMatch:()=>Q,ipfsUpload:()=>G,ipfsUrl:()=>K,isArray:()=>B,isFunction:()=>P,isObject:()=>A,isReactObject:()=>oe,isString:()=>T,isValidAccountId:()=>O,isoDate:()=>J,keysToCamel:()=>U,patternMatch:()=>Z,removeDuplicates:()=>W});const i=require("react");var a=r.n(i);const s=require("react-singleton-hook"),c=require("near-api-js"),l=require("big.js");var u=r.n(l);const d=require("deep-equal");var f=r.n(d);const h=require("ethers"),p=require("bn.js");var g=r.n(p),m=r(686).hp;const y=u()(10).pow(12),w=y.mul(250),v=u()(10).pow(19),b=2,E=64,S=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,k=u()(10).pow(24),x=k.div(2),I={Boundary:"Component triggered an Error Boundary",Compilation:"Compilation error",Execution:"Execution error",Render:"Render error",Source:"Source code not found"},C=a().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",style:{animationDelay:"2s"},role:"status","aria-hidden":"true"}),N=e=>{let{error:t}=e;return a().createElement("div",{role:"alert"},a().createElement("p",null,"Something went wrong:"),a().createElement("pre",null,t.message))};function O(e){return e&&e.length>=b&&e.length<=E&&e.match(S)}const B=e=>Array.isArray(e),A=e=>e===Object(e)&&!B(e)&&"function"!=typeof e,T=e=>"string"==typeof e,P=e=>"function"==typeof e,U=function(e){if(A(e)){const t={};return Object.keys(e).forEach((r=>{var n;t[(n=r,n.replace(/([-_][a-z])/gi,(e=>e.toUpperCase().replace("-","").replace("_",""))))]=U(e[r])})),t}return B(e)?e.map((e=>U(e))):e},R=(e,t)=>e&&t?e.lt(t)?e:t:e||t,j=(e,t)=>e&&t?e.gt(t)?e:t:e||t,M=(e,t,r)=>{if(null===e)return"???";let n=e.toFixed(),o=n.indexOf(".");if(t=t||6,r=r||7,o>0){let e=Math.min(t,Math.max(r-o,0));e>0&&(e+=1),o+e=0;e-=3)n=n.slice(0,e+1)+","+n.slice(e+1);return"0.000000"===n&&6===t&&7===r?"<0.000001":n},_=e=>e?e.eq(1)?a().createElement(a().Fragment,null,"1 ",a().createElement("span",{className:"text-secondary"},"yoctoNEAR")):a().createElement(a().Fragment,null,M(e.div(k))," ",a().createElement("span",{className:"text-secondary"},"NEAR")):"???",q=e=>e?a().createElement(a().Fragment,null,M(e.div(y))," ",a().createElement("span",{className:"text-secondary"},"TGas")):"???",F=e=>e.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"}),L=e=>e.toLocaleString(),D=e=>{if(e&&!e.loading&&e.state){let t=u()(e.state.amount).sub(u()(e.state.storage_usage).mul(u()(v)));if(t.gt(x))return t.sub(x)}return u()(0)},J=e=>e?new Date(e).toISOString().substring(0,10):"",G=async e=>{const t=await fetch("https://ipfs.near.social/add",{method:"POST",headers:{Accept:"application/json"},body:e});return(await t.json()).cid},K=e=>"https://ipfs.near.social/ipfs/".concat(e),z=(e,t)=>A(e)?Object.entries(e).reduce(((e,r)=>{let[n,o]=r;const i=A(t)?t[n]:void 0;return e+(void 0!==i?z(o,i):2*n.length+z(o,void 0)+140)}),A(t)?0:98):((null==e?void 0:e.length)||8)-(T(t)?t.length:0),V=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((e=>{let[r,n]=e;return A(n)?V(n,"".concat(t).concat(r,"/")):"".concat(t).concat(r)})).flat()},W=(e,t)=>{const r=Object.entries(e).reduce(((e,r)=>{let[n,o]=r;const i=A(t)?t[n]:void 0;if(A(o)){const t=A(i)?W(o,i):o;void 0!==t&&(e[n]=t)}else o!==i&&(e[n]=o);return e}),{});return Object.keys(r).length?r:void 0},$=e=>T(e)||null===e?e:JSON.stringify(e),X=e=>A(e)?Object.entries(e).reduce(((e,t)=>{let[r,n]=t;return e[$(r)]=X(n),e}),{}):$(e),H=(e,t)=>{const r=t[0];let n="**"===r;return n?1===t.length:("*"===r||n?Object.values(e):e.hasOwnProperty(r)?[e[r]]:[]).some((e=>A(e)?t.length>1?H(e,t.slice(1)):void 0!==e[""]:1===t.length))},Y=(e,t)=>{const r=t[0];return("*"===r?Object.values(e):e.hasOwnProperty(r)?[e[r]]:[]).some((e=>1===t.length||A(e)&&Y(e,t.slice(1))))},Z=(e,t,r)=>{const n=t.split("/");return"get"===e?H(r,n):"keys"===e&&Y(r,n)},Q=(e,t,r)=>Object.values(r).some((r=>{var n;const o=null==r||null===(n=r.index)||void 0===n?void 0:n[e];try{return o&&JSON.stringify(JSON.parse(o).key)===JSON.stringify(t)}catch{return!1}})),ee={graph:!0,post:!0,index:!0,settings:!0},te=(e,t)=>{const r=A(e)?JSON.parse(JSON.stringify(e)):{};return A(t)&&Object.entries(t).forEach((e=>{let[t,n]=e;if(ee.hasOwnProperty(t))if(A(n)){const e=r[t]=r[t]||{};Object.keys(n).forEach((t=>{e[t]=!0}))}else r[t]=!0;else r[t]=!0})),r},re=e=>(Object.freeze(e),Object.keys(e).forEach((t=>{(function(e,t){return!!Object.getOwnPropertyDescriptor(e,t).get})(e,t)||"object"!=typeof e[t]||Object.isFrozen(e[t])||re(e[t])})),e),ne="$$typeof",oe=e=>null!==e&&"object"==typeof e&&!!e[ne],ie=e=>Array.isArray(e)?e.map((e=>ie(e))):e instanceof Map?new Map([...e.entries()].map((e=>{let[t,r]=e;return[ie(t),ie(r)]}))):e instanceof Set?new Set([...e].map((e=>ie(e)))):m.isBuffer(e)?m.from(e):e instanceof URL?new URL(e):e instanceof File?new File([e],e.name,{type:e.type}):e instanceof Blob?new Blob([e],{type:e.type}):e instanceof Uint8Array||e instanceof ArrayBuffer?e.slice(0):e instanceof h.ethers.BigNumber||e instanceof p.BN||e instanceof u()?e:e instanceof Date?new Date(e):e instanceof WebSocket?e:A(e)?oe(e)?e:Object.fromEntries(Object.entries(e).map((e=>{let[t,r]=e;return[t,ie(r)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e)),ae=e=>A(e)?Object.fromEntries(Object.entries(e).filter((e=>{let[t,r]=e;return void 0!==r}))):e,se=f(),ce=(e,t,r)=>{let n=e?{src:e}:t?{code:t}:null;for(const e of r||[]){var o;if(null!==(o=n)&&void 0!==o&&o.src){var i;const t=n.src;let r=A(null==e?void 0:e.redirectMap)&&e.redirectMap[t];if(!r)try{r=P(null==e?void 0:e.redirect)&&e.redirect(t)}catch{}if(T(r))n={src:r};else if(T(null===(i=r)||void 0===i?void 0:i.code))return{code:r.code}}}return n};var le=r(686).hp;const ue="PENDING_TRANSACTION_AFTER_SIGNIN",de=(e,t,r,n)=>({type:"FunctionCall",params:{methodName:e,args:t,gas:r,deposit:n}}),fe={networkId:"testnet",nodeUrl:"https://rpc.testnet.near.org",archivalNodeUrl:"https://rpc.testnet.internal.near.org",contractName:"v1.social08.testnet",walletUrl:"https://wallet.testnet.near.org",wrapNearAccountId:"wrap.testnet",apiUrl:"https://discovery-api.stage.testnet.near.org",enableWeb4FastRpc:!1},he={networkId:"mainnet",nodeUrl:"https://rpc.mainnet.near.org",archivalNodeUrl:"https://rpc.mainnet.internal.near.org",contractName:"social.near",walletUrl:"https://wallet.near.org",wrapNearAccountId:"wrap.near",apiUrl:"https://api.near.social",enableWeb4FastRpc:!1},pe={get:!0,keys:!0};function ge(e){return new c.keyStores.BrowserLocalStorageKeyStore(window.localStorage,"".concat(e,":keystore:"))}async function me(e,t){const r=ge(t),n=await e.selector;if(n){const o=await n.wallet(),i=await c.connect({keyStore:r,walletUrl:o.metadata.walletUrl,networkId:e.config.networkId,nodeUrl:e.config.nodeUrl,headers:{}});return new c.WalletConnection(i,t)}}async function ye(e,t,r,n,o,i){try{const a=await(await e.selector).wallet();if(t!==e.contract.contractId){const i=await me(e,t);if(i.isSignedIn()){const e=i.account();return await e.functionCall({contractId:t,methodName:r,args:n,gas:o})}}return await a.signAndSendTransaction({receiverId:t,actions:[de(r,n,null!=o?o:y.mul(30).toFixed(0),null!=i?i:"0")]})}catch(e){throw e}}async function we(e,t){if(1===t.length){const{contractName:r,methodName:n,args:o,gas:i,deposit:a}=t[0];if(!a||"0"===a.toString())return await ye(e,r,n,o,null==i?void 0:i.toString())}try{const r=await(await e.selector).wallet(),n=[];let o=u()(0);return t.forEach((e=>{var t;let{contractName:r,methodName:i,args:a,gas:s,deposit:c}=e;const l=o.add(s),u=de(i,a,s.toFixed(0),c.toFixed(0));(null===(t=n[n.length-1])||void 0===t?void 0:t.receiverId)!==r||l.gt(w)?(n.push({receiverId:r,actions:[]}),o=s):o=l,n[n.length-1].actions.push(u)})),await r.signAndSendTransactions({transactions:n})}catch(e){throw e}}async function ve(e){var t;let{networkId:r,config:n,errorCallback:o=(()=>{}),keyStore:i,selector:a,walletConnectCallback:s=(()=>{}),customElements:l={},features:u={}}=e;n||(n={},r||(n.networkId="mainnet")),r&&!n.networkId&&(n.networkId=r),"mainnet"===n.networkId?n=Object.assign({},he,n):"testnet"===n.networkId&&(n=Object.assign({},fe,n)),n.walletConnectCallback=s,n.errorCallback=o,n.customElements=Object.assign({},n.customElements,l),i=null!==(t=i)&&void 0!==t?t:new c.keyStores.BrowserLocalStorageKeyStore;const d=await c.connect(Object.assign({deps:{keyStore:i}},n)),f={config:n,selector:a,keyStore:i,nearConnection:d,features:u};f.nearArchivalConnection=c.Connection.fromConfig({networkId:n.networkId,provider:{type:"JsonRpcProvider",args:{url:n.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}});const h=e=>{var t;return"optimistic"===e||"final"===e?{finality:e,blockId:void 0}:null!=e?{finality:void 0,blockId:parseInt(e)}:{finality:null!==(t=n.defaultFinality)&&void 0!==t?t:"optimistic",blockId:void 0}};f.signMessage=e=>async function(e,t){return(await(await e.selector).wallet()).signMessage(t)}(f,e),f.viewCall=(e,t,r,o)=>{const{blockId:i,finality:a}=h(o),s=()=>async function(e,t,r,n,o,i){o=o||{};const a=await e.query({request_type:"call_function",account_id:r,method_name:n,args_base64:le.from(JSON.stringify(o)).toString("base64"),block_id:t,finality:i});return a.result&&a.result.length>0&&JSON.parse(le.from(a.result).toString())}(i?f.nearArchivalConnection.provider:f.nearConnection.connection.provider,null!=i?i:void 0,e,t,r,a),c=()=>"optimistic"===a&&n.enableWeb4FastRpc?async function(e,t,r,n){r=r||{};const o=new URL("https://rpc.web4.near.page/account/".concat(e,"/view/").concat(t));Object.entries(r).forEach((e=>{let[t,r]=e;void 0!==r&&o.searchParams.append("".concat(t,".json"),JSON.stringify(r))}));try{return await(await fetch(o.toString())).json()}catch(e){return console.log("Web4 view call failed",o.toString()),console.error(e),n()}}(e,t,r,s):s();return e!==n.contractName||!i&&"final"!==a?c():(async(e,t,r,n,o)=>{if(!e.apiUrl||!pe.hasOwnProperty(t))return o();r=r||{},n&&(r.blockHeight=n);try{return await(await fetch("".concat(e.apiUrl,"/").concat(t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).json()}catch(e){return console.log("API call failed",t,r),console.error(e),o()}})(n,t,r,i,c)},f.block=e=>{const t=h(e);return(t.blockId?f.nearArchivalConnection.provider:f.nearConnection.connection.provider).block(t)},f.functionCall=(e,t,r,n,o)=>ye(f,e,t,r,n,o),f.sendTransactions=e=>we(f,e),f.isSignedIntoContract=async e=>async function(e,t){return(await me(e,t)).isSignedIn()}(f,e),f.signInAndSetPendingTransaction=async e=>async function(e,t){const r=t.contractName,n=await me(e,r);if(!n._walletBaseUrl){const n=c.utils.KeyPair.fromRandom("ed25519"),o=c.transactions.functionCallAccessKey(r,[]),i=n.getPublicKey(),a=await e.selector.then((e=>e.wallet())),s=(await a.getAccounts())[0],l=s.accountId,u=await a.signAndSendTransactions({transactions:[{receiverId:l,actions:[{type:"AddKey",params:{publicKey:i.toString(),accessKey:{permission:o.permission.functionCall}}}],gas:y.mul(30)},(()=>{const{contractName:e,methodName:r,args:n,gas:o,deposit:i}=t;return{receiverId:e,actions:[de(r,n,o.toFixed(0),i.toFixed(0))]}})()]}),d=ge(r);return await d.setKey(e.config.networkId,l,n),localStorage.setItem("".concat(r,"_wallet_auth_key"),JSON.stringify({accountId:l,allKeys:[s.publicKey]})),u}sessionStorage.setItem(ue,JSON.stringify(t)),n.requestSignIn({contractId:r,methodNames:[]})}(f,e),f.contract=function(e,t,r){const{viewMethods:n=[],changeMethods:o=[]}={viewMethods:["storage_balance_of","get","get_num_accounts","get_accounts_paged","is_write_permission_granted","keys"],changeMethods:["set","grant_write_permission","storage_deposit","storage_withdraw"]},i={near:e,contractId:t};return n.forEach((r=>{i[r]=n=>e.viewCall(t,r,n)})),o.forEach((r=>{i[r]=(n,o,i)=>e.functionCall(t,r,n,o,i)})),i}(f,n.contractName),f.accountState=e=>async function(e,t){const r=new c.Account(e.nearConnection.connection,t);return await r.state()}(f,e);const p=JSON.parse(sessionStorage.getItem(ue));if(p&&(console.log("found pending transaction",p),await me(f,p.contractName))){console.log("sending pending transaction",p);try{await we(f,[p])}catch(e){console.error("error sending pending transaction",e)}sessionStorage.removeItem(ue)}return f}const be=(0,s.singletonHook)({},(()=>{const[e,t]=(0,i.useState)(null);return{nearPromise:e,initNear:(0,i.useMemo)((()=>e=>{var r;const n=(null===(r=e.config)||void 0===r?void 0:r.networkId)||e.networkId,o="mainnet"!==n&&"testnet"!==n,i="testnet"===n?e:{...e,networkId:"testnet",config:void 0,keyStore:void 0,selector:void 0},a="mainnet"===n?e:{...e,networkId:"mainnet",config:void 0,keyStore:void 0,selector:void 0};return t(Promise.all([i,a].concat(o?e:[]).map(ve)).then((e=>e.map((e=>({...e,default:e.config.networkId===n}))))))}),[])}})),Ee=[],Se=(0,s.singletonHook)(Ee,(()=>{const[e,t]=(0,i.useState)(Ee),{nearPromise:r}=be();return(0,i.useEffect)((()=>{r&&r.then(t)}),[r]),e?{default:e.find((e=>e.default)),testnet:e.find((e=>"testnet"===e.config.networkId)),mainnet:e.find((e=>"mainnet"===e.config.networkId))}:e})),ke=e=>Se()[e||"default"]||null,xe=require("local-storage");var Ie,Ce,Ne,Oe,Be=r.n(xe);const Ae="near-social-vm:v01:",Te=Ae+":accountId:",Pe=Ae+":pretendAccountId:",Ue={loading:!0,signedAccountId:null!==(Ie=Be().get(Te))&&void 0!==Ie?Ie:void 0,pretendAccountId:null!==(Ce=Be().get(Pe))&&void 0!==Ce?Ce:void 0,accountId:null!==(Ne=null!==(Oe=Be().get(Pe))&&void 0!==Oe?Oe:Be().get(Te))&&void 0!==Ne?Ne:void 0,state:null,near:null},Re=async(e,t)=>{var r;const n=e.accountId;n?(Be().set(Te,n),e.config.walletConnectCallback(n)):Be().remove(Te);const o=null!==(r=Be().get(Pe))&&void 0!==r?r:void 0,i={loading:!1,signedAccountId:n,pretendAccountId:o,accountId:null!=o?o:n,state:null,near:e,refresh:async()=>await Re(e,t),startPretending:async r=>{r?Be().set(Pe,r):Be().remove(Pe),await Re(e,t)}};if(n){const[t,r]=await Promise.all([e.contract.storage_balance_of({account_id:n}),e.accountState(n)]);i.storageBalance=t,i.state=r}t(i)},je=(0,s.singletonHook)(Ue,(()=>{const[e,t]=(0,i.useState)(Ue),r=ke();return(0,i.useEffect)((()=>{r&&r.selector.then((e=>{e.store.observable.subscribe((async e=>{await async function(e,t){var r,n,o;if(e.connectedContractId=null===(r=t)||void 0===r||null===(r=r.contract)||void 0===r?void 0:r.contractId,e.connectedContractId&&e.connectedContractId!==e.config.contractName&&e.connectedContractId!==e.config.allowExternalContract){const r=await e.selector,n=await r.wallet();await n.signOut(),e.connectedContractId=null,t=r.store.getState()}if(e.accountId=null!==(n=null===(o=t)||void 0===o||null===(o=o.accounts)||void 0===o||null===(o=o[0])||void 0===o?void 0:o.accountId)&&void 0!==n?n:null,e.accountId){e.publicKey=null;try{var i;if("here-wallet"===(null===(i=t)||void 0===i?void 0:i.selectedWalletId)){const t=Be().get("herewallet:keystore");e.publicKey=c.KeyPair.fromString(t[e.config.networkId].accounts[e.accountId]).getPublicKey()}}catch(e){console.error(e)}if(!e.publicKey)try{var a;e.publicKey=c.KeyPair.fromString(Be().get("meteor-wallet"===(null===(a=t)||void 0===a?void 0:a.selectedWalletId)?"_meteor_wallet".concat(e.accountId,":").concat(e.config.networkId):"near-api-js:keystore:".concat(e.accountId,":").concat(e.config.networkId))).getPublicKey()}catch(e){console.error(e)}}}(r,e);try{await Re(r,t)}catch(e){console.error(e)}}))}))}),[r]),e})),Me=e=>{const t=ke(),r=je();if(t&&(!e||t.config.networkId===e))return r.accountId},_e=require("react-bootstrap/Modal");var qe=r.n(_e);const Fe=require("react-bootstrap/Alert");var Le=r.n(Fe);const De=require("react-bootstrap/Toast");var Je=r.n(De);const Ge=require("react-bootstrap/ToastContainer");var Ke=r.n(Ge);const ze=require("remark-gfm");var Ve=r.n(ze);const We=require("react-markdown");var $e=r.n(We);const Xe=require("react-syntax-highlighter"),He=require("react-syntax-highlighter/dist/esm/styles/prism"),Ye=require("mdast-util-find-and-replace"),Ze=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function Qe(){function e(e,t,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+e.length))||t.length<2||t.length>64)return!1;let n={type:"text",value:e};return n={type:"strong",children:[n],data:{hProperties:{accountId:t}}},n}return function(t){return(0,Ye.findAndReplace)(t,Ze,e),t}}const et=/#(\w+)/gi;function tt(){function e(e,t,r){if(/[\w`]/.test(r.input.charAt(r.index-1))||/[/\w`]/.test(r.input.charAt(r.index+e.length)))return!1;let n={type:"text",value:e};return n={type:"strong",children:[n],data:{hProperties:{hashtag:t}}},n}return function(t){return(0,Ye.findAndReplace)(t,et,e),t}}function rt(){return rt=Object.assign?Object.assign.bind():function(e){for(var t=1;t{const{onLink:t,onLinkClick:r,text:n,onMention:o,onHashtag:i,onImage:s,syntaxHighlighterProps:c}=e;return a().createElement($e(),{plugins:[],rehypePlugins:[],remarkPlugins:[Ve(),Qe,tt],children:n,components:{strong(e){var t,r;let{node:n,children:s,...c}=e;var l,u;return o&&null!==(t=n.properties)&&void 0!==t&&t.accountId?o(null===(l=n.properties)||void 0===l?void 0:l.accountId):i&&null!==(r=n.properties)&&void 0!==r&&r.hashtag?i(null===(u=n.properties)||void 0===u?void 0:u.hashtag):a().createElement("strong",c,s)},a:e=>{var n;let{node:o,...i}=e;return t?t({...i,href:null===(n=o.properties)||void 0===n?void 0:n.href}):r?a().createElement("a",rt({onClick:r},i)):a().createElement("a",rt({target:"_blank"},i))},img:e=>{let{node:t,...r}=e;return s?s({...r}):a().createElement("img",rt({className:"img-fluid"},r))},blockquote:e=>{let{node:t,...r}=e;return a().createElement("blockquote",rt({className:"blockquote"},r))},table:e=>{let{node:t,...r}=e;return a().createElement("table",rt({className:"table table-striped"},r))},code(e){let{node:t,inline:r,className:n,children:o,...i}=e;const s=/language-(\w+)/.exec(n||""),{wrapLines:l,lineProps:u,showLineNumbers:d,lineNumberStyle:f}=null!=c?c:{};return!r&&s?a().createElement(Xe.Prism,rt({children:String(o).replace(/\n$/,""),style:He.tomorrow,language:s[1],PreTag:"div",wrapLines:l,lineProps:u,showLineNumbers:d,lineNumberStyle:f},i)):a().createElement("code",rt({className:n},i),o)}}})},ot=require("idb"),it="ViewCall",at="Fetch",st="LocalStorage",ct="NotStarted",lt="InProgress",ut="Done",dt="Invalidated",ft="cache-v1";class ht{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"cacheDb",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;this.dbPromise=(0,ot.openDB)(e,1,{upgrade(e){e.createObjectStore(ft)}}),this.cache={},this.finalSynchronizationDelayMs=t}invalidateCallbacks(e,t){var r;if(null!==(r=e.invalidationCallbacks)&&void 0!==r&&r.length){const r=e.invalidationCallbacks;e.invalidationCallbacks=[],setTimeout((()=>{r.forEach((e=>{try{e()}catch{}}))}),t?this.finalSynchronizationDelayMs+50:50)}}async innerGet(e){return(await this.dbPromise).get(ft,e)}async innerSet(e,t){return(await this.dbPromise).put(ft,t,e)}cachedPromise(e,t,r,n){e=JSON.stringify(e);const o=this.cache[e]||{status:ct,invalidationCallbacks:[],result:null,time:(new Date).getTime()};if(this.cache[e]=o,A(r)||(r={onInvalidate:r}),r.onInvalidate&&o.invalidationCallbacks.push(r.onInvalidate),!o.subscription&&r.subscribe){const e=()=>{o.subscription=setTimeout((()=>{document.hidden?e():(o.subscription=null,o.status=dt,this.invalidateCallbacks(o,!1))}),5e3)};e()}return o.status===lt||o.status===ut&&o.time+3e5>(new Date).getTime()||(o.status!==ct||null!=n&&n.ignoreCache||this.innerGet(e).then((e=>{(e||null!=n&&n.forceCachedValue)&&o.status===lt&&(o.result=e,o.time=(new Date).getTime(),this.invalidateCallbacks(o,!1))})),o.status=lt,t&&t().then((t=>{o.status=ut,o.time=(new Date).getTime(),JSON.stringify(t)!==JSON.stringify(o.result)&&(o.result=t,this.innerSet(e,t),this.invalidateCallbacks(o,!1))})).catch((t=>{console.error(t),o.status=ut;const r=void 0;o.time=(new Date).getTime(),JSON.stringify(r)!==JSON.stringify(o.result)&&(o.result=r,this.innerSet(e,r),this.invalidateCallbacks(o,!1))}))),o.result}invalidateCache(e,t){const r=[],n="".concat(e.config.apiUrl,"/index");Object.keys(this.cache).forEach((o=>{let i;try{i=JSON.parse(o)}catch(e){return void console.error("Key deserialization failed",o)}if(i.action!==it||i.contractId!==e.config.contractName||i.blockId&&"optimistic"!==i.blockId&&"final"!==i.blockId)i.action===it&&i.contractId===t&&r.push([o,"final"===i.blockId]);else try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((e=>Z(i.methodName,e,t)))&&r.push([o,"final"===i.blockId])}catch{}if(i.action===at&&i.url===n)try{var s;const{action:e,key:n}=JSON.parse(null===(s=i.options)||void 0===s?void 0:s.body);e&&n&&Q(e,n,t)&&r.push([o,!0])}catch{}})),console.log("Cache invalidation",r),r.forEach((e=>{let[t,r]=e;const n=this.cache[t];n.status=dt,this.invalidateCallbacks(n,r)}))}cachedBlock(e,t,r,n){return this.cachedPromise({action:"Block",blockId:t},(()=>e.block(t)),r,n)}cachedViewCall(e,t,r,n,o,i,a){return this.cachedPromise({action:it,contractId:t,methodName:r,args:n,blockId:o},(()=>e.viewCall(t,r,n,o)),i,a)}async asyncFetch(e,t){var r,n,o,i;const a=null===(r=t)||void 0===r||null===(r=r.responseType)||void 0===r?void 0:r.toLowerCase();t={method:null===(n=t)||void 0===n?void 0:n.method,headers:null===(o=t)||void 0===o?void 0:o.headers,body:null===(i=t)||void 0===i?void 0:i.body};try{const r=await fetch(e,t),n=r.status,o=r.ok,i=r.headers.get("content-type"),s=o?await("arraybuffer"===a?r.arrayBuffer():"blob"===a?r.blob():"formdata"===a?r.formData():"json"===a?r.json():"text"===a?r.text():i&&-1!==i.indexOf("application/json")?r.json():r.text()):void 0;return{ok:o,status:n,contentType:i,body:s}}catch(e){return{ok:!1,error:e.message}}}cachedFetch(e,t,r,n){return this.cachedPromise({action:at,url:e,options:t},(()=>this.asyncFetch(e,t)),r,n)}cachedCustomPromise(e,t,r,n){return this.cachedPromise({action:"CustomPromise",key:e},(()=>t()),r,n)}socialGet(e,t,r,n,o,i,a){if(!e)return null;const s={keys:t=(t=Array.isArray(t)?t:[t]).map((e=>r?"".concat(e,"/**"):"".concat(e))),options:o};let c=this.cachedViewCall(e,e.config.contractName,"get",s,n,i,a);if(null===c)return null;if(1===t.length){const e=t[0].split("/");for(let t=0;te[t](...r)),n,o):null}}const pt=new ht,gt=new ht("secondaryCacheDb"),mt=(0,s.singletonHook)(pt,(()=>pt)),yt=(0,s.singletonHook)(gt,(()=>gt)),wt=e=>{const t=ke(),r=mt(),n=yt();return e&&e!==t.config.networkId?n:r},vt=require("react-uuid");var bt=r.n(vt);const Et=e=>{const t=JSON.stringify(e,null,2);return"```json\n".concat(t,"\n```")},St={page:"confirm_transactions"},kt="send_transaction_without_confirmation";function xt(e){var t,r;const n=(0,i.useState)(bt()()),o=ke(e.networkId),s=(Me(e.networkId),wt()),[c,l]=(0,i.useState)(!1),[u]=(0,i.useState)(e.transactions),[d,f]=(0,i.useState)(null),[h,p]=(0,i.useState)(!1),[g,m]=(0,i.useState)(null),y=e.widgetSrc,w=!(null===(t=null==o||null===(r=o.features)||void 0===r?void 0:r.bypassTransactionConfirmation)||void 0===t||!t),v=async(e,t)=>await s.asyncLocalStorageGet(St,{widgetSrc:e,contractId:t,type:kt}),b=w||u[0].contractName!==o.contract.contractId&&1===u.length&&!(u[0].deposit&&u[0].deposit.gt(0));(0,i.useEffect)((()=>{(async()=>{if(b){const e=u[0].contractName,t=await o.isSignedIntoContract(e),r=await v(y,e),n=w||!!(t&&r&&r[u[0].methodName]);if(f(n),n){l(!0);const e=await o.sendTransactions(u);l(!1),E(e)}}else f(!1)})()}),[]);const E=e.onHide,S=!!u;if(null===d)return a().createElement(a().Fragment,null);if(d){const e=u[0];return a().createElement(Ke(),{position:"bottom-end",className:"position-fixed"},a().createElement(Je(),{show:S,bg:"info"},a().createElement(Je().Header,null,"Sending transaction ",C),a().createElement(Je().Body,null,"Calling contract"," ",a().createElement("span",{className:"font-monospace"},e.contractName)," ","with method"," ",a().createElement("span",{className:"font-monospace"},e.methodName))))}return a().createElement(qe(),{size:"xl",centered:!0,scrollable:!0,show:S,onHide:E},a().createElement(qe().Header,{closeButton:!0},a().createElement(qe().Title,null,"Confirm Transaction")),a().createElement(qe().Body,null,u&&u.map(((e,t)=>a().createElement("div",{key:"".concat(n,"-").concat(t)},a().createElement("div",null,a().createElement("h4",null,"Transaction #",t+1)),a().createElement("div",null,a().createElement("span",{className:"text-secondary"},"Contract ID: "),a().createElement("span",{className:"font-monospace"},e.contractName)),a().createElement("div",null,a().createElement("span",{className:"text-secondary"},"Method name: "),a().createElement("span",{className:"font-monospace"},e.methodName)),e.deposit&&e.deposit.gt(0)&&a().createElement("div",null,a().createElement("span",{className:"text-secondary"},"Deposit: "),a().createElement("span",{className:"font-monospace"},_(e.deposit))),a().createElement("div",null,a().createElement("span",{className:"text-secondary"},"Gas: "),a().createElement("span",{className:"font-monospace"},q(e.gas))),a().createElement(nt,{text:Et(e.args)})))),b?a().createElement(a().Fragment,null,a().createElement("div",{class:"form-check form-switch"},a().createElement("input",{class:"form-check-input",type:"checkbox",id:"dontaskagaincheckbox",checked:h,onChange:()=>(async()=>{p(!h),m(null)})()}),a().createElement("label",{class:"form-check-label",for:"dontaskagaincheckbox"},"Don't ask again for sending similar transactions by"," ",a().createElement("span",{className:"font-monospace"},y))),g?a().createElement(Le(),{variant:"danger"},'There was an error when choosing "Don\'t ask again":'," ",g):a().createElement(a().Fragment,null)):a().createElement(a().Fragment,null)),a().createElement(qe().Footer,null,a().createElement("button",{className:"btn btn-success",disabled:c,onClick:async e=>{if(e.preventDefault(),l(!0),h){const t=u[0],r=t.contractName,n=t.methodName,i=await v(y,r)||{};i[n]=!0,s.localStorageSet(St,{widgetSrc:y,contractId:r,type:kt},i);try{if(!await o.isSignedIntoContract(r)){const e=await o.signInAndSetPendingTransaction(t);return l(!1),void E(e?e.find((e=>e.transaction.receiver_id===r)):e)}}catch(e){return m(e.message),void l(!1)}}const t=await o.sendTransactions(u);l(!1),E(t)}},c&&C," Confirm"),a().createElement("button",{className:"btn btn-secondary",onClick:E,disabled:c},"Close")))}const It=require("react-files");var Ct=r.n(It);const Nt=require("react-infinite-scroller");var Ot=r.n(Nt);const Bt=v.mul(2e3),At=v.mul(500),Tt=v.mul(500),Pt=v.mul(500),Ut=require("react-bootstrap");function Rt(){return Rt=Object.assign?Object.assign.bind():function(e){for(var t=1;t{const t=JSON.stringify(e,null,2);return"```json\n".concat(t,"\n```")},Mt={page:"commit"},_t="write_permission",qt=e=>{var t,r,n,o,s,c,l;const d=ke(e.networkId),f=Me(e.networkId),h=wt(),[p,g]=(0,i.useState)(!1),[m,w]=(0,i.useState)(0),[b,E]=(0,i.useState)(!1),[S,k]=(0,i.useState)(null),[x,I]=(0,i.useState)(null),[N,O]=(0,i.useState)(null),[B,A]=(0,i.useState)(!0),T=e.show,P=e.onHide,U=()=>{if(e.onCancel)try{e.onCancel()}catch(e){console.error(e)}P()},R=e.data,M=e.force,q=e.widgetSrc;(0,i.useEffect)((()=>{q?(O(null),h.asyncLocalStorageGet(Mt,{widgetSrc:q,accountId:f,type:_t}).then((e=>O(e)))):O(!1)}),[q,f,h,T]),(0,i.useEffect)((()=>{A(!1!==N)}),[N]),(0,i.useEffect)((()=>{if(b||!T||!f||!d)return;const e=JSON.stringify(null!=R?R:null);(M||e!==S)&&(k(e),I(null),(async(e,t,r,n)=>{await e.selector;const o=e.accountId;if(!o)return void alert("You're not logged in. Sign in to commit data.");const[i,a]=await Promise.all([e.viewCall(e.config.contractName,"get_account_storage",{account_id:o}),o!==t?e.viewCall(e.config.contractName,"is_write_permission_granted",{predecessor_id:o,key:t}):Promise.resolve(!0)]),s=u()((null==i?void 0:i.available_bytes)||"0");let c={[t]:X(r)},l={};n||(l=await(async(e,t)=>{const r=V(t);return await e.contract.get({keys:r})})(e,c),c=W(c,l));const d=v.mul(z(c,l)).add(i?u()(0):At).add(a?u()(0):Pt).add(Tt),f=j(d.sub(s.mul(v)),i?a?u()(0):u()(1):Bt);return{originalData:r,accountId:t,accountStorage:i,availableBytes:s,currentData:l,data:c,expectedDataBalance:d,deposit:f,permissionGranted:a}})(d,f,R,M).then(I))}),[b,R,S,M,d,f,T]);const F=async()=>{E(!0);const t=B&&te(N,x.data[f]);h.localStorageSet(Mt,{widgetSrc:q,accountId:f,type:_t},t),O(t);const r=x.deposit.add(v.mul(m));if(x.permissionGranted?await(async(e,t,r)=>(console.log("Committing data",t),await e.contract.set({data:t},y.mul(100).toFixed(0),r.toFixed(0))))(d,x.data,r):f===d.accountId?await(async(e,t,r)=>{const n=await(await e.selector).wallet(),o=[];return e.publicKey&&(o.push(de("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},y.mul(100).toFixed(0),r.gt(0)?r.toFixed(0):"1")),r=u()(0)),o.push(de("set",{data:t},y.mul(100).toFixed(0),r.gt(0)?r.toFixed(0):"1")),await n.signAndSendTransaction({receiverId:e.config.contractName,actions:o})})(d,x.data,r):alert("No permission to commit under given account"),I(null),k(null),e.onCommit)try{e.onCommit(x.data)}catch(e){console.error(e)}h.invalidateCache(d,x.data),P(),E(!1)},L=x&&!x.permissionGranted&&f!==d.accountId;!b&&!L&&!p&&x&&T&&N&&x.data&&x.deposit.add(v.mul(m)).eq(0)&&x.permissionGranted&&JSON.stringify(te(N,x.data[f]))===JSON.stringify(N)&&(g(!0),F().then((()=>g(!1))));const D={authorIds:null!==(t=null==d||null===(r=d.features)||void 0===r||null===(r=r.commitModalBypass)||void 0===r?void 0:r.authorIds)&&void 0!==t?t:[],sources:null!==(n=null==d||null===(o=d.features)||void 0===o||null===(o=o.commitModalBypass)||void 0===o?void 0:o.sources)&&void 0!==n?n:[],bypassAll:!(null===(s=null==d||null===(c=d.features)||void 0===c||null===(c=c.commitModalBypass)||void 0===c?void 0:c.bypassAll)||void 0===s||!s)},[J]=(null!=q?q:"").split("/"),G=D.bypassAll||!!J&&D.authorIds.indexOf(J)>-1||!!q&&D.sources.indexOf(q.split("@")[0])>-1,K=!L&&G,$=!!x&&T&&!p&&null!==N,H=$&&!K;return(0,i.useEffect)((()=>{$&&K&&!b&&F()}),[$,K,b]),a().createElement(qe(),{size:"xl",centered:!0,scrollable:!0,show:H,onHide:U},a().createElement(qe().Header,{closeButton:!0},a().createElement(qe().Title,null,"Saving data")),a().createElement(qe().Body,null,L?a().createElement("div",null,a().createElement("h5",null,"Can't commit, because the account ",d.accountId," doesn't have permission to write under pretended account ",f)):x?a().createElement("div",null,a().createElement("div",null,x.data?a().createElement(nt,{text:jt(x.data)}):a().createElement("h5",null,"No new data to save")),x.data&&(null==x||null===(l=x.deposit)||void 0===l?void 0:l.gt(0))&&a().createElement("div",null,a().createElement("h6",null,"Required storage deposit"," ",a().createElement("small",{className:"text-secondary"},"(can be recovered later)")),a().createElement("div",{className:"mb-2"},x.deposit.div(v).toFixed(0)," bytes ="," ",_(x.deposit)),a().createElement("h6",null,"Optional storage deposit"," ",a().createElement("small",{className:"text-secondary"},"(can be used to avoid future wallet TX confirmation)")),a().createElement("div",null,a().createElement(Ut.ToggleButtonGroup,{type:"radio",name:"storageDeposit",value:m,onChange:w,disabled:b},a().createElement(Ut.ToggleButton,{id:"esd-0",variant:"outline-success",value:0},"No Deposit"),a().createElement(Ut.ToggleButton,{id:"esd-5000",variant:"outline-success",value:5e3},"0.05 NEAR (5Kb)"),a().createElement(Ut.ToggleButton,{id:"esd-20000",variant:"outline-success",value:2e4},"0.2 NEAR (20Kb)"),a().createElement(Ut.ToggleButton,{id:"esd-100000",variant:"outline-success",value:1e5},"1 NEAR (100Kb)")))),!L&&q&&x.data&&a().createElement("div",{className:"form-check form-switch"},a().createElement("input",{className:"form-check-input",type:"checkbox",role:"switch",id:"dont-ask-for-widget",checked:B,onChange:e=>{A(e.target.checked)}}),a().createElement("label",{className:"form-check-label",htmlFor:"dont-ask-for-widget"},"Don't ask again for saving similar data by"," ",a().createElement("span",{className:"font-monospace"},q)))):C),a().createElement(qe().Footer,null,a().createElement("button",{className:"btn btn-success",disabled:!(null!=x&&x.data)||b||L,onClick:e=>{e.preventDefault(),F()}},b&&C," Save Data"),a().createElement("button",{className:"btn btn-secondary",onClick:U,disabled:b},"Close")))},Ft=e=>{const t=Me(e.networkId),{data:r,children:n,onClick:o,onCommit:s,onCancel:c,disabled:l,widgetSrc:u,force:d,...f}=e,[h,p]=(0,i.useState)(null);return a().createElement(a().Fragment,null,a().createElement("button",Rt({},f,{disabled:l||!r||!!h||!t,onClick:e=>{e.preventDefault(),p("function"==typeof r?r():r),o&&o()}}),!!h&&C,n),a().createElement(qt,{show:!!h,widgetSrc:u,data:h,force:d,onHide:()=>p(null),onCancel:c,onCommit:s}))},Lt=require("react-bootstrap-typeahead"),Dt=require("styled-components");var Jt=r.n(Dt);const Gt=require("elliptic"),Kt=require("tweetnacl"),zt=require("iframe-resizer-react");var Vt=r.n(zt);function Wt(){return Wt=Object.assign?Object.assign.bind():function(e){for(var t=1;t{e.source===w.current.contentWindow&&d&&d(e.data)}),[w,d]),E=()=>{g(!0),u&&u()};return(0,i.useEffect)((()=>(window.addEventListener("message",b,!1),()=>{window.removeEventListener("message",b,!1)})),[b]),(0,i.useEffect)((()=>{if(w.current&&p&&!se(m,l)){if(y(ie(l)),f)return void w.current.sendMessage(l,"*");w.current.contentWindow.postMessage(l,"*")}}),[l,w,p,m]),(0,i.useEffect)((()=>{g(!1)}),[o,s]),f?a().createElement(Vt(),Wt({},(()=>{const e={...h,style:null!=n?n:{width:"1px",minWidth:"100%"},checkOrigin:!1},t="object"==typeof f?f:{},r=["log","autoResize","bodyBackground","bodyMargin","bodyPadding","inPageLinks","heightCalculationMethod","maxHeight","maxWidth","minHeight","minWidth","minWidth","resizeFrom","scrolling","sizeHeight","sizeWidth","tolerance","widthCalculationMethod"];return Object.keys(t).forEach((n=>{r.includes(n)&&(e[n]=t[n])})),t.onResized&&(e.onResized=e=>{let{height:r,width:n}=e;t.onResized({height:r,width:n})}),e})(),{forwardRef:w,sandbox:v,onLoad:E})):a().createElement("iframe",Wt({},h,{ref:w,sandbox:v,onLoad:E}))}const Xt=require("nanoid"),Ht=require("lodash.clonedeep");var Yt=r.n(Ht);const Zt=require("acorn"),Qt=require("acorn-jsx");var er=r.n(Qt);const tr=a().createContext(null),rr=e=>{var t,r,n;const o=(0,i.useContext)(tr),[{wallet:s,connecting:c},l,u]=null!=o&&o.useConnectWallet?null==o?void 0:o.useConnectWallet():[{}];return a().createElement("button",{className:"btn ".concat(e.className," ").concat(c||s?"btn-outline-secondary":"btn-outline-primary"),disabled:(s?!u:!l)||c,onClick:()=>s?null==u?void 0:u(s):null==l?void 0:l()},c?null!==(t=e.connectingLabel)&&void 0!==t?t:"Connecting":s?null!==(r=e.disconnectLabel)&&void 0!==r?r:"Disconnect Web3 Wallet":null!==(n=e.connectLabel)&&void 0!==n?n:"Connect Web3 Wallet")},nr=require("dompurify"),or=require("@radix-ui/react-accordion"),ir=require("@radix-ui/react-alert-dialog"),ar=require("@radix-ui/react-aspect-ratio"),sr=require("@radix-ui/react-avatar"),cr=require("@radix-ui/react-checkbox"),lr=require("@radix-ui/react-collapsible"),ur=require("@radix-ui/react-context-menu"),dr=require("@radix-ui/react-dialog"),fr=require("@radix-ui/react-dropdown-menu"),hr=require("@radix-ui/react-hover-card"),pr=require("@radix-ui/react-label"),gr=require("@radix-ui/react-menubar"),mr=require("@radix-ui/react-navigation-menu"),yr=require("@radix-ui/react-popover"),wr=require("@radix-ui/react-progress"),vr=require("@radix-ui/react-radio-group"),br=require("@radix-ui/react-scroll-area"),Er=require("@radix-ui/react-select"),Sr=require("@radix-ui/react-separator"),kr=require("@radix-ui/react-slider"),xr=require("@radix-ui/react-switch"),Ir=require("@radix-ui/react-tabs"),Cr=require("@radix-ui/react-toast"),Nr=require("@radix-ui/react-toggle"),Or=require("@radix-ui/react-toggle-group"),Br=require("@radix-ui/react-toolbar"),Ar=require("@radix-ui/react-tooltip");var Tr=r(686).hp;function Pr(){return Pr=Object.assign?Object.assign.bind():function(e){for(var t=1;tbtoa(e),atob:e=>atob(e),decodeURI,encodeURI,nacl:{randomBytes:Kt.randomBytes,secretbox:Kt.secretbox,scalarMult:Kt.scalarMult,box:Kt.box,sign:Kt.sign,hash:Kt.hash,verify:Kt.verify},ethers:{utils:(Gr=ie(h.ethers.utils),["checkProperties","deepCopy","defineReadOnly","getStatic","resolveProperties","shallowCopy"].forEach((e=>{delete Gr[e]})),Gr),BigNumber:h.ethers.BigNumber,Contract:h.ethers.Contract,providers:h.ethers.providers},nanoid:{nanoid:Xt.nanoid,customAlphabet:Xt.customAlphabet},Promise,Date,Number,String,Big:u(),Math,Buffer:Tr,Audio,Image,File,Blob,FileReader,URL,Array,BN:g(),Uint8Array,Map,Set}));var Gr;const Kr={[ne]:!0,constructor:!0,prototype:!0,__proto__:!0,__defineGetter__:!0,__defineSetter__:!0,__lookupGetter__:!0,__lookupSetter__:!0},zr={ecmaVersion:13,allowReturnOutsideFunction:!0},Vr=new Map,Wr=Zt.Parser.extend(er()()),$r=e=>{if(!0===Kr[e])throw new Error("".concat(e," is reserved and can't be used"))},Xr=e=>{if(jr.has(e))throw new Error("Native prototypes shouldn't be used")},Hr=e=>{if(Xr(e),oe(e))throw new Error("React objects shouldn't be dereferenced")},Yr=e=>{Hr(e),null!==e&&"object"==typeof e&&Object.entries(e).forEach((e=>{let[t,r]=e;$r(t),Yr(r)}))},Zr=e=>{if(!e||"string"!=typeof e)return;if(!Object.keys(Fr).includes(e.split(".")[0]))return;const t=e.split(".").reduce(((e,t)=>e[t]),Fr);if(void 0===t)throw new Error('"'.concat(e,'" is not a valid Radix component'));return t},Qr=(e,t)=>e&&(null==t||"final"===t||"optimistic"===t),en=e=>{if("Identifier"!==e.type)throw new Error("Non identifier: "+e.type);const t=e.name;if($r(t),Dr.hasOwnProperty(t))throw new Error("Cannot use keyword: "+t);return{type:"Identifier",name:t}},tn=e=>{if("JSXIdentifier"!==e.type)throw new Error("Non JSXIdentifier: "+e.type);return e.name},rn=e=>{if("JSXIdentifier"===e.type)return e.name;if("JSXMemberExpression"===e.type)return rn(e.object)+"."+tn(e.property);throw new Error("Non JSXIdentifier or JSXMemberExpression: "+e.type)},nn=e=>{if("Identifier"===e.type)return en(e);if("ArrayPattern"===e.type)return{type:"ArrayPattern",elements:e.elements.map(nn)};if("ObjectPattern"===e.type)return{type:"ObjectPattern",properties:e.properties.map((e=>{if("Property"===e.type)return{key:en(e.key),value:nn(e.value)};if("RestElement"===e.type)return{type:"RestElement",argument:en(e.argument)};throw new Error("Unknown property type: "+e.type)}))};if("RestElement"===e.type)return{type:"RestElement",argument:en(e.argument)};throw new Error("Unknown pattern: "+e.type)},on=["key","name","className","onChange","onError","accepts","multiple","clickable","maxFiles","maxFileSize","minFileSize","dragActiveClassName"],an=e=>{const t={};return on.forEach((r=>{e.hasOwnProperty(r)&&(t[r]=e[r])})),t};class sn{constructor(e,t){this.prevStack=e,this.state=t}findObj(e){return this.state.hasOwnProperty(e)?this.state:this.prevStack?this.prevStack.findObj(e):void 0}get(e){return this.state.hasOwnProperty(e)?this.state[e]:this.prevStack?this.prevStack.get(e):void 0}}class cn{constructor(e,t,r,n){this.gIndex=0,this.hookIndex=0,this.vm=e,this.isTrusted=!!n,this.stack=new sn(t,r)}newStack(e){return new cn(this.vm,this.stack,{},this.isTrusted||!!e)}executeExpression(e){const t=this.executeExpressionInternal(e);return Xr(t),t}renderElement(e){var t,r;let n="JSXFragment"===e.type?"Fragment":rn(e.openingElement.name),o=Lr[n],i=null;void 0===o&&this.vm.near.config.customElements.hasOwnProperty(n)&&(o=!0,i=this.vm.near.config.customElements[n]);const s=Zr(n),c=void 0===o&&this.executeExpression(e.openingElement.name);if(void 0===o&&!s){if(void 0===c)throw new Error("Unknown element: "+n);if(!(0,Dt.isStyledComponent)(c)&&"function"!=typeof c)throw new Error("Unsupported component: "+n)}let l={};const u={};"input"===n?l.className="form-control":"CommitButton"===n?l.className="btn btn-success":"button"===n?l.className="btn btn-primary":"IpfsImageUpload"===n&&(l.className="btn btn-outline-primary");const d={};var f;("JSXFragment"===e.type?e.openingFragment:e.openingElement).attributes.forEach((e=>{if("JSXAttribute"===e.type){const t=tn(e.name);l[t]=null===e.value||this.executeExpression(e.value),"value"!==t&&"image"!==t&&"onChange"!==t||(d[t]=e.value)}else{if("JSXSpreadAttribute"!==e.type)throw new Error("Unknown attribute type: "+e.type);{const t=this.executeExpression(e.argument);Object.assign(l,t)}}})),"forwardedRef"===l.ref&&(l={...l,...this.vm.forwardedProps}),Object.entries(d).forEach((e=>{let[t,r]=e;if("value"!==t||"input"!==n||"text"!==l.type||"JSXExpressionContainer"!==r.type||"onChange"in d){if("image"===t&&"IpfsImageUpload"===n&&"JSXExpressionContainer"===r.type){const{obj:e,key:t}=this.resolveMemberExpression(r.expression,{requireState:!0,left:!0});u.img=e[t],l.onChange=n=>{(null==n?void 0:n.length)>0?(e[t]={uploading:!0,cid:null},this.vm.setReactState(this.vm.state.state),G(n[0]).then((e=>{if(!this.vm.alive)return;const{obj:t,key:n}=this.vm.vmStack.resolveMemberExpression(r.expression,{requireState:!0,left:!0});t[n]={cid:e},this.vm.setReactState(this.vm.state.state)}))):(e[t]=null,this.vm.setReactState(this.vm.state.state))}}}else{const{obj:e,key:t}=this.resolveMemberExpression(r.expression,{requireState:!0,left:!0});l.value=(null==e?void 0:e[t])||"",l.onChange=r=>{r.preventDefault(),e[t]=r.target.value,this.vm.setReactState(this.vm.state.state)}}})),l.key=null!==(t=l.key)&&void 0!==t?t:"".concat(this.vm.widgetSrc,"-").concat(n,"-").concat(this.vm.gIndex),1==(null===(r=this.vm.near)||void 0===r||null===(r=r.features)||void 0===r?void 0:r.enableComponentSrcDataKey)&&(l["data-component"]=null!==(f=l["data-component"])&&void 0!==f?f:this.vm.widgetSrc),delete l.dangerouslySetInnerHTML,delete l.is;const h=(0,Dt.isStyledComponent)(c)&&(null==c?void 0:c.target)||n;var p;if(l.as&&!qr[l.as]&&delete l.as,l.forwardedAs&&!qr[l.forwardedAs]&&delete l.forwardedAs,"img"===h)l.alt=null!==(p=l.alt)&&void 0!==p?p:"not defined";else if("a"===h||"use"===h)Object.entries(l).forEach((e=>{let[t,r]=e;"href"===t.toLowerCase()&&(l[t]=T(r)&&(0,nr.isValidAttribute)("a","href",r)?r:"about:blank")}));else if("set"===h){if("href"===l.attributeName||"xlink:href"===l.attributeName||"is"===l.attributeName)return a().createElement(a().Fragment,null)}else"Widget"===n?(l.depth=this.vm.depth+1,l.config=[l.config,...this.vm.widgetConfigs].filter(Boolean)):"CommitButton"===n&&(l.networkId=this.vm.networkId);if(!1===o&&e.children.length)throw new Error("And element '"+n+"' contains children, but shouldn't");const g=e.children.map(((e,t)=>(this.vm.gIndex=t,this.executeExpression(e))));if(i)return i({...l,children:g});if(c)return(0,Dt.isStyledComponent)(c)?a().createElement(c,{...l},...g):c({children:g,...l});if("Widget"===n)return a().createElement(dn,l);if("CommitButton"===n)return a().createElement(Ft,Pr({},l,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===n)return a().createElement(Ot(),l,g);if("Tooltip"===n)return a().createElement(Ut.Tooltip,l,g);if("OverlayTrigger"===n)return a().createElement(Ut.OverlayTrigger,l,g.filter((e=>!T(e)||!!e.trim()))[0]);if("Typeahead"===n)return a().createElement(Lt.Typeahead,l);if("Markdown"===n)return a().createElement(nt,l);if("Fragment"===n){const{"data-component":e,...t}=l;return a().createElement(a().Fragment,t,g)}var m,y,w,v;if("IpfsImageUpload"===n)return a().createElement("div",{className:"d-inline-block",key:l.key},(null===(m=u.img)||void 0===m?void 0:m.cid)&&a().createElement("div",{className:"d-inline-block me-2 overflow-hidden align-middle",style:{width:"2.5em",height:"2.5em"}},a().createElement("img",{className:"rounded w-100 h-100",style:{objectFit:"cover"},src:K(null===(y=u.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),a().createElement(Ct(),Pr({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},an(l)),null!==(w=u.img)&&void 0!==w&&w.uploading?a().createElement(a().Fragment,null,C," Uploading"):null!==(v=u.img)&&void 0!==v&&v.cid?"Replace":"Upload an Image"));if("Files"===n)return a().createElement(Ct(),an(l),g);if("iframe"===n)return a().createElement($t,l);if("Web3Connect"===n)return a().createElement(rr,l);if(s){if(n.includes("Portal"))throw new Error("Radix's \"".concat(n,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));let e=g;return Array.isArray(e)&&(e=e.filter((e=>"string"!=typeof e||""!==e.trim())),1===e.length?e=e[0]:0===e.length&&(e=void 0)),a().createElement(s,l,e)}if(!0===o)return a().createElement(n,{...l},...g);if(!1===o)return a().createElement(n,{...l});throw new Error("Unsupported element: "+n)}resolveKey(e,t){const r=t||"Identifier"!==e.type&&"JSXIdentifier"!==e.type?this.executeExpression(e):e.name;return $r(r),r}resolveMemberExpression(e,t){if("Identifier"===e.type||"JSXIdentifier"===e.type){var r;const n=e.name;if($r(n),null!=t&&t.requireState&&n!==Ur)throw new Error("The top object should be ".concat(Ur));const o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(Hr(o),o===this.stack.state&&Dr.hasOwnProperty(n)){if(null!=t&&t.left)throw new Error("Cannot assign to keyword '"+n+"'");return{obj:o,key:n,keyword:n}}if(null!=t&&t.left&&(!o||!o.hasOwnProperty(n)))throw new Error("Accessing undeclared identifier '".concat(e.name,"'"));return{obj:o,key:n}}if("MemberExpression"===e.type||"JSXMemberExpression"===e.type){var n,o;if("Identifier"===(null===(n=e.object)||void 0===n?void 0:n.type)||"JSXIdentifier"===(null===(o=e.object)||void 0===o?void 0:o.type)){const r=e.object.name;if(Dr.hasOwnProperty(r)){if(null==t||!t.callee)throw new Error("Cannot dereference keyword '"+r+"' in non-call expression");return{obj:this.stack.state,key:this.resolveKey(e.property,e.computed),keyword:r}}}const r=this.executeExpression(e.object);return Hr(r),{obj:r,key:this.resolveKey(e.property,e.computed)}}throw new Error("Unsupported member type: '"+e.type+"'")}getArray(e){const t=[];return e.forEach((e=>{"SpreadElement"===e.type?t.push(...this.executeExpression(e.argument)):t.push(this.executeExpression(e))})),t}executeExpressionInternal(e){if(!e)return null;const t=null==e?void 0:e.type;if("AssignmentExpression"===t){const{obj:t,key:n}=this.resolveMemberExpression(e.left,{left:!0}),o=this.executeExpression(e.right);if("="===e.operator)return t[n]=o;if("+="===e.operator)return t[n]+=o;if("-="===e.operator)return t[n]-=o;if("*="===e.operator)return t[n]*=o;if("/="===e.operator)return t[n]/=o;var r;if("??="===e.operator)return null!==(r=t[n])&&void 0!==r?r:t[n]=o;throw new Error("Unknown AssignmentExpression operator '"+e.operator+"'")}if("ChainExpression"===t)return this.executeExpression(e.expression);if("MemberExpression"===t||"JSXMemberExpression"===t){const{obj:t,key:r}=this.resolveMemberExpression(e);return null==t?void 0:t[r]}if("Identifier"===t||"JSXIdentifier"===t)return this.stack.get(e.name);if("JSXExpressionContainer"===t)return this.executeExpression(e.expression);if("TemplateLiteral"===t){const t=[];for(let r=0;r"===e.operator)return t>r;if("<="===e.operator)return t<=r;if(">="===e.operator)return t>=r;if("==="===e.operator||"=="===e.operator)return t===r;if("!=="===e.operator||"!="===e.operator)return t!==r;if("in"===e.operator)return t in r;throw new Error("Unknown BinaryExpression operator '"+e.operator+"'")}if("UnaryExpression"===t){if("delete"===e.operator){const{obj:t,key:r}=this.resolveMemberExpression(e.argument,{left:!0});return null==t||delete t[r]}const t=this.executeExpression(e.argument);if("-"===e.operator)return-t;if("!"===e.operator)return!t;if("typeof"===e.operator)return typeof t;throw new Error("Unknown UnaryExpression operator '"+e.operator+"'")}if("LogicalExpression"===t){const t=this.executeExpression(e.left);if("||"===e.operator)return t||this.executeExpression(e.right);if("&&"===e.operator)return t&&this.executeExpression(e.right);if("??"===e.operator)return null!=t?t:this.executeExpression(e.right);throw new Error("Unknown LogicalExpression operator '"+e.operator+"'")}if("ConditionalExpression"===t)return this.executeExpression(e.test)?this.executeExpression(e.consequent):this.executeExpression(e.alternate);if("UpdateExpression"===t){const{obj:t,key:r}=this.resolveMemberExpression(e.argument,{left:!0});if("++"===e.operator)return e.prefix?++t[r]:t[r]++;if("--"===e.operator)return e.prefix?--t[r]:t[r]--;throw new Error("Unknown UpdateExpression operator '"+e.operator+"'")}if("ObjectExpression"===t)return e.properties.reduce(((e,t)=>{if("Property"===t.type)e[this.resolveKey(t.key,t.computed)]=this.executeExpression(t.value);else{if("SpreadElement"!==t.type)throw new Error("Unknown property type: "+t.type);{const r=this.executeExpression(t.argument);Hr(r),Object.assign(e,r)}}return e}),{});if("ArrayExpression"===t)return this.getArray(e.elements);if("JSXEmptyExpression"===t)return null;if("ArrowFunctionExpression"===t)return this.createFunction(e.params,e.body,e.expression);if("TaggedTemplateExpression"===t){let t,r;if("MemberExpression"!==e.tag.type&&"CallExpression"!==e.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");{const{key:o,keyword:i}=this.resolveMemberExpression("MemberExpression"===e.tag.type?e.tag:e.tag.callee,{callee:!0});if("styled"!==i)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===e.tag.type){var n;const r=this.getArray(e.tag.arguments),o=null==r?void 0:r[0],i=Zr(o),a=this.vm.near.config.customElements[o];if(!(0,Dt.isStyledComponent)(o)&&!i&&!a)throw new Error('styled() can only take `styled` components, Radix component names (EG: "Accordion.Trigger"), or a customElement name (EG: "Link")');t=Jt()(null!==(n=null!=a?a:i)&&void 0!==n?n:o)}else{if("keyframes"===o)t=Dt.keyframes;else{if(!qr.hasOwnProperty(o))throw new Error("Unsupported styled tag: "+o);t=Jt()(o)}r=o}}if("TemplateLiteral"!==e.quasi.type)throw new Error("Unknown quasi type: "+e.quasi.type);const o=e.quasi.quasis.map((e=>{if("TemplateElement"!==e.type)throw new Error("Unknown quasis type: "+e.type);return e.value.cooked})),i=0===e.quasi.expressions.length&&"CallExpression"!==e.tag.type,a=JSON.stringify([r,...o]);if(i&&this.vm.cachedStyledComponents.has(a))return this.vm.cachedStyledComponents.get(a);const s=e.quasi.expressions.map((e=>this.executeExpression(e)));if(t instanceof Function){const e=t(o,...s);return i&&this.vm.cachedStyledComponents.set(a,e),e}throw new Error("styled error")}throw console.log(e),new Error("Unknown expression type '"+t+"'")}createFunction(e,t,r){var n=this;return e=e.map(nn),function(){for(var o,i,a,s=arguments.length,c=new Array(s),l=0;l{let r,n=null==c?void 0:c[t];if(void 0!==n)try{var o,i,a,s,l,u,f,h,p;if((null===(o=n)||void 0===o?void 0:o.nativeEvent)instanceof Event){const e=n;n=n.nativeEvent,n._preventDefault=()=>e.preventDefault(),n._stopPropagation=()=>e.stopPropagation(),n._isDefaultPrevented=()=>e.isDefaultPrevented(),n._isPropagationStopped=()=>e.isPropagationStopped()}n instanceof Event?n=ae({target:n.target?ae({value:null===(i=n.target)||void 0===i?void 0:i.value,id:null===(a=n.target)||void 0===a?void 0:a.id,dataset:null===(s=n.target)||void 0===s?void 0:s.dataset,href:null===(l=n.target)||void 0===l?void 0:l.href,checked:null===(u=n.target)||void 0===u?void 0:u.checked}):void 0,data:n.data,code:n.code,key:n.key,ctrlKey:n.ctrlKey,altKey:n.altKey,shiftKey:n.shiftKey,metaKey:n.metaKey,button:n.button,buttons:n.buttons,clientX:n.clientX,clientY:n.clientY,screenX:n.screenX,screenY:n.screenY,touches:n.touches,preventDefault:null!==(f=n._preventDefault)&&void 0!==f?f:n.preventDefault,stopPropagation:null!==(h=n._stopPropagation)&&void 0!==h?h:n.stopPropagation,defaultPrevented:n.defaultPrevented,isDefaultPrevented:null!==(p=n._isDefaultPrevented)&&void 0!==p?p:()=>n.defaultPrevented,isPropagationStopped:n._isPropagationStopped}):n instanceof Error&&(n=ae({type:n.type,name:n.name,message:n.message})),r=ie(n)}catch(e){console.warn(e)}d.stackDeclare(e,r)})),r?d.executeExpression(t):null===(a=d.executeStatement(t))||void 0===a?void 0:a.result}}stackDeclare(e,t){if("Identifier"===e.type)this.stack.state[e.name]=t;else if("ArrayPattern"===e.type)Hr(t),e.elements.forEach(((e,r)=>{"RestElement"===e.type?this.stackDeclare(e.argument,t.slice(r)):this.stackDeclare(e,null==t?void 0:t[r])}));else{if("ObjectPattern"!==e.type)throw new Error("Unknown pattern type: "+e.type);{Hr(t);const r=new Set;e.properties.forEach((e=>{if("RestElement"===e.type){const n={};A(t)&&(Object.assign(n,t),r.forEach((e=>delete n[e]))),this.stackDeclare(e.argument,n)}else this.stackDeclare(e.value,null==t?void 0:t[e.key.name]),r.add(e.key.name)}))}}}executeStatement(e){if(!e||"EmptyStatement"===e.type)return null;if("VariableDeclaration"===e.type)e.declarations.forEach((e=>{if("VariableDeclarator"!==e.type)throw new Error("Unknown variable declaration type '"+e.type+"'");this.stackDeclare(nn(e.id),this.executeExpression(e.init))}));else{if("ReturnStatement"===e.type)return{result:this.executeExpression(e.argument)};if("FunctionDeclaration"===e.type)this.stackDeclare(en(e.id),this.createFunction(e.params,e.body,e.expression));else if("ExpressionStatement"===e.type)this.executeExpression(e.expression);else if("BlockStatement"===e.type||"Program"===e.type){const t=e.body,r=this.newStack();for(let e=0;e0&&(!e.test||t.executeExpression(e.test));){const r=t.executeStatement(e.body);if(r){if(r.break)break;if(!r.continue)return r}t.executeExpression(e.update)}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("ForOfStatement"===e.type){const t=this.newStack(),r=t.executeExpression(e.right);Hr(r);for(const n of r){if(this.vm.loopLimit--<=0)throw new Error("Exceeded loop limit");if("VariableDeclaration"===e.left.type){if(1!==e.left.declarations.length)throw new Error("Invalid for-of statement");e.left.declarations.forEach((e=>{if("VariableDeclarator"!==e.type)throw new Error("Unknown variable declaration type '"+e.type+"'");this.stackDeclare(nn(e.id),n)}))}else{const{obj:t,key:r}=this.resolveMemberExpression(e.left,{left:!0});t[r]=n}const r=t.executeStatement(e.body);if(r){if(r.break)break;if(!r.continue)return r}}}else if("WhileStatement"===e.type){const t=this.newStack();for(;this.vm.loopLimit-- >0&&t.executeExpression(e.test);){const r=t.executeStatement(e.body);if(r){if(r.break)break;if(!r.continue)return r}}if(this.vm.loopLimit<=0)throw new Error("Exceeded loop limit")}else if("IfStatement"===e.type){const t=this.executeExpression(e.test),r=this.newStack(),n=t?r.executeStatement(e.consequent):r.executeStatement(e.alternate);if(n)return n}else{if("BreakStatement"===e.type)return{break:!0};if("ContinueStatement"===e.type)return{continue:!0};if("ThrowStatement"===e.type)throw this.executeExpression(e.argument);if("TryStatement"===e.type)try{const t=this.newStack().executeStatement(e.block);if(t)return t}catch(t){if(!this.vm.alive||!e.handler)return null;if("CatchClause"!==e.handler.type)throw new Error("Unknown try statement handler type '"+e.handler.type+"'");const r=this.newStack();e.handler.param&&r.stackDeclare(en(e.handler.param),ie(t instanceof Error?{name:null==t?void 0:t.name,message:null==t?void 0:t.message,toString:()=>t.toString()}:t));const n=r.executeStatement(e.handler.body);if(n)return n}finally{this.vm.alive&&this.newStack().executeStatement(e.finalizer)}else{if("SwitchStatement"!==e.type)throw new Error("Unknown token type '"+e.type+"'");{const t=this.executeExpression(e.discriminant),r=this.newStack(),n=e.cases;let o=!1;for(const e of n){if("SwitchCase"!==e.type)throw new Error("Unknown switch case type '"+e.type+"'");if(!o&&null!==e.test&&r.executeExpression(e.test)!==t)continue;o=!0;let n=!1;for(const t of e.consequent){const e=r.executeStatement(t);if(e){if(e.break){n=!0;break}return e}}if(n)break}}}}}return null}}class ln{constructor(e){var t;const{near:r,rawCode:n,setReactState:o,cache:i,refreshCache:a,confirmTransactions:s,depth:c,widgetSrc:l,requestCommit:u,version:d,widgetConfigs:f,ethersProviderContext:p,isModule:g}=e;this.alive=!0,this.isModule=g,this.rawCode=n,this.near=r;try{this.code=(e=>{if(Vr.has(e))return Vr.get(e);const t=Wr.parse(e,zr);return Vr.set(e,t),t})(n),this.compileError=null}catch(e){this.code=null,this.compileError=e,console.error(e)}this.code?(this.setReactState=o?e=>o({hooks:this.hooks,state:A(e)?Object.assign({},e):e}):()=>{throw new Error("State is unavailable for modules")},this.setReactHook=o?(e,t)=>{this.hooks[e]=t,o({hooks:this.hooks,state:this.state.state})}:()=>{throw new Error("State is unavailable for modules")},this.cache=i,this.refreshCache=a,this.confirmTransactions=s,this.depth=null!=c?c:0,this.widgetSrc=l,this.requestCommit=u,this.version=d,this.cachedStyledComponents=new Map,this.widgetConfigs=f,this.ethersProviderContext=p,this.ethersProvider=null!=p&&p.provider?new h.ethers.providers.Web3Provider(p.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map,this.networkId=(null===(t=f.findLast((e=>e&&e.networkId)))||void 0===t?void 0:t.networkId)||r.config.networkId,this.globalFunctions=this.initGlobalFunctions()):this.alive=!1}stop(){this.alive&&(this.alive=!1,this.timeouts.forEach((e=>clearTimeout(e))),this.intervals.forEach((e=>clearInterval(e))),this.websockets.forEach((e=>e.close())),this.vmInstances.forEach((e=>e.stop())))}initGlobalFunctions(){var e=this;const t={getr:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.getr");return e.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!0,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},get:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.get");return e.cachedSocialGet(arguments.length<=0?void 0:arguments[0],!1,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},keys:function(){if(arguments.length<1)throw new Error("Missing argument 'keys' for Social.keys");return e.cachedSocialKeys(...arguments)},index:function(){if(arguments.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return e.cachedIndex(...arguments)},set:function(){if(arguments.length<1)throw new Error("Missing argument 'data' for Social.set");return e.socialSet(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])}},r={signMessage:function(){for(var t=arguments.length,r=new Array(t),n=0;n5)throw new Error("Method: Near.call. Required argument: 'contractName'. If the first argument is a string: 'methodName'. Optional: 'args', 'gas' (defaults to 300Tg), 'deposit' (defaults to 0)");return e.confirmTransactions([{contractName:arguments.length<=0?void 0:arguments[0],methodName:arguments.length<=1?void 0:arguments[1],args:null!==(t=arguments.length<=2?void 0:arguments[2])&&void 0!==t?t:{},gas:arguments.length<=3?void 0:arguments[3],deposit:arguments.length<=4?void 0:arguments[4]}])}},n={stringify:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return Hr(arguments.length<=0?void 0:arguments[0]),JSON.stringify(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},parse:function(){if(arguments.length<1)throw new Error("Missing argument 's' for JSON.parse");try{const e=JSON.parse(arguments.length<=0?void 0:arguments[0]);return Yr(e),e}catch(e){return null}}},o={keys:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.keys");return Hr(arguments.length<=0?void 0:arguments[0]),Object.keys(arguments.length<=0?void 0:arguments[0])},values:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.values");return Hr(arguments.length<=0?void 0:arguments[0]),Object.values(arguments.length<=0?void 0:arguments[0])},entries:function(){if(arguments.length<1)throw new Error("Missing argument 'obj' for Object.entries");return Hr(arguments.length<=0?void 0:arguments[0]),Object.entries(arguments.length<=0?void 0:arguments[0])},assign:function(){for(var e=arguments.length,t=new Array(e),r=0;rHr(e)));const n=Object.assign(...t);return Yr(n),n},fromEntries:function(){const e=Object.fromEntries(arguments.length<=0?void 0:arguments[0]);return Yr(e),e}},i={init:function(){if(arguments.length<1)throw new Error("Missing argument 'initialState' for State.init");if(null===(arguments.length<=0?void 0:arguments[0])||"object"!=typeof(arguments.length<=0?void 0:arguments[0])||oe(arguments.length<=0?void 0:arguments[0]))throw new Error("'initialState' is not an object");if(void 0===e.state.state){const t=arguments.length<=0?void 0:arguments[0];e.state.state=t,e.setReactState(t)}return e.state.state},update:function(){for(var t=arguments.length,r=new Array(t),n=0;nthis.ethersProvider,setChain:function(){var t;const r=null===(t=e.ethersProviderContext)||void 0===t?void 0:t.setChain;if(!r)throw new Error("The gateway doesn't support `setChain` operation");return r(...arguments)},send:function(){for(var t=arguments.length,r=new Array(t),n=0;n{var r;return P(t)&&(t=t(null===(r=e.hooks[n])||void 0===r?void 0:r.state)),e.setReactHook(n,{state:t,setState:i}),t};return[i(r),i]},useEffect:function(){var t;if(!e.currentVmStack||null!==(t=e.currentVmStack)&&void 0!==t&&t.prevStack)throw new Error("Method: useEffect. The hook can an only be called from the top of the stack");if(!e.hooks)throw new Error("Hooks are unavailable for modules");if(arguments.length<1)throw new Error("Method: useEffect. Required arguments: 'setup'. Optional: 'dependencies'");const r=arguments.length<=0?void 0:arguments[0];if(!P(r))throw new Error("Method: useEffect. The first argument 'setup' must be a function");const n=e.currentVmStack.hookIndex++,o=arguments.length<=1?void 0:arguments[1],i=e.hooks[n];if(i){const e=i.dependencies;if(void 0!==e&&se(e,o))return}const a=null==i?void 0:i.cleanup;P(a)&&a(),e.setReactHook(n,{cleanup:r(),dependencies:o})},useMemo:function(){for(var e=arguments.length,t=new Array(e),r=0;r{e.alive&&o()}),i);return e.timeouts.add(a),a},setInterval:function(){if(e.intervals.size>=16)throw new Error("Too many intervals. Max allowed: ".concat(16));for(var t=arguments.length,r=new Array(t),n=0;n{e.alive&&o()}),i);return e.intervals.add(a),a},clearTimeout:function(){const t=arguments.length<=0?void 0:arguments[0];return e.timeouts.delete(t),clearTimeout(t)},clearInterval:function(){const t=arguments.length<=0?void 0:arguments[0];return e.intervals.delete(t),clearInterval(t)}})}cachedPromise(e,t){return ie(e({onInvalidate:()=>{this.alive&&this.refreshCache()},subscribe:!!t}))}cachedSocialGet(e,t,r,n,o){return e=Array.isArray(e)?e:[e],this.cachedPromise((i=>this.cache.socialGet(this.near,e,t,r,n,i,o)),null==n?void 0:n.subscribe)}storageGet(e,t){return this.cachedPromise((r=>this.cache.localStorageGet(e,t,r)))}storageSet(e,t,r){return this.cache.localStorageSet(e,t,r)}cachedSocialKeys(e,t,r,n){return e=Array.isArray(e)?e:[e],this.cachedPromise((o=>this.cache.cachedViewCall(this.near,this.near.config.contractName,"keys",{keys:e,options:r},t,o,n)),null==r?void 0:r.subscribe)}asyncNearView(e,t,r,n){return this.near.viewCall(e,t,r,n)}cachedEthersCall(e,t,r,n){return this.cachedPromise((r=>this.cache.cachedEthersCall(this.ethersProvider,e,t,r,n)),r)}cachedNearView(e,t,r,n,o,i){return this.cachedPromise((o=>this.cache.cachedViewCall(this.near,e,t,r,n,o,i)),o)}cachedNearBlock(e,t,r){return this.cachedPromise((t=>this.cache.cachedBlock(this.near,e,t,r)),t)}asyncFetch(e,t){return this.cache.asyncFetch(e,t)}cachedFetch(e,t,r){return this.cachedPromise((n=>this.cache.cachedFetch(e,t,n,r)),null==t?void 0:t.subscribe)}cachedIndex(e,t,r,n){return this.cachedPromise((o=>this.cache.socialIndex(this.near,e,t,r,o,n)),null==r?void 0:r.subscribe)}useCache(e,t,r,n){return this.cachedPromise((r=>this.cache.cachedCustomPromise({widgetSrc:this.widgetSrc,dataKey:t},e,r,n)),null==r?void 0:r.subscribe)}socialSet(e,t){return this.requestCommit({data:e,force:null==t?void 0:t.force,onCommit:null==t?void 0:t.onCommit,onCancel:null==t?void 0:t.onCancel})}vmRequire(e){const t=ce(e,null,this.widgetConfigs);let r;if(null!=t&&t.src){const e=t.src,[n,o]=e.split("@");if(r=this.cachedSocialGet(n.toString(),!1,o,void 0),!r)return r}else null!=t&&t.code&&(r=t.code);return this.getVmInstance(r,null==t?void 0:t.src).execCode({context:ie(this.context),forwardedProps:this.forwardedProps})}getVmInstance(e,t){if(this.vmInstances.has(e)){const t=this.vmInstances.get(e);if(t.rawCode===e)return t;t.stop(),this.vmInstances.delete(e)}const r=new ln({near:this.near,rawCode:e,cache:this.cache,refreshCache:this.refreshCache,confirmTransactions:this.confirmTransactions,depth:this.depth+1,widgetSrc:t,requestCommit:this.requestCommit,version:this.version,widgetConfigs:this.widgetConfigs,ethersProviderContext:this.ethersProviderContext,isModule:!0});return this.vmInstances.set(e,r),r}renderCode(e){if(this.compileError){const{message:e,stack:t}=this.compileError;return this.near.config.errorCallback({scope:I.Compilation,message:e}),a().createElement("div",{className:"alert alert-danger"},"Compilation error:",a().createElement("pre",null,e),a().createElement("pre",null,t))}if(!this.alive){const e="VM is dead";return this.near.config.errorCallback({scope:I.Render,message:e}),a().createElement("div",{className:"alert alert-danger"},e)}const t=this.execCode(e);return oe(t)||"string"==typeof t||"number"==typeof t?t:a().createElement("pre",null,JSON.stringify(t,void 0,2))}execCode(e){let{props:t,context:r,reactState:n,forwardedProps:o}=e;if(this.compileError)throw this.compileError;if(this.depth>=32)return"Too deep";this.gIndex=0;const{hooks:i,state:a}=null!=n?n:{};this.hooks=i,this.state={...Jr,...this.globalFunctions,window:{location:{get hash(){return window.location.hash},set hash(e){if(""!==e)throw new Error("Set `window.location.hash` only accepts an empty string as a value.");history.pushState(e,document.title,window.location.pathname+window.location.search)}}},props:A(t)?Object.assign({},t):t,context:r,state:a,get elliptic(){return delete this.elliptic,this.elliptic=Yt()(Gt),delete this.elliptic.utils.cachedProperty,this.elliptic}},this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new cn(this,void 0,this.state);const s=this.vmStack.executeStatement(this.code);if(null!=s&&s.break)throw new Error("BreakStatement outside of a loop");if(null!=s&&s.continue)throw new Error("ContinueStatement outside of a loop");return null==s?void 0:s.result}}const un=require("react-error-boundary"),dn=a().forwardRef(((e,t)=>{var r;const{loading:n,src:o,code:s,depth:c,config:l,props:d,...f}=e,[h,p]=(0,i.useState)(0),[g,m]=(0,i.useState)(null),[w,v]=(0,i.useState)(null),[b,E]=(0,i.useState)({hooks:[],state:void 0}),[S,k]=(0,i.useState)(0),[x,O]=(0,i.useState)({}),[B,A]=(0,i.useState)(null),[T,P]=(0,i.useState)(null),[U,R]=(0,i.useState)(null),[j,M]=(0,i.useState)(null),[_,q]=(0,i.useState)(null),[F,L]=(0,i.useState)(null),D=(0,i.useContext)(tr),J=_&&(null===(r=_.findLast((e=>e&&e.networkId)))||void 0===r?void 0:r.networkId),G=wt(J),K=ke(J),z=Me(J),[V,W]=(0,i.useState)(null);(0,i.useEffect)((()=>{const e=l?Array.isArray(l)?l:[l]:[];se(e,_)||q(e)}),[l,_]),(0,i.useEffect)((()=>{const e=ce(o,s,_);se(e,F)||L(e)}),[o,s,_,F]),(0,i.useEffect)((()=>{if(K)if(null!=F&&F.src){const e=F.src,[t,r]=e.split("@"),n=G.socialGet(K,t.toString(),!1,r,void 0,(()=>{p(h+1)}));m(n),v(e)}else if(null!=F&&F.code){var e;m(F.code),v(null!=K&&null!==(e=K.features)&&void 0!==e&&e.enableWidgetSrcWithCodeOverride?o:null)}}),[K,F,h]),(0,i.useEffect)((()=>{A(null),W(null),g||void 0===g&&(K.config.errorCallback({scope:I.Source,message:w}),W(a().createElement("div",{className:"alert alert-danger"},'Source code for "',w,'" is not found')))}),[g,w]);const $=(0,i.useCallback)((e=>{if(!K||!e||0===e.length)return null;e=e.map((e=>({contractName:e.contractName,methodName:e.methodName,args:e.args||{},deposit:e.deposit?u()(e.deposit):u()(0),gas:e.gas?u()(e.gas):y.mul(30)}))),console.log("confirm txs",e),P(e)}),[K]),X=(0,i.useCallback)((e=>{if(!K)return null;console.log("commit requested",e),R(e)}),[K]);(0,i.useEffect)((()=>{if(!K||!g)return;E({hooks:[],state:void 0});const e=new ln({near:K,rawCode:g,setReactState:E,cache:G,refreshCache:()=>{k((e=>e+1))},confirmTransactions:$,depth:c,widgetSrc:w,requestCommit:X,version:bt()(),widgetConfigs:_,ethersProviderContext:D});return A(e),()=>{e.stop()}}),[w,K,g,c,X,$,_,D]),(0,i.useEffect)((()=>{K&&O({loading:!1,accountId:null!=z?z:null,widgetSrc:w,networkId:K.config.networkId})}),[K,z,w]),(0,i.useLayoutEffect)((()=>{if(!B)return;const e={props:d||{},context:x,reactState:b,cacheNonce:S,version:B.version,forwardedProps:{...f,ref:t}};if(!se(e,j)){M(ie(e));try{var r;W(null!==(r=B.renderCode(e))&&void 0!==r?r:"Execution failed")}catch(e){const t=w?"".concat(w,": ").concat(e.message):e.message;K.config.errorCallback({scope:I.Execution,message:t}),W(a().createElement("div",{className:"alert alert-danger"},w?a().createElement(a().Fragment,null,"Src: ",w,a().createElement("br",null)):"","Execution error:",a().createElement("pre",null,e.message),a().createElement("pre",null,e.stack))),console.error(e)}}}),[B,d,x,b,S,j,t,f]);const H=null!=V?a().createElement(un.ErrorBoundary,{FallbackComponent:e=>{K.config.errorCallback({scope:I.Boundary,message:w});const{error:t={message:I.Boundary}}=e;return a().createElement(N,{error:t})},onReset:()=>{W(null)},resetKeys:[V]},a().createElement(a().Fragment,null,V,T&&a().createElement(xt,{transactions:T,widgetSrc:w,onHide:e=>{P(null),e&&e.transaction&&G.invalidateCache(K,e.transaction.receiver_id)},networkId:J}),U&&a().createElement(qt,{show:!0,widgetSrc:w,data:U.data,force:U.force,onHide:()=>R(null),onCommit:U.onCommit,onCancel:U.onCancel,networkId:J}))):null!=n?n:C;return H}));return n})())); \ No newline at end of file