diff --git a/dist/index.js b/dist/index.js index be213fd9..b4f4237d 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(V(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(V(t,ArrayBuffer)||t&&V(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(V(t,SharedArrayBuffer)||t&&V(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||Y(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)||V(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 W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(t).length;default:if(o)return n?-1:W(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 N(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return L(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(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),Y(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(V(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 L(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(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,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||P(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||P(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||P(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||P(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||P(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||P(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||P(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||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||P(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||P(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||P(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||P(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||P(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||P(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||P(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||P(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||T(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||T(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||T(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||T(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||T(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||T(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||T(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 _(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);T(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);T(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||T(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||T(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||T(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||T(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||T(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 _(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 z=/[^+/0-9A-Za-z-_]/g;function W(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 K(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function V(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const H=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:()=>xr,EthersProviderContext:()=>xn,Widget:()=>ko,useAccount:()=>Qt,useAccountId:()=>te,useCache:()=>lr,useInitNear:()=>Pt,useNear:()=>Tt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>A,Loading:()=>L,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>ot,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>D,bigMax:()=>U,bigMin:()=>B,bigToString:()=>R,computeWritePermission:()=>rt,convertToStringLeaves:()=>Y,dateToString:()=>q,deepCopy:()=>at,deepEqual:()=>ct,deepFreeze:()=>nt,displayGas:()=>M,displayNear:()=>F,displayTime:()=>G,estimateDataSize:()=>W,extractKeys:()=>K,indexMatch:()=>tt,ipfsUpload:()=>$,ipfsUrl:()=>z,isArray:()=>C,isObject:()=>P,isReactObject:()=>it,isString:()=>T,isValidAccountId:()=>N,isoDate:()=>J,keysToCamel:()=>_,patternMatch:()=>Q,removeDuplicates:()=>X});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");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(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 d(t){return d="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},d(t)}function y(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)||v(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 v(t,e){if(t){if("string"==typeof t)return m(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)?m(t,e):void 0}}function m(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:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(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 w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),L=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),A=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 N(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var C=function(t){return Array.isArray(t)},P=function(t){return t===Object(t)&&!C(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function t(e){if(P(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 C(e)?e.map((function(e){return t(e)})):e},B=function(t,e){return t&&e?t.lt(e)?t:e:t||e},U=function(t,e){return t&&e?t.gt(e)?t:e:t||e},R=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},F=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,R(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},M=function(t){return t?r().createElement(r().Fragment,null,R(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},q=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},G=function(t){return t.toLocaleString()},D=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},J=function(t){return t?new Date(t).toISOString().substring(0,10):""},$=function(){var t,e=(t=g().mark((function t(e){var r;return g().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){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),z=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return P(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=P(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),P(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return P(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=P(r)?r[i]:void 0;if(P(a)){var u=P(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},V=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return P(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[V(o)]=t(i),e}),{}):V(e)},H=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return P(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Z=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||P(e)&&t(e,r.slice(1))}))},Q=function(t,e,r){var n=e.split("/");return"get"===t?H(r,n):"keys"===t&&Z(r,n)},tt=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}}))},et={graph:!0,post:!0,index:!0,settings:!0},rt=function(t,e){var r=P(t)?JSON.parse(JSON.stringify(t)):{};return P(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in et)if(P(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},nt=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"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},ot="$$typeof",it=function(t){return null!==t&&"object"===d(t)&&!!t[ot]},at=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.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:e instanceof Date?new Date(e):e instanceof WebSocket?e:P(e)?it(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ct=l(),ut=n(764).lW;function st(t){return st="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},st(t)}function lt(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 ft(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)?ft(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 ft(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 pt(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 dt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){pt(i,n,o,a,c,"next",t)}function c(t){pt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var yt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},vt={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},mt={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},gt={get:!0,keys:!0},bt=function(){var t=dt(ht().mark((function t(e,r,n,o,i){return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in gt){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 wt(t,e,r,n,o,i){return Et.apply(this,arguments)}function Et(){return(Et=dt(ht().mark((function t(e,r,n,o,i,a){var c;return ht().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:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[yt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function xt(t,e){return St.apply(this,arguments)}function St(){return(St=dt(ht().mark((function t(e,r){var n;return ht().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 kt(t,e){return Ot.apply(this,arguments)}function Ot(){return(Ot=dt(ht().mark((function t(e,r){var n,o,i;return ht().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:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=yt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).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 It(t,e,r,n,o,i){return Lt.apply(this,arguments)}function Lt(){return(Lt=dt(ht().mark((function t(e,r,n,o,i,a){var c;return ht().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:ut.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(ut.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(t,e,r,n){return Nt.apply(this,arguments)}function Nt(){return(Nt=dt(ht().mark((function t(e,r,n,o){var i;return ht().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=lt(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 Ct(){return(Ct=dt(ht().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},mt,o):"testnet"===o.networkId&&(o=Object.assign({},vt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return It(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?At(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():bt(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return wt(p,t,e,r,n,o)},p.sendTransactions=function(t){return kt(p,t)},p.contract=jt(p,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"]}),p.accountState=function(t){return xt(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Pt=(0,i.singletonHook)({},(function(){var t=lt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){return n(function(t){return Ct.apply(this,arguments)}(t))}}),[])}})),Tt=(0,i.singletonHook)(null,(function(){var t=lt((0,e.useState)(null),2),r=t[0],n=t[1],o=Pt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r}));const _t=require("local-storage");var Bt,Ut,Rt,Ft,Mt=n.n(_t);function qt(t){return qt="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},qt(t)}function Gt(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 Dt(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)?Dt(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 Dt(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 $t(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 zt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){$t(i,n,o,a,c,"next",t)}function c(t){$t(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Wt="near-social-vm:v01:",Kt=Wt+":accountId:",Xt=Wt+":pretendAccountId:",Vt={loading:!0,signedAccountId:null!==(Bt=Mt().get(Kt))&&void 0!==Bt?Bt:void 0,pretendAccountId:null!==(Ut=Mt().get(Xt))&&void 0!==Ut?Ut:void 0,accountId:null!==(Rt=null!==(Ft=Mt().get(Xt))&&void 0!==Ft?Ft:Mt().get(Kt))&&void 0!==Rt?Rt:void 0,state:null,near:null};function Yt(t,e){return Ht.apply(this,arguments)}function Ht(){return(Ht=zt(Jt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Jt().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){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=Mt().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(Mt().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 Zt=function(){var t=zt(Jt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Jt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Mt().set(Kt,o),e.config.walletConnectCallback(o)):Mt().remove(Kt),i=null!==(n=Mt().get(Xt))&&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=zt(Jt().mark((function t(){return Jt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Zt(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=zt(Jt().mark((function t(n){return Jt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Mt().set(Xt,n):Mt().remove(Xt),t.next=3,Zt(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=Gt(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)}}(),Qt=(0,i.singletonHook)(Vt,(function(){var t=Gt((0,e.useState)(Vt),2),r=t[0],n=t[1],o=Tt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=zt(Jt().mark((function t(e){return Jt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Yt(o,e);case 2:return t.prev=2,t.next=5,Zt(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})),te=function(){return Qt().accountId};const ee=require("react-bootstrap/Modal");var re=n.n(ee);const ne=require("remark-gfm");var oe=n.n(ne);const ie=require("react-markdown");var ae=n.n(ie);const ce=require("react-syntax-highlighter"),ue=require("react-syntax-highlighter/dist/esm/styles/prism"),se=require("mdast-util-find-and-replace");var le=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function fe(){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,se.findAndReplace)(e,le,t),e}}var he=/#(\w+)/gi;function pe(){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,se.findAndReplace)(e,he,t),e}}var de=["node","children"],ye=["node"],ve=["node"],me=["node"],ge=["node"],be=["node","inline","className","children"];function we(){return we=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 xe=function(t){var e=t.onLinkClick,n=t.text,o=t.onMention,i=t.onHashtag,a=t.syntaxHighlighterProps;return r().createElement(ae(),{plugins:[],rehypePlugins:[],remarkPlugins:[oe(),fe,pe],children:n,components:{strong:function(t){var e,n,a,c,u=t.node,s=t.children,l=Ee(t,de);return o&&null!==(e=u.properties)&&void 0!==e&&e.accountId?o(null===(a=u.properties)||void 0===a?void 0:a.accountId):i&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?i(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){t.node;var n=Ee(t,ye);return e?r().createElement("a",we({onClick:e},n)):r().createElement("a",we({target:"_blank"},n))},img:function(t){t.node;var e=Ee(t,ve);return r().createElement("img",we({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Ee(t,me);return r().createElement("blockquote",we({className:"blockquote"},e))},table:function(t){t.node;var e=Ee(t,ge);return r().createElement("table",we({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Ee(t,be),c=/language-(\w+)/.exec(n||""),u=null!=a?a:{},s=u.wrapLines,l=u.lineProps,f=u.showLineNumbers,h=u.lineNumberStyle;return!e&&c?r().createElement(ce.Prism,we({children:String(o).replace(/\n$/,""),style:ue.tomorrow,language:c[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",we({className:n},i),o)}}})};const Se=require("react-uuid");var ke=n.n(Se);function Oe(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 Be(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 Ue(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Be(i,n,o,a,c,"next",t)}function c(t){Be(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Re=x.mul(2e3),Fe=x.mul(500),Me=x.mul(500),qe=x.mul(500),Ge=function(){var t=Ue(_e().mark((function t(e,r){var n;return _e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(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)}}(),De=function(){var t=Ue(_e().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return _e().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 Te(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)?Te(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=Y(n),(m=function(t){var e=function(t,e){if("object"!==Pe(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==Pe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===Pe(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,Ge(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):Fe).add(l?u()(0):qe).add(Me),y=U(d.sub(f.mul(x)),s?l?u()(0):u()(1):Re),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)}}(),Je=function(){var t=Ue(_e().mark((function t(e,r,n){return _e().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},w.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)}}(),$e=function(){var t=Ue(_e().mark((function t(e,r,n){var o,i;return _e().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(yt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(yt("set",{data:r},w.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 ze=require("react-bootstrap"),We=require("idb");function Ke(t){return Ke="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},Ke(t)}function Xe(t,e){if(t){if("string"==typeof t)return Ve(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)?Ve(t,e):void 0}}function Ve(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 Ze(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)}))}}function Qe(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,We.openDB)("cacheDb",1,{upgrade:function(t){t.createObjectStore(cr)}}),this.cache={},this.finalSynchronizationDelayMs=e}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=Ze(Ye().mark((function t(e){return Ye().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(cr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=Ze(Ye().mark((function t(e,r){return Ye().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(cr,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:nr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,P(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=ar,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===or||i.status===ir&&i.time+3e5>(new Date).getTime()||(i.status===nr&&this.innerGet(t).then((function(t){(t||n)&&i.status===or&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=or,e&&e().then((function(e){i.status=ir,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=ir;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===tr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return Q(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===er&&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&&tt(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)||Xe(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=ar,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i){return this.cachedPromise({action:tr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i)}},{key:"asyncFetch",value:(n=Ze(Ye().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return Ye().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){var n=this;return this.cachedPromise({action:er,url:t,options:e},(function(){return n.asyncFetch(t,e)}),r)}},{key:"cachedCustomPromise",value:function(t,e,r){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r)}},{key:"socialGet",value:function(t,e,r,n,o,i){if(!t)return null;var a={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},c=this.cachedViewCall(t,t.config.contractName,"get",a,n,i);if(null===c)return null;if(1===e.length)for(var u=e[0].split("/"),s=0;s=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 yr(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 vr(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 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}}(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 mr(t,e){(null==e||e>t.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,hr),p=vr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",pr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&L,i),r().createElement(Er,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Sr=require("react-bootstrap-typeahead"),kr=require("styled-components");var Or=n.n(kr);const jr=require("elliptic"),Ir=require("bn.js");var Lr=n.n(Ir);const Ar=require("tweetnacl"),Nr=require("iframe-resizer-react");var Cr=n.n(Nr);function Pr(){return Pr=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 jn(t,e,r){return jn=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&&In(o,r.prototype),o},jn.apply(null,arguments)}function In(t,e){return In=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},In(t,e)}function Ln(){return Ln=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},n.vm.setReactState(n.vm.state.state),$(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,kr.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!Kn[s.as]&&delete s.as,s.forwardedAs&&!Kn[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=Tn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Ae.sanitizeUrl)(n))})):"Widget"===o&&(s.depth=this.vm.depth+1,s.config=[s.config].concat(An(this.vm.widgetConfigs)).filter(Boolean)),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Fn(Fn({},s),{},{children:g}));if(u)return(0,kr.isStyledComponent)(u)?r().createElement.apply(r(),[u,Fn({},s)].concat(An(g))):u(Fn({children:g},s));if("Widget"===o)return r().createElement(ko,s);if("CommitButton"===o)return r().createElement(xr,Ln({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Ce(),s,g);if("Tooltip"===o)return r().createElement(ze.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(ze.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(Sr.Typeahead,s);if("Markdown"===o)return r().createElement(xe,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.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:z(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Le(),Ln({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,L," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Le(),s,g);if("iframe"===o)return r().createElement(Mr,s);if("Web3Connect"===o)return r().createElement(Sn,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Fn({},s)].concat(An(g)));if(!1===i)return r().createElement(o,Fn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return eo(r),r}},{key:"callFunction",value:function(t,e,r,n,o){var i=this,a=Yn[t];if(!0===a||void 0===a){if("Social"===t&&"getr"===e||"socialGetr"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.getr");return this.vm.cachedSocialGet(r[0],!0,r[1],r[2])}if("Social"===t&&"get"===e||"socialGet"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.get");return this.vm.cachedSocialGet(r[0],!1,r[1],r[2])}if("Social"===t&&"keys"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.keys");return this.vm.cachedSocialKeys(r[0],r[1],r[2])}if("Social"===t&&"index"===e){if(r.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return this.vm.cachedIndex(r[0],r[1],r[2])}if("Social"===t&&"set"===e){if(r.length<1)throw new Error("Missing argument 'data' for Social.set");return this.vm.socialSet(r[0],r[1])}if("Near"===t&&"view"===e){if(r.length<2)throw new Error("Method: Near.view. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality', 'subscribe'");var c=Tn(r,5),u=c[0],s=c[1],l=c[2],f=c[3],h=c[4];return this.vm.cachedNearView(u,s,l,f,io(h,f))}if("Near"===t&&"asyncView"===e){var p;if(r.length<2)throw new Error("Method: Near.asyncView. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality'");return(p=this.vm).asyncNearView.apply(p,An(r))}if("Near"===t&&"block"===e){var d=Tn(r,2),y=d[0],v=d[1];return this.vm.cachedNearBlock(y,io(v,y))}if("Near"===t&&"call"===e){if(1===r.length){if(P(r[0]))return this.vm.confirmTransactions([r[0]]);if(C(r[0]))return this.vm.confirmTransactions(r[0]);throw new Error("Method: Near.call. Required argument: 'tx/txs'. A single argument call requires an TX object or an array of TX objects.")}var m;if(r.length<2||r.length>5)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 this.vm.confirmTransactions([{contractName:r[0],methodName:r[1],args:null!==(m=r[2])&&void 0!==m?m:{},gas:r[3],deposit:r[4]}])}if("fetch"===e){var g;if(r.length<1)throw new Error("Method: fetch. Required arguments: 'url'. Optional: 'options'");return(g=this.vm).cachedFetch.apply(g,An(r))}if("asyncFetch"===e){var b;if(r.length<1)throw new Error("Method: asyncFetch. Required arguments: 'url'. Optional: 'options'");return(b=this.vm).asyncFetch.apply(b,An(r))}if("useCache"===e){var w;if(r.length<2)throw new Error("Method: useCache. Required arguments: 'promiseGenerator', 'dataKey'. Optional: 'options'");if(!(r[0]instanceof Function))throw new Error("Method: useCache. The first argument 'promiseGenerator' must be a function");return(w=this.vm).useCache.apply(w,An(r))}if("parseInt"===e)return parseInt.apply(void 0,An(r));if("parseFloat"===e)return parseFloat.apply(void 0,An(r));if("isNaN"===e)return isNaN.apply(void 0,An(r));if("setTimeout"===e){var E=Tn(r,2),x=E[0],S=E[1],k=setTimeout((function(){i.vm.alive&&x()}),S);return this.vm.timeouts.add(k),k}if("setInterval"===e){if(this.vm.intervals.size>=16)throw new Error("Too many intervals. Max allowed: ".concat(16));var O=Tn(r,2),j=O[0],I=O[1],L=setInterval((function(){i.vm.alive&&j()}),I);return this.vm.intervals.add(L),L}if("clearTimeout"===e){var A=r[0];return this.vm.timeouts.delete(A),clearTimeout(A)}if("clearInterval"===e){var N=r[0];return this.vm.intervals.delete(N),clearInterval(N)}if("JSON"===t&&"stringify"===e||"stringify"===e){if(r.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return ro(r[0]),JSON.stringify(r[0],r[1],r[2])}if("JSON"===t&&"parse"===e){if(r.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var T=JSON.parse(r[0]);return no(T),T}catch(t){return null}}else if("Object"===t){if("keys"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.keys");return ro(r[0]),Object.keys(r[0])}if("values"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.values");return ro(r[0]),Object.values(r[0])}if("entries"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.entries");return ro(r[0]),Object.entries(r[0])}if("assign"===e){r.forEach((function(t){return ro(t)}));var _=Object.assign.apply(Object,An(r));return no(_),_}if("fromEntries"===e){var B=Object.fromEntries(r[0]);return no(B),B}}else{if("State"===t&&"init"===e||"initState"===e){if(r.length<1)throw new Error("Missing argument 'initialState' for State.init");if(null===r[0]||"object"!==Un(r[0])||it(r[0]))throw new Error("'initialState' is not an object");if(void 0===this.vm.state.state){var U=r[0];this.vm.state.state=U,this.vm.setReactState(U)}return this.vm.state.state}if("State"===t&&"update"===e){var R;if(P(r[0]))this.vm.state.state=null!==(R=this.vm.state.state)&&void 0!==R?R:{},Object.assign(this.vm.state.state,r[0]);else if(r[0]instanceof Function){var F;this.vm.state.state=null!==(F=this.vm.state.state)&&void 0!==F?F:{},this.vm.state.state=r[0](this.vm.state.state)}if(void 0===this.vm.state.state)throw new Error("The state was not initialized");return this.vm.setReactState(this.vm.state.state),this.vm.state.state}if("State"===t&&"get"===e)return this.vm.state.state;if("Storage"===t&&"privateSet"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.privateSet");return this.vm.storageSet({src:this.vm.widgetSrc,type:zn},r[0],r[1])}if("Storage"===t&&"privateGet"===e){if(r.length<1)throw new Error("Missing argument 'key' for Storage.privateGet");return this.vm.storageGet({src:this.vm.widgetSrc,type:zn},r[0])}if("Storage"===t&&"set"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.set");return this.vm.storageSet({src:this.vm.widgetSrc,type:Wn},r[0],r[1])}if("Storage"===t&&"get"===e){var M;if(r.length<1)throw new Error("Missing argument 'key' for Storage.get");return this.vm.storageGet({src:null!==(M=r[1])&&void 0!==M?M:this.vm.widgetSrc,type:Wn},r[0])}var q,G,D;if("console"===t&&"log"===e)return(q=console).log.apply(q,[this.vm.widgetSrc].concat(An(r)));if("clipboard"===t&&"writeText"===e)return this.isTrusted?(G=navigator.clipboard).writeText.apply(G,An(r)):Promise.reject(new Error("Not trusted (not a click)"));if("VM"===t&&"require"===e)return(D=this.vm).vmRequire.apply(D,An(r));if("Ethers"===t)return"provider"===e?this.vm.ethersProvider:this.vm.cachedEthersCall(e,r);if("WebSocket"===t){if("WebSocket"===e){var J=jn(WebSocket,An(r));return this.vm.websockets.push(J),J}throw new Error("Unsupported WebSocket method")}}}else{var $=e===t?a:a[e];if("function"==typeof $)return o?jn($,An(r)):$.apply(void 0,An(r))}if(!n)throw new Error(t&&t!==e?"Unsupported callee method '".concat(t,".").concat(e,"'"):"Unsupported callee method '".concat(e,"'"))}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(eo(n),null!=e&&e.requireState&&n!==$n)throw new Error("The top object should be ".concat($n));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(ro(o),o===this.stack.state&&n in Yn){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||!(n in o)))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(c in Yn){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 ro(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,An(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 w>E;if("<="===t.operator)return w<=E;if(">="===t.operator)return w>=E;if("==="===t.operator||"=="===t.operator)return w===E;if("!=="===t.operator||"!="===t.operator)return w!==E;if("in"===t.operator)return w in E;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var x=this.resolveMemberExpression(t.argument,{left:!0}),S=x.obj,k=x.key;return null==S||delete S[k]}var O=this.executeExpression(t.argument);if("-"===t.operator)return-O;if("!"===t.operator)return!O;if("typeof"===t.operator)return Un(O);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var j=this.executeExpression(t.left);if("||"===t.operator)return j||this.executeExpression(t.right);if("&&"===t.operator)return j&&this.executeExpression(t.right);if("??"===t.operator)return null!=j?j: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 I=this.resolveMemberExpression(t.argument,{left:!0}),L=I.obj,A=I.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;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);ro(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 N,C;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var P=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),T=P.key;if("styled"!==P.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var _=this.getArray(t.tag.arguments),B=null==_?void 0:_[0],U=oo(B);if(!(0,kr.isStyledComponent)(B)&&!U)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');N=Or()(null!=U?U:B)}else{if("keyframes"===T)N=kr.keyframes;else{if(!(T in Kn))throw new Error("Unsupported styled tag: "+T);N=Or()(T)}C=T}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var R=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,M=JSON.stringify([C].concat(An(R)));if(F&&this.vm.cachedStyledComponents.has(M))return this.vm.cachedStyledComponents.get(M);var q=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(N instanceof Function){var G=N.apply(void 0,[R].concat(An(q)));return F&&this.vm.cachedStyledComponents.set(M,G),G}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(so),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);ro(s);var l,f=On(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(so(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"===Un(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(ao(t.handler.param),at(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=On(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&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var L,A=!1,N=On(I.consequent);try{for(N.s();!(L=N.n()).done;){var C=L.value,P=k.executeStatement(C);if(P){if(P.break){A=!0;break}return P}}}catch(t){N.e(t)}finally{N.f()}if(A)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),ho=function(){function t(e){Nn(this,t);var r,n=e.near,o=e.rawCode,i=e.setReactState,a=e.cache,c=e.refreshCache,u=e.confirmTransactions,s=e.depth,l=e.widgetSrc,h=e.requestCommit,p=e.version,d=e.widgetConfigs,y=e.ethersProviderContext,v=e.isModule;this.alive=!0,this.isModule=v,this.rawCode=o,this.near=n;try{this.code=(r=o)in Qn?Qn[r]:Qn[r]=to.parse(r,Zn),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=i?function(t){return i(P(t)?Object.assign({},t):t)}:function(){throw new Error("State is unavailable for modules")},this.cache=a,this.refreshCache=c,this.confirmTransactions=u,this.depth=s,this.widgetSrc=l,this.requestCommit=h,this.version=p,this.cachedStyledComponents=new Map,this.widgetConfigs=d,this.ethersProviderContext=y,this.ethersProvider=null!=y&&y.provider?new f.ethers.providers.Web3Provider(y.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map):this.alive=!1}return Pn(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:"cachedPromise",value:function(t,e){var r=this;return at(t({onInvalidate:function(){r.alive&&r.refreshCache()},subscribe:!!e}))}},{key:"cachedSocialGet",value:function(t,e,r,n){var o=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(i){return o.cache.socialGet(o.near,t,e,r,n,i)}),null==n?void 0:n.subscribe)}},{key:"storageGet",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.localStorageGet(t,e,n)}))}},{key:"storageSet",value:function(t,e,r){return this.cache.localStorageSet(t,e,r)}},{key:"cachedSocialKeys",value:function(t,e,r){var n=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(o){return n.cache.cachedViewCall(n.near,n.near.config.contractName,"keys",{keys:t,options:r},e,o)}),null==r?void 0:r.subscribe)}},{key:"asyncNearView",value:function(t,e,r,n){return this.near.viewCall(t,e,r,n)}},{key:"cachedEthersCall",value:function(t,e,r){var n=this;return this.cachedPromise((function(r){return n.cache.cachedEthersCall(n.ethersProvider,t,e,r)}),r)}},{key:"cachedNearView",value:function(t,e,r,n,o){var i=this;return this.cachedPromise((function(o){return i.cache.cachedViewCall(i.near,t,e,r,n,o)}),o)}},{key:"cachedNearBlock",value:function(t,e){var r=this;return this.cachedPromise((function(e){return r.cache.cachedBlock(r.near,t,e)}),e)}},{key:"asyncFetch",value:function(t,e){return this.cache.asyncFetch(t,e)}},{key:"cachedFetch",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.cachedFetch(t,e,n)}),null==e?void 0:e.subscribe)}},{key:"cachedIndex",value:function(t,e,r){var n=this;return this.cachedPromise((function(o){return n.cache.socialIndex(n.near,t,e,r,o)}),null==r?void 0:r.subscribe)}},{key:"useCache",value:function(t,e,r){var n=this;return this.cachedPromise((function(r){return n.cache.cachedCustomPromise({widgetSrc:n.widgetSrc,dataKey:e},t,r)}),null==r?void 0:r.subscribe)}},{key:"socialSet",value:function(t,e){return this.requestCommit({data:t,force:null==e?void 0:e.force,onCommit:null==e?void 0:e.onCommit,onCancel:null==e?void 0:e.onCancel})}},{key:"vmRequire",value:function(t){var e=Tn(t.split("@"),2),r=e[0],n=e[1],o=this.cachedSocialGet(r.toString(),!1,n,void 0);return o?this.getVmInstance(o,t).execCode({context:at(this.context),forwardedProps:this.forwardedProps}):o}},{key:"getVmInstance",value:function(e,r){if(this.vmInstances.has(r)){var n=this.vmInstances[r];if(n.rawCode===e)return n;n.stop(),this.vmInstances.delete(r)}var o=new t({near:this.near,rawCode:e,cache:this.cache,refreshCache:this.refreshCache,confirmTransactions:this.confirmTransactions,depth:this.depth+1,widgetSrc:r,requestCommit:this.requestCommit,version:this.version,widgetConfigs:this.widgetConfigs,ethersProviderContext:this.ethersProviderContext,isModule:!0});return this.vmInstances.set(r,o),o}},{key:"renderCode",value:function(t){if(this.compileError)return r().createElement("div",{className:"alert alert-danger"},"Compilation error:",r().createElement("pre",null,this.compileError.message),r().createElement("pre",null,this.compileError.stack));if(!this.alive)return r().createElement("div",{className:"alert alert-danger"},"VM is dead");var e=this.execCode(t);return it(e)||"string"==typeof e||"number"==typeof e?e:r().createElement("pre",null,JSON.stringify(e,void 0,2))}},{key:"execCode",value:function(t){var e=t.props,r=t.context,n=t.state,o=t.forwardedProps;if(this.compileError)throw this.compileError;if(this.depth>=32)return"Too deep";this.gIndex=0,this.state={props:P(e)?Object.assign({},e):e,context:r,state:n,nacl:Gn,get elliptic(){return delete this.elliptic,this.elliptic=Dr().cloneDeep(jr),this.elliptic},ethers:Dn,nanoid:Jn},this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new fo(this,void 0,this.state);var i=this.vmStack.executeStatement(this.code);if(null!=i&&i.break)throw new Error("BreakStatement outside of a loop");if(null!=i&&i.continue)throw new Error("ContinueStatement outside of a loop");return null==i?void 0:i.result}}]),t}();const po=require("react-error-boundary"),yo=require("react-bootstrap-typeahead/types/utils");function vo(t){return vo="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},vo(t)}var mo=["src","code","depth","config","props"];function go(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 bo(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,mo),f=Eo((0,e.useState)(0),2),h=f[0],p=f[1],d=Eo((0,e.useState)(null),2),y=d[0],v=d[1],m=Eo((0,e.useState)(null),2),g=m[0],b=m[1],E=Eo((0,e.useState)(void 0),2),x=E[0],S=E[1],k=Eo((0,e.useState)(0),2),O=k[0],j=k[1],I=Eo((0,e.useState)({}),2),N=I[0],C=I[1],_=Eo((0,e.useState)(null),2),B=_[0],U=_[1],R=Eo((0,e.useState)(null),2),F=R[0],M=R[1],q=Eo((0,e.useState)(null),2),G=q[0],D=q[1],J=Eo((0,e.useState)(null),2),$=J[0],z=J[1],W=Eo((0,e.useState)(null),2),K=W[0],X=W[1],V=Eo((0,e.useState)(null),2),Y=V[0],H=V[1],Z=(0,e.useContext)(xn),Q=lr(),tt=Tt(),et=te(),rt=Eo((0,e.useState)(null),2),nt=rt[0],ot=rt[1];(0,e.useEffect)((function(){var t=c?Array.isArray(c)?c:[c]:[];ct(t,K)||X(t)}),[c,K]),(0,e.useEffect)((function(){var t=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=xo(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=P(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=(0,yo.isFunction)(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(o,i,K);ct(t,Y)||H(t)}),[o,i,K,Y]),(0,e.useEffect)((function(){if(tt)if(null!=Y&&Y.src){var t=Y.src,e=Eo(t.split("@"),2),r=e[0],n=e[1],o=Q.socialGet(tt,r.toString(),!1,n,void 0,(function(){p(h+1)}));v(o),b(t)}else null!=Y&&Y.code&&(v(Y.code),b(null))}),[tt,Y,h]),(0,e.useEffect)((function(){U(null),ot(null),y||void 0===y&&ot(r().createElement("div",{className:"alert alert-danger"},'Source code for "',g,'" is not found'))}),[y,g]);var it=(0,e.useCallback)((function(t){if(!tt||!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):w.mul(30)}})),console.log("confirm txs",t),M(t)}),[tt]),ut=(0,e.useCallback)((function(t){if(!tt)return null;console.log("commit requested",t),D(t)}),[tt]);return(0,e.useEffect)((function(){if(tt&&y){S(void 0);var t=new ho({near:tt,rawCode:y,setReactState:S,cache:Q,refreshCache:function(){j((function(t){return t+1}))},confirmTransactions:it,depth:a,widgetSrc:g,requestCommit:ut,version:ke()(),widgetConfigs:K,ethersProviderContext:Z});return U(t),function(){t.stop()}}}),[g,tt,y,a,ut,it,K,Z]),(0,e.useEffect)((function(){tt&&C({loading:!1,accountId:null!=et?et:null,widgetSrc:g,networkId:tt.config.networkId})}),[tt,et,g]),(0,e.useLayoutEffect)((function(){if(B){var t={props:s||{},context:N,state:x,cacheNonce:O,version:B.version,forwardedProps:bo(bo({},l),{},{ref:n})};if(!ct(t,$)){z(at(t));try{var e;ot(null!==(e=B.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){ot(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[B,s,N,x,O,$,n,l]),null!=nt?r().createElement(po.ErrorBoundary,{FallbackComponent:A,onReset:function(){ot(null)},resetKeys:[nt]},r().createElement(r().Fragment,null,nt,F&&r().createElement(je,{transactions:F,onHide:function(){return M(null)}}),G&&r().createElement(Er,{show:!0,widgetSrc:g,data:G.data,force:G.force,onHide:function(){return D(null)},onCommit:G.onCommit,onCancel:G.onCancel}))):L}))})(),o})())); \ No newline at end of file +!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(V(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(V(t,ArrayBuffer)||t&&V(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(V(t,SharedArrayBuffer)||t&&V(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||Y(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)||V(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 W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(t).length;default:if(o)return n?-1:W(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 L(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(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),Y(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(V(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 L(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(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,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||P(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||P(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||P(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||P(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||P(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||P(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||P(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||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||P(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||P(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||P(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||P(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||P(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||P(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||P(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||P(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||T(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||T(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||T(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||T(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||T(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||T(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||T(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 _(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);T(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);T(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||T(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||T(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||T(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||T(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||T(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 _(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 z=/[^+/0-9A-Za-z-_]/g;function W(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 K(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function V(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const H=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:()=>xr,EthersProviderContext:()=>xn,Widget:()=>ko,useAccount:()=>Qt,useAccountId:()=>te,useCache:()=>lr,useInitNear:()=>Pt,useNear:()=>Tt,utils:()=>t});var t={};n.r(t),n.d(t,{ErrorFallback:()=>A,Loading:()=>L,MaxGasPerTransaction:()=>E,OneNear:()=>j,ReactKey:()=>ot,StorageCostPerByte:()=>x,TGas:()=>w,availableNearBalance:()=>D,bigMax:()=>U,bigMin:()=>B,bigToString:()=>R,computeWritePermission:()=>rt,convertToStringLeaves:()=>Y,dateToString:()=>q,deepCopy:()=>at,deepEqual:()=>ct,deepFreeze:()=>nt,displayGas:()=>M,displayNear:()=>F,displayTime:()=>G,estimateDataSize:()=>W,extractKeys:()=>K,indexMatch:()=>tt,ipfsUpload:()=>$,ipfsUrl:()=>z,isArray:()=>N,isObject:()=>P,isReactObject:()=>it,isString:()=>T,isValidAccountId:()=>C,isoDate:()=>J,keysToCamel:()=>_,patternMatch:()=>Q,removeDuplicates:()=>X});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");var h=n(764).lW;function p(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(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 d(t){return d="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},d(t)}function y(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)||v(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 v(t,e){if(t){if("string"==typeof t)return m(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)?m(t,e):void 0}}function m(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:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function b(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 w=u()(10).pow(12),E=w.mul(250),x=u()(10).pow(19),S=2,k=64,O=/^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/,j=u()(10).pow(24),I=j.div(2),L=r().createElement("span",{className:"spinner-grow spinner-grow-sm me-1",role:"status","aria-hidden":"true"}),A=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 C(t){return t&&t.length>=S&&t.length<=k&&t.match(O)}var N=function(t){return Array.isArray(t)},P=function(t){return t===Object(t)&&!N(t)&&"function"!=typeof t},T=function(t){return"string"==typeof t},_=function t(e){if(P(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 N(e)?e.map((function(e){return t(e)})):e},B=function(t,e){return t&&e?t.lt(e)?t:e:t||e},U=function(t,e){return t&&e?t.gt(e)?t:e:t||e},R=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},F=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,R(t.div(j))," ",r().createElement("span",{className:"text-secondary"},"NEAR")):"???"},M=function(t){return t?r().createElement(r().Fragment,null,R(t.div(w))," ",r().createElement("span",{className:"text-secondary"},"TGas")):"???"},q=function(t){return t.toLocaleString("en-us",{day:"numeric",month:"short",year:"numeric"})},G=function(t){return t.toLocaleString()},D=function(t){if(t&&!t.loading&&t.state){var e=u()(t.state.amount).sub(u()(t.state.storage_usage).mul(u()(x)));if(e.gt(I))return e.sub(I)}return u()(0)},J=function(t){return t?new Date(t).toISOString().substring(0,10):""},$=function(){var t,e=(t=g().mark((function t(e){var r;return g().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){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}(),z=function(t){return"https://ipfs.near.social/ipfs/".concat(t)},W=function t(e,r){return P(e)?Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=P(r)?r[i]:void 0;return e+(void 0!==c?t(a,c):2*i.length+t(a,void 0)+140)}),P(r)?0:98):((null==e?void 0:e.length)||8)-(T(r)?r.length:0)},K=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(e).map((function(e){var n=y(e,2),o=n[0],i=n[1];return P(i)?t(i,"".concat(r).concat(o,"/")):"".concat(r).concat(o)})).flat()},X=function t(e,r){var n=Object.entries(e).reduce((function(e,n){var o=y(n,2),i=o[0],a=o[1],c=P(r)?r[i]:void 0;if(P(a)){var u=P(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},V=function(t){return T(t)||null===t?t:JSON.stringify(t)},Y=function t(e){return P(e)?Object.entries(e).reduce((function(e,r){var n=y(r,2),o=n[0],i=n[1];return e[V(o)]=t(i),e}),{}):V(e)},H=function t(e,r){var n=r[0],o="**"===n;return o?1===r.length:("*"===n||o?Object.values(e):n in e?[e[n]]:[]).some((function(e){return P(e)?r.length>1?t(e,r.slice(1)):void 0!==e[""]:1===r.length}))},Z=function t(e,r){var n=r[0];return("*"===n?Object.values(e):n in e?[e[n]]:[]).some((function(e){return 1===r.length||P(e)&&t(e,r.slice(1))}))},Q=function(t,e,r){var n=e.split("/");return"get"===t?H(r,n):"keys"===t&&Z(r,n)},tt=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}}))},et={graph:!0,post:!0,index:!0,settings:!0},rt=function(t,e){var r=P(t)?JSON.parse(JSON.stringify(t)):{};return P(e)&&Object.entries(e).forEach((function(t){var e=y(t,2),n=e[0],o=e[1];if(n in et)if(P(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},nt=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"!==d(e[r])||Object.isFrozen(e[r])||t(e[r])})),e},ot="$$typeof",it=function(t){return null!==t&&"object"===d(t)&&!!t[ot]},at=function t(e){return Array.isArray(e)?e.map((function(e){return t(e)})):e instanceof Map?new Map(p(e.entries()).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[t(n),t(o)]}))):e instanceof Set?new Set(p(e).map((function(e){return t(e)}))):h.isBuffer(e)?h.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:e instanceof Date?new Date(e):e instanceof WebSocket?e:P(e)?it(e)?e:Object.fromEntries(Object.entries(e).map((function(e){var r=y(e,2),n=r[0],o=r[1];return[n,t(o)]}))):void 0===e||"function"==typeof e?e:JSON.parse(JSON.stringify(e))},ct=l(),ut=n(764).lW;function st(t){return st="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},st(t)}function lt(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 ft(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)?ft(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 ft(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 pt(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 dt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){pt(i,n,o,a,c,"next",t)}function c(t){pt(i,n,o,a,c,"throw",t)}a(void 0)}))}}var yt=function(t,e,r,n){return{type:"FunctionCall",params:{methodName:t,args:e,gas:r,deposit:n}}},vt={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},mt={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},gt={get:!0,keys:!0},bt=function(){var t=dt(ht().mark((function t(e,r,n,o,i){return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.apiUrl&&r in gt){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 wt(t,e,r,n,o,i){return Et.apply(this,arguments)}function Et(){return(Et=dt(ht().mark((function t(e,r,n,o,i,a){var c;return ht().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:return c=t.sent,t.next=8,c.signAndSendTransaction({receiverId:r,actions:[yt(n,o,null!=i?i:w.mul(30).toFixed(0),null!=a?a:"0")]});case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(0),t.t0;case 14:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function xt(t,e){return St.apply(this,arguments)}function St(){return(St=dt(ht().mark((function t(e,r){var n;return ht().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 kt(t,e){return Ot.apply(this,arguments)}function Ot(){return(Ot=dt(ht().mark((function t(e,r){var n,o,i;return ht().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:return n=t.sent,o=[],i=u()(0),r.forEach((function(t){var e,r=t.contractName,n=t.methodName,a=t.args,c=t.gas,u=t.deposit,s=i.add(c),l=yt(n,a,c.toFixed(0),u.toFixed(0));(null===(e=o[o.length-1])||void 0===e?void 0:e.receiverId)!==r||s.gt(E)?(o.push({receiverId:r,actions:[]}),i=c):i=s,o[o.length-1].actions.push(l)})),t.next=11,n.signAndSendTransactions({transactions:o});case 11:return t.abrupt("return",t.sent);case 14:throw t.prev=14,t.t0=t.catch(0),t.t0;case 17:case"end":return t.stop()}}),t,null,[[0,14]])})))).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 It(t,e,r,n,o,i){return Lt.apply(this,arguments)}function Lt(){return(Lt=dt(ht().mark((function t(e,r,n,o,i,a){var c;return ht().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:ut.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(ut.from(c.result).toString()));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(t,e,r,n){return Ct.apply(this,arguments)}function Ct(){return(Ct=dt(ht().mark((function t(e,r,n,o){var i;return ht().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=lt(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 Nt(){return(Nt=dt(ht().mark((function t(e){var r,n,o,i,c,u,s,l,f,h,p,d;return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.networkId,o=e.config,i=e.keyStore,c=e.selector,u=e.walletConnectCallback,s=void 0===u?function(){}:u,l=e.customElements,f=void 0===l?{}:l,o||(o={},n||(o.networkId="mainnet")),n&&!o.networkId&&(o.networkId=n),"mainnet"===o.networkId?o=Object.assign({},mt,o):"testnet"===o.networkId&&(o=Object.assign({},vt,o)),o.walletConnectCallback=s,o.customElements=Object.assign({},o.customElements,f),i=null!==(r=i)&&void 0!==r?r:new a.keyStores.BrowserLocalStorageKeyStore,t.next=9,a.connect(Object.assign({deps:{keyStore:i}},o));case 9:return h=t.sent,(p={config:o,selector:c,keyStore:i,nearConnection:h}).nearArchivalConnection=a.Connection.fromConfig({networkId:o.networkId,provider:{type:"JsonRpcProvider",args:{url:o.archivalNodeUrl}},signer:{type:"InMemorySigner",keyStore:i}}),d=function(t){return"optimistic"===t||"final"===t?{finality:t,blockId:void 0}:null!=t?{finality:void 0,blockId:parseInt(t)}:{finality:"optimistic",blockId:void 0}},p.viewCall=function(t,e,r,n){var i=d(n),a=i.blockId,c=i.finality,u=function(){return It(a?p.nearArchivalConnection.provider:p.nearConnection.connection.provider,null!=a?a:void 0,t,e,r,c)},s=function(){return"optimistic"===c&&o.enableWeb4FastRpc?At(t,e,r,u):u()};return t!==o.contractName||!a&&"final"!==c?s():bt(o,e,r,a,s)},p.block=function(t){var e=d(t);return(e.blockId?p.nearArchivalConnection.provider:p.nearConnection.connection.provider).block(e)},p.functionCall=function(t,e,r,n,o){return wt(p,t,e,r,n,o)},p.sendTransactions=function(t){return kt(p,t)},p.contract=jt(p,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"]}),p.accountState=function(t){return xt(p,t)},t.abrupt("return",p);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Pt=(0,i.singletonHook)({},(function(){var t=lt((0,e.useState)(null),2),r=t[0],n=t[1];return{nearPromise:r,initNear:(0,e.useMemo)((function(){return function(t){return n(function(t){return Nt.apply(this,arguments)}(t))}}),[])}})),Tt=(0,i.singletonHook)(null,(function(){var t=lt((0,e.useState)(null),2),r=t[0],n=t[1],o=Pt().nearPromise;return(0,e.useEffect)((function(){o&&o.then(n)}),[o]),r}));const _t=require("local-storage");var Bt,Ut,Rt,Ft,Mt=n.n(_t);function qt(t){return qt="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},qt(t)}function Gt(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 Dt(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)?Dt(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 Dt(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 $t(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 zt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){$t(i,n,o,a,c,"next",t)}function c(t){$t(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Wt="near-social-vm:v01:",Kt=Wt+":accountId:",Xt=Wt+":pretendAccountId:",Vt={loading:!0,signedAccountId:null!==(Bt=Mt().get(Kt))&&void 0!==Bt?Bt:void 0,pretendAccountId:null!==(Ut=Mt().get(Xt))&&void 0!==Ut?Ut:void 0,accountId:null!==(Rt=null!==(Ft=Mt().get(Xt))&&void 0!==Ft?Ft:Mt().get(Kt))&&void 0!==Rt?Rt:void 0,state:null,near:null};function Yt(t,e){return Ht.apply(this,arguments)}function Ht(){return(Ht=zt(Jt().mark((function t(e,r){var n,o,i,c,u,s,l,f,h,p,d;return Jt().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){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=Mt().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(Mt().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 Zt=function(){var t=zt(Jt().mark((function t(e,r){var n,o,i,a,c,u,s,l;return Jt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((o=e.accountId)?(Mt().set(Kt,o),e.config.walletConnectCallback(o)):Mt().remove(Kt),i=null!==(n=Mt().get(Xt))&&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=zt(Jt().mark((function t(){return Jt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Zt(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=zt(Jt().mark((function t(n){return Jt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n?Mt().set(Xt,n):Mt().remove(Xt),t.next=3,Zt(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=Gt(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)}}(),Qt=(0,i.singletonHook)(Vt,(function(){var t=Gt((0,e.useState)(Vt),2),r=t[0],n=t[1],o=Tt();return(0,e.useEffect)((function(){o&&o.selector.then((function(t){t.store.observable.subscribe(function(){var t=zt(Jt().mark((function t(e){return Jt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Yt(o,e);case 2:return t.prev=2,t.next=5,Zt(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})),te=function(){return Qt().accountId};const ee=require("react-bootstrap/Modal");var re=n.n(ee);const ne=require("remark-gfm");var oe=n.n(ne);const ie=require("react-markdown");var ae=n.n(ie);const ce=require("react-syntax-highlighter"),ue=require("react-syntax-highlighter/dist/esm/styles/prism"),se=require("mdast-util-find-and-replace");var le=/@((?:(?:[a-z\d]+[-_])*[a-z\d]+\.)*(?:[a-z\d]+[-_])*[a-z\d]+)/gi;function fe(){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,se.findAndReplace)(e,le,t),e}}var he=/#(\w+)/gi;function pe(){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,se.findAndReplace)(e,he,t),e}}var de=["node","children"],ye=["node"],ve=["node"],me=["node"],ge=["node"],be=["node","inline","className","children"];function we(){return we=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 xe=function(t){var e=t.onLinkClick,n=t.text,o=t.onMention,i=t.onHashtag,a=t.syntaxHighlighterProps;return r().createElement(ae(),{plugins:[],rehypePlugins:[],remarkPlugins:[oe(),fe,pe],children:n,components:{strong:function(t){var e,n,a,c,u=t.node,s=t.children,l=Ee(t,de);return o&&null!==(e=u.properties)&&void 0!==e&&e.accountId?o(null===(a=u.properties)||void 0===a?void 0:a.accountId):i&&null!==(n=u.properties)&&void 0!==n&&n.hashtag?i(null===(c=u.properties)||void 0===c?void 0:c.hashtag):r().createElement("strong",l,s)},a:function(t){t.node;var n=Ee(t,ye);return e?r().createElement("a",we({onClick:e},n)):r().createElement("a",we({target:"_blank"},n))},img:function(t){t.node;var e=Ee(t,ve);return r().createElement("img",we({className:"img-fluid"},e))},blockquote:function(t){t.node;var e=Ee(t,me);return r().createElement("blockquote",we({className:"blockquote"},e))},table:function(t){t.node;var e=Ee(t,ge);return r().createElement("table",we({className:"table table-striped"},e))},code:function(t){t.node;var e=t.inline,n=t.className,o=t.children,i=Ee(t,be),c=/language-(\w+)/.exec(n||""),u=null!=a?a:{},s=u.wrapLines,l=u.lineProps,f=u.showLineNumbers,h=u.lineNumberStyle;return!e&&c?r().createElement(ce.Prism,we({children:String(o).replace(/\n$/,""),style:ue.tomorrow,language:c[1],PreTag:"div",wrapLines:s,lineProps:l,showLineNumbers:f,lineNumberStyle:h},i)):r().createElement("code",we({className:n},i),o)}}})};const Se=require("react-uuid");var ke=n.n(Se);function Oe(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 Be(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 Ue(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Be(i,n,o,a,c,"next",t)}function c(t){Be(i,n,o,a,c,"throw",t)}a(void 0)}))}}var Re=x.mul(2e3),Fe=x.mul(500),Me=x.mul(500),qe=x.mul(500),Ge=function(){var t=Ue(_e().mark((function t(e,r){var n;return _e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=K(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)}}(),De=function(){var t=Ue(_e().mark((function t(e,r,n,o){var i,a,c,s,l,f,h,p,d,y;return _e().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 Te(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)?Te(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=Y(n),(m=function(t){var e=function(t,e){if("object"!==Pe(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==Pe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===Pe(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,Ge(e,h);case 18:p=t.sent,h=X(h,p);case 20:return d=x.mul(W(h,p)).add(s?u()(0):Fe).add(l?u()(0):qe).add(Me),y=U(d.sub(f.mul(x)),s?l?u()(0):u()(1):Re),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)}}(),Je=function(){var t=Ue(_e().mark((function t(e,r,n){return _e().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},w.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)}}(),$e=function(){var t=Ue(_e().mark((function t(e,r,n){var o,i;return _e().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(yt("grant_write_permission",{public_key:e.publicKey.toString(),keys:[e.accountId]},w.mul(100).toFixed(0),n.gt(0)?n.toFixed(0):"1")),n=u()(0)),i.push(yt("set",{data:r},w.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 ze=require("react-bootstrap"),We=require("idb");function Ke(t){return Ke="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},Ke(t)}function Xe(t,e){if(t){if("string"==typeof t)return Ve(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)?Ve(t,e):void 0}}function Ve(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 Ze(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)}))}}function Qe(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:3e3;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dbPromise=(0,We.openDB)("cacheDb",1,{upgrade:function(t){t.createObjectStore(cr)}}),this.cache={},this.finalSynchronizationDelayMs=e}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=Ze(Ye().mark((function t(e){return Ye().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(cr,e));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"innerSet",value:(o=Ze(Ye().mark((function t(e,r){return Ye().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(cr,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:nr,invalidationCallbacks:[],result:null,time:(new Date).getTime()};return this.cache[t]=i,P(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=ar,o.invalidateCallbacks(i,!1))}),5e3)}(),i.status===or||i.status===ir&&i.time+3e5>(new Date).getTime()||(i.status===nr&&this.innerGet(t).then((function(t){(t||n)&&i.status===or&&(i.result=t,i.time=(new Date).getTime(),o.invalidateCallbacks(i,!1))})),i.status=or,e&&e().then((function(e){i.status=ir,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=ir;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===tr&&i.contractId===t.config.contractName&&(!i.blockId||"optimistic"===i.blockId||"final"===i.blockId))try{var a;(null===(a=i.args)||void 0===a?void 0:a.keys).some((function(t){return Q(i.methodName,t,e)}))&&n.push([r,"final"===i.blockId])}catch(t){}if(i.action===er&&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&&tt(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)||Xe(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=ar,r.invalidateCallbacks(c,a)}))}},{key:"cachedBlock",value:function(t,e,r){return this.cachedPromise({action:"Block",blockId:e},(function(){return t.block(e)}),r)}},{key:"cachedViewCall",value:function(t,e,r,n,o,i){return this.cachedPromise({action:tr,contractId:e,methodName:r,args:n,blockId:o},(function(){return t.viewCall(e,r,n,o)}),i)}},{key:"asyncFetch",value:(n=Ze(Ye().mark((function t(e,r){var n,o,i,a,c,u,s,l,f,h,p;return Ye().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){var n=this;return this.cachedPromise({action:er,url:t,options:e},(function(){return n.asyncFetch(t,e)}),r)}},{key:"cachedCustomPromise",value:function(t,e,r){return this.cachedPromise({action:"CustomPromise",key:t},(function(){return e()}),r)}},{key:"socialGet",value:function(t,e,r,n,o,i){if(!t)return null;var a={keys:e=(e=Array.isArray(e)?e:[e]).map((function(t){return r?"".concat(t,"/**"):"".concat(t)})),options:o},c=this.cachedViewCall(t,t.config.contractName,"get",a,n,i);if(null===c)return null;if(1===e.length)for(var u=e[0].split("/"),s=0;s=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 yr(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 vr(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 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}}(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 mr(t,e){(null==e||e>t.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,hr),p=vr((0,e.useState)(null),2),d=p[0],y=p[1];return r().createElement(r().Fragment,null,r().createElement("button",pr({},h,{disabled:s||!o||!!d||!n,onClick:function(t){t.preventDefault(),y("function"==typeof o?o():o),a&&a()}}),!!d&&L,i),r().createElement(Er,{show:!!d,widgetSrc:l,data:d,force:f,onHide:function(){return y(null)},onCancel:u,onCommit:c}))};const Sr=require("react-bootstrap-typeahead"),kr=require("styled-components");var Or=n.n(kr);const jr=require("elliptic"),Ir=require("bn.js");var Lr=n.n(Ir);const Ar=require("tweetnacl"),Cr=require("iframe-resizer-react");var Nr=n.n(Cr);function Pr(){return Pr=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 jn(t,e,r){return jn=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&&In(o,r.prototype),o},jn.apply(null,arguments)}function In(t,e){return In=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},In(t,e)}function Ln(){return Ln=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},n.vm.setReactState(n.vm.state.state),$(t[0]).then((function(t){if(n.vm.alive){var e=n.vm.vmStack.resolveMemberExpression(i.expression,{requireState:!0,left:!0});e.obj[e.key]={cid:t},n.vm.setReactState(n.vm.state.state)}}))):(c[u]=null,n.vm.setReactState(n.vm.state.state))}}}else{var h=n.resolveMemberExpression(i.expression,{requireState:!0,left:!0}),p=h.obj,d=h.key;s.value=(null==p?void 0:p[d])||"",s.onChange=function(t){t.preventDefault(),p[d]=t.target.value,n.vm.setReactState(n.vm.state.state)}}})),s.key=null!==(e=s.key)&&void 0!==e?e:"".concat(this.vm.widgetSrc,"-").concat(o,"-").concat(this.vm.gIndex),delete s.dangerouslySetInnerHTML;var h,p=(0,kr.isStyledComponent)(u)&&(null==u?void 0:u.target)||o;if(s.as&&!Kn[s.as]&&delete s.as,s.forwardedAs&&!Kn[s.forwardedAs]&&delete s.forwardedAs,"img"===p?s.alt=null!==(h=s.alt)&&void 0!==h?h:"not defined":"a"===p?Object.entries(s).forEach((function(t){var e=Tn(t,2),r=e[0],n=e[1];"href"===r.toLowerCase()&&(s[r]=(0,Ae.sanitizeUrl)(n))})):"Widget"===o&&(s.depth=this.vm.depth+1,s.config=[s.config].concat(An(this.vm.widgetConfigs)).filter(Boolean)),!1===i&&t.children.length)throw new Error("And element '"+o+"' contains children, but shouldn't");var d,y,v,m,g=t.children.map((function(t,e){return n.vm.gIndex=e,n.executeExpression(t)}));if(a)return a(Fn(Fn({},s),{},{children:g}));if(u)return(0,kr.isStyledComponent)(u)?r().createElement.apply(r(),[u,Fn({},s)].concat(An(g))):u(Fn({children:g},s));if("Widget"===o)return r().createElement(ko,s);if("CommitButton"===o)return r().createElement(xr,Ln({},s,{widgetSrc:this.vm.widgetSrc}),g);if("InfiniteScroll"===o)return r().createElement(Ne(),s,g);if("Tooltip"===o)return r().createElement(ze.Tooltip,s,g);if("OverlayTrigger"===o)return r().createElement(ze.OverlayTrigger,s,g.filter((function(t){return!T(t)||!!t.trim()}))[0]);if("Typeahead"===o)return r().createElement(Sr.Typeahead,s);if("Markdown"===o)return r().createElement(xe,s);if("Fragment"===o)return r().createElement(r().Fragment,s,g);if("IpfsImageUpload"===o)return r().createElement("div",{className:"d-inline-block",key:s.key},(null===(d=l.img)||void 0===d?void 0:d.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:z(null===(y=l.img)||void 0===y?void 0:y.cid),alt:"upload preview"})),r().createElement(Le(),Ln({multiple:!1,accepts:["image/*"],minFileSize:1,clickable:!0},s),null!==(v=l.img)&&void 0!==v&&v.uploading?r().createElement(r().Fragment,null,L," Uploading"):null!==(m=l.img)&&void 0!==m&&m.cid?"Replace":"Upload an Image"));if("Files"===o)return r().createElement(Le(),s,g);if("iframe"===o)return r().createElement(Mr,s);if("Web3Connect"===o)return r().createElement(Sn,s);if(c){if(o.includes("Portal"))throw new Error("Radix's \"".concat(o,"\" component is not allowed. This portal element is an optional Radix feature and isn't necessary for most use cases."));var b=g;return Array.isArray(b)&&(1===(b=b.filter((function(t){return"string"!=typeof t||""!==t.trim()}))).length?b=b[0]:0===b.length&&(b=void 0)),r().createElement(c,s,b)}if(!0===i)return r().createElement.apply(r(),[o,Fn({},s)].concat(An(g)));if(!1===i)return r().createElement(o,Fn({},s));throw new Error("Unsupported element: "+o)}},{key:"resolveKey",value:function(t,e){var r=e||"Identifier"!==t.type&&"JSXIdentifier"!==t.type?this.executeExpression(t):t.name;return eo(r),r}},{key:"callFunction",value:function(t,e,r,n,o){var i=this,a=Yn[t];if(!0===a||void 0===a){if("Social"===t&&"getr"===e||"socialGetr"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.getr");return this.vm.cachedSocialGet(r[0],!0,r[1],r[2])}if("Social"===t&&"get"===e||"socialGet"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.get");return this.vm.cachedSocialGet(r[0],!1,r[1],r[2])}if("Social"===t&&"keys"===e){if(r.length<1)throw new Error("Missing argument 'keys' for Social.keys");return this.vm.cachedSocialKeys(r[0],r[1],r[2])}if("Social"===t&&"index"===e){if(r.length<2)throw new Error("Missing argument 'action' and 'key` for Social.index");return this.vm.cachedIndex(r[0],r[1],r[2])}if("Social"===t&&"set"===e){if(r.length<1)throw new Error("Missing argument 'data' for Social.set");return this.vm.socialSet(r[0],r[1])}if("Near"===t&&"view"===e){if(r.length<2)throw new Error("Method: Near.view. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality', 'subscribe'");var c=Tn(r,5),u=c[0],s=c[1],l=c[2],f=c[3],h=c[4];return this.vm.cachedNearView(u,s,l,f,io(h,f))}if("Near"===t&&"asyncView"===e){var p;if(r.length<2)throw new Error("Method: Near.asyncView. Required arguments: 'contractName', 'methodName'. Optional: 'args', 'blockId/finality'");return(p=this.vm).asyncNearView.apply(p,An(r))}if("Near"===t&&"block"===e){var d=Tn(r,2),y=d[0],v=d[1];return this.vm.cachedNearBlock(y,io(v,y))}if("Near"===t&&"call"===e){if(1===r.length){if(P(r[0]))return this.vm.confirmTransactions([r[0]]);if(N(r[0]))return this.vm.confirmTransactions(r[0]);throw new Error("Method: Near.call. Required argument: 'tx/txs'. A single argument call requires an TX object or an array of TX objects.")}var m;if(r.length<2||r.length>5)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 this.vm.confirmTransactions([{contractName:r[0],methodName:r[1],args:null!==(m=r[2])&&void 0!==m?m:{},gas:r[3],deposit:r[4]}])}if("fetch"===e){var g;if(r.length<1)throw new Error("Method: fetch. Required arguments: 'url'. Optional: 'options'");return(g=this.vm).cachedFetch.apply(g,An(r))}if("asyncFetch"===e){var b;if(r.length<1)throw new Error("Method: asyncFetch. Required arguments: 'url'. Optional: 'options'");return(b=this.vm).asyncFetch.apply(b,An(r))}if("useCache"===e){var w;if(r.length<2)throw new Error("Method: useCache. Required arguments: 'promiseGenerator', 'dataKey'. Optional: 'options'");if(!(r[0]instanceof Function))throw new Error("Method: useCache. The first argument 'promiseGenerator' must be a function");return(w=this.vm).useCache.apply(w,An(r))}if("afterConfirmTx"===e){if(!(r[0]instanceof Function))throw new Error("Method: afterConfirmTx. The first argument must be a function");return this.vm.setTxCallback(r[0])}if("parseInt"===e)return parseInt.apply(void 0,An(r));if("parseFloat"===e)return parseFloat.apply(void 0,An(r));if("isNaN"===e)return isNaN.apply(void 0,An(r));if("setTimeout"===e){var E=Tn(r,2),x=E[0],S=E[1],k=setTimeout((function(){i.vm.alive&&x()}),S);return this.vm.timeouts.add(k),k}if("setInterval"===e){if(this.vm.intervals.size>=16)throw new Error("Too many intervals. Max allowed: ".concat(16));var O=Tn(r,2),j=O[0],I=O[1],L=setInterval((function(){i.vm.alive&&j()}),I);return this.vm.intervals.add(L),L}if("clearTimeout"===e){var A=r[0];return this.vm.timeouts.delete(A),clearTimeout(A)}if("clearInterval"===e){var C=r[0];return this.vm.intervals.delete(C),clearInterval(C)}if("JSON"===t&&"stringify"===e||"stringify"===e){if(r.length<1)throw new Error("Missing argument 'obj' for JSON.stringify");return ro(r[0]),JSON.stringify(r[0],r[1],r[2])}if("JSON"===t&&"parse"===e){if(r.length<1)throw new Error("Missing argument 's' for JSON.parse");try{var T=JSON.parse(r[0]);return no(T),T}catch(t){return null}}else if("Object"===t){if("keys"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.keys");return ro(r[0]),Object.keys(r[0])}if("values"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.values");return ro(r[0]),Object.values(r[0])}if("entries"===e){if(r.length<1)throw new Error("Missing argument 'obj' for Object.entries");return ro(r[0]),Object.entries(r[0])}if("assign"===e){r.forEach((function(t){return ro(t)}));var _=Object.assign.apply(Object,An(r));return no(_),_}if("fromEntries"===e){var B=Object.fromEntries(r[0]);return no(B),B}}else{if("State"===t&&"init"===e||"initState"===e){if(r.length<1)throw new Error("Missing argument 'initialState' for State.init");if(null===r[0]||"object"!==Un(r[0])||it(r[0]))throw new Error("'initialState' is not an object");if(void 0===this.vm.state.state){var U=r[0];this.vm.state.state=U,this.vm.setReactState(U)}return this.vm.state.state}if("State"===t&&"update"===e){var R;if(P(r[0]))this.vm.state.state=null!==(R=this.vm.state.state)&&void 0!==R?R:{},Object.assign(this.vm.state.state,r[0]);else if(r[0]instanceof Function){var F;this.vm.state.state=null!==(F=this.vm.state.state)&&void 0!==F?F:{},this.vm.state.state=r[0](this.vm.state.state)}if(void 0===this.vm.state.state)throw new Error("The state was not initialized");return this.vm.setReactState(this.vm.state.state),this.vm.state.state}if("State"===t&&"get"===e)return this.vm.state.state;if("Storage"===t&&"privateSet"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.privateSet");return this.vm.storageSet({src:this.vm.widgetSrc,type:zn},r[0],r[1])}if("Storage"===t&&"privateGet"===e){if(r.length<1)throw new Error("Missing argument 'key' for Storage.privateGet");return this.vm.storageGet({src:this.vm.widgetSrc,type:zn},r[0])}if("Storage"===t&&"set"===e){if(r.length<2)throw new Error("Missing argument 'key' or 'value' for Storage.set");return this.vm.storageSet({src:this.vm.widgetSrc,type:Wn},r[0],r[1])}if("Storage"===t&&"get"===e){var M;if(r.length<1)throw new Error("Missing argument 'key' for Storage.get");return this.vm.storageGet({src:null!==(M=r[1])&&void 0!==M?M:this.vm.widgetSrc,type:Wn},r[0])}var q,G,D;if("console"===t&&"log"===e)return(q=console).log.apply(q,[this.vm.widgetSrc].concat(An(r)));if("clipboard"===t&&"writeText"===e)return this.isTrusted?(G=navigator.clipboard).writeText.apply(G,An(r)):Promise.reject(new Error("Not trusted (not a click)"));if("VM"===t&&"require"===e)return(D=this.vm).vmRequire.apply(D,An(r));if("Ethers"===t)return"provider"===e?this.vm.ethersProvider:this.vm.cachedEthersCall(e,r);if("WebSocket"===t){if("WebSocket"===e){var J=jn(WebSocket,An(r));return this.vm.websockets.push(J),J}throw new Error("Unsupported WebSocket method")}}}else{var $=e===t?a:a[e];if("function"==typeof $)return o?jn($,An(r)):$.apply(void 0,An(r))}if(!n)throw new Error(t&&t!==e?"Unsupported callee method '".concat(t,".").concat(e,"'"):"Unsupported callee method '".concat(e,"'"))}},{key:"resolveMemberExpression",value:function(t,e){if("Identifier"===t.type||"JSXIdentifier"===t.type){var r,n=t.name;if(eo(n),null!=e&&e.requireState&&n!==$n)throw new Error("The top object should be ".concat($n));var o=null!==(r=this.stack.findObj(n))&&void 0!==r?r:this.stack.state;if(ro(o),o===this.stack.state&&n in Yn){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||!(n in o)))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(c in Yn){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 ro(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,An(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 w>E;if("<="===t.operator)return w<=E;if(">="===t.operator)return w>=E;if("==="===t.operator||"=="===t.operator)return w===E;if("!=="===t.operator||"!="===t.operator)return w!==E;if("in"===t.operator)return w in E;throw new Error("Unknown BinaryExpression operator '"+t.operator+"'")}if("UnaryExpression"===r){if("delete"===t.operator){var x=this.resolveMemberExpression(t.argument,{left:!0}),S=x.obj,k=x.key;return null==S||delete S[k]}var O=this.executeExpression(t.argument);if("-"===t.operator)return-O;if("!"===t.operator)return!O;if("typeof"===t.operator)return Un(O);throw new Error("Unknown UnaryExpression operator '"+t.operator+"'")}if("LogicalExpression"===r){var j=this.executeExpression(t.left);if("||"===t.operator)return j||this.executeExpression(t.right);if("&&"===t.operator)return j&&this.executeExpression(t.right);if("??"===t.operator)return null!=j?j: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 I=this.resolveMemberExpression(t.argument,{left:!0}),L=I.obj,A=I.key;if("++"===t.operator)return t.prefix?++L[A]:L[A]++;if("--"===t.operator)return t.prefix?--L[A]:L[A]--;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);ro(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 C,N;if("MemberExpression"!==t.tag.type&&"CallExpression"!==t.tag.type)throw new Error("TaggedTemplateExpression is only supported for `styled` components");var P=this.resolveMemberExpression("MemberExpression"===t.tag.type?t.tag:t.tag.callee,{callee:!0}),T=P.key;if("styled"!==P.keyword)throw new Error("TaggedTemplateExpression is only supported for `styled` components");if("CallExpression"===t.tag.type){var _=this.getArray(t.tag.arguments),B=null==_?void 0:_[0],U=oo(B);if(!(0,kr.isStyledComponent)(B)&&!U)throw new Error('styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")');C=Or()(null!=U?U:B)}else{if("keyframes"===T)C=kr.keyframes;else{if(!(T in Kn))throw new Error("Unsupported styled tag: "+T);C=Or()(T)}N=T}if("TemplateLiteral"!==t.quasi.type)throw new Error("Unknown quasi type: "+t.quasi.type);var R=t.quasi.quasis.map((function(t){if("TemplateElement"!==t.type)throw new Error("Unknown quasis type: "+t.type);return t.value.cooked})),F=0===t.quasi.expressions.length&&"CallExpression"!==t.tag.type,M=JSON.stringify([N].concat(An(R)));if(F&&this.vm.cachedStyledComponents.has(M))return this.vm.cachedStyledComponents.get(M);var q=t.quasi.expressions.map((function(t){return e.executeExpression(t)}));if(C instanceof Function){var G=C.apply(void 0,[R].concat(An(q)));return F&&this.vm.cachedStyledComponents.set(M,G),G}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(so),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);ro(s);var l,f=On(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(so(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"===Un(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(ao(t.handler.param),at(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=On(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&&I.test){if(k.executeExpression(I.test)!==S)continue;O=!0}if(O){var L,A=!1,C=On(I.consequent);try{for(C.s();!(L=C.n()).done;){var N=L.value,P=k.executeStatement(N);if(P){if(P.break){A=!0;break}return P}}}catch(t){C.e(t)}finally{C.f()}if(A)break}}}catch(t){j.e(t)}finally{j.f()}}}}return null}}]),t}(),ho=function(){function t(e){Cn(this,t);var r,n=e.near,o=e.rawCode,i=e.setReactState,a=e.cache,c=e.refreshCache,u=e.confirmTransactions,s=e.depth,l=e.widgetSrc,h=e.requestCommit,p=e.version,d=e.widgetConfigs,y=e.ethersProviderContext,v=e.isModule;this.alive=!0,this.isModule=v,this.rawCode=o,this.near=n;try{this.code=(r=o)in Qn?Qn[r]:Qn[r]=to.parse(r,Zn),this.compileError=null}catch(t){this.code=null,this.compileError=t,console.error(t)}this.code?(this.setReactState=i?function(t){return i(P(t)?Object.assign({},t):t)}:function(){throw new Error("State is unavailable for modules")},this.cache=a,this.refreshCache=c,this.confirmTransactions=u,this.depth=s,this.widgetSrc=l,this.requestCommit=h,this.version=p,this.cachedStyledComponents=new Map,this.widgetConfigs=d,this.ethersProviderContext=y,this.ethersProvider=null!=y&&y.provider?new f.ethers.providers.Web3Provider(y.provider):null,this.timeouts=new Set,this.intervals=new Set,this.websockets=[],this.vmInstances=new Map):this.alive=!1}return Pn(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:"cachedPromise",value:function(t,e){var r=this;return at(t({onInvalidate:function(){r.alive&&r.refreshCache()},subscribe:!!e}))}},{key:"cachedSocialGet",value:function(t,e,r,n){var o=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(i){return o.cache.socialGet(o.near,t,e,r,n,i)}),null==n?void 0:n.subscribe)}},{key:"storageGet",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.localStorageGet(t,e,n)}))}},{key:"storageSet",value:function(t,e,r){return this.cache.localStorageSet(t,e,r)}},{key:"cachedSocialKeys",value:function(t,e,r){var n=this;return t=Array.isArray(t)?t:[t],this.cachedPromise((function(o){return n.cache.cachedViewCall(n.near,n.near.config.contractName,"keys",{keys:t,options:r},e,o)}),null==r?void 0:r.subscribe)}},{key:"asyncNearView",value:function(t,e,r,n){return this.near.viewCall(t,e,r,n)}},{key:"cachedEthersCall",value:function(t,e,r){var n=this;return this.cachedPromise((function(r){return n.cache.cachedEthersCall(n.ethersProvider,t,e,r)}),r)}},{key:"cachedNearView",value:function(t,e,r,n,o){var i=this;return this.cachedPromise((function(o){return i.cache.cachedViewCall(i.near,t,e,r,n,o)}),o)}},{key:"cachedNearBlock",value:function(t,e){var r=this;return this.cachedPromise((function(e){return r.cache.cachedBlock(r.near,t,e)}),e)}},{key:"asyncFetch",value:function(t,e){return this.cache.asyncFetch(t,e)}},{key:"cachedFetch",value:function(t,e){var r=this;return this.cachedPromise((function(n){return r.cache.cachedFetch(t,e,n)}),null==e?void 0:e.subscribe)}},{key:"cachedIndex",value:function(t,e,r){var n=this;return this.cachedPromise((function(o){return n.cache.socialIndex(n.near,t,e,r,o)}),null==r?void 0:r.subscribe)}},{key:"useCache",value:function(t,e,r){var n=this;return this.cachedPromise((function(r){return n.cache.cachedCustomPromise({widgetSrc:n.widgetSrc,dataKey:e},t,r)}),null==r?void 0:r.subscribe)}},{key:"socialSet",value:function(t,e){return this.requestCommit({data:t,force:null==e?void 0:e.force,onCommit:null==e?void 0:e.onCommit,onCancel:null==e?void 0:e.onCancel})}},{key:"vmRequire",value:function(t){var e=Tn(t.split("@"),2),r=e[0],n=e[1],o=this.cachedSocialGet(r.toString(),!1,n,void 0);return o?this.getVmInstance(o,t).execCode({context:at(this.context),forwardedProps:this.forwardedProps}):o}},{key:"getVmInstance",value:function(e,r){if(this.vmInstances.has(r)){var n=this.vmInstances[r];if(n.rawCode===e)return n;n.stop(),this.vmInstances.delete(r)}var o=new t({near:this.near,rawCode:e,cache:this.cache,refreshCache:this.refreshCache,confirmTransactions:this.confirmTransactions,depth:this.depth+1,widgetSrc:r,requestCommit:this.requestCommit,version:this.version,widgetConfigs:this.widgetConfigs,ethersProviderContext:this.ethersProviderContext,isModule:!0});return this.vmInstances.set(r,o),o}},{key:"renderCode",value:function(t){if(this.compileError)return r().createElement("div",{className:"alert alert-danger"},"Compilation error:",r().createElement("pre",null,this.compileError.message),r().createElement("pre",null,this.compileError.stack));if(!this.alive)return r().createElement("div",{className:"alert alert-danger"},"VM is dead");var e=this.execCode(t);return it(e)||"string"==typeof e||"number"==typeof e?e:r().createElement("pre",null,JSON.stringify(e,void 0,2))}},{key:"execCode",value:function(t){var e=t.props,r=t.context,n=t.state,o=t.forwardedProps;if(this.compileError)throw this.compileError;if(this.depth>=32)return"Too deep";this.gIndex=0,this.state={props:P(e)?Object.assign({},e):e,context:r,state:n,nacl:Gn,get elliptic(){return delete this.elliptic,this.elliptic=Dr().cloneDeep(jr),this.elliptic},ethers:Dn,nanoid:Jn},this.forwardedProps=o,this.loopLimit=1e6,this.vmStack=new fo(this,void 0,this.state);var i=this.vmStack.executeStatement(this.code);if(null!=i&&i.break)throw new Error("BreakStatement outside of a loop");if(null!=i&&i.continue)throw new Error("ContinueStatement outside of a loop");return null==i?void 0:i.result}},{key:"setTxCallback",value:function(t){this.txCallback=t}},{key:"afterConfirmTx",value:function(t){this.txCallback instanceof Function&&this.txCallback(t)}}]),t}();const po=require("react-error-boundary"),yo=require("react-bootstrap-typeahead/types/utils");function vo(t){return vo="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},vo(t)}var mo=["src","code","depth","config","props"];function go(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 bo(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,mo),f=Eo((0,e.useState)(0),2),h=f[0],p=f[1],d=Eo((0,e.useState)(null),2),y=d[0],v=d[1],m=Eo((0,e.useState)(null),2),g=m[0],b=m[1],E=Eo((0,e.useState)(void 0),2),x=E[0],S=E[1],k=Eo((0,e.useState)(0),2),O=k[0],j=k[1],I=Eo((0,e.useState)({}),2),C=I[0],N=I[1],_=Eo((0,e.useState)(null),2),B=_[0],U=_[1],R=Eo((0,e.useState)(null),2),F=R[0],M=R[1],q=Eo((0,e.useState)(null),2),G=q[0],D=q[1],J=Eo((0,e.useState)(null),2),$=J[0],z=J[1],W=Eo((0,e.useState)(null),2),K=W[0],X=W[1],V=Eo((0,e.useState)(null),2),Y=V[0],H=V[1],Z=(0,e.useContext)(xn),Q=lr(),tt=Tt(),et=te(),rt=Eo((0,e.useState)(null),2),nt=rt[0],ot=rt[1];(0,e.useEffect)((function(){var t=c?Array.isArray(c)?c:[c]:[];ct(t,K)||X(t)}),[c,K]),(0,e.useEffect)((function(){var t=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=xo(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=P(null==c?void 0:c.redirectMap)&&c.redirectMap[s];if(!l)try{l=(0,yo.isFunction)(null==c?void 0:c.redirect)&&c.redirect(s)}catch(t){}if(T(l))o={src:l};else if(T(null===(u=l)||void 0===u?void 0:u.code))return{code:l.code}}}}catch(t){i.e(t)}finally{i.f()}return o}(o,i,K);ct(t,Y)||H(t)}),[o,i,K,Y]),(0,e.useEffect)((function(){if(tt)if(null!=Y&&Y.src){var t=Y.src,e=Eo(t.split("@"),2),r=e[0],n=e[1],o=Q.socialGet(tt,r.toString(),!1,n,void 0,(function(){p(h+1)}));v(o),b(t)}else null!=Y&&Y.code&&(v(Y.code),b(null))}),[tt,Y,h]),(0,e.useEffect)((function(){U(null),ot(null),y||void 0===y&&ot(r().createElement("div",{className:"alert alert-danger"},'Source code for "',g,'" is not found'))}),[y,g]);var it=(0,e.useCallback)((function(t){if(!tt||!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):w.mul(30)}})),console.log("confirm txs",t),M(t)}),[tt]),ut=(0,e.useCallback)((function(t){if(!tt)return null;console.log("commit requested",t),D(t)}),[tt]);return(0,e.useEffect)((function(){if(tt&&y){S(void 0);var t=new ho({near:tt,rawCode:y,setReactState:S,cache:Q,refreshCache:function(){j((function(t){return t+1}))},confirmTransactions:it,depth:a,widgetSrc:g,requestCommit:ut,version:ke()(),widgetConfigs:K,ethersProviderContext:Z});return U(t),function(){t.stop()}}}),[g,tt,y,a,ut,it,K,Z]),(0,e.useEffect)((function(){tt&&N({loading:!1,accountId:null!=et?et:null,widgetSrc:g,networkId:tt.config.networkId})}),[tt,et,g]),(0,e.useLayoutEffect)((function(){if(B){var t={props:s||{},context:C,state:x,cacheNonce:O,version:B.version,forwardedProps:bo(bo({},l),{},{ref:n})};if(!ct(t,$)){z(at(t));try{var e;ot(null!==(e=B.renderCode(t))&&void 0!==e?e:"Execution failed")}catch(t){ot(r().createElement("div",{className:"alert alert-danger"},"Execution error:",r().createElement("pre",null,t.message),r().createElement("pre",null,t.stack))),console.error(t)}}}}),[B,s,C,x,O,$,n,l]),null!=nt?r().createElement(po.ErrorBoundary,{FallbackComponent:A,onReset:function(){ot(null)},resetKeys:[nt]},r().createElement(r().Fragment,null,nt,F&&r().createElement(je,{transactions:F,onHide:function(t){M(null),t&&B.afterConfirmTx(t)}}),G&&r().createElement(Er,{show:!0,widgetSrc:g,data:G.data,force:G.force,onHide:function(){return D(null)},onCommit:G.onCommit,onCancel:G.onCancel}))):L}))})(),o})())); \ No newline at end of file diff --git a/src/lib/components/ConfirmTransactions.js b/src/lib/components/ConfirmTransactions.js index 1144db4b..5d940b90 100644 --- a/src/lib/components/ConfirmTransactions.js +++ b/src/lib/components/ConfirmTransactions.js @@ -68,9 +68,9 @@ export default function ConfirmTransactions(props) { onClick={(e) => { e.preventDefault(); setLoading(true); - near.sendTransactions(transactions).then(() => { + near.sendTransactions(transactions).then((res) => { setLoading(false); - onHide(); + onHide(res); }); }} > diff --git a/src/lib/components/Widget.js b/src/lib/components/Widget.js index 4649e6a1..cf493fb3 100644 --- a/src/lib/components/Widget.js +++ b/src/lib/components/Widget.js @@ -265,7 +265,12 @@ export const Widget = React.forwardRef((props, forwardedRef) => { {transactions && ( setTransactions(null)} + onHide={(res) => { + setTransactions(null); + if (res) { + vm.afterConfirmTx(res); + } + }} /> )} {commitRequest && ( diff --git a/src/lib/vm/vm.js b/src/lib/vm/vm.js index f998dfc9..067aadb1 100644 --- a/src/lib/vm/vm.js +++ b/src/lib/vm/vm.js @@ -830,6 +830,13 @@ class VmStack { ); } return this.vm.useCache(...args); + } else if (callee === "afterConfirmTx") { + if (!(args[0] instanceof Function)) { + throw new Error( + "Method: afterConfirmTx. The first argument must be a function" + ); + } + return this.vm.setTxCallback(args[0]); } else if (callee === "parseInt") { return parseInt(...args); } else if (callee === "parseFloat") { @@ -2012,4 +2019,14 @@ export default class VM { } return executionResult?.result; } + + setTxCallback(cb) { + this.txCallback = cb; + } + + afterConfirmTx(res) { + if (this.txCallback instanceof Function) { + this.txCallback(res); + } + } }